UNPKG

151 kBTypeScriptView Raw
1/// <reference types="node" />
2/// <reference types="node" />
3/**
4 * ```js
5 * import { Database } from "arangojs/database";
6 * ```
7 *
8 * The "database" module provides the {@link Database} class and associated
9 * types and interfaces for TypeScript.
10 *
11 * The Database class is also re-exported by the "index" module.
12 *
13 * @packageDocumentation
14 */
15import { Readable } from "stream";
16import { Analyzer, AnalyzerDescription, CreateAnalyzerOptions } from "./analyzer";
17import { AqlLiteral, AqlQuery } from "./aql";
18import { ArangoCollection, Collection, CollectionMetadata, CollectionType, CreateCollectionOptions, DocumentCollection, EdgeCollection } from "./collection";
19import { ArangoApiResponse, Config, Connection, Headers, RequestOptions } from "./connection";
20import { ArrayCursor } from "./cursor";
21import { FoxxManifest } from "./foxx-manifest";
22import { CreateGraphOptions, EdgeDefinitionOptions, Graph, GraphInfo } from "./graph";
23import { Job } from "./job";
24import { Blob } from "./lib/blob";
25import { ArangojsResponse } from "./lib/request";
26import { Route } from "./route";
27import { Transaction } from "./transaction";
28import { CreateViewOptions, View, ViewDescription } from "./view";
29/**
30 * Indicates whether the given value represents a {@link Database}.
31 *
32 * @param database - A value that might be a database.
33 */
34export declare function isArangoDatabase(database: any): database is Database;
35/**
36 * Collections involved in a transaction.
37 */
38export type TransactionCollections = {
39 /**
40 * An array of collections or a single collection that will be read from or
41 * written to during the transaction with no other writes being able to run
42 * in parallel.
43 */
44 exclusive?: (string | ArangoCollection)[] | string | ArangoCollection;
45 /**
46 * An array of collections or a single collection that will be read from or
47 * written to during the transaction.
48 */
49 write?: (string | ArangoCollection)[] | string | ArangoCollection;
50 /**
51 * An array of collections or a single collection that will be read from
52 * during the transaction.
53 */
54 read?: (string | ArangoCollection)[] | string | ArangoCollection;
55};
56/**
57 * Options for how the transaction should be performed.
58 */
59export type TransactionOptions = {
60 /**
61 * Whether the transaction may read from collections not specified for this
62 * transaction. If set to `false`, accessing any collections not specified
63 * will result in the transaction being aborted to avoid potential deadlocks.
64 *
65 * Default: `true`.
66 */
67 allowImplicit?: boolean;
68 /**
69 * If set to `true`, the request will explicitly permit ArangoDB to return a
70 * potentially dirty or stale result and arangojs will load balance the
71 * request without distinguishing between leaders and followers.
72 */
73 allowDirtyRead?: boolean;
74 /**
75 * Determines whether to force the transaction to write all data to disk
76 * before returning.
77 */
78 waitForSync?: boolean;
79 /**
80 * Determines how long the database will wait while attempting to gain locks
81 * on collections used by the transaction before timing out.
82 */
83 lockTimeout?: number;
84 /**
85 * (RocksDB only.) Determines the transaction size limit in bytes.
86 */
87 maxTransactionSize?: number;
88};
89/**
90 * Options for executing a query.
91 *
92 * See {@link Database#query}.
93 */
94export type QueryOptions = {
95 /**
96 * If set to `true`, the query will be executed with support for dirty reads
97 * enabled, permitting ArangoDB to return a potentially dirty or stale result
98 * and arangojs will load balance the request without distinguishing between
99 * leaders and followers.
100 *
101 * Note that dirty reads are only supported for read-only queries, not data
102 * modification queries (e.g. using `INSERT`, `UPDATE`, `REPLACE` or
103 * `REMOVE`) and only when using ArangoDB 3.4 or later.
104 *
105 * Default: `false`
106 */
107 allowDirtyRead?: boolean;
108 /**
109 * If set to `true`, cursor results will be stored by ArangoDB in such a way
110 * that batch reads can be retried in the case of a communication error.
111 *
112 * Default: `false`
113 */
114 allowRetry?: boolean;
115 /**
116 * Maximum time in milliseconds arangojs will wait for a server response.
117 * Exceeding this value will result in the request being cancelled.
118 *
119 * **Note**: Setting a timeout for the client does not guarantee the query
120 * will be killed by ArangoDB if it is already being executed. See the
121 * `maxRuntime` option for limiting the execution time within ArangoDB.
122 */
123 timeout?: number;
124 /**
125 * If set to a positive number, the query will automatically be retried at
126 * most this many times if it results in a write-write conflict.
127 *
128 * Default: `0`
129 */
130 retryOnConflict?: number;
131 /**
132 * Unless set to `false`, the number of result values in the result set will
133 * be returned in the `count` attribute. This may be disabled by default in
134 * a future version of ArangoDB if calculating this value has a performance
135 * impact for some queries.
136 *
137 * Default: `true`.
138 */
139 count?: boolean;
140 /**
141 * Number of result values to be transferred by the server in each
142 * network roundtrip (or "batch").
143 *
144 * Must be greater than zero.
145 */
146 batchSize?: number;
147 /**
148 * If set to `false`, the AQL query results cache lookup will be skipped for
149 * this query.
150 *
151 * Default: `true`
152 */
153 cache?: boolean;
154 /**
155 * Maximum memory size in bytes that the query is allowed to use.
156 * Exceeding this value will result in the query failing with an error.
157 *
158 * If set to `0`, the memory limit is disabled.
159 *
160 * Default: `0`
161 */
162 memoryLimit?: number;
163 /**
164 * Maximum allowed execution time before the query will be killed in seconds.
165 *
166 * If set to `0`, the query will be allowed to run indefinitely.
167 *
168 * Default: `0`
169 */
170 maxRuntime?: number;
171 /**
172 * Time-to-live for the cursor in seconds. The cursor results may be
173 * garbage collected by ArangoDB after this much time has passed.
174 *
175 * Default: `30`
176 */
177 ttl?: number;
178 /**
179 * If set to `true`, the query will throw an exception and abort if it would
180 otherwise produce a warning.
181 */
182 failOnWarning?: boolean;
183 /**
184 * If set to `1` or `true`, additional query profiling information will be
185 * returned in the `extra.profile` attribute if the query is not served from
186 * the result cache.
187 *
188 * If set to `2`, the query will return execution stats per query plan node
189 * in the `extra.stats.nodes` attribute. Additionally the query plan is
190 * returned in `extra.plan`.
191 */
192 profile?: boolean | number;
193 /**
194 * If set to `true`, the query will be executed as a streaming query.
195 */
196 stream?: boolean;
197 /**
198 * Limits the maximum number of warnings a query will return.
199 */
200 maxWarningsCount?: number;
201 /**
202 * If set to `true` and the query has a `LIMIT` clause, the total number of
203 * values matched before the last top-level `LIMIT` in the query was applied
204 * will be returned in the `extra.stats.fullCount` attribute.
205 */
206 fullCount?: boolean;
207 /**
208 * If set to `false`, the query data will not be stored in the RocksDB block
209 * cache. This can be used to avoid thrashing he block cache when reading a
210 * lot of data.
211 */
212 fillBlockCache?: boolean;
213 /**
214 * An object with a `rules` property specifying a list of optimizer rules to
215 * be included or excluded by the optimizer for this query. Prefix a rule
216 * name with `+` to include it, or `-` to exclude it. The name `all` acts as
217 * an alias matching all optimizer rules.
218 */
219 optimizer?: {
220 rules: string[];
221 };
222 /**
223 * Limits the maximum number of plans that will be created by the AQL query
224 * optimizer.
225 */
226 maxPlans?: number;
227 /**
228 * Controls after how many execution nodes in a query a stack split should be
229 * performed.
230 *
231 * Default: `250` (`200` on macOS)
232 */
233 maxNodesPerCallstack?: number;
234 /**
235 * (RocksDB only.) Maximum size of transactions in bytes.
236 */
237 maxTransactionSize?: number;
238 /**
239 * (RocksDB only.) Maximum number of operations after which an intermediate
240 * commit is automatically performed.
241 */
242 intermediateCommitCount?: number;
243 /**
244 * (RocksDB only.) Maximum total size of operations in bytes after which an
245 * intermediate commit is automatically performed.
246 */
247 intermediateCommitSize?: number;
248 /**
249 * (Enterprise Edition cluster only.) If set to `true`, collections
250 * inaccessible to current user will result in an access error instead
251 * of being treated as empty.
252 */
253 skipInaccessibleCollections?: boolean;
254 /**
255 * (Enterprise Edition cluster only.) Limits the maximum time in seconds a
256 * DBServer will wait to bring satellite collections involved in the query
257 * into sync. Exceeding this value will result in the query being stopped.
258 *
259 * Default: `60`
260 */
261 satelliteSyncWait?: number;
262};
263/**
264 * Options for explaining a query.
265 *
266 * See {@link Database#explain}.
267 */
268export type ExplainOptions = {
269 /**
270 * An object with a `rules` property specifying a list of optimizer rules to
271 * be included or excluded by the optimizer for this query. Prefix a rule
272 * name with `+` to include it, or `-` to exclude it. The name `all` acts as
273 * an alias matching all optimizer rules.
274 */
275 optimizer?: {
276 rules: string[];
277 };
278 /**
279 * Maximum number of plans that the optimizer is allowed to generate.
280 * Setting this to a low value limits the amount of work the optimizer does.
281 */
282 maxNumberOfPlans?: number;
283 /**
284 * If set to true, all possible execution plans will be returned as the
285 * `plans` property. Otherwise only the optimal execution plan will be
286 * returned as the `plan` property.
287 *
288 * Default: `false`
289 */
290 allPlans?: boolean;
291};
292/**
293 * Details for a transaction.
294 *
295 * See also {@link transaction.TransactionStatus}.
296 */
297export type TransactionDetails = {
298 /**
299 * Unique identifier of the transaction.
300 */
301 id: string;
302 /**
303 * Status (or "state") of the transaction.
304 */
305 state: "running" | "committed" | "aborted";
306};
307/**
308 * Plan explaining query execution.
309 */
310export type ExplainPlan = {
311 /**
312 * Execution nodes in this plan.
313 */
314 nodes: {
315 [key: string]: any;
316 type: string;
317 id: number;
318 dependencies: number[];
319 estimatedCost: number;
320 estimatedNrItems: number;
321 }[];
322 /**
323 * Rules applied by the optimizer.
324 */
325 rules: string[];
326 /**
327 * Information about collections involved in the query.
328 */
329 collections: {
330 name: string;
331 type: "read" | "write";
332 }[];
333 /**
334 * Variables used in the query.
335 */
336 variables: {
337 id: number;
338 name: string;
339 }[];
340 /**
341 * Total estimated cost of the plan.
342 */
343 estimatedCost: number;
344 /**
345 * Estimated number of items returned by the query.
346 */
347 estimatedNrItems: number;
348 /**
349 * Whether the query is a data modification query.
350 */
351 isModificationQuery: boolean;
352};
353/**
354 * Optimizer statistics for an explained query.
355 */
356export type ExplainStats = {
357 /**
358 * Total number of rules executed for this query.
359 */
360 rulesExecuted: number;
361 /**
362 * Number of rules skipped for this query.
363 */
364 rulesSkipped: number;
365 /**
366 * Total number of plans created.
367 */
368 plansCreated: number;
369 /**
370 * Maximum memory usage in bytes of the query during explain.
371 */
372 peakMemoryUsage: number;
373 /**
374 * Time in seconds needed to explain the query.
375 */
376 executionTime: number;
377};
378/**
379 * Result of explaining a query with a single plan.
380 */
381export type SingleExplainResult = {
382 /**
383 * Query plan.
384 */
385 plan: ExplainPlan;
386 /**
387 * Whether it would be possible to cache the query.
388 */
389 cacheable: boolean;
390 /**
391 * Warnings encountered while planning the query execution.
392 */
393 warnings: {
394 code: number;
395 message: string;
396 }[];
397 /**
398 * Optimizer statistics for the explained query.
399 */
400 stats: ExplainStats;
401};
402/**
403 * Result of explaining a query with multiple plans.
404 */
405export type MultiExplainResult = {
406 /**
407 * Query plans.
408 */
409 plans: ExplainPlan[];
410 /**
411 * Whether it would be possible to cache the query.
412 */
413 cacheable: boolean;
414 /**
415 * Warnings encountered while planning the query execution.
416 */
417 warnings: {
418 code: number;
419 message: string;
420 }[];
421 /**
422 * Optimizer statistics for the explained query.
423 */
424 stats: ExplainStats;
425};
426/**
427 * Node in an AQL abstract syntax tree (AST).
428 */
429export type AstNode = {
430 [key: string]: any;
431 type: string;
432 subNodes: AstNode[];
433};
434/**
435 * Result of parsing a query.
436 */
437export type ParseResult = {
438 /**
439 * Whether the query was parsed.
440 */
441 parsed: boolean;
442 /**
443 * Names of all collections involved in the query.
444 */
445 collections: string[];
446 /**
447 * Names of all bind parameters used in the query.
448 */
449 bindVars: string[];
450 /**
451 * Abstract syntax tree (AST) of the query.
452 */
453 ast: AstNode[];
454};
455/**
456 * Optimizer rule for AQL queries.
457 */
458export type QueryOptimizerRule = {
459 name: string;
460 flags: {
461 hidden: boolean;
462 clusterOnly: boolean;
463 canBeDisabled: boolean;
464 canCreateAdditionalPlans: boolean;
465 disabledByDefault: boolean;
466 enterpriseOnly: boolean;
467 };
468};
469/**
470 * Information about query tracking.
471 */
472export type QueryTracking = {
473 /**
474 * Whether query tracking is enabled.
475 */
476 enabled: boolean;
477 /**
478 * Maximum query string length in bytes that is kept in the list.
479 */
480 maxQueryStringLength: number;
481 /**
482 * Maximum number of slow queries that is kept in the list.
483 */
484 maxSlowQueries: number;
485 /**
486 * Threshold execution time in seconds for when a query is
487 * considered slow.
488 */
489 slowQueryThreshold: number;
490 /**
491 * Whether bind parameters are being tracked along with queries.
492 */
493 trackBindVars: boolean;
494 /**
495 * Whether slow queries are being tracked.
496 */
497 trackSlowQueries: boolean;
498};
499/**
500 * Options for query tracking.
501 *
502 * See {@link Database#queryTracking}.
503 */
504export type QueryTrackingOptions = {
505 /**
506 * If set to `false`, neither queries nor slow queries will be tracked.
507 */
508 enabled?: boolean;
509 /**
510 * Maximum query string length in bytes that will be kept in the list.
511 */
512 maxQueryStringLength?: number;
513 /**
514 * Maximum number of slow queries to be kept in the list.
515 */
516 maxSlowQueries?: number;
517 /**
518 * Threshold execution time in seconds for when a query will be
519 * considered slow.
520 */
521 slowQueryThreshold?: number;
522 /**
523 * If set to `true`, bind parameters will be tracked along with queries.
524 */
525 trackBindVars?: boolean;
526 /**
527 * If set to `true` and `enabled` is also set to `true`, slow queries will be
528 * tracked if their execution time exceeds `slowQueryThreshold`.
529 */
530 trackSlowQueries?: boolean;
531};
532/**
533 * Object describing a query.
534 */
535export type QueryInfo = {
536 /**
537 * Unique identifier for this query.
538 */
539 id: string;
540 /**
541 * Name of the database the query runs in.
542 */
543 database: string;
544 /**
545 * Name of the user that started the query.
546 */
547 user: string;
548 /**
549 * Query string (potentially truncated).
550 */
551 query: string;
552 /**
553 * Bind parameters used in the query.
554 */
555 bindVars: Record<string, any>;
556 /**
557 * Date and time the query was started.
558 */
559 started: string;
560 /**
561 * Query's running time in seconds.
562 */
563 runTime: number;
564 /**
565 * Maximum memory usage in bytes of the query.
566 */
567 peakMemoryUsage: number;
568 /**
569 * Query's current execution state.
570 */
571 state: "executing" | "finished" | "killed";
572 /**
573 * Whether the query uses a streaming cursor.
574 */
575 stream: boolean;
576};
577/**
578 * Information about a cluster imbalance.
579 */
580export type ClusterImbalanceInfo = {
581 /**
582 * Information about the leader imbalance.
583 */
584 leader: {
585 /**
586 * The weight of leader shards per DB-Server. A leader has a weight of 1 by default but it is higher if collections can only be moved together because of `distributeShardsLike`.
587 */
588 weightUsed: number[];
589 /**
590 * The ideal weight of leader shards per DB-Server.
591 */
592 targetWeight: number[];
593 /**
594 * The number of leader shards per DB-Server.
595 */
596 numberShards: number[];
597 /**
598 * The measure of the leader shard distribution. The higher the number, the worse the distribution.
599 */
600 leaderDupl: number[];
601 /**
602 * The sum of all weights.
603 */
604 totalWeight: number;
605 /**
606 * The measure of the total imbalance. A high value indicates a high imbalance.
607 */
608 imbalance: number;
609 /**
610 * The sum of shards, counting leader shards only.
611 */
612 totalShards: number;
613 };
614 /**
615 * Information about the shard imbalance.
616 */
617 shards: {
618 /**
619 * The size of shards per DB-Server.
620 */
621 sizeUsed: number[];
622 /**
623 * The ideal size of shards per DB-Server.
624 */
625 targetSize: number[];
626 /**
627 * The number of leader and follower shards per DB-Server.
628 */
629 numberShards: number[];
630 /**
631 * The sum of the sizes.
632 */
633 totalUsed: number;
634 /**
635 * The sum of shards, counting leader and follower shards.
636 */
637 totalShards: number;
638 /**
639 * The sum of system collection shards, counting leader shards only.
640 */
641 totalShardsFromSystemCollections: number;
642 /**
643 * The measure of the total imbalance. A high value indicates a high imbalance.
644 */
645 imbalance: number;
646 };
647};
648/**
649 * Information about the current state of the cluster imbalance.
650 */
651export type ClusterRebalanceState = ClusterImbalanceInfo & {
652 /**
653 * The number of pending move shard operations.
654 */
655 pendingMoveShards: number;
656 /**
657 * The number of planned move shard operations.
658 */
659 todoMoveShards: number;
660};
661/**
662 * Options for rebalancing the cluster.
663 */
664export type ClusterRebalanceOptions = {
665 /**
666 * Maximum number of moves to be computed.
667 *
668 * Default: `1000`
669 */
670 maximumNumberOfMoves?: number;
671 /**
672 * Allow leader changes without moving data.
673 *
674 * Default: `true`
675 */
676 leaderChanges?: boolean;
677 /**
678 * Allow moving leaders.
679 *
680 * Default: `false`
681 */
682 moveLeaders?: boolean;
683 /**
684 * Allow moving followers.
685 *
686 * Default: `false`
687 */
688 moveFollowers?: boolean;
689 /**
690 * Ignore system collections in the rebalance plan.
691 *
692 * Default: `false`
693 */
694 excludeSystemCollections?: boolean;
695 /**
696 * Default: `256**6`
697 */
698 piFactor?: number;
699 /**
700 * A list of database names to exclude from the analysis.
701 *
702 * Default: `[]`
703 */
704 databasesExcluded?: string[];
705};
706export type ClusterRebalanceMove = {
707 /**
708 * The server name from which to move.
709 */
710 from: string;
711 /**
712 * The ID of the destination server.
713 */
714 to: string;
715 /**
716 * Shard ID of the shard to be moved.
717 */
718 shard: string;
719 /**
720 * Collection ID of the collection the shard belongs to.
721 */
722 collection: number;
723 /**
724 * True if this is a leader move shard operation.
725 */
726 isLeader: boolean;
727};
728export type ClusterRebalanceResult = {
729 /**
730 * Imbalance before the suggested move shard operations are applied.
731 */
732 imbalanceBefore: ClusterImbalanceInfo;
733 /**
734 * Expected imbalance after the suggested move shard operations are applied.
735 */
736 imbalanceAfter: ClusterImbalanceInfo;
737 /**
738 * Suggested move shard operations.
739 */
740 moves: ClusterRebalanceMove[];
741};
742/**
743 * Database user to create with a database.
744 */
745export type CreateDatabaseUser = {
746 /**
747 * Username of the user to create.
748 */
749 username: string;
750 /**
751 * Password of the user to create.
752 *
753 * Default: `""`
754 */
755 passwd?: string;
756 /**
757 * Whether the user is active.
758 *
759 * Default: `true`
760 */
761 active?: boolean;
762 /**
763 * Additional data to store with the user object.
764 */
765 extra?: Record<string, any>;
766};
767/**
768 * Options for creating a database.
769 *
770 * See {@link Database#createDatabase}.
771 */
772export type CreateDatabaseOptions = {
773 /**
774 * Database users to create with the database.
775 */
776 users?: CreateDatabaseUser[];
777 /**
778 * (Cluster only.) The sharding method to use for new collections in the
779 * database.
780 */
781 sharding?: "" | "flexible" | "single";
782 /**
783 * (Cluster only.) Default replication factor for new collections in this
784 * database.
785 *
786 * Setting this to `1` disables replication. Setting this to `"satellite"`
787 * will replicate to every DBServer.
788 */
789 replicationFactor?: "satellite" | number;
790 /**
791 * (Cluster only.) Default write concern for new collections created in this
792 * database.
793 */
794 writeConcern?: number;
795};
796/**
797 * Object describing a database.
798 *
799 * See {@link Database#get}.
800 */
801export type DatabaseInfo = {
802 /**
803 * Name of the database.
804 */
805 name: string;
806 /**
807 * Unique identifier of the database.
808 */
809 id: string;
810 /**
811 * File system path of the database.
812 */
813 path: string;
814 /**
815 * Whether the database is the system database.
816 */
817 isSystem: boolean;
818 /**
819 * (Cluster only.) The sharding method to use for new collections in the
820 * database.
821 */
822 sharding?: "" | "flexible" | "single";
823 /**
824 * (Cluster only.) Default replication factor for new collections in this
825 * database.
826 */
827 replicationFactor?: "satellite" | number;
828 /**
829 * (Cluster only.) Default write concern for new collections created in this
830 * database.
831 */
832 writeConcern?: number;
833};
834/**
835 * Result of retrieving database version information.
836 */
837export type VersionInfo = {
838 /**
839 * Value identifying the server type, i.e. `"arango"`.
840 */
841 server: string;
842 /**
843 * ArangoDB license type or "edition".
844 */
845 license: "community" | "enterprise";
846 /**
847 * ArangoDB server version.
848 */
849 version: string;
850 /**
851 * Additional information about the ArangoDB server.
852 */
853 details?: {
854 [key: string]: string;
855 };
856};
857/**
858 * Definition of an AQL User Function.
859 */
860export type AqlUserFunction = {
861 /**
862 * Name of the AQL User Function.
863 */
864 name: string;
865 /**
866 * Implementation of the AQL User Function.
867 */
868 code: string;
869 /**
870 * Whether the function is deterministic.
871 *
872 * See {@link Database#createFunction}.
873 */
874 isDeterministic: boolean;
875};
876/**
877 * Options for installing the service.
878 *
879 * See {@link Database#installService}.
880 */
881export type InstallServiceOptions = {
882 /**
883 * An object mapping configuration option names to values.
884 *
885 * See also {@link Database#getServiceConfiguration}.
886 */
887 configuration?: Record<string, any>;
888 /**
889 * An object mapping dependency aliases to mount points.
890 *
891 * See also {@link Database#getServiceDependencies}.
892 */
893 dependencies?: Record<string, string>;
894 /**
895 * Whether the service should be installed in development mode.
896 *
897 * See also {@link Database#setServiceDevelopmentMode}.
898 *
899 * Default: `false`
900 */
901 development?: boolean;
902 /**
903 * Whether the service should be installed in legacy compatibility mode
904 *
905 * This overrides the `engines` option in the service manifest (if any).
906 *
907 * Default: `false`
908 */
909 legacy?: boolean;
910 /**
911 * Whether the "setup" script should be executed.
912 *
913 * Default: `true`
914 */
915 setup?: boolean;
916};
917/**
918 * Options for replacing a service.
919 *
920 * See {@link Database#replaceService}.
921 */
922export type ReplaceServiceOptions = {
923 /**
924 * An object mapping configuration option names to values.
925 *
926 * See also {@link Database#getServiceConfiguration}.
927 */
928 configuration?: Record<string, any>;
929 /**
930 * An object mapping dependency aliases to mount points.
931 *
932 * See also {@link Database#getServiceDependencies}.
933 */
934 dependencies?: Record<string, string>;
935 /**
936 * Whether the service should be installed in development mode.
937 *
938 * See also {@link Database#setServiceDevelopmentMode}.
939 *
940 * Default: `false`
941 */
942 development?: boolean;
943 /**
944 * Whether the service should be installed in legacy compatibility mode
945 *
946 * This overrides the `engines` option in the service manifest (if any).
947 *
948 * Default: `false`
949 */
950 legacy?: boolean;
951 /**
952 * Whether the "setup" script should be executed.
953 *
954 * Default: `true`
955 */
956 setup?: boolean;
957 /**
958 * Whether the existing service's "teardown" script should be executed
959 * prior to removing that service.
960 *
961 * Default: `true`
962 */
963 teardown?: boolean;
964 /**
965 * If set to `true`, replacing a service that does not already exist will
966 * fall back to installing the new service.
967 *
968 * Default: `false`
969 */
970 force?: boolean;
971};
972/**
973 * Options for upgrading a service.
974 *
975 * See {@link Database#upgradeService}.
976 */
977export type UpgradeServiceOptions = {
978 /**
979 * An object mapping configuration option names to values.
980 *
981 * See also {@link Database#getServiceConfiguration}.
982 */
983 configuration?: Record<string, any>;
984 /**
985 * An object mapping dependency aliases to mount points.
986 *
987 * See also {@link Database#getServiceDependencies}.
988 */
989 dependencies?: Record<string, string>;
990 /**
991 * Whether the service should be installed in development mode.
992 *
993 * See also {@link Database#setServiceDevelopmentMode}.
994 *
995 * Default: `false`
996 */
997 development?: boolean;
998 /**
999 * Whether the service should be installed in legacy compatibility mode
1000 *
1001 * This overrides the `engines` option in the service manifest (if any).
1002 *
1003 * Default: `false`
1004 */
1005 legacy?: boolean;
1006 /**
1007 * Whether the "setup" script should be executed.
1008 *
1009 * Default: `true`
1010 */
1011 setup?: boolean;
1012 /**
1013 * Whether the existing service's "teardown" script should be executed
1014 * prior to upgrading that service.
1015 *
1016 * Default: `false`
1017 */
1018 teardown?: boolean;
1019 /**
1020 * Unless set to `true`, upgrading a service that does not already exist will
1021 * fall back to installing the new service.
1022 *
1023 * Default: `false`
1024 */
1025 force?: boolean;
1026};
1027/**
1028 * Options for uninstalling a service.
1029 *
1030 * See {@link Database#uninstallService}.
1031 */
1032export type UninstallServiceOptions = {
1033 /**
1034 * Whether the service's "teardown" script should be executed
1035 * prior to removing that service.
1036 *
1037 * Default: `true`
1038 */
1039 teardown?: boolean;
1040 /**
1041 * If set to `true`, uninstalling a service that does not already exist
1042 * will be considered successful.
1043 *
1044 * Default: `false`
1045 */
1046 force?: boolean;
1047};
1048/**
1049 * Object briefly describing a Foxx service.
1050 */
1051export type ServiceSummary = {
1052 /**
1053 * Service mount point, relative to the database.
1054 */
1055 mount: string;
1056 /**
1057 * Name defined in the service manifest.
1058 */
1059 name?: string;
1060 /**
1061 * Version defined in the service manifest.
1062 */
1063 version?: string;
1064 /**
1065 * Service dependencies the service expects to be able to match as a mapping
1066 * from dependency names to versions the service is compatible with.
1067 */
1068 provides: Record<string, string>;
1069 /**
1070 * Whether development mode is enabled for this service.
1071 */
1072 development: boolean;
1073 /**
1074 * Whether the service is running in legacy compatibility mode.
1075 */
1076 legacy: boolean;
1077};
1078/**
1079 * Object describing a Foxx service in detail.
1080 */
1081export type ServiceInfo = {
1082 /**
1083 * Service mount point, relative to the database.
1084 */
1085 mount: string;
1086 /**
1087 * File system path of the service.
1088 */
1089 path: string;
1090 /**
1091 * Name defined in the service manifest.
1092 */
1093 name?: string;
1094 /**
1095 * Version defined in the service manifest.
1096 */
1097 version?: string;
1098 /**
1099 * Whether development mode is enabled for this service.
1100 */
1101 development: boolean;
1102 /**
1103 * Whether the service is running in legacy compatibility mode.
1104 */
1105 legacy: boolean;
1106 /**
1107 * Content of the service manifest of this service.
1108 */
1109 manifest: FoxxManifest;
1110 /**
1111 * Internal checksum of the service's initial source bundle.
1112 */
1113 checksum: string;
1114 /**
1115 * Options for this service.
1116 */
1117 options: {
1118 /**
1119 * Configuration values set for this service.
1120 */
1121 configuration: Record<string, any>;
1122 /**
1123 * Service dependency configuration of this service.
1124 */
1125 dependencies: Record<string, string>;
1126 };
1127};
1128/**
1129 * Object describing a configuration option of a Foxx service.
1130 */
1131export type ServiceConfiguration = {
1132 /**
1133 * Data type of the configuration value.
1134 *
1135 * **Note**: `"int"` and `"bool"` are historical synonyms for `"integer"` and
1136 * `"boolean"`. The `"password"` type is synonymous with `"string"` but can
1137 * be used to distinguish values which should not be displayed in plain text
1138 * by software when managing the service.
1139 */
1140 type: "integer" | "boolean" | "string" | "number" | "json" | "password" | "int" | "bool";
1141 /**
1142 * Current value of the configuration option as stored internally.
1143 */
1144 currentRaw: any;
1145 /**
1146 * Processed current value of the configuration option as exposed in the
1147 * service code.
1148 */
1149 current: any;
1150 /**
1151 * Formatted name of the configuration option.
1152 */
1153 title: string;
1154 /**
1155 * Human-readable description of the configuration option.
1156 */
1157 description?: string;
1158 /**
1159 * Whether the configuration option must be set in order for the service
1160 * to be operational.
1161 */
1162 required: boolean;
1163 /**
1164 * Default value of the configuration option.
1165 */
1166 default?: any;
1167};
1168/**
1169 * Object describing a single-service dependency defined by a Foxx service.
1170 */
1171export type SingleServiceDependency = {
1172 /**
1173 * Whether this is a multi-service dependency.
1174 */
1175 multiple: false;
1176 /**
1177 * Current mount point the dependency is resolved to.
1178 */
1179 current?: string;
1180 /**
1181 * Formatted name of the dependency.
1182 */
1183 title: string;
1184 /**
1185 * Name of the service the dependency expects to match.
1186 */
1187 name: string;
1188 /**
1189 * Version of the service the dependency expects to match.
1190 */
1191 version: string;
1192 /**
1193 * Human-readable description of the dependency.
1194 */
1195 description?: string;
1196 /**
1197 * Whether the dependency must be matched in order for the service
1198 * to be operational.
1199 */
1200 required: boolean;
1201};
1202/**
1203 * Object describing a multi-service dependency defined by a Foxx service.
1204 */
1205export type MultiServiceDependency = {
1206 /**
1207 * Whether this is a multi-service dependency.
1208 */
1209 multiple: true;
1210 /**
1211 * Current mount points the dependency is resolved to.
1212 */
1213 current?: string[];
1214 /**
1215 * Formatted name of the dependency.
1216 */
1217 title: string;
1218 /**
1219 * Name of the service the dependency expects to match.
1220 */
1221 name: string;
1222 /**
1223 * Version of the service the dependency expects to match.
1224 */
1225 version: string;
1226 /**
1227 * Human-readable description of the dependency.
1228 */
1229 description?: string;
1230 /**
1231 * Whether the dependency must be matched in order for the service
1232 * to be operational.
1233 */
1234 required: boolean;
1235};
1236/**
1237 * Test stats for a Foxx service's tests.
1238 */
1239export type ServiceTestStats = {
1240 /**
1241 * Total number of tests found.
1242 */
1243 tests: number;
1244 /**
1245 * Number of tests that ran successfully.
1246 */
1247 passes: number;
1248 /**
1249 * Number of tests that failed.
1250 */
1251 failures: number;
1252 /**
1253 * Number of tests skipped or not executed.
1254 */
1255 pending: number;
1256 /**
1257 * Total test duration in milliseconds.
1258 */
1259 duration: number;
1260};
1261/**
1262 * Test results for a single test case using the stream reporter.
1263 */
1264export type ServiceTestStreamTest = {
1265 title: string;
1266 fullTitle: string;
1267 duration: number;
1268 err?: string;
1269};
1270/**
1271 * Test results for a Foxx service's tests using the stream reporter.
1272 */
1273export type ServiceTestStreamReport = (["start", {
1274 total: number;
1275}] | ["pass", ServiceTestStreamTest] | ["fail", ServiceTestStreamTest] | ["end", ServiceTestStats])[];
1276/**
1277 * Test results for a single test case using the suite reporter.
1278 */
1279export type ServiceTestSuiteTest = {
1280 result: "pending" | "pass" | "fail";
1281 title: string;
1282 duration: number;
1283 err?: any;
1284};
1285/**
1286 * Test results for a single test suite using the suite reporter.
1287 */
1288export type ServiceTestSuite = {
1289 title: string;
1290 suites: ServiceTestSuite[];
1291 tests: ServiceTestSuiteTest[];
1292};
1293/**
1294 * Test results for a Foxx service's tests using the suite reporter.
1295 */
1296export type ServiceTestSuiteReport = {
1297 stats: ServiceTestStats;
1298 suites: ServiceTestSuite[];
1299 tests: ServiceTestSuiteTest[];
1300};
1301/**
1302 * Test results for a single test case in XUnit format using the JSONML
1303 * representation.
1304 */
1305export type ServiceTestXunitTest = ["testcase", {
1306 classname: string;
1307 name: string;
1308 time: number;
1309}] | [
1310 "testcase",
1311 {
1312 classname: string;
1313 name: string;
1314 time: number;
1315 },
1316 [
1317 "failure",
1318 {
1319 message: string;
1320 type: string;
1321 },
1322 string
1323 ]
1324];
1325/**
1326 * Test results for a Foxx service's tests in XUnit format using the JSONML
1327 * representation.
1328 */
1329export type ServiceTestXunitReport = [
1330 "testsuite",
1331 {
1332 timestamp: number;
1333 tests: number;
1334 errors: number;
1335 failures: number;
1336 skip: number;
1337 time: number;
1338 },
1339 ...ServiceTestXunitTest[]
1340];
1341/**
1342 * Test results for a Foxx service's tests in TAP format.
1343 */
1344export type ServiceTestTapReport = string[];
1345/**
1346 * Test results for a single test case using the default reporter.
1347 */
1348export type ServiceTestDefaultTest = {
1349 title: string;
1350 fullTitle: string;
1351 duration: number;
1352 err?: string;
1353};
1354/**
1355 * Test results for a Foxx service's tests using the default reporter.
1356 */
1357export type ServiceTestDefaultReport = {
1358 stats: ServiceTestStats;
1359 tests: ServiceTestDefaultTest[];
1360 pending: ServiceTestDefaultTest[];
1361 failures: ServiceTestDefaultTest[];
1362 passes: ServiceTestDefaultTest[];
1363};
1364/**
1365 * OpenAPI 2.0 description of a Foxx service.
1366 */
1367export type SwaggerJson = {
1368 [key: string]: any;
1369 info: {
1370 title: string;
1371 description: string;
1372 version: string;
1373 license: string;
1374 };
1375 path: {
1376 [key: string]: any;
1377 };
1378};
1379/**
1380 * Access level for an ArangoDB user's access to a collection or database.
1381 */
1382export type AccessLevel = "rw" | "ro" | "none";
1383/**
1384 * Properties of an ArangoDB user object.
1385 */
1386export type ArangoUser = {
1387 /**
1388 * ArangoDB username of the user.
1389 */
1390 user: string;
1391 /**
1392 * Whether the ArangoDB user account is enabled and can authenticate.
1393 */
1394 active: boolean;
1395 /**
1396 * Additional information to store about this user.
1397 */
1398 extra: Record<string, any>;
1399};
1400/**
1401 * Options for creating an ArangoDB user.
1402 */
1403export type CreateUserOptions = {
1404 /**
1405 * ArangoDB username of the user.
1406 */
1407 user: string;
1408 /**
1409 * Password the ArangoDB user will use for authentication.
1410 */
1411 passwd: string;
1412 /**
1413 * Whether the ArangoDB user account is enabled and can authenticate.
1414 *
1415 * Default: `true`
1416 */
1417 active?: boolean;
1418 /**
1419 * Additional information to store about this user.
1420 *
1421 * Default: `{}`
1422 */
1423 extra?: Record<string, any>;
1424};
1425/**
1426 * Options for modifying an ArangoDB user.
1427 */
1428export type UserOptions = {
1429 /**
1430 * Password the ArangoDB user will use for authentication.
1431 */
1432 passwd: string;
1433 /**
1434 * Whether the ArangoDB user account is enabled and can authenticate.
1435 *
1436 * Default: `true`
1437 */
1438 active?: boolean;
1439 /**
1440 * Additional information to store about this user.
1441 *
1442 * Default: `{}`
1443 */
1444 extra?: Record<string, any>;
1445};
1446/**
1447 * Options for accessing or manipulating access levels.
1448 */
1449export type UserAccessLevelOptions = {
1450 /**
1451 * The database to access or manipulate the access level of.
1452 *
1453 * If `collection` is an `ArangoCollection`, this option defaults to the
1454 * database the collection is contained in. Otherwise this option defaults to
1455 * the current database.
1456 */
1457 database?: Database | string;
1458 /**
1459 * The collection to access or manipulate the access level of.
1460 */
1461 collection?: ArangoCollection | string;
1462};
1463/**
1464 * An object providing methods for accessing queue time metrics of the most
1465 * recently received server responses if the server supports this feature.
1466 */
1467export type QueueTimeMetrics = {
1468 /**
1469 * Returns the queue time of the most recently received response in seconds.
1470 */
1471 getLatest: () => number | undefined;
1472 /**
1473 * Returns a list of the most recently received queue time values as tuples
1474 * of the timestamp of the response being processed in milliseconds and the
1475 * queue time in seconds.
1476 */
1477 getValues: () => [number, number][];
1478 /**
1479 * Returns the average queue time of the most recently received responses
1480 * in seconds.
1481 */
1482 getAvg: () => number;
1483};
1484/**
1485 * (Enterprise Edition only.) Options for creating a hot backup.
1486 */
1487export type HotBackupOptions = {
1488 /**
1489 * If set to `true` and no global transaction lock can be acquired within the
1490 * given timeout, a possibly inconsistent backup is taken.
1491 *
1492 * Default: `false`
1493 */
1494 allowInconsistent?: boolean;
1495 /**
1496 * (Enterprise Edition cluster only.) If set to `true` and no global
1497 * transaction lock can be acquired within the given timeout, all running
1498 * transactions are forcefully aborted to ensure that a consistent backup
1499 * can be created.
1500 *
1501 * Default: `false`.
1502 */
1503 force?: boolean;
1504 /**
1505 * Label to appended to the backup's identifier.
1506 *
1507 * Default: If omitted or empty, a UUID will be generated.
1508 */
1509 label?: string;
1510 /**
1511 * Time in seconds that the operation will attempt to get a consistent
1512 * snapshot.
1513 *
1514 * Default: `120`.
1515 */
1516 timeout?: number;
1517};
1518/**
1519 * (Enterprise Edition only.) Result of a hot backup.
1520 */
1521export type HotBackupResult = {
1522 id: string;
1523 potentiallyInconsistent: boolean;
1524 sizeInBytes: number;
1525 datetime: string;
1526 nrDBServers: number;
1527 nrFiles: number;
1528};
1529/**
1530 * (Enterprise Edition only.) List of known hot backups.
1531 */
1532export type HotBackupList = {
1533 server: string;
1534 list: Record<string, HotBackupResult & {
1535 version: string;
1536 keys: any[];
1537 available: boolean;
1538 nrPiecesPresent: number;
1539 countIncludesFilesOnly: boolean;
1540 }>;
1541};
1542/**
1543 * Numeric representation of the logging level of a log entry.
1544 */
1545export declare enum LogLevel {
1546 FATAL = 0,
1547 ERROR = 1,
1548 WARNING = 2,
1549 INFO = 3,
1550 DEBUG = 4
1551}
1552/**
1553 * String representation of the logging level of a log entry.
1554 */
1555export type LogLevelLabel = "FATAL" | "ERROR" | "WARNING" | "INFO" | "DEBUG";
1556/**
1557 * Logging level setting.
1558 */
1559export type LogLevelSetting = LogLevelLabel | "DEFAULT";
1560/**
1561 * Log sorting direction, ascending or descending.
1562 */
1563export type LogSortDirection = "asc" | "desc";
1564/**
1565 * Options for retrieving log entries.
1566 */
1567export type LogEntriesOptions = {
1568 /**
1569 * Maximum log level of the entries to retrieve.
1570 *
1571 * Default: `INFO`.
1572 */
1573 upto?: LogLevel | LogLevelLabel | Lowercase<LogLevelLabel>;
1574 /**
1575 * If set, only log entries with this log level will be returned.
1576 */
1577 level?: LogLevel | LogLevelLabel | Lowercase<LogLevelLabel>;
1578 /**
1579 * If set, only log entries with an `lid` greater than or equal to this value
1580 * will be returned.
1581 */
1582 start?: number;
1583 /**
1584 * If set, only this many entries will be returned.
1585 */
1586 size?: number;
1587 /**
1588 * If set, this many log entries will be skipped.
1589 */
1590 offset?: number;
1591 /**
1592 * If set, only log entries containing the specified text will be returned.
1593 */
1594 search?: string;
1595 /**
1596 * If set to `"desc"`, log entries will be returned in reverse chronological
1597 * order.
1598 *
1599 * Default: `"asc"`.
1600 */
1601 sort?: LogSortDirection;
1602};
1603/**
1604 * An object representing a single log entry.
1605 */
1606export type LogMessage = {
1607 id: number;
1608 topic: string;
1609 level: LogLevelLabel;
1610 date: string;
1611 message: string;
1612};
1613/**
1614 * An object representing a list of log entries.
1615 */
1616export type LogEntries = {
1617 totalAmount: number;
1618 lid: number[];
1619 topic: string[];
1620 level: LogLevel[];
1621 timestamp: number[];
1622 text: string[];
1623};
1624type TrappedError = {
1625 error: true;
1626};
1627type TrappedRequest = {
1628 error?: false;
1629 jobId: string;
1630 onResolve: (res: ArangojsResponse) => void;
1631 onReject: (error: any) => void;
1632};
1633/**
1634 * An object representing a single ArangoDB database. All arangojs collections,
1635 * cursors, analyzers and so on are linked to a `Database` object.
1636 */
1637export declare class Database {
1638 protected _connection: Connection;
1639 protected _name: string;
1640 protected _analyzers: Map<string, Analyzer>;
1641 protected _collections: Map<string, Collection<any>>;
1642 protected _graphs: Map<string, Graph>;
1643 protected _views: Map<string, View>;
1644 protected _trapRequest?: (trapped: TrappedError | TrappedRequest) => void;
1645 /**
1646 * Creates a new `Database` instance with its own connection pool.
1647 *
1648 * See also {@link Database#database}.
1649 *
1650 * @param config - An object with configuration options.
1651 *
1652 * @example
1653 * ```js
1654 * const db = new Database({
1655 * url: "http://127.0.0.1:8529",
1656 * databaseName: "my_database",
1657 * auth: { username: "admin", password: "hunter2" },
1658 * });
1659 * ```
1660 */
1661 constructor(config?: Config);
1662 /**
1663 * Creates a new `Database` instance with its own connection pool.
1664 *
1665 * See also {@link Database#database}.
1666 *
1667 * @param url - Base URL of the ArangoDB server or list of server URLs.
1668 * Equivalent to the `url` option in {@link connection.Config}.
1669 *
1670 * @example
1671 * ```js
1672 * const db = new Database("http://127.0.0.1:8529", "my_database");
1673 * db.useBasicAuth("admin", "hunter2");
1674 * ```
1675 */
1676 constructor(url: string | string[], name?: string);
1677 /**
1678 * @internal
1679 */
1680 constructor(database: Database, name?: string);
1681 /**
1682 * @internal
1683 *
1684 * Indicates that this object represents an ArangoDB database.
1685 */
1686 get isArangoDatabase(): true;
1687 /**
1688 * Name of the ArangoDB database this instance represents.
1689 */
1690 get name(): string;
1691 /**
1692 * Fetches version information from the ArangoDB server.
1693 *
1694 * @param details - If set to `true`, additional information about the
1695 * ArangoDB server will be available as the `details` property.
1696 *
1697 * @example
1698 * ```js
1699 * const db = new Database();
1700 * const version = await db.version();
1701 * // the version object contains the ArangoDB version information.
1702 * // license: "community" or "enterprise"
1703 * // version: ArangoDB version number
1704 * // server: description of the server
1705 * ```
1706 */
1707 version(details?: boolean): Promise<VersionInfo>;
1708 /**
1709 * Retrives the server's current system time in milliseconds with microsecond
1710 * precision.
1711 */
1712 time(): Promise<number>;
1713 /**
1714 * Returns a new {@link route.Route} instance for the given path (relative to the
1715 * database) that can be used to perform arbitrary HTTP requests.
1716 *
1717 * @param path - The database-relative URL of the route. Defaults to the
1718 * database API root.
1719 * @param headers - Default headers that should be sent with each request to
1720 * the route.
1721 *
1722 * @example
1723 * ```js
1724 * const db = new Database();
1725 * const myFoxxService = db.route("my-foxx-service");
1726 * const response = await myFoxxService.post("users", {
1727 * username: "admin",
1728 * password: "hunter2"
1729 * });
1730 * // response.body is the result of
1731 * // POST /_db/_system/my-foxx-service/users
1732 * // with JSON request body '{"username": "admin", "password": "hunter2"}'
1733 * ```
1734 */
1735 route(path?: string, headers?: Headers): Route;
1736 /**
1737 * Creates an async job by executing the given callback function. The first
1738 * database request performed by the callback will be marked for asynchronous
1739 * execution and its result will be made available as an async job.
1740 *
1741 * Returns a {@link Job} instance that can be used to retrieve the result
1742 * of the callback function once the request has been executed.
1743 *
1744 * @param callback - Callback function to execute as an async job.
1745 *
1746 * @example
1747 * ```js
1748 * const db = new Database();
1749 * const job = await db.createJob(() => db.collections());
1750 * while (!job.isLoaded) {
1751 * await timeout(1000);
1752 * await job.load();
1753 * }
1754 * // job.result is a list of Collection instances
1755 * ```
1756 */
1757 createJob<T>(callback: () => Promise<T>): Promise<Job<T>>;
1758 /**
1759 * @internal
1760 *
1761 * Performs an arbitrary HTTP request against the database.
1762 *
1763 * If `absolutePath` is set to `true`, the database path will not be
1764 * automatically prepended to the `basePath`.
1765 *
1766 * @param T - Return type to use. Defaults to the response object type.
1767 * @param options - Options for this request.
1768 * @param transform - An optional function to transform the low-level
1769 * response object to a more useful return value.
1770 */
1771 request<T = any>(options: RequestOptions & {
1772 absolutePath?: boolean;
1773 }, transform?: (res: ArangojsResponse) => T): Promise<T>;
1774 /**
1775 * @internal
1776 *
1777 * Performs an arbitrary HTTP request against the database.
1778 *
1779 * If `absolutePath` is set to `true`, the database path will not be
1780 * automatically prepended to the `basePath`.
1781 *
1782 * @param options - Options for this request.
1783 * @param transform - If set to `false`, the raw response object will be
1784 * returned.
1785 */
1786 request(options: RequestOptions & {
1787 absolutePath?: boolean;
1788 }, transform: false): Promise<ArangojsResponse>;
1789 /**
1790 * Updates the URL list by requesting a list of all coordinators in the
1791 * cluster and adding any endpoints not initially specified in the
1792 * {@link connection.Config}.
1793 *
1794 * For long-running processes communicating with an ArangoDB cluster it is
1795 * recommended to run this method periodically (e.g. once per hour) to make
1796 * sure new coordinators are picked up correctly and can be used for
1797 * fail-over or load balancing.
1798 *
1799 * @param overwrite - If set to `true`, the existing host list will be
1800 * replaced instead of extended.
1801 *
1802 * @example
1803 * ```js
1804 * const db = new Database();
1805 * const interval = setInterval(
1806 * () => db.acquireHostList(),
1807 * 5 * 60 * 1000 // every 5 minutes
1808 * );
1809 *
1810 * // later
1811 * clearInterval(interval);
1812 * system.close();
1813 * ```
1814 */
1815 acquireHostList(overwrite?: boolean): Promise<void>;
1816 /**
1817 * Closes all active connections of this database instance.
1818 *
1819 * Can be used to clean up idling connections during longer periods of
1820 * inactivity.
1821 *
1822 * **Note**: This method currently has no effect in the browser version of
1823 * arangojs.
1824 *
1825 * @example
1826 * ```js
1827 * const db = new Database();
1828 * const sessions = db.collection("sessions");
1829 * // Clean up expired sessions once per hour
1830 * setInterval(async () => {
1831 * await db.query(aql`
1832 * FOR session IN ${sessions}
1833 * FILTER session.expires < DATE_NOW()
1834 * REMOVE session IN ${sessions}
1835 * `);
1836 * // Making sure to close the connections because they're no longer used
1837 * system.close();
1838 * }, 1000 * 60 * 60);
1839 * ```
1840 */
1841 close(): void;
1842 /**
1843 * Attempts to initiate a clean shutdown of the server.
1844 */
1845 shutdown(): Promise<void>;
1846 /**
1847 * Performs a request against every known coordinator and returns when the
1848 * request has succeeded against every coordinator or the timeout is reached.
1849 *
1850 * **Note**: This method is primarily intended to make database setup easier
1851 * in cluster scenarios and requires all coordinators to be known to arangojs
1852 * before the method is invoked. The method is not useful in single-server or
1853 * leader-follower replication scenarios.
1854 *
1855 * @example
1856 * ```js
1857 * const db = new Database({ loadBalancingStrategy: "ROUND_ROBIN" });
1858 * await system.acquireHostList();
1859 * const analyzer = db.analyzer("my-analyzer");
1860 * await analyzer.create();
1861 * await db.waitForPropagation(
1862 * { path: `/_api/analyzer/${encodeURIComponent(analyzer.name)}` },
1863 * 30000
1864 * );
1865 * // Analyzer has been propagated to all coordinators and can safely be used
1866 * ```
1867 *
1868 * @param request - Request to perform against each known coordinator.
1869 * @param timeout - Maximum number of milliseconds to wait for propagation.
1870 */
1871 waitForPropagation(request: RequestOptions, timeout?: number): Promise<void>;
1872 /**
1873 * Methods for accessing the server-reported queue times of the mostly
1874 * recently received responses.
1875 */
1876 get queueTime(): QueueTimeMetrics;
1877 /**
1878 * Sets the limit for the number of values of the most recently received
1879 * server-reported queue times that can be accessed using
1880 * {@link Database#queueTime}.
1881 *
1882 * @param responseQueueTimeSamples - Number of values to maintain.
1883 */
1884 setResponseQueueTimeSamples(responseQueueTimeSamples: number): void;
1885 /**
1886 * Updates the underlying connection's `authorization` header to use Basic
1887 * authentication with the given `username` and `password`, then returns
1888 * itself.
1889 *
1890 * @param username - The username to authenticate with.
1891 * @param password - The password to authenticate with.
1892 *
1893 * @example
1894 * ```js
1895 * const db = new Database();
1896 * db.useBasicAuth("admin", "hunter2");
1897 * // with the username "admin" and password "hunter2".
1898 * ```
1899 */
1900 useBasicAuth(username?: string, password?: string): this;
1901 /**
1902 * Updates the underlying connection's `authorization` header to use Bearer
1903 * authentication with the given authentication `token`, then returns itself.
1904 *
1905 * @param token - The token to authenticate with.
1906 *
1907 * @example
1908 * ```js
1909 * const db = new Database();
1910 * db.useBearerAuth("keyboardcat");
1911 * // The database instance now uses Bearer authentication.
1912 * ```
1913 */
1914 useBearerAuth(token: string): this;
1915 /**
1916 * Validates the given database credentials and exchanges them for an
1917 * authentication token, then uses the authentication token for future
1918 * requests and returns it.
1919 *
1920 * @param username - The username to authenticate with.
1921 * @param password - The password to authenticate with.
1922 *
1923 * @example
1924 * ```js
1925 * const db = new Database();
1926 * await db.login("admin", "hunter2");
1927 * // with an authentication token for the "admin" user.
1928 * ```
1929 */
1930 login(username?: string, password?: string): Promise<string>;
1931 /**
1932 * Attempts to renew the authentication token passed to {@link Database#useBearerAuth}
1933 * or returned and used by {@link Database#login}. If a new authentication
1934 * token is issued, it will be used for future requests and returned.
1935 *
1936 * @example
1937 * ```js
1938 * const db = new Database();
1939 * await db.login("admin", "hunter2");
1940 * // ... later ...
1941 * const newToken = await db.renewAuthToken();
1942 * if (!newToken) // no new token issued
1943 * ```
1944 */
1945 renewAuthToken(): Promise<string | null>;
1946 /**
1947 * Computes the current cluster imbalance.
1948 *
1949 * @example
1950 * ```js
1951 * const db = new Database();
1952 * const imbalance = await db.getClusterImbalance();
1953 * ```
1954 */
1955 getClusterImbalance(): Promise<ClusterRebalanceState>;
1956 /**
1957 * Computes a set of move shard operations to rebalance the cluster.
1958 *
1959 * @example
1960 * ```js
1961 * const db = new Database();
1962 * const result = await db.computerClusterRebalance({
1963 * moveLeaders: true,
1964 * moveFollowers: true
1965 * });
1966 * if (result.moves.length) {
1967 * await db.executeClusterRebalance(result.moves);
1968 * }
1969 * ```
1970 */
1971 computeClusterRebalance(opts: ClusterRebalanceOptions): Promise<ClusterRebalanceResult>;
1972 /**
1973 * Executes the given cluster move shard operations.
1974 *
1975 * @example
1976 * ```js
1977 * const db = new Database();
1978 * const result = await db.computerClusterRebalance({
1979 * moveLeaders: true,
1980 * moveFollowers: true
1981 * });
1982 * if (result.moves.length) {
1983 * await db.executeClusterRebalance(result.moves);
1984 * }
1985 * ```
1986 */
1987 executeClusterRebalance(moves: ClusterRebalanceMove[]): Promise<unknown>;
1988 /**
1989 * Computes a set of move shard operations to rebalance the cluster and
1990 * executes them.
1991 *
1992 * @example
1993 * ```js
1994 * const db = new Database();
1995 * const result = await db.rebalanceCluster({
1996 * moveLeaders: true,
1997 * moveFollowers: true
1998 * });
1999 * // The cluster is now rebalanced.
2000 * ```
2001 */
2002 rebalanceCluster(opts: ClusterRebalanceOptions): Promise<ClusterRebalanceResult>;
2003 /**
2004 * Creates a new `Database` instance for the given `databaseName` that
2005 * shares this database's connection pool.
2006 *
2007 * See also {@link Database:constructor}.
2008 *
2009 * @param databaseName - Name of the database.
2010 *
2011 * @example
2012 * ```js
2013 * const systemDb = new Database();
2014 * const myDb = system.database("my_database");
2015 * ```
2016 */
2017 database(databaseName: string): Database;
2018 /**
2019 * Fetches the database description for the active database from the server.
2020 *
2021 * @example
2022 * ```js
2023 * const db = new Database();
2024 * const info = await db.get();
2025 * // the database exists
2026 * ```
2027 */
2028 get(): Promise<DatabaseInfo>;
2029 /**
2030 * Checks whether the database exists.
2031 *
2032 * @example
2033 * ```js
2034 * const db = new Database();
2035 * const result = await db.exists();
2036 * // result indicates whether the database exists
2037 * ```
2038 */
2039 exists(): Promise<boolean>;
2040 /**
2041 * Creates a new database with the given `databaseName` with the given
2042 * `options` and returns a `Database` instance for that database.
2043 *
2044 * @param databaseName - Name of the database to create.
2045 * @param options - Options for creating the database.
2046 *
2047 * @example
2048 * ```js
2049 * const db = new Database();
2050 * const info = await db.createDatabase("mydb", {
2051 * users: [{ username: "root" }]
2052 * });
2053 * // the database has been created
2054 * ```
2055 */
2056 createDatabase(databaseName: string, options?: CreateDatabaseOptions): Promise<Database>;
2057 /**
2058 * Creates a new database with the given `databaseName` with the given
2059 * `users` and returns a `Database` instance for that database.
2060 *
2061 * @param databaseName - Name of the database to create.
2062 * @param users - Database users to create with the database.
2063 *
2064 * @example
2065 * ```js
2066 * const db = new Database();
2067 * const info = await db.createDatabase("mydb", [{ username: "root" }]);
2068 * // the database has been created
2069 * ```
2070 */
2071 createDatabase(databaseName: string, users: CreateDatabaseUser[]): Promise<Database>;
2072 /**
2073 * Fetches all databases from the server and returns an array of their names.
2074 *
2075 * See also {@link Database#databases} and
2076 * {@link Database#listUserDatabases}.
2077 *
2078 * @example
2079 * ```js
2080 * const db = new Database();
2081 * const names = await db.listDatabases();
2082 * // databases is an array of database names
2083 * ```
2084 */
2085 listDatabases(): Promise<string[]>;
2086 /**
2087 * Fetches all databases accessible to the active user from the server and
2088 * returns an array of their names.
2089 *
2090 * See also {@link Database#userDatabases} and
2091 * {@link Database#listDatabases}.
2092 *
2093 * @example
2094 * ```js
2095 * const db = new Database();
2096 * const names = await db.listUserDatabases();
2097 * // databases is an array of database names
2098 * ```
2099 */
2100 listUserDatabases(): Promise<string[]>;
2101 /**
2102 * Fetches all databases from the server and returns an array of `Database`
2103 * instances for those databases.
2104 *
2105 * See also {@link Database#listDatabases} and
2106 * {@link Database#userDatabases}.
2107 *
2108 * @example
2109 * ```js
2110 * const db = new Database();
2111 * const names = await db.databases();
2112 * // databases is an array of databases
2113 * ```
2114 */
2115 databases(): Promise<Database[]>;
2116 /**
2117 * Fetches all databases accessible to the active user from the server and
2118 * returns an array of `Database` instances for those databases.
2119 *
2120 * See also {@link Database#listUserDatabases} and
2121 * {@link Database#databases}.
2122 *
2123 * @example
2124 * ```js
2125 * const db = new Database();
2126 * const names = await db.userDatabases();
2127 * // databases is an array of databases
2128 * ```
2129 */
2130 userDatabases(): Promise<Database[]>;
2131 /**
2132 * Deletes the database with the given `databaseName` from the server.
2133 *
2134 * @param databaseName - Name of the database to delete.
2135 *
2136 * @example
2137 * ```js
2138 * const db = new Database();
2139 * await db.dropDatabase("mydb");
2140 * // database "mydb" no longer exists
2141 * ```
2142 */
2143 dropDatabase(databaseName: string): Promise<boolean>;
2144 /**
2145 * Returns a `Collection` instance for the given collection name.
2146 *
2147 * In TypeScript the collection implements both the
2148 * {@link collection.DocumentCollection} and {@link collection.EdgeCollection}
2149 * interfaces and can be cast to either type to enforce a stricter API.
2150 *
2151 * @param T - Type to use for document data. Defaults to `any`.
2152 * @param collectionName - Name of the edge collection.
2153 *
2154 * @example
2155 * ```js
2156 * const db = new Database();
2157 * const collection = db.collection("potatoes");
2158 * ```
2159 *
2160 * @example
2161 * ```ts
2162 * interface Person {
2163 * name: string;
2164 * }
2165 * const db = new Database();
2166 * const persons = db.collection<Person>("persons");
2167 * ```
2168 *
2169 * @example
2170 * ```ts
2171 * interface Person {
2172 * name: string;
2173 * }
2174 * interface Friend {
2175 * startDate: number;
2176 * endDate?: number;
2177 * }
2178 * const db = new Database();
2179 * const documents = db.collection("persons") as DocumentCollection<Person>;
2180 * const edges = db.collection("friends") as EdgeCollection<Friend>;
2181 * ```
2182 */
2183 collection<T extends Record<string, any> = any>(collectionName: string): DocumentCollection<T> & EdgeCollection<T>;
2184 /**
2185 * Creates a new collection with the given `collectionName` and `options`,
2186 * then returns a {@link collection.DocumentCollection} instance for the new collection.
2187 *
2188 * @param T - Type to use for document data. Defaults to `any`.
2189 * @param collectionName - Name of the new collection.
2190 * @param options - Options for creating the collection.
2191 *
2192 * @example
2193 * ```ts
2194 * const db = new Database();
2195 * const documents = db.createCollection("persons");
2196 * ```
2197 *
2198 * @example
2199 * ```ts
2200 * interface Person {
2201 * name: string;
2202 * }
2203 * const db = new Database();
2204 * const documents = db.createCollection<Person>("persons");
2205 * ```
2206 */
2207 createCollection<T extends Record<string, any> = any>(collectionName: string, options?: CreateCollectionOptions & {
2208 type?: CollectionType.DOCUMENT_COLLECTION;
2209 }): Promise<DocumentCollection<T>>;
2210 /**
2211 * Creates a new edge collection with the given `collectionName` and
2212 * `options`, then returns an {@link collection.EdgeCollection} instance for the new
2213 * edge collection.
2214 *
2215 * @param T - Type to use for edge document data. Defaults to `any`.
2216 * @param collectionName - Name of the new collection.
2217 * @param options - Options for creating the collection.
2218 *
2219 * @example
2220 * ```js
2221 * const db = new Database();
2222 * const edges = db.createCollection("friends", {
2223 * type: CollectionType.EDGE_COLLECTION
2224 * });
2225 * ```
2226 *
2227 * @example
2228 * ```ts
2229 * interface Friend {
2230 * startDate: number;
2231 * endDate?: number;
2232 * }
2233 * const db = new Database();
2234 * const edges = db.createCollection<Friend>("friends", {
2235 * type: CollectionType.EDGE_COLLECTION
2236 * });
2237 * ```
2238 */
2239 createCollection<T extends Record<string, any> = any>(collectionName: string, options: CreateCollectionOptions & {
2240 type: CollectionType.EDGE_COLLECTION;
2241 }): Promise<EdgeCollection<T>>;
2242 /**
2243 * Creates a new edge collection with the given `collectionName` and
2244 * `options`, then returns an {@link collection.EdgeCollection} instance for the new
2245 * edge collection.
2246 *
2247 * This is a convenience method for calling {@link Database#createCollection}
2248 * with `options.type` set to `EDGE_COLLECTION`.
2249 *
2250 * @param T - Type to use for edge document data. Defaults to `any`.
2251 * @param collectionName - Name of the new collection.
2252 * @param options - Options for creating the collection.
2253 *
2254 * @example
2255 * ```js
2256 * const db = new Database();
2257 * const edges = db.createEdgeCollection("friends");
2258 * ```
2259 *
2260 * @example
2261 * ```ts
2262 * interface Friend {
2263 * startDate: number;
2264 * endDate?: number;
2265 * }
2266 * const db = new Database();
2267 * const edges = db.createEdgeCollection<Friend>("friends");
2268 * ```
2269 */
2270 createEdgeCollection<T extends Record<string, any> = any>(collectionName: string, options?: CreateCollectionOptions): Promise<EdgeCollection<T>>;
2271 /**
2272 * Renames the collection `collectionName` to `newName`.
2273 *
2274 * Additionally removes any stored `Collection` instance for
2275 * `collectionName` from the `Database` instance's internal cache.
2276 *
2277 * **Note**: Renaming collections may not be supported when ArangoDB is
2278 * running in a cluster configuration.
2279 *
2280 * @param collectionName - Current name of the collection.
2281 * @param newName - The new name of the collection.
2282 */
2283 renameCollection(collectionName: string, newName: string): Promise<ArangoApiResponse<CollectionMetadata>>;
2284 /**
2285 * Fetches all collections from the database and returns an array of
2286 * collection descriptions.
2287 *
2288 * See also {@link Database#collections}.
2289 *
2290 * @param excludeSystem - Whether system collections should be excluded.
2291 *
2292 * @example
2293 * ```js
2294 * const db = new Database();
2295 * const collections = await db.listCollections();
2296 * // collections is an array of collection descriptions
2297 * // not including system collections
2298 * ```
2299 *
2300 * @example
2301 * ```js
2302 * const db = new Database();
2303 * const collections = await db.listCollections(false);
2304 * // collections is an array of collection descriptions
2305 * // including system collections
2306 * ```
2307 */
2308 listCollections(excludeSystem?: boolean): Promise<CollectionMetadata[]>;
2309 /**
2310 * Fetches all collections from the database and returns an array of
2311 * `Collection` instances.
2312 *
2313 * In TypeScript these instances implement both the
2314 * {@link collection.DocumentCollection} and {@link collection.EdgeCollection}
2315 * interfaces and can be cast to either type to enforce a stricter API.
2316 *
2317 * See also {@link Database#listCollections}.
2318 *
2319 * @param excludeSystem - Whether system collections should be excluded.
2320 *
2321 * @example
2322 * ```js
2323 * const db = new Database();
2324 * const collections = await db.collections();
2325 * // collections is an array of DocumentCollection and EdgeCollection
2326 * // instances not including system collections
2327 * ```
2328 *
2329 * @example
2330 * ```js
2331 * const db = new Database();
2332 * const collections = await db.collections(false);
2333 * // collections is an array of DocumentCollection and EdgeCollection
2334 * // instances including system collections
2335 * ```
2336 */
2337 collections(excludeSystem?: boolean): Promise<Array<DocumentCollection & EdgeCollection>>;
2338 /**
2339 * Returns a {@link graph.Graph} instance representing the graph with the given
2340 * `graphName`.
2341 *
2342 * @param graphName - Name of the graph.
2343 *
2344 * @example
2345 * ```js
2346 * const db = new Database();
2347 * const graph = db.graph("some-graph");
2348 * ```
2349 */
2350 graph(graphName: string): Graph;
2351 /**
2352 * Creates a graph with the given `graphName` and `edgeDefinitions`, then
2353 * returns a {@link graph.Graph} instance for the new graph.
2354 *
2355 * @param graphName - Name of the graph to be created.
2356 * @param edgeDefinitions - An array of edge definitions.
2357 * @param options - An object defining the properties of the graph.
2358 */
2359 createGraph(graphName: string, edgeDefinitions: EdgeDefinitionOptions[], options?: CreateGraphOptions): Promise<Graph>;
2360 /**
2361 * Fetches all graphs from the database and returns an array of graph
2362 * descriptions.
2363 *
2364 * See also {@link Database#graphs}.
2365 *
2366 * @example
2367 * ```js
2368 * const db = new Database();
2369 * const graphs = await db.listGraphs();
2370 * // graphs is an array of graph descriptions
2371 * ```
2372 */
2373 listGraphs(): Promise<GraphInfo[]>;
2374 /**
2375 * Fetches all graphs from the database and returns an array of {@link graph.Graph}
2376 * instances for those graphs.
2377 *
2378 * See also {@link Database#listGraphs}.
2379 *
2380 * @example
2381 * ```js
2382 * const db = new Database();
2383 * const graphs = await db.graphs();
2384 * // graphs is an array of Graph instances
2385 * ```
2386 */
2387 graphs(): Promise<Graph[]>;
2388 /**
2389 * Returns a {@link view.View} instance for the given `viewName`.
2390 *
2391 * @param viewName - Name of the ArangoSearch or SearchAlias View.
2392 *
2393 * @example
2394 * ```js
2395 * const db = new Database();
2396 * const view = db.view("potatoes");
2397 * ```
2398 */
2399 view(viewName: string): View;
2400 /**
2401 * Creates a new View with the given `viewName` and `options`, then returns a
2402 * {@link view.View} instance for the new View.
2403 *
2404 * @param viewName - Name of the View.
2405 * @param options - An object defining the properties of the View.
2406 *
2407 * @example
2408 * ```js
2409 * const db = new Database();
2410 * const view = await db.createView("potatoes", { type: "arangosearch" });
2411 * // the ArangoSearch View "potatoes" now exists
2412 * ```
2413 */
2414 createView(viewName: string, options: CreateViewOptions): Promise<View>;
2415 /**
2416 * Renames the view `viewName` to `newName`.
2417 *
2418 * Additionally removes any stored {@link view.View} instance for `viewName` from
2419 * the `Database` instance's internal cache.
2420 *
2421 * **Note**: Renaming views may not be supported when ArangoDB is running in
2422 * a cluster configuration.
2423 *
2424 * @param viewName - Current name of the view.
2425 * @param newName - The new name of the view.
2426 */
2427 renameView(viewName: string, newName: string): Promise<ArangoApiResponse<ViewDescription>>;
2428 /**
2429 * Fetches all Views from the database and returns an array of View
2430 * descriptions.
2431 *
2432 * See also {@link Database#views}.
2433 *
2434 * @example
2435 * ```js
2436 * const db = new Database();
2437 *
2438 * const views = await db.listViews();
2439 * // views is an array of View descriptions
2440 * ```
2441 */
2442 listViews(): Promise<ViewDescription[]>;
2443 /**
2444 * Fetches all Views from the database and returns an array of
2445 * {@link view.View} instances
2446 * for the Views.
2447 *
2448 * See also {@link Database#listViews}.
2449 *
2450 * @example
2451 * ```js
2452 * const db = new Database();
2453 * const views = await db.views();
2454 * // views is an array of ArangoSearch View instances
2455 * ```
2456 */
2457 views(): Promise<View[]>;
2458 /**
2459 * Returns an {@link analyzer.Analyzer} instance representing the Analyzer with the
2460 * given `analyzerName`.
2461 *
2462 * @example
2463 * ```js
2464 * const db = new Database();
2465 * const analyzer = db.analyzer("some-analyzer");
2466 * const info = await analyzer.get();
2467 * ```
2468 */
2469 analyzer(analyzerName: string): Analyzer;
2470 /**
2471 * Creates a new Analyzer with the given `analyzerName` and `options`, then
2472 * returns an {@link analyzer.Analyzer} instance for the new Analyzer.
2473 *
2474 * @param analyzerName - Name of the Analyzer.
2475 * @param options - An object defining the properties of the Analyzer.
2476 *
2477 * @example
2478 * ```js
2479 * const db = new Database();
2480 * const analyzer = await db.createAnalyzer("potatoes", { type: "identity" });
2481 * // the identity Analyzer "potatoes" now exists
2482 * ```
2483 */
2484 createAnalyzer(analyzerName: string, options: CreateAnalyzerOptions): Promise<Analyzer>;
2485 /**
2486 * Fetches all Analyzers visible in the database and returns an array of
2487 * Analyzer descriptions.
2488 *
2489 * See also {@link Database#analyzers}.
2490 *
2491 * @example
2492 * ```js
2493 * const db = new Database();
2494 * const analyzers = await db.listAnalyzers();
2495 * // analyzers is an array of Analyzer descriptions
2496 * ```
2497 */
2498 listAnalyzers(): Promise<AnalyzerDescription[]>;
2499 /**
2500 * Fetches all Analyzers visible in the database and returns an array of
2501 * {@link analyzer.Analyzer} instances for those Analyzers.
2502 *
2503 * See also {@link Database#listAnalyzers}.
2504 *
2505 * @example
2506 * ```js
2507 * const db = new Database();
2508 * const analyzers = await db.analyzers();
2509 * // analyzers is an array of Analyzer instances
2510 * ```
2511 */
2512 analyzers(): Promise<Analyzer[]>;
2513 /**
2514 * Fetches all ArangoDB users visible to the authenticated user and returns
2515 * an array of user objects.
2516 *
2517 * @example
2518 * ```js
2519 * const db = new Database();
2520 * const users = await db.listUsers();
2521 * // users is an array of user objects
2522 * ```
2523 */
2524 listUsers(): Promise<ArangoUser[]>;
2525 /**
2526 * Fetches the user data of a single ArangoDB user.
2527 *
2528 * @param username - Name of the ArangoDB user to fetch.
2529 *
2530 * @example
2531 * ```js
2532 * const db = new Database();
2533 * const user = await db.getUser("steve");
2534 * // user is the user object for the user named "steve"
2535 * ```
2536 */
2537 getUser(username: string): Promise<ArangoApiResponse<ArangoUser>>;
2538 /**
2539 * Creates a new ArangoDB user with the given password.
2540 *
2541 * @param username - Name of the ArangoDB user to create.
2542 * @param passwd - Password of the new ArangoDB user.
2543 *
2544 * @example
2545 * ```js
2546 * const db = new Database();
2547 * const user = await db.createUser("steve", "hunter2");
2548 * // The user "steve" has been created
2549 * ```
2550 */
2551 createUser(username: string, passwd: string): Promise<ArangoApiResponse<ArangoUser>>;
2552 /**
2553 * Creates a new ArangoDB user with the given options.
2554 *
2555 * @param username - Name of the ArangoDB user to create.
2556 * @param options - Additional options for creating the ArangoDB user.
2557 *
2558 * @example
2559 * ```js
2560 * const db = new Database();
2561 * const user = await db.createUser("steve", { passwd: "hunter2" });
2562 * // The user "steve" has been created
2563 * ```
2564 */
2565 createUser(username: string, options: UserOptions): Promise<ArangoApiResponse<ArangoUser>>;
2566 /**
2567 * Sets the password of a given ArangoDB user to the new value.
2568 *
2569 * @param username - Name of the ArangoDB user to change the password for.
2570 * @param passwd - New password for the ArangoDB user.
2571 *
2572 * @example
2573 * ```js
2574 * const db = new Database();
2575 * const user = await db.updateUser("steve", "hunter2");
2576 * // The user "steve" has received a new password
2577 * ```
2578 */
2579 updateUser(username: string, passwd: string): Promise<ArangoApiResponse<ArangoUser>>;
2580 /**
2581 * Updates the ArangoDB user with the new options.
2582 *
2583 * @param username - Name of the ArangoDB user to modify.
2584 * @param options - Options of the ArangoDB user to modify.
2585 *
2586 * @example
2587 * ```js
2588 * const db = new Database();
2589 * const user = await db.updateUser("steve", { active: false });
2590 * // The user "steve" has been set to inactive
2591 * ```
2592 */
2593 updateUser(username: string, options: Partial<UserOptions>): Promise<ArangoApiResponse<ArangoUser>>;
2594 /**
2595 * Replaces the ArangoDB user's option with the new options.
2596 *
2597 * @param username - Name of the ArangoDB user to modify.
2598 * @param options - New options to replace the user's existing options.
2599 *
2600 * @example
2601 * ```js
2602 * const db = new Database();
2603 * const user = await db.replaceUser("steve", { passwd: "", active: false });
2604 * // The user "steve" has been set to inactive with an empty password
2605 * ```
2606 */
2607 replaceUser(username: string, options: UserOptions): Promise<ArangoApiResponse<ArangoUser>>;
2608 /**
2609 * Removes the ArangoDB user with the given username from the server.
2610 *
2611 * @param username - Name of the ArangoDB user to remove.
2612 *
2613 * @example
2614 * ```js
2615 * const db = new Database();
2616 * await db.removeUser("steve");
2617 * // The user "steve" has been removed
2618 * ```
2619 */
2620 removeUser(username: string): Promise<ArangoApiResponse<Record<string, never>>>;
2621 /**
2622 * Fetches the given ArangoDB user's access level for the database, or the
2623 * given collection in the given database.
2624 *
2625 * @param username - Name of the ArangoDB user to fetch the access level for.
2626 * @param database - Database to fetch the access level for.
2627 * @param collection - Collection to fetch the access level for.
2628 *
2629 * @example
2630 * ```js
2631 * const db = new Database();
2632 * const accessLevel = await db.getUserAccessLevel("steve");
2633 * // The access level of the user "steve" has been fetched for the current
2634 * // database.
2635 * ```
2636 *
2637 * @example
2638 * ```js
2639 * const db = new Database();
2640 * const accessLevel = await db.getUserAccessLevel("steve", {
2641 * database: "staging"
2642 * });
2643 * // The access level of the user "steve" has been fetched for the "staging"
2644 * // database.
2645 * ```
2646 *
2647 * @example
2648 * ```js
2649 * const db = new Database();
2650 * const accessLevel = await db.getUserAccessLevel("steve", {
2651 * collection: "pokemons"
2652 * });
2653 * // The access level of the user "steve" has been fetched for the
2654 * // "pokemons" collection in the current database.
2655 * ```
2656 *
2657 * @example
2658 * ```js
2659 * const db = new Database();
2660 * const accessLevel = await db.getUserAccessLevel("steve", {
2661 * database: "staging",
2662 * collection: "pokemons"
2663 * });
2664 * // The access level of the user "steve" has been fetched for the
2665 * // "pokemons" collection in the "staging" database.
2666 * ```
2667 *
2668 * @example
2669 * ```js
2670 * const db = new Database();
2671 * const staging = db.database("staging");
2672 * const accessLevel = await db.getUserAccessLevel("steve", {
2673 * database: staging
2674 * });
2675 * // The access level of the user "steve" has been fetched for the "staging"
2676 * // database.
2677 * ```
2678 *
2679 * @example
2680 * ```js
2681 * const db = new Database();
2682 * const staging = db.database("staging");
2683 * const accessLevel = await db.getUserAccessLevel("steve", {
2684 * collection: staging.collection("pokemons")
2685 * });
2686 * // The access level of the user "steve" has been fetched for the
2687 * // "pokemons" collection in database "staging".
2688 * ```
2689 */
2690 getUserAccessLevel(username: string, { database, collection }: UserAccessLevelOptions): Promise<AccessLevel>;
2691 /**
2692 * Sets the given ArangoDB user's access level for the database, or the
2693 * given collection in the given database.
2694 *
2695 * @param username - Name of the ArangoDB user to set the access level for.
2696 * @param database - Database to set the access level for.
2697 * @param collection - Collection to set the access level for.
2698 * @param grant - Access level to set for the given user.
2699 *
2700 * @example
2701 * ```js
2702 * const db = new Database();
2703 * await db.setUserAccessLevel("steve", { grant: "rw" });
2704 * // The user "steve" now has read-write access to the current database.
2705 * ```
2706 *
2707 * @example
2708 * ```js
2709 * const db = new Database();
2710 * await db.setUserAccessLevel("steve", {
2711 * database: "staging",
2712 * grant: "rw"
2713 * });
2714 * // The user "steve" now has read-write access to the "staging" database.
2715 * ```
2716 *
2717 * @example
2718 * ```js
2719 * const db = new Database();
2720 * await db.setUserAccessLevel("steve", {
2721 * collection: "pokemons",
2722 * grant: "rw"
2723 * });
2724 * // The user "steve" now has read-write access to the "pokemons" collection
2725 * // in the current database.
2726 * ```
2727 *
2728 * @example
2729 * ```js
2730 * const db = new Database();
2731 * await db.setUserAccessLevel("steve", {
2732 * database: "staging",
2733 * collection: "pokemons",
2734 * grant: "rw"
2735 * });
2736 * // The user "steve" now has read-write access to the "pokemons" collection
2737 * // in the "staging" database.
2738 * ```
2739 *
2740 * @example
2741 * ```js
2742 * const db = new Database();
2743 * const staging = db.database("staging");
2744 * await db.setUserAccessLevel("steve", {
2745 * database: staging,
2746 * grant: "rw"
2747 * });
2748 * // The user "steve" now has read-write access to the "staging" database.
2749 * ```
2750 *
2751 * @example
2752 * ```js
2753 * const db = new Database();
2754 * const staging = db.database("staging");
2755 * await db.setUserAccessLevel("steve", {
2756 * collection: staging.collection("pokemons"),
2757 * grant: "rw"
2758 * });
2759 * // The user "steve" now has read-write access to the "pokemons" collection
2760 * // in database "staging".
2761 * ```
2762 */
2763 setUserAccessLevel(username: string, { database, collection, grant, }: UserAccessLevelOptions & {
2764 grant: AccessLevel;
2765 }): Promise<ArangoApiResponse<Record<string, AccessLevel>>>;
2766 /**
2767 * Clears the given ArangoDB user's access level for the database, or the
2768 * given collection in the given database.
2769 *
2770 * @param username - Name of the ArangoDB user to clear the access level for.
2771 * @param database - Database to clear the access level for.
2772 * @param collection - Collection to clear the access level for.
2773 *
2774 * @example
2775 * ```js
2776 * const db = new Database();
2777 * await db.clearUserAccessLevel("steve");
2778 * // The access level of the user "steve" has been cleared for the current
2779 * // database.
2780 * ```
2781 *
2782 * @example
2783 * ```js
2784 * const db = new Database();
2785 * await db.clearUserAccessLevel("steve", { database: "staging" });
2786 * // The access level of the user "steve" has been cleared for the "staging"
2787 * // database.
2788 * ```
2789 *
2790 * @example
2791 * ```js
2792 * const db = new Database();
2793 * await db.clearUserAccessLevel("steve", { collection: "pokemons" });
2794 * // The access level of the user "steve" has been cleared for the
2795 * // "pokemons" collection in the current database.
2796 * ```
2797 *
2798 * @example
2799 * ```js
2800 * const db = new Database();
2801 * await db.clearUserAccessLevel("steve", {
2802 * database: "staging",
2803 * collection: "pokemons"
2804 * });
2805 * // The access level of the user "steve" has been cleared for the
2806 * // "pokemons" collection in the "staging" database.
2807 * ```
2808 *
2809 * @example
2810 * ```js
2811 * const db = new Database();
2812 * const staging = db.database("staging");
2813 * await db.clearUserAccessLevel("steve", { database: staging });
2814 * // The access level of the user "steve" has been cleared for the "staging"
2815 * // database.
2816 * ```
2817 *
2818 * @example
2819 * ```js
2820 * const db = new Database();
2821 * const staging = db.database("staging");
2822 * await db.clearUserAccessLevel("steve", {
2823 * collection: staging.collection("pokemons")
2824 * });
2825 * // The access level of the user "steve" has been cleared for the
2826 * // "pokemons" collection in database "staging".
2827 * ```
2828 */
2829 clearUserAccessLevel(username: string, { database, collection }: UserAccessLevelOptions): Promise<ArangoApiResponse<Record<string, AccessLevel>>>;
2830 /**
2831 * Fetches an object mapping names of databases to the access level of the
2832 * given ArangoDB user for those databases.
2833 *
2834 * @param username - Name of the ArangoDB user to fetch the access levels for.
2835 * @param full - Whether access levels for collections should be included.
2836 *
2837 * @example
2838 * ```js
2839 * const db = new Database();
2840 * const accessLevels = await db.getUserDatabases("steve");
2841 * for (const [databaseName, accessLevel] of Object.entries(accessLevels)) {
2842 * console.log(`${databaseName}: ${accessLevel}`);
2843 * }
2844 * ```
2845 */
2846 getUserDatabases(username: string, full?: false): Promise<Record<string, AccessLevel>>;
2847 /**
2848 * Fetches an object mapping names of databases to the access level of the
2849 * given ArangoDB user for those databases and the collections within each
2850 * database.
2851 *
2852 * @param username - Name of the ArangoDB user to fetch the access levels for.
2853 * @param full - Whether access levels for collections should be included.
2854 *
2855 * @example
2856 * ```js
2857 * const db = new Database();
2858 * const accessLevels = await db.getUserDatabases("steve", true);
2859 * for (const [databaseName, obj] of Object.entries(accessLevels)) {
2860 * console.log(`${databaseName}: ${obj.permission}`);
2861 * for (const [collectionName, accessLevel] of Object.entries(obj.collections)) {
2862 * console.log(`${databaseName}/${collectionName}: ${accessLevel}`);
2863 * }
2864 * }
2865 * ```
2866 */
2867 getUserDatabases(username: string, full: true): Promise<Record<string, {
2868 permission: AccessLevel;
2869 collections: Record<string, AccessLevel | "undefined">;
2870 }>>;
2871 /**
2872 * Performs a server-side JavaScript transaction and returns its return
2873 * value.
2874 *
2875 * Collections can be specified as collection names (strings) or objects
2876 * implementing the {@link collection.ArangoCollection} interface: `Collection`,
2877 * {@link graph.GraphVertexCollection}, {@link graph.GraphEdgeCollection} as well as
2878 * (in TypeScript) {@link collection.DocumentCollection} and {@link collection.EdgeCollection}.
2879 *
2880 * **Note**: The `action` function will be evaluated and executed on the
2881 * server inside ArangoDB's embedded JavaScript environment and can not
2882 * access any values other than those passed via the `params` option.
2883 *
2884 * See the official ArangoDB documentation for
2885 * [the JavaScript `@arangodb` module](https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html)
2886 * for information about accessing the database from within ArangoDB's
2887 * server-side JavaScript environment.
2888 *
2889 * @param collections - Collections involved in the transaction.
2890 * @param action - A string evaluating to a JavaScript function to be
2891 * executed on the server.
2892 * @param options - Options for the transaction. If `options.allowImplicit`
2893 * is specified, it will be used if `collections.allowImplicit` was not
2894 * specified.
2895 *
2896 * @example
2897 * ```js
2898 * const db = new Database();
2899 *
2900 * const action = `
2901 * function(params) {
2902 * // This code will be executed inside ArangoDB!
2903 * const { query } = require("@arangodb");
2904 * return query\`
2905 * FOR user IN _users
2906 * FILTER user.age > ${params.age}
2907 * RETURN u.user
2908 * \`.toArray();
2909 * }
2910 * `);
2911 *
2912 * const result = await db.executeTransaction({
2913 * read: ["_users"]
2914 * }, action, {
2915 * params: { age: 12 }
2916 * });
2917 * // result contains the return value of the action
2918 * ```
2919 */
2920 executeTransaction(collections: TransactionCollections & {
2921 allowImplicit?: boolean;
2922 }, action: string, options?: TransactionOptions & {
2923 params?: any;
2924 }): Promise<any>;
2925 /**
2926 * Performs a server-side transaction and returns its return value.
2927 *
2928 * Collections can be specified as collection names (strings) or objects
2929 * implementing the {@link collection.ArangoCollection} interface: `Collection`,
2930 * {@link graph.GraphVertexCollection}, {@link graph.GraphEdgeCollection} as well as
2931 * (in TypeScript) {@link collection.DocumentCollection} and {@link collection.EdgeCollection}.
2932 *
2933 * **Note**: The `action` function will be evaluated and executed on the
2934 * server inside ArangoDB's embedded JavaScript environment and can not
2935 * access any values other than those passed via the `params` option.
2936 * See the official ArangoDB documentation for
2937 * [the JavaScript `@arangodb` module](https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html)
2938 * for information about accessing the database from within ArangoDB's
2939 * server-side JavaScript environment.
2940 *
2941 * @param collections - Collections that can be read from and written to
2942 * during the transaction.
2943 * @param action - A string evaluating to a JavaScript function to be
2944 * executed on the server.
2945 * @param options - Options for the transaction.
2946 *
2947 * @example
2948 * ```js
2949 * const db = new Database();
2950 *
2951 * const action = `
2952 * function(params) {
2953 * // This code will be executed inside ArangoDB!
2954 * const { query } = require("@arangodb");
2955 * return query\`
2956 * FOR user IN _users
2957 * FILTER user.age > ${params.age}
2958 * RETURN u.user
2959 * \`.toArray();
2960 * }
2961 * `);
2962 *
2963 * const result = await db.executeTransaction(["_users"], action, {
2964 * params: { age: 12 }
2965 * });
2966 * // result contains the return value of the action
2967 * ```
2968 */
2969 executeTransaction(collections: (string | ArangoCollection)[], action: string, options?: TransactionOptions & {
2970 params?: any;
2971 }): Promise<any>;
2972 /**
2973 * Performs a server-side transaction and returns its return value.
2974 *
2975 * The Collection can be specified as a collection name (string) or an object
2976 * implementing the {@link collection.ArangoCollection} interface: `Collection`,
2977 * {@link graph.GraphVertexCollection}, {@link graph.GraphEdgeCollection} as well as
2978 * (in TypeScript) {@link collection.DocumentCollection} and {@link collection.EdgeCollection}.
2979 *
2980 * **Note**: The `action` function will be evaluated and executed on the
2981 * server inside ArangoDB's embedded JavaScript environment and can not
2982 * access any values other than those passed via the `params` option.
2983 * See the official ArangoDB documentation for
2984 * [the JavaScript `@arangodb` module](https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html)
2985 * for information about accessing the database from within ArangoDB's
2986 * server-side JavaScript environment.
2987 *
2988 * @param collection - A collection that can be read from and written to
2989 * during the transaction.
2990 * @param action - A string evaluating to a JavaScript function to be
2991 * executed on the server.
2992 * @param options - Options for the transaction.
2993 *
2994 * @example
2995 * ```js
2996 * const db = new Database();
2997 *
2998 * const action = `
2999 * function(params) {
3000 * // This code will be executed inside ArangoDB!
3001 * const { query } = require("@arangodb");
3002 * return query\`
3003 * FOR user IN _users
3004 * FILTER user.age > ${params.age}
3005 * RETURN u.user
3006 * \`.toArray();
3007 * }
3008 * `);
3009 *
3010 * const result = await db.executeTransaction("_users", action, {
3011 * params: { age: 12 }
3012 * });
3013 * // result contains the return value of the action
3014 * ```
3015 */
3016 executeTransaction(collection: string | ArangoCollection, action: string, options?: TransactionOptions & {
3017 params?: any;
3018 }): Promise<any>;
3019 /**
3020 * Returns a {@link transaction.Transaction} instance for an existing streaming
3021 * transaction with the given `id`.
3022 *
3023 * See also {@link Database#beginTransaction}.
3024 *
3025 * @param id - The `id` of an existing stream transaction.
3026 *
3027 * @example
3028 * ```js
3029 * const trx1 = await db.beginTransaction(collections);
3030 * const id = trx1.id;
3031 * // later
3032 * const trx2 = db.transaction(id);
3033 * await trx2.commit();
3034 * ```
3035 */
3036 transaction(transactionId: string): Transaction;
3037 /**
3038 * Begins a new streaming transaction for the given collections, then returns
3039 * a {@link transaction.Transaction} instance for the transaction.
3040 *
3041 * Collections can be specified as collection names (strings) or objects
3042 * implementing the {@link collection.ArangoCollection} interface: `Collection`,
3043 * {@link graph.GraphVertexCollection}, {@link graph.GraphEdgeCollection} as
3044 * well as (in TypeScript) {@link collection.DocumentCollection} and
3045 * {@link collection.EdgeCollection}.
3046 *
3047 * @param collections - Collections involved in the transaction.
3048 * @param options - Options for the transaction.
3049 *
3050 * @example
3051 * ```js
3052 * const vertices = db.collection("vertices");
3053 * const edges = db.collection("edges");
3054 * const trx = await db.beginTransaction({
3055 * read: ["vertices"],
3056 * write: [edges] // collection instances can be passed directly
3057 * });
3058 * const start = await trx.step(() => vertices.document("a"));
3059 * const end = await trx.step(() => vertices.document("b"));
3060 * await trx.step(() => edges.save({ _from: start._id, _to: end._id }));
3061 * await trx.commit();
3062 * ```
3063 */
3064 beginTransaction(collections: TransactionCollections, options?: TransactionOptions): Promise<Transaction>;
3065 /**
3066 * Begins a new streaming transaction for the given collections, then returns
3067 * a {@link transaction.Transaction} instance for the transaction.
3068 *
3069 * Collections can be specified as collection names (strings) or objects
3070 * implementing the {@link collection.ArangoCollection} interface: `Collection`,
3071 * {@link graph.GraphVertexCollection}, {@link graph.GraphEdgeCollection} as well as
3072 * (in TypeScript) {@link collection.DocumentCollection} and {@link collection.EdgeCollection}.
3073 *
3074 * @param collections - Collections that can be read from and written to
3075 * during the transaction.
3076 * @param options - Options for the transaction.
3077 *
3078 * @example
3079 * ```js
3080 * const vertices = db.collection("vertices");
3081 * const edges = db.collection("edges");
3082 * const trx = await db.beginTransaction([
3083 * "vertices",
3084 * edges // collection instances can be passed directly
3085 * ]);
3086 * const start = await trx.step(() => vertices.document("a"));
3087 * const end = await trx.step(() => vertices.document("b"));
3088 * await trx.step(() => edges.save({ _from: start._id, _to: end._id }));
3089 * await trx.commit();
3090 * ```
3091 */
3092 beginTransaction(collections: (string | ArangoCollection)[], options?: TransactionOptions): Promise<Transaction>;
3093 /**
3094 * Begins a new streaming transaction for the given collections, then returns
3095 * a {@link transaction.Transaction} instance for the transaction.
3096 *
3097 * The Collection can be specified as a collection name (string) or an object
3098 * implementing the {@link collection.ArangoCollection} interface: `Collection`,
3099 * {@link graph.GraphVertexCollection}, {@link graph.GraphEdgeCollection} as well as
3100 * (in TypeScript) {@link collection.DocumentCollection} and {@link collection.EdgeCollection}.
3101 *
3102 * @param collection - A collection that can be read from and written to
3103 * during the transaction.
3104 * @param options - Options for the transaction.
3105 *
3106 * @example
3107 * ```js
3108 * const vertices = db.collection("vertices");
3109 * const start = vertices.document("a");
3110 * const end = vertices.document("b");
3111 * const edges = db.collection("edges");
3112 * const trx = await db.beginTransaction(
3113 * edges // collection instances can be passed directly
3114 * );
3115 * await trx.step(() => edges.save({ _from: start._id, _to: end._id }));
3116 * await trx.commit();
3117 * ```
3118 */
3119 beginTransaction(collection: string | ArangoCollection, options?: TransactionOptions): Promise<Transaction>;
3120 /**
3121 * Begins and commits a transaction using the given callback. Individual
3122 * requests that are part of the transaction need to be wrapped in the step
3123 * function passed into the callback. If the promise returned by the callback
3124 * is rejected, the transaction will be aborted.
3125 *
3126 * Collections can be specified as collection names (strings) or objects
3127 * implementing the {@link collection.ArangoCollection} interface: `Collection`,
3128 * {@link graph.GraphVertexCollection}, {@link graph.GraphEdgeCollection} as
3129 * well as (in TypeScript) {@link collection.DocumentCollection} and
3130 * {@link collection.EdgeCollection}.
3131 *
3132 * @param collections - Collections involved in the transaction.
3133 * @param callback - Callback function executing the transaction steps.
3134 * @param options - Options for the transaction.
3135 *
3136 * @example
3137 * ```js
3138 * const vertices = db.collection("vertices");
3139 * const edges = db.collection("edges");
3140 * await db.withTransaction(
3141 * {
3142 * read: ["vertices"],
3143 * write: [edges] // collection instances can be passed directly
3144 * },
3145 * async (step) => {
3146 * const start = await step(() => vertices.document("a"));
3147 * const end = await step(() => vertices.document("b"));
3148 * await step(() => edges.save({ _from: start._id, _to: end._id }));
3149 * }
3150 * );
3151 * ```
3152 */
3153 withTransaction<T>(collections: TransactionCollections, callback: (step: Transaction["step"]) => Promise<T>, options?: TransactionOptions): Promise<T>;
3154 /**
3155 * Begins and commits a transaction using the given callback. Individual
3156 * requests that are part of the transaction need to be wrapped in the step
3157 * function passed into the callback. If the promise returned by the callback
3158 * is rejected, the transaction will be aborted.
3159 *
3160 * Collections can be specified as collection names (strings) or objects
3161 * implementing the {@link collection.ArangoCollection} interface: `Collection`,
3162 * {@link graph.GraphVertexCollection}, {@link graph.GraphEdgeCollection} as well as
3163 * (in TypeScript) {@link collection.DocumentCollection} and {@link collection.EdgeCollection}.
3164 *
3165 * @param collections - Collections that can be read from and written to
3166 * during the transaction.
3167 * @param callback - Callback function executing the transaction steps.
3168 * @param options - Options for the transaction.
3169 *
3170 * @example
3171 * ```js
3172 * const vertices = db.collection("vertices");
3173 * const edges = db.collection("edges");
3174 * await db.withTransaction(
3175 * [
3176 * "vertices",
3177 * edges, // collection instances can be passed directly
3178 * ],
3179 * async (step) => {
3180 * const start = await step(() => vertices.document("a"));
3181 * const end = await step(() => vertices.document("b"));
3182 * await step(() => edges.save({ _from: start._id, _to: end._id }));
3183 * }
3184 * );
3185 * ```
3186 */
3187 withTransaction<T>(collections: (string | ArangoCollection)[], callback: (step: Transaction["step"]) => Promise<T>, options?: TransactionOptions): Promise<T>;
3188 /**
3189 * Begins and commits a transaction using the given callback. Individual
3190 * requests that are part of the transaction need to be wrapped in the step
3191 * function passed into the callback. If the promise returned by the callback
3192 * is rejected, the transaction will be aborted.
3193 *
3194 * The Collection can be specified as a collection name (string) or an object
3195 * implementing the {@link collection.ArangoCollection} interface: `Collection`,
3196 * {@link graph.GraphVertexCollection}, {@link graph.GraphEdgeCollection} as well as
3197 * (in TypeScript) {@link collection.DocumentCollection} and {@link collection.EdgeCollection}.
3198 *
3199 * @param collection - A collection that can be read from and written to
3200 * during the transaction.
3201 * @param callback - Callback function executing the transaction steps.
3202 * @param options - Options for the transaction.
3203 *
3204 * @example
3205 * ```js
3206 * const vertices = db.collection("vertices");
3207 * const start = vertices.document("a");
3208 * const end = vertices.document("b");
3209 * const edges = db.collection("edges");
3210 * await db.withTransaction(
3211 * edges, // collection instances can be passed directly
3212 * async (step) => {
3213 * await step(() => edges.save({ _from: start._id, _to: end._id }));
3214 * }
3215 * );
3216 * ```
3217 */
3218 withTransaction<T>(collection: string | ArangoCollection, callback: (step: Transaction["step"]) => Promise<T>, options?: TransactionOptions): Promise<T>;
3219 /**
3220 * Fetches all active transactions from the database and returns an array of
3221 * transaction descriptions.
3222 *
3223 * See also {@link Database#transactions}.
3224 *
3225 * @example
3226 * ```js
3227 * const db = new Database();
3228 * const transactions = await db.listTransactions();
3229 * // transactions is an array of transaction descriptions
3230 * ```
3231 */
3232 listTransactions(): Promise<TransactionDetails[]>;
3233 /**
3234 * Fetches all active transactions from the database and returns an array of
3235 * {@link transaction.Transaction} instances for those transactions.
3236 *
3237 * See also {@link Database#listTransactions}.
3238 *
3239 * @example
3240 * ```js
3241 * const db = new Database();
3242 * const transactions = await db.transactions();
3243 * // transactions is an array of transactions
3244 * ```
3245 */
3246 transactions(): Promise<Transaction[]>;
3247 /**
3248 * Performs a database query using the given `query`, then returns a new
3249 * {@link cursor.ArrayCursor} instance for the result set.
3250 *
3251 * See the {@link aql!aql} template string handler for information about how
3252 * to create a query string without manually defining bind parameters nor
3253 * having to worry about escaping variables.
3254 *
3255 * **Note**: When executing a query in a streaming transaction using the
3256 * `step` method, the resulting cursor will be bound to that transaction and
3257 * you do not need to use the `step` method to consume it.
3258 *
3259 * @param query - An object containing an AQL query string and bind
3260 * parameters, e.g. the object returned from an {@link aql!aql} template string.
3261 * @param options - Options for the query execution.
3262 *
3263 * @example
3264 * ```js
3265 * const db = new Database();
3266 * const active = true;
3267 * const Users = db.collection("_users");
3268 *
3269 * // Using an aql template string:
3270 * // Bind parameters are automatically extracted and arangojs collections
3271 * // are automatically passed as collection bind parameters.
3272 * const cursor = await db.query(aql`
3273 * FOR u IN ${Users}
3274 * FILTER u.authData.active == ${active}
3275 * RETURN u.user
3276 * `);
3277 * // cursor is a cursor for the query result
3278 * ```
3279 *
3280 * @example
3281 * ```js
3282 * const db = new Database();
3283 * const active = true;
3284 * const Users = db.collection("_users");
3285 *
3286 * // Using an object with a regular multi-line string
3287 * const cursor = await db.query({
3288 * query: `
3289 * FOR u IN @@users
3290 * FILTER u.authData.active == @active
3291 * RETURN u.user
3292 * `,
3293 * bindVars: { active: active, "@users": Users.name }
3294 * });
3295 * ```
3296 */
3297 query<T = any>(query: AqlQuery<T>, options?: QueryOptions): Promise<ArrayCursor<T>>;
3298 /**
3299 * Performs a database query using the given `query` and `bindVars`, then
3300 * returns a new {@link cursor.ArrayCursor} instance for the result set.
3301 *
3302 * See the {@link aql!aql} template string handler for a safer and easier
3303 * alternative to passing strings directly.
3304 *
3305 * **Note**: When executing a query in a streaming transaction using the
3306 * `step` method, the resulting cursor will be bound to that transaction and
3307 * you do not need to use the `step` method to consume it.
3308 *
3309 * @param query - An AQL query string.
3310 * @param bindVars - An object defining bind parameters for the query.
3311 * @param options - Options for the query execution.
3312 *
3313 * @example
3314 * ```js
3315 * const db = new Database();
3316 * const active = true;
3317 * const Users = db.collection("_users");
3318 *
3319 * const cursor = await db.query(
3320 * // A normal multi-line string
3321 * `
3322 * FOR u IN @@users
3323 * FILTER u.authData.active == @active
3324 * RETURN u.user
3325 * `,
3326 * { active: active, "@users": Users.name }
3327 * );
3328 * ```
3329 *
3330 * @example
3331 * ```js
3332 * const db = new Database();
3333 * const active = true;
3334 * const Users = db.collection("_users");
3335 *
3336 * const cursor = await db.query(
3337 * // An AQL literal created from a normal multi-line string
3338 * aql.literal(`
3339 * FOR u IN @@users
3340 * FILTER u.authData.active == @active
3341 * RETURN u.user
3342 * `),
3343 * { active: active, "@users": Users.name }
3344 * );
3345 * ```
3346 */
3347 query<T = any>(query: string | AqlLiteral, bindVars?: Record<string, any>, options?: QueryOptions): Promise<ArrayCursor<T>>;
3348 /**
3349 * Explains a database query using the given `query`.
3350 *
3351 * See the {@link aql!aql} template string handler for information about how
3352 * to create a query string without manually defining bind parameters nor
3353 * having to worry about escaping variables.
3354 *
3355 * @param query - An object containing an AQL query string and bind
3356 * parameters, e.g. the object returned from an {@link aql!aql} template string.
3357 * @param options - Options for explaining the query.
3358 *
3359 * @example
3360 * ```js
3361 * const db = new Database();
3362 * const collection = db.collection("some-collection");
3363 * const explanation = await db.explain(aql`
3364 * FOR doc IN ${collection}
3365 * FILTER doc.flavor == "strawberry"
3366 * RETURN doc._key
3367 * `);
3368 * ```
3369 */
3370 explain(query: AqlQuery, options?: ExplainOptions & {
3371 allPlans?: false;
3372 }): Promise<ArangoApiResponse<SingleExplainResult>>;
3373 /**
3374 * Explains a database query using the given `query`.
3375 *
3376 * See the {@link aql!aql} template string handler for information about how
3377 * to create a query string without manually defining bind parameters nor
3378 * having to worry about escaping variables.
3379 *
3380 * @param query - An object containing an AQL query string and bind
3381 * parameters, e.g. the object returned from an {@link aql!aql} template string.
3382 * @param options - Options for explaining the query.
3383 *
3384 * @example
3385 * ```js
3386 * const db = new Database();
3387 * const collection = db.collection("some-collection");
3388 * const explanation = await db.explain(
3389 * aql`
3390 * FOR doc IN ${collection}
3391 * FILTER doc.flavor == "strawberry"
3392 * RETURN doc._key
3393 * `,
3394 * { allPlans: true }
3395 * );
3396 * ```
3397 */
3398 explain(query: AqlQuery, options?: ExplainOptions & {
3399 allPlans: true;
3400 }): Promise<ArangoApiResponse<MultiExplainResult>>;
3401 /**
3402 * Explains a database query using the given `query` and `bindVars`.
3403 *
3404 * See the {@link aql!aql} template string handler for a safer and easier
3405 * alternative to passing strings directly.
3406 *
3407 * @param query - An AQL query string.
3408 * @param bindVars - An object defining bind parameters for the query.
3409 * @param options - Options for explaining the query.
3410 *
3411 * @example
3412 * ```js
3413 * const db = new Database();
3414 * const collection = db.collection("some-collection");
3415 * const explanation = await db.explain(
3416 * `
3417 * FOR doc IN @@collection
3418 * FILTER doc.flavor == "strawberry"
3419 * RETURN doc._key
3420 * `,
3421 * { "@collection": collection.name }
3422 * );
3423 * ```
3424 */
3425 explain(query: string | AqlLiteral, bindVars?: Record<string, any>, options?: ExplainOptions & {
3426 allPlans?: false;
3427 }): Promise<ArangoApiResponse<SingleExplainResult>>;
3428 /**
3429 * Explains a database query using the given `query` and `bindVars`.
3430 *
3431 * See the {@link aql!aql} template string handler for a safer and easier
3432 * alternative to passing strings directly.
3433 *
3434 * @param query - An AQL query string.
3435 * @param bindVars - An object defining bind parameters for the query.
3436 * @param options - Options for explaining the query.
3437 *
3438 * @example
3439 * ```js
3440 * const db = new Database();
3441 * const collection = db.collection("some-collection");
3442 * const explanation = await db.explain(
3443 * `
3444 * FOR doc IN @@collection
3445 * FILTER doc.flavor == "strawberry"
3446 * RETURN doc._key
3447 * `,
3448 * { "@collection": collection.name },
3449 * { allPlans: true }
3450 * );
3451 * ```
3452 */
3453 explain(query: string | AqlLiteral, bindVars?: Record<string, any>, options?: ExplainOptions & {
3454 allPlans: true;
3455 }): Promise<ArangoApiResponse<MultiExplainResult>>;
3456 /**
3457 * Parses the given query and returns the result.
3458 *
3459 * See the {@link aql!aql} template string handler for information about how
3460 * to create a query string without manually defining bind parameters nor
3461 * having to worry about escaping variables.
3462 *
3463 * @param query - An AQL query string or an object containing an AQL query
3464 * string and bind parameters, e.g. the object returned from an {@link aql!aql}
3465 * template string.
3466 *
3467 * @example
3468 * ```js
3469 * const db = new Database();
3470 * const collection = db.collection("some-collection");
3471 * const ast = await db.parse(aql`
3472 * FOR doc IN ${collection}
3473 * FILTER doc.flavor == "strawberry"
3474 * RETURN doc._key
3475 * `);
3476 * ```
3477 */
3478 parse(query: string | AqlQuery | AqlLiteral): Promise<ParseResult>;
3479 /**
3480 * Fetches the available optimizer rules.
3481 *
3482 * @example
3483 * ```js
3484 * const db = new Database();
3485 * const rules = await db.queryRules();
3486 * for (const rule of rules) {
3487 * console.log(rule.name);
3488 * }
3489 * ```
3490 */
3491 queryRules(): Promise<QueryOptimizerRule[]>;
3492 /**
3493 * Fetches the query tracking properties.
3494 *
3495 * @example
3496 * ```js
3497 * const db = new Database();
3498 * const tracking = await db.queryTracking();
3499 * console.log(tracking.enabled);
3500 * ```
3501 */
3502 queryTracking(): Promise<QueryTracking>;
3503 /**
3504 * Modifies the query tracking properties.
3505 *
3506 * @param options - Options for query tracking.
3507 *
3508 * @example
3509 * ```js
3510 * const db = new Database();
3511 * // track up to 5 slow queries exceeding 5 seconds execution time
3512 * await db.setQueryTracking({
3513 * enabled: true,
3514 * trackSlowQueries: true,
3515 * maxSlowQueries: 5,
3516 * slowQueryThreshold: 5
3517 * });
3518 * ```
3519 */
3520 queryTracking(options: QueryTrackingOptions): Promise<QueryTracking>;
3521 /**
3522 * Fetches a list of information for all currently running queries.
3523 *
3524 * See also {@link Database#listSlowQueries} and {@link Database#killQuery}.
3525 *
3526 * @example
3527 * ```js
3528 * const db = new Database();
3529 * const queries = await db.listRunningQueries();
3530 * ```
3531 */
3532 listRunningQueries(): Promise<QueryInfo[]>;
3533 /**
3534 * Fetches a list of information for all recent slow queries.
3535 *
3536 * See also {@link Database#listRunningQueries} and
3537 * {@link Database#clearSlowQueries}.
3538 *
3539 * @example
3540 * ```js
3541 * const db = new Database();
3542 * const queries = await db.listSlowQueries();
3543 * // Only works if slow query tracking is enabled
3544 * ```
3545 */
3546 listSlowQueries(): Promise<QueryInfo[]>;
3547 /**
3548 * Clears the list of recent slow queries.
3549 *
3550 * See also {@link Database#listSlowQueries}.
3551 *
3552 * @example
3553 * ```js
3554 * const db = new Database();
3555 * await db.clearSlowQueries();
3556 * // Slow query list is now cleared
3557 * ```
3558 */
3559 clearSlowQueries(): Promise<void>;
3560 /**
3561 * Kills a running query with the given `queryId`.
3562 *
3563 * See also {@link Database#listRunningQueries}.
3564 *
3565 * @param queryId - The ID of a currently running query.
3566 *
3567 * @example
3568 * ```js
3569 * const db = new Database();
3570 * const queries = await db.listRunningQueries();
3571 * await Promise.all(queries.map(
3572 * async (query) => {
3573 * if (query.state === "executing") {
3574 * await db.killQuery(query.id);
3575 * }
3576 * }
3577 * ));
3578 * ```
3579 */
3580 killQuery(queryId: string): Promise<void>;
3581 /**
3582 * Fetches a list of all AQL user functions registered with the database.
3583 *
3584 * @example
3585 * ```js
3586 * const db = new Database();
3587 * const functions = await db.listFunctions();
3588 * const names = functions.map(fn => fn.name);
3589 * ```
3590 */
3591 listFunctions(): Promise<AqlUserFunction[]>;
3592 /**
3593 * Creates an AQL user function with the given _name_ and _code_ if it does
3594 * not already exist or replaces it if a function with the same name already
3595 * existed.
3596 *
3597 * @param name - A valid AQL function name. The function name must consist
3598 * of at least two alphanumeric identifiers separated with double colons.
3599 * @param code - A string evaluating to a JavaScript function (not a
3600 * JavaScript function object).
3601 * @param isDeterministic - If set to `true`, the function is expected to
3602 * always return the same result for equivalent inputs. This option currently
3603 * has no effect but may allow for optimizations in the future.
3604 *
3605 * @example
3606 * ```js
3607 * const db = new Database();
3608 * await db.createFunction(
3609 * "ACME::ACCOUNTING::CALCULATE_VAT",
3610 * "(price) => price * 0.19"
3611 * );
3612 * // Use the new function in an AQL query with template handler:
3613 * const cursor = await db.query(aql`
3614 * FOR product IN products
3615 * RETURN MERGE(
3616 * { vat: ACME::ACCOUNTING::CALCULATE_VAT(product.price) },
3617 * product
3618 * )
3619 * `);
3620 * // cursor is a cursor for the query result
3621 * ```
3622 */
3623 createFunction(name: string, code: string, isDeterministic?: boolean): Promise<ArangoApiResponse<{
3624 isNewlyCreated: boolean;
3625 }>>;
3626 /**
3627 * Deletes the AQL user function with the given name from the database.
3628 *
3629 * @param name - The name of the user function to drop.
3630 * @param group - If set to `true`, all functions with a name starting with
3631 * `name` will be deleted, otherwise only the function with the exact name
3632 * will be deleted.
3633 *
3634 * @example
3635 * ```js
3636 * const db = new Database();
3637 * await db.dropFunction("ACME::ACCOUNTING::CALCULATE_VAT");
3638 * // the function no longer exists
3639 * ```
3640 */
3641 dropFunction(name: string, group?: boolean): Promise<ArangoApiResponse<{
3642 deletedCount: number;
3643 }>>;
3644 /**
3645 * Fetches a list of all installed service.
3646 *
3647 * @param excludeSystem - Whether system services should be excluded.
3648 *
3649 * @example
3650 * ```js
3651 * const db = new Database();
3652 * const services = await db.listServices();
3653 * ```
3654 *
3655 * @example
3656 * ```js
3657 * const db = new Database();
3658 * const services = await db.listServices(false); // all services
3659 * ```
3660 */
3661 listServices(excludeSystem?: boolean): Promise<ServiceSummary[]>;
3662 /**
3663 * Installs a new service.
3664 *
3665 * @param mount - The service's mount point, relative to the database.
3666 * @param source - The service bundle to install.
3667 * @param options - Options for installing the service.
3668 *
3669 * @example
3670 * ```js
3671 * const db = new Database();
3672 * // Using a node.js file stream as source
3673 * const source = fs.createReadStream("./my-foxx-service.zip");
3674 * const info = await db.installService("/hello", source);
3675 * ```
3676 *
3677 * @example
3678 * ```js
3679 * const db = new Database();
3680 * // Using a node.js Buffer as source
3681 * const source = fs.readFileSync("./my-foxx-service.zip");
3682 * const info = await db.installService("/hello", source);
3683 * ```
3684 *
3685 * @example
3686 * ```js
3687 * const db = new Database();
3688 * // Using a File (Blob) from a browser file input
3689 * const element = document.getElementById("my-file-input");
3690 * const source = element.files[0];
3691 * const info = await db.installService("/hello", source);
3692 * ```
3693 */
3694 installService(mount: string, source: Readable | Buffer | Blob | string, options?: InstallServiceOptions): Promise<ServiceInfo>;
3695 /**
3696 * Replaces an existing service with a new service by completely removing the
3697 * old service and installing a new service at the same mount point.
3698 *
3699 * @param mount - The service's mount point, relative to the database.
3700 * @param source - The service bundle to install.
3701 * @param options - Options for replacing the service.
3702 *
3703 * @example
3704 * ```js
3705 * const db = new Database();
3706 * // Using a node.js file stream as source
3707 * const source = fs.createReadStream("./my-foxx-service.zip");
3708 * const info = await db.replaceService("/hello", source);
3709 * ```
3710 *
3711 * @example
3712 * ```js
3713 * const db = new Database();
3714 * // Using a node.js Buffer as source
3715 * const source = fs.readFileSync("./my-foxx-service.zip");
3716 * const info = await db.replaceService("/hello", source);
3717 * ```
3718 *
3719 * @example
3720 * ```js
3721 * const db = new Database();
3722 * // Using a File (Blob) from a browser file input
3723 * const element = document.getElementById("my-file-input");
3724 * const source = element.files[0];
3725 * const info = await db.replaceService("/hello", source);
3726 * ```
3727 */
3728 replaceService(mount: string, source: Readable | Buffer | Blob | string, options?: ReplaceServiceOptions): Promise<ServiceInfo>;
3729 /**
3730 * Replaces an existing service with a new service while retaining the old
3731 * service's configuration and dependencies.
3732 *
3733 * @param mount - The service's mount point, relative to the database.
3734 * @param source - The service bundle to install.
3735 * @param options - Options for upgrading the service.
3736 *
3737 * @example
3738 * ```js
3739 * const db = new Database();
3740 * // Using a node.js file stream as source
3741 * const source = fs.createReadStream("./my-foxx-service.zip");
3742 * const info = await db.upgradeService("/hello", source);
3743 * ```
3744 *
3745 * @example
3746 * ```js
3747 * const db = new Database();
3748 * // Using a node.js Buffer as source
3749 * const source = fs.readFileSync("./my-foxx-service.zip");
3750 * const info = await db.upgradeService("/hello", source);
3751 * ```
3752 *
3753 * @example
3754 * ```js
3755 * const db = new Database();
3756 * // Using a File (Blob) from a browser file input
3757 * const element = document.getElementById("my-file-input");
3758 * const source = element.files[0];
3759 * const info = await db.upgradeService("/hello", source);
3760 * ```
3761 */
3762 upgradeService(mount: string, source: Readable | Buffer | Blob | string, options?: UpgradeServiceOptions): Promise<ServiceInfo>;
3763 /**
3764 * Completely removes a service from the database.
3765 *
3766 * @param mount - The service's mount point, relative to the database.
3767 * @param options - Options for uninstalling the service.
3768 *
3769 * @example
3770 * ```js
3771 * const db = new Database();
3772 * await db.uninstallService("/my-foxx");
3773 * ```
3774 */
3775 uninstallService(mount: string, options?: UninstallServiceOptions): Promise<void>;
3776 /**
3777 * Retrieves information about a mounted service.
3778 *
3779 * @param mount - The service's mount point, relative to the database.
3780 *
3781 * @example
3782 * ```js
3783 * const db = new Database();
3784 * const info = await db.getService("/my-service");
3785 * // info contains detailed information about the service
3786 * ```
3787 */
3788 getService(mount: string): Promise<ServiceInfo>;
3789 /**
3790 * Retrieves information about the service's configuration options and their
3791 * current values.
3792 *
3793 * See also {@link Database#replaceServiceConfiguration} and
3794 * {@link Database#updateServiceConfiguration}.
3795 *
3796 * @param mount - The service's mount point, relative to the database.
3797 * @param minimal - If set to `true`, the result will only include each
3798 * configuration option's current value. Otherwise it will include the full
3799 * definition for each option.
3800 *
3801 * @example
3802 * ```js
3803 * const db = new Database();
3804 * const config = await db.getServiceConfiguration("/my-service");
3805 * for (const [key, option] of Object.entries(config)) {
3806 * console.log(`${option.title} (${key}): ${option.current}`);
3807 * }
3808 * ```
3809 */
3810 getServiceConfiguration(mount: string, minimal?: false): Promise<Record<string, ServiceConfiguration>>;
3811 /**
3812 * Retrieves information about the service's configuration options and their
3813 * current values.
3814 *
3815 * See also {@link Database#replaceServiceConfiguration} and
3816 * {@link Database#updateServiceConfiguration}.
3817 *
3818 * @param mount - The service's mount point, relative to the database.
3819 * @param minimal - If set to `true`, the result will only include each
3820 * configuration option's current value. Otherwise it will include the full
3821 * definition for each option.
3822 *
3823 * @example
3824 * ```js
3825 * const db = new Database();
3826 * const config = await db.getServiceConfiguration("/my-service", true);
3827 * for (const [key, value] of Object.entries(config)) {
3828 * console.log(`${key}: ${value}`);
3829 * }
3830 * ```
3831 */
3832 getServiceConfiguration(mount: string, minimal: true): Promise<Record<string, any>>;
3833 /**
3834 * Replaces the configuration of the given service, discarding any existing
3835 * values for options not specified.
3836 *
3837 * See also {@link Database#updateServiceConfiguration} and
3838 * {@link Database#getServiceConfiguration}.
3839 *
3840 * @param mount - The service's mount point, relative to the database.
3841 * @param cfg - An object mapping configuration option names to values.
3842 * @param minimal - If set to `true`, the result will only include each
3843 * configuration option's current value and warning (if any).
3844 * Otherwise it will include the full definition for each option.
3845 *
3846 * @example
3847 * ```js
3848 * const db = new Database();
3849 * const config = { currency: "USD", locale: "en-US" };
3850 * const info = await db.replaceServiceConfiguration("/my-service", config);
3851 * for (const [key, option] of Object.entries(info)) {
3852 * console.log(`${option.title} (${key}): ${option.value}`);
3853 * if (option.warning) console.warn(`Warning: ${option.warning}`);
3854 * }
3855 * ```
3856 */
3857 replaceServiceConfiguration(mount: string, cfg: Record<string, any>, minimal?: false): Promise<Record<string, ServiceConfiguration & {
3858 warning?: string;
3859 }>>;
3860 /**
3861 * Replaces the configuration of the given service, discarding any existing
3862 * values for options not specified.
3863 *
3864 * See also {@link Database#updateServiceConfiguration} and
3865 * {@link Database#getServiceConfiguration}.
3866 *
3867 * @param mount - The service's mount point, relative to the database.
3868 * @param cfg - An object mapping configuration option names to values.
3869 * @param minimal - If set to `true`, the result will only include each
3870 * configuration option's current value and warning (if any).
3871 * Otherwise it will include the full definition for each option.
3872 *
3873 * @example
3874 * ```js
3875 * const db = new Database();
3876 * const config = { currency: "USD", locale: "en-US" };
3877 * const info = await db.replaceServiceConfiguration("/my-service", config);
3878 * for (const [key, value] of Object.entries(info.values)) {
3879 * console.log(`${key}: ${value}`);
3880 * if (info.warnings[key]) console.warn(`Warning: ${info.warnings[key]}`);
3881 * }
3882 * ```
3883 */
3884 replaceServiceConfiguration(mount: string, cfg: Record<string, any>, minimal: true): Promise<{
3885 values: Record<string, any>;
3886 warnings: Record<string, string>;
3887 }>;
3888 /**
3889 * Updates the configuration of the given service while maintaining any
3890 * existing values for options not specified.
3891 *
3892 * See also {@link Database#replaceServiceConfiguration} and
3893 * {@link Database#getServiceConfiguration}.
3894 *
3895 * @param mount - The service's mount point, relative to the database.
3896 * @param cfg - An object mapping configuration option names to values.
3897 * @param minimal - If set to `true`, the result will only include each
3898 * configuration option's current value and warning (if any).
3899 * Otherwise it will include the full definition for each option.
3900 *
3901 * @example
3902 * ```js
3903 * const db = new Database();
3904 * const config = { currency: "USD", locale: "en-US" };
3905 * const info = await db.updateServiceConfiguration("/my-service", config);
3906 * for (const [key, option] of Object.entries(info)) {
3907 * console.log(`${option.title} (${key}): ${option.value}`);
3908 * if (option.warning) console.warn(`Warning: ${option.warning}`);
3909 * }
3910 * ```
3911 */
3912 updateServiceConfiguration(mount: string, cfg: Record<string, any>, minimal?: false): Promise<Record<string, ServiceConfiguration & {
3913 warning?: string;
3914 }>>;
3915 /**
3916 * Updates the configuration of the given service while maintaining any
3917 * existing values for options not specified.
3918 *
3919 * See also {@link Database#replaceServiceConfiguration} and
3920 * {@link Database#getServiceConfiguration}.
3921 *
3922 * @param mount - The service's mount point, relative to the database.
3923 * @param cfg - An object mapping configuration option names to values.
3924 * @param minimal - If set to `true`, the result will only include each
3925 * configuration option's current value and warning (if any).
3926 * Otherwise it will include the full definition for each option.
3927 *
3928 * @example
3929 * ```js
3930 * const db = new Database();
3931 * const config = { currency: "USD", locale: "en-US" };
3932 * const info = await db.updateServiceConfiguration("/my-service", config);
3933 * for (const [key, value] of Object.entries(info.values)) {
3934 * console.log(`${key}: ${value}`);
3935 * if (info.warnings[key]) console.warn(`Warning: ${info.warnings[key]}`);
3936 * }
3937 * ```
3938 */
3939 updateServiceConfiguration(mount: string, cfg: Record<string, any>, minimal: true): Promise<{
3940 values: Record<string, any>;
3941 warnings: Record<string, string>;
3942 }>;
3943 /**
3944 * Retrieves information about the service's dependencies and their current
3945 * mount points.
3946 *
3947 * See also {@link Database#replaceServiceDependencies} and
3948 * {@link Database#updateServiceDependencies}.
3949 *
3950 * @param mount - The service's mount point, relative to the database.
3951 * @param minimal - If set to `true`, the result will only include each
3952 * dependency's current mount point. Otherwise it will include the full
3953 * definition for each dependency.
3954 *
3955 * @example
3956 * ```js
3957 * const db = new Database();
3958 * const deps = await db.getServiceDependencies("/my-service");
3959 * for (const [key, dep] of Object.entries(deps)) {
3960 * console.log(`${dep.title} (${key}): ${dep.current}`);
3961 * }
3962 * ```
3963 */
3964 getServiceDependencies(mount: string, minimal?: false): Promise<Record<string, SingleServiceDependency | MultiServiceDependency>>;
3965 /**
3966 * Retrieves information about the service's dependencies and their current
3967 * mount points.
3968 *
3969 * See also {@link Database#replaceServiceDependencies} and
3970 * {@link Database#updateServiceDependencies}.
3971 *
3972 * @param mount - The service's mount point, relative to the database.
3973 * @param minimal - If set to `true`, the result will only include each
3974 * dependency's current mount point. Otherwise it will include the full
3975 * definition for each dependency.
3976 *
3977 * @example
3978 * ```js
3979 * const db = new Database();
3980 * const deps = await db.getServiceDependencies("/my-service", true);
3981 * for (const [key, value] of Object.entries(deps)) {
3982 * console.log(`${key}: ${value}`);
3983 * }
3984 * ```
3985 */
3986 getServiceDependencies(mount: string, minimal: true): Promise<Record<string, string | string[]>>;
3987 /**
3988 * Replaces the dependencies of the given service, discarding any existing
3989 * mount points for dependencies not specified.
3990 *
3991 * See also {@link Database#updateServiceDependencies} and
3992 * {@link Database#getServiceDependencies}.
3993 *
3994 * @param mount - The service's mount point, relative to the database.
3995 * @param cfg - An object mapping dependency aliases to mount points.
3996 * @param minimal - If set to `true`, the result will only include each
3997 * dependency's current mount point. Otherwise it will include the full
3998 * definition for each dependency.
3999 *
4000 * @example
4001 * ```js
4002 * const db = new Database();
4003 * const deps = { mailer: "/mailer-api", auth: "/remote-auth" };
4004 * const info = await db.replaceServiceDependencies("/my-service", deps);
4005 * for (const [key, dep] of Object.entries(info)) {
4006 * console.log(`${dep.title} (${key}): ${dep.current}`);
4007 * if (dep.warning) console.warn(`Warning: ${dep.warning}`);
4008 * }
4009 * ```
4010 */
4011 replaceServiceDependencies(mount: string, deps: Record<string, string>, minimal?: false): Promise<Record<string, (SingleServiceDependency | MultiServiceDependency) & {
4012 warning?: string;
4013 }>>;
4014 /**
4015 * Replaces the dependencies of the given service, discarding any existing
4016 * mount points for dependencies not specified.
4017 *
4018 * See also {@link Database#updateServiceDependencies} and
4019 * {@link Database#getServiceDependencies}.
4020 *
4021 * @param mount - The service's mount point, relative to the database.
4022 * @param cfg - An object mapping dependency aliases to mount points.
4023 * @param minimal - If set to `true`, the result will only include each
4024 * dependency's current mount point. Otherwise it will include the full
4025 * definition for each dependency.
4026 *
4027 * @example
4028 * ```js
4029 * const db = new Database();
4030 * const deps = { mailer: "/mailer-api", auth: "/remote-auth" };
4031 * const info = await db.replaceServiceDependencies(
4032 * "/my-service",
4033 * deps,
4034 * true
4035 * );
4036 * for (const [key, value] of Object.entries(info)) {
4037 * console.log(`${key}: ${value}`);
4038 * if (info.warnings[key]) console.warn(`Warning: ${info.warnings[key]}`);
4039 * }
4040 * ```
4041 */
4042 replaceServiceDependencies(mount: string, deps: Record<string, string>, minimal: true): Promise<{
4043 values: Record<string, string>;
4044 warnings: Record<string, string>;
4045 }>;
4046 /**
4047 * Updates the dependencies of the given service while maintaining any
4048 * existing mount points for dependencies not specified.
4049 *
4050 * See also {@link Database#replaceServiceDependencies} and
4051 * {@link Database#getServiceDependencies}.
4052 *
4053 * @param mount - The service's mount point, relative to the database.
4054 * @param cfg - An object mapping dependency aliases to mount points.
4055 * @param minimal - If set to `true`, the result will only include each
4056 * dependency's current mount point. Otherwise it will include the full
4057 * definition for each dependency.
4058 *
4059 * @example
4060 * ```js
4061 * const db = new Database();
4062 * const deps = { mailer: "/mailer-api", auth: "/remote-auth" };
4063 * const info = await db.updateServiceDependencies("/my-service", deps);
4064 * for (const [key, dep] of Object.entries(info)) {
4065 * console.log(`${dep.title} (${key}): ${dep.current}`);
4066 * if (dep.warning) console.warn(`Warning: ${dep.warning}`);
4067 * }
4068 * ```
4069 */
4070 updateServiceDependencies(mount: string, deps: Record<string, string>, minimal?: false): Promise<Record<string, (SingleServiceDependency | MultiServiceDependency) & {
4071 warning?: string;
4072 }>>;
4073 /**
4074 * Updates the dependencies of the given service while maintaining any
4075 * existing mount points for dependencies not specified.
4076 *
4077 * See also {@link Database#replaceServiceDependencies} and
4078 * {@link Database#getServiceDependencies}.
4079 *
4080 * @param mount - The service's mount point, relative to the database.
4081 * @param cfg - An object mapping dependency aliases to mount points.
4082 * @param minimal - If set to `true`, the result will only include each
4083 * dependency's current mount point. Otherwise it will include the full
4084 * definition for each dependency.
4085 *
4086 * @example
4087 * ```js
4088 * const db = new Database();
4089 * const deps = { mailer: "/mailer-api", auth: "/remote-auth" };
4090 * const info = await db.updateServiceDependencies(
4091 * "/my-service",
4092 * deps,
4093 * true
4094 * );
4095 * for (const [key, value] of Object.entries(info)) {
4096 * console.log(`${key}: ${value}`);
4097 * if (info.warnings[key]) console.warn(`Warning: ${info.warnings[key]}`);
4098 * }
4099 * ```
4100 */
4101 updateServiceDependencies(mount: string, deps: Record<string, string>, minimal: true): Promise<{
4102 values: Record<string, string>;
4103 warnings: Record<string, string>;
4104 }>;
4105 /**
4106 * Enables or disables development mode for the given service.
4107 *
4108 * @param mount - The service's mount point, relative to the database.
4109 * @param enabled - Whether development mode should be enabled or disabled.
4110 *
4111 * @example
4112 * ```js
4113 * const db = new Database();
4114 * await db.setServiceDevelopmentMode("/my-service", true);
4115 * // the service is now in development mode
4116 * await db.setServiceDevelopmentMode("/my-service", false);
4117 * // the service is now in production mode
4118 * ```
4119 */
4120 setServiceDevelopmentMode(mount: string, enabled?: boolean): Promise<ServiceInfo>;
4121 /**
4122 * Retrieves a list of scripts defined in the service manifest's "scripts"
4123 * section mapped to their human readable representations.
4124 *
4125 * @param mount - The service's mount point, relative to the database.
4126 *
4127 * @example
4128 * ```js
4129 * const db = new Database();
4130 * const scripts = await db.listServiceScripts("/my-service");
4131 * for (const [name, title] of Object.entries(scripts)) {
4132 * console.log(`${name}: ${title}`);
4133 * }
4134 * ```
4135 */
4136 listServiceScripts(mount: string): Promise<Record<string, string>>;
4137 /**
4138 * Executes a service script and retrieves its result exposed as
4139 * `module.exports` (if any).
4140 *
4141 * @param mount - The service's mount point, relative to the database.
4142 * @param name - Name of the service script to execute as defined in the
4143 * service manifest.
4144 * @param params - Arbitrary value that will be exposed to the script as
4145 * `argv[0]` in the service context (e.g. `module.context.argv[0]`).
4146 * Must be serializable to JSON.
4147 *
4148 * @example
4149 * ```js
4150 * const db = new Database();
4151 * const result = await db.runServiceScript(
4152 * "/my-service",
4153 * "create-user",
4154 * {
4155 * username: "service_admin",
4156 * password: "hunter2"
4157 * }
4158 * );
4159 * ```
4160 */
4161 runServiceScript(mount: string, name: string, params?: any): Promise<any>;
4162 /**
4163 * Runs the tests of a given service and returns the results using the
4164 * "default" reporter.
4165 *
4166 * @param mount - The service's mount point, relative to the database.
4167 * @param options - Options for running the tests.
4168 *
4169 * @example
4170 * ```js
4171 * const db = new Database();
4172 * const testReport = await db.runServiceTests("/my-foxx");
4173 * ```
4174 */
4175 runServiceTests(mount: string, options?: {
4176 reporter?: "default";
4177 /**
4178 * Whether the reporter should use "idiomatic" mode. Has no effect when
4179 * using the "default" or "suite" reporters.
4180 */
4181 idiomatic?: false;
4182 /**
4183 * If set, only tests with full names including this exact string will be
4184 * executed.
4185 */
4186 filter?: string;
4187 }): Promise<ServiceTestDefaultReport>;
4188 /**
4189 * Runs the tests of a given service and returns the results using the
4190 * "suite" reporter, which groups the test result by test suite.
4191 *
4192 * @param mount - The service's mount point, relative to the database.
4193 * @param options - Options for running the tests.
4194 *
4195 * @example
4196 * ```js
4197 * const db = new Database();
4198 * const suiteReport = await db.runServiceTests(
4199 * "/my-foxx",
4200 * { reporter: "suite" }
4201 * );
4202 * ```
4203 */
4204 runServiceTests(mount: string, options: {
4205 reporter: "suite";
4206 /**
4207 * Whether the reporter should use "idiomatic" mode. Has no effect when
4208 * using the "default" or "suite" reporters.
4209 */
4210 idiomatic?: false;
4211 /**
4212 * If set, only tests with full names including this exact string will be
4213 * executed.
4214 */
4215 filter?: string;
4216 }): Promise<ServiceTestSuiteReport>;
4217 /**
4218 * Runs the tests of a given service and returns the results using the
4219 * "stream" reporter, which represents the results as a sequence of tuples
4220 * representing events.
4221 *
4222 * @param mount - The service's mount point, relative to the database.
4223 * @param options - Options for running the tests.
4224 *
4225 * @example
4226 * ```js
4227 * const db = new Database();
4228 * const streamEvents = await db.runServiceTests(
4229 * "/my-foxx",
4230 * { reporter: "stream" }
4231 * );
4232 * ```
4233 */
4234 runServiceTests(mount: string, options: {
4235 reporter: "stream";
4236 /**
4237 * Whether the reporter should use "idiomatic" mode. If set to `true`,
4238 * the results will be returned as a formatted string.
4239 */
4240 idiomatic?: false;
4241 /**
4242 * If set, only tests with full names including this exact string will be
4243 * executed.
4244 */
4245 filter?: string;
4246 }): Promise<ServiceTestStreamReport>;
4247 /**
4248 * Runs the tests of a given service and returns the results using the
4249 * "tap" reporter, which represents the results as an array of strings using
4250 * the "tap" format.
4251 *
4252 * @param mount - The service's mount point, relative to the database.
4253 * @param options - Options for running the tests.
4254 *
4255 * @example
4256 * ```js
4257 * const db = new Database();
4258 * const tapLines = await db.runServiceTests(
4259 * "/my-foxx",
4260 * { reporter: "tap" }
4261 * );
4262 * ```
4263 */
4264 runServiceTests(mount: string, options: {
4265 reporter: "tap";
4266 /**
4267 * Whether the reporter should use "idiomatic" mode. If set to `true`,
4268 * the results will be returned as a formatted string.
4269 */
4270 idiomatic?: false;
4271 /**
4272 * If set, only tests with full names including this exact string will be
4273 * executed.
4274 */
4275 filter?: string;
4276 }): Promise<ServiceTestTapReport>;
4277 /**
4278 * Runs the tests of a given service and returns the results using the
4279 * "xunit" reporter, which represents the results as an XML document using
4280 * the JSONML exchange format.
4281 *
4282 * @param mount - The service's mount point, relative to the database.
4283 * @param options - Options for running the tests.
4284 *
4285 * @example
4286 * ```js
4287 * const db = new Database();
4288 * const jsonML = await db.runServiceTests(
4289 * "/my-foxx",
4290 * { reporter: "xunit" }
4291 * );
4292 * ```
4293 */
4294 runServiceTests(mount: string, options: {
4295 reporter: "xunit";
4296 /**
4297 * Whether the reporter should use "idiomatic" mode. If set to `true`,
4298 * the results will be returned as a formatted string.
4299 */
4300 idiomatic?: false;
4301 /**
4302 * If set, only tests with full names including this exact string will be
4303 * executed.
4304 */
4305 filter?: string;
4306 }): Promise<ServiceTestXunitReport>;
4307 /**
4308 * Runs the tests of a given service and returns the results as a string
4309 * using the "stream" reporter in "idiomatic" mode, which represents the
4310 * results as a line-delimited JSON stream of tuples representing events.
4311 *
4312 * @param mount - The service's mount point, relative to the database.
4313 * @param options - Options for running the tests.
4314 *
4315 * @example
4316 * ```js
4317 * const db = new Database();
4318 * const streamReport = await db.runServiceTests(
4319 * "/my-foxx",
4320 * { reporter: "stream", idiomatic: true }
4321 * );
4322 * ```
4323 */
4324 runServiceTests(mount: string, options: {
4325 reporter: "stream";
4326 /**
4327 * Whether the reporter should use "idiomatic" mode. If set to `false`,
4328 * the results will be returned as an array of tuples instead of a
4329 * string.
4330 */
4331 idiomatic: true;
4332 /**
4333 * If set, only tests with full names including this exact string will be
4334 * executed.
4335 */
4336 filter?: string;
4337 }): Promise<string>;
4338 /**
4339 * Runs the tests of a given service and returns the results as a string
4340 * using the "tap" reporter in "idiomatic" mode, which represents the
4341 * results using the "tap" format.
4342 *
4343 * @param mount - The service's mount point, relative to the database.
4344 * @param options - Options for running the tests.
4345 *
4346 * @example
4347 * ```js
4348 * const db = new Database();
4349 * const tapReport = await db.runServiceTests(
4350 * "/my-foxx",
4351 * { reporter: "tap", idiomatic: true }
4352 * );
4353 * ```
4354 */
4355 runServiceTests(mount: string, options: {
4356 reporter: "tap";
4357 /**
4358 * Whether the reporter should use "idiomatic" mode. If set to `false`,
4359 * the results will be returned as an array of strings instead of a
4360 * single string.
4361 */
4362 idiomatic: true;
4363 /**
4364 * If set, only tests with full names including this exact string will be
4365 * executed.
4366 */
4367 filter?: string;
4368 }): Promise<string>;
4369 /**
4370 * Runs the tests of a given service and returns the results as a string
4371 * using the "xunit" reporter in "idiomatic" mode, which represents the
4372 * results as an XML document.
4373 *
4374 * @param mount - The service's mount point, relative to the database.
4375 * @param options - Options for running the tests.
4376 *
4377 * @example
4378 * ```js
4379 * const db = new Database();
4380 * const xml = await db.runServiceTests(
4381 * "/my-foxx",
4382 * { reporter: "xunit", idiomatic: true }
4383 * );
4384 * ```
4385 */
4386 runServiceTests(mount: string, options: {
4387 reporter: "xunit";
4388 /**
4389 * Whether the reporter should use "idiomatic" mode. If set to `false`,
4390 * the results will be returned using the JSONML exchange format
4391 * instead of a string.
4392 */
4393 idiomatic: true;
4394 /**
4395 * If set, only tests with full names including this exact string will be
4396 * executed.
4397 */
4398 filter?: string;
4399 }): Promise<string>;
4400 /**
4401 * Retrieves the text content of the service's `README` or `README.md` file.
4402 *
4403 * Returns `undefined` if no such file could be found.
4404 *
4405 * @param mount - The service's mount point, relative to the database.
4406 *
4407 * @example
4408 * ```js
4409 * const db = new Database();
4410 * const readme = await db.getServiceReadme("/my-service");
4411 * if (readme !== undefined) console.log(readme);
4412 * else console.warn(`No README found.`)
4413 * ```
4414 */
4415 getServiceReadme(mount: string): Promise<string | undefined>;
4416 /**
4417 * Retrieves an Open API compatible Swagger API description object for the
4418 * service installed at the given mount point.
4419 *
4420 * @param mount - The service's mount point, relative to the database.
4421 *
4422 * @example
4423 * ```js
4424 * const db = new Database();
4425 * const spec = await db.getServiceDocumentation("/my-service");
4426 * // spec is a Swagger API description of the service
4427 * ```
4428 */
4429 getServiceDocumentation(mount: string): Promise<SwaggerJson>;
4430 /**
4431 * Retrieves a zip bundle containing the service files.
4432 *
4433 * Returns a `Buffer` in node.js or `Blob` in the browser.
4434 *
4435 * @param mount - The service's mount point, relative to the database.
4436 *
4437 * @example
4438 * ```js
4439 * const db = new Database();
4440 * const serviceBundle = await db.downloadService("/my-foxx");
4441 * ```
4442 */
4443 downloadService(mount: string): Promise<Buffer | Blob>;
4444 /**
4445 * Writes all locally available services to the database and updates any
4446 * service bundles missing in the database.
4447 *
4448 * @param replace - If set to `true`, outdated services will also be
4449 * committed. This can be used to solve some consistency problems when
4450 * service bundles are missing in the database or were deleted manually.
4451 *
4452 * @example
4453 * ```js
4454 * await db.commitLocalServiceState();
4455 * // all services available on the coordinator have been written to the db
4456 * ```
4457 *
4458 * @example
4459 * ```js
4460 * await db.commitLocalServiceState(true);
4461 * // all service conflicts have been resolved in favor of this coordinator
4462 * ```
4463 */
4464 commitLocalServiceState(replace?: boolean): Promise<void>;
4465 /**
4466 * (Enterprise Edition only.) Creates a hot backup of the entire ArangoDB
4467 * deployment including all databases, collections, etc.
4468 *
4469 * Returns an object describing the backup result.
4470 *
4471 * @param options - Options for creating the backup.
4472 *
4473 * @example
4474 * ```js
4475 * const info = await db.createHotBackup();
4476 * // a hot backup has been created
4477 * ```
4478 */
4479 createHotBackup(options?: HotBackupOptions): Promise<HotBackupResult>;
4480 /**
4481 * (Enterprise Edition only.) Retrieves a list of all locally found hot
4482 * backups.
4483 *
4484 * @param id - If specified, only the backup with the given ID will be
4485 * returned.
4486 *
4487 * @example
4488 * ```js
4489 * const backups = await db.listHotBackups();
4490 * for (const backup of backups) {
4491 * console.log(backup.id);
4492 * }
4493 * ```
4494 */
4495 listHotBackups(id?: string | string[]): Promise<HotBackupList>;
4496 /**
4497 * (Enteprise Edition only.) Restores a consistent local hot backup.
4498 *
4499 * Returns the directory path of the restored backup.
4500 *
4501 * @param id - The ID of the backup to restore.
4502 *
4503 * @example
4504 * ```js
4505 * await db.restoreHotBackup("2023-09-19T15.38.21Z_example");
4506 * // the backup has been restored
4507 * ```
4508 */
4509 restoreHotBackup(id: string): Promise<string>;
4510 /**
4511 * (Enterprise Edition only.) Deletes a local hot backup.
4512 *
4513 * @param id - The ID of the backup to delete.
4514 *
4515 * @example
4516 * ```js
4517 * await db.deleteHotBackup("2023-09-19T15.38.21Z_example");
4518 * // the backup has been deleted
4519 * ```
4520 */
4521 deleteHotBackup(id: string): Promise<void>;
4522 /**
4523 * Retrieves the log messages from the server's global log.
4524 *
4525 * @param options - Options for retrieving the log entries.
4526 *
4527 * @example
4528 * ```js
4529 * const log = await db.getLogEntries();
4530 * for (let i = 0; i < log.totalAmount; i++) {
4531 * console.log(`${
4532 * new Date(log.timestamp[i] * 1000).toISOString()
4533 * } - [${LogLevel[log.level[i]]}] ${log.text[i]} (#${log.lid[i]})`);
4534 * }
4535 * ```
4536 */
4537 getLogEntries(options?: LogEntriesOptions): Promise<LogEntries>;
4538 /**
4539 * Retrieves the log messages from the server's global log.
4540 *
4541 * @param options - Options for retrieving the log entries.
4542 *
4543 * @deprecated This endpoint has been deprecated in ArangoDB 3.8.
4544 * Use {@link Database#getLogEntries} instead.
4545 *
4546 * @example
4547 * ```js
4548 * const messages = await db.getLogMessages();
4549 * for (const m of messages) {
4550 * console.log(`${m.date} - [${m.level}] ${m.message} (#${m.id})`);
4551 * }
4552 * ```
4553 */
4554 getLogMessages(options?: LogEntriesOptions): Promise<LogMessage[]>;
4555 /**
4556 * Retrieves the server's current log level for each topic.
4557 *
4558 * @example
4559 * ```js
4560 * const levels = await db.getLogLevel();
4561 * console.log(levels.request); // log level for incoming requests
4562 * ```
4563 */
4564 getLogLevel(): Promise<Record<string, LogLevelSetting>>;
4565 /**
4566 * Sets the server's log level for each of the given topics to the given level.
4567 *
4568 * Any omitted topics will be left unchanged.
4569 *
4570 * @param levels - An object mapping topic names to log levels.
4571 *
4572 * @example
4573 * ```js
4574 * await db.setLogLevel({ request: "debug" });
4575 * // Debug information will now be logged for each request
4576 * ```
4577 */
4578 setLogLevel(levels: Record<string, LogLevelSetting>): Promise<Record<string, LogLevelSetting>>;
4579 /**
4580 * Returns a {@link job.Job} instance for the given `jobId`.
4581 *
4582 * @param jobId - ID of the async job.
4583 *
4584 * @example
4585 * ```js
4586 * const db = new Database();
4587 * const job = db.job("12345");
4588 * ```
4589 */
4590 job(jobId: string): Job;
4591 /**
4592 * Returns a list of the IDs of all currently pending async jobs.
4593 *
4594 * @example
4595 * ```js
4596 * const db = new Database();
4597 * const pendingJobs = await db.listPendingJobs();
4598 * console.log(pendingJobs); // e.g. ["12345", "67890"]
4599 * ```
4600 */
4601 listPendingJobs(): Promise<string[]>;
4602 /**
4603 * Returns a list of the IDs of all currently available completed async jobs.
4604 *
4605 * @example
4606 * ```js
4607 * const db = new Database();
4608 * const completedJobs = await db.listCompletedJobs();
4609 * console.log(completedJobs); // e.g. ["12345", "67890"]
4610 * ```
4611 */
4612 listCompletedJobs(): Promise<string[]>;
4613 /**
4614 * Deletes the results of all completed async jobs created before the given
4615 * threshold.
4616 *
4617 * @param threshold - The expiration timestamp in milliseconds.
4618 *
4619 * @example
4620 * ```js
4621 * const db = new Database();
4622 * const ONE_WEEK = 7 * 24 * 60 * 60 * 1000;
4623 * await db.deleteExpiredJobResults(Date.now() - ONE_WEEK);
4624 * // all job results older than a week have been deleted
4625 * ```
4626 */
4627 deleteExpiredJobResults(threshold: number): Promise<void>;
4628 /**
4629 * Deletes the results of all completed async jobs.
4630 */
4631 deleteAllJobResults(): Promise<void>;
4632}
4633export {};
4634//# sourceMappingURL=database.d.ts.map
\No newline at end of file