@triply/triplydb
    Preparing search index...

    Class App

    The entry point to a TriplyDB instance, and the root of every other object in this library.

    Create one with the static App.get factory; the constructor is not public. All other objects are reached from here, starting with App.getAccount or App.getUser.

    import App from "@triply/triplydb";

    const app = App.get({ token: process.env.TOKEN });
    const me = await app.getUser();
    console.log((await me.getInfo()).accountName);
    const app = App.get({ url: "https://api.triplydb.com" });
    const account = await app.getAccount("my-account");
    const dataset = await account.getDataset("my-dataset");
    Index
    • get url(): string

      The API this instance talks to.

      Returns string

      Resolved from the token when one was given without a URL, so this is the way to confirm which instance you actually connected to.

    • The account with this name, whether it is a User or a Group.

      Parameters

      • OptionalaccountName: string

        Account name, or omit for the token's own account.

      Returns Promise<User | Group>

      Omit accountName to get the account the configured API token belongs to. Use this when you do not care which kind of account it is — every member a caller normally wants is shared between the two. Use App.getUser or App.getGroup to insist on one kind.

      If no account with this name exists, or if accountName is omitted and no token is configured — the error then explains where to create one.

    • The configuration this object was created with.

      Returns AppConfig & { url: string }

      The configuration as given, except that url is always set: it is resolved from the token when one was passed without a URL.

      • url: string

        The API this object talks to. Always set, even when the config was given without one.

    • The group with this name.

      Parameters

      • accountName: string

      Returns Promise<Group>

      If no account with this name exists, or if the name belongs to a User rather than a group. Use App.getAccount when it could be either.

    • The instance's own configuration: its branding, URLs and the limits it enforces.

      Returns Promise<ClientConfig>

      Fetched once and then cached for the life of this object.

    • Parameters

      • accountName: string

      Returns Promise<Group>

      Use getGroup()

    • The user with this name.

      Parameters

      • OptionalaccountName: string

        User name, or omit for the token's own user.

      Returns Promise<User>

      Omit accountName to get the user the configured API token belongs to — the usual way to reach your own account.

      If no account with this name exists, or if the name belongs to a Group rather than a user. Use App.getAccount when it could be either.

    • Whether the instance is at least this version.

      Parameters

      • minimumVersion: string

        The lowest version that will do.

      Returns Promise<boolean>

      true when the instance is new enough, and also for an instance that reports its version as unset, which development builds do.

      For code that depends on a feature added in a known release. Versions are calendar-versioned, not semver — they look like 26.4.300 — and are compared as such.

      If the instance reports no version at all.

    • Connects to a TriplyDB instance.

      Parameters

      Returns App

      The only way to make an App — the constructor is private. Nothing is contacted here: the first request happens when you call a method that needs one, so a wrong URL surfaces then rather than now. A malformed token, though, is rejected immediately.

      If conf carries a token that is not a decodable JWT or contains non-ASCII characters.

      const app = App.get(process.env.TOKEN);