arangojs
Version:
The official ArangoDB JavaScript driver.
1 lines • 43.7 kB
Source Map (JSON)
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/connection.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,uDAAiD;AAEjD,yCAMoB;AACpB,6CAGwB;AACxB,2DAAqD;AACrD,iDAM0B;AAC1B,mDAA6C;AAC7C,2DAAqD;AAErD,MAAM,SAAS,GAAG,2BAA2B,CAAC;AAC9C,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AA2DnD,SAAS,YAAY,CAAC,IAAS;IAC7B,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB;IACzB,IAAI,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;IACtB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;QACf,IAAI,CAAC;YACH,MAAM,GAAG,CAAC;QACZ,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,GAAG,GAAG,CAAC,CAAC;QACV,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AA4RD;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAAC,UAAe;IAChD,OAAO,OAAO,CAAC,UAAU,IAAI,UAAU,CAAC,kBAAkB,CAAC,CAAC;AAC9D,CAAC;AAFD,gDAEC;AAED;;;;GAIG;AACH,MAAa,UAAU;IACX,YAAY,GAAW,CAAC,CAAC;IACzB,cAAc,GAAW,KAAK,CAAC;IAC/B,QAAQ,CAAU;IAClB,sBAAsB,CAAwB;IAC9C,WAAW,CAAiB;IAC5B,aAAa,CAAS;IACtB,cAAc,CAAgB;IAC9B,gBAAgB,CAAS;IACzB,MAAM,GAAG,IAAI,0BAAU,EAAQ,CAAC;IAChC,UAAU,GAAG,IAAI,GAAG,EAAoB,CAAC;IACzC,MAAM,GAAsB,EAAE,CAAC;IAC/B,SAAS,GAAa,EAAE,CAAC;I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,IAAI,OAAO,KAAK,CAAC,iBAAiB,KAAK,UAAU,EAAE,CAAC;oBAClD,MAAM,OAAO,GAAG,EAAgC,CAAC;oBACjD,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;oBACjC,IAAI,CAAC,KAAK,GAAG,GAAG,EAAE,CAChB,KAAK,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACzD,CAAC;qBAAM,CAAC;oBACN,MAAM,OAAO,GAAG,kBAAkB,EAAgC,CAAC;oBACnE,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;wBAC3D,IAAI,CAAC,KAAK,GAAG,GAAG,EAAE,CAChB,KAAK,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;oBACzD,CAAC;gBACH,CAAC;YACH,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACvB,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAthBD,gCAshBC","sourcesContent":["/**\n * ```ts\n * import type { Config } from \"arangojs/connection.js\";\n * ```\n *\n * The \"connection\" module provides connection and configuration related types\n * for TypeScript.\n *\n * @packageDocumentation\n */\nimport { LinkedList } from \"./lib/linkedList.js\";\nimport { Database } from \"./database.js\";\nimport {\n ArangoError,\n HttpError,\n isArangoError,\n isArangoErrorResponse,\n isSystemError,\n} from \"./error.js\";\nimport {\n ERROR_ARANGO_CONFLICT,\n ERROR_ARANGO_MAINTENANCE_MODE,\n} from \"./lib/codes.js\";\nimport { normalizeUrl } from \"./lib/normalizeUrl.js\";\nimport {\n ArangojsError,\n ArangojsResponse,\n createRequest,\n RequestConfig,\n RequestFunction,\n} from \"./lib/request.js\";\nimport { joinPath } from \"./lib/joinPath.js\";\nimport { mergeHeaders } from \"./lib/mergeHeaders.js\";\n\nconst MIME_JSON = /\\/(json|javascript)(\\W|$)/;\nconst LEADER_ENDPOINT_HEADER = \"x-arango-endpoint\";\n\n/**\n * Determines the behavior when multiple URLs are used:\n *\n * - `\"NONE\"`: No load balancing. All requests will be handled by the first\n * URL in the list until a network error is encountered. On network error,\n * arangojs will advance to using the next URL in the list.\n *\n * - `\"ONE_RANDOM\"`: Randomly picks one URL from the list initially, then\n * behaves like `\"NONE\"`.\n *\n * - `\"ROUND_ROBIN\"`: Every sequential request uses the next URL in the list.\n */\nexport type LoadBalancingStrategy = \"NONE\" | \"ROUND_ROBIN\" | \"ONE_RANDOM\";\n\n/**\n * Generic properties shared by all ArangoDB HTTP API responses.\n */\nexport type ArangoResponseMetadata = {\n /**\n * Indicates that the request was successful.\n */\n error: false;\n /**\n * Response status code, typically `200`.\n */\n code: number;\n};\n\n/**\n * Extends the given base type `T` with the generic HTTP API response properties.\n */\nexport type ArangoApiResponse<T> = T & ArangoResponseMetadata;\n\n/**\n * Credentials for HTTP Basic authentication.\n */\nexport type BasicAuthCredentials = {\n /**\n * Username to use for authentication, e.g. `\"root\"`.\n */\n username: string;\n /**\n * Password to use for authentication. Defaults to an empty string.\n */\n password?: string;\n};\n\n/**\n * Credentials for HTTP Bearer token authentication.\n */\nexport type BearerAuthCredentials = {\n /**\n * Bearer token to use for authentication.\n */\n token: string;\n};\n\nfunction isBearerAuth(auth: any): auth is BearerAuthCredentials {\n return auth.hasOwnProperty(\"token\");\n}\n\n/**\n * @internal\n */\nfunction generateStackTrace() {\n let err = new Error();\n if (!err.stack) {\n try {\n throw err;\n } catch (e: any) {\n err = e;\n }\n }\n return err;\n}\n\n/**\n * Options for performing a request with arangojs.\n */\nexport type RequestOptions = {\n /**\n * @internal\n *\n * Identifier of a specific ArangoDB host to use when more than one is known.\n */\n hostUrl?: string;\n /**\n * HTTP method to use in order to perform the request.\n *\n * Default: `\"GET\"`\n */\n method?: string;\n /**\n * Request body data.\n */\n body?: any;\n /**\n * If set to `true`, the response body will not be interpreted as JSON and\n * instead passed as-is.\n */\n expectBinary?: boolean;\n /**\n * If set to `true`, the request body will not be converted to JSON and\n * instead passed as-is.\n */\n isBinary?: boolean;\n /**\n * Whether ArangoDB is allowed to perform a dirty read to respond to this\n * request. If set to `true`, the response may reflect a dirty state from\n * a non-authoritative server.\n */\n allowDirtyRead?: boolean;\n /**\n * If set to a positive number, the request will automatically be retried at\n * most this many times if it results in a write-write conflict.\n *\n * Default: `config.retryOnConflict`\n */\n retryOnConflict?: number;\n /**\n * HTTP headers to pass along with this request in addition to the default\n * headers generated by arangojs.\n */\n headers?: Headers | Record<string, string>;\n /**\n * Time in milliseconds after which arangojs will abort the request if the\n * socket has not already timed out.\n *\n * See also `agentOptions.timeout` in {@link Config}.\n */\n timeout?: number;\n /**\n * Optional prefix path to prepend to the `path`.\n */\n basePath?: string;\n /**\n * URL path, relative to the `basePath` and server domain.\n */\n path?: string;\n /**\n * URL parameters to pass as part of the query string.\n */\n search?: URLSearchParams | Record<string, any>;\n};\n\n/**\n * @internal\n */\ntype Task = {\n hostUrl?: string;\n stack?: () => string;\n allowDirtyRead: boolean;\n retryOnConflict: number;\n resolve: (result: any) => void;\n reject: (error: Error) => void;\n transform?: (res: ArangojsResponse) => any;\n retries: number;\n options: {\n method: string;\n expectBinary: boolean;\n timeout?: number;\n pathname: string;\n search?: URLSearchParams;\n headers: Headers;\n body: any;\n };\n};\n\n/**\n * Options for configuring arangojs.\n */\nexport type Config = {\n /**\n * Name of the database to use.\n *\n * Default: `\"_system\"`\n */\n databaseName?: string;\n /**\n * Base URL of the ArangoDB server or list of server URLs.\n *\n * When working with a cluster, the method {@link database.Database#acquireHostList}\n * can be used to automatically pick up additional coordinators/followers at\n * any point.\n *\n * When running ArangoDB on a unix socket, e.g. `/tmp/arangodb.sock`, the\n * following URL formats are supported for unix sockets:\n *\n * - `unix:///tmp/arangodb.sock` (no SSL)\n * - `http+unix:///tmp/arangodb.sock` (or `https+unix://` for SSL)\n * - `http://unix:/tmp/arangodb.sock` (or `https://unix:` for SSL)\n *\n * Additionally `ssl` and `tls` are treated as synonymous with `https` and\n * `tcp` is treated as synonymous with `http`, so the following URLs are\n * considered identical:\n *\n * - `tcp://127.0.0.1:8529` and `http://127.0.0.1:8529`\n * - `ssl://127.0.0.1:8529` and `https://127.0.0.1:8529`\n * - `tcp+unix:///tmp/arangodb.sock` and `http+unix:///tmp/arangodb.sock`\n * - `ssl+unix:///tmp/arangodb.sock` and `https+unix:///tmp/arangodb.sock`\n * - `tcp://unix:/tmp/arangodb.sock` and `http://unix:/tmp/arangodb.sock`\n * - `ssl://unix:/tmp/arangodb.sock` and `https://unix:/tmp/arangodb.sock`\n *\n * See also `auth` for passing authentication credentials.\n *\n * Default: `\"http://127.0.0.1:8529\"`\n */\n url?: string | string[];\n /**\n * Credentials to use for authentication.\n *\n * See also {@link database.Database#useBasicAuth} and\n * {@link database.Database#useBearerAuth}.\n *\n * Default: `{ username: \"root\", password: \"\" }`\n */\n auth?: BasicAuthCredentials | BearerAuthCredentials;\n /**\n * Numeric representation of the ArangoDB version the driver should expect.\n * The format is defined as `XYYZZ` where `X` is the major version, `Y` is\n * the zero-filled two-digit minor version and `Z` is the zero-filled two-digit\n * bugfix version, e.g. `30102` for 3.1.2, `20811` for 2.8.11.\n *\n * Depending on this value certain methods may become unavailable or change\n * their behavior to remain compatible with different versions of ArangoDB.\n *\n * Default: `31100`\n */\n arangoVersion?: number;\n /**\n * Determines the behavior when multiple URLs are provided:\n *\n * - `\"NONE\"`: No load balancing. All requests will be handled by the first\n * URL in the list until a network error is encountered. On network error,\n * arangojs will advance to using the next URL in the list.\n *\n * - `\"ONE_RANDOM\"`: Randomly picks one URL from the list initially, then\n * behaves like `\"NONE\"`.\n *\n * - `\"ROUND_ROBIN\"`: Every sequential request uses the next URL in the list.\n *\n * Default: `\"NONE\"`\n */\n loadBalancingStrategy?: LoadBalancingStrategy;\n /**\n * Determines the behavior when a request fails because the underlying\n * connection to the server could not be opened\n * (i.e. [`ECONNREFUSED` in Node.js](https://nodejs.org/api/errors.html#errors_common_system_errors)):\n *\n * - `false`: the request fails immediately.\n *\n * - `0`: the request is retried until a server can be reached but only a\n * total number of times matching the number of known servers (including\n * the initial failed request).\n *\n * - any other number: the request is retried until a server can be reached\n * or the request has been retried a total of `maxRetries` number of times\n * (not including the initial failed request).\n *\n * When working with a single server, the retries (if any) will be made to\n * the same server.\n *\n * This setting currently has no effect when using arangojs in a browser.\n *\n * **Note**: Requests bound to a specific server (e.g. fetching query results)\n * will never be retried automatically and ignore this setting.\n *\n * **Note**: To set the number of retries when a write-write conflict is\n * encountered, see `retryOnConflict` instead.\n *\n * Default: `0`\n */\n maxRetries?: false | number;\n /**\n * Maximum number of parallel requests arangojs will perform. If any\n * additional requests are attempted, they will be enqueued until one of the\n * active requests has completed.\n *\n * **Note:** when using `ROUND_ROBIN` load balancing and passing an array of\n * URLs in the `url` option, the default value of this option will be set to\n * `3 * url.length` instead of `3`.\n *\n * Default: `3`\n */\n poolSize?: number;\n /**\n * (Browser only.) Determines whether credentials (e.g. cookies) will be sent\n * with requests to the ArangoDB server.\n *\n * If set to `same-origin`, credentials will only be included with requests\n * on the same URL origin as the invoking script. If set to `include`,\n * credentials will always be sent. If set to `omit`, credentials will be\n * excluded from all requests.\n *\n * Default: `same-origin`\n */\n credentials?: \"omit\" | \"include\" | \"same-origin\";\n /**\n * If set to `true`, requests will keep the underlying connection open until\n * it times out or is closed. In browsers this prevents requests from being\n * cancelled when the user navigates away from the page.\n *\n * Default: `true`\n */\n keepalive?: boolean;\n /**\n * Callback that will be invoked with the finished request object before it\n * is finalized. In the browser the request may already have been sent.\n *\n * @param req - Request object or XHR instance used for this request.\n */\n beforeRequest?: (req: globalThis.Request) => void;\n /**\n * Callback that will be invoked when the server response has been received\n * and processed or when the request has been failed without a response.\n *\n * The originating request will be available as the `request` property\n * on either the error or response object.\n *\n * @param err - Error encountered when handling this request or `null`.\n * @param res - Response object for this request, if no error occurred.\n */\n afterResponse?: (err: ArangojsError | null, res?: ArangojsResponse) => void;\n /**\n * If set to a positive number, requests will automatically be retried at\n * most this many times if they result in a write-write conflict.\n *\n * Default: `0`\n */\n retryOnConflict?: number;\n /**\n * An object with additional headers to send with every request.\n *\n * If an `\"authorization\"` header is provided, it will be overridden when\n * using {@link database.Database#useBasicAuth}, {@link database.Database#useBearerAuth} or\n * the `auth` configuration option.\n */\n headers?: Headers | Record<string, string>;\n /**\n * If set to `true`, arangojs will generate stack traces every time a request\n * is initiated and augment the stack traces of any errors it generates.\n *\n * **Warning**: This will cause arangojs to generate stack traces in advance\n * even if the request does not result in an error. Generating stack traces\n * may negatively impact performance.\n */\n precaptureStackTraces?: boolean;\n /**\n * Limits the number of values of server-reported response queue times that\n * will be stored and accessible using {@link database.Database#queueTime}. If set to\n * a finite value, older values will be discarded to make room for new values\n * when that limit is reached.\n *\n * Default: `10`\n */\n responseQueueTimeSamples?: number;\n};\n\n/**\n * Indicates whether the given value represents a {@link Connection}.\n *\n * @param connection - A value that might be a connection.\n *\n * @internal\n */\nexport function isArangoConnection(connection: any): connection is Connection {\n return Boolean(connection && connection.isArangoConnection);\n}\n\n/**\n * Represents a connection pool shared by one or more databases.\n *\n * @internal\n */\nexport class Connection {\n protected _activeTasks: number = 0;\n protected _arangoVersion: number = 31100;\n protected _headers: Headers;\n protected _loadBalancingStrategy: LoadBalancingStrategy;\n protected _maxRetries: number | false;\n protected _taskPoolSize: number;\n protected _requestConfig: RequestConfig;\n protected _retryOnConflict: number;\n protected _queue = new LinkedList<Task>();\n protected _databases = new Map<string, Database>();\n protected _hosts: RequestFunction[] = [];\n protected _hostUrls: string[] = [];\n protected _activeHostUrl: string;\n protected _activeDirtyHostUrl: string;\n protected _transactionId: string | null = null;\n protected _precaptureStackTraces: boolean;\n protected _queueTimes = new LinkedList<[number, number]>();\n protected _responseQueueTimeSamples: number;\n\n /**\n * @internal\n *\n * Creates a new `Connection` instance.\n *\n * @param config - An object with configuration options.\n *\n */\n constructor(config: Omit<Config, \"databaseName\"> = {}) {\n const URLS = config.url\n ? Array.isArray(config.url)\n ? config.url\n : [config.url]\n : [\"http://127.0.0.1:8529\"];\n const DEFAULT_POOL_SIZE =\n 3 * (config.loadBalancingStrategy === \"ROUND_ROBIN\" ? URLS.length : 1);\n\n if (config.arangoVersion !== undefined) {\n this._arangoVersion = config.arangoVersion;\n }\n this._taskPoolSize = config.poolSize ?? DEFAULT_POOL_SIZE;\n this._requestConfig = {\n credentials: config.credentials ?? \"same-origin\",\n keepalive: config.keepalive ?? true,\n beforeRequest: config.beforeRequest,\n afterResponse: config.afterResponse,\n };\n this._headers = new Headers(config.headers);\n this._headers.set(\"x-arango-version\", String(this._arangoVersion));\n this._headers.set(\n \"x-arango-driver\",\n `arangojs/${process.env.ARANGOJS_VERSION} (cloud)`\n );\n this._loadBalancingStrategy = config.loadBalancingStrategy ?? \"NONE\";\n this._precaptureStackTraces = Boolean(config.precaptureStackTraces);\n this._responseQueueTimeSamples = config.responseQueueTimeSamples ?? 10;\n this._retryOnConflict = config.retryOnConflict ?? 0;\n if (this._responseQueueTimeSamples < 0) {\n this._responseQueueTimeSamples = Infinity;\n }\n if (config.maxRetries === false) {\n this._maxRetries = false;\n } else {\n this._maxRetries = Number(config.maxRetries ?? 0);\n }\n\n this.addToHostList(URLS);\n\n if (config.auth) {\n if (isBearerAuth(config.auth)) {\n this.setBearerAuth(config.auth);\n } else {\n this.setBasicAuth(config.auth);\n }\n }\n\n if (this._loadBalancingStrategy === \"ONE_RANDOM\") {\n this._activeHostUrl =\n this._hostUrls[Math.floor(Math.random() * this._hostUrls.length)];\n this._activeDirtyHostUrl =\n this._hostUrls[Math.floor(Math.random() * this._hostUrls.length)];\n } else {\n this._activeHostUrl = this._hostUrls[0];\n this._activeDirtyHostUrl = this._hostUrls[0];\n }\n }\n\n /**\n * @internal\n *\n * Indicates that this object represents an ArangoDB connection.\n */\n get isArangoConnection(): true {\n return true;\n }\n\n get queueTime() {\n return {\n getLatest: () => this._queueTimes.last?.value[1],\n getValues: () => Array.from(this._queueTimes.values()),\n getAvg: () => {\n let avg = 0;\n for (const [, [, value]] of this._queueTimes) {\n avg += value / this._queueTimes.length;\n }\n return avg;\n },\n };\n }\n\n protected async _runQueue() {\n if (!this._queue.length || this._activeTasks >= this._taskPoolSize) return;\n const task = this._queue.shift()!;\n let hostUrl = this._activeHostUrl;\n if (task.hostUrl !== undefined) {\n hostUrl = task.hostUrl;\n } else if (task.allowDirtyRead) {\n hostUrl = this._activeDirtyHostUrl;\n this._activeDirtyHostUrl =\n this._hostUrls[\n (this._hostUrls.indexOf(this._activeDirtyHostUrl) + 1) %\n this._hostUrls.length\n ];\n task.options.headers.set(\"x-arango-allow-dirty-read\", \"true\");\n } else if (this._loadBalancingStrategy === \"ROUND_ROBIN\") {\n this._activeHostUrl =\n this._hostUrls[\n (this._hostUrls.indexOf(this._activeHostUrl) + 1) %\n this._hostUrls.length\n ];\n }\n this._activeTasks += 1;\n try {\n const res = await this._hosts[this._hostUrls.indexOf(hostUrl)](\n task.options\n );\n const leaderEndpoint = res.headers.get(LEADER_ENDPOINT_HEADER);\n if (res.status === 503 && leaderEndpoint) {\n const [cleanUrl] = this.addToHostList(leaderEndpoint);\n task.hostUrl = cleanUrl;\n if (this._activeHostUrl === hostUrl) {\n this._activeHostUrl = cleanUrl;\n }\n this._queue.push(task);\n } else {\n res.arangojsHostUrl = hostUrl;\n const contentType = res.headers.get(\"content-type\");\n const queueTime = res.headers.get(\"x-arango-queue-time-seconds\");\n if (queueTime) {\n this._queueTimes.push([Date.now(), Number(queueTime)]);\n while (this._responseQueueTimeSamples < this._queueTimes.length) {\n this._queueTimes.shift();\n }\n }\n if (res.status >= 400) {\n try {\n if (contentType?.match(MIME_JSON)) {\n const errorResponse = res.clone();\n let errorBody: any;\n try {\n errorBody = await errorResponse.json();\n } catch {\n // noop\n }\n if (isArangoErrorResponse(errorBody)) {\n res.parsedBody = errorBody;\n throw new ArangoError(res);\n }\n }\n throw new HttpError(res);\n } catch (err: any) {\n if (task.stack) {\n err.stack += task.stack();\n }\n throw err;\n }\n }\n if (res.body) {\n if (task.options.expectBinary) {\n res.parsedBody = await res.blob();\n } else if (contentType?.match(MIME_JSON)) {\n res.parsedBody = await res.json();\n } else {\n res.parsedBody = await res.text();\n }\n }\n task.resolve(task.transform ? task.transform(res) : res);\n }\n } catch (err: any) {\n if (\n !task.allowDirtyRead &&\n this._hosts.length > 1 &&\n this._activeHostUrl === hostUrl &&\n this._loadBalancingStrategy !== \"ROUND_ROBIN\"\n ) {\n this._activeHostUrl =\n this._hostUrls[\n (this._hostUrls.indexOf(this._activeHostUrl) + 1) %\n this._hostUrls.length\n ];\n }\n if (\n isArangoError(err) &&\n err.errorNum === ERROR_ARANGO_CONFLICT &&\n task.retryOnConflict > 0\n ) {\n task.retryOnConflict -= 1;\n this._queue.push(task);\n } else if (\n ((isSystemError(err) &&\n err.syscall === \"connect\" &&\n err.code === \"ECONNREFUSED\") ||\n (isArangoError(err) &&\n err.errorNum === ERROR_ARANGO_MAINTENANCE_MODE)) &&\n task.hostUrl === undefined &&\n this._maxRetries !== false &&\n task.retries < (this._maxRetries || this._hosts.length - 1)\n ) {\n task.retries += 1;\n this._queue.push(task);\n } else {\n if (task.stack) {\n err.stack += task.stack();\n }\n task.reject(err);\n }\n } finally {\n this._activeTasks -= 1;\n }\n this._runQueue();\n }\n\n setBearerAuth(auth: BearerAuthCredentials) {\n this.setHeader(\"authorization\", `Bearer ${auth.token}`);\n }\n\n setBasicAuth(auth: BasicAuthCredentials) {\n this.setHeader(\n \"authorization\",\n `Basic ${btoa(`${auth.username}:${auth.password}`)}`\n );\n }\n\n setResponseQueueTimeSamples(responseQueueTimeSamples: number) {\n if (responseQueueTimeSamples < 0) {\n responseQueueTimeSamples = Infinity;\n }\n this._responseQueueTimeSamples = responseQueueTimeSamples;\n while (this._responseQueueTimeSamples < this._queueTimes.length) {\n this._queueTimes.shift();\n }\n }\n\n /**\n * @internal\n *\n * Fetches a {@link database.Database} instance for the given database name from the\n * internal cache, if available.\n *\n * @param databaseName - Name of the database.\n */\n database(databaseName: string): Database | undefined;\n /**\n * @internal\n *\n * Adds a {@link database.Database} instance for the given database name to the\n * internal cache.\n *\n * @param databaseName - Name of the database.\n * @param database - Database instance to add to the cache.\n */\n database(databaseName: string, database: Database): Database;\n /**\n * @internal\n *\n * Clears any {@link database.Database} instance stored for the given database name\n * from the internal cache, if present.\n *\n * @param databaseName - Name of the database.\n * @param database - Must be `null`.\n */\n database(databaseName: string, database: null): undefined;\n database(\n databaseName: string,\n database?: Database | null\n ): Database | undefined {\n if (database === null) {\n this._databases.delete(databaseName);\n return undefined;\n }\n if (!database) {\n return this._databases.get(databaseName);\n }\n this._databases.set(databaseName, database);\n return database;\n }\n\n /**\n * @internal\n *\n * Replaces the host list with the given URLs.\n *\n * See {@link Connection#acquireHostList}.\n *\n * @param urls - URLs to use as host list.\n */\n setHostList(urls: string[]): void {\n const cleanUrls = urls.map((url) => normalizeUrl(url));\n this._hosts.splice(\n 0,\n this._hosts.length,\n ...cleanUrls.map((url) => {\n const i = this._hostUrls.indexOf(url);\n if (i !== -1) return this._hosts[i];\n const parsedUrl = new URL(url);\n if (!parsedUrl.pathname.endsWith(\"/\")) {\n parsedUrl.pathname += \"/\";\n }\n return createRequest(parsedUrl, this._requestConfig);\n })\n );\n this._hostUrls.splice(0, this._hostUrls.length, ...cleanUrls);\n }\n\n /**\n * @internal\n *\n * Adds the given URL or URLs to the host list.\n *\n * See {@link Connection#acquireHostList}.\n *\n * @param urls - URL or URLs to add.\n */\n addToHostList(urls: string | string[]): string[] {\n const cleanUrls = (Array.isArray(urls) ? urls : [urls]).map((url) =>\n normalizeUrl(url)\n );\n const newUrls = cleanUrls.filter(\n (url) => this._hostUrls.indexOf(url) === -1\n );\n this._hostUrls.push(...newUrls);\n this._hosts.push(\n ...newUrls.map((url: string) => {\n const parsedUrl = new URL(url);\n if (!parsedUrl.pathname.endsWith(\"/\")) {\n parsedUrl.pathname += \"/\";\n }\n return createRequest(parsedUrl, this._requestConfig);\n })\n );\n return cleanUrls;\n }\n\n /**\n * @internal\n *\n * Sets the connection's active `transactionId`.\n *\n * While set, all requests will use this ID, ensuring the requests are executed\n * within the transaction if possible. Setting the ID manually may cause\n * unexpected behavior.\n *\n * See also {@link Connection#clearTransactionId}.\n *\n * @param transactionId - ID of the active transaction.\n */\n setTransactionId(transactionId: string) {\n this._transactionId = transactionId;\n }\n\n /**\n * @internal\n *\n * Clears the connection's active `transactionId`.\n */\n clearTransactionId() {\n this._transactionId = null;\n }\n\n /**\n * @internal\n *\n * Sets the header `headerName` with the given `value` or clears the header if\n * `value` is `null`.\n *\n * @param headerName - Name of the header to set.\n * @param value - Value of the header.\n */\n setHeader(headerName: string, value: string | null) {\n if (value === null) {\n this._headers.delete(headerName);\n } else {\n this._headers.set(headerName, value);\n }\n }\n\n /**\n * @internal\n *\n * Closes all open connections.\n *\n * See {@link database.Database#close}.\n */\n close() {\n for (const host of this._hosts) {\n if (host.close) host.close();\n }\n }\n\n /**\n * @internal\n *\n * Waits for propagation.\n *\n * See {@link database.Database#waitForPropagation}.\n *\n * @param request - Request to perform against each coordinator.\n * @param timeout - Maximum number of milliseconds to wait for propagation.\n */\n async waitForPropagation(request: RequestOptions, timeout = Infinity) {\n const numHosts = this._hosts.length;\n const propagated = [] as string[];\n const started = Date.now();\n let index = 0;\n while (true) {\n if (propagated.length === numHosts) {\n return;\n }\n while (propagated.includes(this._hostUrls[index])) {\n index = (index + 1) % numHosts;\n }\n const hostUrl = this._hostUrls[index];\n try {\n await this.request({ ...request, hostUrl });\n } catch (e: any) {\n if (started + timeout < Date.now()) {\n throw e;\n }\n await new Promise((resolve) => setTimeout(resolve, 1000));\n continue;\n }\n if (!propagated.includes(hostUrl)) {\n propagated.push(hostUrl);\n }\n }\n }\n\n /**\n * @internal\n *\n * Performs a request using the arangojs connection pool.\n */\n request<T = ArangojsResponse>(\n {\n hostUrl,\n method = \"GET\",\n body,\n expectBinary = false,\n isBinary = false,\n allowDirtyRead = false,\n retryOnConflict = this._retryOnConflict,\n timeout = 0,\n headers: requestHeaders,\n basePath,\n path,\n search: params,\n }: RequestOptions,\n transform?: (res: ArangojsResponse) => T\n ): Promise<T> {\n return new Promise((resolve, reject) => {\n const headers = mergeHeaders(this._headers, requestHeaders ?? {});\n\n if (body && !(body instanceof FormData)) {\n let contentType;\n if (isBinary) {\n contentType = \"application/octet-stream\";\n } else if (typeof body === \"object\") {\n body = JSON.stringify(body);\n contentType = \"application/json\";\n } else {\n body = String(body);\n contentType = \"text/plain\";\n }\n if (!headers.has(\"content-type\")) {\n headers.set(\"content-type\", contentType);\n }\n }\n\n if (this._transactionId) {\n headers.set(\"x-arango-trx-id\", this._transactionId);\n }\n\n const task: Task = {\n retries: 0,\n hostUrl,\n allowDirtyRead,\n retryOnConflict,\n options: {\n pathname: joinPath(basePath, path) ?? \"\",\n search:\n params &&\n (params instanceof URLSearchParams\n ? params\n : new URLSearchParams(params)),\n headers,\n timeout,\n method,\n expectBinary,\n body,\n },\n reject,\n resolve,\n transform,\n };\n\n if (this._precaptureStackTraces) {\n if (typeof Error.captureStackTrace === \"function\") {\n const capture = {} as { readonly stack: string };\n Error.captureStackTrace(capture);\n task.stack = () =>\n `\\n${capture.stack.split(\"\\n\").slice(3).join(\"\\n\")}`;\n } else {\n const capture = generateStackTrace() as { readonly stack: string };\n if (Object.prototype.hasOwnProperty.call(capture, \"stack\")) {\n task.stack = () =>\n `\\n${capture.stack.split(\"\\n\").slice(4).join(\"\\n\")}`;\n }\n }\n }\n\n this._queue.push(task);\n this._runQueue();\n });\n }\n}\n"]}