1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | import { Readable } from "stream";
|
16 | import { Analyzer, AnalyzerDescription, CreateAnalyzerOptions } from "./analyzer";
|
17 | import { AqlLiteral, AqlQuery } from "./aql";
|
18 | import { ArangoCollection, Collection, CollectionMetadata, CollectionType, CreateCollectionOptions, DocumentCollection, EdgeCollection } from "./collection";
|
19 | import { ArangoApiResponse, Config, Connection, Headers, RequestOptions } from "./connection";
|
20 | import { ArrayCursor } from "./cursor";
|
21 | import { FoxxManifest } from "./foxx-manifest";
|
22 | import { CreateGraphOptions, EdgeDefinitionOptions, Graph, GraphInfo } from "./graph";
|
23 | import { Job } from "./job";
|
24 | import { Blob } from "./lib/blob";
|
25 | import { ArangojsResponse } from "./lib/request";
|
26 | import { Route } from "./route";
|
27 | import { Transaction } from "./transaction";
|
28 | import { CreateViewOptions, View, ViewDescription } from "./view";
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | export declare function isArangoDatabase(database: any): database is Database;
|
35 |
|
36 |
|
37 |
|
38 | export type TransactionCollections = {
|
39 | |
40 |
|
41 |
|
42 |
|
43 |
|
44 | exclusive?: (string | ArangoCollection)[] | string | ArangoCollection;
|
45 | |
46 |
|
47 |
|
48 |
|
49 | write?: (string | ArangoCollection)[] | string | ArangoCollection;
|
50 | |
51 |
|
52 |
|
53 |
|
54 | read?: (string | ArangoCollection)[] | string | ArangoCollection;
|
55 | };
|
56 |
|
57 |
|
58 |
|
59 | export type TransactionOptions = {
|
60 | |
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 | allowImplicit?: boolean;
|
68 | |
69 |
|
70 |
|
71 |
|
72 |
|
73 | allowDirtyRead?: boolean;
|
74 | |
75 |
|
76 |
|
77 |
|
78 | waitForSync?: boolean;
|
79 | |
80 |
|
81 |
|
82 |
|
83 | lockTimeout?: number;
|
84 | |
85 |
|
86 |
|
87 | maxTransactionSize?: number;
|
88 | };
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 | export type QueryOptions = {
|
95 | |
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 | allowDirtyRead?: boolean;
|
108 | |
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 | allowRetry?: boolean;
|
115 | |
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 | timeout?: number;
|
124 | |
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 | retryOnConflict?: number;
|
131 | |
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 | count?: boolean;
|
140 | |
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 | batchSize?: number;
|
147 | |
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 | cache?: boolean;
|
154 | |
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 | memoryLimit?: number;
|
163 | |
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 | maxRuntime?: number;
|
171 | |
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 | ttl?: number;
|
178 | |
179 |
|
180 |
|
181 |
|
182 | failOnWarning?: boolean;
|
183 | |
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 | profile?: boolean | number;
|
193 | |
194 |
|
195 |
|
196 | stream?: boolean;
|
197 | |
198 |
|
199 |
|
200 | maxWarningsCount?: number;
|
201 | |
202 |
|
203 |
|
204 |
|
205 |
|
206 | fullCount?: boolean;
|
207 | |
208 |
|
209 |
|
210 |
|
211 |
|
212 | fillBlockCache?: boolean;
|
213 | |
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 | optimizer?: {
|
220 | rules: string[];
|
221 | };
|
222 | |
223 |
|
224 |
|
225 |
|
226 | maxPlans?: number;
|
227 | |
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 | maxNodesPerCallstack?: number;
|
234 | |
235 |
|
236 |
|
237 | maxTransactionSize?: number;
|
238 | |
239 |
|
240 |
|
241 |
|
242 | intermediateCommitCount?: number;
|
243 | |
244 |
|
245 |
|
246 |
|
247 | intermediateCommitSize?: number;
|
248 | |
249 |
|
250 |
|
251 |
|
252 |
|
253 | skipInaccessibleCollections?: boolean;
|
254 | |
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 | satelliteSyncWait?: number;
|
262 | };
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 | export type ExplainOptions = {
|
269 | |
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 | optimizer?: {
|
276 | rules: string[];
|
277 | };
|
278 | |
279 |
|
280 |
|
281 |
|
282 | maxNumberOfPlans?: number;
|
283 | |
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 | allPlans?: boolean;
|
291 | };
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 | export type TransactionDetails = {
|
298 | |
299 |
|
300 |
|
301 | id: string;
|
302 | |
303 |
|
304 |
|
305 | state: "running" | "committed" | "aborted";
|
306 | };
|
307 |
|
308 |
|
309 |
|
310 | export type ExplainPlan = {
|
311 | |
312 |
|
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 |
|
324 |
|
325 | rules: string[];
|
326 | |
327 |
|
328 |
|
329 | collections: {
|
330 | name: string;
|
331 | type: "read" | "write";
|
332 | }[];
|
333 | |
334 |
|
335 |
|
336 | variables: {
|
337 | id: number;
|
338 | name: string;
|
339 | }[];
|
340 | |
341 |
|
342 |
|
343 | estimatedCost: number;
|
344 | |
345 |
|
346 |
|
347 | estimatedNrItems: number;
|
348 | |
349 |
|
350 |
|
351 | isModificationQuery: boolean;
|
352 | };
|
353 |
|
354 |
|
355 |
|
356 | export type ExplainStats = {
|
357 | |
358 |
|
359 |
|
360 | rulesExecuted: number;
|
361 | |
362 |
|
363 |
|
364 | rulesSkipped: number;
|
365 | |
366 |
|
367 |
|
368 | plansCreated: number;
|
369 | |
370 |
|
371 |
|
372 | peakMemoryUsage: number;
|
373 | |
374 |
|
375 |
|
376 | executionTime: number;
|
377 | };
|
378 |
|
379 |
|
380 |
|
381 | export type SingleExplainResult = {
|
382 | |
383 |
|
384 |
|
385 | plan: ExplainPlan;
|
386 | |
387 |
|
388 |
|
389 | cacheable: boolean;
|
390 | |
391 |
|
392 |
|
393 | warnings: {
|
394 | code: number;
|
395 | message: string;
|
396 | }[];
|
397 | |
398 |
|
399 |
|
400 | stats: ExplainStats;
|
401 | };
|
402 |
|
403 |
|
404 |
|
405 | export type MultiExplainResult = {
|
406 | |
407 |
|
408 |
|
409 | plans: ExplainPlan[];
|
410 | |
411 |
|
412 |
|
413 | cacheable: boolean;
|
414 | |
415 |
|
416 |
|
417 | warnings: {
|
418 | code: number;
|
419 | message: string;
|
420 | }[];
|
421 | |
422 |
|
423 |
|
424 | stats: ExplainStats;
|
425 | };
|
426 |
|
427 |
|
428 |
|
429 | export type AstNode = {
|
430 | [key: string]: any;
|
431 | type: string;
|
432 | subNodes: AstNode[];
|
433 | };
|
434 |
|
435 |
|
436 |
|
437 | export type ParseResult = {
|
438 | |
439 |
|
440 |
|
441 | parsed: boolean;
|
442 | |
443 |
|
444 |
|
445 | collections: string[];
|
446 | |
447 |
|
448 |
|
449 | bindVars: string[];
|
450 | |
451 |
|
452 |
|
453 | ast: AstNode[];
|
454 | };
|
455 |
|
456 |
|
457 |
|
458 | export 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 |
|
471 |
|
472 | export type QueryTracking = {
|
473 | |
474 |
|
475 |
|
476 | enabled: boolean;
|
477 | |
478 |
|
479 |
|
480 | maxQueryStringLength: number;
|
481 | |
482 |
|
483 |
|
484 | maxSlowQueries: number;
|
485 | |
486 |
|
487 |
|
488 |
|
489 | slowQueryThreshold: number;
|
490 | |
491 |
|
492 |
|
493 | trackBindVars: boolean;
|
494 | |
495 |
|
496 |
|
497 | trackSlowQueries: boolean;
|
498 | };
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 | export type QueryTrackingOptions = {
|
505 | |
506 |
|
507 |
|
508 | enabled?: boolean;
|
509 | |
510 |
|
511 |
|
512 | maxQueryStringLength?: number;
|
513 | |
514 |
|
515 |
|
516 | maxSlowQueries?: number;
|
517 | |
518 |
|
519 |
|
520 |
|
521 | slowQueryThreshold?: number;
|
522 | |
523 |
|
524 |
|
525 | trackBindVars?: boolean;
|
526 | |
527 |
|
528 |
|
529 |
|
530 | trackSlowQueries?: boolean;
|
531 | };
|
532 |
|
533 |
|
534 |
|
535 | export type QueryInfo = {
|
536 | |
537 |
|
538 |
|
539 | id: string;
|
540 | |
541 |
|
542 |
|
543 | database: string;
|
544 | |
545 |
|
546 |
|
547 | user: string;
|
548 | |
549 |
|
550 |
|
551 | query: string;
|
552 | |
553 |
|
554 |
|
555 | bindVars: Record<string, any>;
|
556 | |
557 |
|
558 |
|
559 | started: string;
|
560 | |
561 |
|
562 |
|
563 | runTime: number;
|
564 | |
565 |
|
566 |
|
567 | peakMemoryUsage: number;
|
568 | |
569 |
|
570 |
|
571 | state: "executing" | "finished" | "killed";
|
572 | |
573 |
|
574 |
|
575 | stream: boolean;
|
576 | };
|
577 |
|
578 |
|
579 |
|
580 | export type ClusterImbalanceInfo = {
|
581 | |
582 |
|
583 |
|
584 | leader: {
|
585 | |
586 |
|
587 |
|
588 | weightUsed: number[];
|
589 | |
590 |
|
591 |
|
592 | targetWeight: number[];
|
593 | |
594 |
|
595 |
|
596 | numberShards: number[];
|
597 | |
598 |
|
599 |
|
600 | leaderDupl: number[];
|
601 | |
602 |
|
603 |
|
604 | totalWeight: number;
|
605 | |
606 |
|
607 |
|
608 | imbalance: number;
|
609 | |
610 |
|
611 |
|
612 | totalShards: number;
|
613 | };
|
614 | |
615 |
|
616 |
|
617 | shards: {
|
618 | |
619 |
|
620 |
|
621 | sizeUsed: number[];
|
622 | |
623 |
|
624 |
|
625 | targetSize: number[];
|
626 | |
627 |
|
628 |
|
629 | numberShards: number[];
|
630 | |
631 |
|
632 |
|
633 | totalUsed: number;
|
634 | |
635 |
|
636 |
|
637 | totalShards: number;
|
638 | |
639 |
|
640 |
|
641 | totalShardsFromSystemCollections: number;
|
642 | |
643 |
|
644 |
|
645 | imbalance: number;
|
646 | };
|
647 | };
|
648 |
|
649 |
|
650 |
|
651 | export type ClusterRebalanceState = ClusterImbalanceInfo & {
|
652 | |
653 |
|
654 |
|
655 | pendingMoveShards: number;
|
656 | |
657 |
|
658 |
|
659 | todoMoveShards: number;
|
660 | };
|
661 |
|
662 |
|
663 |
|
664 | export type ClusterRebalanceOptions = {
|
665 | |
666 |
|
667 |
|
668 |
|
669 |
|
670 | maximumNumberOfMoves?: number;
|
671 | |
672 |
|
673 |
|
674 |
|
675 |
|
676 | leaderChanges?: boolean;
|
677 | |
678 |
|
679 |
|
680 |
|
681 |
|
682 | moveLeaders?: boolean;
|
683 | |
684 |
|
685 |
|
686 |
|
687 |
|
688 | moveFollowers?: boolean;
|
689 | |
690 |
|
691 |
|
692 |
|
693 |
|
694 | excludeSystemCollections?: boolean;
|
695 | |
696 |
|
697 |
|
698 | piFactor?: number;
|
699 | |
700 |
|
701 |
|
702 |
|
703 |
|
704 | databasesExcluded?: string[];
|
705 | };
|
706 | export type ClusterRebalanceMove = {
|
707 | |
708 |
|
709 |
|
710 | from: string;
|
711 | |
712 |
|
713 |
|
714 | to: string;
|
715 | |
716 |
|
717 |
|
718 | shard: string;
|
719 | |
720 |
|
721 |
|
722 | collection: number;
|
723 | |
724 |
|
725 |
|
726 | isLeader: boolean;
|
727 | };
|
728 | export type ClusterRebalanceResult = {
|
729 | |
730 |
|
731 |
|
732 | imbalanceBefore: ClusterImbalanceInfo;
|
733 | |
734 |
|
735 |
|
736 | imbalanceAfter: ClusterImbalanceInfo;
|
737 | |
738 |
|
739 |
|
740 | moves: ClusterRebalanceMove[];
|
741 | };
|
742 |
|
743 |
|
744 |
|
745 | export type CreateDatabaseUser = {
|
746 | |
747 |
|
748 |
|
749 | username: string;
|
750 | |
751 |
|
752 |
|
753 |
|
754 |
|
755 | passwd?: string;
|
756 | |
757 |
|
758 |
|
759 |
|
760 |
|
761 | active?: boolean;
|
762 | |
763 |
|
764 |
|
765 | extra?: Record<string, any>;
|
766 | };
|
767 |
|
768 |
|
769 |
|
770 |
|
771 |
|
772 | export type CreateDatabaseOptions = {
|
773 | |
774 |
|
775 |
|
776 | users?: CreateDatabaseUser[];
|
777 | |
778 |
|
779 |
|
780 |
|
781 | sharding?: "" | "flexible" | "single";
|
782 | |
783 |
|
784 |
|
785 |
|
786 |
|
787 |
|
788 |
|
789 | replicationFactor?: "satellite" | number;
|
790 | |
791 |
|
792 |
|
793 |
|
794 | writeConcern?: number;
|
795 | };
|
796 |
|
797 |
|
798 |
|
799 |
|
800 |
|
801 | export type DatabaseInfo = {
|
802 | |
803 |
|
804 |
|
805 | name: string;
|
806 | |
807 |
|
808 |
|
809 | id: string;
|
810 | |
811 |
|
812 |
|
813 | path: string;
|
814 | |
815 |
|
816 |
|
817 | isSystem: boolean;
|
818 | |
819 |
|
820 |
|
821 |
|
822 | sharding?: "" | "flexible" | "single";
|
823 | |
824 |
|
825 |
|
826 |
|
827 | replicationFactor?: "satellite" | number;
|
828 | |
829 |
|
830 |
|
831 |
|
832 | writeConcern?: number;
|
833 | };
|
834 |
|
835 |
|
836 |
|
837 | export type VersionInfo = {
|
838 | |
839 |
|
840 |
|
841 | server: string;
|
842 | |
843 |
|
844 |
|
845 | license: "community" | "enterprise";
|
846 | |
847 |
|
848 |
|
849 | version: string;
|
850 | |
851 |
|
852 |
|
853 | details?: {
|
854 | [key: string]: string;
|
855 | };
|
856 | };
|
857 |
|
858 |
|
859 |
|
860 | export type AqlUserFunction = {
|
861 | |
862 |
|
863 |
|
864 | name: string;
|
865 | |
866 |
|
867 |
|
868 | code: string;
|
869 | |
870 |
|
871 |
|
872 |
|
873 |
|
874 | isDeterministic: boolean;
|
875 | };
|
876 |
|
877 |
|
878 |
|
879 |
|
880 |
|
881 | export type InstallServiceOptions = {
|
882 | |
883 |
|
884 |
|
885 |
|
886 |
|
887 | configuration?: Record<string, any>;
|
888 | |
889 |
|
890 |
|
891 |
|
892 |
|
893 | dependencies?: Record<string, string>;
|
894 | |
895 |
|
896 |
|
897 |
|
898 |
|
899 |
|
900 |
|
901 | development?: boolean;
|
902 | |
903 |
|
904 |
|
905 |
|
906 |
|
907 |
|
908 |
|
909 | legacy?: boolean;
|
910 | |
911 |
|
912 |
|
913 |
|
914 |
|
915 | setup?: boolean;
|
916 | };
|
917 |
|
918 |
|
919 |
|
920 |
|
921 |
|
922 | export type ReplaceServiceOptions = {
|
923 | |
924 |
|
925 |
|
926 |
|
927 |
|
928 | configuration?: Record<string, any>;
|
929 | |
930 |
|
931 |
|
932 |
|
933 |
|
934 | dependencies?: Record<string, string>;
|
935 | |
936 |
|
937 |
|
938 |
|
939 |
|
940 |
|
941 |
|
942 | development?: boolean;
|
943 | |
944 |
|
945 |
|
946 |
|
947 |
|
948 |
|
949 |
|
950 | legacy?: boolean;
|
951 | |
952 |
|
953 |
|
954 |
|
955 |
|
956 | setup?: boolean;
|
957 | |
958 |
|
959 |
|
960 |
|
961 |
|
962 |
|
963 | teardown?: boolean;
|
964 | |
965 |
|
966 |
|
967 |
|
968 |
|
969 |
|
970 | force?: boolean;
|
971 | };
|
972 |
|
973 |
|
974 |
|
975 |
|
976 |
|
977 | export type UpgradeServiceOptions = {
|
978 | |
979 |
|
980 |
|
981 |
|
982 |
|
983 | configuration?: Record<string, any>;
|
984 | |
985 |
|
986 |
|
987 |
|
988 |
|
989 | dependencies?: Record<string, string>;
|
990 | |
991 |
|
992 |
|
993 |
|
994 |
|
995 |
|
996 |
|
997 | development?: boolean;
|
998 | |
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 | legacy?: boolean;
|
1006 | |
1007 |
|
1008 |
|
1009 |
|
1010 |
|
1011 | setup?: boolean;
|
1012 | |
1013 |
|
1014 |
|
1015 |
|
1016 |
|
1017 |
|
1018 | teardown?: boolean;
|
1019 | |
1020 |
|
1021 |
|
1022 |
|
1023 |
|
1024 |
|
1025 | force?: boolean;
|
1026 | };
|
1027 |
|
1028 |
|
1029 |
|
1030 |
|
1031 |
|
1032 | export type UninstallServiceOptions = {
|
1033 | |
1034 |
|
1035 |
|
1036 |
|
1037 |
|
1038 |
|
1039 | teardown?: boolean;
|
1040 | |
1041 |
|
1042 |
|
1043 |
|
1044 |
|
1045 |
|
1046 | force?: boolean;
|
1047 | };
|
1048 |
|
1049 |
|
1050 |
|
1051 | export type ServiceSummary = {
|
1052 | |
1053 |
|
1054 |
|
1055 | mount: string;
|
1056 | |
1057 |
|
1058 |
|
1059 | name?: string;
|
1060 | |
1061 |
|
1062 |
|
1063 | version?: string;
|
1064 | |
1065 |
|
1066 |
|
1067 |
|
1068 | provides: Record<string, string>;
|
1069 | |
1070 |
|
1071 |
|
1072 | development: boolean;
|
1073 | |
1074 |
|
1075 |
|
1076 | legacy: boolean;
|
1077 | };
|
1078 |
|
1079 |
|
1080 |
|
1081 | export type ServiceInfo = {
|
1082 | |
1083 |
|
1084 |
|
1085 | mount: string;
|
1086 | |
1087 |
|
1088 |
|
1089 | path: string;
|
1090 | |
1091 |
|
1092 |
|
1093 | name?: string;
|
1094 | |
1095 |
|
1096 |
|
1097 | version?: string;
|
1098 | |
1099 |
|
1100 |
|
1101 | development: boolean;
|
1102 | |
1103 |
|
1104 |
|
1105 | legacy: boolean;
|
1106 | |
1107 |
|
1108 |
|
1109 | manifest: FoxxManifest;
|
1110 | |
1111 |
|
1112 |
|
1113 | checksum: string;
|
1114 | |
1115 |
|
1116 |
|
1117 | options: {
|
1118 | |
1119 |
|
1120 |
|
1121 | configuration: Record<string, any>;
|
1122 | |
1123 |
|
1124 |
|
1125 | dependencies: Record<string, string>;
|
1126 | };
|
1127 | };
|
1128 |
|
1129 |
|
1130 |
|
1131 | export type ServiceConfiguration = {
|
1132 | |
1133 |
|
1134 |
|
1135 |
|
1136 |
|
1137 |
|
1138 |
|
1139 |
|
1140 | type: "integer" | "boolean" | "string" | "number" | "json" | "password" | "int" | "bool";
|
1141 | |
1142 |
|
1143 |
|
1144 | currentRaw: any;
|
1145 | |
1146 |
|
1147 |
|
1148 |
|
1149 | current: any;
|
1150 | |
1151 |
|
1152 |
|
1153 | title: string;
|
1154 | |
1155 |
|
1156 |
|
1157 | description?: string;
|
1158 | |
1159 |
|
1160 |
|
1161 |
|
1162 | required: boolean;
|
1163 | |
1164 |
|
1165 |
|
1166 | default?: any;
|
1167 | };
|
1168 |
|
1169 |
|
1170 |
|
1171 | export type SingleServiceDependency = {
|
1172 | |
1173 |
|
1174 |
|
1175 | multiple: false;
|
1176 | |
1177 |
|
1178 |
|
1179 | current?: string;
|
1180 | |
1181 |
|
1182 |
|
1183 | title: string;
|
1184 | |
1185 |
|
1186 |
|
1187 | name: string;
|
1188 | |
1189 |
|
1190 |
|
1191 | version: string;
|
1192 | |
1193 |
|
1194 |
|
1195 | description?: string;
|
1196 | |
1197 |
|
1198 |
|
1199 |
|
1200 | required: boolean;
|
1201 | };
|
1202 |
|
1203 |
|
1204 |
|
1205 | export type MultiServiceDependency = {
|
1206 | |
1207 |
|
1208 |
|
1209 | multiple: true;
|
1210 | |
1211 |
|
1212 |
|
1213 | current?: string[];
|
1214 | |
1215 |
|
1216 |
|
1217 | title: string;
|
1218 | |
1219 |
|
1220 |
|
1221 | name: string;
|
1222 | |
1223 |
|
1224 |
|
1225 | version: string;
|
1226 | |
1227 |
|
1228 |
|
1229 | description?: string;
|
1230 | |
1231 |
|
1232 |
|
1233 |
|
1234 | required: boolean;
|
1235 | };
|
1236 |
|
1237 |
|
1238 |
|
1239 | export type ServiceTestStats = {
|
1240 | |
1241 |
|
1242 |
|
1243 | tests: number;
|
1244 | |
1245 |
|
1246 |
|
1247 | passes: number;
|
1248 | |
1249 |
|
1250 |
|
1251 | failures: number;
|
1252 | |
1253 |
|
1254 |
|
1255 | pending: number;
|
1256 | |
1257 |
|
1258 |
|
1259 | duration: number;
|
1260 | };
|
1261 |
|
1262 |
|
1263 |
|
1264 | export type ServiceTestStreamTest = {
|
1265 | title: string;
|
1266 | fullTitle: string;
|
1267 | duration: number;
|
1268 | err?: string;
|
1269 | };
|
1270 |
|
1271 |
|
1272 |
|
1273 | export type ServiceTestStreamReport = (["start", {
|
1274 | total: number;
|
1275 | }] | ["pass", ServiceTestStreamTest] | ["fail", ServiceTestStreamTest] | ["end", ServiceTestStats])[];
|
1276 |
|
1277 |
|
1278 |
|
1279 | export type ServiceTestSuiteTest = {
|
1280 | result: "pending" | "pass" | "fail";
|
1281 | title: string;
|
1282 | duration: number;
|
1283 | err?: any;
|
1284 | };
|
1285 |
|
1286 |
|
1287 |
|
1288 | export type ServiceTestSuite = {
|
1289 | title: string;
|
1290 | suites: ServiceTestSuite[];
|
1291 | tests: ServiceTestSuiteTest[];
|
1292 | };
|
1293 |
|
1294 |
|
1295 |
|
1296 | export type ServiceTestSuiteReport = {
|
1297 | stats: ServiceTestStats;
|
1298 | suites: ServiceTestSuite[];
|
1299 | tests: ServiceTestSuiteTest[];
|
1300 | };
|
1301 |
|
1302 |
|
1303 |
|
1304 |
|
1305 | export 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 |
|
1327 |
|
1328 |
|
1329 | export 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 |
|
1343 |
|
1344 | export type ServiceTestTapReport = string[];
|
1345 |
|
1346 |
|
1347 |
|
1348 | export type ServiceTestDefaultTest = {
|
1349 | title: string;
|
1350 | fullTitle: string;
|
1351 | duration: number;
|
1352 | err?: string;
|
1353 | };
|
1354 |
|
1355 |
|
1356 |
|
1357 | export type ServiceTestDefaultReport = {
|
1358 | stats: ServiceTestStats;
|
1359 | tests: ServiceTestDefaultTest[];
|
1360 | pending: ServiceTestDefaultTest[];
|
1361 | failures: ServiceTestDefaultTest[];
|
1362 | passes: ServiceTestDefaultTest[];
|
1363 | };
|
1364 |
|
1365 |
|
1366 |
|
1367 | export 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 |
|
1381 |
|
1382 | export type AccessLevel = "rw" | "ro" | "none";
|
1383 |
|
1384 |
|
1385 |
|
1386 | export type ArangoUser = {
|
1387 | |
1388 |
|
1389 |
|
1390 | user: string;
|
1391 | |
1392 |
|
1393 |
|
1394 | active: boolean;
|
1395 | |
1396 |
|
1397 |
|
1398 | extra: Record<string, any>;
|
1399 | };
|
1400 |
|
1401 |
|
1402 |
|
1403 | export type CreateUserOptions = {
|
1404 | |
1405 |
|
1406 |
|
1407 | user: string;
|
1408 | |
1409 |
|
1410 |
|
1411 | passwd: string;
|
1412 | |
1413 |
|
1414 |
|
1415 |
|
1416 |
|
1417 | active?: boolean;
|
1418 | |
1419 |
|
1420 |
|
1421 |
|
1422 |
|
1423 | extra?: Record<string, any>;
|
1424 | };
|
1425 |
|
1426 |
|
1427 |
|
1428 | export type UserOptions = {
|
1429 | |
1430 |
|
1431 |
|
1432 | passwd: string;
|
1433 | |
1434 |
|
1435 |
|
1436 |
|
1437 |
|
1438 | active?: boolean;
|
1439 | |
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 | extra?: Record<string, any>;
|
1445 | };
|
1446 |
|
1447 |
|
1448 |
|
1449 | export type UserAccessLevelOptions = {
|
1450 | |
1451 |
|
1452 |
|
1453 |
|
1454 |
|
1455 |
|
1456 |
|
1457 | database?: Database | string;
|
1458 | |
1459 |
|
1460 |
|
1461 | collection?: ArangoCollection | string;
|
1462 | };
|
1463 |
|
1464 |
|
1465 |
|
1466 |
|
1467 | export type QueueTimeMetrics = {
|
1468 | |
1469 |
|
1470 |
|
1471 | getLatest: () => number | undefined;
|
1472 | |
1473 |
|
1474 |
|
1475 |
|
1476 |
|
1477 | getValues: () => [number, number][];
|
1478 | |
1479 |
|
1480 |
|
1481 |
|
1482 | getAvg: () => number;
|
1483 | };
|
1484 |
|
1485 |
|
1486 |
|
1487 | export type HotBackupOptions = {
|
1488 | |
1489 |
|
1490 |
|
1491 |
|
1492 |
|
1493 |
|
1494 | allowInconsistent?: boolean;
|
1495 | |
1496 |
|
1497 |
|
1498 |
|
1499 |
|
1500 |
|
1501 |
|
1502 |
|
1503 | force?: boolean;
|
1504 | |
1505 |
|
1506 |
|
1507 |
|
1508 |
|
1509 | label?: string;
|
1510 | |
1511 |
|
1512 |
|
1513 |
|
1514 |
|
1515 |
|
1516 | timeout?: number;
|
1517 | };
|
1518 |
|
1519 |
|
1520 |
|
1521 | export type HotBackupResult = {
|
1522 | id: string;
|
1523 | potentiallyInconsistent: boolean;
|
1524 | sizeInBytes: number;
|
1525 | datetime: string;
|
1526 | nrDBServers: number;
|
1527 | nrFiles: number;
|
1528 | };
|
1529 |
|
1530 |
|
1531 |
|
1532 | export 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 |
|
1544 |
|
1545 | export declare enum LogLevel {
|
1546 | FATAL = 0,
|
1547 | ERROR = 1,
|
1548 | WARNING = 2,
|
1549 | INFO = 3,
|
1550 | DEBUG = 4
|
1551 | }
|
1552 |
|
1553 |
|
1554 |
|
1555 | export type LogLevelLabel = "FATAL" | "ERROR" | "WARNING" | "INFO" | "DEBUG";
|
1556 |
|
1557 |
|
1558 |
|
1559 | export type LogLevelSetting = LogLevelLabel | "DEFAULT";
|
1560 |
|
1561 |
|
1562 |
|
1563 | export type LogSortDirection = "asc" | "desc";
|
1564 |
|
1565 |
|
1566 |
|
1567 | export type LogEntriesOptions = {
|
1568 | |
1569 |
|
1570 |
|
1571 |
|
1572 |
|
1573 | upto?: LogLevel | LogLevelLabel | Lowercase<LogLevelLabel>;
|
1574 | |
1575 |
|
1576 |
|
1577 | level?: LogLevel | LogLevelLabel | Lowercase<LogLevelLabel>;
|
1578 | |
1579 |
|
1580 |
|
1581 |
|
1582 | start?: number;
|
1583 | |
1584 |
|
1585 |
|
1586 | size?: number;
|
1587 | |
1588 |
|
1589 |
|
1590 | offset?: number;
|
1591 | |
1592 |
|
1593 |
|
1594 | search?: string;
|
1595 | |
1596 |
|
1597 |
|
1598 |
|
1599 |
|
1600 |
|
1601 | sort?: LogSortDirection;
|
1602 | };
|
1603 |
|
1604 |
|
1605 |
|
1606 | export type LogMessage = {
|
1607 | id: number;
|
1608 | topic: string;
|
1609 | level: LogLevelLabel;
|
1610 | date: string;
|
1611 | message: string;
|
1612 | };
|
1613 |
|
1614 |
|
1615 |
|
1616 | export type LogEntries = {
|
1617 | totalAmount: number;
|
1618 | lid: number[];
|
1619 | topic: string[];
|
1620 | level: LogLevel[];
|
1621 | timestamp: number[];
|
1622 | text: string[];
|
1623 | };
|
1624 | type TrappedError = {
|
1625 | error: true;
|
1626 | };
|
1627 | type TrappedRequest = {
|
1628 | error?: false;
|
1629 | jobId: string;
|
1630 | onResolve: (res: ArangojsResponse) => void;
|
1631 | onReject: (error: any) => void;
|
1632 | };
|
1633 |
|
1634 |
|
1635 |
|
1636 |
|
1637 | export 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 |
|
1647 |
|
1648 |
|
1649 |
|
1650 |
|
1651 |
|
1652 |
|
1653 |
|
1654 |
|
1655 |
|
1656 |
|
1657 |
|
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 | *
|
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
|
1808 | * );
|
1809 | *
|
1810 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
1941 | * const newToken = await db.renewAuthToken();
|
1942 | * if (!newToken)
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
2297 | *
|
2298 | * ```
|
2299 | *
|
2300 | * @example
|
2301 | * ```js
|
2302 | * const db = new Database();
|
2303 | * const collections = await db.listCollections(false);
|
2304 | *
|
2305 | *
|
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 | *
|
2326 | *
|
2327 | * ```
|
2328 | *
|
2329 | * @example
|
2330 | * ```js
|
2331 | * const db = new Database();
|
2332 | * const collections = await db.collections(false);
|
2333 | *
|
2334 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
2634 | *
|
2635 | * ```
|
2636 | *
|
2637 | * @example
|
2638 | * ```js
|
2639 | * const db = new Database();
|
2640 | * const accessLevel = await db.getUserAccessLevel("steve", {
|
2641 | * database: "staging"
|
2642 | * });
|
2643 | *
|
2644 | *
|
2645 | * ```
|
2646 | *
|
2647 | * @example
|
2648 | * ```js
|
2649 | * const db = new Database();
|
2650 | * const accessLevel = await db.getUserAccessLevel("steve", {
|
2651 | * collection: "pokemons"
|
2652 | * });
|
2653 | *
|
2654 | *
|
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 | *
|
2665 | *
|
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 | *
|
2676 | *
|
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 | *
|
2687 | *
|
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 | *
|
2705 | * ```
|
2706 | *
|
2707 | * @example
|
2708 | * ```js
|
2709 | * const db = new Database();
|
2710 | * await db.setUserAccessLevel("steve", {
|
2711 | * database: "staging",
|
2712 | * grant: "rw"
|
2713 | * });
|
2714 | *
|
2715 | * ```
|
2716 | *
|
2717 | * @example
|
2718 | * ```js
|
2719 | * const db = new Database();
|
2720 | * await db.setUserAccessLevel("steve", {
|
2721 | * collection: "pokemons",
|
2722 | * grant: "rw"
|
2723 | * });
|
2724 | *
|
2725 | *
|
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 | *
|
2737 | *
|
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 | *
|
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 | *
|
2760 | *
|
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 | *
|
2779 | *
|
2780 | * ```
|
2781 | *
|
2782 | * @example
|
2783 | * ```js
|
2784 | * const db = new Database();
|
2785 | * await db.clearUserAccessLevel("steve", { database: "staging" });
|
2786 | *
|
2787 | *
|
2788 | * ```
|
2789 | *
|
2790 | * @example
|
2791 | * ```js
|
2792 | * const db = new Database();
|
2793 | * await db.clearUserAccessLevel("steve", { collection: "pokemons" });
|
2794 | *
|
2795 | *
|
2796 | * ```
|
2797 | *
|
2798 | * @example
|
2799 | * ```js
|
2800 | * const db = new Database();
|
2801 | * await db.clearUserAccessLevel("steve", {
|
2802 | * database: "staging",
|
2803 | * collection: "pokemons"
|
2804 | * });
|
2805 | *
|
2806 | *
|
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 | *
|
2815 | *
|
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 | *
|
2826 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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]
|
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
|
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
|
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]
|
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,
|
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,
|
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 | *
|
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 | *
|
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 | *
|
3270 | *
|
3271 | *
|
3272 | * const cursor = await db.query(aql`
|
3273 | * FOR u IN ${Users}
|
3274 | * FILTER u.authData.active == ${active}
|
3275 | * RETURN u.user
|
3276 | * `);
|
3277 | *
|
3278 | * ```
|
3279 | *
|
3280 | * @example
|
3281 | * ```js
|
3282 | * const db = new Database();
|
3283 | * const active = true;
|
3284 | * const Users = db.collection("_users");
|
3285 | *
|
3286 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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);
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
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 | *
|
4116 | * await db.setServiceDevelopmentMode("/my-service", false);
|
4117 | *
|
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 | *
|
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 | *
|
4456 | * ```
|
4457 | *
|
4458 | * @example
|
4459 | * ```js
|
4460 | * await db.commitLocalServiceState(true);
|
4461 | *
|
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 | *
|
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 | *
|
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 | *
|
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);
|
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 | *
|
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);
|
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);
|
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 | *
|
4625 | * ```
|
4626 | */
|
4627 | deleteExpiredJobResults(threshold: number): Promise<void>;
|
4628 | /**
|
4629 | * Deletes the results of all completed async jobs.
|
4630 | */
|
4631 | deleteAllJobResults(): Promise<void>;
|
4632 | }
|
4633 | export {};
|
4634 | //# sourceMappingURL=database.d.ts.map |
\ | No newline at end of file |