arangojs 8.7.0 → 8.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -1
- package/analyzer.d.ts +69 -2
- package/analyzer.d.ts.map +1 -1
- package/analyzer.js.map +1 -1
- package/collection.d.ts +56 -26
- package/collection.d.ts.map +1 -1
- package/collection.js.map +1 -1
- package/connection.d.ts +5 -5
- package/connection.js +1 -1
- package/connection.js.map +1 -1
- package/indexes.d.ts +8 -8
- package/indexes.js +1 -1
- package/indexes.js.map +1 -1
- package/package.json +1 -1
- package/web.js +1 -1
- package/web.js.map +1 -1
package/connection.d.ts
CHANGED
|
@@ -274,9 +274,9 @@ export declare type Config = {
|
|
|
274
274
|
/**
|
|
275
275
|
* Base URL of the ArangoDB server or list of server URLs.
|
|
276
276
|
*
|
|
277
|
-
* When working with a cluster
|
|
278
|
-
*
|
|
279
|
-
*
|
|
277
|
+
* When working with a cluster, the method {@link database.Database#acquireHostList}
|
|
278
|
+
* can be used to automatically pick up additional coordinators/followers at
|
|
279
|
+
* any point.
|
|
280
280
|
*
|
|
281
281
|
* When running ArangoDB on a unix socket, e.g. `/tmp/arangodb.sock`, the
|
|
282
282
|
* following URL formats are supported for unix sockets:
|
|
@@ -352,8 +352,8 @@ export declare type Config = {
|
|
|
352
352
|
* or the request has been retried a total of `maxRetries` number of times
|
|
353
353
|
* (not including the initial failed request).
|
|
354
354
|
*
|
|
355
|
-
* When working with a single server
|
|
356
|
-
*
|
|
355
|
+
* When working with a single server, the retries (if any) will be made to
|
|
356
|
+
* the same server.
|
|
357
357
|
*
|
|
358
358
|
* This setting currently has no effect when using arangojs in a browser.
|
|
359
359
|
*
|
package/connection.js
CHANGED
|
@@ -451,7 +451,7 @@ class Connection {
|
|
|
451
451
|
...this._headers,
|
|
452
452
|
"content-type": contentType,
|
|
453
453
|
"x-arango-version": String(this._arangoVersion),
|
|
454
|
-
"x-arango-driver": `arangojs/8.
|
|
454
|
+
"x-arango-driver": `arangojs/8.8.0 (cloud)`,
|
|
455
455
|
};
|
|
456
456
|
if (this._transactionId) {
|
|
457
457
|
extraHeaders["x-arango-trx-id"] = this._transactionId;
|
package/connection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":";;;AAYA,iDAA2C;AAE3C,mCAMiB;AACjB,qCAA0C;AAC1C,uCAGqB;AAErB,qDAAkD;AAClD,yDAAsD;AACtD,2CAMuB;AAEvB,MAAM,SAAS,GAAG,2BAA2B,CAAC;AAC9C,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAyEnD,SAAS,YAAY,CAAC,IAAS;IAC7B,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB;IACzB,IAAI,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;IACtB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE;QACd,IAAI;YACF,MAAM,GAAG,CAAC;SACX;QAAC,OAAO,CAAM,EAAE;YACf,GAAG,GAAG,CAAC,CAAC;SACT;KACF;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAwWD;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAAC,UAAe;IAChD,OAAO,OAAO,CAAC,UAAU,IAAI,UAAU,CAAC,kBAAkB,CAAC,CAAC;AAC9D,CAAC;AAFD,gDAEC;AAED;;;;GAIG;AACH,MAAa,UAAU;IAqBrB;;;;;;;OAOG;IACH,YAAY,SAAuC,EAAE;QA5B3C,iBAAY,GAAW,CAAC,CAAC;QAGzB,mBAAc,GAAW,KAAK,CAAC;QAM/B,WAAM,GAAG,IAAI,0BAAU,EAAQ,CAAC;QAChC,eAAU,GAAG,IAAI,GAAG,EAAoB,CAAC;QACzC,WAAM,GAAsB,EAAE,CAAC;QAC/B,cAAS,GAAa,EAAE,CAAC;QAGzB,mB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;iBACF;aACF;YAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACvB,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAthBD,gCAshBC","sourcesContent":["/**\n * ```ts\n * import type { Config } from \"arangojs/connection\";\n * ```\n *\n * The \"connection\" module provides connection and configuration related types\n * for TypeScript.\n *\n * @packageDocumentation\n */\nimport { ClientRequest } from \"http\";\nimport { AgentOptions as NodeAgentOptions } from \"https\";\nimport { LinkedList } from \"x3-linkedlist\";\nimport { Database } from \"./database\";\nimport {\n ArangoError,\n HttpError,\n isArangoError,\n isArangoErrorResponse,\n isSystemError,\n} from \"./error\";\nimport { base64Encode } from \"./lib/btoa\";\nimport {\n ERROR_ARANGO_CONFLICT,\n ERROR_ARANGO_MAINTENANCE_MODE,\n} from \"./lib/codes\";\nimport { Errback } from \"./lib/errback\";\nimport { normalizeUrl } from \"./lib/normalizeUrl\";\nimport { querystringify } from \"./lib/querystringify\";\nimport {\n ArangojsError,\n ArangojsResponse,\n createRequest,\n isBrowser,\n RequestFunction,\n} from \"./lib/request\";\n\nconst MIME_JSON = /\\/(json|javascript)(\\W|$)/;\nconst LEADER_ENDPOINT_HEADER = \"x-arango-endpoint\";\n\n/**\n * Determines the behavior when multiple URLs are used:\n *\n * - `\"NONE\"`: No load balancing. All requests will be handled by the first\n * URL in the list until a network error is encountered. On network error,\n * arangojs will advance to using the next URL in the list.\n *\n * - `\"ONE_RANDOM\"`: Randomly picks one URL from the list initially, then\n * behaves like `\"NONE\"`.\n *\n * - `\"ROUND_ROBIN\"`: Every sequential request uses the next URL in the list.\n */\nexport type LoadBalancingStrategy = \"NONE\" | \"ROUND_ROBIN\" | \"ONE_RANDOM\";\n\n/**\n * An arbitrary object with string values representing HTTP headers and their\n * values.\n *\n * Header names should always be lowercase.\n */\nexport type Headers = Record<string, string>;\n\n/**\n * An arbitrary object with scalar values representing query string parameters\n * and their values.\n */\nexport type Params = Record<string, any>;\n\n/**\n * Generic properties shared by all ArangoDB HTTP API responses.\n */\nexport type ArangoResponseMetadata = {\n /**\n * Indicates that the request was successful.\n */\n error: false;\n /**\n * Response status code, typically `200`.\n */\n code: number;\n};\n\n/**\n * Extends the given base type `T` with the generic HTTP API response properties.\n */\nexport type ArangoApiResponse<T> = T & ArangoResponseMetadata;\n\n/**\n * Credentials for HTTP Basic authentication.\n */\nexport type BasicAuthCredentials = {\n /**\n * Username to use for authentication, e.g. `\"root\"`.\n */\n username: string;\n /**\n * Password to use for authentication. Defaults to an empty string.\n */\n password?: string;\n};\n\n/**\n * Credentials for HTTP Bearer token authentication.\n */\nexport type BearerAuthCredentials = {\n /**\n * Bearer token to use for authentication.\n */\n token: string;\n};\n\nfunction isBearerAuth(auth: any): auth is BearerAuthCredentials {\n return auth.hasOwnProperty(\"token\");\n}\n\n/**\n * @internal\n */\nfunction generateStackTrace() {\n let err = new Error();\n if (!err.stack) {\n try {\n throw err;\n } catch (e: any) {\n err = e;\n }\n }\n return err;\n}\n\n/**\n * @internal\n */\ntype UrlInfo = {\n absolutePath?: boolean;\n basePath?: string;\n path?: string;\n qs?: string | Params;\n};\n\n/**\n * Options of the `xhr` module that can be set using `agentOptions` when using\n * arangojs in the browser. Additionally `maxSockets` can be used to control\n * the maximum number of parallel requests.\n *\n * See also: [`xhr` on npm](https://www.npmjs.com/package/xhr).\n */\nexport type XhrOptions = {\n /**\n * Maximum number of parallel requests arangojs will perform. If any\n * additional requests are attempted, they will be enqueued until one of the\n * active requests has completed.\n */\n maxSockets?: number;\n /**\n * Number of milliseconds to wait for a response.\n *\n * Default: `0` (disabled)\n */\n timeout?: number;\n /**\n * Callback that will be invoked immediately before the `send` method of the\n * request is called.\n *\n * See also {@link RequestInterceptors}.\n */\n beforeSend?: (xhrObject: any) => void;\n /**\n * `XMLHttpRequest` object to use instead of the native implementation.\n */\n xhr?: any;\n /**\n * (Internet Explorer 10 and lower only.) Whether `XDomainRequest` should be\n * used instead of `XMLHttpRequest`. Only required for performing\n * cross-domain requests in older versions of Internet Explorer.\n */\n useXdr?: boolean;\n /**\n * Specifies whether browser credentials (e.g. cookies) should be sent if\n * performing a cross-domain request.\n *\n * See [`XMLHttpRequest.withCredentials`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials).\n */\n withCredentials?: boolean;\n};\n\n/**\n * Additional options for intercepting the request/response. These methods\n * are primarily intended for tracking network related metrics.\n */\nexport type RequestInterceptors = {\n /**\n * Callback that will be invoked with the finished request object before it\n * is finalized. In the browser the request may already have been sent.\n *\n * @param req - Request object or XHR instance used for this request.\n */\n before?: (req: ClientRequest) => void;\n /**\n * Callback that will be invoked when the server response has been received\n * and processed or when the request has been failed without a response.\n *\n * The originating request will be available as the `request` property\n * on either the error or response object.\n *\n * @param err - Error encountered when handling this request or `null`.\n * @param res - Response object for this request, if no error occurred.\n */\n after?: (err: ArangojsError | null, res?: ArangojsResponse) => void;\n};\n\n/**\n * Options for performing a request with arangojs.\n */\nexport type RequestOptions = {\n /**\n * @internal\n *\n * Identifier of a specific ArangoDB host to use when more than one is known.\n */\n hostUrl?: string;\n /**\n * HTTP method to use in order to perform the request.\n *\n * Default: `\"GET\"`\n */\n method?: string;\n /**\n * Request body data.\n */\n body?: any;\n /**\n * If set to `true`, the response body will not be interpreted as JSON and\n * instead passed as-is.\n */\n expectBinary?: boolean;\n /**\n * If set to `true`, the request body will not be converted to JSON and\n * instead passed as-is.\n */\n isBinary?: boolean;\n /**\n * Whether ArangoDB is allowed to perform a dirty read to respond to this\n * request. If set to `true`, the response may reflect a dirty state from\n * a non-authoritative server.\n */\n allowDirtyRead?: boolean;\n /**\n * If set to a positive number, the request will automatically be retried at\n * most this many times if it results in a write-write conflict.\n *\n * Default: `config.retryOnConflict`\n */\n retryOnConflict?: number;\n /**\n * HTTP headers to pass along with this request in addition to the default\n * headers generated by arangojs.\n */\n headers?: Headers;\n /**\n * Time in milliseconds after which arangojs will abort the request if the\n * socket has not already timed out.\n *\n * See also `agentOptions.timeout` in {@link Config}.\n */\n timeout?: number;\n /**\n * Optional prefix path to prepend to the `path`.\n */\n basePath?: string;\n /**\n * URL path, relative to the `basePath` and server domain.\n */\n path?: string;\n /**\n * URL parameters to pass as part of the query string.\n */\n qs?: string | Params;\n};\n\n/**\n * @internal\n */\ntype Task = {\n hostUrl?: string;\n stack?: () => string;\n allowDirtyRead: boolean;\n retryOnConflict: number;\n resolve: (result: any) => void;\n reject: (error: Error) => void;\n transform?: (res: ArangojsResponse) => any;\n retries: number;\n options: {\n method: string;\n expectBinary: boolean;\n timeout?: number;\n url: { pathname: string; search?: string };\n headers: Headers;\n body: any;\n };\n};\n\n/**\n * Options for creating the Node.js `http.Agent` or `https.Agent`.\n *\n * In browser environments this option can be used to pass additional options\n * to the underlying calls of the\n * [xhr module](https://www.npmjs.com/package/xhr).\n *\n * See also [`http.Agent`](https://nodejs.org/api/http.html#http_new_agent_options)\n * and [`https.Agent`](https://nodejs.org/api/https.html#https_new_agent_options)\n * (when using TLS).\n */\nexport type AgentOptions = NodeAgentOptions | XhrOptions;\n\n/**\n * Options for configuring arangojs.\n */\nexport type Config = {\n /**\n * Name of the database to use.\n *\n * Default: `\"_system\"`\n */\n databaseName?: string;\n /**\n * Base URL of the ArangoDB server or list of server URLs.\n *\n * When working with a cluster or a single server with leader/follower\n * failover, the method {@link database.Database#acquireHostList} can be used to\n * automatically pick up additional coordinators/followers at any point.\n *\n * When running ArangoDB on a unix socket, e.g. `/tmp/arangodb.sock`, the\n * following URL formats are supported for unix sockets:\n *\n * - `unix:///tmp/arangodb.sock` (no SSL)\n * - `http+unix:///tmp/arangodb.sock` (or `https+unix://` for SSL)\n * - `http://unix:/tmp/arangodb.sock` (or `https://unix:` for SSL)\n *\n * Additionally `ssl` and `tls` are treated as synonymous with `https` and\n * `tcp` is treated as synonymous with `http`, so the following URLs are\n * considered identical:\n *\n * - `tcp://127.0.0.1:8529` and `http://127.0.0.1:8529`\n * - `ssl://127.0.0.1:8529` and `https://127.0.0.1:8529`\n * - `tcp+unix:///tmp/arangodb.sock` and `http+unix:///tmp/arangodb.sock`\n * - `ssl+unix:///tmp/arangodb.sock` and `https+unix:///tmp/arangodb.sock`\n * - `tcp://unix:/tmp/arangodb.sock` and `http://unix:/tmp/arangodb.sock`\n * - `ssl://unix:/tmp/arangodb.sock` and `https://unix:/tmp/arangodb.sock`\n *\n * See also `auth` for passing authentication credentials.\n *\n * Default: `\"http://127.0.0.1:8529\"`\n */\n url?: string | string[];\n /**\n * Credentials to use for authentication.\n *\n * See also {@link database.Database#useBasicAuth} and\n * {@link database.Database#useBearerAuth}.\n *\n * Default: `{ username: \"root\", password: \"\" }`\n */\n auth?: BasicAuthCredentials | BearerAuthCredentials;\n /**\n * Numeric representation of the ArangoDB version the driver should expect.\n * The format is defined as `XYYZZ` where `X` is the major version, `Y` is\n * the zero-filled two-digit minor version and `Z` is the zero-filled two-digit\n * bugfix version, e.g. `30102` for 3.1.2, `20811` for 2.8.11.\n *\n * Depending on this value certain methods may become unavailable or change\n * their behavior to remain compatible with different versions of ArangoDB.\n *\n * Default: `30900`\n */\n arangoVersion?: number;\n /**\n * Determines the behavior when multiple URLs are provided:\n *\n * - `\"NONE\"`: No load balancing. All requests will be handled by the first\n * URL in the list until a network error is encountered. On network error,\n * arangojs will advance to using the next URL in the list.\n *\n * - `\"ONE_RANDOM\"`: Randomly picks one URL from the list initially, then\n * behaves like `\"NONE\"`.\n *\n * - `\"ROUND_ROBIN\"`: Every sequential request uses the next URL in the list.\n *\n * Default: `\"NONE\"`\n */\n loadBalancingStrategy?: LoadBalancingStrategy;\n /**\n * Determines the behavior when a request fails because the underlying\n * connection to the server could not be opened\n * (i.e. [`ECONNREFUSED` in Node.js](https://nodejs.org/api/errors.html#errors_common_system_errors)):\n *\n * - `false`: the request fails immediately.\n *\n * - `0`: the request is retried until a server can be reached but only a\n * total number of times matching the number of known servers (including\n * the initial failed request).\n *\n * - any other number: the request is retried until a server can be reached\n * or the request has been retried a total of `maxRetries` number of times\n * (not including the initial failed request).\n *\n * When working with a single server without leader/follower failover, the\n * retries (if any) will be made to the same server.\n *\n * This setting currently has no effect when using arangojs in a browser.\n *\n * **Note**: Requests bound to a specific server (e.g. fetching query results)\n * will never be retried automatically and ignore this setting.\n *\n * **Note**: To set the number of retries when a write-write conflict is\n * encountered, see `retryOnConflict` instead.\n *\n * Default: `0`\n */\n maxRetries?: false | number;\n /**\n * If set to a positive number, requests will automatically be retried at\n * most this many times if they result in a write-write conflict.\n *\n * Default: `0`\n */\n retryOnConflict?: number;\n /**\n * An http `Agent` instance to use for connections.\n *\n * By default a new `Agent` instance will be created using the `agentOptions`.\n *\n * This option has no effect when using the browser version of arangojs.\n *\n * See also [`http.Agent`](https://nodejs.org/api/http.html#http_new_agent_options)\n * and [`https.Agent`](https://nodejs.org/api/https.html#https_new_agent_options)\n * (when using TLS).\n */\n agent?: any;\n /**\n * Options used to create that underlying HTTP/HTTPS `Agent` (or the `xhr`\n * module when using arangojs in the browser). This will be ignored if\n * `agent` is also provided.\n *\n * The option `maxSockets` is also used to limit how many requests\n * arangojs will perform concurrently. The maximum number of requests is\n * equal to `maxSockets`.\n *\n * **Note:** arangojs will limit the number of concurrent requests based on\n * this value even if an `agent` is provided.\n *\n * **Note:** when using `ROUND_ROBIN` load balancing and passing an array of\n * URLs in the `url` option, the default value of `maxSockets` will be set\n * to `3 * url.length` instead of `3`.\n *\n * Default (Node.js): `{ maxSockets: 3, keepAlive: true, keepAliveMsecs: 1000 }`\n *\n * Default (browser): `{ maxSockets: 3, useXDR: true, withCredentials: true }`\n */\n agentOptions?: AgentOptions & RequestInterceptors;\n /**\n * An object with additional headers to send with every request.\n *\n * If an `\"authorization\"` header is provided, it will be overridden when\n * using {@link database.Database#useBasicAuth}, {@link database.Database#useBearerAuth} or\n * the `auth` configuration option.\n */\n headers?: Headers;\n /**\n * If set to `true`, arangojs will generate stack traces every time a request\n * is initiated and augment the stack traces of any errors it generates.\n *\n * **Warning**: This will cause arangojs to generate stack traces in advance\n * even if the request does not result in an error. Generating stack traces\n * may negatively impact performance.\n */\n precaptureStackTraces?: boolean;\n /**\n * Limits the number of values of server-reported response queue times that\n * will be stored and accessible using {@link database.Database#queueTime}. If set to\n * a finite value, older values will be discarded to make room for new values\n * when that limit is reached.\n *\n * Default: `10`\n */\n responseQueueTimeSamples?: number;\n};\n\n/**\n * Indicates whether the given value represents a {@link Connection}.\n *\n * @param connection - A value that might be a connection.\n *\n * @internal\n */\nexport function isArangoConnection(connection: any): connection is Connection {\n return Boolean(connection && connection.isArangoConnection);\n}\n\n/**\n * Represents a connection pool shared by one or more databases.\n *\n * @internal\n */\nexport class Connection {\n protected _activeTasks: number = 0;\n protected _agent?: any;\n protected _agentOptions: { [key: string]: any };\n protected _arangoVersion: number = 30900;\n protected _headers: Headers;\n protected _loadBalancingStrategy: LoadBalancingStrategy;\n protected _maxRetries: number | false;\n protected _retryOnConflict: number;\n protected _maxTasks: number;\n protected _queue = new LinkedList<Task>();\n protected _databases = new Map<string, Database>();\n protected _hosts: RequestFunction[] = [];\n protected _hostUrls: string[] = [];\n protected _activeHostUrl: string;\n protected _activeDirtyHostUrl: string;\n protected _transactionId: string | null = null;\n protected _precaptureStackTraces: boolean;\n protected _queueTimes = new LinkedList<[number, number]>();\n protected _responseQueueTimeSamples: number;\n\n /**\n * @internal\n *\n * Creates a new `Connection` instance.\n *\n * @param config - An object with configuration options.\n *\n */\n constructor(config: Omit<Config, \"databaseName\"> = {}) {\n const URLS = config.url\n ? Array.isArray(config.url)\n ? config.url\n : [config.url]\n : [\"http://127.0.0.1:8529\"];\n const MAX_SOCKETS =\n 3 * (config.loadBalancingStrategy === \"ROUND_ROBIN\" ? URLS.length : 1);\n\n if (config.arangoVersion !== undefined) {\n this._arangoVersion = config.arangoVersion;\n }\n this._agent = config.agent;\n this._agentOptions = isBrowser\n ? { maxSockets: MAX_SOCKETS, ...config.agentOptions }\n : {\n maxSockets: MAX_SOCKETS,\n keepAlive: true,\n keepAliveMsecs: 1000,\n scheduling: \"lifo\",\n ...config.agentOptions,\n };\n this._maxTasks = this._agentOptions.maxSockets;\n this._headers = { ...config.headers };\n this._loadBalancingStrategy = config.loadBalancingStrategy ?? \"NONE\";\n this._precaptureStackTraces = Boolean(config.precaptureStackTraces);\n this._responseQueueTimeSamples = config.responseQueueTimeSamples ?? 10;\n this._retryOnConflict = config.retryOnConflict ?? 0;\n if (this._responseQueueTimeSamples < 0) {\n this._responseQueueTimeSamples = Infinity;\n }\n if (config.maxRetries === false) {\n this._maxRetries = false;\n } else {\n this._maxRetries = Number(config.maxRetries ?? 0);\n }\n\n this.addToHostList(URLS);\n\n if (config.auth) {\n if (isBearerAuth(config.auth)) {\n this.setBearerAuth(config.auth);\n } else {\n this.setBasicAuth(config.auth);\n }\n }\n\n if (this._loadBalancingStrategy === \"ONE_RANDOM\") {\n this._activeHostUrl =\n this._hostUrls[Math.floor(Math.random() * this._hostUrls.length)];\n this._activeDirtyHostUrl =\n this._hostUrls[Math.floor(Math.random() * this._hostUrls.length)];\n } else {\n this._activeHostUrl = this._hostUrls[0];\n this._activeDirtyHostUrl = this._hostUrls[0];\n }\n }\n\n /**\n * @internal\n *\n * Indicates that this object represents an ArangoDB connection.\n */\n get isArangoConnection(): true {\n return true;\n }\n\n get queueTime() {\n return {\n getLatest: () => this._queueTimes.last?.value[1],\n getValues: () => Array.from(this._queueTimes.values()),\n getAvg: () => {\n let avg = 0;\n for (const [, [, value]] of this._queueTimes) {\n avg += value / this._queueTimes.length;\n }\n return avg;\n },\n };\n }\n\n protected _runQueue() {\n if (!this._queue.length || this._activeTasks >= this._maxTasks) return;\n const task = this._queue.shift()!;\n let hostUrl = this._activeHostUrl;\n if (task.hostUrl !== undefined) {\n hostUrl = task.hostUrl;\n } else if (task.allowDirtyRead) {\n hostUrl = this._activeDirtyHostUrl;\n this._activeDirtyHostUrl =\n this._hostUrls[\n (this._hostUrls.indexOf(this._activeDirtyHostUrl) + 1) %\n this._hostUrls.length\n ];\n task.options.headers[\"x-arango-allow-dirty-read\"] = \"true\";\n } else if (this._loadBalancingStrategy === \"ROUND_ROBIN\") {\n this._activeHostUrl =\n this._hostUrls[\n (this._hostUrls.indexOf(this._activeHostUrl) + 1) %\n this._hostUrls.length\n ];\n }\n this._activeTasks += 1;\n const callback: Errback<ArangojsResponse> = (err, res) => {\n this._activeTasks -= 1;\n if (!err && res) {\n if (res.statusCode === 503 && res.headers[LEADER_ENDPOINT_HEADER]) {\n const url = res.headers[LEADER_ENDPOINT_HEADER]!;\n const [cleanUrl] = this.addToHostList(url);\n task.hostUrl = cleanUrl;\n if (this._activeHostUrl === hostUrl) {\n this._activeHostUrl = cleanUrl;\n }\n this._queue.push(task);\n } else {\n res.arangojsHostUrl = hostUrl;\n const contentType = res.headers[\"content-type\"];\n const queueTime = res.headers[\"x-arango-queue-time-seconds\"];\n if (queueTime) {\n this._queueTimes.push([Date.now(), Number(queueTime)]);\n while (this._responseQueueTimeSamples < this._queueTimes.length) {\n this._queueTimes.shift();\n }\n }\n let parsedBody: any = undefined;\n if (res.body.length && contentType && contentType.match(MIME_JSON)) {\n try {\n parsedBody = res.body;\n parsedBody = JSON.parse(parsedBody);\n } catch (e: any) {\n if (!task.options.expectBinary) {\n if (typeof parsedBody !== \"string\") {\n parsedBody = res.body.toString(\"utf-8\");\n }\n e.res = res;\n if (task.stack) {\n e.stack += task.stack();\n }\n callback(e);\n return;\n }\n }\n } else if (res.body && !task.options.expectBinary) {\n parsedBody = res.body.toString(\"utf-8\");\n } else {\n parsedBody = res.body;\n }\n if (isArangoErrorResponse(parsedBody)) {\n res.body = parsedBody;\n err = new ArangoError(res);\n } else if (res.statusCode && res.statusCode >= 400) {\n res.body = parsedBody;\n err = new HttpError(res);\n } else {\n if (!task.options.expectBinary) res.body = parsedBody;\n task.resolve(task.transform ? task.transform(res) : (res as any));\n }\n }\n }\n if (err) {\n if (\n !task.allowDirtyRead &&\n this._hosts.length > 1 &&\n this._activeHostUrl === hostUrl &&\n this._loadBalancingStrategy !== \"ROUND_ROBIN\"\n ) {\n this._activeHostUrl =\n this._hostUrls[\n (this._hostUrls.indexOf(this._activeHostUrl) + 1) %\n this._hostUrls.length\n ];\n }\n if (\n isArangoError(err) &&\n err.errorNum === ERROR_ARANGO_CONFLICT &&\n task.retryOnConflict > 0\n ) {\n task.retryOnConflict -= 1;\n this._queue.push(task);\n } else if (\n ((isSystemError(err) &&\n err.syscall === \"connect\" &&\n err.code === \"ECONNREFUSED\") ||\n (isArangoError(err) &&\n err.errorNum === ERROR_ARANGO_MAINTENANCE_MODE)) &&\n task.hostUrl === undefined &&\n this._maxRetries !== false &&\n task.retries < (this._maxRetries || this._hosts.length - 1)\n ) {\n task.retries += 1;\n this._queue.push(task);\n } else {\n if (task.stack) {\n err.stack += task.stack();\n }\n task.reject(err);\n }\n }\n this._runQueue();\n };\n try {\n this._hosts[this._hostUrls.indexOf(hostUrl)](task.options, callback);\n } catch (e: any) {\n callback(e);\n }\n }\n\n protected _buildUrl({ basePath, path, qs }: UrlInfo) {\n const pathname = `${basePath || \"\"}${path || \"\"}`;\n let search;\n if (qs) {\n if (typeof qs === \"string\") search = `?${qs}`;\n else search = `?${querystringify(qs)}`;\n }\n return search ? { pathname, search } : { pathname };\n }\n\n setBearerAuth(auth: BearerAuthCredentials) {\n this.setHeader(\"authorization\", `Bearer ${auth.token}`);\n }\n\n setBasicAuth(auth: BasicAuthCredentials) {\n this.setHeader(\n \"authorization\",\n `Basic ${base64Encode(`${auth.username}:${auth.password}`)}`\n );\n }\n\n setResponseQueueTimeSamples(responseQueueTimeSamples: number) {\n if (responseQueueTimeSamples < 0) {\n responseQueueTimeSamples = Infinity;\n }\n this._responseQueueTimeSamples = responseQueueTimeSamples;\n while (this._responseQueueTimeSamples < this._queueTimes.length) {\n this._queueTimes.shift();\n }\n }\n\n /**\n * @internal\n *\n * Fetches a {@link database.Database} instance for the given database name from the\n * internal cache, if available.\n *\n * @param databaseName - Name of the database.\n */\n database(databaseName: string): Database | undefined;\n /**\n * @internal\n *\n * Adds a {@link database.Database} instance for the given database name to the\n * internal cache.\n *\n * @param databaseName - Name of the database.\n * @param database - Database instance to add to the cache.\n */\n database(databaseName: string, database: Database): Database;\n /**\n * @internal\n *\n * Clears any {@link database.Database} instance stored for the given database name\n * from the internal cache, if present.\n *\n * @param databaseName - Name of the database.\n * @param database - Must be `null`.\n */\n database(databaseName: string, database: null): undefined;\n database(\n databaseName: string,\n database?: Database | null\n ): Database | undefined {\n if (database === null) {\n this._databases.delete(databaseName);\n return undefined;\n }\n if (!database) {\n return this._databases.get(databaseName);\n }\n this._databases.set(databaseName, database);\n return database;\n }\n\n /**\n * @internal\n *\n * Replaces the host list with the given URLs.\n *\n * See {@link Connection#acquireHostList}.\n *\n * @param urls - URLs to use as host list.\n */\n setHostList(urls: string[]): void {\n const cleanUrls = urls.map((url) => normalizeUrl(url));\n this._hosts.splice(\n 0,\n this._hosts.length,\n ...cleanUrls.map((url) => {\n const i = this._hostUrls.indexOf(url);\n if (i !== -1) return this._hosts[i];\n return createRequest(url, this._agentOptions, this._agent);\n })\n );\n this._hostUrls.splice(0, this._hostUrls.length, ...cleanUrls);\n }\n\n /**\n * @internal\n *\n * Adds the given URL or URLs to the host list.\n *\n * See {@link Connection#acquireHostList}.\n *\n * @param urls - URL or URLs to add.\n */\n addToHostList(urls: string | string[]): string[] {\n const cleanUrls = (Array.isArray(urls) ? urls : [urls]).map((url) =>\n normalizeUrl(url)\n );\n const newUrls = cleanUrls.filter(\n (url) => this._hostUrls.indexOf(url) === -1\n );\n this._hostUrls.push(...newUrls);\n this._hosts.push(\n ...newUrls.map((url: string) =>\n createRequest(url, this._agentOptions, this._agent)\n )\n );\n return cleanUrls;\n }\n\n /**\n * @internal\n *\n * Sets the connection's active `transactionId`.\n *\n * While set, all requests will use this ID, ensuring the requests are executed\n * within the transaction if possible. Setting the ID manually may cause\n * unexpected behavior.\n *\n * See also {@link Connection#clearTransactionId}.\n *\n * @param transactionId - ID of the active transaction.\n */\n setTransactionId(transactionId: string) {\n this._transactionId = transactionId;\n }\n\n /**\n * @internal\n *\n * Clears the connection's active `transactionId`.\n */\n clearTransactionId() {\n this._transactionId = null;\n }\n\n /**\n * @internal\n *\n * Sets the header `headerName` with the given `value` or clears the header if\n * `value` is `null`.\n *\n * @param headerName - Name of the header to set.\n * @param value - Value of the header.\n */\n setHeader(headerName: string, value: string | null) {\n if (value === null) {\n delete this._headers[headerName];\n } else {\n this._headers[headerName] = value;\n }\n }\n\n /**\n * @internal\n *\n * Closes all open connections.\n *\n * See {@link database.Database#close}.\n */\n close() {\n for (const host of this._hosts) {\n if (host.close) host.close();\n }\n }\n\n /**\n * @internal\n *\n * Waits for propagation.\n *\n * See {@link database.Database#waitForPropagation}.\n *\n * @param request - Request to perform against each coordinator.\n * @param timeout - Maximum number of milliseconds to wait for propagation.\n */\n async waitForPropagation(request: RequestOptions, timeout = Infinity) {\n const numHosts = this._hosts.length;\n const propagated = [] as string[];\n const started = Date.now();\n let index = 0;\n while (true) {\n if (propagated.length === numHosts) {\n return;\n }\n while (propagated.includes(this._hostUrls[index])) {\n index = (index + 1) % numHosts;\n }\n const hostUrl = this._hostUrls[index];\n try {\n await this.request({ ...request, hostUrl });\n } catch (e: any) {\n if (started + timeout < Date.now()) {\n throw e;\n }\n await new Promise((resolve) => setTimeout(resolve, 1000));\n continue;\n }\n if (!propagated.includes(hostUrl)) {\n propagated.push(hostUrl);\n }\n }\n }\n\n /**\n * @internal\n *\n * Performs a request using the arangojs connection pool.\n */\n request<T = ArangojsResponse>(\n {\n hostUrl,\n method = \"GET\",\n body,\n expectBinary = false,\n isBinary = false,\n allowDirtyRead = false,\n retryOnConflict = this._retryOnConflict,\n timeout = 0,\n headers,\n ...urlInfo\n }: RequestOptions,\n transform?: (res: ArangojsResponse) => T\n ): Promise<T> {\n return new Promise((resolve, reject) => {\n let contentType = \"text/plain\";\n if (isBinary) {\n contentType = \"application/octet-stream\";\n } else if (body) {\n if (typeof body === \"object\") {\n body = JSON.stringify(body);\n contentType = \"application/json\";\n } else {\n body = String(body);\n }\n }\n\n const extraHeaders: Headers = {\n ...this._headers,\n \"content-type\": contentType,\n \"x-arango-version\": String(this._arangoVersion),\n \"x-arango-driver\": `arangojs/${process.env.ARANGOJS_VERSION} (cloud)`,\n };\n\n if (this._transactionId) {\n extraHeaders[\"x-arango-trx-id\"] = this._transactionId;\n }\n\n const task: Task = {\n retries: 0,\n hostUrl,\n allowDirtyRead,\n retryOnConflict,\n options: {\n url: this._buildUrl(urlInfo),\n headers: { ...extraHeaders, ...headers },\n timeout,\n method,\n expectBinary,\n body,\n },\n reject,\n resolve,\n transform,\n };\n\n if (this._precaptureStackTraces) {\n if (typeof Error.captureStackTrace === \"function\") {\n const capture = {} as { readonly stack: string };\n Error.captureStackTrace(capture);\n task.stack = () =>\n `\\n${capture.stack.split(\"\\n\").slice(3).join(\"\\n\")}`;\n } else {\n const capture = generateStackTrace() as { readonly stack: string };\n if (Object.prototype.hasOwnProperty.call(capture, \"stack\")) {\n task.stack = () =>\n `\\n${capture.stack.split(\"\\n\").slice(4).join(\"\\n\")}`;\n }\n }\n }\n\n this._queue.push(task);\n this._runQueue();\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":";;;AAYA,iDAA2C;AAE3C,mCAMiB;AACjB,qCAA0C;AAC1C,uCAGqB;AAErB,qDAAkD;AAClD,yDAAsD;AACtD,2CAMuB;AAEvB,MAAM,SAAS,GAAG,2BAA2B,CAAC;AAC9C,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAyEnD,SAAS,YAAY,CAAC,IAAS;IAC7B,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB;IACzB,IAAI,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;IACtB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE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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;iBACxD;qBAAM;oBACL,MAAM,OAAO,GAAG,kBAAkB,EAAgC,CAAC;oBACnE,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE;wBAC1D,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;qBACxD;iBACF;aACF;YAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACvB,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAthBD,gCAshBC","sourcesContent":["/**\n * ```ts\n * import type { Config } from \"arangojs/connection\";\n * ```\n *\n * The \"connection\" module provides connection and configuration related types\n * for TypeScript.\n *\n * @packageDocumentation\n */\nimport { ClientRequest } from \"http\";\nimport { AgentOptions as NodeAgentOptions } from \"https\";\nimport { LinkedList } from \"x3-linkedlist\";\nimport { Database } from \"./database\";\nimport {\n ArangoError,\n HttpError,\n isArangoError,\n isArangoErrorResponse,\n isSystemError,\n} from \"./error\";\nimport { base64Encode } from \"./lib/btoa\";\nimport {\n ERROR_ARANGO_CONFLICT,\n ERROR_ARANGO_MAINTENANCE_MODE,\n} from \"./lib/codes\";\nimport { Errback } from \"./lib/errback\";\nimport { normalizeUrl } from \"./lib/normalizeUrl\";\nimport { querystringify } from \"./lib/querystringify\";\nimport {\n ArangojsError,\n ArangojsResponse,\n createRequest,\n isBrowser,\n RequestFunction,\n} from \"./lib/request\";\n\nconst MIME_JSON = /\\/(json|javascript)(\\W|$)/;\nconst LEADER_ENDPOINT_HEADER = \"x-arango-endpoint\";\n\n/**\n * Determines the behavior when multiple URLs are used:\n *\n * - `\"NONE\"`: No load balancing. All requests will be handled by the first\n * URL in the list until a network error is encountered. On network error,\n * arangojs will advance to using the next URL in the list.\n *\n * - `\"ONE_RANDOM\"`: Randomly picks one URL from the list initially, then\n * behaves like `\"NONE\"`.\n *\n * - `\"ROUND_ROBIN\"`: Every sequential request uses the next URL in the list.\n */\nexport type LoadBalancingStrategy = \"NONE\" | \"ROUND_ROBIN\" | \"ONE_RANDOM\";\n\n/**\n * An arbitrary object with string values representing HTTP headers and their\n * values.\n *\n * Header names should always be lowercase.\n */\nexport type Headers = Record<string, string>;\n\n/**\n * An arbitrary object with scalar values representing query string parameters\n * and their values.\n */\nexport type Params = Record<string, any>;\n\n/**\n * Generic properties shared by all ArangoDB HTTP API responses.\n */\nexport type ArangoResponseMetadata = {\n /**\n * Indicates that the request was successful.\n */\n error: false;\n /**\n * Response status code, typically `200`.\n */\n code: number;\n};\n\n/**\n * Extends the given base type `T` with the generic HTTP API response properties.\n */\nexport type ArangoApiResponse<T> = T & ArangoResponseMetadata;\n\n/**\n * Credentials for HTTP Basic authentication.\n */\nexport type BasicAuthCredentials = {\n /**\n * Username to use for authentication, e.g. `\"root\"`.\n */\n username: string;\n /**\n * Password to use for authentication. Defaults to an empty string.\n */\n password?: string;\n};\n\n/**\n * Credentials for HTTP Bearer token authentication.\n */\nexport type BearerAuthCredentials = {\n /**\n * Bearer token to use for authentication.\n */\n token: string;\n};\n\nfunction isBearerAuth(auth: any): auth is BearerAuthCredentials {\n return auth.hasOwnProperty(\"token\");\n}\n\n/**\n * @internal\n */\nfunction generateStackTrace() {\n let err = new Error();\n if (!err.stack) {\n try {\n throw err;\n } catch (e: any) {\n err = e;\n }\n }\n return err;\n}\n\n/**\n * @internal\n */\ntype UrlInfo = {\n absolutePath?: boolean;\n basePath?: string;\n path?: string;\n qs?: string | Params;\n};\n\n/**\n * Options of the `xhr` module that can be set using `agentOptions` when using\n * arangojs in the browser. Additionally `maxSockets` can be used to control\n * the maximum number of parallel requests.\n *\n * See also: [`xhr` on npm](https://www.npmjs.com/package/xhr).\n */\nexport type XhrOptions = {\n /**\n * Maximum number of parallel requests arangojs will perform. If any\n * additional requests are attempted, they will be enqueued until one of the\n * active requests has completed.\n */\n maxSockets?: number;\n /**\n * Number of milliseconds to wait for a response.\n *\n * Default: `0` (disabled)\n */\n timeout?: number;\n /**\n * Callback that will be invoked immediately before the `send` method of the\n * request is called.\n *\n * See also {@link RequestInterceptors}.\n */\n beforeSend?: (xhrObject: any) => void;\n /**\n * `XMLHttpRequest` object to use instead of the native implementation.\n */\n xhr?: any;\n /**\n * (Internet Explorer 10 and lower only.) Whether `XDomainRequest` should be\n * used instead of `XMLHttpRequest`. Only required for performing\n * cross-domain requests in older versions of Internet Explorer.\n */\n useXdr?: boolean;\n /**\n * Specifies whether browser credentials (e.g. cookies) should be sent if\n * performing a cross-domain request.\n *\n * See [`XMLHttpRequest.withCredentials`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials).\n */\n withCredentials?: boolean;\n};\n\n/**\n * Additional options for intercepting the request/response. These methods\n * are primarily intended for tracking network related metrics.\n */\nexport type RequestInterceptors = {\n /**\n * Callback that will be invoked with the finished request object before it\n * is finalized. In the browser the request may already have been sent.\n *\n * @param req - Request object or XHR instance used for this request.\n */\n before?: (req: ClientRequest) => void;\n /**\n * Callback that will be invoked when the server response has been received\n * and processed or when the request has been failed without a response.\n *\n * The originating request will be available as the `request` property\n * on either the error or response object.\n *\n * @param err - Error encountered when handling this request or `null`.\n * @param res - Response object for this request, if no error occurred.\n */\n after?: (err: ArangojsError | null, res?: ArangojsResponse) => void;\n};\n\n/**\n * Options for performing a request with arangojs.\n */\nexport type RequestOptions = {\n /**\n * @internal\n *\n * Identifier of a specific ArangoDB host to use when more than one is known.\n */\n hostUrl?: string;\n /**\n * HTTP method to use in order to perform the request.\n *\n * Default: `\"GET\"`\n */\n method?: string;\n /**\n * Request body data.\n */\n body?: any;\n /**\n * If set to `true`, the response body will not be interpreted as JSON and\n * instead passed as-is.\n */\n expectBinary?: boolean;\n /**\n * If set to `true`, the request body will not be converted to JSON and\n * instead passed as-is.\n */\n isBinary?: boolean;\n /**\n * Whether ArangoDB is allowed to perform a dirty read to respond to this\n * request. If set to `true`, the response may reflect a dirty state from\n * a non-authoritative server.\n */\n allowDirtyRead?: boolean;\n /**\n * If set to a positive number, the request will automatically be retried at\n * most this many times if it results in a write-write conflict.\n *\n * Default: `config.retryOnConflict`\n */\n retryOnConflict?: number;\n /**\n * HTTP headers to pass along with this request in addition to the default\n * headers generated by arangojs.\n */\n headers?: Headers;\n /**\n * Time in milliseconds after which arangojs will abort the request if the\n * socket has not already timed out.\n *\n * See also `agentOptions.timeout` in {@link Config}.\n */\n timeout?: number;\n /**\n * Optional prefix path to prepend to the `path`.\n */\n basePath?: string;\n /**\n * URL path, relative to the `basePath` and server domain.\n */\n path?: string;\n /**\n * URL parameters to pass as part of the query string.\n */\n qs?: string | Params;\n};\n\n/**\n * @internal\n */\ntype Task = {\n hostUrl?: string;\n stack?: () => string;\n allowDirtyRead: boolean;\n retryOnConflict: number;\n resolve: (result: any) => void;\n reject: (error: Error) => void;\n transform?: (res: ArangojsResponse) => any;\n retries: number;\n options: {\n method: string;\n expectBinary: boolean;\n timeout?: number;\n url: { pathname: string; search?: string };\n headers: Headers;\n body: any;\n };\n};\n\n/**\n * Options for creating the Node.js `http.Agent` or `https.Agent`.\n *\n * In browser environments this option can be used to pass additional options\n * to the underlying calls of the\n * [xhr module](https://www.npmjs.com/package/xhr).\n *\n * See also [`http.Agent`](https://nodejs.org/api/http.html#http_new_agent_options)\n * and [`https.Agent`](https://nodejs.org/api/https.html#https_new_agent_options)\n * (when using TLS).\n */\nexport type AgentOptions = NodeAgentOptions | XhrOptions;\n\n/**\n * Options for configuring arangojs.\n */\nexport type Config = {\n /**\n * Name of the database to use.\n *\n * Default: `\"_system\"`\n */\n databaseName?: string;\n /**\n * Base URL of the ArangoDB server or list of server URLs.\n *\n * When working with a cluster, the method {@link database.Database#acquireHostList}\n * can be used to automatically pick up additional coordinators/followers at\n * any point.\n *\n * When running ArangoDB on a unix socket, e.g. `/tmp/arangodb.sock`, the\n * following URL formats are supported for unix sockets:\n *\n * - `unix:///tmp/arangodb.sock` (no SSL)\n * - `http+unix:///tmp/arangodb.sock` (or `https+unix://` for SSL)\n * - `http://unix:/tmp/arangodb.sock` (or `https://unix:` for SSL)\n *\n * Additionally `ssl` and `tls` are treated as synonymous with `https` and\n * `tcp` is treated as synonymous with `http`, so the following URLs are\n * considered identical:\n *\n * - `tcp://127.0.0.1:8529` and `http://127.0.0.1:8529`\n * - `ssl://127.0.0.1:8529` and `https://127.0.0.1:8529`\n * - `tcp+unix:///tmp/arangodb.sock` and `http+unix:///tmp/arangodb.sock`\n * - `ssl+unix:///tmp/arangodb.sock` and `https+unix:///tmp/arangodb.sock`\n * - `tcp://unix:/tmp/arangodb.sock` and `http://unix:/tmp/arangodb.sock`\n * - `ssl://unix:/tmp/arangodb.sock` and `https://unix:/tmp/arangodb.sock`\n *\n * See also `auth` for passing authentication credentials.\n *\n * Default: `\"http://127.0.0.1:8529\"`\n */\n url?: string | string[];\n /**\n * Credentials to use for authentication.\n *\n * See also {@link database.Database#useBasicAuth} and\n * {@link database.Database#useBearerAuth}.\n *\n * Default: `{ username: \"root\", password: \"\" }`\n */\n auth?: BasicAuthCredentials | BearerAuthCredentials;\n /**\n * Numeric representation of the ArangoDB version the driver should expect.\n * The format is defined as `XYYZZ` where `X` is the major version, `Y` is\n * the zero-filled two-digit minor version and `Z` is the zero-filled two-digit\n * bugfix version, e.g. `30102` for 3.1.2, `20811` for 2.8.11.\n *\n * Depending on this value certain methods may become unavailable or change\n * their behavior to remain compatible with different versions of ArangoDB.\n *\n * Default: `30900`\n */\n arangoVersion?: number;\n /**\n * Determines the behavior when multiple URLs are provided:\n *\n * - `\"NONE\"`: No load balancing. All requests will be handled by the first\n * URL in the list until a network error is encountered. On network error,\n * arangojs will advance to using the next URL in the list.\n *\n * - `\"ONE_RANDOM\"`: Randomly picks one URL from the list initially, then\n * behaves like `\"NONE\"`.\n *\n * - `\"ROUND_ROBIN\"`: Every sequential request uses the next URL in the list.\n *\n * Default: `\"NONE\"`\n */\n loadBalancingStrategy?: LoadBalancingStrategy;\n /**\n * Determines the behavior when a request fails because the underlying\n * connection to the server could not be opened\n * (i.e. [`ECONNREFUSED` in Node.js](https://nodejs.org/api/errors.html#errors_common_system_errors)):\n *\n * - `false`: the request fails immediately.\n *\n * - `0`: the request is retried until a server can be reached but only a\n * total number of times matching the number of known servers (including\n * the initial failed request).\n *\n * - any other number: the request is retried until a server can be reached\n * or the request has been retried a total of `maxRetries` number of times\n * (not including the initial failed request).\n *\n * When working with a single server, the retries (if any) will be made to\n * the same server.\n *\n * This setting currently has no effect when using arangojs in a browser.\n *\n * **Note**: Requests bound to a specific server (e.g. fetching query results)\n * will never be retried automatically and ignore this setting.\n *\n * **Note**: To set the number of retries when a write-write conflict is\n * encountered, see `retryOnConflict` instead.\n *\n * Default: `0`\n */\n maxRetries?: false | number;\n /**\n * If set to a positive number, requests will automatically be retried at\n * most this many times if they result in a write-write conflict.\n *\n * Default: `0`\n */\n retryOnConflict?: number;\n /**\n * An http `Agent` instance to use for connections.\n *\n * By default a new `Agent` instance will be created using the `agentOptions`.\n *\n * This option has no effect when using the browser version of arangojs.\n *\n * See also [`http.Agent`](https://nodejs.org/api/http.html#http_new_agent_options)\n * and [`https.Agent`](https://nodejs.org/api/https.html#https_new_agent_options)\n * (when using TLS).\n */\n agent?: any;\n /**\n * Options used to create that underlying HTTP/HTTPS `Agent` (or the `xhr`\n * module when using arangojs in the browser). This will be ignored if\n * `agent` is also provided.\n *\n * The option `maxSockets` is also used to limit how many requests\n * arangojs will perform concurrently. The maximum number of requests is\n * equal to `maxSockets`.\n *\n * **Note:** arangojs will limit the number of concurrent requests based on\n * this value even if an `agent` is provided.\n *\n * **Note:** when using `ROUND_ROBIN` load balancing and passing an array of\n * URLs in the `url` option, the default value of `maxSockets` will be set\n * to `3 * url.length` instead of `3`.\n *\n * Default (Node.js): `{ maxSockets: 3, keepAlive: true, keepAliveMsecs: 1000 }`\n *\n * Default (browser): `{ maxSockets: 3, useXDR: true, withCredentials: true }`\n */\n agentOptions?: AgentOptions & RequestInterceptors;\n /**\n * An object with additional headers to send with every request.\n *\n * If an `\"authorization\"` header is provided, it will be overridden when\n * using {@link database.Database#useBasicAuth}, {@link database.Database#useBearerAuth} or\n * the `auth` configuration option.\n */\n headers?: Headers;\n /**\n * If set to `true`, arangojs will generate stack traces every time a request\n * is initiated and augment the stack traces of any errors it generates.\n *\n * **Warning**: This will cause arangojs to generate stack traces in advance\n * even if the request does not result in an error. Generating stack traces\n * may negatively impact performance.\n */\n precaptureStackTraces?: boolean;\n /**\n * Limits the number of values of server-reported response queue times that\n * will be stored and accessible using {@link database.Database#queueTime}. If set to\n * a finite value, older values will be discarded to make room for new values\n * when that limit is reached.\n *\n * Default: `10`\n */\n responseQueueTimeSamples?: number;\n};\n\n/**\n * Indicates whether the given value represents a {@link Connection}.\n *\n * @param connection - A value that might be a connection.\n *\n * @internal\n */\nexport function isArangoConnection(connection: any): connection is Connection {\n return Boolean(connection && connection.isArangoConnection);\n}\n\n/**\n * Represents a connection pool shared by one or more databases.\n *\n * @internal\n */\nexport class Connection {\n protected _activeTasks: number = 0;\n protected _agent?: any;\n protected _agentOptions: { [key: string]: any };\n protected _arangoVersion: number = 30900;\n protected _headers: Headers;\n protected _loadBalancingStrategy: LoadBalancingStrategy;\n protected _maxRetries: number | false;\n protected _retryOnConflict: number;\n protected _maxTasks: number;\n protected _queue = new LinkedList<Task>();\n protected _databases = new Map<string, Database>();\n protected _hosts: RequestFunction[] = [];\n protected _hostUrls: string[] = [];\n protected _activeHostUrl: string;\n protected _activeDirtyHostUrl: string;\n protected _transactionId: string | null = null;\n protected _precaptureStackTraces: boolean;\n protected _queueTimes = new LinkedList<[number, number]>();\n protected _responseQueueTimeSamples: number;\n\n /**\n * @internal\n *\n * Creates a new `Connection` instance.\n *\n * @param config - An object with configuration options.\n *\n */\n constructor(config: Omit<Config, \"databaseName\"> = {}) {\n const URLS = config.url\n ? Array.isArray(config.url)\n ? config.url\n : [config.url]\n : [\"http://127.0.0.1:8529\"];\n const MAX_SOCKETS =\n 3 * (config.loadBalancingStrategy === \"ROUND_ROBIN\" ? URLS.length : 1);\n\n if (config.arangoVersion !== undefined) {\n this._arangoVersion = config.arangoVersion;\n }\n this._agent = config.agent;\n this._agentOptions = isBrowser\n ? { maxSockets: MAX_SOCKETS, ...config.agentOptions }\n : {\n maxSockets: MAX_SOCKETS,\n keepAlive: true,\n keepAliveMsecs: 1000,\n scheduling: \"lifo\",\n ...config.agentOptions,\n };\n this._maxTasks = this._agentOptions.maxSockets;\n this._headers = { ...config.headers };\n this._loadBalancingStrategy = config.loadBalancingStrategy ?? \"NONE\";\n this._precaptureStackTraces = Boolean(config.precaptureStackTraces);\n this._responseQueueTimeSamples = config.responseQueueTimeSamples ?? 10;\n this._retryOnConflict = config.retryOnConflict ?? 0;\n if (this._responseQueueTimeSamples < 0) {\n this._responseQueueTimeSamples = Infinity;\n }\n if (config.maxRetries === false) {\n this._maxRetries = false;\n } else {\n this._maxRetries = Number(config.maxRetries ?? 0);\n }\n\n this.addToHostList(URLS);\n\n if (config.auth) {\n if (isBearerAuth(config.auth)) {\n this.setBearerAuth(config.auth);\n } else {\n this.setBasicAuth(config.auth);\n }\n }\n\n if (this._loadBalancingStrategy === \"ONE_RANDOM\") {\n this._activeHostUrl =\n this._hostUrls[Math.floor(Math.random() * this._hostUrls.length)];\n this._activeDirtyHostUrl =\n this._hostUrls[Math.floor(Math.random() * this._hostUrls.length)];\n } else {\n this._activeHostUrl = this._hostUrls[0];\n this._activeDirtyHostUrl = this._hostUrls[0];\n }\n }\n\n /**\n * @internal\n *\n * Indicates that this object represents an ArangoDB connection.\n */\n get isArangoConnection(): true {\n return true;\n }\n\n get queueTime() {\n return {\n getLatest: () => this._queueTimes.last?.value[1],\n getValues: () => Array.from(this._queueTimes.values()),\n getAvg: () => {\n let avg = 0;\n for (const [, [, value]] of this._queueTimes) {\n avg += value / this._queueTimes.length;\n }\n return avg;\n },\n };\n }\n\n protected _runQueue() {\n if (!this._queue.length || this._activeTasks >= this._maxTasks) return;\n const task = this._queue.shift()!;\n let hostUrl = this._activeHostUrl;\n if (task.hostUrl !== undefined) {\n hostUrl = task.hostUrl;\n } else if (task.allowDirtyRead) {\n hostUrl = this._activeDirtyHostUrl;\n this._activeDirtyHostUrl =\n this._hostUrls[\n (this._hostUrls.indexOf(this._activeDirtyHostUrl) + 1) %\n this._hostUrls.length\n ];\n task.options.headers[\"x-arango-allow-dirty-read\"] = \"true\";\n } else if (this._loadBalancingStrategy === \"ROUND_ROBIN\") {\n this._activeHostUrl =\n this._hostUrls[\n (this._hostUrls.indexOf(this._activeHostUrl) + 1) %\n this._hostUrls.length\n ];\n }\n this._activeTasks += 1;\n const callback: Errback<ArangojsResponse> = (err, res) => {\n this._activeTasks -= 1;\n if (!err && res) {\n if (res.statusCode === 503 && res.headers[LEADER_ENDPOINT_HEADER]) {\n const url = res.headers[LEADER_ENDPOINT_HEADER]!;\n const [cleanUrl] = this.addToHostList(url);\n task.hostUrl = cleanUrl;\n if (this._activeHostUrl === hostUrl) {\n this._activeHostUrl = cleanUrl;\n }\n this._queue.push(task);\n } else {\n res.arangojsHostUrl = hostUrl;\n const contentType = res.headers[\"content-type\"];\n const queueTime = res.headers[\"x-arango-queue-time-seconds\"];\n if (queueTime) {\n this._queueTimes.push([Date.now(), Number(queueTime)]);\n while (this._responseQueueTimeSamples < this._queueTimes.length) {\n this._queueTimes.shift();\n }\n }\n let parsedBody: any = undefined;\n if (res.body.length && contentType && contentType.match(MIME_JSON)) {\n try {\n parsedBody = res.body;\n parsedBody = JSON.parse(parsedBody);\n } catch (e: any) {\n if (!task.options.expectBinary) {\n if (typeof parsedBody !== \"string\") {\n parsedBody = res.body.toString(\"utf-8\");\n }\n e.res = res;\n if (task.stack) {\n e.stack += task.stack();\n }\n callback(e);\n return;\n }\n }\n } else if (res.body && !task.options.expectBinary) {\n parsedBody = res.body.toString(\"utf-8\");\n } else {\n parsedBody = res.body;\n }\n if (isArangoErrorResponse(parsedBody)) {\n res.body = parsedBody;\n err = new ArangoError(res);\n } else if (res.statusCode && res.statusCode >= 400) {\n res.body = parsedBody;\n err = new HttpError(res);\n } else {\n if (!task.options.expectBinary) res.body = parsedBody;\n task.resolve(task.transform ? task.transform(res) : (res as any));\n }\n }\n }\n if (err) {\n if (\n !task.allowDirtyRead &&\n this._hosts.length > 1 &&\n this._activeHostUrl === hostUrl &&\n this._loadBalancingStrategy !== \"ROUND_ROBIN\"\n ) {\n this._activeHostUrl =\n this._hostUrls[\n (this._hostUrls.indexOf(this._activeHostUrl) + 1) %\n this._hostUrls.length\n ];\n }\n if (\n isArangoError(err) &&\n err.errorNum === ERROR_ARANGO_CONFLICT &&\n task.retryOnConflict > 0\n ) {\n task.retryOnConflict -= 1;\n this._queue.push(task);\n } else if (\n ((isSystemError(err) &&\n err.syscall === \"connect\" &&\n err.code === \"ECONNREFUSED\") ||\n (isArangoError(err) &&\n err.errorNum === ERROR_ARANGO_MAINTENANCE_MODE)) &&\n task.hostUrl === undefined &&\n this._maxRetries !== false &&\n task.retries < (this._maxRetries || this._hosts.length - 1)\n ) {\n task.retries += 1;\n this._queue.push(task);\n } else {\n if (task.stack) {\n err.stack += task.stack();\n }\n task.reject(err);\n }\n }\n this._runQueue();\n };\n try {\n this._hosts[this._hostUrls.indexOf(hostUrl)](task.options, callback);\n } catch (e: any) {\n callback(e);\n }\n }\n\n protected _buildUrl({ basePath, path, qs }: UrlInfo) {\n const pathname = `${basePath || \"\"}${path || \"\"}`;\n let search;\n if (qs) {\n if (typeof qs === \"string\") search = `?${qs}`;\n else search = `?${querystringify(qs)}`;\n }\n return search ? { pathname, search } : { pathname };\n }\n\n setBearerAuth(auth: BearerAuthCredentials) {\n this.setHeader(\"authorization\", `Bearer ${auth.token}`);\n }\n\n setBasicAuth(auth: BasicAuthCredentials) {\n this.setHeader(\n \"authorization\",\n `Basic ${base64Encode(`${auth.username}:${auth.password}`)}`\n );\n }\n\n setResponseQueueTimeSamples(responseQueueTimeSamples: number) {\n if (responseQueueTimeSamples < 0) {\n responseQueueTimeSamples = Infinity;\n }\n this._responseQueueTimeSamples = responseQueueTimeSamples;\n while (this._responseQueueTimeSamples < this._queueTimes.length) {\n this._queueTimes.shift();\n }\n }\n\n /**\n * @internal\n *\n * Fetches a {@link database.Database} instance for the given database name from the\n * internal cache, if available.\n *\n * @param databaseName - Name of the database.\n */\n database(databaseName: string): Database | undefined;\n /**\n * @internal\n *\n * Adds a {@link database.Database} instance for the given database name to the\n * internal cache.\n *\n * @param databaseName - Name of the database.\n * @param database - Database instance to add to the cache.\n */\n database(databaseName: string, database: Database): Database;\n /**\n * @internal\n *\n * Clears any {@link database.Database} instance stored for the given database name\n * from the internal cache, if present.\n *\n * @param databaseName - Name of the database.\n * @param database - Must be `null`.\n */\n database(databaseName: string, database: null): undefined;\n database(\n databaseName: string,\n database?: Database | null\n ): Database | undefined {\n if (database === null) {\n this._databases.delete(databaseName);\n return undefined;\n }\n if (!database) {\n return this._databases.get(databaseName);\n }\n this._databases.set(databaseName, database);\n return database;\n }\n\n /**\n * @internal\n *\n * Replaces the host list with the given URLs.\n *\n * See {@link Connection#acquireHostList}.\n *\n * @param urls - URLs to use as host list.\n */\n setHostList(urls: string[]): void {\n const cleanUrls = urls.map((url) => normalizeUrl(url));\n this._hosts.splice(\n 0,\n this._hosts.length,\n ...cleanUrls.map((url) => {\n const i = this._hostUrls.indexOf(url);\n if (i !== -1) return this._hosts[i];\n return createRequest(url, this._agentOptions, this._agent);\n })\n );\n this._hostUrls.splice(0, this._hostUrls.length, ...cleanUrls);\n }\n\n /**\n * @internal\n *\n * Adds the given URL or URLs to the host list.\n *\n * See {@link Connection#acquireHostList}.\n *\n * @param urls - URL or URLs to add.\n */\n addToHostList(urls: string | string[]): string[] {\n const cleanUrls = (Array.isArray(urls) ? urls : [urls]).map((url) =>\n normalizeUrl(url)\n );\n const newUrls = cleanUrls.filter(\n (url) => this._hostUrls.indexOf(url) === -1\n );\n this._hostUrls.push(...newUrls);\n this._hosts.push(\n ...newUrls.map((url: string) =>\n createRequest(url, this._agentOptions, this._agent)\n )\n );\n return cleanUrls;\n }\n\n /**\n * @internal\n *\n * Sets the connection's active `transactionId`.\n *\n * While set, all requests will use this ID, ensuring the requests are executed\n * within the transaction if possible. Setting the ID manually may cause\n * unexpected behavior.\n *\n * See also {@link Connection#clearTransactionId}.\n *\n * @param transactionId - ID of the active transaction.\n */\n setTransactionId(transactionId: string) {\n this._transactionId = transactionId;\n }\n\n /**\n * @internal\n *\n * Clears the connection's active `transactionId`.\n */\n clearTransactionId() {\n this._transactionId = null;\n }\n\n /**\n * @internal\n *\n * Sets the header `headerName` with the given `value` or clears the header if\n * `value` is `null`.\n *\n * @param headerName - Name of the header to set.\n * @param value - Value of the header.\n */\n setHeader(headerName: string, value: string | null) {\n if (value === null) {\n delete this._headers[headerName];\n } else {\n this._headers[headerName] = value;\n }\n }\n\n /**\n * @internal\n *\n * Closes all open connections.\n *\n * See {@link database.Database#close}.\n */\n close() {\n for (const host of this._hosts) {\n if (host.close) host.close();\n }\n }\n\n /**\n * @internal\n *\n * Waits for propagation.\n *\n * See {@link database.Database#waitForPropagation}.\n *\n * @param request - Request to perform against each coordinator.\n * @param timeout - Maximum number of milliseconds to wait for propagation.\n */\n async waitForPropagation(request: RequestOptions, timeout = Infinity) {\n const numHosts = this._hosts.length;\n const propagated = [] as string[];\n const started = Date.now();\n let index = 0;\n while (true) {\n if (propagated.length === numHosts) {\n return;\n }\n while (propagated.includes(this._hostUrls[index])) {\n index = (index + 1) % numHosts;\n }\n const hostUrl = this._hostUrls[index];\n try {\n await this.request({ ...request, hostUrl });\n } catch (e: any) {\n if (started + timeout < Date.now()) {\n throw e;\n }\n await new Promise((resolve) => setTimeout(resolve, 1000));\n continue;\n }\n if (!propagated.includes(hostUrl)) {\n propagated.push(hostUrl);\n }\n }\n }\n\n /**\n * @internal\n *\n * Performs a request using the arangojs connection pool.\n */\n request<T = ArangojsResponse>(\n {\n hostUrl,\n method = \"GET\",\n body,\n expectBinary = false,\n isBinary = false,\n allowDirtyRead = false,\n retryOnConflict = this._retryOnConflict,\n timeout = 0,\n headers,\n ...urlInfo\n }: RequestOptions,\n transform?: (res: ArangojsResponse) => T\n ): Promise<T> {\n return new Promise((resolve, reject) => {\n let contentType = \"text/plain\";\n if (isBinary) {\n contentType = \"application/octet-stream\";\n } else if (body) {\n if (typeof body === \"object\") {\n body = JSON.stringify(body);\n contentType = \"application/json\";\n } else {\n body = String(body);\n }\n }\n\n const extraHeaders: Headers = {\n ...this._headers,\n \"content-type\": contentType,\n \"x-arango-version\": String(this._arangoVersion),\n \"x-arango-driver\": `arangojs/${process.env.ARANGOJS_VERSION} (cloud)`,\n };\n\n if (this._transactionId) {\n extraHeaders[\"x-arango-trx-id\"] = this._transactionId;\n }\n\n const task: Task = {\n retries: 0,\n hostUrl,\n allowDirtyRead,\n retryOnConflict,\n options: {\n url: this._buildUrl(urlInfo),\n headers: { ...extraHeaders, ...headers },\n timeout,\n method,\n expectBinary,\n body,\n },\n reject,\n resolve,\n transform,\n };\n\n if (this._precaptureStackTraces) {\n if (typeof Error.captureStackTrace === \"function\") {\n const capture = {} as { readonly stack: string };\n Error.captureStackTrace(capture);\n task.stack = () =>\n `\\n${capture.stack.split(\"\\n\").slice(3).join(\"\\n\")}`;\n } else {\n const capture = generateStackTrace() as { readonly stack: string };\n if (Object.prototype.hasOwnProperty.call(capture, \"stack\")) {\n task.stack = () =>\n `\\n${capture.stack.split(\"\\n\").slice(4).join(\"\\n\")}`;\n }\n }\n }\n\n this._queue.push(task);\n this._runQueue();\n });\n }\n}\n"]}
|
package/indexes.d.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* import type {
|
|
4
4
|
* FulltextIndex,
|
|
5
5
|
* GeoIndex,
|
|
6
|
+
* MdiIndex,
|
|
6
7
|
* PersistentIndex,
|
|
7
8
|
* PrimaryIndex,
|
|
8
9
|
* TtlIndex,
|
|
9
|
-
* ZkdIndex,
|
|
10
10
|
* } from "arangojs/indexes";
|
|
11
11
|
* ```
|
|
12
12
|
*
|
|
@@ -212,13 +212,13 @@ export declare type EnsureTtlIndexOptions = {
|
|
|
212
212
|
inBackground?: boolean;
|
|
213
213
|
};
|
|
214
214
|
/**
|
|
215
|
-
* Options for creating a
|
|
215
|
+
* Options for creating a MDI index.
|
|
216
216
|
*/
|
|
217
|
-
export declare type
|
|
217
|
+
export declare type EnsureMdiIndexOptions = {
|
|
218
218
|
/**
|
|
219
219
|
* Type of this index.
|
|
220
220
|
*/
|
|
221
|
-
type: "
|
|
221
|
+
type: "mdi";
|
|
222
222
|
/**
|
|
223
223
|
* An array containing attribute paths for the dimensions.
|
|
224
224
|
*/
|
|
@@ -610,10 +610,10 @@ export declare type TtlIndex = GenericIndex & {
|
|
|
610
610
|
selectivityEstimate: number;
|
|
611
611
|
};
|
|
612
612
|
/**
|
|
613
|
-
* An object representing a
|
|
613
|
+
* An object representing a MDI index.
|
|
614
614
|
*/
|
|
615
|
-
export declare type
|
|
616
|
-
type: "
|
|
615
|
+
export declare type MdiIndex = GenericIndex & {
|
|
616
|
+
type: "mdi";
|
|
617
617
|
fields: string[];
|
|
618
618
|
fieldValueTypes: "double";
|
|
619
619
|
};
|
|
@@ -676,7 +676,7 @@ export declare type InvertedIndex = GenericIndex & {
|
|
|
676
676
|
/**
|
|
677
677
|
* An object representing an index.
|
|
678
678
|
*/
|
|
679
|
-
export declare type Index = GeoIndex | FulltextIndex | PersistentIndex | PrimaryIndex | TtlIndex |
|
|
679
|
+
export declare type Index = GeoIndex | FulltextIndex | PersistentIndex | PrimaryIndex | TtlIndex | MdiIndex | InvertedIndex;
|
|
680
680
|
export declare type ObjectWithId = {
|
|
681
681
|
[key: string]: any;
|
|
682
682
|
id: string;
|
package/indexes.js
CHANGED
package/indexes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexes.js","sourceRoot":"","sources":["../src/indexes.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAssBH;;GAEG;AACH,SAAgB,YAAY,CAC1B,QAAuB,EACvB,cAAsB;IAEtB,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QAChC,IAAI,QAAQ,CAAC,EAAE,EAAE;YACf,OAAO,YAAY,CAAC,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;SAClD;QACD,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;KACH;IACD,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC1B,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5C,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,cAAc,KAAK,cAAc,EAAE;YACrC,MAAM,IAAI,KAAK,CACb,aAAa,QAAQ,qCAAqC,cAAc,GAAG,CAC5E,CAAC;SACH;QACD,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC3C,OAAO,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAC7C;IACD,OAAO,GAAG,cAAc,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;AAClE,CAAC;AAxBD,oCAwBC","sourcesContent":["/**\n * ```ts\n * import type {\n * FulltextIndex,\n * GeoIndex,\n * PersistentIndex,\n * PrimaryIndex,\n * TtlIndex,\n * ZkdIndex,\n * } from \"arangojs/indexes\";\n * ```\n *\n * The \"indexes\" module provides index-related types for TypeScript.\n *\n * @packageDocumentation\n */\n\nimport { AnalyzerFeature } from \"./analyzer\";\nimport { Compression, Direction, TierConsolidationPolicy } from \"./view\";\n\n/**\n * Options for creating a persistent index.\n */\nexport type EnsurePersistentIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"persistent\";\n /**\n * An array of attribute paths.\n */\n fields: string[];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true`, a unique index will be created.\n *\n * Default: `false`\n */\n unique?: boolean;\n /**\n * If set to `true`, the index will omit documents that do not contain at\n * least one of the attribute paths in `fields` and these documents will be\n * ignored for uniqueness checks.\n *\n * Default: `false`\n */\n sparse?: boolean;\n /**\n * If set to `false`, inserting duplicate index values from the same\n * document will lead to a unique constraint error if this is a unique index.\n *\n * Default: `true`\n */\n deduplicate?: boolean;\n /**\n * If set to `false`, index selectivity estimates will be disabled for this\n * index.\n *\n * Default: `true`\n */\n estimates?: boolean;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n /**\n * If set to `true`, an in-memory hash cache will be put in front of the\n * persistent index.\n *\n * Default: `false`\n */\n cacheEnabled?: boolean;\n /**\n * An array of attribute paths that will be stored in the index but can not\n * be used for index lookups or sorting but can avoid full document lookups.\n */\n storedValues?: string[];\n};\n\n/**\n * Options for creating a geo index.\n */\nexport type EnsureGeoIndexOptions =\n | {\n type: \"geo\";\n /**\n * If set to `true`, `fields` must be an array containing a single attribute\n * path and the attribute value must be an array with two values, the first\n * of which will be interpreted as the longitude and the second of which will\n * be interpreted as the latitude of the document.\n *\n * Default: `false`\n */\n geoJson?: false;\n /**\n * If set to `true`, the index will use pre-3.10 rules for parsing\n * GeoJSON polygons. This option is always implicitly `true` when using\n * ArangoDB 3.9 or lower.\n */\n legacyPolygons?: boolean;\n /**\n * Attribute paths for the document's latitude and longitude values.\n */\n fields: [string, string];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n }\n | {\n type: \"geo\";\n /**\n * If set to `true`, `fields` must be an array containing a single attribute\n * path and the attribute value must be an array with two values, the first\n * of which will be interpreted as the longitude and the second of which will\n * be interpreted as the latitude of the document.\n *\n * Default: `false`\n */\n geoJson?: boolean;\n /**\n * If set to `true`, the index will use pre-3.10 rules for parsing\n * GeoJSON polygons. This option is always implicitly `true` when using\n * ArangoDB 3.9 or lower.\n */\n legacyPolygons?: boolean;\n /**\n * An array containing the attribute path for an array containing two values,\n * the first of which will be interpreted as the latitude, the second as the\n * longitude. If `geoJson` is set to `true`, the order is reversed to match\n * the GeoJSON format.\n */\n fields: [string];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n };\n\n/**\n * Options for creating a fulltext index.\n *\n * @deprecated Fulltext indexes have been deprecated in ArangoDB 3.10 and\n * should be replaced with ArangoSearch.\n */\nexport type EnsureFulltextIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"fulltext\";\n /**\n * An array containing exactly one attribute path.\n */\n fields: [string];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * Minimum character length of words to index.\n */\n minLength?: number;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n};\n\n/**\n * Options for creating a TTL index.\n */\nexport type EnsureTtlIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"ttl\";\n /**\n * An array containing exactly one attribute path.\n */\n fields: [string];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * Duration in seconds after the attribute value at which the document will\n * be considered as expired.\n */\n expireAfter: number;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n};\n\n/**\n * Options for creating a ZKD index.\n */\nexport type EnsureZkdIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"zkd\";\n /**\n * An array containing attribute paths for the dimensions.\n */\n fields: string[];\n /**\n * Data type of the dimension attributes.\n */\n fieldValueTypes: \"double\";\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true`, a unique index will be created.\n *\n * Default: `false`\n */\n unique?: boolean;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n};\n\n/**\n * (Enterprise Edition only.) Options for a nested field in an inverted index.\n */\nexport type InvertedIndexNestedFieldOptions = {\n /**\n * An attribute path.\n */\n name: string;\n /**\n * Name of the Analyzer to apply to the values of this field.\n *\n * Defaults to the `analyzer` specified on the parent options or on the index\n * itself.\n */\n analyzer?: string;\n /**\n * List of Analyzer features to enable for this field's Analyzer.\n *\n * Defaults to the features of the Analyzer.\n */\n features?: AnalyzerFeature[];\n /**\n * If set to `true` array values will be indexed using the same behavior as\n * ArangoSearch Views. This option only applies when using the index in a\n * SearchAlias View.\n *\n * Defaults to the value of `searchField` specified on the index itself.\n */\n searchField?: boolean;\n /**\n * Sub-objects to index to allow querying for co-occurring values.\n */\n nested?: (string | InvertedIndexNestedFieldOptions)[];\n};\n\n/**\n * Options for an attribute path in an inverted index.\n */\nexport type InvertedIndexFieldOptions = {\n /**\n * An attribute path.\n */\n name: string;\n /**\n * Name of the Analyzer to apply to the values of this field.\n *\n * Defaults to the `analyzer` specified on the index itself.\n */\n analyzer?: string;\n /**\n * List of Analyzer features to enable for this field's Analyzer.\n *\n * Defaults to the features of the Analyzer.\n */\n features?: AnalyzerFeature[];\n /**\n * If set to `true`, all document attributes are indexed, excluding any\n * sub-attributes configured in the `fields` array. The `analyzer` and\n * `features` properties apply to the sub-attributes. This option only\n * applies when using the index in a SearchAlias View.\n *\n * Defaults to the value of `includeAllFields` specified on the index itself.\n */\n includeAllFields?: boolean;\n /**\n * If set to `true` array values will be indexed using the same behavior as\n * ArangoSearch Views. This option only applies when using the index in a\n * SearchAlias View.\n *\n * Defaults to the value of `searchField` specified on the index itself.\n */\n searchField?: boolean;\n /**\n * If set to `true`, the position of values in array values are tracked and\n * need to be specified in queries. Otherwise all values in an array are\n * treated as equivalent. This option only applies when using the index in a\n * SearchAlias View.\n *\n * Defaults to the value of `trackListPositions` specified on the index\n * itself.\n */\n trackListPositions?: boolean;\n /**\n * (Enterprise Edition only.) Sub-objects to index to allow querying for\n * co-occurring values.\n */\n nested?: (string | InvertedIndexNestedFieldOptions)[];\n /**\n * (Enterprise Edition only.) If set to `true`, then field normalization\n * values will always be cached in memory.\n *\n * Defaults to the value of `cache` specified on the index itself.\n */\n cache?: boolean;\n};\n\n/**\n * Options for defining a stored value on an inverted index.\n */\nexport type InvertedIndexStoredValueOptions = {\n /**\n * The attribute paths to store.\n */\n fields: string[];\n /**\n * How the attribute values should be compressed.\n *\n * Default: `\"lz4\"`\n */\n compression?: Compression;\n /**\n * (Enterprise Edition only.) If set to `true`, then stored values will\n * always be cached in memory.\n *\n * Default: `false`\n */\n cache?: boolean;\n};\n\n/**\n * Options for defining a primary sort field on an inverted index.\n */\nexport type InvertedIndexPrimarySortFieldOptions = {\n /**\n * The attribute path to sort by.\n */\n field: string;\n /**\n * The sorting direction.\n */\n direction: Direction;\n};\n\n/**\n * Options for creating an inverted index.\n */\nexport type EnsureInvertedIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"inverted\";\n /**\n * An array of attribute paths or objects specifying options for the fields.\n */\n fields: (string | InvertedIndexFieldOptions)[];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true` array values will by default be indexed using the same\n * behavior as ArangoSearch Views. This option only applies when using the\n * index in a SearchAlias View.\n *\n * Default: `false`\n */\n searchField?: boolean;\n /**\n * An array of attribute paths that will be stored in the index but can not\n * be used for index lookups or sorting but can avoid full document lookups.\n */\n storedValues?: InvertedIndexStoredValueOptions[];\n /**\n * Primary sort order to optimize AQL queries using a matching sort order.\n */\n primarySort?: {\n /**\n * An array of fields to sort the index by.\n */\n fields: InvertedIndexPrimarySortFieldOptions[];\n /**\n * How the primary sort data should be compressed.\n *\n * Default: `\"lz4\"`\n */\n compression?: Compression;\n /**\n * (Enterprise Edition only.) If set to `true`, then primary sort columns\n * will always be cached in memory.\n *\n * Default: `false`\n */\n cache?: boolean;\n };\n /**\n * (Enterprise Edition only.) If set to `true`, then the primary key column\n * will always be cached in memory.\n *\n * Default: `false`\n */\n primaryKeyCache?: boolean;\n /**\n * Name of the default Analyzer to apply to the values of indexed fields.\n *\n * Default: `\"identity\"`\n */\n analyzer?: string;\n /**\n * List of Analyzer features to enable for the default Analyzer.\n *\n * Defaults to the Analyzer's features.\n */\n features?: AnalyzerFeature[];\n /**\n * If set to `true`, all document attributes are indexed, excluding any\n * sub-attributes configured in the `fields` array. The `analyzer` and\n * `features` properties apply to the sub-attributes. This option only\n * applies when using the index in a SearchAlias View.\n *\n * Default: `false`\n */\n includeAllFields?: boolean;\n /**\n * If set to `true`, the position of values in array values are tracked and\n * need to be specified in queries. Otherwise all values in an array are\n * treated as equivalent. This option only applies when using the index in a\n * SearchAlias View.\n *\n * Default: `false`\n */\n trackListPositions?: boolean;\n /**\n * The number of threads to use for indexing the fields.\n *\n * Default: `2`\n */\n parallelism?: number;\n /**\n * Wait at least this many commits between removing unused files in the\n * ArangoSearch data directory.\n *\n * Default: `2`\n */\n cleanupIntervalStep?: number;\n /**\n * Wait at least this many milliseconds between committing View data store\n * changes and making documents visible to queries.\n *\n * Default: `1000`\n */\n commitIntervalMsec?: number;\n /**\n * Wait at least this many milliseconds between applying\n * `consolidationPolicy` to consolidate View data store and possibly release\n * space on the filesystem.\n *\n * Default: `1000`\n */\n consolidationIntervalMsec?: number;\n /**\n * The consolidation policy to apply for selecting which segments should be\n * merged.\n *\n * Default: `{ type: \"tier\" }`\n */\n consolidationPolicy?: TierConsolidationPolicy;\n /**\n * Maximum number of writers (segments) cached in the pool.\n *\n * Default: `64`\n */\n writeBufferIdle?: number;\n /**\n * Maximum number of concurrent active writers (segments) that perform a\n * transaction.\n *\n * Default: `0` (disabled)\n */\n writeBufferActive?: number;\n /**\n * Maximum memory byte size per writer (segment) before a writer (segment)\n * flush is triggered.\n *\n * Default: `33554432` (32 MiB)\n */\n writeBufferSizeMax?: number;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n /**\n * (Enterprise Edition only.) If set to `true`, then field normalization\n * values will always be cached in memory.\n *\n * Default: `false`\n */\n cache?: boolean;\n /**\n * An array of strings defining sort expressions to optimize.\n */\n optimizeTopK?: string[];\n};\n\n/**\n * Shared attributes of all index types.\n */\nexport type GenericIndex = {\n /**\n * A unique name for this index.\n */\n name: string;\n /**\n * A unique identifier for this index.\n */\n id: string;\n /**\n * Whether documents not containing at least one of the attribute paths\n * are omitted by this index.\n */\n sparse: boolean;\n /**\n * Whether this index enforces uniqueness for values of its attribute paths.\n */\n unique: boolean;\n};\n\n/**\n * An object representing a persistent index.\n */\nexport type PersistentIndex = GenericIndex & {\n type: \"persistent\";\n fields: string[];\n cacheEnabled: boolean;\n deduplicate: boolean;\n estimates: boolean;\n storedValues?: string[];\n};\n\n/**\n * An object representing a primary index.\n */\nexport type PrimaryIndex = GenericIndex & {\n type: \"primary\";\n fields: string[];\n selectivityEstimate: number;\n};\n\n/**\n * An object representing a fulltext index.\n *\n * @deprecated Fulltext indexes have been deprecated in ArangoDB 3.10 and\n * should be replaced with ArangoSearch.\n */\nexport type FulltextIndex = GenericIndex & {\n type: \"fulltext\";\n fields: [string];\n minLength: number;\n};\n\n/**\n * An object representing a geo index.\n */\nexport type GeoIndex = GenericIndex & {\n type: \"geo\";\n fields: [string] | [string, string];\n geoJson: boolean;\n legacyPolygons: boolean;\n bestIndexedLevel: number;\n worstIndexedLevel: number;\n maxNumCoverCells: number;\n};\n\n/**\n * An object representing a TTL index.\n */\nexport type TtlIndex = GenericIndex & {\n type: \"ttl\";\n fields: [string];\n expireAfter: number;\n selectivityEstimate: number;\n};\n\n/**\n * An object representing a ZKD index.\n */\nexport type ZkdIndex = GenericIndex & {\n type: \"zkd\";\n fields: string[];\n fieldValueTypes: \"double\";\n};\n\n/**\n * (Enterprise Edition only.) An object representing a nested field in an\n * inverted index.\n */\nexport type InvertedIndexNestedField = {\n name: string;\n analyzer?: string;\n features?: AnalyzerFeature[];\n searchField?: boolean;\n nested?: InvertedIndexNestedField[];\n};\n\n/**\n * An object representing an inverted index.\n */\nexport type InvertedIndex = GenericIndex & {\n type: \"inverted\";\n fields: {\n name: string;\n analyzer?: string;\n features?: AnalyzerFeature[];\n includeAllFields?: boolean;\n searchField?: boolean;\n trackListPositions?: boolean;\n nested?: InvertedIndexNestedField[];\n cache?: boolean;\n }[];\n searchField: boolean;\n cache?: boolean;\n storedValues: {\n fields: string[];\n compression: Compression;\n cache?: boolean;\n }[];\n primarySort: {\n fields: {\n field: string;\n direction: Direction;\n }[];\n compression: Compression;\n cache?: boolean;\n };\n primaryKeyCache?: boolean;\n analyzer: string;\n features: AnalyzerFeature[];\n includeAllFields: boolean;\n trackListPositions: boolean;\n parallelism: number;\n cleanupIntervalStep: number;\n commitIntervalMsec: number;\n consolidationIntervalMsec: number;\n consolidationPolicy: Required<TierConsolidationPolicy>;\n writeBufferIdle: number;\n writeBufferActive: number;\n writeBufferSizeMax: number;\n optimizeTopK: string[];\n};\n\n/**\n * An object representing an index.\n */\nexport type Index =\n | GeoIndex\n | FulltextIndex\n | PersistentIndex\n | PrimaryIndex\n | TtlIndex\n | ZkdIndex\n | InvertedIndex;\n\nexport type ObjectWithId = {\n [key: string]: any;\n id: string;\n};\n\nexport type ObjectWithName = {\n [key: string]: any;\n name: string;\n};\n\n/**\n * Index name, id or object with a `name` or `id` property.\n */\nexport type IndexSelector = ObjectWithId | ObjectWithName | string;\n\n/**\n * @internal\n */\nexport function _indexHandle(\n selector: IndexSelector,\n collectionName: string\n): string {\n if (typeof selector !== \"string\") {\n if (selector.id) {\n return _indexHandle(selector.id, collectionName);\n }\n throw new Error(\n \"Index handle must be a string or an object with an id attribute\"\n );\n }\n if (selector.includes(\"/\")) {\n const [head, ...tail] = selector.split(\"/\");\n const normalizedHead = head.normalize(\"NFC\");\n if (normalizedHead !== collectionName) {\n throw new Error(\n `Index ID \"${selector}\" does not match collection name \"${collectionName}\"`\n );\n }\n selector = tail.join(\"/\").normalize(\"NFC\");\n return [normalizedHead, selector].join(\"/\");\n }\n return `${collectionName}/${String(selector).normalize(\"NFC\")}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"indexes.js","sourceRoot":"","sources":["../src/indexes.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAssBH;;GAEG;AACH,SAAgB,YAAY,CAC1B,QAAuB,EACvB,cAAsB;IAEtB,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QAChC,IAAI,QAAQ,CAAC,EAAE,EAAE;YACf,OAAO,YAAY,CAAC,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;SAClD;QACD,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;KACH;IACD,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC1B,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5C,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,cAAc,KAAK,cAAc,EAAE;YACrC,MAAM,IAAI,KAAK,CACb,aAAa,QAAQ,qCAAqC,cAAc,GAAG,CAC5E,CAAC;SACH;QACD,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC3C,OAAO,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAC7C;IACD,OAAO,GAAG,cAAc,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;AAClE,CAAC;AAxBD,oCAwBC","sourcesContent":["/**\n * ```ts\n * import type {\n * FulltextIndex,\n * GeoIndex,\n * MdiIndex,\n * PersistentIndex,\n * PrimaryIndex,\n * TtlIndex,\n * } from \"arangojs/indexes\";\n * ```\n *\n * The \"indexes\" module provides index-related types for TypeScript.\n *\n * @packageDocumentation\n */\n\nimport { AnalyzerFeature } from \"./analyzer\";\nimport { Compression, Direction, TierConsolidationPolicy } from \"./view\";\n\n/**\n * Options for creating a persistent index.\n */\nexport type EnsurePersistentIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"persistent\";\n /**\n * An array of attribute paths.\n */\n fields: string[];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true`, a unique index will be created.\n *\n * Default: `false`\n */\n unique?: boolean;\n /**\n * If set to `true`, the index will omit documents that do not contain at\n * least one of the attribute paths in `fields` and these documents will be\n * ignored for uniqueness checks.\n *\n * Default: `false`\n */\n sparse?: boolean;\n /**\n * If set to `false`, inserting duplicate index values from the same\n * document will lead to a unique constraint error if this is a unique index.\n *\n * Default: `true`\n */\n deduplicate?: boolean;\n /**\n * If set to `false`, index selectivity estimates will be disabled for this\n * index.\n *\n * Default: `true`\n */\n estimates?: boolean;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n /**\n * If set to `true`, an in-memory hash cache will be put in front of the\n * persistent index.\n *\n * Default: `false`\n */\n cacheEnabled?: boolean;\n /**\n * An array of attribute paths that will be stored in the index but can not\n * be used for index lookups or sorting but can avoid full document lookups.\n */\n storedValues?: string[];\n};\n\n/**\n * Options for creating a geo index.\n */\nexport type EnsureGeoIndexOptions =\n | {\n type: \"geo\";\n /**\n * If set to `true`, `fields` must be an array containing a single attribute\n * path and the attribute value must be an array with two values, the first\n * of which will be interpreted as the longitude and the second of which will\n * be interpreted as the latitude of the document.\n *\n * Default: `false`\n */\n geoJson?: false;\n /**\n * If set to `true`, the index will use pre-3.10 rules for parsing\n * GeoJSON polygons. This option is always implicitly `true` when using\n * ArangoDB 3.9 or lower.\n */\n legacyPolygons?: boolean;\n /**\n * Attribute paths for the document's latitude and longitude values.\n */\n fields: [string, string];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n }\n | {\n type: \"geo\";\n /**\n * If set to `true`, `fields` must be an array containing a single attribute\n * path and the attribute value must be an array with two values, the first\n * of which will be interpreted as the longitude and the second of which will\n * be interpreted as the latitude of the document.\n *\n * Default: `false`\n */\n geoJson?: boolean;\n /**\n * If set to `true`, the index will use pre-3.10 rules for parsing\n * GeoJSON polygons. This option is always implicitly `true` when using\n * ArangoDB 3.9 or lower.\n */\n legacyPolygons?: boolean;\n /**\n * An array containing the attribute path for an array containing two values,\n * the first of which will be interpreted as the latitude, the second as the\n * longitude. If `geoJson` is set to `true`, the order is reversed to match\n * the GeoJSON format.\n */\n fields: [string];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n };\n\n/**\n * Options for creating a fulltext index.\n *\n * @deprecated Fulltext indexes have been deprecated in ArangoDB 3.10 and\n * should be replaced with ArangoSearch.\n */\nexport type EnsureFulltextIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"fulltext\";\n /**\n * An array containing exactly one attribute path.\n */\n fields: [string];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * Minimum character length of words to index.\n */\n minLength?: number;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n};\n\n/**\n * Options for creating a TTL index.\n */\nexport type EnsureTtlIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"ttl\";\n /**\n * An array containing exactly one attribute path.\n */\n fields: [string];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * Duration in seconds after the attribute value at which the document will\n * be considered as expired.\n */\n expireAfter: number;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n};\n\n/**\n * Options for creating a MDI index.\n */\nexport type EnsureMdiIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"mdi\";\n /**\n * An array containing attribute paths for the dimensions.\n */\n fields: string[];\n /**\n * Data type of the dimension attributes.\n */\n fieldValueTypes: \"double\";\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true`, a unique index will be created.\n *\n * Default: `false`\n */\n unique?: boolean;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n};\n\n/**\n * (Enterprise Edition only.) Options for a nested field in an inverted index.\n */\nexport type InvertedIndexNestedFieldOptions = {\n /**\n * An attribute path.\n */\n name: string;\n /**\n * Name of the Analyzer to apply to the values of this field.\n *\n * Defaults to the `analyzer` specified on the parent options or on the index\n * itself.\n */\n analyzer?: string;\n /**\n * List of Analyzer features to enable for this field's Analyzer.\n *\n * Defaults to the features of the Analyzer.\n */\n features?: AnalyzerFeature[];\n /**\n * If set to `true` array values will be indexed using the same behavior as\n * ArangoSearch Views. This option only applies when using the index in a\n * SearchAlias View.\n *\n * Defaults to the value of `searchField` specified on the index itself.\n */\n searchField?: boolean;\n /**\n * Sub-objects to index to allow querying for co-occurring values.\n */\n nested?: (string | InvertedIndexNestedFieldOptions)[];\n};\n\n/**\n * Options for an attribute path in an inverted index.\n */\nexport type InvertedIndexFieldOptions = {\n /**\n * An attribute path.\n */\n name: string;\n /**\n * Name of the Analyzer to apply to the values of this field.\n *\n * Defaults to the `analyzer` specified on the index itself.\n */\n analyzer?: string;\n /**\n * List of Analyzer features to enable for this field's Analyzer.\n *\n * Defaults to the features of the Analyzer.\n */\n features?: AnalyzerFeature[];\n /**\n * If set to `true`, all document attributes are indexed, excluding any\n * sub-attributes configured in the `fields` array. The `analyzer` and\n * `features` properties apply to the sub-attributes. This option only\n * applies when using the index in a SearchAlias View.\n *\n * Defaults to the value of `includeAllFields` specified on the index itself.\n */\n includeAllFields?: boolean;\n /**\n * If set to `true` array values will be indexed using the same behavior as\n * ArangoSearch Views. This option only applies when using the index in a\n * SearchAlias View.\n *\n * Defaults to the value of `searchField` specified on the index itself.\n */\n searchField?: boolean;\n /**\n * If set to `true`, the position of values in array values are tracked and\n * need to be specified in queries. Otherwise all values in an array are\n * treated as equivalent. This option only applies when using the index in a\n * SearchAlias View.\n *\n * Defaults to the value of `trackListPositions` specified on the index\n * itself.\n */\n trackListPositions?: boolean;\n /**\n * (Enterprise Edition only.) Sub-objects to index to allow querying for\n * co-occurring values.\n */\n nested?: (string | InvertedIndexNestedFieldOptions)[];\n /**\n * (Enterprise Edition only.) If set to `true`, then field normalization\n * values will always be cached in memory.\n *\n * Defaults to the value of `cache` specified on the index itself.\n */\n cache?: boolean;\n};\n\n/**\n * Options for defining a stored value on an inverted index.\n */\nexport type InvertedIndexStoredValueOptions = {\n /**\n * The attribute paths to store.\n */\n fields: string[];\n /**\n * How the attribute values should be compressed.\n *\n * Default: `\"lz4\"`\n */\n compression?: Compression;\n /**\n * (Enterprise Edition only.) If set to `true`, then stored values will\n * always be cached in memory.\n *\n * Default: `false`\n */\n cache?: boolean;\n};\n\n/**\n * Options for defining a primary sort field on an inverted index.\n */\nexport type InvertedIndexPrimarySortFieldOptions = {\n /**\n * The attribute path to sort by.\n */\n field: string;\n /**\n * The sorting direction.\n */\n direction: Direction;\n};\n\n/**\n * Options for creating an inverted index.\n */\nexport type EnsureInvertedIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"inverted\";\n /**\n * An array of attribute paths or objects specifying options for the fields.\n */\n fields: (string | InvertedIndexFieldOptions)[];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true` array values will by default be indexed using the same\n * behavior as ArangoSearch Views. This option only applies when using the\n * index in a SearchAlias View.\n *\n * Default: `false`\n */\n searchField?: boolean;\n /**\n * An array of attribute paths that will be stored in the index but can not\n * be used for index lookups or sorting but can avoid full document lookups.\n */\n storedValues?: InvertedIndexStoredValueOptions[];\n /**\n * Primary sort order to optimize AQL queries using a matching sort order.\n */\n primarySort?: {\n /**\n * An array of fields to sort the index by.\n */\n fields: InvertedIndexPrimarySortFieldOptions[];\n /**\n * How the primary sort data should be compressed.\n *\n * Default: `\"lz4\"`\n */\n compression?: Compression;\n /**\n * (Enterprise Edition only.) If set to `true`, then primary sort columns\n * will always be cached in memory.\n *\n * Default: `false`\n */\n cache?: boolean;\n };\n /**\n * (Enterprise Edition only.) If set to `true`, then the primary key column\n * will always be cached in memory.\n *\n * Default: `false`\n */\n primaryKeyCache?: boolean;\n /**\n * Name of the default Analyzer to apply to the values of indexed fields.\n *\n * Default: `\"identity\"`\n */\n analyzer?: string;\n /**\n * List of Analyzer features to enable for the default Analyzer.\n *\n * Defaults to the Analyzer's features.\n */\n features?: AnalyzerFeature[];\n /**\n * If set to `true`, all document attributes are indexed, excluding any\n * sub-attributes configured in the `fields` array. The `analyzer` and\n * `features` properties apply to the sub-attributes. This option only\n * applies when using the index in a SearchAlias View.\n *\n * Default: `false`\n */\n includeAllFields?: boolean;\n /**\n * If set to `true`, the position of values in array values are tracked and\n * need to be specified in queries. Otherwise all values in an array are\n * treated as equivalent. This option only applies when using the index in a\n * SearchAlias View.\n *\n * Default: `false`\n */\n trackListPositions?: boolean;\n /**\n * The number of threads to use for indexing the fields.\n *\n * Default: `2`\n */\n parallelism?: number;\n /**\n * Wait at least this many commits between removing unused files in the\n * ArangoSearch data directory.\n *\n * Default: `2`\n */\n cleanupIntervalStep?: number;\n /**\n * Wait at least this many milliseconds between committing View data store\n * changes and making documents visible to queries.\n *\n * Default: `1000`\n */\n commitIntervalMsec?: number;\n /**\n * Wait at least this many milliseconds between applying\n * `consolidationPolicy` to consolidate View data store and possibly release\n * space on the filesystem.\n *\n * Default: `1000`\n */\n consolidationIntervalMsec?: number;\n /**\n * The consolidation policy to apply for selecting which segments should be\n * merged.\n *\n * Default: `{ type: \"tier\" }`\n */\n consolidationPolicy?: TierConsolidationPolicy;\n /**\n * Maximum number of writers (segments) cached in the pool.\n *\n * Default: `64`\n */\n writeBufferIdle?: number;\n /**\n * Maximum number of concurrent active writers (segments) that perform a\n * transaction.\n *\n * Default: `0` (disabled)\n */\n writeBufferActive?: number;\n /**\n * Maximum memory byte size per writer (segment) before a writer (segment)\n * flush is triggered.\n *\n * Default: `33554432` (32 MiB)\n */\n writeBufferSizeMax?: number;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n /**\n * (Enterprise Edition only.) If set to `true`, then field normalization\n * values will always be cached in memory.\n *\n * Default: `false`\n */\n cache?: boolean;\n /**\n * An array of strings defining sort expressions to optimize.\n */\n optimizeTopK?: string[];\n};\n\n/**\n * Shared attributes of all index types.\n */\nexport type GenericIndex = {\n /**\n * A unique name for this index.\n */\n name: string;\n /**\n * A unique identifier for this index.\n */\n id: string;\n /**\n * Whether documents not containing at least one of the attribute paths\n * are omitted by this index.\n */\n sparse: boolean;\n /**\n * Whether this index enforces uniqueness for values of its attribute paths.\n */\n unique: boolean;\n};\n\n/**\n * An object representing a persistent index.\n */\nexport type PersistentIndex = GenericIndex & {\n type: \"persistent\";\n fields: string[];\n cacheEnabled: boolean;\n deduplicate: boolean;\n estimates: boolean;\n storedValues?: string[];\n};\n\n/**\n * An object representing a primary index.\n */\nexport type PrimaryIndex = GenericIndex & {\n type: \"primary\";\n fields: string[];\n selectivityEstimate: number;\n};\n\n/**\n * An object representing a fulltext index.\n *\n * @deprecated Fulltext indexes have been deprecated in ArangoDB 3.10 and\n * should be replaced with ArangoSearch.\n */\nexport type FulltextIndex = GenericIndex & {\n type: \"fulltext\";\n fields: [string];\n minLength: number;\n};\n\n/**\n * An object representing a geo index.\n */\nexport type GeoIndex = GenericIndex & {\n type: \"geo\";\n fields: [string] | [string, string];\n geoJson: boolean;\n legacyPolygons: boolean;\n bestIndexedLevel: number;\n worstIndexedLevel: number;\n maxNumCoverCells: number;\n};\n\n/**\n * An object representing a TTL index.\n */\nexport type TtlIndex = GenericIndex & {\n type: \"ttl\";\n fields: [string];\n expireAfter: number;\n selectivityEstimate: number;\n};\n\n/**\n * An object representing a MDI index.\n */\nexport type MdiIndex = GenericIndex & {\n type: \"mdi\";\n fields: string[];\n fieldValueTypes: \"double\";\n};\n\n/**\n * (Enterprise Edition only.) An object representing a nested field in an\n * inverted index.\n */\nexport type InvertedIndexNestedField = {\n name: string;\n analyzer?: string;\n features?: AnalyzerFeature[];\n searchField?: boolean;\n nested?: InvertedIndexNestedField[];\n};\n\n/**\n * An object representing an inverted index.\n */\nexport type InvertedIndex = GenericIndex & {\n type: \"inverted\";\n fields: {\n name: string;\n analyzer?: string;\n features?: AnalyzerFeature[];\n includeAllFields?: boolean;\n searchField?: boolean;\n trackListPositions?: boolean;\n nested?: InvertedIndexNestedField[];\n cache?: boolean;\n }[];\n searchField: boolean;\n cache?: boolean;\n storedValues: {\n fields: string[];\n compression: Compression;\n cache?: boolean;\n }[];\n primarySort: {\n fields: {\n field: string;\n direction: Direction;\n }[];\n compression: Compression;\n cache?: boolean;\n };\n primaryKeyCache?: boolean;\n analyzer: string;\n features: AnalyzerFeature[];\n includeAllFields: boolean;\n trackListPositions: boolean;\n parallelism: number;\n cleanupIntervalStep: number;\n commitIntervalMsec: number;\n consolidationIntervalMsec: number;\n consolidationPolicy: Required<TierConsolidationPolicy>;\n writeBufferIdle: number;\n writeBufferActive: number;\n writeBufferSizeMax: number;\n optimizeTopK: string[];\n};\n\n/**\n * An object representing an index.\n */\nexport type Index =\n | GeoIndex\n | FulltextIndex\n | PersistentIndex\n | PrimaryIndex\n | TtlIndex\n | MdiIndex\n | InvertedIndex;\n\nexport type ObjectWithId = {\n [key: string]: any;\n id: string;\n};\n\nexport type ObjectWithName = {\n [key: string]: any;\n name: string;\n};\n\n/**\n * Index name, id or object with a `name` or `id` property.\n */\nexport type IndexSelector = ObjectWithId | ObjectWithName | string;\n\n/**\n * @internal\n */\nexport function _indexHandle(\n selector: IndexSelector,\n collectionName: string\n): string {\n if (typeof selector !== \"string\") {\n if (selector.id) {\n return _indexHandle(selector.id, collectionName);\n }\n throw new Error(\n \"Index handle must be a string or an object with an id attribute\"\n );\n }\n if (selector.includes(\"/\")) {\n const [head, ...tail] = selector.split(\"/\");\n const normalizedHead = head.normalize(\"NFC\");\n if (normalizedHead !== collectionName) {\n throw new Error(\n `Index ID \"${selector}\" does not match collection name \"${collectionName}\"`\n );\n }\n selector = tail.join(\"/\").normalize(\"NFC\");\n return [normalizedHead, selector].join(\"/\");\n }\n return `${collectionName}/${String(selector).normalize(\"NFC\")}`;\n}\n"]}
|