forked from fauna/faunadb-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.js
3498 lines (3273 loc) · 97.5 KB
/
mod.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
__markAsModule(target);
for (var name2 in all)
__defProp(target, name2, { get: all[name2], enumerable: true });
};
var __reExport = (target, module2, desc) => {
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
for (let key of __getOwnPropNames(module2))
if (!__hasOwnProp.call(target, key) && key !== "default")
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
}
return target;
};
var __toModule = (module2) => {
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
};
// node_modules/base64-js/index.js
var require_base64_js = __commonJS({
"node_modules/base64-js/index.js"(exports2) {
"use strict";
exports2.byteLength = byteLength;
exports2.toByteArray = toByteArray2;
exports2.fromByteArray = fromByteArray2;
var lookup = [];
var revLookup = [];
var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
for (i = 0, len = code.length; i < len; ++i) {
lookup[i] = code[i];
revLookup[code.charCodeAt(i)] = i;
}
var i;
var len;
revLookup["-".charCodeAt(0)] = 62;
revLookup["_".charCodeAt(0)] = 63;
function getLens(b64) {
var len2 = b64.length;
if (len2 % 4 > 0) {
throw new Error("Invalid string. Length must be a multiple of 4");
}
var validLen = b64.indexOf("=");
if (validLen === -1)
validLen = len2;
var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
return [validLen, placeHoldersLen];
}
function byteLength(b64) {
var lens = getLens(b64);
var validLen = lens[0];
var placeHoldersLen = lens[1];
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
}
function _byteLength(b64, validLen, placeHoldersLen) {
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
}
function toByteArray2(b64) {
var tmp;
var lens = getLens(b64);
var validLen = lens[0];
var placeHoldersLen = lens[1];
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
var curByte = 0;
var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
var i2;
for (i2 = 0; i2 < len2; i2 += 4) {
tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
arr[curByte++] = tmp >> 16 & 255;
arr[curByte++] = tmp >> 8 & 255;
arr[curByte++] = tmp & 255;
}
if (placeHoldersLen === 2) {
tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
arr[curByte++] = tmp & 255;
}
if (placeHoldersLen === 1) {
tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
arr[curByte++] = tmp >> 8 & 255;
arr[curByte++] = tmp & 255;
}
return arr;
}
function tripletToBase64(num) {
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
}
function encodeChunk(uint8, start, end) {
var tmp;
var output = [];
for (var i2 = start; i2 < end; i2 += 3) {
tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
output.push(tripletToBase64(tmp));
}
return output.join("");
}
function fromByteArray2(uint8) {
var tmp;
var len2 = uint8.length;
var extraBytes = len2 % 3;
var parts = [];
var maxChunkLength = 16383;
for (var i2 = 0, len22 = len2 - extraBytes; i2 < len22; i2 += maxChunkLength) {
parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
}
if (extraBytes === 1) {
tmp = uint8[len2 - 1];
parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==");
} else if (extraBytes === 2) {
tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=");
}
return parts.join("");
}
}
});
// node_modules/fn-annotate/index.js
var require_fn_annotate = __commonJS({
"node_modules/fn-annotate/index.js"(exports2, module2) {
"use strict";
module2.exports = annotate2;
function annotate2(fn) {
if (typeof fn !== "function") {
throw new Error("Could not parse function signature for injection dependencies: Object is not a function");
}
if (!fn.length)
return [];
var injects = /^()\(?([^)=]*)\)? *=>/.exec(fn + "") || /^[^(]+([^ \(]*) *\(([^\)]*)\)/.exec(fn + "");
if (!injects) {
throw new Error("Could not parse function signature for injection dependencies: " + fn + "");
}
var argumentString = injects[2].replace(/\/\*[\S\s]*?\*\//g, " ").replace(/\/\/.*/g, " ");
function groupSubArguments(_, type, keys) {
return type + keys.split(",").map(function(arg) {
return arg && arg.trim();
}).filter(Boolean).join("@");
}
argumentString = argumentString.replace(/(\{)([^}]*)\}/g, groupSubArguments);
argumentString = argumentString.replace(/(\[)([^}]*)\]/g, groupSubArguments);
return argumentString.split(",").map(function(arg) {
return arg && arg.trim();
}).map(function(arg) {
if (arg[0] === "{") {
return arg.substring(1).split("@");
}
if (arg[0] === "[") {
return { items: arg.substring(1).split("@") };
}
return arg;
}).filter(Boolean);
}
}
});
// src/query/index.js
var query_exports = {};
__export(query_exports, {
Abort: () => Abort,
Abs: () => Abs,
AccessProvider: () => AccessProvider,
AccessProviders: () => AccessProviders,
Acos: () => Acos,
Add: () => Add,
All: () => All,
And: () => And,
Any: () => Any,
Append: () => Append,
Asin: () => Asin,
At: () => At,
Atan: () => Atan,
BitAnd: () => BitAnd,
BitNot: () => BitNot,
BitOr: () => BitOr,
BitXor: () => BitXor,
Bytes: () => Bytes2,
Call: () => Call,
Casefold: () => Casefold,
Ceil: () => Ceil,
Class: () => Class_default,
Classes: () => Classes_default,
Collection: () => Collection,
Collections: () => Collections,
Concat: () => Concat,
Contains: () => Contains_default,
ContainsField: () => ContainsField,
ContainsPath: () => ContainsPath,
ContainsStr: () => ContainsStr,
ContainsStrRegex: () => ContainsStrRegex,
ContainsValue: () => ContainsValue,
Cos: () => Cos,
Cosh: () => Cosh,
Count: () => Count,
Create: () => Create,
CreateAccessProvider: () => CreateAccessProvider,
CreateClass: () => CreateClass_default,
CreateCollection: () => CreateCollection,
CreateDatabase: () => CreateDatabase,
CreateFunction: () => CreateFunction,
CreateIndex: () => CreateIndex,
CreateKey: () => CreateKey,
CreateRole: () => CreateRole,
Credentials: () => Credentials,
CurrentIdentity: () => CurrentIdentity,
CurrentToken: () => CurrentToken,
Database: () => Database,
Databases: () => Databases,
Date: () => Date2,
DayOfMonth: () => DayOfMonth,
DayOfWeek: () => DayOfWeek,
DayOfYear: () => DayOfYear,
Degrees: () => Degrees,
Delete: () => Delete,
Difference: () => Difference,
Distinct: () => Distinct,
Divide: () => Divide,
Do: () => Do,
Documents: () => Documents,
Drop: () => Drop,
EndsWith: () => EndsWith,
Epoch: () => Epoch,
Equals: () => Equals,
Events: () => Events,
Exists: () => Exists,
Exp: () => Exp,
FaunaFunction: () => FaunaFunction,
FaunaIndex: () => FaunaIndex,
FaunaObject: () => FaunaObject_default,
Filter: () => Filter,
FindStr: () => FindStr,
FindStrRegex: () => FindStrRegex,
Floor: () => Floor,
Foreach: () => Foreach,
Format: () => Format,
Functions: () => Functions,
GT: () => GT,
GTE: () => GTE,
Get: () => Get,
HasCurrentIdentity: () => HasCurrentIdentity,
HasCurrentToken: () => HasCurrentToken,
HasIdentity: () => HasIdentity_default,
Hour: () => Hour,
Hypot: () => Hypot,
Identify: () => Identify,
Identity: () => Identity_default,
If: () => If,
Indexes: () => Indexes,
Insert: () => Insert,
Intersection: () => Intersection,
IsArray: () => IsArray,
IsBoolean: () => IsBoolean,
IsBytes: () => IsBytes,
IsCollection: () => IsCollection,
IsCredentials: () => IsCredentials,
IsDatabase: () => IsDatabase,
IsDate: () => IsDate,
IsDoc: () => IsDoc,
IsDouble: () => IsDouble,
IsEmpty: () => IsEmpty,
IsFunction: () => IsFunction,
IsIndex: () => IsIndex,
IsInteger: () => IsInteger,
IsKey: () => IsKey,
IsLambda: () => IsLambda,
IsNonEmpty: () => IsNonEmpty,
IsNull: () => IsNull,
IsNumber: () => IsNumber,
IsObject: () => IsObject,
IsRef: () => IsRef,
IsRole: () => IsRole,
IsSet: () => IsSet,
IsString: () => IsString,
IsTimestamp: () => IsTimestamp,
IsToken: () => IsToken,
Join: () => Join,
KeyFromSecret: () => KeyFromSecret,
Keys: () => Keys,
LT: () => LT,
LTE: () => LTE,
LTrim: () => LTrim,
Lambda: () => Lambda,
Length: () => Length,
Let: () => Let,
Ln: () => Ln,
Log: () => Log,
Login: () => Login,
Logout: () => Logout,
LowerCase: () => LowerCase,
Map: () => Map2,
Match: () => Match,
Max: () => Max,
Mean: () => Mean,
Merge: () => Merge,
Min: () => Min,
Minute: () => Minute,
Modulo: () => Modulo,
Month: () => Month,
MoveDatabase: () => MoveDatabase,
Multiply: () => Multiply,
NGram: () => NGram,
NewId: () => NewId,
NextId: () => NextId_default,
Not: () => Not,
Now: () => Now,
Or: () => Or,
Paginate: () => Paginate,
Pow: () => Pow,
Prepend: () => Prepend,
Query: () => Query2,
RTrim: () => RTrim,
Radians: () => Radians,
Range: () => Range,
Reduce: () => Reduce,
Ref: () => Ref2,
RegexEscape: () => RegexEscape,
Remove: () => Remove,
Repeat: () => Repeat,
Replace: () => Replace,
ReplaceStr: () => ReplaceStr,
ReplaceStrRegex: () => ReplaceStrRegex,
Reverse: () => Reverse,
Role: () => Role,
Roles: () => Roles,
Round: () => Round,
Second: () => Second,
Select: () => Select,
SelectAll: () => SelectAll_default,
Sign: () => Sign,
Sin: () => Sin,
Singleton: () => Singleton,
Sinh: () => Sinh,
Space: () => Space,
Sqrt: () => Sqrt,
StartsWith: () => StartsWith,
SubString: () => SubString,
Subtract: () => Subtract,
Sum: () => Sum,
Take: () => Take,
Tan: () => Tan,
Tanh: () => Tanh,
Time: () => Time,
TimeAdd: () => TimeAdd,
TimeDiff: () => TimeDiff,
TimeSubtract: () => TimeSubtract,
TitleCase: () => TitleCase,
ToArray: () => ToArray,
ToDate: () => ToDate,
ToDouble: () => ToDouble,
ToInteger: () => ToInteger,
ToMicros: () => ToMicros,
ToMillis: () => ToMillis,
ToNumber: () => ToNumber,
ToObject: () => ToObject,
ToSeconds: () => ToSeconds,
ToString: () => ToString,
ToTime: () => ToTime,
Tokens: () => Tokens,
Trim: () => Trim,
Trunc: () => Trunc,
Union: () => Union,
Update: () => Update,
UpperCase: () => UpperCase,
Var: () => Var,
Year: () => Year
});
// package.json
var name = "@yacinehmito/faunadb";
var version = "5.0.0-deno-alpha9";
var apiVersion = "5";
var description = "FaunaDB Javascript driver for Node.JS and Browsers";
var homepage = "https://fauna.com";
var repository = "fauna/faunadb-js";
var license = "MPL-2.0";
var keywords = [
"database",
"fauna",
"official",
"driver"
];
var bugs = {
url: "https://github.com/fauna/faunadb-js/issues"
};
var files = [
"index.d.ts",
"src/",
"dist/",
"cjs/",
"esm5/",
"query/",
"tools/printReleaseNotes.js"
];
var main = "./cjs/index.js";
var module = "./esm5/index.js";
var es2015 = "./src/index.js";
var exports = {
".": {
require: "./cjs/index.js",
import: "./esm5/index.js"
},
"./stream": {
require: "./cjs/stream.js",
import: "./esm5/stream.js"
},
"./query": {
require: "./cjs/query/index.js",
import: "./esm5/query/index.js"
},
"./query/": {
require: "./cjs/query/",
import: "./esm5/query/"
},
"./query/*": {
require: "./cjs/query/*.js",
import: "./esm5/query/*.js"
}
};
var scripts = {
doc: "jsdoc -c ./jsdoc.json",
prettify: 'prettier --write "{src,test}/**/*.{js,ts}"',
test: "jest --env=node --testTimeout 200000 --verbose=true --forceExit --runInBand ./test",
"bundle:analyze": "webpack --env analyze",
"bundle:stats": "webpack --env analyze --env stats",
"bundle:diff": "node tools/bundleDiff.js",
"build:clean": "shx rm -rf ./dist ./cjs ./esm5 ./query ./mod.js ./mod.d.ts",
"build:browser": "webpack",
"build:cjs": "cross-env BABEL_ENV=cjs npx babel src -d ./cjs",
"build:esm5": "cross-env BABEL_ENV=esm npx babel src -d ./esm5",
"build:package": "npm-run-all build:clean build:deno",
"build:deno": "esbuild --bundle src/index.js --outfile=mod.js --platform=neutral --format=esm --target=esnext && api-extractor run",
"postbuild:package": "node tools/postBuildPackage.js",
posttest: "node ./test/afterComplete",
"semantic-release": "semantic-release",
wp: "webpack",
"load-test": "node ./tools/loadTest"
};
var types = "index.d.ts";
var dependencies = {
"core-js": "^3.9.1",
"base64-js": "^1.2.0",
dotenv: "^8.2.0",
"fn-annotate": "^1.1.3",
"object-assign": "^4.1.0"
};
var devDependencies = {
"@actions/core": "^1.2.6",
"@actions/github": "^4.0.0",
"@babel/cli": "^7.13.10",
"@babel/core": "^7.13.10",
"@babel/preset-env": "^7.13.10",
"@microsoft/api-extractor": "^7.18.19",
"babel-loader": "^8.2.2",
"cross-env": "^7.0.3",
esbuild: "^0.13.13",
"ansi-regex": ">=5.0.1",
eslint: "^5.3.0",
"eslint-config-prettier": "^6.5.0",
"eslint-plugin-prettier": "^3.1.1",
husky: "^7.0.4",
"ink-docstrap": "^1.2.1",
jest: "^27.4.7",
jsdoc: "^3.6.10",
"json-schema": ">=0.4.0",
"lint-staged": ">=8",
marked: ">=4.0.10",
"modify-source-webpack-plugin": "^1.1.0-beta.3",
"npm-run-all": "^4.1.5",
prettier: "1.18.2",
"semantic-release": "^19.0.3",
shx: "^0.3.3",
terser: "^4.3.9",
webpack: "^5.23.0",
"webpack-bundle-analyzer": "^4.4.0",
"webpack-bundle-diff": "^1.0.0",
"webpack-cli": "^4.5.0",
yargs: "^16.2.0"
};
var lint_staged = {
"*.{js,css,json,md}": [
"prettier --write",
"git add"
],
"*.js": [
"eslint --fix",
"git add"
]
};
var release = {
branches: [
"main"
]
};
var browser = {
http2: false,
http: false,
https: false,
os: false
};
var jest = {
transform: {
"^.+\\.js$": "babel-jest"
}
};
var volta = {
node: "16.13.0",
npm: "8.1.3"
};
var package_default = {
name,
version,
apiVersion,
description,
homepage,
repository,
license,
keywords,
bugs,
files,
main,
module,
es2015,
exports,
scripts,
types,
dependencies,
devDependencies,
"lint-staged": lint_staged,
release,
browser,
jest,
volta
};
// src/_util.js
"use strict";
function inherits(ctor, superCtor) {
if (ctor === void 0 || ctor === null) {
throw new TypeError('The constructor to "inherits" must not be null or undefined');
}
if (superCtor === void 0 || superCtor === null) {
throw new TypeError('The super constructor to "inherits" must not be null or undefined');
}
if (superCtor.prototype === void 0) {
throw new TypeError('The super constructor to "inherits" must have a prototype');
}
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
}
function getEnvVariable(envKey) {
var areEnvVarsAvailable = !!(typeof process !== "undefined" && process && process.env);
if (areEnvVarsAvailable && process.env[envKey] != null) {
return process.env[envKey];
}
}
function getBrowserDetails() {
var browser2 = navigator.appName;
var browserVersion = "" + parseFloat(navigator.appVersion);
var nameOffset, verOffset, ix;
if ((verOffset = navigator.userAgent.indexOf("Opera")) != -1) {
browser2 = "Opera";
browserVersion = navigator.userAgent.substring(verOffset + 6);
if ((verOffset = navigator.userAgent.indexOf("Version")) != -1) {
browserVersion = navigator.userAgent.substring(verOffset + 8);
}
} else if ((verOffset = navigator.userAgent.indexOf("MSIE")) != -1) {
browser2 = "Microsoft Internet Explorer";
browserVersion = navigator.userAgent.substring(verOffset + 5);
} else if (browser2 == "Netscape" && navigator.userAgent.indexOf("Trident/") != -1) {
browser2 = "Microsoft Internet Explorer";
browserVersion = navigator.userAgent.substring(verOffset + 5);
if ((verOffset = navigator.userAgent.indexOf("rv:")) != -1) {
browserVersion = navigator.userAgent.substring(verOffset + 3);
}
} else if ((verOffset = navigator.userAgent.indexOf("Chrome")) != -1) {
browser2 = "Chrome";
browserVersion = navigator.userAgent.substring(verOffset + 7);
} else if ((verOffset = navigator.userAgent.indexOf("Safari")) != -1) {
browser2 = "Safari";
browserVersion = navigator.userAgent.substring(verOffset + 7);
if ((verOffset = navigator.userAgent.indexOf("Version")) != -1) {
browserVersion = navigator.userAgent.substring(verOffset + 8);
}
if (navigator.userAgent.indexOf("CriOS") != -1) {
browser2 = "Chrome";
}
} else if ((verOffset = navigator.userAgent.indexOf("Firefox")) != -1) {
browser2 = "Firefox";
browserVersion = navigator.userAgent.substring(verOffset + 8);
} else if ((nameOffset = navigator.userAgent.lastIndexOf(" ") + 1) < (verOffset = navigator.userAgent.lastIndexOf("/"))) {
browser2 = navigator.userAgent.substring(nameOffset, verOffset);
browserVersion = navigator.userAgent.substring(verOffset + 1);
if (browser2.toLowerCase() == browser2.toUpperCase()) {
browser2 = navigator.appName;
}
}
if ((ix = browserVersion.indexOf(";")) != -1)
browserVersion = browserVersion.substring(0, ix);
if ((ix = browserVersion.indexOf(" ")) != -1)
browserVersion = browserVersion.substring(0, ix);
if ((ix = browserVersion.indexOf(")")) != -1)
browserVersion = browserVersion.substring(0, ix);
return [browser2, browserVersion].join("-");
}
function getBrowserOsDetails() {
var os = "unknown";
var clientStrings = [
{ s: "Windows 10", r: /(Windows 10.0|Windows NT 10.0)/ },
{ s: "Windows 8.1", r: /(Windows 8.1|Windows NT 6.3)/ },
{ s: "Windows 8", r: /(Windows 8|Windows NT 6.2)/ },
{ s: "Windows 7", r: /(Windows 7|Windows NT 6.1)/ },
{ s: "Windows Vista", r: /Windows NT 6.0/ },
{ s: "Windows Server 2003", r: /Windows NT 5.2/ },
{ s: "Windows XP", r: /(Windows NT 5.1|Windows XP)/ },
{ s: "Windows 2000", r: /(Windows NT 5.0|Windows 2000)/ },
{ s: "Windows ME", r: /(Win 9x 4.90|Windows ME)/ },
{ s: "Windows 98", r: /(Windows 98|Win98)/ },
{ s: "Windows 95", r: /(Windows 95|Win95|Windows_95)/ },
{ s: "Windows NT 4.0", r: /(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/ },
{ s: "Windows CE", r: /Windows CE/ },
{ s: "Windows 3.11", r: /Win16/ },
{ s: "Android", r: /Android/ },
{ s: "Open BSD", r: /OpenBSD/ },
{ s: "Sun OS", r: /SunOS/ },
{ s: "Chrome OS", r: /CrOS/ },
{ s: "Linux", r: /(Linux|X11(?!.*CrOS))/ },
{ s: "iOS", r: /(iPhone|iPad|iPod)/ },
{ s: "Mac OS X", r: /Mac OS X/ },
{ s: "Mac OS", r: /(Mac OS|MacPPC|MacIntel|Mac_PowerPC|Macintosh)/ },
{ s: "QNX", r: /QNX/ },
{ s: "UNIX", r: /UNIX/ },
{ s: "BeOS", r: /BeOS/ },
{ s: "OS/2", r: /OS\/2/ },
{
s: "Search Bot",
r: /(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/
}
];
for (var id in clientStrings) {
var cs = clientStrings[id];
if (cs.r.test(navigator.userAgent)) {
os = cs.s;
break;
}
}
var osVersion = "unknown";
if (/Windows/.test(os)) {
osVersion = /Windows (.*)/.exec(os)[1];
os = "Windows";
}
switch (os) {
case "Mac OS":
case "Mac OS X":
case "Android":
osVersion = /(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([\.\_\d]+)/.exec(navigator.userAgent)[1];
break;
case "iOS":
osVersion = /OS (\d+)_(\d+)_?(\d+)?/.exec(navigator.appVersion);
osVersion = osVersion[1] + "." + osVersion[2] + "." + (osVersion[3] | 0);
break;
}
return [os, osVersion].join("-");
}
function defaults(obj, def) {
if (obj === void 0) {
return def;
} else {
return obj;
}
}
function applyDefaults(provided, defaults2) {
var out = {};
for (var providedKey in provided) {
if (!(providedKey in defaults2)) {
throw new Error("No such option " + providedKey);
}
out[providedKey] = provided[providedKey];
}
for (var defaultsKey in defaults2) {
if (!(defaultsKey in out)) {
out[defaultsKey] = defaults2[defaultsKey];
}
}
return out;
}
function removeNullAndUndefinedValues(object) {
var res = {};
for (var key in object) {
var val = object[key];
if (val !== null && val !== void 0) {
res[key] = val;
}
}
return res;
}
function removeUndefinedValues(object) {
var res = {};
for (var key in object) {
var val = object[key];
if (val !== void 0) {
res[key] = val;
}
}
return res;
}
function checkInstanceHasProperty(obj, prop) {
return typeof obj === "object" && obj !== null && Boolean(obj[prop]);
}
function formatUrl(base, path, query) {
query = typeof query === "object" ? querystringify(query) : query;
return [
base,
path ? path.charAt(0) === "/" ? "" : "/" + path : "",
query ? query.charAt(0) === "?" ? "" : "?" + query : ""
].join("");
}
function querystringify(obj, prefix) {
prefix = prefix || "";
var pairs = [], value, key;
if (typeof prefix !== "string")
prefix = "?";
for (key in obj) {
if (checkInstanceHasProperty(obj, key)) {
value = obj[key];
if (!value && (value === null || value === void 0 || isNaN(value))) {
value = "";
}
key = encode(key);
value = encode(value);
if (key === null || value === null)
continue;
pairs.push(key + "=" + value);
}
}
return pairs.length ? prefix + pairs.join("&") : "";
}
function encode(input) {
try {
return encodeURIComponent(input);
} catch (e) {
return null;
}
}
function notifyAboutNewVersion() {
const checkAndNotify = () => {
return;
};
return checkAndNotify;
}
// src/Expr.js
"use strict";
function Expr(obj) {
this.raw = obj;
}
Expr.prototype._isFaunaExpr = true;
Expr.prototype.toJSON = function() {
return this.raw;
};
Expr.prototype.toFQL = function() {
return exprToString(this.raw);
};
var varArgsFunctions = [
"Do",
"Call",
"Union",
"Intersection",
"Difference",
"Equals",
"Add",
"BitAnd",
"BitOr",
"BitXor",
"Divide",
"Max",
"Min",
"Modulo",
"Multiply",
"Subtract",
"LT",
"LTE",
"GT",
"GTE",
"And",
"Or"
];
var specialCases = {
containsstrregex: "ContainsStrRegex",
containsstr: "ContainsStr",
endswith: "EndsWith",
findstr: "FindStr",
findstrregex: "FindStrRegex",
gt: "GT",
gte: "GTE",
is_nonempty: "is_non_empty",
lowercase: "LowerCase",
lt: "LT",
lte: "LTE",
ltrim: "LTrim",
ngram: "NGram",
rtrim: "RTrim",
regexescape: "RegexEscape",
replacestr: "ReplaceStr",
replacestrregex: "ReplaceStrRegex",
startswith: "StartsWith",
substring: "SubString",
titlecase: "TitleCase",
uppercase: "UpperCase"
};
function isExpr(expression) {
return expression instanceof Expr || checkInstanceHasProperty(expression, "_isFaunaExpr");
}
function printObject(obj) {
return "{" + Object.keys(obj).map(function(k) {
return '"' + k + '": ' + exprToString(obj[k]);
}).join(", ") + "}";
}
function printArray(arr, toStr) {
return arr.map(function(item) {
return toStr(item);
}).join(", ");
}
function convertToCamelCase(fn) {
if (fn in specialCases)
fn = specialCases[fn];
return fn.split("_").map(function(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}).join("");
}
var exprToString = function(expr, caller) {
if (isExpr(expr)) {
if ("value" in expr)
return expr.toString();
expr = expr.raw;
}
if (expr === null) {
return "null";
}
switch (typeof expr) {
case "string":
return JSON.stringify(expr);
case "symbol":
case "number":
case "boolean":
return expr.toString();
case "undefined":
return "undefined";
}
if (Array.isArray(expr)) {
var array = printArray(expr, exprToString);
return varArgsFunctions.indexOf(caller) != -1 ? array : "[" + array + "]";
}
if ("match" in expr) {
var matchStr = exprToString(expr["match"]);
var terms = expr["terms"] || [];
if (isExpr(terms))
terms = terms.raw;
if (Array.isArray(terms) && terms.length == 0)
return "Match(" + matchStr + ")";
if (Array.isArray(terms)) {
return "Match(" + matchStr + ", [" + printArray(terms, exprToString) + "])";
}
return "Match(" + matchStr + ", " + exprToString(terms) + ")";
}
if ("paginate" in expr) {
var exprKeys = Object.keys(expr);
if (exprKeys.length === 1) {
return "Paginate(" + exprToString(expr["paginate"]) + ")";
}
var expr2 = Object.assign({}, expr);
delete expr2["paginate"];
return "Paginate(" + exprToString(expr["paginate"]) + ", " + printObject(expr2) + ")";
}
if ("let" in expr && "in" in expr) {
var letExpr = "";
if (Array.isArray(expr["let"]))
letExpr = "[" + printArray(expr["let"], printObject) + "]";
else
letExpr = printObject(expr["let"]);
return "Let(" + letExpr + ", " + exprToString(expr["in"]) + ")";
}
if ("object" in expr)
return printObject(expr["object"]);
if ("merge" in expr) {
if (expr.lambda) {
return "Merge(" + exprToString(expr.merge) + ", " + exprToString(expr.with) + ", " + exprToString(expr.lambda) + ")";
}
return "Merge(" + exprToString(expr.merge) + ", " + exprToString(expr.with) + ")";
}
if ("lambda" in expr) {
return "Lambda(" + exprToString(expr["lambda"]) + ", " + exprToString(expr["expr"]) + ")";
}
if ("filter" in expr) {
return "Filter(" + exprToString(expr["collection"]) + ", " + exprToString(expr["filter"]) + ")";
}
if ("call" in expr) {
return "Call(" + exprToString(expr["call"]) + ", " + exprToString(expr["arguments"]) + ")";
}
if ("map" in expr) {
return "Map(" + exprToString(expr["collection"]) + ", " + exprToString(expr["map"]) + ")";
}
if ("foreach" in expr) {
return "Foreach(" + exprToString(expr["collection"]) + ", " + exprToString(expr["foreach"]) + ")";
}
var keys = Object.keys(expr);
var fn = keys[0];
fn = convertToCamelCase(fn);
var args = keys.filter((k) => expr[k] !== null || keys.length > 1).map((k) => exprToString(expr[k], fn)).join(", ");
return fn + "(" + args + ")";
};
Expr.toString = exprToString;
// src/errors.js
"use strict";
function FaunaError(name2, message, description2) {
Error.call(this);
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
} else
this.stack = new Error().stack;
this.name = name2;
this.message = message;
this.description = description2;
}
inherits(FaunaError, Error);
function InvalidValue(message) {
FaunaError.call(this, "InvalidValue", message);
}
inherits(InvalidValue, FaunaError);
function InvalidArity(min, max, actual, callerFunc) {
var arityInfo = `${callerFunc} function requires ${messageForArity(min, max)} argument(s) but ${actual} were given`;
var documentationLink = logDocumentationLink(callerFunc);
FaunaError.call(this, "InvalidArity", `${arityInfo}
${documentationLink}`);
this.min = min;
this.max = max;
this.actual = actual;
function messageForArity(min2, max2) {
if (max2 === null)
return "at least " + min2;
if (min2 === null)
return "up to " + max2;
if (min2 === max2)
return min2;
return "from " + min2 + " to " + max2;
}
function logDocumentationLink(functionName) {
var docsURL = "https://docs.fauna.com/fauna/current/api/fql/functions/";
return `For more info, see the docs: ${docsURL}${functionName.toLowerCase()}`;
}
}
inherits(InvalidArity, FaunaError);
function FaunaHTTPError(name2, requestResult) {
var response = requestResult.responseContent;
var errors = response.errors;
var message = errors.length === 0 ? '(empty "errors")' : errors[0].code;
var description2 = errors.length === 0 ? '(empty "errors")' : errors[0].description;
FaunaError.call(this, name2, message, description2);
this.requestResult = requestResult;
this.code = this.errors()[0].code;
this.position = this.errors()[0].position || [];
this.httpStatusCode = requestResult.statusCode;
}
inherits(FaunaHTTPError, FaunaError);
FaunaHTTPError.prototype.errors = function() {
return this.requestResult.responseContent.errors;
};
FaunaHTTPError.raiseForStatusCode = function(requestResult) {
var code = requestResult.statusCode;
if (code < 200 || code >= 300) {
switch (code) {
case 400:
throw getQueryError(requestResult);
case 401:
throw new Unauthorized(requestResult);
case 403:
throw new PermissionDenied(requestResult);
case 404:
throw new NotFound(requestResult);
case 405:
throw new MethodNotAllowed(requestResult);
case 409:
throw new Conflict(requestResult);
case 413:
throw new PayloadTooLarge(requestResult);
case 429: