Socket
Socket
Sign inDemoInstall

arangojs

Package Overview
Dependencies
Maintainers
4
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arangojs - npm Package Compare versions

Comparing version 7.8.0 to 8.0.0-rc.1

lib/querystringify.d.ts

784

analyzer.d.ts

@@ -11,3 +11,3 @@ /**

*/
import { ArangoResponseMetadata } from "./connection";
import { ArangoApiResponse } from "./connection";
import { Database } from "./database";

@@ -23,27 +23,11 @@ /**

*/
export declare type AnalyzerFeature = "frequency" | "norm" | "position";
export declare type AnalyzerFeature = "frequency" | "norm" | "position" | "offset";
/**
* An object describing an Analyzer.
*/
export declare type AnalyzerDescription = AnalyzerInfo & {
name: string;
features: AnalyzerFeature[];
};
/**
* Options for creating an Analyzer.
*/
export declare type CreateAnalyzerOptions = AnalyzerInfo & {
/**
* Features to enable for this Analyzer.
*/
features?: AnalyzerFeature[];
};
/**
* Analyzer type and its type-specific properties.
*/
export declare type AnalyzerInfo = IdentityAnalyzerInfo | DelimiterAnalyzerInfo | StemAnalyzerInfo | NormAnalyzerInfo | NgramAnalyzerInfo | TextAnalyzerInfo | PipelineAnalyzer | AqlAnalyzer | GeoJsonAnalyzer | GeoPointAnalyzer | StopwordsAnalyzer | SegmentationAnalyzer | CollationAnalyzer;
export declare type CreateAnalyzerOptions = CreateIdentityAnalyzerOptions | CreateDelimiterAnalyzerOptions | CreateStemAnalyzerOptions | CreateNormAnalyzerOptions | CreateNgramAnalyzerOptions | CreateTextAnalyzerOptions | CreateSegmentationAnalyzerOptions | CreateAqlAnalyzerOptions | CreatePipelineAnalyzerOptions | CreateStopwordsAnalyzerOptions | CreateCollationAnalyzerOptions | CreateMinHashAnalyzerOptions | CreateClassificationAnalyzerOptions | CreateNearestNeighborsAnalyzerOptions | CreateGeoJsonAnalyzerOptions | CreateGeoPointAnalyzerOptions;
/**
* Analyzer type and type-specific properties for an Identity Analyzer.
* Options for creating an Identity Analyzer.
*/
export declare type IdentityAnalyzerInfo = {
export declare type CreateIdentityAnalyzerOptions = {
/**

@@ -54,2 +38,6 @@ * Type of the Analyzer.

/**
* Features to enable for this Analyzer.
*/
features?: AnalyzerFeature[];
/**
* Additional properties for the Analyzer.

@@ -59,8 +47,8 @@ *

*/
properties?: null;
properties?: Record<string, never>;
};
/**
* Analyzer type and type-specific properties for a Delimiter Analyzer.
* Options for creating a Delimiter Analyzer.
*/
export declare type DelimiterAnalyzerInfo = {
export declare type CreateDelimiterAnalyzerOptions = {
/**

@@ -71,2 +59,6 @@ * Type of the Analyzer.

/**
* Features to enable for this Analyzer.
*/
features?: AnalyzerFeature[];
/**
* Additional properties for the Analyzer.

@@ -82,5 +74,5 @@ *

/**
* Analyzer type and type-specific properties for a Stem Analyzer.
* Options for creating a Stem Analyzer.
*/
export declare type StemAnalyzerInfo = {
export declare type CreateStemAnalyzerOptions = {
/**

@@ -91,2 +83,6 @@ * Type of the Analyzer.

/**
* Features to enable for this Analyzer.
*/
features?: AnalyzerFeature[];
/**
* Additional properties for the Analyzer.

@@ -103,273 +99,418 @@ *

/**
* Properties of a Norm Analyzer.
* Options for creating a Norm Analyzer.
*/
export declare type NormAnalyzerProperties = {
export declare type CreateNormAnalyzerOptions = {
/**
* Text locale.
*
* Format: `language[_COUNTRY][.encoding][@variant]`
* Type of the Analyzer.
*/
locale: string;
type: "norm";
/**
* Case conversion.
*
* Default: `"lower"`
* Features to enable for this Analyzer.
*/
case?: "lower" | "none" | "upper";
features?: AnalyzerFeature[];
/**
* Preserve accents in returned words.
*
* Default: `false`
* Additional properties for the Analyzer.
*/
accent?: boolean;
properties: {
/**
* Text locale.
*
* Format: `language[_COUNTRY][.encoding][@variant]`
*/
locale: string;
/**
* Case conversion.
*
* Default: `"lower"`
*/
case?: "lower" | "none" | "upper";
/**
* Preserve accents in returned words.
*
* Default: `false`
*/
accent?: boolean;
};
};
/**
* Analyzer type and type-specific properties for a Norm Analyzer.
* Options for creating an Ngram Analyzer.
*/
export declare type NormAnalyzerInfo = {
export declare type CreateNgramAnalyzerOptions = {
/**
* Type of the Analyzer.
*/
type: "norm";
type: "ngram";
/**
* Features to enable for this Analyzer.
*/
features?: AnalyzerFeature[];
/**
* Additional properties for the Analyzer.
*/
properties: NormAnalyzerProperties;
properties: {
/**
* Maximum n-gram length.
*/
max: number;
/**
* Minimum n-gram length.
*/
min: number;
/**
* Output the original value as well.
*/
preserveOriginal: boolean;
};
};
/**
* Properties of an Ngram Analyzer.
* Options for creating a Text Analyzer.
*/
export declare type NgramAnalyzerProperties = {
export declare type CreateTextAnalyzerOptions = {
/**
* Maximum n-gram length.
* Type of the Analyzer.
*/
max: number;
type: "text";
/**
* Minimum n-gram length.
* Features to enable for this Analyzer.
*/
min: number;
features?: AnalyzerFeature[];
/**
* Output the original value as well.
* Additional properties for the Analyzer.
*/
preserveOriginal: boolean;
properties: {
/**
* Text locale.
*
* Format: `language[_COUNTRY][.encoding][@variant]`
*/
locale: string;
/**
* Case conversion.
*
* Default: `"lower"`
*/
case?: "lower" | "none" | "upper";
/**
* Words to omit from result.
*
* Defaults to the words loaded from the file at `stopwordsPath`.
*/
stopwords?: string[];
/**
* Path with a `language` sub-directory containing files with words to omit.
*
* Defaults to the path specified in the server-side environment variable
* `IRESEARCH_TEXT_STOPWORD_PATH` or the current working directory of the
* ArangoDB process.
*/
stopwordsPath?: string;
/**
* Preserve accents in returned words.
*
* Default: `false`
*/
accent?: boolean;
/**
* Apply stemming on returned words.
*
* Default: `true`
*/
stemming?: boolean;
/**
* If present, then edge n-grams are generated for each token (word).
*/
edgeNgram?: {
min?: number;
max?: number;
preserveOriginal?: boolean;
};
};
};
/**
* Analyzer type and type-specific properties for an Ngram Analyzer.
* Options for creating a Segmentation Analyzer
*/
export declare type NgramAnalyzerInfo = {
export declare type CreateSegmentationAnalyzerOptions = {
/**
* Type of the Analyzer.
*/
type: "ngram";
type: "segmentation";
/**
* Features to enable for this Analyzer.
*/
features?: AnalyzerFeature[];
/**
* Additional properties for the Analyzer.
*/
properties: NgramAnalyzerProperties;
properties: {
/**
* Which tokens should be returned.
*
* Default: `"alpha"`
*/
break?: "all" | "alpha" | "graphic";
/**
* What case all returned tokens should be converted to if applicable.
*
* Default: `"none"`
*/
case?: "lower" | "upper" | "none";
};
};
/**
* Properties of a Text Analyzer.
* Options for creating an AQL Analyzer
*/
export declare type TextAnalyzerProperties = {
export declare type CreateAqlAnalyzerOptions = {
/**
* Text locale.
*
* Format: `language[_COUNTRY][.encoding][@variant]`
* Type of the Analyzer.
*/
locale: string;
type: "aql";
/**
* Case conversion.
*
* Default: `"lower"`
* Features to enable for this Analyzer.
*/
case?: "lower" | "none" | "upper";
features?: AnalyzerFeature[];
/**
* Words to omit from result.
*
* Defaults to the words loaded from the file at `stopwordsPath`.
* Additional properties for the Analyzer.
*/
stopwords?: string[];
properties: {
/**
* AQL query to be executed.
*/
queryString: string;
/**
* If set to `true`, the position is set to `0` for all members of the query result array.
*
* Default: `false`
*/
collapsePositions?: boolean;
/**
* If set to `false`, `null` values will be discarded from the View index.
*
* Default: `true`
*/
keepNull?: boolean;
/**
* Number between `1` and `1000` that determines the batch size for reading
* data from the query.
*
* Default: `1`
*/
batchSize?: number;
/**
* Memory limit for query execution in bytes.
*
* Default: `1048576` (1 MiB)
*/
memoryLimit?: number;
/**
* Data type of the returned tokens.
*
* Default: `"string"`
*/
returnType?: "string" | "number" | "bool";
};
};
/**
* Options for creating a Pipeline Analyzer
*/
export declare type CreatePipelineAnalyzerOptions = {
/**
* Path with a `language` sub-directory containing files with words to omit.
*
* Defaults to the path specified in the server-side environment variable
* `IRESEARCH_TEXT_STOPWORD_PATH` or the current working directory of the
* ArangoDB process.
* Type of the Analyzer.
*/
stopwordsPath?: string;
type: "pipeline";
/**
* Preserve accents in returned words.
*
* Default: `false`
* Features to enable for this Analyzer.
*/
accent?: boolean;
features?: AnalyzerFeature[];
/**
* Apply stemming on returned words.
*
* Default: `true`
* Additional properties for the Analyzer.
*/
stemming?: boolean;
/**
* If present, then edge n-grams are generated for each token (word).
*/
edgeNgram?: {
min?: number;
max?: number;
preserveOriginal?: boolean;
properties: {
/**
* Definitions for Analyzers to chain in this Pipeline Analyzer.
*/
pipeline: Omit<CreateAnalyzerOptions, "features">[];
};
};
/**
* Analyzer type and type-specific properties for a Text Analyzer.
* Options for creating a Stopwords Analyzer
*/
export declare type TextAnalyzerInfo = {
export declare type CreateStopwordsAnalyzerOptions = {
/**
* Type of the Analyzer.
*/
type: "text";
type: "stopwords";
/**
* Additional properties for the Analyzer.
* Features to enable for this Analyzer.
*/
properties: TextAnalyzerProperties;
};
/**
* Properties of a Pipeline Analyzer.
*/
export declare type PipelineAnalyzerProperties = {
features?: AnalyzerFeature[];
/**
* Definitions for Analyzers to chain in this Pipeline Analyzer.
* Additional properties for the Analyzer.
*/
pipeline: AnalyzerInfo[];
properties: {
/**
* Array of strings that describe the tokens to be discarded.
*/
stopwords: string[];
/**
* Whether stopword values should be interpreted as hex-encoded strings.
*
* Default: `false`
*/
hex?: boolean;
};
};
/**
* Analyzer type and type-specific properties for a Pipeline Analyzer
* Options for creating a Collation Analyzer
*/
export declare type PipelineAnalyzer = {
export declare type CreateCollationAnalyzerOptions = {
/**
* Type of the Analyzer.
*/
type: "pipeline";
type: "collation";
/**
* Features to enable for this Analyzer.
*/
features?: AnalyzerFeature[];
/**
* Additional properties for the Analyzer.
*/
properties: PipelineAnalyzerProperties;
properties: {
/**
* Text locale.
*
* Format: `language[_COUNTRY][.encoding][@variant]`
*/
locale: string;
};
};
/**
* Properties of an AQL Analyzer.
* Options for creating a MinHash Analyzer
*/
export declare type AqlAnalyzerProperties = {
export declare type CreateMinHashAnalyzerOptions = {
/**
* AQL query to be executed.
* Type of the Analyzer.
*/
queryString: string;
type: "minhash";
/**
* If set to `true`, the position is set to `0` for all members of the query result array.
*
* Default: `false`
* Features to enable for this Analyzer.
*/
collapsePositions?: boolean;
features?: AnalyzerFeature[];
/**
* If set to `false`, `null` values will be discarded from the View index.
*
* Default: `true`
* Additional properties for the Analyzer.
*/
keepNull?: boolean;
/**
* Number between `1` and `1000` that determines the batch size for reading
* data from the query.
*
* Default: `1`
*/
batchSize?: number;
/**
* Memory limit for query execution in bytes.
*
* Default: `1048576` (1 MiB)
*/
memoryLimit?: number;
/**
* Data type of the returned tokens.
*
* Default: `"string"`
*/
returnType?: "string" | "number" | "bool";
properties: {
/**
* An Analyzer definition-like object with `type` and `properties` attributes.
*/
analyzer: Omit<CreateAnalyzerOptions, "features">;
/**
* Size of the MinHash signature.
*/
numHashes: number;
};
};
/**
* Analyzer type and type-specific properties for an AQL Analyzer
* Options for creating a Classification Analyzer
*/
export declare type AqlAnalyzer = {
export declare type CreateClassificationAnalyzerOptions = {
/**
* Type of the Analyzer.
*/
type: "aql";
type: "classification";
/**
* Additional properties for the Analyzer.
* Features to enable for this Analyzer.
*/
properties: AqlAnalyzerProperties;
};
/**
* Properties of a GeoJSON Analyzer.
*/
export declare type GeoJsonAnalyzerProperties = {
features?: AnalyzerFeature[];
/**
* If set to `"centroid"`, only the centroid of the input geometry will be
* computed and indexed.
*
* If set to `"point"` only GeoJSON objects of type Point will be indexed and
* all other geometry types will be ignored.
*
* Default: `"shape"`
* Additional properties for the Analyzer.
*/
type?: "shape" | "centroid" | "point";
/**
* Options for fine-tuning geo queries.
*
* Default: `{ maxCells: 20, minLevel: 4, maxLevel: 23 }`
*/
options?: {
maxCells?: number;
minLevel?: number;
maxLevel?: number;
properties: {
/**
* On-disk path to the trained fastText supervised model.
*/
model_location: string;
/**
* Number of class labels that will be produced per input.
*
* Default: `1`
*/
top_k?: number;
/**
* Probability threshold for which a label will be assigned to an input.
*
* Default: `0.99`
*/
threshold?: number;
};
};
/**
* Analyzer type and type-specific properties for a GeoJSON Analyzer
* Options for creating a NearestNeighbors Analyzer
*/
export declare type GeoJsonAnalyzer = {
export declare type CreateNearestNeighborsAnalyzerOptions = {
/**
* Type of the Analyzer.
*/
type: "geojson";
type: "nearest_neighbors";
/**
* Features to enable for this Analyzer.
*/
features?: AnalyzerFeature[];
/**
* Additional properties for the Analyzer.
*/
properties: GeoJsonAnalyzerProperties;
properties: {
/**
* On-disk path to the trained fastText supervised model.
*/
model_location: string;
/**
* Number of class labels that will be produced per input.
*
* Default: `1`
*/
top_k?: number;
};
};
/**
* Properties of a GeoPoint Analyzer.
* Options for creating a GeoJSON Analyzer
*/
export declare type GeoPointAnalyzerProperties = {
export declare type CreateGeoJsonAnalyzerOptions = {
/**
* Attribute paths of the latitude value relative to the field for which the
* Analyzer is defined in the View.
* Type of the Analyzer.
*/
latitude?: string[];
type: "geojson";
/**
* Attribute paths of the longitude value relative to the field for which the
* Analyzer is defined in the View.
* Features to enable for this Analyzer.
*/
longitude?: string[];
features?: AnalyzerFeature[];
/**
* Options for fine-tuning geo queries.
*
* Default: `{ maxCells: 20, minLevel: 4, maxLevel: 23 }`
* Additional properties for the Analyzer.
*/
options?: {
minCells?: number;
minLevel?: number;
maxLevel?: number;
properties: {
/**
* If set to `"centroid"`, only the centroid of the input geometry will be
* computed and indexed.
*
* If set to `"point"` only GeoJSON objects of type Point will be indexed and
* all other geometry types will be ignored.
*
* Default: `"shape"`
*/
type?: "shape" | "centroid" | "point";
/**
* Options for fine-tuning geo queries.
*
* Default: `{ maxCells: 20, minLevel: 4, maxLevel: 23 }`
*/
options?: {
maxCells?: number;
minLevel?: number;
maxLevel?: number;
};
};
};
/**
* Analyzer type and type-specific properties for a GeoPoint Analyzer
* Options for creating a GeoPoint Analyzer
*/
export declare type GeoPointAnalyzer = {
export declare type CreateGeoPointAnalyzerOptions = {
/**

@@ -380,91 +521,229 @@ * Type of the Analyzer.

/**
* Features to enable for this Analyzer.
*/
features?: AnalyzerFeature[];
/**
* Additional properties for the Analyzer.
*/
properties: GeoPointAnalyzerProperties;
properties: {
/**
* Attribute paths of the latitude value relative to the field for which the
* Analyzer is defined in the View.
*/
latitude?: string[];
/**
* Attribute paths of the longitude value relative to the field for which the
* Analyzer is defined in the View.
*/
longitude?: string[];
/**
* Options for fine-tuning geo queries.
*
* Default: `{ maxCells: 20, minLevel: 4, maxLevel: 23 }`
*/
options?: {
minCells?: number;
minLevel?: number;
maxLevel?: number;
};
};
};
/**
* Properties of a Stopwords Analyzer.
* Shared attributes of all Analyzer descriptions.
*/
export declare type StopwordsAnalyzerProperties = {
export declare type GenericAnalyzerDescription = {
/**
* Array of strings that describe the tokens to be discarded.
* A unique name for this Analyzer.
*/
stopwords: string[];
name: string;
/**
* Whether stopword values should be interpreted as hex-encoded strings.
*
* Default: `false`
* Features enabled for this Analyzer.
*/
hex?: boolean;
features: AnalyzerFeature[];
};
/**
* Analyzer type and type-specific properties for a Stopwords Analyzer
* An object describing an Analyzer.
*/
export declare type StopwordsAnalyzer = {
/**
* Type of the Analyzer.
*/
type: "stopwords";
/**
* Additional properties for the Analyzer.
*/
properties: StopwordsAnalyzerProperties;
export declare type AnalyzerDescription = IdentityAnalyzerDescription | DelimiterAnalyzerDescription | StemAnalyzerDescription | NormAnalyzerDescription | NgramAnalyzerDescription | TextAnalyzerDescription | SegmentationAnalyzerDescription | AqlAnalyzerDescription | PipelineAnalyzerDescription | StopwordsAnalyzerDescription | CollationAnalyzerDescription | MinHashAnalyzerDescription | ClassificationAnalyzerDescription | NearestNeighborsAnalyzerDescription | GeoJsonAnalyzerDescription | GeoPointAnalyzerDescription;
/**
* An object describing an Identity Analyzer.
*/
export declare type IdentityAnalyzerDescription = GenericAnalyzerDescription & {
type: "identity";
properties: Record<string, never>;
};
/**
* Properties of a Segmentation Analyzer.
* An object describing a Delimiter Analyzer.
*/
export declare type SegmentationAnalyzerProperties = {
/**
* Which tokens should be returned.
*
* Default: `"alpha"`
*/
break?: "all" | "alpha" | "graphic";
/**
* What case all returned tokens should be converted to if applicable.
*
* Default: `"none"`
*/
case?: "lower" | "upper" | "none";
export declare type DelimiterAnalyzerDescription = GenericAnalyzerDescription & {
type: "delimiter";
properties: {
delimiter: string;
};
};
/**
* Analyzer type and type-specific properties for a Segmentation Analyzer
* An object describing a Stem Analyzer.
*/
export declare type SegmentationAnalyzer = {
/**
* Type of the Analyzer.
*/
export declare type StemAnalyzerDescription = GenericAnalyzerDescription & {
type: "stem";
properties: {
locale: string;
};
};
/**
* An object describing a Norm Analyzer.
*/
export declare type NormAnalyzerDescription = GenericAnalyzerDescription & {
type: "norm";
properties: {
locale: string;
case: "lower" | "none" | "upper";
accent: boolean;
};
};
/**
* An object describing an Ngram Analyzer.
*/
export declare type NgramAnalyzerDescription = GenericAnalyzerDescription & {
type: "ngram";
properties: {
max: number;
min: number;
preserveOriginal: boolean;
};
};
/**
* An object describing a Text Analyzer.
*/
export declare type TextAnalyzerDescription = GenericAnalyzerDescription & {
type: "text";
properties: {
locale: string;
case: "lower" | "none" | "upper";
stopwords: string[];
stopwordsPath: string;
accent: boolean;
stemming: boolean;
edgeNgram: {
min: number;
max: number;
preserveOriginal: boolean;
};
};
};
/**
* An object describing a Segmentation Analyzer
*/
export declare type SegmentationAnalyzerDescription = GenericAnalyzerDescription & {
type: "segmentation";
/**
* Additional properties for the Analyzer.
*/
properties: SegmentationAnalyzerProperties;
properties: {
break: "all" | "alpha" | "graphic";
case: "lower" | "upper" | "none";
};
};
/**
* Properties of a Collation Analyzer.
* An object describing an AQL Analyzer
*/
export declare type CollationAnalyzerProperties = {
/**
* Text locale.
*
* Format: `language[_COUNTRY][.encoding][@variant]`
*/
locale: string;
export declare type AqlAnalyzerDescription = GenericAnalyzerDescription & {
type: "aql";
properties: {
queryString: string;
collapsePositions: boolean;
keepNull: boolean;
batchSize: number;
memoryLimit: number;
returnType: "string" | "number" | "bool";
};
};
/**
* Analyzer type and type-specific properties for a Collation Analyzer
* An object describing a Pipeline Analyzer
*/
export declare type CollationAnalyzer = {
/**
* Type of the Analyzer.
*/
export declare type PipelineAnalyzerDescription = GenericAnalyzerDescription & {
type: "pipeline";
properties: {
pipeline: Omit<AnalyzerDescription, "name" | "features">[];
};
};
/**
* An object describing a Stopwords Analyzer
*/
export declare type StopwordsAnalyzerDescription = GenericAnalyzerDescription & {
type: "stopwords";
properties: {
stopwords: string[];
hex: boolean;
};
};
/**
* An object describing a Collation Analyzer
*/
export declare type CollationAnalyzerDescription = GenericAnalyzerDescription & {
type: "collation";
/**
* Additional properties for the Analyzer.
*/
properties: CollationAnalyzerProperties;
properties: {
locale: string;
};
};
/**
* Represents an Analyzer in a {@link Database}.
* (Enterprise Edition only.) An object describing a MinHash Analyzer
*/
export declare type MinHashAnalyzerDescription = GenericAnalyzerDescription & {
type: "minhash";
properties: {
analyzer: Omit<AnalyzerDescription, "name" | "features">;
numHashes: number;
};
};
/**
* (Enterprise Edition only.) An object describing a Classification Analyzer
*/
export declare type ClassificationAnalyzerDescription = GenericAnalyzerDescription & {
type: "classification";
properties: {
model_location: string;
top_k: number;
threshold: number;
};
};
/**
* (Enterprise Edition only.) An object describing a NearestNeighbors Analyzer
*/
export declare type NearestNeighborsAnalyzerDescription = GenericAnalyzerDescription & {
type: "nearest_neighbors";
properties: {
model_location: string;
top_k: number;
};
};
/**
* An object describing a GeoJSON Analyzer
*/
export declare type GeoJsonAnalyzerDescription = GenericAnalyzerDescription & {
type: "geojson";
properties: {
type: "shape" | "centroid" | "point";
description: {
maxCells: number;
minLevel: number;
maxLevel: number;
};
};
};
/**
* An object describing a GeoPoint Analyzer
*/
export declare type GeoPointAnalyzerDescription = GenericAnalyzerDescription & {
type: "geopoint";
properties: {
latitude: string[];
longitude: string[];
description: {
minCells: number;
minLevel: number;
maxLevel: number;
};
};
};
/**
* Represents an Analyzer in a {@link database.Database}.
*/
export declare class Analyzer {

@@ -475,3 +754,2 @@ protected _name: string;

* @internal
* @hidden
*/

@@ -488,3 +766,3 @@ constructor(db: Database, name: string);

*
* See also {@link Database.analyzer}.
* See also {@link database.Database}.
*/

@@ -515,7 +793,7 @@ get name(): string;

*/
get(): Promise<ArangoResponseMetadata & AnalyzerDescription>;
get(): Promise<ArangoApiResponse<AnalyzerDescription>>;
/**
* Creates a new Analyzer with the given `options` and the instance's name.
*
* See also {@link Database.createAnalyzer}.
* See also {@link database.Database#createAnalyzer}.
*

@@ -532,3 +810,3 @@ * @param options - Options for creating the Analyzer.

*/
create(options: CreateAnalyzerOptions): Promise<AnalyzerDescription>;
create<Options extends CreateAnalyzerOptions>(options: Options): Promise<Options extends CreateIdentityAnalyzerOptions ? IdentityAnalyzerDescription : Options extends CreateDelimiterAnalyzerOptions ? DelimiterAnalyzerDescription : Options extends CreateStemAnalyzerOptions ? StemAnalyzerDescription : Options extends CreateNormAnalyzerOptions ? NormAnalyzerDescription : Options extends CreateNgramAnalyzerOptions ? NgramAnalyzerDescription : Options extends CreateTextAnalyzerOptions ? TextAnalyzerDescription : Options extends CreateSegmentationAnalyzerOptions ? SegmentationAnalyzerDescription : Options extends CreateAqlAnalyzerOptions ? AqlAnalyzerDescription : Options extends CreatePipelineAnalyzerOptions ? PipelineAnalyzerDescription : Options extends CreateStopwordsAnalyzerOptions ? StopwordsAnalyzerDescription : Options extends CreateCollationAnalyzerOptions ? CollationAnalyzerDescription : Options extends CreateMinHashAnalyzerOptions ? MinHashAnalyzerDescription : Options extends CreateClassificationAnalyzerOptions ? ClassificationAnalyzerDescription : Options extends CreateNearestNeighborsAnalyzerOptions ? NearestNeighborsAnalyzerDescription : Options extends CreateGeoJsonAnalyzerOptions ? GeoJsonAnalyzerDescription : Options extends CreateGeoPointAnalyzerOptions ? GeoPointAnalyzerDescription : AnalyzerDescription>;
/**

@@ -548,6 +826,6 @@ * Deletes the Analyzer from the database.

*/
drop(force?: boolean): Promise<ArangoResponseMetadata & {
drop(force?: boolean): Promise<ArangoApiResponse<{
name: string;
}>;
}>>;
}
//# sourceMappingURL=analyzer.d.ts.map

@@ -16,3 +16,3 @@ "use strict";

/**
* Represents an Analyzer in a {@link Database}.
* Represents an Analyzer in a {@link database.Database}.
*/

@@ -22,3 +22,2 @@ class Analyzer {

* @internal
* @hidden
*/

@@ -40,3 +39,3 @@ constructor(db, name) {

*
* See also {@link Database.analyzer}.
* See also {@link database.Database}.
*/

@@ -63,3 +62,3 @@ get name() {

catch (err) {
if (error_1.isArangoError(err) && err.errorNum === codes_1.ANALYZER_NOT_FOUND) {
if ((0, error_1.isArangoError)(err) && err.errorNum === codes_1.ANALYZER_NOT_FOUND) {
return false;

@@ -82,3 +81,5 @@ }

get() {
return this._db.request({ path: `/_api/analyzer/${encodeURIComponent(this._name)}` }, (res) => res.body);
return this._db.request({
path: `/_api/analyzer/${encodeURIComponent(this._name)}`,
});
}

@@ -88,3 +89,3 @@ /**

*
* See also {@link Database.createAnalyzer}.
* See also {@link database.Database#createAnalyzer}.
*

@@ -106,3 +107,3 @@ * @param options - Options for creating the Analyzer.

body: { name: this._name, ...options },
}, (res) => res.body);
});
}

@@ -128,3 +129,3 @@ /**

qs: { force },
}, (res) => res.body);
});
}

@@ -131,0 +132,0 @@ }

@@ -1,15 +0,2 @@

/**
* ```js
* import { aql } from "arangojs/aql";
* ```
*
* The "aql" module provides the {@link aql} template string handler and
* helper functions, as well as associated types and interfaces for TypeScript.
*
* The aql function and namespace is also re-exported by the "index" module.
*
* @packageDocumentation
*/
import { ArangoCollection } from "./collection";
import { Dict } from "./connection";
import { Graph } from "./graph";

@@ -32,3 +19,3 @@ import { View } from "./view";

*/
bindVars: Dict<any>;
bindVars: Record<string, any>;
}

@@ -45,3 +32,2 @@ /**

* @internal
* @hidden
*/

@@ -58,3 +44,3 @@ _source: () => {

* Arbitrary values can be converted to trusted AQL literals by passing them
* to the {@link aql.literal} helper function.
* to the {@link literal} helper function.
*/

@@ -87,3 +73,2 @@ export interface AqlLiteral {

* @internal
* @hidden
*/

@@ -107,4 +92,4 @@ export declare function isGeneratedAqlQuery(query: any): query is GeneratedAqlQuery;

*
* Any {@link ArangoCollection} instance used in a query string will be
* recognized as a collection reference and generate an AQL collection bind
* Any {@link collection.ArangoCollection} instance used in a query string will
* be recognized as a collection reference and generate an AQL collection bind
* parameter instead of a regular AQL value bind parameter.

@@ -188,122 +173,120 @@ *

export declare function aql(templateStrings: TemplateStringsArray, ...args: AqlValue[]): GeneratedAqlQuery;
export declare namespace aql {
/**
* Marks an arbitrary scalar value (i.e. a string, number or boolean) as
* safe for being inlined directly into AQL queries when used in an `aql`
* template string, rather than being converted into a bind parameter.
*
* **Note**: Nesting `aql` template strings is a much safer alternative for
* most use cases. This low-level helper function only exists to help with
* rare edge cases where a trusted AQL query fragment must be read from a
* string (e.g. when reading query fragments from JSON) and should only be
* used as a last resort.
*
* @example
* ```js
* // BAD! DO NOT DO THIS!
* const sortDirection = aql.literal('ASC');
*
* // GOOD! DO THIS INSTEAD!
* const sortDirection = aql`ASC`;
* ```
*
* @example
* ```js
* // BAD! DO NOT DO THIS!
* const filterColor = aql.literal('FILTER d.color == "green"');
* const result = await db.query(aql`
* FOR d IN some-collection
* ${filterColor}
* RETURN d
* `);
*
* // GOOD! DO THIS INSTEAD!
* const color = "green";
* const filterColor = aql`FILTER d.color === ${color}`;
* const result = await db.query(aql`
* FOR d IN some-collection
* ${filterColor}
* RETURN d
* `);
* ```
*
* @example
* ```js
* // WARNING: We explicitly trust the environment variable to be safe!
* const filter = aql.literal(process.env.FILTER_STATEMENT);
* const users = await db.query(aql`
* FOR user IN users
* ${filter}
* RETURN user
* `);
* ```
*/
function literal(value: string | number | boolean | AqlLiteral | null | undefined): AqlLiteral;
/**
* Constructs {@link AqlQuery} objects from an array of arbitrary values.
*
* **Note**: Nesting `aql` template strings is a much safer alternative
* for most use cases. This low-level helper function only exists to
* complement the `aql` tag when constructing complex queries from dynamic
* arrays of query fragments.
*
* @param values - Array of values to join. These values will behave exactly
* like values interpolated in an `aql` template string.
* @param sep - Seperator to insert between values. This value will behave
* exactly like a value passed to {@link aql.literal}, i.e. it will be
* inlined as-is, rather than being converted into a bind parameter.
*
* @example
* ```js
* const users = db.collection("users");
* const filters = [];
* if (adminsOnly) filters.push(aql`FILTER user.admin`);
* if (activeOnly) filters.push(aql`FILTER user.active`);
* const result = await db.query(aql`
* FOR user IN ${users}
* ${aql.join(filters)}
* RETURN user
* `);
* ```
*
* @example
* ```js
* const users = db.collection("users");
* const keys = ["jreyes", "ghermann"];
*
* // BAD! NEEDLESSLY COMPLEX!
* const docs = keys.map(key => aql`DOCUMENT(${users}, ${key}`));
* const result = await db.query(aql`
* FOR user IN [
* ${aql.join(docs, ", ")}
* ]
* RETURN user
* `);
* // Query:
* // FOR user IN [
* // DOCUMENT(@@value0, @value1), DOCUMENT(@@value0, @value2)
* // ]
* // RETURN user
* // Bind parameters:
* // @value0 -> "users"
* // value1 -> "jreyes"
* // value2 -> "ghermann"
*
* // GOOD! MUCH SIMPLER!
* const result = await db.query(aql`
* FOR key IN ${keys}
* LET user = DOCUMENT(${users}, key)
* RETURN user
* `);
* // Query:
* // FOR user IN @value0
* // LET user = DOCUMENT(@@value1, key)
* // RETURN user
* // Bind parameters:
* // value0 -> ["jreyes", "ghermann"]
* // @value1 -> "users"
* ```
*/
function join(values: AqlValue[], sep?: string): GeneratedAqlQuery;
}
/**
* Marks an arbitrary scalar value (i.e. a string, number or boolean) as
* safe for being inlined directly into AQL queries when used in an `aql`
* template string, rather than being converted into a bind parameter.
*
* **Note**: Nesting `aql` template strings is a much safer alternative for
* most use cases. This low-level helper function only exists to help with
* rare edge cases where a trusted AQL query fragment must be read from a
* string (e.g. when reading query fragments from JSON) and should only be
* used as a last resort.
*
* @example
* ```js
* // BAD! DO NOT DO THIS!
* const sortDirection = literal('ASC');
*
* // GOOD! DO THIS INSTEAD!
* const sortDirection = aql`ASC`;
* ```
*
* @example
* ```js
* // BAD! DO NOT DO THIS!
* const filterColor = literal('FILTER d.color == "green"');
* const result = await db.query(aql`
* FOR d IN some-collection
* ${filterColor}
* RETURN d
* `);
*
* // GOOD! DO THIS INSTEAD!
* const color = "green";
* const filterColor = aql`FILTER d.color === ${color}`;
* const result = await db.query(aql`
* FOR d IN some-collection
* ${filterColor}
* RETURN d
* `);
* ```
*
* @example
* ```js
* // WARNING: We explicitly trust the environment variable to be safe!
* const filter = literal(process.env.FILTER_STATEMENT);
* const users = await db.query(aql`
* FOR user IN users
* ${filter}
* RETURN user
* `);
* ```
*/
export declare function literal(value: string | number | boolean | AqlLiteral | null | undefined): AqlLiteral;
/**
* Constructs {@link AqlQuery} objects from an array of arbitrary values.
*
* **Note**: Nesting `aql` template strings is a much safer alternative
* for most use cases. This low-level helper function only exists to
* complement the `aql` tag when constructing complex queries from dynamic
* arrays of query fragments.
*
* @param values - Array of values to join. These values will behave exactly
* like values interpolated in an `aql` template string.
* @param sep - Seperator to insert between values. This value will behave
* exactly like a value passed to {@link literal}, i.e. it will be
* inlined as-is, rather than being converted into a bind parameter.
*
* @example
* ```js
* const users = db.collection("users");
* const filters = [];
* if (adminsOnly) filters.push(aql`FILTER user.admin`);
* if (activeOnly) filters.push(aql`FILTER user.active`);
* const result = await db.query(aql`
* FOR user IN ${users}
* ${join(filters)}
* RETURN user
* `);
* ```
*
* @example
* ```js
* const users = db.collection("users");
* const keys = ["jreyes", "ghermann"];
*
* // BAD! NEEDLESSLY COMPLEX!
* const docs = keys.map(key => aql`DOCUMENT(${users}, ${key}`));
* const result = await db.query(aql`
* FOR user IN [
* ${join(docs, ", ")}
* ]
* RETURN user
* `);
* // Query:
* // FOR user IN [
* // DOCUMENT(@@value0, @value1), DOCUMENT(@@value0, @value2)
* // ]
* // RETURN user
* // Bind parameters:
* // @value0 -> "users"
* // value1 -> "jreyes"
* // value2 -> "ghermann"
*
* // GOOD! MUCH SIMPLER!
* const result = await db.query(aql`
* FOR key IN ${keys}
* LET user = DOCUMENT(${users}, key)
* RETURN user
* `);
* // Query:
* // FOR user IN @value0
* // LET user = DOCUMENT(@@value1, key)
* // RETURN user
* // Bind parameters:
* // value0 -> ["jreyes", "ghermann"]
* // @value1 -> "users"
* ```
*/
export declare function join(values: AqlValue[], sep?: string): GeneratedAqlQuery;
//# sourceMappingURL=aql.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.aql = exports.isAqlLiteral = exports.isGeneratedAqlQuery = exports.isAqlQuery = void 0;
exports.join = exports.literal = exports.aql = exports.isAqlLiteral = exports.isGeneratedAqlQuery = exports.isAqlQuery = void 0;
/**

@@ -16,2 +16,3 @@ * ```js

*/
const analyzer_1 = require("./analyzer");
const collection_1 = require("./collection");

@@ -35,3 +36,2 @@ const graph_1 = require("./graph");

* @internal
* @hidden
*/

@@ -61,4 +61,4 @@ function isGeneratedAqlQuery(query) {

*
* Any {@link ArangoCollection} instance used in a query string will be
* recognized as a collection reference and generate an AQL collection bind
* Any {@link collection.ArangoCollection} instance used in a query string will
* be recognized as a collection reference and generate an AQL collection bind
* parameter instead of a regular AQL value bind parameter.

@@ -175,5 +175,6 @@ *

let name = `value${isKnown ? index : bindValues.length}`;
if (collection_1.isArangoCollection(rawValue) ||
graph_1.isArangoGraph(rawValue) ||
view_1.isArangoView(rawValue)) {
if ((0, collection_1.isArangoCollection)(rawValue) ||
(0, graph_1.isArangoGraph)(rawValue) ||
(0, view_1.isArangoView)(rawValue) ||
(0, analyzer_1.isArangoAnalyzer)(rawValue)) {
name = `@${name}`;

@@ -195,145 +196,142 @@ value = rawValue.name;

exports.aql = aql;
// eslint-disable-next-line @typescript-eslint/no-namespace
(function (aql) {
/**
* Marks an arbitrary scalar value (i.e. a string, number or boolean) as
* safe for being inlined directly into AQL queries when used in an `aql`
* template string, rather than being converted into a bind parameter.
*
* **Note**: Nesting `aql` template strings is a much safer alternative for
* most use cases. This low-level helper function only exists to help with
* rare edge cases where a trusted AQL query fragment must be read from a
* string (e.g. when reading query fragments from JSON) and should only be
* used as a last resort.
*
* @example
* ```js
* // BAD! DO NOT DO THIS!
* const sortDirection = aql.literal('ASC');
*
* // GOOD! DO THIS INSTEAD!
* const sortDirection = aql`ASC`;
* ```
*
* @example
* ```js
* // BAD! DO NOT DO THIS!
* const filterColor = aql.literal('FILTER d.color == "green"');
* const result = await db.query(aql`
* FOR d IN some-collection
* ${filterColor}
* RETURN d
* `);
*
* // GOOD! DO THIS INSTEAD!
* const color = "green";
* const filterColor = aql`FILTER d.color === ${color}`;
* const result = await db.query(aql`
* FOR d IN some-collection
* ${filterColor}
* RETURN d
* `);
* ```
*
* @example
* ```js
* // WARNING: We explicitly trust the environment variable to be safe!
* const filter = aql.literal(process.env.FILTER_STATEMENT);
* const users = await db.query(aql`
* FOR user IN users
* ${filter}
* RETURN user
* `);
* ```
*/
function literal(value) {
if (isAqlLiteral(value)) {
return value;
}
return {
toAQL() {
if (value === undefined) {
return "";
}
return String(value);
},
};
/**
* Marks an arbitrary scalar value (i.e. a string, number or boolean) as
* safe for being inlined directly into AQL queries when used in an `aql`
* template string, rather than being converted into a bind parameter.
*
* **Note**: Nesting `aql` template strings is a much safer alternative for
* most use cases. This low-level helper function only exists to help with
* rare edge cases where a trusted AQL query fragment must be read from a
* string (e.g. when reading query fragments from JSON) and should only be
* used as a last resort.
*
* @example
* ```js
* // BAD! DO NOT DO THIS!
* const sortDirection = literal('ASC');
*
* // GOOD! DO THIS INSTEAD!
* const sortDirection = aql`ASC`;
* ```
*
* @example
* ```js
* // BAD! DO NOT DO THIS!
* const filterColor = literal('FILTER d.color == "green"');
* const result = await db.query(aql`
* FOR d IN some-collection
* ${filterColor}
* RETURN d
* `);
*
* // GOOD! DO THIS INSTEAD!
* const color = "green";
* const filterColor = aql`FILTER d.color === ${color}`;
* const result = await db.query(aql`
* FOR d IN some-collection
* ${filterColor}
* RETURN d
* `);
* ```
*
* @example
* ```js
* // WARNING: We explicitly trust the environment variable to be safe!
* const filter = literal(process.env.FILTER_STATEMENT);
* const users = await db.query(aql`
* FOR user IN users
* ${filter}
* RETURN user
* `);
* ```
*/
function literal(value) {
if (isAqlLiteral(value)) {
return value;
}
aql.literal = literal;
/**
* Constructs {@link AqlQuery} objects from an array of arbitrary values.
*
* **Note**: Nesting `aql` template strings is a much safer alternative
* for most use cases. This low-level helper function only exists to
* complement the `aql` tag when constructing complex queries from dynamic
* arrays of query fragments.
*
* @param values - Array of values to join. These values will behave exactly
* like values interpolated in an `aql` template string.
* @param sep - Seperator to insert between values. This value will behave
* exactly like a value passed to {@link aql.literal}, i.e. it will be
* inlined as-is, rather than being converted into a bind parameter.
*
* @example
* ```js
* const users = db.collection("users");
* const filters = [];
* if (adminsOnly) filters.push(aql`FILTER user.admin`);
* if (activeOnly) filters.push(aql`FILTER user.active`);
* const result = await db.query(aql`
* FOR user IN ${users}
* ${aql.join(filters)}
* RETURN user
* `);
* ```
*
* @example
* ```js
* const users = db.collection("users");
* const keys = ["jreyes", "ghermann"];
*
* // BAD! NEEDLESSLY COMPLEX!
* const docs = keys.map(key => aql`DOCUMENT(${users}, ${key}`));
* const result = await db.query(aql`
* FOR user IN [
* ${aql.join(docs, ", ")}
* ]
* RETURN user
* `);
* // Query:
* // FOR user IN [
* // DOCUMENT(@@value0, @value1), DOCUMENT(@@value0, @value2)
* // ]
* // RETURN user
* // Bind parameters:
* // @value0 -> "users"
* // value1 -> "jreyes"
* // value2 -> "ghermann"
*
* // GOOD! MUCH SIMPLER!
* const result = await db.query(aql`
* FOR key IN ${keys}
* LET user = DOCUMENT(${users}, key)
* RETURN user
* `);
* // Query:
* // FOR user IN @value0
* // LET user = DOCUMENT(@@value1, key)
* // RETURN user
* // Bind parameters:
* // value0 -> ["jreyes", "ghermann"]
* // @value1 -> "users"
* ```
*/
function join(values, sep = " ") {
if (!values.length) {
return aql ``;
}
if (values.length === 1) {
return aql `${values[0]}`;
}
return aql(["", ...Array(values.length - 1).fill(sep), ""], ...values);
return {
toAQL() {
if (value === undefined) {
return "";
}
return String(value);
},
};
}
exports.literal = literal;
/**
* Constructs {@link AqlQuery} objects from an array of arbitrary values.
*
* **Note**: Nesting `aql` template strings is a much safer alternative
* for most use cases. This low-level helper function only exists to
* complement the `aql` tag when constructing complex queries from dynamic
* arrays of query fragments.
*
* @param values - Array of values to join. These values will behave exactly
* like values interpolated in an `aql` template string.
* @param sep - Seperator to insert between values. This value will behave
* exactly like a value passed to {@link literal}, i.e. it will be
* inlined as-is, rather than being converted into a bind parameter.
*
* @example
* ```js
* const users = db.collection("users");
* const filters = [];
* if (adminsOnly) filters.push(aql`FILTER user.admin`);
* if (activeOnly) filters.push(aql`FILTER user.active`);
* const result = await db.query(aql`
* FOR user IN ${users}
* ${join(filters)}
* RETURN user
* `);
* ```
*
* @example
* ```js
* const users = db.collection("users");
* const keys = ["jreyes", "ghermann"];
*
* // BAD! NEEDLESSLY COMPLEX!
* const docs = keys.map(key => aql`DOCUMENT(${users}, ${key}`));
* const result = await db.query(aql`
* FOR user IN [
* ${join(docs, ", ")}
* ]
* RETURN user
* `);
* // Query:
* // FOR user IN [
* // DOCUMENT(@@value0, @value1), DOCUMENT(@@value0, @value2)
* // ]
* // RETURN user
* // Bind parameters:
* // @value0 -> "users"
* // value1 -> "jreyes"
* // value2 -> "ghermann"
*
* // GOOD! MUCH SIMPLER!
* const result = await db.query(aql`
* FOR key IN ${keys}
* LET user = DOCUMENT(${users}, key)
* RETURN user
* `);
* // Query:
* // FOR user IN @value0
* // LET user = DOCUMENT(@@value1, key)
* // RETURN user
* // Bind parameters:
* // value0 -> ["jreyes", "ghermann"]
* // @value1 -> "users"
* ```
*/
function join(values, sep = " ") {
if (!values.length) {
return aql ``;
}
aql.join = join;
})(aql = exports.aql || (exports.aql = {}));
if (values.length === 1) {
return aql `${values[0]}`;
}
return aql(["", ...Array(values.length - 1).fill(sep), ""], ...values);
}
exports.join = join;
//# sourceMappingURL=aql.js.map

@@ -17,2 +17,246 @@ # Changelog

## [8.0.0-rc.1]
### Removed
- Removed Node.js 10 and Node.js 12 support
With Node.js 10 and 12 having reached their end of life, arangojs will no
longer support these versions of Node.js going forward.
- Removed Internet Explorer support
As of version 8 arangojs no longer maintains compatibility for IE11 in the
pre-built browser bundle. You may still be able to use arangojs in IE11 when
bundling arangojs yourself but this may require polyfills and transformation.
- Removed `Dict` type from `connection` module
The `Dict<T>` type was identical to `Record<string, T>` and has been replaced
with this built-in type across arangojs.
- Removed workaround for ArangoDB pre-3.2.8 Foxx HTTP API responses
When fetching or modifying the configuration or dependencies of a Foxx
service using ArangoDB 3.2.7 and earlier, arangojs would perform additional
operations to convert the server response to a compatible format. All
affected versions of ArangoDB have reached End of Life since December 2018.
- Removed deprecated `db.useDatabase` method
The method was previously deprecated and can be replaced with `db.database`,
which returns a new `Database` object instead of modifying the existing one.
- Removed deprecated MMFiles methods and types
The MMFiles storage engine was removed in ArangoDB 3.7.
- Removed `BytesAccumConsolidationPolicy` type
The `bytes_accum` consolidation policy for views was deprecated in
ArangoDB 3.7 and should be replaced with the `tier` consolidation policy.
- Removed deprecated `minReplicationFactor` option from collection and
database related types
This option was renamed to `writeConcern` in ArangoDB 3.6.
- Removed deprecated `overwrite` option from `CollectionInsertOptions` type
This option was deprecated in ArangoDB 3.7 and should be replaced with the
`overwriteMode` option.
- Removed internal `request.host` attribute
This attribute has been replaced with `request.hostUrl`.
- Removed internal `response.arangojsHostId` attribute
This attribute has been replaced with `response.arangojsHostUrl`.
- Removed `CollectionStatus` and `CollectionType` enum re-exports
Previously these would be re-exported by the arangojs module for backwards
compatibility. If you still need to access these enums, you can import them
from the `collection` sub-module instead. Note that the `ViewType` enum
has been removed completely.
### Changed
- Changed default URL to `http://127.0.0.1:8529` to match ArangoDB default
Previously arangojs would use `localhost` which on some systems resolves to
the IPv6 address `::1` instead, resulting in confusing connection errors.
- Changed TypeScript compilation target to ES2020
Since all evergreen browsers including Firefox ESR and all active Node.js LTS
releases fully support ES2020, the compilation target for the browser bundle
and Node.js has been moved from ES2016 and ES2018 respectively to ES2020.
- Updated TypeScript to version 4.8
This may result in type signatures that are incompatible with TypeScript 3
being added in future releases (including patch releases).
- Changed default behavior of _internal_ `db.request` method
Previously this method would always return the full response object if no
`transform` callback was provided. The method now defaults to a `transform`
callback that extracts the response body instead. The previous behavior can
still be forced by passing `false` instead of a callback function.
This change has no effect on other methods like `route.request`.
- Replaced node core module polyfills with native APIs in browser build
As part of upgrading to webpack 5, arangojs now no longer requires node core
modules to be polyfilled to work in the browser. This also drastically
reduces the file size of the pre-built browser bundle `arangojs/web`.
- `db.query` now supports a generic return type ([#764](https://github.com/arangodb/arangojs/issues/764))
This allows explictly setting the item type of the `ArrayCursor` returned by
the query without using a type assertion on the promise result. Note that
arangojs can make no guarantees that the type matches the actual data
returned by the query.
```ts
const numbers = await db.query<{ index: number; squared: number }>(aql`
FOR i IN 1..1000
RETURN {
index: i,
squared: i * i
}
`);
const first = await numbers.next();
console.log(first.index, first.squared); // 1 1
```
- Moved `aql.literal` and `aql.join` into `aql` module
Previously these were available as methods on the `aql` function. Now they
need to be imported from the `aql` module.
- Changed return values of `db.getUserAccessLevel` and `db.getUserDatabases`
to match documented return types
- Retry requests resulting in status 503 `ArangoError` ([#710](https://github.com/arangodb/arangojs/issues/710))
Unless retries are explicitly disabled by setting `config.maxRetries` to
`false`, requests will now also be retried if the server responded with a
503 `ArangoError`, which ArangoDB uses to indicate the server is running in
maintenance mode. Previously this would always result in an error.
- Extended `CursorExtras` type in TypeScript
The types of the attributes `plan`, `profile`, and `stats` are now defined
more explicitly.
- Changed behavior of `collection.removeAll` for non-string arrays
Previously `collection.removeAll` would always convert its argument into an
array of document IDs and fail with an error if passed any documents had an
ID not matching the collection name. Now the selector argument is passed
as-is, bypassing this validation but allowing `ignoreRevs` to be respected
by the server.
- Extracted type `ArangoSearchViewLinkOptions` from `ArangoSearchViewLink`
Note that `ArangoSearchViewLink` now represents the type of the value
returned by the server, marking several properties as required.
- Extracted type `CreateArangoSearchView` from
`ArangoSearchViewPropertiesOptions`
Note that `ArangoSearchViewPropertiesOptions` now includes only those options
that can be updated/replaced whereas `CreateArangoSearchView` also includes
options that can only be set during creation of a view.
- Renamed type `GraphCreateOptions` to `CreateGraphOptions`
- Renamed type `PrimarySortCompression` to `Compression`
- Replaced type `AnalyzerInfo` and all its constituent types
Previously each type of Analyzer was represented by an `AnalyzerInfo` type
and (where relevant) an `AnalyzerProperties` type, which were used for both
creating and fetching Analyzers. The new types more closely follow the
pattern already used for index types, providing pairs of
`CreateAnalyzerOptions` and `AnalyzerDescription` types.
- Removed enum `ViewType`, type `ArangoSearchView` and changed `View` class to
be non-generic
The `View` class now behaves analogous to the `Analyzer` class. The various
types related to different view types have been restructured to more closely
follow the pattern used for indexes and analyzers.
### Deprecated
- Deprecated `EnsureFulltextIndexOptions` and `FulltextIndex` types
Fulltext indexes have been deprecated in ArangoDB 3.10 and should be replaced
with ArangoSearch.
### Added
- Added `toJSON` method to system errors
ArangoJS already adds the `request` object to system errors encountered
while attempting to make network requests. This change makes it easier
to serialize these error objects to JSON the same way `ArangoError` and
`HttpError` objects can already be serialized.
- Added `allowDirtyRead` option to `db.beginTransaction`, `trx.commit`,
`trx.abort`, `collection.edges`, `collection.inEdges`, `collection.outEdges`
The option is only respected by read-only requests.
- Added support for `ifMatch` and `ifNoneMatch` options ([#707](https://github.com/arangodb/arangojs/issues/707))
- Added `overwrite` option to `db.acquireHostList` ([#711](https://github.com/arangodb/arangojs/issues/711))
Setting this option to `true` will replace the current host list, removing any
hosts no longer present in the cluster.
- Added new ArangoDB 3.10 `legacyPolygons` option to `EnsureGeoIndexOptions`
and `GeoIndex` types
Geo indexes created in ArangoDB pre-3.10 will implicitly default this option
to `true`. ArangoDB 3.10 and later will default to `false` and use the new
parsing rules for geo indexes.
- Added support for new ArangoDB 3.10 `cacheEnabled` and `storedValues` options
in persistent indexes
- Added support for new ArangoDB 3.10 computed values in collections
- Added support for new ArangoDB 3.10 `InvertedIndex` type
- Added support for new ArangoDB 3.10 `offset` Analyzer feature
- Added support for new ArangoDB 3.10 `minhash`, `classification` and
`nearest_neighbors` Analyzer types
- Added missing `replicationFactor` and `writeConcern` options to
`CollectionPropertiesOptions` type
- Added missing `commitIntervalMsec` option to `ArangoSearchViewProperties`
type
- Added missing `deduplicate` option to `EnsurePersistentIndexOptions` type
([#771](https://github.com/arangodb/arangojs/issues/771))
- Added missing `unique` option to `EnsureZkdIndexOptions` type
- Added missing `deduplicate` and `estimates` fields to `PersistentIndex` type
- Added new ArangoDB 3.10 `db.queryRules` method
- Added support for `Analyzer` in `aql` templates
`Analyzer` objects can now be passed into `aql` templates like `View` and
`ArangoCollection` objects.
## [7.8.0] - 2022-05-19

@@ -104,7 +348,7 @@

- Added missing `hex` flag to `StopwordsAnalyzer` type ([#732](https://github.com/arangodb/arangojs/issues/732))
- Added missing `hex` option to `StopwordsAnalyzer` type ([#732](https://github.com/arangodb/arangojs/issues/732))
- Added missing `details` flag to `collection.figures` ([#728](https://github.com/arangodb/arangojs/issues/728))
- Added missing `details` option to `collection.figures` ([#728](https://github.com/arangodb/arangojs/issues/728))
- Added missing `inBackground` flag to index options ([#734](https://github.com/arangodb/arangojs/issues/734))
- Added missing `inBackground` option to index options ([#734](https://github.com/arangodb/arangojs/issues/734))

@@ -1297,2 +1541,3 @@ ## [7.5.0] - 2021-04-22

[8.0.0-rc.1]: https://github.com/arangodb/arangojs/compare/v7.8.0...v8.0.0-rc.1
[7.8.0]: https://github.com/arangodb/arangojs/compare/v7.7.0...v7.8.0

@@ -1299,0 +1544,0 @@ [7.7.0]: https://github.com/arangodb/arangojs/compare/v7.6.1...v7.7.0

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Collection = exports.CollectionStatus = exports.CollectionType = exports.collectionToString = exports.isArangoCollection = void 0;
/**
* ```ts
* import type {
* DocumentCollection,
* EdgeCollection,
* } from "arangojs/collection";
* ```
*
* The "collection" module provides collection related types and interfaces
* for TypeScript.
*
* @packageDocumentation
*/
const aql_1 = require("./aql");
const cursor_1 = require("./cursor");

@@ -54,3 +68,2 @@ const documents_1 = require("./documents");

* @internal
* @hidden
*/

@@ -61,3 +74,2 @@ class Collection {

* @internal
* @hidden
*/

@@ -68,17 +80,2 @@ constructor(db, name) {

}
//#region internals
_get(path, qs) {
return this._db.request({
path: `/_api/collection/${encodeURIComponent(this._name)}/${path}`,
qs,
}, (res) => res.body);
}
_put(path, body) {
return this._db.request({
method: "PUT",
path: `/_api/collection/${encodeURIComponent(this._name)}/${path}`,
body,
}, (res) => res.body);
}
//#endregion
//#region metadata

@@ -92,3 +89,5 @@ get isArangoCollection() {

get() {
return this._db.request({ path: `/_api/collection/${encodeURIComponent(this._name)}` }, (res) => res.body);
return this._db.request({
path: `/_api/collection/${encodeURIComponent(this._name)}`,
});
}

@@ -101,3 +100,3 @@ async exists() {

catch (err) {
if (error_1.isArangoError(err) && err.errorNum === codes_1.COLLECTION_NOT_FOUND) {
if ((0, error_1.isArangoError)(err) && err.errorNum === codes_1.COLLECTION_NOT_FOUND) {
return false;

@@ -108,4 +107,21 @@ }

}
create(options) {
const { waitForSyncReplication = undefined, enforceReplicationFactor = undefined, ...opts } = options || {};
create(options = {}) {
const { waitForSyncReplication = undefined, enforceReplicationFactor = undefined, ...opts } = options;
if (opts.computedValues) {
opts.computedValues = opts.computedValues.map((computedValue) => {
if ((0, aql_1.isAqlLiteral)(computedValue.expression)) {
return {
...computedValue,
expression: computedValue.expression.toAQL(),
};
}
if ((0, aql_1.isAqlQuery)(computedValue.expression)) {
return {
...computedValue,
expression: computedValue.expression.query,
};
}
return computedValue;
});
}
const qs = {};

@@ -126,15 +142,26 @@ if (typeof waitForSyncReplication === "boolean") {

},
}, (res) => res.body);
});
}
properties(properties) {
if (!properties)
return this._get("properties");
return this._put("properties", properties);
if (!properties) {
return this._db.request({
path: `/_api/collection/${encodeURIComponent(this._name)}/properties`,
});
}
return this._db.request({
method: "PUT",
path: `/_api/collection/${encodeURIComponent(this._name)}/properties`,
body: properties,
});
}
count() {
return this._get("count");
return this._db.request({
path: `/_api/collection/${encodeURIComponent(this._name)}/count`,
});
}
async recalculateCount() {
const body = await this._put("recalculateCount");
return body.result;
return this._db.request({
method: "PUT",
path: `/_api/collection/${encodeURIComponent(this._name)}/recalculateCount`,
}, (res) => res.body.result);
}

@@ -148,17 +175,18 @@ figures(details = false) {

revision() {
return this._get("revision");
return this._db.request({
path: `/_api/collection/${encodeURIComponent(this._name)}/revision`,
});
}
checksum(options) {
return this._get("checksum", options);
return this._db.request({
path: `/_api/collection/${encodeURIComponent(this._name)}/checksum`,
qs: options,
});
}
load(count) {
return this._put("load", typeof count === "boolean" ? { count } : undefined);
}
async loadIndexes() {
const body = await this._put("loadIndexesIntoMemory");
return body.result;
return this._db.request({
method: "PUT",
path: `/_api/collection/${encodeURIComponent(this._name)}/loadIndexesIntoMemory`,
}, (res) => res.body.result);
}
unload() {
return this._put("unload");
}
async rename(newName) {

@@ -169,8 +197,7 @@ const result = await this._db.renameCollection(this._name, newName);

}
async rotate() {
const body = await this._put("rotate");
return body.result;
}
truncate() {
return this._put("truncate");
return this._db.request({
method: "PUT",
path: `/_api/collection/${this._name}/truncate`,
});
}

@@ -182,3 +209,3 @@ drop(options) {

qs: options,
}, (res) => res.body);
});
}

@@ -195,10 +222,22 @@ //#endregion

documentId(selector) {
return documents_1._documentHandle(selector, this._name);
return (0, documents_1._documentHandle)(selector, this._name);
}
async documentExists(selector) {
async documentExists(selector, options = {}) {
const { ifMatch = undefined, ifNoneMatch = undefined } = options;
const headers = {};
if (ifMatch)
headers["if-match"] = ifMatch;
if (ifNoneMatch)
headers["if-none-match"] = ifNoneMatch;
try {
return await this._db.request({
method: "HEAD",
path: `/_api/document/${encodeURI(documents_1._documentHandle(selector, this._name))}`,
}, () => true);
path: `/_api/document/${encodeURI((0, documents_1._documentHandle)(selector, this._name))}`,
headers,
}, (res) => {
if (ifNoneMatch && res.statusCode === 304) {
throw new error_1.HttpError(res);
}
return true;
});
}

@@ -220,3 +259,3 @@ catch (err) {

body: selectors,
}, (res) => res.body);
});
}

@@ -227,7 +266,18 @@ async document(selector, options = {}) {

}
const { allowDirtyRead = undefined, graceful = false } = options;
const { allowDirtyRead = undefined, graceful = false, ifMatch = undefined, ifNoneMatch = undefined, } = options;
const headers = {};
if (ifMatch)
headers["if-match"] = ifMatch;
if (ifNoneMatch)
headers["if-none-match"] = ifNoneMatch;
const result = this._db.request({
path: `/_api/document/${encodeURI(documents_1._documentHandle(selector, this._name))}`,
path: `/_api/document/${encodeURI((0, documents_1._documentHandle)(selector, this._name))}`,
headers,
allowDirtyRead,
}, (res) => res.body);
}, (res) => {
if (ifNoneMatch && res.statusCode === 304) {
throw new error_1.HttpError(res);
}
return res.body;
});
if (!graceful)

@@ -239,3 +289,3 @@ return result;

catch (err) {
if (error_1.isArangoError(err) && err.errorNum === codes_1.DOCUMENT_NOT_FOUND) {
if ((0, error_1.isArangoError)(err) && err.errorNum === codes_1.DOCUMENT_NOT_FOUND) {
return null;

@@ -252,3 +302,3 @@ }

qs: options,
}, (res) => (options && options.silent ? undefined : res.body));
}, (res) => (options?.silent ? undefined : res.body));
}

@@ -261,11 +311,16 @@ saveAll(data, options) {

qs: options,
}, (res) => (options && options.silent ? undefined : res.body));
}, (res) => (options?.silent ? undefined : res.body));
}
replace(selector, newData, options) {
replace(selector, newData, options = {}) {
const { ifMatch = undefined, ...opts } = options;
const headers = {};
if (ifMatch)
headers["if-match"] = ifMatch;
return this._db.request({
method: "PUT",
path: `/_api/document/${encodeURI(documents_1._documentHandle(selector, this._name))}`,
path: `/_api/document/${encodeURI((0, documents_1._documentHandle)(selector, this._name))}`,
headers,
body: newData,
qs: options,
}, (res) => (options && options.silent ? undefined : res.body));
qs: opts,
}, (res) => (options?.silent ? undefined : res.body));
}

@@ -278,11 +333,16 @@ replaceAll(newData, options) {

qs: options,
}, (res) => (options && options.silent ? undefined : res.body));
}, (res) => (options?.silent ? undefined : res.body));
}
update(selector, newData, options) {
update(selector, newData, options = {}) {
const { ifMatch = undefined, ...opts } = options;
const headers = {};
if (ifMatch)
headers["if-match"] = ifMatch;
return this._db.request({
method: "PATCH",
path: `/_api/document/${encodeURI(documents_1._documentHandle(selector, this._name))}`,
path: `/_api/document/${encodeURI((0, documents_1._documentHandle)(selector, this._name))}`,
headers,
body: newData,
qs: options,
}, (res) => (options && options.silent ? undefined : res.body));
qs: opts,
}, (res) => (options?.silent ? undefined : res.body));
}

@@ -295,10 +355,15 @@ updateAll(newData, options) {

qs: options,
}, (res) => (options && options.silent ? undefined : res.body));
}, (res) => (options?.silent ? undefined : res.body));
}
remove(selector, options) {
remove(selector, options = {}) {
const { ifMatch = undefined, ...opts } = options;
const headers = {};
if (ifMatch)
headers["if-match"] = ifMatch;
return this._db.request({
method: "DELETE",
path: `/_api/document/${encodeURI(documents_1._documentHandle(selector, this._name))}`,
qs: options,
}, (res) => (options && options.silent ? undefined : res.body));
path: `/_api/document/${encodeURI((0, documents_1._documentHandle)(selector, this._name))}`,
headers,
qs: opts,
}, (res) => (options?.silent ? undefined : res.body));
}

@@ -309,5 +374,5 @@ removeAll(selectors, options) {

path: `/_api/document/${encodeURIComponent(this._name)}`,
body: selectors.map((selector) => documents_1._documentHandle(selector, this._name)),
body: selectors,
qs: options,
}, (res) => (options && options.silent ? undefined : res.body));
}, (res) => (options?.silent ? undefined : res.body));
}

@@ -327,23 +392,25 @@ import(data, options = {}) {

qs,
}, (res) => res.body);
});
}
//#endregion
//#region edges
_edges(selector, direction) {
_edges(selector, options, direction) {
const { allowDirtyRead = undefined } = options;
return this._db.request({
path: `/_api/edges/${encodeURIComponent(this._name)}`,
allowDirtyRead,
qs: {
direction,
vertex: documents_1._documentHandle(selector, this._name, false),
vertex: (0, documents_1._documentHandle)(selector, this._name, false),
},
}, (res) => res.body);
});
}
edges(vertex) {
return this._edges(vertex);
edges(vertex, options) {
return this._edges(vertex, options);
}
inEdges(vertex) {
return this._edges(vertex, "in");
inEdges(vertex, options) {
return this._edges(vertex, options, "in");
}
outEdges(vertex) {
return this._edges(vertex, "out");
outEdges(vertex, options) {
return this._edges(vertex, options, "out");
}

@@ -368,3 +435,3 @@ traversal(startVertex, options) {

body: { type, collection: this._name },
}, (res) => new cursor_1.BatchedArrayCursor(this._db, res.body, res.arangojsHostId).items);
}, (res) => new cursor_1.BatchedArrayCursor(this._db, res.body, res.arangojsHostUrl).items);
}

@@ -379,3 +446,3 @@ all(options) {

},
}, (res) => new cursor_1.BatchedArrayCursor(this._db, res.body, res.arangojsHostId).items);
}, (res) => new cursor_1.BatchedArrayCursor(this._db, res.body, res.arangojsHostUrl).items);
}

@@ -398,3 +465,3 @@ any() {

},
}, (res) => new cursor_1.BatchedArrayCursor(this._db, res.body, res.arangojsHostId).items);
}, (res) => new cursor_1.BatchedArrayCursor(this._db, res.body, res.arangojsHostUrl).items);
}

@@ -420,3 +487,3 @@ firstExample(example) {

},
}, (res) => res.body);
});
}

@@ -433,3 +500,3 @@ replaceByExample(example, newValue, options) {

},
}, (res) => res.body);
});
}

@@ -446,3 +513,3 @@ updateByExample(example, newValue, options) {

},
}, (res) => res.body);
});
}

@@ -468,3 +535,3 @@ lookupByKeys(keys) {

},
}, (res) => res.body);
});
}

@@ -481,4 +548,4 @@ //#endregion

return this._db.request({
path: `/_api/index/${encodeURI(indexes_1._indexHandle(selector, this._name))}`,
}, (res) => res.body);
path: `/_api/index/${encodeURI((0, indexes_1._indexHandle)(selector, this._name))}`,
});
}

@@ -491,3 +558,3 @@ ensureIndex(options) {

qs: { collection: this._name },
}, (res) => res.body);
});
}

@@ -497,4 +564,4 @@ dropIndex(selector) {

method: "DELETE",
path: `/_api/index/${encodeURI(indexes_1._indexHandle(selector, this._name))}`,
}, (res) => res.body);
path: `/_api/index/${encodeURI((0, indexes_1._indexHandle)(selector, this._name))}`,
});
}

@@ -507,3 +574,3 @@ fulltext(attribute, query, { index, ...options } = {}) {

...options,
index: index ? indexes_1._indexHandle(index, this._name) : undefined,
index: index ? (0, indexes_1._indexHandle)(index, this._name) : undefined,
attribute,

@@ -513,3 +580,3 @@ query,

},
}, (res) => new cursor_1.BatchedArrayCursor(this._db, res.body, res.arangojsHostId).items);
}, (res) => new cursor_1.BatchedArrayCursor(this._db, res.body, res.arangojsHostUrl).items);
}

@@ -516,0 +583,0 @@ compact() {

/// <reference types="node" />
/// <reference types="node" />
/**

@@ -18,10 +19,2 @@ * ```ts

/**
* Generic type representing an object with values of a given value type.
*
* @param T - Type of the object's property values.
*/
export declare type Dict<T> = {
[key: string]: T;
};
/**
* Determines the behavior when multiple URLs are used:

@@ -45,3 +38,3 @@ *

*/
export declare type Headers = Dict<string>;
export declare type Headers = Record<string, string>;
/**

@@ -51,3 +44,3 @@ * An arbitrary object with scalar values representing query string parameters

*/
export declare type Params = Dict<any>;
export declare type Params = Record<string, any>;
/**

@@ -67,2 +60,6 @@ * Generic properties shared by all ArangoDB HTTP API responses.

/**
* Extends the given base type `T` with the generic HTTP API response properties.
*/
export declare type ArangoApiResponse<T> = T & ArangoResponseMetadata;
/**
* Credentials for HTTP Basic authentication.

@@ -91,3 +88,2 @@ */

* @internal
* @hidden
*/

@@ -105,3 +101,3 @@ declare type UrlInfo = {

*
* See also: {@link https://www.npmjs.com/package/xhr | `xhr` on npm }.
* See also: [`xhr` on npm](https://www.npmjs.com/package/xhr).
*/

@@ -142,3 +138,3 @@ export declare type XhrOptions = {

*
* See {@link https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials | `XMLHttpRequest.withCredentials`}.
* See [`XMLHttpRequest.withCredentials`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials).
*/

@@ -180,3 +176,3 @@ withCredentials?: boolean;

*/
host?: number;
hostUrl?: string;
/**

@@ -242,11 +238,11 @@ * HTTP method to use in order to perform the request.

* @internal
* @hidden
*/
declare type Task = {
host?: number;
hostUrl?: string;
stack?: () => string;
allowDirtyRead: boolean;
retryOnConflict: number;
resolve: (res: ArangojsResponse) => void;
resolve: (result: any) => void;
reject: (error: Error) => void;
transform?: (res: ArangojsResponse) => any;
retries: number;

@@ -270,6 +266,6 @@ options: {

* to the underlying calls of the
* {@link https://www.npmjs.com/package/xhr | xhr module}.
* [xhr module](https://www.npmjs.com/package/xhr).
*
* See also {@link https://nodejs.org/api/http.html#http_new_agent_options | `http.Agent`}
* and {@link https://nodejs.org/api/https.html#https_new_agent_options | `https.Agent`}
* See also [`http.Agent`](https://nodejs.org/api/http.html#http_new_agent_options)
* and [`https.Agent`](https://nodejs.org/api/https.html#https_new_agent_options)
* (when using TLS).

@@ -292,3 +288,3 @@ */

* When working with a cluster or a single server with leader/follower
* failover, the method {@link Database.acquireHostList} can be used to
* failover, the method {@link database.Database#acquireHostList} can be used to
* automatically pick up additional coordinators/followers at any point.

@@ -307,4 +303,4 @@ *

*
* - `tcp://localhost:8529` and `http://localhost:8529`
* - `ssl://localhost:8529` and `https://localhost:8529`
* - `tcp://127.0.0.1:8529` and `http://127.0.0.1:8529`
* - `ssl://127.0.0.1:8529` and `https://127.0.0.1:8529`
* - `tcp+unix:///tmp/arangodb.sock` and `http+unix:///tmp/arangodb.sock`

@@ -317,3 +313,3 @@ * - `ssl+unix:///tmp/arangodb.sock` and `https+unix:///tmp/arangodb.sock`

*
* Default: `"http://localhost:8529"`
* Default: `"http://127.0.0.1:8529"`
*/

@@ -324,3 +320,4 @@ url?: string | string[];

*
* See also {@link Database.useBasicAuth} and {@link Database.useBearerAuth}.
* See also {@link database.Database#useBasicAuth} and
* {@link database.Database#useBearerAuth}.
*

@@ -339,3 +336,3 @@ * Default: `{ username: "root", password: "" }`

*
* Default: `30400`
* Default: `30900`
*/

@@ -361,3 +358,3 @@ arangoVersion?: number;

* connection to the server could not be opened
* (i.e. {@link https://nodejs.org/api/errors.html#errors_common_system_errors | `ECONNREFUSED` in Node.js}):
* (i.e. [`ECONNREFUSED` in Node.js](https://nodejs.org/api/errors.html#errors_common_system_errors)):
*

@@ -392,4 +389,4 @@ * - `false`: the request fails immediately.

*
* See also: {@link https://nodejs.org/api/http.html#http_new_agent_options | `http.Agent`}
* and {@link https://nodejs.org/api/https.html#https_new_agent_options | `https.Agent`}
* See also [`http.Agent`](https://nodejs.org/api/http.html#http_new_agent_options)
* and [`https.Agent`](https://nodejs.org/api/https.html#https_new_agent_options)
* (when using TLS).

@@ -423,3 +420,3 @@ */

* If an `"authorization"` header is provided, it will be overridden when
* using {@link Database.useBasicAuth}, {@link Database.useBearerAuth} or
* using {@link database.Database#useBasicAuth}, {@link database.Database#useBearerAuth} or
* the `auth` configuration option.

@@ -439,3 +436,3 @@ */

* Limits the number of values of server-reported response queue times that
* will be stored and accessible using {@link Database.queueTime}. If set to
* will be stored and accessible using {@link database.Database#queueTime}. If set to
* a finite value, older values will be discarded to make room for new values

@@ -454,3 +451,2 @@ * when that limit is reached.

* @internal
* @hidden
*/

@@ -462,3 +458,2 @@ export declare function isArangoConnection(connection: any): connection is Connection;

* @internal
* @hidden
*/

@@ -474,5 +469,3 @@ export declare class Connection {

protected _loadBalancingStrategy: LoadBalancingStrategy;
protected _useFailOver: boolean;
protected _shouldRetry: boolean;
protected _maxRetries: number;
protected _maxRetries: number | false;
protected _maxTasks: number;

@@ -482,9 +475,9 @@ protected _queue: LinkedList<Task>;

protected _hosts: RequestFunction[];
protected _urls: string[];
protected _activeHost: number;
protected _activeDirtyHost: number;
protected _hostUrls: string[];
protected _activeHostUrl: string;
protected _activeDirtyHostUrl: string;
protected _transactionId: string | null;
protected _precaptureStackTraces: boolean;
protected _queueTimes: LinkedList<[number, number]>;
protected _responseQueueTimeSamples: number;
protected _queueTimes: LinkedList<[number, number]>;
/**

@@ -497,3 +490,2 @@ * @internal

*
* @hidden
*/

@@ -526,3 +518,3 @@ constructor(config?: Omit<Config, "databaseName">);

*
* Fetches a {@link Database} instance for the given database name from the
* Fetches a {@link database.Database} instance for the given database name from the
* internal cache, if available.

@@ -536,3 +528,3 @@ *

*
* Adds a {@link Database} instance for the given database name to the
* Adds a {@link database.Database} instance for the given database name to the
* internal cache.

@@ -547,3 +539,3 @@ *

*
* Clears any {@link Database} instance stored for the given database name
* Clears any {@link database.Database} instance stored for the given database name
* from the internal cache, if present.

@@ -558,9 +550,19 @@ *

*
* Replaces the host list with the given URLs.
*
* See {@link Connection#acquireHostList}.
*
* @param urls - URLs to use as host list.
*/
setHostList(urls: string[]): void;
/**
* @internal
*
* Adds the given URL or URLs to the host list.
*
* See {@link Connection.acquireHostList}.
* See {@link Connection#acquireHostList}.
*
* @param urls - URL or URLs to add.
*/
addToHostList(urls: string | string[]): number[];
addToHostList(urls: string | string[]): string[];
/**

@@ -575,3 +577,3 @@ * @internal

*
* See also {@link Connection.clearTransactionId}.
* See also {@link Connection#clearTransactionId}.
*

@@ -602,3 +604,3 @@ * @param transactionId - ID of the active transaction.

*
* See {@link Database.close}.
* See {@link database.Database#close}.
*/

@@ -611,3 +613,3 @@ close(): void;

*
* See {@link Database.waitForPropagation}.
* See {@link database.Database#waitForPropagation}.
*

@@ -623,5 +625,5 @@ * @param request - Request to perform against each coordinator.

*/
request<T = ArangojsResponse>({ host, method, body, expectBinary, isBinary, allowDirtyRead, retryOnConflict, timeout, headers, ...urlInfo }: RequestOptions, transform?: (res: ArangojsResponse) => T): Promise<T>;
request<T = ArangojsResponse>({ hostUrl, method, body, expectBinary, isBinary, allowDirtyRead, retryOnConflict, timeout, headers, ...urlInfo }: RequestOptions, transform?: (res: ArangojsResponse) => T): Promise<T>;
}
export {};
//# sourceMappingURL=connection.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Connection = exports.isArangoConnection = void 0;
const querystring_1 = require("querystring");
const x3_linkedlist_1 = require("x3-linkedlist");

@@ -10,15 +9,6 @@ const error_1 = require("./error");

const normalizeUrl_1 = require("./lib/normalizeUrl");
const querystringify_1 = require("./lib/querystringify");
const request_1 = require("./lib/request");
const MIME_JSON = /\/(json|javascript)(\W|$)/;
const LEADER_ENDPOINT_HEADER = "x-arango-endpoint";
function clean(obj) {
const result = {};
for (const key of Object.keys(obj)) {
const value = obj[key];
if (value === undefined)
continue;
result[key] = value;
}
return result;
}
function isBearerAuth(auth) {

@@ -29,3 +19,2 @@ return auth.hasOwnProperty("token");

* @internal
* @hidden
*/

@@ -50,3 +39,2 @@ function generateStackTrace() {

* @internal
* @hidden
*/

@@ -61,3 +49,2 @@ function isArangoConnection(connection) {

* @internal
* @hidden
*/

@@ -72,12 +59,10 @@ class Connection {

*
* @hidden
*/
constructor(config = {}) {
var _a, _b, _c;
this._activeTasks = 0;
this._arangoVersion = 30400;
this._arangoVersion = 30900;
this._queue = new x3_linkedlist_1.LinkedList();
this._databases = new Map();
this._hosts = [];
this._urls = [];
this._hostUrls = [];
this._transactionId = null;

@@ -89,3 +74,3 @@ this._queueTimes = new x3_linkedlist_1.LinkedList();

: [config.url]
: ["http://localhost:8529"];
: ["http://127.0.0.1:8529"];
const MAX_SOCKETS = 3 * (config.loadBalancingStrategy === "ROUND_ROBIN" ? URLS.length : 1);

@@ -107,6 +92,5 @@ if (config.arangoVersion !== undefined) {

this._headers = { ...config.headers };
this._loadBalancingStrategy = (_a = config.loadBalancingStrategy) !== null && _a !== void 0 ? _a : "NONE";
this._useFailOver = this._loadBalancingStrategy !== "ROUND_ROBIN";
this._loadBalancingStrategy = config.loadBalancingStrategy ?? "NONE";
this._precaptureStackTraces = Boolean(config.precaptureStackTraces);
this._responseQueueTimeSamples = (_b = config.responseQueueTimeSamples) !== null && _b !== void 0 ? _b : 10;
this._responseQueueTimeSamples = config.responseQueueTimeSamples ?? 10;
if (this._responseQueueTimeSamples < 0) {

@@ -116,8 +100,6 @@ this._responseQueueTimeSamples = Infinity;

if (config.maxRetries === false) {
this._shouldRetry = false;
this._maxRetries = 0;
this._maxRetries = false;
}
else {
this._shouldRetry = true;
this._maxRetries = (_c = config.maxRetries) !== null && _c !== void 0 ? _c : 0;
this._maxRetries = Number(config.maxRetries ?? 0);
}

@@ -134,8 +116,10 @@ this.addToHostList(URLS);

if (this._loadBalancingStrategy === "ONE_RANDOM") {
this._activeHost = Math.floor(Math.random() * this._hosts.length);
this._activeDirtyHost = Math.floor(Math.random() * this._hosts.length);
this._activeHostUrl =
this._hostUrls[Math.floor(Math.random() * this._hostUrls.length)];
this._activeDirtyHostUrl =
this._hostUrls[Math.floor(Math.random() * this._hostUrls.length)];
}
else {
this._activeHost = 0;
this._activeDirtyHost = 0;
this._activeHostUrl = this._hostUrls[0];
this._activeDirtyHostUrl = this._hostUrls[0];
}

@@ -153,3 +137,3 @@ }

return {
getLatest: () => { var _a; return (_a = this._queueTimes.last) === null || _a === void 0 ? void 0 : _a.value[1]; },
getLatest: () => this._queueTimes.last?.value[1],
getValues: () => Array.from(this._queueTimes.values()),

@@ -169,13 +153,17 @@ getAvg: () => {

const task = this._queue.shift();
let host = this._activeHost;
if (task.host !== undefined) {
host = task.host;
let hostUrl = this._activeHostUrl;
if (task.hostUrl !== undefined) {
hostUrl = task.hostUrl;
}
else if (task.allowDirtyRead) {
host = this._activeDirtyHost;
this._activeDirtyHost = (this._activeDirtyHost + 1) % this._hosts.length;
hostUrl = this._activeDirtyHostUrl;
this._activeDirtyHostUrl =
this._hostUrls[(this._hostUrls.indexOf(this._activeDirtyHostUrl) + 1) %
this._hostUrls.length];
task.options.headers["x-arango-allow-dirty-read"] = "true";
}
else if (this._loadBalancingStrategy === "ROUND_ROBIN") {
this._activeHost = (this._activeHost + 1) % this._hosts.length;
this._activeHostUrl =
this._hostUrls[(this._hostUrls.indexOf(this._activeHostUrl) + 1) %
this._hostUrls.length];
}

@@ -185,10 +173,73 @@ this._activeTasks += 1;

this._activeTasks -= 1;
if (!err && res) {
if (res.statusCode === 503 && res.headers[LEADER_ENDPOINT_HEADER]) {
const url = res.headers[LEADER_ENDPOINT_HEADER];
const [cleanUrl] = this.addToHostList(url);
task.hostUrl = cleanUrl;
if (this._activeHostUrl === hostUrl) {
this._activeHostUrl = cleanUrl;
}
this._queue.push(task);
}
else {
res.arangojsHostUrl = hostUrl;
const contentType = res.headers["content-type"];
const queueTime = res.headers["x-arango-queue-time-seconds"];
if (queueTime) {
this._queueTimes.push([Date.now(), Number(queueTime)]);
while (this._responseQueueTimeSamples < this._queueTimes.length) {
this._queueTimes.shift();
}
}
let parsedBody = undefined;
if (res.body.length && contentType && contentType.match(MIME_JSON)) {
try {
parsedBody = res.body;
parsedBody = JSON.parse(parsedBody);
}
catch (e) {
if (!task.options.expectBinary) {
if (typeof parsedBody !== "string") {
parsedBody = res.body.toString("utf-8");
}
e.res = res;
if (task.stack) {
e.stack += task.stack();
}
callback(e);
return;
}
}
}
else if (res.body && !task.options.expectBinary) {
parsedBody = res.body.toString("utf-8");
}
else {
parsedBody = res.body;
}
if ((0, error_1.isArangoErrorResponse)(parsedBody)) {
res.body = parsedBody;
err = new error_1.ArangoError(res);
}
else if (res.statusCode && res.statusCode >= 400) {
res.body = parsedBody;
err = new error_1.HttpError(res);
}
else {
if (!task.options.expectBinary)
res.body = parsedBody;
task.resolve(task.transform ? task.transform(res) : res);
}
}
}
if (err) {
if (!task.allowDirtyRead &&
this._hosts.length > 1 &&
this._activeHost === host &&
this._useFailOver) {
this._activeHost = (this._activeHost + 1) % this._hosts.length;
this._activeHostUrl === hostUrl &&
this._loadBalancingStrategy !== "ROUND_ROBIN") {
this._activeHostUrl =
this._hostUrls[(this._hostUrls.indexOf(this._activeHostUrl) + 1) %
this._hostUrls.length];
}
if (error_1.isArangoError(err) &&
if ((0, error_1.isArangoError)(err) &&
err.errorNum === codes_1.ERROR_ARANGO_CONFLICT &&

@@ -199,8 +250,10 @@ task.retryOnConflict > 0) {

}
else if (!task.host &&
this._shouldRetry &&
task.retries < (this._maxRetries || this._hosts.length - 1) &&
error_1.isSystemError(err) &&
else if ((((0, error_1.isSystemError)(err) &&
err.syscall === "connect" &&
err.code === "ECONNREFUSED") {
err.code === "ECONNREFUSED") ||
((0, error_1.isArangoError)(err) &&
err.errorNum === codes_1.ERROR_ARANGO_MAINTENANCE_MODE)) &&
task.hostUrl === undefined &&
this._maxRetries !== false &&
task.retries < (this._maxRetries || this._hosts.length - 1)) {
task.retries += 1;

@@ -216,23 +269,6 @@ this._queue.push(task);

}
else {
const response = res;
if (response.statusCode === 503 &&
response.headers[LEADER_ENDPOINT_HEADER]) {
const url = response.headers[LEADER_ENDPOINT_HEADER];
const [index] = this.addToHostList(url);
task.host = index;
if (this._activeHost === host) {
this._activeHost = index;
}
this._queue.push(task);
}
else {
response.arangojsHostId = host;
task.resolve(response);
}
}
this._runQueue();
};
try {
this._hosts[host](task.options, callback);
this._hosts[this._hostUrls.indexOf(hostUrl)](task.options, callback);
}

@@ -250,3 +286,3 @@ catch (e) {

else
search = `?${querystring_1.stringify(clean(qs))}`;
search = `?${(0, querystringify_1.querystringify)(qs)}`;
}

@@ -259,3 +295,3 @@ return search ? { pathname, search } : { pathname };

setBasicAuth(auth) {
this.setHeader("authorization", `Basic ${btoa_1.btoa(`${auth.username}:${auth.password}`)}`);
this.setHeader("authorization", `Basic ${(0, btoa_1.base64Encode)(`${auth.username}:${auth.password}`)}`);
}

@@ -285,5 +321,24 @@ setResponseQueueTimeSamples(responseQueueTimeSamples) {

*
* Replaces the host list with the given URLs.
*
* See {@link Connection#acquireHostList}.
*
* @param urls - URLs to use as host list.
*/
setHostList(urls) {
const cleanUrls = urls.map((url) => (0, normalizeUrl_1.normalizeUrl)(url));
this._hosts.splice(0, this._hosts.length, ...cleanUrls.map((url) => {
const i = this._hostUrls.indexOf(url);
if (i !== -1)
return this._hosts[i];
return (0, request_1.createRequest)(url, this._agentOptions, this._agent);
}));
this._hostUrls.splice(0, this._hostUrls.length, ...cleanUrls);
}
/**
* @internal
*
* Adds the given URL or URLs to the host list.
*
* See {@link Connection.acquireHostList}.
* See {@link Connection#acquireHostList}.
*

@@ -293,7 +348,7 @@ * @param urls - URL or URLs to add.

addToHostList(urls) {
const cleanUrls = (Array.isArray(urls) ? urls : [urls]).map((url) => normalizeUrl_1.normalizeUrl(url));
const newUrls = cleanUrls.filter((url) => this._urls.indexOf(url) === -1);
this._urls.push(...newUrls);
this._hosts.push(...newUrls.map((url) => request_1.createRequest(url, this._agentOptions, this._agent)));
return cleanUrls.map((url) => this._urls.indexOf(url));
const cleanUrls = (Array.isArray(urls) ? urls : [urls]).map((url) => (0, normalizeUrl_1.normalizeUrl)(url));
const newUrls = cleanUrls.filter((url) => this._hostUrls.indexOf(url) === -1);
this._hostUrls.push(...newUrls);
this._hosts.push(...newUrls.map((url) => (0, request_1.createRequest)(url, this._agentOptions, this._agent)));
return cleanUrls;
}

@@ -309,3 +364,3 @@ /**

*
* See also {@link Connection.clearTransactionId}.
* See also {@link Connection#clearTransactionId}.
*

@@ -347,3 +402,3 @@ * @param transactionId - ID of the active transaction.

*
* See {@link Database.close}.
* See {@link database.Database#close}.
*/

@@ -361,3 +416,3 @@ close() {

*
* See {@link Database.waitForPropagation}.
* See {@link database.Database#waitForPropagation}.
*

@@ -371,3 +426,3 @@ * @param request - Request to perform against each coordinator.

const started = Date.now();
let host = 0;
let index = 0;
while (true) {

@@ -377,7 +432,8 @@ if (propagated.length === numHosts) {

}
while (propagated.includes(host)) {
host = (host + 1) % numHosts;
while (propagated.includes(this._hostUrls[index])) {
index = (index + 1) % numHosts;
}
const hostUrl = this._hostUrls[index];
try {
await this.request({ ...request, host });
await this.request({ ...request, hostUrl });
}

@@ -391,4 +447,4 @@ catch (e) {

}
if (!propagated.includes(host)) {
propagated.push(host);
if (!propagated.includes(hostUrl)) {
propagated.push(hostUrl);
}

@@ -402,3 +458,3 @@ }

*/
request({ host, method = "GET", body, expectBinary = false, isBinary = false, allowDirtyRead = false, retryOnConflict = 0, timeout = 0, headers, ...urlInfo }, transform) {
request({ hostUrl, method = "GET", body, expectBinary = false, isBinary = false, allowDirtyRead = false, retryOnConflict = 0, timeout = 0, headers, ...urlInfo }, transform) {
return new Promise((resolve, reject) => {

@@ -428,3 +484,3 @@ let contentType = "text/plain";

retries: 0,
host,
hostUrl,
allowDirtyRead,

@@ -441,59 +497,4 @@ retryOnConflict,

reject,
resolve: (res) => {
const contentType = res.headers["content-type"];
const queueTime = res.headers["x-arango-queue-time-seconds"];
if (queueTime) {
this._queueTimes.push([Date.now(), Number(queueTime)]);
while (this._responseQueueTimeSamples < this._queueTimes.length) {
this._queueTimes.shift();
}
}
let parsedBody = undefined;
if (res.body.length && contentType && contentType.match(MIME_JSON)) {
try {
parsedBody = res.body;
parsedBody = JSON.parse(parsedBody);
}
catch (e) {
if (!expectBinary) {
if (typeof parsedBody !== "string") {
parsedBody = res.body.toString("utf-8");
}
e.response = res;
if (task.stack) {
e.stack += task.stack();
}
reject(e);
return;
}
}
}
else if (res.body && !expectBinary) {
parsedBody = res.body.toString("utf-8");
}
else {
parsedBody = res.body;
}
if (error_1.isArangoErrorResponse(parsedBody)) {
res.body = parsedBody;
const err = new error_1.ArangoError(res);
if (task.stack) {
err.stack += task.stack();
}
reject(err);
}
else if (res.statusCode && res.statusCode >= 400) {
res.body = parsedBody;
const err = new error_1.HttpError(res);
if (task.stack) {
err.stack += task.stack();
}
reject(err);
}
else {
if (!expectBinary)
res.body = parsedBody;
resolve(transform ? transform(res) : res);
}
},
resolve,
transform,
};

@@ -500,0 +501,0 @@ if (this._precaptureStackTraces) {

@@ -23,3 +23,3 @@ # Contributing

By default the tests will be run against a server listening on
`http://localhost:8529` (using username `root` with no password). To
`http://127.0.0.1:8529` (using username `root` with no password). To
override this, you can set the environment variable `TEST_ARANGODB_URL` to

@@ -26,0 +26,0 @@ something different:

@@ -11,3 +11,2 @@ /**

import { LinkedList } from "x3-linkedlist";
import { Dict } from "./connection";
import { Database } from "./database";

@@ -28,12 +27,77 @@ /**

*/
plan?: any;
plan?: Record<string, any>;
/**
* Additional profiling information for the executed query.
*/
profile?: any;
profile?: Record<string, number>;
/**
* Additional statistics about the query execution.
*/
stats?: Dict<any>;
stats?: CursorStats;
}
/**
* Additional statics about the query execution of the cursor.
*/
export interface CursorStats {
/**
* Total number of index entries read from in-memory caches for indexes of
* type edge or persistent.
*/
cacheHits: number;
/**
* Total number of cache read attempts for index entries that could not be
* served from in-memory caches for indexes of type edge or persistent.
*/
cacheMisses: number;
/**
* Total number of cursor objects created during query execution.
*/
cursorsCreated: number;
/**
* Total number of times an existing cursor object was repurposed.
*/
cursorsRearmed: number;
/**
* Total number of data-modification operations successfully executed.
*/
writesExecuted: number;
/**
* Total number of data-modification operations that were unsuccessful, but have been ignored because of query option ignoreErrors.
*/
writesIgnored: number;
/**
* Total number of documents iterated over when scanning a collection without an index.
*/
scannedFull: number;
/**
* Total number of documents iterated over when scanning a collection using an index.
*/
scannedIndex: number;
/**
* Total number of documents that were removed after executing a filter condition in a FilterNode.
*/
filtered: number;
/**
* Maximum memory usage of the query while it was running.
*/
peakMemoryUsage: number;
/**
* Execution time of the query in seconds.
*/
executionTime: number;
/**
* Total number of documents that matched the search condition if the query’s final top-level LIMIT statement were not present.
*/
fullCount?: number;
/**
* Runtime statistics per query execution node.
*/
nodes?: {
id: number;
calls: number;
items: number;
filter: number;
runtime: number;
}[];
}
interface BatchView<T = any> {

@@ -80,3 +144,3 @@ isEmpty: boolean;

protected _id: string | undefined;
protected _host?: number;
protected _hostUrl?: string;
protected _allowDirtyRead?: boolean;

@@ -86,3 +150,2 @@ protected _itemsCursor: ArrayCursor<T>;

* @internal
* @hidden
*/

@@ -95,3 +158,3 @@ constructor(db: Database, body: {

count: number;
}, host?: number, allowDirtyRead?: boolean);
}, hostUrl?: string, allowDirtyRead?: boolean);
protected _more(): Promise<void>;

@@ -101,3 +164,3 @@ /**

*
* See also {@link ArrayCursor.batches}.
* See also {@link ArrayCursor#batches}.
*/

@@ -224,3 +287,3 @@ get items(): ArrayCursor<T>;

* See also:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach | `Array.prototype.forEach`}.
* [`Array.prototype.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach).
*

@@ -268,7 +331,7 @@ * @param callback - Function to execute on each element.

* memory use when working with very large query result sets. Consider using
* {@link BatchedArrayCursor.forEach}, {@link BatchedArrayCursor.reduce} or
* {@link BatchedArrayCursor.flatMap} instead.
* {@link BatchedArrayCursor#forEach}, {@link BatchedArrayCursor#reduce} or
* {@link BatchedArrayCursor#flatMap} instead.
*
* See also:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | `Array.prototype.map`}.
* [`Array.prototype.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
*

@@ -303,3 +366,3 @@ * @param R - Return type of the `callback` function.

* See also:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | `Array.prototype.flatMap`}.
* [`Array.prototype.flatMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap).
*

@@ -344,3 +407,3 @@ * @param R - Return type of the `callback` function.

* **Note**: Most complex uses of the `reduce` method can be replaced with
* simpler code using {@link BatchedArrayCursor.forEach} or the `for await`
* simpler code using {@link BatchedArrayCursor#forEach} or the `for await`
* syntax.

@@ -354,3 +417,3 @@ *

* See also:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | `Array.prototype.reduce`}.
* [`Array.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).
*

@@ -421,3 +484,3 @@ * @param R - Return type of the `reducer` function.

* See also:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | `Array.prototype.reduce`}.
* [`Array.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).
*

@@ -466,3 +529,3 @@ * @param R - Return type of the `reducer` function.

* The `ArrayCursor` type represents a cursor returned from a
* {@link Database.query}.
* {@link database.Database#query}.
*

@@ -497,2 +560,5 @@ * When using TypeScript, cursors can be cast to a specific item type in order

protected _view: BatchView<T>;
/**
* @internal
*/
constructor(batchedCursor: BatchedArrayCursor, view: BatchView<T>);

@@ -503,3 +569,3 @@ /**

*
* See also {@link BatchedArrayCursor.items}.
* See also {@link BatchedArrayCursor#items}.
*/

@@ -586,3 +652,3 @@ get batches(): BatchedArrayCursor<T>;

* See also:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach | `Array.prototype.forEach`}.
* [`Array.prototype.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach).
*

@@ -620,7 +686,7 @@ * @param callback - Function to execute on each element.

* memory use when working with very large query result sets. Consider using
* {@link ArrayCursor.forEach}, {@link ArrayCursor.reduce} or
* {@link ArrayCursor.flatMap} instead.
* {@link ArrayCursor#forEach}, {@link ArrayCursor#reduce} or
* {@link ArrayCursor#flatMap} instead.
*
* See also:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | `Array.prototype.map`}.
* [`Array.prototype.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
*

@@ -652,3 +718,3 @@ * @param R - Return type of the `callback` function.

* See also:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | `Array.prototype.flatMap`}.
* [`Array.prototype.flatMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap).
*

@@ -687,3 +753,3 @@ * @param R - Return type of the `callback` function.

* **Note**: Most complex uses of the `reduce` method can be replaced with
* simpler code using {@link ArrayCursor.forEach} or the `for await` syntax.
* simpler code using {@link ArrayCursor#forEach} or the `for await` syntax.
*

@@ -696,3 +762,3 @@ * **Note**: If the result set spans multiple batches, any remaining batches

* See also:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | `Array.prototype.reduce`}.
* [`Array.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).
*

@@ -757,3 +823,3 @@ * @param R - Return type of the `reducer` function.

* See also:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | `Array.prototype.reduce`}.
* [`Array.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).
*

@@ -760,0 +826,0 @@ * @param R - Return type of the `reducer` function.

@@ -46,5 +46,4 @@ "use strict";

* @internal
* @hidden
*/
constructor(db, body, host, allowDirtyRead) {
constructor(db, body, hostUrl, allowDirtyRead) {
const batches = new x3_linkedlist_1.LinkedList(body.result.length ? [new x3_linkedlist_1.LinkedList(body.result)] : []);

@@ -55,3 +54,3 @@ this._db = db;

this._hasMore = Boolean(body.id && body.hasMore);
this._host = host;
this._hostUrl = hostUrl;
this._count = body.count;

@@ -66,7 +65,6 @@ this._extra = body.extra;

shift: () => {
var _a, _b;
let batch = (_a = batches.first) === null || _a === void 0 ? void 0 : _a.value;
let batch = batches.first?.value;
while (batch && !batch.length) {
batches.shift();
batch = (_b = batches.first) === null || _b === void 0 ? void 0 : _b.value;
batch = batches.first?.value;
}

@@ -85,10 +83,10 @@ if (!batch)

return;
const res = await this._db.request({
const body = await this._db.request({
method: "PUT",
path: `/_api/cursor/${encodeURIComponent(this._id)}`,
host: this._host,
hostUrl: this._hostUrl,
allowDirtyRead: this._allowDirtyRead,
});
this._batches.push(new x3_linkedlist_1.LinkedList(res.body.result));
this._hasMore = res.body.hasMore;
this._batches.push(new x3_linkedlist_1.LinkedList(body.result));
this._hasMore = body.hasMore;
}

@@ -98,3 +96,3 @@ /**

*
* See also {@link ArrayCursor.batches}.
* See also {@link ArrayCursor#batches}.
*/

@@ -255,3 +253,3 @@ get items() {

* See also:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach | `Array.prototype.forEach`}.
* [`Array.prototype.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach).
*

@@ -311,7 +309,7 @@ * @param callback - Function to execute on each element.

* memory use when working with very large query result sets. Consider using
* {@link BatchedArrayCursor.forEach}, {@link BatchedArrayCursor.reduce} or
* {@link BatchedArrayCursor.flatMap} instead.
* {@link BatchedArrayCursor#forEach}, {@link BatchedArrayCursor#reduce} or
* {@link BatchedArrayCursor#flatMap} instead.
*
* See also:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | `Array.prototype.map`}.
* [`Array.prototype.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
*

@@ -355,3 +353,3 @@ * @param R - Return type of the `callback` function.

* See also:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | `Array.prototype.flatMap`}.
* [`Array.prototype.flatMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap).
*

@@ -461,3 +459,3 @@ * @param R - Return type of the `callback` function.

* The `ArrayCursor` type represents a cursor returned from a
* {@link Database.query}.
* {@link database.Database#query}.
*

@@ -490,2 +488,5 @@ * When using TypeScript, cursors can be cast to a specific item type in order

class ArrayCursor {
/**
* @internal
*/
constructor(batchedCursor, view) {

@@ -499,3 +500,3 @@ this._batches = batchedCursor;

*
* See also {@link BatchedArrayCursor.items}.
* See also {@link BatchedArrayCursor#items}.
*/

@@ -605,3 +606,3 @@ get batches() {

* See also:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach | `Array.prototype.forEach`}.
* [`Array.prototype.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach).
*

@@ -649,7 +650,7 @@ * @param callback - Function to execute on each element.

* memory use when working with very large query result sets. Consider using
* {@link ArrayCursor.forEach}, {@link ArrayCursor.reduce} or
* {@link ArrayCursor.flatMap} instead.
* {@link ArrayCursor#forEach}, {@link ArrayCursor#reduce} or
* {@link ArrayCursor#flatMap} instead.
*
* See also:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | `Array.prototype.map`}.
* [`Array.prototype.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
*

@@ -690,3 +691,3 @@ * @param R - Return type of the `callback` function.

* See also:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | `Array.prototype.flatMap`}.
* [`Array.prototype.flatMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap).
*

@@ -693,0 +694,0 @@ * @param R - Return type of the `callback` function.

@@ -71,3 +71,3 @@ /**

*
* See {@link DocumentMetadata}.
* See {@link documents.DocumentMetadata}.
*/

@@ -81,3 +81,3 @@ export declare type ObjectWithId = {

*
* See {@link DocumentMetadata}.
* See {@link documents.DocumentMetadata}.
*/

@@ -93,3 +93,3 @@ export declare type ObjectWithKey = {

*
* See {@link DocumentMetadata}.
* See {@link documents.DocumentMetadata}.
*/

@@ -99,5 +99,4 @@ export declare type DocumentSelector = ObjectWithId | ObjectWithKey | string;

* @internal
* @hidden
*/
export declare function _documentHandle(selector: DocumentSelector, collectionName: string, strict?: boolean): string;
//# sourceMappingURL=documents.d.ts.map

@@ -15,3 +15,2 @@ "use strict";

* @internal
* @hidden
*/

@@ -18,0 +17,0 @@ function _documentHandle(selector, collectionName, strict = true) {

@@ -11,3 +11,2 @@ /**

*/
import { ExtendableError } from "./lib/error";
/**

@@ -40,3 +39,3 @@ * Indicates whether the given value represents an {@link ArangoError}.

*/
export declare class ArangoError extends ExtendableError {
export declare class ArangoError extends Error {
name: string;

@@ -46,3 +45,3 @@ /**

*
* See {@link https://www.arangodb.com/docs/stable/appendix-error-codes.html | ArangoDB error documentation}.
* See [ArangoDB error documentation](https://www.arangodb.com/docs/stable/appendix-error-codes.html).
*/

@@ -60,3 +59,2 @@ errorNum: number;

* @internal
* @hidden
*/

@@ -80,3 +78,3 @@ constructor(response: any);

*/
export declare class HttpError extends ExtendableError {
export declare class HttpError extends Error {
name: string;

@@ -93,3 +91,2 @@ /**

* @internal
* @hidden
*/

@@ -96,0 +93,0 @@ constructor(response: any);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpError = exports.ArangoError = exports.isSystemError = exports.isArangoErrorResponse = exports.isArangoError = void 0;
/**

@@ -14,5 +12,7 @@ * ```ts

*/
const error_1 = require("./lib/error");
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpError = exports.ArangoError = exports.isSystemError = exports.isArangoErrorResponse = exports.isArangoError = void 0;
const messages = {
0: "Network Error",
304: "Not Modified",
400: "Bad Request",

@@ -104,6 +104,5 @@ 401: "Unauthorized",

*/
class ArangoError extends error_1.ExtendableError {
class ArangoError extends Error {
/**
* @internal
* @hidden
*/

@@ -145,6 +144,5 @@ constructor(response) {

*/
class HttpError extends error_1.ExtendableError {
class HttpError extends Error {
/**
* @internal
* @hidden
*/

@@ -151,0 +149,0 @@ constructor(response) {

@@ -8,3 +8,3 @@ /**

*
* Generated from {@link http://json.schemastore.org/foxx-manifest | JSON Schema}
* Generated from [JSON Schema](http://json.schemastore.org/foxx-manifest)
* using `json-schema-to-typescript`.

@@ -14,3 +14,2 @@ *

*/
import { Dict } from "./connection";
/**

@@ -23,3 +22,3 @@ * Schema for ArangoDB Foxx service manifests.

*/
configuration?: Dict<Configuration>;
configuration?: Record<string, Configuration>;
/**

@@ -32,11 +31,11 @@ * If specified, the / (root) route of the service will automatically redirect to the given relative path, e.g. "index.html".

*/
dependencies?: Dict<string | Dependency>;
dependencies?: Record<string, string | Dependency>;
/**
* The dependencies this provides, i.e. which APIs it claims to be compatible with.
*/
provides?: Dict<string>;
provides?: Record<string, string>;
/**
* An object indicating the semantic version ranges of ArangoDB (or compatible environments) the service will be compatible with.
*/
engines?: Dict<string> & {
engines?: Record<string, string> & {
arangodb?: string;

@@ -47,3 +46,3 @@ };

*/
files?: Dict<string | File>;
files?: Record<string, string | File>;
/**

@@ -60,3 +59,3 @@ * The relative path to the Foxx JavaScript files in the service, e.g. "lib". Defaults to the folder containing this manifest.

*/
scripts?: Dict<string>;
scripts?: Record<string, string>;
/**

@@ -63,0 +62,0 @@ * A path/pattern or list of paths/patterns of JavaScript tests provided for this service.

@@ -9,3 +9,3 @@ "use strict";

*
* Generated from {@link http://json.schemastore.org/foxx-manifest | JSON Schema}
* Generated from [JSON Schema](http://json.schemastore.org/foxx-manifest)
* using `json-schema-to-typescript`.

@@ -12,0 +12,0 @@ *

@@ -19,3 +19,3 @@ /**

/**
* Indicates whether the given value represents a {@link Graph}.
* Indicates whether the given value represents a {@link graph.Graph}.
*

@@ -33,3 +33,3 @@ * @param graph - A value that might be a Graph.

*
* See also {@link DocumentMetadata}.
* See also {@link documents.DocumentMetadata}.
*/

@@ -79,3 +79,3 @@ rev?: string;

*
* See also {@link DocumentMetadata}.
* See also {@link documents.DocumentMetadata}.
*/

@@ -119,3 +119,3 @@ rev?: string;

*
* See also {@link DocumentMetadata}.
* See also {@link documents.DocumentMetadata}.
*/

@@ -138,3 +138,3 @@ rev?: string;

/**
* Definition of a relation in a {@link Graph}.
* Definition of a relation in a {@link graph.Graph}.
*/

@@ -156,3 +156,3 @@ export declare type EdgeDefinition = {

/**
* An edge definition used to define a collection of edges in a {@link Graph}.
* An edge definition used to define a collection of edges in a {@link graph.Graph}.
*/

@@ -180,3 +180,3 @@ export declare type EdgeDefinitionOptions = {

*
* See {@link DocumentMetadata}.
* See {@link documents.DocumentMetadata}.
*

@@ -189,3 +189,3 @@ * @internal

*
* See {@link DocumentMetadata}.
* See {@link documents.DocumentMetadata}.
*

@@ -198,3 +198,3 @@ * @internal

*
* See {@link DocumentMetadata}.
* See {@link documents.DocumentMetadata}.
*

@@ -232,8 +232,2 @@ * @internal

/**
* (Cluster only.) Write concern for new collections in the graph.
*
* @deprecated Renamed to `writeConcern` in ArangoDB 3.6.
*/
minReplicationFactor?: number;
/**
* (Enterprise Edition cluster only.) If set to `true`, the graph is a

@@ -262,3 +256,3 @@ * SatelliteGraph.

*/
export declare type GraphCreateOptions = {
export declare type CreateGraphOptions = {
/**

@@ -297,10 +291,2 @@ * If set to `true`, the request will wait until all modifications have been

/**
* (Cluster only.) Write concern for new collections in the graph.
*
* Has no effect when `replicationFactor` is set to `"satellite"`.
*
* @deprecated Renamed to `writeConcern` in ArangoDB 3.6.
*/
minReplicationFactor?: number;
/**
* (Enterprise Edition cluster only.) If set to `true`, the graph will be

@@ -315,4 +301,2 @@ * created as a SmartGraph.

* value to use for smart sharding.
*
* **Note**: `isSmart` must be set to `true`.
*/

@@ -355,3 +339,3 @@ smartGraphAttribute?: string;

/**
* Represents a {@link DocumentCollection} of vertices in a {@link Graph}.
* Represents a {@link collection.DocumentCollection} of vertices in a {@link graph.Graph}.
*

@@ -367,3 +351,2 @@ * @param T - Type to use for document data. Defaults to `any`.

* @internal
* @hidden
*/

@@ -382,7 +365,7 @@ constructor(db: Database, name: string, graph: Graph);

/**
* A {@link DocumentCollection} instance for this vertex collection.
* A {@link collection.DocumentCollection} instance for this vertex collection.
*/
get collection(): DocumentCollection<T>;
/**
* The {@link Graph} instance this vertex collection is bound to.
* The {@link graph.Graph} instance this vertex collection is bound to.
*/

@@ -428,3 +411,3 @@ get graph(): Graph;

* console.log(vertex);
* } catch (e) {
* } catch (e: any) {
* console.error("Could not find vertex");

@@ -465,3 +448,3 @@ * }

* console.log(vertex);
* } catch (e) {
* } catch (e: any) {
* console.error("Could not find vertex");

@@ -592,3 +575,3 @@ * }

/**
* Represents a {@link EdgeCollection} of edges in a {@link Graph}.
* Represents a {@link collection.EdgeCollection} of edges in a {@link graph.Graph}.
*

@@ -604,3 +587,2 @@ * @param T - Type to use for document data. Defaults to `any`.

* @internal
* @hidden
*/

@@ -619,7 +601,7 @@ constructor(db: Database, name: string, graph: Graph);

/**
* A {@link EdgeCollection} instance for this edge collection.
* A {@link collection.EdgeCollection} instance for this edge collection.
*/
get collection(): EdgeCollection<T>;
/**
* The {@link Graph} instance this edge collection is bound to.
* The {@link graph.Graph} instance this edge collection is bound to.
*/

@@ -665,3 +647,3 @@ get graph(): Graph;

* console.log(edge);
* } catch (e) {
* } catch (e: any) {
* console.error("Could not find edge");

@@ -702,3 +684,3 @@ * }

* console.log(edge);
* } catch (e) {
* } catch (e: any) {
* console.error("Could not find edge");

@@ -836,3 +818,3 @@ * }

/**
* Represents a graph in a {@link Database}.
* Represents a graph in a {@link database.Database}.
*/

@@ -844,3 +826,2 @@ export declare class Graph {

* @internal
* @hidden
*/

@@ -903,3 +884,3 @@ constructor(db: Database, name: string);

*/
create(edgeDefinitions: EdgeDefinitionOptions[], options?: GraphCreateOptions): Promise<GraphInfo>;
create(edgeDefinitions: EdgeDefinitionOptions[], options?: CreateGraphOptions): Promise<GraphInfo>;
/**

@@ -921,3 +902,3 @@ * Deletes the graph from the database.

/**
* Returns a {@link GraphVertexCollection} instance for the given collection
* Returns a {@link graph.GraphVertexCollection} instance for the given collection
* name representing the collection in this graph.

@@ -933,3 +914,3 @@ *

*
* See also {@link Graph.vertexCollections}.
* See also {@link graph.Graph#vertexCollections}.
*

@@ -954,5 +935,5 @@ * @example

* Fetches all vertex collections of this graph from the database and returns
* an array of {@link GraphVertexCollection} instances.
* an array of {@link graph.GraphVertexCollection} instances.
*
* See also {@link Graph.listVertexCollections}.
* See also {@link graph.Graph#listVertexCollections}.
*

@@ -1020,3 +1001,3 @@ * @example

/**
* Returns a {@link GraphEdgeCollection} instance for the given collection
* Returns a {@link graph.GraphEdgeCollection} instance for the given collection
* name representing the collection in this graph.

@@ -1048,3 +1029,3 @@ *

*
* See also {@link Graph.edgeCollections}.
* See also {@link graph.Graph#edgeCollections}.
*

@@ -1069,5 +1050,5 @@ * @example

* Fetches all edge collections of this graph from the database and returns
* an array of {@link GraphEdgeCollection} instances.
* an array of {@link graph.GraphEdgeCollection} instances.
*
* See also {@link Graph.listEdgeCollections}.
* See also {@link graph.Graph#listEdgeCollections}.
*

@@ -1191,3 +1172,3 @@ * @example

*
* See also {@link EdgeCollection.traversal}.
* See also {@link collection.EdgeCollection#traversal}.
*

@@ -1211,8 +1192,9 @@ * @param startVertex - Document `_id` of a vertex in this graph.

* ]);
* const result = await graph.traversal("vertices/a", {
* direction: "outbound",
* init: "result.vertices = [];",
* visitor: "result.vertices.push(vertex._key);",
* });
* console.log(result.vertices); // ["a", "b", "c", "d"]
* const startVertex = "vertices/a";
* const cursor = await db.query(aql`
* FOR vertex IN OUTBOUND ${startVertex} GRAPH ${graph}
* RETURN vertex._key
* `);
* const result = await cursor.all();
* console.log(result); // ["a", "b", "c", "d"]
* ```

@@ -1219,0 +1201,0 @@ */

@@ -23,3 +23,3 @@ "use strict";

/**
* Indicates whether the given value represents a {@link Graph}.
* Indicates whether the given value represents a {@link graph.Graph}.
*

@@ -34,3 +34,2 @@ * @param graph - A value that might be a Graph.

* @internal
* @hidden
*/

@@ -48,17 +47,16 @@ function mungeGharialResponse(body, prop) {

* @internal
* @hidden
*/
function coerceEdgeDefinition(options) {
const edgeDefinition = {};
edgeDefinition.collection = collection_1.collectionToString(options.collection);
edgeDefinition.collection = (0, collection_1.collectionToString)(options.collection);
edgeDefinition.from = Array.isArray(options.from)
? options.from.map(collection_1.collectionToString)
: [collection_1.collectionToString(options.from)];
: [(0, collection_1.collectionToString)(options.from)];
edgeDefinition.to = Array.isArray(options.to)
? options.to.map(collection_1.collectionToString)
: [collection_1.collectionToString(options.to)];
: [(0, collection_1.collectionToString)(options.to)];
return edgeDefinition;
}
/**
* Represents a {@link DocumentCollection} of vertices in a {@link Graph}.
* Represents a {@link collection.DocumentCollection} of vertices in a {@link graph.Graph}.
*

@@ -70,3 +68,2 @@ * @param T - Type to use for document data. Defaults to `any`.

* @internal
* @hidden
*/

@@ -94,3 +91,3 @@ constructor(db, name, graph) {

/**
* A {@link DocumentCollection} instance for this vertex collection.
* A {@link collection.DocumentCollection} instance for this vertex collection.
*/

@@ -101,3 +98,3 @@ get collection() {

/**
* The {@link Graph} instance this vertex collection is bound to.
* The {@link graph.Graph} instance this vertex collection is bound to.
*/

@@ -131,3 +128,3 @@ get graph() {

method: "HEAD",
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/vertex/${encodeURI(documents_1._documentHandle(selector, this._name))}`,
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/vertex/${encodeURI((0, documents_1._documentHandle)(selector, this._name))}`,
}, () => true);

@@ -151,3 +148,3 @@ }

const result = this._db.request({
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/vertex/${encodeURI(documents_1._documentHandle(selector, this._name))}`,
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/vertex/${encodeURI((0, documents_1._documentHandle)(selector, this._name))}`,
headers,

@@ -163,3 +160,3 @@ qs,

catch (err) {
if (error_1.isArangoError(err) && err.errorNum === codes_1.DOCUMENT_NOT_FOUND) {
if ((0, error_1.isArangoError)(err) && err.errorNum === codes_1.DOCUMENT_NOT_FOUND) {
return null;

@@ -188,3 +185,3 @@ }

method: "PUT",
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/vertex/${encodeURI(documents_1._documentHandle(selector, this._name))}`,
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/vertex/${encodeURI((0, documents_1._documentHandle)(selector, this._name))}`,
body: newValue,

@@ -205,3 +202,3 @@ qs,

method: "PATCH",
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/vertex/${encodeURI(documents_1._documentHandle(selector, this._name))}`,
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/vertex/${encodeURI((0, documents_1._documentHandle)(selector, this._name))}`,
body: newValue,

@@ -222,3 +219,3 @@ qs,

method: "DELETE",
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/vertex/${encodeURI(documents_1._documentHandle(selector, this._name))}`,
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/vertex/${encodeURI((0, documents_1._documentHandle)(selector, this._name))}`,
qs,

@@ -231,3 +228,3 @@ headers,

/**
* Represents a {@link EdgeCollection} of edges in a {@link Graph}.
* Represents a {@link collection.EdgeCollection} of edges in a {@link graph.Graph}.
*

@@ -239,3 +236,2 @@ * @param T - Type to use for document data. Defaults to `any`.

* @internal
* @hidden
*/

@@ -263,3 +259,3 @@ constructor(db, name, graph) {

/**
* A {@link EdgeCollection} instance for this edge collection.
* A {@link collection.EdgeCollection} instance for this edge collection.
*/

@@ -270,3 +266,3 @@ get collection() {

/**
* The {@link Graph} instance this edge collection is bound to.
* The {@link graph.Graph} instance this edge collection is bound to.
*/

@@ -300,3 +296,3 @@ get graph() {

method: "HEAD",
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/edge/${encodeURI(documents_1._documentHandle(selector, this._name))}`,
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/edge/${encodeURI((0, documents_1._documentHandle)(selector, this._name))}`,
}, () => true);

@@ -320,3 +316,3 @@ }

const result = this._db.request({
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/edge/${encodeURI(documents_1._documentHandle(selector, this._name))}`,
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/edge/${encodeURI((0, documents_1._documentHandle)(selector, this._name))}`,
qs,

@@ -331,3 +327,3 @@ allowDirtyRead,

catch (err) {
if (error_1.isArangoError(err) && err.errorNum === codes_1.DOCUMENT_NOT_FOUND) {
if ((0, error_1.isArangoError)(err) && err.errorNum === codes_1.DOCUMENT_NOT_FOUND) {
return null;

@@ -356,3 +352,3 @@ }

method: "PUT",
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/edge/${encodeURI(documents_1._documentHandle(selector, this._name))}`,
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/edge/${encodeURI((0, documents_1._documentHandle)(selector, this._name))}`,
body: newValue,

@@ -373,3 +369,3 @@ qs,

method: "PATCH",
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/edge/${encodeURI(documents_1._documentHandle(selector, this._name))}`,
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/edge/${encodeURI((0, documents_1._documentHandle)(selector, this._name))}`,
body: newValue,

@@ -390,3 +386,3 @@ qs,

method: "DELETE",
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/edge/${encodeURI(documents_1._documentHandle(selector, this._name))}`,
path: `/_api/gharial/${encodeURIComponent(this.graph.name)}/edge/${encodeURI((0, documents_1._documentHandle)(selector, this._name))}`,
qs,

@@ -399,3 +395,3 @@ headers,

/**
* Represents a graph in a {@link Database}.
* Represents a graph in a {@link database.Database}.
*/

@@ -405,3 +401,2 @@ class Graph {

* @internal
* @hidden
*/

@@ -443,3 +438,3 @@ constructor(db, name) {

catch (err) {
if (error_1.isArangoError(err) && err.errorNum === codes_1.GRAPH_NOT_FOUND) {
if ((0, error_1.isArangoError)(err) && err.errorNum === codes_1.GRAPH_NOT_FOUND) {
return false;

@@ -485,4 +480,4 @@ }

*/
create(edgeDefinitions, options) {
const { orphanCollections, satellites, waitForSync, isSmart, isDisjoint, ...opts } = options !== null && options !== void 0 ? options : {};
create(edgeDefinitions, options = {}) {
const { orphanCollections, satellites, waitForSync, isSmart, isDisjoint, ...opts } = options;
return this._db.request({

@@ -495,3 +490,3 @@ method: "POST",

? orphanCollections.map(collection_1.collectionToString)
: [collection_1.collectionToString(orphanCollections)]),
: [(0, collection_1.collectionToString)(orphanCollections)]),
edgeDefinitions: edgeDefinitions.map(coerceEdgeDefinition),

@@ -501,3 +496,3 @@ isSmart,

name: this._name,
options: { ...opts, satellites: satellites === null || satellites === void 0 ? void 0 : satellites.map(collection_1.collectionToString) },
options: { ...opts, satellites: satellites?.map(collection_1.collectionToString) },
},

@@ -529,3 +524,3 @@ qs: { waitForSync },

/**
* Returns a {@link GraphVertexCollection} instance for the given collection
* Returns a {@link graph.GraphVertexCollection} instance for the given collection
* name representing the collection in this graph.

@@ -537,3 +532,3 @@ *

vertexCollection(collection) {
return new GraphVertexCollection(this._db, collection_1.collectionToString(collection), this);
return new GraphVertexCollection(this._db, (0, collection_1.collectionToString)(collection), this);
}

@@ -544,3 +539,3 @@ /**

*
* See also {@link Graph.vertexCollections}.
* See also {@link graph.Graph#vertexCollections}.
*

@@ -567,5 +562,5 @@ * @example

* Fetches all vertex collections of this graph from the database and returns
* an array of {@link GraphVertexCollection} instances.
* an array of {@link graph.GraphVertexCollection} instances.
*
* See also {@link Graph.listVertexCollections}.
* See also {@link graph.Graph#listVertexCollections}.
*

@@ -611,4 +606,4 @@ * @example

*/
addVertexCollection(collection, options) {
const { satellites, ...opts } = options !== null && options !== void 0 ? options : {};
addVertexCollection(collection, options = {}) {
const { satellites, ...opts } = options;
return this._db.request({

@@ -618,4 +613,4 @@ method: "POST",

body: {
collection: collection_1.collectionToString(collection),
options: { ...opts, satellites: satellites === null || satellites === void 0 ? void 0 : satellites.map(collection_1.collectionToString) },
collection: (0, collection_1.collectionToString)(collection),
options: { ...opts, satellites: satellites?.map(collection_1.collectionToString) },
},

@@ -649,3 +644,3 @@ }, (res) => res.body.graph);

method: "DELETE",
path: `/_api/gharial/${encodeURIComponent(this._name)}/vertex/${encodeURIComponent(collection_1.collectionToString(collection))}`,
path: `/_api/gharial/${encodeURIComponent(this._name)}/vertex/${encodeURIComponent((0, collection_1.collectionToString)(collection))}`,
qs: {

@@ -657,3 +652,3 @@ dropCollection,

/**
* Returns a {@link GraphEdgeCollection} instance for the given collection
* Returns a {@link graph.GraphEdgeCollection} instance for the given collection
* name representing the collection in this graph.

@@ -681,3 +676,3 @@ *

edgeCollection(collection) {
return new GraphEdgeCollection(this._db, collection_1.collectionToString(collection), this);
return new GraphEdgeCollection(this._db, (0, collection_1.collectionToString)(collection), this);
}

@@ -688,3 +683,3 @@ /**

*
* See also {@link Graph.edgeCollections}.
* See also {@link graph.Graph#edgeCollections}.
*

@@ -711,5 +706,5 @@ * @example

* Fetches all edge collections of this graph from the database and returns
* an array of {@link GraphEdgeCollection} instances.
* an array of {@link graph.GraphEdgeCollection} instances.
*
* See also {@link Graph.listEdgeCollections}.
* See also {@link graph.Graph#listEdgeCollections}.
*

@@ -755,4 +750,4 @@ * @example

*/
addEdgeDefinition(edgeDefinition, options) {
const { satellites, ...opts } = options !== null && options !== void 0 ? options : {};
addEdgeDefinition(edgeDefinition, options = {}) {
const { satellites, ...opts } = options;
return this._db.request({

@@ -763,7 +758,7 @@ method: "POST",

...coerceEdgeDefinition(edgeDefinition),
options: { ...opts, satellites: satellites === null || satellites === void 0 ? void 0 : satellites.map(collection_1.collectionToString) },
options: { ...opts, satellites: satellites?.map(collection_1.collectionToString) },
},
}, (res) => res.body.graph);
}
replaceEdgeDefinition(collectionOrEdgeDefinitionOptions, edgeDefinitionOrOptions, options) {
replaceEdgeDefinition(collectionOrEdgeDefinitionOptions, edgeDefinitionOrOptions, options = {}) {
let collection = collectionOrEdgeDefinitionOptions;

@@ -781,9 +776,9 @@ let edgeDefinition = edgeDefinitionOrOptions;

}
const { satellites, ...opts } = options !== null && options !== void 0 ? options : {};
const { satellites, ...opts } = options;
return this._db.request({
method: "PUT",
path: `/_api/gharial/${encodeURIComponent(this._name)}/edge/${encodeURIComponent(collection_1.collectionToString(collection))}`,
path: `/_api/gharial/${encodeURIComponent(this._name)}/edge/${encodeURIComponent((0, collection_1.collectionToString)(collection))}`,
body: {
...coerceEdgeDefinition(edgeDefinition),
options: { ...opts, satellites: satellites === null || satellites === void 0 ? void 0 : satellites.map(collection_1.collectionToString) },
options: { ...opts, satellites: satellites?.map(collection_1.collectionToString) },
},

@@ -817,3 +812,3 @@ }, (res) => res.body.graph);

method: "DELETE",
path: `/_api/gharial/${encodeURIComponent(this._name)}/edge/${encodeURIComponent(collection_1.collectionToString(collection))}`,
path: `/_api/gharial/${encodeURIComponent(this._name)}/edge/${encodeURIComponent((0, collection_1.collectionToString)(collection))}`,
qs: {

@@ -828,3 +823,3 @@ dropCollection,

*
* See also {@link EdgeCollection.traversal}.
* See also {@link collection.EdgeCollection#traversal}.
*

@@ -848,8 +843,9 @@ * @param startVertex - Document `_id` of a vertex in this graph.

* ]);
* const result = await graph.traversal("vertices/a", {
* direction: "outbound",
* init: "result.vertices = [];",
* visitor: "result.vertices.push(vertex._key);",
* });
* console.log(result.vertices); // ["a", "b", "c", "d"]
* const startVertex = "vertices/a";
* const cursor = await db.query(aql`
* FOR vertex IN OUTBOUND ${startVertex} GRAPH ${graph}
* RETURN vertex._key
* `);
* const result = await cursor.all();
* console.log(result); // ["a", "b", "c", "d"]
* ```

@@ -856,0 +852,0 @@ */

@@ -11,3 +11,3 @@ /**

* {@link arangojs} function, which is also the default export of this module,
* or the {@link Database} class for which it is a wrapper.
* or the {@link database.Database} class for which it is a wrapper.
*

@@ -21,3 +21,3 @@ * @packageDocumentation

*
* This is a wrapper function for the {@link Database.constructor}.
* This is a wrapper function for the {@link database.Database:constructor}.
*

@@ -29,3 +29,3 @@ * @param config - An object with configuration options.

* const db = arangojs({
* url: "http://localhost:8529",
* url: "http://127.0.0.1:8529",
* databaseName: "myDatabase",

@@ -40,10 +40,10 @@ * auth: { username: "admin", password: "hunter2" },

*
* This is a wrapper function for the {@link Database.constructor}.
* This is a wrapper function for the {@link database.Database:constructor}.
*
* @param url - Base URL of the ArangoDB server or list of server URLs.
* Equivalent to the `url` option in {@link Config}.
* Equivalent to the `url` option in {@link connection.Config}.
*
* @example
* ```js
* const db = arangojs("http://localhost:8529", "myDatabase");
* const db = arangojs("http://127.0.0.1:8529", "myDatabase");
* db.useBasicAuth("admin", "hunter2");

@@ -55,5 +55,3 @@ * ```

export { aql } from "./aql";
export { CollectionStatus, CollectionType } from "./collection";
export { Database } from "./database";
export { ViewType } from "./view";
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.arangojs = void 0;
exports.Database = exports.aql = exports.arangojs = void 0;
const database_1 = require("./database");

@@ -17,9 +17,4 @@ module.exports = exports = arangojs;

Object.defineProperty(exports, "aql", { enumerable: true, get: function () { return aql_1.aql; } });
var collection_1 = require("./collection");
Object.defineProperty(exports, "CollectionStatus", { enumerable: true, get: function () { return collection_1.CollectionStatus; } });
Object.defineProperty(exports, "CollectionType", { enumerable: true, get: function () { return collection_1.CollectionType; } });
var database_2 = require("./database");
Object.defineProperty(exports, "Database", { enumerable: true, get: function () { return database_2.Database; } });
var view_1 = require("./view");
Object.defineProperty(exports, "ViewType", { enumerable: true, get: function () { return view_1.ViewType; } });
//# sourceMappingURL=index.js.map

@@ -6,7 +6,6 @@ /**

* GeoIndex,
* HashIndex,
* PersistentIndex,
* PrimaryIndex,
* SkiplistIndex,
* TtlIndex,
* ZkdIndex,
* } from "arangojs/indexes";

@@ -19,16 +18,12 @@ * ```

*/
import { AnalyzerFeature } from "./analyzer";
import { Compression, Direction, TierConsolidationPolicy } from "./view";
/**
* (MMFiles only.) Options for creating a hash index.
*
* When using the RocksDB storage engine, this index type behaves identically
* to {@link EnsurePersistentIndexOptions}.
*
* @deprecated Hash indexes have been deprecated in ArangoDB 3.9 and should be
* replaced with persistent indexes.
* Options for creating a persistent index.
*/
export declare type EnsureHashIndexOptions = {
export declare type EnsurePersistentIndexOptions = {
/**
* Type of this index.
*/
type: "hash";
type: "persistent";
/**

@@ -57,3 +52,4 @@ * An array of attribute paths.

/**
* If set to `false`, array values will not be deduplicated.
* If set to `false`, inserting duplicate index values from the same
* document will lead to a unique constraint error if this is a unique index.
*

@@ -77,106 +73,16 @@ * Default: `true`

inBackground?: boolean;
};
/**
* (MMFiles only.) Options for creating a skiplist index.
*
* When using the RocksDB storage engine, this index type behaves identically
* to {@link EnsurePersistentIndexOptions}.
*
* @deprecated Skiplist indexes have been deprecated in ArangoDB 3.9 and should
* be replaced with persistent indexes.
*/
export declare type EnsureSkiplistIndexOptions = {
/**
* Type of this index.
*/
type: "skiplist";
/**
* An array of attribute paths.
*/
fields: string[];
/**
* A unique name for this index.
*/
name?: string;
/**
* If set to `true`, a unique index will be created.
* If set to `true`, an in-memory hash cache will be put in front of the
* persistent index.
*
* Default: `false`
*/
unique?: boolean;
cacheEnabled?: boolean;
/**
* If set to `true`, the index will omit documents that do not contain at
* least one of the attribute paths in `fields` and these documents will be
* ignored for uniqueness checks.
*
* Default: `false`
* An array of attribute paths that will be stored in the index but can not
* be used for index lookups or sorting but can avoid full document lookups.
*/
sparse?: boolean;
/**
* If set to `false`, array values will not be deduplicated.
*
* Default: `true`
*/
deduplicate?: boolean;
/**
* If set to `false`, index selectivity estimates will be disabled for this
* index.
*
* Default: `true`
*/
estimates?: boolean;
/**
* If set to `true`, the index will be created in the background to reduce
* the write-lock duration for the collection during index creation.
*
* Default: `false`
*/
inBackground?: boolean;
storedValues?: string[];
};
/**
* Options for creating a persistent index.
*/
export declare type EnsurePersistentIndexOptions = {
/**
* Type of this index.
*/
type: "persistent";
/**
* An array of attribute paths.
*/
fields: string[];
/**
* A unique name for this index.
*/
name?: string;
/**
* If set to `true`, a unique index will be created.
*
* Default: `false`
*/
unique?: boolean;
/**
* If set to `true`, the index will omit documents that do not contain at
* least one of the attribute paths in `fields` and these documents will be
* ignored for uniqueness checks.
*
* Default: `false`
*/
sparse?: boolean;
/**
* If set to `false`, index selectivity estimates will be disabled for this
* index.
*
* Default: `true`
*/
estimates?: boolean;
/**
* If set to `true`, the index will be created in the background to reduce
* the write-lock duration for the collection during index creation.
*
* Default: `false`
*/
inBackground?: boolean;
};
/**
* Options for creating a geo index.

@@ -196,2 +102,8 @@ */

/**
* If set to `true`, the index will use pre-3.10 rules for parsing
* GeoJSON polygons. This option is always implicitly `true` when using
* ArangoDB 3.9 or lower.
*/
legacyPolygons?: boolean;
/**
* Attribute paths for the document's latitude and longitude values.

@@ -223,2 +135,8 @@ */

/**
* If set to `true`, the index will use pre-3.10 rules for parsing
* GeoJSON polygons. This option is always implicitly `true` when using
* ArangoDB 3.9 or lower.
*/
legacyPolygons?: boolean;
/**
* An array containing the attribute path for an array containing two values,

@@ -244,2 +162,5 @@ * the first of which will be interpreted as the latitude, the second as the

* Options for creating a fulltext index.
*
* @deprecated Fulltext indexes have been deprecated in ArangoDB 3.10 and
* should be replaced with ArangoSearch.
*/

@@ -321,2 +242,8 @@ export declare type EnsureFulltextIndexOptions = {

/**
* If set to `true`, a unique index will be created.
*
* Default: `false`
*/
unique?: boolean;
/**
* If set to `true`, the index will be created in the background to reduce

@@ -330,2 +257,254 @@ * the write-lock duration for the collection during index creation.

/**
* (Enterprise Edition only.) Options for a nested field in an inverted index.
*/
export declare type InvertedIndexNestedFieldOptions = {
/**
* An attribute path.
*/
name: string;
/**
* Name of the Analyzer to apply to the values of this field.
*
* Defaults to the `analyzer` specified on the parent options or on the index
* itself.
*/
analyzer?: string;
/**
* List of Analyzer features to enable for this field's Analyzer.
*
* Defaults to the features of the Analyzer.
*/
features?: AnalyzerFeature[];
/**
* If set to `true` array values will be indexed using the same behavior as
* ArangoSearch Views. This option only applies when using the index in a
* SearchAlias View.
*
* Defaults to the value of `searchField` specified on the index itself.
*/
searchField?: boolean;
/**
* Sub-objects to index to allow querying for co-occurring values.
*/
nested?: (string | InvertedIndexNestedFieldOptions)[];
};
/**
* Options for an attribute path in an inverted index.
*/
export declare type InvertedIndexFieldOptions = {
/**
* An attribute path.
*/
name: string;
/**
* Name of the Analyzer to apply to the values of this field.
*
* Defaults to the `analyzer` specified on the index itself.
*/
analyzer?: string;
/**
* List of Analyzer features to enable for this field's Analyzer.
*
* Defaults to the features of the Analyzer.
*/
features?: AnalyzerFeature[];
/**
* If set to `true`, all document attributes are indexed, excluding any
* sub-attributes configured in the `fields` array. The `analyzer` and
* `features` properties apply to the sub-attributes. This option only
* applies when using the index in a SearchAlias View.
*
* Defaults to the value of `includeAllFields` specified on the index itself.
*/
includeAllFields?: boolean;
/**
* If set to `true` array values will be indexed using the same behavior as
* ArangoSearch Views. This option only applies when using the index in a
* SearchAlias View.
*
* Defaults to the value of `searchField` specified on the index itself.
*/
searchField?: boolean;
/**
* If set to `true`, the position of values in array values are tracked and
* need to be specified in queries. Otherwise all values in an array are
* treated as equivalent. This option only applies when using the index in a
* SearchAlias View.
*
* Defaults to the value of `trackListPositions` specified on the index
* itself.
*/
trackListPositions?: boolean;
/**
* (Enterprise Edition only.) Sub-objects to index to allow querying for
* co-occurring values.
*/
nested?: (string | InvertedIndexNestedFieldOptions)[];
};
/**
* Options for defining a stored value on an inverted index.
*/
export declare type InvertedIndexStoredValueOptions = {
/**
* The attribute paths to store.
*/
fields: string[];
/**
* How the attribute values should be compressed.
*
* Default: `"lz4"`
*/
compression?: Compression;
};
/**
* Options for defining a primary sort field on an inverted index.
*/
export declare type InvertedIndexPrimarySortFieldOptions = {
/**
* The attribute path to sort by.
*/
field: string;
/**
* The sorting direction.
*/
direction: Direction;
};
/**
* Options for creating an inverted index.
*/
export declare type EnsureInvertedIndexOptions = {
/**
* Type of this index.
*/
type: "inverted";
/**
* An array of attribute paths or objects specifying options for the fields.
*/
fields: (string | InvertedIndexFieldOptions)[];
/**
* A unique name for this index.
*/
name?: string;
/**
* If set to `true` array values will by default be indexed using the same
* behavior as ArangoSearch Views. This option only applies when using the
* index in a SearchAlias View.
*
* Default: `false`
*/
searchField?: boolean;
/**
* An array of attribute paths that will be stored in the index but can not
* be used for index lookups or sorting but can avoid full document lookups.
*/
storedValues?: InvertedIndexStoredValueOptions[];
/**
* Primary sort order to optimize AQL queries using a matching sort order.
*/
primarySort?: {
/**
* An array of fields to sort the index by.
*/
fields: InvertedIndexPrimarySortFieldOptions[];
/**
* How the primary sort data should be compressed.
*
* Default: `"lz4"`
*/
compression?: Compression;
};
/**
* Name of the default Analyzer to apply to the values of indexed fields.
*
* Default: `"identity"`
*/
analyzer?: string;
/**
* List of Analyzer features to enable for the default Analyzer.
*
* Defaults to the Analyzer's features.
*/
features?: AnalyzerFeature[];
/**
* If set to `true`, all document attributes are indexed, excluding any
* sub-attributes configured in the `fields` array. The `analyzer` and
* `features` properties apply to the sub-attributes. This option only
* applies when using the index in a SearchAlias View.
*
* Default: `false`
*/
includeAllFields?: boolean;
/**
* If set to `true`, the position of values in array values are tracked and
* need to be specified in queries. Otherwise all values in an array are
* treated as equivalent. This option only applies when using the index in a
* SearchAlias View.
*
* Default: `false`
*/
trackListPositions?: boolean;
/**
* The number of threads to use for indexing the fields.
*
* Default: `2`
*/
parallelism?: number;
/**
* Wait at least this many commits between removing unused files in the
* ArangoSearch data directory.
*
* Default: `2`
*/
cleanupIntervalStep?: number;
/**
* Wait at least this many milliseconds between committing View data store
* changes and making documents visible to queries.
*
* Default: `1000`
*/
commitIntervalMsec?: number;
/**
* Wait at least this many milliseconds between applying
* `consolidationPolicy` to consolidate View data store and possibly release
* space on the filesystem.
*
* Default: `1000`
*/
consolidationIntervalMsec?: number;
/**
* The consolidation policy to apply for selecting which segments should be
* merged.
*
* Default: `{ type: "tier" }`
*/
consolidationPolicy?: TierConsolidationPolicy;
/**
* Maximum number of writers (segments) cached in the pool.
*
* Default: `64`
*/
writeBufferIdle?: number;
/**
* Maximum number of concurrent active writers (segments) that perform a
* transaction.
*
* Default: `0` (disabled)
*/
writeBufferActive?: number;
/**
* Maximum memory byte size per writer (segment) before a writer (segment)
* flush is triggered.
*
* Default: `33554432` (32 MiB)
*/
writeBufferSizeMax?: number;
/**
* If set to `true`, the index will be created in the background to reduce
* the write-lock duration for the collection during index creation.
*
* Default: `false`
*/
inBackground?: boolean;
};
/**
* Shared attributes of all index types.

@@ -337,3 +516,3 @@ */

*/
name?: string;
name: string;
/**

@@ -359,19 +538,8 @@ * A unique identifier for this index.

fields: string[];
cacheEnabled: boolean;
deduplicate: boolean;
estimates: boolean;
storedValues?: string[];
};
/**
* An object representing a skiplist index.
*/
export declare type SkiplistIndex = GenericIndex & {
type: "skiplist";
fields: string[];
};
/**
* An object representing a hash index.
*/
export declare type HashIndex = GenericIndex & {
type: "hash";
fields: string[];
selectivityEstimate: number;
};
/**
* An object representing a primary index.

@@ -386,2 +554,5 @@ */

* An object representing a fulltext index.
*
* @deprecated Fulltext indexes have been deprecated in ArangoDB 3.10 and
* should be replaced with ArangoSearch.
*/

@@ -400,2 +571,3 @@ export declare type FulltextIndex = GenericIndex & {

geoJson: boolean;
legacyPolygons: boolean;
bestIndexedLevel: number;

@@ -415,3 +587,3 @@ worstIndexedLevel: number;

/**
* An object representing a TTL index.
* An object representing a ZKD index.
*/

@@ -424,5 +596,55 @@ export declare type ZkdIndex = GenericIndex & {

/**
* (Enterprise Edition only.) An object representing a nested field in an
* inverted index.
*/
export declare type InvertedIndexNestedField = {
name: string;
analyzer?: string;
features?: AnalyzerFeature[];
searchField?: boolean;
nested?: InvertedIndexNestedField[];
};
/**
* An object representing an inverted index.
*/
export declare type InvertedIndex = GenericIndex & {
type: "inverted";
fields: {
name: string;
analyzer?: string;
features?: AnalyzerFeature[];
includeAllFields?: boolean;
searchField?: boolean;
trackListPositions?: boolean;
nested?: InvertedIndexNestedField[];
}[];
searchField: boolean;
storedValues: {
fields: string[];
compression: Compression;
}[];
primarySort: {
fields: {
field: string;
direction: Direction;
}[];
compression: Compression;
};
analyzer: string;
features: AnalyzerFeature[];
includeAllFields: boolean;
trackListPositions: boolean;
parallelism: number;
cleanupIntervalStep: number;
commitIntervalMsec: number;
consolidationIntervalMsec: number;
consolidationPolicy: Required<TierConsolidationPolicy>;
writeBufferIdle: number;
writeBufferActive: number;
writeBufferSizeMax: number;
};
/**
* An object representing an index.
*/
export declare type Index = GeoIndex | FulltextIndex | PersistentIndex | PrimaryIndex | HashIndex | SkiplistIndex | TtlIndex | ZkdIndex;
export declare type Index = GeoIndex | FulltextIndex | PersistentIndex | PrimaryIndex | TtlIndex | ZkdIndex | InvertedIndex;
export declare type ObjectWithId = {

@@ -442,5 +664,4 @@ [key: string]: any;

* @internal
* @hidden
*/
export declare function _indexHandle(selector: IndexSelector, collectionName: string): string;
//# sourceMappingURL=indexes.d.ts.map

@@ -7,7 +7,6 @@ "use strict";

* GeoIndex,
* HashIndex,
* PersistentIndex,
* PrimaryIndex,
* SkiplistIndex,
* TtlIndex,
* ZkdIndex,
* } from "arangojs/indexes";

@@ -24,3 +23,2 @@ * ```

* @internal
* @hidden
*/

@@ -27,0 +25,0 @@ function _indexHandle(selector, collectionName) {

@@ -6,7 +6,5 @@ /**

* @internal
* @hidden
*/
/**
* @internal
* @hidden
*/

@@ -13,0 +11,0 @@ export interface Blob {

@@ -7,5 +7,4 @@ "use strict";

* @internal
* @hidden
*/
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=blob.js.map

@@ -6,9 +6,7 @@ /**

* @internal
* @hidden
*/
/**
* @internal
* @hidden
*/
export declare function btoa(str: string): string;
export declare function base64Encode(str: string): string;
//# sourceMappingURL=btoa.d.ts.map

@@ -7,14 +7,12 @@ "use strict";

* @internal
* @hidden
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.btoa = void 0;
exports.base64Encode = void 0;
/**
* @internal
* @hidden
*/
function btoa(str) {
function base64Encode(str) {
return Buffer.from(str).toString("base64");
}
exports.btoa = btoa;
exports.base64Encode = base64Encode;
//# sourceMappingURL=btoa.js.map

@@ -7,9 +7,7 @@ /**

* @internal
* @hidden
*/
/**
* @internal
* @hidden
*/
export declare function btoa(str: string): string;
export declare function base64Encode(str: string): string;
//# sourceMappingURL=btoa.web.d.ts.map

@@ -8,14 +8,12 @@ "use strict";

* @internal
* @hidden
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.btoa = void 0;
exports.base64Encode = void 0;
/**
* @internal
* @hidden
*/
function btoa(str) {
return window.btoa(str);
function base64Encode(str) {
return btoa(str);
}
exports.btoa = btoa;
exports.base64Encode = base64Encode;
//# sourceMappingURL=btoa.web.js.map
/**
* Error codes handled by arangojs.
*
* See also {@link https://www.arangodb.com/docs/stable/appendix-error-codes.html | ArangoDB error documentation}.
* See also [ArangoDB error documentation](https://www.arangodb.com/docs/stable/appendix-error-codes.html).
*
* @packageDocumentation
* @internal
* @hidden
*/
export declare const TRANSACTION_NOT_FOUND = 10;
export declare const ERROR_ARANGO_MAINTENANCE_MODE = 503;
export declare const ERROR_ARANGO_CONFLICT = 1200;

@@ -12,0 +12,0 @@ export declare const ANALYZER_NOT_FOUND = 1202;

@@ -5,11 +5,11 @@ "use strict";

*
* See also {@link https://www.arangodb.com/docs/stable/appendix-error-codes.html | ArangoDB error documentation}.
* See also [ArangoDB error documentation](https://www.arangodb.com/docs/stable/appendix-error-codes.html).
*
* @packageDocumentation
* @internal
* @hidden
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.GRAPH_NOT_FOUND = exports.DATABASE_NOT_FOUND = exports.VIEW_NOT_FOUND = exports.COLLECTION_NOT_FOUND = exports.DOCUMENT_NOT_FOUND = exports.ANALYZER_NOT_FOUND = exports.ERROR_ARANGO_CONFLICT = exports.TRANSACTION_NOT_FOUND = void 0;
exports.GRAPH_NOT_FOUND = exports.DATABASE_NOT_FOUND = exports.VIEW_NOT_FOUND = exports.COLLECTION_NOT_FOUND = exports.DOCUMENT_NOT_FOUND = exports.ANALYZER_NOT_FOUND = exports.ERROR_ARANGO_CONFLICT = exports.ERROR_ARANGO_MAINTENANCE_MODE = exports.TRANSACTION_NOT_FOUND = void 0;
exports.TRANSACTION_NOT_FOUND = 10;
exports.ERROR_ARANGO_MAINTENANCE_MODE = 503;
exports.ERROR_ARANGO_CONFLICT = 1200;

@@ -16,0 +16,0 @@ exports.ANALYZER_NOT_FOUND = 1202;

@@ -6,3 +6,2 @@ /**

* @internal
* @hidden
*/

@@ -15,5 +14,4 @@ /**

* @internal
* @hidden
*/
export declare type Errback<T = never> = (err: Error | null, result?: T) => void;
//# sourceMappingURL=errback.d.ts.map

@@ -6,9 +6,7 @@ /**

* @internal
* @hidden
*/
/**
* @internal
* @hidden
*/
export declare const joinPath: (...paths: string[]) => string;
//# sourceMappingURL=joinPath.d.ts.map

@@ -7,3 +7,2 @@ "use strict";

* @internal
* @hidden
*/

@@ -15,5 +14,4 @@ Object.defineProperty(exports, "__esModule", { value: true });

* @internal
* @hidden
*/
exports.joinPath = path_1.posix.join;
//# sourceMappingURL=joinPath.js.map

@@ -6,9 +6,7 @@ /**

* @internal
* @hidden
*/
/**
* @internal
* @hidden
*/
export { join as joinPath } from "path";
//# sourceMappingURL=joinPath.web.d.ts.map

@@ -7,8 +7,7 @@ "use strict";

* @internal
* @hidden
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.joinPath = void 0;
/**
* @internal
* @hidden
*/

@@ -15,0 +14,0 @@ var path_1 = require("path");

@@ -6,3 +6,2 @@ /**

* @internal
* @hidden
*/

@@ -13,3 +12,2 @@ /// <reference types="node" />

* @internal
* @hidden
*/

@@ -21,3 +19,2 @@ export declare type Fields = {

* @internal
* @hidden
*/

@@ -30,5 +27,4 @@ export interface MultipartRequest {

* @internal
* @hidden
*/
export declare function toForm(fields: Fields): Promise<MultipartRequest>;
//# sourceMappingURL=multipart.d.ts.map

@@ -7,3 +7,2 @@ "use strict";

* @internal
* @hidden
*/

@@ -17,3 +16,2 @@ Object.defineProperty(exports, "__esModule", { value: true });

* @internal
* @hidden
*/

@@ -20,0 +18,0 @@ function toForm(fields) {

@@ -6,3 +6,2 @@ /**

* @internal
* @hidden
*/

@@ -13,5 +12,4 @@ import { Errback } from "./errback";

* @internal
* @hidden
*/
export declare function toForm(fields: Fields, callback: Errback<MultipartRequest>): void;
//# sourceMappingURL=multipart.web.d.ts.map

@@ -7,3 +7,2 @@ "use strict";

* @internal
* @hidden
*/

@@ -14,3 +13,2 @@ Object.defineProperty(exports, "__esModule", { value: true });

* @internal
* @hidden
*/

@@ -17,0 +15,0 @@ function toForm(fields, callback) {

@@ -6,9 +6,7 @@ /**

* @internal
* @hidden
*/
/**
* @internal
* @hidden
*/
export declare function normalizeUrl(url: string): string;
//# sourceMappingURL=normalizeUrl.d.ts.map

@@ -7,3 +7,2 @@ "use strict";

* @internal
* @hidden
*/

@@ -14,3 +13,2 @@ Object.defineProperty(exports, "__esModule", { value: true });

* @internal
* @hidden
*/

@@ -17,0 +15,0 @@ function normalizeUrl(url) {

@@ -6,9 +6,7 @@ /**

* @internal
* @hidden
*/
/**
* @internal
* @hidden
*/
export declare function omit<T>(obj: T, keys: (keyof T)[]): T;
export declare function omit<T extends {}>(obj: T, keys: (keyof T)[]): T;
//# sourceMappingURL=omit.d.ts.map

@@ -7,3 +7,2 @@ "use strict";

* @internal
* @hidden
*/

@@ -14,4 +13,4 @@ Object.defineProperty(exports, "__esModule", { value: true });

* @internal
* @hidden
*/
// eslint-disable-next-line @typescript-eslint/ban-types
function omit(obj, keys) {

@@ -18,0 +17,0 @@ const result = {};

@@ -8,5 +8,4 @@ /**

* @internal
* @hidden
*/
export * from "./request.node";
//# sourceMappingURL=request.d.ts.map

@@ -9,7 +9,10 @@ "use strict";

* @internal
* @hidden
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -20,3 +23,3 @@ if (k2 === undefined) k2 = k;

var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};

@@ -23,0 +26,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

@@ -6,3 +6,2 @@ /**

* @internal
* @hidden
*/

@@ -15,3 +14,2 @@ /// <reference types="node" />

* @internal
* @hidden
*/

@@ -21,14 +19,13 @@ export interface ArangojsResponse extends IncomingMessage {

body?: any;
arangojsHostId?: number;
arangojsHostUrl?: string;
}
/**
* @internal
* @hidden
*/
export interface ArangojsError extends Error {
request: ClientRequest;
toJSON: () => Record<string, any>;
}
/**
* @internal
* @hidden
*/

@@ -48,3 +45,2 @@ export declare type RequestOptions = {

* @internal
* @hidden
*/

@@ -57,3 +53,2 @@ export declare type RequestFunction = {

* @internal
* @hidden
*/

@@ -69,5 +64,4 @@ export declare const isBrowser = false;

* @internal
* @hidden
*/
export declare function createRequest(baseUrl: string, agentOptions: AgentOptions & RequestInterceptors, agent?: any): RequestFunction;
//# sourceMappingURL=request.node.d.ts.map

@@ -7,3 +7,2 @@ "use strict";

* @internal
* @hidden
*/

@@ -20,4 +19,14 @@ Object.defineProperty(exports, "__esModule", { value: true });

* @internal
* @hidden
*/
function systemErrorToJSON() {
return {
error: true,
errno: this.errno,
code: this.code,
syscall: this.syscall,
};
}
/**
* @internal
*/
exports.isBrowser = false;

@@ -32,6 +41,5 @@ /**

* @internal
* @hidden
*/
function createRequest(baseUrl, agentOptions, agent) {
const baseUrlParts = url_1.parse(baseUrl);
const baseUrlParts = (0, url_1.parse)(baseUrl);
if (!baseUrlParts.protocol) {

@@ -63,3 +71,3 @@ throw new Error(`Invalid URL (no protocol): ${baseUrl}`);

if (!agent) {
const opts = omit_1.omit(agentOptions, ["before", "after"]);
const opts = (0, omit_1.omit)(agentOptions, ["before", "after"]);
if (isTls)

@@ -73,3 +81,3 @@ agent = new https_1.Agent(opts);

? url.pathname
? joinPath_1.joinPath(baseUrlParts.pathname, url.pathname)
? (0, joinPath_1.joinPath)(baseUrlParts.pathname, url.pathname)
: baseUrlParts.pathname

@@ -88,3 +96,3 @@ : url.pathname;

if (!headers["authorization"]) {
headers["authorization"] = `Basic ${btoa_1.btoa(baseUrlParts.auth || "root:")}`;
headers["authorization"] = `Basic ${(0, btoa_1.base64Encode)(baseUrlParts.auth || "root:")}`;
}

@@ -126,2 +134,3 @@ const options = { path, method, headers, agent };

error.request = req;
error.toJSON = systemErrorToJSON;
if (called)

@@ -128,0 +137,0 @@ return;

@@ -0,1 +1,2 @@

/// <reference lib="dom" />
/**

@@ -6,3 +7,2 @@ * Node.js implementation of the HTTP(S) request function.

* @internal
* @hidden
*/

@@ -23,5 +23,4 @@ import { RequestInterceptors, XhrOptions } from "../connection";

* @internal
* @hidden
*/
export declare function createRequest(baseUrl: string, agentOptions: XhrOptions & RequestInterceptors): ({ method, url, headers, body, timeout, expectBinary }: RequestOptions, cb: Errback<ArangojsResponse>) => void;
export declare function createRequest(baseUrl: string, agentOptions: XhrOptions & RequestInterceptors): ({ method, url: reqUrl, headers, body, timeout, expectBinary, }: RequestOptions, cb: Errback<ArangojsResponse>) => void;
//# sourceMappingURL=request.web.d.ts.map
"use strict";
/**
* Node.js implementation of the HTTP(S) request function.
*
* @packageDocumentation
* @internal
* @hidden
*/
/// <reference lib="dom" />
Object.defineProperty(exports, "__esModule", { value: true });
exports.createRequest = exports.isBrowser = void 0;
const url_1 = require("url");
const btoa_1 = require("./btoa");
const joinPath_1 = require("./joinPath");
const omit_1 = require("./omit");

@@ -18,2 +10,11 @@ const xhr_1 = require("./xhr");

/**
* @internal
*/
function errorToJSON() {
return {
error: true,
message: this.message,
};
}
/**
* Create a function for performing requests against a given host.

@@ -28,23 +29,18 @@ *

* @internal
* @hidden
*/
function createRequest(baseUrl, agentOptions) {
const { auth, ...baseUrlParts } = url_1.parse(baseUrl);
const options = omit_1.omit(agentOptions, ["maxSockets"]);
return function request({ method, url, headers, body, timeout, expectBinary }, cb) {
const urlParts = {
...baseUrlParts,
pathname: url.pathname
? baseUrlParts.pathname
? joinPath_1.joinPath(baseUrlParts.pathname, url.pathname)
: url.pathname
: baseUrlParts.pathname,
search: url.search
? baseUrlParts.search
? `${baseUrlParts.search}&${url.search.slice(1)}`
: url.search
: baseUrlParts.search,
};
const base = new URL(baseUrl);
const auth = (0, btoa_1.base64Encode)(`${base.username || "root"}:${base.password}`);
base.username = "";
base.password = "";
const options = (0, omit_1.omit)(agentOptions, ["maxSockets"]);
return function request({ method, url: reqUrl, headers, body, timeout, expectBinary, }, cb) {
const url = new URL(reqUrl.pathname, base);
if (base.search || reqUrl.search) {
url.search = reqUrl.search
? `${base.search}&${reqUrl.search.slice(1)}`
: base.search;
}
if (!headers["authorization"]) {
headers["authorization"] = `Basic ${btoa_1.btoa(auth || "root:")}`;
headers["authorization"] = `Basic ${auth}`;
}

@@ -55,3 +51,3 @@ let callback = (err, res) => {

};
const req = xhr_1.default({
const req = (0, xhr_1.default)({
useXDR: true,

@@ -61,3 +57,3 @@ withCredentials: true,

responseType: expectBinary ? "blob" : "text",
url: url_1.format(urlParts),
url: String(url),
body,

@@ -81,2 +77,3 @@ method,

error.request = req;
error.toJSON = errorToJSON;
if (options.after) {

@@ -83,0 +80,0 @@ options.after(error);

@@ -6,12 +6,10 @@ /**

* @internal
* @hidden
*/
import { ClientRequest } from "http";
import { Errback } from "./errback";
declare const _default: (options: any, cb: Errback<any>) => ClientRequest;
/**
* @internal
* @hidden
*/
declare const _default: (options: any, cb: Errback<any>) => ClientRequest;
export default _default;
//# sourceMappingURL=xhr.d.ts.map

@@ -7,3 +7,2 @@ "use strict";

* @internal
* @hidden
*/

@@ -13,3 +12,2 @@ Object.defineProperty(exports, "__esModule", { value: true });

* @internal
* @hidden
*/

@@ -16,0 +14,0 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires

# Migrating
## v7 to v8
Version 8 drops support for Internet Explorer 11 and Node.js 10 and 12. If you
need to continue supporting Internet Explorer, you can try transpiling arangojs
as a dependency using Babel with the relevant polyfills.
### General
In TypeScript the type `Dict<T>` has been removed from the `connection` module.
The built-in type `Record<string, T>` can be used as a replacement:
```diff
import { Database } from "arangojs";
-import type { Dict } from "arangojs/connection";
const db = new Database();
-let deps: Dict<string, string[], undefined>;
+let deps: Record<string, string | string[] | undefined>;
deps = await db.getServiceDependencies("/my-foxx-service", true);
```
### Default URL
The default URL has been changed to `http://127.0.0.1:8529` to match the ArangoDB
default. Previously the default URL was `http://localhost:8529`, which on some
systems would resolve to the IPv6 address `::1` instead.
If you don't want to use the IPv4 address `127.0.0.1` and instead want to continue
letting the operating system resolve `localhost`, you can pass the URL explicitly:
```diff
import { Database } from "arangojs";
const db = new Database({
+ url: "http://localhost:8529"
});
```
### Databases
Previously arangojs allowed changing the database using the deprecated
`db.useDatabase` method. This could make it difficult to remember which
database you were interacting with. Instead, you should create a new `Database`
instance for each database you want to interact with using the `db.database`
method:
```diff
import { Database } from "arangojs";
const db = new Database();
-db.useDatabase("database2");
+const db2 = db.database("database2");
```
### Queries
The functions `aql.literal` and `aql.join` are no longer available as methods
on the `aql` template handler and need to be imported separately:
```diff
import { aql } from "arangojs";
+import { join } from "arangojs/aql";
-const filters = aql.join([
+const filters = join([
aql`FILTER size == 'big'`,
aql`FILTER color == 'yellow'`
]);
```
### Users
The return values of `db.getUserDatabases` and `db.getUserAccessLevel` have
been changed to match the documented return types:
```diff
import { Database } from "arangojs";
const db = new Database();
-const dbs = (await db.getUserDatabases("ash")).result;
+const dbs = await db.getUserDatabases("ash");
for (const [db, obj] of Object.entries(dbs)) {
console.log(`${db}: ${obj.permission}`);
for (const [col, access] of Object.entries(obj.collections)) {
console.log(`${db}/${col}: ${access}`);
}
}
-const access = (await db.getUserAccessLevel("ash", "pokemons")).result;
+const access = await db.getUserAccessLevel("ash", "pokemons");
if (access === "rw") {
db.collection("pokemons").save({ name: "Pikachu" });
}
```
### Graphs
In TypeScript the type `GraphCreateOptions` has been renamed to
`CreateGraphOptions`:
```diff
-import type { GraphCreateOptions } from "arangojs/graph";
+import type { CreateGraphOptions } from "arangojs/graph";
```
## v6 to v7

@@ -15,3 +120,3 @@

const db = new Database({
url: "http://localhost:8529",
url: "http://127.0.0.1:8529",
+ databaseName: "my_database",

@@ -18,0 +123,0 @@ });

{
"name": "arangojs",
"version": "7.8.0",
"version": "8.0.0-rc.1",
"engines": {
"node": ">=10"
"node": ">=14"
},

@@ -36,3 +36,3 @@ "license": "Apache-2.0",

"main": "index.js",
"typings": "arangojs.d.ts",
"typings": "index.d.ts",
"browser": {

@@ -51,3 +51,2 @@ "./lib/btoa.js": "./lib/btoa.web.js",

"@types/node": ">=13.13.4",
"es6-error": "^4.0.1",
"multi-part": "^3.0.0",

@@ -54,0 +53,0 @@ "x3-linkedlist": "1.2.0",

@@ -34,3 +34,3 @@ # ArangoDB JavaScript Driver

For use without a compiler, the npm release comes with a precompiled browser
build for evergreen browsers and Internet Explorer 11:
build for evergreen browsers:

@@ -44,4 +44,4 @@ ```js

```html
< !-- note the path includes the version number (e.g. 7.0.0) -- >
<script src="https://unpkg.com/arangojs@7.0.0/web.js"></script>
< !-- note the path includes the version number (e.g. 8.0.0) -- >
<script src="https://unpkg.com/arangojs@8.0.0/web.js"></script>
<script>

@@ -53,7 +53,2 @@ var db = new arangojs.Database();

If you are targetting browsers older than Internet Explorer 11 you may want to
use [babel](https://babeljs.io) with a
[polyfill](https://babeljs.io/docs/usage/polyfill) to provide missing
functionality needed to use arangojs.
When loading the browser build with a script tag make sure to load the polyfill first:

@@ -63,3 +58,3 @@

<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.26.0/polyfill.js"></script>
<script src="https://unpkg.com/arangojs@7.0.0/web.js"></script>
<script src="https://unpkg.com/arangojs@8.0.0/web.js"></script>
```

@@ -101,3 +96,3 @@

const db = new Database({
url: "http://localhost:8529",
url: "http://127.0.0.1:8529",
databaseName: "pancakes",

@@ -107,4 +102,3 @@ auth: { username: "root", password: "hunter2" },

// The database can be swapped at any time
db.useDatabase("waffles");
// The credentials can be swapped at any time
db.useBasicAuth("admin", "maplesyrup");

@@ -184,3 +178,3 @@ ```

Changes in the major version number of arangojs (e.g. 6.x.y -> 7.0.0) indicate
Changes in the major version number of arangojs (e.g. 7.x.y -> 8.0.0) indicate
backwards-incompatible changes in the arangojs API that may require changes in

@@ -187,0 +181,0 @@ your code when upgrading your version of arangojs.

@@ -22,3 +22,2 @@ /**

* @internal
* @hidden
*/

@@ -61,3 +60,3 @@ constructor(db: Database, path?: string, headers?: Headers);

*/
request(options?: RequestOptions): Promise<ArangojsResponse>;
request(options?: RequestOptions): Promise<any>;
/**

@@ -64,0 +63,0 @@ * Performs a DELETE request against the given path relative to this route

@@ -10,3 +10,2 @@ "use strict";

* @internal
* @hidden
*/

@@ -77,3 +76,3 @@ constructor(db, path = "", headers = {}) {

opts.method = opts.method ? opts.method.toUpperCase() : "GET";
return this._db.request(opts);
return this._db.request(opts, false);
}

@@ -80,0 +79,0 @@ delete(...args) {

@@ -9,5 +9,27 @@ import { Database } from "./database";

/**
* Options for how the transaction should be committed.
*/
export declare type TransactionCommitOptions = {
/**
* If set to `true`, the request will explicitly permit ArangoDB to return a
* potentially dirty or stale result and arangojs will load balance the
* request without distinguishing between leaders and followers.
*/
allowDirtyRead?: boolean;
};
/**
* Options for how the transaction should be aborted.
*/
export declare type TransactionAbortOptions = {
/**
* If set to `true`, the request will explicitly permit ArangoDB to return a
* potentially dirty or stale result and arangojs will load balance the
* request without distinguishing between leaders and followers.
*/
allowDirtyRead?: boolean;
};
/**
* Status of a given transaction.
*
* See also {@link TransactionDetails}.
* See also {@link database.TransactionDetails}.
*/

@@ -25,3 +47,3 @@ export declare type TransactionStatus = {

/**
* Represents a streaming transaction in a {@link Database}.
* Represents a streaming transaction in a {@link database.Database}.
*/

@@ -33,3 +55,2 @@ export declare class Transaction {

* @internal
* @hidden
*/

@@ -46,3 +67,3 @@ constructor(db: Database, id: string);

*
* See {@link Database.transaction}.
* See {@link database.Database#transaction}.
*/

@@ -79,2 +100,4 @@ get id(): string;

*
* @param options - Options for comitting the transaction.
*
* @example

@@ -90,6 +113,8 @@ * ```js

*/
commit(): Promise<TransactionStatus>;
commit(options?: TransactionCommitOptions): Promise<TransactionStatus>;
/**
* Attempts to abort the transaction to the databases.
*
* @param options - Options for aborting the transaction.
*
* @example

@@ -105,3 +130,3 @@ * ```js

*/
abort(): Promise<TransactionStatus>;
abort(options?: TransactionAbortOptions): Promise<TransactionStatus>;
/**

@@ -108,0 +133,0 @@ * Executes the given function locally as a single step of the transaction.

@@ -16,3 +16,3 @@ "use strict";

/**
* Represents a streaming transaction in a {@link Database}.
* Represents a streaming transaction in a {@link database.Database}.
*/

@@ -22,3 +22,2 @@ class Transaction {

* @internal
* @hidden
*/

@@ -40,3 +39,3 @@ constructor(db, id) {

*
* See {@link Database.transaction}.
* See {@link database.Database#transaction}.
*/

@@ -63,3 +62,3 @@ get id() {

catch (err) {
if (error_1.isArangoError(err) && err.errorNum === codes_1.TRANSACTION_NOT_FOUND) {
if ((0, error_1.isArangoError)(err) && err.errorNum === codes_1.TRANSACTION_NOT_FOUND) {
return false;

@@ -91,2 +90,4 @@ }

*
* @param options - Options for comitting the transaction.
*
* @example

@@ -102,6 +103,8 @@ * ```js

*/
commit() {
commit(options = {}) {
const { allowDirtyRead = undefined } = options;
return this._db.request({
method: "PUT",
path: `/_api/transaction/${encodeURIComponent(this.id)}`,
allowDirtyRead,
}, (res) => res.body.result);

@@ -112,2 +115,4 @@ }

*
* @param options - Options for aborting the transaction.
*
* @example

@@ -123,6 +128,8 @@ * ```js

*/
abort() {
abort(options = {}) {
const { allowDirtyRead = undefined } = options;
return this._db.request({
method: "DELETE",
path: `/_api/transaction/${encodeURIComponent(this.id)}`,
allowDirtyRead,
}, (res) => res.body.result);

@@ -129,0 +136,0 @@ }

@@ -10,11 +10,5 @@ /**

*/
import { ArangoResponseMetadata, Dict } from "./connection";
import { ArangoApiResponse } from "./connection";
import { Database } from "./database";
/**
* String values indicating the View type.
*/
export declare enum ViewType {
ARANGOSEARCH_VIEW = "arangosearch"
}
/**
* Indicates whether the given value represents a {@link View}.

@@ -26,26 +20,68 @@ *

/**
* Generic description of a View.
* Sorting direction. Descending or ascending.
*/
export declare type ViewDescription = {
export declare type Direction = "desc" | "asc";
/**
* Policy to consolidate if the sum of all candidate segment byte size is less
* than the total segment byte size multiplied by a given threshold.
*/
export declare type TierConsolidationPolicy = {
/**
* A globally unique identifier for this View.
* Type of consolidation policy.
*/
globallyUniqueId: string;
type: "tier";
/**
* An identifier for this View.
* Size below which all segments are treated as equivalent.
*
* Default: `2097152` (2 MiB)
*/
id: string;
segmentsBytesFloor?: number;
/**
* Name of the View.
* Maximum allowed size of all consolidation segments.
*
* Default: `5368709120` (5 GiB)
*/
name: string;
segmentsBytesMax?: number;
/**
* Type of the View.
* Maximum number of segments that are evaluated as candidates for
* consolidation.
*
* Default: `10`
*/
type: ViewType;
segmentsMax?: number;
/**
* Minimum number of segments that are evaluated as candidates for
* consolidation.
*
* Default: `1`
*/
segmentsMin?: number;
/**
* Consolidation candidates with a score less than this value will be
* filtered out.
*
* Default: `0`
*/
minScore?: number;
};
/**
* Compression for storing data.
*/
export declare type Compression = "lz4" | "none";
/**
* Options for creating a View.
*/
export declare type CreateViewOptions = CreateArangoSearchViewOptions | CreateSearchAliasViewOptions;
/**
* Options for replacing a View's properties.
*/
export declare type ViewPropertiesOptions = ArangoSearchViewPropertiesOptions | SearchAliasViewPropertiesOptions;
/**
* Options for partially modifying a View's properties.
*/
export declare type ViewPatchPropertiesOptions = ArangoSearchViewPropertiesOptions | SearchAliasViewPatchPropertiesOptions;
/**
* A link definition for an ArangoSearch View.
*/
export declare type ArangoSearchViewLink = {
export declare type ArangoSearchViewLinkOptions = {
/**

@@ -60,5 +96,5 @@ * A list of names of Analyzers to apply to values of processed document

* An object mapping names of attributes to process for each document to
* {@link ArangoSearchViewLink} definitions.
* {@link ArangoSearchViewLinkOptions} definitions.
*/
fields?: Dict<ArangoSearchViewLink | undefined>;
fields?: Record<string, ArangoSearchViewLinkOptions>;
/**

@@ -72,2 +108,8 @@ * If set to `true`, all document attributes will be processed, otherwise

/**
* (Enterprise Edition only.) An object mapping attribute names to
* {@link ArangoSearchViewLinkOptions} definitions to index sub-objects
* stored in an array.
*/
nested?: Record<string, ArangoSearchViewLinkOptions>;
/**
* If set to `true`, the position of values in array values will be tracked,

@@ -92,154 +134,50 @@ * otherwise all values in an array will be treated as equal alternatives.

/**
* Properties of an ArangoSearch View.
* Options for modifying the properties of an ArangoSearch View.
*/
export declare type ArangoSearchViewProperties = {
export declare type ArangoSearchViewPropertiesOptions = {
/**
* How many commits to wait between removing unused files.
*
* Default: `2`
*/
cleanupIntervalStep: number;
cleanupIntervalStep?: number;
/**
* How long to wait between applying the `consolidationPolicy`.
*
* Default: `10000`
*/
consolidationIntervalMsec: number;
consolidationIntervalMsec?: number;
/**
* Maximum number of writers cached in the pool.
* How long to wait between commiting View data store changes and making
* documents visible to queries.
*
* Default: `1000`
*/
writebufferIdle: number;
commitIntervalMsec?: number;
/**
* Maximum number of concurrent active writers that perform a transaction.
*/
writebufferActive: number;
/**
* Maximum memory byte size per writer before a writer flush is triggered.
*/
writebufferSizeMax: number;
/**
* Consolidation policy to apply for selecting which segments should be
* merged.
*/
consolidationPolicy: BytesAccumConsolidationPolicy | TierConsolidationPolicy;
/**
* Attribute path (`field`) for the value of each document that is
* used for sorting.
*/
primarySort: {
/**
* Attribute path for the value of each document used for
* sorting.
*/
field: string;
/**
* If set to `"asc"`, the primary sorting order is ascending.
* If set to `"desc"`, the primary sorting order is descending.
*/
direction: "desc" | "asc";
}[];
/**
* Compression to use for the primary sort data.
*
* Default: `"lz4"`
* Default: `{ type: "tier" }`
*/
primarySortCompression: PrimarySortCompression;
consolidationPolicy?: TierConsolidationPolicy;
/**
* Attribute paths for which values should be stored in the view index
* in addition to those used for sorting via `primarySort`.
*/
storedValues: {
/**
* Attribute paths for which values should be stored in the view index
* in addition to those used for sorting via `primarySort`.
*/
fields: string[];
}[];
/**
* An object mapping names of linked collections to
* {@link ArangoSearchViewLink} definitions.
* {@link ArangoSearchViewLinkOptions} definitions.
*/
links: Dict<ArangoSearchViewLink | undefined>;
links?: Record<string, Omit<ArangoSearchViewLinkOptions, "nested">>;
};
/**
* Policy to consolidate based on segment byte size and live document count as
* dictated by the customization attributes.
* Options for partially modifying the properties of an ArangoSearch View.
*/
export declare type BytesAccumConsolidationPolicy = {
/**
* Type of consolidation policy.
*/
type: "bytes_accum";
/**
* Must be in the range of `0.0` to `1.0`.
*/
threshold?: number;
};
export declare type ArangoSearchViewPatchPropertiesOptions = ArangoSearchViewPropertiesOptions;
/**
* Policy to consolidate if the sum of all candidate segment byte size is less
* than the total segment byte size multiplied by a given threshold.
* Options for creating an ArangoSearch View.
*/
export declare type TierConsolidationPolicy = {
export declare type CreateArangoSearchViewOptions = ArangoSearchViewPropertiesOptions & {
/**
* Type of consolidation policy.
* Type of the View.
*/
type: "tier";
type: "arangosearch";
/**
* Minimum number of segments that will be evaluated as candidates
* for consolidation.
*
* Default: `1`
*/
segmentsMin?: number;
/**
* Maximum number of segments that will be evaluated as candidates
* for consolidation.
*
* Default: `10`
*/
segmentsMax?: number;
/**
* Maximum allowed size of all consolidated segments.
*
* Default: `5368709120`, i.e. 5 GiB
*/
segmentsBytesMax?: number;
/**
* Defines the value to treat all smaller segments as equal for
* consolidation selection.
*
* Default: `2097152`, i.e. 2 MiB
*/
segmentsBytesFloor?: number;
/**
* Minimum score.
*/
minScore?: number;
};
/**
* Compression to use for primary sort data of a View.
*
* Default: `"lz4"`
*/
export declare type PrimarySortCompression = "lz4" | "none";
/**
* Properties of an ArangoSearch View.
*/
export declare type ArangoSearchViewPropertiesOptions = {
/**
* How many commits to wait between removing unused files.
*
* Default: `2`
*/
cleanupIntervalStep?: number;
/**
* How long to wait between applying the `consolidationPolicy`.
*
* Default: `10000`
*/
consolidationIntervalMsec?: number;
/**
* How long to wait between commiting View data store changes and making
* documents visible to queries.
*
* Default: `1000`
*/
commitIntervalMsec?: number;
/**
* Maximum number of writers cached in the pool.

@@ -259,11 +197,6 @@ *

*
* Default: `33554432`, i.e. 32 MiB
* Default: `33554432` (32 MiB)
*/
writebufferSizeMax?: number;
/**
* Consolidation policy to apply for selecting which segments should be
* merged.
*/
consolidationPolicy?: BytesAccumConsolidationPolicy | TierConsolidationPolicy;
/**
* Attribute path (`field`) for the value of each document that will be

@@ -288,3 +221,3 @@ * used for sorting.

*/
direction: "desc" | "asc";
direction: Direction;
} | {

@@ -307,3 +240,3 @@ /**

*/
primarySortCompression?: PrimarySortCompression;
primarySortCompression?: Compression;
/**

@@ -319,16 +252,132 @@ * Attribute paths for which values should be stored in the view index

fields: string[];
/**
* How the attribute values should be compressed.
*
* Default: `"lz4"`
*/
compression?: Compression;
}[];
};
/**
* Options defining an index used in a SearchAlias View.
*/
export declare type SearchAliasViewIndexOptions = {
/**
* An object mapping names of linked collections to
* {@link ArangoSearchViewLink} definitions.
* Name of a collection.
*/
links?: Dict<ArangoSearchViewLink | undefined>;
collection: string;
/**
* Name of an inverted index in the collection.
*/
index: string;
};
/**
* Represents a View in a {@link Database}.
*
* See {@link ArangoSearchView} for the concrete type representing an
* ArangoSearch View.
* Options for modifying the properties of a SearchAlias View.
*/
export declare class View<PropertiesOptions extends Record<string, any> = any, Properties extends Record<string, any> = any> {
export declare type SearchAliasViewPropertiesOptions = {
/**
* An array of inverted indexes to add to the View.
*/
indexes: SearchAliasViewIndexOptions[];
};
/**
* Options defining an index to be modified in a SearchAlias View.
*/
export declare type SearchAliasViewPatchIndexOptions = SearchAliasViewIndexOptions & {
/**
* Whether to add or remove the index.
*
* Default: `"add"`
*/
operation?: "add" | "del";
};
/**
* Options for partially modifying the properties of a SearchAlias View.
*/
export declare type SearchAliasViewPatchPropertiesOptions = {
/**
* An array of inverted indexes to add to the View.
*/
indexes: SearchAliasViewPatchIndexOptions[];
};
/**
* Options for creating a SearchAlias View.
*/
export declare type CreateSearchAliasViewOptions = SearchAliasViewPropertiesOptions & {
/**
* Type of the View.
*/
type: "search-alias";
};
/**
* Generic description of a View.
*/
export declare type GenericViewDescription = {
/**
* A globally unique identifier for this View.
*/
globallyUniqueId: string;
/**
* An identifier for this View.
*/
id: string;
/**
* Name of the View.
*/
name: string;
};
export declare type ViewDescription = ArangoSearchViewDescription | SearchAliasViewDescription;
export declare type ArangoSearchViewDescription = GenericViewDescription & {
type: "arangosearch";
};
export declare type SearchAliasViewDescription = GenericViewDescription & {
type: "search-alias";
};
export declare type ViewProperties = ArangoSearchViewProperties | SearchAliasViewProperties;
/**
* A link definition for an ArangoSearch View.
*/
export declare type ArangoSearchViewLink = {
analyzers: string[];
fields: Record<string, ArangoSearchViewLink>;
includeAllFields: boolean;
nested?: Record<string, ArangoSearchViewLink>;
trackListPositions: boolean;
storeValues: "none" | "id";
};
/**
* Properties of an ArangoSearch View.
*/
export declare type ArangoSearchViewProperties = ArangoSearchViewDescription & {
cleanupIntervalStep: number;
consolidationIntervalMsec: number;
commitIntervalMsec: number;
writebufferIdle: number;
writebufferActive: number;
writebufferSizeMax: number;
consolidationPolicy: TierConsolidationPolicy;
primarySort: {
field: string;
direction: Direction;
}[];
primarySortCompression: Compression;
storedValues: {
fields: string[];
compression: Compression;
}[];
links: Record<string, Omit<ArangoSearchViewLink, "nested">>;
};
/**
* Properties of a SearchAlias View.
*/
export declare type SearchAliasViewProperties = SearchAliasViewDescription & {
indexes: {
collection: string;
index: string;
}[];
};
/**
* Represents a View in a {@link database.Database}.
*/
export declare class View {
protected _name: string;

@@ -338,3 +387,2 @@ protected _db: Database;

* @internal
* @hidden
*/

@@ -363,3 +411,3 @@ constructor(db: Database, name: string);

*/
get(): Promise<ViewDescription & ArangoResponseMetadata>;
get(): Promise<ArangoApiResponse<ViewDescription>>;
/**

@@ -380,3 +428,3 @@ * Checks whether the View exists.

*
* See also {@link Database.createView}.
* See also {@link database.Database#createView}.
*

@@ -391,9 +439,7 @@ * @example

*/
create(options?: PropertiesOptions & {
type: ViewType;
}): Promise<ViewDescription & Properties>;
create<Options extends CreateViewOptions>(options: CreateViewOptions): Promise<typeof options extends CreateArangoSearchViewOptions ? ArangoSearchViewDescription : Options extends CreateSearchAliasViewOptions ? SearchAliasViewDescription : ViewDescription>;
/**
* Renames the View and updates the instance's `name` to `newName`.
*
* Additionally removes the instance from the {@link Database}'s internal
* Additionally removes the instance from the {@link database.Database}'s internal
* cache.

@@ -417,3 +463,3 @@ *

*/
rename(newName: string): Promise<ViewDescription & ArangoResponseMetadata>;
rename(newName: string): Promise<ArangoApiResponse<ViewDescription>>;
/**

@@ -430,3 +476,3 @@ * Retrieves the View's properties.

*/
properties(): Promise<ViewDescription & Properties & ArangoResponseMetadata>;
properties(): Promise<ArangoApiResponse<ViewProperties>>;
/**

@@ -447,3 +493,3 @@ * Updates the properties of the View.

*/
updateProperties(properties?: PropertiesOptions): Promise<ViewDescription & Properties>;
updateProperties<Properties extends ViewPatchPropertiesOptions | undefined>(properties?: Properties): Promise<Properties extends ArangoSearchViewPatchPropertiesOptions ? ArangoSearchViewProperties : Properties extends SearchAliasViewPatchPropertiesOptions ? SearchAliasViewProperties : ViewProperties>;
/**

@@ -464,3 +510,3 @@ * Replaces the properties of the View.

*/
replaceProperties(properties?: PropertiesOptions): Promise<ViewDescription & Properties>;
replaceProperties<Properties extends ViewPropertiesOptions | undefined>(properties?: Properties): Promise<Properties extends ArangoSearchViewPropertiesOptions ? ArangoSearchViewProperties : Properties extends SearchAliasViewPropertiesOptions ? SearchAliasViewProperties : ViewProperties>;
/**

@@ -480,9 +526,2 @@ * Deletes the View from the database.

}
/**
* Represents an ArangoSearch View in a {@link Database}.
*/
export interface ArangoSearchView extends View<ArangoSearchViewPropertiesOptions, ArangoSearchViewProperties & {
type: ViewType.ARANGOSEARCH_VIEW;
}> {
}
//# sourceMappingURL=view.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.View = exports.isArangoView = exports.ViewType = void 0;
exports.View = exports.isArangoView = void 0;
const error_1 = require("./error");
const codes_1 = require("./lib/codes");
/**
* String values indicating the View type.
*/
var ViewType;
(function (ViewType) {
ViewType["ARANGOSEARCH_VIEW"] = "arangosearch";
})(ViewType = exports.ViewType || (exports.ViewType = {}));
/**
* Indicates whether the given value represents a {@link View}.

@@ -23,6 +16,3 @@ *

/**
* Represents a View in a {@link Database}.
*
* See {@link ArangoSearchView} for the concrete type representing an
* ArangoSearch View.
* Represents a View in a {@link database.Database}.
*/

@@ -32,3 +22,2 @@ class View {

* @internal
* @hidden
*/

@@ -65,3 +54,5 @@ constructor(db, name) {

get() {
return this._db.request({ path: `/_api/view/${encodeURIComponent(this._name)}` }, (res) => res.body);
return this._db.request({
path: `/_api/view/${encodeURIComponent(this._name)}`,
});
}

@@ -85,3 +76,3 @@ /**

catch (err) {
if (error_1.isArangoError(err) && err.errorNum === codes_1.VIEW_NOT_FOUND) {
if ((0, error_1.isArangoError)(err) && err.errorNum === codes_1.VIEW_NOT_FOUND) {
return false;

@@ -95,3 +86,3 @@ }

*
* See also {@link Database.createView}.
* See also {@link database.Database#createView}.
*

@@ -111,7 +102,6 @@ * @example

body: {
type: ViewType.ARANGOSEARCH_VIEW,
...(options || {}),
...options,
name: this._name,
},
}, (res) => res.body);
});
}

@@ -121,3 +111,3 @@ /**

*
* Additionally removes the instance from the {@link Database}'s internal
* Additionally removes the instance from the {@link database.Database}'s internal
* cache.

@@ -158,3 +148,5 @@ *

properties() {
return this._db.request({ path: `/_api/view/${encodeURIComponent(this._name)}/properties` }, (res) => res.body);
return this._db.request({
path: `/_api/view/${encodeURIComponent(this._name)}/properties`,
});
}

@@ -180,4 +172,4 @@ /**

path: `/_api/view/${encodeURIComponent(this._name)}/properties`,
body: properties || {},
}, (res) => res.body);
body: properties ?? {},
});
}

@@ -203,4 +195,4 @@ /**

path: `/_api/view/${encodeURIComponent(this._name)}/properties`,
body: properties || {},
}, (res) => res.body);
body: properties ?? {},
});
}

@@ -207,0 +199,0 @@ /**

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc