arangojs 8.7.0 → 8.8.1

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 (60) hide show
  1. package/CHANGELOG.md +37 -1
  2. package/README.md +1 -1
  3. package/analyzer.d.ts +105 -38
  4. package/analyzer.d.ts.map +1 -1
  5. package/analyzer.js.map +1 -1
  6. package/aql.d.ts +1 -1
  7. package/aql.d.ts.map +1 -1
  8. package/aql.js.map +1 -1
  9. package/collection.d.ts +117 -66
  10. package/collection.d.ts.map +1 -1
  11. package/collection.js +2 -2
  12. package/collection.js.map +1 -1
  13. package/connection.d.ts +19 -19
  14. package/connection.d.ts.map +1 -1
  15. package/connection.js +1 -1
  16. package/connection.js.map +1 -1
  17. package/cursor.js.map +1 -1
  18. package/database.d.ts +63 -63
  19. package/database.d.ts.map +1 -1
  20. package/database.js +1 -1
  21. package/database.js.map +1 -1
  22. package/documents.d.ts +10 -10
  23. package/documents.d.ts.map +1 -1
  24. package/documents.js.map +1 -1
  25. package/error.js.map +1 -1
  26. package/foxx-manifest.d.ts +4 -4
  27. package/foxx-manifest.d.ts.map +1 -1
  28. package/graph.d.ts +11 -11
  29. package/graph.d.ts.map +1 -1
  30. package/graph.js.map +1 -1
  31. package/index.js.map +1 -1
  32. package/indexes.d.ts +28 -28
  33. package/indexes.d.ts.map +1 -1
  34. package/indexes.js +1 -1
  35. package/indexes.js.map +1 -1
  36. package/job.js.map +1 -1
  37. package/lib/errback.d.ts +1 -1
  38. package/lib/errback.d.ts.map +1 -1
  39. package/lib/multipart.d.ts +1 -1
  40. package/lib/multipart.d.ts.map +1 -1
  41. package/lib/multipart.js.map +1 -1
  42. package/lib/multipart.web.js.map +1 -1
  43. package/lib/omit.js.map +1 -1
  44. package/lib/querystringify.js.map +1 -1
  45. package/lib/querystringify.web.js.map +1 -1
  46. package/lib/request.node.d.ts +2 -2
  47. package/lib/request.node.d.ts.map +1 -1
  48. package/lib/request.node.js.map +1 -1
  49. package/lib/request.web.js.map +1 -1
  50. package/lib/xhr.d.ts +1 -0
  51. package/lib/xhr.d.ts.map +1 -1
  52. package/package.json +1 -1
  53. package/transaction.d.ts +3 -3
  54. package/transaction.d.ts.map +1 -1
  55. package/transaction.js.map +1 -1
  56. package/view.d.ts +24 -24
  57. package/view.d.ts.map +1 -1
  58. package/view.js.map +1 -1
  59. package/web.js +1 -1
  60. package/web.js.map +1 -1
package/indexes.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"indexes.js","sourceRoot":"","sources":["../src/indexes.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAssBH;;GAEG;AACH,SAAgB,YAAY,CAC1B,QAAuB,EACvB,cAAsB;IAEtB,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QAChC,IAAI,QAAQ,CAAC,EAAE,EAAE;YACf,OAAO,YAAY,CAAC,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;SAClD;QACD,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;KACH;IACD,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC1B,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5C,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,cAAc,KAAK,cAAc,EAAE;YACrC,MAAM,IAAI,KAAK,CACb,aAAa,QAAQ,qCAAqC,cAAc,GAAG,CAC5E,CAAC;SACH;QACD,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC3C,OAAO,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAC7C;IACD,OAAO,GAAG,cAAc,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;AAClE,CAAC;AAxBD,oCAwBC","sourcesContent":["/**\n * ```ts\n * import type {\n * FulltextIndex,\n * GeoIndex,\n * PersistentIndex,\n * PrimaryIndex,\n * TtlIndex,\n * ZkdIndex,\n * } from \"arangojs/indexes\";\n * ```\n *\n * The \"indexes\" module provides index-related types for TypeScript.\n *\n * @packageDocumentation\n */\n\nimport { AnalyzerFeature } from \"./analyzer\";\nimport { Compression, Direction, TierConsolidationPolicy } from \"./view\";\n\n/**\n * Options for creating a persistent index.\n */\nexport type EnsurePersistentIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"persistent\";\n /**\n * An array of attribute paths.\n */\n fields: string[];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true`, a unique index will be created.\n *\n * Default: `false`\n */\n unique?: boolean;\n /**\n * If set to `true`, the index will omit documents that do not contain at\n * least one of the attribute paths in `fields` and these documents will be\n * ignored for uniqueness checks.\n *\n * Default: `false`\n */\n sparse?: boolean;\n /**\n * If set to `false`, inserting duplicate index values from the same\n * document will lead to a unique constraint error if this is a unique index.\n *\n * Default: `true`\n */\n deduplicate?: boolean;\n /**\n * If set to `false`, index selectivity estimates will be disabled for this\n * index.\n *\n * Default: `true`\n */\n estimates?: boolean;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n /**\n * If set to `true`, an in-memory hash cache will be put in front of the\n * persistent index.\n *\n * Default: `false`\n */\n cacheEnabled?: boolean;\n /**\n * An array of attribute paths that will be stored in the index but can not\n * be used for index lookups or sorting but can avoid full document lookups.\n */\n storedValues?: string[];\n};\n\n/**\n * Options for creating a geo index.\n */\nexport type EnsureGeoIndexOptions =\n | {\n type: \"geo\";\n /**\n * If set to `true`, `fields` must be an array containing a single attribute\n * path and the attribute value must be an array with two values, the first\n * of which will be interpreted as the longitude and the second of which will\n * be interpreted as the latitude of the document.\n *\n * Default: `false`\n */\n geoJson?: false;\n /**\n * If set to `true`, the index will use pre-3.10 rules for parsing\n * GeoJSON polygons. This option is always implicitly `true` when using\n * ArangoDB 3.9 or lower.\n */\n legacyPolygons?: boolean;\n /**\n * Attribute paths for the document's latitude and longitude values.\n */\n fields: [string, string];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n }\n | {\n type: \"geo\";\n /**\n * If set to `true`, `fields` must be an array containing a single attribute\n * path and the attribute value must be an array with two values, the first\n * of which will be interpreted as the longitude and the second of which will\n * be interpreted as the latitude of the document.\n *\n * Default: `false`\n */\n geoJson?: boolean;\n /**\n * If set to `true`, the index will use pre-3.10 rules for parsing\n * GeoJSON polygons. This option is always implicitly `true` when using\n * ArangoDB 3.9 or lower.\n */\n legacyPolygons?: boolean;\n /**\n * An array containing the attribute path for an array containing two values,\n * the first of which will be interpreted as the latitude, the second as the\n * longitude. If `geoJson` is set to `true`, the order is reversed to match\n * the GeoJSON format.\n */\n fields: [string];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n };\n\n/**\n * Options for creating a fulltext index.\n *\n * @deprecated Fulltext indexes have been deprecated in ArangoDB 3.10 and\n * should be replaced with ArangoSearch.\n */\nexport type EnsureFulltextIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"fulltext\";\n /**\n * An array containing exactly one attribute path.\n */\n fields: [string];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * Minimum character length of words to index.\n */\n minLength?: number;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n};\n\n/**\n * Options for creating a TTL index.\n */\nexport type EnsureTtlIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"ttl\";\n /**\n * An array containing exactly one attribute path.\n */\n fields: [string];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * Duration in seconds after the attribute value at which the document will\n * be considered as expired.\n */\n expireAfter: number;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n};\n\n/**\n * Options for creating a ZKD index.\n */\nexport type EnsureZkdIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"zkd\";\n /**\n * An array containing attribute paths for the dimensions.\n */\n fields: string[];\n /**\n * Data type of the dimension attributes.\n */\n fieldValueTypes: \"double\";\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true`, a unique index will be created.\n *\n * Default: `false`\n */\n unique?: boolean;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n};\n\n/**\n * (Enterprise Edition only.) Options for a nested field in an inverted index.\n */\nexport type InvertedIndexNestedFieldOptions = {\n /**\n * An attribute path.\n */\n name: string;\n /**\n * Name of the Analyzer to apply to the values of this field.\n *\n * Defaults to the `analyzer` specified on the parent options or on the index\n * itself.\n */\n analyzer?: string;\n /**\n * List of Analyzer features to enable for this field's Analyzer.\n *\n * Defaults to the features of the Analyzer.\n */\n features?: AnalyzerFeature[];\n /**\n * If set to `true` array values will be indexed using the same behavior as\n * ArangoSearch Views. This option only applies when using the index in a\n * SearchAlias View.\n *\n * Defaults to the value of `searchField` specified on the index itself.\n */\n searchField?: boolean;\n /**\n * Sub-objects to index to allow querying for co-occurring values.\n */\n nested?: (string | InvertedIndexNestedFieldOptions)[];\n};\n\n/**\n * Options for an attribute path in an inverted index.\n */\nexport type InvertedIndexFieldOptions = {\n /**\n * An attribute path.\n */\n name: string;\n /**\n * Name of the Analyzer to apply to the values of this field.\n *\n * Defaults to the `analyzer` specified on the index itself.\n */\n analyzer?: string;\n /**\n * List of Analyzer features to enable for this field's Analyzer.\n *\n * Defaults to the features of the Analyzer.\n */\n features?: AnalyzerFeature[];\n /**\n * If set to `true`, all document attributes are indexed, excluding any\n * sub-attributes configured in the `fields` array. The `analyzer` and\n * `features` properties apply to the sub-attributes. This option only\n * applies when using the index in a SearchAlias View.\n *\n * Defaults to the value of `includeAllFields` specified on the index itself.\n */\n includeAllFields?: boolean;\n /**\n * If set to `true` array values will be indexed using the same behavior as\n * ArangoSearch Views. This option only applies when using the index in a\n * SearchAlias View.\n *\n * Defaults to the value of `searchField` specified on the index itself.\n */\n searchField?: boolean;\n /**\n * If set to `true`, the position of values in array values are tracked and\n * need to be specified in queries. Otherwise all values in an array are\n * treated as equivalent. This option only applies when using the index in a\n * SearchAlias View.\n *\n * Defaults to the value of `trackListPositions` specified on the index\n * itself.\n */\n trackListPositions?: boolean;\n /**\n * (Enterprise Edition only.) Sub-objects to index to allow querying for\n * co-occurring values.\n */\n nested?: (string | InvertedIndexNestedFieldOptions)[];\n /**\n * (Enterprise Edition only.) If set to `true`, then field normalization\n * values will always be cached in memory.\n *\n * Defaults to the value of `cache` specified on the index itself.\n */\n cache?: boolean;\n};\n\n/**\n * Options for defining a stored value on an inverted index.\n */\nexport type InvertedIndexStoredValueOptions = {\n /**\n * The attribute paths to store.\n */\n fields: string[];\n /**\n * How the attribute values should be compressed.\n *\n * Default: `\"lz4\"`\n */\n compression?: Compression;\n /**\n * (Enterprise Edition only.) If set to `true`, then stored values will\n * always be cached in memory.\n *\n * Default: `false`\n */\n cache?: boolean;\n};\n\n/**\n * Options for defining a primary sort field on an inverted index.\n */\nexport type InvertedIndexPrimarySortFieldOptions = {\n /**\n * The attribute path to sort by.\n */\n field: string;\n /**\n * The sorting direction.\n */\n direction: Direction;\n};\n\n/**\n * Options for creating an inverted index.\n */\nexport type EnsureInvertedIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"inverted\";\n /**\n * An array of attribute paths or objects specifying options for the fields.\n */\n fields: (string | InvertedIndexFieldOptions)[];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true` array values will by default be indexed using the same\n * behavior as ArangoSearch Views. This option only applies when using the\n * index in a SearchAlias View.\n *\n * Default: `false`\n */\n searchField?: boolean;\n /**\n * An array of attribute paths that will be stored in the index but can not\n * be used for index lookups or sorting but can avoid full document lookups.\n */\n storedValues?: InvertedIndexStoredValueOptions[];\n /**\n * Primary sort order to optimize AQL queries using a matching sort order.\n */\n primarySort?: {\n /**\n * An array of fields to sort the index by.\n */\n fields: InvertedIndexPrimarySortFieldOptions[];\n /**\n * How the primary sort data should be compressed.\n *\n * Default: `\"lz4\"`\n */\n compression?: Compression;\n /**\n * (Enterprise Edition only.) If set to `true`, then primary sort columns\n * will always be cached in memory.\n *\n * Default: `false`\n */\n cache?: boolean;\n };\n /**\n * (Enterprise Edition only.) If set to `true`, then the primary key column\n * will always be cached in memory.\n *\n * Default: `false`\n */\n primaryKeyCache?: boolean;\n /**\n * Name of the default Analyzer to apply to the values of indexed fields.\n *\n * Default: `\"identity\"`\n */\n analyzer?: string;\n /**\n * List of Analyzer features to enable for the default Analyzer.\n *\n * Defaults to the Analyzer's features.\n */\n features?: AnalyzerFeature[];\n /**\n * If set to `true`, all document attributes are indexed, excluding any\n * sub-attributes configured in the `fields` array. The `analyzer` and\n * `features` properties apply to the sub-attributes. This option only\n * applies when using the index in a SearchAlias View.\n *\n * Default: `false`\n */\n includeAllFields?: boolean;\n /**\n * If set to `true`, the position of values in array values are tracked and\n * need to be specified in queries. Otherwise all values in an array are\n * treated as equivalent. This option only applies when using the index in a\n * SearchAlias View.\n *\n * Default: `false`\n */\n trackListPositions?: boolean;\n /**\n * The number of threads to use for indexing the fields.\n *\n * Default: `2`\n */\n parallelism?: number;\n /**\n * Wait at least this many commits between removing unused files in the\n * ArangoSearch data directory.\n *\n * Default: `2`\n */\n cleanupIntervalStep?: number;\n /**\n * Wait at least this many milliseconds between committing View data store\n * changes and making documents visible to queries.\n *\n * Default: `1000`\n */\n commitIntervalMsec?: number;\n /**\n * Wait at least this many milliseconds between applying\n * `consolidationPolicy` to consolidate View data store and possibly release\n * space on the filesystem.\n *\n * Default: `1000`\n */\n consolidationIntervalMsec?: number;\n /**\n * The consolidation policy to apply for selecting which segments should be\n * merged.\n *\n * Default: `{ type: \"tier\" }`\n */\n consolidationPolicy?: TierConsolidationPolicy;\n /**\n * Maximum number of writers (segments) cached in the pool.\n *\n * Default: `64`\n */\n writeBufferIdle?: number;\n /**\n * Maximum number of concurrent active writers (segments) that perform a\n * transaction.\n *\n * Default: `0` (disabled)\n */\n writeBufferActive?: number;\n /**\n * Maximum memory byte size per writer (segment) before a writer (segment)\n * flush is triggered.\n *\n * Default: `33554432` (32 MiB)\n */\n writeBufferSizeMax?: number;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n /**\n * (Enterprise Edition only.) If set to `true`, then field normalization\n * values will always be cached in memory.\n *\n * Default: `false`\n */\n cache?: boolean;\n /**\n * An array of strings defining sort expressions to optimize.\n */\n optimizeTopK?: string[];\n};\n\n/**\n * Shared attributes of all index types.\n */\nexport type GenericIndex = {\n /**\n * A unique name for this index.\n */\n name: string;\n /**\n * A unique identifier for this index.\n */\n id: string;\n /**\n * Whether documents not containing at least one of the attribute paths\n * are omitted by this index.\n */\n sparse: boolean;\n /**\n * Whether this index enforces uniqueness for values of its attribute paths.\n */\n unique: boolean;\n};\n\n/**\n * An object representing a persistent index.\n */\nexport type PersistentIndex = GenericIndex & {\n type: \"persistent\";\n fields: string[];\n cacheEnabled: boolean;\n deduplicate: boolean;\n estimates: boolean;\n storedValues?: string[];\n};\n\n/**\n * An object representing a primary index.\n */\nexport type PrimaryIndex = GenericIndex & {\n type: \"primary\";\n fields: string[];\n selectivityEstimate: number;\n};\n\n/**\n * An object representing a fulltext index.\n *\n * @deprecated Fulltext indexes have been deprecated in ArangoDB 3.10 and\n * should be replaced with ArangoSearch.\n */\nexport type FulltextIndex = GenericIndex & {\n type: \"fulltext\";\n fields: [string];\n minLength: number;\n};\n\n/**\n * An object representing a geo index.\n */\nexport type GeoIndex = GenericIndex & {\n type: \"geo\";\n fields: [string] | [string, string];\n geoJson: boolean;\n legacyPolygons: boolean;\n bestIndexedLevel: number;\n worstIndexedLevel: number;\n maxNumCoverCells: number;\n};\n\n/**\n * An object representing a TTL index.\n */\nexport type TtlIndex = GenericIndex & {\n type: \"ttl\";\n fields: [string];\n expireAfter: number;\n selectivityEstimate: number;\n};\n\n/**\n * An object representing a ZKD index.\n */\nexport type ZkdIndex = GenericIndex & {\n type: \"zkd\";\n fields: string[];\n fieldValueTypes: \"double\";\n};\n\n/**\n * (Enterprise Edition only.) An object representing a nested field in an\n * inverted index.\n */\nexport type InvertedIndexNestedField = {\n name: string;\n analyzer?: string;\n features?: AnalyzerFeature[];\n searchField?: boolean;\n nested?: InvertedIndexNestedField[];\n};\n\n/**\n * An object representing an inverted index.\n */\nexport type InvertedIndex = GenericIndex & {\n type: \"inverted\";\n fields: {\n name: string;\n analyzer?: string;\n features?: AnalyzerFeature[];\n includeAllFields?: boolean;\n searchField?: boolean;\n trackListPositions?: boolean;\n nested?: InvertedIndexNestedField[];\n cache?: boolean;\n }[];\n searchField: boolean;\n cache?: boolean;\n storedValues: {\n fields: string[];\n compression: Compression;\n cache?: boolean;\n }[];\n primarySort: {\n fields: {\n field: string;\n direction: Direction;\n }[];\n compression: Compression;\n cache?: boolean;\n };\n primaryKeyCache?: boolean;\n analyzer: string;\n features: AnalyzerFeature[];\n includeAllFields: boolean;\n trackListPositions: boolean;\n parallelism: number;\n cleanupIntervalStep: number;\n commitIntervalMsec: number;\n consolidationIntervalMsec: number;\n consolidationPolicy: Required<TierConsolidationPolicy>;\n writeBufferIdle: number;\n writeBufferActive: number;\n writeBufferSizeMax: number;\n optimizeTopK: string[];\n};\n\n/**\n * An object representing an index.\n */\nexport type Index =\n | GeoIndex\n | FulltextIndex\n | PersistentIndex\n | PrimaryIndex\n | TtlIndex\n | ZkdIndex\n | InvertedIndex;\n\nexport type ObjectWithId = {\n [key: string]: any;\n id: string;\n};\n\nexport type ObjectWithName = {\n [key: string]: any;\n name: string;\n};\n\n/**\n * Index name, id or object with a `name` or `id` property.\n */\nexport type IndexSelector = ObjectWithId | ObjectWithName | string;\n\n/**\n * @internal\n */\nexport function _indexHandle(\n selector: IndexSelector,\n collectionName: string\n): string {\n if (typeof selector !== \"string\") {\n if (selector.id) {\n return _indexHandle(selector.id, collectionName);\n }\n throw new Error(\n \"Index handle must be a string or an object with an id attribute\"\n );\n }\n if (selector.includes(\"/\")) {\n const [head, ...tail] = selector.split(\"/\");\n const normalizedHead = head.normalize(\"NFC\");\n if (normalizedHead !== collectionName) {\n throw new Error(\n `Index ID \"${selector}\" does not match collection name \"${collectionName}\"`\n );\n }\n selector = tail.join(\"/\").normalize(\"NFC\");\n return [normalizedHead, selector].join(\"/\");\n }\n return `${collectionName}/${String(selector).normalize(\"NFC\")}`;\n}\n"]}
1
+ {"version":3,"file":"indexes.js","sourceRoot":"","sources":["../src/indexes.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAssBH;;GAEG;AACH,SAAgB,YAAY,CAC1B,QAAuB,EACvB,cAAsB;IAEtB,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,IAAI,QAAQ,CAAC,EAAE,EAAE,CAAC;YAChB,OAAO,YAAY,CAAC,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;QACnD,CAAC;QACD,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;IACJ,CAAC;IACD,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5C,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,cAAc,KAAK,cAAc,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CACb,aAAa,QAAQ,qCAAqC,cAAc,GAAG,CAC5E,CAAC;QACJ,CAAC;QACD,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC3C,OAAO,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,GAAG,cAAc,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;AAClE,CAAC;AAxBD,oCAwBC","sourcesContent":["/**\n * ```ts\n * import type {\n * FulltextIndex,\n * GeoIndex,\n * MdiIndex,\n * PersistentIndex,\n * PrimaryIndex,\n * TtlIndex,\n * } from \"arangojs/indexes\";\n * ```\n *\n * The \"indexes\" module provides index-related types for TypeScript.\n *\n * @packageDocumentation\n */\n\nimport { AnalyzerFeature } from \"./analyzer\";\nimport { Compression, Direction, TierConsolidationPolicy } from \"./view\";\n\n/**\n * Options for creating a persistent index.\n */\nexport type EnsurePersistentIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"persistent\";\n /**\n * An array of attribute paths.\n */\n fields: string[];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true`, a unique index will be created.\n *\n * Default: `false`\n */\n unique?: boolean;\n /**\n * If set to `true`, the index will omit documents that do not contain at\n * least one of the attribute paths in `fields` and these documents will be\n * ignored for uniqueness checks.\n *\n * Default: `false`\n */\n sparse?: boolean;\n /**\n * If set to `false`, inserting duplicate index values from the same\n * document will lead to a unique constraint error if this is a unique index.\n *\n * Default: `true`\n */\n deduplicate?: boolean;\n /**\n * If set to `false`, index selectivity estimates will be disabled for this\n * index.\n *\n * Default: `true`\n */\n estimates?: boolean;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n /**\n * If set to `true`, an in-memory hash cache will be put in front of the\n * persistent index.\n *\n * Default: `false`\n */\n cacheEnabled?: boolean;\n /**\n * An array of attribute paths that will be stored in the index but can not\n * be used for index lookups or sorting but can avoid full document lookups.\n */\n storedValues?: string[];\n};\n\n/**\n * Options for creating a geo index.\n */\nexport type EnsureGeoIndexOptions =\n | {\n type: \"geo\";\n /**\n * If set to `true`, `fields` must be an array containing a single attribute\n * path and the attribute value must be an array with two values, the first\n * of which will be interpreted as the longitude and the second of which will\n * be interpreted as the latitude of the document.\n *\n * Default: `false`\n */\n geoJson?: false;\n /**\n * If set to `true`, the index will use pre-3.10 rules for parsing\n * GeoJSON polygons. This option is always implicitly `true` when using\n * ArangoDB 3.9 or lower.\n */\n legacyPolygons?: boolean;\n /**\n * Attribute paths for the document's latitude and longitude values.\n */\n fields: [string, string];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n }\n | {\n type: \"geo\";\n /**\n * If set to `true`, `fields` must be an array containing a single attribute\n * path and the attribute value must be an array with two values, the first\n * of which will be interpreted as the longitude and the second of which will\n * be interpreted as the latitude of the document.\n *\n * Default: `false`\n */\n geoJson?: boolean;\n /**\n * If set to `true`, the index will use pre-3.10 rules for parsing\n * GeoJSON polygons. This option is always implicitly `true` when using\n * ArangoDB 3.9 or lower.\n */\n legacyPolygons?: boolean;\n /**\n * An array containing the attribute path for an array containing two values,\n * the first of which will be interpreted as the latitude, the second as the\n * longitude. If `geoJson` is set to `true`, the order is reversed to match\n * the GeoJSON format.\n */\n fields: [string];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n };\n\n/**\n * Options for creating a fulltext index.\n *\n * @deprecated Fulltext indexes have been deprecated in ArangoDB 3.10 and\n * should be replaced with ArangoSearch.\n */\nexport type EnsureFulltextIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"fulltext\";\n /**\n * An array containing exactly one attribute path.\n */\n fields: [string];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * Minimum character length of words to index.\n */\n minLength?: number;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n};\n\n/**\n * Options for creating a TTL index.\n */\nexport type EnsureTtlIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"ttl\";\n /**\n * An array containing exactly one attribute path.\n */\n fields: [string];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * Duration in seconds after the attribute value at which the document will\n * be considered as expired.\n */\n expireAfter: number;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n};\n\n/**\n * Options for creating a MDI index.\n */\nexport type EnsureMdiIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"mdi\";\n /**\n * An array containing attribute paths for the dimensions.\n */\n fields: string[];\n /**\n * Data type of the dimension attributes.\n */\n fieldValueTypes: \"double\";\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true`, a unique index will be created.\n *\n * Default: `false`\n */\n unique?: boolean;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n};\n\n/**\n * (Enterprise Edition only.) Options for a nested field in an inverted index.\n */\nexport type InvertedIndexNestedFieldOptions = {\n /**\n * An attribute path.\n */\n name: string;\n /**\n * Name of the Analyzer to apply to the values of this field.\n *\n * Defaults to the `analyzer` specified on the parent options or on the index\n * itself.\n */\n analyzer?: string;\n /**\n * List of Analyzer features to enable for this field's Analyzer.\n *\n * Defaults to the features of the Analyzer.\n */\n features?: AnalyzerFeature[];\n /**\n * If set to `true` array values will be indexed using the same behavior as\n * ArangoSearch Views. This option only applies when using the index in a\n * SearchAlias View.\n *\n * Defaults to the value of `searchField` specified on the index itself.\n */\n searchField?: boolean;\n /**\n * Sub-objects to index to allow querying for co-occurring values.\n */\n nested?: (string | InvertedIndexNestedFieldOptions)[];\n};\n\n/**\n * Options for an attribute path in an inverted index.\n */\nexport type InvertedIndexFieldOptions = {\n /**\n * An attribute path.\n */\n name: string;\n /**\n * Name of the Analyzer to apply to the values of this field.\n *\n * Defaults to the `analyzer` specified on the index itself.\n */\n analyzer?: string;\n /**\n * List of Analyzer features to enable for this field's Analyzer.\n *\n * Defaults to the features of the Analyzer.\n */\n features?: AnalyzerFeature[];\n /**\n * If set to `true`, all document attributes are indexed, excluding any\n * sub-attributes configured in the `fields` array. The `analyzer` and\n * `features` properties apply to the sub-attributes. This option only\n * applies when using the index in a SearchAlias View.\n *\n * Defaults to the value of `includeAllFields` specified on the index itself.\n */\n includeAllFields?: boolean;\n /**\n * If set to `true` array values will be indexed using the same behavior as\n * ArangoSearch Views. This option only applies when using the index in a\n * SearchAlias View.\n *\n * Defaults to the value of `searchField` specified on the index itself.\n */\n searchField?: boolean;\n /**\n * If set to `true`, the position of values in array values are tracked and\n * need to be specified in queries. Otherwise all values in an array are\n * treated as equivalent. This option only applies when using the index in a\n * SearchAlias View.\n *\n * Defaults to the value of `trackListPositions` specified on the index\n * itself.\n */\n trackListPositions?: boolean;\n /**\n * (Enterprise Edition only.) Sub-objects to index to allow querying for\n * co-occurring values.\n */\n nested?: (string | InvertedIndexNestedFieldOptions)[];\n /**\n * (Enterprise Edition only.) If set to `true`, then field normalization\n * values will always be cached in memory.\n *\n * Defaults to the value of `cache` specified on the index itself.\n */\n cache?: boolean;\n};\n\n/**\n * Options for defining a stored value on an inverted index.\n */\nexport type InvertedIndexStoredValueOptions = {\n /**\n * The attribute paths to store.\n */\n fields: string[];\n /**\n * How the attribute values should be compressed.\n *\n * Default: `\"lz4\"`\n */\n compression?: Compression;\n /**\n * (Enterprise Edition only.) If set to `true`, then stored values will\n * always be cached in memory.\n *\n * Default: `false`\n */\n cache?: boolean;\n};\n\n/**\n * Options for defining a primary sort field on an inverted index.\n */\nexport type InvertedIndexPrimarySortFieldOptions = {\n /**\n * The attribute path to sort by.\n */\n field: string;\n /**\n * The sorting direction.\n */\n direction: Direction;\n};\n\n/**\n * Options for creating an inverted index.\n */\nexport type EnsureInvertedIndexOptions = {\n /**\n * Type of this index.\n */\n type: \"inverted\";\n /**\n * An array of attribute paths or objects specifying options for the fields.\n */\n fields: (string | InvertedIndexFieldOptions)[];\n /**\n * A unique name for this index.\n */\n name?: string;\n /**\n * If set to `true` array values will by default be indexed using the same\n * behavior as ArangoSearch Views. This option only applies when using the\n * index in a SearchAlias View.\n *\n * Default: `false`\n */\n searchField?: boolean;\n /**\n * An array of attribute paths that will be stored in the index but can not\n * be used for index lookups or sorting but can avoid full document lookups.\n */\n storedValues?: InvertedIndexStoredValueOptions[];\n /**\n * Primary sort order to optimize AQL queries using a matching sort order.\n */\n primarySort?: {\n /**\n * An array of fields to sort the index by.\n */\n fields: InvertedIndexPrimarySortFieldOptions[];\n /**\n * How the primary sort data should be compressed.\n *\n * Default: `\"lz4\"`\n */\n compression?: Compression;\n /**\n * (Enterprise Edition only.) If set to `true`, then primary sort columns\n * will always be cached in memory.\n *\n * Default: `false`\n */\n cache?: boolean;\n };\n /**\n * (Enterprise Edition only.) If set to `true`, then the primary key column\n * will always be cached in memory.\n *\n * Default: `false`\n */\n primaryKeyCache?: boolean;\n /**\n * Name of the default Analyzer to apply to the values of indexed fields.\n *\n * Default: `\"identity\"`\n */\n analyzer?: string;\n /**\n * List of Analyzer features to enable for the default Analyzer.\n *\n * Defaults to the Analyzer's features.\n */\n features?: AnalyzerFeature[];\n /**\n * If set to `true`, all document attributes are indexed, excluding any\n * sub-attributes configured in the `fields` array. The `analyzer` and\n * `features` properties apply to the sub-attributes. This option only\n * applies when using the index in a SearchAlias View.\n *\n * Default: `false`\n */\n includeAllFields?: boolean;\n /**\n * If set to `true`, the position of values in array values are tracked and\n * need to be specified in queries. Otherwise all values in an array are\n * treated as equivalent. This option only applies when using the index in a\n * SearchAlias View.\n *\n * Default: `false`\n */\n trackListPositions?: boolean;\n /**\n * The number of threads to use for indexing the fields.\n *\n * Default: `2`\n */\n parallelism?: number;\n /**\n * Wait at least this many commits between removing unused files in the\n * ArangoSearch data directory.\n *\n * Default: `2`\n */\n cleanupIntervalStep?: number;\n /**\n * Wait at least this many milliseconds between committing View data store\n * changes and making documents visible to queries.\n *\n * Default: `1000`\n */\n commitIntervalMsec?: number;\n /**\n * Wait at least this many milliseconds between applying\n * `consolidationPolicy` to consolidate View data store and possibly release\n * space on the filesystem.\n *\n * Default: `1000`\n */\n consolidationIntervalMsec?: number;\n /**\n * The consolidation policy to apply for selecting which segments should be\n * merged.\n *\n * Default: `{ type: \"tier\" }`\n */\n consolidationPolicy?: TierConsolidationPolicy;\n /**\n * Maximum number of writers (segments) cached in the pool.\n *\n * Default: `64`\n */\n writeBufferIdle?: number;\n /**\n * Maximum number of concurrent active writers (segments) that perform a\n * transaction.\n *\n * Default: `0` (disabled)\n */\n writeBufferActive?: number;\n /**\n * Maximum memory byte size per writer (segment) before a writer (segment)\n * flush is triggered.\n *\n * Default: `33554432` (32 MiB)\n */\n writeBufferSizeMax?: number;\n /**\n * If set to `true`, the index will be created in the background to reduce\n * the write-lock duration for the collection during index creation.\n *\n * Default: `false`\n */\n inBackground?: boolean;\n /**\n * (Enterprise Edition only.) If set to `true`, then field normalization\n * values will always be cached in memory.\n *\n * Default: `false`\n */\n cache?: boolean;\n /**\n * An array of strings defining sort expressions to optimize.\n */\n optimizeTopK?: string[];\n};\n\n/**\n * Shared attributes of all index types.\n */\nexport type GenericIndex = {\n /**\n * A unique name for this index.\n */\n name: string;\n /**\n * A unique identifier for this index.\n */\n id: string;\n /**\n * Whether documents not containing at least one of the attribute paths\n * are omitted by this index.\n */\n sparse: boolean;\n /**\n * Whether this index enforces uniqueness for values of its attribute paths.\n */\n unique: boolean;\n};\n\n/**\n * An object representing a persistent index.\n */\nexport type PersistentIndex = GenericIndex & {\n type: \"persistent\";\n fields: string[];\n cacheEnabled: boolean;\n deduplicate: boolean;\n estimates: boolean;\n storedValues?: string[];\n};\n\n/**\n * An object representing a primary index.\n */\nexport type PrimaryIndex = GenericIndex & {\n type: \"primary\";\n fields: string[];\n selectivityEstimate: number;\n};\n\n/**\n * An object representing a fulltext index.\n *\n * @deprecated Fulltext indexes have been deprecated in ArangoDB 3.10 and\n * should be replaced with ArangoSearch.\n */\nexport type FulltextIndex = GenericIndex & {\n type: \"fulltext\";\n fields: [string];\n minLength: number;\n};\n\n/**\n * An object representing a geo index.\n */\nexport type GeoIndex = GenericIndex & {\n type: \"geo\";\n fields: [string] | [string, string];\n geoJson: boolean;\n legacyPolygons: boolean;\n bestIndexedLevel: number;\n worstIndexedLevel: number;\n maxNumCoverCells: number;\n};\n\n/**\n * An object representing a TTL index.\n */\nexport type TtlIndex = GenericIndex & {\n type: \"ttl\";\n fields: [string];\n expireAfter: number;\n selectivityEstimate: number;\n};\n\n/**\n * An object representing a MDI index.\n */\nexport type MdiIndex = GenericIndex & {\n type: \"mdi\";\n fields: string[];\n fieldValueTypes: \"double\";\n};\n\n/**\n * (Enterprise Edition only.) An object representing a nested field in an\n * inverted index.\n */\nexport type InvertedIndexNestedField = {\n name: string;\n analyzer?: string;\n features?: AnalyzerFeature[];\n searchField?: boolean;\n nested?: InvertedIndexNestedField[];\n};\n\n/**\n * An object representing an inverted index.\n */\nexport type InvertedIndex = GenericIndex & {\n type: \"inverted\";\n fields: {\n name: string;\n analyzer?: string;\n features?: AnalyzerFeature[];\n includeAllFields?: boolean;\n searchField?: boolean;\n trackListPositions?: boolean;\n nested?: InvertedIndexNestedField[];\n cache?: boolean;\n }[];\n searchField: boolean;\n cache?: boolean;\n storedValues: {\n fields: string[];\n compression: Compression;\n cache?: boolean;\n }[];\n primarySort: {\n fields: {\n field: string;\n direction: Direction;\n }[];\n compression: Compression;\n cache?: boolean;\n };\n primaryKeyCache?: boolean;\n analyzer: string;\n features: AnalyzerFeature[];\n includeAllFields: boolean;\n trackListPositions: boolean;\n parallelism: number;\n cleanupIntervalStep: number;\n commitIntervalMsec: number;\n consolidationIntervalMsec: number;\n consolidationPolicy: Required<TierConsolidationPolicy>;\n writeBufferIdle: number;\n writeBufferActive: number;\n writeBufferSizeMax: number;\n optimizeTopK: string[];\n};\n\n/**\n * An object representing an index.\n */\nexport type Index =\n | GeoIndex\n | FulltextIndex\n | PersistentIndex\n | PrimaryIndex\n | TtlIndex\n | MdiIndex\n | InvertedIndex;\n\nexport type ObjectWithId = {\n [key: string]: any;\n id: string;\n};\n\nexport type ObjectWithName = {\n [key: string]: any;\n name: string;\n};\n\n/**\n * Index name, id or object with a `name` or `id` property.\n */\nexport type IndexSelector = ObjectWithId | ObjectWithName | string;\n\n/**\n * @internal\n */\nexport function _indexHandle(\n selector: IndexSelector,\n collectionName: string\n): string {\n if (typeof selector !== \"string\") {\n if (selector.id) {\n return _indexHandle(selector.id, collectionName);\n }\n throw new Error(\n \"Index handle must be a string or an object with an id attribute\"\n );\n }\n if (selector.includes(\"/\")) {\n const [head, ...tail] = selector.split(\"/\");\n const normalizedHead = head.normalize(\"NFC\");\n if (normalizedHead !== collectionName) {\n throw new Error(\n `Index ID \"${selector}\" does not match collection name \"${collectionName}\"`\n );\n }\n selector = tail.join(\"/\").normalize(\"NFC\");\n return [normalizedHead, selector].join(\"/\");\n }\n return `${collectionName}/${String(selector).normalize(\"NFC\")}`;\n}\n"]}
package/job.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"job.js","sourceRoot":"","sources":["../src/job.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,MAAa,GAAG;IAQd;;OAEG;IACH,YACE,EAAY,EACZ,EAAU,EACV,iBAAyD,EACzD,cAA2C;QAVnC,YAAO,GAAY,KAAK,CAAC;QAYjC,IAAI,CAAC,GAAG,GAAG,EAA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AAG,SAAS;SACrC,EACD,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CACrB;YACE,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,aAAa,IAAI,CAAC,GAAG,EAAE;SAC9B,EACD,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CACrB;YACE,IAAI,EAAE,aAAa,IAAI,CAAC,GAAG,EAAE;SAC9B,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,KAAK,GAAG,CAChC,CAAC;IACJ,CAAC;CACF;AArID,kBAqIC","sourcesContent":["import { Database } from \"./database\";\nimport { ArangojsResponse } from \"./lib/request.node\";\n\n/**\n * Represents an async job in a {@link database.Database}.\n */\nexport class Job<T = any> {\n protected _id: string;\n protected _db: Database;\n protected _transformResponse?: (res: ArangojsResponse) => Promise<T>;\n protected _transformError?: (error: any) => Promise<T>;\n protected _loaded: boolean = false;\n protected _result: T | undefined;\n\n /**\n * @internal\n */\n constructor(\n db: Database,\n id: string,\n transformResponse?: (res: ArangojsResponse) => Promise<T>,\n transformError?: (error: any) => Promise<T>\n ) {\n this._db = db;\n this._id = id;\n this._transformResponse = transformResponse;\n this._transformError = transformError;\n }\n\n /**\n * Whether the job's results have been loaded. If set to `true`, the job's\n * result can be accessed from {@link Job.result}.\n */\n get isLoaded(): boolean {\n return this._loaded;\n }\n\n /**\n * The job's result if it has been loaded or `undefined` otherwise.\n */\n get result(): T | undefined {\n return this._result;\n }\n\n /**\n * Loads the job's result from the database if it is not already loaded.\n *\n * @example\n * ```js\n * // poll for the job to complete\n * while (!job.isLoaded) {\n * await timeout(1000);\n * const result = await job.load();\n * console.log(result);\n * }\n * // job result is now loaded and can also be accessed from job.result\n * console.log(job.result);\n * ```\n */\n async load(): Promise<T | undefined> {\n if (!this.isLoaded) {\n let res: ArangojsResponse;\n try {\n res = await this._db.request(\n {\n method: \"PUT\",\n path: `/_api/job/${this._id}`,\n },\n false\n );\n } catch (e) {\n if (this._transformError) {\n return this._transformError(e);\n }\n throw e;\n }\n if (res.statusCode !== 204) {\n this._loaded = true;\n if (this._transformResponse) {\n this._result = await this._transformResponse(res);\n } else {\n this._result = res.body;\n }\n }\n }\n return this._result;\n }\n\n /**\n * Cancels the job if it is still running. Note that it may take some time to\n * actually cancel the job.\n */\n cancel(): Promise<void> {\n return this._db.request(\n {\n method: \"PUT\",\n path: `/_api/job/${this._id}/cancel`,\n },\n () => undefined\n );\n }\n\n /**\n * Deletes the result if it has not already been retrieved or deleted.\n */\n deleteResult(): Promise<void> {\n return this._db.request(\n {\n method: \"DELETE\",\n path: `/_api/job/${this._id}`,\n },\n () => undefined\n );\n }\n\n /**\n * Fetches the job's completion state.\n *\n * Returns `true` if the job has completed, `false` otherwise.\n *\n * @example\n * ```js\n * // poll for the job to complete\n * while (!(await job.getCompleted())) {\n * await timeout(1000);\n * }\n * // job result is now available and can be loaded\n * await job.load();\n * console.log(job.result);\n * ```\n */\n getCompleted(): Promise<boolean> {\n return this._db.request(\n {\n path: `/_api/job/${this._id}`,\n },\n (res) => res.statusCode !== 204\n );\n }\n}\n"]}
1
+ {"version":3,"file":"job.js","sourceRoot":"","sources":["../src/job.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,MAAa,GAAG;IAQd;;OAEG;IACH,YACE,EAAY,EACZ,EAAU,EACV,iBAAyD,EACzD,cAA2C;QAVnC,YAAO,GAAY,KAAK,CAAC;QAYjC,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,CAAC;QAC5C,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IACxC,CAAC;IAED;;;OA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;;OAEG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CACrB;YACE,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,aAAa,IAAI,CAAC,GAAG,EAAE;SAC9B,EACD,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CACrB;YACE,IAAI,EAAE,aAAa,IAAI,CAAC,GAAG,EAAE;SAC9B,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,KAAK,GAAG,CAChC,CAAC;IACJ,CAAC;CACF;AArID,kBAqIC","sourcesContent":["import { Database } from \"./database\";\nimport { ArangojsResponse } from \"./lib/request.node\";\n\n/**\n * Represents an async job in a {@link database.Database}.\n */\nexport class Job<T = any> {\n protected _id: string;\n protected _db: Database;\n protected _transformResponse?: (res: ArangojsResponse) => Promise<T>;\n protected _transformError?: (error: any) => Promise<T>;\n protected _loaded: boolean = false;\n protected _result: T | undefined;\n\n /**\n * @internal\n */\n constructor(\n db: Database,\n id: string,\n transformResponse?: (res: ArangojsResponse) => Promise<T>,\n transformError?: (error: any) => Promise<T>\n ) {\n this._db = db;\n this._id = id;\n this._transformResponse = transformResponse;\n this._transformError = transformError;\n }\n\n /**\n * Whether the job's results have been loaded. If set to `true`, the job's\n * result can be accessed from {@link Job.result}.\n */\n get isLoaded(): boolean {\n return this._loaded;\n }\n\n /**\n * The job's result if it has been loaded or `undefined` otherwise.\n */\n get result(): T | undefined {\n return this._result;\n }\n\n /**\n * Loads the job's result from the database if it is not already loaded.\n *\n * @example\n * ```js\n * // poll for the job to complete\n * while (!job.isLoaded) {\n * await timeout(1000);\n * const result = await job.load();\n * console.log(result);\n * }\n * // job result is now loaded and can also be accessed from job.result\n * console.log(job.result);\n * ```\n */\n async load(): Promise<T | undefined> {\n if (!this.isLoaded) {\n let res: ArangojsResponse;\n try {\n res = await this._db.request(\n {\n method: \"PUT\",\n path: `/_api/job/${this._id}`,\n },\n false\n );\n } catch (e) {\n if (this._transformError) {\n return this._transformError(e);\n }\n throw e;\n }\n if (res.statusCode !== 204) {\n this._loaded = true;\n if (this._transformResponse) {\n this._result = await this._transformResponse(res);\n } else {\n this._result = res.body;\n }\n }\n }\n return this._result;\n }\n\n /**\n * Cancels the job if it is still running. Note that it may take some time to\n * actually cancel the job.\n */\n cancel(): Promise<void> {\n return this._db.request(\n {\n method: \"PUT\",\n path: `/_api/job/${this._id}/cancel`,\n },\n () => undefined\n );\n }\n\n /**\n * Deletes the result if it has not already been retrieved or deleted.\n */\n deleteResult(): Promise<void> {\n return this._db.request(\n {\n method: \"DELETE\",\n path: `/_api/job/${this._id}`,\n },\n () => undefined\n );\n }\n\n /**\n * Fetches the job's completion state.\n *\n * Returns `true` if the job has completed, `false` otherwise.\n *\n * @example\n * ```js\n * // poll for the job to complete\n * while (!(await job.getCompleted())) {\n * await timeout(1000);\n * }\n * // job result is now available and can be loaded\n * await job.load();\n * console.log(job.result);\n * ```\n */\n getCompleted(): Promise<boolean> {\n return this._db.request(\n {\n path: `/_api/job/${this._id}`,\n },\n (res) => res.statusCode !== 204\n );\n }\n}\n"]}
package/lib/errback.d.ts CHANGED
@@ -11,5 +11,5 @@
11
11
  *
12
12
  * @internal
13
13
  */
14
- export declare type Errback<T = never> = (err: Error | null, result?: T) => void;
14
+ export type Errback<T = never> = (err: Error | null, result?: T) => void;
15
15
  //# sourceMappingURL=errback.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errback.d.ts","sourceRoot":"","sources":["../../src/lib/errback.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH;;;;;;GAMG;AACH,oBAAY,OAAO,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC"}
1
+ {"version":3,"file":"errback.d.ts","sourceRoot":"","sources":["../../src/lib/errback.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH;;;;;;GAMG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC"}
@@ -9,7 +9,7 @@ import { Headers } from "../connection";
9
9
  /**
10
10
  * @internal
11
11
  */
12
- export declare type Fields = {
12
+ export type Fields = {
13
13
  [key: string]: any;
14
14
  };
15
15
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"multipart.d.ts","sourceRoot":"","sources":["../../src/lib/multipart.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAexC;;GAEG;AACH,oBAAY,MAAM,GAAG;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAkBtE"}
1
+ {"version":3,"file":"multipart.d.ts","sourceRoot":"","sources":["../../src/lib/multipart.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAexC;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAkBtE"}
@@ -1 +1 @@
1
- {"version":3,"file":"multipart.js","sourceRoot":"","sources":["../../src/lib/multipart.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,mCAAkC;AAalC,8DAA8D;AAC9D,MAAM,SAAS,GAAG,OAAO,CAAC,YAAY,CAAqB,CAAC;AAiB5D;;GAEG;AACI,KAAK,UAAU,MAAM,CAAC,MAAc;IACzC,MAAM,IAAI,GAAG,IAAI,SAAS,EAAE,CAAC;IAC7B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QACrC,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,IACE,CAAC,CAAC,KAAK,YAAY,iBAAQ,CAAC;YAC5B,CAAC,CAAC,KAAK,YAAY,MAAM,CAAC,MAAM,CAAC;YACjC,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC,EAC1D;YACA,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;SAC/B;QACD,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;KACzB;IACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;IACjC,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IAClC,OAAO,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC3B,CAAC;AAlBD,wBAkBC","sourcesContent":["/**\n * Utility function for constructing a multipart form in Node.js.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport { Readable } from \"stream\";\nimport { Headers } from \"../connection\";\n\ndeclare class MultiPart {\n append(\n field: string,\n value: any,\n options?: { filename?: string; contentType?: string }\n ): this;\n getHeaders(): Headers;\n buffer(): Promise<Buffer>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst Multipart = require(\"multi-part\") as typeof MultiPart;\n\n/**\n * @internal\n */\nexport type Fields = {\n [key: string]: any;\n};\n\n/**\n * @internal\n */\nexport interface MultipartRequest {\n headers?: Headers;\n body: Buffer;\n}\n\n/**\n * @internal\n */\nexport async function toForm(fields: Fields): Promise<MultipartRequest> {\n const form = new Multipart();\n for (const key of Object.keys(fields)) {\n let value = fields[key];\n if (value === undefined) continue;\n if (\n !(value instanceof Readable) &&\n !(value instanceof global.Buffer) &&\n (typeof value === \"object\" || typeof value === \"function\")\n ) {\n value = JSON.stringify(value);\n }\n form.append(key, value);\n }\n const body = await form.buffer();\n const headers = form.getHeaders();\n delete headers[\"transfer-encoding\"];\n return { body, headers };\n}\n"]}
1
+ {"version":3,"file":"multipart.js","sourceRoot":"","sources":["../../src/lib/multipart.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,mCAAkC;AAalC,8DAA8D;AAC9D,MAAM,SAAS,GAAG,OAAO,CAAC,YAAY,CAAqB,CAAC;AAiB5D;;GAEG;AACI,KAAK,UAAU,MAAM,CAAC,MAAc;IACzC,MAAM,IAAI,GAAG,IAAI,SAAS,EAAE,CAAC;IAC7B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,IACE,CAAC,CAAC,KAAK,YAAY,iBAAQ,CAAC;YAC5B,CAAC,CAAC,KAAK,YAAY,MAAM,CAAC,MAAM,CAAC;YACjC,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC,EAC1D,CAAC;YACD,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC1B,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;IACjC,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IAClC,OAAO,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC3B,CAAC;AAlBD,wBAkBC","sourcesContent":["/**\n * Utility function for constructing a multipart form in Node.js.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport { Readable } from \"stream\";\nimport { Headers } from \"../connection\";\n\ndeclare class MultiPart {\n append(\n field: string,\n value: any,\n options?: { filename?: string; contentType?: string }\n ): this;\n getHeaders(): Headers;\n buffer(): Promise<Buffer>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst Multipart = require(\"multi-part\") as typeof MultiPart;\n\n/**\n * @internal\n */\nexport type Fields = {\n [key: string]: any;\n};\n\n/**\n * @internal\n */\nexport interface MultipartRequest {\n headers?: Headers;\n body: Buffer;\n}\n\n/**\n * @internal\n */\nexport async function toForm(fields: Fields): Promise<MultipartRequest> {\n const form = new Multipart();\n for (const key of Object.keys(fields)) {\n let value = fields[key];\n if (value === undefined) continue;\n if (\n !(value instanceof Readable) &&\n !(value instanceof global.Buffer) &&\n (typeof value === \"object\" || typeof value === \"function\")\n ) {\n value = JSON.stringify(value);\n }\n form.append(key, value);\n }\n const body = await form.buffer();\n const headers = form.getHeaders();\n delete headers[\"transfer-encoding\"];\n return { body, headers };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"multipart.web.js","sourceRoot":"","sources":["../../src/lib/multipart.web.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAQH;;GAEG;AACH,SAAgB,MAAM,CAAC,MAAc,EAAE,QAAmC;IACxE,IAAI,IAAI,CAAC;IACT,IAAI;QACF,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;QACtB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;YACrC,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YACxB,IAAI,KAAK,KAAK,SAAS;gBAAE,SAAS;YAClC,IACE,CAAC,CAAC,KAAK,YAAY,IAAI,CAAC;gBACxB,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC,EAC1D;gBACA,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;aAC/B;YACD,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;SACzB;KACF;IAAC,OAAO,CAAM,EAAE;QACf,QAAQ,CAAC,CAAC,CAAC,CAAC;QACZ,OAAO;KACR;IACD,QAAQ,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AACjC,CAAC;AApBD,wBAoBC","sourcesContent":["/**\n * Utility function for constructing a multipart form in the browser.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport { Errback } from \"./errback\";\nimport { Fields, MultipartRequest } from \"./multipart\";\n\ndeclare const FormData: any;\ndeclare const Blob: any;\n\n/**\n * @internal\n */\nexport function toForm(fields: Fields, callback: Errback<MultipartRequest>) {\n let form;\n try {\n form = new FormData();\n for (const key of Object.keys(fields)) {\n let value = fields[key];\n if (value === undefined) continue;\n if (\n !(value instanceof Blob) &&\n (typeof value === \"object\" || typeof value === \"function\")\n ) {\n value = JSON.stringify(value);\n }\n form.append(key, value);\n }\n } catch (e: any) {\n callback(e);\n return;\n }\n callback(null, { body: form });\n}\n"]}
1
+ {"version":3,"file":"multipart.web.js","sourceRoot":"","sources":["../../src/lib/multipart.web.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAQH;;GAEG;AACH,SAAgB,MAAM,CAAC,MAAc,EAAE,QAAmC;IACxE,IAAI,IAAI,CAAC;IACT,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;QACtB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACtC,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YACxB,IAAI,KAAK,KAAK,SAAS;gBAAE,SAAS;YAClC,IACE,CAAC,CAAC,KAAK,YAAY,IAAI,CAAC;gBACxB,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC,EAC1D,CAAC;gBACD,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,QAAQ,CAAC,CAAC,CAAC,CAAC;QACZ,OAAO;IACT,CAAC;IACD,QAAQ,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AACjC,CAAC;AApBD,wBAoBC","sourcesContent":["/**\n * Utility function for constructing a multipart form in the browser.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport { Errback } from \"./errback\";\nimport { Fields, MultipartRequest } from \"./multipart\";\n\ndeclare const FormData: any;\ndeclare const Blob: any;\n\n/**\n * @internal\n */\nexport function toForm(fields: Fields, callback: Errback<MultipartRequest>) {\n let form;\n try {\n form = new FormData();\n for (const key of Object.keys(fields)) {\n let value = fields[key];\n if (value === undefined) continue;\n if (\n !(value instanceof Blob) &&\n (typeof value === \"object\" || typeof value === \"function\")\n ) {\n value = JSON.stringify(value);\n }\n form.append(key, value);\n }\n } catch (e: any) {\n callback(e);\n return;\n }\n callback(null, { body: form });\n}\n"]}
package/lib/omit.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"omit.js","sourceRoot":"","sources":["../../src/lib/omit.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH;;GAEG;AACH,wDAAwD;AACxD,SAAgB,IAAI,CAAe,GAAM,EAAE,IAAiB;IAC1D,MAAM,MAAM,GAAG,EAAO,CAAC;IACvB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAClC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAc,CAAC;YAAE,SAAS;QAC5C,MAAM,CAAC,GAAc,CAAC,GAAG,GAAG,CAAC,GAAc,CAAC,CAAC;KAC9C;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAPD,oBAOC","sourcesContent":["/**\n * Utility function for omitting properties by key.\n *\n * @packageDocumentation\n * @internal\n */\n\n/**\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function omit<T extends {}>(obj: T, keys: (keyof T)[]): T {\n const result = {} as T;\n for (const key of Object.keys(obj)) {\n if (keys.includes(key as keyof T)) continue;\n result[key as keyof T] = obj[key as keyof T];\n }\n return result;\n}\n"]}
1
+ {"version":3,"file":"omit.js","sourceRoot":"","sources":["../../src/lib/omit.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH;;GAEG;AACH,wDAAwD;AACxD,SAAgB,IAAI,CAAe,GAAM,EAAE,IAAiB;IAC1D,MAAM,MAAM,GAAG,EAAO,CAAC;IACvB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAc,CAAC;YAAE,SAAS;QAC5C,MAAM,CAAC,GAAc,CAAC,GAAG,GAAG,CAAC,GAAc,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAPD,oBAOC","sourcesContent":["/**\n * Utility function for omitting properties by key.\n *\n * @packageDocumentation\n * @internal\n */\n\n/**\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function omit<T extends {}>(obj: T, keys: (keyof T)[]): T {\n const result = {} as T;\n for (const key of Object.keys(obj)) {\n if (keys.includes(key as keyof T)) continue;\n result[key as keyof T] = obj[key as keyof T];\n }\n return result;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"querystringify.js","sourceRoot":"","sources":["../../src/lib/querystringify.ts"],"names":[],"mappings":";;;AAAA,SAAgB,cAAc,CAAC,GAAwB;IACrD,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAC9C,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACzB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;SAC3B;aAAM;YACL,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;gBACxB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;aAC1B;SACF;KACF;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;AACxB,CAAC;AAbD,wCAaC","sourcesContent":["export function querystringify(obj: Record<string, any>) {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(obj)) {\n if (value === undefined) continue;\n if (!Array.isArray(value)) {\n params.append(key, value);\n } else {\n for (const item of value) {\n params.append(key, item);\n }\n }\n }\n return String(params);\n}\n"]}
1
+ {"version":3,"file":"querystringify.js","sourceRoot":"","sources":["../../src/lib/querystringify.ts"],"names":[],"mappings":";;;AAAA,SAAgB,cAAc,CAAC,GAAwB;IACrD,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC5B,CAAC;aAAM,CAAC;YACN,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;AACxB,CAAC;AAbD,wCAaC","sourcesContent":["export function querystringify(obj: Record<string, any>) {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(obj)) {\n if (value === undefined) continue;\n if (!Array.isArray(value)) {\n params.append(key, value);\n } else {\n for (const item of value) {\n params.append(key, item);\n }\n }\n }\n return String(params);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"querystringify.web.js","sourceRoot":"","sources":["../../src/lib/querystringify.web.ts"],"names":[],"mappings":";;;AAAA,SAAgB,cAAc,CAC5B,GAQC;IAED,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAC5C,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,GAAG,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACzB,IAAI,KAAK,KAAK,IAAI;gBAAE,KAAK,GAAG,EAAE,CAAC;;gBAC1B,KAAK,GAAG,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC/C,MAAM,IAAI,IAAI,GAAG,IAAI,KAAK,EAAE,CAAC;SAC9B;aAAM;YACL,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE;gBACtB,IAAI,IAAI,IAAI,IAAI;oBAAE,IAAI,GAAG,EAAE,CAAC;;oBACvB,IAAI,GAAG,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC7C,MAAM,IAAI,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;aAC7B;SACF;KACF;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACzB,CAAC;AA5BD,wCA4BC","sourcesContent":["export function querystringify(\n obj: Record<\n string,\n | string\n | number\n | boolean\n | null\n | undefined\n | readonly (string | number | boolean | null | undefined)[]\n >\n) {\n let result = \"\";\n for (let [key, value] of Object.entries(obj)) {\n if (value === undefined) continue;\n key = encodeURIComponent(key);\n if (!Array.isArray(value)) {\n if (value === null) value = \"\";\n else value = encodeURIComponent(String(value));\n result += `&${key}=${value}`;\n } else {\n for (let item of value) {\n if (item == null) item = \"\";\n else item = encodeURIComponent(String(item));\n result += `&${key}=${item}`;\n }\n }\n }\n return result.slice(1);\n}\n"]}
1
+ {"version":3,"file":"querystringify.web.js","sourceRoot":"","sources":["../../src/lib/querystringify.web.ts"],"names":[],"mappings":";;;AAAA,SAAgB,cAAc,CAC5B,GAQC;IAED,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7C,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,GAAG,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,IAAI,KAAK,KAAK,IAAI;gBAAE,KAAK,GAAG,EAAE,CAAC;;gBAC1B,KAAK,GAAG,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC/C,MAAM,IAAI,IAAI,GAAG,IAAI,KAAK,EAAE,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;gBACvB,IAAI,IAAI,IAAI,IAAI;oBAAE,IAAI,GAAG,EAAE,CAAC;;oBACvB,IAAI,GAAG,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC7C,MAAM,IAAI,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACzB,CAAC;AA5BD,wCA4BC","sourcesContent":["export function querystringify(\n obj: Record<\n string,\n | string\n | number\n | boolean\n | null\n | undefined\n | readonly (string | number | boolean | null | undefined)[]\n >\n) {\n let result = \"\";\n for (let [key, value] of Object.entries(obj)) {\n if (value === undefined) continue;\n key = encodeURIComponent(key);\n if (!Array.isArray(value)) {\n if (value === null) value = \"\";\n else value = encodeURIComponent(String(value));\n result += `&${key}=${value}`;\n } else {\n for (let item of value) {\n if (item == null) item = \"\";\n else item = encodeURIComponent(String(item));\n result += `&${key}=${item}`;\n }\n }\n }\n return result.slice(1);\n}\n"]}
@@ -26,7 +26,7 @@ export interface ArangojsError extends Error {
26
26
  /**
27
27
  * @internal
28
28
  */
29
- export declare type RequestOptions = {
29
+ export type RequestOptions = {
30
30
  method: string;
31
31
  url: {
32
32
  pathname: string;
@@ -40,7 +40,7 @@ export declare type RequestOptions = {
40
40
  /**
41
41
  * @internal
42
42
  */
43
- export declare type RequestFunction = {
43
+ export type RequestFunction = {
44
44
  (options: RequestOptions, cb: Errback<ArangojsResponse>): void;
45
45
  close?: () => void;
46
46
  };
@@ -1 +1 @@
1
- {"version":3,"file":"request.node.d.ts","sourceRoot":"","sources":["../../src/lib/request.node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAEL,YAAY,EACZ,aAAa,EAEb,eAAe,EAEhB,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,OAA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AAC,CAAC;SACP;IACH,CAAC,EACD;QACE,KAAK;YACH,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,CAAC;KACF,CACF,CAAC;AACJ,CAAC;AA5HD,sCA4HC","sourcesContent":["/**\n * Node.js implementation of the HTTP(S) request function.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport {\n Agent as HttpAgent,\n AgentOptions,\n ClientRequest,\n ClientRequestArgs,\n IncomingMessage,\n request as httpRequest,\n} from \"http\";\nimport { Agent as HttpsAgent, request as httpsRequest } from \"https\";\nimport { parse as parseUrl, UrlWithStringQuery } from \"url\";\nimport { Headers, RequestInterceptors } from \"../connection\";\nimport { SystemError } from \"../error\";\nimport { base64Encode } from \"./btoa\";\nimport { Errback } from \"./errback\";\nimport { joinPath } from \"./joinPath\";\nimport { omit } from \"./omit\";\n\n/**\n * @internal\n */\nfunction systemErrorToJSON(this: SystemError) {\n return {\n error: true,\n errno: this.errno,\n code: this.code,\n syscall: this.syscall,\n };\n}\n\n/**\n * @internal\n */\nexport interface ArangojsResponse extends IncomingMessage {\n request: ClientRequest;\n body?: any;\n arangojsHostUrl?: string;\n}\n\n/**\n * @internal\n */\nexport interface ArangojsError extends Error {\n request: ClientRequest;\n toJSON: () => Record<string, any>;\n}\n\n/**\n * @internal\n */\nexport type RequestOptions = {\n method: string;\n url: { pathname: string; search?: string };\n headers: Headers;\n body: any;\n expectBinary: boolean;\n timeout?: number;\n};\n\n/**\n * @internal\n */\nexport type RequestFunction = {\n (options: RequestOptions, cb: Errback<ArangojsResponse>): void;\n close?: () => void;\n};\n\n/**\n * @internal\n */\nexport const isBrowser = false;\n\n/**\n * Create a function for performing requests against a given host.\n *\n * @param baseUrl - Base URL of the host, i.e. protocol, port and domain name.\n * @param agentOptions - Options to use for creating the agent.\n * @param agent - Agent to use for performing requests.\n *\n * @internal\n */\nexport function createRequest(\n baseUrl: string,\n agentOptions: AgentOptions & RequestInterceptors,\n agent?: any\n): RequestFunction {\n const baseUrlParts = parseUrl(baseUrl) as Partial<UrlWithStringQuery>;\n if (!baseUrlParts.protocol) {\n throw new Error(`Invalid URL (no protocol): ${baseUrl}`);\n }\n const isTls = baseUrlParts.protocol === \"https:\";\n let socketPath: string | undefined;\n if (baseUrl.startsWith(`${baseUrlParts.protocol}//unix:`)) {\n if (!baseUrlParts.pathname) {\n throw new Error(\n `Unix socket URL must be in the format http://unix:/socket/path, http+unix:///socket/path or unix:///socket/path not ${baseUrl}`\n );\n }\n const i = baseUrlParts.pathname.indexOf(\":\");\n if (i === -1) {\n socketPath = baseUrlParts.pathname;\n delete baseUrlParts.pathname;\n } else {\n socketPath = baseUrlParts.pathname.slice(0, i);\n baseUrlParts.pathname = baseUrlParts.pathname.slice(i + 1);\n if (baseUrlParts.pathname === \"\") {\n delete baseUrlParts.pathname;\n }\n }\n }\n if (socketPath && !socketPath.replace(/\\//g, \"\").length) {\n throw new Error(`Invalid URL (empty unix socket path): ${baseUrl}`);\n }\n if (!agent) {\n const opts = omit(agentOptions, [\"before\", \"after\"]);\n if (isTls) agent = new HttpsAgent(opts);\n else agent = new HttpAgent(opts);\n }\n return Object.assign(\n function request(\n { method, url, headers, body, timeout }: RequestOptions,\n callback: Errback<ArangojsResponse>\n ) {\n let path = baseUrlParts.pathname\n ? url.pathname\n ? joinPath(baseUrlParts.pathname, url.pathname)\n : baseUrlParts.pathname\n : url.pathname;\n const search = url.search\n ? baseUrlParts.search\n ? `${baseUrlParts.search}&${url.search.slice(1)}`\n : url.search\n : baseUrlParts.search;\n if (search) path += search;\n if (body && !headers[\"content-length\"]) {\n headers[\"content-length\"] = String(Buffer.byteLength(body));\n }\n if (!headers[\"authorization\"]) {\n headers[\"authorization\"] = `Basic ${base64Encode(\n baseUrlParts.auth || \"root:\"\n )}`;\n }\n const options: ClientRequestArgs = { path, method, headers, agent };\n if (socketPath) {\n options.socketPath = socketPath;\n } else {\n options.host = baseUrlParts.hostname;\n options.port = baseUrlParts.port;\n }\n let called = false;\n try {\n const req = (isTls ? httpsRequest : httpRequest)(\n options,\n (res: IncomingMessage) => {\n const data: Buffer[] = [];\n res.on(\"data\", (chunk) => data.push(chunk as Buffer));\n res.on(\"end\", () => {\n const response = res as ArangojsResponse;\n response.request = req;\n response.body = Buffer.concat(data);\n if (called) return;\n called = true;\n if (agentOptions.after) {\n agentOptions.after(null, response);\n }\n callback(null, response);\n });\n }\n );\n if (timeout) {\n req.setTimeout(timeout);\n }\n req.on(\"timeout\", () => {\n req.abort();\n });\n req.on(\"error\", (err) => {\n const error = err as ArangojsError;\n error.request = req;\n error.toJSON = systemErrorToJSON;\n if (called) return;\n called = true;\n if (agentOptions.after) {\n agentOptions.after(error);\n }\n callback(error);\n });\n if (body) req.write(body);\n if (agentOptions.before) {\n agentOptions.before(req);\n }\n req.end();\n } catch (e: any) {\n if (called) return;\n called = true;\n setTimeout(() => {\n callback(e);\n }, 0);\n }\n },\n {\n close() {\n agent.destroy();\n },\n }\n );\n}\n"]}
1
+ {"version":3,"file":"request.node.js","sourceRoot":"","sources":["../../src/lib/request.node.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+BAOc;AACd,iCAAqE;AACrE,6BAA4D;AAG5D,iCAAsC;AAEtC,yCAAsC;AACtC,iCAA8B;AAE9B;;GAEG;AACH,SAAS,iBAAiB;IACxB,OAAO;QACL,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,OAAO,EAAE,IAAI,CAAC,OAAO;KACtB,CAAC;AACJ,CAAC;AAuCD;;GAEG;AACU,QAAA,SAAS,GAAG,KAAK,CAAC;AAE/B;;;;;;;;GAQG;AACH,SAAgB,aAAa,CAC3B,OAAe,EACf,YAAgD,EAChD,KAAW;IAEX,MAAM,YAAY,GAAG,IAAA,WAAQ,EAAC,OAAO,CAAgC,CAAC;IACtE,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,8B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,EAAE,CAAC;YACd,CAAC,CAAC,CAAC;YACH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;gBACtB,MAAM,KAAK,GAAG,GAAoB,CAAC;gBACnC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;gBACpB,KAAK,CAAC,MAAM,GAAG,iBAAiB,CAAC;gBACjC,IAAI,MAAM;oBAAE,OAAO;gBACnB,MAAM,GAAG,IAAI,CAAC;gBACd,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC;oBACvB,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBAC5B,CAAC;gBACD,QAAQ,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;YACH,IAAI,IAAI;gBAAE,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC1B,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;gBACxB,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC3B,CAAC;YACD,GAAG,CAAC,GAAG,EAAE,CAAC;QACZ,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,IAAI,MAAM;gBAAE,OAAO;YACnB,MAAM,GAAG,IAAI,CAAC;YACd,UAAU,CAAC,GAAG,EAAE;gBACd,QAAQ,CAAC,CAAC,CAAC,CAAC;YACd,CAAC,EAAE,CAAC,CAAC,CAAC;QACR,CAAC;IACH,CAAC,EACD;QACE,KAAK;YACH,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,CAAC;KACF,CACF,CAAC;AACJ,CAAC;AA5HD,sCA4HC","sourcesContent":["/**\n * Node.js implementation of the HTTP(S) request function.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport {\n Agent as HttpAgent,\n AgentOptions,\n ClientRequest,\n ClientRequestArgs,\n IncomingMessage,\n request as httpRequest,\n} from \"http\";\nimport { Agent as HttpsAgent, request as httpsRequest } from \"https\";\nimport { parse as parseUrl, UrlWithStringQuery } from \"url\";\nimport { Headers, RequestInterceptors } from \"../connection\";\nimport { SystemError } from \"../error\";\nimport { base64Encode } from \"./btoa\";\nimport { Errback } from \"./errback\";\nimport { joinPath } from \"./joinPath\";\nimport { omit } from \"./omit\";\n\n/**\n * @internal\n */\nfunction systemErrorToJSON(this: SystemError) {\n return {\n error: true,\n errno: this.errno,\n code: this.code,\n syscall: this.syscall,\n };\n}\n\n/**\n * @internal\n */\nexport interface ArangojsResponse extends IncomingMessage {\n request: ClientRequest;\n body?: any;\n arangojsHostUrl?: string;\n}\n\n/**\n * @internal\n */\nexport interface ArangojsError extends Error {\n request: ClientRequest;\n toJSON: () => Record<string, any>;\n}\n\n/**\n * @internal\n */\nexport type RequestOptions = {\n method: string;\n url: { pathname: string; search?: string };\n headers: Headers;\n body: any;\n expectBinary: boolean;\n timeout?: number;\n};\n\n/**\n * @internal\n */\nexport type RequestFunction = {\n (options: RequestOptions, cb: Errback<ArangojsResponse>): void;\n close?: () => void;\n};\n\n/**\n * @internal\n */\nexport const isBrowser = false;\n\n/**\n * Create a function for performing requests against a given host.\n *\n * @param baseUrl - Base URL of the host, i.e. protocol, port and domain name.\n * @param agentOptions - Options to use for creating the agent.\n * @param agent - Agent to use for performing requests.\n *\n * @internal\n */\nexport function createRequest(\n baseUrl: string,\n agentOptions: AgentOptions & RequestInterceptors,\n agent?: any\n): RequestFunction {\n const baseUrlParts = parseUrl(baseUrl) as Partial<UrlWithStringQuery>;\n if (!baseUrlParts.protocol) {\n throw new Error(`Invalid URL (no protocol): ${baseUrl}`);\n }\n const isTls = baseUrlParts.protocol === \"https:\";\n let socketPath: string | undefined;\n if (baseUrl.startsWith(`${baseUrlParts.protocol}//unix:`)) {\n if (!baseUrlParts.pathname) {\n throw new Error(\n `Unix socket URL must be in the format http://unix:/socket/path, http+unix:///socket/path or unix:///socket/path not ${baseUrl}`\n );\n }\n const i = baseUrlParts.pathname.indexOf(\":\");\n if (i === -1) {\n socketPath = baseUrlParts.pathname;\n delete baseUrlParts.pathname;\n } else {\n socketPath = baseUrlParts.pathname.slice(0, i);\n baseUrlParts.pathname = baseUrlParts.pathname.slice(i + 1);\n if (baseUrlParts.pathname === \"\") {\n delete baseUrlParts.pathname;\n }\n }\n }\n if (socketPath && !socketPath.replace(/\\//g, \"\").length) {\n throw new Error(`Invalid URL (empty unix socket path): ${baseUrl}`);\n }\n if (!agent) {\n const opts = omit(agentOptions, [\"before\", \"after\"]);\n if (isTls) agent = new HttpsAgent(opts);\n else agent = new HttpAgent(opts);\n }\n return Object.assign(\n function request(\n { method, url, headers, body, timeout }: RequestOptions,\n callback: Errback<ArangojsResponse>\n ) {\n let path = baseUrlParts.pathname\n ? url.pathname\n ? joinPath(baseUrlParts.pathname, url.pathname)\n : baseUrlParts.pathname\n : url.pathname;\n const search = url.search\n ? baseUrlParts.search\n ? `${baseUrlParts.search}&${url.search.slice(1)}`\n : url.search\n : baseUrlParts.search;\n if (search) path += search;\n if (body && !headers[\"content-length\"]) {\n headers[\"content-length\"] = String(Buffer.byteLength(body));\n }\n if (!headers[\"authorization\"]) {\n headers[\"authorization\"] = `Basic ${base64Encode(\n baseUrlParts.auth || \"root:\"\n )}`;\n }\n const options: ClientRequestArgs = { path, method, headers, agent };\n if (socketPath) {\n options.socketPath = socketPath;\n } else {\n options.host = baseUrlParts.hostname;\n options.port = baseUrlParts.port;\n }\n let called = false;\n try {\n const req = (isTls ? httpsRequest : httpRequest)(\n options,\n (res: IncomingMessage) => {\n const data: Buffer[] = [];\n res.on(\"data\", (chunk) => data.push(chunk as Buffer));\n res.on(\"end\", () => {\n const response = res as ArangojsResponse;\n response.request = req;\n response.body = Buffer.concat(data);\n if (called) return;\n called = true;\n if (agentOptions.after) {\n agentOptions.after(null, response);\n }\n callback(null, response);\n });\n }\n );\n if (timeout) {\n req.setTimeout(timeout);\n }\n req.on(\"timeout\", () => {\n req.abort();\n });\n req.on(\"error\", (err) => {\n const error = err as ArangojsError;\n error.request = req;\n error.toJSON = systemErrorToJSON;\n if (called) return;\n called = true;\n if (agentOptions.after) {\n agentOptions.after(error);\n }\n callback(error);\n });\n if (body) req.write(body);\n if (agentOptions.before) {\n agentOptions.before(req);\n }\n req.end();\n } catch (e: any) {\n if (called) return;\n called = true;\n setTimeout(() => {\n callback(e);\n }, 0);\n }\n },\n {\n close() {\n agent.destroy();\n },\n }\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"request.web.js","sourceRoot":"","sources":["../../src/lib/request.web.ts"],"names":[],"mappings":";AAAA,2BAA2B;;;AAU3B,iCAAsC;AAEtC,iCAA8B;AAM9B,+BAAwB;AAEX,QAAA,SAAS,GAAG,IAAI,CAAC;AAE9B;;GAEG;AACH,SAAS,WAAW;IAClB,OAAO;QACL,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,IAAI,CAAC,OAAO;KACtB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,aAAa,CAC3B,OAAe,EACf,YAA8C;IAE9C,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9B,MAAM,IAAI,GAAG,IAAA,mBAAY,EAAC,GAAG,IAAI,CAAC,QAAQ,IAAI,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IACzE,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACnB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACnB,MAAM,OAAO,GAAG,IAAA,WAAI,EAAC,YAAY,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IACnD,OAAO,SAAS,OAAO,CACrB,EACE,MAAM,EACN,GAAG,EAAE,MAAM,EACX,OAAO,EACP,IAAI,EACJ,OAAO,EACP,YAAY,GACG,EACjB,EAA6B;QAE7B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC3C,IAAI,MAAM,CAAC,MAAM,EAAE;YACjB,IAAI,CAAC,IAAI,CAAC,M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AAC;aAC9C;iBAAM;gBACL,MAAM,KAAK,GAAG,GAAoB,CAAC;gBACnC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;gBACpB,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC;gBAC3B,IAAI,OAAO,CAAC,KAAK,EAAE;oBACjB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBACtB;gBACD,QAAQ,CAAC,KAAK,CAAC,CAAC;aACjB;QACH,CAAC,CACF,CAAC;QACF,IAAI,OAAO,CAAC,MAAM,EAAE;YAClB,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SACrB;IACH,CAAC,CAAC;AACJ,CAAC;AArED,sCAqEC","sourcesContent":["/// <reference lib=\"dom\" />\n\n/**\n * Node.js implementation of the HTTP(S) request function.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport { RequestInterceptors, XhrOptions } from \"../connection\";\nimport { base64Encode } from \"./btoa\";\nimport { Errback } from \"./errback\";\nimport { omit } from \"./omit\";\nimport {\n ArangojsError,\n ArangojsResponse,\n RequestOptions\n} from \"./request.node\";\nimport xhr from \"./xhr\";\n\nexport const isBrowser = true;\n\n/**\n * @internal\n */\nfunction errorToJSON(this: Error) {\n return {\n error: true,\n message: this.message,\n };\n}\n\n/**\n * Create a function for performing requests against a given host.\n *\n * @param baseUrl - Base URL of the host, i.e. protocol, port and domain name.\n * @param agentOptions - Options to use for performing requests.\n *\n * @param baseUrl\n * @param agentOptions\n *\n * @internal\n */\nexport function createRequest(\n baseUrl: string,\n agentOptions: XhrOptions & RequestInterceptors\n) {\n const base = new URL(baseUrl);\n const auth = base64Encode(`${base.username || \"root\"}:${base.password}`);\n base.username = \"\";\n base.password = \"\";\n const options = omit(agentOptions, [\"maxSockets\"]);\n return function request(\n {\n method,\n url: reqUrl,\n headers,\n body,\n timeout,\n expectBinary,\n }: RequestOptions,\n cb: Errback<ArangojsResponse>\n ) {\n const url = new URL(reqUrl.pathname, base);\n if (reqUrl.search) {\n if (!base.search) url.search = reqUrl.search.slice(1);\n else url.search = `${base.search}&${reqUrl.search.slice(1)}`\n } else url.search = base.search;\n if (!headers[\"authorization\"]) {\n headers[\"authorization\"] = `Basic ${auth}`;\n }\n\n let callback: Errback<ArangojsResponse> = (err, res) => {\n callback = () => undefined;\n cb(err, res);\n };\n const req = xhr(\n {\n useXDR: true,\n withCredentials: true,\n ...options,\n responseType: expectBinary ? \"blob\" : \"text\",\n url: String(url),\n body,\n method,\n headers,\n timeout,\n },\n (err: Error | null, res?: any) => {\n if (!err) {\n const response = res as ArangojsResponse;\n response.request = req;\n if (!response.body) response.body = \"\";\n if (options.after) {\n options.after(null, response);\n }\n callback(null, response as ArangojsResponse);\n } else {\n const error = err as ArangojsError;\n error.request = req;\n error.toJSON = errorToJSON;\n if (options.after) {\n options.after(error);\n }\n callback(error);\n }\n }\n );\n if (options.before) {\n options.before(req);\n }\n };\n}\n"]}
1
+ {"version":3,"file":"request.web.js","sourceRoot":"","sources":["../../src/lib/request.web.ts"],"names":[],"mappings":";AAAA,2BAA2B;;;AAU3B,iCAAsC;AAEtC,iCAA8B;AAM9B,+BAAwB;AAEX,QAAA,SAAS,GAAG,IAAI,CAAC;AAE9B;;GAEG;AACH,SAAS,WAAW;IAClB,OAAO;QACL,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,IAAI,CAAC,OAAO;KACtB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,aAAa,CAC3B,OAAe,EACf,YAA8C;IAE9C,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9B,MAAM,IAAI,GAAG,IAAA,mBAAY,EAAC,GAAG,IAAI,CAAC,QAAQ,IAAI,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IACzE,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACnB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACnB,MAAM,OAAO,GAAG,IAAA,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E,EAAE;YAC/B,IAAI,CAAC,GAAG,EAAE,CAAC;gBACT,MAAM,QAAQ,GAAG,GAAuB,CAAC;gBACzC,QAAQ,CAAC,OAAO,GAAG,GAAG,CAAC;gBACvB,IAAI,CAAC,QAAQ,CAAC,IAAI;oBAAE,QAAQ,CAAC,IAAI,GAAG,EAAE,CAAC;gBACvC,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;oBAClB,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;gBAChC,CAAC;gBACD,QAAQ,CAAC,IAAI,EAAE,QAA4B,CAAC,CAAC;YAC/C,CAAC;iBAAM,CAAC;gBACN,MAAM,KAAK,GAAG,GAAoB,CAAC;gBACnC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;gBACpB,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC;gBAC3B,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;oBAClB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACvB,CAAC;gBACD,QAAQ,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC;QACH,CAAC,CACF,CAAC;QACF,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AArED,sCAqEC","sourcesContent":["/// <reference lib=\"dom\" />\n\n/**\n * Node.js implementation of the HTTP(S) request function.\n *\n * @packageDocumentation\n * @internal\n */\n\nimport { RequestInterceptors, XhrOptions } from \"../connection\";\nimport { base64Encode } from \"./btoa\";\nimport { Errback } from \"./errback\";\nimport { omit } from \"./omit\";\nimport {\n ArangojsError,\n ArangojsResponse,\n RequestOptions\n} from \"./request.node\";\nimport xhr from \"./xhr\";\n\nexport const isBrowser = true;\n\n/**\n * @internal\n */\nfunction errorToJSON(this: Error) {\n return {\n error: true,\n message: this.message,\n };\n}\n\n/**\n * Create a function for performing requests against a given host.\n *\n * @param baseUrl - Base URL of the host, i.e. protocol, port and domain name.\n * @param agentOptions - Options to use for performing requests.\n *\n * @param baseUrl\n * @param agentOptions\n *\n * @internal\n */\nexport function createRequest(\n baseUrl: string,\n agentOptions: XhrOptions & RequestInterceptors\n) {\n const base = new URL(baseUrl);\n const auth = base64Encode(`${base.username || \"root\"}:${base.password}`);\n base.username = \"\";\n base.password = \"\";\n const options = omit(agentOptions, [\"maxSockets\"]);\n return function request(\n {\n method,\n url: reqUrl,\n headers,\n body,\n timeout,\n expectBinary,\n }: RequestOptions,\n cb: Errback<ArangojsResponse>\n ) {\n const url = new URL(reqUrl.pathname, base);\n if (reqUrl.search) {\n if (!base.search) url.search = reqUrl.search.slice(1);\n else url.search = `${base.search}&${reqUrl.search.slice(1)}`\n } else url.search = base.search;\n if (!headers[\"authorization\"]) {\n headers[\"authorization\"] = `Basic ${auth}`;\n }\n\n let callback: Errback<ArangojsResponse> = (err, res) => {\n callback = () => undefined;\n cb(err, res);\n };\n const req = xhr(\n {\n useXDR: true,\n withCredentials: true,\n ...options,\n responseType: expectBinary ? \"blob\" : \"text\",\n url: String(url),\n body,\n method,\n headers,\n timeout,\n },\n (err: Error | null, res?: any) => {\n if (!err) {\n const response = res as ArangojsResponse;\n response.request = req;\n if (!response.body) response.body = \"\";\n if (options.after) {\n options.after(null, response);\n }\n callback(null, response as ArangojsResponse);\n } else {\n const error = err as ArangojsError;\n error.request = req;\n error.toJSON = errorToJSON;\n if (options.after) {\n options.after(error);\n }\n callback(error);\n }\n }\n );\n if (options.before) {\n options.before(req);\n }\n };\n}\n"]}
package/lib/xhr.d.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  * @packageDocumentation
5
5
  * @internal
6
6
  */
7
+ /// <reference types="node" />
7
8
  import { ClientRequest } from "http";
8
9
  import { Errback } from "./errback";
9
10
  /**
package/lib/xhr.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"xhr.d.ts","sourceRoot":"","sources":["../../src/lib/xhr.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;kCAGQ,GAAG,MACR,QAAQ,GAAG,CAAC,KACb,aAAa;AAHlB,wBAGmB"}
1
+ {"version":3,"file":"xhr.d.ts","sourceRoot":"","sources":["../../src/lib/xhr.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;kCAGQ,GAAG,MACR,QAAQ,GAAG,CAAC,KACb,aAAa;AAHlB,wBAGmB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arangojs",
3
- "version": "8.7.0",
3
+ "version": "8.8.1",
4
4
  "engines": {
5
5
  "node": ">=14"
6
6
  },
package/transaction.d.ts CHANGED
@@ -8,7 +8,7 @@ export declare function isArangoTransaction(transaction: any): transaction is Tr
8
8
  /**
9
9
  * Options for how the transaction should be committed.
10
10
  */
11
- export declare type TransactionCommitOptions = {
11
+ export type TransactionCommitOptions = {
12
12
  /**
13
13
  * If set to `true`, the request will explicitly permit ArangoDB to return a
14
14
  * potentially dirty or stale result and arangojs will load balance the
@@ -19,7 +19,7 @@ export declare type TransactionCommitOptions = {
19
19
  /**
20
20
  * Options for how the transaction should be aborted.
21
21
  */
22
- export declare type TransactionAbortOptions = {
22
+ export type TransactionAbortOptions = {
23
23
  /**
24
24
  * If set to `true`, the request will explicitly permit ArangoDB to return a
25
25
  * potentially dirty or stale result and arangojs will load balance the
@@ -32,7 +32,7 @@ export declare type TransactionAbortOptions = {
32
32
  *
33
33
  * See also {@link database.TransactionDetails}.
34
34
  */
35
- export declare type TransactionStatus = {
35
+ export type TransactionStatus = {
36
36
  /**
37
37
  * Unique identifier of the transaction.
38
38
  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B,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0LG;IACH,IAAI,CAAI,QAA0B;QAChC,MAAM,IAAI,GAAI,IAAI,CAAC,GAAW,CAAC,WAAyB,CAAC;QACzD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/B,IAAI;YACF,MAAM,OAAO,GAAG,QAAQ,EAAE,CAAC;YAC3B,IAAI,CAAC,OAAO,EAAE;gBACZ,MAAM,IAAI,KAAK,CACb,6EAA6E,CAC9E,CAAC;aACH;YACD,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;SACjC;gBAAS;YACR,IAAI,CAAC,kBAAkB,EAAE,CAAC;SAC3B;IACH,CAAC;CACF;AA3UD,kCA2UC","sourcesContent":["/**\n * ```ts\n * import type { Transaction } from \"arangojs/transaction\";\n * ```\n *\n * The \"transaction\" module provides transaction related types and interfaces\n * for TypeScript.\n *\n * @packageDocumentation\n */\nimport { Connection } from \"./connection\";\nimport { Database } from \"./database\";\nimport { isArangoError } from \"./error\";\nimport { TRANSACTION_NOT_FOUND } from \"./lib/codes\";\n\n/**\n * Indicates whether the given value represents a {@link Transaction}.\n *\n * @param transaction - A value that might be a transaction.\n */\nexport function isArangoTransaction(\n transaction: any\n): transaction is Transaction {\n return Boolean(transaction && transaction.isArangoTransaction);\n}\n\n/**\n * Options for how the transaction should be committed.\n */\nexport type TransactionCommitOptions = {\n /**\n * If set to `true`, the request will explicitly permit ArangoDB to return a\n * potentially dirty or stale result and arangojs will load balance the\n * request without distinguishing between leaders and followers.\n */\n allowDirtyRead?: boolean;\n};\n\n/**\n * Options for how the transaction should be aborted.\n */\nexport type TransactionAbortOptions = {\n /**\n * If set to `true`, the request will explicitly permit ArangoDB to return a\n * potentially dirty or stale result and arangojs will load balance the\n * request without distinguishing between leaders and followers.\n */\n allowDirtyRead?: boolean;\n};\n\n/**\n * Status of a given transaction.\n *\n * See also {@link database.TransactionDetails}.\n */\nexport type TransactionStatus = {\n /**\n * Unique identifier of the transaction.\n */\n id: string;\n /**\n * Status of the transaction.\n */\n status: \"running\" | \"committed\" | \"aborted\";\n};\n\n/**\n * Represents a streaming transaction in a {@link database.Database}.\n */\nexport class Transaction {\n protected _db: Database;\n protected _id: string;\n\n /**\n * @internal\n */\n constructor(db: Database, id: string) {\n this._db = db;\n this._id = id;\n }\n\n /**\n * @internal\n *\n * Indicates that this object represents an ArangoDB transaction.\n */\n get isArangoTransaction(): true {\n return true;\n }\n\n /**\n * Unique identifier of this transaction.\n *\n * See {@link database.Database#transaction}.\n */\n get id() {\n return this._id;\n }\n\n /**\n * Checks whether the transaction exists.\n *\n * @example\n * ```js\n * const db = new Database();\n * const trx = db.transaction(\"some-transaction\");\n * const result = await trx.exists();\n * // result indicates whether the transaction exists\n * ```\n */\n async exists(): Promise<boolean> {\n try {\n await this.get();\n return true;\n } catch (err: any) {\n if (isArangoError(err) && err.errorNum === TRANSACTION_NOT_FOUND) {\n return false;\n }\n throw err;\n }\n }\n\n /**\n * Retrieves general information about the transaction.\n *\n * @example\n * ```js\n * const db = new Database();\n * const col = db.collection(\"some-collection\");\n * const trx = db.beginTransaction(col);\n * await trx.step(() => col.save({ hello: \"world\" }));\n * const info = await trx.get();\n * // the transaction exists\n * ```\n */\n get(): Promise<TransactionStatus> {\n return this._db.request(\n {\n path: `/_api/transaction/${encodeURIComponent(this.id)}`,\n },\n (res) => res.body.result\n );\n }\n\n /**\n * Attempts to commit the transaction to the databases.\n *\n * @param options - Options for comitting the transaction.\n *\n * @example\n * ```js\n * const db = new Database();\n * const col = db.collection(\"some-collection\");\n * const trx = db.beginTransaction(col);\n * await trx.step(() => col.save({ hello: \"world\" }));\n * const result = await trx.commit();\n * // result indicates the updated transaction status\n * ```\n */\n commit(options: TransactionCommitOptions = {}): Promise<TransactionStatus> {\n const { allowDirtyRead = undefined } = options;\n return this._db.request(\n {\n method: \"PUT\",\n path: `/_api/transaction/${encodeURIComponent(this.id)}`,\n allowDirtyRead,\n },\n (res) => res.body.result\n );\n }\n\n /**\n * Attempts to abort the transaction to the databases.\n *\n * @param options - Options for aborting the transaction.\n *\n * @example\n * ```js\n * const db = new Database();\n * const col = db.collection(\"some-collection\");\n * const trx = db.beginTransaction(col);\n * await trx.step(() => col.save({ hello: \"world\" }));\n * const result = await trx.abort();\n * // result indicates the updated transaction status\n * ```\n */\n abort(options: TransactionAbortOptions = {}): Promise<TransactionStatus> {\n const { allowDirtyRead = undefined } = options;\n return this._db.request(\n {\n method: \"DELETE\",\n path: `/_api/transaction/${encodeURIComponent(this.id)}`,\n allowDirtyRead,\n },\n (res) => res.body.result\n );\n }\n\n /**\n * Executes the given function locally as a single step of the transaction.\n *\n * @param T - Type of the callback's returned promise.\n * @param callback - Callback function returning a promise.\n *\n * **Warning**: The callback function should wrap a single call of an async\n * arangojs method (e.g. a method on a `Collection` object of a collection\n * that is involved in the transaction or the `db.query` method).\n * If the callback function is async, only the first promise-returning (or\n * async) method call will be executed as part of the transaction. See the\n * examples below for how to avoid common mistakes when using this method.\n *\n * **Note**: Avoid defining the callback as an async function if possible\n * as arangojs will throw an error if the callback did not return a promise.\n * Async functions will return an empty promise by default, making it harder\n * to notice if you forgot to return something from the callback.\n *\n * **Note**: Although almost anything can be wrapped in a callback and passed\n * to this method, that does not guarantee ArangoDB can actually do it in a\n * transaction. Refer to the ArangoDB documentation if you are unsure whether\n * a given operation can be executed as part of a transaction. Generally any\n * modification or retrieval of data is eligible but modifications of\n * collections or databases are not.\n *\n * @example\n * ```js\n * const db = new Database();\n * const vertices = db.collection(\"vertices\");\n * const edges = db.collection(\"edges\");\n * const trx = await db.beginTransaction({ write: [vertices, edges] });\n *\n * // The following code will be part of the transaction\n * const left = await trx.step(() => vertices.save({ label: \"left\" }));\n * const right = await trx.step(() => vertices.save({ label: \"right\" }));\n *\n * // Results from preceding actions can be used normally\n * await trx.step(() => edges.save({\n * _from: left._id,\n * _to: right._id,\n * data: \"potato\"\n * }));\n *\n * // Transaction must be committed for changes to take effected\n * // Always call either trx.commit or trx.abort to end a transaction\n * await trx.commit();\n * ```\n *\n * @example\n * ```js\n * // BAD! If the callback is an async function it must only use await once!\n * await trx.step(async () => {\n * await collection.save(data);\n * await collection.save(moreData); // WRONG\n * });\n *\n * // BAD! Callback function must use only one arangojs call!\n * await trx.step(() => {\n * return collection.save(data)\n * .then(() => collection.save(moreData)); // WRONG\n * });\n *\n * // BETTER: Wrap every arangojs method call that should be part of the\n * // transaction in a separate `trx.step` call\n * await trx.step(() => collection.save(data));\n * await trx.step(() => collection.save(moreData));\n * ```\n *\n * @example\n * ```js\n * // BAD! If the callback is an async function it must not await before\n * // calling an arangojs method!\n * await trx.step(async () => {\n * await doSomethingElse();\n * return collection.save(data); // WRONG\n * });\n *\n * // BAD! Any arangojs inside the callback must not happen inside a promise\n * // method!\n * await trx.step(() => {\n * return doSomethingElse()\n * .then(() => collection.save(data)); // WRONG\n * });\n *\n * // BETTER: Perform any async logic needed outside the `trx.step` call\n * await doSomethingElse();\n * await trx.step(() => collection.save(data));\n *\n * // OKAY: You can perform async logic in the callback after the arangojs\n * // method call as long as it does not involve additional arangojs method\n * // calls, but this makes it easy to make mistakes later\n * await trx.step(async () => {\n * await collection.save(data);\n * await doSomethingDifferent(); // no arangojs method calls allowed\n * });\n * ```\n *\n * @example\n * ```js\n * // BAD! The callback should not use any functions that themselves use any\n * // arangojs methods!\n * async function saveSomeData() {\n * await collection.save(data);\n * await collection.save(moreData);\n * }\n * await trx.step(() => saveSomeData()); // WRONG\n *\n * // BETTER: Pass the transaction to functions that need to call arangojs\n * // methods inside a transaction\n * async function saveSomeData(trx) {\n * await trx.step(() => collection.save(data));\n * await trx.step(() => collection.save(moreData));\n * }\n * await saveSomeData(); // no `trx.step` call needed\n * ```\n *\n * @example\n * ```js\n * // BAD! You must wait for the promise to resolve (or await on the\n * // `trx.step` call) before calling `trx.step` again!\n * trx.step(() => collection.save(data)); // WRONG\n * await trx.step(() => collection.save(moreData));\n *\n * // BAD! The trx.step callback can not make multiple calls to async arangojs\n * // methods, not even using Promise.all!\n * await trx.step(() => Promise.all([ // WRONG\n * collection.save(data),\n * collection.save(moreData),\n * ]));\n *\n * // BAD! Multiple `trx.step` calls can not run in parallel!\n * await Promise.all([ // WRONG\n * trx.step(() => collection.save(data)),\n * trx.step(() => collection.save(moreData)),\n * ]));\n *\n * // BETTER: Always call `trx.step` sequentially, one after the other\n * await trx.step(() => collection.save(data));\n * await trx.step(() => collection.save(moreData));\n *\n * // OKAY: The then callback can be used if async/await is not available\n * trx.step(() => collection.save(data))\n * .then(() => trx.step(() => collection.save(moreData)));\n * ```\n *\n * @example\n * ```js\n * // BAD! The callback will return an empty promise that resolves before\n * // the inner arangojs method call has even talked to ArangoDB!\n * await trx.step(async () => {\n * collection.save(data); // WRONG\n * });\n *\n * // BETTER: Use an arrow function so you don't forget to return\n * await trx.step(() => collection.save(data));\n *\n * // OKAY: Remember to always return when using a function body\n * await trx.step(() => {\n * return collection.save(data); // easy to forget!\n * });\n *\n * // OKAY: You do not have to use arrow functions but it helps\n * await trx.step(function () {\n * return collection.save(data);\n * });\n * ```\n *\n * @example\n * ```js\n * // BAD! You can not pass promises instead of a callback!\n * await trx.step(collection.save(data)); // WRONG\n *\n * // BETTER: Wrap the code in a function and pass the function instead\n * await trx.step(() => collection.save(data));\n * ```\n *\n * @example\n * ```js\n * // WORSE: Calls to non-async arangojs methods don't need to be performed\n * // as part of a transaction\n * const collection = await trx.step(() => db.collection(\"my-documents\"));\n *\n * // BETTER: If an arangojs method is not async and doesn't return promises,\n * // call it without `trx.step`\n * const collection = db.collection(\"my-documents\");\n * ```\n */\n step<T>(callback: () => Promise<T>): Promise<T> {\n const conn = (this._db as any)._connection as Connection;\n conn.setTransactionId(this.id);\n try {\n const promise = callback();\n if (!promise) {\n throw new Error(\n \"Transaction callback was not an async function or did not return a promise!\"\n );\n }\n return Promise.resolve(promise);\n } finally {\n conn.clearTransactionId();\n }\n }\n}\n"]}
1
+ {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":";;;AAYA,mCAAwC;AACxC,uCAAoD;AAEpD;;;;GAIG;AACH,SAAgB,mBAAmB,CACjC,WAAgB;IAEhB,OAAO,OAAO,CAAC,WAAW,IAAI,WAAW,CAAC,mBAAmB,CAAC,CAAC;AACjE,CAAC;AAJD,kDAIC;AA0CD;;GAEG;AACH,MAAa,WAAW;IAItB;;OAEG;IACH,YAAY,EAAY,EAAE,EAAU;QAClC,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACH,IAAI,mBAAmB;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,MAAM;QACV,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,IAAA,qBAAa,EAAC,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,KAAK,6BAAqB,EAAE,CAAC;gBACjE,OAAO,KAAK,CAAC;YACf,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,GAAG;QACD,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CACrB;YACE,IAAI,EAAE,qBAAqB,kBAAkB,CAAC,IAAI,CAAC,EAA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IAAI,CAAC;YACH,MAAM,OAAO,GAAG,QAAQ,EAAE,CAAC;YAC3B,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CACb,6EAA6E,CAC9E,CAAC;YACJ,CAAC;YACD,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC5B,CAAC;IACH,CAAC;CACF;AA3UD,kCA2UC","sourcesContent":["/**\n * ```ts\n * import type { Transaction } from \"arangojs/transaction\";\n * ```\n *\n * The \"transaction\" module provides transaction related types and interfaces\n * for TypeScript.\n *\n * @packageDocumentation\n */\nimport { Connection } from \"./connection\";\nimport { Database } from \"./database\";\nimport { isArangoError } from \"./error\";\nimport { TRANSACTION_NOT_FOUND } from \"./lib/codes\";\n\n/**\n * Indicates whether the given value represents a {@link Transaction}.\n *\n * @param transaction - A value that might be a transaction.\n */\nexport function isArangoTransaction(\n transaction: any\n): transaction is Transaction {\n return Boolean(transaction && transaction.isArangoTransaction);\n}\n\n/**\n * Options for how the transaction should be committed.\n */\nexport type TransactionCommitOptions = {\n /**\n * If set to `true`, the request will explicitly permit ArangoDB to return a\n * potentially dirty or stale result and arangojs will load balance the\n * request without distinguishing between leaders and followers.\n */\n allowDirtyRead?: boolean;\n};\n\n/**\n * Options for how the transaction should be aborted.\n */\nexport type TransactionAbortOptions = {\n /**\n * If set to `true`, the request will explicitly permit ArangoDB to return a\n * potentially dirty or stale result and arangojs will load balance the\n * request without distinguishing between leaders and followers.\n */\n allowDirtyRead?: boolean;\n};\n\n/**\n * Status of a given transaction.\n *\n * See also {@link database.TransactionDetails}.\n */\nexport type TransactionStatus = {\n /**\n * Unique identifier of the transaction.\n */\n id: string;\n /**\n * Status of the transaction.\n */\n status: \"running\" | \"committed\" | \"aborted\";\n};\n\n/**\n * Represents a streaming transaction in a {@link database.Database}.\n */\nexport class Transaction {\n protected _db: Database;\n protected _id: string;\n\n /**\n * @internal\n */\n constructor(db: Database, id: string) {\n this._db = db;\n this._id = id;\n }\n\n /**\n * @internal\n *\n * Indicates that this object represents an ArangoDB transaction.\n */\n get isArangoTransaction(): true {\n return true;\n }\n\n /**\n * Unique identifier of this transaction.\n *\n * See {@link database.Database#transaction}.\n */\n get id() {\n return this._id;\n }\n\n /**\n * Checks whether the transaction exists.\n *\n * @example\n * ```js\n * const db = new Database();\n * const trx = db.transaction(\"some-transaction\");\n * const result = await trx.exists();\n * // result indicates whether the transaction exists\n * ```\n */\n async exists(): Promise<boolean> {\n try {\n await this.get();\n return true;\n } catch (err: any) {\n if (isArangoError(err) && err.errorNum === TRANSACTION_NOT_FOUND) {\n return false;\n }\n throw err;\n }\n }\n\n /**\n * Retrieves general information about the transaction.\n *\n * @example\n * ```js\n * const db = new Database();\n * const col = db.collection(\"some-collection\");\n * const trx = db.beginTransaction(col);\n * await trx.step(() => col.save({ hello: \"world\" }));\n * const info = await trx.get();\n * // the transaction exists\n * ```\n */\n get(): Promise<TransactionStatus> {\n return this._db.request(\n {\n path: `/_api/transaction/${encodeURIComponent(this.id)}`,\n },\n (res) => res.body.result\n );\n }\n\n /**\n * Attempts to commit the transaction to the databases.\n *\n * @param options - Options for comitting the transaction.\n *\n * @example\n * ```js\n * const db = new Database();\n * const col = db.collection(\"some-collection\");\n * const trx = db.beginTransaction(col);\n * await trx.step(() => col.save({ hello: \"world\" }));\n * const result = await trx.commit();\n * // result indicates the updated transaction status\n * ```\n */\n commit(options: TransactionCommitOptions = {}): Promise<TransactionStatus> {\n const { allowDirtyRead = undefined } = options;\n return this._db.request(\n {\n method: \"PUT\",\n path: `/_api/transaction/${encodeURIComponent(this.id)}`,\n allowDirtyRead,\n },\n (res) => res.body.result\n );\n }\n\n /**\n * Attempts to abort the transaction to the databases.\n *\n * @param options - Options for aborting the transaction.\n *\n * @example\n * ```js\n * const db = new Database();\n * const col = db.collection(\"some-collection\");\n * const trx = db.beginTransaction(col);\n * await trx.step(() => col.save({ hello: \"world\" }));\n * const result = await trx.abort();\n * // result indicates the updated transaction status\n * ```\n */\n abort(options: TransactionAbortOptions = {}): Promise<TransactionStatus> {\n const { allowDirtyRead = undefined } = options;\n return this._db.request(\n {\n method: \"DELETE\",\n path: `/_api/transaction/${encodeURIComponent(this.id)}`,\n allowDirtyRead,\n },\n (res) => res.body.result\n );\n }\n\n /**\n * Executes the given function locally as a single step of the transaction.\n *\n * @param T - Type of the callback's returned promise.\n * @param callback - Callback function returning a promise.\n *\n * **Warning**: The callback function should wrap a single call of an async\n * arangojs method (e.g. a method on a `Collection` object of a collection\n * that is involved in the transaction or the `db.query` method).\n * If the callback function is async, only the first promise-returning (or\n * async) method call will be executed as part of the transaction. See the\n * examples below for how to avoid common mistakes when using this method.\n *\n * **Note**: Avoid defining the callback as an async function if possible\n * as arangojs will throw an error if the callback did not return a promise.\n * Async functions will return an empty promise by default, making it harder\n * to notice if you forgot to return something from the callback.\n *\n * **Note**: Although almost anything can be wrapped in a callback and passed\n * to this method, that does not guarantee ArangoDB can actually do it in a\n * transaction. Refer to the ArangoDB documentation if you are unsure whether\n * a given operation can be executed as part of a transaction. Generally any\n * modification or retrieval of data is eligible but modifications of\n * collections or databases are not.\n *\n * @example\n * ```js\n * const db = new Database();\n * const vertices = db.collection(\"vertices\");\n * const edges = db.collection(\"edges\");\n * const trx = await db.beginTransaction({ write: [vertices, edges] });\n *\n * // The following code will be part of the transaction\n * const left = await trx.step(() => vertices.save({ label: \"left\" }));\n * const right = await trx.step(() => vertices.save({ label: \"right\" }));\n *\n * // Results from preceding actions can be used normally\n * await trx.step(() => edges.save({\n * _from: left._id,\n * _to: right._id,\n * data: \"potato\"\n * }));\n *\n * // Transaction must be committed for changes to take effected\n * // Always call either trx.commit or trx.abort to end a transaction\n * await trx.commit();\n * ```\n *\n * @example\n * ```js\n * // BAD! If the callback is an async function it must only use await once!\n * await trx.step(async () => {\n * await collection.save(data);\n * await collection.save(moreData); // WRONG\n * });\n *\n * // BAD! Callback function must use only one arangojs call!\n * await trx.step(() => {\n * return collection.save(data)\n * .then(() => collection.save(moreData)); // WRONG\n * });\n *\n * // BETTER: Wrap every arangojs method call that should be part of the\n * // transaction in a separate `trx.step` call\n * await trx.step(() => collection.save(data));\n * await trx.step(() => collection.save(moreData));\n * ```\n *\n * @example\n * ```js\n * // BAD! If the callback is an async function it must not await before\n * // calling an arangojs method!\n * await trx.step(async () => {\n * await doSomethingElse();\n * return collection.save(data); // WRONG\n * });\n *\n * // BAD! Any arangojs inside the callback must not happen inside a promise\n * // method!\n * await trx.step(() => {\n * return doSomethingElse()\n * .then(() => collection.save(data)); // WRONG\n * });\n *\n * // BETTER: Perform any async logic needed outside the `trx.step` call\n * await doSomethingElse();\n * await trx.step(() => collection.save(data));\n *\n * // OKAY: You can perform async logic in the callback after the arangojs\n * // method call as long as it does not involve additional arangojs method\n * // calls, but this makes it easy to make mistakes later\n * await trx.step(async () => {\n * await collection.save(data);\n * await doSomethingDifferent(); // no arangojs method calls allowed\n * });\n * ```\n *\n * @example\n * ```js\n * // BAD! The callback should not use any functions that themselves use any\n * // arangojs methods!\n * async function saveSomeData() {\n * await collection.save(data);\n * await collection.save(moreData);\n * }\n * await trx.step(() => saveSomeData()); // WRONG\n *\n * // BETTER: Pass the transaction to functions that need to call arangojs\n * // methods inside a transaction\n * async function saveSomeData(trx) {\n * await trx.step(() => collection.save(data));\n * await trx.step(() => collection.save(moreData));\n * }\n * await saveSomeData(); // no `trx.step` call needed\n * ```\n *\n * @example\n * ```js\n * // BAD! You must wait for the promise to resolve (or await on the\n * // `trx.step` call) before calling `trx.step` again!\n * trx.step(() => collection.save(data)); // WRONG\n * await trx.step(() => collection.save(moreData));\n *\n * // BAD! The trx.step callback can not make multiple calls to async arangojs\n * // methods, not even using Promise.all!\n * await trx.step(() => Promise.all([ // WRONG\n * collection.save(data),\n * collection.save(moreData),\n * ]));\n *\n * // BAD! Multiple `trx.step` calls can not run in parallel!\n * await Promise.all([ // WRONG\n * trx.step(() => collection.save(data)),\n * trx.step(() => collection.save(moreData)),\n * ]));\n *\n * // BETTER: Always call `trx.step` sequentially, one after the other\n * await trx.step(() => collection.save(data));\n * await trx.step(() => collection.save(moreData));\n *\n * // OKAY: The then callback can be used if async/await is not available\n * trx.step(() => collection.save(data))\n * .then(() => trx.step(() => collection.save(moreData)));\n * ```\n *\n * @example\n * ```js\n * // BAD! The callback will return an empty promise that resolves before\n * // the inner arangojs method call has even talked to ArangoDB!\n * await trx.step(async () => {\n * collection.save(data); // WRONG\n * });\n *\n * // BETTER: Use an arrow function so you don't forget to return\n * await trx.step(() => collection.save(data));\n *\n * // OKAY: Remember to always return when using a function body\n * await trx.step(() => {\n * return collection.save(data); // easy to forget!\n * });\n *\n * // OKAY: You do not have to use arrow functions but it helps\n * await trx.step(function () {\n * return collection.save(data);\n * });\n * ```\n *\n * @example\n * ```js\n * // BAD! You can not pass promises instead of a callback!\n * await trx.step(collection.save(data)); // WRONG\n *\n * // BETTER: Wrap the code in a function and pass the function instead\n * await trx.step(() => collection.save(data));\n * ```\n *\n * @example\n * ```js\n * // WORSE: Calls to non-async arangojs methods don't need to be performed\n * // as part of a transaction\n * const collection = await trx.step(() => db.collection(\"my-documents\"));\n *\n * // BETTER: If an arangojs method is not async and doesn't return promises,\n * // call it without `trx.step`\n * const collection = db.collection(\"my-documents\");\n * ```\n */\n step<T>(callback: () => Promise<T>): Promise<T> {\n const conn = (this._db as any)._connection as Connection;\n conn.setTransactionId(this.id);\n try {\n const promise = callback();\n if (!promise) {\n throw new Error(\n \"Transaction callback was not an async function or did not return a promise!\"\n );\n }\n return Promise.resolve(promise);\n } finally {\n conn.clearTransactionId();\n }\n }\n}\n"]}