arangojs 10.2.1 → 10.2.2
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 +10 -0
- package/cjs/connection.d.ts.map +1 -1
- package/cjs/connection.js +3 -1
- package/cjs/connection.js.map +1 -1
- package/connection.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/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,15 @@ This driver uses semantic versioning:
|
|
|
14
14
|
- A change in the major version (e.g. 1.Y.Z -> 2.0.0) indicates _breaking_
|
|
15
15
|
changes that require changes in your code to upgrade.
|
|
16
16
|
|
|
17
|
+
## [10.2.2] - 2026-01-30
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- Fixed "Fetch failed: Invalid URL" error when using agentOptions by ensuring request creation
|
|
22
|
+
consistently uses undici.Request together with undici.fetch when the undici-based
|
|
23
|
+
dispatcher is active. This avoids invalid URL errors caused by mixing globalThis.Request
|
|
24
|
+
with undici request implementations.
|
|
25
|
+
|
|
17
26
|
## [10.2.1] - 2026-01-23
|
|
18
27
|
|
|
19
28
|
### Fixed
|
|
@@ -2550,6 +2559,7 @@ For a detailed list of changes between pre-release versions of v7 see the
|
|
|
2550
2559
|
|
|
2551
2560
|
Graph methods now only return the relevant part of the response body.
|
|
2552
2561
|
|
|
2562
|
+
[10.2.2]: https://github.com/arangodb/arangojs/compare/v10.2.1...v10.2.2
|
|
2553
2563
|
[10.2.1]: https://github.com/arangodb/arangojs/compare/v10.2.0...v10.2.1
|
|
2554
2564
|
[10.2.0]: https://github.com/arangodb/arangojs/compare/v10.1.2...v10.2.0
|
|
2555
2565
|
[10.1.2]: https://github.com/arangodb/arangojs/compare/v10.1.1...v10.1.2
|
package/cjs/connection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/connection.ts"],"names":[],"mappings":";;AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOpD;;GAEG;AACH,KAAK,IAAI,GAAG;IACV;;;;;;;OAOG;IACH,KAAK,EAAE,CACL,OAAO,EAAE,IAAI,CACX,cAAc,EACZ,YAAY,GACZ,iBAAiB,GACjB,gBAAgB,GAChB,SAAS,GACT,cAAc,GACd,UAAU,CACb,KACE,OAAO,CAAC,UAAU,CAAC,QAAQ,GAAG;QAAE,OAAO,EAAE,UAAU,CAAC,OAAO,CAAA;KAAE,CAAC,CAAC;IACpE;;;;OAIG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/connection.ts"],"names":[],"mappings":";;AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOpD;;GAEG;AACH,KAAK,IAAI,GAAG;IACV;;;;;;;OAOG;IACH,KAAK,EAAE,CACL,OAAO,EAAE,IAAI,CACX,cAAc,EACZ,YAAY,GACZ,iBAAiB,GACjB,gBAAgB,GAChB,SAAS,GACT,cAAc,GACd,UAAU,CACb,KACE,OAAO,CAAC,UAAU,CAAC,QAAQ,GAAG;QAAE,OAAO,EAAE,UAAU,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,GAAG;QACzB,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;QAC5B,UAAU,CAAC,EAAE,GAAG,CAAC;KAClB,KACE,CAAC,GACL,OAAO,CAAC,CAAC,CAAC;CAmJd"}
|
package/cjs/connection.js
CHANGED
|
@@ -58,6 +58,7 @@ function createHost(arangojsHostUrl, agentOptions) {
|
|
|
58
58
|
},
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
+
let Request = globalThis.Request;
|
|
61
62
|
if (agentOptions) {
|
|
62
63
|
createDispatcher = async () => {
|
|
63
64
|
let undici;
|
|
@@ -77,6 +78,7 @@ function createHost(arangojsHostUrl, agentOptions) {
|
|
|
77
78
|
});
|
|
78
79
|
}
|
|
79
80
|
fetch = undici.fetch;
|
|
81
|
+
Request = undici.Request;
|
|
80
82
|
return new undici.Agent(agentOptions);
|
|
81
83
|
};
|
|
82
84
|
}
|
|
@@ -353,7 +355,7 @@ class Connection {
|
|
|
353
355
|
...commonFetchOptions,
|
|
354
356
|
};
|
|
355
357
|
this._commonFetchOptions.headers.set("x-arango-version", String(arangoVersion));
|
|
356
|
-
this._commonFetchOptions.headers.set("x-arango-driver", `arangojs/10.2.
|
|
358
|
+
this._commonFetchOptions.headers.set("x-arango-driver", `arangojs/10.2.2 (cloud)`);
|
|
357
359
|
this.addToHostList(URLS);
|
|
358
360
|
if (auth) {
|
|
359
361
|
if (configuration.isBearerAuth(auth)) {
|
package/cjs/connection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/connection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,kEAAoD;AAEpD,oDAAsC;AACtC,6CAAuD;AACvD,oDAAsC;AACtC,6DAAoD;AAEpD,MAAM,SAAS,GAAG,2BAA2B,CAAC;AAC9C,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AACnD,MAAM,cAAc,GAAG,SAAS,CAAC;AAkCjC;;;;;;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C,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;AAxmBD,gCAwmBC;AACD,YAAY","sourcesContent":["/**\r\n * ```ts\r\n * import type { ArangoApiResponse } from \"arangojs/connection\";\r\n * ```\r\n *\r\n * The \"connection\" module provides connection related types for TypeScript.\r\n *\r\n * @packageDocumentation\r\n */\r\nimport * as administration from \"./administration.js\";\r\nimport * as configuration from \"./configuration.js\";\r\nimport * as databases from \"./databases.js\";\r\nimport * as errors from \"./errors.js\";\r\nimport { ERROR_ARANGO_CONFLICT } from \"./lib/codes.js\";\r\nimport * as util from \"./lib/util.js\";\r\nimport { LinkedList } from \"./lib/x3-linkedlist.js\";\r\n\r\nconst MIME_JSON = /\\/(json|javascript)(\\W|$)/;\r\nconst LEADER_ENDPOINT_HEADER = \"x-arango-endpoint\";\r\nconst REASON_TIMEOUT = \"timeout\";\r\n\r\n//#region Host\r\n/**\r\n * @internal\r\n */\r\ntype Host = {\r\n /**\r\n * @internal\r\n *\r\n * Perform a fetch request against this host.\r\n *\r\n * @param pathname - URL path, relative to the server URL.\r\n * @param options - Options for this fetch request.\r\n */\r\n fetch: (\r\n options: Omit<\r\n RequestOptions,\r\n | \"maxRetries\"\r\n | \"retryOnConflict\"\r\n | \"allowDirtyRead\"\r\n | \"hostUrl\"\r\n | \"expectBinary\"\r\n | \"isBinary\"\r\n >\r\n ) => Promise<globalThis.Response & { request: globalThis.Request }>;\r\n /**\r\n * @internal\r\n *\r\n * Close the pending request, if any.\r\n */\r\n close: () => void;\r\n};\r\n\r\n/**\r\n * @internal\r\n *\r\n * Create a function for performing fetch requests against a given host.\r\n *\r\n * @param arangojsHostUrl - Base URL of the host, i.e. protocol, port and domain name.\r\n * @param options - Options to use for all fetch requests.\r\n */\r\nfunction createHost(arangojsHostUrl: string, agentOptions?: any): Host {\r\n const baseUrl = new URL(arangojsHostUrl);\r\n let fetch = globalThis.fetch;\r\n let createDispatcher: (() => Promise<any>) | undefined;\r\n let dispatcher: any;\r\n let socketPath: string | undefined;\r\n if (arangojsHostUrl.match(/^\\w+:\\/\\/unix:\\//)) {\r\n socketPath = baseUrl.pathname;\r\n baseUrl.hostname = \"localhost\";\r\n baseUrl.pathname = \"/\";\r\n agentOptions = {\r\n ...agentOptions,\r\n connect: {\r\n ...agentOptions?.connect,\r\n socketPath,\r\n },\r\n };\r\n }\r\n if (agentOptions) {\r\n createDispatcher = async () => {\r\n let undici: any;\r\n try {\r\n // Prevent overzealous bundlers from attempting to bundle undici\r\n const undiciName = \"undici\";\r\n undici = await import(undiciName);\r\n } catch (cause) {\r\n if (socketPath) {\r\n throw new Error(\"Undici is required for Unix domain sockets\", {\r\n cause,\r\n });\r\n }\r\n throw new Error(\"Undici is required when using config.agentOptions\", {\r\n cause,\r\n });\r\n }\r\n fetch = undici.fetch;\r\n return new undici.Agent(agentOptions);\r\n };\r\n }\r\n const pending = new Map<string, AbortController>();\r\n return {\r\n async fetch({\r\n method,\r\n pathname,\r\n search,\r\n headers: requestHeaders,\r\n body,\r\n timeout,\r\n fetchOptions,\r\n beforeRequest,\r\n afterResponse,\r\n }: Omit<\r\n RequestOptions,\r\n | \"maxRetries\"\r\n | \"retryOnConflict\"\r\n | \"allowDirtyRead\"\r\n | \"hostUrl\"\r\n | \"expectBinary\"\r\n | \"isBinary\"\r\n >) {\r\n const url = new URL(pathname + baseUrl.search, baseUrl);\r\n if (search) {\r\n const searchParams =\r\n search instanceof URLSearchParams\r\n ? search\r\n : new URLSearchParams(search);\r\n for (const [key, value] of searchParams) {\r\n url.searchParams.append(key, value);\r\n }\r\n }\r\n const headers = new Headers(requestHeaders);\r\n if (!headers.has(\"authorization\")) {\r\n headers.set(\r\n \"authorization\",\r\n `Basic ${btoa(\r\n `${baseUrl.username || \"root\"}:${baseUrl.password || \"\"}`\r\n )}`\r\n );\r\n }\r\n const abortController = new AbortController();\r\n const signal = abortController.signal;\r\n if (createDispatcher) {\r\n dispatcher = await createDispatcher();\r\n createDispatcher = undefined;\r\n }\r\n const request = new Request(url, {\r\n ...fetchOptions,\r\n dispatcher,\r\n method,\r\n headers,\r\n body,\r\n signal,\r\n } as globalThis.RequestInit);\r\n if (beforeRequest) {\r\n const p = beforeRequest(request);\r\n if (p instanceof Promise) await p;\r\n }\r\n const requestId = util.generateRequestId();\r\n pending.set(requestId, abortController);\r\n let clearTimer: (() => void) | undefined;\r\n if (timeout) {\r\n clearTimer = util.createTimer(timeout, () => {\r\n clearTimer = undefined;\r\n abortController.abort(REASON_TIMEOUT);\r\n });\r\n }\r\n let response: globalThis.Response & { request: globalThis.Request };\r\n try {\r\n response = Object.assign(await fetch(request), {\r\n request,\r\n arangojsHostUrl,\r\n });\r\n if (fetchOptions?.redirect === \"manual\" && isRedirect(response)) {\r\n throw new errors.HttpError(response);\r\n }\r\n } catch (e: unknown) {\r\n const cause = e instanceof Error ? e : new Error(String(e));\r\n let error: errors.NetworkError;\r\n if (cause instanceof errors.NetworkError) {\r\n error = cause;\r\n } else if (signal.aborted) {\r\n const reason =\r\n typeof signal.reason == \"string\" ? signal.reason : undefined;\r\n if (reason === REASON_TIMEOUT) {\r\n error = new errors.ResponseTimeoutError(undefined, request, {\r\n cause,\r\n });\r\n } else {\r\n error = new errors.RequestAbortedError(reason, request, { cause });\r\n }\r\n } else if (cause instanceof TypeError) {\r\n error = new errors.FetchFailedError(undefined, request, { cause });\r\n } else {\r\n error = new errors.NetworkError(cause.message, request, { cause });\r\n }\r\n if (afterResponse) {\r\n const p = afterResponse(error);\r\n if (p instanceof Promise) await p;\r\n }\r\n throw error;\r\n } finally {\r\n clearTimer?.();\r\n pending.delete(requestId);\r\n }\r\n if (afterResponse) {\r\n const p = afterResponse(null, response);\r\n if (p instanceof Promise) await p;\r\n }\r\n return response;\r\n },\r\n close() {\r\n if (!pending.size) return;\r\n const controllers = [...pending.values()];\r\n pending.clear();\r\n for (const controller of controllers) {\r\n try {\r\n controller.abort();\r\n } catch (e) {\r\n // noop\r\n }\r\n }\r\n },\r\n };\r\n}\r\n//#endregion\r\n\r\n//#region Response types\r\nconst STATUS_CODE_DEFAULT_MESSAGES = {\r\n 0: \"Network Error\",\r\n 300: \"Multiple Choices\",\r\n 301: \"Moved Permanently\",\r\n 302: \"Found\",\r\n 303: \"See Other\",\r\n 304: \"Not Modified\",\r\n 307: \"Temporary Redirect\",\r\n 308: \"Permanent Redirect\",\r\n 400: \"Bad Request\",\r\n 401: \"Unauthorized\",\r\n 402: \"Payment Required\",\r\n 403: \"Forbidden\",\r\n 404: \"Not Found\",\r\n 405: \"Method Not Allowed\",\r\n 406: \"Not Acceptable\",\r\n 407: \"Proxy Authentication Required\",\r\n 408: \"Request Timeout\",\r\n 409: \"Conflict\",\r\n 410: \"Gone\",\r\n 411: \"Length Required\",\r\n 412: \"Precondition Failed\",\r\n 413: \"Payload Too Large\",\r\n 414: \"Request-URI Too Long\",\r\n 415: \"Unsupported Media Type\",\r\n 416: \"Requested Range Not Satisfiable\",\r\n 417: \"Expectation Failed\",\r\n 418: \"I'm a teapot\",\r\n 421: \"Misdirected Request\",\r\n 422: \"Unprocessable Entity\",\r\n 423: \"Locked\",\r\n 424: \"Failed Dependency\",\r\n 426: \"Upgrade Required\",\r\n 428: \"Precondition Required\",\r\n 429: \"Too Many Requests\",\r\n 431: \"Request Header Fields Too Large\",\r\n 444: \"Connection Closed Without Response\",\r\n 451: \"Unavailable For Legal Reasons\",\r\n 499: \"Client Closed Request\",\r\n 500: \"Internal Server Error\",\r\n 501: \"Not Implemented\",\r\n 502: \"Bad Gateway\",\r\n 503: \"Service Unavailable\",\r\n 504: \"Gateway Timeout\",\r\n 505: \"HTTP Version Not Supported\",\r\n 506: \"Variant Also Negotiates\",\r\n 507: \"Insufficient Storage\",\r\n 508: \"Loop Detected\",\r\n 510: \"Not Extended\",\r\n 511: \"Network Authentication Required\",\r\n 599: \"Network Connect Timeout Error\",\r\n};\r\n\r\ntype KnownStatusCode = keyof typeof STATUS_CODE_DEFAULT_MESSAGES;\r\nconst KNOWN_STATUS_CODES = Object.keys(STATUS_CODE_DEFAULT_MESSAGES).map((k) =>\r\n Number(k)\r\n) as KnownStatusCode[];\r\nconst REDIRECT_CODES = [301, 302, 303, 307, 308] satisfies KnownStatusCode[];\r\ntype RedirectStatusCode = (typeof REDIRECT_CODES)[number];\r\n\r\n/**\r\n * @internal\r\n *\r\n * Indicates whether the given status code can be translated to a known status\r\n * message.\r\n */\r\nfunction isKnownStatusCode(code: number): code is KnownStatusCode {\r\n return KNOWN_STATUS_CODES.includes(code as KnownStatusCode);\r\n}\r\n\r\n/**\r\n * @internal\r\n *\r\n * Indicates whether the given status code represents a redirect.\r\n */\r\nfunction isRedirect(response: ProcessedResponse): boolean {\r\n return REDIRECT_CODES.includes(response.status as RedirectStatusCode);\r\n}\r\n\r\n/**\r\n * Returns the status message for the given response's status code or the\r\n * status text of the response.\r\n */\r\nexport function getStatusMessage(response: ProcessedResponse): string {\r\n if (isKnownStatusCode(response.status)) {\r\n return STATUS_CODE_DEFAULT_MESSAGES[response.status];\r\n }\r\n if (response.statusText) return response.statusText;\r\n return \"Unknown response status\";\r\n}\r\n\r\n/**\r\n * Generic properties shared by all ArangoDB HTTP API responses.\r\n */\r\nexport type ArangoResponseMetadata = {\r\n /**\r\n * Indicates that the request was successful.\r\n */\r\n error: false;\r\n /**\r\n * Response status code, typically `200`.\r\n */\r\n code: number;\r\n};\r\n\r\n/**\r\n * Extends the given base type `T` with the generic HTTP API response properties.\r\n */\r\nexport type ArangoApiResponse<T> = T & ArangoResponseMetadata;\r\n\r\n/**\r\n * Indicates whether the given value represents an ArangoDB error response.\r\n */\r\nexport function isArangoErrorResponse(\r\n body: unknown\r\n): body is ArangoErrorResponse {\r\n if (!body || typeof body !== \"object\") return false;\r\n const obj = body as Record<string, unknown>;\r\n return (\r\n obj.error === true &&\r\n typeof obj.errorMessage === \"string\" &&\r\n typeof obj.errorNum === \"number\" &&\r\n (obj.code === undefined || typeof obj.code === \"number\")\r\n );\r\n}\r\n\r\n/**\r\n * Interface representing an ArangoDB error response.\r\n */\r\nexport type ArangoErrorResponse = {\r\n /**\r\n * Indicates that the request resulted in an error.\r\n */\r\n error: true;\r\n /**\r\n * Intended response status code as provided in the response body.\r\n */\r\n code?: number;\r\n /**\r\n * Error message as provided in the response body.\r\n */\r\n errorMessage: string;\r\n /**\r\n * ArangoDB error code as provided in the response body.\r\n *\r\n * See the [ArangoDB error documentation](https://docs.arangodb.com/stable/develop/error-codes-and-meanings/)\r\n * for more information.\r\n */\r\n errorNum: number;\r\n};\r\n\r\n/**\r\n * Processed response object.\r\n */\r\nexport interface ProcessedResponse<T = any> extends globalThis.Response {\r\n /**\r\n * @internal\r\n *\r\n * Identifier of the ArangoDB host that served this request.\r\n */\r\n arangojsHostUrl?: string;\r\n /**\r\n * Fetch request object.\r\n */\r\n request: globalThis.Request;\r\n /**\r\n * Parsed response body.\r\n */\r\n parsedBody?: T;\r\n}\r\n//#endregion\r\n\r\n//#region Request options\r\n/**\r\n * Options available for requests made with the Fetch API.\r\n */\r\nexport type CommonFetchOptions = {\r\n /**\r\n * Headers object containing any additional headers to send with the request.\r\n *\r\n * Note that the `Authorization` header will be overridden if the `auth`\r\n * configuration option is set.\r\n */\r\n headers?:\r\n | string[][]\r\n | Record<string, string | ReadonlyArray<string>>\r\n | Headers;\r\n /**\r\n * Controls whether the socket should be reused for subsequent requests.\r\n *\r\n * Default: `false`\r\n */\r\n keepalive?: boolean;\r\n /**\r\n * Controls what to do when the response status code is a redirect.\r\n *\r\n * - `\"error\"`: Abort with a network error.\r\n * - `\"follow\"`: Automatically follow redirects.\r\n * - `\"manual\"`: Abort with an `HttpError`.\r\n *\r\n * Default: `\"follow\"`\r\n */\r\n redirect?: \"error\" | \"follow\" | \"manual\";\r\n /**\r\n * Value to use for the `Referer` header.\r\n *\r\n * If set to `\"about:client\"`, the default value for the context in which the\r\n * request is made will be used.\r\n *\r\n * Default: `\"about:client\"`\r\n */\r\n referrer?: string;\r\n /**\r\n * (Browser only.) Controls the Attribution Reporting API specific behavior.\r\n *\r\n * See the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n */\r\n attributionReporting?: any;\r\n /**\r\n * (Browser only.) Cache mode to use for the request.\r\n *\r\n * See [the Fetch API specification](https://fetch.spec.whatwg.org/#request-class)\r\n * or the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n */\r\n cache?: string;\r\n /**\r\n * (Browser only.) Controls sending of credentials and cookies.\r\n *\r\n * - `\"omit\"`: Never send cookies.\r\n * - `\"include\"`: Always send cookies.\r\n * - `\"same-origin\"`: Only send cookies if the request is to the same origin.\r\n *\r\n * Default: `\"same-origin\"`\r\n */\r\n credentials?: \"omit\" | \"include\" | \"same-origin\";\r\n /**\r\n * (Node.js only.) Undici `Dispatcher` instance to use for the request.\r\n *\r\n * Defaults to the global dispatcher.\r\n */\r\n dispatcher?: any;\r\n /**\r\n * (Browser only.) Sets cross-origin behavior for the request.\r\n *\r\n * See [the Fetch API specification](https://fetch.spec.whatwg.org/#request-class)\r\n * or the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n *\r\n * Default: `\"cors\"`\r\n */\r\n mode?: string;\r\n /**\r\n * (Browser only.) Request priority relative to other requests of the same type.\r\n *\r\n * See [the Fetch API specification](https://fetch.spec.whatwg.org/#request-class)\r\n * or the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n *\r\n * Default: `\"auto\"`\r\n */\r\n priority?: \"low\" | \"high\" | \"auto\";\r\n /**\r\n * (Browser only.) Policy to use for the `Referer` header, equivalent to the\r\n * semantics of the `Referrer-Policy` header.\r\n *\r\n * See [the Fetch API specification](https://fetch.spec.whatwg.org/#request-class)\r\n * or the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n */\r\n referrerPolicy?: string;\r\n};\r\n\r\n/**\r\n * Fetch-specific options for performing a request with arangojs.\r\n */\r\nexport type FetchOptions = CommonFetchOptions & {\r\n /**\r\n * Subresource integrity value to use for the request, formatted as\r\n * `<hash-algorithm>-<hash-source>`.\r\n */\r\n integrity?: `${string}-${string}`;\r\n};\r\n\r\n/**\r\n * Options that can be shared globally for all requests made with arangojs.\r\n */\r\nexport type CommonRequestOptions = {\r\n /**\r\n * Determines the behavior when a request fails because the underlying\r\n * connection to the server could not be opened\r\n * (e.g. [`ECONNREFUSED` in Node.js](https://nodejs.org/api/errors.html#errors_common_system_errors)):\r\n *\r\n * - `false`: the request fails immediately.\r\n *\r\n * - `0`: the request is retried until a server can be reached but only a\r\n * total number of times matching the number of known servers (including\r\n * the initial failed request).\r\n *\r\n * - any other number: the request is retried until a server can be reached\r\n * or the request has been retried a total of `maxRetries` number of times\r\n * (not including the initial failed request).\r\n *\r\n * When working with a single server, the retries (if any) will be made to\r\n * the same server.\r\n *\r\n * This setting currently has no effect when using arangojs in a browser.\r\n *\r\n * **Note**: Requests bound to a specific server (e.g. fetching query results)\r\n * will never be retried automatically and ignore this setting.\r\n *\r\n * **Note**: To set the number of retries when a write-write conflict is\r\n * encountered, see `retryOnConflict` instead.\r\n *\r\n * Default: `0`\r\n */\r\n maxRetries?: false | number;\r\n /**\r\n * If set to a positive number, requests will automatically be retried at\r\n * most this many times if they result in a write-write conflict.\r\n *\r\n * Default: `0`\r\n */\r\n retryOnConflict?: number;\r\n /**\r\n * Time in milliseconds after which arangojs will abort the request if the\r\n * socket has not already timed out.\r\n */\r\n timeout?: number;\r\n /**\r\n * Whether ArangoDB is allowed to perform a dirty read to respond to the\r\n * request. If set to `true`, the response may reflect a dirty state from\r\n * a non-authoritative server.\r\n *\r\n * Default: `false`\r\n */\r\n allowDirtyRead?: boolean;\r\n /**\r\n * Callback that will be invoked with the finished request object before it\r\n * is finalized. In the browser the request may already have been sent.\r\n *\r\n * @param req - Request object or XHR instance used for this request.\r\n */\r\n beforeRequest?: (req: globalThis.Request) => void | Promise<void>;\r\n /**\r\n * Callback that will be invoked when the server response has been received\r\n * and processed or when the request has been failed without a response.\r\n *\r\n * The originating request will be available as the `request` property\r\n * on either the error or response object.\r\n *\r\n * @param err - Error encountered when handling this request or `null`.\r\n * @param res - Response object for this request, if no error occurred.\r\n */\r\n afterResponse?: (\r\n err: errors.NetworkError | null,\r\n res?: globalThis.Response & { request: globalThis.Request }\r\n ) => void | Promise<void>;\r\n};\r\n\r\n/**\r\n * Options for performing a request with arangojs.\r\n */\r\nexport type RequestOptions = CommonRequestOptions & {\r\n /**\r\n * @internal\r\n *\r\n * Identifier of a specific ArangoDB host to use when more than one is known.\r\n */\r\n hostUrl?: string;\r\n /**\r\n * HTTP method to use in order to perform the request.\r\n *\r\n * Default: `\"GET\"`\r\n */\r\n method?: string;\r\n /**\r\n * URL path, relative to the server domain.\r\n */\r\n pathname?: string;\r\n /**\r\n * URL parameters to pass as part of the query string.\r\n */\r\n search?: URLSearchParams | Record<string, any>;\r\n /**\r\n * Headers object containing any additional headers to send with the request.\r\n *\r\n * Note that the `Authorization` header will be overridden if the `auth`\r\n * configuration option is set.\r\n */\r\n headers?:\r\n | string[][]\r\n | Record<string, string | ReadonlyArray<string>>\r\n | Headers;\r\n /**\r\n * Request body data.\r\n */\r\n body?: any;\r\n /**\r\n * Additional options to pass to the `fetch` function.\r\n */\r\n fetchOptions?: Omit<FetchOptions, \"headers\">;\r\n /**\r\n * If set to `true`, the request body will not be converted to JSON and\r\n * instead passed as-is.\r\n */\r\n isBinary?: boolean;\r\n /**\r\n * If set to `true`, the response body will not be interpreted as JSON and\r\n * instead passed as-is.\r\n */\r\n expectBinary?: boolean;\r\n};\r\n//#endregion\r\n\r\n//#region Connection class\r\n/**\r\n * @internal\r\n */\r\ntype Task<T = any> = {\r\n stack?: () => string;\r\n resolve: (result: T) => void;\r\n reject: (error: unknown) => void;\r\n transform?: (res: ProcessedResponse<any>) => T;\r\n retries: number;\r\n conflicts: number;\r\n options: RequestOptions;\r\n};\r\n\r\n/**\r\n * Indicates whether the given value represents a {@link Connection}.\r\n *\r\n * @param connection - A value that might be a connection.\r\n *\r\n * @internal\r\n */\r\nexport function isArangoConnection(connection: any): connection is Connection {\r\n return Boolean(connection && connection.isArangoConnection);\r\n}\r\n\r\n/**\r\n * Represents a connection pool shared by one or more databases.\r\n *\r\n * @internal\r\n */\r\nexport class Connection {\r\n protected _activeTasks: number = 0;\r\n protected _arangoVersion: number;\r\n protected _loadBalancingStrategy: configuration.LoadBalancingStrategy;\r\n protected _taskPoolSize: number;\r\n protected _commonRequestOptions: CommonRequestOptions;\r\n protected _commonFetchOptions: CommonFetchOptions & { headers: Headers };\r\n protected _queue = new LinkedList<Task>();\r\n protected _databases = new Map<string, databases.Database>();\r\n protected _hosts: Host[] = [];\r\n protected _hostUrls: string[] = [];\r\n protected _activeHostUrl: string;\r\n protected _activeDirtyHostUrl: string;\r\n protected _transactionId: string | null = null;\r\n protected _onError?: (err: Error) => void | Promise<void>;\r\n protected _precaptureStackTraces: boolean;\r\n protected _queueTimes = new LinkedList<[number, number]>();\r\n protected _responseQueueTimeSamples: number;\r\n protected _agentOptions?: any;\r\n\r\n /**\r\n * @internal\r\n *\r\n * Creates a new `Connection` instance.\r\n *\r\n * @param config - An object with configuration options.\r\n *\r\n */\r\n constructor(config: Omit<configuration.ConfigOptions, \"databaseName\"> = {}) {\r\n const {\r\n url = \"http://127.0.0.1:8529\",\r\n auth,\r\n arangoVersion = 31100,\r\n loadBalancingStrategy = \"NONE\",\r\n maxRetries = 0,\r\n poolSize = 3 *\r\n (loadBalancingStrategy === \"ROUND_ROBIN\" && Array.isArray(url)\r\n ? url.length\r\n : 1),\r\n fetchOptions: { headers, ...commonFetchOptions } = {},\r\n agentOptions,\r\n onError,\r\n precaptureStackTraces = false,\r\n responseQueueTimeSamples = 10,\r\n ...commonRequestOptions\r\n } = config;\r\n const URLS = Array.isArray(url) ? url : [url];\r\n this._loadBalancingStrategy = loadBalancingStrategy;\r\n this._precaptureStackTraces = precaptureStackTraces;\r\n this._responseQueueTimeSamples =\r\n responseQueueTimeSamples < 0 ? Infinity : responseQueueTimeSamples;\r\n this._arangoVersion = arangoVersion;\r\n this._taskPoolSize = poolSize;\r\n this._onError = onError;\r\n this._agentOptions = agentOptions;\r\n\r\n this._commonRequestOptions = commonRequestOptions;\r\n this._commonFetchOptions = {\r\n headers: new Headers(headers),\r\n ...commonFetchOptions,\r\n };\r\n\r\n this._commonFetchOptions.headers.set(\r\n \"x-arango-version\",\r\n String(arangoVersion)\r\n );\r\n this._commonFetchOptions.headers.set(\r\n \"x-arango-driver\",\r\n `arangojs/${process.env.ARANGOJS_VERSION} (cloud)`\r\n );\r\n\r\n this.addToHostList(URLS);\r\n\r\n if (auth) {\r\n if (configuration.isBearerAuth(auth)) {\r\n this.setBearerAuth(auth);\r\n } else {\r\n this.setBasicAuth(auth);\r\n }\r\n }\r\n\r\n if (this._loadBalancingStrategy === \"ONE_RANDOM\") {\r\n this._activeHostUrl =\r\n this._hostUrls[Math.floor(Math.random() * this._hostUrls.length)];\r\n this._activeDirtyHostUrl =\r\n this._hostUrls[Math.floor(Math.random() * this._hostUrls.length)];\r\n } else {\r\n this._activeHostUrl = this._hostUrls[0];\r\n this._activeDirtyHostUrl = this._hostUrls[0];\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Indicates that this object represents an ArangoDB connection.\r\n */\r\n get isArangoConnection(): true {\r\n return true;\r\n }\r\n\r\n get queueTime(): administration.QueueTimeMetrics {\r\n return {\r\n getLatest: () => this._queueTimes.last?.value[1],\r\n getValues: () => Array.from(this._queueTimes.values()),\r\n getAvg: () => {\r\n let avg = 0;\r\n for (const [, [, value]] of this._queueTimes) {\r\n avg += value / this._queueTimes.length;\r\n }\r\n return avg;\r\n },\r\n };\r\n }\r\n\r\n protected async _runQueue() {\r\n if (this._activeTasks >= this._taskPoolSize) return;\r\n const task = this._queue.shift();\r\n if (!task) return;\r\n let hostUrl = this._activeHostUrl;\r\n try {\r\n this._activeTasks += 1;\r\n if (task.options.hostUrl !== undefined) {\r\n hostUrl = task.options.hostUrl;\r\n } else if (task.options.allowDirtyRead) {\r\n hostUrl = this._activeDirtyHostUrl;\r\n const i = this._hostUrls.indexOf(this._activeDirtyHostUrl) + 1;\r\n this._activeDirtyHostUrl = this._hostUrls[i % this._hostUrls.length];\r\n } else if (this._loadBalancingStrategy === \"ROUND_ROBIN\") {\r\n const i = this._hostUrls.indexOf(this._activeHostUrl) + 1;\r\n this._activeHostUrl = this._hostUrls[i % this._hostUrls.length];\r\n }\r\n const host = this._hosts[this._hostUrls.indexOf(hostUrl)];\r\n const res: globalThis.Response & {\r\n request: globalThis.Request;\r\n arangojsHostUrl: string;\r\n parsedBody?: any;\r\n } = Object.assign(await host.fetch(task.options), {\r\n arangojsHostUrl: hostUrl,\r\n });\r\n const leaderEndpoint = res.headers.get(LEADER_ENDPOINT_HEADER);\r\n if (res.status === 503 && leaderEndpoint) {\r\n const [cleanUrl] = this.addToHostList(leaderEndpoint);\r\n task.options.hostUrl = cleanUrl;\r\n if (this._activeHostUrl === hostUrl) {\r\n this._activeHostUrl = cleanUrl;\r\n }\r\n this._queue.push(task);\r\n return;\r\n }\r\n const queueTime = res.headers.get(\"x-arango-queue-time-seconds\");\r\n if (queueTime) {\r\n this._queueTimes.push([Date.now(), Number(queueTime)]);\r\n while (this._responseQueueTimeSamples < this._queueTimes.length) {\r\n this._queueTimes.shift();\r\n }\r\n }\r\n const contentType = res.headers.get(\"content-type\");\r\n if (res.status >= 400) {\r\n if (contentType?.match(MIME_JSON)) {\r\n const errorResponse = res.clone();\r\n let errorBody: any;\r\n try {\r\n errorBody = await errorResponse.json();\r\n } catch {\r\n // noop\r\n }\r\n if (isArangoErrorResponse(errorBody)) {\r\n res.parsedBody = errorBody;\r\n throw errors.ArangoError.from(res);\r\n }\r\n }\r\n throw new errors.HttpError(res);\r\n }\r\n // Per RFC 7231, HEAD responses must not include a body \r\n // Skip body parsing for non-error HEAD responses to ensure cross-runtime compatibility\r\n if (res.body && task.options.method !== \"HEAD\") {\r\n if (task.options.expectBinary) {\r\n res.parsedBody = await res.blob();\r\n } else if (contentType?.match(MIME_JSON)) {\r\n res.parsedBody = await res.json();\r\n } else {\r\n res.parsedBody = await res.text();\r\n }\r\n }\r\n let result: any = res;\r\n if (task.transform) result = task.transform(res);\r\n task.resolve(result);\r\n } catch (e: unknown) {\r\n const err = e as Error;\r\n if (\r\n !task.options.allowDirtyRead &&\r\n this._hosts.length > 1 &&\r\n this._activeHostUrl === hostUrl &&\r\n this._loadBalancingStrategy !== \"ROUND_ROBIN\"\r\n ) {\r\n const i = this._hostUrls.indexOf(this._activeHostUrl) + 1;\r\n this._activeHostUrl = this._hostUrls[i % this._hostUrls.length];\r\n }\r\n if (\r\n errors.isArangoError(err) &&\r\n err.errorNum === ERROR_ARANGO_CONFLICT &&\r\n task.options.retryOnConflict &&\r\n task.conflicts < task.options.retryOnConflict\r\n ) {\r\n task.conflicts += 1;\r\n this._queue.push(task);\r\n return;\r\n }\r\n if (\r\n (errors.isNetworkError(err) || errors.isArangoError(err)) &&\r\n err.isSafeToRetry &&\r\n task.options.hostUrl === undefined &&\r\n this._commonRequestOptions.maxRetries !== false &&\r\n task.retries <\r\n (this._commonRequestOptions.maxRetries || this._hosts.length - 1)\r\n ) {\r\n task.retries += 1;\r\n this._queue.push(task);\r\n return;\r\n }\r\n if (task.stack) {\r\n err.stack += task.stack();\r\n }\r\n if (this._onError) {\r\n try {\r\n const p = this._onError(err);\r\n if (p instanceof Promise) await p;\r\n } catch (e) {\r\n (e as Error).cause = err;\r\n task.reject(e);\r\n return;\r\n }\r\n }\r\n task.reject(err);\r\n } finally {\r\n this._activeTasks -= 1;\r\n setTimeout(() => this._runQueue(), 0);\r\n }\r\n }\r\n\r\n setBearerAuth(auth: configuration.BearerAuthCredentials) {\r\n this.setHeader(\"authorization\", `Bearer ${auth.token}`);\r\n }\r\n\r\n setBasicAuth(auth: configuration.BasicAuthCredentials) {\r\n this.setHeader(\r\n \"authorization\",\r\n `Basic ${btoa(`${auth.username}:${auth.password}`)}`\r\n );\r\n }\r\n\r\n setResponseQueueTimeSamples(responseQueueTimeSamples: number) {\r\n if (responseQueueTimeSamples < 0) {\r\n responseQueueTimeSamples = Infinity;\r\n }\r\n this._responseQueueTimeSamples = responseQueueTimeSamples;\r\n while (this._responseQueueTimeSamples < this._queueTimes.length) {\r\n this._queueTimes.shift();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Fetches a {@link databases.Database} instance for the given database name from the\r\n * internal cache, if available.\r\n *\r\n * @param databaseName - Name of the database.\r\n */\r\n database(databaseName: string): databases.Database | undefined;\r\n /**\r\n * @internal\r\n *\r\n * Adds a {@link databases.Database} instance for the given database name to the\r\n * internal cache.\r\n *\r\n * @param databaseName - Name of the database.\r\n * @param database - Database instance to add to the cache.\r\n */\r\n database(\r\n databaseName: string,\r\n database: databases.Database\r\n ): databases.Database;\r\n /**\r\n * @internal\r\n *\r\n * Clears any {@link databases.Database} instance stored for the given database name\r\n * from the internal cache, if present.\r\n *\r\n * @param databaseName - Name of the database.\r\n * @param database - Must be `null`.\r\n */\r\n database(databaseName: string, database: null): undefined;\r\n database(\r\n databaseName: string,\r\n database?: databases.Database | null\r\n ): databases.Database | undefined {\r\n if (database === null) {\r\n this._databases.delete(databaseName);\r\n return undefined;\r\n }\r\n if (!database) {\r\n return this._databases.get(databaseName);\r\n }\r\n this._databases.set(databaseName, database);\r\n return database;\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Replaces the host list with the given URLs.\r\n *\r\n * See {@link Connection#acquireHostList}.\r\n *\r\n * @param urls - URLs to use as host list.\r\n */\r\n setHostList(urls: string[]): void {\r\n const cleanUrls = urls.map((url) => util.normalizeUrl(url));\r\n this._hosts.splice(\r\n 0,\r\n this._hosts.length,\r\n ...cleanUrls.map((url) => {\r\n const i = this._hostUrls.indexOf(url);\r\n if (i !== -1) return this._hosts[i];\r\n return createHost(url, this._agentOptions);\r\n })\r\n );\r\n this._hostUrls.splice(0, this._hostUrls.length, ...cleanUrls);\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Adds the given URL or URLs to the host list.\r\n *\r\n * See {@link Connection#acquireHostList}.\r\n *\r\n * @param urls - URL or URLs to add.\r\n */\r\n addToHostList(urls: string | string[]): string[] {\r\n const cleanUrls = (Array.isArray(urls) ? urls : [urls]).map((url) =>\r\n util.normalizeUrl(url)\r\n );\r\n const newUrls = cleanUrls.filter(\r\n (url) => this._hostUrls.indexOf(url) === -1\r\n );\r\n this._hostUrls.push(...newUrls);\r\n this._hosts.push(...newUrls.map((url) => createHost(url, this._agentOptions)));\r\n return cleanUrls;\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Sets the connection's active `transactionId`.\r\n *\r\n * While set, all requests will use this ID, ensuring the requests are executed\r\n * within the transaction if possible. Setting the ID manually may cause\r\n * unexpected behavior.\r\n *\r\n * See also {@link Connection#clearTransactionId}.\r\n *\r\n * @param transactionId - ID of the active transaction.\r\n */\r\n setTransactionId(transactionId: string) {\r\n this._transactionId = transactionId;\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Clears the connection's active `transactionId`.\r\n */\r\n clearTransactionId() {\r\n this._transactionId = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Sets the header `headerName` with the given `value` or clears the header if\r\n * `value` is `null`.\r\n *\r\n * @param headerName - Name of the header to set.\r\n * @param value - Value of the header.\r\n */\r\n setHeader(headerName: string, value: string | null) {\r\n if (value === null) {\r\n this._commonFetchOptions.headers.delete(headerName);\r\n } else {\r\n this._commonFetchOptions.headers.set(headerName, value);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Closes all open connections.\r\n *\r\n * See {@link databases.Database#close}.\r\n */\r\n close() {\r\n for (const host of this._hosts) {\r\n if (host.close) host.close();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Waits for propagation.\r\n *\r\n * See {@link databases.Database#waitForPropagation}.\r\n *\r\n * @param request - Request to perform against each coordinator.\r\n * @param timeout - Maximum number of milliseconds to wait for propagation.\r\n */\r\n async waitForPropagation(request: RequestOptions, timeout = Infinity) {\r\n const numHosts = this._hosts.length;\r\n const propagated = [] as string[];\r\n const started = Date.now();\r\n const endOfTime = started + timeout;\r\n let index = 0;\r\n while (true) {\r\n if (propagated.length === numHosts) {\r\n return;\r\n }\r\n while (propagated.includes(this._hostUrls[index])) {\r\n index = (index + 1) % numHosts;\r\n }\r\n const hostUrl = this._hostUrls[index];\r\n try {\r\n await this.request({\r\n ...request,\r\n hostUrl,\r\n timeout: endOfTime - Date.now(),\r\n });\r\n } catch (e) {\r\n if (endOfTime < Date.now()) {\r\n throw new errors.PropagationTimeoutError(undefined, {\r\n cause: e as Error,\r\n });\r\n }\r\n await new Promise((resolve) => setTimeout(resolve, 1000));\r\n continue;\r\n }\r\n if (!propagated.includes(hostUrl)) {\r\n propagated.push(hostUrl);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Performs a request using the arangojs connection pool.\r\n */\r\n async request<\r\n T = globalThis.Response & { request: globalThis.Request; parsedBody?: any },\r\n >(\r\n requestOptions: RequestOptions & { isBinary?: boolean },\r\n transform?: (\r\n res: globalThis.Response & {\r\n request: globalThis.Request;\r\n parsedBody?: any;\r\n }\r\n ) => T\r\n ): Promise<T> {\r\n const {\r\n hostUrl,\r\n allowDirtyRead = false,\r\n isBinary = false,\r\n maxRetries = 0,\r\n method = \"GET\",\r\n retryOnConflict = 0,\r\n timeout = 0,\r\n headers: requestHeaders,\r\n body: requestBody,\r\n fetchOptions,\r\n ...taskOptions\r\n } = { ...this._commonRequestOptions, ...requestOptions };\r\n\r\n const headers = util.mergeHeaders(\r\n this._commonFetchOptions.headers,\r\n requestHeaders\r\n );\r\n\r\n let body = requestBody;\r\n if (body instanceof FormData) {\r\n const res = new Response(body);\r\n const blob = await res.blob();\r\n // Workaround for ArangoDB 3.12.0-rc1 and earlier:\r\n // Omitting the final CRLF results in \"bad request body\" fatal error\r\n body = new Blob([blob, \"\\r\\n\"], { type: blob.type });\r\n // Set content-length for Blob (needed for Next.js dynamic routes)\r\n if (!headers.has(\"content-length\")) {\r\n headers.set(\"content-length\", String(body.size));\r\n }\r\n } else if (body !== null && body !== undefined) {\r\n // Handle empty string explicitly\r\n if (body === \"\") {\r\n if (!headers.has(\"content-length\")) {\r\n headers.set(\"content-length\", \"0\");\r\n }\r\n if (!headers.has(\"content-type\")) {\r\n headers.set(\"content-type\", \"text/plain\");\r\n }\r\n } else {\r\n let contentType;\r\n if (isBinary) {\r\n contentType = \"application/octet-stream\";\r\n } else if (typeof body === \"object\") {\r\n body = JSON.stringify(body);\r\n contentType = \"application/json\";\r\n } else {\r\n body = String(body);\r\n contentType = \"text/plain\";\r\n }\r\n if (!headers.has(\"content-type\")) {\r\n headers.set(\"content-type\", contentType);\r\n }\r\n // Explicitly set content-length for fixed-size bodies\r\n // This is needed for Next.js dynamic routes (e.g., when using cookies())\r\n // and ensures compatibility with environments that don't set it automatically\r\n if (!headers.has(\"content-length\")) {\r\n if (typeof body === \"string\") {\r\n // Calculate byte length for UTF-8 encoded strings\r\n // Buffer is available in Node.js (required: >=20) and browser polyfills\r\n if (\r\n typeof globalThis.Buffer !== \"undefined\" &&\r\n globalThis.Buffer.byteLength\r\n ) {\r\n const contentLength = globalThis.Buffer.byteLength(body, \"utf8\");\r\n headers.set(\"content-length\", String(contentLength));\r\n } else {\r\n // Fallback: use TextEncoder for browser environments\r\n const encoder = new TextEncoder();\r\n const contentLength = encoder.encode(body).length;\r\n headers.set(\"content-length\", String(contentLength));\r\n }\r\n } else if (body instanceof Blob) {\r\n headers.set(\"content-length\", String(body.size));\r\n } else if (\r\n typeof globalThis.Buffer !== \"undefined\" &&\r\n globalThis.Buffer.isBuffer &&\r\n globalThis.Buffer.isBuffer(body)\r\n ) {\r\n headers.set(\"content-length\", String(body.length));\r\n }\r\n // Note: ArangoDB does not support Transfer-Encoding: chunked.\r\n // All public APIs only accept fixed-size bodies (string, Buffer, Blob, FormData, or objects that get JSON.stringify'd),\r\n // so streams should never reach this point. If an unknown body type is passed, it will be converted to string above.\r\n }\r\n }\r\n }\r\n // Handle null/undefined body for POST/PUT/PATCH methods that might need content-length: 0\r\n // This ensures compatibility with NextJS 15 and other environments that expect explicit content-length\r\n else if (\r\n (method === \"POST\" || method === \"PUT\" || method === \"PATCH\") &&\r\n !headers.has(\"content-length\")\r\n ) {\r\n headers.set(\"content-length\", \"0\");\r\n }\r\n\r\n if (this._transactionId) {\r\n headers.set(\"x-arango-trx-id\", this._transactionId);\r\n }\r\n\r\n if (allowDirtyRead) {\r\n headers.set(\"x-arango-allow-dirty-read\", \"true\");\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n const task: Task = {\r\n resolve,\r\n reject,\r\n transform,\r\n retries: 0,\r\n conflicts: 0,\r\n options: {\r\n ...taskOptions,\r\n hostUrl,\r\n method,\r\n headers,\r\n body,\r\n allowDirtyRead,\r\n retryOnConflict,\r\n maxRetries,\r\n fetchOptions,\r\n timeout,\r\n },\r\n };\r\n\r\n if (this._precaptureStackTraces) {\r\n if (typeof Error.captureStackTrace === \"function\") {\r\n const capture = {} as { readonly stack: string };\r\n Error.captureStackTrace(capture);\r\n task.stack = () =>\r\n `\\n${capture.stack.split(\"\\n\").slice(3).join(\"\\n\")}`;\r\n } else {\r\n const capture = util.generateStackTrace() as {\r\n readonly stack: string;\r\n };\r\n if (Object.prototype.hasOwnProperty.call(capture, \"stack\")) {\r\n task.stack = () =>\r\n `\\n${capture.stack.split(\"\\n\").slice(4).join(\"\\n\")}`;\r\n }\r\n }\r\n }\r\n\r\n this._queue.push(task);\r\n this._runQueue();\r\n });\r\n }\r\n}\r\n//#endregion\r\n"]}
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/connection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,kEAAoD;AAEpD,oDAAsC;AACtC,6CAAuD;AACvD,oDAAsC;AACtC,6DAAoD;AAEpD,MAAM,SAAS,GAAG,2BAA2B,CAAC;AAC9C,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AACnD,MAAM,cAAc,GAAG,SAAS,CAAC;AAkCjC;;;;;;;GAOG;AACH,SAAS,UAAU,CAAC,eAAuB,EAAE,YAAkB;IAC7D,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC;IACzC,IAAI,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAC7B,IAAI,gBAAkD,CAAC;IACvD,IAAI,UAAe,CAAC;IACpB,IAAI,UAA8B,CAAC;IACnC,IAAI,eAAe,CAAC,KAAK,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC9C,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC;QAC9B,OAAO,CAAC,QAAQ,GAAG,WAAW,CAAC;QAC/B,OAAO,CAAC,QAAQ,GAAG,GAAG,CAAC;QACvB,YAAY,GAAG;YACb,GAAG,YAAY;YACf,OAAO,EAAE;gBACP,GAAG,YAAY,EAAE,OAAO;gBACxB,UAAU;aACX;SACF,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;IACjC,IAAI,YAAY,EAAE,CAAC;QACjB,gBAAgB,GAAG,KAAK,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SAAS,EAAE,CAAC;gBACZ,OAAO,EAAE;oBACP,GAAG,WAAW;oBACd,OAAO;oBACP,MAAM;oBACN,OAAO;oBACP,IAAI;oBACJ,cAAc;oBACd,eAAe;oBACf,UAAU;oBACV,YAAY;oBACZ,OAAO;iBACR;aACF,CAAC;YAEF,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;gBAChC,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,IAAI,CAAC,kBAAkB,EAEtC,CAAC;oBACF,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;AAxmBD,gCAwmBC;AACD,YAAY","sourcesContent":["/**\r\n * ```ts\r\n * import type { ArangoApiResponse } from \"arangojs/connection\";\r\n * ```\r\n *\r\n * The \"connection\" module provides connection related types for TypeScript.\r\n *\r\n * @packageDocumentation\r\n */\r\nimport * as administration from \"./administration.js\";\r\nimport * as configuration from \"./configuration.js\";\r\nimport * as databases from \"./databases.js\";\r\nimport * as errors from \"./errors.js\";\r\nimport { ERROR_ARANGO_CONFLICT } from \"./lib/codes.js\";\r\nimport * as util from \"./lib/util.js\";\r\nimport { LinkedList } from \"./lib/x3-linkedlist.js\";\r\n\r\nconst MIME_JSON = /\\/(json|javascript)(\\W|$)/;\r\nconst LEADER_ENDPOINT_HEADER = \"x-arango-endpoint\";\r\nconst REASON_TIMEOUT = \"timeout\";\r\n\r\n//#region Host\r\n/**\r\n * @internal\r\n */\r\ntype Host = {\r\n /**\r\n * @internal\r\n *\r\n * Perform a fetch request against this host.\r\n *\r\n * @param pathname - URL path, relative to the server URL.\r\n * @param options - Options for this fetch request.\r\n */\r\n fetch: (\r\n options: Omit<\r\n RequestOptions,\r\n | \"maxRetries\"\r\n | \"retryOnConflict\"\r\n | \"allowDirtyRead\"\r\n | \"hostUrl\"\r\n | \"expectBinary\"\r\n | \"isBinary\"\r\n >\r\n ) => Promise<globalThis.Response & { request: globalThis.Request }>;\r\n /**\r\n * @internal\r\n *\r\n * Close the pending request, if any.\r\n */\r\n close: () => void;\r\n};\r\n\r\n/**\r\n * @internal\r\n *\r\n * Create a function for performing fetch requests against a given host.\r\n *\r\n * @param arangojsHostUrl - Base URL of the host, i.e. protocol, port and domain name.\r\n * @param options - Options to use for all fetch requests.\r\n */\r\nfunction createHost(arangojsHostUrl: string, agentOptions?: any): Host {\r\n const baseUrl = new URL(arangojsHostUrl);\r\n let fetch = globalThis.fetch;\r\n let createDispatcher: (() => Promise<any>) | undefined;\r\n let dispatcher: any;\r\n let socketPath: string | undefined;\r\n if (arangojsHostUrl.match(/^\\w+:\\/\\/unix:\\//)) {\r\n socketPath = baseUrl.pathname;\r\n baseUrl.hostname = \"localhost\";\r\n baseUrl.pathname = \"/\";\r\n agentOptions = {\r\n ...agentOptions,\r\n connect: {\r\n ...agentOptions?.connect,\r\n socketPath,\r\n },\r\n };\r\n }\r\n let Request = globalThis.Request;\r\n if (agentOptions) {\r\n createDispatcher = async () => {\r\n let undici: any;\r\n try {\r\n // Prevent overzealous bundlers from attempting to bundle undici\r\n const undiciName = \"undici\";\r\n undici = await import(undiciName);\r\n } catch (cause) {\r\n if (socketPath) {\r\n throw new Error(\"Undici is required for Unix domain sockets\", {\r\n cause,\r\n });\r\n }\r\n throw new Error(\"Undici is required when using config.agentOptions\", {\r\n cause,\r\n });\r\n }\r\n fetch = undici.fetch;\r\n Request = undici.Request;\r\n return new undici.Agent(agentOptions);\r\n };\r\n }\r\n const pending = new Map<string, AbortController>();\r\n return {\r\n async fetch({\r\n method,\r\n pathname,\r\n search,\r\n headers: requestHeaders,\r\n body,\r\n timeout,\r\n fetchOptions,\r\n beforeRequest,\r\n afterResponse,\r\n }: Omit<\r\n RequestOptions,\r\n | \"maxRetries\"\r\n | \"retryOnConflict\"\r\n | \"allowDirtyRead\"\r\n | \"hostUrl\"\r\n | \"expectBinary\"\r\n | \"isBinary\"\r\n >) {\r\n const url = new URL(pathname + baseUrl.search, baseUrl);\r\n if (search) {\r\n const searchParams =\r\n search instanceof URLSearchParams\r\n ? search\r\n : new URLSearchParams(search);\r\n for (const [key, value] of searchParams) {\r\n url.searchParams.append(key, value);\r\n }\r\n }\r\n const headers = new Headers(requestHeaders);\r\n if (!headers.has(\"authorization\")) {\r\n headers.set(\r\n \"authorization\",\r\n `Basic ${btoa(\r\n `${baseUrl.username || \"root\"}:${baseUrl.password || \"\"}`\r\n )}`\r\n );\r\n }\r\n const abortController = new AbortController();\r\n const signal = abortController.signal;\r\n if (createDispatcher) {\r\n dispatcher = await createDispatcher();\r\n createDispatcher = undefined;\r\n }\r\n const request = new Request(url, {\r\n ...fetchOptions,\r\n dispatcher,\r\n method,\r\n headers,\r\n body,\r\n signal,\r\n } as globalThis.RequestInit);\r\n if (beforeRequest) {\r\n const p = beforeRequest(request);\r\n if (p instanceof Promise) await p;\r\n }\r\n const requestId = util.generateRequestId();\r\n pending.set(requestId, abortController);\r\n let clearTimer: (() => void) | undefined;\r\n if (timeout) {\r\n clearTimer = util.createTimer(timeout, () => {\r\n clearTimer = undefined;\r\n abortController.abort(REASON_TIMEOUT);\r\n });\r\n }\r\n let response: globalThis.Response & { request: globalThis.Request };\r\n try {\r\n response = Object.assign(await fetch(request), {\r\n request,\r\n arangojsHostUrl,\r\n });\r\n if (fetchOptions?.redirect === \"manual\" && isRedirect(response)) {\r\n throw new errors.HttpError(response);\r\n }\r\n } catch (e: unknown) {\r\n const cause = e instanceof Error ? e : new Error(String(e));\r\n let error: errors.NetworkError;\r\n if (cause instanceof errors.NetworkError) {\r\n error = cause;\r\n } else if (signal.aborted) {\r\n const reason =\r\n typeof signal.reason == \"string\" ? signal.reason : undefined;\r\n if (reason === REASON_TIMEOUT) {\r\n error = new errors.ResponseTimeoutError(undefined, request, {\r\n cause,\r\n });\r\n } else {\r\n error = new errors.RequestAbortedError(reason, request, { cause });\r\n }\r\n } else if (cause instanceof TypeError) {\r\n error = new errors.FetchFailedError(undefined, request, { cause });\r\n } else {\r\n error = new errors.NetworkError(cause.message, request, { cause });\r\n }\r\n if (afterResponse) {\r\n const p = afterResponse(error);\r\n if (p instanceof Promise) await p;\r\n }\r\n throw error;\r\n } finally {\r\n clearTimer?.();\r\n pending.delete(requestId);\r\n }\r\n if (afterResponse) {\r\n const p = afterResponse(null, response);\r\n if (p instanceof Promise) await p;\r\n }\r\n return response;\r\n },\r\n close() {\r\n if (!pending.size) return;\r\n const controllers = [...pending.values()];\r\n pending.clear();\r\n for (const controller of controllers) {\r\n try {\r\n controller.abort();\r\n } catch (e) {\r\n // noop\r\n }\r\n }\r\n },\r\n };\r\n}\r\n//#endregion\r\n\r\n//#region Response types\r\nconst STATUS_CODE_DEFAULT_MESSAGES = {\r\n 0: \"Network Error\",\r\n 300: \"Multiple Choices\",\r\n 301: \"Moved Permanently\",\r\n 302: \"Found\",\r\n 303: \"See Other\",\r\n 304: \"Not Modified\",\r\n 307: \"Temporary Redirect\",\r\n 308: \"Permanent Redirect\",\r\n 400: \"Bad Request\",\r\n 401: \"Unauthorized\",\r\n 402: \"Payment Required\",\r\n 403: \"Forbidden\",\r\n 404: \"Not Found\",\r\n 405: \"Method Not Allowed\",\r\n 406: \"Not Acceptable\",\r\n 407: \"Proxy Authentication Required\",\r\n 408: \"Request Timeout\",\r\n 409: \"Conflict\",\r\n 410: \"Gone\",\r\n 411: \"Length Required\",\r\n 412: \"Precondition Failed\",\r\n 413: \"Payload Too Large\",\r\n 414: \"Request-URI Too Long\",\r\n 415: \"Unsupported Media Type\",\r\n 416: \"Requested Range Not Satisfiable\",\r\n 417: \"Expectation Failed\",\r\n 418: \"I'm a teapot\",\r\n 421: \"Misdirected Request\",\r\n 422: \"Unprocessable Entity\",\r\n 423: \"Locked\",\r\n 424: \"Failed Dependency\",\r\n 426: \"Upgrade Required\",\r\n 428: \"Precondition Required\",\r\n 429: \"Too Many Requests\",\r\n 431: \"Request Header Fields Too Large\",\r\n 444: \"Connection Closed Without Response\",\r\n 451: \"Unavailable For Legal Reasons\",\r\n 499: \"Client Closed Request\",\r\n 500: \"Internal Server Error\",\r\n 501: \"Not Implemented\",\r\n 502: \"Bad Gateway\",\r\n 503: \"Service Unavailable\",\r\n 504: \"Gateway Timeout\",\r\n 505: \"HTTP Version Not Supported\",\r\n 506: \"Variant Also Negotiates\",\r\n 507: \"Insufficient Storage\",\r\n 508: \"Loop Detected\",\r\n 510: \"Not Extended\",\r\n 511: \"Network Authentication Required\",\r\n 599: \"Network Connect Timeout Error\",\r\n};\r\n\r\ntype KnownStatusCode = keyof typeof STATUS_CODE_DEFAULT_MESSAGES;\r\nconst KNOWN_STATUS_CODES = Object.keys(STATUS_CODE_DEFAULT_MESSAGES).map((k) =>\r\n Number(k)\r\n) as KnownStatusCode[];\r\nconst REDIRECT_CODES = [301, 302, 303, 307, 308] satisfies KnownStatusCode[];\r\ntype RedirectStatusCode = (typeof REDIRECT_CODES)[number];\r\n\r\n/**\r\n * @internal\r\n *\r\n * Indicates whether the given status code can be translated to a known status\r\n * message.\r\n */\r\nfunction isKnownStatusCode(code: number): code is KnownStatusCode {\r\n return KNOWN_STATUS_CODES.includes(code as KnownStatusCode);\r\n}\r\n\r\n/**\r\n * @internal\r\n *\r\n * Indicates whether the given status code represents a redirect.\r\n */\r\nfunction isRedirect(response: ProcessedResponse): boolean {\r\n return REDIRECT_CODES.includes(response.status as RedirectStatusCode);\r\n}\r\n\r\n/**\r\n * Returns the status message for the given response's status code or the\r\n * status text of the response.\r\n */\r\nexport function getStatusMessage(response: ProcessedResponse): string {\r\n if (isKnownStatusCode(response.status)) {\r\n return STATUS_CODE_DEFAULT_MESSAGES[response.status];\r\n }\r\n if (response.statusText) return response.statusText;\r\n return \"Unknown response status\";\r\n}\r\n\r\n/**\r\n * Generic properties shared by all ArangoDB HTTP API responses.\r\n */\r\nexport type ArangoResponseMetadata = {\r\n /**\r\n * Indicates that the request was successful.\r\n */\r\n error: false;\r\n /**\r\n * Response status code, typically `200`.\r\n */\r\n code: number;\r\n};\r\n\r\n/**\r\n * Extends the given base type `T` with the generic HTTP API response properties.\r\n */\r\nexport type ArangoApiResponse<T> = T & ArangoResponseMetadata;\r\n\r\n/**\r\n * Indicates whether the given value represents an ArangoDB error response.\r\n */\r\nexport function isArangoErrorResponse(\r\n body: unknown\r\n): body is ArangoErrorResponse {\r\n if (!body || typeof body !== \"object\") return false;\r\n const obj = body as Record<string, unknown>;\r\n return (\r\n obj.error === true &&\r\n typeof obj.errorMessage === \"string\" &&\r\n typeof obj.errorNum === \"number\" &&\r\n (obj.code === undefined || typeof obj.code === \"number\")\r\n );\r\n}\r\n\r\n/**\r\n * Interface representing an ArangoDB error response.\r\n */\r\nexport type ArangoErrorResponse = {\r\n /**\r\n * Indicates that the request resulted in an error.\r\n */\r\n error: true;\r\n /**\r\n * Intended response status code as provided in the response body.\r\n */\r\n code?: number;\r\n /**\r\n * Error message as provided in the response body.\r\n */\r\n errorMessage: string;\r\n /**\r\n * ArangoDB error code as provided in the response body.\r\n *\r\n * See the [ArangoDB error documentation](https://docs.arangodb.com/stable/develop/error-codes-and-meanings/)\r\n * for more information.\r\n */\r\n errorNum: number;\r\n};\r\n\r\n/**\r\n * Processed response object.\r\n */\r\nexport interface ProcessedResponse<T = any> extends globalThis.Response {\r\n /**\r\n * @internal\r\n *\r\n * Identifier of the ArangoDB host that served this request.\r\n */\r\n arangojsHostUrl?: string;\r\n /**\r\n * Fetch request object.\r\n */\r\n request: globalThis.Request;\r\n /**\r\n * Parsed response body.\r\n */\r\n parsedBody?: T;\r\n}\r\n//#endregion\r\n\r\n//#region Request options\r\n/**\r\n * Options available for requests made with the Fetch API.\r\n */\r\nexport type CommonFetchOptions = {\r\n /**\r\n * Headers object containing any additional headers to send with the request.\r\n *\r\n * Note that the `Authorization` header will be overridden if the `auth`\r\n * configuration option is set.\r\n */\r\n headers?:\r\n | string[][]\r\n | Record<string, string | ReadonlyArray<string>>\r\n | Headers;\r\n /**\r\n * Controls whether the socket should be reused for subsequent requests.\r\n *\r\n * Default: `false`\r\n */\r\n keepalive?: boolean;\r\n /**\r\n * Controls what to do when the response status code is a redirect.\r\n *\r\n * - `\"error\"`: Abort with a network error.\r\n * - `\"follow\"`: Automatically follow redirects.\r\n * - `\"manual\"`: Abort with an `HttpError`.\r\n *\r\n * Default: `\"follow\"`\r\n */\r\n redirect?: \"error\" | \"follow\" | \"manual\";\r\n /**\r\n * Value to use for the `Referer` header.\r\n *\r\n * If set to `\"about:client\"`, the default value for the context in which the\r\n * request is made will be used.\r\n *\r\n * Default: `\"about:client\"`\r\n */\r\n referrer?: string;\r\n /**\r\n * (Browser only.) Controls the Attribution Reporting API specific behavior.\r\n *\r\n * See the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n */\r\n attributionReporting?: any;\r\n /**\r\n * (Browser only.) Cache mode to use for the request.\r\n *\r\n * See [the Fetch API specification](https://fetch.spec.whatwg.org/#request-class)\r\n * or the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n */\r\n cache?: string;\r\n /**\r\n * (Browser only.) Controls sending of credentials and cookies.\r\n *\r\n * - `\"omit\"`: Never send cookies.\r\n * - `\"include\"`: Always send cookies.\r\n * - `\"same-origin\"`: Only send cookies if the request is to the same origin.\r\n *\r\n * Default: `\"same-origin\"`\r\n */\r\n credentials?: \"omit\" | \"include\" | \"same-origin\";\r\n /**\r\n * (Node.js only.) Undici `Dispatcher` instance to use for the request.\r\n *\r\n * Defaults to the global dispatcher.\r\n */\r\n dispatcher?: any;\r\n /**\r\n * (Browser only.) Sets cross-origin behavior for the request.\r\n *\r\n * See [the Fetch API specification](https://fetch.spec.whatwg.org/#request-class)\r\n * or the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n *\r\n * Default: `\"cors\"`\r\n */\r\n mode?: string;\r\n /**\r\n * (Browser only.) Request priority relative to other requests of the same type.\r\n *\r\n * See [the Fetch API specification](https://fetch.spec.whatwg.org/#request-class)\r\n * or the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n *\r\n * Default: `\"auto\"`\r\n */\r\n priority?: \"low\" | \"high\" | \"auto\";\r\n /**\r\n * (Browser only.) Policy to use for the `Referer` header, equivalent to the\r\n * semantics of the `Referrer-Policy` header.\r\n *\r\n * See [the Fetch API specification](https://fetch.spec.whatwg.org/#request-class)\r\n * or the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n */\r\n referrerPolicy?: string;\r\n};\r\n\r\n/**\r\n * Fetch-specific options for performing a request with arangojs.\r\n */\r\nexport type FetchOptions = CommonFetchOptions & {\r\n /**\r\n * Subresource integrity value to use for the request, formatted as\r\n * `<hash-algorithm>-<hash-source>`.\r\n */\r\n integrity?: `${string}-${string}`;\r\n};\r\n\r\n/**\r\n * Options that can be shared globally for all requests made with arangojs.\r\n */\r\nexport type CommonRequestOptions = {\r\n /**\r\n * Determines the behavior when a request fails because the underlying\r\n * connection to the server could not be opened\r\n * (e.g. [`ECONNREFUSED` in Node.js](https://nodejs.org/api/errors.html#errors_common_system_errors)):\r\n *\r\n * - `false`: the request fails immediately.\r\n *\r\n * - `0`: the request is retried until a server can be reached but only a\r\n * total number of times matching the number of known servers (including\r\n * the initial failed request).\r\n *\r\n * - any other number: the request is retried until a server can be reached\r\n * or the request has been retried a total of `maxRetries` number of times\r\n * (not including the initial failed request).\r\n *\r\n * When working with a single server, the retries (if any) will be made to\r\n * the same server.\r\n *\r\n * This setting currently has no effect when using arangojs in a browser.\r\n *\r\n * **Note**: Requests bound to a specific server (e.g. fetching query results)\r\n * will never be retried automatically and ignore this setting.\r\n *\r\n * **Note**: To set the number of retries when a write-write conflict is\r\n * encountered, see `retryOnConflict` instead.\r\n *\r\n * Default: `0`\r\n */\r\n maxRetries?: false | number;\r\n /**\r\n * If set to a positive number, requests will automatically be retried at\r\n * most this many times if they result in a write-write conflict.\r\n *\r\n * Default: `0`\r\n */\r\n retryOnConflict?: number;\r\n /**\r\n * Time in milliseconds after which arangojs will abort the request if the\r\n * socket has not already timed out.\r\n */\r\n timeout?: number;\r\n /**\r\n * Whether ArangoDB is allowed to perform a dirty read to respond to the\r\n * request. If set to `true`, the response may reflect a dirty state from\r\n * a non-authoritative server.\r\n *\r\n * Default: `false`\r\n */\r\n allowDirtyRead?: boolean;\r\n /**\r\n * Callback that will be invoked with the finished request object before it\r\n * is finalized. In the browser the request may already have been sent.\r\n *\r\n * @param req - Request object or XHR instance used for this request.\r\n */\r\n beforeRequest?: (req: globalThis.Request) => void | Promise<void>;\r\n /**\r\n * Callback that will be invoked when the server response has been received\r\n * and processed or when the request has been failed without a response.\r\n *\r\n * The originating request will be available as the `request` property\r\n * on either the error or response object.\r\n *\r\n * @param err - Error encountered when handling this request or `null`.\r\n * @param res - Response object for this request, if no error occurred.\r\n */\r\n afterResponse?: (\r\n err: errors.NetworkError | null,\r\n res?: globalThis.Response & { request: globalThis.Request }\r\n ) => void | Promise<void>;\r\n};\r\n\r\n/**\r\n * Options for performing a request with arangojs.\r\n */\r\nexport type RequestOptions = CommonRequestOptions & {\r\n /**\r\n * @internal\r\n *\r\n * Identifier of a specific ArangoDB host to use when more than one is known.\r\n */\r\n hostUrl?: string;\r\n /**\r\n * HTTP method to use in order to perform the request.\r\n *\r\n * Default: `\"GET\"`\r\n */\r\n method?: string;\r\n /**\r\n * URL path, relative to the server domain.\r\n */\r\n pathname?: string;\r\n /**\r\n * URL parameters to pass as part of the query string.\r\n */\r\n search?: URLSearchParams | Record<string, any>;\r\n /**\r\n * Headers object containing any additional headers to send with the request.\r\n *\r\n * Note that the `Authorization` header will be overridden if the `auth`\r\n * configuration option is set.\r\n */\r\n headers?:\r\n | string[][]\r\n | Record<string, string | ReadonlyArray<string>>\r\n | Headers;\r\n /**\r\n * Request body data.\r\n */\r\n body?: any;\r\n /**\r\n * Additional options to pass to the `fetch` function.\r\n */\r\n fetchOptions?: Omit<FetchOptions, \"headers\">;\r\n /**\r\n * If set to `true`, the request body will not be converted to JSON and\r\n * instead passed as-is.\r\n */\r\n isBinary?: boolean;\r\n /**\r\n * If set to `true`, the response body will not be interpreted as JSON and\r\n * instead passed as-is.\r\n */\r\n expectBinary?: boolean;\r\n};\r\n//#endregion\r\n\r\n//#region Connection class\r\n/**\r\n * @internal\r\n */\r\ntype Task<T = any> = {\r\n stack?: () => string;\r\n resolve: (result: T) => void;\r\n reject: (error: unknown) => void;\r\n transform?: (res: ProcessedResponse<any>) => T;\r\n retries: number;\r\n conflicts: number;\r\n options: RequestOptions;\r\n};\r\n\r\n/**\r\n * Indicates whether the given value represents a {@link Connection}.\r\n *\r\n * @param connection - A value that might be a connection.\r\n *\r\n * @internal\r\n */\r\nexport function isArangoConnection(connection: any): connection is Connection {\r\n return Boolean(connection && connection.isArangoConnection);\r\n}\r\n\r\n/**\r\n * Represents a connection pool shared by one or more databases.\r\n *\r\n * @internal\r\n */\r\nexport class Connection {\r\n protected _activeTasks: number = 0;\r\n protected _arangoVersion: number;\r\n protected _loadBalancingStrategy: configuration.LoadBalancingStrategy;\r\n protected _taskPoolSize: number;\r\n protected _commonRequestOptions: CommonRequestOptions;\r\n protected _commonFetchOptions: CommonFetchOptions & { headers: Headers };\r\n protected _queue = new LinkedList<Task>();\r\n protected _databases = new Map<string, databases.Database>();\r\n protected _hosts: Host[] = [];\r\n protected _hostUrls: string[] = [];\r\n protected _activeHostUrl: string;\r\n protected _activeDirtyHostUrl: string;\r\n protected _transactionId: string | null = null;\r\n protected _onError?: (err: Error) => void | Promise<void>;\r\n protected _precaptureStackTraces: boolean;\r\n protected _queueTimes = new LinkedList<[number, number]>();\r\n protected _responseQueueTimeSamples: number;\r\n protected _agentOptions?: any;\r\n\r\n /**\r\n * @internal\r\n *\r\n * Creates a new `Connection` instance.\r\n *\r\n * @param config - An object with configuration options.\r\n *\r\n */\r\n constructor(config: Omit<configuration.ConfigOptions, \"databaseName\"> = {}) {\r\n const {\r\n url = \"http://127.0.0.1:8529\",\r\n auth,\r\n arangoVersion = 31100,\r\n loadBalancingStrategy = \"NONE\",\r\n maxRetries = 0,\r\n poolSize = 3 *\r\n (loadBalancingStrategy === \"ROUND_ROBIN\" && Array.isArray(url)\r\n ? url.length\r\n : 1),\r\n fetchOptions: { headers, ...commonFetchOptions } = {},\r\n agentOptions,\r\n onError,\r\n precaptureStackTraces = false,\r\n responseQueueTimeSamples = 10,\r\n ...commonRequestOptions\r\n } = config;\r\n const URLS = Array.isArray(url) ? url : [url];\r\n this._loadBalancingStrategy = loadBalancingStrategy;\r\n this._precaptureStackTraces = precaptureStackTraces;\r\n this._responseQueueTimeSamples =\r\n responseQueueTimeSamples < 0 ? Infinity : responseQueueTimeSamples;\r\n this._arangoVersion = arangoVersion;\r\n this._taskPoolSize = poolSize;\r\n this._onError = onError;\r\n this._agentOptions = agentOptions;\r\n\r\n this._commonRequestOptions = commonRequestOptions;\r\n this._commonFetchOptions = {\r\n headers: new Headers(headers),\r\n ...commonFetchOptions,\r\n };\r\n\r\n this._commonFetchOptions.headers.set(\r\n \"x-arango-version\",\r\n String(arangoVersion)\r\n );\r\n this._commonFetchOptions.headers.set(\r\n \"x-arango-driver\",\r\n `arangojs/${process.env.ARANGOJS_VERSION} (cloud)`\r\n );\r\n\r\n this.addToHostList(URLS);\r\n\r\n if (auth) {\r\n if (configuration.isBearerAuth(auth)) {\r\n this.setBearerAuth(auth);\r\n } else {\r\n this.setBasicAuth(auth);\r\n }\r\n }\r\n\r\n if (this._loadBalancingStrategy === \"ONE_RANDOM\") {\r\n this._activeHostUrl =\r\n this._hostUrls[Math.floor(Math.random() * this._hostUrls.length)];\r\n this._activeDirtyHostUrl =\r\n this._hostUrls[Math.floor(Math.random() * this._hostUrls.length)];\r\n } else {\r\n this._activeHostUrl = this._hostUrls[0];\r\n this._activeDirtyHostUrl = this._hostUrls[0];\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Indicates that this object represents an ArangoDB connection.\r\n */\r\n get isArangoConnection(): true {\r\n return true;\r\n }\r\n\r\n get queueTime(): administration.QueueTimeMetrics {\r\n return {\r\n getLatest: () => this._queueTimes.last?.value[1],\r\n getValues: () => Array.from(this._queueTimes.values()),\r\n getAvg: () => {\r\n let avg = 0;\r\n for (const [, [, value]] of this._queueTimes) {\r\n avg += value / this._queueTimes.length;\r\n }\r\n return avg;\r\n },\r\n };\r\n }\r\n\r\n protected async _runQueue() {\r\n if (this._activeTasks >= this._taskPoolSize) return;\r\n const task = this._queue.shift();\r\n if (!task) return;\r\n let hostUrl = this._activeHostUrl;\r\n try {\r\n this._activeTasks += 1;\r\n if (task.options.hostUrl !== undefined) {\r\n hostUrl = task.options.hostUrl;\r\n } else if (task.options.allowDirtyRead) {\r\n hostUrl = this._activeDirtyHostUrl;\r\n const i = this._hostUrls.indexOf(this._activeDirtyHostUrl) + 1;\r\n this._activeDirtyHostUrl = this._hostUrls[i % this._hostUrls.length];\r\n } else if (this._loadBalancingStrategy === \"ROUND_ROBIN\") {\r\n const i = this._hostUrls.indexOf(this._activeHostUrl) + 1;\r\n this._activeHostUrl = this._hostUrls[i % this._hostUrls.length];\r\n }\r\n const host = this._hosts[this._hostUrls.indexOf(hostUrl)];\r\n const res: globalThis.Response & {\r\n request: globalThis.Request;\r\n arangojsHostUrl: string;\r\n parsedBody?: any;\r\n } = Object.assign(await host.fetch(task.options), {\r\n arangojsHostUrl: hostUrl,\r\n });\r\n const leaderEndpoint = res.headers.get(LEADER_ENDPOINT_HEADER);\r\n if (res.status === 503 && leaderEndpoint) {\r\n const [cleanUrl] = this.addToHostList(leaderEndpoint);\r\n task.options.hostUrl = cleanUrl;\r\n if (this._activeHostUrl === hostUrl) {\r\n this._activeHostUrl = cleanUrl;\r\n }\r\n this._queue.push(task);\r\n return;\r\n }\r\n const queueTime = res.headers.get(\"x-arango-queue-time-seconds\");\r\n if (queueTime) {\r\n this._queueTimes.push([Date.now(), Number(queueTime)]);\r\n while (this._responseQueueTimeSamples < this._queueTimes.length) {\r\n this._queueTimes.shift();\r\n }\r\n }\r\n const contentType = res.headers.get(\"content-type\");\r\n if (res.status >= 400) {\r\n if (contentType?.match(MIME_JSON)) {\r\n const errorResponse = res.clone();\r\n let errorBody: any;\r\n try {\r\n errorBody = await errorResponse.json();\r\n } catch {\r\n // noop\r\n }\r\n if (isArangoErrorResponse(errorBody)) {\r\n res.parsedBody = errorBody;\r\n throw errors.ArangoError.from(res);\r\n }\r\n }\r\n throw new errors.HttpError(res);\r\n }\r\n // Per RFC 7231, HEAD responses must not include a body \r\n // Skip body parsing for non-error HEAD responses to ensure cross-runtime compatibility\r\n if (res.body && task.options.method !== \"HEAD\") {\r\n if (task.options.expectBinary) {\r\n res.parsedBody = await res.blob();\r\n } else if (contentType?.match(MIME_JSON)) {\r\n res.parsedBody = await res.json();\r\n } else {\r\n res.parsedBody = await res.text();\r\n }\r\n }\r\n let result: any = res;\r\n if (task.transform) result = task.transform(res);\r\n task.resolve(result);\r\n } catch (e: unknown) {\r\n const err = e as Error;\r\n if (\r\n !task.options.allowDirtyRead &&\r\n this._hosts.length > 1 &&\r\n this._activeHostUrl === hostUrl &&\r\n this._loadBalancingStrategy !== \"ROUND_ROBIN\"\r\n ) {\r\n const i = this._hostUrls.indexOf(this._activeHostUrl) + 1;\r\n this._activeHostUrl = this._hostUrls[i % this._hostUrls.length];\r\n }\r\n if (\r\n errors.isArangoError(err) &&\r\n err.errorNum === ERROR_ARANGO_CONFLICT &&\r\n task.options.retryOnConflict &&\r\n task.conflicts < task.options.retryOnConflict\r\n ) {\r\n task.conflicts += 1;\r\n this._queue.push(task);\r\n return;\r\n }\r\n if (\r\n (errors.isNetworkError(err) || errors.isArangoError(err)) &&\r\n err.isSafeToRetry &&\r\n task.options.hostUrl === undefined &&\r\n this._commonRequestOptions.maxRetries !== false &&\r\n task.retries <\r\n (this._commonRequestOptions.maxRetries || this._hosts.length - 1)\r\n ) {\r\n task.retries += 1;\r\n this._queue.push(task);\r\n return;\r\n }\r\n if (task.stack) {\r\n err.stack += task.stack();\r\n }\r\n if (this._onError) {\r\n try {\r\n const p = this._onError(err);\r\n if (p instanceof Promise) await p;\r\n } catch (e) {\r\n (e as Error).cause = err;\r\n task.reject(e);\r\n return;\r\n }\r\n }\r\n task.reject(err);\r\n } finally {\r\n this._activeTasks -= 1;\r\n setTimeout(() => this._runQueue(), 0);\r\n }\r\n }\r\n\r\n setBearerAuth(auth: configuration.BearerAuthCredentials) {\r\n this.setHeader(\"authorization\", `Bearer ${auth.token}`);\r\n }\r\n\r\n setBasicAuth(auth: configuration.BasicAuthCredentials) {\r\n this.setHeader(\r\n \"authorization\",\r\n `Basic ${btoa(`${auth.username}:${auth.password}`)}`\r\n );\r\n }\r\n\r\n setResponseQueueTimeSamples(responseQueueTimeSamples: number) {\r\n if (responseQueueTimeSamples < 0) {\r\n responseQueueTimeSamples = Infinity;\r\n }\r\n this._responseQueueTimeSamples = responseQueueTimeSamples;\r\n while (this._responseQueueTimeSamples < this._queueTimes.length) {\r\n this._queueTimes.shift();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Fetches a {@link databases.Database} instance for the given database name from the\r\n * internal cache, if available.\r\n *\r\n * @param databaseName - Name of the database.\r\n */\r\n database(databaseName: string): databases.Database | undefined;\r\n /**\r\n * @internal\r\n *\r\n * Adds a {@link databases.Database} instance for the given database name to the\r\n * internal cache.\r\n *\r\n * @param databaseName - Name of the database.\r\n * @param database - Database instance to add to the cache.\r\n */\r\n database(\r\n databaseName: string,\r\n database: databases.Database\r\n ): databases.Database;\r\n /**\r\n * @internal\r\n *\r\n * Clears any {@link databases.Database} instance stored for the given database name\r\n * from the internal cache, if present.\r\n *\r\n * @param databaseName - Name of the database.\r\n * @param database - Must be `null`.\r\n */\r\n database(databaseName: string, database: null): undefined;\r\n database(\r\n databaseName: string,\r\n database?: databases.Database | null\r\n ): databases.Database | undefined {\r\n if (database === null) {\r\n this._databases.delete(databaseName);\r\n return undefined;\r\n }\r\n if (!database) {\r\n return this._databases.get(databaseName);\r\n }\r\n this._databases.set(databaseName, database);\r\n return database;\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Replaces the host list with the given URLs.\r\n *\r\n * See {@link Connection#acquireHostList}.\r\n *\r\n * @param urls - URLs to use as host list.\r\n */\r\n setHostList(urls: string[]): void {\r\n const cleanUrls = urls.map((url) => util.normalizeUrl(url));\r\n this._hosts.splice(\r\n 0,\r\n this._hosts.length,\r\n ...cleanUrls.map((url) => {\r\n const i = this._hostUrls.indexOf(url);\r\n if (i !== -1) return this._hosts[i];\r\n return createHost(url, this._agentOptions);\r\n })\r\n );\r\n this._hostUrls.splice(0, this._hostUrls.length, ...cleanUrls);\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Adds the given URL or URLs to the host list.\r\n *\r\n * See {@link Connection#acquireHostList}.\r\n *\r\n * @param urls - URL or URLs to add.\r\n */\r\n addToHostList(urls: string | string[]): string[] {\r\n const cleanUrls = (Array.isArray(urls) ? urls : [urls]).map((url) =>\r\n util.normalizeUrl(url)\r\n );\r\n const newUrls = cleanUrls.filter(\r\n (url) => this._hostUrls.indexOf(url) === -1\r\n );\r\n this._hostUrls.push(...newUrls);\r\n this._hosts.push(...newUrls.map((url) => createHost(url, this._agentOptions)));\r\n return cleanUrls;\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Sets the connection's active `transactionId`.\r\n *\r\n * While set, all requests will use this ID, ensuring the requests are executed\r\n * within the transaction if possible. Setting the ID manually may cause\r\n * unexpected behavior.\r\n *\r\n * See also {@link Connection#clearTransactionId}.\r\n *\r\n * @param transactionId - ID of the active transaction.\r\n */\r\n setTransactionId(transactionId: string) {\r\n this._transactionId = transactionId;\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Clears the connection's active `transactionId`.\r\n */\r\n clearTransactionId() {\r\n this._transactionId = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Sets the header `headerName` with the given `value` or clears the header if\r\n * `value` is `null`.\r\n *\r\n * @param headerName - Name of the header to set.\r\n * @param value - Value of the header.\r\n */\r\n setHeader(headerName: string, value: string | null) {\r\n if (value === null) {\r\n this._commonFetchOptions.headers.delete(headerName);\r\n } else {\r\n this._commonFetchOptions.headers.set(headerName, value);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Closes all open connections.\r\n *\r\n * See {@link databases.Database#close}.\r\n */\r\n close() {\r\n for (const host of this._hosts) {\r\n if (host.close) host.close();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Waits for propagation.\r\n *\r\n * See {@link databases.Database#waitForPropagation}.\r\n *\r\n * @param request - Request to perform against each coordinator.\r\n * @param timeout - Maximum number of milliseconds to wait for propagation.\r\n */\r\n async waitForPropagation(request: RequestOptions, timeout = Infinity) {\r\n const numHosts = this._hosts.length;\r\n const propagated = [] as string[];\r\n const started = Date.now();\r\n const endOfTime = started + timeout;\r\n let index = 0;\r\n while (true) {\r\n if (propagated.length === numHosts) {\r\n return;\r\n }\r\n while (propagated.includes(this._hostUrls[index])) {\r\n index = (index + 1) % numHosts;\r\n }\r\n const hostUrl = this._hostUrls[index];\r\n try {\r\n await this.request({\r\n ...request,\r\n hostUrl,\r\n timeout: endOfTime - Date.now(),\r\n });\r\n } catch (e) {\r\n if (endOfTime < Date.now()) {\r\n throw new errors.PropagationTimeoutError(undefined, {\r\n cause: e as Error,\r\n });\r\n }\r\n await new Promise((resolve) => setTimeout(resolve, 1000));\r\n continue;\r\n }\r\n if (!propagated.includes(hostUrl)) {\r\n propagated.push(hostUrl);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Performs a request using the arangojs connection pool.\r\n */\r\n async request<\r\n T = globalThis.Response & { request: globalThis.Request; parsedBody?: any },\r\n >(\r\n requestOptions: RequestOptions & { isBinary?: boolean },\r\n transform?: (\r\n res: globalThis.Response & {\r\n request: globalThis.Request;\r\n parsedBody?: any;\r\n }\r\n ) => T\r\n ): Promise<T> {\r\n const {\r\n hostUrl,\r\n allowDirtyRead = false,\r\n isBinary = false,\r\n maxRetries = 0,\r\n method = \"GET\",\r\n retryOnConflict = 0,\r\n timeout = 0,\r\n headers: requestHeaders,\r\n body: requestBody,\r\n fetchOptions,\r\n ...taskOptions\r\n } = { ...this._commonRequestOptions, ...requestOptions };\r\n\r\n const headers = util.mergeHeaders(\r\n this._commonFetchOptions.headers,\r\n requestHeaders\r\n );\r\n\r\n let body = requestBody;\r\n if (body instanceof FormData) {\r\n const res = new Response(body);\r\n const blob = await res.blob();\r\n // Workaround for ArangoDB 3.12.0-rc1 and earlier:\r\n // Omitting the final CRLF results in \"bad request body\" fatal error\r\n body = new Blob([blob, \"\\r\\n\"], { type: blob.type });\r\n // Set content-length for Blob (needed for Next.js dynamic routes)\r\n if (!headers.has(\"content-length\")) {\r\n headers.set(\"content-length\", String(body.size));\r\n }\r\n } else if (body !== null && body !== undefined) {\r\n // Handle empty string explicitly\r\n if (body === \"\") {\r\n if (!headers.has(\"content-length\")) {\r\n headers.set(\"content-length\", \"0\");\r\n }\r\n if (!headers.has(\"content-type\")) {\r\n headers.set(\"content-type\", \"text/plain\");\r\n }\r\n } else {\r\n let contentType;\r\n if (isBinary) {\r\n contentType = \"application/octet-stream\";\r\n } else if (typeof body === \"object\") {\r\n body = JSON.stringify(body);\r\n contentType = \"application/json\";\r\n } else {\r\n body = String(body);\r\n contentType = \"text/plain\";\r\n }\r\n if (!headers.has(\"content-type\")) {\r\n headers.set(\"content-type\", contentType);\r\n }\r\n // Explicitly set content-length for fixed-size bodies\r\n // This is needed for Next.js dynamic routes (e.g., when using cookies())\r\n // and ensures compatibility with environments that don't set it automatically\r\n if (!headers.has(\"content-length\")) {\r\n if (typeof body === \"string\") {\r\n // Calculate byte length for UTF-8 encoded strings\r\n // Buffer is available in Node.js (required: >=20) and browser polyfills\r\n if (\r\n typeof globalThis.Buffer !== \"undefined\" &&\r\n globalThis.Buffer.byteLength\r\n ) {\r\n const contentLength = globalThis.Buffer.byteLength(body, \"utf8\");\r\n headers.set(\"content-length\", String(contentLength));\r\n } else {\r\n // Fallback: use TextEncoder for browser environments\r\n const encoder = new TextEncoder();\r\n const contentLength = encoder.encode(body).length;\r\n headers.set(\"content-length\", String(contentLength));\r\n }\r\n } else if (body instanceof Blob) {\r\n headers.set(\"content-length\", String(body.size));\r\n } else if (\r\n typeof globalThis.Buffer !== \"undefined\" &&\r\n globalThis.Buffer.isBuffer &&\r\n globalThis.Buffer.isBuffer(body)\r\n ) {\r\n headers.set(\"content-length\", String(body.length));\r\n }\r\n // Note: ArangoDB does not support Transfer-Encoding: chunked.\r\n // All public APIs only accept fixed-size bodies (string, Buffer, Blob, FormData, or objects that get JSON.stringify'd),\r\n // so streams should never reach this point. If an unknown body type is passed, it will be converted to string above.\r\n }\r\n }\r\n }\r\n // Handle null/undefined body for POST/PUT/PATCH methods that might need content-length: 0\r\n // This ensures compatibility with NextJS 15 and other environments that expect explicit content-length\r\n else if (\r\n (method === \"POST\" || method === \"PUT\" || method === \"PATCH\") &&\r\n !headers.has(\"content-length\")\r\n ) {\r\n headers.set(\"content-length\", \"0\");\r\n }\r\n\r\n if (this._transactionId) {\r\n headers.set(\"x-arango-trx-id\", this._transactionId);\r\n }\r\n\r\n if (allowDirtyRead) {\r\n headers.set(\"x-arango-allow-dirty-read\", \"true\");\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n const task: Task = {\r\n resolve,\r\n reject,\r\n transform,\r\n retries: 0,\r\n conflicts: 0,\r\n options: {\r\n ...taskOptions,\r\n hostUrl,\r\n method,\r\n headers,\r\n body,\r\n allowDirtyRead,\r\n retryOnConflict,\r\n maxRetries,\r\n fetchOptions,\r\n timeout,\r\n },\r\n };\r\n\r\n if (this._precaptureStackTraces) {\r\n if (typeof Error.captureStackTrace === \"function\") {\r\n const capture = {} as { readonly stack: string };\r\n Error.captureStackTrace(capture);\r\n task.stack = () =>\r\n `\\n${capture.stack.split(\"\\n\").slice(3).join(\"\\n\")}`;\r\n } else {\r\n const capture = util.generateStackTrace() as {\r\n readonly stack: string;\r\n };\r\n if (Object.prototype.hasOwnProperty.call(capture, \"stack\")) {\r\n task.stack = () =>\r\n `\\n${capture.stack.split(\"\\n\").slice(4).join(\"\\n\")}`;\r\n }\r\n }\r\n }\r\n\r\n this._queue.push(task);\r\n this._runQueue();\r\n });\r\n }\r\n}\r\n//#endregion\r\n"]}
|
package/connection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":";;AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAA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,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/connection.ts"],"names":[],"mappings":";;AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOpD;;GAEG;AACH,KAAK,IAAI,GAAG;IACV;;;;;;;OAOG;IACH,KAAK,EAAE,CACL,OAAO,EAAE,IAAI,CACX,cAAc,EACZ,YAAY,GACZ,iBAAiB,GACjB,gBAAgB,GAChB,SAAS,GACT,cAAc,GACd,UAAU,CACb,KACE,OAAO,CAAC,UAAU,CAAC,QAAQ,GAAG;QAAE,OAAO,EAAE,UAAU,CAAC,OAAO,CAAA;KAAE,CAAC,CAAC;IACpE;;;;OAIG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/connection.ts"],"names":[],"mappings":";;AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOpD;;GAEG;AACH,KAAK,IAAI,GAAG;IACV;;;;;;;OAOG;IACH,KAAK,EAAE,CACL,OAAO,EAAE,IAAI,CACX,cAAc,EACZ,YAAY,GACZ,iBAAiB,GACjB,gBAAgB,GAChB,SAAS,GACT,cAAc,GACd,UAAU,CACb,KACE,OAAO,CAAC,UAAU,CAAC,QAAQ,GAAG;QAAE,OAAO,EAAE,UAA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AQ,GAAG;QACzB,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;QAC5B,UAAU,CAAC,EAAE,GAAG,CAAC;KAClB,KACE,CAAC,GACL,OAAO,CAAC,CAAC,CAAC;CAmJd"}
|
package/esm/connection.js
CHANGED
|
@@ -32,6 +32,7 @@ function createHost(arangojsHostUrl, agentOptions) {
|
|
|
32
32
|
},
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
+
let Request = globalThis.Request;
|
|
35
36
|
if (agentOptions) {
|
|
36
37
|
createDispatcher = async () => {
|
|
37
38
|
let undici;
|
|
@@ -51,6 +52,7 @@ function createHost(arangojsHostUrl, agentOptions) {
|
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
fetch = undici.fetch;
|
|
55
|
+
Request = undici.Request;
|
|
54
56
|
return new undici.Agent(agentOptions);
|
|
55
57
|
};
|
|
56
58
|
}
|
|
@@ -324,7 +326,7 @@ export class Connection {
|
|
|
324
326
|
...commonFetchOptions,
|
|
325
327
|
};
|
|
326
328
|
this._commonFetchOptions.headers.set("x-arango-version", String(arangoVersion));
|
|
327
|
-
this._commonFetchOptions.headers.set("x-arango-driver", `arangojs/10.2.
|
|
329
|
+
this._commonFetchOptions.headers.set("x-arango-driver", `arangojs/10.2.2 (cloud)`);
|
|
328
330
|
this.addToHostList(URLS);
|
|
329
331
|
if (auth) {
|
|
330
332
|
if (configuration.isBearerAuth(auth)) {
|
package/esm/connection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/connection.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;A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C,EAAE,CAAC;gBACzD,CAAC;qBAAM,CAAC;oBACN,MAAM,OAAO,GAAG,IAAI,CAAC,kBAAkB,EAEtC,CAAC;oBACF,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;AACD,YAAY","sourcesContent":["/**\r\n * ```ts\r\n * import type { ArangoApiResponse } from \"arangojs/connection\";\r\n * ```\r\n *\r\n * The \"connection\" module provides connection related types for TypeScript.\r\n *\r\n * @packageDocumentation\r\n */\r\nimport * as administration from \"./administration.js\";\r\nimport * as configuration from \"./configuration.js\";\r\nimport * as databases from \"./databases.js\";\r\nimport * as errors from \"./errors.js\";\r\nimport { ERROR_ARANGO_CONFLICT } from \"./lib/codes.js\";\r\nimport * as util from \"./lib/util.js\";\r\nimport { LinkedList } from \"./lib/x3-linkedlist.js\";\r\n\r\nconst MIME_JSON = /\\/(json|javascript)(\\W|$)/;\r\nconst LEADER_ENDPOINT_HEADER = \"x-arango-endpoint\";\r\nconst REASON_TIMEOUT = \"timeout\";\r\n\r\n//#region Host\r\n/**\r\n * @internal\r\n */\r\ntype Host = {\r\n /**\r\n * @internal\r\n *\r\n * Perform a fetch request against this host.\r\n *\r\n * @param pathname - URL path, relative to the server URL.\r\n * @param options - Options for this fetch request.\r\n */\r\n fetch: (\r\n options: Omit<\r\n RequestOptions,\r\n | \"maxRetries\"\r\n | \"retryOnConflict\"\r\n | \"allowDirtyRead\"\r\n | \"hostUrl\"\r\n | \"expectBinary\"\r\n | \"isBinary\"\r\n >\r\n ) => Promise<globalThis.Response & { request: globalThis.Request }>;\r\n /**\r\n * @internal\r\n *\r\n * Close the pending request, if any.\r\n */\r\n close: () => void;\r\n};\r\n\r\n/**\r\n * @internal\r\n *\r\n * Create a function for performing fetch requests against a given host.\r\n *\r\n * @param arangojsHostUrl - Base URL of the host, i.e. protocol, port and domain name.\r\n * @param options - Options to use for all fetch requests.\r\n */\r\nfunction createHost(arangojsHostUrl: string, agentOptions?: any): Host {\r\n const baseUrl = new URL(arangojsHostUrl);\r\n let fetch = globalThis.fetch;\r\n let createDispatcher: (() => Promise<any>) | undefined;\r\n let dispatcher: any;\r\n let socketPath: string | undefined;\r\n if (arangojsHostUrl.match(/^\\w+:\\/\\/unix:\\//)) {\r\n socketPath = baseUrl.pathname;\r\n baseUrl.hostname = \"localhost\";\r\n baseUrl.pathname = \"/\";\r\n agentOptions = {\r\n ...agentOptions,\r\n connect: {\r\n ...agentOptions?.connect,\r\n socketPath,\r\n },\r\n };\r\n }\r\n if (agentOptions) {\r\n createDispatcher = async () => {\r\n let undici: any;\r\n try {\r\n // Prevent overzealous bundlers from attempting to bundle undici\r\n const undiciName = \"undici\";\r\n undici = await import(undiciName);\r\n } catch (cause) {\r\n if (socketPath) {\r\n throw new Error(\"Undici is required for Unix domain sockets\", {\r\n cause,\r\n });\r\n }\r\n throw new Error(\"Undici is required when using config.agentOptions\", {\r\n cause,\r\n });\r\n }\r\n fetch = undici.fetch;\r\n return new undici.Agent(agentOptions);\r\n };\r\n }\r\n const pending = new Map<string, AbortController>();\r\n return {\r\n async fetch({\r\n method,\r\n pathname,\r\n search,\r\n headers: requestHeaders,\r\n body,\r\n timeout,\r\n fetchOptions,\r\n beforeRequest,\r\n afterResponse,\r\n }: Omit<\r\n RequestOptions,\r\n | \"maxRetries\"\r\n | \"retryOnConflict\"\r\n | \"allowDirtyRead\"\r\n | \"hostUrl\"\r\n | \"expectBinary\"\r\n | \"isBinary\"\r\n >) {\r\n const url = new URL(pathname + baseUrl.search, baseUrl);\r\n if (search) {\r\n const searchParams =\r\n search instanceof URLSearchParams\r\n ? search\r\n : new URLSearchParams(search);\r\n for (const [key, value] of searchParams) {\r\n url.searchParams.append(key, value);\r\n }\r\n }\r\n const headers = new Headers(requestHeaders);\r\n if (!headers.has(\"authorization\")) {\r\n headers.set(\r\n \"authorization\",\r\n `Basic ${btoa(\r\n `${baseUrl.username || \"root\"}:${baseUrl.password || \"\"}`\r\n )}`\r\n );\r\n }\r\n const abortController = new AbortController();\r\n const signal = abortController.signal;\r\n if (createDispatcher) {\r\n dispatcher = await createDispatcher();\r\n createDispatcher = undefined;\r\n }\r\n const request = new Request(url, {\r\n ...fetchOptions,\r\n dispatcher,\r\n method,\r\n headers,\r\n body,\r\n signal,\r\n } as globalThis.RequestInit);\r\n if (beforeRequest) {\r\n const p = beforeRequest(request);\r\n if (p instanceof Promise) await p;\r\n }\r\n const requestId = util.generateRequestId();\r\n pending.set(requestId, abortController);\r\n let clearTimer: (() => void) | undefined;\r\n if (timeout) {\r\n clearTimer = util.createTimer(timeout, () => {\r\n clearTimer = undefined;\r\n abortController.abort(REASON_TIMEOUT);\r\n });\r\n }\r\n let response: globalThis.Response & { request: globalThis.Request };\r\n try {\r\n response = Object.assign(await fetch(request), {\r\n request,\r\n arangojsHostUrl,\r\n });\r\n if (fetchOptions?.redirect === \"manual\" && isRedirect(response)) {\r\n throw new errors.HttpError(response);\r\n }\r\n } catch (e: unknown) {\r\n const cause = e instanceof Error ? e : new Error(String(e));\r\n let error: errors.NetworkError;\r\n if (cause instanceof errors.NetworkError) {\r\n error = cause;\r\n } else if (signal.aborted) {\r\n const reason =\r\n typeof signal.reason == \"string\" ? signal.reason : undefined;\r\n if (reason === REASON_TIMEOUT) {\r\n error = new errors.ResponseTimeoutError(undefined, request, {\r\n cause,\r\n });\r\n } else {\r\n error = new errors.RequestAbortedError(reason, request, { cause });\r\n }\r\n } else if (cause instanceof TypeError) {\r\n error = new errors.FetchFailedError(undefined, request, { cause });\r\n } else {\r\n error = new errors.NetworkError(cause.message, request, { cause });\r\n }\r\n if (afterResponse) {\r\n const p = afterResponse(error);\r\n if (p instanceof Promise) await p;\r\n }\r\n throw error;\r\n } finally {\r\n clearTimer?.();\r\n pending.delete(requestId);\r\n }\r\n if (afterResponse) {\r\n const p = afterResponse(null, response);\r\n if (p instanceof Promise) await p;\r\n }\r\n return response;\r\n },\r\n close() {\r\n if (!pending.size) return;\r\n const controllers = [...pending.values()];\r\n pending.clear();\r\n for (const controller of controllers) {\r\n try {\r\n controller.abort();\r\n } catch (e) {\r\n // noop\r\n }\r\n }\r\n },\r\n };\r\n}\r\n//#endregion\r\n\r\n//#region Response types\r\nconst STATUS_CODE_DEFAULT_MESSAGES = {\r\n 0: \"Network Error\",\r\n 300: \"Multiple Choices\",\r\n 301: \"Moved Permanently\",\r\n 302: \"Found\",\r\n 303: \"See Other\",\r\n 304: \"Not Modified\",\r\n 307: \"Temporary Redirect\",\r\n 308: \"Permanent Redirect\",\r\n 400: \"Bad Request\",\r\n 401: \"Unauthorized\",\r\n 402: \"Payment Required\",\r\n 403: \"Forbidden\",\r\n 404: \"Not Found\",\r\n 405: \"Method Not Allowed\",\r\n 406: \"Not Acceptable\",\r\n 407: \"Proxy Authentication Required\",\r\n 408: \"Request Timeout\",\r\n 409: \"Conflict\",\r\n 410: \"Gone\",\r\n 411: \"Length Required\",\r\n 412: \"Precondition Failed\",\r\n 413: \"Payload Too Large\",\r\n 414: \"Request-URI Too Long\",\r\n 415: \"Unsupported Media Type\",\r\n 416: \"Requested Range Not Satisfiable\",\r\n 417: \"Expectation Failed\",\r\n 418: \"I'm a teapot\",\r\n 421: \"Misdirected Request\",\r\n 422: \"Unprocessable Entity\",\r\n 423: \"Locked\",\r\n 424: \"Failed Dependency\",\r\n 426: \"Upgrade Required\",\r\n 428: \"Precondition Required\",\r\n 429: \"Too Many Requests\",\r\n 431: \"Request Header Fields Too Large\",\r\n 444: \"Connection Closed Without Response\",\r\n 451: \"Unavailable For Legal Reasons\",\r\n 499: \"Client Closed Request\",\r\n 500: \"Internal Server Error\",\r\n 501: \"Not Implemented\",\r\n 502: \"Bad Gateway\",\r\n 503: \"Service Unavailable\",\r\n 504: \"Gateway Timeout\",\r\n 505: \"HTTP Version Not Supported\",\r\n 506: \"Variant Also Negotiates\",\r\n 507: \"Insufficient Storage\",\r\n 508: \"Loop Detected\",\r\n 510: \"Not Extended\",\r\n 511: \"Network Authentication Required\",\r\n 599: \"Network Connect Timeout Error\",\r\n};\r\n\r\ntype KnownStatusCode = keyof typeof STATUS_CODE_DEFAULT_MESSAGES;\r\nconst KNOWN_STATUS_CODES = Object.keys(STATUS_CODE_DEFAULT_MESSAGES).map((k) =>\r\n Number(k)\r\n) as KnownStatusCode[];\r\nconst REDIRECT_CODES = [301, 302, 303, 307, 308] satisfies KnownStatusCode[];\r\ntype RedirectStatusCode = (typeof REDIRECT_CODES)[number];\r\n\r\n/**\r\n * @internal\r\n *\r\n * Indicates whether the given status code can be translated to a known status\r\n * message.\r\n */\r\nfunction isKnownStatusCode(code: number): code is KnownStatusCode {\r\n return KNOWN_STATUS_CODES.includes(code as KnownStatusCode);\r\n}\r\n\r\n/**\r\n * @internal\r\n *\r\n * Indicates whether the given status code represents a redirect.\r\n */\r\nfunction isRedirect(response: ProcessedResponse): boolean {\r\n return REDIRECT_CODES.includes(response.status as RedirectStatusCode);\r\n}\r\n\r\n/**\r\n * Returns the status message for the given response's status code or the\r\n * status text of the response.\r\n */\r\nexport function getStatusMessage(response: ProcessedResponse): string {\r\n if (isKnownStatusCode(response.status)) {\r\n return STATUS_CODE_DEFAULT_MESSAGES[response.status];\r\n }\r\n if (response.statusText) return response.statusText;\r\n return \"Unknown response status\";\r\n}\r\n\r\n/**\r\n * Generic properties shared by all ArangoDB HTTP API responses.\r\n */\r\nexport type ArangoResponseMetadata = {\r\n /**\r\n * Indicates that the request was successful.\r\n */\r\n error: false;\r\n /**\r\n * Response status code, typically `200`.\r\n */\r\n code: number;\r\n};\r\n\r\n/**\r\n * Extends the given base type `T` with the generic HTTP API response properties.\r\n */\r\nexport type ArangoApiResponse<T> = T & ArangoResponseMetadata;\r\n\r\n/**\r\n * Indicates whether the given value represents an ArangoDB error response.\r\n */\r\nexport function isArangoErrorResponse(\r\n body: unknown\r\n): body is ArangoErrorResponse {\r\n if (!body || typeof body !== \"object\") return false;\r\n const obj = body as Record<string, unknown>;\r\n return (\r\n obj.error === true &&\r\n typeof obj.errorMessage === \"string\" &&\r\n typeof obj.errorNum === \"number\" &&\r\n (obj.code === undefined || typeof obj.code === \"number\")\r\n );\r\n}\r\n\r\n/**\r\n * Interface representing an ArangoDB error response.\r\n */\r\nexport type ArangoErrorResponse = {\r\n /**\r\n * Indicates that the request resulted in an error.\r\n */\r\n error: true;\r\n /**\r\n * Intended response status code as provided in the response body.\r\n */\r\n code?: number;\r\n /**\r\n * Error message as provided in the response body.\r\n */\r\n errorMessage: string;\r\n /**\r\n * ArangoDB error code as provided in the response body.\r\n *\r\n * See the [ArangoDB error documentation](https://docs.arangodb.com/stable/develop/error-codes-and-meanings/)\r\n * for more information.\r\n */\r\n errorNum: number;\r\n};\r\n\r\n/**\r\n * Processed response object.\r\n */\r\nexport interface ProcessedResponse<T = any> extends globalThis.Response {\r\n /**\r\n * @internal\r\n *\r\n * Identifier of the ArangoDB host that served this request.\r\n */\r\n arangojsHostUrl?: string;\r\n /**\r\n * Fetch request object.\r\n */\r\n request: globalThis.Request;\r\n /**\r\n * Parsed response body.\r\n */\r\n parsedBody?: T;\r\n}\r\n//#endregion\r\n\r\n//#region Request options\r\n/**\r\n * Options available for requests made with the Fetch API.\r\n */\r\nexport type CommonFetchOptions = {\r\n /**\r\n * Headers object containing any additional headers to send with the request.\r\n *\r\n * Note that the `Authorization` header will be overridden if the `auth`\r\n * configuration option is set.\r\n */\r\n headers?:\r\n | string[][]\r\n | Record<string, string | ReadonlyArray<string>>\r\n | Headers;\r\n /**\r\n * Controls whether the socket should be reused for subsequent requests.\r\n *\r\n * Default: `false`\r\n */\r\n keepalive?: boolean;\r\n /**\r\n * Controls what to do when the response status code is a redirect.\r\n *\r\n * - `\"error\"`: Abort with a network error.\r\n * - `\"follow\"`: Automatically follow redirects.\r\n * - `\"manual\"`: Abort with an `HttpError`.\r\n *\r\n * Default: `\"follow\"`\r\n */\r\n redirect?: \"error\" | \"follow\" | \"manual\";\r\n /**\r\n * Value to use for the `Referer` header.\r\n *\r\n * If set to `\"about:client\"`, the default value for the context in which the\r\n * request is made will be used.\r\n *\r\n * Default: `\"about:client\"`\r\n */\r\n referrer?: string;\r\n /**\r\n * (Browser only.) Controls the Attribution Reporting API specific behavior.\r\n *\r\n * See the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n */\r\n attributionReporting?: any;\r\n /**\r\n * (Browser only.) Cache mode to use for the request.\r\n *\r\n * See [the Fetch API specification](https://fetch.spec.whatwg.org/#request-class)\r\n * or the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n */\r\n cache?: string;\r\n /**\r\n * (Browser only.) Controls sending of credentials and cookies.\r\n *\r\n * - `\"omit\"`: Never send cookies.\r\n * - `\"include\"`: Always send cookies.\r\n * - `\"same-origin\"`: Only send cookies if the request is to the same origin.\r\n *\r\n * Default: `\"same-origin\"`\r\n */\r\n credentials?: \"omit\" | \"include\" | \"same-origin\";\r\n /**\r\n * (Node.js only.) Undici `Dispatcher` instance to use for the request.\r\n *\r\n * Defaults to the global dispatcher.\r\n */\r\n dispatcher?: any;\r\n /**\r\n * (Browser only.) Sets cross-origin behavior for the request.\r\n *\r\n * See [the Fetch API specification](https://fetch.spec.whatwg.org/#request-class)\r\n * or the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n *\r\n * Default: `\"cors\"`\r\n */\r\n mode?: string;\r\n /**\r\n * (Browser only.) Request priority relative to other requests of the same type.\r\n *\r\n * See [the Fetch API specification](https://fetch.spec.whatwg.org/#request-class)\r\n * or the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n *\r\n * Default: `\"auto\"`\r\n */\r\n priority?: \"low\" | \"high\" | \"auto\";\r\n /**\r\n * (Browser only.) Policy to use for the `Referer` header, equivalent to the\r\n * semantics of the `Referrer-Policy` header.\r\n *\r\n * See [the Fetch API specification](https://fetch.spec.whatwg.org/#request-class)\r\n * or the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n */\r\n referrerPolicy?: string;\r\n};\r\n\r\n/**\r\n * Fetch-specific options for performing a request with arangojs.\r\n */\r\nexport type FetchOptions = CommonFetchOptions & {\r\n /**\r\n * Subresource integrity value to use for the request, formatted as\r\n * `<hash-algorithm>-<hash-source>`.\r\n */\r\n integrity?: `${string}-${string}`;\r\n};\r\n\r\n/**\r\n * Options that can be shared globally for all requests made with arangojs.\r\n */\r\nexport type CommonRequestOptions = {\r\n /**\r\n * Determines the behavior when a request fails because the underlying\r\n * connection to the server could not be opened\r\n * (e.g. [`ECONNREFUSED` in Node.js](https://nodejs.org/api/errors.html#errors_common_system_errors)):\r\n *\r\n * - `false`: the request fails immediately.\r\n *\r\n * - `0`: the request is retried until a server can be reached but only a\r\n * total number of times matching the number of known servers (including\r\n * the initial failed request).\r\n *\r\n * - any other number: the request is retried until a server can be reached\r\n * or the request has been retried a total of `maxRetries` number of times\r\n * (not including the initial failed request).\r\n *\r\n * When working with a single server, the retries (if any) will be made to\r\n * the same server.\r\n *\r\n * This setting currently has no effect when using arangojs in a browser.\r\n *\r\n * **Note**: Requests bound to a specific server (e.g. fetching query results)\r\n * will never be retried automatically and ignore this setting.\r\n *\r\n * **Note**: To set the number of retries when a write-write conflict is\r\n * encountered, see `retryOnConflict` instead.\r\n *\r\n * Default: `0`\r\n */\r\n maxRetries?: false | number;\r\n /**\r\n * If set to a positive number, requests will automatically be retried at\r\n * most this many times if they result in a write-write conflict.\r\n *\r\n * Default: `0`\r\n */\r\n retryOnConflict?: number;\r\n /**\r\n * Time in milliseconds after which arangojs will abort the request if the\r\n * socket has not already timed out.\r\n */\r\n timeout?: number;\r\n /**\r\n * Whether ArangoDB is allowed to perform a dirty read to respond to the\r\n * request. If set to `true`, the response may reflect a dirty state from\r\n * a non-authoritative server.\r\n *\r\n * Default: `false`\r\n */\r\n allowDirtyRead?: boolean;\r\n /**\r\n * Callback that will be invoked with the finished request object before it\r\n * is finalized. In the browser the request may already have been sent.\r\n *\r\n * @param req - Request object or XHR instance used for this request.\r\n */\r\n beforeRequest?: (req: globalThis.Request) => void | Promise<void>;\r\n /**\r\n * Callback that will be invoked when the server response has been received\r\n * and processed or when the request has been failed without a response.\r\n *\r\n * The originating request will be available as the `request` property\r\n * on either the error or response object.\r\n *\r\n * @param err - Error encountered when handling this request or `null`.\r\n * @param res - Response object for this request, if no error occurred.\r\n */\r\n afterResponse?: (\r\n err: errors.NetworkError | null,\r\n res?: globalThis.Response & { request: globalThis.Request }\r\n ) => void | Promise<void>;\r\n};\r\n\r\n/**\r\n * Options for performing a request with arangojs.\r\n */\r\nexport type RequestOptions = CommonRequestOptions & {\r\n /**\r\n * @internal\r\n *\r\n * Identifier of a specific ArangoDB host to use when more than one is known.\r\n */\r\n hostUrl?: string;\r\n /**\r\n * HTTP method to use in order to perform the request.\r\n *\r\n * Default: `\"GET\"`\r\n */\r\n method?: string;\r\n /**\r\n * URL path, relative to the server domain.\r\n */\r\n pathname?: string;\r\n /**\r\n * URL parameters to pass as part of the query string.\r\n */\r\n search?: URLSearchParams | Record<string, any>;\r\n /**\r\n * Headers object containing any additional headers to send with the request.\r\n *\r\n * Note that the `Authorization` header will be overridden if the `auth`\r\n * configuration option is set.\r\n */\r\n headers?:\r\n | string[][]\r\n | Record<string, string | ReadonlyArray<string>>\r\n | Headers;\r\n /**\r\n * Request body data.\r\n */\r\n body?: any;\r\n /**\r\n * Additional options to pass to the `fetch` function.\r\n */\r\n fetchOptions?: Omit<FetchOptions, \"headers\">;\r\n /**\r\n * If set to `true`, the request body will not be converted to JSON and\r\n * instead passed as-is.\r\n */\r\n isBinary?: boolean;\r\n /**\r\n * If set to `true`, the response body will not be interpreted as JSON and\r\n * instead passed as-is.\r\n */\r\n expectBinary?: boolean;\r\n};\r\n//#endregion\r\n\r\n//#region Connection class\r\n/**\r\n * @internal\r\n */\r\ntype Task<T = any> = {\r\n stack?: () => string;\r\n resolve: (result: T) => void;\r\n reject: (error: unknown) => void;\r\n transform?: (res: ProcessedResponse<any>) => T;\r\n retries: number;\r\n conflicts: number;\r\n options: RequestOptions;\r\n};\r\n\r\n/**\r\n * Indicates whether the given value represents a {@link Connection}.\r\n *\r\n * @param connection - A value that might be a connection.\r\n *\r\n * @internal\r\n */\r\nexport function isArangoConnection(connection: any): connection is Connection {\r\n return Boolean(connection && connection.isArangoConnection);\r\n}\r\n\r\n/**\r\n * Represents a connection pool shared by one or more databases.\r\n *\r\n * @internal\r\n */\r\nexport class Connection {\r\n protected _activeTasks: number = 0;\r\n protected _arangoVersion: number;\r\n protected _loadBalancingStrategy: configuration.LoadBalancingStrategy;\r\n protected _taskPoolSize: number;\r\n protected _commonRequestOptions: CommonRequestOptions;\r\n protected _commonFetchOptions: CommonFetchOptions & { headers: Headers };\r\n protected _queue = new LinkedList<Task>();\r\n protected _databases = new Map<string, databases.Database>();\r\n protected _hosts: Host[] = [];\r\n protected _hostUrls: string[] = [];\r\n protected _activeHostUrl: string;\r\n protected _activeDirtyHostUrl: string;\r\n protected _transactionId: string | null = null;\r\n protected _onError?: (err: Error) => void | Promise<void>;\r\n protected _precaptureStackTraces: boolean;\r\n protected _queueTimes = new LinkedList<[number, number]>();\r\n protected _responseQueueTimeSamples: number;\r\n protected _agentOptions?: any;\r\n\r\n /**\r\n * @internal\r\n *\r\n * Creates a new `Connection` instance.\r\n *\r\n * @param config - An object with configuration options.\r\n *\r\n */\r\n constructor(config: Omit<configuration.ConfigOptions, \"databaseName\"> = {}) {\r\n const {\r\n url = \"http://127.0.0.1:8529\",\r\n auth,\r\n arangoVersion = 31100,\r\n loadBalancingStrategy = \"NONE\",\r\n maxRetries = 0,\r\n poolSize = 3 *\r\n (loadBalancingStrategy === \"ROUND_ROBIN\" && Array.isArray(url)\r\n ? url.length\r\n : 1),\r\n fetchOptions: { headers, ...commonFetchOptions } = {},\r\n agentOptions,\r\n onError,\r\n precaptureStackTraces = false,\r\n responseQueueTimeSamples = 10,\r\n ...commonRequestOptions\r\n } = config;\r\n const URLS = Array.isArray(url) ? url : [url];\r\n this._loadBalancingStrategy = loadBalancingStrategy;\r\n this._precaptureStackTraces = precaptureStackTraces;\r\n this._responseQueueTimeSamples =\r\n responseQueueTimeSamples < 0 ? Infinity : responseQueueTimeSamples;\r\n this._arangoVersion = arangoVersion;\r\n this._taskPoolSize = poolSize;\r\n this._onError = onError;\r\n this._agentOptions = agentOptions;\r\n\r\n this._commonRequestOptions = commonRequestOptions;\r\n this._commonFetchOptions = {\r\n headers: new Headers(headers),\r\n ...commonFetchOptions,\r\n };\r\n\r\n this._commonFetchOptions.headers.set(\r\n \"x-arango-version\",\r\n String(arangoVersion)\r\n );\r\n this._commonFetchOptions.headers.set(\r\n \"x-arango-driver\",\r\n `arangojs/${process.env.ARANGOJS_VERSION} (cloud)`\r\n );\r\n\r\n this.addToHostList(URLS);\r\n\r\n if (auth) {\r\n if (configuration.isBearerAuth(auth)) {\r\n this.setBearerAuth(auth);\r\n } else {\r\n this.setBasicAuth(auth);\r\n }\r\n }\r\n\r\n if (this._loadBalancingStrategy === \"ONE_RANDOM\") {\r\n this._activeHostUrl =\r\n this._hostUrls[Math.floor(Math.random() * this._hostUrls.length)];\r\n this._activeDirtyHostUrl =\r\n this._hostUrls[Math.floor(Math.random() * this._hostUrls.length)];\r\n } else {\r\n this._activeHostUrl = this._hostUrls[0];\r\n this._activeDirtyHostUrl = this._hostUrls[0];\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Indicates that this object represents an ArangoDB connection.\r\n */\r\n get isArangoConnection(): true {\r\n return true;\r\n }\r\n\r\n get queueTime(): administration.QueueTimeMetrics {\r\n return {\r\n getLatest: () => this._queueTimes.last?.value[1],\r\n getValues: () => Array.from(this._queueTimes.values()),\r\n getAvg: () => {\r\n let avg = 0;\r\n for (const [, [, value]] of this._queueTimes) {\r\n avg += value / this._queueTimes.length;\r\n }\r\n return avg;\r\n },\r\n };\r\n }\r\n\r\n protected async _runQueue() {\r\n if (this._activeTasks >= this._taskPoolSize) return;\r\n const task = this._queue.shift();\r\n if (!task) return;\r\n let hostUrl = this._activeHostUrl;\r\n try {\r\n this._activeTasks += 1;\r\n if (task.options.hostUrl !== undefined) {\r\n hostUrl = task.options.hostUrl;\r\n } else if (task.options.allowDirtyRead) {\r\n hostUrl = this._activeDirtyHostUrl;\r\n const i = this._hostUrls.indexOf(this._activeDirtyHostUrl) + 1;\r\n this._activeDirtyHostUrl = this._hostUrls[i % this._hostUrls.length];\r\n } else if (this._loadBalancingStrategy === \"ROUND_ROBIN\") {\r\n const i = this._hostUrls.indexOf(this._activeHostUrl) + 1;\r\n this._activeHostUrl = this._hostUrls[i % this._hostUrls.length];\r\n }\r\n const host = this._hosts[this._hostUrls.indexOf(hostUrl)];\r\n const res: globalThis.Response & {\r\n request: globalThis.Request;\r\n arangojsHostUrl: string;\r\n parsedBody?: any;\r\n } = Object.assign(await host.fetch(task.options), {\r\n arangojsHostUrl: hostUrl,\r\n });\r\n const leaderEndpoint = res.headers.get(LEADER_ENDPOINT_HEADER);\r\n if (res.status === 503 && leaderEndpoint) {\r\n const [cleanUrl] = this.addToHostList(leaderEndpoint);\r\n task.options.hostUrl = cleanUrl;\r\n if (this._activeHostUrl === hostUrl) {\r\n this._activeHostUrl = cleanUrl;\r\n }\r\n this._queue.push(task);\r\n return;\r\n }\r\n const queueTime = res.headers.get(\"x-arango-queue-time-seconds\");\r\n if (queueTime) {\r\n this._queueTimes.push([Date.now(), Number(queueTime)]);\r\n while (this._responseQueueTimeSamples < this._queueTimes.length) {\r\n this._queueTimes.shift();\r\n }\r\n }\r\n const contentType = res.headers.get(\"content-type\");\r\n if (res.status >= 400) {\r\n if (contentType?.match(MIME_JSON)) {\r\n const errorResponse = res.clone();\r\n let errorBody: any;\r\n try {\r\n errorBody = await errorResponse.json();\r\n } catch {\r\n // noop\r\n }\r\n if (isArangoErrorResponse(errorBody)) {\r\n res.parsedBody = errorBody;\r\n throw errors.ArangoError.from(res);\r\n }\r\n }\r\n throw new errors.HttpError(res);\r\n }\r\n // Per RFC 7231, HEAD responses must not include a body \r\n // Skip body parsing for non-error HEAD responses to ensure cross-runtime compatibility\r\n if (res.body && task.options.method !== \"HEAD\") {\r\n if (task.options.expectBinary) {\r\n res.parsedBody = await res.blob();\r\n } else if (contentType?.match(MIME_JSON)) {\r\n res.parsedBody = await res.json();\r\n } else {\r\n res.parsedBody = await res.text();\r\n }\r\n }\r\n let result: any = res;\r\n if (task.transform) result = task.transform(res);\r\n task.resolve(result);\r\n } catch (e: unknown) {\r\n const err = e as Error;\r\n if (\r\n !task.options.allowDirtyRead &&\r\n this._hosts.length > 1 &&\r\n this._activeHostUrl === hostUrl &&\r\n this._loadBalancingStrategy !== \"ROUND_ROBIN\"\r\n ) {\r\n const i = this._hostUrls.indexOf(this._activeHostUrl) + 1;\r\n this._activeHostUrl = this._hostUrls[i % this._hostUrls.length];\r\n }\r\n if (\r\n errors.isArangoError(err) &&\r\n err.errorNum === ERROR_ARANGO_CONFLICT &&\r\n task.options.retryOnConflict &&\r\n task.conflicts < task.options.retryOnConflict\r\n ) {\r\n task.conflicts += 1;\r\n this._queue.push(task);\r\n return;\r\n }\r\n if (\r\n (errors.isNetworkError(err) || errors.isArangoError(err)) &&\r\n err.isSafeToRetry &&\r\n task.options.hostUrl === undefined &&\r\n this._commonRequestOptions.maxRetries !== false &&\r\n task.retries <\r\n (this._commonRequestOptions.maxRetries || this._hosts.length - 1)\r\n ) {\r\n task.retries += 1;\r\n this._queue.push(task);\r\n return;\r\n }\r\n if (task.stack) {\r\n err.stack += task.stack();\r\n }\r\n if (this._onError) {\r\n try {\r\n const p = this._onError(err);\r\n if (p instanceof Promise) await p;\r\n } catch (e) {\r\n (e as Error).cause = err;\r\n task.reject(e);\r\n return;\r\n }\r\n }\r\n task.reject(err);\r\n } finally {\r\n this._activeTasks -= 1;\r\n setTimeout(() => this._runQueue(), 0);\r\n }\r\n }\r\n\r\n setBearerAuth(auth: configuration.BearerAuthCredentials) {\r\n this.setHeader(\"authorization\", `Bearer ${auth.token}`);\r\n }\r\n\r\n setBasicAuth(auth: configuration.BasicAuthCredentials) {\r\n this.setHeader(\r\n \"authorization\",\r\n `Basic ${btoa(`${auth.username}:${auth.password}`)}`\r\n );\r\n }\r\n\r\n setResponseQueueTimeSamples(responseQueueTimeSamples: number) {\r\n if (responseQueueTimeSamples < 0) {\r\n responseQueueTimeSamples = Infinity;\r\n }\r\n this._responseQueueTimeSamples = responseQueueTimeSamples;\r\n while (this._responseQueueTimeSamples < this._queueTimes.length) {\r\n this._queueTimes.shift();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Fetches a {@link databases.Database} instance for the given database name from the\r\n * internal cache, if available.\r\n *\r\n * @param databaseName - Name of the database.\r\n */\r\n database(databaseName: string): databases.Database | undefined;\r\n /**\r\n * @internal\r\n *\r\n * Adds a {@link databases.Database} instance for the given database name to the\r\n * internal cache.\r\n *\r\n * @param databaseName - Name of the database.\r\n * @param database - Database instance to add to the cache.\r\n */\r\n database(\r\n databaseName: string,\r\n database: databases.Database\r\n ): databases.Database;\r\n /**\r\n * @internal\r\n *\r\n * Clears any {@link databases.Database} instance stored for the given database name\r\n * from the internal cache, if present.\r\n *\r\n * @param databaseName - Name of the database.\r\n * @param database - Must be `null`.\r\n */\r\n database(databaseName: string, database: null): undefined;\r\n database(\r\n databaseName: string,\r\n database?: databases.Database | null\r\n ): databases.Database | undefined {\r\n if (database === null) {\r\n this._databases.delete(databaseName);\r\n return undefined;\r\n }\r\n if (!database) {\r\n return this._databases.get(databaseName);\r\n }\r\n this._databases.set(databaseName, database);\r\n return database;\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Replaces the host list with the given URLs.\r\n *\r\n * See {@link Connection#acquireHostList}.\r\n *\r\n * @param urls - URLs to use as host list.\r\n */\r\n setHostList(urls: string[]): void {\r\n const cleanUrls = urls.map((url) => util.normalizeUrl(url));\r\n this._hosts.splice(\r\n 0,\r\n this._hosts.length,\r\n ...cleanUrls.map((url) => {\r\n const i = this._hostUrls.indexOf(url);\r\n if (i !== -1) return this._hosts[i];\r\n return createHost(url, this._agentOptions);\r\n })\r\n );\r\n this._hostUrls.splice(0, this._hostUrls.length, ...cleanUrls);\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Adds the given URL or URLs to the host list.\r\n *\r\n * See {@link Connection#acquireHostList}.\r\n *\r\n * @param urls - URL or URLs to add.\r\n */\r\n addToHostList(urls: string | string[]): string[] {\r\n const cleanUrls = (Array.isArray(urls) ? urls : [urls]).map((url) =>\r\n util.normalizeUrl(url)\r\n );\r\n const newUrls = cleanUrls.filter(\r\n (url) => this._hostUrls.indexOf(url) === -1\r\n );\r\n this._hostUrls.push(...newUrls);\r\n this._hosts.push(...newUrls.map((url) => createHost(url, this._agentOptions)));\r\n return cleanUrls;\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Sets the connection's active `transactionId`.\r\n *\r\n * While set, all requests will use this ID, ensuring the requests are executed\r\n * within the transaction if possible. Setting the ID manually may cause\r\n * unexpected behavior.\r\n *\r\n * See also {@link Connection#clearTransactionId}.\r\n *\r\n * @param transactionId - ID of the active transaction.\r\n */\r\n setTransactionId(transactionId: string) {\r\n this._transactionId = transactionId;\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Clears the connection's active `transactionId`.\r\n */\r\n clearTransactionId() {\r\n this._transactionId = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Sets the header `headerName` with the given `value` or clears the header if\r\n * `value` is `null`.\r\n *\r\n * @param headerName - Name of the header to set.\r\n * @param value - Value of the header.\r\n */\r\n setHeader(headerName: string, value: string | null) {\r\n if (value === null) {\r\n this._commonFetchOptions.headers.delete(headerName);\r\n } else {\r\n this._commonFetchOptions.headers.set(headerName, value);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Closes all open connections.\r\n *\r\n * See {@link databases.Database#close}.\r\n */\r\n close() {\r\n for (const host of this._hosts) {\r\n if (host.close) host.close();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Waits for propagation.\r\n *\r\n * See {@link databases.Database#waitForPropagation}.\r\n *\r\n * @param request - Request to perform against each coordinator.\r\n * @param timeout - Maximum number of milliseconds to wait for propagation.\r\n */\r\n async waitForPropagation(request: RequestOptions, timeout = Infinity) {\r\n const numHosts = this._hosts.length;\r\n const propagated = [] as string[];\r\n const started = Date.now();\r\n const endOfTime = started + timeout;\r\n let index = 0;\r\n while (true) {\r\n if (propagated.length === numHosts) {\r\n return;\r\n }\r\n while (propagated.includes(this._hostUrls[index])) {\r\n index = (index + 1) % numHosts;\r\n }\r\n const hostUrl = this._hostUrls[index];\r\n try {\r\n await this.request({\r\n ...request,\r\n hostUrl,\r\n timeout: endOfTime - Date.now(),\r\n });\r\n } catch (e) {\r\n if (endOfTime < Date.now()) {\r\n throw new errors.PropagationTimeoutError(undefined, {\r\n cause: e as Error,\r\n });\r\n }\r\n await new Promise((resolve) => setTimeout(resolve, 1000));\r\n continue;\r\n }\r\n if (!propagated.includes(hostUrl)) {\r\n propagated.push(hostUrl);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Performs a request using the arangojs connection pool.\r\n */\r\n async request<\r\n T = globalThis.Response & { request: globalThis.Request; parsedBody?: any },\r\n >(\r\n requestOptions: RequestOptions & { isBinary?: boolean },\r\n transform?: (\r\n res: globalThis.Response & {\r\n request: globalThis.Request;\r\n parsedBody?: any;\r\n }\r\n ) => T\r\n ): Promise<T> {\r\n const {\r\n hostUrl,\r\n allowDirtyRead = false,\r\n isBinary = false,\r\n maxRetries = 0,\r\n method = \"GET\",\r\n retryOnConflict = 0,\r\n timeout = 0,\r\n headers: requestHeaders,\r\n body: requestBody,\r\n fetchOptions,\r\n ...taskOptions\r\n } = { ...this._commonRequestOptions, ...requestOptions };\r\n\r\n const headers = util.mergeHeaders(\r\n this._commonFetchOptions.headers,\r\n requestHeaders\r\n );\r\n\r\n let body = requestBody;\r\n if (body instanceof FormData) {\r\n const res = new Response(body);\r\n const blob = await res.blob();\r\n // Workaround for ArangoDB 3.12.0-rc1 and earlier:\r\n // Omitting the final CRLF results in \"bad request body\" fatal error\r\n body = new Blob([blob, \"\\r\\n\"], { type: blob.type });\r\n // Set content-length for Blob (needed for Next.js dynamic routes)\r\n if (!headers.has(\"content-length\")) {\r\n headers.set(\"content-length\", String(body.size));\r\n }\r\n } else if (body !== null && body !== undefined) {\r\n // Handle empty string explicitly\r\n if (body === \"\") {\r\n if (!headers.has(\"content-length\")) {\r\n headers.set(\"content-length\", \"0\");\r\n }\r\n if (!headers.has(\"content-type\")) {\r\n headers.set(\"content-type\", \"text/plain\");\r\n }\r\n } else {\r\n let contentType;\r\n if (isBinary) {\r\n contentType = \"application/octet-stream\";\r\n } else if (typeof body === \"object\") {\r\n body = JSON.stringify(body);\r\n contentType = \"application/json\";\r\n } else {\r\n body = String(body);\r\n contentType = \"text/plain\";\r\n }\r\n if (!headers.has(\"content-type\")) {\r\n headers.set(\"content-type\", contentType);\r\n }\r\n // Explicitly set content-length for fixed-size bodies\r\n // This is needed for Next.js dynamic routes (e.g., when using cookies())\r\n // and ensures compatibility with environments that don't set it automatically\r\n if (!headers.has(\"content-length\")) {\r\n if (typeof body === \"string\") {\r\n // Calculate byte length for UTF-8 encoded strings\r\n // Buffer is available in Node.js (required: >=20) and browser polyfills\r\n if (\r\n typeof globalThis.Buffer !== \"undefined\" &&\r\n globalThis.Buffer.byteLength\r\n ) {\r\n const contentLength = globalThis.Buffer.byteLength(body, \"utf8\");\r\n headers.set(\"content-length\", String(contentLength));\r\n } else {\r\n // Fallback: use TextEncoder for browser environments\r\n const encoder = new TextEncoder();\r\n const contentLength = encoder.encode(body).length;\r\n headers.set(\"content-length\", String(contentLength));\r\n }\r\n } else if (body instanceof Blob) {\r\n headers.set(\"content-length\", String(body.size));\r\n } else if (\r\n typeof globalThis.Buffer !== \"undefined\" &&\r\n globalThis.Buffer.isBuffer &&\r\n globalThis.Buffer.isBuffer(body)\r\n ) {\r\n headers.set(\"content-length\", String(body.length));\r\n }\r\n // Note: ArangoDB does not support Transfer-Encoding: chunked.\r\n // All public APIs only accept fixed-size bodies (string, Buffer, Blob, FormData, or objects that get JSON.stringify'd),\r\n // so streams should never reach this point. If an unknown body type is passed, it will be converted to string above.\r\n }\r\n }\r\n }\r\n // Handle null/undefined body for POST/PUT/PATCH methods that might need content-length: 0\r\n // This ensures compatibility with NextJS 15 and other environments that expect explicit content-length\r\n else if (\r\n (method === \"POST\" || method === \"PUT\" || method === \"PATCH\") &&\r\n !headers.has(\"content-length\")\r\n ) {\r\n headers.set(\"content-length\", \"0\");\r\n }\r\n\r\n if (this._transactionId) {\r\n headers.set(\"x-arango-trx-id\", this._transactionId);\r\n }\r\n\r\n if (allowDirtyRead) {\r\n headers.set(\"x-arango-allow-dirty-read\", \"true\");\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n const task: Task = {\r\n resolve,\r\n reject,\r\n transform,\r\n retries: 0,\r\n conflicts: 0,\r\n options: {\r\n ...taskOptions,\r\n hostUrl,\r\n method,\r\n headers,\r\n body,\r\n allowDirtyRead,\r\n retryOnConflict,\r\n maxRetries,\r\n fetchOptions,\r\n timeout,\r\n },\r\n };\r\n\r\n if (this._precaptureStackTraces) {\r\n if (typeof Error.captureStackTrace === \"function\") {\r\n const capture = {} as { readonly stack: string };\r\n Error.captureStackTrace(capture);\r\n task.stack = () =>\r\n `\\n${capture.stack.split(\"\\n\").slice(3).join(\"\\n\")}`;\r\n } else {\r\n const capture = util.generateStackTrace() as {\r\n readonly stack: string;\r\n };\r\n if (Object.prototype.hasOwnProperty.call(capture, \"stack\")) {\r\n task.stack = () =>\r\n `\\n${capture.stack.split(\"\\n\").slice(4).join(\"\\n\")}`;\r\n }\r\n }\r\n }\r\n\r\n this._queue.push(task);\r\n this._runQueue();\r\n });\r\n }\r\n}\r\n//#endregion\r\n"]}
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/connection.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,MAAM,SAAS,GAAG,2BAA2B,CAAC;AAC9C,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AACnD,MAAM,cAAc,GAAG,SAAS,CAAC;AAkCjC;;;;;;;GAOG;AACH,SAAS,UAAU,CAAC,eAAuB,EAAE,YAAkB;IAC7D,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC;IACzC,IAAI,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAC7B,IAAI,gBAAkD,CAAC;IACvD,IAAI,UAAe,CAAC;IACpB,IAAI,UAA8B,CAAC;IACnC,IAAI,eAAe,CAAC,KAAK,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC9C,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC;QAC9B,OAAO,CAAC,QAAQ,GAAG,WAAW,CAAC;QAC/B,OAAO,CAAC,QAAQ,GAAG,GAAG,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ACvB,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AACD,YAAY","sourcesContent":["/**\r\n * ```ts\r\n * import type { ArangoApiResponse } from \"arangojs/connection\";\r\n * ```\r\n *\r\n * The \"connection\" module provides connection related types for TypeScript.\r\n *\r\n * @packageDocumentation\r\n */\r\nimport * as administration from \"./administration.js\";\r\nimport * as configuration from \"./configuration.js\";\r\nimport * as databases from \"./databases.js\";\r\nimport * as errors from \"./errors.js\";\r\nimport { ERROR_ARANGO_CONFLICT } from \"./lib/codes.js\";\r\nimport * as util from \"./lib/util.js\";\r\nimport { LinkedList } from \"./lib/x3-linkedlist.js\";\r\n\r\nconst MIME_JSON = /\\/(json|javascript)(\\W|$)/;\r\nconst LEADER_ENDPOINT_HEADER = \"x-arango-endpoint\";\r\nconst REASON_TIMEOUT = \"timeout\";\r\n\r\n//#region Host\r\n/**\r\n * @internal\r\n */\r\ntype Host = {\r\n /**\r\n * @internal\r\n *\r\n * Perform a fetch request against this host.\r\n *\r\n * @param pathname - URL path, relative to the server URL.\r\n * @param options - Options for this fetch request.\r\n */\r\n fetch: (\r\n options: Omit<\r\n RequestOptions,\r\n | \"maxRetries\"\r\n | \"retryOnConflict\"\r\n | \"allowDirtyRead\"\r\n | \"hostUrl\"\r\n | \"expectBinary\"\r\n | \"isBinary\"\r\n >\r\n ) => Promise<globalThis.Response & { request: globalThis.Request }>;\r\n /**\r\n * @internal\r\n *\r\n * Close the pending request, if any.\r\n */\r\n close: () => void;\r\n};\r\n\r\n/**\r\n * @internal\r\n *\r\n * Create a function for performing fetch requests against a given host.\r\n *\r\n * @param arangojsHostUrl - Base URL of the host, i.e. protocol, port and domain name.\r\n * @param options - Options to use for all fetch requests.\r\n */\r\nfunction createHost(arangojsHostUrl: string, agentOptions?: any): Host {\r\n const baseUrl = new URL(arangojsHostUrl);\r\n let fetch = globalThis.fetch;\r\n let createDispatcher: (() => Promise<any>) | undefined;\r\n let dispatcher: any;\r\n let socketPath: string | undefined;\r\n if (arangojsHostUrl.match(/^\\w+:\\/\\/unix:\\//)) {\r\n socketPath = baseUrl.pathname;\r\n baseUrl.hostname = \"localhost\";\r\n baseUrl.pathname = \"/\";\r\n agentOptions = {\r\n ...agentOptions,\r\n connect: {\r\n ...agentOptions?.connect,\r\n socketPath,\r\n },\r\n };\r\n }\r\n let Request = globalThis.Request;\r\n if (agentOptions) {\r\n createDispatcher = async () => {\r\n let undici: any;\r\n try {\r\n // Prevent overzealous bundlers from attempting to bundle undici\r\n const undiciName = \"undici\";\r\n undici = await import(undiciName);\r\n } catch (cause) {\r\n if (socketPath) {\r\n throw new Error(\"Undici is required for Unix domain sockets\", {\r\n cause,\r\n });\r\n }\r\n throw new Error(\"Undici is required when using config.agentOptions\", {\r\n cause,\r\n });\r\n }\r\n fetch = undici.fetch;\r\n Request = undici.Request;\r\n return new undici.Agent(agentOptions);\r\n };\r\n }\r\n const pending = new Map<string, AbortController>();\r\n return {\r\n async fetch({\r\n method,\r\n pathname,\r\n search,\r\n headers: requestHeaders,\r\n body,\r\n timeout,\r\n fetchOptions,\r\n beforeRequest,\r\n afterResponse,\r\n }: Omit<\r\n RequestOptions,\r\n | \"maxRetries\"\r\n | \"retryOnConflict\"\r\n | \"allowDirtyRead\"\r\n | \"hostUrl\"\r\n | \"expectBinary\"\r\n | \"isBinary\"\r\n >) {\r\n const url = new URL(pathname + baseUrl.search, baseUrl);\r\n if (search) {\r\n const searchParams =\r\n search instanceof URLSearchParams\r\n ? search\r\n : new URLSearchParams(search);\r\n for (const [key, value] of searchParams) {\r\n url.searchParams.append(key, value);\r\n }\r\n }\r\n const headers = new Headers(requestHeaders);\r\n if (!headers.has(\"authorization\")) {\r\n headers.set(\r\n \"authorization\",\r\n `Basic ${btoa(\r\n `${baseUrl.username || \"root\"}:${baseUrl.password || \"\"}`\r\n )}`\r\n );\r\n }\r\n const abortController = new AbortController();\r\n const signal = abortController.signal;\r\n if (createDispatcher) {\r\n dispatcher = await createDispatcher();\r\n createDispatcher = undefined;\r\n }\r\n const request = new Request(url, {\r\n ...fetchOptions,\r\n dispatcher,\r\n method,\r\n headers,\r\n body,\r\n signal,\r\n } as globalThis.RequestInit);\r\n if (beforeRequest) {\r\n const p = beforeRequest(request);\r\n if (p instanceof Promise) await p;\r\n }\r\n const requestId = util.generateRequestId();\r\n pending.set(requestId, abortController);\r\n let clearTimer: (() => void) | undefined;\r\n if (timeout) {\r\n clearTimer = util.createTimer(timeout, () => {\r\n clearTimer = undefined;\r\n abortController.abort(REASON_TIMEOUT);\r\n });\r\n }\r\n let response: globalThis.Response & { request: globalThis.Request };\r\n try {\r\n response = Object.assign(await fetch(request), {\r\n request,\r\n arangojsHostUrl,\r\n });\r\n if (fetchOptions?.redirect === \"manual\" && isRedirect(response)) {\r\n throw new errors.HttpError(response);\r\n }\r\n } catch (e: unknown) {\r\n const cause = e instanceof Error ? e : new Error(String(e));\r\n let error: errors.NetworkError;\r\n if (cause instanceof errors.NetworkError) {\r\n error = cause;\r\n } else if (signal.aborted) {\r\n const reason =\r\n typeof signal.reason == \"string\" ? signal.reason : undefined;\r\n if (reason === REASON_TIMEOUT) {\r\n error = new errors.ResponseTimeoutError(undefined, request, {\r\n cause,\r\n });\r\n } else {\r\n error = new errors.RequestAbortedError(reason, request, { cause });\r\n }\r\n } else if (cause instanceof TypeError) {\r\n error = new errors.FetchFailedError(undefined, request, { cause });\r\n } else {\r\n error = new errors.NetworkError(cause.message, request, { cause });\r\n }\r\n if (afterResponse) {\r\n const p = afterResponse(error);\r\n if (p instanceof Promise) await p;\r\n }\r\n throw error;\r\n } finally {\r\n clearTimer?.();\r\n pending.delete(requestId);\r\n }\r\n if (afterResponse) {\r\n const p = afterResponse(null, response);\r\n if (p instanceof Promise) await p;\r\n }\r\n return response;\r\n },\r\n close() {\r\n if (!pending.size) return;\r\n const controllers = [...pending.values()];\r\n pending.clear();\r\n for (const controller of controllers) {\r\n try {\r\n controller.abort();\r\n } catch (e) {\r\n // noop\r\n }\r\n }\r\n },\r\n };\r\n}\r\n//#endregion\r\n\r\n//#region Response types\r\nconst STATUS_CODE_DEFAULT_MESSAGES = {\r\n 0: \"Network Error\",\r\n 300: \"Multiple Choices\",\r\n 301: \"Moved Permanently\",\r\n 302: \"Found\",\r\n 303: \"See Other\",\r\n 304: \"Not Modified\",\r\n 307: \"Temporary Redirect\",\r\n 308: \"Permanent Redirect\",\r\n 400: \"Bad Request\",\r\n 401: \"Unauthorized\",\r\n 402: \"Payment Required\",\r\n 403: \"Forbidden\",\r\n 404: \"Not Found\",\r\n 405: \"Method Not Allowed\",\r\n 406: \"Not Acceptable\",\r\n 407: \"Proxy Authentication Required\",\r\n 408: \"Request Timeout\",\r\n 409: \"Conflict\",\r\n 410: \"Gone\",\r\n 411: \"Length Required\",\r\n 412: \"Precondition Failed\",\r\n 413: \"Payload Too Large\",\r\n 414: \"Request-URI Too Long\",\r\n 415: \"Unsupported Media Type\",\r\n 416: \"Requested Range Not Satisfiable\",\r\n 417: \"Expectation Failed\",\r\n 418: \"I'm a teapot\",\r\n 421: \"Misdirected Request\",\r\n 422: \"Unprocessable Entity\",\r\n 423: \"Locked\",\r\n 424: \"Failed Dependency\",\r\n 426: \"Upgrade Required\",\r\n 428: \"Precondition Required\",\r\n 429: \"Too Many Requests\",\r\n 431: \"Request Header Fields Too Large\",\r\n 444: \"Connection Closed Without Response\",\r\n 451: \"Unavailable For Legal Reasons\",\r\n 499: \"Client Closed Request\",\r\n 500: \"Internal Server Error\",\r\n 501: \"Not Implemented\",\r\n 502: \"Bad Gateway\",\r\n 503: \"Service Unavailable\",\r\n 504: \"Gateway Timeout\",\r\n 505: \"HTTP Version Not Supported\",\r\n 506: \"Variant Also Negotiates\",\r\n 507: \"Insufficient Storage\",\r\n 508: \"Loop Detected\",\r\n 510: \"Not Extended\",\r\n 511: \"Network Authentication Required\",\r\n 599: \"Network Connect Timeout Error\",\r\n};\r\n\r\ntype KnownStatusCode = keyof typeof STATUS_CODE_DEFAULT_MESSAGES;\r\nconst KNOWN_STATUS_CODES = Object.keys(STATUS_CODE_DEFAULT_MESSAGES).map((k) =>\r\n Number(k)\r\n) as KnownStatusCode[];\r\nconst REDIRECT_CODES = [301, 302, 303, 307, 308] satisfies KnownStatusCode[];\r\ntype RedirectStatusCode = (typeof REDIRECT_CODES)[number];\r\n\r\n/**\r\n * @internal\r\n *\r\n * Indicates whether the given status code can be translated to a known status\r\n * message.\r\n */\r\nfunction isKnownStatusCode(code: number): code is KnownStatusCode {\r\n return KNOWN_STATUS_CODES.includes(code as KnownStatusCode);\r\n}\r\n\r\n/**\r\n * @internal\r\n *\r\n * Indicates whether the given status code represents a redirect.\r\n */\r\nfunction isRedirect(response: ProcessedResponse): boolean {\r\n return REDIRECT_CODES.includes(response.status as RedirectStatusCode);\r\n}\r\n\r\n/**\r\n * Returns the status message for the given response's status code or the\r\n * status text of the response.\r\n */\r\nexport function getStatusMessage(response: ProcessedResponse): string {\r\n if (isKnownStatusCode(response.status)) {\r\n return STATUS_CODE_DEFAULT_MESSAGES[response.status];\r\n }\r\n if (response.statusText) return response.statusText;\r\n return \"Unknown response status\";\r\n}\r\n\r\n/**\r\n * Generic properties shared by all ArangoDB HTTP API responses.\r\n */\r\nexport type ArangoResponseMetadata = {\r\n /**\r\n * Indicates that the request was successful.\r\n */\r\n error: false;\r\n /**\r\n * Response status code, typically `200`.\r\n */\r\n code: number;\r\n};\r\n\r\n/**\r\n * Extends the given base type `T` with the generic HTTP API response properties.\r\n */\r\nexport type ArangoApiResponse<T> = T & ArangoResponseMetadata;\r\n\r\n/**\r\n * Indicates whether the given value represents an ArangoDB error response.\r\n */\r\nexport function isArangoErrorResponse(\r\n body: unknown\r\n): body is ArangoErrorResponse {\r\n if (!body || typeof body !== \"object\") return false;\r\n const obj = body as Record<string, unknown>;\r\n return (\r\n obj.error === true &&\r\n typeof obj.errorMessage === \"string\" &&\r\n typeof obj.errorNum === \"number\" &&\r\n (obj.code === undefined || typeof obj.code === \"number\")\r\n );\r\n}\r\n\r\n/**\r\n * Interface representing an ArangoDB error response.\r\n */\r\nexport type ArangoErrorResponse = {\r\n /**\r\n * Indicates that the request resulted in an error.\r\n */\r\n error: true;\r\n /**\r\n * Intended response status code as provided in the response body.\r\n */\r\n code?: number;\r\n /**\r\n * Error message as provided in the response body.\r\n */\r\n errorMessage: string;\r\n /**\r\n * ArangoDB error code as provided in the response body.\r\n *\r\n * See the [ArangoDB error documentation](https://docs.arangodb.com/stable/develop/error-codes-and-meanings/)\r\n * for more information.\r\n */\r\n errorNum: number;\r\n};\r\n\r\n/**\r\n * Processed response object.\r\n */\r\nexport interface ProcessedResponse<T = any> extends globalThis.Response {\r\n /**\r\n * @internal\r\n *\r\n * Identifier of the ArangoDB host that served this request.\r\n */\r\n arangojsHostUrl?: string;\r\n /**\r\n * Fetch request object.\r\n */\r\n request: globalThis.Request;\r\n /**\r\n * Parsed response body.\r\n */\r\n parsedBody?: T;\r\n}\r\n//#endregion\r\n\r\n//#region Request options\r\n/**\r\n * Options available for requests made with the Fetch API.\r\n */\r\nexport type CommonFetchOptions = {\r\n /**\r\n * Headers object containing any additional headers to send with the request.\r\n *\r\n * Note that the `Authorization` header will be overridden if the `auth`\r\n * configuration option is set.\r\n */\r\n headers?:\r\n | string[][]\r\n | Record<string, string | ReadonlyArray<string>>\r\n | Headers;\r\n /**\r\n * Controls whether the socket should be reused for subsequent requests.\r\n *\r\n * Default: `false`\r\n */\r\n keepalive?: boolean;\r\n /**\r\n * Controls what to do when the response status code is a redirect.\r\n *\r\n * - `\"error\"`: Abort with a network error.\r\n * - `\"follow\"`: Automatically follow redirects.\r\n * - `\"manual\"`: Abort with an `HttpError`.\r\n *\r\n * Default: `\"follow\"`\r\n */\r\n redirect?: \"error\" | \"follow\" | \"manual\";\r\n /**\r\n * Value to use for the `Referer` header.\r\n *\r\n * If set to `\"about:client\"`, the default value for the context in which the\r\n * request is made will be used.\r\n *\r\n * Default: `\"about:client\"`\r\n */\r\n referrer?: string;\r\n /**\r\n * (Browser only.) Controls the Attribution Reporting API specific behavior.\r\n *\r\n * See the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n */\r\n attributionReporting?: any;\r\n /**\r\n * (Browser only.) Cache mode to use for the request.\r\n *\r\n * See [the Fetch API specification](https://fetch.spec.whatwg.org/#request-class)\r\n * or the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n */\r\n cache?: string;\r\n /**\r\n * (Browser only.) Controls sending of credentials and cookies.\r\n *\r\n * - `\"omit\"`: Never send cookies.\r\n * - `\"include\"`: Always send cookies.\r\n * - `\"same-origin\"`: Only send cookies if the request is to the same origin.\r\n *\r\n * Default: `\"same-origin\"`\r\n */\r\n credentials?: \"omit\" | \"include\" | \"same-origin\";\r\n /**\r\n * (Node.js only.) Undici `Dispatcher` instance to use for the request.\r\n *\r\n * Defaults to the global dispatcher.\r\n */\r\n dispatcher?: any;\r\n /**\r\n * (Browser only.) Sets cross-origin behavior for the request.\r\n *\r\n * See [the Fetch API specification](https://fetch.spec.whatwg.org/#request-class)\r\n * or the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n *\r\n * Default: `\"cors\"`\r\n */\r\n mode?: string;\r\n /**\r\n * (Browser only.) Request priority relative to other requests of the same type.\r\n *\r\n * See [the Fetch API specification](https://fetch.spec.whatwg.org/#request-class)\r\n * or the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n *\r\n * Default: `\"auto\"`\r\n */\r\n priority?: \"low\" | \"high\" | \"auto\";\r\n /**\r\n * (Browser only.) Policy to use for the `Referer` header, equivalent to the\r\n * semantics of the `Referrer-Policy` header.\r\n *\r\n * See [the Fetch API specification](https://fetch.spec.whatwg.org/#request-class)\r\n * or the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\r\n * for more information on the available options.\r\n */\r\n referrerPolicy?: string;\r\n};\r\n\r\n/**\r\n * Fetch-specific options for performing a request with arangojs.\r\n */\r\nexport type FetchOptions = CommonFetchOptions & {\r\n /**\r\n * Subresource integrity value to use for the request, formatted as\r\n * `<hash-algorithm>-<hash-source>`.\r\n */\r\n integrity?: `${string}-${string}`;\r\n};\r\n\r\n/**\r\n * Options that can be shared globally for all requests made with arangojs.\r\n */\r\nexport type CommonRequestOptions = {\r\n /**\r\n * Determines the behavior when a request fails because the underlying\r\n * connection to the server could not be opened\r\n * (e.g. [`ECONNREFUSED` in Node.js](https://nodejs.org/api/errors.html#errors_common_system_errors)):\r\n *\r\n * - `false`: the request fails immediately.\r\n *\r\n * - `0`: the request is retried until a server can be reached but only a\r\n * total number of times matching the number of known servers (including\r\n * the initial failed request).\r\n *\r\n * - any other number: the request is retried until a server can be reached\r\n * or the request has been retried a total of `maxRetries` number of times\r\n * (not including the initial failed request).\r\n *\r\n * When working with a single server, the retries (if any) will be made to\r\n * the same server.\r\n *\r\n * This setting currently has no effect when using arangojs in a browser.\r\n *\r\n * **Note**: Requests bound to a specific server (e.g. fetching query results)\r\n * will never be retried automatically and ignore this setting.\r\n *\r\n * **Note**: To set the number of retries when a write-write conflict is\r\n * encountered, see `retryOnConflict` instead.\r\n *\r\n * Default: `0`\r\n */\r\n maxRetries?: false | number;\r\n /**\r\n * If set to a positive number, requests will automatically be retried at\r\n * most this many times if they result in a write-write conflict.\r\n *\r\n * Default: `0`\r\n */\r\n retryOnConflict?: number;\r\n /**\r\n * Time in milliseconds after which arangojs will abort the request if the\r\n * socket has not already timed out.\r\n */\r\n timeout?: number;\r\n /**\r\n * Whether ArangoDB is allowed to perform a dirty read to respond to the\r\n * request. If set to `true`, the response may reflect a dirty state from\r\n * a non-authoritative server.\r\n *\r\n * Default: `false`\r\n */\r\n allowDirtyRead?: boolean;\r\n /**\r\n * Callback that will be invoked with the finished request object before it\r\n * is finalized. In the browser the request may already have been sent.\r\n *\r\n * @param req - Request object or XHR instance used for this request.\r\n */\r\n beforeRequest?: (req: globalThis.Request) => void | Promise<void>;\r\n /**\r\n * Callback that will be invoked when the server response has been received\r\n * and processed or when the request has been failed without a response.\r\n *\r\n * The originating request will be available as the `request` property\r\n * on either the error or response object.\r\n *\r\n * @param err - Error encountered when handling this request or `null`.\r\n * @param res - Response object for this request, if no error occurred.\r\n */\r\n afterResponse?: (\r\n err: errors.NetworkError | null,\r\n res?: globalThis.Response & { request: globalThis.Request }\r\n ) => void | Promise<void>;\r\n};\r\n\r\n/**\r\n * Options for performing a request with arangojs.\r\n */\r\nexport type RequestOptions = CommonRequestOptions & {\r\n /**\r\n * @internal\r\n *\r\n * Identifier of a specific ArangoDB host to use when more than one is known.\r\n */\r\n hostUrl?: string;\r\n /**\r\n * HTTP method to use in order to perform the request.\r\n *\r\n * Default: `\"GET\"`\r\n */\r\n method?: string;\r\n /**\r\n * URL path, relative to the server domain.\r\n */\r\n pathname?: string;\r\n /**\r\n * URL parameters to pass as part of the query string.\r\n */\r\n search?: URLSearchParams | Record<string, any>;\r\n /**\r\n * Headers object containing any additional headers to send with the request.\r\n *\r\n * Note that the `Authorization` header will be overridden if the `auth`\r\n * configuration option is set.\r\n */\r\n headers?:\r\n | string[][]\r\n | Record<string, string | ReadonlyArray<string>>\r\n | Headers;\r\n /**\r\n * Request body data.\r\n */\r\n body?: any;\r\n /**\r\n * Additional options to pass to the `fetch` function.\r\n */\r\n fetchOptions?: Omit<FetchOptions, \"headers\">;\r\n /**\r\n * If set to `true`, the request body will not be converted to JSON and\r\n * instead passed as-is.\r\n */\r\n isBinary?: boolean;\r\n /**\r\n * If set to `true`, the response body will not be interpreted as JSON and\r\n * instead passed as-is.\r\n */\r\n expectBinary?: boolean;\r\n};\r\n//#endregion\r\n\r\n//#region Connection class\r\n/**\r\n * @internal\r\n */\r\ntype Task<T = any> = {\r\n stack?: () => string;\r\n resolve: (result: T) => void;\r\n reject: (error: unknown) => void;\r\n transform?: (res: ProcessedResponse<any>) => T;\r\n retries: number;\r\n conflicts: number;\r\n options: RequestOptions;\r\n};\r\n\r\n/**\r\n * Indicates whether the given value represents a {@link Connection}.\r\n *\r\n * @param connection - A value that might be a connection.\r\n *\r\n * @internal\r\n */\r\nexport function isArangoConnection(connection: any): connection is Connection {\r\n return Boolean(connection && connection.isArangoConnection);\r\n}\r\n\r\n/**\r\n * Represents a connection pool shared by one or more databases.\r\n *\r\n * @internal\r\n */\r\nexport class Connection {\r\n protected _activeTasks: number = 0;\r\n protected _arangoVersion: number;\r\n protected _loadBalancingStrategy: configuration.LoadBalancingStrategy;\r\n protected _taskPoolSize: number;\r\n protected _commonRequestOptions: CommonRequestOptions;\r\n protected _commonFetchOptions: CommonFetchOptions & { headers: Headers };\r\n protected _queue = new LinkedList<Task>();\r\n protected _databases = new Map<string, databases.Database>();\r\n protected _hosts: Host[] = [];\r\n protected _hostUrls: string[] = [];\r\n protected _activeHostUrl: string;\r\n protected _activeDirtyHostUrl: string;\r\n protected _transactionId: string | null = null;\r\n protected _onError?: (err: Error) => void | Promise<void>;\r\n protected _precaptureStackTraces: boolean;\r\n protected _queueTimes = new LinkedList<[number, number]>();\r\n protected _responseQueueTimeSamples: number;\r\n protected _agentOptions?: any;\r\n\r\n /**\r\n * @internal\r\n *\r\n * Creates a new `Connection` instance.\r\n *\r\n * @param config - An object with configuration options.\r\n *\r\n */\r\n constructor(config: Omit<configuration.ConfigOptions, \"databaseName\"> = {}) {\r\n const {\r\n url = \"http://127.0.0.1:8529\",\r\n auth,\r\n arangoVersion = 31100,\r\n loadBalancingStrategy = \"NONE\",\r\n maxRetries = 0,\r\n poolSize = 3 *\r\n (loadBalancingStrategy === \"ROUND_ROBIN\" && Array.isArray(url)\r\n ? url.length\r\n : 1),\r\n fetchOptions: { headers, ...commonFetchOptions } = {},\r\n agentOptions,\r\n onError,\r\n precaptureStackTraces = false,\r\n responseQueueTimeSamples = 10,\r\n ...commonRequestOptions\r\n } = config;\r\n const URLS = Array.isArray(url) ? url : [url];\r\n this._loadBalancingStrategy = loadBalancingStrategy;\r\n this._precaptureStackTraces = precaptureStackTraces;\r\n this._responseQueueTimeSamples =\r\n responseQueueTimeSamples < 0 ? Infinity : responseQueueTimeSamples;\r\n this._arangoVersion = arangoVersion;\r\n this._taskPoolSize = poolSize;\r\n this._onError = onError;\r\n this._agentOptions = agentOptions;\r\n\r\n this._commonRequestOptions = commonRequestOptions;\r\n this._commonFetchOptions = {\r\n headers: new Headers(headers),\r\n ...commonFetchOptions,\r\n };\r\n\r\n this._commonFetchOptions.headers.set(\r\n \"x-arango-version\",\r\n String(arangoVersion)\r\n );\r\n this._commonFetchOptions.headers.set(\r\n \"x-arango-driver\",\r\n `arangojs/${process.env.ARANGOJS_VERSION} (cloud)`\r\n );\r\n\r\n this.addToHostList(URLS);\r\n\r\n if (auth) {\r\n if (configuration.isBearerAuth(auth)) {\r\n this.setBearerAuth(auth);\r\n } else {\r\n this.setBasicAuth(auth);\r\n }\r\n }\r\n\r\n if (this._loadBalancingStrategy === \"ONE_RANDOM\") {\r\n this._activeHostUrl =\r\n this._hostUrls[Math.floor(Math.random() * this._hostUrls.length)];\r\n this._activeDirtyHostUrl =\r\n this._hostUrls[Math.floor(Math.random() * this._hostUrls.length)];\r\n } else {\r\n this._activeHostUrl = this._hostUrls[0];\r\n this._activeDirtyHostUrl = this._hostUrls[0];\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Indicates that this object represents an ArangoDB connection.\r\n */\r\n get isArangoConnection(): true {\r\n return true;\r\n }\r\n\r\n get queueTime(): administration.QueueTimeMetrics {\r\n return {\r\n getLatest: () => this._queueTimes.last?.value[1],\r\n getValues: () => Array.from(this._queueTimes.values()),\r\n getAvg: () => {\r\n let avg = 0;\r\n for (const [, [, value]] of this._queueTimes) {\r\n avg += value / this._queueTimes.length;\r\n }\r\n return avg;\r\n },\r\n };\r\n }\r\n\r\n protected async _runQueue() {\r\n if (this._activeTasks >= this._taskPoolSize) return;\r\n const task = this._queue.shift();\r\n if (!task) return;\r\n let hostUrl = this._activeHostUrl;\r\n try {\r\n this._activeTasks += 1;\r\n if (task.options.hostUrl !== undefined) {\r\n hostUrl = task.options.hostUrl;\r\n } else if (task.options.allowDirtyRead) {\r\n hostUrl = this._activeDirtyHostUrl;\r\n const i = this._hostUrls.indexOf(this._activeDirtyHostUrl) + 1;\r\n this._activeDirtyHostUrl = this._hostUrls[i % this._hostUrls.length];\r\n } else if (this._loadBalancingStrategy === \"ROUND_ROBIN\") {\r\n const i = this._hostUrls.indexOf(this._activeHostUrl) + 1;\r\n this._activeHostUrl = this._hostUrls[i % this._hostUrls.length];\r\n }\r\n const host = this._hosts[this._hostUrls.indexOf(hostUrl)];\r\n const res: globalThis.Response & {\r\n request: globalThis.Request;\r\n arangojsHostUrl: string;\r\n parsedBody?: any;\r\n } = Object.assign(await host.fetch(task.options), {\r\n arangojsHostUrl: hostUrl,\r\n });\r\n const leaderEndpoint = res.headers.get(LEADER_ENDPOINT_HEADER);\r\n if (res.status === 503 && leaderEndpoint) {\r\n const [cleanUrl] = this.addToHostList(leaderEndpoint);\r\n task.options.hostUrl = cleanUrl;\r\n if (this._activeHostUrl === hostUrl) {\r\n this._activeHostUrl = cleanUrl;\r\n }\r\n this._queue.push(task);\r\n return;\r\n }\r\n const queueTime = res.headers.get(\"x-arango-queue-time-seconds\");\r\n if (queueTime) {\r\n this._queueTimes.push([Date.now(), Number(queueTime)]);\r\n while (this._responseQueueTimeSamples < this._queueTimes.length) {\r\n this._queueTimes.shift();\r\n }\r\n }\r\n const contentType = res.headers.get(\"content-type\");\r\n if (res.status >= 400) {\r\n if (contentType?.match(MIME_JSON)) {\r\n const errorResponse = res.clone();\r\n let errorBody: any;\r\n try {\r\n errorBody = await errorResponse.json();\r\n } catch {\r\n // noop\r\n }\r\n if (isArangoErrorResponse(errorBody)) {\r\n res.parsedBody = errorBody;\r\n throw errors.ArangoError.from(res);\r\n }\r\n }\r\n throw new errors.HttpError(res);\r\n }\r\n // Per RFC 7231, HEAD responses must not include a body \r\n // Skip body parsing for non-error HEAD responses to ensure cross-runtime compatibility\r\n if (res.body && task.options.method !== \"HEAD\") {\r\n if (task.options.expectBinary) {\r\n res.parsedBody = await res.blob();\r\n } else if (contentType?.match(MIME_JSON)) {\r\n res.parsedBody = await res.json();\r\n } else {\r\n res.parsedBody = await res.text();\r\n }\r\n }\r\n let result: any = res;\r\n if (task.transform) result = task.transform(res);\r\n task.resolve(result);\r\n } catch (e: unknown) {\r\n const err = e as Error;\r\n if (\r\n !task.options.allowDirtyRead &&\r\n this._hosts.length > 1 &&\r\n this._activeHostUrl === hostUrl &&\r\n this._loadBalancingStrategy !== \"ROUND_ROBIN\"\r\n ) {\r\n const i = this._hostUrls.indexOf(this._activeHostUrl) + 1;\r\n this._activeHostUrl = this._hostUrls[i % this._hostUrls.length];\r\n }\r\n if (\r\n errors.isArangoError(err) &&\r\n err.errorNum === ERROR_ARANGO_CONFLICT &&\r\n task.options.retryOnConflict &&\r\n task.conflicts < task.options.retryOnConflict\r\n ) {\r\n task.conflicts += 1;\r\n this._queue.push(task);\r\n return;\r\n }\r\n if (\r\n (errors.isNetworkError(err) || errors.isArangoError(err)) &&\r\n err.isSafeToRetry &&\r\n task.options.hostUrl === undefined &&\r\n this._commonRequestOptions.maxRetries !== false &&\r\n task.retries <\r\n (this._commonRequestOptions.maxRetries || this._hosts.length - 1)\r\n ) {\r\n task.retries += 1;\r\n this._queue.push(task);\r\n return;\r\n }\r\n if (task.stack) {\r\n err.stack += task.stack();\r\n }\r\n if (this._onError) {\r\n try {\r\n const p = this._onError(err);\r\n if (p instanceof Promise) await p;\r\n } catch (e) {\r\n (e as Error).cause = err;\r\n task.reject(e);\r\n return;\r\n }\r\n }\r\n task.reject(err);\r\n } finally {\r\n this._activeTasks -= 1;\r\n setTimeout(() => this._runQueue(), 0);\r\n }\r\n }\r\n\r\n setBearerAuth(auth: configuration.BearerAuthCredentials) {\r\n this.setHeader(\"authorization\", `Bearer ${auth.token}`);\r\n }\r\n\r\n setBasicAuth(auth: configuration.BasicAuthCredentials) {\r\n this.setHeader(\r\n \"authorization\",\r\n `Basic ${btoa(`${auth.username}:${auth.password}`)}`\r\n );\r\n }\r\n\r\n setResponseQueueTimeSamples(responseQueueTimeSamples: number) {\r\n if (responseQueueTimeSamples < 0) {\r\n responseQueueTimeSamples = Infinity;\r\n }\r\n this._responseQueueTimeSamples = responseQueueTimeSamples;\r\n while (this._responseQueueTimeSamples < this._queueTimes.length) {\r\n this._queueTimes.shift();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Fetches a {@link databases.Database} instance for the given database name from the\r\n * internal cache, if available.\r\n *\r\n * @param databaseName - Name of the database.\r\n */\r\n database(databaseName: string): databases.Database | undefined;\r\n /**\r\n * @internal\r\n *\r\n * Adds a {@link databases.Database} instance for the given database name to the\r\n * internal cache.\r\n *\r\n * @param databaseName - Name of the database.\r\n * @param database - Database instance to add to the cache.\r\n */\r\n database(\r\n databaseName: string,\r\n database: databases.Database\r\n ): databases.Database;\r\n /**\r\n * @internal\r\n *\r\n * Clears any {@link databases.Database} instance stored for the given database name\r\n * from the internal cache, if present.\r\n *\r\n * @param databaseName - Name of the database.\r\n * @param database - Must be `null`.\r\n */\r\n database(databaseName: string, database: null): undefined;\r\n database(\r\n databaseName: string,\r\n database?: databases.Database | null\r\n ): databases.Database | undefined {\r\n if (database === null) {\r\n this._databases.delete(databaseName);\r\n return undefined;\r\n }\r\n if (!database) {\r\n return this._databases.get(databaseName);\r\n }\r\n this._databases.set(databaseName, database);\r\n return database;\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Replaces the host list with the given URLs.\r\n *\r\n * See {@link Connection#acquireHostList}.\r\n *\r\n * @param urls - URLs to use as host list.\r\n */\r\n setHostList(urls: string[]): void {\r\n const cleanUrls = urls.map((url) => util.normalizeUrl(url));\r\n this._hosts.splice(\r\n 0,\r\n this._hosts.length,\r\n ...cleanUrls.map((url) => {\r\n const i = this._hostUrls.indexOf(url);\r\n if (i !== -1) return this._hosts[i];\r\n return createHost(url, this._agentOptions);\r\n })\r\n );\r\n this._hostUrls.splice(0, this._hostUrls.length, ...cleanUrls);\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Adds the given URL or URLs to the host list.\r\n *\r\n * See {@link Connection#acquireHostList}.\r\n *\r\n * @param urls - URL or URLs to add.\r\n */\r\n addToHostList(urls: string | string[]): string[] {\r\n const cleanUrls = (Array.isArray(urls) ? urls : [urls]).map((url) =>\r\n util.normalizeUrl(url)\r\n );\r\n const newUrls = cleanUrls.filter(\r\n (url) => this._hostUrls.indexOf(url) === -1\r\n );\r\n this._hostUrls.push(...newUrls);\r\n this._hosts.push(...newUrls.map((url) => createHost(url, this._agentOptions)));\r\n return cleanUrls;\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Sets the connection's active `transactionId`.\r\n *\r\n * While set, all requests will use this ID, ensuring the requests are executed\r\n * within the transaction if possible. Setting the ID manually may cause\r\n * unexpected behavior.\r\n *\r\n * See also {@link Connection#clearTransactionId}.\r\n *\r\n * @param transactionId - ID of the active transaction.\r\n */\r\n setTransactionId(transactionId: string) {\r\n this._transactionId = transactionId;\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Clears the connection's active `transactionId`.\r\n */\r\n clearTransactionId() {\r\n this._transactionId = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Sets the header `headerName` with the given `value` or clears the header if\r\n * `value` is `null`.\r\n *\r\n * @param headerName - Name of the header to set.\r\n * @param value - Value of the header.\r\n */\r\n setHeader(headerName: string, value: string | null) {\r\n if (value === null) {\r\n this._commonFetchOptions.headers.delete(headerName);\r\n } else {\r\n this._commonFetchOptions.headers.set(headerName, value);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Closes all open connections.\r\n *\r\n * See {@link databases.Database#close}.\r\n */\r\n close() {\r\n for (const host of this._hosts) {\r\n if (host.close) host.close();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Waits for propagation.\r\n *\r\n * See {@link databases.Database#waitForPropagation}.\r\n *\r\n * @param request - Request to perform against each coordinator.\r\n * @param timeout - Maximum number of milliseconds to wait for propagation.\r\n */\r\n async waitForPropagation(request: RequestOptions, timeout = Infinity) {\r\n const numHosts = this._hosts.length;\r\n const propagated = [] as string[];\r\n const started = Date.now();\r\n const endOfTime = started + timeout;\r\n let index = 0;\r\n while (true) {\r\n if (propagated.length === numHosts) {\r\n return;\r\n }\r\n while (propagated.includes(this._hostUrls[index])) {\r\n index = (index + 1) % numHosts;\r\n }\r\n const hostUrl = this._hostUrls[index];\r\n try {\r\n await this.request({\r\n ...request,\r\n hostUrl,\r\n timeout: endOfTime - Date.now(),\r\n });\r\n } catch (e) {\r\n if (endOfTime < Date.now()) {\r\n throw new errors.PropagationTimeoutError(undefined, {\r\n cause: e as Error,\r\n });\r\n }\r\n await new Promise((resolve) => setTimeout(resolve, 1000));\r\n continue;\r\n }\r\n if (!propagated.includes(hostUrl)) {\r\n propagated.push(hostUrl);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n *\r\n * Performs a request using the arangojs connection pool.\r\n */\r\n async request<\r\n T = globalThis.Response & { request: globalThis.Request; parsedBody?: any },\r\n >(\r\n requestOptions: RequestOptions & { isBinary?: boolean },\r\n transform?: (\r\n res: globalThis.Response & {\r\n request: globalThis.Request;\r\n parsedBody?: any;\r\n }\r\n ) => T\r\n ): Promise<T> {\r\n const {\r\n hostUrl,\r\n allowDirtyRead = false,\r\n isBinary = false,\r\n maxRetries = 0,\r\n method = \"GET\",\r\n retryOnConflict = 0,\r\n timeout = 0,\r\n headers: requestHeaders,\r\n body: requestBody,\r\n fetchOptions,\r\n ...taskOptions\r\n } = { ...this._commonRequestOptions, ...requestOptions };\r\n\r\n const headers = util.mergeHeaders(\r\n this._commonFetchOptions.headers,\r\n requestHeaders\r\n );\r\n\r\n let body = requestBody;\r\n if (body instanceof FormData) {\r\n const res = new Response(body);\r\n const blob = await res.blob();\r\n // Workaround for ArangoDB 3.12.0-rc1 and earlier:\r\n // Omitting the final CRLF results in \"bad request body\" fatal error\r\n body = new Blob([blob, \"\\r\\n\"], { type: blob.type });\r\n // Set content-length for Blob (needed for Next.js dynamic routes)\r\n if (!headers.has(\"content-length\")) {\r\n headers.set(\"content-length\", String(body.size));\r\n }\r\n } else if (body !== null && body !== undefined) {\r\n // Handle empty string explicitly\r\n if (body === \"\") {\r\n if (!headers.has(\"content-length\")) {\r\n headers.set(\"content-length\", \"0\");\r\n }\r\n if (!headers.has(\"content-type\")) {\r\n headers.set(\"content-type\", \"text/plain\");\r\n }\r\n } else {\r\n let contentType;\r\n if (isBinary) {\r\n contentType = \"application/octet-stream\";\r\n } else if (typeof body === \"object\") {\r\n body = JSON.stringify(body);\r\n contentType = \"application/json\";\r\n } else {\r\n body = String(body);\r\n contentType = \"text/plain\";\r\n }\r\n if (!headers.has(\"content-type\")) {\r\n headers.set(\"content-type\", contentType);\r\n }\r\n // Explicitly set content-length for fixed-size bodies\r\n // This is needed for Next.js dynamic routes (e.g., when using cookies())\r\n // and ensures compatibility with environments that don't set it automatically\r\n if (!headers.has(\"content-length\")) {\r\n if (typeof body === \"string\") {\r\n // Calculate byte length for UTF-8 encoded strings\r\n // Buffer is available in Node.js (required: >=20) and browser polyfills\r\n if (\r\n typeof globalThis.Buffer !== \"undefined\" &&\r\n globalThis.Buffer.byteLength\r\n ) {\r\n const contentLength = globalThis.Buffer.byteLength(body, \"utf8\");\r\n headers.set(\"content-length\", String(contentLength));\r\n } else {\r\n // Fallback: use TextEncoder for browser environments\r\n const encoder = new TextEncoder();\r\n const contentLength = encoder.encode(body).length;\r\n headers.set(\"content-length\", String(contentLength));\r\n }\r\n } else if (body instanceof Blob) {\r\n headers.set(\"content-length\", String(body.size));\r\n } else if (\r\n typeof globalThis.Buffer !== \"undefined\" &&\r\n globalThis.Buffer.isBuffer &&\r\n globalThis.Buffer.isBuffer(body)\r\n ) {\r\n headers.set(\"content-length\", String(body.length));\r\n }\r\n // Note: ArangoDB does not support Transfer-Encoding: chunked.\r\n // All public APIs only accept fixed-size bodies (string, Buffer, Blob, FormData, or objects that get JSON.stringify'd),\r\n // so streams should never reach this point. If an unknown body type is passed, it will be converted to string above.\r\n }\r\n }\r\n }\r\n // Handle null/undefined body for POST/PUT/PATCH methods that might need content-length: 0\r\n // This ensures compatibility with NextJS 15 and other environments that expect explicit content-length\r\n else if (\r\n (method === \"POST\" || method === \"PUT\" || method === \"PATCH\") &&\r\n !headers.has(\"content-length\")\r\n ) {\r\n headers.set(\"content-length\", \"0\");\r\n }\r\n\r\n if (this._transactionId) {\r\n headers.set(\"x-arango-trx-id\", this._transactionId);\r\n }\r\n\r\n if (allowDirtyRead) {\r\n headers.set(\"x-arango-allow-dirty-read\", \"true\");\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n const task: Task = {\r\n resolve,\r\n reject,\r\n transform,\r\n retries: 0,\r\n conflicts: 0,\r\n options: {\r\n ...taskOptions,\r\n hostUrl,\r\n method,\r\n headers,\r\n body,\r\n allowDirtyRead,\r\n retryOnConflict,\r\n maxRetries,\r\n fetchOptions,\r\n timeout,\r\n },\r\n };\r\n\r\n if (this._precaptureStackTraces) {\r\n if (typeof Error.captureStackTrace === \"function\") {\r\n const capture = {} as { readonly stack: string };\r\n Error.captureStackTrace(capture);\r\n task.stack = () =>\r\n `\\n${capture.stack.split(\"\\n\").slice(3).join(\"\\n\")}`;\r\n } else {\r\n const capture = util.generateStackTrace() as {\r\n readonly stack: string;\r\n };\r\n if (Object.prototype.hasOwnProperty.call(capture, \"stack\")) {\r\n task.stack = () =>\r\n `\\n${capture.stack.split(\"\\n\").slice(4).join(\"\\n\")}`;\r\n }\r\n }\r\n }\r\n\r\n this._queue.push(task);\r\n this._runQueue();\r\n });\r\n }\r\n}\r\n//#endregion\r\n"]}
|