arangojs 7.6.0 → 7.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 +75 -5
- package/README.md +2 -2
- package/analyzer.d.ts +55 -1
- package/analyzer.d.ts.map +1 -1
- package/analyzer.js +4 -4
- package/analyzer.js.map +1 -1
- package/aql.d.ts +1 -1
- package/aql.d.ts.map +1 -1
- package/aql.js.map +1 -1
- package/collection.d.ts +77 -11
- package/collection.d.ts.map +1 -1
- package/collection.js +35 -24
- package/collection.js.map +1 -1
- package/connection.d.ts +26 -1
- package/connection.d.ts.map +1 -1
- package/connection.js +46 -4
- package/connection.js.map +1 -1
- package/cursor.d.ts +12 -6
- package/cursor.d.ts.map +1 -1
- package/cursor.js +2 -2
- package/cursor.js.map +1 -1
- package/database.d.ts +56 -7
- package/database.d.ts.map +1 -1
- package/database.js +73 -36
- package/database.js.map +1 -1
- package/documents.d.ts +5 -5
- package/documents.d.ts.map +1 -1
- package/documents.js +4 -2
- package/documents.js.map +1 -1
- package/graph.d.ts +34 -8
- package/graph.d.ts.map +1 -1
- package/graph.js +58 -56
- package/graph.js.map +1 -1
- package/indexes.d.ts +43 -1
- package/indexes.d.ts.map +1 -1
- package/indexes.js +4 -2
- package/indexes.js.map +1 -1
- package/lib/codes.d.ts +1 -0
- package/lib/codes.d.ts.map +1 -1
- package/lib/codes.js +2 -1
- package/lib/codes.js.map +1 -1
- package/package.json +1 -1
- package/transaction.js +3 -3
- package/transaction.js.map +1 -1
- package/view.d.ts +8 -1
- package/view.d.ts.map +1 -1
- package/view.js +8 -8
- package/view.js.map +1 -1
- package/web.js +1 -1
- package/web.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,73 @@ 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.8.0] - 2022-05-19
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- Added `retryOnConflict` option to `db.query` and `route.request`
|
|
22
|
+
|
|
23
|
+
This option allows specifying the number of times the request will be retried
|
|
24
|
+
if it results in a write-write conflict.
|
|
25
|
+
|
|
26
|
+
## [7.7.0] - 2022-01-26
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- Unicode names are now automatically NFC normalized
|
|
31
|
+
|
|
32
|
+
This change affects all database, collection, graph, view and analyzer names
|
|
33
|
+
using unicode characters. **The change has no effect when using non-unicode
|
|
34
|
+
(ASCII) names.** At this time, ArangoDB does not support unicode characters
|
|
35
|
+
in any of these names but experimental support for unicode database names is
|
|
36
|
+
available in ArangoDB 3.9 using the `--database.extended-names-databases`
|
|
37
|
+
startup option.
|
|
38
|
+
|
|
39
|
+
Any names used to create `Database`, `Collection`, etc instances or passed to
|
|
40
|
+
methods will automatically be NFC normalized. Additionally the collection
|
|
41
|
+
name part of any value passed as a `DocumentSelector` and the collection name
|
|
42
|
+
part of values returned by `collection.documentId` will automatically be NFC
|
|
43
|
+
normalized.
|
|
44
|
+
|
|
45
|
+
### Deprecated
|
|
46
|
+
|
|
47
|
+
- Deprecated `EnsureHashIndexOptions` and `EnsureSkiplistIndexOptions` types
|
|
48
|
+
|
|
49
|
+
The hash and skiplist index types have been deprecated in ArangoDB 3.9 and
|
|
50
|
+
should be replaced with persistent indexes which behave identically.
|
|
51
|
+
|
|
52
|
+
- Deprecated all MMFiles related options and methods
|
|
53
|
+
|
|
54
|
+
The MMFiles storage engine was removed in ArangoDB 3.7.
|
|
55
|
+
|
|
56
|
+
### Added
|
|
57
|
+
|
|
58
|
+
- Added support for new ArangoDB 3.9 `CollationAnalyzer` and
|
|
59
|
+
`SegmentationAnalyzer` types
|
|
60
|
+
|
|
61
|
+
- Added support for new ArangoDB 3.9 (multi-dimensional) `ZkdIndex` type
|
|
62
|
+
|
|
63
|
+
- Added support for new ArangoDB 3.9 Hybrid SmartGraphs graph options
|
|
64
|
+
|
|
65
|
+
- Added support for new ArangoDB 3.9 response queue time reporting
|
|
66
|
+
|
|
67
|
+
This adds the `db.queueTime` property, which provides methods for accessing
|
|
68
|
+
queue time metrics reported by the most recently received server responses if
|
|
69
|
+
the server supports this feature.
|
|
70
|
+
|
|
71
|
+
- Added `ArangoSearchViewLink#inBackground` ([#759](https://github.com/arangodb/arangojs/issues/759))
|
|
72
|
+
|
|
73
|
+
- Added `collection.compact` ([#630](https://github.com/arangodb/arangojs/issues/630))
|
|
74
|
+
|
|
75
|
+
## [7.6.1] - 2021-10-26
|
|
76
|
+
|
|
77
|
+
### Fixed
|
|
78
|
+
|
|
79
|
+
- Changed all uses of `Record<string, unknown>` to `Record<string, any>` ([#750](https://github.com/arangodb/arangojs/issues/750))
|
|
80
|
+
|
|
81
|
+
This should allow using more specific types without having to implement
|
|
82
|
+
index signatures.
|
|
83
|
+
|
|
17
84
|
## [7.6.0] - 2021-10-20
|
|
18
85
|
|
|
19
86
|
### Added
|
|
@@ -22,22 +89,22 @@ This driver uses semantic versioning:
|
|
|
22
89
|
|
|
23
90
|
- Added support for `fillBlockCache` query option
|
|
24
91
|
|
|
25
|
-
- Added support for passing `Graph` objects in AQL queries [#740](https://github.com/arangodb/arangojs/issues/740)
|
|
92
|
+
- Added support for passing `Graph` objects in AQL queries ([#740](https://github.com/arangodb/arangojs/issues/740))
|
|
26
93
|
|
|
27
94
|
This also adds the `isArangoGraph` helper function for type checking.
|
|
28
95
|
|
|
29
|
-
- Added User Management API [#664](https://github.com/arangodb/arangojs/issues/664)
|
|
96
|
+
- Added User Management API ([#664](https://github.com/arangodb/arangojs/issues/664))
|
|
30
97
|
|
|
31
98
|
This implements the endpoints of the
|
|
32
99
|
[HTTP Interface for User Management](https://www.arangodb.com/docs/stable/http/user-management.html)
|
|
33
100
|
|
|
34
101
|
### Fixed
|
|
35
102
|
|
|
36
|
-
- Added missing `hex` flag to `StopwordsAnalyzer` type [#732](https://github.com/arangodb/arangojs/issues/732)
|
|
103
|
+
- Added missing `hex` flag to `StopwordsAnalyzer` type ([#732](https://github.com/arangodb/arangojs/issues/732))
|
|
37
104
|
|
|
38
|
-
- Added missing `details` flag to `collection.figures` [#728](https://github.com/arangodb/arangojs/issues/728)
|
|
105
|
+
- Added missing `details` flag to `collection.figures` ([#728](https://github.com/arangodb/arangojs/issues/728))
|
|
39
106
|
|
|
40
|
-
- Added missing `inBackground` flag to index options [#734](https://github.com/arangodb/arangojs/issues/734)
|
|
107
|
+
- Added missing `inBackground` flag to index options ([#734](https://github.com/arangodb/arangojs/issues/734))
|
|
41
108
|
|
|
42
109
|
## [7.5.0] - 2021-04-22
|
|
43
110
|
|
|
@@ -1225,6 +1292,9 @@ For a detailed list of changes between pre-release versions of v7 see the
|
|
|
1225
1292
|
|
|
1226
1293
|
Graph methods now only return the relevant part of the response body.
|
|
1227
1294
|
|
|
1295
|
+
[7.8.0]: https://github.com/arangodb/arangojs/compare/v7.7.0...v7.8.0
|
|
1296
|
+
[7.7.0]: https://github.com/arangodb/arangojs/compare/v7.6.1...v7.7.0
|
|
1297
|
+
[7.6.1]: https://github.com/arangodb/arangojs/compare/v7.6.0...v7.6.1
|
|
1228
1298
|
[7.6.0]: https://github.com/arangodb/arangojs/compare/v7.5.0...v7.6.0
|
|
1229
1299
|
[7.5.0]: https://github.com/arangodb/arangojs/compare/v7.4.0...v7.5.0
|
|
1230
1300
|
[7.4.0]: https://github.com/arangodb/arangojs/compare/v7.3.0...v7.4.0
|
package/README.md
CHANGED
|
@@ -114,8 +114,8 @@ var db = new Database();
|
|
|
114
114
|
var pokemons = db.collection("pokemons");
|
|
115
115
|
|
|
116
116
|
db.query({
|
|
117
|
-
query: "FOR p IN @@c FILTER p.type
|
|
118
|
-
bindVars: { c: pokemons },
|
|
117
|
+
query: "FOR p IN @@c FILTER p.type == 'fire' RETURN p",
|
|
118
|
+
bindVars: { "@c": "pokemons" },
|
|
119
119
|
})
|
|
120
120
|
.then(function (cursor) {
|
|
121
121
|
console.log("My pokemons, let me show you them:");
|
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 | PipelineAnalyzer | AqlAnalyzer | GeoJsonAnalyzer | GeoPointAnalyzer | StopwordsAnalyzer;
|
|
42
|
+
export declare type AnalyzerInfo = IdentityAnalyzerInfo | DelimiterAnalyzerInfo | StemAnalyzerInfo | NormAnalyzerInfo | NgramAnalyzerInfo | TextAnalyzerInfo | PipelineAnalyzer | AqlAnalyzer | GeoJsonAnalyzer | GeoPointAnalyzer | StopwordsAnalyzer | SegmentationAnalyzer | CollationAnalyzer;
|
|
43
43
|
/**
|
|
44
44
|
* Analyzer type and type-specific properties for an Identity Analyzer.
|
|
45
45
|
*/
|
|
@@ -401,6 +401,60 @@ export declare type StopwordsAnalyzer = {
|
|
|
401
401
|
*/
|
|
402
402
|
properties: StopwordsAnalyzerProperties;
|
|
403
403
|
};
|
|
404
|
+
/**
|
|
405
|
+
* Properties of a Segmentation Analyzer.
|
|
406
|
+
*/
|
|
407
|
+
export declare type SegmentationAnalyzerProperties = {
|
|
408
|
+
/**
|
|
409
|
+
* Which tokens should be returned.
|
|
410
|
+
*
|
|
411
|
+
* Default: `"alpha"`
|
|
412
|
+
*/
|
|
413
|
+
break?: "all" | "alpha" | "graphic";
|
|
414
|
+
/**
|
|
415
|
+
* What case all returned tokens should be converted to if applicable.
|
|
416
|
+
*
|
|
417
|
+
* Default: `"none"`
|
|
418
|
+
*/
|
|
419
|
+
case?: "lower" | "upper" | "none";
|
|
420
|
+
};
|
|
421
|
+
/**
|
|
422
|
+
* Analyzer type and type-specific properties for a Segmentation Analyzer
|
|
423
|
+
*/
|
|
424
|
+
export declare type SegmentationAnalyzer = {
|
|
425
|
+
/**
|
|
426
|
+
* Type of the Analyzer.
|
|
427
|
+
*/
|
|
428
|
+
type: "segmentation";
|
|
429
|
+
/**
|
|
430
|
+
* Additional properties for the Analyzer.
|
|
431
|
+
*/
|
|
432
|
+
properties: SegmentationAnalyzerProperties;
|
|
433
|
+
};
|
|
434
|
+
/**
|
|
435
|
+
* Properties of a Collation Analyzer.
|
|
436
|
+
*/
|
|
437
|
+
export declare type CollationAnalyzerProperties = {
|
|
438
|
+
/**
|
|
439
|
+
* Text locale.
|
|
440
|
+
*
|
|
441
|
+
* Format: `language[_COUNTRY][.encoding][@variant]`
|
|
442
|
+
*/
|
|
443
|
+
locale: string;
|
|
444
|
+
};
|
|
445
|
+
/**
|
|
446
|
+
* Analyzer type and type-specific properties for a Collation Analyzer
|
|
447
|
+
*/
|
|
448
|
+
export declare type CollationAnalyzer = {
|
|
449
|
+
/**
|
|
450
|
+
* Type of the Analyzer.
|
|
451
|
+
*/
|
|
452
|
+
type: "collation";
|
|
453
|
+
/**
|
|
454
|
+
* Additional properties for the Analyzer.
|
|
455
|
+
*/
|
|
456
|
+
properties: CollationAnalyzerProperties;
|
|
457
|
+
};
|
|
404
458
|
/**
|
|
405
459
|
* Represents an Analyzer in a {@link Database}.
|
|
406
460
|
*/
|
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,eAA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AE,cAAc,CAAC;IACrB;;OAEG;IACH,UAAU,EAAE,8BAA8B,CAAC;CAC5C,CAAC;AAEF;;GAEG;AACH,oBAAY,2BAA2B,GAAG;IACxC;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,oBAAY,iBAAiB,GAAG;IAC9B;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAClB;;OAEG;IACH,UAAU,EAAE,2BAA2B,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,qBAAa,QAAQ;IACnB,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC;IAExB;;;OAGG;gBACS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM;IAKtC;;;;OAIG;IACH,IAAI,gBAAgB,IAAI,IAAI,CAE3B;IAED;;;;OAIG;IACH,IAAI,IAAI,WAEP;IAED;;;;;;;;;;OAUG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAYhC;;;;;;;;;;OAUG;IACH,GAAG,IAAI,OAAO,CAAC,sBAAsB,GAAG,mBAAmB,CAAC;IAO5D;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAWpE;;;;;;;;;;;;;OAaG;IACH,IAAI,CACF,KAAK,GAAE,OAAe,GACrB,OAAO,CAAC,sBAAsB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAUtD"}
|
package/analyzer.js
CHANGED
|
@@ -22,7 +22,7 @@ class Analyzer {
|
|
|
22
22
|
*/
|
|
23
23
|
constructor(db, name) {
|
|
24
24
|
this._db = db;
|
|
25
|
-
this._name = name;
|
|
25
|
+
this._name = name.normalize("NFC");
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* @internal
|
|
@@ -75,7 +75,7 @@ class Analyzer {
|
|
|
75
75
|
* ```
|
|
76
76
|
*/
|
|
77
77
|
get() {
|
|
78
|
-
return this._db.request({ path: `/_api/analyzer/${this.
|
|
78
|
+
return this._db.request({ path: `/_api/analyzer/${encodeURIComponent(this._name)}` }, (res) => res.body);
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
81
|
* Creates a new Analyzer with the given `options` and the instance's name.
|
|
@@ -96,7 +96,7 @@ class Analyzer {
|
|
|
96
96
|
return this._db.request({
|
|
97
97
|
method: "POST",
|
|
98
98
|
path: "/_api/analyzer",
|
|
99
|
-
body: { name: this.
|
|
99
|
+
body: { name: this._name, ...options },
|
|
100
100
|
}, (res) => res.body);
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
@@ -116,7 +116,7 @@ class Analyzer {
|
|
|
116
116
|
drop(force = false) {
|
|
117
117
|
return this._db.request({
|
|
118
118
|
method: "DELETE",
|
|
119
|
-
path: `/_api/analyzer/${this.
|
|
119
|
+
path: `/_api/analyzer/${encodeURIComponent(this._name)}`,
|
|
120
120
|
qs: { force },
|
|
121
121
|
}, (res) => res.body);
|
|
122
122
|
}
|
package/analyzer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.js","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":";;;AAYA,mCAAwC;AACxC,uCAAiD;AAEjD;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,QAAa;IAC5C,OAAO,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AACxD,CAAC;AAFD,4CAEC;AAqZD;;GAEG;AACH,MAAa,QAAQ;IAInB;;;OAGG;IACH,YAAY,EAAY,EAAE,IAAY;QACpC,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,IA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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"]}
|
|
1
|
+
{"version":3,"file":"analyzer.js","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":";;;AAYA,mCAAwC;AACxC,uCAAiD;AAEjD;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,QAAa;IAC5C,OAAO,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AACxD,CAAC;AAFD,4CAEC;AAidD;;GAEG;AACH,MAAa,QAAQ;IAInB;;;OAGG;IACH,YAAY,EAAY,EAAE,IAAY;QACpC,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,MAAM;QACV,IAAI;YACF,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC;SACb;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,qBAAa,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,KAAK,0BAAkB,EAAE;gBAC7D,OAAO,KAAK,CAAC;aACd;YACD,MAAM,GAAG,CAAC;SACX;IACH,CAAC;IAED;;;;;;;;;;OAUG;IACH,GAAG;QACD,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CACrB,EAAE,IAAI,EAAE,kBAAkB,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,EAC5D,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,KAAK,EAAE,GAAG,OAAO,EAAE;SACvC,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,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YACxD,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 | SegmentationAnalyzer\n | CollationAnalyzer;\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 * Properties of a Segmentation Analyzer.\n */\nexport type SegmentationAnalyzerProperties = {\n /**\n * Which tokens should be returned.\n *\n * Default: `\"alpha\"`\n */\n break?: \"all\" | \"alpha\" | \"graphic\";\n /**\n * What case all returned tokens should be converted to if applicable.\n *\n * Default: `\"none\"`\n */\n case?: \"lower\" | \"upper\" | \"none\";\n};\n\n/**\n * Analyzer type and type-specific properties for a Segmentation Analyzer\n */\nexport type SegmentationAnalyzer = {\n /**\n * Type of the Analyzer.\n */\n type: \"segmentation\";\n /**\n * Additional properties for the Analyzer.\n */\n properties: SegmentationAnalyzerProperties;\n};\n\n/**\n * Properties of a Collation Analyzer.\n */\nexport type CollationAnalyzerProperties = {\n /**\n * Text locale.\n *\n * Format: `language[_COUNTRY][.encoding][@variant]`\n */\n locale: string;\n};\n\n/**\n * Analyzer type and type-specific properties for a Collation Analyzer\n */\nexport type CollationAnalyzer = {\n /**\n * Type of the Analyzer.\n */\n type: \"collation\";\n /**\n * Additional properties for the Analyzer.\n */\n properties: CollationAnalyzerProperties;\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.normalize(\"NFC\");\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/${encodeURIComponent(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/${encodeURIComponent(this._name)}`,\n qs: { force },\n },\n (res) => res.body\n );\n }\n}\n"]}
|
package/aql.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export interface AqlLiteral {
|
|
|
68
68
|
* A value that can be used in an AQL template string or passed to an AQL
|
|
69
69
|
* helper function.
|
|
70
70
|
*/
|
|
71
|
-
export declare type AqlValue = ArangoCollection | View | Graph | GeneratedAqlQuery | AqlLiteral | string | number | boolean | null | undefined | Record<string,
|
|
71
|
+
export declare type AqlValue = ArangoCollection | View | Graph | GeneratedAqlQuery | AqlLiteral | string | number | boolean | null | undefined | Record<string, any> | any[];
|
|
72
72
|
/**
|
|
73
73
|
* Indicates whether the given value is an {@link AqlQuery}.
|
|
74
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,EAAE,KAAK,EAAiB,MAAM,SAAS,CAAC;AAC/C,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,KAAK,GACL,iBAAiB,GACjB,UAAU,GACV,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,MAAM,CAAC,MAAM,EAAE,
|
|
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,EAAE,KAAK,EAAiB,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAgB,IAAI,EAAE,M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GAAG;IAClB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkDG;IACH,SAAgB,OAAO,CACrB,KAAgE;QAEhE,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE;YACvB,OAAO,KAAK,CAAC;SACd;QACD,OAAO;YACL,KAAK;gBACH,IAAI,KAAK,KAAK,SAAS,EAAE;oBACvB,OAAO,EAAE,CAAC;iBACX;gBACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;SACF,CAAC;IACJ,CAAC;IAde,WAAO,UActB,CAAA;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgEG;IACH,SAAgB,IAAI,CAClB,MAAkB,EAClB,MAAc,GAAG;QAEjB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAClB,OAAO,GAAG,CAAA,EAAE,CAAC;SACd;QACD,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"]}
|
|
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,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,OAAQ,KAAa,CAAC,OAAO,KAAK,UAAU,CAAC;AA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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 { 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, any>\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"]}
|