@triply/triplydb
    Preparing search index...

    Interface AccountBase

    The members every account has, whether it is a User or a Group.

    Both classes attach the shared implementations to their prototypes and merge these declarations in, so this is the one place their signatures are written — and where the documentation for them lives. A User or Group page lists them as inherited from here.

    pinItems and update are the two whose return type follows the account kind; each class narrows them back to itself.

    interface AccountBase {
        addDataset(name: string, ds?: AddDatasetOptions): Promise<Dataset>;
        addQuery(name: string, opts: AddQueryOptions): Promise<Query>;
        addStory(
            name: string,
            args?: NewStory | NewStory_deprecated,
        ): Promise<Story>;
        asGroup(): Promise<Group>;
        asOrganization(): Promise<Group>;
        asUser(): Promise<User>;
        ensureDataset(name: string, newDs?: AddDatasetOptions): Promise<Dataset>;
        ensureStory(
            name: string,
            newStory?: NewStory | NewStory_deprecated,
        ): Promise<Story>;
        getDataset(name: string): Promise<Dataset>;
        getDatasets(): ResultIterator<DatasetInfo, Dataset>;
        getInfo(): Promise<AccountInfo>;
        getPinnedItems(): Promise<(Dataset | Query | Story)[]>;
        getQueries(): ResultIterator<QueryInfo, Query>;
        getQuery(name: string): Promise<Query>;
        getStories(): ResultIterator<StoryInfo, Story>;
        getStory(name: string): Promise<Story>;
        hasDataset(name: string): Promise<boolean>;
        hasQuery(name: string): Promise<boolean>;
        hasStory(name: string): Promise<boolean>;
        importDataset(
            sourceDataset: Dataset,
            opts: ImportDatasetOpts,
        ): Promise<Dataset>;
        importQuery(sourceQuery: Query, opts: ImportQueryOpts): Promise<Query>;
        importStory(sourceStory: Story, opts: ImportStoryOpts): Promise<Story>;
        pinItems(items: (Dataset | Query | Story)[]): Promise<User | Group>;
        runPipeline(opts: RunPipelineOpts): Promise<Pipeline>;
        setAvatar(pathOrBuffer: string | Buffer<ArrayBufferLike>): Promise<void>;
        update(
            updateObj: Omit<AccountUpdate, "pinnedDatasets">,
        ): Promise<User | Group>;
    }

    Implemented by

    Index
    • Creates a new, empty dataset owned by this account.

      Parameters

      • name: string

        Name for the new dataset, which becomes part of its URL.

      • Optionalds: AddDatasetOptions

        Metadata to create it with. accessLevel defaults to the instance's own default.

      Returns Promise<Dataset>

      A new dataset has no graphs; load data into it with Dataset.importFromFiles, Dataset.importFromUrls or Dataset.importFromDataset.

      If the name is already taken — it becomes part of the dataset's URL, so an account cannot have two. Use ensureDataset when you want the existing dataset instead of an error.

    • Creates a new saved query owned by this account.

      Parameters

      • name: string

        Name for the new query, which becomes part of its URL.

      • opts: AddQueryOptions

        The query text plus the dataset and service type to run it against; both are required, because a saved query is stored together with what it queries.

      Returns Promise<Query>

      If the name is already taken. Use getQuery to fetch the existing one.

    • Creates a new story owned by this account.

      Parameters

      • name: string

        Name for the new story, which becomes part of its URL.

      • Optionalargs: NewStory | NewStory_deprecated

        Initial content and access level. A story created without content is empty and can be filled in later.

      Returns Promise<Story>

      If the name is already taken. Use ensureStory when you want the existing one.

    • This account as a Group.

      Returns Promise<Group>

      For narrowing an Account whose kind you have established. A user cannot become a group.

      If this account is a User.

    • Returns Promise<Group>

      Use asGroup()

    • This account as a User.

      Returns Promise<User>

      For narrowing an Account whose kind you have established.

      If this account is a Group.

    • The dataset with this name, created first if this account does not have one yet.

      Parameters

      • name: string

        Name of the dataset to get or create.

      • OptionalnewDs: AddDatasetOptions

        Metadata to create it with, used only when it does not exist yet.

      Returns Promise<Dataset>

      The idempotent form of addDataset, for code that runs more than once.

      Only the absence of the dataset is reconciled: when it already exists, newDs is ignored rather than applied, so this never edits an existing dataset's metadata.

      If the dataset exists and newDs.accessLevel disagrees with the access level it already has — rather than silently leaving it as it was.

    • The story with this name, created first if this account does not have one yet.

      Parameters

      Returns Promise<Story>

      The idempotent form of addStory. As with ensureDataset, newStory applies only when the story does not exist yet, so this never edits an existing story.

      If the story exists and newStory.accessLevel disagrees with the access level it already has — rather than silently leaving it as it was.

    • The dataset with this name, owned by this account.

      Parameters

      • name: string

        The dataset's name, as it appears in its URL.

      Returns Promise<Dataset>

      If this account has no dataset with that name. Use hasDataset to test first, or ensureDataset to create it when missing.

    • This account's own metadata: its name, display name, avatar and the rest of its profile.

      Returns Promise<AccountInfo>

      The type field is what tells a User and a Group apart when you hold an Account.

    • The datasets, stories and queries pinned to this account's profile, in the order they appear.

      Returns Promise<(Dataset | Query | Story)[]>

      A single list of mixed kinds; narrow with instanceof when you need to treat them differently.

    • The saved query with this name, owned by this account.

      Parameters

      • name: string

        The query's name, as it appears in its URL.

      Returns Promise<Query>

      If this account has no query with that name. Use hasQuery to test first.

    • The story with this name, owned by this account.

      Parameters

      • name: string

        The story's name, as it appears in its URL.

      Returns Promise<Story>

      If this account has no story with that name. Use hasStory to test first.

    • Whether this account has a dataset with this name, without throwing when it does not.

      Parameters

      • name: string

      Returns Promise<boolean>

    • Whether this account has a saved query with this name, without throwing when it does not.

      Parameters

      • name: string

      Returns Promise<boolean>

    • Whether this account has a story with this name, without throwing when it does not.

      Parameters

      • name: string

      Returns Promise<boolean>

    • Copies a dataset from another instance into this account.

      Parameters

      Returns Promise<Dataset>

      For moving content between deployments. Destructive: opts.overwrite must be true, and a dataset of the same name in this account is replaced rather than merged into.

      If the source is on the same instance as this account — importing is only supported between different instances. Use Dataset.importFromDataset to copy within one.

    • Copies a saved query from another instance into this account.

      Parameters

      Returns Promise<Query>

      Destructive in the same way as AccountBase.importDataset. The query's dataset must already exist in this account, since a query without its data cannot run.

      If the source is on the same instance as this account.

    • Copies a story from another instance into this account.

      Parameters

      Returns Promise<Story>

      Destructive in the same way as AccountBase.importDataset. A story is a shell around saved queries, so import those first or its elements will have nothing to show.

      If the source is on the same instance as this account.

    • Sets which datasets, stories and queries are pinned to this account's profile.

      Parameters

      Returns Promise<User | Group>

      Replaces the pinned list rather than adding to it, and the array's order becomes the display order. To add one, read AccountBase.getPinnedItems first and pass the result back with your addition; passing an empty array unpins everything.

    • Runs saved queries as one batch job and writes their results into a dataset.

      Parameters

      • opts: RunPipelineOpts

        The queries to run and the dataset to write to. source is only needed when the queries do not all target the same dataset.

      Returns Promise<Pipeline>

      The way to materialise query results at scale, rather than paging through them in process. The returned Pipeline has started but not finished — wait for it with Pipeline.waitForPipelineToFinish, or follow it through opts.onProgress.

      If opts.queries is empty; or, when opts.source is omitted, if the queries reference no dataset at all or reference more than one — in both cases pass source explicitly.

    • Replaces this account's profile image.

      Parameters

      • pathOrBuffer: string | Buffer<ArrayBufferLike>

        Path to an image file, or its contents.

      Returns Promise<void>

    • Changes this account's profile fields.

      Parameters

      Returns Promise<User | Group>

      Only the fields you pass are changed; the rest are left alone. Pinned items are not settable here — use AccountBase.pinItems.

      A Group widens this to accept accessLevel as well, since only a group has one.