arangojs 10.2.1 → 10.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/cjs/connection.d.ts.map +1 -1
- package/cjs/connection.js +3 -1
- package/cjs/connection.js.map +1 -1
- package/cjs/databases.d.ts.map +1 -1
- package/cjs/databases.js +11 -1
- package/cjs/databases.js.map +1 -1
- package/cjs/indexes.d.ts +26 -0
- package/cjs/indexes.d.ts.map +1 -1
- package/cjs/indexes.js.map +1 -1
- package/cjs/queries.d.ts +71 -1
- package/cjs/queries.d.ts.map +1 -1
- package/cjs/queries.js.map +1 -1
- package/connection.d.ts.map +1 -1
- package/databases.d.ts.map +1 -1
- package/esm/connection.d.ts.map +1 -1
- package/esm/connection.js +3 -1
- package/esm/connection.js.map +1 -1
- package/esm/databases.d.ts.map +1 -1
- package/esm/databases.js +11 -1
- package/esm/databases.js.map +1 -1
- package/esm/indexes.d.ts +26 -0
- package/esm/indexes.d.ts.map +1 -1
- package/esm/indexes.js.map +1 -1
- package/esm/queries.d.ts +71 -1
- package/esm/queries.d.ts.map +1 -1
- package/esm/queries.js.map +1 -1
- package/indexes.d.ts +26 -0
- package/indexes.d.ts.map +1 -1
- package/package.json +1 -1
- package/queries.d.ts +71 -1
- package/queries.d.ts.map +1 -1
package/cjs/databases.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"databases.js","sourceRoot":"","sources":["../../src/databases.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,0DAA4C;AAC5C,8CAAgC;AAEhC,8DAAgD;AAEhD,4DAA8C;AAC9C,sDAAwC;AACxC,oDAAsC;AACtC,oDAAsC;AAEtC,gDAAkC;AAClC,6CAAoD;AACpD,oDAAsC;AAGtC,oDAAsC;AAEtC,gEAAkD;AAElD,kDAAoC;AA4FpC,wBAAwB;AACxB;;;;GAIG;AACH,SAAgB,gBAAgB,CAA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,CACjB;YACE,QAAQ,EAAE,mBAAmB;SAC9B,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CACxB,CAAC;IACJ,CAAC;IAED;;;;;;;;;OASG;IACH,iBAAiB;QACf,OAAO,IAAI,CAAC,OAAO,CACjB;YACE,QAAQ,EAAE,gBAAgB;SAC3B,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CACxB,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,uBAAuB,CAAC,SAAiB;QACvC,OAAO,IAAI,CAAC,OAAO,CACjB;YACE,MAAM,EAAE,QAAQ;YAChB,QAAQ,EAAE,mBAAmB;YAC7B,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,EAAE;SACpC,EACD,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,mBAAmB;QACjB,OAAO,IAAI,CAAC,OAAO,CACjB;YACE,MAAM,EAAE,QAAQ;YAChB,QAAQ,EAAE,eAAe;SAC1B,EACD,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;IACJ,CAAC;CAEF;AApvJD,4BAovJC;AACD,YAAY","sourcesContent":["/**\r\n * ```js\r\n * import { Database } from \"arangojs/databases\";\r\n * ```\r\n *\r\n * The \"databases\" module provides the {@link Database} class and associated\r\n * types and interfaces for TypeScript.\r\n *\r\n * The Database class is also re-exported by the \"index\" module.\r\n *\r\n * @packageDocumentation\r\n */\r\nimport * as administration from \"./administration.js\";\r\nimport * as analyzers from \"./analyzers.js\";\r\nimport * as aql from \"./aql.js\";\r\nimport * as cluster from \"./cluster.js\";\r\nimport * as collections from \"./collections.js\";\r\nimport * as configuration from \"./configuration.js\";\r\nimport * as connection from \"./connection.js\";\r\nimport * as cursors from \"./cursors.js\";\r\nimport * as errors from \"./errors.js\";\r\nimport * as graphs from \"./graphs.js\";\r\nimport * as hotBackups from \"./hot-backups.js\";\r\nimport * as jobs from \"./jobs.js\";\r\nimport { DATABASE_NOT_FOUND } from \"./lib/codes.js\";\r\nimport * as util from \"./lib/util.js\";\r\nimport * as logs from \"./logs.js\";\r\nimport * as queries from \"./queries.js\";\r\nimport * as routes from \"./routes.js\";\r\nimport * as services from \"./services.js\";\r\nimport * as transactions from \"./transactions.js\";\r\nimport * as users from \"./users.js\";\r\nimport * as views from \"./views.js\";\r\n\r\n//#region Database operation options\r\n/**\r\n * Options for creating a database.\r\n *\r\n * See {@link Database#createDatabase}.\r\n */\r\nexport type CreateDatabaseOptions = {\r\n /**\r\n * Database users to create with the database.\r\n */\r\n users?: users.CreateDatabaseUserOptions[];\r\n /**\r\n * (Cluster only.) The sharding method to use for new collections in the\r\n * database.\r\n */\r\n sharding?: \"\" | \"flexible\" | \"single\";\r\n /**\r\n * (Cluster only.) Default replication factor for new collections in this\r\n * database.\r\n *\r\n * Setting this to `1` disables replication. Setting this to `\"satellite\"`\r\n * will replicate to every DBServer.\r\n */\r\n replicationFactor?: \"satellite\" | number;\r\n /**\r\n * (Cluster only.) Default write concern for new collections created in this\r\n * database.\r\n */\r\n writeConcern?: number;\r\n};\r\n//#endregion\r\n\r\n//#region DatabaseDescription\r\n/**\r\n * Object describing a database.\r\n *\r\n * See {@link Database#get}.\r\n */\r\nexport type DatabaseDescription = {\r\n /**\r\n * Name of the database.\r\n */\r\n name: string;\r\n /**\r\n * Unique identifier of the database.\r\n */\r\n id: string;\r\n /**\r\n * File system path of the database.\r\n */\r\n path: string;\r\n /**\r\n * Whether the database is the system database.\r\n */\r\n isSystem: boolean;\r\n /**\r\n * (Cluster only.) The sharding method to use for new collections in the\r\n * database.\r\n */\r\n sharding?: \"\" | \"flexible\" | \"single\";\r\n /**\r\n * (Cluster only.) Default replication factor for new collections in this\r\n * database.\r\n */\r\n replicationFactor?: \"satellite\" | number;\r\n /**\r\n * (Cluster only.) Default write concern for new collections created in this\r\n * database.\r\n */\r\n writeConcern?: number;\r\n};\r\n//#endregion\r\n\r\n/**\r\n * @internal\r\n */\r\ntype TrappedError = {\r\n error: true;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\ntype TrappedRequest<T = any> = {\r\n error?: false;\r\n jobId: string;\r\n onResolve: (res: connection.ProcessedResponse<T>) => void;\r\n onReject: (error: any) => void;\r\n};\r\n\r\n//#region Database class\r\n/**\r\n * Indicates whether the given value represents a {@link Database}.\r\n *\r\n * @param database - A value that might be a database.\r\n */\r\nexport function isArangoDatabase(database: any): database is Database {\r\n return Boolean(database && database.isArangoDatabase);\r\n}\r\n\r\n/**\r\n * An object representing a single ArangoDB database. All arangojs collections,\r\n * cursors, analyzers and so on are linked to a `Database` object.\r\n */\r\nexport class Database {\r\n protected _connection: connection.Connection;\r\n protected _name: string;\r\n protected _analyzers = new Map<string, analyzers.Analyzer>();\r\n protected _collections = new Map<string, collections.Collection>();\r\n protected _graphs = new Map<string, graphs.Graph>();\r\n protected _views = new Map<string, views.View>();\r\n protected _trapRequest?: (\r\n trapped: TrappedError | TrappedRequest<any>\r\n ) => void;\r\n\r\n /**\r\n * Creates a new `Database` instance with its own connection pool.\r\n *\r\n * See also {@link Database#database}.\r\n *\r\n * @param config - An object with configuration options.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database({\r\n * url: \"http://127.0.0.1:8529\",\r\n * databaseName: \"my_database\",\r\n * auth: { username: \"admin\", password: \"hunter2\" },\r\n * });\r\n * ```\r\n */\r\n constructor(config?: configuration.ConfigOptions);\r\n /**\r\n * Creates a new `Database` instance with its own connection pool.\r\n *\r\n * See also {@link Database#database}.\r\n *\r\n * @param url - Base URL of the ArangoDB server or list of server URLs.\r\n * Equivalent to the `url` option in {@link configuration.ConfigOptions}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database(\"http://127.0.0.1:8529\", \"my_database\");\r\n * db.useBasicAuth(\"admin\", \"hunter2\");\r\n * ```\r\n */\r\n constructor(url: string | string[], name?: string);\r\n /**\r\n * @internal\r\n */\r\n constructor(database: Database, name?: string);\r\n constructor(\r\n configOrDatabase:\r\n | string\r\n | string[]\r\n | configuration.ConfigOptions\r\n | Database = {},\r\n name?: string\r\n ) {\r\n if (isArangoDatabase(configOrDatabase)) {\r\n const connection = configOrDatabase._connection;\r\n const databaseName = name || configOrDatabase.name;\r\n this._connection = connection;\r\n this._name = databaseName;\r\n const database = connection.database(databaseName);\r\n if (database) return database;\r\n } else {\r\n const config = configOrDatabase;\r\n const { databaseName, ...options } =\r\n typeof config === \"string\" || Array.isArray(config)\r\n ? { databaseName: name, url: config }\r\n : config;\r\n this._connection = new connection.Connection(options);\r\n this._name = databaseName || \"_system\";\r\n }\r\n }\r\n\r\n //#region misc\r\n /**\r\n * @internal\r\n *\r\n * Indicates that this object represents an ArangoDB database.\r\n */\r\n get isArangoDatabase(): true {\r\n return true;\r\n }\r\n\r\n /**\r\n * Name of the ArangoDB database this instance represents.\r\n */\r\n get name() {\r\n return this._name;\r\n }\r\n\r\n /**\r\n * Returns a new {@link routes.Route} instance for the given path (relative to the\r\n * database) that can be used to perform arbitrary HTTP requests.\r\n *\r\n * @param path - The database-relative URL of the route. Defaults to the\r\n * database API root.\r\n * @param headers - Default headers that should be sent with each request to\r\n * the route.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const myFoxxService = db.route(\"my-foxx-service\");\r\n * const response = await myFoxxService.post(\"users\", {\r\n * username: \"admin\",\r\n * password: \"hunter2\"\r\n * });\r\n * // response.body is the result of\r\n * // POST /_db/_system/my-foxx-service/users\r\n * // with JSON request body '{\"username\": \"admin\", \"password\": \"hunter2\"}'\r\n * ```\r\n */\r\n route(\r\n path?: string,\r\n headers?: Headers | Record<string, string>\r\n ): routes.Route {\r\n return new routes.Route(this, path, headers);\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Performs an arbitrary HTTP request against the database.\r\n *\r\n * @param BodyType - Type of the expected response body.\r\n * @param ReturnType - Type the response body will be transformed to.\r\n * @param options - Options for this request.\r\n * @param transform - An optional function to transform the low-level\r\n * response object to a more useful return value.\r\n */\r\n async request<BodyType = any, ReturnType = BodyType>(\r\n options: connection.RequestOptions,\r\n transform?: (res: connection.ProcessedResponse<BodyType>) => ReturnType\r\n ): Promise<ReturnType>;\r\n /**\r\n * @internal\r\n *\r\n * Performs an arbitrary HTTP request against the database.\r\n *\r\n * @param BodyType - Type of the expected response body.\r\n * @param options - Options for this request.\r\n * @param transform - If set to `false`, the raw response object will be\r\n * returned.\r\n */\r\n async request<BodyType = any>(\r\n options: connection.RequestOptions,\r\n transform: false\r\n ): Promise<connection.ProcessedResponse<BodyType>>;\r\n async request<BodyType = any, ReturnType = BodyType>(\r\n { pathname, ...opts }: connection.RequestOptions,\r\n transform:\r\n | false\r\n | ((res: connection.ProcessedResponse<BodyType>) => ReturnType) = (res) =>\r\n res.parsedBody as ReturnType\r\n ): Promise<ReturnType> {\r\n pathname = util.joinPath(\"_db\", encodeURIComponent(this._name), pathname);\r\n if (this._trapRequest) {\r\n const trap = this._trapRequest;\r\n this._trapRequest = undefined;\r\n return new Promise<ReturnType>(async (resolveRequest, rejectRequest) => {\r\n opts.headers = new Headers(opts.headers);\r\n opts.headers.set(\"x-arango-async\", \"store\");\r\n let jobRes: connection.ProcessedResponse<any>;\r\n try {\r\n jobRes = await this._connection.request({ pathname, ...opts });\r\n } catch (e) {\r\n trap({ error: true });\r\n rejectRequest(e);\r\n return;\r\n }\r\n const jobId = jobRes.headers.get(\"x-arango-async-id\")!;\r\n trap({\r\n jobId,\r\n onResolve: (res) => {\r\n const result = transform ? transform(res) : (res as ReturnType);\r\n resolveRequest(result);\r\n return result;\r\n },\r\n onReject: (err) => {\r\n rejectRequest(err);\r\n throw err;\r\n },\r\n });\r\n });\r\n }\r\n return this._connection.request(\r\n { pathname, ...opts },\r\n transform || undefined\r\n );\r\n }\r\n\r\n /**\r\n * Updates the URL list by requesting a list of all coordinators in the\r\n * cluster and adding any endpoints not initially specified in the\r\n * {@link configuration.ConfigOptions}.\r\n *\r\n * For long-running processes communicating with an ArangoDB cluster it is\r\n * recommended to run this method periodically (e.g. once per hour) to make\r\n * sure new coordinators are picked up correctly and can be used for\r\n * fail-over or load balancing.\r\n *\r\n * @param overwrite - If set to `true`, the existing host list will be\r\n * replaced instead of extended.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const interval = setInterval(\r\n * () => db.acquireHostList(),\r\n * 5 * 60 * 1000 // every 5 minutes\r\n * );\r\n *\r\n * // later\r\n * clearInterval(interval);\r\n * system.close();\r\n * ```\r\n */\r\n async acquireHostList(overwrite = false): Promise<void> {\r\n const urls: string[] = await this.request(\r\n { pathname: \"/_api/cluster/endpoints\" },\r\n (res) =>\r\n res.parsedBody.endpoints.map((endpoint: any) => endpoint.endpoint)\r\n );\r\n if (urls.length > 0) {\r\n if (overwrite) this._connection.setHostList(urls);\r\n else this._connection.addToHostList(urls);\r\n }\r\n }\r\n\r\n /**\r\n * Closes all active connections of this database instance.\r\n *\r\n * Can be used to clean up idling connections during longer periods of\r\n * inactivity.\r\n *\r\n * **Note**: This method currently has no effect in the browser version of\r\n * arangojs.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const sessions = db.collection(\"sessions\");\r\n * // Clean up expired sessions once per hour\r\n * setInterval(async () => {\r\n * await db.query(aql`\r\n * FOR session IN ${sessions}\r\n * FILTER session.expires < DATE_NOW()\r\n * REMOVE session IN ${sessions}\r\n * `);\r\n * // Making sure to close the connections because they're no longer used\r\n * system.close();\r\n * }, 1000 * 60 * 60);\r\n * ```\r\n */\r\n close(): void {\r\n this._connection.close();\r\n }\r\n\r\n /**\r\n * Performs a request against every known coordinator and returns when the\r\n * request has succeeded against every coordinator or the timeout is reached.\r\n *\r\n * **Note**: This method is primarily intended to make database setup easier\r\n * in cluster scenarios and requires all coordinators to be known to arangojs\r\n * before the method is invoked. The method is not useful in single-server or\r\n * leader-follower replication scenarios.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database({ loadBalancingStrategy: \"ROUND_ROBIN\" });\r\n * await system.acquireHostList();\r\n * const analyzer = db.analyzer(\"my-analyzer\");\r\n * await analyzer.create();\r\n * await db.waitForPropagation(\r\n * { pathname: `/_api/analyzer/${encodeURIComponent(analyzer.name)}` },\r\n * 30000\r\n * );\r\n * // Analyzer has been propagated to all coordinators and can safely be used\r\n * ```\r\n *\r\n * @param request - Request to perform against each known coordinator.\r\n * @param timeout - Maximum number of milliseconds to wait for propagation.\r\n */\r\n async waitForPropagation(\r\n request: connection.RequestOptions,\r\n timeout?: number\r\n ): Promise<void>;\r\n async waitForPropagation(\r\n { pathname, ...request }: connection.RequestOptions,\r\n timeout?: number\r\n ): Promise<void> {\r\n await this._connection.waitForPropagation(\r\n {\r\n ...request,\r\n pathname: util.joinPath(\r\n \"_db\",\r\n encodeURIComponent(this._name),\r\n pathname\r\n ),\r\n },\r\n timeout\r\n );\r\n }\r\n\r\n /**\r\n * Methods for accessing the server-reported queue times of the mostly\r\n * recently received responses.\r\n */\r\n get queueTime(): administration.QueueTimeMetrics {\r\n return this._connection.queueTime;\r\n }\r\n\r\n /**\r\n * Sets the limit for the number of values of the most recently received\r\n * server-reported queue times that can be accessed using\r\n * {@link Database#queueTime}.\r\n *\r\n * @param responseQueueTimeSamples - Number of values to maintain.\r\n */\r\n setResponseQueueTimeSamples(responseQueueTimeSamples: number) {\r\n this._connection.setResponseQueueTimeSamples(responseQueueTimeSamples);\r\n }\r\n //#endregion\r\n\r\n //#region auth\r\n /**\r\n * Updates the underlying connection's `authorization` header to use Basic\r\n * authentication with the given `username` and `password`, then returns\r\n * itself.\r\n *\r\n * @param username - The username to authenticate with.\r\n * @param password - The password to authenticate with.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * db.useBasicAuth(\"admin\", \"hunter2\");\r\n * // with the username \"admin\" and password \"hunter2\".\r\n * ```\r\n */\r\n useBasicAuth(username: string = \"root\", password: string = \"\"): this {\r\n this._connection.setBasicAuth({ username, password });\r\n return this;\r\n }\r\n\r\n /**\r\n * Updates the underlying connection's `authorization` header to use Bearer\r\n * authentication with the given authentication `token`, then returns itself.\r\n *\r\n * @param token - The token to authenticate with.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * db.useBearerAuth(\"keyboardcat\");\r\n * // The database instance now uses Bearer authentication.\r\n * ```\r\n */\r\n useBearerAuth(token: string): this {\r\n this._connection.setBearerAuth({ token });\r\n return this;\r\n }\r\n\r\n /**\r\n * Updates the underlying connection's `authorization` header to use Basic\r\n * authentication with the given access token, then returns itself.\r\n *\r\n * Access tokens contain embedded username information, so the username field\r\n * in Basic Auth can be empty. The token acts as a password replacement.\r\n *\r\n * @param token - The access token to authenticate with.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const tokenResult = await db.createAccessToken(\"appUser\", {\r\n * name: \"CI token\"\r\n * });\r\n * db.useAccessToken(tokenResult.token);\r\n * // The database instance now uses the access token for authentication.\r\n * ```\r\n */\r\n useAccessToken(token: string): this {\r\n if (!token || typeof token !== \"string\") {\r\n throw new Error(\"Token must be a non-empty string\");\r\n }\r\n // Access tokens can be used with empty username in Basic Auth\r\n // The token contains embedded username information\r\n return this.useBasicAuth(\"\", token);\r\n }\r\n\r\n /**\r\n * Validates the given database credentials and exchanges them for an\r\n * authentication token, then uses the authentication token for future\r\n * requests and returns it.\r\n *\r\n * @param username - The username to authenticate with.\r\n * @param password - The password to authenticate with.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.login(\"admin\", \"hunter2\");\r\n * // with an authentication token for the \"admin\" user.\r\n * ```\r\n */\r\n login(username: string = \"root\", password: string = \"\"): Promise<string> {\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_open/auth\",\r\n body: { username, password },\r\n },\r\n (res: any) => {\r\n this.useBearerAuth(res.parsedBody.jwt);\r\n return res.parsedBody.jwt;\r\n }\r\n );\r\n }\r\n\r\n /**\r\n * Attempts to renew the authentication token passed to {@link Database#useBearerAuth}\r\n * or returned and used by {@link Database#login}. If a new authentication\r\n * token is issued, it will be used for future requests and returned.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.login(\"admin\", \"hunter2\");\r\n * // ... later ...\r\n * const newToken = await db.renewAuthToken();\r\n * if (!newToken) // no new token issued\r\n * ```\r\n */\r\n renewAuthToken(): Promise<string | null> {\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_open/auth/renew\",\r\n },\r\n (res) => {\r\n if (!res.parsedBody.jwt) return null;\r\n this.useBearerAuth(res.parsedBody.jwt);\r\n return res.parsedBody.jwt;\r\n }\r\n );\r\n }\r\n //#endregion\r\n\r\n //#region administration\r\n /**\r\n * Fetches version information from the ArangoDB server.\r\n *\r\n * @param details - If set to `true`, additional information about the\r\n * ArangoDB server will be available as the `details` property.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const version = await db.version();\r\n * // the version object contains the ArangoDB version information.\r\n * // license: \"community\" or \"enterprise\"\r\n * // version: ArangoDB version number\r\n * // server: description of the server\r\n * ```\r\n */\r\n version(details?: boolean): Promise<administration.VersionInfo> {\r\n return this.request({\r\n method: \"GET\",\r\n pathname: \"/_api/version\",\r\n search: { details },\r\n });\r\n }\r\n\r\n /**\r\n * Fetches storage engine information from the ArangoDB server.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const engine = await db.engine();\r\n * // the engine object contains the storage engine information, e.g.\r\n * // name: name of the storage engine\r\n * ```\r\n */\r\n engine(): Promise<administration.EngineInfo> {\r\n return this.request({\r\n method: \"GET\",\r\n pathname: \"/_api/engine\",\r\n });\r\n }\r\n\r\n /**\r\n * Fetches detailed storage engine performance and resource usage information\r\n * from the ArangoDB server.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const stats = await db.engineStats();\r\n * // the stats object contains the storage engine stats\r\n * ```\r\n */\r\n engineStats(): Promise<administration.EngineStatsInfo> {\r\n return this.request({\r\n method: \"GET\",\r\n pathname: \"/_api/engine/stats\",\r\n });\r\n }\r\n\r\n /**\r\n * Retrives the server's current system time in milliseconds with microsecond\r\n * precision.\r\n */\r\n time(): Promise<number> {\r\n return this.request(\r\n {\r\n method: \"GET\",\r\n pathname: \"/_admin/time\",\r\n },\r\n (res) => res.parsedBody.time * 1000\r\n );\r\n }\r\n\r\n /**\r\n * Fetches information about the server status.\r\n *\r\n * @example\r\n * ```js\r\n * const status = await db.status();\r\n * // the status object contains the ArangoDB status information, e.g.\r\n * // version: ArangoDB version number\r\n * // host: host identifier of the server\r\n * // serverInfo: detailed information about the server\r\n * ```\r\n */\r\n status(): Promise<administration.ServerStatusInfo> {\r\n return this.request({\r\n method: \"GET\",\r\n pathname: \"/_admin/status\",\r\n });\r\n }\r\n\r\n /**\r\n * Fetches availability information about the server.\r\n *\r\n * @param graceful - If set to `true`, the method will always return `false`\r\n * instead of throwing an error; otherwise `false` will only be returned\r\n * when the server responds with a 503 status code or an ArangoDB error with\r\n * a code of 503, such as during shutdown.\r\n *\r\n * @example\r\n * ```js\r\n * const availability = await db.availability();\r\n * // availability is either \"default\", \"readonly\", or false\r\n * ```\r\n */\r\n async availability(\r\n graceful = false\r\n ): Promise<administration.ServerAvailability> {\r\n try {\r\n return this.request(\r\n {\r\n method: \"GET\",\r\n pathname: \"/_admin/server/availability\",\r\n },\r\n (res) => res.parsedBody.mode\r\n );\r\n } catch (e) {\r\n if (graceful) return false;\r\n if (\r\n (errors.isArangoError(e) || e instanceof errors.HttpError) &&\r\n e.code === 503\r\n ) {\r\n return false;\r\n }\r\n throw e;\r\n }\r\n }\r\n\r\n /**\r\n * Fetches deployment information about the server for support purposes.\r\n *\r\n * Note that this API may reveal sensitive data about the deployment.\r\n */\r\n supportInfo(): Promise<\r\n administration.SingleServerSupportInfo | administration.ClusterSupportInfo\r\n > {\r\n return this.request({\r\n method: \"GET\",\r\n pathname: \"/_admin/support-info\",\r\n });\r\n }\r\n\r\n /**\r\n * Fetches the license information and status of an Enterprise Edition server.\r\n */\r\n getLicense(): Promise<administration.LicenseInfo> {\r\n return this.request({\r\n method: \"GET\",\r\n pathname: \"/_admin/license\",\r\n });\r\n }\r\n\r\n /**\r\n * Set a new license for an Enterprise Edition server.\r\n *\r\n * @param license - The license as a base 64 encoded string.\r\n * @param force - If set to `true`, the license will be changed even if it\r\n * expires sooner than the current license.\r\n */\r\n setLicense(license: string, force = false): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"PUT\",\r\n pathname: \"/_admin/license\",\r\n body: license,\r\n search: { force },\r\n },\r\n () => undefined\r\n );\r\n }\r\n\r\n /**\r\n * Compacts all databases on the server.\r\n *\r\n * @param options - Options for compacting the databases.\r\n */\r\n compact(options: administration.CompactOptions = {}): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"PUT\",\r\n pathname: \"/_admin/compact\",\r\n body: options,\r\n },\r\n () => undefined\r\n );\r\n }\r\n\r\n /**\r\n * Attempts to initiate a clean shutdown of the server.\r\n */\r\n shutdown(): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: \"/_admin/shutdown\",\r\n },\r\n () => undefined\r\n );\r\n }\r\n //#endregion\r\n\r\n //#region rebalancing\r\n /**\r\n * Computes the current cluster imbalance.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const imbalance = await db.getClusterImbalance();\r\n * ```\r\n */\r\n getClusterImbalance(): Promise<cluster.ClusterRebalanceState> {\r\n return this.request(\r\n { pathname: \"/_admin/cluster/rebalance\" },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Computes a set of move shard operations to rebalance the cluster.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const result = await db.computerClusterRebalance({\r\n * moveLeaders: true,\r\n * moveFollowers: true\r\n * });\r\n * if (result.moves.length) {\r\n * await db.executeClusterRebalance(result.moves);\r\n * }\r\n * ```\r\n */\r\n computeClusterRebalance(\r\n options: cluster.ClusterRebalanceOptions\r\n ): Promise<cluster.ClusterRebalanceResult> {\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_admin/cluster/rebalance\",\r\n body: {\r\n version: 1,\r\n ...options,\r\n },\r\n },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Executes the given cluster move shard operations.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const result = await db.computerClusterRebalance({\r\n * moveLeaders: true,\r\n * moveFollowers: true\r\n * });\r\n * if (result.moves.length) {\r\n * await db.executeClusterRebalance(result.moves);\r\n * }\r\n * ```\r\n */\r\n executeClusterRebalance(\r\n moves: cluster.ClusterRebalanceMove[]\r\n ): Promise<unknown> {\r\n return this.request({\r\n method: \"POST\",\r\n pathname: \"/_admin/cluster/rebalance/execute\",\r\n body: {\r\n version: 1,\r\n moves,\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Computes a set of move shard operations to rebalance the cluster and\r\n * executes them.\r\n *\r\n * @param options - Options for rebalancing the cluster.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const result = await db.rebalanceCluster({\r\n * moveLeaders: true,\r\n * moveFollowers: true\r\n * });\r\n * // The cluster is now rebalanced.\r\n * ```\r\n */\r\n rebalanceCluster(\r\n options: cluster.ClusterRebalanceOptions\r\n ): Promise<cluster.ClusterRebalanceResult> {\r\n return this.request({\r\n method: \"PUT\",\r\n pathname: \"/_admin/cluster/rebalance\",\r\n body: {\r\n version: 1,\r\n ...options,\r\n },\r\n });\r\n }\r\n //#endregion\r\n\r\n //#region databases\r\n /**\r\n * Creates a new `Database` instance for the given `databaseName` that\r\n * shares this database's connection pool.\r\n *\r\n * See also {@link Database:constructor}.\r\n *\r\n * @param databaseName - Name of the database.\r\n *\r\n * @example\r\n * ```js\r\n * const systemDb = new Database();\r\n * const myDb = systemDb.database(\"my_database\");\r\n * ```\r\n */\r\n database(databaseName: string) {\r\n return new Database(this, databaseName);\r\n }\r\n\r\n /**\r\n * Fetches the database description for the active database from the server.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const info = await db.get();\r\n * // the database exists\r\n * ```\r\n */\r\n get(): Promise<DatabaseDescription> {\r\n return this.request(\r\n { pathname: \"/_api/database/current\" },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Checks whether the database exists.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const result = await db.exists();\r\n * // result indicates whether the database exists\r\n * ```\r\n */\r\n async exists(): Promise<boolean> {\r\n try {\r\n await this.get();\r\n return true;\r\n } catch (err: any) {\r\n if (errors.isArangoError(err) && err.errorNum === DATABASE_NOT_FOUND) {\r\n return false;\r\n }\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new database with the given `databaseName` with the given\r\n * `options` and returns a `Database` instance for that database.\r\n *\r\n * @param databaseName - Name of the database to create.\r\n * @param options - Options for creating the database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const info = await db.createDatabase(\"mydb\", {\r\n * users: [{ username: \"root\" }]\r\n * });\r\n * // the database has been created\r\n * ```\r\n */\r\n createDatabase(\r\n databaseName: string,\r\n options?: CreateDatabaseOptions\r\n ): Promise<Database>;\r\n /**\r\n * Creates a new database with the given `databaseName` with the given\r\n * `users` and returns a `Database` instance for that database.\r\n *\r\n * @param databaseName - Name of the database to create.\r\n * @param users - Database users to create with the database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const info = await db.createDatabase(\"mydb\", [{ username: \"root\" }]);\r\n * // the database has been created\r\n * ```\r\n */\r\n createDatabase(\r\n databaseName: string,\r\n users: users.CreateDatabaseUserOptions[]\r\n ): Promise<Database>;\r\n createDatabase(\r\n databaseName: string,\r\n usersOrOptions:\r\n | users.CreateDatabaseUserOptions[]\r\n | CreateDatabaseOptions = {}\r\n ): Promise<Database> {\r\n const { users, ...options } = Array.isArray(usersOrOptions)\r\n ? { users: usersOrOptions }\r\n : usersOrOptions;\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_api/database\",\r\n body: { name: databaseName, users, options },\r\n },\r\n () => this.database(databaseName)\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all databases from the server and returns an array of their names.\r\n *\r\n * See also {@link Database#databases} and\r\n * {@link Database#listUserDatabases}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const names = await db.listDatabases();\r\n * // databases is an array of database names\r\n * ```\r\n */\r\n listDatabases(): Promise<string[]> {\r\n return this.request(\r\n { pathname: \"/_api/database\" },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all databases accessible to the active user from the server and\r\n * returns an array of their names.\r\n *\r\n * See also {@link Database#userDatabases} and\r\n * {@link Database#listDatabases}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const names = await db.listUserDatabases();\r\n * // databases is an array of database names\r\n * ```\r\n */\r\n listUserDatabases(): Promise<string[]> {\r\n return this.request(\r\n { pathname: \"/_api/database/user\" },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all databases from the server and returns an array of `Database`\r\n * instances for those databases.\r\n *\r\n * See also {@link Database#listDatabases} and\r\n * {@link Database#userDatabases}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const names = await db.databases();\r\n * // databases is an array of databases\r\n * ```\r\n */\r\n databases(): Promise<Database[]> {\r\n return this.request({ pathname: \"/_api/database\" }, (res) =>\r\n (res.parsedBody.result as string[]).map((databaseName) =>\r\n this.database(databaseName)\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all databases accessible to the active user from the server and\r\n * returns an array of `Database` instances for those databases.\r\n *\r\n * See also {@link Database#listUserDatabases} and\r\n * {@link Database#databases}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const names = await db.userDatabases();\r\n * // databases is an array of databases\r\n * ```\r\n */\r\n userDatabases(): Promise<Database[]> {\r\n return this.request({ pathname: \"/_api/database/user\" }, (res) =>\r\n (res.parsedBody.result as string[]).map((databaseName) =>\r\n this.database(databaseName)\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * Deletes the database with the given `databaseName` from the server.\r\n *\r\n * @param databaseName - Name of the database to delete.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.dropDatabase(\"mydb\");\r\n * // database \"mydb\" no longer exists\r\n * ```\r\n */\r\n dropDatabase(databaseName: string): Promise<boolean> {\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: `/_api/database/${encodeURIComponent(databaseName)}`,\r\n },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n //#endregion\r\n\r\n //#region collections\r\n /**\r\n * Returns a `Collection` instance for the given collection name.\r\n *\r\n * In TypeScript the collection implements both the\r\n * {@link collections.DocumentCollection} and {@link collections.EdgeCollection}\r\n * interfaces and can be cast to either type to enforce a stricter API.\r\n *\r\n * @param EntryResultType - Type to represent document contents returned by\r\n * the server (including computed properties).\r\n * @param EntryInputType - Type to represent document contents passed when\r\n * inserting or replacing documents (without computed properties).\r\n * @param collectionName - Name of the edge collection.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collection = db.collection(\"potatoes\");\r\n * ```\r\n *\r\n * @example\r\n * ```ts\r\n * interface Person {\r\n * name: string;\r\n * }\r\n * const db = new Database();\r\n * const persons = db.collection<Person>(\"persons\");\r\n * ```\r\n *\r\n * @example\r\n * ```ts\r\n * interface Person {\r\n * name: string;\r\n * }\r\n * interface Friend {\r\n * startDate: number;\r\n * endDate?: number;\r\n * }\r\n * const db = new Database();\r\n * const documents = db.collection(\"persons\") as DocumentCollection<Person>;\r\n * const edges = db.collection(\"friends\") as EdgeCollection<Friend>;\r\n * ```\r\n */\r\n collection<\r\n EntryResultType extends Record<string, any> = any,\r\n EntryInputType extends Record<string, any> = EntryResultType,\r\n >(\r\n collectionName: string\r\n ): collections.DocumentCollection<EntryResultType, EntryInputType> &\r\n collections.EdgeCollection<EntryResultType, EntryInputType> {\r\n collectionName = collectionName;\r\n if (!this._collections.has(collectionName)) {\r\n this._collections.set(\r\n collectionName,\r\n new collections.Collection(this, collectionName)\r\n );\r\n }\r\n return this._collections.get(collectionName)!;\r\n }\r\n\r\n /**\r\n * Creates a new collection with the given `collectionName` and `options`,\r\n * then returns a {@link collections.DocumentCollection} instance for the new collection.\r\n *\r\n * @param EntryResultType - Type to represent document contents returned by\r\n * the server (including computed properties).\r\n * @param EntryInputType - Type to represent document contents passed when\r\n * inserting or replacing documents (without computed properties).\r\n * @param collectionName - Name of the new collection.\r\n * @param options - Options for creating the collection.\r\n *\r\n * @example\r\n * ```ts\r\n * const db = new Database();\r\n * const documents = db.createCollection(\"persons\");\r\n * ```\r\n *\r\n * @example\r\n * ```ts\r\n * interface Person {\r\n * name: string;\r\n * }\r\n * const db = new Database();\r\n * const documents = db.createCollection<Person>(\"persons\");\r\n * ```\r\n */\r\n async createCollection<\r\n EntryResultType extends Record<string, any> = any,\r\n EntryInputType extends Record<string, any> = EntryResultType,\r\n >(\r\n collectionName: string,\r\n options?: collections.CreateCollectionOptions & {\r\n type?: collections.CollectionType.DOCUMENT_COLLECTION;\r\n }\r\n ): Promise<collections.DocumentCollection<EntryResultType, EntryInputType>>;\r\n /**\r\n * Creates a new edge collection with the given `collectionName` and\r\n * `options`, then returns an {@link collections.EdgeCollection} instance for the new\r\n * edge collection.\r\n *\r\n * @param EntryResultType - Type to represent edge document contents returned\r\n * by the server (including computed properties).\r\n * @param EntryInputType - Type to represent edge document contents passed\r\n * when inserting or replacing documents (without computed properties).\r\n * @param collectionName - Name of the new collection.\r\n * @param options - Options for creating the collection.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const edges = db.createCollection(\"friends\", {\r\n * type: CollectionType.EDGE_COLLECTION\r\n * });\r\n * ```\r\n *\r\n * @example\r\n * ```ts\r\n * interface Friend {\r\n * startDate: number;\r\n * endDate?: number;\r\n * }\r\n * const db = new Database();\r\n * const edges = db.createCollection<Friend>(\"friends\", {\r\n * type: CollectionType.EDGE_COLLECTION\r\n * });\r\n * ```\r\n */\r\n async createCollection<\r\n EntryResultType extends Record<string, any> = any,\r\n EntryInputType extends Record<string, any> = EntryResultType,\r\n >(\r\n collectionName: string,\r\n options: collections.CreateCollectionOptions & {\r\n type: collections.CollectionType.EDGE_COLLECTION;\r\n }\r\n ): Promise<collections.EdgeCollection<EntryResultType, EntryInputType>>;\r\n async createCollection<\r\n EntryResultType extends Record<string, any> = any,\r\n EntryInputType extends Record<string, any> = EntryResultType,\r\n >(\r\n collectionName: string,\r\n options?: collections.CreateCollectionOptions & {\r\n type?: collections.CollectionType;\r\n }\r\n ): Promise<\r\n collections.DocumentCollection<EntryResultType, EntryInputType> &\r\n collections.EdgeCollection<EntryResultType, EntryInputType>\r\n > {\r\n const collection = this.collection(collectionName);\r\n await collection.create(options);\r\n return collection;\r\n }\r\n\r\n /**\r\n * Creates a new edge collection with the given `collectionName` and\r\n * `options`, then returns an {@link collections.EdgeCollection} instance for the new\r\n * edge collection.\r\n *\r\n * This is a convenience method for calling {@link Database#createCollection}\r\n * with `options.type` set to `EDGE_COLLECTION`.\r\n *\r\n * @param EntryResultType - Type to represent edge document contents returned\r\n * by the server (including computed properties).\r\n * @param EntryInputType - Type to represent edge document contents passed\r\n * when inserting or replacing documents (without computed properties).\r\n * @param collectionName - Name of the new collection.\r\n * @param options - Options for creating the collection.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const edges = db.createEdgeCollection(\"friends\");\r\n * ```\r\n *\r\n * @example\r\n * ```ts\r\n * interface Friend {\r\n * startDate: number;\r\n * endDate?: number;\r\n * }\r\n * const db = new Database();\r\n * const edges = db.createEdgeCollection<Friend>(\"friends\");\r\n * ```\r\n */\r\n async createEdgeCollection<\r\n EntryResultType extends Record<string, any> = any,\r\n EntryInputType extends Record<string, any> = EntryResultType,\r\n >(\r\n collectionName: string,\r\n options?: collections.CreateCollectionOptions\r\n ): Promise<collections.EdgeCollection<EntryResultType, EntryInputType>> {\r\n return this.createCollection(collectionName, {\r\n ...options,\r\n type: collections.CollectionType.EDGE_COLLECTION,\r\n });\r\n }\r\n\r\n /**\r\n * Renames the collection `collectionName` to `newName`.\r\n *\r\n * Additionally removes any stored `Collection` instance for\r\n * `collectionName` from the `Database` instance's internal cache.\r\n *\r\n * **Note**: Renaming collections may not be supported when ArangoDB is\r\n * running in a cluster configuration.\r\n *\r\n * @param collectionName - Current name of the collection.\r\n * @param newName - The new name of the collection.\r\n */\r\n async renameCollection(\r\n collectionName: string,\r\n newName: string\r\n ): Promise<connection.ArangoApiResponse<collections.CollectionDescription>> {\r\n const result = await this.request({\r\n method: \"PUT\",\r\n pathname: `/_api/collection/${encodeURIComponent(collectionName)}/rename`,\r\n body: { name: newName },\r\n });\r\n this._collections.delete(collectionName);\r\n return result;\r\n }\r\n\r\n /**\r\n * Fetches all collections from the database and returns an array of\r\n * collection descriptions.\r\n *\r\n * See also {@link Database#collections}.\r\n *\r\n * @param excludeSystem - Whether system collections should be excluded.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collections = await db.listCollections();\r\n * // collections is an array of collection descriptions\r\n * // not including system collections\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collections = await db.listCollections(false);\r\n * // collections is an array of collection descriptions\r\n * // including system collections\r\n * ```\r\n */\r\n listCollections(\r\n excludeSystem: boolean = true\r\n ): Promise<collections.CollectionDescription[]> {\r\n return this.request(\r\n {\r\n pathname: \"/_api/collection\",\r\n search: { excludeSystem },\r\n },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all collections from the database and returns an array of\r\n * `Collection` instances.\r\n *\r\n * In TypeScript these instances implement both the\r\n * {@link collections.DocumentCollection} and {@link collections.EdgeCollection}\r\n * interfaces and can be cast to either type to enforce a stricter API.\r\n *\r\n * See also {@link Database#listCollections}.\r\n *\r\n * @param excludeSystem - Whether system collections should be excluded.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collections = await db.collections();\r\n * // collections is an array of DocumentCollection and EdgeCollection\r\n * // instances not including system collections\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collections = await db.collections(false);\r\n * // collections is an array of DocumentCollection and EdgeCollection\r\n * // instances including system collections\r\n * ```\r\n */\r\n async collections(\r\n excludeSystem: boolean = true\r\n ): Promise<\r\n Array<collections.DocumentCollection & collections.EdgeCollection>\r\n > {\r\n const collections = await this.listCollections(excludeSystem);\r\n return collections.map((data) => this.collection(data.name));\r\n }\r\n //#endregion\r\n\r\n //#region graphs\r\n /**\r\n * Returns a {@link graphs.Graph} instance representing the graph with the given\r\n * `graphName`.\r\n *\r\n * @param graphName - Name of the graph.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const graph = db.graph(\"some-graph\");\r\n * ```\r\n */\r\n graph(graphName: string): graphs.Graph {\r\n if (!this._graphs.has(graphName)) {\r\n this._graphs.set(graphName, new graphs.Graph(this, graphName));\r\n }\r\n return this._graphs.get(graphName)!;\r\n }\r\n\r\n /**\r\n * Creates a graph with the given `graphName` and `edgeDefinitions`, then\r\n * returns a {@link graphs.Graph} instance for the new graph.\r\n *\r\n * @param graphName - Name of the graph to be created.\r\n * @param edgeDefinitions - An array of edge definitions.\r\n * @param options - An object defining the properties of the graph.\r\n */\r\n async createGraph(\r\n graphName: string,\r\n edgeDefinitions: graphs.EdgeDefinitionOptions[],\r\n options?: graphs.CreateGraphOptions\r\n ): Promise<graphs.Graph> {\r\n const graph = this.graph(graphName);\r\n await graph.create(edgeDefinitions, options);\r\n return graph;\r\n }\r\n\r\n /**\r\n * Fetches all graphs from the database and returns an array of graph\r\n * descriptions.\r\n *\r\n * See also {@link Database#graphs}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const graphs = await db.listGraphs();\r\n * // graphs is an array of graph descriptions\r\n * ```\r\n */\r\n listGraphs(): Promise<graphs.GraphDescription[]> {\r\n return this.request(\r\n { pathname: \"/_api/gharial\" },\r\n (res) => res.parsedBody.graphs\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all graphs from the database and returns an array of {@link graphs.Graph}\r\n * instances for those graphs.\r\n *\r\n * See also {@link Database#listGraphs}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const graphs = await db.graphs();\r\n * // graphs is an array of Graph instances\r\n * ```\r\n */\r\n async graphs(): Promise<graphs.Graph[]> {\r\n const graphs = await this.listGraphs();\r\n return graphs.map((data: any) => this.graph(data._key));\r\n }\r\n //#endregion\r\n\r\n //#region views\r\n /**\r\n * Returns a {@link views.View} instance for the given `viewName`.\r\n *\r\n * @param viewName - Name of the ArangoSearch or SearchAlias View.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const view = db.view(\"potatoes\");\r\n * ```\r\n */\r\n view(viewName: string): views.View {\r\n if (!this._views.has(viewName)) {\r\n this._views.set(viewName, new views.View(this, viewName));\r\n }\r\n return this._views.get(viewName)!;\r\n }\r\n\r\n /**\r\n * Creates a new View with the given `viewName` and `options`, then returns a\r\n * {@link views.View} instance for the new View.\r\n *\r\n * @param viewName - Name of the View.\r\n * @param options - An object defining the properties of the View.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const view = await db.createView(\"potatoes\", { type: \"arangosearch\" });\r\n * // the ArangoSearch View \"potatoes\" now exists\r\n * ```\r\n */\r\n async createView(\r\n viewName: string,\r\n options: views.CreateViewOptions\r\n ): Promise<views.View> {\r\n const view = this.view(viewName);\r\n await view.create(options);\r\n return view;\r\n }\r\n\r\n /**\r\n * Renames the view `viewName` to `newName`.\r\n *\r\n * Additionally removes any stored {@link views.View} instance for `viewName` from\r\n * the `Database` instance's internal cache.\r\n *\r\n * **Note**: Renaming views may not be supported when ArangoDB is running in\r\n * a cluster configuration.\r\n *\r\n * @param viewName - Current name of the view.\r\n * @param newName - The new name of the view.\r\n */\r\n async renameView(\r\n viewName: string,\r\n newName: string\r\n ): Promise<connection.ArangoApiResponse<views.ViewDescription>> {\r\n const result = await this.request({\r\n method: \"PUT\",\r\n pathname: `/_api/view/${encodeURIComponent(viewName)}/rename`,\r\n body: { name: newName },\r\n });\r\n this._views.delete(viewName);\r\n return result;\r\n }\r\n\r\n /**\r\n * Fetches all Views from the database and returns an array of View\r\n * descriptions.\r\n *\r\n * See also {@link Database#views}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n *\r\n * const views = await db.listViews();\r\n * // views is an array of View descriptions\r\n * ```\r\n */\r\n listViews(): Promise<views.ViewDescription[]> {\r\n return this.request(\r\n { pathname: \"/_api/view\" },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all Views from the database and returns an array of\r\n * {@link views.View} instances\r\n * for the Views.\r\n *\r\n * See also {@link Database#listViews}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const views = await db.views();\r\n * // views is an array of ArangoSearch View instances\r\n * ```\r\n */\r\n async views(): Promise<views.View[]> {\r\n const views = await this.listViews();\r\n return views.map((data) => this.view(data.name));\r\n }\r\n //#endregion\r\n\r\n //#region analyzers\r\n /**\r\n * Returns an {@link analyzers.Analyzer} instance representing the Analyzer with the\r\n * given `analyzerName`.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const analyzer = db.analyzer(\"some-analyzer\");\r\n * const info = await analyzer.get();\r\n * ```\r\n */\r\n analyzer(analyzerName: string): analyzers.Analyzer {\r\n if (!this._analyzers.has(analyzerName)) {\r\n this._analyzers.set(\r\n analyzerName,\r\n new analyzers.Analyzer(this, analyzerName)\r\n );\r\n }\r\n return this._analyzers.get(analyzerName)!;\r\n }\r\n\r\n /**\r\n * Creates a new Analyzer with the given `analyzerName` and `options`, then\r\n * returns an {@link analyzers.Analyzer} instance for the new Analyzer.\r\n *\r\n * @param analyzerName - Name of the Analyzer.\r\n * @param options - An object defining the properties of the Analyzer.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const analyzer = await db.createAnalyzer(\"potatoes\", { type: \"identity\" });\r\n * // the identity Analyzer \"potatoes\" now exists\r\n * ```\r\n */\r\n async createAnalyzer(\r\n analyzerName: string,\r\n options: analyzers.CreateAnalyzerOptions\r\n ): Promise<analyzers.Analyzer> {\r\n const analyzer = this.analyzer(analyzerName);\r\n await analyzer.create(options);\r\n return analyzer;\r\n }\r\n\r\n /**\r\n * Fetches all Analyzers visible in the database and returns an array of\r\n * Analyzer descriptions.\r\n *\r\n * See also {@link Database#analyzers}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const analyzers = await db.listAnalyzers();\r\n * // analyzers is an array of Analyzer descriptions\r\n * ```\r\n */\r\n listAnalyzers(): Promise<analyzers.AnalyzerDescription[]> {\r\n return this.request(\r\n { pathname: \"/_api/analyzer\" },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all Analyzers visible in the database and returns an array of\r\n * {@link analyzers.Analyzer} instances for those Analyzers.\r\n *\r\n * See also {@link Database#listAnalyzers}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const analyzers = await db.analyzers();\r\n * // analyzers is an array of Analyzer instances\r\n * ```\r\n */\r\n async analyzers(): Promise<analyzers.Analyzer[]> {\r\n const analyzers = await this.listAnalyzers();\r\n return analyzers.map((data) => this.analyzer(data.name));\r\n }\r\n //#endregion\r\n\r\n //#region users\r\n /**\r\n * Fetches all ArangoDB users visible to the authenticated user and returns\r\n * an array of user objects.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const users = await db.listUsers();\r\n * // users is an array of user objects\r\n * ```\r\n */\r\n listUsers(): Promise<users.ArangoUser[]> {\r\n return this.request(\r\n {\r\n pathname: \"/_api/user\",\r\n },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Fetches the user data of a single ArangoDB user.\r\n *\r\n * @param username - Name of the ArangoDB user to fetch.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const user = await db.getUser(\"steve\");\r\n * // user is the user object for the user named \"steve\"\r\n * ```\r\n */\r\n getUser(\r\n username: string\r\n ): Promise<connection.ArangoApiResponse<users.ArangoUser>> {\r\n return this.request({\r\n pathname: `/_api/user/${encodeURIComponent(username)}`,\r\n });\r\n }\r\n\r\n /**\r\n * Creates a new ArangoDB user with the given password.\r\n *\r\n * @param username - Name of the ArangoDB user to create.\r\n * @param passwd - Password of the new ArangoDB user.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const user = await db.createUser(\"steve\", \"hunter2\");\r\n * // The user \"steve\" has been created\r\n * ```\r\n */\r\n createUser(\r\n username: string,\r\n passwd: string\r\n ): Promise<connection.ArangoApiResponse<users.ArangoUser>>;\r\n /**\r\n * Creates a new ArangoDB user with the given options.\r\n *\r\n * @param username - Name of the ArangoDB user to create.\r\n * @param options - Additional options for creating the ArangoDB user.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const user = await db.createUser(\"steve\", { passwd: \"hunter2\" });\r\n * // The user \"steve\" has been created\r\n * ```\r\n */\r\n createUser(\r\n username: string,\r\n options: users.UserOptions\r\n ): Promise<connection.ArangoApiResponse<users.ArangoUser>>;\r\n createUser(\r\n username: string,\r\n options: string | users.UserOptions\r\n ): Promise<connection.ArangoApiResponse<users.ArangoUser>> {\r\n if (typeof options === \"string\") {\r\n options = { passwd: options };\r\n }\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_api/user\",\r\n body: { user: username, ...options },\r\n },\r\n (res) => res.parsedBody\r\n );\r\n }\r\n\r\n /**\r\n * Sets the password of a given ArangoDB user to the new value.\r\n *\r\n * @param username - Name of the ArangoDB user to change the password for.\r\n * @param passwd - New password for the ArangoDB user.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const user = await db.updateUser(\"steve\", \"hunter2\");\r\n * // The user \"steve\" has received a new password\r\n * ```\r\n */\r\n updateUser(\r\n username: string,\r\n passwd: string\r\n ): Promise<connection.ArangoApiResponse<users.ArangoUser>>;\r\n /**\r\n * Updates the ArangoDB user with the new options.\r\n *\r\n * @param username - Name of the ArangoDB user to modify.\r\n * @param options - Options of the ArangoDB user to modify.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const user = await db.updateUser(\"steve\", { active: false });\r\n * // The user \"steve\" has been set to inactive\r\n * ```\r\n */\r\n updateUser(\r\n username: string,\r\n options: Partial<users.UserOptions>\r\n ): Promise<connection.ArangoApiResponse<users.ArangoUser>>;\r\n updateUser(\r\n username: string,\r\n options: string | Partial<users.UserOptions>\r\n ): Promise<connection.ArangoApiResponse<users.ArangoUser>> {\r\n if (typeof options === \"string\") {\r\n options = { passwd: options };\r\n }\r\n return this.request(\r\n {\r\n method: \"PATCH\",\r\n pathname: `/_api/user/${encodeURIComponent(username)}`,\r\n body: options,\r\n },\r\n (res) => res.parsedBody\r\n );\r\n }\r\n\r\n /**\r\n * Replaces the ArangoDB user's option with the new options.\r\n *\r\n * @param username - Name of the ArangoDB user to modify.\r\n * @param options - New options to replace the user's existing options.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const user = await db.replaceUser(\"steve\", { passwd: \"\", active: false });\r\n * // The user \"steve\" has been set to inactive with an empty password\r\n * ```\r\n */\r\n replaceUser(\r\n username: string,\r\n options: users.UserOptions\r\n ): Promise<connection.ArangoApiResponse<users.ArangoUser>> {\r\n if (typeof options === \"string\") {\r\n options = { passwd: options };\r\n }\r\n return this.request(\r\n {\r\n method: \"PUT\",\r\n pathname: `/_api/user/${encodeURIComponent(username)}`,\r\n body: options,\r\n },\r\n (res) => res.parsedBody\r\n );\r\n }\r\n\r\n /**\r\n * Removes the ArangoDB user with the given username from the server.\r\n *\r\n * @param username - Name of the ArangoDB user to remove.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.removeUser(\"steve\");\r\n * // The user \"steve\" has been removed\r\n * ```\r\n */\r\n removeUser(username: string): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: `/_api/user/${encodeURIComponent(username)}`,\r\n },\r\n () => undefined\r\n );\r\n }\r\n\r\n /**\r\n * Fetches the given ArangoDB user's access level for the database, or the\r\n * given collection in the given database.\r\n *\r\n * @param username - Name of the ArangoDB user to fetch the access level for.\r\n * @param options - Collection and/or database to fetch the access level for.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const accessLevel = await db.getUserAccessLevel(\"steve\");\r\n * // The access level of the user \"steve\" has been fetched for the current\r\n * // database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const accessLevel = await db.getUserAccessLevel(\"steve\", {\r\n * database: \"staging\"\r\n * });\r\n * // The access level of the user \"steve\" has been fetched for the \"staging\"\r\n * // database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const accessLevel = await db.getUserAccessLevel(\"steve\", {\r\n * collection: \"pokemons\"\r\n * });\r\n * // The access level of the user \"steve\" has been fetched for the\r\n * // \"pokemons\" collection in the current database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const accessLevel = await db.getUserAccessLevel(\"steve\", {\r\n * database: \"staging\",\r\n * collection: \"pokemons\"\r\n * });\r\n * // The access level of the user \"steve\" has been fetched for the\r\n * // \"pokemons\" collection in the \"staging\" database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const staging = db.database(\"staging\");\r\n * const accessLevel = await db.getUserAccessLevel(\"steve\", {\r\n * database: staging\r\n * });\r\n * // The access level of the user \"steve\" has been fetched for the \"staging\"\r\n * // database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const staging = db.database(\"staging\");\r\n * const accessLevel = await db.getUserAccessLevel(\"steve\", {\r\n * collection: staging.collection(\"pokemons\")\r\n * });\r\n * // The access level of the user \"steve\" has been fetched for the\r\n * // \"pokemons\" collection in database \"staging\".\r\n * ```\r\n */\r\n getUserAccessLevel(\r\n username: string,\r\n options: users.UserAccessLevelOptions\r\n ): Promise<users.AccessLevel> {\r\n const { database, collection } = options;\r\n const databaseName = isArangoDatabase(database)\r\n ? database.name\r\n : (database ??\r\n (collection instanceof collections.Collection\r\n ? collection.database.name\r\n : this._name));\r\n const suffix = collection\r\n ? `/${encodeURIComponent(\r\n collections.isArangoCollection(collection)\r\n ? collection.name\r\n : collection\r\n )}`\r\n : \"\";\r\n return this.request(\r\n {\r\n pathname: `/_api/user/${encodeURIComponent(\r\n username\r\n )}/database/${encodeURIComponent(databaseName)}${suffix}`,\r\n },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Sets the given ArangoDB user's access level for the database, or the\r\n * given collection in the given database.\r\n *\r\n * @param username - Name of the ArangoDB user to set the access level for.\r\n * @param options - Database and/or collection to set the access level for.\r\n * @param grant - Access level to set for the given user.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.setUserAccessLevel(\"steve\", { grant: \"rw\" });\r\n * // The user \"steve\" now has read-write access to the current database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.setUserAccessLevel(\"steve\", {\r\n * database: \"staging\",\r\n * grant: \"rw\"\r\n * });\r\n * // The user \"steve\" now has read-write access to the \"staging\" database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.setUserAccessLevel(\"steve\", {\r\n * collection: \"pokemons\",\r\n * grant: \"rw\"\r\n * });\r\n * // The user \"steve\" now has read-write access to the \"pokemons\" collection\r\n * // in the current database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.setUserAccessLevel(\"steve\", {\r\n * database: \"staging\",\r\n * collection: \"pokemons\",\r\n * grant: \"rw\"\r\n * });\r\n * // The user \"steve\" now has read-write access to the \"pokemons\" collection\r\n * // in the \"staging\" database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const staging = db.database(\"staging\");\r\n * await db.setUserAccessLevel(\"steve\", {\r\n * database: staging,\r\n * grant: \"rw\"\r\n * });\r\n * // The user \"steve\" now has read-write access to the \"staging\" database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const staging = db.database(\"staging\");\r\n * await db.setUserAccessLevel(\"steve\", {\r\n * collection: staging.collection(\"pokemons\"),\r\n * grant: \"rw\"\r\n * });\r\n * // The user \"steve\" now has read-write access to the \"pokemons\" collection\r\n * // in database \"staging\".\r\n * ```\r\n */\r\n setUserAccessLevel(\r\n username: string,\r\n options: users.UserAccessLevelOptions,\r\n grant: users.AccessLevel\r\n ): Promise<connection.ArangoApiResponse<Record<string, users.AccessLevel>>> {\r\n const { database, collection } = options;\r\n const databaseName = isArangoDatabase(database)\r\n ? database.name\r\n : (database ??\r\n (collection instanceof collections.Collection\r\n ? collection.database.name\r\n : this._name));\r\n const suffix = collection\r\n ? `/${encodeURIComponent(\r\n collections.isArangoCollection(collection)\r\n ? collection.name\r\n : collection\r\n )}`\r\n : \"\";\r\n return this.request(\r\n {\r\n method: \"PUT\",\r\n pathname: `/_api/user/${encodeURIComponent(\r\n username\r\n )}/database/${encodeURIComponent(databaseName)}${suffix}`,\r\n body: { grant },\r\n },\r\n (res) => res.parsedBody\r\n );\r\n }\r\n\r\n /**\r\n * Clears the given ArangoDB user's access level for the database, or the\r\n * given collection in the given database.\r\n *\r\n * @param username - Name of the ArangoDB user to clear the access level for.\r\n * @param options - Database and/or collection to clear the access level for.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.clearUserAccessLevel(\"steve\");\r\n * // The access level of the user \"steve\" has been cleared for the current\r\n * // database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.clearUserAccessLevel(\"steve\", { database: \"staging\" });\r\n * // The access level of the user \"steve\" has been cleared for the \"staging\"\r\n * // database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.clearUserAccessLevel(\"steve\", { collection: \"pokemons\" });\r\n * // The access level of the user \"steve\" has been cleared for the\r\n * // \"pokemons\" collection in the current database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.clearUserAccessLevel(\"steve\", {\r\n * database: \"staging\",\r\n * collection: \"pokemons\"\r\n * });\r\n * // The access level of the user \"steve\" has been cleared for the\r\n * // \"pokemons\" collection in the \"staging\" database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const staging = db.database(\"staging\");\r\n * await db.clearUserAccessLevel(\"steve\", { database: staging });\r\n * // The access level of the user \"steve\" has been cleared for the \"staging\"\r\n * // database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const staging = db.database(\"staging\");\r\n * await db.clearUserAccessLevel(\"steve\", {\r\n * collection: staging.collection(\"pokemons\")\r\n * });\r\n * // The access level of the user \"steve\" has been cleared for the\r\n * // \"pokemons\" collection in database \"staging\".\r\n * ```\r\n */\r\n clearUserAccessLevel(\r\n username: string,\r\n options: users.UserAccessLevelOptions\r\n ): Promise<connection.ArangoApiResponse<Record<string, users.AccessLevel>>> {\r\n const { database, collection } = options;\r\n const databaseName = isArangoDatabase(database)\r\n ? database.name\r\n : (database ??\r\n (collection instanceof collections.Collection\r\n ? collection.database.name\r\n : this._name));\r\n const suffix = collection\r\n ? `/${encodeURIComponent(\r\n collections.isArangoCollection(collection)\r\n ? collection.name\r\n : collection\r\n )}`\r\n : \"\";\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: `/_api/user/${encodeURIComponent(\r\n username\r\n )}/database/${encodeURIComponent(databaseName)}${suffix}`,\r\n },\r\n (res) => res.parsedBody\r\n );\r\n }\r\n\r\n /**\r\n * Fetches an object mapping names of databases to the access level of the\r\n * given ArangoDB user for those databases.\r\n *\r\n * @param username - Name of the ArangoDB user to fetch the access levels for.\r\n * @param full - Whether access levels for collections should be included.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const accessLevels = await db.getUserDatabases(\"steve\");\r\n * for (const [databaseName, accessLevel] of Object.entries(accessLevels)) {\r\n * console.log(`${databaseName}: ${accessLevel}`);\r\n * }\r\n * ```\r\n */\r\n getUserDatabases(\r\n username: string,\r\n full?: false\r\n ): Promise<Record<string, users.AccessLevel>>;\r\n /**\r\n * Fetches an object mapping names of databases to the access level of the\r\n * given ArangoDB user for those databases and the collections within each\r\n * database.\r\n *\r\n * @param username - Name of the ArangoDB user to fetch the access levels for.\r\n * @param full - Whether access levels for collections should be included.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const accessLevels = await db.getUserDatabases(\"steve\", true);\r\n * for (const [databaseName, obj] of Object.entries(accessLevels)) {\r\n * console.log(`${databaseName}: ${obj.permission}`);\r\n * for (const [collectionName, accessLevel] of Object.entries(obj.collections)) {\r\n * console.log(`${databaseName}/${collectionName}: ${accessLevel}`);\r\n * }\r\n * }\r\n * ```\r\n */\r\n getUserDatabases(\r\n username: string,\r\n full: true\r\n ): Promise<\r\n Record<\r\n string,\r\n {\r\n permission: users.AccessLevel;\r\n collections: Record<string, users.AccessLevel | \"undefined\">;\r\n }\r\n >\r\n >;\r\n getUserDatabases(username: string, full?: boolean) {\r\n return this.request(\r\n {\r\n pathname: `/_api/user/${encodeURIComponent(username)}/database`,\r\n search: { full },\r\n },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Creates a new access token for the given ArangoDB user.\r\n *\r\n * Access tokens can be used as password replacements for authentication.\r\n * The token value is only returned once in this response and cannot be\r\n * retrieved again. Store it securely.\r\n *\r\n * @param username - Name of the ArangoDB user to create the token for.\r\n * @param options - Options for creating the access token.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Convert Date to Unix timestamp (seconds)\r\n * const expiryDate = new Date(\"2025-12-31\");\r\n * const expiryTimestamp = Math.floor(expiryDate.getTime() / 1000);\r\n * const token = await db.createAccessToken(\"appUser\", {\r\n * name: \"CI token\",\r\n * valid_until: expiryTimestamp\r\n * });\r\n * console.log(token.token); // Store this securely!\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const token = await db.createAccessToken(\"appUser\", {\r\n * name: \"Production token\",\r\n * valid_until: Math.floor(Date.now() / 1000) + (30 * 24 * 60 * 60) // 30 days\r\n * });\r\n * ```\r\n */\r\n createAccessToken(\r\n username: string,\r\n options: users.CreateAccessTokenOptions\r\n ): Promise<connection.ArangoApiResponse<users.AccessToken>> {\r\n if (!username || typeof username !== \"string\") {\r\n throw new Error(\"Username must be a non-empty string\");\r\n }\r\n if (!options || typeof options !== \"object\") {\r\n throw new Error(\"Options must be an object\");\r\n }\r\n if (!options.name || typeof options.name !== \"string\") {\r\n throw new Error(\"Token name must be a non-empty string\");\r\n }\r\n\r\n const body: { name: string; valid_until?: number } = {\r\n name: options.name,\r\n };\r\n\r\n if (options.valid_until !== undefined) {\r\n if (typeof options.valid_until !== \"number\") {\r\n throw new Error(\r\n \"valid_until must be a Unix timestamp (number in seconds)\"\r\n );\r\n }\r\n body.valid_until = options.valid_until;\r\n }\r\n\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: `/_api/token/${encodeURIComponent(username)}`,\r\n body,\r\n },\r\n (res) => res.parsedBody\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all access tokens for the given ArangoDB user.\r\n *\r\n * Note: Token values are not returned. Only metadata (id, name, expiry, etc.)\r\n * is available. Token values can only be retrieved when creating a new token.\r\n *\r\n * @param username - Name of the ArangoDB user to fetch tokens for.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const tokens = await db.getAccessTokens(\"appUser\");\r\n * for (const token of tokens) {\r\n * console.log(`${token.name}: expires ${new Date(token.valid_until * 1000)}`);\r\n * }\r\n * ```\r\n */\r\n getAccessTokens(\r\n username: string\r\n ): Promise<users.AccessTokenMetadata[]> {\r\n if (!username || typeof username !== \"string\") {\r\n throw new Error(\"Username must be a non-empty string\");\r\n }\r\n\r\n return this.request(\r\n {\r\n pathname: `/_api/token/${encodeURIComponent(username)}`,\r\n },\r\n (res) => res.parsedBody.tokens\r\n );\r\n }\r\n\r\n /**\r\n * Deletes (revokes) an access token for the given ArangoDB user.\r\n *\r\n * Once deleted, the token cannot be used for authentication and cannot be recovered.\r\n *\r\n * @param username - Name of the ArangoDB user who owns the token.\r\n * @param tokenId - Unique identifier of the token to delete.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const tokens = await db.getAccessTokens(\"appUser\");\r\n * for (const token of tokens) {\r\n * if (token.name === \"Old CI token\") {\r\n * await db.deleteAccessToken(\"appUser\", token.id);\r\n * }\r\n * }\r\n * ```\r\n */\r\n deleteAccessToken(\r\n username: string,\r\n tokenId: number\r\n ): Promise<void> {\r\n if (!username || typeof username !== \"string\") {\r\n throw new Error(\"Username must be a non-empty string\");\r\n }\r\n if (typeof tokenId !== \"number\" || !Number.isInteger(tokenId) || tokenId < 0) {\r\n throw new Error(\"Token ID must be a non-negative integer\");\r\n }\r\n\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: `/_api/token/${encodeURIComponent(username)}/${tokenId}`,\r\n },\r\n () => undefined\r\n );\r\n }\r\n //#endregion\r\n\r\n //#region transactions\r\n /**\r\n * Performs a server-side JavaScript transaction and returns its return\r\n * value.\r\n *\r\n * Collections can be specified as collection names (strings) or objects\r\n * implementing the {@link collections.ArangoCollection} interface: `Collection`,\r\n * {@link graphs.GraphVertexCollection}, {@link graphs.GraphEdgeCollection} as well as\r\n * (in TypeScript) {@link collections.DocumentCollection} and {@link collections.EdgeCollection}.\r\n *\r\n * **Note**: The `action` function will be evaluated and executed on the\r\n * server inside ArangoDB's embedded JavaScript environment and can not\r\n * access any values other than those passed via the `params` option.\r\n *\r\n * See the official ArangoDB documentation for\r\n * [the JavaScript `@arangodb` module](https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html)\r\n * for information about accessing the database from within ArangoDB's\r\n * server-side JavaScript environment.\r\n *\r\n * @param collections - Collections involved in the transaction.\r\n * @param action - A string evaluating to a JavaScript function to be\r\n * executed on the server.\r\n * @param options - Options for the transaction. If `options.allowImplicit`\r\n * is specified, it will be used if `collections.allowImplicit` was not\r\n * specified.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n *\r\n * const action = `\r\n * function(params) {\r\n * // This code will be executed inside ArangoDB!\r\n * const { query } = require(\"@arangodb\");\r\n * return query\\`\r\n * FOR user IN _users\r\n * FILTER user.age > ${params.age}\r\n * RETURN u.user\r\n * \\`.toArray();\r\n * }\r\n * `);\r\n *\r\n * const result = await db.executeTransaction({\r\n * read: [\"_users\"]\r\n * }, action, {\r\n * params: { age: 12 }\r\n * });\r\n * // result contains the return value of the action\r\n * ```\r\n */\r\n executeTransaction(\r\n collections: transactions.TransactionCollectionOptions & {\r\n allowImplicit?: boolean;\r\n },\r\n action: string,\r\n options?: transactions.TransactionOptions & { params?: any }\r\n ): Promise<any>;\r\n /**\r\n * Performs a server-side transaction and returns its return value.\r\n *\r\n * Collections can be specified as collection names (strings) or objects\r\n * implementing the {@link collections.ArangoCollection} interface: `Collection`,\r\n * {@link graphs.GraphVertexCollection}, {@link graphs.GraphEdgeCollection} as well as\r\n * (in TypeScript) {@link collections.DocumentCollection} and {@link collections.EdgeCollection}.\r\n *\r\n * **Note**: The `action` function will be evaluated and executed on the\r\n * server inside ArangoDB's embedded JavaScript environment and can not\r\n * access any values other than those passed via the `params` option.\r\n * See the official ArangoDB documentation for\r\n * [the JavaScript `@arangodb` module](https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html)\r\n * for information about accessing the database from within ArangoDB's\r\n * server-side JavaScript environment.\r\n *\r\n * @param collections - Collections that can be read from and written to\r\n * during the transaction.\r\n * @param action - A string evaluating to a JavaScript function to be\r\n * executed on the server.\r\n * @param options - Options for the transaction.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n *\r\n * const action = `\r\n * function(params) {\r\n * // This code will be executed inside ArangoDB!\r\n * const { query } = require(\"@arangodb\");\r\n * return query\\`\r\n * FOR user IN _users\r\n * FILTER user.age > ${params.age}\r\n * RETURN u.user\r\n * \\`.toArray();\r\n * }\r\n * `);\r\n *\r\n * const result = await db.executeTransaction([\"_users\"], action, {\r\n * params: { age: 12 }\r\n * });\r\n * // result contains the return value of the action\r\n * ```\r\n */\r\n executeTransaction(\r\n collections: (string | collections.ArangoCollection)[],\r\n action: string,\r\n options?: transactions.TransactionOptions & { params?: any }\r\n ): Promise<any>;\r\n /**\r\n * Performs a server-side transaction and returns its return value.\r\n *\r\n * The Collection can be specified as a collection name (string) or an object\r\n * implementing the {@link collections.ArangoCollection} interface: `Collection`,\r\n * {@link graphs.GraphVertexCollection}, {@link graphs.GraphEdgeCollection} as well as\r\n * (in TypeScript) {@link collections.DocumentCollection} and {@link collections.EdgeCollection}.\r\n *\r\n * **Note**: The `action` function will be evaluated and executed on the\r\n * server inside ArangoDB's embedded JavaScript environment and can not\r\n * access any values other than those passed via the `params` option.\r\n * See the official ArangoDB documentation for\r\n * [the JavaScript `@arangodb` module](https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html)\r\n * for information about accessing the database from within ArangoDB's\r\n * server-side JavaScript environment.\r\n *\r\n * @param collection - A collection that can be read from and written to\r\n * during the transaction.\r\n * @param action - A string evaluating to a JavaScript function to be\r\n * executed on the server.\r\n * @param options - Options for the transaction.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n *\r\n * const action = `\r\n * function(params) {\r\n * // This code will be executed inside ArangoDB!\r\n * const { query } = require(\"@arangodb\");\r\n * return query\\`\r\n * FOR user IN _users\r\n * FILTER user.age > ${params.age}\r\n * RETURN u.user\r\n * \\`.toArray();\r\n * }\r\n * `);\r\n *\r\n * const result = await db.executeTransaction(\"_users\", action, {\r\n * params: { age: 12 }\r\n * });\r\n * // result contains the return value of the action\r\n * ```\r\n */\r\n executeTransaction(\r\n collection: string | collections.ArangoCollection,\r\n action: string,\r\n options?: transactions.TransactionOptions & { params?: any }\r\n ): Promise<any>;\r\n executeTransaction(\r\n collections:\r\n | (transactions.TransactionCollectionOptions & {\r\n allowImplicit?: boolean;\r\n })\r\n | (string | collections.ArangoCollection)[]\r\n | string\r\n | collections.ArangoCollection,\r\n action: string,\r\n options: transactions.TransactionOptions & { params?: any } = {}\r\n ): Promise<any> {\r\n const { allowDirtyRead = undefined, ...opts } = options;\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_api/transaction\",\r\n allowDirtyRead,\r\n body: {\r\n collections: transactions.coerceTransactionCollections(collections),\r\n action,\r\n ...opts,\r\n },\r\n },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Returns a {@link transactions.Transaction} instance for an existing streaming\r\n * transaction with the given `id`.\r\n *\r\n * See also {@link Database#beginTransaction}.\r\n *\r\n * @param transactionId - The `id` of an existing stream transaction.\r\n *\r\n * @example\r\n * ```js\r\n * const trx1 = await db.beginTransaction(collections);\r\n * const id = trx1.id;\r\n * // later\r\n * const trx2 = db.transaction(id);\r\n * await trx2.commit();\r\n * ```\r\n */\r\n transaction(transactionId: string): transactions.Transaction {\r\n return new transactions.Transaction(this, transactionId);\r\n }\r\n\r\n /**\r\n * Begins a new streaming transaction for the given collections, then returns\r\n * a {@link transactions.Transaction} instance for the transaction.\r\n *\r\n * Collections can be specified as collection names (strings) or objects\r\n * implementing the {@link collections.ArangoCollection} interface: `Collection`,\r\n * {@link graphs.GraphVertexCollection}, {@link graphs.GraphEdgeCollection} as\r\n * well as (in TypeScript) {@link collections.DocumentCollection} and\r\n * {@link collections.EdgeCollection}.\r\n *\r\n * @param collections - Collections involved in the transaction.\r\n * @param options - Options for the transaction.\r\n *\r\n * @example\r\n * ```js\r\n * const vertices = db.collection(\"vertices\");\r\n * const edges = db.collection(\"edges\");\r\n * const trx = await db.beginTransaction({\r\n * read: [\"vertices\"],\r\n * write: [edges] // collection instances can be passed directly\r\n * });\r\n * const start = await trx.step(() => vertices.document(\"a\"));\r\n * const end = await trx.step(() => vertices.document(\"b\"));\r\n * await trx.step(() => edges.save({ _from: start._id, _to: end._id }));\r\n * await trx.commit();\r\n * ```\r\n */\r\n beginTransaction(\r\n collections: transactions.TransactionCollectionOptions,\r\n options?: transactions.TransactionOptions\r\n ): Promise<transactions.Transaction>;\r\n /**\r\n * Begins a new streaming transaction for the given collections, then returns\r\n * a {@link transactions.Transaction} instance for the transaction.\r\n *\r\n * Collections can be specified as collection names (strings) or objects\r\n * implementing the {@link collections.ArangoCollection} interface: `Collection`,\r\n * {@link graphs.GraphVertexCollection}, {@link graphs.GraphEdgeCollection} as well as\r\n * (in TypeScript) {@link collections.DocumentCollection} and {@link collections.EdgeCollection}.\r\n *\r\n * @param collections - Collections that can be read from and written to\r\n * during the transaction.\r\n * @param options - Options for the transaction.\r\n *\r\n * @example\r\n * ```js\r\n * const vertices = db.collection(\"vertices\");\r\n * const edges = db.collection(\"edges\");\r\n * const trx = await db.beginTransaction([\r\n * \"vertices\",\r\n * edges // collection instances can be passed directly\r\n * ]);\r\n * const start = await trx.step(() => vertices.document(\"a\"));\r\n * const end = await trx.step(() => vertices.document(\"b\"));\r\n * await trx.step(() => edges.save({ _from: start._id, _to: end._id }));\r\n * await trx.commit();\r\n * ```\r\n */\r\n beginTransaction(\r\n collections: (string | collections.ArangoCollection)[],\r\n options?: transactions.TransactionOptions\r\n ): Promise<transactions.Transaction>;\r\n /**\r\n * Begins a new streaming transaction for the given collections, then returns\r\n * a {@link transactions.Transaction} instance for the transaction.\r\n *\r\n * The Collection can be specified as a collection name (string) or an object\r\n * implementing the {@link collections.ArangoCollection} interface: `Collection`,\r\n * {@link graphs.GraphVertexCollection}, {@link graphs.GraphEdgeCollection} as well as\r\n * (in TypeScript) {@link collections.DocumentCollection} and {@link collections.EdgeCollection}.\r\n *\r\n * @param collection - A collection that can be read from and written to\r\n * during the transaction.\r\n * @param options - Options for the transaction.\r\n *\r\n * @example\r\n * ```js\r\n * const vertices = db.collection(\"vertices\");\r\n * const start = vertices.document(\"a\");\r\n * const end = vertices.document(\"b\");\r\n * const edges = db.collection(\"edges\");\r\n * const trx = await db.beginTransaction(\r\n * edges // collection instances can be passed directly\r\n * );\r\n * await trx.step(() => edges.save({ _from: start._id, _to: end._id }));\r\n * await trx.commit();\r\n * ```\r\n */\r\n beginTransaction(\r\n collection: string | collections.ArangoCollection,\r\n options?: transactions.TransactionOptions\r\n ): Promise<transactions.Transaction>;\r\n beginTransaction(\r\n collections:\r\n | transactions.TransactionCollectionOptions\r\n | (string | collections.ArangoCollection)[]\r\n | string\r\n | collections.ArangoCollection,\r\n options: transactions.TransactionOptions = {}\r\n ): Promise<transactions.Transaction> {\r\n const { allowDirtyRead = undefined, ...opts } = options;\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_api/transaction/begin\",\r\n allowDirtyRead,\r\n body: {\r\n collections: transactions.coerceTransactionCollections(collections),\r\n ...opts,\r\n },\r\n },\r\n (res) => new transactions.Transaction(this, res.parsedBody.result.id)\r\n );\r\n }\r\n\r\n /**\r\n * Begins and commits a transaction using the given callback. Individual\r\n * requests that are part of the transaction need to be wrapped in the step\r\n * function passed into the callback. If the promise returned by the callback\r\n * is rejected, the transaction will be aborted.\r\n *\r\n * Collections can be specified as collection names (strings) or objects\r\n * implementing the {@link collections.ArangoCollection} interface: `Collection`,\r\n * {@link graphs.GraphVertexCollection}, {@link graphs.GraphEdgeCollection} as\r\n * well as (in TypeScript) {@link collections.DocumentCollection} and\r\n * {@link collections.EdgeCollection}.\r\n *\r\n * @param collections - Collections involved in the transaction.\r\n * @param callback - Callback function executing the transaction steps.\r\n * @param options - Options for the transaction.\r\n *\r\n * @example\r\n * ```js\r\n * const vertices = db.collection(\"vertices\");\r\n * const edges = db.collection(\"edges\");\r\n * await db.withTransaction(\r\n * {\r\n * read: [\"vertices\"],\r\n * write: [edges] // collection instances can be passed directly\r\n * },\r\n * async (step) => {\r\n * const start = await step(() => vertices.document(\"a\"));\r\n * const end = await step(() => vertices.document(\"b\"));\r\n * await step(() => edges.save({ _from: start._id, _to: end._id }));\r\n * }\r\n * );\r\n * ```\r\n */\r\n withTransaction<T>(\r\n collections: transactions.TransactionCollectionOptions,\r\n callback: (step: transactions.Transaction[\"step\"]) => Promise<T>,\r\n options?: transactions.TransactionOptions\r\n ): Promise<T>;\r\n /**\r\n * Begins and commits a transaction using the given callback. Individual\r\n * requests that are part of the transaction need to be wrapped in the step\r\n * function passed into the callback. If the promise returned by the callback\r\n * is rejected, the transaction will be aborted.\r\n *\r\n * Collections can be specified as collection names (strings) or objects\r\n * implementing the {@link collections.ArangoCollection} interface: `Collection`,\r\n * {@link graphs.GraphVertexCollection}, {@link graphs.GraphEdgeCollection} as well as\r\n * (in TypeScript) {@link collections.DocumentCollection} and {@link collections.EdgeCollection}.\r\n *\r\n * @param collections - Collections that can be read from and written to\r\n * during the transaction.\r\n * @param callback - Callback function executing the transaction steps.\r\n * @param options - Options for the transaction.\r\n *\r\n * @example\r\n * ```js\r\n * const vertices = db.collection(\"vertices\");\r\n * const edges = db.collection(\"edges\");\r\n * await db.withTransaction(\r\n * [\r\n * \"vertices\",\r\n * edges, // collection instances can be passed directly\r\n * ],\r\n * async (step) => {\r\n * const start = await step(() => vertices.document(\"a\"));\r\n * const end = await step(() => vertices.document(\"b\"));\r\n * await step(() => edges.save({ _from: start._id, _to: end._id }));\r\n * }\r\n * );\r\n * ```\r\n */\r\n withTransaction<T>(\r\n collections: (string | collections.ArangoCollection)[],\r\n callback: (step: transactions.Transaction[\"step\"]) => Promise<T>,\r\n options?: transactions.TransactionOptions\r\n ): Promise<T>;\r\n /**\r\n * Begins and commits a transaction using the given callback. Individual\r\n * requests that are part of the transaction need to be wrapped in the step\r\n * function passed into the callback. If the promise returned by the callback\r\n * is rejected, the transaction will be aborted.\r\n *\r\n * The Collection can be specified as a collection name (string) or an object\r\n * implementing the {@link collections.ArangoCollection} interface: `Collection`,\r\n * {@link graphs.GraphVertexCollection}, {@link graphs.GraphEdgeCollection} as well as\r\n * (in TypeScript) {@link collections.DocumentCollection} and {@link collections.EdgeCollection}.\r\n *\r\n * @param collection - A collection that can be read from and written to\r\n * during the transaction.\r\n * @param callback - Callback function executing the transaction steps.\r\n * @param options - Options for the transaction.\r\n *\r\n * @example\r\n * ```js\r\n * const vertices = db.collection(\"vertices\");\r\n * const start = vertices.document(\"a\");\r\n * const end = vertices.document(\"b\");\r\n * const edges = db.collection(\"edges\");\r\n * await db.withTransaction(\r\n * edges, // collection instances can be passed directly\r\n * async (step) => {\r\n * await step(() => edges.save({ _from: start._id, _to: end._id }));\r\n * }\r\n * );\r\n * ```\r\n */\r\n withTransaction<T>(\r\n collection: string | collections.ArangoCollection,\r\n callback: (step: transactions.Transaction[\"step\"]) => Promise<T>,\r\n options?: transactions.TransactionOptions\r\n ): Promise<T>;\r\n async withTransaction<T>(\r\n collections:\r\n | transactions.TransactionCollectionOptions\r\n | (string | collections.ArangoCollection)[]\r\n | string\r\n | collections.ArangoCollection,\r\n callback: (step: transactions.Transaction[\"step\"]) => Promise<T>,\r\n options: transactions.TransactionOptions = {}\r\n ): Promise<T> {\r\n const trx = await this.beginTransaction(\r\n collections as transactions.TransactionCollectionOptions,\r\n options\r\n );\r\n try {\r\n const result = await callback((fn) => trx.step(fn));\r\n await trx.commit();\r\n return result;\r\n } catch (e) {\r\n try {\r\n await trx.abort();\r\n } catch {}\r\n throw e;\r\n }\r\n }\r\n\r\n /**\r\n * Fetches all active transactions from the database and returns an array of\r\n * transaction descriptions.\r\n *\r\n * See also {@link Database#transactions}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const transactions = await db.listTransactions();\r\n * // transactions is an array of transaction descriptions\r\n * ```\r\n */\r\n listTransactions(): Promise<transactions.TransactionDescription[]> {\r\n return this._connection.request(\r\n { pathname: \"/_api/transaction\" },\r\n (res) => res.parsedBody.transactions\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all active transactions from the database and returns an array of\r\n * {@link transactions.Transaction} instances for those transactions.\r\n *\r\n * See also {@link Database#listTransactions}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const transactions = await db.transactions();\r\n * // transactions is an array of transactions\r\n * ```\r\n */\r\n async transactions(): Promise<transactions.Transaction[]> {\r\n const transactions = await this.listTransactions();\r\n return transactions.map((data) => this.transaction(data.id));\r\n }\r\n //#endregion\r\n\r\n //#region queries\r\n /**\r\n * Performs a database query using the given `query`, then returns a new\r\n * {@link cursors.Cursor} instance for the result set.\r\n *\r\n * See the {@link aql.aql} template string handler for information about how\r\n * to create a query string without manually defining bind parameters nor\r\n * having to worry about escaping variables.\r\n *\r\n * **Note**: When executing a query in a streaming transaction using the\r\n * `step` method, the resulting cursor will be bound to that transaction and\r\n * you do not need to use the `step` method to consume it.\r\n *\r\n * @param query - An object containing an AQL query string and bind\r\n * parameters, e.g. the object returned from an {@link aql.aql} template string.\r\n * @param options - Options for the query execution.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const active = true;\r\n * const Users = db.collection(\"_users\");\r\n *\r\n * // Using an aql template string:\r\n * // Bind parameters are automatically extracted and arangojs collections\r\n * // are automatically passed as collection bind parameters.\r\n * const cursor = await db.query(aql`\r\n * FOR u IN ${Users}\r\n * FILTER u.authData.active == ${active}\r\n * RETURN u.user\r\n * `);\r\n * // cursor is a cursor for the query result\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const active = true;\r\n * const Users = db.collection(\"_users\");\r\n *\r\n * // Using an object with a regular multi-line string\r\n * const cursor = await db.query({\r\n * query: `\r\n * FOR u IN @@users\r\n * FILTER u.authData.active == @active\r\n * RETURN u.user\r\n * `,\r\n * bindVars: { active: active, \"@users\": Users.name }\r\n * });\r\n * ```\r\n */\r\n query<T = any>(\r\n query: aql.AqlQuery<T>,\r\n options?: queries.QueryOptions\r\n ): Promise<cursors.Cursor<T>>;\r\n /**\r\n * Performs a database query using the given `query` and `bindVars`, then\r\n * returns a new {@link cursors.Cursor} instance for the result set.\r\n *\r\n * See the {@link aql.aql} template string handler for a safer and easier\r\n * alternative to passing strings directly.\r\n *\r\n * **Note**: When executing a query in a streaming transaction using the\r\n * `step` method, the resulting cursor will be bound to that transaction and\r\n * you do not need to use the `step` method to consume it.\r\n *\r\n * @param query - An AQL query string.\r\n * @param bindVars - An object defining bind parameters for the query.\r\n * @param options - Options for the query execution.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const active = true;\r\n * const Users = db.collection(\"_users\");\r\n *\r\n * const cursor = await db.query(\r\n * // A normal multi-line string\r\n * `\r\n * FOR u IN @@users\r\n * FILTER u.authData.active == @active\r\n * RETURN u.user\r\n * `,\r\n * { active: active, \"@users\": Users.name }\r\n * );\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const active = true;\r\n * const Users = db.collection(\"_users\");\r\n *\r\n * const cursor = await db.query(\r\n * // An AQL literal created from a normal multi-line string\r\n * aql.literal(`\r\n * FOR u IN @@users\r\n * FILTER u.authData.active == @active\r\n * RETURN u.user\r\n * `),\r\n * { active: active, \"@users\": Users.name }\r\n * );\r\n * ```\r\n */\r\n query<T = any>(\r\n query: string | aql.AqlLiteral,\r\n bindVars?: Record<string, any>,\r\n options?: queries.QueryOptions\r\n ): Promise<cursors.Cursor<T>>;\r\n query<T = any>(\r\n query: string | aql.AqlQuery | aql.AqlLiteral,\r\n bindVars?: Record<string, any>,\r\n options: queries.QueryOptions = {}\r\n ): Promise<cursors.Cursor<T>> {\r\n if (aql.isAqlQuery(query)) {\r\n options = bindVars ?? {};\r\n bindVars = query.bindVars;\r\n query = query.query;\r\n } else if (aql.isAqlLiteral(query)) {\r\n query = query.toAQL();\r\n }\r\n const {\r\n allowDirtyRead,\r\n retryOnConflict,\r\n count,\r\n batchSize,\r\n cache,\r\n memoryLimit,\r\n ttl,\r\n timeout,\r\n ...opts\r\n } = options;\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_api/cursor\",\r\n body: {\r\n query,\r\n bindVars,\r\n count,\r\n batchSize,\r\n cache,\r\n memoryLimit,\r\n ttl,\r\n options: opts,\r\n },\r\n allowDirtyRead,\r\n retryOnConflict,\r\n timeout,\r\n },\r\n (res) =>\r\n new cursors.BatchCursor<T>(\r\n this,\r\n res.parsedBody,\r\n res.arangojsHostUrl,\r\n allowDirtyRead\r\n ).items\r\n );\r\n }\r\n\r\n /**\r\n * Explains a database query using the given `query`.\r\n *\r\n * See the {@link aql.aql} template string handler for information about how\r\n * to create a query string without manually defining bind parameters nor\r\n * having to worry about escaping variables.\r\n *\r\n * @param query - An object containing an AQL query string and bind\r\n * parameters, e.g. the object returned from an {@link aql.aql} template string.\r\n * @param options - Options for explaining the query.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collection = db.collection(\"some-collection\");\r\n * const explanation = await db.explain(aql`\r\n * FOR doc IN ${collection}\r\n * FILTER doc.flavor == \"strawberry\"\r\n * RETURN doc._key\r\n * `);\r\n * ```\r\n */\r\n explain(\r\n query: aql.AqlQuery,\r\n options?: queries.ExplainOptions & { allPlans?: false }\r\n ): Promise<connection.ArangoApiResponse<queries.SingleExplainResult>>;\r\n /**\r\n * Explains a database query using the given `query`.\r\n *\r\n * See the {@link aql.aql} template string handler for information about how\r\n * to create a query string without manually defining bind parameters nor\r\n * having to worry about escaping variables.\r\n *\r\n * @param query - An object containing an AQL query string and bind\r\n * parameters, e.g. the object returned from an {@link aql.aql} template string.\r\n * @param options - Options for explaining the query.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collection = db.collection(\"some-collection\");\r\n * const explanation = await db.explain(\r\n * aql`\r\n * FOR doc IN ${collection}\r\n * FILTER doc.flavor == \"strawberry\"\r\n * RETURN doc._key\r\n * `,\r\n * { allPlans: true }\r\n * );\r\n * ```\r\n */\r\n explain(\r\n query: aql.AqlQuery,\r\n options?: queries.ExplainOptions & { allPlans: true }\r\n ): Promise<connection.ArangoApiResponse<queries.MultiExplainResult>>;\r\n /**\r\n * Explains a database query using the given `query` and `bindVars`.\r\n *\r\n * See the {@link aql.aql} template string handler for a safer and easier\r\n * alternative to passing strings directly.\r\n *\r\n * @param query - An AQL query string.\r\n * @param bindVars - An object defining bind parameters for the query.\r\n * @param options - Options for explaining the query.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collection = db.collection(\"some-collection\");\r\n * const explanation = await db.explain(\r\n * `\r\n * FOR doc IN @@collection\r\n * FILTER doc.flavor == \"strawberry\"\r\n * RETURN doc._key\r\n * `,\r\n * { \"@collection\": collection.name }\r\n * );\r\n * ```\r\n */\r\n explain(\r\n query: string | aql.AqlLiteral,\r\n bindVars?: Record<string, any>,\r\n options?: queries.ExplainOptions & { allPlans?: false }\r\n ): Promise<connection.ArangoApiResponse<queries.SingleExplainResult>>;\r\n /**\r\n * Explains a database query using the given `query` and `bindVars`.\r\n *\r\n * See the {@link aql.aql} template string handler for a safer and easier\r\n * alternative to passing strings directly.\r\n *\r\n * @param query - An AQL query string.\r\n * @param bindVars - An object defining bind parameters for the query.\r\n * @param options - Options for explaining the query.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collection = db.collection(\"some-collection\");\r\n * const explanation = await db.explain(\r\n * `\r\n * FOR doc IN @@collection\r\n * FILTER doc.flavor == \"strawberry\"\r\n * RETURN doc._key\r\n * `,\r\n * { \"@collection\": collection.name },\r\n * { allPlans: true }\r\n * );\r\n * ```\r\n */\r\n explain(\r\n query: string | aql.AqlLiteral,\r\n bindVars?: Record<string, any>,\r\n options?: queries.ExplainOptions & { allPlans: true }\r\n ): Promise<connection.ArangoApiResponse<queries.MultiExplainResult>>;\r\n explain(\r\n query: string | aql.AqlQuery | aql.AqlLiteral,\r\n bindVars?: Record<string, any>,\r\n options?: queries.ExplainOptions\r\n ): Promise<\r\n connection.ArangoApiResponse<\r\n queries.SingleExplainResult | queries.MultiExplainResult\r\n >\r\n > {\r\n if (aql.isAqlQuery(query)) {\r\n options = bindVars;\r\n bindVars = query.bindVars;\r\n query = query.query;\r\n } else if (aql.isAqlLiteral(query)) {\r\n query = query.toAQL();\r\n }\r\n return this.request({\r\n method: \"POST\",\r\n pathname: \"/_api/explain\",\r\n body: { query, bindVars, options },\r\n });\r\n }\r\n\r\n /**\r\n * Parses the given query and returns the result.\r\n *\r\n * See the {@link aql.aql} template string handler for information about how\r\n * to create a query string without manually defining bind parameters nor\r\n * having to worry about escaping variables.\r\n *\r\n * @param query - An AQL query string or an object containing an AQL query\r\n * string and bind parameters, e.g. the object returned from an {@link aql.aql}\r\n * template string.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collection = db.collection(\"some-collection\");\r\n * const ast = await db.parse(aql`\r\n * FOR doc IN ${collection}\r\n * FILTER doc.flavor == \"strawberry\"\r\n * RETURN doc._key\r\n * `);\r\n * ```\r\n aql.*/\r\n parse(\r\n query: string | aql.AqlQuery | aql.AqlLiteral\r\n ): Promise<queries.ParseResult> {\r\n if (aql.isAqlQuery(query)) {\r\n query = query.query;\r\n } else if (aql.isAqlLiteral(query)) {\r\n query = query.toAQL();\r\n }\r\n return this.request({\r\n method: \"POST\",\r\n pathname: \"/_api/query\",\r\n body: { query },\r\n });\r\n }\r\n\r\n /**\r\n * Fetches the available optimizer rules.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const rules = await db.queryRules();\r\n * for (const rule of rules) {\r\n * console.log(rule.name);\r\n * }\r\n * ```\r\n */\r\n queryRules(): Promise<queries.QueryOptimizerRule[]> {\r\n return this.request({\r\n pathname: \"/_api/query/rules\",\r\n });\r\n }\r\n\r\n /**\r\n * Fetches the query tracking properties.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const tracking = await db.queryTracking();\r\n * console.log(tracking.enabled);\r\n * ```\r\n */\r\n queryTracking(): Promise<queries.QueryTrackingInfo>;\r\n /**\r\n * Modifies the query tracking properties.\r\n *\r\n * @param options - Options for query tracking.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // track up to 5 slow queries exceeding 5 seconds execution time\r\n * await db.queryTracking({\r\n * enabled: true,\r\n * trackSlowQueries: true,\r\n * maxSlowQueries: 5,\r\n * slowQueryThreshold: 5\r\n * });\r\n * ```\r\n */\r\n queryTracking(\r\n options: queries.QueryTrackingOptions\r\n ): Promise<queries.QueryTrackingInfo>;\r\n queryTracking(\r\n options?: queries.QueryTrackingOptions\r\n ): Promise<queries.QueryTrackingInfo> {\r\n return this.request(\r\n options\r\n ? {\r\n method: \"PUT\",\r\n pathname: \"/_api/query/properties\",\r\n body: options,\r\n }\r\n : {\r\n method: \"GET\",\r\n pathname: \"/_api/query/properties\",\r\n }\r\n );\r\n }\r\n\r\n /**\r\n * Fetches a list of information for all currently running queries.\r\n *\r\n * See also {@link Database#listSlowQueries} and {@link Database#killQuery}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const queries = await db.listRunningQueries();\r\n * ```\r\n */\r\n listRunningQueries(): Promise<queries.QueryDescription[]> {\r\n return this.request({\r\n method: \"GET\",\r\n pathname: \"/_api/query/current\",\r\n });\r\n }\r\n\r\n /**\r\n * Fetches a list of information for all recent slow queries.\r\n *\r\n * See also {@link Database#listRunningQueries} and\r\n * {@link Database#clearSlowQueries}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const queries = await db.listSlowQueries();\r\n * // Only works if slow query tracking is enabled\r\n * ```\r\n */\r\n listSlowQueries(): Promise<queries.QueryDescription[]> {\r\n return this.request({\r\n method: \"GET\",\r\n pathname: \"/_api/query/slow\",\r\n });\r\n }\r\n\r\n /**\r\n * Clears the list of recent slow queries.\r\n *\r\n * See also {@link Database#listSlowQueries}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.clearSlowQueries();\r\n * // Slow query list is now cleared\r\n * ```\r\n */\r\n clearSlowQueries(): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: \"/_api/query/slow\",\r\n },\r\n () => undefined\r\n );\r\n }\r\n\r\n /**\r\n * Kills a running query with the given `queryId`.\r\n *\r\n * See also {@link Database#listRunningQueries}.\r\n *\r\n * @param queryId - The ID of a currently running query.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const queries = await db.listRunningQueries();\r\n * await Promise.all(queries.map(\r\n * async (query) => {\r\n * if (query.state === \"executing\") {\r\n * await db.killQuery(query.id);\r\n * }\r\n * }\r\n * ));\r\n * ```\r\n */\r\n killQuery(queryId: string): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: `/_api/query/${encodeURIComponent(queryId)}`,\r\n },\r\n () => undefined\r\n );\r\n }\r\n\r\n /**\r\n * Fetches a list of all entries in the AQL query results cache of the\r\n * current database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const entries = await db.listQueryCacheEntries();\r\n * console.log(entries);\r\n * ```\r\n */\r\n listQueryCacheEntries(): Promise<queries.QueryCacheEntry[]> {\r\n return this.request({\r\n pathname: \"/_api/query-cache/entries\",\r\n });\r\n }\r\n\r\n /**\r\n * Clears the AQL query results cache of the current database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.clearQueryCache();\r\n * // Cache is now cleared\r\n * ```\r\n */\r\n clearQueryCache(): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: \"/_api/query-cache\",\r\n },\r\n () => undefined\r\n );\r\n }\r\n\r\n /**\r\n * Fetches the global properties for the AQL query results cache.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const properties = await db.getQueryCacheProperties();\r\n * console.log(properties);\r\n * ```\r\n */\r\n getQueryCacheProperties(): Promise<queries.QueryCacheProperties> {\r\n return this.request({\r\n pathname: \"/_api/query-cache/properties\",\r\n });\r\n }\r\n\r\n /**\r\n * Updates the global properties for the AQL query results cache.\r\n *\r\n * @param properties - The new properties for the AQL query results cache.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.setQueryCacheProperties({ maxResults: 9000 });\r\n * ```\r\n */\r\n setQueryCacheProperties(\r\n properties: queries.QueryCachePropertiesOptions\r\n ): Promise<queries.QueryCacheProperties> {\r\n return this.request({\r\n method: \"PUT\",\r\n pathname: \"/_api/query-cache/properties\",\r\n body: properties,\r\n });\r\n }\r\n //#endregion\r\n\r\n //#region user functions\r\n /**\r\n * Fetches a list of all AQL user functions registered with the database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const functions = await db.listUserFunctions();\r\n * const names = functions.map(fn => fn.name);\r\n * ```\r\n */\r\n listUserFunctions(): Promise<queries.UserFunctionDescription[]> {\r\n return this.request(\r\n { pathname: \"/_api/aqlfunction\" },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Creates an AQL user function with the given _name_ and _code_ if it does\r\n * not already exist or replaces it if a function with the same name already\r\n * existed.\r\n *\r\n * @param name - A valid AQL function name. The function name must consist\r\n * of at least two alphanumeric identifiers separated with double colons.\r\n * @param code - A string evaluating to a JavaScript function (not a\r\n * JavaScript function object).\r\n * @param isDeterministic - If set to `true`, the function is expected to\r\n * always return the same result for equivalent inputs. This option currently\r\n * has no effect but may allow for optimizations in the future.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.createUserFunction(\r\n * \"ACME::ACCOUNTING::CALCULATE_VAT\",\r\n * \"(price) => price * 0.19\"\r\n * );\r\n * // Use the new function in an AQL query with template handler:\r\n * const cursor = await db.query(aql`\r\n * FOR product IN products\r\n * RETURN MERGE(\r\n * { vat: ACME::ACCOUNTING::CALCULATE_VAT(product.price) },\r\n * product\r\n * )\r\n * `);\r\n * // cursor is a cursor for the query result\r\n * ```\r\n */\r\n createUserFunction(\r\n name: string,\r\n code: string,\r\n isDeterministic: boolean = false\r\n ): Promise<connection.ArangoApiResponse<{ isNewlyCreated: boolean }>> {\r\n return this.request({\r\n method: \"POST\",\r\n pathname: \"/_api/aqlfunction\",\r\n body: { name, code, isDeterministic },\r\n });\r\n }\r\n\r\n /**\r\n * Deletes the AQL user function with the given name from the database.\r\n *\r\n * @param name - The name of the user function to drop.\r\n * @param group - If set to `true`, all functions with a name starting with\r\n * `name` will be deleted, otherwise only the function with the exact name\r\n * will be deleted.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.dropUserFunction(\"ACME::ACCOUNTING::CALCULATE_VAT\");\r\n * // the function no longer exists\r\n * ```\r\n */\r\n dropUserFunction(\r\n name: string,\r\n group: boolean = false\r\n ): Promise<connection.ArangoApiResponse<{ deletedCount: number }>> {\r\n return this.request({\r\n method: \"DELETE\",\r\n pathname: `/_api/aqlfunction/${encodeURIComponent(name)}`,\r\n search: { group },\r\n });\r\n }\r\n //#endregion\r\n\r\n //#region services\r\n /**\r\n * Fetches a list of all installed service.\r\n *\r\n * @param excludeSystem - Whether system services should be excluded.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const services = await db.listServices();\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const services = await db.listServices(false); // all services\r\n * ```\r\n */\r\n listServices(\r\n excludeSystem: boolean = true\r\n ): Promise<services.ServiceSummary[]> {\r\n return this.request({\r\n pathname: \"/_api/foxx\",\r\n search: { excludeSystem },\r\n });\r\n }\r\n\r\n /**\r\n * Installs a new service.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param source - The service bundle to install.\r\n * @param options - Options for installing the service.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Using a Buffer in Node.js as source\r\n * const source = new Blob([await fs.readFileSync(\"./my-foxx-service.zip\")]);\r\n * const info = await db.installService(\"/hello\", source);\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Using a Blob in Node.js as source\r\n * const source = await fs.openAsBlob(\"./my-foxx-service.zip\");\r\n * const info = await db.installService(\"/hello\", source);\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Using a File from a browser file input as source\r\n * const element = document.getElementById(\"my-file-input\");\r\n * const source = element.files[0];\r\n * const info = await db.installService(\"/hello\", source);\r\n * ```\r\n */\r\n async installService(\r\n mount: string,\r\n source: Blob | string,\r\n options: services.InstallServiceOptions = {}\r\n ): Promise<services.ServiceDescription> {\r\n const { configuration, dependencies, ...search } = options;\r\n const form = new FormData();\r\n if (configuration) {\r\n form.append(\"configuration\", JSON.stringify(configuration));\r\n }\r\n if (dependencies) {\r\n form.append(\"dependencies\", JSON.stringify(dependencies));\r\n }\r\n form.append(\r\n \"source\",\r\n typeof source === \"string\" ? JSON.stringify(source) : source\r\n );\r\n return await this.request({\r\n body: form,\r\n method: \"POST\",\r\n pathname: \"/_api/foxx\",\r\n search: { ...search, mount },\r\n });\r\n }\r\n\r\n /**\r\n * Replaces an existing service with a new service by completely removing the\r\n * old service and installing a new service at the same mount point.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param source - The service bundle to install.\r\n * @param options - Options for replacing the service.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Using a Buffer in Node.js as source\r\n * const source = new Blob([await fs.readFileSync(\"./my-foxx-service.zip\")]);\r\n * const info = await db.replaceService(\"/hello\", source);\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Using a Blob in Node.js as source\r\n * const source = await fs.openAsBlob(\"./my-foxx-service.zip\");\r\n * const info = await db.replaceService(\"/hello\", source);\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Using a File from a browser file input as source\r\n * const element = document.getElementById(\"my-file-input\");\r\n * const source = element.files[0];\r\n * const info = await db.replaceService(\"/hello\", source);\r\n * ```\r\n */\r\n async replaceService(\r\n mount: string,\r\n source: Blob | string,\r\n options: services.ReplaceServiceOptions = {}\r\n ): Promise<services.ServiceDescription> {\r\n const { configuration, dependencies, ...search } = options;\r\n const form = new FormData();\r\n if (configuration) {\r\n form.append(\"configuration\", JSON.stringify(configuration));\r\n }\r\n if (dependencies) {\r\n form.append(\"dependencies\", JSON.stringify(dependencies));\r\n }\r\n form.append(\r\n \"source\",\r\n typeof source === \"string\" ? JSON.stringify(source) : source\r\n );\r\n return await this.request({\r\n body: form,\r\n method: \"PUT\",\r\n pathname: \"/_api/foxx/service\",\r\n search: { ...search, mount },\r\n });\r\n }\r\n\r\n /**\r\n * Replaces an existing service with a new service while retaining the old\r\n * service's configuration and dependencies.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param source - The service bundle to install.\r\n * @param options - Options for upgrading the service.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Using a Buffer in Node.js as source\r\n * const source = new Blob([await fs.readFileSync(\"./my-foxx-service.zip\")]);\r\n * const info = await db.upgradeService(\"/hello\", source);\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Using a Blob in Node.js as source\r\n * const source = await fs.openAsBlob(\"./my-foxx-service.zip\");\r\n * const info = await db.upgradeService(\"/hello\", source);\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Using a File from a browser file input as source\r\n * const element = document.getElementById(\"my-file-input\");\r\n * const source = element.files[0];\r\n * const info = await db.upgradeService(\"/hello\", source);\r\n * ```\r\n */\r\n async upgradeService(\r\n mount: string,\r\n source: Blob | string,\r\n options: services.UpgradeServiceOptions = {}\r\n ): Promise<services.ServiceDescription> {\r\n const { configuration, dependencies, ...search } = options;\r\n const form = new FormData();\r\n if (configuration) {\r\n form.append(\"configuration\", JSON.stringify(configuration));\r\n }\r\n if (dependencies) {\r\n form.append(\"dependencies\", JSON.stringify(dependencies));\r\n }\r\n form.append(\r\n \"source\",\r\n typeof source === \"string\" ? JSON.stringify(source) : source\r\n );\r\n return await this.request({\r\n body: form,\r\n method: \"PATCH\",\r\n pathname: \"/_api/foxx/service\",\r\n search: { ...search, mount },\r\n });\r\n }\r\n\r\n /**\r\n * Completely removes a service from the database.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param options - Options for uninstalling the service.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.uninstallService(\"/my-foxx\");\r\n * ```\r\n */\r\n uninstallService(\r\n mount: string,\r\n options?: services.UninstallServiceOptions\r\n ): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: \"/_api/foxx/service\",\r\n search: { ...options, mount },\r\n },\r\n () => undefined\r\n );\r\n }\r\n\r\n /**\r\n * Retrieves information about a mounted service.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const info = await db.getService(\"/my-service\");\r\n * // info contains detailed information about the service\r\n * ```\r\n */\r\n getService(mount: string): Promise<services.ServiceDescription> {\r\n return this.request({\r\n pathname: \"/_api/foxx/service\",\r\n search: { mount },\r\n });\r\n }\r\n\r\n /**\r\n * Retrieves information about the service's configuration options and their\r\n * current values.\r\n *\r\n * See also {@link Database#replaceServiceConfiguration} and\r\n * {@link Database#updateServiceConfiguration}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * configuration option's current value. Otherwise it will include the full\r\n * definition for each option.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const config = await db.getServiceConfiguration(\"/my-service\");\r\n * for (const [key, option] of Object.entries(config)) {\r\n * console.log(`${option.title} (${key}): ${option.current}`);\r\n * }\r\n * ```\r\n */\r\n getServiceConfiguration(\r\n mount: string,\r\n minimal?: false\r\n ): Promise<Record<string, services.ServiceConfiguration>>;\r\n /**\r\n * Retrieves information about the service's configuration options and their\r\n * current values.\r\n *\r\n * See also {@link Database#replaceServiceConfiguration} and\r\n * {@link Database#updateServiceConfiguration}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * configuration option's current value. Otherwise it will include the full\r\n * definition for each option.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const config = await db.getServiceConfiguration(\"/my-service\", true);\r\n * for (const [key, value] of Object.entries(config)) {\r\n * console.log(`${key}: ${value}`);\r\n * }\r\n * ```\r\n */\r\n getServiceConfiguration(\r\n mount: string,\r\n minimal: true\r\n ): Promise<Record<string, any>>;\r\n getServiceConfiguration(mount: string, minimal: boolean = false) {\r\n return this.request({\r\n pathname: \"/_api/foxx/configuration\",\r\n search: { mount, minimal },\r\n });\r\n }\r\n\r\n /**\r\n * Replaces the configuration of the given service, discarding any existing\r\n * values for options not specified.\r\n *\r\n * See also {@link Database#updateServiceConfiguration} and\r\n * {@link Database#getServiceConfiguration}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param cfg - An object mapping configuration option names to values.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * configuration option's current value and warning (if any).\r\n * Otherwise it will include the full definition for each option.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const config = { currency: \"USD\", locale: \"en-US\" };\r\n * const info = await db.replaceServiceConfiguration(\"/my-service\", config);\r\n * for (const [key, option] of Object.entries(info)) {\r\n * console.log(`${option.title} (${key}): ${option.value}`);\r\n * if (option.warning) console.warn(`Warning: ${option.warning}`);\r\n * }\r\n * ```\r\n */\r\n replaceServiceConfiguration(\r\n mount: string,\r\n cfg: Record<string, any>,\r\n minimal?: false\r\n ): Promise<\r\n Record<string, services.ServiceConfiguration & { warning?: string }>\r\n >;\r\n /**\r\n * Replaces the configuration of the given service, discarding any existing\r\n * values for options not specified.\r\n *\r\n * See also {@link Database#updateServiceConfiguration} and\r\n * {@link Database#getServiceConfiguration}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param cfg - An object mapping configuration option names to values.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * configuration option's current value and warning (if any).\r\n * Otherwise it will include the full definition for each option.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const config = { currency: \"USD\", locale: \"en-US\" };\r\n * const info = await db.replaceServiceConfiguration(\"/my-service\", config);\r\n * for (const [key, value] of Object.entries(info.values)) {\r\n * console.log(`${key}: ${value}`);\r\n * if (info.warnings[key]) console.warn(`Warning: ${info.warnings[key]}`);\r\n * }\r\n * ```\r\n */\r\n replaceServiceConfiguration(\r\n mount: string,\r\n cfg: Record<string, any>,\r\n minimal: true\r\n ): Promise<{\r\n values: Record<string, any>;\r\n warnings: Record<string, string>;\r\n }>;\r\n replaceServiceConfiguration(\r\n mount: string,\r\n cfg: Record<string, any>,\r\n minimal: boolean = false\r\n ) {\r\n return this.request({\r\n method: \"PUT\",\r\n pathname: \"/_api/foxx/configuration\",\r\n body: cfg,\r\n search: { mount, minimal },\r\n });\r\n }\r\n\r\n /**\r\n * Updates the configuration of the given service while maintaining any\r\n * existing values for options not specified.\r\n *\r\n * See also {@link Database#replaceServiceConfiguration} and\r\n * {@link Database#getServiceConfiguration}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param cfg - An object mapping configuration option names to values.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * configuration option's current value and warning (if any).\r\n * Otherwise it will include the full definition for each option.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const config = { currency: \"USD\", locale: \"en-US\" };\r\n * const info = await db.updateServiceConfiguration(\"/my-service\", config);\r\n * for (const [key, option] of Object.entries(info)) {\r\n * console.log(`${option.title} (${key}): ${option.value}`);\r\n * if (option.warning) console.warn(`Warning: ${option.warning}`);\r\n * }\r\n * ```\r\n */\r\n updateServiceConfiguration(\r\n mount: string,\r\n cfg: Record<string, any>,\r\n minimal?: false\r\n ): Promise<\r\n Record<string, services.ServiceConfiguration & { warning?: string }>\r\n >;\r\n /**\r\n * Updates the configuration of the given service while maintaining any\r\n * existing values for options not specified.\r\n *\r\n * See also {@link Database#replaceServiceConfiguration} and\r\n * {@link Database#getServiceConfiguration}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param cfg - An object mapping configuration option names to values.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * configuration option's current value and warning (if any).\r\n * Otherwise it will include the full definition for each option.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const config = { currency: \"USD\", locale: \"en-US\" };\r\n * const info = await db.updateServiceConfiguration(\"/my-service\", config);\r\n * for (const [key, value] of Object.entries(info.values)) {\r\n * console.log(`${key}: ${value}`);\r\n * if (info.warnings[key]) console.warn(`Warning: ${info.warnings[key]}`);\r\n * }\r\n * ```\r\n */\r\n updateServiceConfiguration(\r\n mount: string,\r\n cfg: Record<string, any>,\r\n minimal: true\r\n ): Promise<{\r\n values: Record<string, any>;\r\n warnings: Record<string, string>;\r\n }>;\r\n updateServiceConfiguration(\r\n mount: string,\r\n cfg: Record<string, any>,\r\n minimal: boolean = false\r\n ) {\r\n return this.request({\r\n method: \"PATCH\",\r\n pathname: \"/_api/foxx/configuration\",\r\n body: cfg,\r\n search: { mount, minimal },\r\n });\r\n }\r\n\r\n /**\r\n * Retrieves information about the service's dependencies and their current\r\n * mount points.\r\n *\r\n * See also {@link Database#replaceServiceDependencies} and\r\n * {@link Database#updateServiceDependencies}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * dependency's current mount point. Otherwise it will include the full\r\n * definition for each dependency.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const deps = await db.getServiceDependencies(\"/my-service\");\r\n * for (const [key, dep] of Object.entries(deps)) {\r\n * console.log(`${dep.title} (${key}): ${dep.current}`);\r\n * }\r\n * ```\r\n */\r\n getServiceDependencies(\r\n mount: string,\r\n minimal?: false\r\n ): Promise<\r\n Record<\r\n string,\r\n services.SingleServiceDependency | services.MultiServiceDependency\r\n >\r\n >;\r\n /**\r\n * Retrieves information about the service's dependencies and their current\r\n * mount points.\r\n *\r\n * See also {@link Database#replaceServiceDependencies} and\r\n * {@link Database#updateServiceDependencies}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * dependency's current mount point. Otherwise it will include the full\r\n * definition for each dependency.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const deps = await db.getServiceDependencies(\"/my-service\", true);\r\n * for (const [key, value] of Object.entries(deps)) {\r\n * console.log(`${key}: ${value}`);\r\n * }\r\n * ```\r\n */\r\n getServiceDependencies(\r\n mount: string,\r\n minimal: true\r\n ): Promise<Record<string, string | string[]>>;\r\n getServiceDependencies(mount: string, minimal: boolean = false) {\r\n return this.request({\r\n pathname: \"/_api/foxx/dependencies\",\r\n search: { mount, minimal },\r\n });\r\n }\r\n\r\n /**\r\n * Replaces the dependencies of the given service, discarding any existing\r\n * mount points for dependencies not specified.\r\n *\r\n * See also {@link Database#updateServiceDependencies} and\r\n * {@link Database#getServiceDependencies}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param deps - An object mapping dependency aliases to mount points.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * dependency's current mount point. Otherwise it will include the full\r\n * definition for each dependency.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const deps = { mailer: \"/mailer-api\", auth: \"/remote-auth\" };\r\n * const info = await db.replaceServiceDependencies(\"/my-service\", deps);\r\n * for (const [key, dep] of Object.entries(info)) {\r\n * console.log(`${dep.title} (${key}): ${dep.current}`);\r\n * if (dep.warning) console.warn(`Warning: ${dep.warning}`);\r\n * }\r\n * ```\r\n */\r\n replaceServiceDependencies(\r\n mount: string,\r\n deps: Record<string, string>,\r\n minimal?: false\r\n ): Promise<\r\n Record<\r\n string,\r\n (services.SingleServiceDependency | services.MultiServiceDependency) & {\r\n warning?: string;\r\n }\r\n >\r\n >;\r\n /**\r\n * Replaces the dependencies of the given service, discarding any existing\r\n * mount points for dependencies not specified.\r\n *\r\n * See also {@link Database#updateServiceDependencies} and\r\n * {@link Database#getServiceDependencies}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param deps - An object mapping dependency aliases to mount points.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * dependency's current mount point. Otherwise it will include the full\r\n * definition for each dependency.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const deps = { mailer: \"/mailer-api\", auth: \"/remote-auth\" };\r\n * const info = await db.replaceServiceDependencies(\r\n * \"/my-service\",\r\n * deps,\r\n * true\r\n * );\r\n * for (const [key, value] of Object.entries(info)) {\r\n * console.log(`${key}: ${value}`);\r\n * if (info.warnings[key]) console.warn(`Warning: ${info.warnings[key]}`);\r\n * }\r\n * ```\r\n */\r\n replaceServiceDependencies(\r\n mount: string,\r\n deps: Record<string, string>,\r\n minimal: true\r\n ): Promise<{\r\n values: Record<string, string>;\r\n warnings: Record<string, string>;\r\n }>;\r\n replaceServiceDependencies(\r\n mount: string,\r\n deps: Record<string, string>,\r\n minimal: boolean = false\r\n ) {\r\n return this.request({\r\n method: \"PUT\",\r\n pathname: \"/_api/foxx/dependencies\",\r\n body: deps,\r\n search: { mount, minimal },\r\n });\r\n }\r\n\r\n /**\r\n * Updates the dependencies of the given service while maintaining any\r\n * existing mount points for dependencies not specified.\r\n *\r\n * See also {@link Database#replaceServiceDependencies} and\r\n * {@link Database#getServiceDependencies}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param deps - An object mapping dependency aliases to mount points.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * dependency's current mount point. Otherwise it will include the full\r\n * definition for each dependency.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const deps = { mailer: \"/mailer-api\", auth: \"/remote-auth\" };\r\n * const info = await db.updateServiceDependencies(\"/my-service\", deps);\r\n * for (const [key, dep] of Object.entries(info)) {\r\n * console.log(`${dep.title} (${key}): ${dep.current}`);\r\n * if (dep.warning) console.warn(`Warning: ${dep.warning}`);\r\n * }\r\n * ```\r\n */\r\n updateServiceDependencies(\r\n mount: string,\r\n deps: Record<string, string>,\r\n minimal?: false\r\n ): Promise<\r\n Record<\r\n string,\r\n (services.SingleServiceDependency | services.MultiServiceDependency) & {\r\n warning?: string;\r\n }\r\n >\r\n >;\r\n /**\r\n * Updates the dependencies of the given service while maintaining any\r\n * existing mount points for dependencies not specified.\r\n *\r\n * See also {@link Database#replaceServiceDependencies} and\r\n * {@link Database#getServiceDependencies}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param deps - An object mapping dependency aliases to mount points.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * dependency's current mount point. Otherwise it will include the full\r\n * definition for each dependency.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const deps = { mailer: \"/mailer-api\", auth: \"/remote-auth\" };\r\n * const info = await db.updateServiceDependencies(\r\n * \"/my-service\",\r\n * deps,\r\n * true\r\n * );\r\n * for (const [key, value] of Object.entries(info)) {\r\n * console.log(`${key}: ${value}`);\r\n * if (info.warnings[key]) console.warn(`Warning: ${info.warnings[key]}`);\r\n * }\r\n * ```\r\n */\r\n updateServiceDependencies(\r\n mount: string,\r\n deps: Record<string, string>,\r\n minimal: true\r\n ): Promise<{\r\n values: Record<string, string>;\r\n warnings: Record<string, string>;\r\n }>;\r\n updateServiceDependencies(\r\n mount: string,\r\n deps: Record<string, string>,\r\n minimal: boolean = false\r\n ) {\r\n return this.request({\r\n method: \"PATCH\",\r\n pathname: \"/_api/foxx/dependencies\",\r\n body: deps,\r\n search: { mount, minimal },\r\n });\r\n }\r\n\r\n /**\r\n * Enables or disables development mode for the given service.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param enabled - Whether development mode should be enabled or disabled.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.setServiceDevelopmentMode(\"/my-service\", true);\r\n * // the service is now in development mode\r\n * await db.setServiceDevelopmentMode(\"/my-service\", false);\r\n * // the service is now in production mode\r\n * ```\r\n */\r\n setServiceDevelopmentMode(\r\n mount: string,\r\n enabled: boolean = true\r\n ): Promise<services.ServiceDescription> {\r\n return this.request({\r\n method: enabled ? \"POST\" : \"DELETE\",\r\n pathname: \"/_api/foxx/development\",\r\n search: { mount },\r\n });\r\n }\r\n\r\n /**\r\n * Retrieves an object mapping script names to their human readable\r\n * representations, as defined in the service manifest's \"scripts\" section.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const scripts = await db.getServiceScripts(\"/my-service\");\r\n * for (const [name, title] of Object.entries(scripts)) {\r\n * console.log(`${name}: ${title}`);\r\n * }\r\n * ```\r\n */\r\n getServiceScripts(mount: string): Promise<Record<string, string>> {\r\n return this.request({\r\n pathname: \"/_api/foxx/scripts\",\r\n search: { mount },\r\n });\r\n }\r\n\r\n /**\r\n * Executes a service script and retrieves its result exposed as\r\n * `module.exports` (if any).\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param name - Name of the service script to execute as defined in the\r\n * service manifest.\r\n * @param params - Arbitrary value that will be exposed to the script as\r\n * `argv[0]` in the service context (e.g. `module.context.argv[0]`).\r\n * Must be serializable to JSON.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const result = await db.runServiceScript(\r\n * \"/my-service\",\r\n * \"create-user\",\r\n * {\r\n * username: \"service_admin\",\r\n * password: \"hunter2\"\r\n * }\r\n * );\r\n * ```\r\n */\r\n runServiceScript(mount: string, name: string, params?: any): Promise<any> {\r\n return this.request({\r\n method: \"POST\",\r\n pathname: `/_api/foxx/scripts/${encodeURIComponent(name)}`,\r\n body: params,\r\n search: { mount },\r\n });\r\n }\r\n\r\n /**\r\n * Runs the tests of a given service and returns the results using the\r\n * \"default\" reporter.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param options - Options for running the tests.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const testReport = await db.runServiceTests(\"/my-foxx\");\r\n * ```\r\n */\r\n runServiceTests(\r\n mount: string,\r\n options?: {\r\n reporter?: \"default\";\r\n /**\r\n * Whether the reporter should use \"idiomatic\" mode. Has no effect when\r\n * using the \"default\" or \"suite\" reporters.\r\n */\r\n idiomatic?: false;\r\n /**\r\n * If set, only tests with full names including this exact string will be\r\n * executed.\r\n */\r\n filter?: string;\r\n }\r\n ): Promise<services.ServiceTestDefaultReport>;\r\n /**\r\n * Runs the tests of a given service and returns the results using the\r\n * \"suite\" reporter, which groups the test result by test suite.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param options - Options for running the tests.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const suiteReport = await db.runServiceTests(\r\n * \"/my-foxx\",\r\n * { reporter: \"suite\" }\r\n * );\r\n * ```\r\n */\r\n runServiceTests(\r\n mount: string,\r\n options: {\r\n reporter: \"suite\";\r\n /**\r\n * Whether the reporter should use \"idiomatic\" mode. Has no effect when\r\n * using the \"default\" or \"suite\" reporters.\r\n */\r\n idiomatic?: false;\r\n /**\r\n * If set, only tests with full names including this exact string will be\r\n * executed.\r\n */\r\n filter?: string;\r\n }\r\n ): Promise<services.ServiceTestSuiteReport>;\r\n /**\r\n * Runs the tests of a given service and returns the results using the\r\n * \"stream\" reporter, which represents the results as a sequence of tuples\r\n * representing events.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param options - Options for running the tests.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const streamEvents = await db.runServiceTests(\r\n * \"/my-foxx\",\r\n * { reporter: \"stream\" }\r\n * );\r\n * ```\r\n */\r\n runServiceTests(\r\n mount: string,\r\n options: {\r\n reporter: \"stream\";\r\n /**\r\n * Whether the reporter should use \"idiomatic\" mode. If set to `true`,\r\n * the results will be returned as a formatted string.\r\n */\r\n idiomatic?: false;\r\n /**\r\n * If set, only tests with full names including this exact string will be\r\n * executed.\r\n */\r\n filter?: string;\r\n }\r\n ): Promise<services.ServiceTestStreamReport>;\r\n /**\r\n * Runs the tests of a given service and returns the results using the\r\n * \"tap\" reporter, which represents the results as an array of strings using\r\n * the \"tap\" format.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param options - Options for running the tests.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const tapLines = await db.runServiceTests(\r\n * \"/my-foxx\",\r\n * { reporter: \"tap\" }\r\n * );\r\n * ```\r\n */\r\n runServiceTests(\r\n mount: string,\r\n options: {\r\n reporter: \"tap\";\r\n /**\r\n * Whether the reporter should use \"idiomatic\" mode. If set to `true`,\r\n * the results will be returned as a formatted string.\r\n */\r\n idiomatic?: false;\r\n /**\r\n * If set, only tests with full names including this exact string will be\r\n * executed.\r\n */\r\n filter?: string;\r\n }\r\n ): Promise<services.ServiceTestTapReport>;\r\n /**\r\n * Runs the tests of a given service and returns the results using the\r\n * \"xunit\" reporter, which represents the results as an XML document using\r\n * the JSONML exchange format.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param options - Options for running the tests.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const jsonML = await db.runServiceTests(\r\n * \"/my-foxx\",\r\n * { reporter: \"xunit\" }\r\n * );\r\n * ```\r\n */\r\n runServiceTests(\r\n mount: string,\r\n options: {\r\n reporter: \"xunit\";\r\n /**\r\n * Whether the reporter should use \"idiomatic\" mode. If set to `true`,\r\n * the results will be returned as a formatted string.\r\n */\r\n idiomatic?: false;\r\n /**\r\n * If set, only tests with full names including this exact string will be\r\n * executed.\r\n */\r\n filter?: string;\r\n }\r\n ): Promise<services.ServiceTestXunitReport>;\r\n /**\r\n * Runs the tests of a given service and returns the results as a string\r\n * using the \"stream\" reporter in \"idiomatic\" mode, which represents the\r\n * results as a line-delimited JSON stream of tuples representing events.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param options - Options for running the tests.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const streamReport = await db.runServiceTests(\r\n * \"/my-foxx\",\r\n * { reporter: \"stream\", idiomatic: true }\r\n * );\r\n * ```\r\n */\r\n runServiceTests(\r\n mount: string,\r\n options: {\r\n reporter: \"stream\";\r\n /**\r\n * Whether the reporter should use \"idiomatic\" mode. If set to `false`,\r\n * the results will be returned as an array of tuples instead of a\r\n * string.\r\n */\r\n idiomatic: true;\r\n /**\r\n * If set, only tests with full names including this exact string will be\r\n * executed.\r\n */\r\n filter?: string;\r\n }\r\n ): Promise<string>;\r\n /**\r\n * Runs the tests of a given service and returns the results as a string\r\n * using the \"tap\" reporter in \"idiomatic\" mode, which represents the\r\n * results using the \"tap\" format.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param options - Options for running the tests.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const tapReport = await db.runServiceTests(\r\n * \"/my-foxx\",\r\n * { reporter: \"tap\", idiomatic: true }\r\n * );\r\n * ```\r\n */\r\n runServiceTests(\r\n mount: string,\r\n options: {\r\n reporter: \"tap\";\r\n /**\r\n * Whether the reporter should use \"idiomatic\" mode. If set to `false`,\r\n * the results will be returned as an array of strings instead of a\r\n * single string.\r\n */\r\n idiomatic: true;\r\n /**\r\n * If set, only tests with full names including this exact string will be\r\n * executed.\r\n */\r\n filter?: string;\r\n }\r\n ): Promise<string>;\r\n /**\r\n * Runs the tests of a given service and returns the results as a string\r\n * using the \"xunit\" reporter in \"idiomatic\" mode, which represents the\r\n * results as an XML document.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param options - Options for running the tests.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const xml = await db.runServiceTests(\r\n * \"/my-foxx\",\r\n * { reporter: \"xunit\", idiomatic: true }\r\n * );\r\n * ```\r\n */\r\n runServiceTests(\r\n mount: string,\r\n options: {\r\n reporter: \"xunit\";\r\n /**\r\n * Whether the reporter should use \"idiomatic\" mode. If set to `false`,\r\n * the results will be returned using the JSONML exchange format\r\n * instead of a string.\r\n */\r\n idiomatic: true;\r\n /**\r\n * If set, only tests with full names including this exact string will be\r\n * executed.\r\n */\r\n filter?: string;\r\n }\r\n ): Promise<string>;\r\n runServiceTests(\r\n mount: string,\r\n options?: {\r\n reporter?: string;\r\n idiomatic?: boolean;\r\n filter?: string;\r\n }\r\n ) {\r\n return this.request({\r\n method: \"POST\",\r\n pathname: \"/_api/foxx/tests\",\r\n search: {\r\n ...options,\r\n mount,\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Retrieves the text content of the service's `README` or `README.md` file.\r\n *\r\n * Returns `undefined` if no such file could be found.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const readme = await db.getServiceReadme(\"/my-service\");\r\n * if (readme !== undefined) console.log(readme);\r\n * else console.warn(`No README found.`)\r\n * ```\r\n */\r\n getServiceReadme(mount: string): Promise<string | undefined> {\r\n return this.request({\r\n pathname: \"/_api/foxx/readme\",\r\n search: { mount },\r\n });\r\n }\r\n\r\n /**\r\n * Retrieves an Open API compatible Swagger API description object for the\r\n * service installed at the given mount point.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const spec = await db.getServiceDocumentation(\"/my-service\");\r\n * // spec is a Swagger API description of the service\r\n * ```\r\n */\r\n getServiceDocumentation(mount: string): Promise<services.SwaggerJson> {\r\n return this.request({\r\n pathname: \"/_api/foxx/swagger\",\r\n search: { mount },\r\n });\r\n }\r\n\r\n /**\r\n * Retrieves a zip bundle containing the service files.\r\n *\r\n * Returns a `Buffer` in node.js or `Blob` in the browser.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const serviceBundle = await db.downloadService(\"/my-foxx\");\r\n * ```\r\n */\r\n downloadService(mount: string): Promise<Buffer | Blob> {\r\n return this.request({\r\n method: \"POST\",\r\n pathname: \"/_api/foxx/download\",\r\n search: { mount },\r\n expectBinary: true,\r\n });\r\n }\r\n\r\n /**\r\n * Writes all locally available services to the database and updates any\r\n * service bundles missing in the database.\r\n *\r\n * @param replace - If set to `true`, outdated services will also be\r\n * committed. This can be used to solve some consistency problems when\r\n * service bundles are missing in the database or were deleted manually.\r\n *\r\n * @example\r\n * ```js\r\n * await db.commitLocalServiceState();\r\n * // all services available on the coordinator have been written to the db\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * await db.commitLocalServiceState(true);\r\n * // all service conflicts have been resolved in favor of this coordinator\r\n * ```\r\n */\r\n commitLocalServiceState(replace: boolean = false): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_api/foxx/commit\",\r\n search: { replace },\r\n },\r\n () => undefined\r\n );\r\n }\r\n //#endregion\r\n //#region hot backups\r\n /**\r\n * (Enterprise Edition only.) Creates a hot backup of the entire ArangoDB\r\n * deployment including all databases, collections, etc.\r\n *\r\n * Returns an object describing the backup result.\r\n *\r\n * @param options - Options for creating the backup.\r\n *\r\n * @example\r\n * ```js\r\n * const info = await db.createHotBackup();\r\n * // a hot backup has been created\r\n * ```\r\n */\r\n createHotBackup(\r\n options: hotBackups.HotBackupOptions = {}\r\n ): Promise<hotBackups.HotBackupResult> {\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_admin/backup/create\",\r\n body: options,\r\n },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * (Enterprise Edition only.) Retrieves a list of all locally found hot\r\n * backups.\r\n *\r\n * @param id - If specified, only the backup with the given ID will be\r\n * returned.\r\n *\r\n * @example\r\n * ```js\r\n * const backups = await db.getHotBackups();\r\n * for (const backup of backups.list) {\r\n * console.log(backup.id);\r\n * }\r\n * ```\r\n */\r\n getHotBackups(id?: string | string[]): Promise<hotBackups.HotBackupList> {\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_admin/backup/list\",\r\n body: id ? { id } : undefined,\r\n },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * (Enteprise Edition only.) Restores a consistent local hot backup.\r\n *\r\n * Returns the directory path of the restored backup.\r\n *\r\n * @param id - The ID of the backup to restore.\r\n *\r\n * @example\r\n * ```js\r\n * await db.restoreHotBackup(\"2023-09-19T15.38.21Z_example\");\r\n * // the backup has been restored\r\n * ```\r\n */\r\n restoreHotBackup(id: string): Promise<string> {\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_admin/backup/restore\",\r\n body: { id },\r\n },\r\n (res) => res.parsedBody.result.previous\r\n );\r\n }\r\n\r\n /**\r\n * (Enterprise Edition only.) Deletes a local hot backup.\r\n *\r\n * @param id - The ID of the backup to delete.\r\n *\r\n * @example\r\n * ```js\r\n * await db.deleteHotBackup(\"2023-09-19T15.38.21Z_example\");\r\n * // the backup has been deleted\r\n * ```\r\n */\r\n deleteHotBackup(id: string): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_admin/backup/delete\",\r\n body: { id },\r\n },\r\n () => undefined\r\n );\r\n }\r\n //#endregion\r\n //#region logs\r\n /**\r\n * Retrieves the log messages from the server's global log.\r\n *\r\n * @param options - Options for retrieving the log entries.\r\n *\r\n * @example\r\n * ```js\r\n * const log = await db.getLogEntries();\r\n * for (let i = 0; i < log.totalAmount; i++) {\r\n * console.log(`${\r\n * new Date(log.timestamp[i] * 1000).toISOString()\r\n * } - [${LogLevel[log.level[i]]}] ${log.text[i]} (#${log.lid[i]})`);\r\n * }\r\n * ```\r\n */\r\n getLogEntries(options?: logs.LogEntriesOptions): Promise<logs.LogEntries> {\r\n return this.request(\r\n {\r\n pathname: \"/_admin/log/entries\",\r\n search: options,\r\n },\r\n (res) => res.parsedBody\r\n );\r\n }\r\n\r\n /**\r\n * Retrieves the log messages from the server's global log.\r\n *\r\n * @param options - Options for retrieving the log entries.\r\n *\r\n * @deprecated This endpoint has been deprecated in ArangoDB 3.8.\r\n * Use {@link Database#getLogEntries} instead.\r\n *\r\n * @example\r\n * ```js\r\n * const messages = await db.listLogMessages();\r\n * for (const m of messages) {\r\n * console.log(`${m.date} - [${m.level}] ${m.message} (#${m.id})`);\r\n * }\r\n * ```\r\n */\r\n listLogMessages(\r\n options?: logs.LogEntriesOptions\r\n ): Promise<logs.LogMessage[]> {\r\n return this.request(\r\n {\r\n pathname: \"/_admin/log\",\r\n search: options,\r\n },\r\n (res) => res.parsedBody.messages\r\n );\r\n }\r\n\r\n /**\r\n * Retrieves the server's current log level for each topic.\r\n *\r\n * @example\r\n * ```js\r\n * const levels = await db.getLogLevel();\r\n * console.log(levels.request); // log level for incoming requests\r\n * ```\r\n */\r\n getLogLevel(): Promise<Record<string, logs.LogLevelSetting>> {\r\n return this.request({\r\n pathname: \"/_admin/log/level\",\r\n });\r\n }\r\n\r\n /**\r\n * Sets the server's log level for each of the given topics to the given level.\r\n *\r\n * Any omitted topics will be left unchanged.\r\n *\r\n * @param levels - An object mapping topic names to log levels.\r\n *\r\n * @example\r\n * ```js\r\n * await db.setLogLevel({ request: \"debug\" });\r\n * // Debug information will now be logged for each request\r\n * ```\r\n */\r\n setLogLevel(\r\n levels: Record<string, logs.LogLevelSetting>\r\n ): Promise<Record<string, logs.LogLevelSetting>> {\r\n return this.request({\r\n method: \"PUT\",\r\n pathname: \"/_admin/log/level\",\r\n body: levels,\r\n });\r\n }\r\n //#endregion\r\n //#region async jobs\r\n\r\n /**\r\n * Creates an async job by executing the given callback function. The first\r\n * database request performed by the callback will be marked for asynchronous\r\n * execution and its result will be made available as an async job.\r\n *\r\n * Returns a {@link jobs.Job} instance that can be used to retrieve the result\r\n * of the callback function once the request has been executed.\r\n *\r\n * @param callback - Callback function to execute as an async job.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const job = await db.createJob(() => db.collections());\r\n * while (!job.isLoaded) {\r\n * await timeout(1000);\r\n * await job.load();\r\n * }\r\n * // job.result is a list of Collection instances\r\n * ```\r\n */\r\n async createJob<T>(callback: () => Promise<T>): Promise<jobs.Job<T>> {\r\n const trap = new Promise<TrappedError | TrappedRequest<T>>(\r\n (resolveTrap) => {\r\n this._trapRequest = (trapped) => resolveTrap(trapped);\r\n }\r\n );\r\n const eventualResult = callback();\r\n const trapped = await trap;\r\n if (trapped.error) return eventualResult as Promise<any>;\r\n const { jobId, onResolve, onReject } = trapped;\r\n return new jobs.Job(\r\n this,\r\n jobId,\r\n (res) => {\r\n onResolve(res);\r\n return eventualResult;\r\n },\r\n (e) => {\r\n onReject(e);\r\n return eventualResult;\r\n }\r\n );\r\n }\r\n\r\n /**\r\n * Returns a {@link jobs.Job} instance for the given `jobId`.\r\n *\r\n * @param jobId - ID of the async job.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const job = db.job(\"12345\");\r\n * ```\r\n */\r\n job(jobId: string): jobs.Job {\r\n return new jobs.Job(this, jobId);\r\n }\r\n\r\n /**\r\n * Returns a list of the IDs of all currently pending async jobs.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const pendingJobs = await db.listPendingJobs();\r\n * console.log(pendingJobs); // e.g. [\"12345\", \"67890\"]\r\n * ```\r\n */\r\n listPendingJobs(): Promise<string[]> {\r\n return this.request(\r\n {\r\n pathname: \"/_api/job/pending\",\r\n },\r\n (res) => res.parsedBody\r\n );\r\n }\r\n\r\n /**\r\n * Returns a list of the IDs of all currently available completed async jobs.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const completedJobs = await db.listCompletedJobs();\r\n * console.log(completedJobs); // e.g. [\"12345\", \"67890\"]\r\n * ```\r\n */\r\n listCompletedJobs(): Promise<string[]> {\r\n return this.request(\r\n {\r\n pathname: \"/_api/job/done\",\r\n },\r\n (res) => res.parsedBody\r\n );\r\n }\r\n\r\n /**\r\n * Deletes the results of all completed async jobs created before the given\r\n * threshold.\r\n *\r\n * @param threshold - The expiration timestamp in milliseconds.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const ONE_WEEK = 7 * 24 * 60 * 60 * 1000;\r\n * await db.deleteExpiredJobResults(Date.now() - ONE_WEEK);\r\n * // all job results older than a week have been deleted\r\n * ```\r\n */\r\n deleteExpiredJobResults(threshold: number): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: `/_api/job/expired`,\r\n search: { stamp: threshold / 1000 },\r\n },\r\n () => undefined\r\n );\r\n }\r\n\r\n /**\r\n * Deletes the results of all completed async jobs.\r\n */\r\n deleteAllJobResults(): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: `/_api/job/all`,\r\n },\r\n () => undefined\r\n );\r\n }\r\n //#endregion\r\n}\r\n//#endregion\r\n"]}
|
|
1
|
+
{"version":3,"file":"databases.js","sourceRoot":"","sources":["../../src/databases.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,0DAA4C;AAC5C,8CAAgC;AAEhC,8DAAgD;AAEhD,4DAA8C;AAC9C,sDAAwC;AACxC,oDAAsC;AACtC,oDAAsC;AAEtC,gDAAkC;AAClC,6CAAoD;AACpD,oDAAsC;AAGtC,oDAAsC;AAEtC,gEAAkD;AAElD,kDAAoC;AA4FpC,wBAAwB;AACxB;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,QAAa;IAC5C,OAAO,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AACxD,CAAC;AAFD,4CAEC;AAED;;;GAGG;AACH,MAAa,QAAQ;IACT,WAAW,CAAwB;IACnC,KAAK,CAAS;IACd,UAAU,GAAG,IAAI,GAAG,EAA8B,CAAC;IACnD,YAAY,GAAG,IAAI,GAAG,EAAkC,CAAC;IACzD,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC1C,MAAM,GAAG,IAAI,GAAG,EAAsB,CAA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,CAAC,OAAO,CACjB;YACE,QAAQ,EAAE,mBAAmB;SAC9B,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CACxB,CAAC;IACJ,CAAC;IAED;;;;;;;;;OASG;IACH,iBAAiB;QACf,OAAO,IAAI,CAAC,OAAO,CACjB;YACE,QAAQ,EAAE,gBAAgB;SAC3B,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CACxB,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,uBAAuB,CAAC,SAAiB;QACvC,OAAO,IAAI,CAAC,OAAO,CACjB;YACE,MAAM,EAAE,QAAQ;YAChB,QAAQ,EAAE,mBAAmB;YAC7B,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,EAAE;SACpC,EACD,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,mBAAmB;QACjB,OAAO,IAAI,CAAC,OAAO,CACjB;YACE,MAAM,EAAE,QAAQ;YAChB,QAAQ,EAAE,eAAe;SAC1B,EACD,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;IACJ,CAAC;CAEF;AAvwJD,4BAuwJC;AACD,YAAY","sourcesContent":["/**\r\n * ```js\r\n * import { Database } from \"arangojs/databases\";\r\n * ```\r\n *\r\n * The \"databases\" module provides the {@link Database} class and associated\r\n * types and interfaces for TypeScript.\r\n *\r\n * The Database class is also re-exported by the \"index\" module.\r\n *\r\n * @packageDocumentation\r\n */\r\nimport * as administration from \"./administration.js\";\r\nimport * as analyzers from \"./analyzers.js\";\r\nimport * as aql from \"./aql.js\";\r\nimport * as cluster from \"./cluster.js\";\r\nimport * as collections from \"./collections.js\";\r\nimport * as configuration from \"./configuration.js\";\r\nimport * as connection from \"./connection.js\";\r\nimport * as cursors from \"./cursors.js\";\r\nimport * as errors from \"./errors.js\";\r\nimport * as graphs from \"./graphs.js\";\r\nimport * as hotBackups from \"./hot-backups.js\";\r\nimport * as jobs from \"./jobs.js\";\r\nimport { DATABASE_NOT_FOUND } from \"./lib/codes.js\";\r\nimport * as util from \"./lib/util.js\";\r\nimport * as logs from \"./logs.js\";\r\nimport * as queries from \"./queries.js\";\r\nimport * as routes from \"./routes.js\";\r\nimport * as services from \"./services.js\";\r\nimport * as transactions from \"./transactions.js\";\r\nimport * as users from \"./users.js\";\r\nimport * as views from \"./views.js\";\r\n\r\n//#region Database operation options\r\n/**\r\n * Options for creating a database.\r\n *\r\n * See {@link Database#createDatabase}.\r\n */\r\nexport type CreateDatabaseOptions = {\r\n /**\r\n * Database users to create with the database.\r\n */\r\n users?: users.CreateDatabaseUserOptions[];\r\n /**\r\n * (Cluster only.) The sharding method to use for new collections in the\r\n * database.\r\n */\r\n sharding?: \"\" | \"flexible\" | \"single\";\r\n /**\r\n * (Cluster only.) Default replication factor for new collections in this\r\n * database.\r\n *\r\n * Setting this to `1` disables replication. Setting this to `\"satellite\"`\r\n * will replicate to every DBServer.\r\n */\r\n replicationFactor?: \"satellite\" | number;\r\n /**\r\n * (Cluster only.) Default write concern for new collections created in this\r\n * database.\r\n */\r\n writeConcern?: number;\r\n};\r\n//#endregion\r\n\r\n//#region DatabaseDescription\r\n/**\r\n * Object describing a database.\r\n *\r\n * See {@link Database#get}.\r\n */\r\nexport type DatabaseDescription = {\r\n /**\r\n * Name of the database.\r\n */\r\n name: string;\r\n /**\r\n * Unique identifier of the database.\r\n */\r\n id: string;\r\n /**\r\n * File system path of the database.\r\n */\r\n path: string;\r\n /**\r\n * Whether the database is the system database.\r\n */\r\n isSystem: boolean;\r\n /**\r\n * (Cluster only.) The sharding method to use for new collections in the\r\n * database.\r\n */\r\n sharding?: \"\" | \"flexible\" | \"single\";\r\n /**\r\n * (Cluster only.) Default replication factor for new collections in this\r\n * database.\r\n */\r\n replicationFactor?: \"satellite\" | number;\r\n /**\r\n * (Cluster only.) Default write concern for new collections created in this\r\n * database.\r\n */\r\n writeConcern?: number;\r\n};\r\n//#endregion\r\n\r\n/**\r\n * @internal\r\n */\r\ntype TrappedError = {\r\n error: true;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\ntype TrappedRequest<T = any> = {\r\n error?: false;\r\n jobId: string;\r\n onResolve: (res: connection.ProcessedResponse<T>) => void;\r\n onReject: (error: any) => void;\r\n};\r\n\r\n//#region Database class\r\n/**\r\n * Indicates whether the given value represents a {@link Database}.\r\n *\r\n * @param database - A value that might be a database.\r\n */\r\nexport function isArangoDatabase(database: any): database is Database {\r\n return Boolean(database && database.isArangoDatabase);\r\n}\r\n\r\n/**\r\n * An object representing a single ArangoDB database. All arangojs collections,\r\n * cursors, analyzers and so on are linked to a `Database` object.\r\n */\r\nexport class Database {\r\n protected _connection: connection.Connection;\r\n protected _name: string;\r\n protected _analyzers = new Map<string, analyzers.Analyzer>();\r\n protected _collections = new Map<string, collections.Collection>();\r\n protected _graphs = new Map<string, graphs.Graph>();\r\n protected _views = new Map<string, views.View>();\r\n protected _trapRequest?: (\r\n trapped: TrappedError | TrappedRequest<any>\r\n ) => void;\r\n\r\n /**\r\n * Creates a new `Database` instance with its own connection pool.\r\n *\r\n * See also {@link Database#database}.\r\n *\r\n * @param config - An object with configuration options.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database({\r\n * url: \"http://127.0.0.1:8529\",\r\n * databaseName: \"my_database\",\r\n * auth: { username: \"admin\", password: \"hunter2\" },\r\n * });\r\n * ```\r\n */\r\n constructor(config?: configuration.ConfigOptions);\r\n /**\r\n * Creates a new `Database` instance with its own connection pool.\r\n *\r\n * See also {@link Database#database}.\r\n *\r\n * @param url - Base URL of the ArangoDB server or list of server URLs.\r\n * Equivalent to the `url` option in {@link configuration.ConfigOptions}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database(\"http://127.0.0.1:8529\", \"my_database\");\r\n * db.useBasicAuth(\"admin\", \"hunter2\");\r\n * ```\r\n */\r\n constructor(url: string | string[], name?: string);\r\n /**\r\n * @internal\r\n */\r\n constructor(database: Database, name?: string);\r\n constructor(\r\n configOrDatabase:\r\n | string\r\n | string[]\r\n | configuration.ConfigOptions\r\n | Database = {},\r\n name?: string\r\n ) {\r\n if (isArangoDatabase(configOrDatabase)) {\r\n const connection = configOrDatabase._connection;\r\n const databaseName = name || configOrDatabase.name;\r\n this._connection = connection;\r\n this._name = databaseName;\r\n const database = connection.database(databaseName);\r\n if (database) return database;\r\n } else {\r\n const config = configOrDatabase;\r\n const { databaseName, ...options } =\r\n typeof config === \"string\" || Array.isArray(config)\r\n ? { databaseName: name, url: config }\r\n : config;\r\n this._connection = new connection.Connection(options);\r\n this._name = databaseName || \"_system\";\r\n }\r\n }\r\n\r\n //#region misc\r\n /**\r\n * @internal\r\n *\r\n * Indicates that this object represents an ArangoDB database.\r\n */\r\n get isArangoDatabase(): true {\r\n return true;\r\n }\r\n\r\n /**\r\n * Name of the ArangoDB database this instance represents.\r\n */\r\n get name() {\r\n return this._name;\r\n }\r\n\r\n /**\r\n * Returns a new {@link routes.Route} instance for the given path (relative to the\r\n * database) that can be used to perform arbitrary HTTP requests.\r\n *\r\n * @param path - The database-relative URL of the route. Defaults to the\r\n * database API root.\r\n * @param headers - Default headers that should be sent with each request to\r\n * the route.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const myFoxxService = db.route(\"my-foxx-service\");\r\n * const response = await myFoxxService.post(\"users\", {\r\n * username: \"admin\",\r\n * password: \"hunter2\"\r\n * });\r\n * // response.body is the result of\r\n * // POST /_db/_system/my-foxx-service/users\r\n * // with JSON request body '{\"username\": \"admin\", \"password\": \"hunter2\"}'\r\n * ```\r\n */\r\n route(\r\n path?: string,\r\n headers?: Headers | Record<string, string>\r\n ): routes.Route {\r\n return new routes.Route(this, path, headers);\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Performs an arbitrary HTTP request against the database.\r\n *\r\n * @param BodyType - Type of the expected response body.\r\n * @param ReturnType - Type the response body will be transformed to.\r\n * @param options - Options for this request.\r\n * @param transform - An optional function to transform the low-level\r\n * response object to a more useful return value.\r\n */\r\n async request<BodyType = any, ReturnType = BodyType>(\r\n options: connection.RequestOptions,\r\n transform?: (res: connection.ProcessedResponse<BodyType>) => ReturnType\r\n ): Promise<ReturnType>;\r\n /**\r\n * @internal\r\n *\r\n * Performs an arbitrary HTTP request against the database.\r\n *\r\n * @param BodyType - Type of the expected response body.\r\n * @param options - Options for this request.\r\n * @param transform - If set to `false`, the raw response object will be\r\n * returned.\r\n */\r\n async request<BodyType = any>(\r\n options: connection.RequestOptions,\r\n transform: false\r\n ): Promise<connection.ProcessedResponse<BodyType>>;\r\n async request<BodyType = any, ReturnType = BodyType>(\r\n { pathname, ...opts }: connection.RequestOptions,\r\n transform:\r\n | false\r\n | ((res: connection.ProcessedResponse<BodyType>) => ReturnType) = (res) =>\r\n res.parsedBody as ReturnType\r\n ): Promise<ReturnType> {\r\n pathname = util.joinPath(\"_db\", encodeURIComponent(this._name), pathname);\r\n if (this._trapRequest) {\r\n const trap = this._trapRequest;\r\n this._trapRequest = undefined;\r\n return new Promise<ReturnType>(async (resolveRequest, rejectRequest) => {\r\n opts.headers = new Headers(opts.headers);\r\n opts.headers.set(\"x-arango-async\", \"store\");\r\n let jobRes: connection.ProcessedResponse<any>;\r\n try {\r\n jobRes = await this._connection.request({ pathname, ...opts });\r\n } catch (e) {\r\n trap({ error: true });\r\n rejectRequest(e);\r\n return;\r\n }\r\n const jobId = jobRes.headers.get(\"x-arango-async-id\")!;\r\n trap({\r\n jobId,\r\n onResolve: (res) => {\r\n const result = transform ? transform(res) : (res as ReturnType);\r\n resolveRequest(result);\r\n return result;\r\n },\r\n onReject: (err) => {\r\n rejectRequest(err);\r\n throw err;\r\n },\r\n });\r\n });\r\n }\r\n return this._connection.request(\r\n { pathname, ...opts },\r\n transform || undefined\r\n );\r\n }\r\n\r\n /**\r\n * Updates the URL list by requesting a list of all coordinators in the\r\n * cluster and adding any endpoints not initially specified in the\r\n * {@link configuration.ConfigOptions}.\r\n *\r\n * For long-running processes communicating with an ArangoDB cluster it is\r\n * recommended to run this method periodically (e.g. once per hour) to make\r\n * sure new coordinators are picked up correctly and can be used for\r\n * fail-over or load balancing.\r\n *\r\n * @param overwrite - If set to `true`, the existing host list will be\r\n * replaced instead of extended.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const interval = setInterval(\r\n * () => db.acquireHostList(),\r\n * 5 * 60 * 1000 // every 5 minutes\r\n * );\r\n *\r\n * // later\r\n * clearInterval(interval);\r\n * system.close();\r\n * ```\r\n */\r\n async acquireHostList(overwrite = false): Promise<void> {\r\n const urls: string[] = await this.request(\r\n { pathname: \"/_api/cluster/endpoints\" },\r\n (res) =>\r\n res.parsedBody.endpoints.map((endpoint: any) => endpoint.endpoint)\r\n );\r\n if (urls.length > 0) {\r\n if (overwrite) this._connection.setHostList(urls);\r\n else this._connection.addToHostList(urls);\r\n }\r\n }\r\n\r\n /**\r\n * Closes all active connections of this database instance.\r\n *\r\n * Can be used to clean up idling connections during longer periods of\r\n * inactivity.\r\n *\r\n * **Note**: This method currently has no effect in the browser version of\r\n * arangojs.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const sessions = db.collection(\"sessions\");\r\n * // Clean up expired sessions once per hour\r\n * setInterval(async () => {\r\n * await db.query(aql`\r\n * FOR session IN ${sessions}\r\n * FILTER session.expires < DATE_NOW()\r\n * REMOVE session IN ${sessions}\r\n * `);\r\n * // Making sure to close the connections because they're no longer used\r\n * system.close();\r\n * }, 1000 * 60 * 60);\r\n * ```\r\n */\r\n close(): void {\r\n this._connection.close();\r\n }\r\n\r\n /**\r\n * Performs a request against every known coordinator and returns when the\r\n * request has succeeded against every coordinator or the timeout is reached.\r\n *\r\n * **Note**: This method is primarily intended to make database setup easier\r\n * in cluster scenarios and requires all coordinators to be known to arangojs\r\n * before the method is invoked. The method is not useful in single-server or\r\n * leader-follower replication scenarios.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database({ loadBalancingStrategy: \"ROUND_ROBIN\" });\r\n * await system.acquireHostList();\r\n * const analyzer = db.analyzer(\"my-analyzer\");\r\n * await analyzer.create();\r\n * await db.waitForPropagation(\r\n * { pathname: `/_api/analyzer/${encodeURIComponent(analyzer.name)}` },\r\n * 30000\r\n * );\r\n * // Analyzer has been propagated to all coordinators and can safely be used\r\n * ```\r\n *\r\n * @param request - Request to perform against each known coordinator.\r\n * @param timeout - Maximum number of milliseconds to wait for propagation.\r\n */\r\n async waitForPropagation(\r\n request: connection.RequestOptions,\r\n timeout?: number\r\n ): Promise<void>;\r\n async waitForPropagation(\r\n { pathname, ...request }: connection.RequestOptions,\r\n timeout?: number\r\n ): Promise<void> {\r\n await this._connection.waitForPropagation(\r\n {\r\n ...request,\r\n pathname: util.joinPath(\r\n \"_db\",\r\n encodeURIComponent(this._name),\r\n pathname\r\n ),\r\n },\r\n timeout\r\n );\r\n }\r\n\r\n /**\r\n * Methods for accessing the server-reported queue times of the mostly\r\n * recently received responses.\r\n */\r\n get queueTime(): administration.QueueTimeMetrics {\r\n return this._connection.queueTime;\r\n }\r\n\r\n /**\r\n * Sets the limit for the number of values of the most recently received\r\n * server-reported queue times that can be accessed using\r\n * {@link Database#queueTime}.\r\n *\r\n * @param responseQueueTimeSamples - Number of values to maintain.\r\n */\r\n setResponseQueueTimeSamples(responseQueueTimeSamples: number) {\r\n this._connection.setResponseQueueTimeSamples(responseQueueTimeSamples);\r\n }\r\n //#endregion\r\n\r\n //#region auth\r\n /**\r\n * Updates the underlying connection's `authorization` header to use Basic\r\n * authentication with the given `username` and `password`, then returns\r\n * itself.\r\n *\r\n * @param username - The username to authenticate with.\r\n * @param password - The password to authenticate with.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * db.useBasicAuth(\"admin\", \"hunter2\");\r\n * // with the username \"admin\" and password \"hunter2\".\r\n * ```\r\n */\r\n useBasicAuth(username: string = \"root\", password: string = \"\"): this {\r\n this._connection.setBasicAuth({ username, password });\r\n return this;\r\n }\r\n\r\n /**\r\n * Updates the underlying connection's `authorization` header to use Bearer\r\n * authentication with the given authentication `token`, then returns itself.\r\n *\r\n * @param token - The token to authenticate with.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * db.useBearerAuth(\"keyboardcat\");\r\n * // The database instance now uses Bearer authentication.\r\n * ```\r\n */\r\n useBearerAuth(token: string): this {\r\n this._connection.setBearerAuth({ token });\r\n return this;\r\n }\r\n\r\n /**\r\n * Updates the underlying connection's `authorization` header to use Basic\r\n * authentication with the given access token, then returns itself.\r\n *\r\n * Access tokens contain embedded username information, so the username field\r\n * in Basic Auth can be empty. The token acts as a password replacement.\r\n *\r\n * @param token - The access token to authenticate with.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const tokenResult = await db.createAccessToken(\"appUser\", {\r\n * name: \"CI token\"\r\n * });\r\n * db.useAccessToken(tokenResult.token);\r\n * // The database instance now uses the access token for authentication.\r\n * ```\r\n */\r\n useAccessToken(token: string): this {\r\n if (!token || typeof token !== \"string\") {\r\n throw new Error(\"Token must be a non-empty string\");\r\n }\r\n // Access tokens can be used with empty username in Basic Auth\r\n // The token contains embedded username information\r\n return this.useBasicAuth(\"\", token);\r\n }\r\n\r\n /**\r\n * Validates the given database credentials and exchanges them for an\r\n * authentication token, then uses the authentication token for future\r\n * requests and returns it.\r\n *\r\n * @param username - The username to authenticate with.\r\n * @param password - The password to authenticate with.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.login(\"admin\", \"hunter2\");\r\n * // with an authentication token for the \"admin\" user.\r\n * ```\r\n */\r\n login(username: string = \"root\", password: string = \"\"): Promise<string> {\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_open/auth\",\r\n body: { username, password },\r\n },\r\n (res: any) => {\r\n this.useBearerAuth(res.parsedBody.jwt);\r\n return res.parsedBody.jwt;\r\n }\r\n );\r\n }\r\n\r\n /**\r\n * Attempts to renew the authentication token passed to {@link Database#useBearerAuth}\r\n * or returned and used by {@link Database#login}. If a new authentication\r\n * token is issued, it will be used for future requests and returned.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.login(\"admin\", \"hunter2\");\r\n * // ... later ...\r\n * const newToken = await db.renewAuthToken();\r\n * if (!newToken) // no new token issued\r\n * ```\r\n */\r\n renewAuthToken(): Promise<string | null> {\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_open/auth/renew\",\r\n },\r\n (res) => {\r\n if (!res.parsedBody.jwt) return null;\r\n this.useBearerAuth(res.parsedBody.jwt);\r\n return res.parsedBody.jwt;\r\n }\r\n );\r\n }\r\n //#endregion\r\n\r\n //#region administration\r\n /**\r\n * Fetches version information from the ArangoDB server.\r\n *\r\n * @param details - If set to `true`, additional information about the\r\n * ArangoDB server will be available as the `details` property.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const version = await db.version();\r\n * // the version object contains the ArangoDB version information.\r\n * // license: \"community\" or \"enterprise\"\r\n * // version: ArangoDB version number\r\n * // server: description of the server\r\n * ```\r\n */\r\n version(details?: boolean): Promise<administration.VersionInfo> {\r\n return this.request({\r\n method: \"GET\",\r\n pathname: \"/_api/version\",\r\n search: { details },\r\n });\r\n }\r\n\r\n /**\r\n * Fetches storage engine information from the ArangoDB server.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const engine = await db.engine();\r\n * // the engine object contains the storage engine information, e.g.\r\n * // name: name of the storage engine\r\n * ```\r\n */\r\n engine(): Promise<administration.EngineInfo> {\r\n return this.request({\r\n method: \"GET\",\r\n pathname: \"/_api/engine\",\r\n });\r\n }\r\n\r\n /**\r\n * Fetches detailed storage engine performance and resource usage information\r\n * from the ArangoDB server.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const stats = await db.engineStats();\r\n * // the stats object contains the storage engine stats\r\n * ```\r\n */\r\n engineStats(): Promise<administration.EngineStatsInfo> {\r\n return this.request({\r\n method: \"GET\",\r\n pathname: \"/_api/engine/stats\",\r\n });\r\n }\r\n\r\n /**\r\n * Retrives the server's current system time in milliseconds with microsecond\r\n * precision.\r\n */\r\n time(): Promise<number> {\r\n return this.request(\r\n {\r\n method: \"GET\",\r\n pathname: \"/_admin/time\",\r\n },\r\n (res) => res.parsedBody.time * 1000\r\n );\r\n }\r\n\r\n /**\r\n * Fetches information about the server status.\r\n *\r\n * @example\r\n * ```js\r\n * const status = await db.status();\r\n * // the status object contains the ArangoDB status information, e.g.\r\n * // version: ArangoDB version number\r\n * // host: host identifier of the server\r\n * // serverInfo: detailed information about the server\r\n * ```\r\n */\r\n status(): Promise<administration.ServerStatusInfo> {\r\n return this.request({\r\n method: \"GET\",\r\n pathname: \"/_admin/status\",\r\n });\r\n }\r\n\r\n /**\r\n * Fetches availability information about the server.\r\n *\r\n * @param graceful - If set to `true`, the method will always return `false`\r\n * instead of throwing an error; otherwise `false` will only be returned\r\n * when the server responds with a 503 status code or an ArangoDB error with\r\n * a code of 503, such as during shutdown.\r\n *\r\n * @example\r\n * ```js\r\n * const availability = await db.availability();\r\n * // availability is either \"default\", \"readonly\", or false\r\n * ```\r\n */\r\n async availability(\r\n graceful = false\r\n ): Promise<administration.ServerAvailability> {\r\n try {\r\n return this.request(\r\n {\r\n method: \"GET\",\r\n pathname: \"/_admin/server/availability\",\r\n },\r\n (res) => res.parsedBody.mode\r\n );\r\n } catch (e) {\r\n if (graceful) return false;\r\n if (\r\n (errors.isArangoError(e) || e instanceof errors.HttpError) &&\r\n e.code === 503\r\n ) {\r\n return false;\r\n }\r\n throw e;\r\n }\r\n }\r\n\r\n /**\r\n * Fetches deployment information about the server for support purposes.\r\n *\r\n * Note that this API may reveal sensitive data about the deployment.\r\n */\r\n supportInfo(): Promise<\r\n administration.SingleServerSupportInfo | administration.ClusterSupportInfo\r\n > {\r\n return this.request({\r\n method: \"GET\",\r\n pathname: \"/_admin/support-info\",\r\n });\r\n }\r\n\r\n /**\r\n * Fetches the license information and status of an Enterprise Edition server.\r\n */\r\n getLicense(): Promise<administration.LicenseInfo> {\r\n return this.request({\r\n method: \"GET\",\r\n pathname: \"/_admin/license\",\r\n });\r\n }\r\n\r\n /**\r\n * Set a new license for an Enterprise Edition server.\r\n *\r\n * @param license - The license as a base 64 encoded string.\r\n * @param force - If set to `true`, the license will be changed even if it\r\n * expires sooner than the current license.\r\n */\r\n setLicense(license: string, force = false): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"PUT\",\r\n pathname: \"/_admin/license\",\r\n body: license,\r\n search: { force },\r\n },\r\n () => undefined\r\n );\r\n }\r\n\r\n /**\r\n * Compacts all databases on the server.\r\n *\r\n * @param options - Options for compacting the databases.\r\n */\r\n compact(options: administration.CompactOptions = {}): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"PUT\",\r\n pathname: \"/_admin/compact\",\r\n body: options,\r\n },\r\n () => undefined\r\n );\r\n }\r\n\r\n /**\r\n * Attempts to initiate a clean shutdown of the server.\r\n */\r\n shutdown(): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: \"/_admin/shutdown\",\r\n },\r\n () => undefined\r\n );\r\n }\r\n //#endregion\r\n\r\n //#region rebalancing\r\n /**\r\n * Computes the current cluster imbalance.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const imbalance = await db.getClusterImbalance();\r\n * ```\r\n */\r\n getClusterImbalance(): Promise<cluster.ClusterRebalanceState> {\r\n return this.request(\r\n { pathname: \"/_admin/cluster/rebalance\" },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Computes a set of move shard operations to rebalance the cluster.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const result = await db.computerClusterRebalance({\r\n * moveLeaders: true,\r\n * moveFollowers: true\r\n * });\r\n * if (result.moves.length) {\r\n * await db.executeClusterRebalance(result.moves);\r\n * }\r\n * ```\r\n */\r\n computeClusterRebalance(\r\n options: cluster.ClusterRebalanceOptions\r\n ): Promise<cluster.ClusterRebalanceResult> {\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_admin/cluster/rebalance\",\r\n body: {\r\n version: 1,\r\n ...options,\r\n },\r\n },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Executes the given cluster move shard operations.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const result = await db.computerClusterRebalance({\r\n * moveLeaders: true,\r\n * moveFollowers: true\r\n * });\r\n * if (result.moves.length) {\r\n * await db.executeClusterRebalance(result.moves);\r\n * }\r\n * ```\r\n */\r\n executeClusterRebalance(\r\n moves: cluster.ClusterRebalanceMove[]\r\n ): Promise<unknown> {\r\n return this.request({\r\n method: \"POST\",\r\n pathname: \"/_admin/cluster/rebalance/execute\",\r\n body: {\r\n version: 1,\r\n moves,\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Computes a set of move shard operations to rebalance the cluster and\r\n * executes them.\r\n *\r\n * @param options - Options for rebalancing the cluster.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const result = await db.rebalanceCluster({\r\n * moveLeaders: true,\r\n * moveFollowers: true\r\n * });\r\n * // The cluster is now rebalanced.\r\n * ```\r\n */\r\n rebalanceCluster(\r\n options: cluster.ClusterRebalanceOptions\r\n ): Promise<cluster.ClusterRebalanceResult> {\r\n return this.request({\r\n method: \"PUT\",\r\n pathname: \"/_admin/cluster/rebalance\",\r\n body: {\r\n version: 1,\r\n ...options,\r\n },\r\n });\r\n }\r\n //#endregion\r\n\r\n //#region databases\r\n /**\r\n * Creates a new `Database` instance for the given `databaseName` that\r\n * shares this database's connection pool.\r\n *\r\n * See also {@link Database:constructor}.\r\n *\r\n * @param databaseName - Name of the database.\r\n *\r\n * @example\r\n * ```js\r\n * const systemDb = new Database();\r\n * const myDb = systemDb.database(\"my_database\");\r\n * ```\r\n */\r\n database(databaseName: string) {\r\n return new Database(this, databaseName);\r\n }\r\n\r\n /**\r\n * Fetches the database description for the active database from the server.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const info = await db.get();\r\n * // the database exists\r\n * ```\r\n */\r\n get(): Promise<DatabaseDescription> {\r\n return this.request(\r\n { pathname: \"/_api/database/current\" },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Checks whether the database exists.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const result = await db.exists();\r\n * // result indicates whether the database exists\r\n * ```\r\n */\r\n async exists(): Promise<boolean> {\r\n try {\r\n await this.get();\r\n return true;\r\n } catch (err: any) {\r\n if (errors.isArangoError(err) && err.errorNum === DATABASE_NOT_FOUND) {\r\n return false;\r\n }\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new database with the given `databaseName` with the given\r\n * `options` and returns a `Database` instance for that database.\r\n *\r\n * @param databaseName - Name of the database to create.\r\n * @param options - Options for creating the database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const info = await db.createDatabase(\"mydb\", {\r\n * users: [{ username: \"root\" }]\r\n * });\r\n * // the database has been created\r\n * ```\r\n */\r\n createDatabase(\r\n databaseName: string,\r\n options?: CreateDatabaseOptions\r\n ): Promise<Database>;\r\n /**\r\n * Creates a new database with the given `databaseName` with the given\r\n * `users` and returns a `Database` instance for that database.\r\n *\r\n * @param databaseName - Name of the database to create.\r\n * @param users - Database users to create with the database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const info = await db.createDatabase(\"mydb\", [{ username: \"root\" }]);\r\n * // the database has been created\r\n * ```\r\n */\r\n createDatabase(\r\n databaseName: string,\r\n users: users.CreateDatabaseUserOptions[]\r\n ): Promise<Database>;\r\n createDatabase(\r\n databaseName: string,\r\n usersOrOptions:\r\n | users.CreateDatabaseUserOptions[]\r\n | CreateDatabaseOptions = {}\r\n ): Promise<Database> {\r\n const { users, ...options } = Array.isArray(usersOrOptions)\r\n ? { users: usersOrOptions }\r\n : usersOrOptions;\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_api/database\",\r\n body: { name: databaseName, users, options },\r\n },\r\n () => this.database(databaseName)\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all databases from the server and returns an array of their names.\r\n *\r\n * See also {@link Database#databases} and\r\n * {@link Database#listUserDatabases}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const names = await db.listDatabases();\r\n * // databases is an array of database names\r\n * ```\r\n */\r\n listDatabases(): Promise<string[]> {\r\n return this.request(\r\n { pathname: \"/_api/database\" },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all databases accessible to the active user from the server and\r\n * returns an array of their names.\r\n *\r\n * See also {@link Database#userDatabases} and\r\n * {@link Database#listDatabases}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const names = await db.listUserDatabases();\r\n * // databases is an array of database names\r\n * ```\r\n */\r\n listUserDatabases(): Promise<string[]> {\r\n return this.request(\r\n { pathname: \"/_api/database/user\" },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all databases from the server and returns an array of `Database`\r\n * instances for those databases.\r\n *\r\n * See also {@link Database#listDatabases} and\r\n * {@link Database#userDatabases}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const names = await db.databases();\r\n * // databases is an array of databases\r\n * ```\r\n */\r\n databases(): Promise<Database[]> {\r\n return this.request({ pathname: \"/_api/database\" }, (res) =>\r\n (res.parsedBody.result as string[]).map((databaseName) =>\r\n this.database(databaseName)\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all databases accessible to the active user from the server and\r\n * returns an array of `Database` instances for those databases.\r\n *\r\n * See also {@link Database#listUserDatabases} and\r\n * {@link Database#databases}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const names = await db.userDatabases();\r\n * // databases is an array of databases\r\n * ```\r\n */\r\n userDatabases(): Promise<Database[]> {\r\n return this.request({ pathname: \"/_api/database/user\" }, (res) =>\r\n (res.parsedBody.result as string[]).map((databaseName) =>\r\n this.database(databaseName)\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * Deletes the database with the given `databaseName` from the server.\r\n *\r\n * @param databaseName - Name of the database to delete.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.dropDatabase(\"mydb\");\r\n * // database \"mydb\" no longer exists\r\n * ```\r\n */\r\n dropDatabase(databaseName: string): Promise<boolean> {\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: `/_api/database/${encodeURIComponent(databaseName)}`,\r\n },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n //#endregion\r\n\r\n //#region collections\r\n /**\r\n * Returns a `Collection` instance for the given collection name.\r\n *\r\n * In TypeScript the collection implements both the\r\n * {@link collections.DocumentCollection} and {@link collections.EdgeCollection}\r\n * interfaces and can be cast to either type to enforce a stricter API.\r\n *\r\n * @param EntryResultType - Type to represent document contents returned by\r\n * the server (including computed properties).\r\n * @param EntryInputType - Type to represent document contents passed when\r\n * inserting or replacing documents (without computed properties).\r\n * @param collectionName - Name of the edge collection.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collection = db.collection(\"potatoes\");\r\n * ```\r\n *\r\n * @example\r\n * ```ts\r\n * interface Person {\r\n * name: string;\r\n * }\r\n * const db = new Database();\r\n * const persons = db.collection<Person>(\"persons\");\r\n * ```\r\n *\r\n * @example\r\n * ```ts\r\n * interface Person {\r\n * name: string;\r\n * }\r\n * interface Friend {\r\n * startDate: number;\r\n * endDate?: number;\r\n * }\r\n * const db = new Database();\r\n * const documents = db.collection(\"persons\") as DocumentCollection<Person>;\r\n * const edges = db.collection(\"friends\") as EdgeCollection<Friend>;\r\n * ```\r\n */\r\n collection<\r\n EntryResultType extends Record<string, any> = any,\r\n EntryInputType extends Record<string, any> = EntryResultType,\r\n >(\r\n collectionName: string\r\n ): collections.DocumentCollection<EntryResultType, EntryInputType> &\r\n collections.EdgeCollection<EntryResultType, EntryInputType> {\r\n collectionName = collectionName;\r\n if (!this._collections.has(collectionName)) {\r\n this._collections.set(\r\n collectionName,\r\n new collections.Collection(this, collectionName)\r\n );\r\n }\r\n return this._collections.get(collectionName)!;\r\n }\r\n\r\n /**\r\n * Creates a new collection with the given `collectionName` and `options`,\r\n * then returns a {@link collections.DocumentCollection} instance for the new collection.\r\n *\r\n * @param EntryResultType - Type to represent document contents returned by\r\n * the server (including computed properties).\r\n * @param EntryInputType - Type to represent document contents passed when\r\n * inserting or replacing documents (without computed properties).\r\n * @param collectionName - Name of the new collection.\r\n * @param options - Options for creating the collection.\r\n *\r\n * @example\r\n * ```ts\r\n * const db = new Database();\r\n * const documents = db.createCollection(\"persons\");\r\n * ```\r\n *\r\n * @example\r\n * ```ts\r\n * interface Person {\r\n * name: string;\r\n * }\r\n * const db = new Database();\r\n * const documents = db.createCollection<Person>(\"persons\");\r\n * ```\r\n */\r\n async createCollection<\r\n EntryResultType extends Record<string, any> = any,\r\n EntryInputType extends Record<string, any> = EntryResultType,\r\n >(\r\n collectionName: string,\r\n options?: collections.CreateCollectionOptions & {\r\n type?: collections.CollectionType.DOCUMENT_COLLECTION;\r\n }\r\n ): Promise<collections.DocumentCollection<EntryResultType, EntryInputType>>;\r\n /**\r\n * Creates a new edge collection with the given `collectionName` and\r\n * `options`, then returns an {@link collections.EdgeCollection} instance for the new\r\n * edge collection.\r\n *\r\n * @param EntryResultType - Type to represent edge document contents returned\r\n * by the server (including computed properties).\r\n * @param EntryInputType - Type to represent edge document contents passed\r\n * when inserting or replacing documents (without computed properties).\r\n * @param collectionName - Name of the new collection.\r\n * @param options - Options for creating the collection.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const edges = db.createCollection(\"friends\", {\r\n * type: CollectionType.EDGE_COLLECTION\r\n * });\r\n * ```\r\n *\r\n * @example\r\n * ```ts\r\n * interface Friend {\r\n * startDate: number;\r\n * endDate?: number;\r\n * }\r\n * const db = new Database();\r\n * const edges = db.createCollection<Friend>(\"friends\", {\r\n * type: CollectionType.EDGE_COLLECTION\r\n * });\r\n * ```\r\n */\r\n async createCollection<\r\n EntryResultType extends Record<string, any> = any,\r\n EntryInputType extends Record<string, any> = EntryResultType,\r\n >(\r\n collectionName: string,\r\n options: collections.CreateCollectionOptions & {\r\n type: collections.CollectionType.EDGE_COLLECTION;\r\n }\r\n ): Promise<collections.EdgeCollection<EntryResultType, EntryInputType>>;\r\n async createCollection<\r\n EntryResultType extends Record<string, any> = any,\r\n EntryInputType extends Record<string, any> = EntryResultType,\r\n >(\r\n collectionName: string,\r\n options?: collections.CreateCollectionOptions & {\r\n type?: collections.CollectionType;\r\n }\r\n ): Promise<\r\n collections.DocumentCollection<EntryResultType, EntryInputType> &\r\n collections.EdgeCollection<EntryResultType, EntryInputType>\r\n > {\r\n const collection = this.collection(collectionName);\r\n await collection.create(options);\r\n return collection;\r\n }\r\n\r\n /**\r\n * Creates a new edge collection with the given `collectionName` and\r\n * `options`, then returns an {@link collections.EdgeCollection} instance for the new\r\n * edge collection.\r\n *\r\n * This is a convenience method for calling {@link Database#createCollection}\r\n * with `options.type` set to `EDGE_COLLECTION`.\r\n *\r\n * @param EntryResultType - Type to represent edge document contents returned\r\n * by the server (including computed properties).\r\n * @param EntryInputType - Type to represent edge document contents passed\r\n * when inserting or replacing documents (without computed properties).\r\n * @param collectionName - Name of the new collection.\r\n * @param options - Options for creating the collection.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const edges = db.createEdgeCollection(\"friends\");\r\n * ```\r\n *\r\n * @example\r\n * ```ts\r\n * interface Friend {\r\n * startDate: number;\r\n * endDate?: number;\r\n * }\r\n * const db = new Database();\r\n * const edges = db.createEdgeCollection<Friend>(\"friends\");\r\n * ```\r\n */\r\n async createEdgeCollection<\r\n EntryResultType extends Record<string, any> = any,\r\n EntryInputType extends Record<string, any> = EntryResultType,\r\n >(\r\n collectionName: string,\r\n options?: collections.CreateCollectionOptions\r\n ): Promise<collections.EdgeCollection<EntryResultType, EntryInputType>> {\r\n return this.createCollection(collectionName, {\r\n ...options,\r\n type: collections.CollectionType.EDGE_COLLECTION,\r\n });\r\n }\r\n\r\n /**\r\n * Renames the collection `collectionName` to `newName`.\r\n *\r\n * Additionally removes any stored `Collection` instance for\r\n * `collectionName` from the `Database` instance's internal cache.\r\n *\r\n * **Note**: Renaming collections may not be supported when ArangoDB is\r\n * running in a cluster configuration.\r\n *\r\n * @param collectionName - Current name of the collection.\r\n * @param newName - The new name of the collection.\r\n */\r\n async renameCollection(\r\n collectionName: string,\r\n newName: string\r\n ): Promise<connection.ArangoApiResponse<collections.CollectionDescription>> {\r\n const result = await this.request({\r\n method: \"PUT\",\r\n pathname: `/_api/collection/${encodeURIComponent(collectionName)}/rename`,\r\n body: { name: newName },\r\n });\r\n this._collections.delete(collectionName);\r\n return result;\r\n }\r\n\r\n /**\r\n * Fetches all collections from the database and returns an array of\r\n * collection descriptions.\r\n *\r\n * See also {@link Database#collections}.\r\n *\r\n * @param excludeSystem - Whether system collections should be excluded.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collections = await db.listCollections();\r\n * // collections is an array of collection descriptions\r\n * // not including system collections\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collections = await db.listCollections(false);\r\n * // collections is an array of collection descriptions\r\n * // including system collections\r\n * ```\r\n */\r\n listCollections(\r\n excludeSystem: boolean = true\r\n ): Promise<collections.CollectionDescription[]> {\r\n return this.request(\r\n {\r\n pathname: \"/_api/collection\",\r\n search: { excludeSystem },\r\n },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all collections from the database and returns an array of\r\n * `Collection` instances.\r\n *\r\n * In TypeScript these instances implement both the\r\n * {@link collections.DocumentCollection} and {@link collections.EdgeCollection}\r\n * interfaces and can be cast to either type to enforce a stricter API.\r\n *\r\n * See also {@link Database#listCollections}.\r\n *\r\n * @param excludeSystem - Whether system collections should be excluded.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collections = await db.collections();\r\n * // collections is an array of DocumentCollection and EdgeCollection\r\n * // instances not including system collections\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collections = await db.collections(false);\r\n * // collections is an array of DocumentCollection and EdgeCollection\r\n * // instances including system collections\r\n * ```\r\n */\r\n async collections(\r\n excludeSystem: boolean = true\r\n ): Promise<\r\n Array<collections.DocumentCollection & collections.EdgeCollection>\r\n > {\r\n const collections = await this.listCollections(excludeSystem);\r\n return collections.map((data) => this.collection(data.name));\r\n }\r\n //#endregion\r\n\r\n //#region graphs\r\n /**\r\n * Returns a {@link graphs.Graph} instance representing the graph with the given\r\n * `graphName`.\r\n *\r\n * @param graphName - Name of the graph.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const graph = db.graph(\"some-graph\");\r\n * ```\r\n */\r\n graph(graphName: string): graphs.Graph {\r\n if (!this._graphs.has(graphName)) {\r\n this._graphs.set(graphName, new graphs.Graph(this, graphName));\r\n }\r\n return this._graphs.get(graphName)!;\r\n }\r\n\r\n /**\r\n * Creates a graph with the given `graphName` and `edgeDefinitions`, then\r\n * returns a {@link graphs.Graph} instance for the new graph.\r\n *\r\n * @param graphName - Name of the graph to be created.\r\n * @param edgeDefinitions - An array of edge definitions.\r\n * @param options - An object defining the properties of the graph.\r\n */\r\n async createGraph(\r\n graphName: string,\r\n edgeDefinitions: graphs.EdgeDefinitionOptions[],\r\n options?: graphs.CreateGraphOptions\r\n ): Promise<graphs.Graph> {\r\n const graph = this.graph(graphName);\r\n await graph.create(edgeDefinitions, options);\r\n return graph;\r\n }\r\n\r\n /**\r\n * Fetches all graphs from the database and returns an array of graph\r\n * descriptions.\r\n *\r\n * See also {@link Database#graphs}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const graphs = await db.listGraphs();\r\n * // graphs is an array of graph descriptions\r\n * ```\r\n */\r\n listGraphs(): Promise<graphs.GraphDescription[]> {\r\n return this.request(\r\n { pathname: \"/_api/gharial\" },\r\n (res) => res.parsedBody.graphs\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all graphs from the database and returns an array of {@link graphs.Graph}\r\n * instances for those graphs.\r\n *\r\n * See also {@link Database#listGraphs}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const graphs = await db.graphs();\r\n * // graphs is an array of Graph instances\r\n * ```\r\n */\r\n async graphs(): Promise<graphs.Graph[]> {\r\n const graphs = await this.listGraphs();\r\n return graphs.map((data: any) => this.graph(data._key));\r\n }\r\n //#endregion\r\n\r\n //#region views\r\n /**\r\n * Returns a {@link views.View} instance for the given `viewName`.\r\n *\r\n * @param viewName - Name of the ArangoSearch or SearchAlias View.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const view = db.view(\"potatoes\");\r\n * ```\r\n */\r\n view(viewName: string): views.View {\r\n if (!this._views.has(viewName)) {\r\n this._views.set(viewName, new views.View(this, viewName));\r\n }\r\n return this._views.get(viewName)!;\r\n }\r\n\r\n /**\r\n * Creates a new View with the given `viewName` and `options`, then returns a\r\n * {@link views.View} instance for the new View.\r\n *\r\n * @param viewName - Name of the View.\r\n * @param options - An object defining the properties of the View.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const view = await db.createView(\"potatoes\", { type: \"arangosearch\" });\r\n * // the ArangoSearch View \"potatoes\" now exists\r\n * ```\r\n */\r\n async createView(\r\n viewName: string,\r\n options: views.CreateViewOptions\r\n ): Promise<views.View> {\r\n const view = this.view(viewName);\r\n await view.create(options);\r\n return view;\r\n }\r\n\r\n /**\r\n * Renames the view `viewName` to `newName`.\r\n *\r\n * Additionally removes any stored {@link views.View} instance for `viewName` from\r\n * the `Database` instance's internal cache.\r\n *\r\n * **Note**: Renaming views may not be supported when ArangoDB is running in\r\n * a cluster configuration.\r\n *\r\n * @param viewName - Current name of the view.\r\n * @param newName - The new name of the view.\r\n */\r\n async renameView(\r\n viewName: string,\r\n newName: string\r\n ): Promise<connection.ArangoApiResponse<views.ViewDescription>> {\r\n const result = await this.request({\r\n method: \"PUT\",\r\n pathname: `/_api/view/${encodeURIComponent(viewName)}/rename`,\r\n body: { name: newName },\r\n });\r\n this._views.delete(viewName);\r\n return result;\r\n }\r\n\r\n /**\r\n * Fetches all Views from the database and returns an array of View\r\n * descriptions.\r\n *\r\n * See also {@link Database#views}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n *\r\n * const views = await db.listViews();\r\n * // views is an array of View descriptions\r\n * ```\r\n */\r\n listViews(): Promise<views.ViewDescription[]> {\r\n return this.request(\r\n { pathname: \"/_api/view\" },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all Views from the database and returns an array of\r\n * {@link views.View} instances\r\n * for the Views.\r\n *\r\n * See also {@link Database#listViews}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const views = await db.views();\r\n * // views is an array of ArangoSearch View instances\r\n * ```\r\n */\r\n async views(): Promise<views.View[]> {\r\n const views = await this.listViews();\r\n return views.map((data) => this.view(data.name));\r\n }\r\n //#endregion\r\n\r\n //#region analyzers\r\n /**\r\n * Returns an {@link analyzers.Analyzer} instance representing the Analyzer with the\r\n * given `analyzerName`.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const analyzer = db.analyzer(\"some-analyzer\");\r\n * const info = await analyzer.get();\r\n * ```\r\n */\r\n analyzer(analyzerName: string): analyzers.Analyzer {\r\n if (!this._analyzers.has(analyzerName)) {\r\n this._analyzers.set(\r\n analyzerName,\r\n new analyzers.Analyzer(this, analyzerName)\r\n );\r\n }\r\n return this._analyzers.get(analyzerName)!;\r\n }\r\n\r\n /**\r\n * Creates a new Analyzer with the given `analyzerName` and `options`, then\r\n * returns an {@link analyzers.Analyzer} instance for the new Analyzer.\r\n *\r\n * @param analyzerName - Name of the Analyzer.\r\n * @param options - An object defining the properties of the Analyzer.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const analyzer = await db.createAnalyzer(\"potatoes\", { type: \"identity\" });\r\n * // the identity Analyzer \"potatoes\" now exists\r\n * ```\r\n */\r\n async createAnalyzer(\r\n analyzerName: string,\r\n options: analyzers.CreateAnalyzerOptions\r\n ): Promise<analyzers.Analyzer> {\r\n const analyzer = this.analyzer(analyzerName);\r\n await analyzer.create(options);\r\n return analyzer;\r\n }\r\n\r\n /**\r\n * Fetches all Analyzers visible in the database and returns an array of\r\n * Analyzer descriptions.\r\n *\r\n * See also {@link Database#analyzers}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const analyzers = await db.listAnalyzers();\r\n * // analyzers is an array of Analyzer descriptions\r\n * ```\r\n */\r\n listAnalyzers(): Promise<analyzers.AnalyzerDescription[]> {\r\n return this.request(\r\n { pathname: \"/_api/analyzer\" },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all Analyzers visible in the database and returns an array of\r\n * {@link analyzers.Analyzer} instances for those Analyzers.\r\n *\r\n * See also {@link Database#listAnalyzers}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const analyzers = await db.analyzers();\r\n * // analyzers is an array of Analyzer instances\r\n * ```\r\n */\r\n async analyzers(): Promise<analyzers.Analyzer[]> {\r\n const analyzers = await this.listAnalyzers();\r\n return analyzers.map((data) => this.analyzer(data.name));\r\n }\r\n //#endregion\r\n\r\n //#region users\r\n /**\r\n * Fetches all ArangoDB users visible to the authenticated user and returns\r\n * an array of user objects.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const users = await db.listUsers();\r\n * // users is an array of user objects\r\n * ```\r\n */\r\n listUsers(): Promise<users.ArangoUser[]> {\r\n return this.request(\r\n {\r\n pathname: \"/_api/user\",\r\n },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Fetches the user data of a single ArangoDB user.\r\n *\r\n * @param username - Name of the ArangoDB user to fetch.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const user = await db.getUser(\"steve\");\r\n * // user is the user object for the user named \"steve\"\r\n * ```\r\n */\r\n getUser(\r\n username: string\r\n ): Promise<connection.ArangoApiResponse<users.ArangoUser>> {\r\n return this.request({\r\n pathname: `/_api/user/${encodeURIComponent(username)}`,\r\n });\r\n }\r\n\r\n /**\r\n * Creates a new ArangoDB user with the given password.\r\n *\r\n * @param username - Name of the ArangoDB user to create.\r\n * @param passwd - Password of the new ArangoDB user.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const user = await db.createUser(\"steve\", \"hunter2\");\r\n * // The user \"steve\" has been created\r\n * ```\r\n */\r\n createUser(\r\n username: string,\r\n passwd: string\r\n ): Promise<connection.ArangoApiResponse<users.ArangoUser>>;\r\n /**\r\n * Creates a new ArangoDB user with the given options.\r\n *\r\n * @param username - Name of the ArangoDB user to create.\r\n * @param options - Additional options for creating the ArangoDB user.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const user = await db.createUser(\"steve\", { passwd: \"hunter2\" });\r\n * // The user \"steve\" has been created\r\n * ```\r\n */\r\n createUser(\r\n username: string,\r\n options: users.UserOptions\r\n ): Promise<connection.ArangoApiResponse<users.ArangoUser>>;\r\n createUser(\r\n username: string,\r\n options: string | users.UserOptions\r\n ): Promise<connection.ArangoApiResponse<users.ArangoUser>> {\r\n if (typeof options === \"string\") {\r\n options = { passwd: options };\r\n }\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_api/user\",\r\n body: { user: username, ...options },\r\n },\r\n (res) => res.parsedBody\r\n );\r\n }\r\n\r\n /**\r\n * Sets the password of a given ArangoDB user to the new value.\r\n *\r\n * @param username - Name of the ArangoDB user to change the password for.\r\n * @param passwd - New password for the ArangoDB user.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const user = await db.updateUser(\"steve\", \"hunter2\");\r\n * // The user \"steve\" has received a new password\r\n * ```\r\n */\r\n updateUser(\r\n username: string,\r\n passwd: string\r\n ): Promise<connection.ArangoApiResponse<users.ArangoUser>>;\r\n /**\r\n * Updates the ArangoDB user with the new options.\r\n *\r\n * @param username - Name of the ArangoDB user to modify.\r\n * @param options - Options of the ArangoDB user to modify.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const user = await db.updateUser(\"steve\", { active: false });\r\n * // The user \"steve\" has been set to inactive\r\n * ```\r\n */\r\n updateUser(\r\n username: string,\r\n options: Partial<users.UserOptions>\r\n ): Promise<connection.ArangoApiResponse<users.ArangoUser>>;\r\n updateUser(\r\n username: string,\r\n options: string | Partial<users.UserOptions>\r\n ): Promise<connection.ArangoApiResponse<users.ArangoUser>> {\r\n if (typeof options === \"string\") {\r\n options = { passwd: options };\r\n }\r\n return this.request(\r\n {\r\n method: \"PATCH\",\r\n pathname: `/_api/user/${encodeURIComponent(username)}`,\r\n body: options,\r\n },\r\n (res) => res.parsedBody\r\n );\r\n }\r\n\r\n /**\r\n * Replaces the ArangoDB user's option with the new options.\r\n *\r\n * @param username - Name of the ArangoDB user to modify.\r\n * @param options - New options to replace the user's existing options.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const user = await db.replaceUser(\"steve\", { passwd: \"\", active: false });\r\n * // The user \"steve\" has been set to inactive with an empty password\r\n * ```\r\n */\r\n replaceUser(\r\n username: string,\r\n options: users.UserOptions\r\n ): Promise<connection.ArangoApiResponse<users.ArangoUser>> {\r\n if (typeof options === \"string\") {\r\n options = { passwd: options };\r\n }\r\n return this.request(\r\n {\r\n method: \"PUT\",\r\n pathname: `/_api/user/${encodeURIComponent(username)}`,\r\n body: options,\r\n },\r\n (res) => res.parsedBody\r\n );\r\n }\r\n\r\n /**\r\n * Removes the ArangoDB user with the given username from the server.\r\n *\r\n * @param username - Name of the ArangoDB user to remove.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.removeUser(\"steve\");\r\n * // The user \"steve\" has been removed\r\n * ```\r\n */\r\n removeUser(username: string): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: `/_api/user/${encodeURIComponent(username)}`,\r\n },\r\n () => undefined\r\n );\r\n }\r\n\r\n /**\r\n * Fetches the given ArangoDB user's access level for the database, or the\r\n * given collection in the given database.\r\n *\r\n * @param username - Name of the ArangoDB user to fetch the access level for.\r\n * @param options - Collection and/or database to fetch the access level for.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const accessLevel = await db.getUserAccessLevel(\"steve\");\r\n * // The access level of the user \"steve\" has been fetched for the current\r\n * // database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const accessLevel = await db.getUserAccessLevel(\"steve\", {\r\n * database: \"staging\"\r\n * });\r\n * // The access level of the user \"steve\" has been fetched for the \"staging\"\r\n * // database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const accessLevel = await db.getUserAccessLevel(\"steve\", {\r\n * collection: \"pokemons\"\r\n * });\r\n * // The access level of the user \"steve\" has been fetched for the\r\n * // \"pokemons\" collection in the current database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const accessLevel = await db.getUserAccessLevel(\"steve\", {\r\n * database: \"staging\",\r\n * collection: \"pokemons\"\r\n * });\r\n * // The access level of the user \"steve\" has been fetched for the\r\n * // \"pokemons\" collection in the \"staging\" database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const staging = db.database(\"staging\");\r\n * const accessLevel = await db.getUserAccessLevel(\"steve\", {\r\n * database: staging\r\n * });\r\n * // The access level of the user \"steve\" has been fetched for the \"staging\"\r\n * // database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const staging = db.database(\"staging\");\r\n * const accessLevel = await db.getUserAccessLevel(\"steve\", {\r\n * collection: staging.collection(\"pokemons\")\r\n * });\r\n * // The access level of the user \"steve\" has been fetched for the\r\n * // \"pokemons\" collection in database \"staging\".\r\n * ```\r\n */\r\n getUserAccessLevel(\r\n username: string,\r\n options: users.UserAccessLevelOptions\r\n ): Promise<users.AccessLevel> {\r\n const { database, collection } = options;\r\n const databaseName = isArangoDatabase(database)\r\n ? database.name\r\n : (database ??\r\n (collection instanceof collections.Collection\r\n ? collection.database.name\r\n : this._name));\r\n const suffix = collection\r\n ? `/${encodeURIComponent(\r\n collections.isArangoCollection(collection)\r\n ? collection.name\r\n : collection\r\n )}`\r\n : \"\";\r\n return this.request(\r\n {\r\n pathname: `/_api/user/${encodeURIComponent(\r\n username\r\n )}/database/${encodeURIComponent(databaseName)}${suffix}`,\r\n },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Sets the given ArangoDB user's access level for the database, or the\r\n * given collection in the given database.\r\n *\r\n * @param username - Name of the ArangoDB user to set the access level for.\r\n * @param options - Database and/or collection to set the access level for.\r\n * @param grant - Access level to set for the given user.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.setUserAccessLevel(\"steve\", { grant: \"rw\" });\r\n * // The user \"steve\" now has read-write access to the current database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.setUserAccessLevel(\"steve\", {\r\n * database: \"staging\",\r\n * grant: \"rw\"\r\n * });\r\n * // The user \"steve\" now has read-write access to the \"staging\" database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.setUserAccessLevel(\"steve\", {\r\n * collection: \"pokemons\",\r\n * grant: \"rw\"\r\n * });\r\n * // The user \"steve\" now has read-write access to the \"pokemons\" collection\r\n * // in the current database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.setUserAccessLevel(\"steve\", {\r\n * database: \"staging\",\r\n * collection: \"pokemons\",\r\n * grant: \"rw\"\r\n * });\r\n * // The user \"steve\" now has read-write access to the \"pokemons\" collection\r\n * // in the \"staging\" database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const staging = db.database(\"staging\");\r\n * await db.setUserAccessLevel(\"steve\", {\r\n * database: staging,\r\n * grant: \"rw\"\r\n * });\r\n * // The user \"steve\" now has read-write access to the \"staging\" database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const staging = db.database(\"staging\");\r\n * await db.setUserAccessLevel(\"steve\", {\r\n * collection: staging.collection(\"pokemons\"),\r\n * grant: \"rw\"\r\n * });\r\n * // The user \"steve\" now has read-write access to the \"pokemons\" collection\r\n * // in database \"staging\".\r\n * ```\r\n */\r\n setUserAccessLevel(\r\n username: string,\r\n options: users.UserAccessLevelOptions,\r\n grant: users.AccessLevel\r\n ): Promise<connection.ArangoApiResponse<Record<string, users.AccessLevel>>> {\r\n const { database, collection } = options;\r\n const databaseName = isArangoDatabase(database)\r\n ? database.name\r\n : (database ??\r\n (collection instanceof collections.Collection\r\n ? collection.database.name\r\n : this._name));\r\n const suffix = collection\r\n ? `/${encodeURIComponent(\r\n collections.isArangoCollection(collection)\r\n ? collection.name\r\n : collection\r\n )}`\r\n : \"\";\r\n return this.request(\r\n {\r\n method: \"PUT\",\r\n pathname: `/_api/user/${encodeURIComponent(\r\n username\r\n )}/database/${encodeURIComponent(databaseName)}${suffix}`,\r\n body: { grant },\r\n },\r\n (res) => res.parsedBody\r\n );\r\n }\r\n\r\n /**\r\n * Clears the given ArangoDB user's access level for the database, or the\r\n * given collection in the given database.\r\n *\r\n * @param username - Name of the ArangoDB user to clear the access level for.\r\n * @param options - Database and/or collection to clear the access level for.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.clearUserAccessLevel(\"steve\");\r\n * // The access level of the user \"steve\" has been cleared for the current\r\n * // database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.clearUserAccessLevel(\"steve\", { database: \"staging\" });\r\n * // The access level of the user \"steve\" has been cleared for the \"staging\"\r\n * // database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.clearUserAccessLevel(\"steve\", { collection: \"pokemons\" });\r\n * // The access level of the user \"steve\" has been cleared for the\r\n * // \"pokemons\" collection in the current database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.clearUserAccessLevel(\"steve\", {\r\n * database: \"staging\",\r\n * collection: \"pokemons\"\r\n * });\r\n * // The access level of the user \"steve\" has been cleared for the\r\n * // \"pokemons\" collection in the \"staging\" database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const staging = db.database(\"staging\");\r\n * await db.clearUserAccessLevel(\"steve\", { database: staging });\r\n * // The access level of the user \"steve\" has been cleared for the \"staging\"\r\n * // database.\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const staging = db.database(\"staging\");\r\n * await db.clearUserAccessLevel(\"steve\", {\r\n * collection: staging.collection(\"pokemons\")\r\n * });\r\n * // The access level of the user \"steve\" has been cleared for the\r\n * // \"pokemons\" collection in database \"staging\".\r\n * ```\r\n */\r\n clearUserAccessLevel(\r\n username: string,\r\n options: users.UserAccessLevelOptions\r\n ): Promise<connection.ArangoApiResponse<Record<string, users.AccessLevel>>> {\r\n const { database, collection } = options;\r\n const databaseName = isArangoDatabase(database)\r\n ? database.name\r\n : (database ??\r\n (collection instanceof collections.Collection\r\n ? collection.database.name\r\n : this._name));\r\n const suffix = collection\r\n ? `/${encodeURIComponent(\r\n collections.isArangoCollection(collection)\r\n ? collection.name\r\n : collection\r\n )}`\r\n : \"\";\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: `/_api/user/${encodeURIComponent(\r\n username\r\n )}/database/${encodeURIComponent(databaseName)}${suffix}`,\r\n },\r\n (res) => res.parsedBody\r\n );\r\n }\r\n\r\n /**\r\n * Fetches an object mapping names of databases to the access level of the\r\n * given ArangoDB user for those databases.\r\n *\r\n * @param username - Name of the ArangoDB user to fetch the access levels for.\r\n * @param full - Whether access levels for collections should be included.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const accessLevels = await db.getUserDatabases(\"steve\");\r\n * for (const [databaseName, accessLevel] of Object.entries(accessLevels)) {\r\n * console.log(`${databaseName}: ${accessLevel}`);\r\n * }\r\n * ```\r\n */\r\n getUserDatabases(\r\n username: string,\r\n full?: false\r\n ): Promise<Record<string, users.AccessLevel>>;\r\n /**\r\n * Fetches an object mapping names of databases to the access level of the\r\n * given ArangoDB user for those databases and the collections within each\r\n * database.\r\n *\r\n * @param username - Name of the ArangoDB user to fetch the access levels for.\r\n * @param full - Whether access levels for collections should be included.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const accessLevels = await db.getUserDatabases(\"steve\", true);\r\n * for (const [databaseName, obj] of Object.entries(accessLevels)) {\r\n * console.log(`${databaseName}: ${obj.permission}`);\r\n * for (const [collectionName, accessLevel] of Object.entries(obj.collections)) {\r\n * console.log(`${databaseName}/${collectionName}: ${accessLevel}`);\r\n * }\r\n * }\r\n * ```\r\n */\r\n getUserDatabases(\r\n username: string,\r\n full: true\r\n ): Promise<\r\n Record<\r\n string,\r\n {\r\n permission: users.AccessLevel;\r\n collections: Record<string, users.AccessLevel | \"undefined\">;\r\n }\r\n >\r\n >;\r\n getUserDatabases(username: string, full?: boolean) {\r\n return this.request(\r\n {\r\n pathname: `/_api/user/${encodeURIComponent(username)}/database`,\r\n search: { full },\r\n },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Creates a new access token for the given ArangoDB user.\r\n *\r\n * Access tokens can be used as password replacements for authentication.\r\n * The token value is only returned once in this response and cannot be\r\n * retrieved again. Store it securely.\r\n *\r\n * @param username - Name of the ArangoDB user to create the token for.\r\n * @param options - Options for creating the access token.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Convert Date to Unix timestamp (seconds)\r\n * const expiryDate = new Date(\"2025-12-31\");\r\n * const expiryTimestamp = Math.floor(expiryDate.getTime() / 1000);\r\n * const token = await db.createAccessToken(\"appUser\", {\r\n * name: \"CI token\",\r\n * valid_until: expiryTimestamp\r\n * });\r\n * console.log(token.token); // Store this securely!\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const token = await db.createAccessToken(\"appUser\", {\r\n * name: \"Production token\",\r\n * valid_until: Math.floor(Date.now() / 1000) + (30 * 24 * 60 * 60) // 30 days\r\n * });\r\n * ```\r\n */\r\n createAccessToken(\r\n username: string,\r\n options: users.CreateAccessTokenOptions\r\n ): Promise<connection.ArangoApiResponse<users.AccessToken>> {\r\n if (!username || typeof username !== \"string\") {\r\n throw new Error(\"Username must be a non-empty string\");\r\n }\r\n if (!options || typeof options !== \"object\") {\r\n throw new Error(\"Options must be an object\");\r\n }\r\n if (!options.name || typeof options.name !== \"string\") {\r\n throw new Error(\"Token name must be a non-empty string\");\r\n }\r\n\r\n const body: { name: string; valid_until?: number } = {\r\n name: options.name,\r\n };\r\n\r\n if (options.valid_until !== undefined) {\r\n if (typeof options.valid_until !== \"number\") {\r\n throw new Error(\r\n \"valid_until must be a Unix timestamp (number in seconds)\"\r\n );\r\n }\r\n body.valid_until = options.valid_until;\r\n }\r\n\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: `/_api/token/${encodeURIComponent(username)}`,\r\n body,\r\n },\r\n (res) => res.parsedBody\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all access tokens for the given ArangoDB user.\r\n *\r\n * Note: Token values are not returned. Only metadata (id, name, expiry, etc.)\r\n * is available. Token values can only be retrieved when creating a new token.\r\n *\r\n * @param username - Name of the ArangoDB user to fetch tokens for.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const tokens = await db.getAccessTokens(\"appUser\");\r\n * for (const token of tokens) {\r\n * console.log(`${token.name}: expires ${new Date(token.valid_until * 1000)}`);\r\n * }\r\n * ```\r\n */\r\n getAccessTokens(\r\n username: string\r\n ): Promise<users.AccessTokenMetadata[]> {\r\n if (!username || typeof username !== \"string\") {\r\n throw new Error(\"Username must be a non-empty string\");\r\n }\r\n\r\n return this.request(\r\n {\r\n pathname: `/_api/token/${encodeURIComponent(username)}`,\r\n },\r\n (res) => res.parsedBody.tokens\r\n );\r\n }\r\n\r\n /**\r\n * Deletes (revokes) an access token for the given ArangoDB user.\r\n *\r\n * Once deleted, the token cannot be used for authentication and cannot be recovered.\r\n *\r\n * @param username - Name of the ArangoDB user who owns the token.\r\n * @param tokenId - Unique identifier of the token to delete.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const tokens = await db.getAccessTokens(\"appUser\");\r\n * for (const token of tokens) {\r\n * if (token.name === \"Old CI token\") {\r\n * await db.deleteAccessToken(\"appUser\", token.id);\r\n * }\r\n * }\r\n * ```\r\n */\r\n deleteAccessToken(\r\n username: string,\r\n tokenId: number\r\n ): Promise<void> {\r\n if (!username || typeof username !== \"string\") {\r\n throw new Error(\"Username must be a non-empty string\");\r\n }\r\n if (typeof tokenId !== \"number\" || !Number.isInteger(tokenId) || tokenId < 0) {\r\n throw new Error(\"Token ID must be a non-negative integer\");\r\n }\r\n\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: `/_api/token/${encodeURIComponent(username)}/${tokenId}`,\r\n },\r\n () => undefined\r\n );\r\n }\r\n //#endregion\r\n\r\n //#region transactions\r\n /**\r\n * Performs a server-side JavaScript transaction and returns its return\r\n * value.\r\n *\r\n * Collections can be specified as collection names (strings) or objects\r\n * implementing the {@link collections.ArangoCollection} interface: `Collection`,\r\n * {@link graphs.GraphVertexCollection}, {@link graphs.GraphEdgeCollection} as well as\r\n * (in TypeScript) {@link collections.DocumentCollection} and {@link collections.EdgeCollection}.\r\n *\r\n * **Note**: The `action` function will be evaluated and executed on the\r\n * server inside ArangoDB's embedded JavaScript environment and can not\r\n * access any values other than those passed via the `params` option.\r\n *\r\n * See the official ArangoDB documentation for\r\n * [the JavaScript `@arangodb` module](https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html)\r\n * for information about accessing the database from within ArangoDB's\r\n * server-side JavaScript environment.\r\n *\r\n * @param collections - Collections involved in the transaction.\r\n * @param action - A string evaluating to a JavaScript function to be\r\n * executed on the server.\r\n * @param options - Options for the transaction. If `options.allowImplicit`\r\n * is specified, it will be used if `collections.allowImplicit` was not\r\n * specified.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n *\r\n * const action = `\r\n * function(params) {\r\n * // This code will be executed inside ArangoDB!\r\n * const { query } = require(\"@arangodb\");\r\n * return query\\`\r\n * FOR user IN _users\r\n * FILTER user.age > ${params.age}\r\n * RETURN u.user\r\n * \\`.toArray();\r\n * }\r\n * `);\r\n *\r\n * const result = await db.executeTransaction({\r\n * read: [\"_users\"]\r\n * }, action, {\r\n * params: { age: 12 }\r\n * });\r\n * // result contains the return value of the action\r\n * ```\r\n */\r\n executeTransaction(\r\n collections: transactions.TransactionCollectionOptions & {\r\n allowImplicit?: boolean;\r\n },\r\n action: string,\r\n options?: transactions.TransactionOptions & { params?: any }\r\n ): Promise<any>;\r\n /**\r\n * Performs a server-side transaction and returns its return value.\r\n *\r\n * Collections can be specified as collection names (strings) or objects\r\n * implementing the {@link collections.ArangoCollection} interface: `Collection`,\r\n * {@link graphs.GraphVertexCollection}, {@link graphs.GraphEdgeCollection} as well as\r\n * (in TypeScript) {@link collections.DocumentCollection} and {@link collections.EdgeCollection}.\r\n *\r\n * **Note**: The `action` function will be evaluated and executed on the\r\n * server inside ArangoDB's embedded JavaScript environment and can not\r\n * access any values other than those passed via the `params` option.\r\n * See the official ArangoDB documentation for\r\n * [the JavaScript `@arangodb` module](https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html)\r\n * for information about accessing the database from within ArangoDB's\r\n * server-side JavaScript environment.\r\n *\r\n * @param collections - Collections that can be read from and written to\r\n * during the transaction.\r\n * @param action - A string evaluating to a JavaScript function to be\r\n * executed on the server.\r\n * @param options - Options for the transaction.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n *\r\n * const action = `\r\n * function(params) {\r\n * // This code will be executed inside ArangoDB!\r\n * const { query } = require(\"@arangodb\");\r\n * return query\\`\r\n * FOR user IN _users\r\n * FILTER user.age > ${params.age}\r\n * RETURN u.user\r\n * \\`.toArray();\r\n * }\r\n * `);\r\n *\r\n * const result = await db.executeTransaction([\"_users\"], action, {\r\n * params: { age: 12 }\r\n * });\r\n * // result contains the return value of the action\r\n * ```\r\n */\r\n executeTransaction(\r\n collections: (string | collections.ArangoCollection)[],\r\n action: string,\r\n options?: transactions.TransactionOptions & { params?: any }\r\n ): Promise<any>;\r\n /**\r\n * Performs a server-side transaction and returns its return value.\r\n *\r\n * The Collection can be specified as a collection name (string) or an object\r\n * implementing the {@link collections.ArangoCollection} interface: `Collection`,\r\n * {@link graphs.GraphVertexCollection}, {@link graphs.GraphEdgeCollection} as well as\r\n * (in TypeScript) {@link collections.DocumentCollection} and {@link collections.EdgeCollection}.\r\n *\r\n * **Note**: The `action` function will be evaluated and executed on the\r\n * server inside ArangoDB's embedded JavaScript environment and can not\r\n * access any values other than those passed via the `params` option.\r\n * See the official ArangoDB documentation for\r\n * [the JavaScript `@arangodb` module](https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html)\r\n * for information about accessing the database from within ArangoDB's\r\n * server-side JavaScript environment.\r\n *\r\n * @param collection - A collection that can be read from and written to\r\n * during the transaction.\r\n * @param action - A string evaluating to a JavaScript function to be\r\n * executed on the server.\r\n * @param options - Options for the transaction.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n *\r\n * const action = `\r\n * function(params) {\r\n * // This code will be executed inside ArangoDB!\r\n * const { query } = require(\"@arangodb\");\r\n * return query\\`\r\n * FOR user IN _users\r\n * FILTER user.age > ${params.age}\r\n * RETURN u.user\r\n * \\`.toArray();\r\n * }\r\n * `);\r\n *\r\n * const result = await db.executeTransaction(\"_users\", action, {\r\n * params: { age: 12 }\r\n * });\r\n * // result contains the return value of the action\r\n * ```\r\n */\r\n executeTransaction(\r\n collection: string | collections.ArangoCollection,\r\n action: string,\r\n options?: transactions.TransactionOptions & { params?: any }\r\n ): Promise<any>;\r\n executeTransaction(\r\n collections:\r\n | (transactions.TransactionCollectionOptions & {\r\n allowImplicit?: boolean;\r\n })\r\n | (string | collections.ArangoCollection)[]\r\n | string\r\n | collections.ArangoCollection,\r\n action: string,\r\n options: transactions.TransactionOptions & { params?: any } = {}\r\n ): Promise<any> {\r\n const { allowDirtyRead = undefined, ...opts } = options;\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_api/transaction\",\r\n allowDirtyRead,\r\n body: {\r\n collections: transactions.coerceTransactionCollections(collections),\r\n action,\r\n ...opts,\r\n },\r\n },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Returns a {@link transactions.Transaction} instance for an existing streaming\r\n * transaction with the given `id`.\r\n *\r\n * See also {@link Database#beginTransaction}.\r\n *\r\n * @param transactionId - The `id` of an existing stream transaction.\r\n *\r\n * @example\r\n * ```js\r\n * const trx1 = await db.beginTransaction(collections);\r\n * const id = trx1.id;\r\n * // later\r\n * const trx2 = db.transaction(id);\r\n * await trx2.commit();\r\n * ```\r\n */\r\n transaction(transactionId: string): transactions.Transaction {\r\n return new transactions.Transaction(this, transactionId);\r\n }\r\n\r\n /**\r\n * Begins a new streaming transaction for the given collections, then returns\r\n * a {@link transactions.Transaction} instance for the transaction.\r\n *\r\n * Collections can be specified as collection names (strings) or objects\r\n * implementing the {@link collections.ArangoCollection} interface: `Collection`,\r\n * {@link graphs.GraphVertexCollection}, {@link graphs.GraphEdgeCollection} as\r\n * well as (in TypeScript) {@link collections.DocumentCollection} and\r\n * {@link collections.EdgeCollection}.\r\n *\r\n * @param collections - Collections involved in the transaction.\r\n * @param options - Options for the transaction.\r\n *\r\n * @example\r\n * ```js\r\n * const vertices = db.collection(\"vertices\");\r\n * const edges = db.collection(\"edges\");\r\n * const trx = await db.beginTransaction({\r\n * read: [\"vertices\"],\r\n * write: [edges] // collection instances can be passed directly\r\n * });\r\n * const start = await trx.step(() => vertices.document(\"a\"));\r\n * const end = await trx.step(() => vertices.document(\"b\"));\r\n * await trx.step(() => edges.save({ _from: start._id, _to: end._id }));\r\n * await trx.commit();\r\n * ```\r\n */\r\n beginTransaction(\r\n collections: transactions.TransactionCollectionOptions,\r\n options?: transactions.TransactionOptions\r\n ): Promise<transactions.Transaction>;\r\n /**\r\n * Begins a new streaming transaction for the given collections, then returns\r\n * a {@link transactions.Transaction} instance for the transaction.\r\n *\r\n * Collections can be specified as collection names (strings) or objects\r\n * implementing the {@link collections.ArangoCollection} interface: `Collection`,\r\n * {@link graphs.GraphVertexCollection}, {@link graphs.GraphEdgeCollection} as well as\r\n * (in TypeScript) {@link collections.DocumentCollection} and {@link collections.EdgeCollection}.\r\n *\r\n * @param collections - Collections that can be read from and written to\r\n * during the transaction.\r\n * @param options - Options for the transaction.\r\n *\r\n * @example\r\n * ```js\r\n * const vertices = db.collection(\"vertices\");\r\n * const edges = db.collection(\"edges\");\r\n * const trx = await db.beginTransaction([\r\n * \"vertices\",\r\n * edges // collection instances can be passed directly\r\n * ]);\r\n * const start = await trx.step(() => vertices.document(\"a\"));\r\n * const end = await trx.step(() => vertices.document(\"b\"));\r\n * await trx.step(() => edges.save({ _from: start._id, _to: end._id }));\r\n * await trx.commit();\r\n * ```\r\n */\r\n beginTransaction(\r\n collections: (string | collections.ArangoCollection)[],\r\n options?: transactions.TransactionOptions\r\n ): Promise<transactions.Transaction>;\r\n /**\r\n * Begins a new streaming transaction for the given collections, then returns\r\n * a {@link transactions.Transaction} instance for the transaction.\r\n *\r\n * The Collection can be specified as a collection name (string) or an object\r\n * implementing the {@link collections.ArangoCollection} interface: `Collection`,\r\n * {@link graphs.GraphVertexCollection}, {@link graphs.GraphEdgeCollection} as well as\r\n * (in TypeScript) {@link collections.DocumentCollection} and {@link collections.EdgeCollection}.\r\n *\r\n * @param collection - A collection that can be read from and written to\r\n * during the transaction.\r\n * @param options - Options for the transaction.\r\n *\r\n * @example\r\n * ```js\r\n * const vertices = db.collection(\"vertices\");\r\n * const start = vertices.document(\"a\");\r\n * const end = vertices.document(\"b\");\r\n * const edges = db.collection(\"edges\");\r\n * const trx = await db.beginTransaction(\r\n * edges // collection instances can be passed directly\r\n * );\r\n * await trx.step(() => edges.save({ _from: start._id, _to: end._id }));\r\n * await trx.commit();\r\n * ```\r\n */\r\n beginTransaction(\r\n collection: string | collections.ArangoCollection,\r\n options?: transactions.TransactionOptions\r\n ): Promise<transactions.Transaction>;\r\n beginTransaction(\r\n collections:\r\n | transactions.TransactionCollectionOptions\r\n | (string | collections.ArangoCollection)[]\r\n | string\r\n | collections.ArangoCollection,\r\n options: transactions.TransactionOptions = {}\r\n ): Promise<transactions.Transaction> {\r\n const { allowDirtyRead = undefined, ...opts } = options;\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_api/transaction/begin\",\r\n allowDirtyRead,\r\n body: {\r\n collections: transactions.coerceTransactionCollections(collections),\r\n ...opts,\r\n },\r\n },\r\n (res) => new transactions.Transaction(this, res.parsedBody.result.id)\r\n );\r\n }\r\n\r\n /**\r\n * Begins and commits a transaction using the given callback. Individual\r\n * requests that are part of the transaction need to be wrapped in the step\r\n * function passed into the callback. If the promise returned by the callback\r\n * is rejected, the transaction will be aborted.\r\n *\r\n * Collections can be specified as collection names (strings) or objects\r\n * implementing the {@link collections.ArangoCollection} interface: `Collection`,\r\n * {@link graphs.GraphVertexCollection}, {@link graphs.GraphEdgeCollection} as\r\n * well as (in TypeScript) {@link collections.DocumentCollection} and\r\n * {@link collections.EdgeCollection}.\r\n *\r\n * @param collections - Collections involved in the transaction.\r\n * @param callback - Callback function executing the transaction steps.\r\n * @param options - Options for the transaction.\r\n *\r\n * @example\r\n * ```js\r\n * const vertices = db.collection(\"vertices\");\r\n * const edges = db.collection(\"edges\");\r\n * await db.withTransaction(\r\n * {\r\n * read: [\"vertices\"],\r\n * write: [edges] // collection instances can be passed directly\r\n * },\r\n * async (step) => {\r\n * const start = await step(() => vertices.document(\"a\"));\r\n * const end = await step(() => vertices.document(\"b\"));\r\n * await step(() => edges.save({ _from: start._id, _to: end._id }));\r\n * }\r\n * );\r\n * ```\r\n */\r\n withTransaction<T>(\r\n collections: transactions.TransactionCollectionOptions,\r\n callback: (step: transactions.Transaction[\"step\"]) => Promise<T>,\r\n options?: transactions.TransactionOptions\r\n ): Promise<T>;\r\n /**\r\n * Begins and commits a transaction using the given callback. Individual\r\n * requests that are part of the transaction need to be wrapped in the step\r\n * function passed into the callback. If the promise returned by the callback\r\n * is rejected, the transaction will be aborted.\r\n *\r\n * Collections can be specified as collection names (strings) or objects\r\n * implementing the {@link collections.ArangoCollection} interface: `Collection`,\r\n * {@link graphs.GraphVertexCollection}, {@link graphs.GraphEdgeCollection} as well as\r\n * (in TypeScript) {@link collections.DocumentCollection} and {@link collections.EdgeCollection}.\r\n *\r\n * @param collections - Collections that can be read from and written to\r\n * during the transaction.\r\n * @param callback - Callback function executing the transaction steps.\r\n * @param options - Options for the transaction.\r\n *\r\n * @example\r\n * ```js\r\n * const vertices = db.collection(\"vertices\");\r\n * const edges = db.collection(\"edges\");\r\n * await db.withTransaction(\r\n * [\r\n * \"vertices\",\r\n * edges, // collection instances can be passed directly\r\n * ],\r\n * async (step) => {\r\n * const start = await step(() => vertices.document(\"a\"));\r\n * const end = await step(() => vertices.document(\"b\"));\r\n * await step(() => edges.save({ _from: start._id, _to: end._id }));\r\n * }\r\n * );\r\n * ```\r\n */\r\n withTransaction<T>(\r\n collections: (string | collections.ArangoCollection)[],\r\n callback: (step: transactions.Transaction[\"step\"]) => Promise<T>,\r\n options?: transactions.TransactionOptions\r\n ): Promise<T>;\r\n /**\r\n * Begins and commits a transaction using the given callback. Individual\r\n * requests that are part of the transaction need to be wrapped in the step\r\n * function passed into the callback. If the promise returned by the callback\r\n * is rejected, the transaction will be aborted.\r\n *\r\n * The Collection can be specified as a collection name (string) or an object\r\n * implementing the {@link collections.ArangoCollection} interface: `Collection`,\r\n * {@link graphs.GraphVertexCollection}, {@link graphs.GraphEdgeCollection} as well as\r\n * (in TypeScript) {@link collections.DocumentCollection} and {@link collections.EdgeCollection}.\r\n *\r\n * @param collection - A collection that can be read from and written to\r\n * during the transaction.\r\n * @param callback - Callback function executing the transaction steps.\r\n * @param options - Options for the transaction.\r\n *\r\n * @example\r\n * ```js\r\n * const vertices = db.collection(\"vertices\");\r\n * const start = vertices.document(\"a\");\r\n * const end = vertices.document(\"b\");\r\n * const edges = db.collection(\"edges\");\r\n * await db.withTransaction(\r\n * edges, // collection instances can be passed directly\r\n * async (step) => {\r\n * await step(() => edges.save({ _from: start._id, _to: end._id }));\r\n * }\r\n * );\r\n * ```\r\n */\r\n withTransaction<T>(\r\n collection: string | collections.ArangoCollection,\r\n callback: (step: transactions.Transaction[\"step\"]) => Promise<T>,\r\n options?: transactions.TransactionOptions\r\n ): Promise<T>;\r\n async withTransaction<T>(\r\n collections:\r\n | transactions.TransactionCollectionOptions\r\n | (string | collections.ArangoCollection)[]\r\n | string\r\n | collections.ArangoCollection,\r\n callback: (step: transactions.Transaction[\"step\"]) => Promise<T>,\r\n options: transactions.TransactionOptions = {}\r\n ): Promise<T> {\r\n const trx = await this.beginTransaction(\r\n collections as transactions.TransactionCollectionOptions,\r\n options\r\n );\r\n try {\r\n const result = await callback((fn) => trx.step(fn));\r\n await trx.commit();\r\n return result;\r\n } catch (e) {\r\n try {\r\n await trx.abort();\r\n } catch {}\r\n throw e;\r\n }\r\n }\r\n\r\n /**\r\n * Fetches all active transactions from the database and returns an array of\r\n * transaction descriptions.\r\n *\r\n * See also {@link Database#transactions}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const transactions = await db.listTransactions();\r\n * // transactions is an array of transaction descriptions\r\n * ```\r\n */\r\n listTransactions(): Promise<transactions.TransactionDescription[]> {\r\n return this._connection.request(\r\n { pathname: \"/_api/transaction\" },\r\n (res) => res.parsedBody.transactions\r\n );\r\n }\r\n\r\n /**\r\n * Fetches all active transactions from the database and returns an array of\r\n * {@link transactions.Transaction} instances for those transactions.\r\n *\r\n * See also {@link Database#listTransactions}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const transactions = await db.transactions();\r\n * // transactions is an array of transactions\r\n * ```\r\n */\r\n async transactions(): Promise<transactions.Transaction[]> {\r\n const transactions = await this.listTransactions();\r\n return transactions.map((data) => this.transaction(data.id));\r\n }\r\n //#endregion\r\n\r\n //#region queries\r\n /**\r\n * Performs a database query using the given `query`, then returns a new\r\n * {@link cursors.Cursor} instance for the result set.\r\n *\r\n * See the {@link aql.aql} template string handler for information about how\r\n * to create a query string without manually defining bind parameters nor\r\n * having to worry about escaping variables.\r\n *\r\n * **Note**: When executing a query in a streaming transaction using the\r\n * `step` method, the resulting cursor will be bound to that transaction and\r\n * you do not need to use the `step` method to consume it.\r\n *\r\n * @param query - An object containing an AQL query string and bind\r\n * parameters, e.g. the object returned from an {@link aql.aql} template string.\r\n * @param options - Options for the query execution.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const active = true;\r\n * const Users = db.collection(\"_users\");\r\n *\r\n * // Using an aql template string:\r\n * // Bind parameters are automatically extracted and arangojs collections\r\n * // are automatically passed as collection bind parameters.\r\n * const cursor = await db.query(aql`\r\n * FOR u IN ${Users}\r\n * FILTER u.authData.active == ${active}\r\n * RETURN u.user\r\n * `);\r\n * // cursor is a cursor for the query result\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const active = true;\r\n * const Users = db.collection(\"_users\");\r\n *\r\n * // Using an object with a regular multi-line string\r\n * const cursor = await db.query({\r\n * query: `\r\n * FOR u IN @@users\r\n * FILTER u.authData.active == @active\r\n * RETURN u.user\r\n * `,\r\n * bindVars: { active: active, \"@users\": Users.name }\r\n * });\r\n * ```\r\n */\r\n query<T = any>(\r\n query: aql.AqlQuery<T>,\r\n options?: queries.QueryOptions\r\n ): Promise<cursors.Cursor<T>>;\r\n /**\r\n * Performs a database query using the given `query` and `bindVars`, then\r\n * returns a new {@link cursors.Cursor} instance for the result set.\r\n *\r\n * See the {@link aql.aql} template string handler for a safer and easier\r\n * alternative to passing strings directly.\r\n *\r\n * **Note**: When executing a query in a streaming transaction using the\r\n * `step` method, the resulting cursor will be bound to that transaction and\r\n * you do not need to use the `step` method to consume it.\r\n *\r\n * @param query - An AQL query string.\r\n * @param bindVars - An object defining bind parameters for the query.\r\n * @param options - Options for the query execution.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const active = true;\r\n * const Users = db.collection(\"_users\");\r\n *\r\n * const cursor = await db.query(\r\n * // A normal multi-line string\r\n * `\r\n * FOR u IN @@users\r\n * FILTER u.authData.active == @active\r\n * RETURN u.user\r\n * `,\r\n * { active: active, \"@users\": Users.name }\r\n * );\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const active = true;\r\n * const Users = db.collection(\"_users\");\r\n *\r\n * const cursor = await db.query(\r\n * // An AQL literal created from a normal multi-line string\r\n * aql.literal(`\r\n * FOR u IN @@users\r\n * FILTER u.authData.active == @active\r\n * RETURN u.user\r\n * `),\r\n * { active: active, \"@users\": Users.name }\r\n * );\r\n * ```\r\n */\r\n query<T = any>(\r\n query: string | aql.AqlLiteral,\r\n bindVars?: Record<string, any>,\r\n options?: queries.QueryOptions\r\n ): Promise<cursors.Cursor<T>>;\r\n query<T = any>(\r\n query: string | aql.AqlQuery | aql.AqlLiteral,\r\n bindVars?: Record<string, any>,\r\n options: queries.QueryOptions = {}\r\n ): Promise<cursors.Cursor<T>> {\r\n if (aql.isAqlQuery(query)) {\r\n options = bindVars ?? {};\r\n bindVars = query.bindVars;\r\n query = query.query;\r\n } else if (aql.isAqlLiteral(query)) {\r\n query = query.toAQL();\r\n }\r\n const {\r\n allowDirtyRead,\r\n retryOnConflict,\r\n count,\r\n batchSize,\r\n cache,\r\n memoryLimit,\r\n ttl,\r\n timeout,\r\n ...opts\r\n } = options;\r\n // Accept legacy maxPlans and new maxNumberOfPlans; always send maxNumberOfPlans\r\n const {\r\n maxPlans,\r\n maxNumberOfPlans,\r\n ...remainingOpts\r\n } = opts as queries.QueryOptions & {\r\n maxPlans?: number;\r\n maxNumberOfPlans?: number;\r\n };\r\n \r\n const normalizedOptions = {\r\n ...remainingOpts,\r\n ...(maxNumberOfPlans !== undefined\r\n ? { maxNumberOfPlans }\r\n : maxPlans !== undefined\r\n ? { maxNumberOfPlans: maxPlans }\r\n : {}),\r\n };\r\n\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_api/cursor\",\r\n body: {\r\n query,\r\n bindVars,\r\n count,\r\n batchSize,\r\n cache,\r\n memoryLimit,\r\n ttl,\r\n options: normalizedOptions,\r\n },\r\n allowDirtyRead,\r\n retryOnConflict,\r\n timeout,\r\n },\r\n (res) =>\r\n new cursors.BatchCursor<T>(\r\n this,\r\n res.parsedBody,\r\n res.arangojsHostUrl,\r\n allowDirtyRead\r\n ).items\r\n );\r\n }\r\n\r\n /**\r\n * Explains a database query using the given `query`.\r\n *\r\n * See the {@link aql.aql} template string handler for information about how\r\n * to create a query string without manually defining bind parameters nor\r\n * having to worry about escaping variables.\r\n *\r\n * @param query - An object containing an AQL query string and bind\r\n * parameters, e.g. the object returned from an {@link aql.aql} template string.\r\n * @param options - Options for explaining the query.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collection = db.collection(\"some-collection\");\r\n * const explanation = await db.explain(aql`\r\n * FOR doc IN ${collection}\r\n * FILTER doc.flavor == \"strawberry\"\r\n * RETURN doc._key\r\n * `);\r\n * ```\r\n */\r\n explain(\r\n query: aql.AqlQuery,\r\n options?: queries.ExplainOptions & { allPlans?: false }\r\n ): Promise<connection.ArangoApiResponse<queries.SingleExplainResult>>;\r\n /**\r\n * Explains a database query using the given `query`.\r\n *\r\n * See the {@link aql.aql} template string handler for information about how\r\n * to create a query string without manually defining bind parameters nor\r\n * having to worry about escaping variables.\r\n *\r\n * @param query - An object containing an AQL query string and bind\r\n * parameters, e.g. the object returned from an {@link aql.aql} template string.\r\n * @param options - Options for explaining the query.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collection = db.collection(\"some-collection\");\r\n * const explanation = await db.explain(\r\n * aql`\r\n * FOR doc IN ${collection}\r\n * FILTER doc.flavor == \"strawberry\"\r\n * RETURN doc._key\r\n * `,\r\n * { allPlans: true }\r\n * );\r\n * ```\r\n */\r\n explain(\r\n query: aql.AqlQuery,\r\n options?: queries.ExplainOptions & { allPlans: true }\r\n ): Promise<connection.ArangoApiResponse<queries.MultiExplainResult>>;\r\n /**\r\n * Explains a database query using the given `query` and `bindVars`.\r\n *\r\n * See the {@link aql.aql} template string handler for a safer and easier\r\n * alternative to passing strings directly.\r\n *\r\n * @param query - An AQL query string.\r\n * @param bindVars - An object defining bind parameters for the query.\r\n * @param options - Options for explaining the query.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collection = db.collection(\"some-collection\");\r\n * const explanation = await db.explain(\r\n * `\r\n * FOR doc IN @@collection\r\n * FILTER doc.flavor == \"strawberry\"\r\n * RETURN doc._key\r\n * `,\r\n * { \"@collection\": collection.name }\r\n * );\r\n * ```\r\n */\r\n explain(\r\n query: string | aql.AqlLiteral,\r\n bindVars?: Record<string, any>,\r\n options?: queries.ExplainOptions & { allPlans?: false }\r\n ): Promise<connection.ArangoApiResponse<queries.SingleExplainResult>>;\r\n /**\r\n * Explains a database query using the given `query` and `bindVars`.\r\n *\r\n * See the {@link aql.aql} template string handler for a safer and easier\r\n * alternative to passing strings directly.\r\n *\r\n * @param query - An AQL query string.\r\n * @param bindVars - An object defining bind parameters for the query.\r\n * @param options - Options for explaining the query.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collection = db.collection(\"some-collection\");\r\n * const explanation = await db.explain(\r\n * `\r\n * FOR doc IN @@collection\r\n * FILTER doc.flavor == \"strawberry\"\r\n * RETURN doc._key\r\n * `,\r\n * { \"@collection\": collection.name },\r\n * { allPlans: true }\r\n * );\r\n * ```\r\n */\r\n explain(\r\n query: string | aql.AqlLiteral,\r\n bindVars?: Record<string, any>,\r\n options?: queries.ExplainOptions & { allPlans: true }\r\n ): Promise<connection.ArangoApiResponse<queries.MultiExplainResult>>;\r\n explain(\r\n query: string | aql.AqlQuery | aql.AqlLiteral,\r\n bindVars?: Record<string, any>,\r\n options?: queries.ExplainOptions\r\n ): Promise<\r\n connection.ArangoApiResponse<\r\n queries.SingleExplainResult | queries.MultiExplainResult\r\n >\r\n > {\r\n if (aql.isAqlQuery(query)) {\r\n options = bindVars;\r\n bindVars = query.bindVars;\r\n query = query.query;\r\n } else if (aql.isAqlLiteral(query)) {\r\n query = query.toAQL();\r\n }\r\n return this.request({\r\n method: \"POST\",\r\n pathname: \"/_api/explain\",\r\n body: { query, bindVars, options },\r\n });\r\n }\r\n\r\n /**\r\n * Parses the given query and returns the result.\r\n *\r\n * See the {@link aql.aql} template string handler for information about how\r\n * to create a query string without manually defining bind parameters nor\r\n * having to worry about escaping variables.\r\n *\r\n * @param query - An AQL query string or an object containing an AQL query\r\n * string and bind parameters, e.g. the object returned from an {@link aql.aql}\r\n * template string.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const collection = db.collection(\"some-collection\");\r\n * const ast = await db.parse(aql`\r\n * FOR doc IN ${collection}\r\n * FILTER doc.flavor == \"strawberry\"\r\n * RETURN doc._key\r\n * `);\r\n * ```\r\n aql.*/\r\n parse(\r\n query: string | aql.AqlQuery | aql.AqlLiteral\r\n ): Promise<queries.ParseResult> {\r\n if (aql.isAqlQuery(query)) {\r\n query = query.query;\r\n } else if (aql.isAqlLiteral(query)) {\r\n query = query.toAQL();\r\n }\r\n return this.request({\r\n method: \"POST\",\r\n pathname: \"/_api/query\",\r\n body: { query },\r\n });\r\n }\r\n\r\n /**\r\n * Fetches the available optimizer rules.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const rules = await db.queryRules();\r\n * for (const rule of rules) {\r\n * console.log(rule.name);\r\n * }\r\n * ```\r\n */\r\n queryRules(): Promise<queries.QueryOptimizerRule[]> {\r\n return this.request({\r\n pathname: \"/_api/query/rules\",\r\n });\r\n }\r\n\r\n /**\r\n * Fetches the query tracking properties.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const tracking = await db.queryTracking();\r\n * console.log(tracking.enabled);\r\n * ```\r\n */\r\n queryTracking(): Promise<queries.QueryTrackingInfo>;\r\n /**\r\n * Modifies the query tracking properties.\r\n *\r\n * @param options - Options for query tracking.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // track up to 5 slow queries exceeding 5 seconds execution time\r\n * await db.queryTracking({\r\n * enabled: true,\r\n * trackSlowQueries: true,\r\n * maxSlowQueries: 5,\r\n * slowQueryThreshold: 5\r\n * });\r\n * ```\r\n */\r\n queryTracking(\r\n options: queries.QueryTrackingOptions\r\n ): Promise<queries.QueryTrackingInfo>;\r\n queryTracking(\r\n options?: queries.QueryTrackingOptions\r\n ): Promise<queries.QueryTrackingInfo> {\r\n return this.request(\r\n options\r\n ? {\r\n method: \"PUT\",\r\n pathname: \"/_api/query/properties\",\r\n body: options,\r\n }\r\n : {\r\n method: \"GET\",\r\n pathname: \"/_api/query/properties\",\r\n }\r\n );\r\n }\r\n\r\n /**\r\n * Fetches a list of information for all currently running queries.\r\n *\r\n * See also {@link Database#listSlowQueries} and {@link Database#killQuery}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const queries = await db.listRunningQueries();\r\n * ```\r\n */\r\n listRunningQueries(): Promise<queries.QueryDescription[]> {\r\n return this.request({\r\n method: \"GET\",\r\n pathname: \"/_api/query/current\",\r\n });\r\n }\r\n\r\n /**\r\n * Fetches a list of information for all recent slow queries.\r\n *\r\n * See also {@link Database#listRunningQueries} and\r\n * {@link Database#clearSlowQueries}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const queries = await db.listSlowQueries();\r\n * // Only works if slow query tracking is enabled\r\n * ```\r\n */\r\n listSlowQueries(): Promise<queries.QueryDescription[]> {\r\n return this.request({\r\n method: \"GET\",\r\n pathname: \"/_api/query/slow\",\r\n });\r\n }\r\n\r\n /**\r\n * Clears the list of recent slow queries.\r\n *\r\n * See also {@link Database#listSlowQueries}.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.clearSlowQueries();\r\n * // Slow query list is now cleared\r\n * ```\r\n */\r\n clearSlowQueries(): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: \"/_api/query/slow\",\r\n },\r\n () => undefined\r\n );\r\n }\r\n\r\n /**\r\n * Kills a running query with the given `queryId`.\r\n *\r\n * See also {@link Database#listRunningQueries}.\r\n *\r\n * @param queryId - The ID of a currently running query.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const queries = await db.listRunningQueries();\r\n * await Promise.all(queries.map(\r\n * async (query) => {\r\n * if (query.state === \"executing\") {\r\n * await db.killQuery(query.id);\r\n * }\r\n * }\r\n * ));\r\n * ```\r\n */\r\n killQuery(queryId: string): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: `/_api/query/${encodeURIComponent(queryId)}`,\r\n },\r\n () => undefined\r\n );\r\n }\r\n\r\n /**\r\n * Fetches a list of all entries in the AQL query results cache of the\r\n * current database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const entries = await db.listQueryCacheEntries();\r\n * console.log(entries);\r\n * ```\r\n */\r\n listQueryCacheEntries(): Promise<queries.QueryCacheEntry[]> {\r\n return this.request({\r\n pathname: \"/_api/query-cache/entries\",\r\n });\r\n }\r\n\r\n /**\r\n * Clears the AQL query results cache of the current database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.clearQueryCache();\r\n * // Cache is now cleared\r\n * ```\r\n */\r\n clearQueryCache(): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: \"/_api/query-cache\",\r\n },\r\n () => undefined\r\n );\r\n }\r\n\r\n /**\r\n * Fetches the global properties for the AQL query results cache.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const properties = await db.getQueryCacheProperties();\r\n * console.log(properties);\r\n * ```\r\n */\r\n getQueryCacheProperties(): Promise<queries.QueryCacheProperties> {\r\n return this.request({\r\n pathname: \"/_api/query-cache/properties\",\r\n });\r\n }\r\n\r\n /**\r\n * Updates the global properties for the AQL query results cache.\r\n *\r\n * @param properties - The new properties for the AQL query results cache.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.setQueryCacheProperties({ maxResults: 9000 });\r\n * ```\r\n */\r\n setQueryCacheProperties(\r\n properties: queries.QueryCachePropertiesOptions\r\n ): Promise<queries.QueryCacheProperties> {\r\n return this.request({\r\n method: \"PUT\",\r\n pathname: \"/_api/query-cache/properties\",\r\n body: properties,\r\n });\r\n }\r\n //#endregion\r\n\r\n //#region user functions\r\n /**\r\n * Fetches a list of all AQL user functions registered with the database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const functions = await db.listUserFunctions();\r\n * const names = functions.map(fn => fn.name);\r\n * ```\r\n */\r\n listUserFunctions(): Promise<queries.UserFunctionDescription[]> {\r\n return this.request(\r\n { pathname: \"/_api/aqlfunction\" },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * Creates an AQL user function with the given _name_ and _code_ if it does\r\n * not already exist or replaces it if a function with the same name already\r\n * existed.\r\n *\r\n * @param name - A valid AQL function name. The function name must consist\r\n * of at least two alphanumeric identifiers separated with double colons.\r\n * @param code - A string evaluating to a JavaScript function (not a\r\n * JavaScript function object).\r\n * @param isDeterministic - If set to `true`, the function is expected to\r\n * always return the same result for equivalent inputs. This option currently\r\n * has no effect but may allow for optimizations in the future.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.createUserFunction(\r\n * \"ACME::ACCOUNTING::CALCULATE_VAT\",\r\n * \"(price) => price * 0.19\"\r\n * );\r\n * // Use the new function in an AQL query with template handler:\r\n * const cursor = await db.query(aql`\r\n * FOR product IN products\r\n * RETURN MERGE(\r\n * { vat: ACME::ACCOUNTING::CALCULATE_VAT(product.price) },\r\n * product\r\n * )\r\n * `);\r\n * // cursor is a cursor for the query result\r\n * ```\r\n */\r\n createUserFunction(\r\n name: string,\r\n code: string,\r\n isDeterministic: boolean = false\r\n ): Promise<connection.ArangoApiResponse<{ isNewlyCreated: boolean }>> {\r\n return this.request({\r\n method: \"POST\",\r\n pathname: \"/_api/aqlfunction\",\r\n body: { name, code, isDeterministic },\r\n });\r\n }\r\n\r\n /**\r\n * Deletes the AQL user function with the given name from the database.\r\n *\r\n * @param name - The name of the user function to drop.\r\n * @param group - If set to `true`, all functions with a name starting with\r\n * `name` will be deleted, otherwise only the function with the exact name\r\n * will be deleted.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.dropUserFunction(\"ACME::ACCOUNTING::CALCULATE_VAT\");\r\n * // the function no longer exists\r\n * ```\r\n */\r\n dropUserFunction(\r\n name: string,\r\n group: boolean = false\r\n ): Promise<connection.ArangoApiResponse<{ deletedCount: number }>> {\r\n return this.request({\r\n method: \"DELETE\",\r\n pathname: `/_api/aqlfunction/${encodeURIComponent(name)}`,\r\n search: { group },\r\n });\r\n }\r\n //#endregion\r\n\r\n //#region services\r\n /**\r\n * Fetches a list of all installed service.\r\n *\r\n * @param excludeSystem - Whether system services should be excluded.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const services = await db.listServices();\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const services = await db.listServices(false); // all services\r\n * ```\r\n */\r\n listServices(\r\n excludeSystem: boolean = true\r\n ): Promise<services.ServiceSummary[]> {\r\n return this.request({\r\n pathname: \"/_api/foxx\",\r\n search: { excludeSystem },\r\n });\r\n }\r\n\r\n /**\r\n * Installs a new service.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param source - The service bundle to install.\r\n * @param options - Options for installing the service.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Using a Buffer in Node.js as source\r\n * const source = new Blob([await fs.readFileSync(\"./my-foxx-service.zip\")]);\r\n * const info = await db.installService(\"/hello\", source);\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Using a Blob in Node.js as source\r\n * const source = await fs.openAsBlob(\"./my-foxx-service.zip\");\r\n * const info = await db.installService(\"/hello\", source);\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Using a File from a browser file input as source\r\n * const element = document.getElementById(\"my-file-input\");\r\n * const source = element.files[0];\r\n * const info = await db.installService(\"/hello\", source);\r\n * ```\r\n */\r\n async installService(\r\n mount: string,\r\n source: Blob | string,\r\n options: services.InstallServiceOptions = {}\r\n ): Promise<services.ServiceDescription> {\r\n const { configuration, dependencies, ...search } = options;\r\n const form = new FormData();\r\n if (configuration) {\r\n form.append(\"configuration\", JSON.stringify(configuration));\r\n }\r\n if (dependencies) {\r\n form.append(\"dependencies\", JSON.stringify(dependencies));\r\n }\r\n form.append(\r\n \"source\",\r\n typeof source === \"string\" ? JSON.stringify(source) : source\r\n );\r\n return await this.request({\r\n body: form,\r\n method: \"POST\",\r\n pathname: \"/_api/foxx\",\r\n search: { ...search, mount },\r\n });\r\n }\r\n\r\n /**\r\n * Replaces an existing service with a new service by completely removing the\r\n * old service and installing a new service at the same mount point.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param source - The service bundle to install.\r\n * @param options - Options for replacing the service.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Using a Buffer in Node.js as source\r\n * const source = new Blob([await fs.readFileSync(\"./my-foxx-service.zip\")]);\r\n * const info = await db.replaceService(\"/hello\", source);\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Using a Blob in Node.js as source\r\n * const source = await fs.openAsBlob(\"./my-foxx-service.zip\");\r\n * const info = await db.replaceService(\"/hello\", source);\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Using a File from a browser file input as source\r\n * const element = document.getElementById(\"my-file-input\");\r\n * const source = element.files[0];\r\n * const info = await db.replaceService(\"/hello\", source);\r\n * ```\r\n */\r\n async replaceService(\r\n mount: string,\r\n source: Blob | string,\r\n options: services.ReplaceServiceOptions = {}\r\n ): Promise<services.ServiceDescription> {\r\n const { configuration, dependencies, ...search } = options;\r\n const form = new FormData();\r\n if (configuration) {\r\n form.append(\"configuration\", JSON.stringify(configuration));\r\n }\r\n if (dependencies) {\r\n form.append(\"dependencies\", JSON.stringify(dependencies));\r\n }\r\n form.append(\r\n \"source\",\r\n typeof source === \"string\" ? JSON.stringify(source) : source\r\n );\r\n return await this.request({\r\n body: form,\r\n method: \"PUT\",\r\n pathname: \"/_api/foxx/service\",\r\n search: { ...search, mount },\r\n });\r\n }\r\n\r\n /**\r\n * Replaces an existing service with a new service while retaining the old\r\n * service's configuration and dependencies.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param source - The service bundle to install.\r\n * @param options - Options for upgrading the service.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Using a Buffer in Node.js as source\r\n * const source = new Blob([await fs.readFileSync(\"./my-foxx-service.zip\")]);\r\n * const info = await db.upgradeService(\"/hello\", source);\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Using a Blob in Node.js as source\r\n * const source = await fs.openAsBlob(\"./my-foxx-service.zip\");\r\n * const info = await db.upgradeService(\"/hello\", source);\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * // Using a File from a browser file input as source\r\n * const element = document.getElementById(\"my-file-input\");\r\n * const source = element.files[0];\r\n * const info = await db.upgradeService(\"/hello\", source);\r\n * ```\r\n */\r\n async upgradeService(\r\n mount: string,\r\n source: Blob | string,\r\n options: services.UpgradeServiceOptions = {}\r\n ): Promise<services.ServiceDescription> {\r\n const { configuration, dependencies, ...search } = options;\r\n const form = new FormData();\r\n if (configuration) {\r\n form.append(\"configuration\", JSON.stringify(configuration));\r\n }\r\n if (dependencies) {\r\n form.append(\"dependencies\", JSON.stringify(dependencies));\r\n }\r\n form.append(\r\n \"source\",\r\n typeof source === \"string\" ? JSON.stringify(source) : source\r\n );\r\n return await this.request({\r\n body: form,\r\n method: \"PATCH\",\r\n pathname: \"/_api/foxx/service\",\r\n search: { ...search, mount },\r\n });\r\n }\r\n\r\n /**\r\n * Completely removes a service from the database.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param options - Options for uninstalling the service.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.uninstallService(\"/my-foxx\");\r\n * ```\r\n */\r\n uninstallService(\r\n mount: string,\r\n options?: services.UninstallServiceOptions\r\n ): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: \"/_api/foxx/service\",\r\n search: { ...options, mount },\r\n },\r\n () => undefined\r\n );\r\n }\r\n\r\n /**\r\n * Retrieves information about a mounted service.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const info = await db.getService(\"/my-service\");\r\n * // info contains detailed information about the service\r\n * ```\r\n */\r\n getService(mount: string): Promise<services.ServiceDescription> {\r\n return this.request({\r\n pathname: \"/_api/foxx/service\",\r\n search: { mount },\r\n });\r\n }\r\n\r\n /**\r\n * Retrieves information about the service's configuration options and their\r\n * current values.\r\n *\r\n * See also {@link Database#replaceServiceConfiguration} and\r\n * {@link Database#updateServiceConfiguration}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * configuration option's current value. Otherwise it will include the full\r\n * definition for each option.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const config = await db.getServiceConfiguration(\"/my-service\");\r\n * for (const [key, option] of Object.entries(config)) {\r\n * console.log(`${option.title} (${key}): ${option.current}`);\r\n * }\r\n * ```\r\n */\r\n getServiceConfiguration(\r\n mount: string,\r\n minimal?: false\r\n ): Promise<Record<string, services.ServiceConfiguration>>;\r\n /**\r\n * Retrieves information about the service's configuration options and their\r\n * current values.\r\n *\r\n * See also {@link Database#replaceServiceConfiguration} and\r\n * {@link Database#updateServiceConfiguration}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * configuration option's current value. Otherwise it will include the full\r\n * definition for each option.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const config = await db.getServiceConfiguration(\"/my-service\", true);\r\n * for (const [key, value] of Object.entries(config)) {\r\n * console.log(`${key}: ${value}`);\r\n * }\r\n * ```\r\n */\r\n getServiceConfiguration(\r\n mount: string,\r\n minimal: true\r\n ): Promise<Record<string, any>>;\r\n getServiceConfiguration(mount: string, minimal: boolean = false) {\r\n return this.request({\r\n pathname: \"/_api/foxx/configuration\",\r\n search: { mount, minimal },\r\n });\r\n }\r\n\r\n /**\r\n * Replaces the configuration of the given service, discarding any existing\r\n * values for options not specified.\r\n *\r\n * See also {@link Database#updateServiceConfiguration} and\r\n * {@link Database#getServiceConfiguration}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param cfg - An object mapping configuration option names to values.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * configuration option's current value and warning (if any).\r\n * Otherwise it will include the full definition for each option.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const config = { currency: \"USD\", locale: \"en-US\" };\r\n * const info = await db.replaceServiceConfiguration(\"/my-service\", config);\r\n * for (const [key, option] of Object.entries(info)) {\r\n * console.log(`${option.title} (${key}): ${option.value}`);\r\n * if (option.warning) console.warn(`Warning: ${option.warning}`);\r\n * }\r\n * ```\r\n */\r\n replaceServiceConfiguration(\r\n mount: string,\r\n cfg: Record<string, any>,\r\n minimal?: false\r\n ): Promise<\r\n Record<string, services.ServiceConfiguration & { warning?: string }>\r\n >;\r\n /**\r\n * Replaces the configuration of the given service, discarding any existing\r\n * values for options not specified.\r\n *\r\n * See also {@link Database#updateServiceConfiguration} and\r\n * {@link Database#getServiceConfiguration}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param cfg - An object mapping configuration option names to values.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * configuration option's current value and warning (if any).\r\n * Otherwise it will include the full definition for each option.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const config = { currency: \"USD\", locale: \"en-US\" };\r\n * const info = await db.replaceServiceConfiguration(\"/my-service\", config);\r\n * for (const [key, value] of Object.entries(info.values)) {\r\n * console.log(`${key}: ${value}`);\r\n * if (info.warnings[key]) console.warn(`Warning: ${info.warnings[key]}`);\r\n * }\r\n * ```\r\n */\r\n replaceServiceConfiguration(\r\n mount: string,\r\n cfg: Record<string, any>,\r\n minimal: true\r\n ): Promise<{\r\n values: Record<string, any>;\r\n warnings: Record<string, string>;\r\n }>;\r\n replaceServiceConfiguration(\r\n mount: string,\r\n cfg: Record<string, any>,\r\n minimal: boolean = false\r\n ) {\r\n return this.request({\r\n method: \"PUT\",\r\n pathname: \"/_api/foxx/configuration\",\r\n body: cfg,\r\n search: { mount, minimal },\r\n });\r\n }\r\n\r\n /**\r\n * Updates the configuration of the given service while maintaining any\r\n * existing values for options not specified.\r\n *\r\n * See also {@link Database#replaceServiceConfiguration} and\r\n * {@link Database#getServiceConfiguration}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param cfg - An object mapping configuration option names to values.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * configuration option's current value and warning (if any).\r\n * Otherwise it will include the full definition for each option.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const config = { currency: \"USD\", locale: \"en-US\" };\r\n * const info = await db.updateServiceConfiguration(\"/my-service\", config);\r\n * for (const [key, option] of Object.entries(info)) {\r\n * console.log(`${option.title} (${key}): ${option.value}`);\r\n * if (option.warning) console.warn(`Warning: ${option.warning}`);\r\n * }\r\n * ```\r\n */\r\n updateServiceConfiguration(\r\n mount: string,\r\n cfg: Record<string, any>,\r\n minimal?: false\r\n ): Promise<\r\n Record<string, services.ServiceConfiguration & { warning?: string }>\r\n >;\r\n /**\r\n * Updates the configuration of the given service while maintaining any\r\n * existing values for options not specified.\r\n *\r\n * See also {@link Database#replaceServiceConfiguration} and\r\n * {@link Database#getServiceConfiguration}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param cfg - An object mapping configuration option names to values.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * configuration option's current value and warning (if any).\r\n * Otherwise it will include the full definition for each option.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const config = { currency: \"USD\", locale: \"en-US\" };\r\n * const info = await db.updateServiceConfiguration(\"/my-service\", config);\r\n * for (const [key, value] of Object.entries(info.values)) {\r\n * console.log(`${key}: ${value}`);\r\n * if (info.warnings[key]) console.warn(`Warning: ${info.warnings[key]}`);\r\n * }\r\n * ```\r\n */\r\n updateServiceConfiguration(\r\n mount: string,\r\n cfg: Record<string, any>,\r\n minimal: true\r\n ): Promise<{\r\n values: Record<string, any>;\r\n warnings: Record<string, string>;\r\n }>;\r\n updateServiceConfiguration(\r\n mount: string,\r\n cfg: Record<string, any>,\r\n minimal: boolean = false\r\n ) {\r\n return this.request({\r\n method: \"PATCH\",\r\n pathname: \"/_api/foxx/configuration\",\r\n body: cfg,\r\n search: { mount, minimal },\r\n });\r\n }\r\n\r\n /**\r\n * Retrieves information about the service's dependencies and their current\r\n * mount points.\r\n *\r\n * See also {@link Database#replaceServiceDependencies} and\r\n * {@link Database#updateServiceDependencies}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * dependency's current mount point. Otherwise it will include the full\r\n * definition for each dependency.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const deps = await db.getServiceDependencies(\"/my-service\");\r\n * for (const [key, dep] of Object.entries(deps)) {\r\n * console.log(`${dep.title} (${key}): ${dep.current}`);\r\n * }\r\n * ```\r\n */\r\n getServiceDependencies(\r\n mount: string,\r\n minimal?: false\r\n ): Promise<\r\n Record<\r\n string,\r\n services.SingleServiceDependency | services.MultiServiceDependency\r\n >\r\n >;\r\n /**\r\n * Retrieves information about the service's dependencies and their current\r\n * mount points.\r\n *\r\n * See also {@link Database#replaceServiceDependencies} and\r\n * {@link Database#updateServiceDependencies}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * dependency's current mount point. Otherwise it will include the full\r\n * definition for each dependency.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const deps = await db.getServiceDependencies(\"/my-service\", true);\r\n * for (const [key, value] of Object.entries(deps)) {\r\n * console.log(`${key}: ${value}`);\r\n * }\r\n * ```\r\n */\r\n getServiceDependencies(\r\n mount: string,\r\n minimal: true\r\n ): Promise<Record<string, string | string[]>>;\r\n getServiceDependencies(mount: string, minimal: boolean = false) {\r\n return this.request({\r\n pathname: \"/_api/foxx/dependencies\",\r\n search: { mount, minimal },\r\n });\r\n }\r\n\r\n /**\r\n * Replaces the dependencies of the given service, discarding any existing\r\n * mount points for dependencies not specified.\r\n *\r\n * See also {@link Database#updateServiceDependencies} and\r\n * {@link Database#getServiceDependencies}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param deps - An object mapping dependency aliases to mount points.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * dependency's current mount point. Otherwise it will include the full\r\n * definition for each dependency.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const deps = { mailer: \"/mailer-api\", auth: \"/remote-auth\" };\r\n * const info = await db.replaceServiceDependencies(\"/my-service\", deps);\r\n * for (const [key, dep] of Object.entries(info)) {\r\n * console.log(`${dep.title} (${key}): ${dep.current}`);\r\n * if (dep.warning) console.warn(`Warning: ${dep.warning}`);\r\n * }\r\n * ```\r\n */\r\n replaceServiceDependencies(\r\n mount: string,\r\n deps: Record<string, string>,\r\n minimal?: false\r\n ): Promise<\r\n Record<\r\n string,\r\n (services.SingleServiceDependency | services.MultiServiceDependency) & {\r\n warning?: string;\r\n }\r\n >\r\n >;\r\n /**\r\n * Replaces the dependencies of the given service, discarding any existing\r\n * mount points for dependencies not specified.\r\n *\r\n * See also {@link Database#updateServiceDependencies} and\r\n * {@link Database#getServiceDependencies}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param deps - An object mapping dependency aliases to mount points.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * dependency's current mount point. Otherwise it will include the full\r\n * definition for each dependency.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const deps = { mailer: \"/mailer-api\", auth: \"/remote-auth\" };\r\n * const info = await db.replaceServiceDependencies(\r\n * \"/my-service\",\r\n * deps,\r\n * true\r\n * );\r\n * for (const [key, value] of Object.entries(info)) {\r\n * console.log(`${key}: ${value}`);\r\n * if (info.warnings[key]) console.warn(`Warning: ${info.warnings[key]}`);\r\n * }\r\n * ```\r\n */\r\n replaceServiceDependencies(\r\n mount: string,\r\n deps: Record<string, string>,\r\n minimal: true\r\n ): Promise<{\r\n values: Record<string, string>;\r\n warnings: Record<string, string>;\r\n }>;\r\n replaceServiceDependencies(\r\n mount: string,\r\n deps: Record<string, string>,\r\n minimal: boolean = false\r\n ) {\r\n return this.request({\r\n method: \"PUT\",\r\n pathname: \"/_api/foxx/dependencies\",\r\n body: deps,\r\n search: { mount, minimal },\r\n });\r\n }\r\n\r\n /**\r\n * Updates the dependencies of the given service while maintaining any\r\n * existing mount points for dependencies not specified.\r\n *\r\n * See also {@link Database#replaceServiceDependencies} and\r\n * {@link Database#getServiceDependencies}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param deps - An object mapping dependency aliases to mount points.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * dependency's current mount point. Otherwise it will include the full\r\n * definition for each dependency.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const deps = { mailer: \"/mailer-api\", auth: \"/remote-auth\" };\r\n * const info = await db.updateServiceDependencies(\"/my-service\", deps);\r\n * for (const [key, dep] of Object.entries(info)) {\r\n * console.log(`${dep.title} (${key}): ${dep.current}`);\r\n * if (dep.warning) console.warn(`Warning: ${dep.warning}`);\r\n * }\r\n * ```\r\n */\r\n updateServiceDependencies(\r\n mount: string,\r\n deps: Record<string, string>,\r\n minimal?: false\r\n ): Promise<\r\n Record<\r\n string,\r\n (services.SingleServiceDependency | services.MultiServiceDependency) & {\r\n warning?: string;\r\n }\r\n >\r\n >;\r\n /**\r\n * Updates the dependencies of the given service while maintaining any\r\n * existing mount points for dependencies not specified.\r\n *\r\n * See also {@link Database#replaceServiceDependencies} and\r\n * {@link Database#getServiceDependencies}.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param deps - An object mapping dependency aliases to mount points.\r\n * @param minimal - If set to `true`, the result will only include each\r\n * dependency's current mount point. Otherwise it will include the full\r\n * definition for each dependency.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const deps = { mailer: \"/mailer-api\", auth: \"/remote-auth\" };\r\n * const info = await db.updateServiceDependencies(\r\n * \"/my-service\",\r\n * deps,\r\n * true\r\n * );\r\n * for (const [key, value] of Object.entries(info)) {\r\n * console.log(`${key}: ${value}`);\r\n * if (info.warnings[key]) console.warn(`Warning: ${info.warnings[key]}`);\r\n * }\r\n * ```\r\n */\r\n updateServiceDependencies(\r\n mount: string,\r\n deps: Record<string, string>,\r\n minimal: true\r\n ): Promise<{\r\n values: Record<string, string>;\r\n warnings: Record<string, string>;\r\n }>;\r\n updateServiceDependencies(\r\n mount: string,\r\n deps: Record<string, string>,\r\n minimal: boolean = false\r\n ) {\r\n return this.request({\r\n method: \"PATCH\",\r\n pathname: \"/_api/foxx/dependencies\",\r\n body: deps,\r\n search: { mount, minimal },\r\n });\r\n }\r\n\r\n /**\r\n * Enables or disables development mode for the given service.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param enabled - Whether development mode should be enabled or disabled.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * await db.setServiceDevelopmentMode(\"/my-service\", true);\r\n * // the service is now in development mode\r\n * await db.setServiceDevelopmentMode(\"/my-service\", false);\r\n * // the service is now in production mode\r\n * ```\r\n */\r\n setServiceDevelopmentMode(\r\n mount: string,\r\n enabled: boolean = true\r\n ): Promise<services.ServiceDescription> {\r\n return this.request({\r\n method: enabled ? \"POST\" : \"DELETE\",\r\n pathname: \"/_api/foxx/development\",\r\n search: { mount },\r\n });\r\n }\r\n\r\n /**\r\n * Retrieves an object mapping script names to their human readable\r\n * representations, as defined in the service manifest's \"scripts\" section.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const scripts = await db.getServiceScripts(\"/my-service\");\r\n * for (const [name, title] of Object.entries(scripts)) {\r\n * console.log(`${name}: ${title}`);\r\n * }\r\n * ```\r\n */\r\n getServiceScripts(mount: string): Promise<Record<string, string>> {\r\n return this.request({\r\n pathname: \"/_api/foxx/scripts\",\r\n search: { mount },\r\n });\r\n }\r\n\r\n /**\r\n * Executes a service script and retrieves its result exposed as\r\n * `module.exports` (if any).\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param name - Name of the service script to execute as defined in the\r\n * service manifest.\r\n * @param params - Arbitrary value that will be exposed to the script as\r\n * `argv[0]` in the service context (e.g. `module.context.argv[0]`).\r\n * Must be serializable to JSON.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const result = await db.runServiceScript(\r\n * \"/my-service\",\r\n * \"create-user\",\r\n * {\r\n * username: \"service_admin\",\r\n * password: \"hunter2\"\r\n * }\r\n * );\r\n * ```\r\n */\r\n runServiceScript(mount: string, name: string, params?: any): Promise<any> {\r\n return this.request({\r\n method: \"POST\",\r\n pathname: `/_api/foxx/scripts/${encodeURIComponent(name)}`,\r\n body: params,\r\n search: { mount },\r\n });\r\n }\r\n\r\n /**\r\n * Runs the tests of a given service and returns the results using the\r\n * \"default\" reporter.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param options - Options for running the tests.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const testReport = await db.runServiceTests(\"/my-foxx\");\r\n * ```\r\n */\r\n runServiceTests(\r\n mount: string,\r\n options?: {\r\n reporter?: \"default\";\r\n /**\r\n * Whether the reporter should use \"idiomatic\" mode. Has no effect when\r\n * using the \"default\" or \"suite\" reporters.\r\n */\r\n idiomatic?: false;\r\n /**\r\n * If set, only tests with full names including this exact string will be\r\n * executed.\r\n */\r\n filter?: string;\r\n }\r\n ): Promise<services.ServiceTestDefaultReport>;\r\n /**\r\n * Runs the tests of a given service and returns the results using the\r\n * \"suite\" reporter, which groups the test result by test suite.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param options - Options for running the tests.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const suiteReport = await db.runServiceTests(\r\n * \"/my-foxx\",\r\n * { reporter: \"suite\" }\r\n * );\r\n * ```\r\n */\r\n runServiceTests(\r\n mount: string,\r\n options: {\r\n reporter: \"suite\";\r\n /**\r\n * Whether the reporter should use \"idiomatic\" mode. Has no effect when\r\n * using the \"default\" or \"suite\" reporters.\r\n */\r\n idiomatic?: false;\r\n /**\r\n * If set, only tests with full names including this exact string will be\r\n * executed.\r\n */\r\n filter?: string;\r\n }\r\n ): Promise<services.ServiceTestSuiteReport>;\r\n /**\r\n * Runs the tests of a given service and returns the results using the\r\n * \"stream\" reporter, which represents the results as a sequence of tuples\r\n * representing events.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param options - Options for running the tests.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const streamEvents = await db.runServiceTests(\r\n * \"/my-foxx\",\r\n * { reporter: \"stream\" }\r\n * );\r\n * ```\r\n */\r\n runServiceTests(\r\n mount: string,\r\n options: {\r\n reporter: \"stream\";\r\n /**\r\n * Whether the reporter should use \"idiomatic\" mode. If set to `true`,\r\n * the results will be returned as a formatted string.\r\n */\r\n idiomatic?: false;\r\n /**\r\n * If set, only tests with full names including this exact string will be\r\n * executed.\r\n */\r\n filter?: string;\r\n }\r\n ): Promise<services.ServiceTestStreamReport>;\r\n /**\r\n * Runs the tests of a given service and returns the results using the\r\n * \"tap\" reporter, which represents the results as an array of strings using\r\n * the \"tap\" format.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param options - Options for running the tests.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const tapLines = await db.runServiceTests(\r\n * \"/my-foxx\",\r\n * { reporter: \"tap\" }\r\n * );\r\n * ```\r\n */\r\n runServiceTests(\r\n mount: string,\r\n options: {\r\n reporter: \"tap\";\r\n /**\r\n * Whether the reporter should use \"idiomatic\" mode. If set to `true`,\r\n * the results will be returned as a formatted string.\r\n */\r\n idiomatic?: false;\r\n /**\r\n * If set, only tests with full names including this exact string will be\r\n * executed.\r\n */\r\n filter?: string;\r\n }\r\n ): Promise<services.ServiceTestTapReport>;\r\n /**\r\n * Runs the tests of a given service and returns the results using the\r\n * \"xunit\" reporter, which represents the results as an XML document using\r\n * the JSONML exchange format.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param options - Options for running the tests.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const jsonML = await db.runServiceTests(\r\n * \"/my-foxx\",\r\n * { reporter: \"xunit\" }\r\n * );\r\n * ```\r\n */\r\n runServiceTests(\r\n mount: string,\r\n options: {\r\n reporter: \"xunit\";\r\n /**\r\n * Whether the reporter should use \"idiomatic\" mode. If set to `true`,\r\n * the results will be returned as a formatted string.\r\n */\r\n idiomatic?: false;\r\n /**\r\n * If set, only tests with full names including this exact string will be\r\n * executed.\r\n */\r\n filter?: string;\r\n }\r\n ): Promise<services.ServiceTestXunitReport>;\r\n /**\r\n * Runs the tests of a given service and returns the results as a string\r\n * using the \"stream\" reporter in \"idiomatic\" mode, which represents the\r\n * results as a line-delimited JSON stream of tuples representing events.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param options - Options for running the tests.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const streamReport = await db.runServiceTests(\r\n * \"/my-foxx\",\r\n * { reporter: \"stream\", idiomatic: true }\r\n * );\r\n * ```\r\n */\r\n runServiceTests(\r\n mount: string,\r\n options: {\r\n reporter: \"stream\";\r\n /**\r\n * Whether the reporter should use \"idiomatic\" mode. If set to `false`,\r\n * the results will be returned as an array of tuples instead of a\r\n * string.\r\n */\r\n idiomatic: true;\r\n /**\r\n * If set, only tests with full names including this exact string will be\r\n * executed.\r\n */\r\n filter?: string;\r\n }\r\n ): Promise<string>;\r\n /**\r\n * Runs the tests of a given service and returns the results as a string\r\n * using the \"tap\" reporter in \"idiomatic\" mode, which represents the\r\n * results using the \"tap\" format.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param options - Options for running the tests.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const tapReport = await db.runServiceTests(\r\n * \"/my-foxx\",\r\n * { reporter: \"tap\", idiomatic: true }\r\n * );\r\n * ```\r\n */\r\n runServiceTests(\r\n mount: string,\r\n options: {\r\n reporter: \"tap\";\r\n /**\r\n * Whether the reporter should use \"idiomatic\" mode. If set to `false`,\r\n * the results will be returned as an array of strings instead of a\r\n * single string.\r\n */\r\n idiomatic: true;\r\n /**\r\n * If set, only tests with full names including this exact string will be\r\n * executed.\r\n */\r\n filter?: string;\r\n }\r\n ): Promise<string>;\r\n /**\r\n * Runs the tests of a given service and returns the results as a string\r\n * using the \"xunit\" reporter in \"idiomatic\" mode, which represents the\r\n * results as an XML document.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n * @param options - Options for running the tests.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const xml = await db.runServiceTests(\r\n * \"/my-foxx\",\r\n * { reporter: \"xunit\", idiomatic: true }\r\n * );\r\n * ```\r\n */\r\n runServiceTests(\r\n mount: string,\r\n options: {\r\n reporter: \"xunit\";\r\n /**\r\n * Whether the reporter should use \"idiomatic\" mode. If set to `false`,\r\n * the results will be returned using the JSONML exchange format\r\n * instead of a string.\r\n */\r\n idiomatic: true;\r\n /**\r\n * If set, only tests with full names including this exact string will be\r\n * executed.\r\n */\r\n filter?: string;\r\n }\r\n ): Promise<string>;\r\n runServiceTests(\r\n mount: string,\r\n options?: {\r\n reporter?: string;\r\n idiomatic?: boolean;\r\n filter?: string;\r\n }\r\n ) {\r\n return this.request({\r\n method: \"POST\",\r\n pathname: \"/_api/foxx/tests\",\r\n search: {\r\n ...options,\r\n mount,\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Retrieves the text content of the service's `README` or `README.md` file.\r\n *\r\n * Returns `undefined` if no such file could be found.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const readme = await db.getServiceReadme(\"/my-service\");\r\n * if (readme !== undefined) console.log(readme);\r\n * else console.warn(`No README found.`)\r\n * ```\r\n */\r\n getServiceReadme(mount: string): Promise<string | undefined> {\r\n return this.request({\r\n pathname: \"/_api/foxx/readme\",\r\n search: { mount },\r\n });\r\n }\r\n\r\n /**\r\n * Retrieves an Open API compatible Swagger API description object for the\r\n * service installed at the given mount point.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const spec = await db.getServiceDocumentation(\"/my-service\");\r\n * // spec is a Swagger API description of the service\r\n * ```\r\n */\r\n getServiceDocumentation(mount: string): Promise<services.SwaggerJson> {\r\n return this.request({\r\n pathname: \"/_api/foxx/swagger\",\r\n search: { mount },\r\n });\r\n }\r\n\r\n /**\r\n * Retrieves a zip bundle containing the service files.\r\n *\r\n * Returns a `Buffer` in node.js or `Blob` in the browser.\r\n *\r\n * @param mount - The service's mount point, relative to the database.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const serviceBundle = await db.downloadService(\"/my-foxx\");\r\n * ```\r\n */\r\n downloadService(mount: string): Promise<Buffer | Blob> {\r\n return this.request({\r\n method: \"POST\",\r\n pathname: \"/_api/foxx/download\",\r\n search: { mount },\r\n expectBinary: true,\r\n });\r\n }\r\n\r\n /**\r\n * Writes all locally available services to the database and updates any\r\n * service bundles missing in the database.\r\n *\r\n * @param replace - If set to `true`, outdated services will also be\r\n * committed. This can be used to solve some consistency problems when\r\n * service bundles are missing in the database or were deleted manually.\r\n *\r\n * @example\r\n * ```js\r\n * await db.commitLocalServiceState();\r\n * // all services available on the coordinator have been written to the db\r\n * ```\r\n *\r\n * @example\r\n * ```js\r\n * await db.commitLocalServiceState(true);\r\n * // all service conflicts have been resolved in favor of this coordinator\r\n * ```\r\n */\r\n commitLocalServiceState(replace: boolean = false): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_api/foxx/commit\",\r\n search: { replace },\r\n },\r\n () => undefined\r\n );\r\n }\r\n //#endregion\r\n //#region hot backups\r\n /**\r\n * (Enterprise Edition only.) Creates a hot backup of the entire ArangoDB\r\n * deployment including all databases, collections, etc.\r\n *\r\n * Returns an object describing the backup result.\r\n *\r\n * @param options - Options for creating the backup.\r\n *\r\n * @example\r\n * ```js\r\n * const info = await db.createHotBackup();\r\n * // a hot backup has been created\r\n * ```\r\n */\r\n createHotBackup(\r\n options: hotBackups.HotBackupOptions = {}\r\n ): Promise<hotBackups.HotBackupResult> {\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_admin/backup/create\",\r\n body: options,\r\n },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * (Enterprise Edition only.) Retrieves a list of all locally found hot\r\n * backups.\r\n *\r\n * @param id - If specified, only the backup with the given ID will be\r\n * returned.\r\n *\r\n * @example\r\n * ```js\r\n * const backups = await db.getHotBackups();\r\n * for (const backup of backups.list) {\r\n * console.log(backup.id);\r\n * }\r\n * ```\r\n */\r\n getHotBackups(id?: string | string[]): Promise<hotBackups.HotBackupList> {\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_admin/backup/list\",\r\n body: id ? { id } : undefined,\r\n },\r\n (res) => res.parsedBody.result\r\n );\r\n }\r\n\r\n /**\r\n * (Enteprise Edition only.) Restores a consistent local hot backup.\r\n *\r\n * Returns the directory path of the restored backup.\r\n *\r\n * @param id - The ID of the backup to restore.\r\n *\r\n * @example\r\n * ```js\r\n * await db.restoreHotBackup(\"2023-09-19T15.38.21Z_example\");\r\n * // the backup has been restored\r\n * ```\r\n */\r\n restoreHotBackup(id: string): Promise<string> {\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_admin/backup/restore\",\r\n body: { id },\r\n },\r\n (res) => res.parsedBody.result.previous\r\n );\r\n }\r\n\r\n /**\r\n * (Enterprise Edition only.) Deletes a local hot backup.\r\n *\r\n * @param id - The ID of the backup to delete.\r\n *\r\n * @example\r\n * ```js\r\n * await db.deleteHotBackup(\"2023-09-19T15.38.21Z_example\");\r\n * // the backup has been deleted\r\n * ```\r\n */\r\n deleteHotBackup(id: string): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"POST\",\r\n pathname: \"/_admin/backup/delete\",\r\n body: { id },\r\n },\r\n () => undefined\r\n );\r\n }\r\n //#endregion\r\n //#region logs\r\n /**\r\n * Retrieves the log messages from the server's global log.\r\n *\r\n * @param options - Options for retrieving the log entries.\r\n *\r\n * @example\r\n * ```js\r\n * const log = await db.getLogEntries();\r\n * for (let i = 0; i < log.totalAmount; i++) {\r\n * console.log(`${\r\n * new Date(log.timestamp[i] * 1000).toISOString()\r\n * } - [${LogLevel[log.level[i]]}] ${log.text[i]} (#${log.lid[i]})`);\r\n * }\r\n * ```\r\n */\r\n getLogEntries(options?: logs.LogEntriesOptions): Promise<logs.LogEntries> {\r\n return this.request(\r\n {\r\n pathname: \"/_admin/log/entries\",\r\n search: options,\r\n },\r\n (res) => res.parsedBody\r\n );\r\n }\r\n\r\n /**\r\n * Retrieves the log messages from the server's global log.\r\n *\r\n * @param options - Options for retrieving the log entries.\r\n *\r\n * @deprecated This endpoint has been deprecated in ArangoDB 3.8.\r\n * Use {@link Database#getLogEntries} instead.\r\n *\r\n * @example\r\n * ```js\r\n * const messages = await db.listLogMessages();\r\n * for (const m of messages) {\r\n * console.log(`${m.date} - [${m.level}] ${m.message} (#${m.id})`);\r\n * }\r\n * ```\r\n */\r\n listLogMessages(\r\n options?: logs.LogEntriesOptions\r\n ): Promise<logs.LogMessage[]> {\r\n return this.request(\r\n {\r\n pathname: \"/_admin/log\",\r\n search: options,\r\n },\r\n (res) => res.parsedBody.messages\r\n );\r\n }\r\n\r\n /**\r\n * Retrieves the server's current log level for each topic.\r\n *\r\n * @example\r\n * ```js\r\n * const levels = await db.getLogLevel();\r\n * console.log(levels.request); // log level for incoming requests\r\n * ```\r\n */\r\n getLogLevel(): Promise<Record<string, logs.LogLevelSetting>> {\r\n return this.request({\r\n pathname: \"/_admin/log/level\",\r\n });\r\n }\r\n\r\n /**\r\n * Sets the server's log level for each of the given topics to the given level.\r\n *\r\n * Any omitted topics will be left unchanged.\r\n *\r\n * @param levels - An object mapping topic names to log levels.\r\n *\r\n * @example\r\n * ```js\r\n * await db.setLogLevel({ request: \"debug\" });\r\n * // Debug information will now be logged for each request\r\n * ```\r\n */\r\n setLogLevel(\r\n levels: Record<string, logs.LogLevelSetting>\r\n ): Promise<Record<string, logs.LogLevelSetting>> {\r\n return this.request({\r\n method: \"PUT\",\r\n pathname: \"/_admin/log/level\",\r\n body: levels,\r\n });\r\n }\r\n //#endregion\r\n //#region async jobs\r\n\r\n /**\r\n * Creates an async job by executing the given callback function. The first\r\n * database request performed by the callback will be marked for asynchronous\r\n * execution and its result will be made available as an async job.\r\n *\r\n * Returns a {@link jobs.Job} instance that can be used to retrieve the result\r\n * of the callback function once the request has been executed.\r\n *\r\n * @param callback - Callback function to execute as an async job.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const job = await db.createJob(() => db.collections());\r\n * while (!job.isLoaded) {\r\n * await timeout(1000);\r\n * await job.load();\r\n * }\r\n * // job.result is a list of Collection instances\r\n * ```\r\n */\r\n async createJob<T>(callback: () => Promise<T>): Promise<jobs.Job<T>> {\r\n const trap = new Promise<TrappedError | TrappedRequest<T>>(\r\n (resolveTrap) => {\r\n this._trapRequest = (trapped) => resolveTrap(trapped);\r\n }\r\n );\r\n const eventualResult = callback();\r\n const trapped = await trap;\r\n if (trapped.error) return eventualResult as Promise<any>;\r\n const { jobId, onResolve, onReject } = trapped;\r\n return new jobs.Job(\r\n this,\r\n jobId,\r\n (res) => {\r\n onResolve(res);\r\n return eventualResult;\r\n },\r\n (e) => {\r\n onReject(e);\r\n return eventualResult;\r\n }\r\n );\r\n }\r\n\r\n /**\r\n * Returns a {@link jobs.Job} instance for the given `jobId`.\r\n *\r\n * @param jobId - ID of the async job.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const job = db.job(\"12345\");\r\n * ```\r\n */\r\n job(jobId: string): jobs.Job {\r\n return new jobs.Job(this, jobId);\r\n }\r\n\r\n /**\r\n * Returns a list of the IDs of all currently pending async jobs.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const pendingJobs = await db.listPendingJobs();\r\n * console.log(pendingJobs); // e.g. [\"12345\", \"67890\"]\r\n * ```\r\n */\r\n listPendingJobs(): Promise<string[]> {\r\n return this.request(\r\n {\r\n pathname: \"/_api/job/pending\",\r\n },\r\n (res) => res.parsedBody\r\n );\r\n }\r\n\r\n /**\r\n * Returns a list of the IDs of all currently available completed async jobs.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const completedJobs = await db.listCompletedJobs();\r\n * console.log(completedJobs); // e.g. [\"12345\", \"67890\"]\r\n * ```\r\n */\r\n listCompletedJobs(): Promise<string[]> {\r\n return this.request(\r\n {\r\n pathname: \"/_api/job/done\",\r\n },\r\n (res) => res.parsedBody\r\n );\r\n }\r\n\r\n /**\r\n * Deletes the results of all completed async jobs created before the given\r\n * threshold.\r\n *\r\n * @param threshold - The expiration timestamp in milliseconds.\r\n *\r\n * @example\r\n * ```js\r\n * const db = new Database();\r\n * const ONE_WEEK = 7 * 24 * 60 * 60 * 1000;\r\n * await db.deleteExpiredJobResults(Date.now() - ONE_WEEK);\r\n * // all job results older than a week have been deleted\r\n * ```\r\n */\r\n deleteExpiredJobResults(threshold: number): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: `/_api/job/expired`,\r\n search: { stamp: threshold / 1000 },\r\n },\r\n () => undefined\r\n );\r\n }\r\n\r\n /**\r\n * Deletes the results of all completed async jobs.\r\n */\r\n deleteAllJobResults(): Promise<void> {\r\n return this.request(\r\n {\r\n method: \"DELETE\",\r\n pathname: `/_api/job/all`,\r\n },\r\n () => undefined\r\n );\r\n }\r\n //#endregion\r\n}\r\n//#endregion\r\n"]}
|