/// /** * ```js * import { Database } from "arangojs/database"; * ``` * * The "database" module provides the {@link Database} class and associated * types and interfaces for TypeScript. * * The Database class is also re-exported by the "index" module. * * @packageDocumentation */ import { Readable } from "stream"; import { Analyzer, AnalyzerDescription, CreateAnalyzerOptions } from "./analyzer"; import { AqlLiteral, AqlQuery } from "./aql"; import { ArangoCollection, Collection, CollectionMetadata, CollectionType, CreateCollectionOptions, DocumentCollection, EdgeCollection } from "./collection"; import { ArangoResponseMetadata, Config, Connection, Headers, RequestOptions } from "./connection"; import { ArrayCursor } from "./cursor"; import { FoxxManifest } from "./foxx-manifest"; import { EdgeDefinitionOptions, Graph, GraphCreateOptions, GraphInfo } from "./graph"; import { Blob } from "./lib/blob"; import { ArangojsResponse } from "./lib/request"; import { Route } from "./route"; import { Transaction } from "./transaction"; import { ArangoSearchView, ArangoSearchViewPropertiesOptions, ViewDescription } from "./view"; /** * Indicates whether the given value represents a {@link Database}. * * @param database - A value that might be a database. */ export declare function isArangoDatabase(database: any): database is Database; /** * Collections involved in a transaction. */ export declare type TransactionCollections = { /** * An array of collections or a single collection that will be read from or * written to during the transaction with no other writes being able to run * in parallel. */ exclusive?: (string | ArangoCollection)[] | string | ArangoCollection; /** * An array of collections or a single collection that will be read from or * written to during the transaction. * * If ArangoDB is using the MMFiles storage engine, this option behaves * exactly like `exclusive`, i.e. no other writes will run in parallel. */ write?: (string | ArangoCollection)[] | string | ArangoCollection; /** * An array of collections or a single collection that will be read from * during the transaction. */ read?: (string | ArangoCollection)[] | string | ArangoCollection; }; /** * Options for how the transaction should be performed. */ export declare type TransactionOptions = { /** * Whether the transaction may read from collections not specified for this * transaction. If set to `false`, accessing any collections not specified * will result in the transaction being aborted to avoid potential deadlocks. * * Default: `true`. */ allowImplicit?: boolean; /** * Determines whether to force the transaction to write all data to disk * before returning. */ waitForSync?: boolean; /** * Determines how long the database will wait while attempting to gain locks * on collections used by the transaction before timing out. */ lockTimeout?: number; /** * (RocksDB only.) Determines the transaction size limit in bytes. */ maxTransactionSize?: number; /** * (RocksDB only.) Determines the maximum number of operations after which an * intermediate commit is performed automatically. * * @deprecated Removed in ArangoDB 3.4. */ intermediateCommitCount?: number; /** * (RocksDB only.) Determine the maximum total size of operations after which * an intermediate commit is performed automatically. * * @deprecated Removed in ArangoDB 3.4. */ intermediateCommitSize?: number; }; /** * Options for executing a query. * * See {@link Database.query}. */ export declare type QueryOptions = { /** * If set to `true`, the query will be executed with support for dirty reads * enabled, permitting ArangoDB to return a potentially dirty or stale result * and arangojs will load balance the request without distinguishing between * leaders and followers. * * Note that dirty reads are only supported for read-only queries, not data * modification queries (e.g. using `INSERT`, `UPDATE`, `REPLACE` or * `REMOVE`) and only when using ArangoDB 3.4 or later. * * Default: `false` */ allowDirtyRead?: boolean; /** * Maximum time in milliseconds arangojs will wait for a server response. * Exceeding this value will result in the request being cancelled. * * **Note**: Setting a timeout for the client does not guarantee the query * will be killed by ArangoDB if it is already being executed. See the * `maxRuntime` option for limiting the execution time within ArangoDB. */ timeout?: number; /** * Unless set to `false`, the number of result values in the result set will * be returned in the `count` attribute. This may be disabled by default in * a future version of ArangoDB if calculating this value has a performance * impact for some queries. * * Default: `true`. */ count?: boolean; /** * Number of result values to be transferred by the server in each * network roundtrip (or "batch"). * * Must be greater than zero. */ batchSize?: number; /** * If set to `false`, the AQL query results cache lookup will be skipped for * this query. * * Default: `true` */ cache?: boolean; /** * Maximum memory size in bytes that the query is allowed to use. * Exceeding this value will result in the query failing with an error. * * If set to `0`, the memory limit is disabled. * * Default: `0` */ memoryLimit?: number; /** * Maximum allowed execution time before the query will be killed in seconds. * * If set to `0`, the query will be allowed to run indefinitely. * * Default: `0` */ maxRuntime?: number; /** * Time-to-live for the cursor in seconds. The cursor results may be * garbage collected by ArangoDB after this much time has passed. * * Default: `30` */ ttl?: number; /** * If set to `true`, the query will throw an exception and abort if it would otherwise produce a warning. */ failOnWarning?: boolean; /** * If set to `1` or `true`, additional query profiling information will be * returned in the `extra.profile` attribute if the query is not served from * the result cache. * * If set to `2`, the query will return execution stats per query plan node * in the `extra.stats.nodes` attribute. Additionally the query plan is * returned in `extra.plan`. */ profile?: boolean | number; /** * If set to `true`, the query will be executed as a streaming query. */ stream?: boolean; /** * Limits the maximum number of warnings a query will return. */ maxWarningsCount?: number; /** * If set to `true` and the query has a `LIMIT` clause, the total number of * values matched before the last top-level `LIMIT` in the query was applied * will be returned in the `extra.stats.fullCount` attribute. */ fullCount?: boolean; /** * If set to `false`, the query data will not be stored in the RocksDB block * cache. This can be used to avoid thrashing he block cache when reading a * lot of data. */ fillBlockCache?: boolean; /** * An object with a `rules` property specifying a list of optimizer rules to * be included or excluded by the optimizer for this query. Prefix a rule * name with `+` to include it, or `-` to exclude it. The name `all` acts as * an alias matching all optimizer rules. */ optimizer?: { rules: string[]; }; /** * Limits the maximum number of plans that will be created by the AQL query * optimizer. */ maxPlans?: number; /** * (RocksDB only.) Maximum size of transactions in bytes. */ maxTransactionSize?: number; /** * (RocksDB only.) Maximum number of operations after which an intermediate * commit is automatically performed. */ intermediateCommitCount?: number; /** * (RocksDB only.) Maximum total size of operations in bytes after which an * intermediate commit is automatically performed. */ intermediateCommitSize?: number; /** * (Enterprise Edition cluster only.) If set to `true`, collections * inaccessible to current user will result in an access error instead * of being treated as empty. */ skipInaccessibleCollections?: boolean; /** * (Enterprise Edition cluster only.) Limits the maximum time in seconds a * DBServer will wait to bring satellite collections involved in the query * into sync. Exceeding this value will result in the query being stopped. * * Default: `60` */ satelliteSyncWait?: number; }; /** * Options for explaining a query. * * See {@link Database.explain}. */ export declare type ExplainOptions = { /** * An object with a `rules` property specifying a list of optimizer rules to * be included or excluded by the optimizer for this query. Prefix a rule * name with `+` to include it, or `-` to exclude it. The name `all` acts as * an alias matching all optimizer rules. */ optimizer?: { rules: string[]; }; /** * Maximum number of plans that the optimizer is allowed to generate. * Setting this to a low value limits the amount of work the optimizer does. */ maxNumberOfPlans?: number; /** * If set to true, all possible execution plans will be returned as the * `plans` property. Otherwise only the optimal execution plan will be * returned as the `plan` property. * * Default: `false` */ allPlans?: boolean; }; /** * Details for a transaction. * * See also {@link TransactionStatus}. */ export declare type TransactionDetails = { /** * Unique identifier of the transaction. */ id: string; /** * Status (or "state") of the transaction. */ state: "running" | "committed" | "aborted"; }; /** * Plan explaining query execution. */ export declare type ExplainPlan = { /** * Execution nodes in this plan. */ nodes: { [key: string]: any; type: string; id: number; dependencies: number[]; estimatedCost: number; estimatedNrItems: number; }[]; /** * Rules applied by the optimizer. */ rules: string[]; /** * Information about collections involved in the query. */ collections: { name: string; type: "read" | "write"; }[]; /** * Variables used in the query. */ variables: { id: number; name: string; }[]; /** * Total estimated cost of the plan. */ estimatedCost: number; /** * Estimated number of items returned by the query. */ estimatedNrItems: number; /** * Whether the query is a data modification query. */ isModificationQuery: boolean; }; /** * Result of explaining a query with a single plan. */ export declare type SingleExplainResult = { /** * Query plan. */ plan: ExplainPlan; /** * Whether it would be possible to cache the query. */ cacheable: boolean; /** * Warnings encountered while planning the query execution. */ warnings: { code: number; message: string; }[]; /** * Statistical information about the query plan generation. */ stats: { /** * Total number of rules executed for this query. */ rulesExecuted: number; /** * Number of rules skipped for this query. */ rulesSkipped: number; /** * Total number of plans created. */ plansCreated: number; }; }; /** * Result of explaining a query with multiple plans. */ export declare type MultiExplainResult = { /** * Query plans. */ plans: ExplainPlan[]; /** * Whether it would be possible to cache the query. */ cacheable: boolean; /** * Warnings encountered while planning the query execution. */ warnings: { code: number; message: string; }[]; /** * Statistical information about the query plan generation. */ stats: { /** * Total number of rules executed for this query. */ rulesExecuted: number; /** * Number of rules skipped for this query. */ rulesSkipped: number; /** * Total number of plans created. */ plansCreated: number; }; }; /** * Node in an AQL abstract syntax tree (AST). */ export declare type AstNode = { [key: string]: any; type: string; subNodes: AstNode[]; }; /** * Result of parsing a query. */ export declare type ParseResult = { /** * Whether the query was parsed. */ parsed: boolean; /** * Names of all collections involved in the query. */ collections: string[]; /** * Names of all bind parameters used in the query. */ bindVars: string[]; /** * Abstract syntax tree (AST) of the query. */ ast: AstNode[]; }; /** * Information about query tracking. */ export declare type QueryTracking = { /** * Whether query tracking is enabled. */ enabled: boolean; /** * Maximum query string length in bytes that is kept in the list. */ maxQueryStringLength: number; /** * Maximum number of slow queries that is kept in the list. */ maxSlowQueries: number; /** * Threshold execution time in seconds for when a query is * considered slow. */ slowQueryThreshold: number; /** * Whether bind parameters are being tracked along with queries. */ trackBindVars: boolean; /** * Whether slow queries are being tracked. */ trackSlowQueries: boolean; }; /** * Options for query tracking. * * See {@link Database.queryTracking}. */ export declare type QueryTrackingOptions = { /** * If set to `false`, neither queries nor slow queries will be tracked. */ enabled?: boolean; /** * Maximum query string length in bytes that will be kept in the list. */ maxQueryStringLength?: number; /** * Maximum number of slow queries to be kept in the list. */ maxSlowQueries?: number; /** * Threshold execution time in seconds for when a query will be * considered slow. */ slowQueryThreshold?: number; /** * If set to `true`, bind parameters will be tracked along with queries. */ trackBindVars?: boolean; /** * If set to `true` and `enabled` is also set to `true`, slow queries will be * tracked if their execution time exceeds `slowQueryThreshold`. */ trackSlowQueries?: boolean; }; /** * Object describing a query. */ export declare type QueryInfo = { /** * Unique identifier for this query. */ id: string; /** * Query string (potentially truncated). */ query: string; /** * Bind parameters used in the query. */ bindVars: Record; /** * Query's running time in seconds. */ runTime: number; /** * Date and time the query was started. */ started: string; /** * Query's current execution state. */ state: "executing" | "finished" | "killed"; /** * Whether the query uses a streaming cursor. */ stream: boolean; }; /** * Database user to create with a database. */ export declare type CreateDatabaseUser = { /** * Username of the user to create. */ username: string; /** * Password of the user to create. * * Default: `""` */ passwd?: string; /** * Whether the user is active. * * Default: `true` */ active?: boolean; /** * Additional data to store with the user object. */ extra?: Record; }; /** * Options for creating a database. * * See {@link Database.createDatabase}. */ export declare type CreateDatabaseOptions = { /** * Database users to create with the database. */ users?: CreateDatabaseUser[]; /** * (Cluster only.) The sharding method to use for new collections in the * database. */ sharding?: "" | "flexible" | "single"; /** * (Cluster only.) Default replication factor for new collections in this * database. * * Setting this to `1` disables replication. Setting this to `"satellite"` * will replicate to every DBServer. */ replicationFactor?: "satellite" | number; /** * (Cluster only.) Default write concern for new collections created in this * database. */ writeConcern?: number; /** * (Cluster only.) Default write concern for new collections created in this * database. * * @deprecated Renamed to `writeConcern` in ArangoDB 3.6. */ minReplicationFactor?: number; }; /** * Object describing a database. * * See {@link Database.get}. */ export declare type DatabaseInfo = { /** * Name of the database. */ name: string; /** * Unique identifier of the database. */ id: string; /** * File system path of the database. */ path: string; /** * Whether the database is the system database. */ isSystem: boolean; /** * (Cluster only.) The sharding method to use for new collections in the * database. */ sharding?: "" | "flexible" | "single"; /** * (Cluster only.) Default replication factor for new collections in this * database. */ replicationFactor?: "satellite" | number; /** * (Cluster only.) Default write concern for new collections created in this * database. */ writeConcern?: number; /** * (Cluster only.) Default write concern for new collections created in this * database. * * @deprecated Renamed to `writeConcern` in ArangoDB 3.6. */ minReplicationFactor?: number; }; /** * Result of retrieving database version information. */ export declare type VersionInfo = { /** * Value identifying the server type, i.e. `"arango"`. */ server: string; /** * ArangoDB license type or "edition". */ license: "community" | "enterprise"; /** * ArangoDB server version. */ version: string; /** * Additional information about the ArangoDB server. */ details?: { [key: string]: string; }; }; /** * Definition of an AQL User Function. */ export declare type AqlUserFunction = { /** * Name of the AQL User Function. */ name: string; /** * Implementation of the AQL User Function. */ code: string; /** * Whether the function is deterministic. * * See {@link Database.createFunction}. */ isDeterministic: boolean; }; /** * Options for installing the service. * * See {@link Database.installService}. */ export declare type InstallServiceOptions = { /** * An object mapping configuration option names to values. * * See also {@link Database.getServiceConfiguration}. */ configuration?: Record; /** * An object mapping dependency aliases to mount points. * * See also {@link Database.getServiceDependencies}. */ dependencies?: Record; /** * Whether the service should be installed in development mode. * * See also {@link Database.setServiceDevelopmentMode}. * * Default: `false` */ development?: boolean; /** * Whether the service should be installed in legacy compatibility mode * * This overrides the `engines` option in the service manifest (if any). * * Default: `false` */ legacy?: boolean; /** * Whether the "setup" script should be executed. * * Default: `true` */ setup?: boolean; }; /** * Options for replacing a service. * * See {@link Database.replaceService}. */ export declare type ReplaceServiceOptions = { /** * An object mapping configuration option names to values. * * See also {@link Database.getServiceConfiguration}. */ configuration?: Record; /** * An object mapping dependency aliases to mount points. * * See also {@link Database.getServiceDependencies}. */ dependencies?: Record; /** * Whether the service should be installed in development mode. * * See also {@link Database.setServiceDevelopmentMode}. * * Default: `false` */ development?: boolean; /** * Whether the service should be installed in legacy compatibility mode * * This overrides the `engines` option in the service manifest (if any). * * Default: `false` */ legacy?: boolean; /** * Whether the "setup" script should be executed. * * Default: `true` */ setup?: boolean; /** * Whether the existing service's "teardown" script should be executed * prior to removing that service. * * Default: `true` */ teardown?: boolean; /** * If set to `true`, replacing a service that does not already exist will * fall back to installing the new service. * * Default: `false` */ force?: boolean; }; /** * Options for upgrading a service. * * See {@link Database.upgradeService}. */ export declare type UpgradeServiceOptions = { /** * An object mapping configuration option names to values. * * See also {@link Database.getServiceConfiguration}. */ configuration?: Record; /** * An object mapping dependency aliases to mount points. * * See also {@link Database.getServiceDependencies}. */ dependencies?: Record; /** * Whether the service should be installed in development mode. * * See also {@link Database.setServiceDevelopmentMode}. * * Default: `false` */ development?: boolean; /** * Whether the service should be installed in legacy compatibility mode * * This overrides the `engines` option in the service manifest (if any). * * Default: `false` */ legacy?: boolean; /** * Whether the "setup" script should be executed. * * Default: `true` */ setup?: boolean; /** * Whether the existing service's "teardown" script should be executed * prior to upgrading that service. * * Default: `false` */ teardown?: boolean; /** * Unless set to `true`, upgrading a service that does not already exist will * fall back to installing the new service. * * Default: `false` */ force?: boolean; }; /** * Options for uninstalling a service. * * See {@link Database.uninstallService}. */ export declare type UninstallServiceOptions = { /** * Whether the service's "teardown" script should be executed * prior to removing that service. * * Default: `true` */ teardown?: boolean; /** * If set to `true`, uninstalling a service that does not already exist * will be considered successful. * * Default: `false` */ force?: boolean; }; /** * Object briefly describing a Foxx service. */ export declare type ServiceSummary = { /** * Service mount point, relative to the database. */ mount: string; /** * Name defined in the service manifest. */ name?: string; /** * Version defined in the service manifest. */ version?: string; /** * Service dependencies the service expects to be able to match as a mapping * from dependency names to versions the service is compatible with. */ provides: Record; /** * Whether development mode is enabled for this service. */ development: boolean; /** * Whether the service is running in legacy compatibility mode. */ legacy: boolean; }; /** * Object describing a Foxx service in detail. */ export declare type ServiceInfo = { /** * Service mount point, relative to the database. */ mount: string; /** * File system path of the service. */ path: string; /** * Name defined in the service manifest. */ name?: string; /** * Version defined in the service manifest. */ version?: string; /** * Whether development mode is enabled for this service. */ development: boolean; /** * Whether the service is running in legacy compatibility mode. */ legacy: boolean; /** * Content of the service manifest of this service. */ manifest: FoxxManifest; /** * Internal checksum of the service's initial source bundle. */ checksum: string; /** * Options for this service. */ options: { /** * Configuration values set for this service. */ configuration: Record; /** * Service dependency configuration of this service. */ dependencies: Record; }; }; /** * Object describing a configuration option of a Foxx service. */ export declare type ServiceConfiguration = { /** * Data type of the configuration value. * * **Note**: `"int"` and `"bool"` are historical synonyms for `"integer"` and * `"boolean"`. The `"password"` type is synonymous with `"string"` but can * be used to distinguish values which should not be displayed in plain text * by software when managing the service. */ type: "integer" | "boolean" | "string" | "number" | "json" | "password" | "int" | "bool"; /** * Current value of the configuration option as stored internally. */ currentRaw: any; /** * Processed current value of the configuration option as exposed in the * service code. */ current: any; /** * Formatted name of the configuration option. */ title: string; /** * Human-readable description of the configuration option. */ description?: string; /** * Whether the configuration option must be set in order for the service * to be operational. */ required: boolean; /** * Default value of the configuration option. */ default?: any; }; /** * Object describing a single-service dependency defined by a Foxx service. */ export declare type SingleServiceDependency = { /** * Whether this is a multi-service dependency. */ multiple: false; /** * Current mount point the dependency is resolved to. */ current?: string; /** * Formatted name of the dependency. */ title: string; /** * Name of the service the dependency expects to match. */ name: string; /** * Version of the service the dependency expects to match. */ version: string; /** * Human-readable description of the dependency. */ description?: string; /** * Whether the dependency must be matched in order for the service * to be operational. */ required: boolean; }; /** * Object describing a multi-service dependency defined by a Foxx service. */ export declare type MultiServiceDependency = { /** * Whether this is a multi-service dependency. */ multiple: true; /** * Current mount points the dependency is resolved to. */ current?: string[]; /** * Formatted name of the dependency. */ title: string; /** * Name of the service the dependency expects to match. */ name: string; /** * Version of the service the dependency expects to match. */ version: string; /** * Human-readable description of the dependency. */ description?: string; /** * Whether the dependency must be matched in order for the service * to be operational. */ required: boolean; }; /** * Test stats for a Foxx service's tests. */ export declare type ServiceTestStats = { /** * Total number of tests found. */ tests: number; /** * Number of tests that ran successfully. */ passes: number; /** * Number of tests that failed. */ failures: number; /** * Number of tests skipped or not executed. */ pending: number; /** * Total test duration in milliseconds. */ duration: number; }; /** * Test results for a single test case using the stream reporter. */ export declare type ServiceTestStreamTest = { title: string; fullTitle: string; duration: number; err?: string; }; /** * Test results for a Foxx service's tests using the stream reporter. */ export declare type ServiceTestStreamReport = (["start", { total: number; }] | ["pass", ServiceTestStreamTest] | ["fail", ServiceTestStreamTest] | ["end", ServiceTestStats])[]; /** * Test results for a single test case using the suite reporter. */ export declare type ServiceTestSuiteTest = { result: "pending" | "pass" | "fail"; title: string; duration: number; err?: any; }; /** * Test results for a single test suite using the suite reporter. */ export declare type ServiceTestSuite = { title: string; suites: ServiceTestSuite[]; tests: ServiceTestSuiteTest[]; }; /** * Test results for a Foxx service's tests using the suite reporter. */ export declare type ServiceTestSuiteReport = { stats: ServiceTestStats; suites: ServiceTestSuite[]; tests: ServiceTestSuiteTest[]; }; /** * Test results for a single test case in XUnit format using the JSONML * representation. */ export declare type ServiceTestXunitTest = ["testcase", { classname: string; name: string; time: number; }] | [ "testcase", { classname: string; name: string; time: number; }, [ "failure", { message: string; type: string; }, string ] ]; /** * Test results for a Foxx service's tests in XUnit format using the JSONML * representation. */ export declare type ServiceTestXunitReport = [ "testsuite", { timestamp: number; tests: number; errors: number; failures: number; skip: number; time: number; }, ...ServiceTestXunitTest[] ]; /** * Test results for a Foxx service's tests in TAP format. */ export declare type ServiceTestTapReport = string[]; /** * Test results for a single test case using the default reporter. */ export declare type ServiceTestDefaultTest = { title: string; fullTitle: string; duration: number; err?: string; }; /** * Test results for a Foxx service's tests using the default reporter. */ export declare type ServiceTestDefaultReport = { stats: ServiceTestStats; tests: ServiceTestDefaultTest[]; pending: ServiceTestDefaultTest[]; failures: ServiceTestDefaultTest[]; passes: ServiceTestDefaultTest[]; }; /** * OpenAPI 2.0 description of a Foxx service. */ export declare type SwaggerJson = { [key: string]: any; info: { title: string; description: string; version: string; license: string; }; path: { [key: string]: any; }; }; /** * An object representing a single ArangoDB database. All arangojs collections, * cursors, analyzers and so on are linked to a `Database` object. */ export declare class Database { protected _connection: Connection; protected _name: string; protected _analyzers: Map; protected _collections: Map>; protected _graphs: Map; protected _views: Map; /** * Creates a new `Database` instance with its own connection pool. * * See also {@link Database.database}. * * @param config - An object with configuration options. * * @example * ```js * const db = new Database({ * url: "http://localhost:8529", * databaseName: "my_database", * auth: { username: "admin", password: "hunter2" }, * }); * ``` */ constructor(config?: Config); /** * Creates a new `Database` instance with its own connection pool. * * See also {@link Database.database}. * * @param url - Base URL of the ArangoDB server or list of server URLs. * Equivalent to the `url` option in {@link Config}. * * @example * ```js * const db = new Database("http://localhost:8529", "my_database"); * db.useBasicAuth("admin", "hunter2"); * ``` */ constructor(url: string | string[], name?: string); /** * @internal * * Indicates that this object represents an ArangoDB database. */ get isArangoDatabase(): true; /** * Name of the ArangoDB database this instance represents. */ get name(): string; /** * Fetches version information from the ArangoDB server. * * @param details - If set to `true`, additional information about the * ArangoDB server will be available as the `details` property. * * @example * ```js * const db = new Database(); * const version = await db.version(); * // the version object contains the ArangoDB version information. * // license: "community" or "enterprise" * // version: ArangoDB version number * // server: description of the server * ``` */ version(details?: boolean): Promise; /** * Returns a new {@link Route} instance for the given path (relative to the * database) that can be used to perform arbitrary HTTP requests. * * @param path - The database-relative URL of the route. Defaults to the * database API root. * @param headers - Default headers that should be sent with each request to * the route. * * @example * ```js * const db = new Database(); * const myFoxxService = db.route("my-foxx-service"); * const response = await myFoxxService.post("users", { * username: "admin", * password: "hunter2" * }); * // response.body is the result of * // POST /_db/_system/my-foxx-service/users * // with JSON request body '{"username": "admin", "password": "hunter2"}' * ``` */ route(path?: string, headers?: Headers): Route; /** * @internal * * Performs an arbitrary HTTP request against the database. * * If `absolutePath` is set to `true`, the database path will not be * automatically prepended to the `basePath`. * * @param T - Return type to use. Defaults to the response object type. * @param options - Options for this request. * @param transform - An optional function to transform the low-level * response object to a more useful return value. */ request(options: RequestOptions & { absolutePath?: boolean; }, transform?: (res: ArangojsResponse) => T): Promise; /** * Updates the URL list by requesting a list of all coordinators in the * cluster and adding any endpoints not initially specified in the * {@link Config}. * * For long-running processes communicating with an ArangoDB cluster it is * recommended to run this method periodically (e.g. once per hour) to make * sure new coordinators are picked up correctly and can be used for * fail-over or load balancing. * * @example * ```js * const db = new Database(); * const interval = setInterval( * () => db.acquireHostList(), * 5 * 60 * 1000 // every 5 minutes * ); * * // later * clearInterval(interval); * db.close(); * ``` */ acquireHostList(): Promise; /** * Closes all active connections of this database instance. * * Can be used to clean up idling connections during longer periods of * inactivity. * * **Note**: This method currently has no effect in the browser version of * arangojs. * * @example * ```js * const db = new Database(); * const sessions = db.collection("sessions"); * // Clean up expired sessions once per hour * setInterval(async () => { * await db.query(aql` * FOR session IN ${sessions} * FILTER session.expires < DATE_NOW() * REMOVE session IN ${sessions} * `); * // Making sure to close the connections because they're no longer used * db.close(); * }, 1000 * 60 * 60); * ``` */ close(): void; /** * Performs a request against every known coordinator and returns when the * request has succeeded against every coordinator or the timeout is reached. * * **Note**: This method is primarily intended to make database setup easier * in cluster scenarios and requires all coordinators to be known to arangojs * before the method is invoked. The method is not useful in single-server or * leader-follower replication scenarios. * * @example * ```js * const db = new Database({ loadBalancingStrategy: "ROUND_ROBIN" }); * await db.acquireHostList(); * const analyzer = db.analyzer("my-analyzer"); * await analyzer.create(); * await db.waitForPropagation( * { path: `/_api/analyzer/${analyzer.name}` }, * 30000 * ); * // Analyzer has been propagated to all coordinators and can safely be used * ``` * * @param request - Request to perform against each known coordinator. * @param timeout - Maximum number of milliseconds to wait for propagation. */ waitForPropagation(request: RequestOptions, timeout?: number): Promise; /** * Updates the `Database` instance and its connection string to use the given * `databaseName`, then returns itself. * * **Note**: This also affects all collections, cursors and other arangojs * objects originating from this database object, which may cause unexpected * results. * * @param databaseName - Name of the database to use. * * @deprecated Use {@link Database.database} instead. * * @example * ```js * const systemDb = new Database(); * // systemDb.useDatabase("my_database"); // deprecated * const myDb = systemDb.database("my_database"); * ``` */ useDatabase(databaseName: string): this; /** * Updates the `Database` instance's `authorization` header to use Basic * authentication with the given `username` and `password`, then returns * itself. * * @param username - The username to authenticate with. * @param password - The password to authenticate with. * * @example * ```js * const db = new Database(); * db.useDatabase("test"); * db.useBasicAuth("admin", "hunter2"); * // The database instance now uses the database "test" * // with the username "admin" and password "hunter2". * ``` */ useBasicAuth(username?: string, password?: string): this; /** * Updates the `Database` instance's `authorization` header to use Bearer * authentication with the given authentication `token`, then returns itself. * * @param token - The token to authenticate with. * * @example * ```js * const db = new Database(); * db.useBearerAuth("keyboardcat"); * // The database instance now uses Bearer authentication. * ``` */ useBearerAuth(token: string): this; /** * Validates the given database credentials and exchanges them for an * authentication token, then uses the authentication token for future * requests and returns it. * * @param username - The username to authenticate with. * @param password - The password to authenticate with. * * @example * ```js * const db = new Database(); * db.useDatabase("test"); * await db.login("admin", "hunter2"); * // The database instance now uses the database "test" * // with an authentication token for the "admin" user. * ``` */ login(username?: string, password?: string): Promise; /** * Creates a new `Database` instance for the given `databaseName` that * shares this database's connection pool. * * See also {@link Database.constructor}. * * @param databaseName - Name of the database. * * @example * ```js * const systemDb = new Database(); * const myDb = system.database("my_database"); * ``` */ database(databaseName: string): Database; /** * Fetches the database description for the active database from the server. * * @example * ```js * const db = new Database(); * const info = await db.get(); * // the database exists * ``` */ get(): Promise; /** * Checks whether the database exists. * * @example * ```js * const db = new Database(); * const result = await db.exists(); * // result indicates whether the database exists * ``` */ exists(): Promise; /** * Creates a new database with the given `databaseName` with the given * `options` and returns a `Database` instance for that database. * * @param databaseName - Name of the database to create. * @param options - Options for creating the database. * * @example * ```js * const db = new Database(); * const info = await db.createDatabase("mydb", { * users: [{ username: "root" }] * }); * // the database has been created * db.useDatabase("mydb"); * db.useBasicAuth("root", ""); * ``` */ createDatabase(databaseName: string, options?: CreateDatabaseOptions): Promise; /** * Creates a new database with the given `databaseName` with the given * `users` and returns a `Database` instance for that database. * * @param databaseName - Name of the database to create. * @param users - Database users to create with the database. * * @example * ```js * const db = new Database(); * const info = await db.createDatabase("mydb", [{ username: "root" }]); * // the database has been created * db.useDatabase("mydb"); * db.useBasicAuth("root", ""); * ``` */ createDatabase(databaseName: string, users: CreateDatabaseUser[]): Promise; /** * Fetches all databases from the server and returns an array of their names. * * See also {@link Database.databases} and * {@link Database.listUserDatabases}. * * @example * ```js * const db = new Database(); * const names = await db.listDatabases(); * // databases is an array of database names * ``` */ listDatabases(): Promise; /** * Fetches all databases accessible to the active user from the server and * returns an array of their names. * * See also {@link Database.userDatabases} and * {@link Database.listDatabases}. * * @example * ```js * const db = new Database(); * const names = await db.listUserDatabases(); * // databases is an array of database names * ``` */ listUserDatabases(): Promise; /** * Fetches all databases from the server and returns an array of `Database` * instances for those databases. * * See also {@link Database.listDatabases} and * {@link Database.userDatabases}. * * @example * ```js * const db = new Database(); * const names = await db.databases(); * // databases is an array of databases * ``` */ databases(): Promise; /** * Fetches all databases accessible to the active user from the server and * returns an array of `Database` instances for those databases. * * See also {@link Database.listUserDatabases} and * {@link Database.databases}. * * @example * ```js * const db = new Database(); * const names = await db.userDatabases(); * // databases is an array of databases * ``` */ userDatabases(): Promise; /** * Deletes the database with the given `databaseName` from the server. * * @param databaseName - Name of the database to delete. * * @example * ```js * const db = new Database(); * await db.dropDatabase("mydb"); * // database "mydb" no longer exists * ``` */ dropDatabase(databaseName: string): Promise; /** * Returns a `Collection` instance for the given collection name. * * In TypeScript the collection implements both the * {@link DocumentCollection} and {@link EdgeCollection} interfaces and can * be cast to either type to enforce a stricter API. * * @param T - Type to use for document data. Defaults to `any`. * @param collectionName - Name of the edge collection. * * @example * ```js * const db = new Database(); * const collection = db.collection("potatoes"); * ``` * * @example * ```ts * interface Person { * name: string; * } * const db = new Database(); * const persons = db.collection("persons"); * ``` * * @example * ```ts * interface Person { * name: string; * } * interface Friend { * startDate: number; * endDate?: number; * } * const db = new Database(); * const documents = db.collection("persons") as DocumentCollection; * const edges = db.collection("friends") as EdgeCollection; * ``` */ collection = any>(collectionName: string): DocumentCollection & EdgeCollection; /** * Creates a new collection with the given `collectionName` and `options`, * then returns a {@link DocumentCollection} instance for the new collection. * * @param T - Type to use for document data. Defaults to `any`. * @param collectionName - Name of the new collection. * @param options - Options for creating the collection. * * @example * ```ts * const db = new Database(); * const documents = db.createCollection("persons"); * ``` * * @example * ```ts * interface Person { * name: string; * } * const db = new Database(); * const documents = db.createCollection("persons"); * ``` */ createCollection = any>(collectionName: string, options?: CreateCollectionOptions & { type?: CollectionType.DOCUMENT_COLLECTION; }): Promise>; /** * Creates a new edge collection with the given `collectionName` and * `options`, then returns an {@link EdgeCollection} instance for the new * edge collection. * * @param T - Type to use for edge document data. Defaults to `any`. * @param collectionName - Name of the new collection. * @param options - Options for creating the collection. * * @example * ```js * const db = new Database(); * const edges = db.createCollection("friends", { * type: CollectionType.EDGE_COLLECTION * }); * ``` * * @example * ```ts * interface Friend { * startDate: number; * endDate?: number; * } * const db = new Database(); * const edges = db.createCollection("friends", { * type: CollectionType.EDGE_COLLECTION * }); * ``` */ createCollection = any>(collectionName: string, options: CreateCollectionOptions & { type: CollectionType.EDGE_COLLECTION; }): Promise>; /** * Creates a new edge collection with the given `collectionName` and * `options`, then returns an {@link EdgeCollection} instance for the new * edge collection. * * This is a convenience method for calling {@link Database.createCollection} * with `options.type` set to `EDGE_COLLECTION`. * * @param T - Type to use for edge document data. Defaults to `any`. * @param collectionName - Name of the new collection. * @param options - Options for creating the collection. * * @example * ```js * const db = new Database(); * const edges = db.createEdgeCollection("friends"); * ``` * * @example * ```ts * interface Friend { * startDate: number; * endDate?: number; * } * const db = new Database(); * const edges = db.createEdgeCollection("friends"); * ``` */ createEdgeCollection = any>(collectionName: string, options?: CreateCollectionOptions): Promise>; /** * Renames the collection `collectionName` to `newName`. * * Additionally removes any stored `Collection` instance for * `collectionName` from the `Database` instance's internal cache. * * **Note**: Renaming collections may not be supported when ArangoDB is * running in a cluster configuration. * * @param collectionName - Current name of the collection. * @param newName - The new name of the collection. */ renameCollection(collectionName: string, newName: string): Promise; /** * Fetches all collections from the database and returns an array of * collection descriptions. * * See also {@link Database.collections}. * * @param excludeSystem - Whether system collections should be excluded. * * @example * ```js * const db = new Database(); * const collections = await db.listCollections(); * // collections is an array of collection descriptions * // not including system collections * ``` * * @example * ```js * const db = new Database(); * const collections = await db.listCollections(false); * // collections is an array of collection descriptions * // including system collections * ``` */ listCollections(excludeSystem?: boolean): Promise; /** * Fetches all collections from the database and returns an array of * `Collection` instances. * * In TypeScript these instances implement both the * {@link DocumentCollection} and {@link EdgeCollection} interfaces and can * be cast to either type to enforce a stricter API. * * See also {@link Database.listCollections}. * * @param excludeSystem - Whether system collections should be excluded. * * @example * ```js * const db = new Database(); * const collections = await db.collections(); * // collections is an array of DocumentCollection * // and EdgeCollection instances * // not including system collections * ``` * * @example * ```js * const db = new Database(); * const collections = await db.collections(false); * // collections is an array of DocumentCollection * // and EdgeCollection instances * // including system collections * ``` */ collections(excludeSystem?: boolean): Promise>; /** * Returns a {@link Graph} instance representing the graph with the given * `graphName`. * * @param graphName - Name of the graph. * * @example * ```js * const db = new Database(); * const graph = db.graph("some-graph"); * ``` */ graph(graphName: string): Graph; /** * Creates a graph with the given `graphName` and `edgeDefinitions`, then * returns a {@link Graph} instance for the new graph. * * @param graphName - Name of the graph to be created. * @param edgeDefinitions - An array of edge definitions. * @param options - An object defining the properties of the graph. */ createGraph(graphName: string, edgeDefinitions: EdgeDefinitionOptions[], options?: GraphCreateOptions): Promise; /** * Fetches all graphs from the database and returns an array of graph * descriptions. * * See also {@link Database.graphs}. * * @example * ```js * const db = new Database(); * const graphs = await db.listGraphs(); * // graphs is an array of graph descriptions * ``` */ listGraphs(): Promise; /** * Fetches all graphs from the database and returns an array of {@link Graph} * instances for those graphs. * * See also {@link Database.listGraphs}. * * @example * ```js * const db = new Database(); * const graphs = await db.graphs(); * // graphs is an array of Graph instances * ``` */ graphs(): Promise; /** * Returns an {@link ArangoSearchView} instance for the given `viewName`. * * @param viewName - Name of the ArangoSearch View. * * @example * ```js * const db = new Database(); * const view = db.view("potatoes"); * ``` */ view(viewName: string): ArangoSearchView; /** * Creates a new ArangoSearch View with the given `viewName` and `options` * and returns an {@link ArangoSearchView} instance for the created View. * * @param viewName - Name of the ArangoSearch View. * @param options - An object defining the properties of the View. * * @example * ```js * const db = new Database(); * const view = await db.createView("potatoes"); * // the ArangoSearch View "potatoes" now exists * ``` */ createView(viewName: string, options?: ArangoSearchViewPropertiesOptions): Promise; /** * Renames the view `viewName` to `newName`. * * Additionally removes any stored {@link View} instance for `viewName` from * the `Database` instance's internal cache. * * **Note**: Renaming views may not be supported when ArangoDB is running in * a cluster configuration. * * @param viewName - Current name of the view. * @param newName - The new name of the view. */ renameView(viewName: string, newName: string): Promise; /** * Fetches all Views from the database and returns an array of View * descriptions. * * See also {@link Database.views}. * * @example * ```js * const db = new Database(); * * const views = await db.listViews(); * // views is an array of View descriptions * ``` */ listViews(): Promise; /** * Fetches all Views from the database and returns an array of * {@link ArangoSearchView} instances for the Views. * * See also {@link Database.listViews}. * * @example * ```js * const db = new Database(); * const views = await db.views(); * // views is an array of ArangoSearch View instances * ``` */ views(): Promise; /** * Returns an {@link Analyzer} instance representing the Analyzer with the * given `analyzerName`. * * @example * ```js * const db = new Database(); * const analyzer = db.analyzer("some-analyzer"); * const info = await analyzer.get(); * ``` */ analyzer(analyzerName: string): Analyzer; /** * Creates a new Analyzer with the given `analyzerName` and `options`, then * returns an {@link Analyzer} instance for the new Analyzer. * * @param analyzerName - Name of the Analyzer. * @param options - An object defining the properties of the Analyzer. * * @example * ```js * const db = new Database(); * const analyzer = await db.createAnalyzer("potatoes", { type: "identity" }); * // the identity Analyzer "potatoes" now exists * ``` */ createAnalyzer(analyzerName: string, options: CreateAnalyzerOptions): Promise; /** * Fetches all Analyzers visible in the database and returns an array of * Analyzer descriptions. * * See also {@link Database.analyzers}. * * @example * ```js * const db = new Database(); * const analyzers = await db.listAnalyzers(); * // analyzers is an array of Analyzer descriptions * ``` */ listAnalyzers(): Promise; /** * Fetches all Analyzers visible in the database and returns an array of * {@link Analyzer} instances for those Analyzers. * * See also {@link Database.listAnalyzers}. * * @example * ```js * const db = new Database(); * const analyzers = await db.analyzers(); * // analyzers is an array of Analyzer instances * ``` */ analyzers(): Promise; /** * Performs a server-side JavaScript transaction and returns its return * value. * * Collections can be specified as collection names (strings) or objects * implementing the {@link ArangoCollection} interface: `Collection`, * {@link GraphVertexCollection}, {@link GraphEdgeCollection} as well as * (in TypeScript) {@link DocumentCollection} and {@link EdgeCollection}. * * **Note**: The `action` function will be evaluated and executed on the * server inside ArangoDB's embedded JavaScript environment and can not * access any values other than those passed via the `params` option. * * See the official ArangoDB documentation for * {@link https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html | the JavaScript `@arangodb` module} * for information about accessing the database from within ArangoDB's * server-side JavaScript environment. * * @param collections - Collections involved in the transaction. * @param action - A string evaluating to a JavaScript function to be * executed on the server. * @param options - Options for the transaction. If `options.allowImplicit` * is specified, it will be used if `collections.allowImplicit` was not * specified. * * @example * ```js * const db = new Database(); * * const action = ` * function(params) { * // This code will be executed inside ArangoDB! * const { query } = require("@arangodb"); * return query\` * FOR user IN _users * FILTER user.age > ${params.age} * RETURN u.user * \`.toArray(); * } * `); * * const result = await db.executeTransaction({ * read: ["_users"] * }, action, { * params: { age: 12 } * }); * // result contains the return value of the action * ``` */ executeTransaction(collections: TransactionCollections & { allowImplicit?: boolean; }, action: string, options?: TransactionOptions & { params?: any; }): Promise; /** * Performs a server-side transaction and returns its return value. * * Collections can be specified as collection names (strings) or objects * implementing the {@link ArangoCollection} interface: `Collection`, * {@link GraphVertexCollection}, {@link GraphEdgeCollection} as well as * (in TypeScript) {@link DocumentCollection} and {@link EdgeCollection}. * * **Note**: The `action` function will be evaluated and executed on the * server inside ArangoDB's embedded JavaScript environment and can not * access any values other than those passed via the `params` option. * See the official ArangoDB documentation for * {@link https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html | the JavaScript `@arangodb` module} * for information about accessing the database from within ArangoDB's * server-side JavaScript environment. * * @param collections - Collections that can be read from and written to * during the transaction. * @param action - A string evaluating to a JavaScript function to be * executed on the server. * @param options - Options for the transaction. * * @example * ```js * const db = new Database(); * * const action = ` * function(params) { * // This code will be executed inside ArangoDB! * const { query } = require("@arangodb"); * return query\` * FOR user IN _users * FILTER user.age > ${params.age} * RETURN u.user * \`.toArray(); * } * `); * * const result = await db.executeTransaction(["_users"], action, { * params: { age: 12 } * }); * // result contains the return value of the action * ``` */ executeTransaction(collections: (string | ArangoCollection)[], action: string, options?: TransactionOptions & { params?: any; }): Promise; /** * Performs a server-side transaction and returns its return value. * * The Collection can be specified as a collection name (string) or an object * implementing the {@link ArangoCollection} interface: `Collection`, * {@link GraphVertexCollection}, {@link GraphEdgeCollection} as well as * (in TypeScript) {@link DocumentCollection} and {@link EdgeCollection}. * * **Note**: The `action` function will be evaluated and executed on the * server inside ArangoDB's embedded JavaScript environment and can not * access any values other than those passed via the `params` option. * See the official ArangoDB documentation for * {@link https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html | the JavaScript `@arangodb` module} * for information about accessing the database from within ArangoDB's * server-side JavaScript environment. * * @param collection - A collection that can be read from and written to * during the transaction. * @param action - A string evaluating to a JavaScript function to be * executed on the server. * @param options - Options for the transaction. * * @example * ```js * const db = new Database(); * * const action = ` * function(params) { * // This code will be executed inside ArangoDB! * const { query } = require("@arangodb"); * return query\` * FOR user IN _users * FILTER user.age > ${params.age} * RETURN u.user * \`.toArray(); * } * `); * * const result = await db.executeTransaction("_users", action, { * params: { age: 12 } * }); * // result contains the return value of the action * ``` */ executeTransaction(collection: string | ArangoCollection, action: string, options?: TransactionOptions & { params?: any; }): Promise; /** * Returns a {@link Transaction} instance for an existing streaming * transaction with the given `id`. * * See also {@link Database.beginTransaction}. * * @param id - The `id` of an existing stream transaction. * * @example * ```js * const trx1 = await db.beginTransaction(collections); * const id = trx1.id; * // later * const trx2 = db.transaction(id); * await trx2.commit(); * ``` */ transaction(transactionId: string): Transaction; /** * Begins a new streaming transaction for the given collections, then returns * a {@link Transaction} instance for the transaction. * * Collections can be specified as collection names (strings) or objects * implementing the {@link ArangoCollection} interface: `Collection`, * {@link GraphVertexCollection}, {@link GraphEdgeCollection} as well as * (in TypeScript) {@link DocumentCollection} and {@link EdgeCollection}. * * @param collections - Collections involved in the transaction. * @param options - Options for the transaction. * * @example * ```js * const vertices = db.collection("vertices"); * const edges = db.collection("edges"); * const trx = await db.beginTransaction({ * read: ["vertices"], * write: [edges] // collection instances can be passed directly * }); * const start = await trx.step(() => vertices.document("a")); * const end = await trx.step(() => vertices.document("b")); * await trx.step(() => edges.save({ _from: start._id, _to: end._id })); * await trx.commit(); * ``` */ beginTransaction(collections: TransactionCollections, options?: TransactionOptions): Promise; /** * Begins a new streaming transaction for the given collections, then returns * a {@link Transaction} instance for the transaction. * * Collections can be specified as collection names (strings) or objects * implementing the {@link ArangoCollection} interface: `Collection`, * {@link GraphVertexCollection}, {@link GraphEdgeCollection} as well as * (in TypeScript) {@link DocumentCollection} and {@link EdgeCollection}. * * @param collections - Collections that can be read from and written to * during the transaction. * @param options - Options for the transaction. * * @example * ```js * const vertices = db.collection("vertices"); * const edges = db.collection("edges"); * const trx = await db.beginTransaction([ * "vertices", * edges // collection instances can be passed directly * ]); * const start = await trx.step(() => vertices.document("a")); * const end = await trx.step(() => vertices.document("b")); * await trx.step(() => edges.save({ _from: start._id, _to: end._id })); * await trx.commit(); * ``` */ beginTransaction(collections: (string | ArangoCollection)[], options?: TransactionOptions): Promise; /** * Begins a new streaming transaction for the given collections, then returns * a {@link Transaction} instance for the transaction. * * The Collection can be specified as a collection name (string) or an object * implementing the {@link ArangoCollection} interface: `Collection`, * {@link GraphVertexCollection}, {@link GraphEdgeCollection} as well as * (in TypeScript) {@link DocumentCollection} and {@link EdgeCollection}. * * @param collections - A collection that can be read from and written to * during the transaction. * @param options - Options for the transaction. * * @example * ```js * const vertices = db.collection("vertices"); * const start = vertices.document("a"); * const end = vertices.document("b"); * const edges = db.collection("edges"); * const trx = await db.beginTransaction( * edges // collection instances can be passed directly * ); * await trx.step(() => edges.save({ _from: start._id, _to: end._id })); * await trx.commit(); * ``` */ beginTransaction(collection: string | ArangoCollection, options?: TransactionOptions): Promise; /** * Fetches all active transactions from the database and returns an array of * transaction descriptions. * * See also {@link Database.transactions}. * * @example * ```js * const db = new Database(); * const transactions = await db.listTransactions(); * // transactions is an array of transaction descriptions * ``` */ listTransactions(): Promise; /** * Fetches all active transactions from the database and returns an array of * {@link Transaction} instances for those transactions. * * See also {@link Database.listTransactions}. * * @example * ```js * const db = new Database(); * const transactions = await db.transactions(); * // transactions is an array of transactions * ``` */ transactions(): Promise; /** * Performs a database query using the given `query`, then returns a new * {@link ArrayCursor} instance for the result set. * * See the {@link aql} template string handler for information about how * to create a query string without manually defining bind parameters nor * having to worry about escaping variables. * * @param query - An object containing an AQL query string and bind * parameters, e.g. the object returned from an {@link aql} template string. * @param options - Options for the query execution. * * @example * ```js * const db = new Database(); * const active = true; * * // Using an aql template string * const cursor = await db.query(aql` * FOR u IN _users * FILTER u.authData.active == ${active} * RETURN u.user * `); * // cursor is a cursor for the query result * ``` * * @example * ```js * const db = new Database(); * const active = true; * * // Using an object with a regular multi-line string * const cursor = await db.query({ * query: ` * FOR u IN _users * FILTER u.authData.active == @active * RETURN u.user * `, * bindVars: { active: active } * }); * ``` */ query(query: AqlQuery, options?: QueryOptions): Promise; /** * Performs a database query using the given `query` and `bindVars`, then * returns a new {@link ArrayCursor} instance for the result set. * * See the {@link aql} template string handler for a safer and easier * alternative to passing strings directly. * * @param query - An AQL query string. * @param bindVars - An object defining bind parameters for the query. * @param options - Options for the query execution. * * @example * ```js * const db = new Database(); * const active = true; * * const cursor = await db.query( * // A normal multi-line string * ` * FOR u IN _users * FILTER u.authData.active == @active * RETURN u.user * `, * { active: active } * ); * ``` * * @example * ```js * const db = new Database(); * const active = true; * * const cursor = await db.query( * // An AQL literal created from a normal multi-line string * aql.literal(` * FOR u IN _users * FILTER u.authData.active == @active * RETURN u.user * `), * { active: active } * ); * ``` */ query(query: string | AqlLiteral, bindVars?: Record, options?: QueryOptions): Promise; /** * Explains a database query using the given `query`. * * See the {@link aql} template string handler for information about how * to create a query string without manually defining bind parameters nor * having to worry about escaping variables. * * @param query - An object containing an AQL query string and bind * parameters, e.g. the object returned from an {@link aql} template string. * @param options - Options for explaining the query. * * @example * ```js * const db = new Database(); * const collection = db.collection("some-collection"); * const explanation = await db.explain(aql` * FOR doc IN ${collection} * FILTER doc.flavor == "strawberry" * RETURN doc._key * `); * ``` */ explain(query: AqlQuery, options?: ExplainOptions & { allPlans?: false; }): Promise; /** * Explains a database query using the given `query`. * * See the {@link aql} template string handler for information about how * to create a query string without manually defining bind parameters nor * having to worry about escaping variables. * * @param query - An object containing an AQL query string and bind * parameters, e.g. the object returned from an {@link aql} template string. * @param options - Options for explaining the query. * * @example * ```js * const db = new Database(); * const collection = db.collection("some-collection"); * const explanation = await db.explain( * aql` * FOR doc IN ${collection} * FILTER doc.flavor == "strawberry" * RETURN doc._key * `, * { allPlans: true } * ); * ``` */ explain(query: AqlQuery, options?: ExplainOptions & { allPlans: true; }): Promise; /** * Explains a database query using the given `query` and `bindVars`. * * See the {@link aql} template string handler for a safer and easier * alternative to passing strings directly. * * @param query - An AQL query string. * @param bindVars - An object defining bind parameters for the query. * @param options - Options for explaining the query. * * @example * ```js * const db = new Database(); * const collection = db.collection("some-collection"); * const explanation = await db.explain( * ` * FOR doc IN @@collection * FILTER doc.flavor == "strawberry" * RETURN doc._key * `, * { "@collection": collection.name } * ); * ``` */ explain(query: string | AqlLiteral, bindVars?: Record, options?: ExplainOptions & { allPlans?: false; }): Promise; /** * Explains a database query using the given `query` and `bindVars`. * * See the {@link aql} template string handler for a safer and easier * alternative to passing strings directly. * * @param query - An AQL query string. * @param bindVars - An object defining bind parameters for the query. * @param options - Options for explaining the query. * * @example * ```js * const db = new Database(); * const collection = db.collection("some-collection"); * const explanation = await db.explain( * ` * FOR doc IN @@collection * FILTER doc.flavor == "strawberry" * RETURN doc._key * `, * { "@collection": collection.name }, * { allPlans: true } * ); * ``` */ explain(query: string | AqlLiteral, bindVars?: Record, options?: ExplainOptions & { allPlans: true; }): Promise; /** * Parses the given query and returns the result. * * See the {@link aql} template string handler for information about how * to create a query string without manually defining bind parameters nor * having to worry about escaping variables. * * @param query - An AQL query string or an object containing an AQL query * string and bind parameters, e.g. the object returned from an {@link aql} * template string. * * @example * ```js * const db = new Database(); * const collection = db.collection("some-collection"); * const ast = await db.parse(aql` * FOR doc IN ${collection} * FILTER doc.flavor == "strawberry" * RETURN doc._key * `); * ``` */ parse(query: string | AqlQuery | AqlLiteral): Promise; /** * Fetches the query tracking properties. * * @example * ```js * const db = new Database(); * const tracking = await db.queryTracking(); * console.log(tracking.enabled); * ``` */ queryTracking(): Promise; /** * Modifies the query tracking properties. * * @param options - Options for query tracking. * * @example * ```js * const db = new Database(); * // track up to 5 slow queries exceeding 5 seconds execution time * await db.setQueryTracking({ * enabled: true, * trackSlowQueries: true, * maxSlowQueries: 5, * slowQueryThreshold: 5 * }); * ``` */ queryTracking(options: QueryTrackingOptions): Promise; /** * Fetches a list of information for all currently running queries. * * See also {@link Database.listSlowQueries} and {@link Database.killQuery}. * * @example * ```js * const db = new Database(); * const queries = await db.listRunningQueries(); * ``` */ listRunningQueries(): Promise; /** * Fetches a list of information for all recent slow queries. * * See also {@link Database.listRunningQueries} and * {@link Database.clearSlowQueries}. * * @example * ```js * const db = new Database(); * const queries = await db.listSlowQueries(); * // Only works if slow query tracking is enabled * ``` */ listSlowQueries(): Promise; /** * Clears the list of recent slow queries. * * See also {@link Database.listSlowQueries}. * * @example * ```js * const db = new Database(); * await db.clearSlowQueries(); * // Slow query list is now cleared * ``` */ clearSlowQueries(): Promise; /** * Kills a running query with the given `queryId`. * * See also {@link Database.listRunningQueries}. * * @param queryId - The ID of a currently running query. * * @example * ```js * const db = new Database(); * const queries = await db.listRunningQueries(); * await Promise.all(queries.map( * async (query) => { * if (query.state === "executing") { * await db.killQuery(query.id); * } * } * )); * ``` */ killQuery(queryId: string): Promise; /** * Fetches a list of all AQL user functions registered with the database. * * @example * ```js * const db = new Database(); * const functions = await db.listFunctions(); * const names = functions.map(fn => fn.name); * ``` */ listFunctions(): Promise; /** * Creates an AQL user function with the given _name_ and _code_ if it does * not already exist or replaces it if a function with the same name already * existed. * * @param name - A valid AQL function name. The function name must consist * of at least two alphanumeric identifiers separated with double colons. * @param code - A string evaluating to a JavaScript function (not a * JavaScript function object). * @param isDeterministic - If set to `true`, the function is expected to * always return the same result for equivalent inputs. This option currently * has no effect but may allow for optimizations in the future. * * @example * ```js * const db = new Database(); * await db.createFunction( * "ACME::ACCOUNTING::CALCULATE_VAT", * "(price) => price * 0.19" * ); * // Use the new function in an AQL query with template handler: * const cursor = await db.query(aql` * FOR product IN products * RETURN MERGE( * { vat: ACME::ACCOUNTING::CALCULATE_VAT(product.price) }, * product * ) * `); * // cursor is a cursor for the query result * ``` */ createFunction(name: string, code: string, isDeterministic?: boolean): Promise; /** * Deletes the AQL user function with the given name from the database. * * @param name - The name of the user function to drop. * @param group - If set to `true`, all functions with a name starting with * `name` will be deleted, otherwise only the function with the exact name * will be deleted. * * @example * ```js * const db = new Database(); * await db.dropFunction("ACME::ACCOUNTING::CALCULATE_VAT"); * // the function no longer exists * ``` */ dropFunction(name: string, group?: boolean): Promise; /** * Fetches a list of all installed service. * * @param excludeSystem - Whether system services should be excluded. * * @example * ```js * const db = new Database(); * const services = await db.listServices(); * ``` * * @example * ```js * const db = new Database(); * const services = await db.listServices(false); // all services * ``` */ listServices(excludeSystem?: boolean): Promise; /** * Installs a new service. * * @param mount - The service's mount point, relative to the database. * @param source - The service bundle to install. * @param options - Options for installing the service. * * @example * ```js * const db = new Database(); * // Using a node.js file stream as source * const source = fs.createReadStream("./my-foxx-service.zip"); * const info = await db.installService("/hello", source); * ``` * * @example * ```js * const db = new Database(); * // Using a node.js Buffer as source * const source = fs.readFileSync("./my-foxx-service.zip"); * const info = await db.installService("/hello", source); * ``` * * @example * ```js * const db = new Database(); * // Using a File (Blob) from a browser file input * const element = document.getElementById("my-file-input"); * const source = element.files[0]; * const info = await db.installService("/hello", source); * ``` */ installService(mount: string, source: Readable | Buffer | Blob | string, options?: InstallServiceOptions): Promise; /** * Replaces an existing service with a new service by completely removing the * old service and installing a new service at the same mount point. * * @param mount - The service's mount point, relative to the database. * @param source - The service bundle to install. * @param options - Options for replacing the service. * * @example * ```js * const db = new Database(); * // Using a node.js file stream as source * const source = fs.createReadStream("./my-foxx-service.zip"); * const info = await db.replaceService("/hello", source); * ``` * * @example * ```js * const db = new Database(); * // Using a node.js Buffer as source * const source = fs.readFileSync("./my-foxx-service.zip"); * const info = await db.replaceService("/hello", source); * ``` * * @example * ```js * const db = new Database(); * // Using a File (Blob) from a browser file input * const element = document.getElementById("my-file-input"); * const source = element.files[0]; * const info = await db.replaceService("/hello", source); * ``` */ replaceService(mount: string, source: Readable | Buffer | Blob | string, options?: ReplaceServiceOptions): Promise; /** * Replaces an existing service with a new service while retaining the old * service's configuration and dependencies. * * @param mount - The service's mount point, relative to the database. * @param source - The service bundle to install. * @param options - Options for upgrading the service. * * @example * ```js * const db = new Database(); * // Using a node.js file stream as source * const source = fs.createReadStream("./my-foxx-service.zip"); * const info = await db.upgradeService("/hello", source); * ``` * * @example * ```js * const db = new Database(); * // Using a node.js Buffer as source * const source = fs.readFileSync("./my-foxx-service.zip"); * const info = await db.upgradeService("/hello", source); * ``` * * @example * ```js * const db = new Database(); * // Using a File (Blob) from a browser file input * const element = document.getElementById("my-file-input"); * const source = element.files[0]; * const info = await db.upgradeService("/hello", source); * ``` */ upgradeService(mount: string, source: Readable | Buffer | Blob | string, options?: UpgradeServiceOptions): Promise; /** * Completely removes a service from the database. * * @param mount - The service's mount point, relative to the database. * @param options - Options for uninstalling the service. * * @example * ```js * const db = new Database(); * await db.uninstallService("/my-foxx"); * ``` */ uninstallService(mount: string, options?: UninstallServiceOptions): Promise; /** * Retrieves information about a mounted service. * * @param mount - The service's mount point, relative to the database. * * @example * ```js * const db = new Database(); * const info = await db.getService("/my-service"); * // info contains detailed information about the service * ``` */ getService(mount: string): Promise; /** * Retrieves information about the service's configuration options and their * current values. * * See also {@link Database.replaceServiceConfiguration} and * {@link Database.updateServiceConfiguration}. * * @param mount - The service's mount point, relative to the database. * @param minimal - If set to `true`, the result will only include each * configuration option's current value. Otherwise it will include the full * definition for each option. * * @example * ```js * const db = new Database(); * const config = await db.getServiceConfiguration("/my-service"); * for (const [key, option] of Object.entries(config)) { * console.log(`${option.title} (${key}): ${option.current}`); * } * ``` */ getServiceConfiguration(mount: string, minimal?: false): Promise>; /** * Retrieves information about the service's configuration options and their * current values. * * See also {@link Database.replaceServiceConfiguration} and * {@link Database.updateServiceConfiguration}. * * @param mount - The service's mount point, relative to the database. * @param minimal - If set to `true`, the result will only include each * configuration option's current value. Otherwise it will include the full * definition for each option. * * @example * ```js * const db = new Database(); * const config = await db.getServiceConfiguration("/my-service", true); * for (const [key, value] of Object.entries(config)) { * console.log(`${key}: ${value}`); * } * ``` */ getServiceConfiguration(mount: string, minimal: true): Promise>; /** * Replaces the configuration of the given service, discarding any existing * values for options not specified. * * See also {@link Database.updateServiceConfiguration} and * {@link Database.getServiceConfiguration}. * * @param mount - The service's mount point, relative to the database. * @param cfg - An object mapping configuration option names to values. * @param minimal - If set to `true`, the result will only include each * configuration option's current value and warning (if any). * Otherwise it will include the full definition for each option. * * **Note**: When using ArangoDB 3.2.8 or older, setting the `minimal` option * to `true` avoids triggering a second request to fetch the full * configuration definitions. * * @example * ```js * const db = new Database(); * const config = { currency: "USD", locale: "en-US" }; * const info = await db.replaceServiceConfiguration("/my-service", config); * for (const [key, option] of Object.entries(info)) { * console.log(`${option.title} (${key}): ${option.value}`); * if (option.warning) console.warn(`Warning: ${option.warning}`); * } * ``` */ replaceServiceConfiguration(mount: string, cfg: Record, minimal?: false): Promise>; /** * Replaces the configuration of the given service, discarding any existing * values for options not specified. * * See also {@link Database.updateServiceConfiguration} and * {@link Database.getServiceConfiguration}. * * @param mount - The service's mount point, relative to the database. * @param cfg - An object mapping configuration option names to values. * @param minimal - If set to `true`, the result will only include each * configuration option's current value and warning (if any). * Otherwise it will include the full definition for each option. * * **Note**: When using ArangoDB 3.2.8 or older, setting the `minimal` option * to `true` avoids triggering a second request to fetch the full * configuration definitions. * * @example * ```js * const db = new Database(); * const config = { currency: "USD", locale: "en-US" }; * const info = await db.replaceServiceConfiguration("/my-service", config); * for (const [key, value] of Object.entries(info.values)) { * console.log(`${key}: ${value}`); * if (info.warnings[key]) console.warn(`Warning: ${info.warnings[key]}`); * } * ``` */ replaceServiceConfiguration(mount: string, cfg: Record, minimal: true): Promise<{ values: Record; warnings: Record; }>; /** * Updates the configuration of the given service while maintaining any * existing values for options not specified. * * See also {@link Database.replaceServiceConfiguration} and * {@link Database.getServiceConfiguration}. * * @param mount - The service's mount point, relative to the database. * @param cfg - An object mapping configuration option names to values. * @param minimal - If set to `true`, the result will only include each * configuration option's current value and warning (if any). * Otherwise it will include the full definition for each option. * * **Note**: When using ArangoDB 3.2.8 or older, setting the `minimal` option * to `true` avoids triggering a second request to fetch the full * configuration definitions. * * @example * ```js * const db = new Database(); * const config = { currency: "USD", locale: "en-US" }; * const info = await db.updateServiceConfiguration("/my-service", config); * for (const [key, option] of Object.entries(info)) { * console.log(`${option.title} (${key}): ${option.value}`); * if (option.warning) console.warn(`Warning: ${option.warning}`); * } * ``` */ updateServiceConfiguration(mount: string, cfg: Record, minimal?: false): Promise>; /** * Updates the configuration of the given service while maintaining any * existing values for options not specified. * * See also {@link Database.replaceServiceConfiguration} and * {@link Database.getServiceConfiguration}. * * @param mount - The service's mount point, relative to the database. * @param cfg - An object mapping configuration option names to values. * @param minimal - If set to `true`, the result will only include each * configuration option's current value and warning (if any). * Otherwise it will include the full definition for each option. * * **Note**: When using ArangoDB 3.2.8 or older, setting the `minimal` option * to `true` avoids triggering a second request to fetch the full * configuration definitions. * * @example * ```js * const db = new Database(); * const config = { currency: "USD", locale: "en-US" }; * const info = await db.updateServiceConfiguration("/my-service", config); * for (const [key, value] of Object.entries(info.values)) { * console.log(`${key}: ${value}`); * if (info.warnings[key]) console.warn(`Warning: ${info.warnings[key]}`); * } * ``` */ updateServiceConfiguration(mount: string, cfg: Record, minimal: true): Promise<{ values: Record; warnings: Record; }>; /** * Retrieves information about the service's dependencies and their current * mount points. * * See also {@link Database.replaceServiceDependencies} and * {@link Database.updateServiceDependencies}. * * @param mount - The service's mount point, relative to the database. * @param minimal - If set to `true`, the result will only include each * dependency's current mount point. Otherwise it will include the full * definition for each dependency. * * @example * ```js * const db = new Database(); * const deps = await db.getServiceDependencies("/my-service"); * for (const [key, dep] of Object.entries(deps)) { * console.log(`${dep.title} (${key}): ${dep.current}`); * } * ``` */ getServiceDependencies(mount: string, minimal?: false): Promise>; /** * Retrieves information about the service's dependencies and their current * mount points. * * See also {@link Database.replaceServiceDependencies} and * {@link Database.updateServiceDependencies}. * * @param mount - The service's mount point, relative to the database. * @param minimal - If set to `true`, the result will only include each * dependency's current mount point. Otherwise it will include the full * definition for each dependency. * * @example * ```js * const db = new Database(); * const deps = await db.getServiceDependencies("/my-service", true); * for (const [key, value] of Object.entries(deps)) { * console.log(`${key}: ${value}`); * } * ``` */ getServiceDependencies(mount: string, minimal: true): Promise>; /** * Replaces the dependencies of the given service, discarding any existing * mount points for dependencies not specified. * * See also {@link Database.updateServiceDependencies} and * {@link Database.getServiceDependencies}. * * @param mount - The service's mount point, relative to the database. * @param cfg - An object mapping dependency aliases to mount points. * @param minimal - If set to `true`, the result will only include each * dependency's current mount point. Otherwise it will include the full * definition for each dependency. * * **Note**: When using ArangoDB 3.2.8 or older, setting the `minimal` option * to `true` avoids triggering a second request to fetch the full * dependency definitions. * * @example * ```js * const db = new Database(); * const deps = { mailer: "/mailer-api", auth: "/remote-auth" }; * const info = await db.replaceServiceDependencies("/my-service", deps); * for (const [key, dep] of Object.entries(info)) { * console.log(`${dep.title} (${key}): ${dep.current}`); * if (dep.warning) console.warn(`Warning: ${dep.warning}`); * } * ``` */ replaceServiceDependencies(mount: string, deps: Record, minimal?: false): Promise>; /** * Replaces the dependencies of the given service, discarding any existing * mount points for dependencies not specified. * * See also {@link Database.updateServiceDependencies} and * {@link Database.getServiceDependencies}. * * @param mount - The service's mount point, relative to the database. * @param cfg - An object mapping dependency aliases to mount points. * @param minimal - If set to `true`, the result will only include each * dependency's current mount point. Otherwise it will include the full * definition for each dependency. * * **Note**: When using ArangoDB 3.2.8 or older, setting the `minimal` option * to `true` avoids triggering a second request to fetch the full * dependency definitions. * * @example * ```js * const db = new Database(); * const deps = { mailer: "/mailer-api", auth: "/remote-auth" }; * const info = await db.replaceServiceDependencies( * "/my-service", * deps, * true * ); * for (const [key, value] of Object.entries(info)) { * console.log(`${key}: ${value}`); * if (info.warnings[key]) console.warn(`Warning: ${info.warnings[key]}`); * } * ``` */ replaceServiceDependencies(mount: string, deps: Record, minimal: true): Promise<{ values: Record; warnings: Record; }>; /** * Updates the dependencies of the given service while maintaining any * existing mount points for dependencies not specified. * * See also {@link Database.replaceServiceDependencies} and * {@link Database.getServiceDependencies}. * * @param mount - The service's mount point, relative to the database. * @param cfg - An object mapping dependency aliases to mount points. * @param minimal - If set to `true`, the result will only include each * dependency's current mount point. Otherwise it will include the full * definition for each dependency. * * **Note**: When using ArangoDB 3.2.8 or older, setting the `minimal` option * to `true` avoids triggering a second request to fetch the full * dependency definitions. * * @example * ```js * const db = new Database(); * const deps = { mailer: "/mailer-api", auth: "/remote-auth" }; * const info = await db.updateServiceDependencies("/my-service", deps); * for (const [key, dep] of Object.entries(info)) { * console.log(`${dep.title} (${key}): ${dep.current}`); * if (dep.warning) console.warn(`Warning: ${dep.warning}`); * } * ``` */ updateServiceDependencies(mount: string, deps: Record, minimal?: false): Promise>; /** * Updates the dependencies of the given service while maintaining any * existing mount points for dependencies not specified. * * See also {@link Database.replaceServiceDependencies} and * {@link Database.getServiceDependencies}. * * @param mount - The service's mount point, relative to the database. * @param cfg - An object mapping dependency aliases to mount points. * @param minimal - If set to `true`, the result will only include each * dependency's current mount point. Otherwise it will include the full * definition for each dependency. * * **Note**: When using ArangoDB 3.2.8 or older, setting the `minimal` option * to `true` avoids triggering a second request to fetch the full * dependency definitions. * * @example * ```js * const db = new Database(); * const deps = { mailer: "/mailer-api", auth: "/remote-auth" }; * const info = await db.updateServiceDependencies( * "/my-service", * deps, * true * ); * for (const [key, value] of Object.entries(info)) { * console.log(`${key}: ${value}`); * if (info.warnings[key]) console.warn(`Warning: ${info.warnings[key]}`); * } * ``` */ updateServiceDependencies(mount: string, deps: Record, minimal: true): Promise<{ values: Record; warnings: Record; }>; /** * Enables or disables development mode for the given service. * * @param mount - The service's mount point, relative to the database. * @param enabled - Whether development mode should be enabled or disabled. * * @example * ```js * const db = new Database(); * await db.setServiceDevelopmentMode("/my-service", true); * // the service is now in development mode * await db.setServiceDevelopmentMode("/my-service", false); * // the service is now in production mode * ``` */ setServiceDevelopmentMode(mount: string, enabled?: boolean): Promise; /** * Retrieves a list of scripts defined in the service manifest's "scripts" * section mapped to their human readable representations. * * @param mount - The service's mount point, relative to the database. * * @example * ```js * const db = new Database(); * const scripts = await db.listServiceScripts("/my-service"); * for (const [name, title] of Object.entries(scripts)) { * console.log(`${name}: ${title}`); * } * ``` */ listServiceScripts(mount: string): Promise>; /** * Executes a service script and retrieves its result exposed as * `module.exports` (if any). * * @param mount - The service's mount point, relative to the database. * @param name - Name of the service script to execute as defined in the * service manifest. * @param params - Arbitrary value that will be exposed to the script as * `argv[0]` in the service context (e.g. `module.context.argv[0]`). * Must be serializable to JSON. * * @example * ```js * const db = new Database(); * const result = await db.runServiceScript( * "/my-service", * "create-user", * { * username: "service_admin", * password: "hunter2" * } * ); * ``` */ runServiceScript(mount: string, name: string, params?: any): Promise; /** * Runs the tests of a given service and returns the results using the * "default" reporter. * * @param mount - The service's mount point, relative to the database. * @param options - Options for running the tests. * * @example * ```js * const db = new Database(); * const testReport = await db.runServiceTests("/my-foxx"); * ``` */ runServiceTests(mount: string, options?: { reporter?: "default"; /** * Whether the reporter should use "idiomatic" mode. Has no effect when * using the "default" or "suite" reporters. */ idiomatic?: false; /** * If set, only tests with full names including this exact string will be * executed. */ filter?: string; }): Promise; /** * Runs the tests of a given service and returns the results using the * "suite" reporter, which groups the test result by test suite. * * @param mount - The service's mount point, relative to the database. * @param options - Options for running the tests. * * @example * ```js * const db = new Database(); * const suiteReport = await db.runServiceTests( * "/my-foxx", * { reporter: "suite" } * ); * ``` */ runServiceTests(mount: string, options: { reporter: "suite"; /** * Whether the reporter should use "idiomatic" mode. Has no effect when * using the "default" or "suite" reporters. */ idiomatic?: false; /** * If set, only tests with full names including this exact string will be * executed. */ filter?: string; }): Promise; /** * Runs the tests of a given service and returns the results using the * "stream" reporter, which represents the results as a sequence of tuples * representing events. * * @param mount - The service's mount point, relative to the database. * @param options - Options for running the tests. * * @example * ```js * const db = new Database(); * const streamEvents = await db.runServiceTests( * "/my-foxx", * { reporter: "stream" } * ); * ``` */ runServiceTests(mount: string, options: { reporter: "stream"; /** * Whether the reporter should use "idiomatic" mode. If set to `true`, * the results will be returned as a formatted string. */ idiomatic?: false; /** * If set, only tests with full names including this exact string will be * executed. */ filter?: string; }): Promise; /** * Runs the tests of a given service and returns the results using the * "tap" reporter, which represents the results as an array of strings using * the "tap" format. * * @param mount - The service's mount point, relative to the database. * @param options - Options for running the tests. * * @example * ```js * const db = new Database(); * const tapLines = await db.runServiceTests( * "/my-foxx", * { reporter: "tap" } * ); * ``` */ runServiceTests(mount: string, options: { reporter: "tap"; /** * Whether the reporter should use "idiomatic" mode. If set to `true`, * the results will be returned as a formatted string. */ idiomatic?: false; /** * If set, only tests with full names including this exact string will be * executed. */ filter?: string; }): Promise; /** * Runs the tests of a given service and returns the results using the * "xunit" reporter, which represents the results as an XML document using * the JSONML exchange format. * * @param mount - The service's mount point, relative to the database. * @param options - Options for running the tests. * * @example * ```js * const db = new Database(); * const jsonML = await db.runServiceTests( * "/my-foxx", * { reporter: "xunit" } * ); * ``` */ runServiceTests(mount: string, options: { reporter: "xunit"; /** * Whether the reporter should use "idiomatic" mode. If set to `true`, * the results will be returned as a formatted string. */ idiomatic?: false; /** * If set, only tests with full names including this exact string will be * executed. */ filter?: string; }): Promise; /** * Runs the tests of a given service and returns the results as a string * using the "stream" reporter in "idiomatic" mode, which represents the * results as a line-delimited JSON stream of tuples representing events. * * @param mount - The service's mount point, relative to the database. * @param options - Options for running the tests. * * @example * ```js * const db = new Database(); * const streamReport = await db.runServiceTests( * "/my-foxx", * { reporter: "stream", idiomatic: true } * ); * ``` */ runServiceTests(mount: string, options: { reporter: "stream"; /** * Whether the reporter should use "idiomatic" mode. If set to `false`, * the results will be returned as an array of tuples instead of a * string. */ idiomatic: true; /** * If set, only tests with full names including this exact string will be * executed. */ filter?: string; }): Promise; /** * Runs the tests of a given service and returns the results as a string * using the "tap" reporter in "idiomatic" mode, which represents the * results using the "tap" format. * * @param mount - The service's mount point, relative to the database. * @param options - Options for running the tests. * * @example * ```js * const db = new Database(); * const tapReport = await db.runServiceTests( * "/my-foxx", * { reporter: "tap", idiomatic: true } * ); * ``` */ runServiceTests(mount: string, options: { reporter: "tap"; /** * Whether the reporter should use "idiomatic" mode. If set to `false`, * the results will be returned as an array of strings instead of a * single string. */ idiomatic: true; /** * If set, only tests with full names including this exact string will be * executed. */ filter?: string; }): Promise; /** * Runs the tests of a given service and returns the results as a string * using the "xunit" reporter in "idiomatic" mode, which represents the * results as an XML document. * * @param mount - The service's mount point, relative to the database. * @param options - Options for running the tests. * * @example * ```js * const db = new Database(); * const xml = await db.runServiceTests( * "/my-foxx", * { reporter: "xunit", idiomatic: true } * ); * ``` */ runServiceTests(mount: string, options: { reporter: "xunit"; /** * Whether the reporter should use "idiomatic" mode. If set to `false`, * the results will be returned using the JSONML exchange format * instead of a string. */ idiomatic: true; /** * If set, only tests with full names including this exact string will be * executed. */ filter?: string; }): Promise; /** * Retrieves the text content of the service's `README` or `README.md` file. * * Returns `undefined` if no such file could be found. * * @param mount - The service's mount point, relative to the database. * * @example * ```js * const db = new Database(); * const readme = await db.getServiceReadme("/my-service"); * if (readme !== undefined) console.log(readme); * else console.warn(`No README found.`) * ``` */ getServiceReadme(mount: string): Promise; /** * Retrieves an Open API compatible Swagger API description object for the * service installed at the given mount point. * * @param mount - The service's mount point, relative to the database. * * @example * ```js * const db = new Database(); * const spec = await db.getServiceDocumentation("/my-service"); * // spec is a Swagger API description of the service * ``` */ getServiceDocumentation(mount: string): Promise; /** * Retrieves a zip bundle containing the service files. * * Returns a `Buffer` in node.js or `Blob` in the browser. * * @param mount - The service's mount point, relative to the database. * * @example * ```js * const db = new Database(); * const serviceBundle = await db.downloadService("/my-foxx"); * ``` */ downloadService(mount: string): Promise; /** * Writes all locally available services to the database and updates any * service bundles missing in the database. * * @param replace - If set to `true`, outdated services will also be * committed. This can be used to solve some consistency problems when * service bundles are missing in the database or were deleted manually. * * @example * ```js * await db.commitLocalServiceState(); * // all services available on the coordinator have been written to the db * ``` * * @example * ```js * await db.commitLocalServiceState(true); * // all service conflicts have been resolved in favor of this coordinator * ``` */ commitLocalServiceState(replace?: boolean): Promise; } //# sourceMappingURL=database.d.ts.map