arangojs 7.3.0 → 7.6.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/README.md +4 -2
  3. package/analyzer.d.ts +188 -1
  4. package/analyzer.d.ts.map +1 -1
  5. package/analyzer.js.map +1 -1
  6. package/aql.d.ts +2 -1
  7. package/aql.d.ts.map +1 -1
  8. package/aql.js +5 -1
  9. package/aql.js.map +1 -1
  10. package/collection.d.ts +72 -11
  11. package/collection.d.ts.map +1 -1
  12. package/collection.js +16 -3
  13. package/collection.js.map +1 -1
  14. package/connection.d.ts +3 -3
  15. package/connection.d.ts.map +1 -1
  16. package/connection.js +21 -9
  17. package/connection.js.map +1 -1
  18. package/cursor.js +4 -4
  19. package/cursor.js.map +1 -1
  20. package/database.d.ts +451 -4
  21. package/database.d.ts.map +1 -1
  22. package/database.js +357 -0
  23. package/database.js.map +1 -1
  24. package/documents.d.ts +6 -6
  25. package/documents.d.ts.map +1 -1
  26. package/documents.js +2 -2
  27. package/documents.js.map +1 -1
  28. package/error.d.ts +10 -0
  29. package/error.d.ts.map +1 -1
  30. package/error.js +14 -0
  31. package/error.js.map +1 -1
  32. package/graph.d.ts +16 -4
  33. package/graph.d.ts.map +1 -1
  34. package/graph.js +18 -1
  35. package/graph.js.map +1 -1
  36. package/indexes.d.ts +70 -0
  37. package/indexes.d.ts.map +1 -1
  38. package/indexes.js.map +1 -1
  39. package/lib/error.d.ts.map +1 -1
  40. package/lib/error.js +1 -0
  41. package/lib/error.js.map +1 -1
  42. package/lib/multipart.d.ts.map +1 -1
  43. package/lib/multipart.js +1 -0
  44. package/lib/multipart.js.map +1 -1
  45. package/lib/normalizeUrl.js +1 -1
  46. package/lib/normalizeUrl.js.map +1 -1
  47. package/lib/request.node.js.map +1 -1
  48. package/lib/xhr.d.ts.map +1 -1
  49. package/lib/xhr.js +1 -0
  50. package/lib/xhr.js.map +1 -1
  51. package/package.json +1 -1
  52. package/view.d.ts +1 -1
  53. package/view.d.ts.map +1 -1
  54. package/view.js.map +1 -1
  55. package/web.js +1 -1
  56. package/web.js.map +1 -1
package/CHANGELOG.md CHANGED
@@ -14,6 +14,78 @@ This driver uses semantic versioning:
14
14
  - A change in the major version (e.g. 1.Y.Z -> 2.0.0) indicates _breaking_
15
15
  changes that require changes in your code to upgrade.
16
16
 
17
+ ## [7.6.0] - 2021-10-20
18
+
19
+ ### Added
20
+
21
+ - Added `collection.documents` for fetching multiple documents
22
+
23
+ - Added support for `fillBlockCache` query option
24
+
25
+ - Added support for passing `Graph` objects in AQL queries [#740](https://github.com/arangodb/arangojs/issues/740)
26
+
27
+ This also adds the `isArangoGraph` helper function for type checking.
28
+
29
+ - Added User Management API [#664](https://github.com/arangodb/arangojs/issues/664)
30
+
31
+ This implements the endpoints of the
32
+ [HTTP Interface for User Management](https://www.arangodb.com/docs/stable/http/user-management.html)
33
+
34
+ ### Fixed
35
+
36
+ - Added missing `hex` flag to `StopwordsAnalyzer` type [#732](https://github.com/arangodb/arangojs/issues/732)
37
+
38
+ - Added missing `details` flag to `collection.figures` [#728](https://github.com/arangodb/arangojs/issues/728)
39
+
40
+ - Added missing `inBackground` flag to index options [#734](https://github.com/arangodb/arangojs/issues/734)
41
+
42
+ ## [7.5.0] - 2021-04-22
43
+
44
+ ### Added
45
+
46
+ - Added support for new ArangoDB 3.8 Analyzer types
47
+
48
+ This adds the `PipelineAnalyzer`, `AqlAnalyzer`, `GeoJsonAnalyzer`,
49
+ `GeoPointAnalyzer` and `StopwordsAnalyzer` types in TypeScript, as well as
50
+ the Analyzer-specific properties types.
51
+
52
+ - Added support for new ArangoDB 3.8 `estimates` option for indexes
53
+
54
+ This affects the `PersistentIndex`, `HashIndex` and `SkiplistIndex` types
55
+ in TypeScript.
56
+
57
+ ## [7.4.0] - 2021-04-09
58
+
59
+ ### Added
60
+
61
+ - Implemented `toJSON` methods for `ArangoError` and `HttpError` ([#632](https://github.com/arangodb/arangojs/issues/632))
62
+
63
+ This prevents an error where `JSON.stringify` would reliably throw if passed
64
+ an instance of either of these error types generated by arangojs. Note that
65
+ you may still want to implement your own JSON representation logic as system
66
+ errors (e.g. `ECONNREFUSED`) are not wrapped by arangojs and thrown as-is.
67
+
68
+ ### Fixed
69
+
70
+ - Stack traces are now improved for most errors when using `precaptureStackTraces` ([#722](https://github.com/arangodb/arangojs/issues/722))
71
+
72
+ Previously this option would only affect network errors, making it far less
73
+ useful than intended. Now parsing errors, `ArangoError` instances and HTTP
74
+ errors also receive improved error stack traces when this option is enabled.
75
+
76
+ - Improved performance for `precaptureStackTraces` when no errors occur
77
+
78
+ The generated stack is now only accessed on demand, allowing the runtime to
79
+ delay generation of the stack trace string. Previously the stack would always
80
+ be accessed prior to the request being sent, causing a noticeable delay even
81
+ when no error occurs.
82
+
83
+ - Fixed document selector validation in `collection.edges` and its variants ([#704](https://github.com/arangodb/arangojs/issues/704))
84
+
85
+ These methods previously only permitted start vertices that are documents
86
+ within the edge collection itself. This behavior has now been corrected to
87
+ permit start vertices outside the collection, as expected.
88
+
17
89
  ## [7.3.0] - 2021-03-08
18
90
 
19
91
  ### Changed
@@ -1153,6 +1225,9 @@ For a detailed list of changes between pre-release versions of v7 see the
1153
1225
 
1154
1226
  Graph methods now only return the relevant part of the response body.
1155
1227
 
1228
+ [7.6.0]: https://github.com/arangodb/arangojs/compare/v7.5.0...v7.6.0
1229
+ [7.5.0]: https://github.com/arangodb/arangojs/compare/v7.4.0...v7.5.0
1230
+ [7.4.0]: https://github.com/arangodb/arangojs/compare/v7.3.0...v7.4.0
1156
1231
  [7.3.0]: https://github.com/arangodb/arangojs/compare/v7.2.0...v7.3.0
1157
1232
  [7.2.0]: https://github.com/arangodb/arangojs/compare/v7.1.1...v7.2.0
1158
1233
  [7.1.1]: https://github.com/arangodb/arangojs/compare/v7.1.0...v7.1.1
package/README.md CHANGED
@@ -69,12 +69,12 @@ Modern JavaScript/TypeScript with async/await:
69
69
  const { Database, aql } = require("arangojs");
70
70
 
71
71
  const db = new Database();
72
- const pokemons = db.collection("my-pokemons");
72
+ const Pokemons = db.collection("my-pokemons");
73
73
 
74
74
  async function main() {
75
75
  try {
76
76
  const pokemons = await db.query(aql`
77
- FOR pokemon IN ${pokemons}
77
+ FOR pokemon IN ${Pokemons}
78
78
  FILTER pokemon.type == "fire"
79
79
  RETURN pokemon
80
80
  `);
@@ -345,6 +345,8 @@ Please refer to the documentation of this method for additional examples.
345
345
 
346
346
  ### Streaming transactions timeout in cluster
347
347
 
348
+ Example messages: `transaction not found`, `transaction already expired`.
349
+
348
350
  Transactions have
349
351
  [different guarantees](https://www.arangodb.com/docs/stable/transactions-limitations.html#in-clusters)
350
352
  in a cluster.
package/analyzer.d.ts CHANGED
@@ -39,7 +39,7 @@ export declare type CreateAnalyzerOptions = AnalyzerInfo & {
39
39
  /**
40
40
  * Analyzer type and its type-specific properties.
41
41
  */
42
- export declare type AnalyzerInfo = IdentityAnalyzerInfo | DelimiterAnalyzerInfo | StemAnalyzerInfo | NormAnalyzerInfo | NgramAnalyzerInfo | TextAnalyzerInfo;
42
+ export declare type AnalyzerInfo = IdentityAnalyzerInfo | DelimiterAnalyzerInfo | StemAnalyzerInfo | NormAnalyzerInfo | NgramAnalyzerInfo | TextAnalyzerInfo | PipelineAnalyzer | AqlAnalyzer | GeoJsonAnalyzer | GeoPointAnalyzer | StopwordsAnalyzer;
43
43
  /**
44
44
  * Analyzer type and type-specific properties for an Identity Analyzer.
45
45
  */
@@ -200,6 +200,14 @@ export declare type TextAnalyzerProperties = {
200
200
  * Default: `true`
201
201
  */
202
202
  stemming?: boolean;
203
+ /**
204
+ * If present, then edge n-grams are generated for each token (word).
205
+ */
206
+ edgeNgram?: {
207
+ min?: number;
208
+ max?: number;
209
+ preserveOriginal?: boolean;
210
+ };
203
211
  };
204
212
  /**
205
213
  * Analyzer type and type-specific properties for a Text Analyzer.
@@ -214,6 +222,185 @@ export declare type TextAnalyzerInfo = {
214
222
  */
215
223
  properties: TextAnalyzerProperties;
216
224
  };
225
+ /**
226
+ * Properties of a Pipeline Analyzer.
227
+ */
228
+ export declare type PipelineAnalyzerProperties = {
229
+ /**
230
+ * Definitions for Analyzers to chain in this Pipeline Analyzer.
231
+ */
232
+ pipeline: AnalyzerInfo[];
233
+ };
234
+ /**
235
+ * Analyzer type and type-specific properties for a Pipeline Analyzer
236
+ */
237
+ export declare type PipelineAnalyzer = {
238
+ /**
239
+ * Type of the Analyzer.
240
+ */
241
+ type: "pipeline";
242
+ /**
243
+ * Additional properties for the Analyzer.
244
+ */
245
+ properties: PipelineAnalyzerProperties;
246
+ };
247
+ /**
248
+ * Properties of an AQL Analyzer.
249
+ */
250
+ export declare type AqlAnalyzerProperties = {
251
+ /**
252
+ * AQL query to be executed.
253
+ */
254
+ queryString: string;
255
+ /**
256
+ * If set to `true`, the position is set to `0` for all members of the query result array.
257
+ *
258
+ * Default: `false`
259
+ */
260
+ collapsePositions?: boolean;
261
+ /**
262
+ * If set to `false`, `null` values will be discarded from the View index.
263
+ *
264
+ * Default: `true`
265
+ */
266
+ keepNull?: boolean;
267
+ /**
268
+ * Number between `1` and `1000` that determines the batch size for reading
269
+ * data from the query.
270
+ *
271
+ * Default: `1`
272
+ */
273
+ batchSize?: number;
274
+ /**
275
+ * Memory limit for query execution in bytes.
276
+ *
277
+ * Default: `1048576` (1 MiB)
278
+ */
279
+ memoryLimit?: number;
280
+ /**
281
+ * Data type of the returned tokens.
282
+ *
283
+ * Default: `"string"`
284
+ */
285
+ returnType?: "string" | "number" | "bool";
286
+ };
287
+ /**
288
+ * Analyzer type and type-specific properties for an AQL Analyzer
289
+ */
290
+ export declare type AqlAnalyzer = {
291
+ /**
292
+ * Type of the Analyzer.
293
+ */
294
+ type: "aql";
295
+ /**
296
+ * Additional properties for the Analyzer.
297
+ */
298
+ properties: AqlAnalyzerProperties;
299
+ };
300
+ /**
301
+ * Properties of a GeoJSON Analyzer.
302
+ */
303
+ export declare type GeoJsonAnalyzerProperties = {
304
+ /**
305
+ * If set to `"centroid"`, only the centroid of the input geometry will be
306
+ * computed and indexed.
307
+ *
308
+ * If set to `"point"` only GeoJSON objects of type Point will be indexed and
309
+ * all other geometry types will be ignored.
310
+ *
311
+ * Default: `"shape"`
312
+ */
313
+ type?: "shape" | "centroid" | "point";
314
+ /**
315
+ * Options for fine-tuning geo queries.
316
+ *
317
+ * Default: `{ maxCells: 20, minLevel: 4, maxLevel: 23 }`
318
+ */
319
+ options?: {
320
+ maxCells?: number;
321
+ minLevel?: number;
322
+ maxLevel?: number;
323
+ };
324
+ };
325
+ /**
326
+ * Analyzer type and type-specific properties for a GeoJSON Analyzer
327
+ */
328
+ export declare type GeoJsonAnalyzer = {
329
+ /**
330
+ * Type of the Analyzer.
331
+ */
332
+ type: "geojson";
333
+ /**
334
+ * Additional properties for the Analyzer.
335
+ */
336
+ properties: GeoJsonAnalyzerProperties;
337
+ };
338
+ /**
339
+ * Properties of a GeoPoint Analyzer.
340
+ */
341
+ export declare type GeoPointAnalyzerProperties = {
342
+ /**
343
+ * Attribute paths of the latitude value relative to the field for which the
344
+ * Analyzer is defined in the View.
345
+ */
346
+ latitude?: string[];
347
+ /**
348
+ * Attribute paths of the longitude value relative to the field for which the
349
+ * Analyzer is defined in the View.
350
+ */
351
+ longitude?: string[];
352
+ /**
353
+ * Options for fine-tuning geo queries.
354
+ *
355
+ * Default: `{ maxCells: 20, minLevel: 4, maxLevel: 23 }`
356
+ */
357
+ options?: {
358
+ minCells?: number;
359
+ minLevel?: number;
360
+ maxLevel?: number;
361
+ };
362
+ };
363
+ /**
364
+ * Analyzer type and type-specific properties for a GeoPoint Analyzer
365
+ */
366
+ export declare type GeoPointAnalyzer = {
367
+ /**
368
+ * Type of the Analyzer.
369
+ */
370
+ type: "geopoint";
371
+ /**
372
+ * Additional properties for the Analyzer.
373
+ */
374
+ properties: GeoPointAnalyzerProperties;
375
+ };
376
+ /**
377
+ * Properties of a Stopwords Analyzer.
378
+ */
379
+ export declare type StopwordsAnalyzerProperties = {
380
+ /**
381
+ * Array of strings that describe the tokens to be discarded.
382
+ */
383
+ stopwords: string[];
384
+ /**
385
+ * Whether stopword values should be interpreted as hex-encoded strings.
386
+ *
387
+ * Default: `false`
388
+ */
389
+ hex?: boolean;
390
+ };
391
+ /**
392
+ * Analyzer type and type-specific properties for a Stopwords Analyzer
393
+ */
394
+ export declare type StopwordsAnalyzer = {
395
+ /**
396
+ * Type of the Analyzer.
397
+ */
398
+ type: "stopwords";
399
+ /**
400
+ * Additional properties for the Analyzer.
401
+ */
402
+ properties: StopwordsAnalyzerProperties;
403
+ };
217
404
  /**
218
405
  * Represents an Analyzer in a {@link Database}.
219
406
  */
package/analyzer.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,GAAG,GAAG,QAAQ,IAAI,QAAQ,CAEpE;AAED;;GAEG;AACH,oBAAY,eAAe,GAAG,WAAW,GAAG,MAAM,GAAG,UAAU,CAAC;AAEhE;;GAEG;AACH,oBAAY,mBAAmB,GAAG,YAAY,GAAG;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,oBAAY,qBAAqB,GAAG,YAAY,GAAG;IACjD;;OAEG;IACH,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;CAC9B,CAAC;AAEF;;GAEG;AACH,oBAAY,YAAY,GACpB,oBAAoB,GACpB,qBAAqB,GACrB,gBAAgB,GAChB,gBAAgB,GAChB,iBAAiB,GACjB,gBAAgB,CAAC;AAErB;;GAEG;AACH,oBAAY,oB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EAAE,EACvC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAClB,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,OAA8B;QACnC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CACrB;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,OAAO,EAAE;SACtC,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAClB,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,IAAI,CACF,QAAiB,KAAK;QAEtB,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CACrB;YACE,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,kBAAkB,IAAI,CAAC,IAAI,EAAE;YACnC,EAAE,EAAE,EAAE,KAAK,EAAE;SACd,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAClB,CAAC;IACJ,CAAC;CACF;AA5HD,4BA4HC","sourcesContent":["/**\n * ```ts\n * import type { Analyzer } from \"arangojs/analyzer\";\n * ```\n *\n * The \"analyzer\" module provides analyzer related types and interfaces\n * for TypeScript.\n *\n * @packageDocumentation\n */\nimport { ArangoResponseMetadata } from \"./connection\";\nimport { Database } from \"./database\";\nimport { isArangoError } from \"./error\";\nimport { ANALYZER_NOT_FOUND } from \"./lib/codes\";\n\n/**\n * Indicates whether the given value represents an {@link Analyzer}.\n *\n * @param analyzer - A value that might be an Analyzer.\n */\nexport function isArangoAnalyzer(analyzer: any): analyzer is Analyzer {\n return Boolean(analyzer && analyzer.isArangoAnalyzer);\n}\n\n/**\n * Name of a feature enabled for an Analyzer.\n */\nexport type AnalyzerFeature = \"frequency\" | \"norm\" | \"position\";\n\n/**\n * An object describing an Analyzer.\n */\nexport type AnalyzerDescription = AnalyzerInfo & {\n name: string;\n features: AnalyzerFeature[];\n};\n\n/**\n * Options for creating an Analyzer.\n */\nexport type CreateAnalyzerOptions = AnalyzerInfo & {\n /**\n * Features to enable for this Analyzer.\n */\n features?: AnalyzerFeature[];\n};\n\n/**\n * Analyzer type and its type-specific properties.\n */\nexport type AnalyzerInfo =\n | IdentityAnalyzerInfo\n | DelimiterAnalyzerInfo\n | StemAnalyzerInfo\n | NormAnalyzerInfo\n | NgramAnalyzerInfo\n | TextAnalyzerInfo;\n\n/**\n * Analyzer type and type-specific properties for an Identity Analyzer.\n */\nexport type IdentityAnalyzerInfo = {\n /**\n * Type of the Analyzer.\n */\n type: \"identity\";\n /**\n * Additional properties for the Analyzer.\n *\n * The `identity` Analyzer does not take additional properties.\n */\n properties?: null;\n};\n\n/**\n * Analyzer type and type-specific properties for a Delimiter Analyzer.\n */\nexport type DelimiterAnalyzerInfo = {\n /**\n * Type of the Analyzer.\n */\n type: \"delimiter\";\n /**\n * Additional properties for the Analyzer.\n *\n * The value will be used as delimiter to split text into tokens as specified\n * in RFC 4180, without starting new records on newlines.\n */\n properties: string | { delimiter: string };\n};\n\n/**\n * Analyzer type and type-specific properties for a Stem Analyzer.\n */\nexport type StemAnalyzerInfo = {\n /**\n * Type of the Analyzer.\n */\n type: \"stem\";\n /**\n * Additional properties for the Analyzer.\n *\n * The value defines the text locale.\n *\n * Format: `language[_COUNTRY][.encoding][@variant]`\n */\n properties: { locale: string };\n};\n\n/**\n * Properties of a Norm Analyzer.\n */\nexport type NormAnalyzerProperties = {\n /**\n * Text locale.\n *\n * Format: `language[_COUNTRY][.encoding][@variant]`\n */\n locale: string;\n /**\n * Case conversion.\n *\n * Default: `\"lower\"`\n */\n case?: \"lower\" | \"none\" | \"upper\";\n /**\n * Preserve accents in returned words.\n *\n * Default: `false`\n */\n accent?: boolean;\n};\n\n/**\n * Analyzer type and type-specific properties for a Norm Analyzer.\n */\nexport type NormAnalyzerInfo = {\n /**\n * Type of the Analyzer.\n */\n type: \"norm\";\n /**\n * Additional properties for the Analyzer.\n */\n properties: NormAnalyzerProperties;\n};\n\n/**\n * Properties of an Ngram Analyzer.\n */\nexport type NgramAnalyzerProperties = {\n /**\n * Maximum n-gram length.\n */\n max: number;\n /**\n * Minimum n-gram length.\n */\n min: number;\n /**\n * Output the original value as well.\n */\n preserveOriginal: boolean;\n};\n\n/**\n * Analyzer type and type-specific properties for an Ngram Analyzer.\n */\nexport type NgramAnalyzerInfo = {\n /**\n * Type of the Analyzer.\n */\n type: \"ngram\";\n /**\n * Additional properties for the Analyzer.\n */\n properties: NgramAnalyzerProperties;\n};\n\n/**\n * Properties of a Text Analyzer.\n */\nexport type TextAnalyzerProperties = {\n /**\n * Text locale.\n *\n * Format: `language[_COUNTRY][.encoding][@variant]`\n */\n locale: string;\n /**\n * Case conversion.\n *\n * Default: `\"lower\"`\n */\n case?: \"lower\" | \"none\" | \"upper\";\n /**\n * Words to omit from result.\n *\n * Defaults to the words loaded from the file at `stopwordsPath`.\n */\n stopwords?: string[];\n /**\n * Path with a `language` sub-directory containing files with words to omit.\n *\n * Defaults to the path specified in the server-side environment variable\n * `IRESEARCH_TEXT_STOPWORD_PATH` or the current working directory of the\n * ArangoDB process.\n */\n stopwordsPath?: string;\n /**\n * Preserve accents in returned words.\n *\n * Default: `false`\n */\n accent?: boolean;\n /**\n * Apply stemming on returned words.\n *\n * Default: `true`\n */\n stemming?: boolean;\n};\n\n/**\n * Analyzer type and type-specific properties for a Text Analyzer.\n */\nexport type TextAnalyzerInfo = {\n /**\n * Type of the Analyzer.\n */\n type: \"text\";\n /**\n * Additional properties for the Analyzer.\n */\n properties: TextAnalyzerProperties;\n};\n\n/**\n * Represents an Analyzer in a {@link Database}.\n */\nexport class Analyzer {\n protected _name: string;\n protected _db: Database;\n\n /**\n * @internal\n * @hidden\n */\n constructor(db: Database, name: string) {\n this._db = db;\n this._name = name;\n }\n\n /**\n * @internal\n *\n * Indicates that this object represents an ArangoDB Analyzer.\n */\n get isArangoAnalyzer(): true {\n return true;\n }\n\n /**\n * Name of this Analyzer.\n *\n * See also {@link Database.analyzer}.\n */\n get name() {\n return this._name;\n }\n\n /**\n * Checks whether the Analyzer exists.\n *\n * @example\n * ```js\n * const db = new Database();\n * const analyzer = db.analyzer(\"some-analyzer\");\n * const result = await analyzer.exists();\n * // result indicates whether the Analyzer exists\n * ```\n */\n async exists(): Promise<boolean> {\n try {\n await this.get();\n return true;\n } catch (err) {\n if (isArangoError(err) && err.errorNum === ANALYZER_NOT_FOUND) {\n return false;\n }\n throw err;\n }\n }\n\n /**\n * Retrieves the Analyzer definition for the Analyzer.\n *\n * @example\n * ```js\n * const db = new Database();\n * const analyzer = db.analyzer(\"some-analyzer\");\n * const definition = await analyzer.get();\n * // definition contains the Analyzer definition\n * ```\n */\n get(): Promise<ArangoResponseMetadata & AnalyzerDescription> {\n return this._db.request(\n { path: `/_api/analyzer/${this.name}` },\n (res) => res.body\n );\n }\n\n /**\n * Creates a new Analyzer with the given `options` and the instance's name.\n *\n * See also {@link Database.createAnalyzer}.\n *\n * @param options - Options for creating the Analyzer.\n *\n * @example\n * ```js\n * const db = new Database();\n * const analyzer = db.analyzer(\"potatoes\");\n * await analyzer.create({ type: \"identity\" });\n * // the identity Analyzer \"potatoes\" now exists\n * ```\n */\n create(options: CreateAnalyzerOptions): Promise<AnalyzerDescription> {\n return this._db.request(\n {\n method: \"POST\",\n path: \"/_api/analyzer\",\n body: { name: this.name, ...options },\n },\n (res) => res.body\n );\n }\n\n /**\n * Deletes the Analyzer from the database.\n *\n * @param force - Whether the Analyzer should still be deleted even if it\n * is currently in use.\n *\n * @example\n * ```js\n * const db = new Database();\n * const analyzer = db.analyzer(\"some-analyzer\");\n * await analyzer.drop();\n * // the Analyzer \"some-analyzer\" no longer exists\n * ```\n */\n drop(\n force: boolean = false\n ): Promise<ArangoResponseMetadata & { name: string }> {\n return this._db.request(\n {\n method: \"DELETE\",\n path: `/_api/analyzer/${this.name}`,\n qs: { force },\n },\n (res) => res.body\n );\n }\n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gB;YACtB,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,OAAO,EAAE;SACtC,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAClB,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,IAAI,CACF,QAAiB,KAAK;QAEtB,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CACrB;YACE,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,kBAAkB,IAAI,CAAC,IAAI,EAAE;YACnC,EAAE,EAAE,EAAE,KAAK,EAAE;SACd,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAClB,CAAC;IACJ,CAAC;CACF;AA5HD,4BA4HC","sourcesContent":["/**\n * ```ts\n * import type { Analyzer } from \"arangojs/analyzer\";\n * ```\n *\n * The \"analyzer\" module provides analyzer related types and interfaces\n * for TypeScript.\n *\n * @packageDocumentation\n */\nimport { ArangoResponseMetadata } from \"./connection\";\nimport { Database } from \"./database\";\nimport { isArangoError } from \"./error\";\nimport { ANALYZER_NOT_FOUND } from \"./lib/codes\";\n\n/**\n * Indicates whether the given value represents an {@link Analyzer}.\n *\n * @param analyzer - A value that might be an Analyzer.\n */\nexport function isArangoAnalyzer(analyzer: any): analyzer is Analyzer {\n return Boolean(analyzer && analyzer.isArangoAnalyzer);\n}\n\n/**\n * Name of a feature enabled for an Analyzer.\n */\nexport type AnalyzerFeature = \"frequency\" | \"norm\" | \"position\";\n\n/**\n * An object describing an Analyzer.\n */\nexport type AnalyzerDescription = AnalyzerInfo & {\n name: string;\n features: AnalyzerFeature[];\n};\n\n/**\n * Options for creating an Analyzer.\n */\nexport type CreateAnalyzerOptions = AnalyzerInfo & {\n /**\n * Features to enable for this Analyzer.\n */\n features?: AnalyzerFeature[];\n};\n\n/**\n * Analyzer type and its type-specific properties.\n */\nexport type AnalyzerInfo =\n | IdentityAnalyzerInfo\n | DelimiterAnalyzerInfo\n | StemAnalyzerInfo\n | NormAnalyzerInfo\n | NgramAnalyzerInfo\n | TextAnalyzerInfo\n | PipelineAnalyzer\n | AqlAnalyzer\n | GeoJsonAnalyzer\n | GeoPointAnalyzer\n | StopwordsAnalyzer;\n\n/**\n * Analyzer type and type-specific properties for an Identity Analyzer.\n */\nexport type IdentityAnalyzerInfo = {\n /**\n * Type of the Analyzer.\n */\n type: \"identity\";\n /**\n * Additional properties for the Analyzer.\n *\n * The `identity` Analyzer does not take additional properties.\n */\n properties?: null;\n};\n\n/**\n * Analyzer type and type-specific properties for a Delimiter Analyzer.\n */\nexport type DelimiterAnalyzerInfo = {\n /**\n * Type of the Analyzer.\n */\n type: \"delimiter\";\n /**\n * Additional properties for the Analyzer.\n *\n * The value will be used as delimiter to split text into tokens as specified\n * in RFC 4180, without starting new records on newlines.\n */\n properties: string | { delimiter: string };\n};\n\n/**\n * Analyzer type and type-specific properties for a Stem Analyzer.\n */\nexport type StemAnalyzerInfo = {\n /**\n * Type of the Analyzer.\n */\n type: \"stem\";\n /**\n * Additional properties for the Analyzer.\n *\n * The value defines the text locale.\n *\n * Format: `language[_COUNTRY][.encoding][@variant]`\n */\n properties: { locale: string };\n};\n\n/**\n * Properties of a Norm Analyzer.\n */\nexport type NormAnalyzerProperties = {\n /**\n * Text locale.\n *\n * Format: `language[_COUNTRY][.encoding][@variant]`\n */\n locale: string;\n /**\n * Case conversion.\n *\n * Default: `\"lower\"`\n */\n case?: \"lower\" | \"none\" | \"upper\";\n /**\n * Preserve accents in returned words.\n *\n * Default: `false`\n */\n accent?: boolean;\n};\n\n/**\n * Analyzer type and type-specific properties for a Norm Analyzer.\n */\nexport type NormAnalyzerInfo = {\n /**\n * Type of the Analyzer.\n */\n type: \"norm\";\n /**\n * Additional properties for the Analyzer.\n */\n properties: NormAnalyzerProperties;\n};\n\n/**\n * Properties of an Ngram Analyzer.\n */\nexport type NgramAnalyzerProperties = {\n /**\n * Maximum n-gram length.\n */\n max: number;\n /**\n * Minimum n-gram length.\n */\n min: number;\n /**\n * Output the original value as well.\n */\n preserveOriginal: boolean;\n};\n\n/**\n * Analyzer type and type-specific properties for an Ngram Analyzer.\n */\nexport type NgramAnalyzerInfo = {\n /**\n * Type of the Analyzer.\n */\n type: \"ngram\";\n /**\n * Additional properties for the Analyzer.\n */\n properties: NgramAnalyzerProperties;\n};\n\n/**\n * Properties of a Text Analyzer.\n */\nexport type TextAnalyzerProperties = {\n /**\n * Text locale.\n *\n * Format: `language[_COUNTRY][.encoding][@variant]`\n */\n locale: string;\n /**\n * Case conversion.\n *\n * Default: `\"lower\"`\n */\n case?: \"lower\" | \"none\" | \"upper\";\n /**\n * Words to omit from result.\n *\n * Defaults to the words loaded from the file at `stopwordsPath`.\n */\n stopwords?: string[];\n /**\n * Path with a `language` sub-directory containing files with words to omit.\n *\n * Defaults to the path specified in the server-side environment variable\n * `IRESEARCH_TEXT_STOPWORD_PATH` or the current working directory of the\n * ArangoDB process.\n */\n stopwordsPath?: string;\n /**\n * Preserve accents in returned words.\n *\n * Default: `false`\n */\n accent?: boolean;\n /**\n * Apply stemming on returned words.\n *\n * Default: `true`\n */\n stemming?: boolean;\n /**\n * If present, then edge n-grams are generated for each token (word).\n */\n edgeNgram?: { min?: number; max?: number; preserveOriginal?: boolean };\n};\n\n/**\n * Analyzer type and type-specific properties for a Text Analyzer.\n */\nexport type TextAnalyzerInfo = {\n /**\n * Type of the Analyzer.\n */\n type: \"text\";\n /**\n * Additional properties for the Analyzer.\n */\n properties: TextAnalyzerProperties;\n};\n\n/**\n * Properties of a Pipeline Analyzer.\n */\nexport type PipelineAnalyzerProperties = {\n /**\n * Definitions for Analyzers to chain in this Pipeline Analyzer.\n */\n pipeline: AnalyzerInfo[];\n};\n\n/**\n * Analyzer type and type-specific properties for a Pipeline Analyzer\n */\nexport type PipelineAnalyzer = {\n /**\n * Type of the Analyzer.\n */\n type: \"pipeline\";\n /**\n * Additional properties for the Analyzer.\n */\n properties: PipelineAnalyzerProperties;\n};\n\n/**\n * Properties of an AQL Analyzer.\n */\nexport type AqlAnalyzerProperties = {\n /**\n * AQL query to be executed.\n */\n queryString: string;\n /**\n * If set to `true`, the position is set to `0` for all members of the query result array.\n *\n * Default: `false`\n */\n collapsePositions?: boolean;\n /**\n * If set to `false`, `null` values will be discarded from the View index.\n *\n * Default: `true`\n */\n keepNull?: boolean;\n /**\n * Number between `1` and `1000` that determines the batch size for reading\n * data from the query.\n *\n * Default: `1`\n */\n batchSize?: number;\n /**\n * Memory limit for query execution in bytes.\n *\n * Default: `1048576` (1 MiB)\n */\n memoryLimit?: number;\n /**\n * Data type of the returned tokens.\n *\n * Default: `\"string\"`\n */\n returnType?: \"string\" | \"number\" | \"bool\";\n};\n\n/**\n * Analyzer type and type-specific properties for an AQL Analyzer\n */\nexport type AqlAnalyzer = {\n /**\n * Type of the Analyzer.\n */\n type: \"aql\";\n /**\n * Additional properties for the Analyzer.\n */\n properties: AqlAnalyzerProperties;\n};\n\n/**\n * Properties of a GeoJSON Analyzer.\n */\nexport type GeoJsonAnalyzerProperties = {\n /**\n * If set to `\"centroid\"`, only the centroid of the input geometry will be\n * computed and indexed.\n *\n * If set to `\"point\"` only GeoJSON objects of type Point will be indexed and\n * all other geometry types will be ignored.\n *\n * Default: `\"shape\"`\n */\n type?: \"shape\" | \"centroid\" | \"point\";\n /**\n * Options for fine-tuning geo queries.\n *\n * Default: `{ maxCells: 20, minLevel: 4, maxLevel: 23 }`\n */\n options?: { maxCells?: number; minLevel?: number; maxLevel?: number };\n};\n\n/**\n * Analyzer type and type-specific properties for a GeoJSON Analyzer\n */\nexport type GeoJsonAnalyzer = {\n /**\n * Type of the Analyzer.\n */\n type: \"geojson\";\n /**\n * Additional properties for the Analyzer.\n */\n properties: GeoJsonAnalyzerProperties;\n};\n\n/**\n * Properties of a GeoPoint Analyzer.\n */\nexport type GeoPointAnalyzerProperties = {\n /**\n * Attribute paths of the latitude value relative to the field for which the\n * Analyzer is defined in the View.\n */\n latitude?: string[];\n /**\n * Attribute paths of the longitude value relative to the field for which the\n * Analyzer is defined in the View.\n */\n longitude?: string[];\n /**\n * Options for fine-tuning geo queries.\n *\n * Default: `{ maxCells: 20, minLevel: 4, maxLevel: 23 }`\n */\n options?: { minCells?: number; minLevel?: number; maxLevel?: number };\n};\n\n/**\n * Analyzer type and type-specific properties for a GeoPoint Analyzer\n */\nexport type GeoPointAnalyzer = {\n /**\n * Type of the Analyzer.\n */\n type: \"geopoint\";\n /**\n * Additional properties for the Analyzer.\n */\n properties: GeoPointAnalyzerProperties;\n};\n\n/**\n * Properties of a Stopwords Analyzer.\n */\nexport type StopwordsAnalyzerProperties = {\n /**\n * Array of strings that describe the tokens to be discarded.\n */\n stopwords: string[];\n /**\n * Whether stopword values should be interpreted as hex-encoded strings.\n *\n * Default: `false`\n */\n hex?: boolean;\n};\n\n/**\n * Analyzer type and type-specific properties for a Stopwords Analyzer\n */\nexport type StopwordsAnalyzer = {\n /**\n * Type of the Analyzer.\n */\n type: \"stopwords\";\n /**\n * Additional properties for the Analyzer.\n */\n properties: StopwordsAnalyzerProperties;\n};\n\n/**\n * Represents an Analyzer in a {@link Database}.\n */\nexport class Analyzer {\n protected _name: string;\n protected _db: Database;\n\n /**\n * @internal\n * @hidden\n */\n constructor(db: Database, name: string) {\n this._db = db;\n this._name = name;\n }\n\n /**\n * @internal\n *\n * Indicates that this object represents an ArangoDB Analyzer.\n */\n get isArangoAnalyzer(): true {\n return true;\n }\n\n /**\n * Name of this Analyzer.\n *\n * See also {@link Database.analyzer}.\n */\n get name() {\n return this._name;\n }\n\n /**\n * Checks whether the Analyzer exists.\n *\n * @example\n * ```js\n * const db = new Database();\n * const analyzer = db.analyzer(\"some-analyzer\");\n * const result = await analyzer.exists();\n * // result indicates whether the Analyzer exists\n * ```\n */\n async exists(): Promise<boolean> {\n try {\n await this.get();\n return true;\n } catch (err) {\n if (isArangoError(err) && err.errorNum === ANALYZER_NOT_FOUND) {\n return false;\n }\n throw err;\n }\n }\n\n /**\n * Retrieves the Analyzer definition for the Analyzer.\n *\n * @example\n * ```js\n * const db = new Database();\n * const analyzer = db.analyzer(\"some-analyzer\");\n * const definition = await analyzer.get();\n * // definition contains the Analyzer definition\n * ```\n */\n get(): Promise<ArangoResponseMetadata & AnalyzerDescription> {\n return this._db.request(\n { path: `/_api/analyzer/${this.name}` },\n (res) => res.body\n );\n }\n\n /**\n * Creates a new Analyzer with the given `options` and the instance's name.\n *\n * See also {@link Database.createAnalyzer}.\n *\n * @param options - Options for creating the Analyzer.\n *\n * @example\n * ```js\n * const db = new Database();\n * const analyzer = db.analyzer(\"potatoes\");\n * await analyzer.create({ type: \"identity\" });\n * // the identity Analyzer \"potatoes\" now exists\n * ```\n */\n create(options: CreateAnalyzerOptions): Promise<AnalyzerDescription> {\n return this._db.request(\n {\n method: \"POST\",\n path: \"/_api/analyzer\",\n body: { name: this.name, ...options },\n },\n (res) => res.body\n );\n }\n\n /**\n * Deletes the Analyzer from the database.\n *\n * @param force - Whether the Analyzer should still be deleted even if it\n * is currently in use.\n *\n * @example\n * ```js\n * const db = new Database();\n * const analyzer = db.analyzer(\"some-analyzer\");\n * await analyzer.drop();\n * // the Analyzer \"some-analyzer\" no longer exists\n * ```\n */\n drop(\n force: boolean = false\n ): Promise<ArangoResponseMetadata & { name: string }> {\n return this._db.request(\n {\n method: \"DELETE\",\n path: `/_api/analyzer/${this.name}`,\n qs: { force },\n },\n (res) => res.body\n );\n }\n}\n"]}
package/aql.d.ts CHANGED
@@ -12,6 +12,7 @@
12
12
  */
13
13
  import { ArangoCollection } from "./collection";
14
14
  import { Dict } from "./connection";
15
+ import { Graph } from "./graph";
15
16
  import { View } from "./view";
16
17
  /**
17
18
  * Generic AQL query object consisting of an AQL query string and its bind
@@ -67,7 +68,7 @@ export interface AqlLiteral {
67
68
  * A value that can be used in an AQL template string or passed to an AQL
68
69
  * helper function.
69
70
  */
70
- export declare type AqlValue = ArangoCollection | View | GeneratedAqlQuery | AqlLiteral | string | number | boolean | null | undefined | object | any[];
71
+ export declare type AqlValue = ArangoCollection | View | Graph | GeneratedAqlQuery | AqlLiteral | string | number | boolean | null | undefined | Record<string, unknown> | any[];
71
72
  /**
72
73
  * Indicates whether the given value is an {@link AqlQuery}.
73
74
  *
package/aql.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"aql.d.ts","sourceRoot":"","sources":["../src/aql.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,gBAAgB,EAAsB,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAgB,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE5C;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;IACjD;;;OAGG;IACH,OAAO,EAAE,MAAM;QAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,EAAE,QAAQ,EAAE,CAAA;KAAE,CAAC;CACxD;AAED;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;OAKG;IACH,KAAK,EAAE,MAAM,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,oBAAY,QAAQ,GAChB,gBAAgB,GAChB,IAAI,GACJ,iBAAiB,GACjB,UAAU,GACV,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,MAAM,GACN,GAAG,EAAE,CAAC;AAEV;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,QAAQ,CAExD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,iBAAiB,CAE1E;AAED;;;;GA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H,SAAgB,IAAI,CAClB,MAAM,EAAE,QAAQ,EAAE,EAClB,GAAG,GAAE,MAAY,GAChB,iBAAiB,CAWnB;CACF"}
package/aql.js CHANGED
@@ -14,6 +14,7 @@ exports.aql = exports.isAqlLiteral = exports.isGeneratedAqlQuery = exports.isAql
14
14
  * @packageDocumentation
15
15
  */
16
16
  const collection_1 = require("./collection");
17
+ const graph_1 = require("./graph");
17
18
  const view_1 = require("./view");
18
19
  /**
19
20
  * Indicates whether the given value is an {@link AqlQuery}.
@@ -168,7 +169,9 @@ function aql(templateStrings, ...args) {
168
169
  const index = bindValues.indexOf(rawValue);
169
170
  const isKnown = index !== -1;
170
171
  let name = `value${isKnown ? index : bindValues.length}`;
171
- if (collection_1.isArangoCollection(rawValue) || view_1.isArangoView(rawValue)) {
172
+ if (collection_1.isArangoCollection(rawValue) ||
173
+ graph_1.isArangoGraph(rawValue) ||
174
+ view_1.isArangoView(rawValue)) {
172
175
  name = `@${name}`;
173
176
  value = rawValue.name;
174
177
  }
@@ -185,6 +188,7 @@ function aql(templateStrings, ...args) {
185
188
  };
186
189
  }
187
190
  exports.aql = aql;
191
+ // eslint-disable-next-line @typescript-eslint/no-namespace
188
192
  (function (aql) {
189
193
  /**
190
194
  * Marks an arbitrary scalar value (i.e. a string, number or boolean) as
package/aql.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"aql.js","sourceRoot":"","sources":["../src/aql.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;GAWG;AACH,6CAAoE;AAEpE,iCAA4C;AAqE5C;;;;GAIG;AACH,SAAgB,UAAU,CAAC,KAAU;IACnC,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC7E,CAAC;AAFD,gCAEC;AAED;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAAC,KAAU;IAC5C,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,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EACtD,GAAG,MAAM,CACV,CAAC;IACJ,CAAC;IAde,QAAI,OAcnB,CAAA;AACH,CAAC,EApJgB,GAAG,GAAH,WAAG,KAAH,WAAG,QAoJnB","sourcesContent":["/**\n * ```js\n * import { aql } from \"arangojs/aql\";\n * ```\n *\n * The \"aql\" module provides the {@link aql} template string handler and\n * helper functions, as well as associated types and interfaces for TypeScript.\n *\n * The aql function and namespace is also re-exported by the \"index\" module.\n *\n * @packageDocumentation\n */\nimport { ArangoCollection, isArangoCollection } from \"./collection\";\nimport { Dict } from \"./connection\";\nimport { isArangoView, View } from \"./view\";\n\n/**\n * Generic AQL query object consisting of an AQL query string and its bind\n * parameters.\n */\nexport interface AqlQuery {\n /**\n * An AQL query string.\n */\n query: string;\n /**\n * An object mapping AQL bind parameter names to their respective values.\n *\n * Names of parameters representing collections are prefixed with an\n * at-symbol.\n */\n bindVars: Dict<any>;\n}\n\n/**\n * Derived type representing AQL query objects generated by the AQL helper\n * functions and the AQL template string handler. These objects can be fed\n * back into these helper functions to be inlined or merged in complex queries.\n *\n * @internal\n */\nexport interface GeneratedAqlQuery extends AqlQuery {\n /**\n * @internal\n * @hidden\n */\n _source: () => { strings: string[]; args: AqlValue[] };\n}\n\n/**\n * An object representing a trusted AQL literal that will be inlined directly\n * when used in an AQL template or passed to AQL helper functions.\n *\n * Arbitrary values can be converted to trusted AQL literals by passing them\n * to the {@link aql.literal} helper function.\n */\nexport interface AqlLiteral {\n /**\n * @internal\n *\n * Returns a string representation of this AQL literal that can be inlined\n * in an AQL template.\n */\n toAQL: () => string;\n}\n\n/**\n * A value that can be used in an AQL template string or passed to an AQL\n * helper function.\n */\nexport type AqlValue =\n | ArangoCollection\n | View\n | GeneratedAqlQuery\n | AqlLiteral\n | string\n | number\n | boolean\n | null\n | undefined\n | object\n | any[];\n\n/**\n * Indicates whether the given value is an {@link AqlQuery}.\n *\n * @param query - A value that might be an `AqlQuery`.\n */\nexport function isAqlQuery(query: any): query is AqlQuery {\n return Boolean(query && typeof query.query === \"string\" && query.bindVars);\n}\n\n/**\n * Indicates whether the given value is a {@link GeneratedAqlQuery}.\n *\n * @param query - A value that might be a `GeneratedAqlQuery`.\n *\n * @internal\n * @hidden\n */\nexport function isGeneratedAqlQuery(query: any): query is GeneratedAqlQuery {\n return isAqlQuery(query) && typeof (query as any)._source === \"function\";\n}\n\n/**\n * Indicates whether the given value is an {@link AqlLiteral}.\n *\n * @param literal - A value that might be an `AqlLiteral`.\n */\nexport function isAqlLiteral(literal: any): literal is AqlLiteral {\n return Boolean(literal && typeof literal.toAQL === \"function\");\n}\n\n/**\n * Template string handler (template tag) for AQL queries.\n *\n * The `aql` tag can be used to write complex AQL queries as multi-line strings\n * without having to worry about `bindVars` and the distinction between\n * collections and regular parameters.\n *\n * Tagged template strings will return an {@link AqlQuery} object with\n * `query` and `bindVars` attributes reflecting any interpolated values.\n *\n * Any {@link ArangoCollection} instance used in a query string will be\n * recognized as a collection reference and generate an AQL collection bind\n * parameter instead of a regular AQL value bind parameter.\n *\n * **Note**: you should always use the `aql` template tag when writing\n * dynamic AQL queries instead of using untagged (normal) template strings.\n * Untagged template strings will inline any interpolated values and return\n * a plain string as result. The `aql` template tag will only inline references\n * to the interpolated values and produce an AQL query object containing both\n * the query and the values. This prevents most injection attacks when using\n * untrusted values in dynamic queries.\n *\n * @example\n * ```js\n * // Some user-supplied string that may be malicious\n * const untrustedValue = req.body.email;\n *\n * // Without aql tag: BAD! DO NOT DO THIS!\n * const badQuery = `\n * FOR user IN users\n * FILTER user.email == \"${untrustedValue}\"\n * RETURN user\n * `;\n * // e.g. if untrustedValue is '\" || user.admin == true || \"':\n * // Query:\n * // FOR user IN users\n * // FILTER user.email == \"\" || user.admin == true || \"\"\n * // RETURN user\n *\n * // With the aql tag: GOOD! MUCH SAFER!\n * const betterQuery = aql`\n * FOR user IN users\n * FILTER user.email == ${untrustedValue}\n * RETURN user\n * `;\n * // Query:\n * // FOR user IN users\n * // FILTER user.email == @value0\n * // RETURN user\n * // Bind parameters:\n * // value0 -> untrustedValue\n * ```\n *\n * @example\n * ```js\n * const collection = db.collection(\"some-collection\");\n * const minValue = 23;\n * const result = await db.query(aql`\n * FOR d IN ${collection}\n * FILTER d.num > ${minValue}\n * RETURN d\n * `);\n *\n * // Equivalent raw query object\n * const result2 = await db.query({\n * query: `\n * FOR d IN @@collection\n * FILTER d.num > @minValue\n * RETURN d\n * `,\n * bindVars: {\n * \"@collection\": collection.name,\n * minValue: minValue\n * }\n * });\n * ```\n *\n * @example\n * ```js\n * const collection = db.collection(\"some-collection\");\n * const color = \"green\";\n * const filter = aql`FILTER d.color == ${color}'`;\n * const result = await db.query(aql`\n * FOR d IN ${collection}\n * ${filter}\n * RETURN d\n * `);\n * ```\n */\nexport function aql(\n templateStrings: TemplateStringsArray,\n ...args: AqlValue[]\n): GeneratedAqlQuery {\n const strings = [...templateStrings];\n const bindVars: Dict<any> = {};\n const bindValues = [];\n let query = strings[0];\n for (let i = 0; i < args.length; i++) {\n const rawValue = args[i];\n let value = rawValue;\n if (isGeneratedAqlQuery(rawValue)) {\n const src = rawValue._source();\n if (src.args.length) {\n query += src.strings[0];\n args.splice(i, 1, ...src.args);\n strings.splice(\n i,\n 2,\n strings[i] + src.strings[0],\n ...src.strings.slice(1, src.args.length),\n src.strings[src.args.length] + strings[i + 1]\n );\n } else {\n query += rawValue.query + strings[i + 1];\n args.splice(i, 1);\n strings.splice(i, 2, strings[i] + rawValue.query + strings[i + 1]);\n }\n i -= 1;\n continue;\n }\n if (rawValue === undefined) {\n query += strings[i + 1];\n continue;\n }\n if (isAqlLiteral(rawValue)) {\n query += `${rawValue.toAQL()}${strings[i + 1]}`;\n continue;\n }\n const index = bindValues.indexOf(rawValue);\n const isKnown = index !== -1;\n let name = `value${isKnown ? index : bindValues.length}`;\n if (isArangoCollection(rawValue) || isArangoView(rawValue)) {\n name = `@${name}`;\n value = rawValue.name;\n }\n if (!isKnown) {\n bindValues.push(rawValue);\n bindVars[name] = value;\n }\n query += `@${name}${strings[i + 1]}`;\n }\n return {\n query,\n bindVars,\n _source: () => ({ strings, args }),\n };\n}\n\nexport namespace aql {\n /**\n * Marks an arbitrary scalar value (i.e. a string, number or boolean) as\n * safe for being inlined directly into AQL queries when used in an `aql`\n * template string, rather than being converted into a bind parameter.\n *\n * **Note**: Nesting `aql` template strings is a much safer alternative for\n * most use cases. This low-level helper function only exists to help with\n * rare edge cases where a trusted AQL query fragment must be read from a\n * string (e.g. when reading query fragments from JSON) and should only be\n * used as a last resort.\n *\n * @example\n * ```js\n * // BAD! DO NOT DO THIS!\n * const sortDirection = aql.literal('ASC');\n *\n * // GOOD! DO THIS INSTEAD!\n * const sortDirection = aql`ASC`;\n * ```\n *\n * @example\n * ```js\n * // BAD! DO NOT DO THIS!\n * const filterColor = aql.literal('FILTER d.color == \"green\"');\n * const result = await db.query(aql`\n * FOR d IN some-collection\n * ${filterColor}\n * RETURN d\n * `);\n *\n * // GOOD! DO THIS INSTEAD!\n * const color = \"green\";\n * const filterColor = aql`FILTER d.color === ${color}`;\n * const result = await db.query(aql`\n * FOR d IN some-collection\n * ${filterColor}\n * RETURN d\n * `);\n * ```\n *\n * @example\n * ```js\n * // WARNING: We explicitly trust the environment variable to be safe!\n * const filter = aql.literal(process.env.FILTER_STATEMENT);\n * const users = await db.query(aql`\n * FOR user IN users\n * ${filter}\n * RETURN user\n * `);\n * ```\n */\n export function literal(\n value: string | number | boolean | AqlLiteral | null | undefined\n ): AqlLiteral {\n if (isAqlLiteral(value)) {\n return value;\n }\n return {\n toAQL() {\n if (value === undefined) {\n return \"\";\n }\n return String(value);\n },\n };\n }\n\n /**\n * Constructs {@link AqlQuery} objects from an array of arbitrary values.\n *\n * **Note**: Nesting `aql` template strings is a much safer alternative\n * for most use cases. This low-level helper function only exists to\n * complement the `aql` tag when constructing complex queries from dynamic\n * arrays of query fragments.\n *\n * @param values - Array of values to join. These values will behave exactly\n * like values interpolated in an `aql` template string.\n * @param sep - Seperator to insert between values. This value will behave\n * exactly like a value passed to {@link aql.literal}, i.e. it will be\n * inlined as-is, rather than being converted into a bind parameter.\n *\n * @example\n * ```js\n * const users = db.collection(\"users\");\n * const filters = [];\n * if (adminsOnly) filters.push(aql`FILTER user.admin`);\n * if (activeOnly) filters.push(aql`FILTER user.active`);\n * const result = await db.query(aql`\n * FOR user IN ${users}\n * ${aql.join(filters)}\n * RETURN user\n * `);\n * ```\n *\n * @example\n * ```js\n * const users = db.collection(\"users\");\n * const keys = [\"jreyes\", \"ghermann\"];\n *\n * // BAD! NEEDLESSLY COMPLEX!\n * const docs = keys.map(key => aql`DOCUMENT(${users}, ${key}`));\n * const result = await db.query(aql`\n * FOR user IN [\n * ${aql.join(docs, \", \")}\n * ]\n * RETURN user\n * `);\n * // Query:\n * // FOR user IN [\n * // DOCUMENT(@@value0, @value1), DOCUMENT(@@value0, @value2)\n * // ]\n * // RETURN user\n * // Bind parameters:\n * // @value0 -> \"users\"\n * // value1 -> \"jreyes\"\n * // value2 -> \"ghermann\"\n *\n * // GOOD! MUCH SIMPLER!\n * const result = await db.query(aql`\n * FOR key IN ${keys}\n * LET user = DOCUMENT(${users}, key)\n * RETURN user\n * `);\n * // Query:\n * // FOR user IN @value0\n * // LET user = DOCUMENT(@@value1, key)\n * // RETURN user\n * // Bind parameters:\n * // value0 -> [\"jreyes\", \"ghermann\"]\n * // @value1 -> \"users\"\n * ```\n */\n export function join(\n values: AqlValue[],\n sep: string = \" \"\n ): GeneratedAqlQuery {\n if (!values.length) {\n return aql``;\n }\n if (values.length === 1) {\n return aql`${values[0]}`;\n }\n return aql(\n [\"\", ...Array(values.length - 1).fill(sep), \"\"] as any,\n ...values\n );\n }\n}\n"]}
1
+ {"version":3,"file":"aql.js","sourceRoot":"","sources":["../src/aql.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;GAWG;AACH,6CAAoE;AAEpE,mCAA+C;AAC/C,iCAA4C;AAsE5C;;;;GAIG;AACH,SAAgB,UAAU,CAAC,KAAU;IACnC,OAAO,OAA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D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACvB,OAAO,GAAG,CAAA,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1B;QACD,OAAO,GAAG,CACR,CAAC,EAAE,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAQ,EACtD,GAAG,MAAM,CACV,CAAC;IACJ,CAAC;IAde,QAAI,OAcnB,CAAA;AACH,CAAC,EApJgB,GAAG,GAAH,WAAG,KAAH,WAAG,QAoJnB","sourcesContent":["/**\n * ```js\n * import { aql } from \"arangojs/aql\";\n * ```\n *\n * The \"aql\" module provides the {@link aql} template string handler and\n * helper functions, as well as associated types and interfaces for TypeScript.\n *\n * The aql function and namespace is also re-exported by the \"index\" module.\n *\n * @packageDocumentation\n */\nimport { ArangoCollection, isArangoCollection } from \"./collection\";\nimport { Dict } from \"./connection\";\nimport { Graph, isArangoGraph } from \"./graph\";\nimport { isArangoView, View } from \"./view\";\n\n/**\n * Generic AQL query object consisting of an AQL query string and its bind\n * parameters.\n */\nexport interface AqlQuery {\n /**\n * An AQL query string.\n */\n query: string;\n /**\n * An object mapping AQL bind parameter names to their respective values.\n *\n * Names of parameters representing collections are prefixed with an\n * at-symbol.\n */\n bindVars: Dict<any>;\n}\n\n/**\n * Derived type representing AQL query objects generated by the AQL helper\n * functions and the AQL template string handler. These objects can be fed\n * back into these helper functions to be inlined or merged in complex queries.\n *\n * @internal\n */\nexport interface GeneratedAqlQuery extends AqlQuery {\n /**\n * @internal\n * @hidden\n */\n _source: () => { strings: string[]; args: AqlValue[] };\n}\n\n/**\n * An object representing a trusted AQL literal that will be inlined directly\n * when used in an AQL template or passed to AQL helper functions.\n *\n * Arbitrary values can be converted to trusted AQL literals by passing them\n * to the {@link aql.literal} helper function.\n */\nexport interface AqlLiteral {\n /**\n * @internal\n *\n * Returns a string representation of this AQL literal that can be inlined\n * in an AQL template.\n */\n toAQL: () => string;\n}\n\n/**\n * A value that can be used in an AQL template string or passed to an AQL\n * helper function.\n */\nexport type AqlValue =\n | ArangoCollection\n | View\n | Graph\n | GeneratedAqlQuery\n | AqlLiteral\n | string\n | number\n | boolean\n | null\n | undefined\n | Record<string, unknown>\n | any[];\n\n/**\n * Indicates whether the given value is an {@link AqlQuery}.\n *\n * @param query - A value that might be an `AqlQuery`.\n */\nexport function isAqlQuery(query: any): query is AqlQuery {\n return Boolean(query && typeof query.query === \"string\" && query.bindVars);\n}\n\n/**\n * Indicates whether the given value is a {@link GeneratedAqlQuery}.\n *\n * @param query - A value that might be a `GeneratedAqlQuery`.\n *\n * @internal\n * @hidden\n */\nexport function isGeneratedAqlQuery(query: any): query is GeneratedAqlQuery {\n return isAqlQuery(query) && typeof (query as any)._source === \"function\";\n}\n\n/**\n * Indicates whether the given value is an {@link AqlLiteral}.\n *\n * @param literal - A value that might be an `AqlLiteral`.\n */\nexport function isAqlLiteral(literal: any): literal is AqlLiteral {\n return Boolean(literal && typeof literal.toAQL === \"function\");\n}\n\n/**\n * Template string handler (template tag) for AQL queries.\n *\n * The `aql` tag can be used to write complex AQL queries as multi-line strings\n * without having to worry about `bindVars` and the distinction between\n * collections and regular parameters.\n *\n * Tagged template strings will return an {@link AqlQuery} object with\n * `query` and `bindVars` attributes reflecting any interpolated values.\n *\n * Any {@link ArangoCollection} instance used in a query string will be\n * recognized as a collection reference and generate an AQL collection bind\n * parameter instead of a regular AQL value bind parameter.\n *\n * **Note**: you should always use the `aql` template tag when writing\n * dynamic AQL queries instead of using untagged (normal) template strings.\n * Untagged template strings will inline any interpolated values and return\n * a plain string as result. The `aql` template tag will only inline references\n * to the interpolated values and produce an AQL query object containing both\n * the query and the values. This prevents most injection attacks when using\n * untrusted values in dynamic queries.\n *\n * @example\n * ```js\n * // Some user-supplied string that may be malicious\n * const untrustedValue = req.body.email;\n *\n * // Without aql tag: BAD! DO NOT DO THIS!\n * const badQuery = `\n * FOR user IN users\n * FILTER user.email == \"${untrustedValue}\"\n * RETURN user\n * `;\n * // e.g. if untrustedValue is '\" || user.admin == true || \"':\n * // Query:\n * // FOR user IN users\n * // FILTER user.email == \"\" || user.admin == true || \"\"\n * // RETURN user\n *\n * // With the aql tag: GOOD! MUCH SAFER!\n * const betterQuery = aql`\n * FOR user IN users\n * FILTER user.email == ${untrustedValue}\n * RETURN user\n * `;\n * // Query:\n * // FOR user IN users\n * // FILTER user.email == @value0\n * // RETURN user\n * // Bind parameters:\n * // value0 -> untrustedValue\n * ```\n *\n * @example\n * ```js\n * const collection = db.collection(\"some-collection\");\n * const minValue = 23;\n * const result = await db.query(aql`\n * FOR d IN ${collection}\n * FILTER d.num > ${minValue}\n * RETURN d\n * `);\n *\n * // Equivalent raw query object\n * const result2 = await db.query({\n * query: `\n * FOR d IN @@collection\n * FILTER d.num > @minValue\n * RETURN d\n * `,\n * bindVars: {\n * \"@collection\": collection.name,\n * minValue: minValue\n * }\n * });\n * ```\n *\n * @example\n * ```js\n * const collection = db.collection(\"some-collection\");\n * const color = \"green\";\n * const filter = aql`FILTER d.color == ${color}'`;\n * const result = await db.query(aql`\n * FOR d IN ${collection}\n * ${filter}\n * RETURN d\n * `);\n * ```\n */\nexport function aql(\n templateStrings: TemplateStringsArray,\n ...args: AqlValue[]\n): GeneratedAqlQuery {\n const strings = [...templateStrings];\n const bindVars: Dict<any> = {};\n const bindValues = [];\n let query = strings[0];\n for (let i = 0; i < args.length; i++) {\n const rawValue = args[i];\n let value = rawValue;\n if (isGeneratedAqlQuery(rawValue)) {\n const src = rawValue._source();\n if (src.args.length) {\n query += src.strings[0];\n args.splice(i, 1, ...src.args);\n strings.splice(\n i,\n 2,\n strings[i] + src.strings[0],\n ...src.strings.slice(1, src.args.length),\n src.strings[src.args.length] + strings[i + 1]\n );\n } else {\n query += rawValue.query + strings[i + 1];\n args.splice(i, 1);\n strings.splice(i, 2, strings[i] + rawValue.query + strings[i + 1]);\n }\n i -= 1;\n continue;\n }\n if (rawValue === undefined) {\n query += strings[i + 1];\n continue;\n }\n if (isAqlLiteral(rawValue)) {\n query += `${rawValue.toAQL()}${strings[i + 1]}`;\n continue;\n }\n const index = bindValues.indexOf(rawValue);\n const isKnown = index !== -1;\n let name = `value${isKnown ? index : bindValues.length}`;\n if (\n isArangoCollection(rawValue) ||\n isArangoGraph(rawValue) ||\n isArangoView(rawValue)\n ) {\n name = `@${name}`;\n value = rawValue.name;\n }\n if (!isKnown) {\n bindValues.push(rawValue);\n bindVars[name] = value;\n }\n query += `@${name}${strings[i + 1]}`;\n }\n return {\n query,\n bindVars,\n _source: () => ({ strings, args }),\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace aql {\n /**\n * Marks an arbitrary scalar value (i.e. a string, number or boolean) as\n * safe for being inlined directly into AQL queries when used in an `aql`\n * template string, rather than being converted into a bind parameter.\n *\n * **Note**: Nesting `aql` template strings is a much safer alternative for\n * most use cases. This low-level helper function only exists to help with\n * rare edge cases where a trusted AQL query fragment must be read from a\n * string (e.g. when reading query fragments from JSON) and should only be\n * used as a last resort.\n *\n * @example\n * ```js\n * // BAD! DO NOT DO THIS!\n * const sortDirection = aql.literal('ASC');\n *\n * // GOOD! DO THIS INSTEAD!\n * const sortDirection = aql`ASC`;\n * ```\n *\n * @example\n * ```js\n * // BAD! DO NOT DO THIS!\n * const filterColor = aql.literal('FILTER d.color == \"green\"');\n * const result = await db.query(aql`\n * FOR d IN some-collection\n * ${filterColor}\n * RETURN d\n * `);\n *\n * // GOOD! DO THIS INSTEAD!\n * const color = \"green\";\n * const filterColor = aql`FILTER d.color === ${color}`;\n * const result = await db.query(aql`\n * FOR d IN some-collection\n * ${filterColor}\n * RETURN d\n * `);\n * ```\n *\n * @example\n * ```js\n * // WARNING: We explicitly trust the environment variable to be safe!\n * const filter = aql.literal(process.env.FILTER_STATEMENT);\n * const users = await db.query(aql`\n * FOR user IN users\n * ${filter}\n * RETURN user\n * `);\n * ```\n */\n export function literal(\n value: string | number | boolean | AqlLiteral | null | undefined\n ): AqlLiteral {\n if (isAqlLiteral(value)) {\n return value;\n }\n return {\n toAQL() {\n if (value === undefined) {\n return \"\";\n }\n return String(value);\n },\n };\n }\n\n /**\n * Constructs {@link AqlQuery} objects from an array of arbitrary values.\n *\n * **Note**: Nesting `aql` template strings is a much safer alternative\n * for most use cases. This low-level helper function only exists to\n * complement the `aql` tag when constructing complex queries from dynamic\n * arrays of query fragments.\n *\n * @param values - Array of values to join. These values will behave exactly\n * like values interpolated in an `aql` template string.\n * @param sep - Seperator to insert between values. This value will behave\n * exactly like a value passed to {@link aql.literal}, i.e. it will be\n * inlined as-is, rather than being converted into a bind parameter.\n *\n * @example\n * ```js\n * const users = db.collection(\"users\");\n * const filters = [];\n * if (adminsOnly) filters.push(aql`FILTER user.admin`);\n * if (activeOnly) filters.push(aql`FILTER user.active`);\n * const result = await db.query(aql`\n * FOR user IN ${users}\n * ${aql.join(filters)}\n * RETURN user\n * `);\n * ```\n *\n * @example\n * ```js\n * const users = db.collection(\"users\");\n * const keys = [\"jreyes\", \"ghermann\"];\n *\n * // BAD! NEEDLESSLY COMPLEX!\n * const docs = keys.map(key => aql`DOCUMENT(${users}, ${key}`));\n * const result = await db.query(aql`\n * FOR user IN [\n * ${aql.join(docs, \", \")}\n * ]\n * RETURN user\n * `);\n * // Query:\n * // FOR user IN [\n * // DOCUMENT(@@value0, @value1), DOCUMENT(@@value0, @value2)\n * // ]\n * // RETURN user\n * // Bind parameters:\n * // @value0 -> \"users\"\n * // value1 -> \"jreyes\"\n * // value2 -> \"ghermann\"\n *\n * // GOOD! MUCH SIMPLER!\n * const result = await db.query(aql`\n * FOR key IN ${keys}\n * LET user = DOCUMENT(${users}, key)\n * RETURN user\n * `);\n * // Query:\n * // FOR user IN @value0\n * // LET user = DOCUMENT(@@value1, key)\n * // RETURN user\n * // Bind parameters:\n * // value0 -> [\"jreyes\", \"ghermann\"]\n * // @value1 -> \"users\"\n * ```\n */\n export function join(\n values: AqlValue[],\n sep: string = \" \"\n ): GeneratedAqlQuery {\n if (!values.length) {\n return aql``;\n }\n if (values.length === 1) {\n return aql`${values[0]}`;\n }\n return aql(\n [\"\", ...Array(values.length - 1).fill(sep), \"\"] as any,\n ...values\n );\n }\n}\n"]}