@concavejs/docstore-bun-sqlite 0.0.1-alpha.7 → 0.0.1-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +766 -802
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
// src/sqlite-docstore.ts
|
|
3
|
-
import { Database } from "bun:sqlite";
|
|
4
|
-
|
|
5
|
-
// ../docstore-sqlite-base/dist/index.js
|
|
6
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
7
|
-
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
8
2
|
var __defProp = Object.defineProperty;
|
|
9
3
|
var __export = (target, all) => {
|
|
10
4
|
for (var name in all)
|
|
@@ -16,6 +10,9 @@ var __export = (target, all) => {
|
|
|
16
10
|
});
|
|
17
11
|
};
|
|
18
12
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
13
|
+
var __require = import.meta.require;
|
|
14
|
+
|
|
15
|
+
// ../../node_modules/convex/dist/esm/values/base64.js
|
|
19
16
|
function getLens(b64) {
|
|
20
17
|
var len2 = b64.length;
|
|
21
18
|
if (len2 % 4 > 0) {
|
|
@@ -86,12 +83,7 @@ function fromByteArray(uint8) {
|
|
|
86
83
|
}
|
|
87
84
|
return parts.join("");
|
|
88
85
|
}
|
|
89
|
-
var lookup;
|
|
90
|
-
var revLookup;
|
|
91
|
-
var Arr;
|
|
92
|
-
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
93
|
-
var i;
|
|
94
|
-
var len;
|
|
86
|
+
var lookup, revLookup, Arr, code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", i, len;
|
|
95
87
|
var init_base64 = __esm(() => {
|
|
96
88
|
lookup = [];
|
|
97
89
|
revLookup = [];
|
|
@@ -103,6 +95,8 @@ var init_base64 = __esm(() => {
|
|
|
103
95
|
revLookup[45] = 62;
|
|
104
96
|
revLookup[95] = 63;
|
|
105
97
|
});
|
|
98
|
+
|
|
99
|
+
// ../../node_modules/convex/dist/esm/common/index.js
|
|
106
100
|
function parseArgs(args) {
|
|
107
101
|
if (args === undefined) {
|
|
108
102
|
return {};
|
|
@@ -118,6 +112,8 @@ function isSimpleObject(value) {
|
|
|
118
112
|
const isSimple = prototype === null || prototype === Object.prototype || prototype?.constructor?.name === "Object";
|
|
119
113
|
return isObject && isSimple;
|
|
120
114
|
}
|
|
115
|
+
|
|
116
|
+
// ../../node_modules/convex/dist/esm/values/value.js
|
|
121
117
|
function isSpecial(n) {
|
|
122
118
|
return Number.isNaN(n) || !Number.isFinite(n) || Object.is(n, -0);
|
|
123
119
|
}
|
|
@@ -352,16 +348,7 @@ function convexOrUndefinedToJson(value) {
|
|
|
352
348
|
function patchValueToJson(value) {
|
|
353
349
|
return convexToJsonInternal(value, value, "", true);
|
|
354
350
|
}
|
|
355
|
-
var LITTLE_ENDIAN = true;
|
|
356
|
-
var MIN_INT64;
|
|
357
|
-
var MAX_INT64;
|
|
358
|
-
var ZERO;
|
|
359
|
-
var EIGHT;
|
|
360
|
-
var TWOFIFTYSIX;
|
|
361
|
-
var bigIntToBase64;
|
|
362
|
-
var base64ToBigInt;
|
|
363
|
-
var MAX_IDENTIFIER_LEN = 1024;
|
|
364
|
-
var MAX_VALUE_FOR_ERROR_LEN = 16384;
|
|
351
|
+
var LITTLE_ENDIAN = true, MIN_INT64, MAX_INT64, ZERO, EIGHT, TWOFIFTYSIX, bigIntToBase64, base64ToBigInt, MAX_IDENTIFIER_LEN = 1024, MAX_VALUE_FOR_ERROR_LEN = 16384;
|
|
365
352
|
var init_value = __esm(() => {
|
|
366
353
|
init_base64();
|
|
367
354
|
MIN_INT64 = BigInt("-9223372036854775808");
|
|
@@ -372,6 +359,8 @@ var init_value = __esm(() => {
|
|
|
372
359
|
bigIntToBase64 = DataView.prototype.setBigInt64 ? modernBigIntToBase64 : slowBigIntToBase64;
|
|
373
360
|
base64ToBigInt = DataView.prototype.getBigInt64 ? modernBase64ToBigInt : slowBase64ToBigInt;
|
|
374
361
|
});
|
|
362
|
+
|
|
363
|
+
// ../../node_modules/convex/dist/esm/values/validators.js
|
|
375
364
|
function throwUndefinedValidatorError(context, fieldName) {
|
|
376
365
|
const fieldInfo = fieldName !== undefined ? ` for field "${fieldName}"` : "";
|
|
377
366
|
throw new Error(`A validator is undefined${fieldInfo} in ${context}. This is often caused by circular imports. See ${UNDEFINED_VALIDATOR_ERROR_URL} for details.`);
|
|
@@ -387,27 +376,11 @@ class BaseValidator {
|
|
|
387
376
|
this.isConvexValidator = true;
|
|
388
377
|
}
|
|
389
378
|
}
|
|
390
|
-
var __defProp2;
|
|
391
|
-
var __defNormalProp = (obj, key, value) => (key in obj) ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
392
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
393
|
-
var UNDEFINED_VALIDATOR_ERROR_URL = "https://docs.convex.dev/error#undefined-validator";
|
|
394
|
-
var VId;
|
|
395
|
-
var VFloat64;
|
|
396
|
-
var VInt64;
|
|
397
|
-
var VBoolean;
|
|
398
|
-
var VBytes;
|
|
399
|
-
var VString;
|
|
400
|
-
var VNull;
|
|
401
|
-
var VAny;
|
|
402
|
-
var VObject;
|
|
403
|
-
var VLiteral;
|
|
404
|
-
var VArray;
|
|
405
|
-
var VRecord;
|
|
406
|
-
var VUnion;
|
|
379
|
+
var __defProp2, __defNormalProp = (obj, key, value) => (key in obj) ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value), UNDEFINED_VALIDATOR_ERROR_URL = "https://docs.convex.dev/error#undefined-validator", VId, VFloat64, VInt64, VBoolean, VBytes, VString, VNull, VAny, VObject, VLiteral, VArray, VRecord, VUnion;
|
|
407
380
|
var init_validators = __esm(() => {
|
|
408
381
|
init_value();
|
|
409
382
|
__defProp2 = Object.defineProperty;
|
|
410
|
-
VId = class
|
|
383
|
+
VId = class VId extends BaseValidator {
|
|
411
384
|
constructor({
|
|
412
385
|
isOptional,
|
|
413
386
|
tableName
|
|
@@ -424,13 +397,13 @@ var init_validators = __esm(() => {
|
|
|
424
397
|
return { type: "id", tableName: this.tableName };
|
|
425
398
|
}
|
|
426
399
|
asOptional() {
|
|
427
|
-
return new
|
|
400
|
+
return new VId({
|
|
428
401
|
isOptional: "optional",
|
|
429
402
|
tableName: this.tableName
|
|
430
403
|
});
|
|
431
404
|
}
|
|
432
405
|
};
|
|
433
|
-
VFloat64 = class
|
|
406
|
+
VFloat64 = class VFloat64 extends BaseValidator {
|
|
434
407
|
constructor() {
|
|
435
408
|
super(...arguments);
|
|
436
409
|
__publicField(this, "kind", "float64");
|
|
@@ -439,12 +412,12 @@ var init_validators = __esm(() => {
|
|
|
439
412
|
return { type: "number" };
|
|
440
413
|
}
|
|
441
414
|
asOptional() {
|
|
442
|
-
return new
|
|
415
|
+
return new VFloat64({
|
|
443
416
|
isOptional: "optional"
|
|
444
417
|
});
|
|
445
418
|
}
|
|
446
419
|
};
|
|
447
|
-
VInt64 = class
|
|
420
|
+
VInt64 = class VInt64 extends BaseValidator {
|
|
448
421
|
constructor() {
|
|
449
422
|
super(...arguments);
|
|
450
423
|
__publicField(this, "kind", "int64");
|
|
@@ -453,10 +426,10 @@ var init_validators = __esm(() => {
|
|
|
453
426
|
return { type: "bigint" };
|
|
454
427
|
}
|
|
455
428
|
asOptional() {
|
|
456
|
-
return new
|
|
429
|
+
return new VInt64({ isOptional: "optional" });
|
|
457
430
|
}
|
|
458
431
|
};
|
|
459
|
-
VBoolean = class
|
|
432
|
+
VBoolean = class VBoolean extends BaseValidator {
|
|
460
433
|
constructor() {
|
|
461
434
|
super(...arguments);
|
|
462
435
|
__publicField(this, "kind", "boolean");
|
|
@@ -465,12 +438,12 @@ var init_validators = __esm(() => {
|
|
|
465
438
|
return { type: this.kind };
|
|
466
439
|
}
|
|
467
440
|
asOptional() {
|
|
468
|
-
return new
|
|
441
|
+
return new VBoolean({
|
|
469
442
|
isOptional: "optional"
|
|
470
443
|
});
|
|
471
444
|
}
|
|
472
445
|
};
|
|
473
|
-
VBytes = class
|
|
446
|
+
VBytes = class VBytes extends BaseValidator {
|
|
474
447
|
constructor() {
|
|
475
448
|
super(...arguments);
|
|
476
449
|
__publicField(this, "kind", "bytes");
|
|
@@ -479,10 +452,10 @@ var init_validators = __esm(() => {
|
|
|
479
452
|
return { type: this.kind };
|
|
480
453
|
}
|
|
481
454
|
asOptional() {
|
|
482
|
-
return new
|
|
455
|
+
return new VBytes({ isOptional: "optional" });
|
|
483
456
|
}
|
|
484
457
|
};
|
|
485
|
-
VString = class
|
|
458
|
+
VString = class VString extends BaseValidator {
|
|
486
459
|
constructor() {
|
|
487
460
|
super(...arguments);
|
|
488
461
|
__publicField(this, "kind", "string");
|
|
@@ -491,12 +464,12 @@ var init_validators = __esm(() => {
|
|
|
491
464
|
return { type: this.kind };
|
|
492
465
|
}
|
|
493
466
|
asOptional() {
|
|
494
|
-
return new
|
|
467
|
+
return new VString({
|
|
495
468
|
isOptional: "optional"
|
|
496
469
|
});
|
|
497
470
|
}
|
|
498
471
|
};
|
|
499
|
-
VNull = class
|
|
472
|
+
VNull = class VNull extends BaseValidator {
|
|
500
473
|
constructor() {
|
|
501
474
|
super(...arguments);
|
|
502
475
|
__publicField(this, "kind", "null");
|
|
@@ -505,10 +478,10 @@ var init_validators = __esm(() => {
|
|
|
505
478
|
return { type: this.kind };
|
|
506
479
|
}
|
|
507
480
|
asOptional() {
|
|
508
|
-
return new
|
|
481
|
+
return new VNull({ isOptional: "optional" });
|
|
509
482
|
}
|
|
510
483
|
};
|
|
511
|
-
VAny = class
|
|
484
|
+
VAny = class VAny extends BaseValidator {
|
|
512
485
|
constructor() {
|
|
513
486
|
super(...arguments);
|
|
514
487
|
__publicField(this, "kind", "any");
|
|
@@ -519,12 +492,12 @@ var init_validators = __esm(() => {
|
|
|
519
492
|
};
|
|
520
493
|
}
|
|
521
494
|
asOptional() {
|
|
522
|
-
return new
|
|
495
|
+
return new VAny({
|
|
523
496
|
isOptional: "optional"
|
|
524
497
|
});
|
|
525
498
|
}
|
|
526
499
|
};
|
|
527
|
-
VObject = class
|
|
500
|
+
VObject = class VObject extends BaseValidator {
|
|
528
501
|
constructor({
|
|
529
502
|
isOptional,
|
|
530
503
|
fields
|
|
@@ -555,7 +528,7 @@ var init_validators = __esm(() => {
|
|
|
555
528
|
};
|
|
556
529
|
}
|
|
557
530
|
asOptional() {
|
|
558
|
-
return new
|
|
531
|
+
return new VObject({
|
|
559
532
|
isOptional: "optional",
|
|
560
533
|
fields: this.fields
|
|
561
534
|
});
|
|
@@ -565,7 +538,7 @@ var init_validators = __esm(() => {
|
|
|
565
538
|
for (const field of fields) {
|
|
566
539
|
delete newFields[field];
|
|
567
540
|
}
|
|
568
|
-
return new
|
|
541
|
+
return new VObject({
|
|
569
542
|
isOptional: this.isOptional,
|
|
570
543
|
fields: newFields
|
|
571
544
|
});
|
|
@@ -575,7 +548,7 @@ var init_validators = __esm(() => {
|
|
|
575
548
|
for (const field of fields) {
|
|
576
549
|
newFields[field] = this.fields[field];
|
|
577
550
|
}
|
|
578
|
-
return new
|
|
551
|
+
return new VObject({
|
|
579
552
|
isOptional: this.isOptional,
|
|
580
553
|
fields: newFields
|
|
581
554
|
});
|
|
@@ -585,19 +558,19 @@ var init_validators = __esm(() => {
|
|
|
585
558
|
for (const [key, validator] of globalThis.Object.entries(this.fields)) {
|
|
586
559
|
newFields[key] = validator.asOptional();
|
|
587
560
|
}
|
|
588
|
-
return new
|
|
561
|
+
return new VObject({
|
|
589
562
|
isOptional: this.isOptional,
|
|
590
563
|
fields: newFields
|
|
591
564
|
});
|
|
592
565
|
}
|
|
593
566
|
extend(fields) {
|
|
594
|
-
return new
|
|
567
|
+
return new VObject({
|
|
595
568
|
isOptional: this.isOptional,
|
|
596
569
|
fields: { ...this.fields, ...fields }
|
|
597
570
|
});
|
|
598
571
|
}
|
|
599
572
|
};
|
|
600
|
-
VLiteral = class
|
|
573
|
+
VLiteral = class VLiteral extends BaseValidator {
|
|
601
574
|
constructor({ isOptional, value }) {
|
|
602
575
|
super({ isOptional });
|
|
603
576
|
__publicField(this, "value");
|
|
@@ -614,13 +587,13 @@ var init_validators = __esm(() => {
|
|
|
614
587
|
};
|
|
615
588
|
}
|
|
616
589
|
asOptional() {
|
|
617
|
-
return new
|
|
590
|
+
return new VLiteral({
|
|
618
591
|
isOptional: "optional",
|
|
619
592
|
value: this.value
|
|
620
593
|
});
|
|
621
594
|
}
|
|
622
595
|
};
|
|
623
|
-
VArray = class
|
|
596
|
+
VArray = class VArray extends BaseValidator {
|
|
624
597
|
constructor({
|
|
625
598
|
isOptional,
|
|
626
599
|
element
|
|
@@ -640,13 +613,13 @@ var init_validators = __esm(() => {
|
|
|
640
613
|
};
|
|
641
614
|
}
|
|
642
615
|
asOptional() {
|
|
643
|
-
return new
|
|
616
|
+
return new VArray({
|
|
644
617
|
isOptional: "optional",
|
|
645
618
|
element: this.element
|
|
646
619
|
});
|
|
647
620
|
}
|
|
648
621
|
};
|
|
649
|
-
VRecord = class
|
|
622
|
+
VRecord = class VRecord extends BaseValidator {
|
|
650
623
|
constructor({
|
|
651
624
|
isOptional,
|
|
652
625
|
key,
|
|
@@ -685,14 +658,14 @@ var init_validators = __esm(() => {
|
|
|
685
658
|
};
|
|
686
659
|
}
|
|
687
660
|
asOptional() {
|
|
688
|
-
return new
|
|
661
|
+
return new VRecord({
|
|
689
662
|
isOptional: "optional",
|
|
690
663
|
key: this.key,
|
|
691
664
|
value: this.value
|
|
692
665
|
});
|
|
693
666
|
}
|
|
694
667
|
};
|
|
695
|
-
VUnion = class
|
|
668
|
+
VUnion = class VUnion extends BaseValidator {
|
|
696
669
|
constructor({ isOptional, members }) {
|
|
697
670
|
super({ isOptional });
|
|
698
671
|
__publicField(this, "members");
|
|
@@ -714,13 +687,15 @@ var init_validators = __esm(() => {
|
|
|
714
687
|
};
|
|
715
688
|
}
|
|
716
689
|
asOptional() {
|
|
717
|
-
return new
|
|
690
|
+
return new VUnion({
|
|
718
691
|
isOptional: "optional",
|
|
719
692
|
members: this.members
|
|
720
693
|
});
|
|
721
694
|
}
|
|
722
695
|
};
|
|
723
696
|
});
|
|
697
|
+
|
|
698
|
+
// ../../node_modules/convex/dist/esm/values/validator.js
|
|
724
699
|
function isValidator(v2) {
|
|
725
700
|
return !!v2.isConvexValidator;
|
|
726
701
|
}
|
|
@@ -798,18 +773,14 @@ var init_validator = __esm(() => {
|
|
|
798
773
|
}
|
|
799
774
|
};
|
|
800
775
|
});
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
804
|
-
var _a;
|
|
805
|
-
var _b;
|
|
806
|
-
var IDENTIFYING_FIELD;
|
|
807
|
-
var ConvexError;
|
|
776
|
+
|
|
777
|
+
// ../../node_modules/convex/dist/esm/values/errors.js
|
|
778
|
+
var __defProp3, __defNormalProp2 = (obj, key, value) => (key in obj) ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value), _a, _b, IDENTIFYING_FIELD, ConvexError;
|
|
808
779
|
var init_errors = __esm(() => {
|
|
809
780
|
init_value();
|
|
810
781
|
__defProp3 = Object.defineProperty;
|
|
811
782
|
IDENTIFYING_FIELD = Symbol.for("ConvexError");
|
|
812
|
-
ConvexError = class
|
|
783
|
+
ConvexError = class ConvexError extends (_b = Error, _a = IDENTIFYING_FIELD, _b) {
|
|
813
784
|
constructor(data) {
|
|
814
785
|
super(typeof data === "string" ? data : stringifyValueForError(data));
|
|
815
786
|
__publicField2(this, "name", "ConvexError");
|
|
@@ -819,11 +790,15 @@ var init_errors = __esm(() => {
|
|
|
819
790
|
}
|
|
820
791
|
};
|
|
821
792
|
});
|
|
793
|
+
|
|
794
|
+
// ../../node_modules/convex/dist/esm/values/index.js
|
|
822
795
|
var init_values = __esm(() => {
|
|
823
796
|
init_value();
|
|
824
797
|
init_validator();
|
|
825
798
|
init_errors();
|
|
826
799
|
});
|
|
800
|
+
|
|
801
|
+
// ../core/dist/utils/utils.js
|
|
827
802
|
function hexToArrayBuffer(hex) {
|
|
828
803
|
if (hex === "") {
|
|
829
804
|
return new Uint8Array(0).buffer;
|
|
@@ -860,235 +835,9 @@ function deserializeDeveloperId(developerId) {
|
|
|
860
835
|
}
|
|
861
836
|
return null;
|
|
862
837
|
}
|
|
863
|
-
var DOC_ID_SEPARATOR = ":";
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
const buffer = new ArrayBuffer(8);
|
|
867
|
-
const view = new DataView(buffer);
|
|
868
|
-
view.setFloat64(0, n, false);
|
|
869
|
-
const bytes = new Uint8Array(buffer);
|
|
870
|
-
if (n >= 0) {
|
|
871
|
-
bytes[0] ^= 128;
|
|
872
|
-
} else {
|
|
873
|
-
for (let i2 = 0;i2 < 8; i2++) {
|
|
874
|
-
bytes[i2] ^= 255;
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
return bytes;
|
|
878
|
-
}
|
|
879
|
-
function encodeBigInt(n) {
|
|
880
|
-
const INT64_MIN = -(2n ** 63n);
|
|
881
|
-
const INT64_MAX = 2n ** 63n - 1n;
|
|
882
|
-
if (n < INT64_MIN)
|
|
883
|
-
n = INT64_MIN;
|
|
884
|
-
if (n > INT64_MAX)
|
|
885
|
-
n = INT64_MAX;
|
|
886
|
-
const buffer = new ArrayBuffer(8);
|
|
887
|
-
const view = new DataView(buffer);
|
|
888
|
-
const unsigned = n < 0n ? n + 2n ** 64n : n;
|
|
889
|
-
view.setBigUint64(0, unsigned, false);
|
|
890
|
-
const bytes = new Uint8Array(buffer);
|
|
891
|
-
bytes[0] ^= 128;
|
|
892
|
-
return bytes;
|
|
893
|
-
}
|
|
894
|
-
function encodeString(s) {
|
|
895
|
-
const encoder = new TextEncoder;
|
|
896
|
-
const raw = encoder.encode(s);
|
|
897
|
-
let nullCount = 0;
|
|
898
|
-
for (const byte of raw) {
|
|
899
|
-
if (byte === 0)
|
|
900
|
-
nullCount++;
|
|
901
|
-
}
|
|
902
|
-
const result = new Uint8Array(raw.length + nullCount + 2);
|
|
903
|
-
let writeIndex = 0;
|
|
904
|
-
for (const byte of raw) {
|
|
905
|
-
if (byte === 0) {
|
|
906
|
-
result[writeIndex++] = 0;
|
|
907
|
-
result[writeIndex++] = 1;
|
|
908
|
-
} else {
|
|
909
|
-
result[writeIndex++] = byte;
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
result[writeIndex++] = 0;
|
|
913
|
-
result[writeIndex++] = 0;
|
|
914
|
-
return result;
|
|
915
|
-
}
|
|
916
|
-
function encodeValue(value) {
|
|
917
|
-
if (value === null || value === undefined) {
|
|
918
|
-
return new Uint8Array([TypeTag.Null]);
|
|
919
|
-
}
|
|
920
|
-
if (typeof value === "boolean") {
|
|
921
|
-
return new Uint8Array([value ? TypeTag.True : TypeTag.False]);
|
|
922
|
-
}
|
|
923
|
-
if (typeof value === "number") {
|
|
924
|
-
if (Number.isNaN(value)) {
|
|
925
|
-
return new Uint8Array([TypeTag.NaN]);
|
|
926
|
-
}
|
|
927
|
-
if (!Number.isFinite(value)) {
|
|
928
|
-
return new Uint8Array([value === -Infinity ? TypeTag.NegativeInfinity : TypeTag.PositiveInfinity]);
|
|
929
|
-
}
|
|
930
|
-
if (value === 0) {
|
|
931
|
-
return new Uint8Array([Object.is(value, -0) ? TypeTag.NegativeZero : TypeTag.Zero]);
|
|
932
|
-
}
|
|
933
|
-
const tag = value > 0 ? TypeTag.PositiveNumber : TypeTag.NegativeNumber;
|
|
934
|
-
const encoded = encodeNumber(value);
|
|
935
|
-
const result = new Uint8Array(1 + encoded.length);
|
|
936
|
-
result[0] = tag;
|
|
937
|
-
result.set(encoded, 1);
|
|
938
|
-
return result;
|
|
939
|
-
}
|
|
940
|
-
if (typeof value === "bigint") {
|
|
941
|
-
if (value === 0n) {
|
|
942
|
-
return new Uint8Array([TypeTag.ZeroBigInt]);
|
|
943
|
-
}
|
|
944
|
-
const tag = value > 0n ? TypeTag.PositiveBigInt : TypeTag.NegativeBigInt;
|
|
945
|
-
const encoded = encodeBigInt(value);
|
|
946
|
-
const result = new Uint8Array(1 + encoded.length);
|
|
947
|
-
result[0] = tag;
|
|
948
|
-
result.set(encoded, 1);
|
|
949
|
-
return result;
|
|
950
|
-
}
|
|
951
|
-
if (typeof value === "string") {
|
|
952
|
-
const encoded = encodeString(value);
|
|
953
|
-
const result = new Uint8Array(1 + encoded.length);
|
|
954
|
-
result[0] = TypeTag.String;
|
|
955
|
-
result.set(encoded, 1);
|
|
956
|
-
return result;
|
|
957
|
-
}
|
|
958
|
-
if (value instanceof ArrayBuffer || value instanceof Uint8Array) {
|
|
959
|
-
const bytes = value instanceof Uint8Array ? value : new Uint8Array(value);
|
|
960
|
-
const result = new Uint8Array(1 + bytes.length + 2);
|
|
961
|
-
result[0] = TypeTag.Bytes;
|
|
962
|
-
result.set(bytes, 1);
|
|
963
|
-
result[result.length - 2] = 0;
|
|
964
|
-
result[result.length - 1] = 0;
|
|
965
|
-
return result;
|
|
966
|
-
}
|
|
967
|
-
throw new Error(`Cannot encode value of type ${typeof value} in index key`);
|
|
968
|
-
}
|
|
969
|
-
function encodeIndexKey(values) {
|
|
970
|
-
if (values.length === 0) {
|
|
971
|
-
return new ArrayBuffer(0);
|
|
972
|
-
}
|
|
973
|
-
const encoded = values.map(encodeValue);
|
|
974
|
-
const totalLength = encoded.reduce((sum, arr) => sum + arr.length, 0);
|
|
975
|
-
const result = new Uint8Array(totalLength);
|
|
976
|
-
let offset = 0;
|
|
977
|
-
for (const chunk of encoded) {
|
|
978
|
-
result.set(chunk, offset);
|
|
979
|
-
offset += chunk.length;
|
|
980
|
-
}
|
|
981
|
-
return result.buffer;
|
|
982
|
-
}
|
|
983
|
-
function compareIndexKeys(a, b) {
|
|
984
|
-
const viewA = new Uint8Array(a);
|
|
985
|
-
const viewB = new Uint8Array(b);
|
|
986
|
-
const minLen = Math.min(viewA.length, viewB.length);
|
|
987
|
-
for (let i2 = 0;i2 < minLen; i2++) {
|
|
988
|
-
if (viewA[i2] < viewB[i2])
|
|
989
|
-
return -1;
|
|
990
|
-
if (viewA[i2] > viewB[i2])
|
|
991
|
-
return 1;
|
|
992
|
-
}
|
|
993
|
-
if (viewA.length < viewB.length)
|
|
994
|
-
return -1;
|
|
995
|
-
if (viewA.length > viewB.length)
|
|
996
|
-
return 1;
|
|
997
|
-
return 0;
|
|
998
|
-
}
|
|
999
|
-
function indexKeysEqual(a, b) {
|
|
1000
|
-
return compareIndexKeys(a, b) === 0;
|
|
1001
|
-
}
|
|
1002
|
-
var TypeTag;
|
|
1003
|
-
var init_index_key_codec = __esm(() => {
|
|
1004
|
-
(function(TypeTag2) {
|
|
1005
|
-
TypeTag2[TypeTag2["Null"] = 0] = "Null";
|
|
1006
|
-
TypeTag2[TypeTag2["False"] = 16] = "False";
|
|
1007
|
-
TypeTag2[TypeTag2["True"] = 17] = "True";
|
|
1008
|
-
TypeTag2[TypeTag2["NegativeInfinity"] = 32] = "NegativeInfinity";
|
|
1009
|
-
TypeTag2[TypeTag2["NegativeNumber"] = 33] = "NegativeNumber";
|
|
1010
|
-
TypeTag2[TypeTag2["NegativeZero"] = 34] = "NegativeZero";
|
|
1011
|
-
TypeTag2[TypeTag2["Zero"] = 35] = "Zero";
|
|
1012
|
-
TypeTag2[TypeTag2["PositiveNumber"] = 36] = "PositiveNumber";
|
|
1013
|
-
TypeTag2[TypeTag2["PositiveInfinity"] = 37] = "PositiveInfinity";
|
|
1014
|
-
TypeTag2[TypeTag2["NaN"] = 38] = "NaN";
|
|
1015
|
-
TypeTag2[TypeTag2["NegativeBigInt"] = 48] = "NegativeBigInt";
|
|
1016
|
-
TypeTag2[TypeTag2["ZeroBigInt"] = 49] = "ZeroBigInt";
|
|
1017
|
-
TypeTag2[TypeTag2["PositiveBigInt"] = 50] = "PositiveBigInt";
|
|
1018
|
-
TypeTag2[TypeTag2["String"] = 64] = "String";
|
|
1019
|
-
TypeTag2[TypeTag2["Bytes"] = 80] = "Bytes";
|
|
1020
|
-
})(TypeTag || (TypeTag = {}));
|
|
1021
|
-
});
|
|
1022
|
-
function getFieldValue(doc, fieldPath) {
|
|
1023
|
-
const parts = fieldPath.split(".");
|
|
1024
|
-
let current = doc;
|
|
1025
|
-
for (const part of parts) {
|
|
1026
|
-
if (current === null || current === undefined) {
|
|
1027
|
-
return;
|
|
1028
|
-
}
|
|
1029
|
-
if (typeof current !== "object" || Array.isArray(current)) {
|
|
1030
|
-
return;
|
|
1031
|
-
}
|
|
1032
|
-
current = current[part];
|
|
1033
|
-
}
|
|
1034
|
-
return current;
|
|
1035
|
-
}
|
|
1036
|
-
function extractIndexKey(doc, fields) {
|
|
1037
|
-
const values = [];
|
|
1038
|
-
for (const field of fields) {
|
|
1039
|
-
const value = getFieldValue(doc, field);
|
|
1040
|
-
if (value === undefined) {
|
|
1041
|
-
return null;
|
|
1042
|
-
}
|
|
1043
|
-
values.push(value);
|
|
1044
|
-
}
|
|
1045
|
-
return encodeIndexKey(values);
|
|
1046
|
-
}
|
|
1047
|
-
function generateIndexUpdates(tableName, docId, newValue, oldValue, indexes) {
|
|
1048
|
-
const updates = [];
|
|
1049
|
-
for (const index of indexes) {
|
|
1050
|
-
const indexId = stringToHex(`${tableName}:${index.name}`);
|
|
1051
|
-
const oldKey = oldValue !== null ? extractIndexKey(oldValue, index.fields) : null;
|
|
1052
|
-
const newKey = newValue !== null ? extractIndexKey(newValue, index.fields) : null;
|
|
1053
|
-
const keyChanged = oldKey === null && newKey !== null || oldKey !== null && newKey === null || oldKey !== null && newKey !== null && !indexKeysEqual(oldKey, newKey);
|
|
1054
|
-
if (!keyChanged) {
|
|
1055
|
-
continue;
|
|
1056
|
-
}
|
|
1057
|
-
if (oldKey !== null) {
|
|
1058
|
-
updates.push({
|
|
1059
|
-
index_id: indexId,
|
|
1060
|
-
key: oldKey,
|
|
1061
|
-
value: { type: "Deleted" }
|
|
1062
|
-
});
|
|
1063
|
-
}
|
|
1064
|
-
if (newKey !== null) {
|
|
1065
|
-
updates.push({
|
|
1066
|
-
index_id: indexId,
|
|
1067
|
-
key: newKey,
|
|
1068
|
-
value: {
|
|
1069
|
-
type: "NonClustered",
|
|
1070
|
-
doc_id: docId
|
|
1071
|
-
}
|
|
1072
|
-
});
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
return updates;
|
|
1076
|
-
}
|
|
1077
|
-
function getStandardIndexes() {
|
|
1078
|
-
return [
|
|
1079
|
-
{
|
|
1080
|
-
name: "by_creation_time",
|
|
1081
|
-
fields: ["_creationTime", "_id"]
|
|
1082
|
-
},
|
|
1083
|
-
{
|
|
1084
|
-
name: "by_id",
|
|
1085
|
-
fields: ["_id"]
|
|
1086
|
-
}
|
|
1087
|
-
];
|
|
1088
|
-
}
|
|
1089
|
-
var init_index_manager = __esm(() => {
|
|
1090
|
-
init_index_key_codec();
|
|
1091
|
-
});
|
|
838
|
+
var DOC_ID_SEPARATOR = ":", LEGACY_DOC_ID_SEPARATOR = ";";
|
|
839
|
+
|
|
840
|
+
// ../core/dist/tables/interface.js
|
|
1092
841
|
function getFullTableName(tableName, componentPath) {
|
|
1093
842
|
if (!componentPath || componentPath === "") {
|
|
1094
843
|
return tableName;
|
|
@@ -1108,8 +857,7 @@ function parseFullTableName(fullName) {
|
|
|
1108
857
|
function isSystemTable(tableName) {
|
|
1109
858
|
return tableName.startsWith("_");
|
|
1110
859
|
}
|
|
1111
|
-
var SYSTEM_TABLE_NUMBERS;
|
|
1112
|
-
var FIRST_USER_TABLE_NUMBER = 100;
|
|
860
|
+
var SYSTEM_TABLE_NUMBERS, FIRST_USER_TABLE_NUMBER = 100;
|
|
1113
861
|
var init_interface = __esm(() => {
|
|
1114
862
|
SYSTEM_TABLE_NUMBERS = {
|
|
1115
863
|
_tables: 1,
|
|
@@ -1118,39 +866,111 @@ var init_interface = __esm(() => {
|
|
|
1118
866
|
_crons: 4
|
|
1119
867
|
};
|
|
1120
868
|
});
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
869
|
+
|
|
870
|
+
// ../core/dist/kernel/context-storage.js
|
|
871
|
+
function resolveFromRequire(req) {
|
|
872
|
+
for (const specifier of ["node:async_hooks", "async_hooks"]) {
|
|
873
|
+
try {
|
|
874
|
+
const mod = req(specifier);
|
|
875
|
+
if (mod?.AsyncLocalStorage) {
|
|
876
|
+
return mod.AsyncLocalStorage;
|
|
877
|
+
}
|
|
878
|
+
} catch {}
|
|
1125
879
|
}
|
|
1126
|
-
|
|
1127
|
-
return JSON.parse(resultStr);
|
|
880
|
+
return;
|
|
1128
881
|
}
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
} catch (e) {
|
|
1137
|
-
if (e.data !== undefined) {
|
|
1138
|
-
const rethrown = new ConvexError(e.message);
|
|
1139
|
-
rethrown.data = jsonToConvex(e.data);
|
|
1140
|
-
throw rethrown;
|
|
882
|
+
|
|
883
|
+
class ContextStorage {
|
|
884
|
+
als;
|
|
885
|
+
stack = [];
|
|
886
|
+
constructor() {
|
|
887
|
+
if (AsyncLocalStorageCtor) {
|
|
888
|
+
this.als = new AsyncLocalStorageCtor;
|
|
1141
889
|
}
|
|
1142
|
-
throw new Error(e.message);
|
|
1143
890
|
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
891
|
+
getStore() {
|
|
892
|
+
if (this.als) {
|
|
893
|
+
return this.als.getStore() ?? undefined;
|
|
894
|
+
}
|
|
895
|
+
return this.stack.length > 0 ? this.stack[this.stack.length - 1] : undefined;
|
|
896
|
+
}
|
|
897
|
+
run(value, callback) {
|
|
898
|
+
if (this.als) {
|
|
899
|
+
return this.als.run(value, callback);
|
|
900
|
+
}
|
|
901
|
+
this.stack.push(value);
|
|
902
|
+
const result = callback();
|
|
903
|
+
if (result && typeof result.then === "function") {
|
|
904
|
+
return result.finally(() => {
|
|
905
|
+
this.stack.pop();
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
this.stack.pop();
|
|
909
|
+
return result;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
var resolveAsyncLocalStorage = () => {
|
|
913
|
+
const globalCtor = globalThis?.AsyncLocalStorage;
|
|
914
|
+
if (globalCtor) {
|
|
915
|
+
return globalCtor;
|
|
916
|
+
}
|
|
917
|
+
const runtimeRequire = __require;
|
|
918
|
+
if (runtimeRequire) {
|
|
919
|
+
const ctor = resolveFromRequire(runtimeRequire);
|
|
920
|
+
if (ctor) {
|
|
921
|
+
return ctor;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
const globalRequire = globalThis?.require;
|
|
925
|
+
if (typeof globalRequire === "function") {
|
|
926
|
+
return resolveFromRequire(globalRequire);
|
|
927
|
+
}
|
|
928
|
+
return;
|
|
929
|
+
}, AsyncLocalStorageCtor;
|
|
930
|
+
var init_context_storage = __esm(() => {
|
|
931
|
+
AsyncLocalStorageCtor = resolveAsyncLocalStorage();
|
|
932
|
+
});
|
|
933
|
+
|
|
934
|
+
// ../../node_modules/convex/dist/esm/index.js
|
|
935
|
+
var version = "1.31.7";
|
|
936
|
+
|
|
937
|
+
// ../../node_modules/convex/dist/esm/server/impl/syscall.js
|
|
938
|
+
function performSyscall(op, arg) {
|
|
939
|
+
if (typeof Convex === "undefined" || Convex.syscall === undefined) {
|
|
940
|
+
throw new Error("The Convex database and auth objects are being used outside of a Convex backend. Did you mean to use `useQuery` or `useMutation` to call a Convex function?");
|
|
941
|
+
}
|
|
942
|
+
const resultStr = Convex.syscall(op, JSON.stringify(arg));
|
|
943
|
+
return JSON.parse(resultStr);
|
|
944
|
+
}
|
|
945
|
+
async function performAsyncSyscall(op, arg) {
|
|
946
|
+
if (typeof Convex === "undefined" || Convex.asyncSyscall === undefined) {
|
|
947
|
+
throw new Error("The Convex database and auth objects are being used outside of a Convex backend. Did you mean to use `useQuery` or `useMutation` to call a Convex function?");
|
|
948
|
+
}
|
|
949
|
+
let resultStr;
|
|
950
|
+
try {
|
|
951
|
+
resultStr = await Convex.asyncSyscall(op, JSON.stringify(arg));
|
|
952
|
+
} catch (e) {
|
|
953
|
+
if (e.data !== undefined) {
|
|
954
|
+
const rethrown = new ConvexError(e.message);
|
|
955
|
+
rethrown.data = jsonToConvex(e.data);
|
|
956
|
+
throw rethrown;
|
|
957
|
+
}
|
|
958
|
+
throw new Error(e.message);
|
|
959
|
+
}
|
|
960
|
+
return JSON.parse(resultStr);
|
|
961
|
+
}
|
|
962
|
+
var init_syscall = __esm(() => {
|
|
1147
963
|
init_errors();
|
|
1148
964
|
init_value();
|
|
1149
965
|
});
|
|
966
|
+
|
|
967
|
+
// ../../node_modules/convex/dist/esm/server/functionName.js
|
|
1150
968
|
var functionName;
|
|
1151
969
|
var init_functionName = __esm(() => {
|
|
1152
970
|
functionName = Symbol.for("functionName");
|
|
1153
971
|
});
|
|
972
|
+
|
|
973
|
+
// ../../node_modules/convex/dist/esm/server/components/paths.js
|
|
1154
974
|
function extractReferencePath(reference) {
|
|
1155
975
|
return reference[toReferencePath] ?? null;
|
|
1156
976
|
}
|
|
@@ -1181,6 +1001,8 @@ var init_paths = __esm(() => {
|
|
|
1181
1001
|
init_functionName();
|
|
1182
1002
|
toReferencePath = Symbol.for("toReferencePath");
|
|
1183
1003
|
});
|
|
1004
|
+
|
|
1005
|
+
// ../../node_modules/convex/dist/esm/server/impl/validate.js
|
|
1184
1006
|
function validateArg(arg, idx, method, argName) {
|
|
1185
1007
|
if (arg === undefined) {
|
|
1186
1008
|
throw new TypeError(`Must provide arg ${idx} \`${argName}\` to \`${method}\``);
|
|
@@ -1191,6 +1013,8 @@ function validateArgIsNonNegativeInteger(arg, idx, method, argName) {
|
|
|
1191
1013
|
throw new TypeError(`Arg ${idx} \`${argName}\` to \`${method}\` must be a non-negative integer`);
|
|
1192
1014
|
}
|
|
1193
1015
|
}
|
|
1016
|
+
|
|
1017
|
+
// ../../node_modules/convex/dist/esm/server/impl/authentication_impl.js
|
|
1194
1018
|
function setupAuth(requestId) {
|
|
1195
1019
|
return {
|
|
1196
1020
|
getUserIdentity: async () => {
|
|
@@ -1204,18 +1028,19 @@ var init_authentication_impl = __esm(() => {
|
|
|
1204
1028
|
init_syscall();
|
|
1205
1029
|
});
|
|
1206
1030
|
|
|
1031
|
+
// ../../node_modules/convex/dist/esm/server/filter_builder.js
|
|
1207
1032
|
class Expression {
|
|
1208
1033
|
constructor() {
|
|
1209
1034
|
__publicField3(this, "_isExpression");
|
|
1210
1035
|
__publicField3(this, "_value");
|
|
1211
1036
|
}
|
|
1212
1037
|
}
|
|
1213
|
-
var __defProp4;
|
|
1214
|
-
var __defNormalProp3 = (obj, key, value) => (key in obj) ? __defProp4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1215
|
-
var __publicField3 = (obj, key, value) => __defNormalProp3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1038
|
+
var __defProp4, __defNormalProp3 = (obj, key, value) => (key in obj) ? __defProp4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, __publicField3 = (obj, key, value) => __defNormalProp3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1216
1039
|
var init_filter_builder = __esm(() => {
|
|
1217
1040
|
__defProp4 = Object.defineProperty;
|
|
1218
1041
|
});
|
|
1042
|
+
|
|
1043
|
+
// ../../node_modules/convex/dist/esm/server/impl/filter_builder_impl.js
|
|
1219
1044
|
function serializeExpression(expr) {
|
|
1220
1045
|
if (expr instanceof ExpressionImpl) {
|
|
1221
1046
|
return expr.serialize();
|
|
@@ -1223,16 +1048,12 @@ function serializeExpression(expr) {
|
|
|
1223
1048
|
return { $literal: convexOrUndefinedToJson(expr) };
|
|
1224
1049
|
}
|
|
1225
1050
|
}
|
|
1226
|
-
var __defProp5;
|
|
1227
|
-
var __defNormalProp4 = (obj, key, value) => (key in obj) ? __defProp5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1228
|
-
var __publicField4 = (obj, key, value) => __defNormalProp4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1229
|
-
var ExpressionImpl;
|
|
1230
|
-
var filterBuilderImpl;
|
|
1051
|
+
var __defProp5, __defNormalProp4 = (obj, key, value) => (key in obj) ? __defProp5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, __publicField4 = (obj, key, value) => __defNormalProp4(obj, typeof key !== "symbol" ? key + "" : key, value), ExpressionImpl, filterBuilderImpl;
|
|
1231
1052
|
var init_filter_builder_impl = __esm(() => {
|
|
1232
1053
|
init_value();
|
|
1233
1054
|
init_filter_builder();
|
|
1234
1055
|
__defProp5 = Object.defineProperty;
|
|
1235
|
-
ExpressionImpl = class
|
|
1056
|
+
ExpressionImpl = class ExpressionImpl extends Expression {
|
|
1236
1057
|
constructor(inner) {
|
|
1237
1058
|
super();
|
|
1238
1059
|
__publicField4(this, "inner");
|
|
@@ -1316,26 +1137,24 @@ var init_filter_builder_impl = __esm(() => {
|
|
|
1316
1137
|
};
|
|
1317
1138
|
});
|
|
1318
1139
|
|
|
1140
|
+
// ../../node_modules/convex/dist/esm/server/index_range_builder.js
|
|
1319
1141
|
class IndexRange {
|
|
1320
1142
|
constructor() {
|
|
1321
1143
|
__publicField5(this, "_isIndexRange");
|
|
1322
1144
|
}
|
|
1323
1145
|
}
|
|
1324
|
-
var __defProp6;
|
|
1325
|
-
var __defNormalProp5 = (obj, key, value) => (key in obj) ? __defProp6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1326
|
-
var __publicField5 = (obj, key, value) => __defNormalProp5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1146
|
+
var __defProp6, __defNormalProp5 = (obj, key, value) => (key in obj) ? __defProp6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, __publicField5 = (obj, key, value) => __defNormalProp5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1327
1147
|
var init_index_range_builder = __esm(() => {
|
|
1328
1148
|
__defProp6 = Object.defineProperty;
|
|
1329
1149
|
});
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
var __publicField6 = (obj, key, value) => __defNormalProp6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1333
|
-
var IndexRangeBuilderImpl;
|
|
1150
|
+
|
|
1151
|
+
// ../../node_modules/convex/dist/esm/server/impl/index_range_builder_impl.js
|
|
1152
|
+
var __defProp7, __defNormalProp6 = (obj, key, value) => (key in obj) ? __defProp7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, __publicField6 = (obj, key, value) => __defNormalProp6(obj, typeof key !== "symbol" ? key + "" : key, value), IndexRangeBuilderImpl;
|
|
1334
1153
|
var init_index_range_builder_impl = __esm(() => {
|
|
1335
1154
|
init_value();
|
|
1336
1155
|
init_index_range_builder();
|
|
1337
1156
|
__defProp7 = Object.defineProperty;
|
|
1338
|
-
IndexRangeBuilderImpl = class
|
|
1157
|
+
IndexRangeBuilderImpl = class IndexRangeBuilderImpl extends IndexRange {
|
|
1339
1158
|
constructor(rangeExpressions) {
|
|
1340
1159
|
super();
|
|
1341
1160
|
__publicField6(this, "rangeExpressions");
|
|
@@ -1344,7 +1163,7 @@ var init_index_range_builder_impl = __esm(() => {
|
|
|
1344
1163
|
this.isConsumed = false;
|
|
1345
1164
|
}
|
|
1346
1165
|
static new() {
|
|
1347
|
-
return new
|
|
1166
|
+
return new IndexRangeBuilderImpl([]);
|
|
1348
1167
|
}
|
|
1349
1168
|
consume() {
|
|
1350
1169
|
if (this.isConsumed) {
|
|
@@ -1354,7 +1173,7 @@ var init_index_range_builder_impl = __esm(() => {
|
|
|
1354
1173
|
}
|
|
1355
1174
|
eq(fieldName, value) {
|
|
1356
1175
|
this.consume();
|
|
1357
|
-
return new
|
|
1176
|
+
return new IndexRangeBuilderImpl(this.rangeExpressions.concat({
|
|
1358
1177
|
type: "Eq",
|
|
1359
1178
|
fieldPath: fieldName,
|
|
1360
1179
|
value: convexOrUndefinedToJson(value)
|
|
@@ -1362,7 +1181,7 @@ var init_index_range_builder_impl = __esm(() => {
|
|
|
1362
1181
|
}
|
|
1363
1182
|
gt(fieldName, value) {
|
|
1364
1183
|
this.consume();
|
|
1365
|
-
return new
|
|
1184
|
+
return new IndexRangeBuilderImpl(this.rangeExpressions.concat({
|
|
1366
1185
|
type: "Gt",
|
|
1367
1186
|
fieldPath: fieldName,
|
|
1368
1187
|
value: convexOrUndefinedToJson(value)
|
|
@@ -1370,7 +1189,7 @@ var init_index_range_builder_impl = __esm(() => {
|
|
|
1370
1189
|
}
|
|
1371
1190
|
gte(fieldName, value) {
|
|
1372
1191
|
this.consume();
|
|
1373
|
-
return new
|
|
1192
|
+
return new IndexRangeBuilderImpl(this.rangeExpressions.concat({
|
|
1374
1193
|
type: "Gte",
|
|
1375
1194
|
fieldPath: fieldName,
|
|
1376
1195
|
value: convexOrUndefinedToJson(value)
|
|
@@ -1378,7 +1197,7 @@ var init_index_range_builder_impl = __esm(() => {
|
|
|
1378
1197
|
}
|
|
1379
1198
|
lt(fieldName, value) {
|
|
1380
1199
|
this.consume();
|
|
1381
|
-
return new
|
|
1200
|
+
return new IndexRangeBuilderImpl(this.rangeExpressions.concat({
|
|
1382
1201
|
type: "Lt",
|
|
1383
1202
|
fieldPath: fieldName,
|
|
1384
1203
|
value: convexOrUndefinedToJson(value)
|
|
@@ -1386,7 +1205,7 @@ var init_index_range_builder_impl = __esm(() => {
|
|
|
1386
1205
|
}
|
|
1387
1206
|
lte(fieldName, value) {
|
|
1388
1207
|
this.consume();
|
|
1389
|
-
return new
|
|
1208
|
+
return new IndexRangeBuilderImpl(this.rangeExpressions.concat({
|
|
1390
1209
|
type: "Lte",
|
|
1391
1210
|
fieldPath: fieldName,
|
|
1392
1211
|
value: convexOrUndefinedToJson(value)
|
|
@@ -1399,26 +1218,24 @@ var init_index_range_builder_impl = __esm(() => {
|
|
|
1399
1218
|
};
|
|
1400
1219
|
});
|
|
1401
1220
|
|
|
1221
|
+
// ../../node_modules/convex/dist/esm/server/search_filter_builder.js
|
|
1402
1222
|
class SearchFilter {
|
|
1403
1223
|
constructor() {
|
|
1404
1224
|
__publicField7(this, "_isSearchFilter");
|
|
1405
1225
|
}
|
|
1406
1226
|
}
|
|
1407
|
-
var __defProp8;
|
|
1408
|
-
var __defNormalProp7 = (obj, key, value) => (key in obj) ? __defProp8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1409
|
-
var __publicField7 = (obj, key, value) => __defNormalProp7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1227
|
+
var __defProp8, __defNormalProp7 = (obj, key, value) => (key in obj) ? __defProp8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, __publicField7 = (obj, key, value) => __defNormalProp7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1410
1228
|
var init_search_filter_builder = __esm(() => {
|
|
1411
1229
|
__defProp8 = Object.defineProperty;
|
|
1412
1230
|
});
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
var __publicField8 = (obj, key, value) => __defNormalProp8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1416
|
-
var SearchFilterBuilderImpl;
|
|
1231
|
+
|
|
1232
|
+
// ../../node_modules/convex/dist/esm/server/impl/search_filter_builder_impl.js
|
|
1233
|
+
var __defProp9, __defNormalProp8 = (obj, key, value) => (key in obj) ? __defProp9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, __publicField8 = (obj, key, value) => __defNormalProp8(obj, typeof key !== "symbol" ? key + "" : key, value), SearchFilterBuilderImpl;
|
|
1417
1234
|
var init_search_filter_builder_impl = __esm(() => {
|
|
1418
1235
|
init_value();
|
|
1419
1236
|
init_search_filter_builder();
|
|
1420
1237
|
__defProp9 = Object.defineProperty;
|
|
1421
|
-
SearchFilterBuilderImpl = class
|
|
1238
|
+
SearchFilterBuilderImpl = class SearchFilterBuilderImpl extends SearchFilter {
|
|
1422
1239
|
constructor(filters) {
|
|
1423
1240
|
super();
|
|
1424
1241
|
__publicField8(this, "filters");
|
|
@@ -1427,7 +1244,7 @@ var init_search_filter_builder_impl = __esm(() => {
|
|
|
1427
1244
|
this.isConsumed = false;
|
|
1428
1245
|
}
|
|
1429
1246
|
static new() {
|
|
1430
|
-
return new
|
|
1247
|
+
return new SearchFilterBuilderImpl([]);
|
|
1431
1248
|
}
|
|
1432
1249
|
consume() {
|
|
1433
1250
|
if (this.isConsumed) {
|
|
@@ -1439,7 +1256,7 @@ var init_search_filter_builder_impl = __esm(() => {
|
|
|
1439
1256
|
validateArg(fieldName, 1, "search", "fieldName");
|
|
1440
1257
|
validateArg(query, 2, "search", "query");
|
|
1441
1258
|
this.consume();
|
|
1442
|
-
return new
|
|
1259
|
+
return new SearchFilterBuilderImpl(this.filters.concat({
|
|
1443
1260
|
type: "Search",
|
|
1444
1261
|
fieldPath: fieldName,
|
|
1445
1262
|
value: query
|
|
@@ -1451,7 +1268,7 @@ var init_search_filter_builder_impl = __esm(() => {
|
|
|
1451
1268
|
validateArg(value, 2, "search", "value");
|
|
1452
1269
|
}
|
|
1453
1270
|
this.consume();
|
|
1454
|
-
return new
|
|
1271
|
+
return new SearchFilterBuilderImpl(this.filters.concat({
|
|
1455
1272
|
type: "Eq",
|
|
1456
1273
|
fieldPath: fieldName,
|
|
1457
1274
|
value: convexOrUndefinedToJson(value)
|
|
@@ -1463,15 +1280,12 @@ var init_search_filter_builder_impl = __esm(() => {
|
|
|
1463
1280
|
}
|
|
1464
1281
|
};
|
|
1465
1282
|
});
|
|
1283
|
+
|
|
1284
|
+
// ../../node_modules/convex/dist/esm/server/impl/query_impl.js
|
|
1466
1285
|
function throwClosedError(type) {
|
|
1467
1286
|
throw new Error(type === "consumed" ? "This query is closed and can't emit any more values." : "This query has been chained with another operator and can't be reused.");
|
|
1468
1287
|
}
|
|
1469
|
-
var __defProp10;
|
|
1470
|
-
var __defNormalProp9 = (obj, key, value) => (key in obj) ? __defProp10(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1471
|
-
var __publicField9 = (obj, key, value) => __defNormalProp9(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1472
|
-
var MAX_QUERY_OPERATORS = 256;
|
|
1473
|
-
var QueryInitializerImpl;
|
|
1474
|
-
var QueryImpl;
|
|
1288
|
+
var __defProp10, __defNormalProp9 = (obj, key, value) => (key in obj) ? __defProp10(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, __publicField9 = (obj, key, value) => __defNormalProp9(obj, typeof key !== "symbol" ? key + "" : key, value), MAX_QUERY_OPERATORS = 256, QueryInitializerImpl, QueryImpl;
|
|
1475
1289
|
var init_query_impl = __esm(() => {
|
|
1476
1290
|
init_values();
|
|
1477
1291
|
init_syscall();
|
|
@@ -1479,7 +1293,7 @@ var init_query_impl = __esm(() => {
|
|
|
1479
1293
|
init_index_range_builder_impl();
|
|
1480
1294
|
init_search_filter_builder_impl();
|
|
1481
1295
|
__defProp10 = Object.defineProperty;
|
|
1482
|
-
QueryInitializerImpl = class
|
|
1296
|
+
QueryInitializerImpl = class QueryInitializerImpl {
|
|
1483
1297
|
constructor(tableName) {
|
|
1484
1298
|
__publicField9(this, "tableName");
|
|
1485
1299
|
this.tableName = tableName;
|
|
@@ -1558,7 +1372,7 @@ var init_query_impl = __esm(() => {
|
|
|
1558
1372
|
return this.fullTableScan()[Symbol.asyncIterator]();
|
|
1559
1373
|
}
|
|
1560
1374
|
};
|
|
1561
|
-
QueryImpl = class
|
|
1375
|
+
QueryImpl = class QueryImpl {
|
|
1562
1376
|
constructor(query) {
|
|
1563
1377
|
__publicField9(this, "state");
|
|
1564
1378
|
__publicField9(this, "tableNameForErrorMessages");
|
|
@@ -1606,7 +1420,7 @@ var init_query_impl = __esm(() => {
|
|
|
1606
1420
|
throw new Error("Queries may only specify order at most once");
|
|
1607
1421
|
}
|
|
1608
1422
|
query.source.order = order;
|
|
1609
|
-
return new
|
|
1423
|
+
return new QueryImpl(query);
|
|
1610
1424
|
}
|
|
1611
1425
|
filter(predicate) {
|
|
1612
1426
|
validateArg(predicate, 1, "filter", "predicate");
|
|
@@ -1617,13 +1431,13 @@ var init_query_impl = __esm(() => {
|
|
|
1617
1431
|
query.operators.push({
|
|
1618
1432
|
filter: serializeExpression(predicate(filterBuilderImpl))
|
|
1619
1433
|
});
|
|
1620
|
-
return new
|
|
1434
|
+
return new QueryImpl(query);
|
|
1621
1435
|
}
|
|
1622
1436
|
limit(n) {
|
|
1623
1437
|
validateArg(n, 1, "limit", "n");
|
|
1624
1438
|
const query = this.takeQuery();
|
|
1625
1439
|
query.operators.push({ limit: n });
|
|
1626
|
-
return new
|
|
1440
|
+
return new QueryImpl(query);
|
|
1627
1441
|
}
|
|
1628
1442
|
[Symbol.asyncIterator]() {
|
|
1629
1443
|
this.startQuery();
|
|
@@ -1703,6 +1517,8 @@ var init_query_impl = __esm(() => {
|
|
|
1703
1517
|
}
|
|
1704
1518
|
};
|
|
1705
1519
|
});
|
|
1520
|
+
|
|
1521
|
+
// ../../node_modules/convex/dist/esm/server/impl/database_impl.js
|
|
1706
1522
|
async function get(table, id, isSystem) {
|
|
1707
1523
|
validateArg(id, 1, "get", "id");
|
|
1708
1524
|
if (typeof id !== "string") {
|
|
@@ -1836,7 +1652,7 @@ var init_database_impl = __esm(() => {
|
|
|
1836
1652
|
init_syscall();
|
|
1837
1653
|
init_query_impl();
|
|
1838
1654
|
init_value();
|
|
1839
|
-
TableWriter = class
|
|
1655
|
+
TableWriter = class TableWriter extends TableReader {
|
|
1840
1656
|
async insert(value) {
|
|
1841
1657
|
return insert(this.tableName, value);
|
|
1842
1658
|
}
|
|
@@ -1851,6 +1667,8 @@ var init_database_impl = __esm(() => {
|
|
|
1851
1667
|
}
|
|
1852
1668
|
};
|
|
1853
1669
|
});
|
|
1670
|
+
|
|
1671
|
+
// ../../node_modules/convex/dist/esm/server/impl/scheduler_impl.js
|
|
1854
1672
|
function setupMutationScheduler() {
|
|
1855
1673
|
return {
|
|
1856
1674
|
runAfter: async (delayMs, functionReference, args) => {
|
|
@@ -1911,6 +1729,8 @@ var init_scheduler_impl = __esm(() => {
|
|
|
1911
1729
|
init_syscall();
|
|
1912
1730
|
init_paths();
|
|
1913
1731
|
});
|
|
1732
|
+
|
|
1733
|
+
// ../../node_modules/convex/dist/esm/server/impl/storage_impl.js
|
|
1914
1734
|
function setupStorageReader(requestId) {
|
|
1915
1735
|
return {
|
|
1916
1736
|
getUrl: async (storageId) => {
|
|
@@ -1953,6 +1773,8 @@ function setupStorageWriter(requestId) {
|
|
|
1953
1773
|
var init_storage_impl = __esm(() => {
|
|
1954
1774
|
init_syscall();
|
|
1955
1775
|
});
|
|
1776
|
+
|
|
1777
|
+
// ../../node_modules/convex/dist/esm/server/impl/registration_impl.js
|
|
1956
1778
|
async function invokeMutation(func, argsStr) {
|
|
1957
1779
|
const requestId = "";
|
|
1958
1780
|
const args = jsonToConvex(JSON.parse(argsStr));
|
|
@@ -2065,8 +1887,7 @@ var mutationGeneric = (functionDefinition) => {
|
|
|
2065
1887
|
func.exportReturns = exportReturns(functionDefinition);
|
|
2066
1888
|
func._handler = handler;
|
|
2067
1889
|
return func;
|
|
2068
|
-
}
|
|
2069
|
-
var queryGeneric = (functionDefinition) => {
|
|
1890
|
+
}, queryGeneric = (functionDefinition) => {
|
|
2070
1891
|
const handler = typeof functionDefinition === "function" ? functionDefinition : functionDefinition.handler;
|
|
2071
1892
|
const func = dontCallDirectly("query", handler);
|
|
2072
1893
|
assertNotBrowser();
|
|
@@ -2089,6 +1910,8 @@ var init_registration_impl = __esm(() => {
|
|
|
2089
1910
|
init_validator();
|
|
2090
1911
|
init_paths();
|
|
2091
1912
|
});
|
|
1913
|
+
|
|
1914
|
+
// ../../node_modules/convex/dist/esm/server/pagination.js
|
|
2092
1915
|
var paginationOptsValidator;
|
|
2093
1916
|
var init_pagination = __esm(() => {
|
|
2094
1917
|
init_validator();
|
|
@@ -2101,11 +1924,34 @@ var init_pagination = __esm(() => {
|
|
|
2101
1924
|
maximumBytesRead: v.optional(v.number())
|
|
2102
1925
|
});
|
|
2103
1926
|
});
|
|
1927
|
+
|
|
1928
|
+
// ../../node_modules/convex/dist/esm/server/index.js
|
|
2104
1929
|
var init_server = __esm(() => {
|
|
2105
1930
|
init_registration_impl();
|
|
2106
1931
|
init_pagination();
|
|
2107
1932
|
init_search_filter_builder();
|
|
2108
1933
|
});
|
|
1934
|
+
|
|
1935
|
+
// ../core/dist/kernel/missing-schema-error.js
|
|
1936
|
+
function isMissingSchemaModuleError(error) {
|
|
1937
|
+
if (!error)
|
|
1938
|
+
return false;
|
|
1939
|
+
const errorString = String(error);
|
|
1940
|
+
const isMissing = errorString.includes('Unable to resolve module "schema"') || errorString.includes("Module not found: schema") || errorString.includes('Unable to resolve module "convex/schema"');
|
|
1941
|
+
if (isMissing)
|
|
1942
|
+
return true;
|
|
1943
|
+
const causes = error.causes;
|
|
1944
|
+
if (Array.isArray(causes)) {
|
|
1945
|
+
return causes.some(isMissingSchemaModuleError);
|
|
1946
|
+
}
|
|
1947
|
+
const cause = error.cause;
|
|
1948
|
+
if (cause) {
|
|
1949
|
+
return isMissingSchemaModuleError(cause);
|
|
1950
|
+
}
|
|
1951
|
+
return false;
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
// ../core/dist/udf/analysis/udf-analyze.js
|
|
2109
1955
|
function invalidUdfError(message) {
|
|
2110
1956
|
return new UdfAnalysisError(message);
|
|
2111
1957
|
}
|
|
@@ -2296,17 +2142,21 @@ function analyzeCrons(crons) {
|
|
|
2296
2142
|
}
|
|
2297
2143
|
var UdfAnalysisError;
|
|
2298
2144
|
var init_udf_analyze = __esm(() => {
|
|
2299
|
-
UdfAnalysisError = class
|
|
2145
|
+
UdfAnalysisError = class UdfAnalysisError extends Error {
|
|
2300
2146
|
constructor(message) {
|
|
2301
2147
|
super(message);
|
|
2302
2148
|
this.name = "UdfAnalysisError";
|
|
2303
2149
|
}
|
|
2304
2150
|
};
|
|
2305
2151
|
});
|
|
2152
|
+
|
|
2153
|
+
// ../core/dist/udf/analysis/index.js
|
|
2306
2154
|
var init_analysis = __esm(() => {
|
|
2307
2155
|
init_udf_analyze();
|
|
2308
2156
|
init_validator2();
|
|
2309
2157
|
});
|
|
2158
|
+
|
|
2159
|
+
// ../core/dist/system/function-introspection.js
|
|
2310
2160
|
async function listSystemFunctions(options = {}) {
|
|
2311
2161
|
const componentPath = options.componentPath;
|
|
2312
2162
|
const moduleLoader = await ensureModuleLoaderApi();
|
|
@@ -2457,14 +2307,13 @@ function isNpmPackageError(error) {
|
|
|
2457
2307
|
return !modulePath.startsWith(".") && !modulePath.startsWith("/");
|
|
2458
2308
|
});
|
|
2459
2309
|
}
|
|
2460
|
-
var moduleAnalysisCache;
|
|
2461
|
-
var moduleLoaderApiPromise = null;
|
|
2462
|
-
var unsubscribeModuleLoader = null;
|
|
2310
|
+
var moduleAnalysisCache, moduleLoaderApiPromise = null, unsubscribeModuleLoader = null;
|
|
2463
2311
|
var init_function_introspection = __esm(() => {
|
|
2464
2312
|
init_analysis();
|
|
2465
2313
|
moduleAnalysisCache = new Map;
|
|
2466
2314
|
});
|
|
2467
2315
|
|
|
2316
|
+
// ../core/dist/system/execution-log.js
|
|
2468
2317
|
class InMemoryLogSink {
|
|
2469
2318
|
entries = [];
|
|
2470
2319
|
nextId = 1;
|
|
@@ -2513,11 +2362,12 @@ function queryExecutionLog(filter = {}) {
|
|
|
2513
2362
|
function clearExecutionLog() {
|
|
2514
2363
|
defaultSink.clear();
|
|
2515
2364
|
}
|
|
2516
|
-
var MAX_ENTRIES = 1000;
|
|
2517
|
-
var defaultSink;
|
|
2365
|
+
var MAX_ENTRIES = 1000, defaultSink;
|
|
2518
2366
|
var init_execution_log = __esm(() => {
|
|
2519
2367
|
defaultSink = new InMemoryLogSink;
|
|
2520
2368
|
});
|
|
2369
|
+
|
|
2370
|
+
// ../core/dist/system/internal.js
|
|
2521
2371
|
function createSystemFunctions(deps) {
|
|
2522
2372
|
const { query, mutation } = deps;
|
|
2523
2373
|
return {
|
|
@@ -2909,8 +2759,9 @@ function createSystemFunctions(deps) {
|
|
|
2909
2759
|
systemListFunctions: query({
|
|
2910
2760
|
args: { componentPath: v.optional(v.string()) },
|
|
2911
2761
|
handler: async (ctx, args) => {
|
|
2912
|
-
const
|
|
2913
|
-
const
|
|
2762
|
+
const requestedComponentPath = args.componentPath ?? ctx?.componentPath ?? undefined;
|
|
2763
|
+
const normalizedComponentPath = typeof requestedComponentPath === "string" && requestedComponentPath.trim().length === 0 ? undefined : requestedComponentPath;
|
|
2764
|
+
const functions = await listSystemFunctions({ componentPath: normalizedComponentPath });
|
|
2914
2765
|
return functions.map((fn) => ({
|
|
2915
2766
|
name: fn.name,
|
|
2916
2767
|
path: fn.path,
|
|
@@ -3109,11 +2960,16 @@ function describeFieldType(node) {
|
|
|
3109
2960
|
var init_internal = __esm(() => {
|
|
3110
2961
|
init_values();
|
|
3111
2962
|
init_module_loader();
|
|
3112
|
-
init_schema_service();
|
|
3113
2963
|
init_function_introspection();
|
|
3114
2964
|
init_interface();
|
|
3115
2965
|
init_execution_log();
|
|
3116
2966
|
});
|
|
2967
|
+
|
|
2968
|
+
// ../core/dist/system/system-functions-module.js
|
|
2969
|
+
var exports_system_functions_module = {};
|
|
2970
|
+
__export(exports_system_functions_module, {
|
|
2971
|
+
getSystemFunctionsModule: () => getSystemFunctionsModule
|
|
2972
|
+
});
|
|
3117
2973
|
function getSystemFunctionsModule() {
|
|
3118
2974
|
return systemFunctions;
|
|
3119
2975
|
}
|
|
@@ -3126,6 +2982,8 @@ var init_system_functions_module = __esm(() => {
|
|
|
3126
2982
|
mutation: mutationGeneric
|
|
3127
2983
|
});
|
|
3128
2984
|
});
|
|
2985
|
+
|
|
2986
|
+
// ../core/dist/udf/module-loader/module-loader.js
|
|
3129
2987
|
var exports_module_loader = {};
|
|
3130
2988
|
__export(exports_module_loader, {
|
|
3131
2989
|
withModuleRegistry: () => withModuleRegistry,
|
|
@@ -3144,6 +3002,23 @@ __export(exports_module_loader, {
|
|
|
3144
3002
|
clearModuleLoader: () => clearModuleLoader,
|
|
3145
3003
|
ModuleRegistry: () => ModuleRegistry
|
|
3146
3004
|
});
|
|
3005
|
+
function allowConvexFunctionsInBrowser() {
|
|
3006
|
+
if (browserConvexFunctionsAllowed) {
|
|
3007
|
+
return;
|
|
3008
|
+
}
|
|
3009
|
+
browserConvexFunctionsAllowed = true;
|
|
3010
|
+
const globalAny = globalThis;
|
|
3011
|
+
if (globalAny.window && typeof globalAny.window === "object") {
|
|
3012
|
+
globalAny.window.__convexAllowFunctionsInBrowser = true;
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3015
|
+
async function getBuiltInSystemFunctionsModule() {
|
|
3016
|
+
if (!builtInSystemFunctionsModulePromise) {
|
|
3017
|
+
allowConvexFunctionsInBrowser();
|
|
3018
|
+
builtInSystemFunctionsModulePromise = Promise.resolve().then(() => (init_system_functions_module(), exports_system_functions_module)).then((mod) => mod.getSystemFunctionsModule());
|
|
3019
|
+
}
|
|
3020
|
+
return builtInSystemFunctionsModulePromise;
|
|
3021
|
+
}
|
|
3147
3022
|
|
|
3148
3023
|
class ModuleRegistry {
|
|
3149
3024
|
scopedLoaders = new Map;
|
|
@@ -3196,6 +3071,7 @@ class ModuleRegistry {
|
|
|
3196
3071
|
};
|
|
3197
3072
|
}
|
|
3198
3073
|
async load(request) {
|
|
3074
|
+
allowConvexFunctionsInBrowser();
|
|
3199
3075
|
const scopes = expandComponentScopes(request.componentPath);
|
|
3200
3076
|
const errors2 = [];
|
|
3201
3077
|
let attempted = false;
|
|
@@ -3287,6 +3163,8 @@ function getModuleState() {
|
|
|
3287
3163
|
function resetModuleState() {
|
|
3288
3164
|
const globalAny = globalThis;
|
|
3289
3165
|
delete globalAny[MODULE_STATE_SYMBOL];
|
|
3166
|
+
builtInSystemFunctionsModulePromise = undefined;
|
|
3167
|
+
browserConvexFunctionsAllowed = false;
|
|
3290
3168
|
}
|
|
3291
3169
|
function getModuleRegistry() {
|
|
3292
3170
|
return MODULE_REGISTRY_CONTEXT.getStore() ?? getModuleState().registry;
|
|
@@ -3321,7 +3199,7 @@ async function loadConvexModule(specifier, options = {}) {
|
|
|
3321
3199
|
return await getModuleRegistry().load(request);
|
|
3322
3200
|
} catch (error) {
|
|
3323
3201
|
if (error?.message?.includes("Unable to resolve")) {
|
|
3324
|
-
return
|
|
3202
|
+
return await getBuiltInSystemFunctionsModule();
|
|
3325
3203
|
}
|
|
3326
3204
|
throw error;
|
|
3327
3205
|
}
|
|
@@ -3550,16 +3428,15 @@ function isIterable(value) {
|
|
|
3550
3428
|
function isAsyncIterable(value) {
|
|
3551
3429
|
return value && typeof value[Symbol.asyncIterator] === "function";
|
|
3552
3430
|
}
|
|
3553
|
-
var MODULE_STATE_SYMBOL;
|
|
3554
|
-
var MODULE_LOADER_METADATA_SYMBOL;
|
|
3555
|
-
var MODULE_REGISTRY_CONTEXT;
|
|
3431
|
+
var MODULE_STATE_SYMBOL, MODULE_LOADER_METADATA_SYMBOL, MODULE_REGISTRY_CONTEXT, builtInSystemFunctionsModulePromise, browserConvexFunctionsAllowed = false;
|
|
3556
3432
|
var init_module_loader = __esm(() => {
|
|
3557
|
-
|
|
3433
|
+
init_context_storage();
|
|
3558
3434
|
MODULE_STATE_SYMBOL = Symbol.for("concave.moduleLoader.state");
|
|
3559
3435
|
MODULE_LOADER_METADATA_SYMBOL = Symbol.for("concave.moduleLoader.metadata");
|
|
3560
|
-
MODULE_REGISTRY_CONTEXT = new
|
|
3436
|
+
MODULE_REGISTRY_CONTEXT = new ContextStorage;
|
|
3561
3437
|
});
|
|
3562
3438
|
|
|
3439
|
+
// ../core/dist/udf/analysis/validator.js
|
|
3563
3440
|
class SchemaValidator {
|
|
3564
3441
|
schemaCache = new Map;
|
|
3565
3442
|
componentPath;
|
|
@@ -3811,8 +3688,7 @@ var ValidatorError;
|
|
|
3811
3688
|
var init_validator2 = __esm(() => {
|
|
3812
3689
|
init_interface();
|
|
3813
3690
|
init_module_loader();
|
|
3814
|
-
|
|
3815
|
-
ValidatorError = class ValidatorError2 extends Error {
|
|
3691
|
+
ValidatorError = class ValidatorError extends Error {
|
|
3816
3692
|
path;
|
|
3817
3693
|
constructor(message, path = "") {
|
|
3818
3694
|
super(message);
|
|
@@ -3822,160 +3698,7 @@ var init_validator2 = __esm(() => {
|
|
|
3822
3698
|
};
|
|
3823
3699
|
});
|
|
3824
3700
|
|
|
3825
|
-
|
|
3826
|
-
cachedSchemaDefinition = undefined;
|
|
3827
|
-
tableCache = new Map;
|
|
3828
|
-
schemaValidator;
|
|
3829
|
-
componentPath;
|
|
3830
|
-
constructor(componentPath) {
|
|
3831
|
-
this.componentPath = componentPath;
|
|
3832
|
-
this.schemaValidator = new SchemaValidator(componentPath);
|
|
3833
|
-
}
|
|
3834
|
-
async validate(tableName, document) {
|
|
3835
|
-
try {
|
|
3836
|
-
await this.schemaValidator.validateDocument(tableName, document);
|
|
3837
|
-
} catch (error) {
|
|
3838
|
-
if (error instanceof ValidatorError) {
|
|
3839
|
-
throw new Error(error.message);
|
|
3840
|
-
}
|
|
3841
|
-
throw error;
|
|
3842
|
-
}
|
|
3843
|
-
}
|
|
3844
|
-
async getTableSchema(tableName) {
|
|
3845
|
-
if (this.tableCache.has(tableName)) {
|
|
3846
|
-
return this.tableCache.get(tableName) ?? null;
|
|
3847
|
-
}
|
|
3848
|
-
const schemaDefinition = await this.getSchemaDefinition();
|
|
3849
|
-
const tableSchema = schemaDefinition?.tables?.[tableName] ?? null;
|
|
3850
|
-
this.tableCache.set(tableName, tableSchema);
|
|
3851
|
-
return tableSchema;
|
|
3852
|
-
}
|
|
3853
|
-
async getIndexFieldsForTable(tableName, indexDescriptor) {
|
|
3854
|
-
if (indexDescriptor === "by_creation_time") {
|
|
3855
|
-
return ["_creationTime", "_id"];
|
|
3856
|
-
}
|
|
3857
|
-
if (indexDescriptor === "by_id") {
|
|
3858
|
-
return ["_id"];
|
|
3859
|
-
}
|
|
3860
|
-
const tableSchema = await this.getTableSchema(tableName);
|
|
3861
|
-
const dbIndexes = tableSchema?.indexes;
|
|
3862
|
-
const matchingIndex = dbIndexes?.find((idx) => idx.indexDescriptor === indexDescriptor);
|
|
3863
|
-
if (!matchingIndex) {
|
|
3864
|
-
return null;
|
|
3865
|
-
}
|
|
3866
|
-
return [...matchingIndex.fields, "_creationTime", "_id"];
|
|
3867
|
-
}
|
|
3868
|
-
async getAllIndexesForTable(tableName) {
|
|
3869
|
-
const indexes = [...getStandardIndexes()];
|
|
3870
|
-
const tableSchema = await this.getTableSchema(tableName);
|
|
3871
|
-
const schemaIndexes = tableSchema?.indexes;
|
|
3872
|
-
if (schemaIndexes) {
|
|
3873
|
-
for (const idx of schemaIndexes) {
|
|
3874
|
-
indexes.push({
|
|
3875
|
-
name: idx.indexDescriptor,
|
|
3876
|
-
fields: [...idx.fields, "_creationTime", "_id"]
|
|
3877
|
-
});
|
|
3878
|
-
}
|
|
3879
|
-
}
|
|
3880
|
-
return indexes;
|
|
3881
|
-
}
|
|
3882
|
-
async getSearchIndexConfig(tableName, indexDescriptor) {
|
|
3883
|
-
const tableSchema = await this.getTableSchema(tableName);
|
|
3884
|
-
const searchIndexes = tableSchema?.searchIndexes;
|
|
3885
|
-
return searchIndexes?.find((idx) => idx.indexDescriptor === indexDescriptor) ?? null;
|
|
3886
|
-
}
|
|
3887
|
-
async getVectorIndexConfig(tableName, indexDescriptor) {
|
|
3888
|
-
const tableSchema = await this.getTableSchema(tableName);
|
|
3889
|
-
const vectorIndexes = tableSchema?.vectorIndexes;
|
|
3890
|
-
return vectorIndexes?.find((idx) => idx.indexDescriptor === indexDescriptor) ?? null;
|
|
3891
|
-
}
|
|
3892
|
-
async getAllVectorIndexes() {
|
|
3893
|
-
const schemaDefinition = await this.getSchemaDefinition();
|
|
3894
|
-
if (!schemaDefinition?.tables) {
|
|
3895
|
-
return [];
|
|
3896
|
-
}
|
|
3897
|
-
const allVectorIndexes = [];
|
|
3898
|
-
for (const [tableName, tableSchema] of Object.entries(schemaDefinition.tables)) {
|
|
3899
|
-
const vectorIndexes = tableSchema?.vectorIndexes;
|
|
3900
|
-
if (vectorIndexes) {
|
|
3901
|
-
for (const vectorIndex of vectorIndexes) {
|
|
3902
|
-
allVectorIndexes.push({
|
|
3903
|
-
tableName,
|
|
3904
|
-
indexDescriptor: vectorIndex.indexDescriptor,
|
|
3905
|
-
vectorField: vectorIndex.vectorField,
|
|
3906
|
-
filterFields: vectorIndex.filterFields ?? []
|
|
3907
|
-
});
|
|
3908
|
-
}
|
|
3909
|
-
}
|
|
3910
|
-
}
|
|
3911
|
-
return allVectorIndexes;
|
|
3912
|
-
}
|
|
3913
|
-
async getAllSearchIndexes() {
|
|
3914
|
-
const schemaDefinition = await this.getSchemaDefinition();
|
|
3915
|
-
if (!schemaDefinition?.tables) {
|
|
3916
|
-
return [];
|
|
3917
|
-
}
|
|
3918
|
-
const allSearchIndexes = [];
|
|
3919
|
-
for (const [tableName, tableSchema] of Object.entries(schemaDefinition.tables)) {
|
|
3920
|
-
const searchIndexes = tableSchema?.searchIndexes;
|
|
3921
|
-
if (searchIndexes) {
|
|
3922
|
-
for (const searchIndex of searchIndexes) {
|
|
3923
|
-
allSearchIndexes.push({
|
|
3924
|
-
tableName,
|
|
3925
|
-
indexDescriptor: searchIndex.indexDescriptor,
|
|
3926
|
-
searchField: searchIndex.searchField,
|
|
3927
|
-
filterFields: searchIndex.filterFields ?? []
|
|
3928
|
-
});
|
|
3929
|
-
}
|
|
3930
|
-
}
|
|
3931
|
-
}
|
|
3932
|
-
return allSearchIndexes;
|
|
3933
|
-
}
|
|
3934
|
-
async getTableNames() {
|
|
3935
|
-
const schemaDefinition = await this.getSchemaDefinition();
|
|
3936
|
-
if (!schemaDefinition?.tables) {
|
|
3937
|
-
return [];
|
|
3938
|
-
}
|
|
3939
|
-
return Object.keys(schemaDefinition.tables);
|
|
3940
|
-
}
|
|
3941
|
-
async getSchemaDefinition() {
|
|
3942
|
-
if (this.cachedSchemaDefinition !== undefined) {
|
|
3943
|
-
return this.cachedSchemaDefinition;
|
|
3944
|
-
}
|
|
3945
|
-
try {
|
|
3946
|
-
const schemaModule = await loadConvexModule("schema", { hint: "schema", componentPath: this.componentPath });
|
|
3947
|
-
this.cachedSchemaDefinition = schemaModule.default ?? null;
|
|
3948
|
-
} catch (error) {
|
|
3949
|
-
if (!isMissingSchemaModuleError(error)) {
|
|
3950
|
-
console.warn("Failed to load Convex schema definition:", error);
|
|
3951
|
-
}
|
|
3952
|
-
this.cachedSchemaDefinition = null;
|
|
3953
|
-
}
|
|
3954
|
-
return this.cachedSchemaDefinition;
|
|
3955
|
-
}
|
|
3956
|
-
}
|
|
3957
|
-
function isMissingSchemaModuleError(error) {
|
|
3958
|
-
if (!error)
|
|
3959
|
-
return false;
|
|
3960
|
-
const errorString = String(error);
|
|
3961
|
-
const isMissing = errorString.includes('Unable to resolve module "schema"') || errorString.includes("Module not found: schema") || errorString.includes('Unable to resolve module "convex/schema"');
|
|
3962
|
-
if (isMissing)
|
|
3963
|
-
return true;
|
|
3964
|
-
const causes = error.causes;
|
|
3965
|
-
if (Array.isArray(causes)) {
|
|
3966
|
-
return causes.some(isMissingSchemaModuleError);
|
|
3967
|
-
}
|
|
3968
|
-
const cause = error.cause;
|
|
3969
|
-
if (cause) {
|
|
3970
|
-
return isMissingSchemaModuleError(cause);
|
|
3971
|
-
}
|
|
3972
|
-
return false;
|
|
3973
|
-
}
|
|
3974
|
-
var init_schema_service = __esm(() => {
|
|
3975
|
-
init_index_manager();
|
|
3976
|
-
init_validator2();
|
|
3977
|
-
init_module_loader();
|
|
3978
|
-
});
|
|
3701
|
+
// ../core/dist/id-codec/base32.js
|
|
3979
3702
|
function base32Encode(data) {
|
|
3980
3703
|
if (data.length === 0)
|
|
3981
3704
|
return "";
|
|
@@ -4027,8 +3750,7 @@ function isValidBase32(str) {
|
|
|
4027
3750
|
}
|
|
4028
3751
|
return true;
|
|
4029
3752
|
}
|
|
4030
|
-
var ALPHABET = "0123456789abcdefghjkmnpqrstvwxyz";
|
|
4031
|
-
var ALPHABET_MAP;
|
|
3753
|
+
var ALPHABET = "0123456789abcdefghjkmnpqrstvwxyz", ALPHABET_MAP;
|
|
4032
3754
|
var init_base32 = __esm(() => {
|
|
4033
3755
|
ALPHABET_MAP = new Map;
|
|
4034
3756
|
for (let i2 = 0;i2 < ALPHABET.length; i2++) {
|
|
@@ -4042,6 +3764,8 @@ var init_base32 = __esm(() => {
|
|
|
4042
3764
|
ALPHABET_MAP.set("o", 0);
|
|
4043
3765
|
ALPHABET_MAP.set("O", 0);
|
|
4044
3766
|
});
|
|
3767
|
+
|
|
3768
|
+
// ../core/dist/id-codec/vint.js
|
|
4045
3769
|
function vintEncode(value) {
|
|
4046
3770
|
if (value < 0) {
|
|
4047
3771
|
throw new Error("VInt cannot encode negative numbers");
|
|
@@ -4119,6 +3843,8 @@ function vintDecode(data, offset = 0) {
|
|
|
4119
3843
|
}
|
|
4120
3844
|
throw new Error("VInt decode: invalid prefix");
|
|
4121
3845
|
}
|
|
3846
|
+
|
|
3847
|
+
// ../core/dist/id-codec/fletcher16.js
|
|
4122
3848
|
function fletcher16(data) {
|
|
4123
3849
|
let sum1 = 0;
|
|
4124
3850
|
let sum2 = 0;
|
|
@@ -4134,6 +3860,14 @@ function verifyFletcher16(data, checksum) {
|
|
|
4134
3860
|
const computed = fletcher16(data);
|
|
4135
3861
|
return computed[0] === checksum[0] && computed[1] === checksum[1];
|
|
4136
3862
|
}
|
|
3863
|
+
|
|
3864
|
+
// ../core/dist/utils/crypto.js
|
|
3865
|
+
var weakRandomState;
|
|
3866
|
+
var init_crypto = __esm(() => {
|
|
3867
|
+
weakRandomState = (Date.now() ^ 2654435769) >>> 0;
|
|
3868
|
+
});
|
|
3869
|
+
|
|
3870
|
+
// ../core/dist/id-codec/document-id.js
|
|
4137
3871
|
function encodeDocumentId(tableNumber, internalId) {
|
|
4138
3872
|
if (internalId.length !== INTERNAL_ID_LENGTH) {
|
|
4139
3873
|
throw new Error(`Internal ID must be exactly ${INTERNAL_ID_LENGTH} bytes, got ${internalId.length}`);
|
|
@@ -4189,15 +3923,19 @@ function internalIdToHex(internalId) {
|
|
|
4189
3923
|
}
|
|
4190
3924
|
return hex;
|
|
4191
3925
|
}
|
|
4192
|
-
var INTERNAL_ID_LENGTH = 16;
|
|
4193
|
-
var MIN_ENCODED_LENGTH = 31;
|
|
4194
|
-
var MAX_ENCODED_LENGTH = 37;
|
|
4195
|
-
var cryptoGetRandomValues;
|
|
3926
|
+
var INTERNAL_ID_LENGTH = 16, MIN_ENCODED_LENGTH = 31, MAX_ENCODED_LENGTH = 37;
|
|
4196
3927
|
var init_document_id = __esm(() => {
|
|
4197
3928
|
init_base32();
|
|
4198
|
-
|
|
3929
|
+
init_crypto();
|
|
4199
3930
|
});
|
|
3931
|
+
|
|
3932
|
+
// src/sqlite-docstore.ts
|
|
3933
|
+
import { Database } from "bun:sqlite";
|
|
3934
|
+
|
|
3935
|
+
// ../docstore-sqlite-base/dist/base.js
|
|
4200
3936
|
init_values();
|
|
3937
|
+
|
|
3938
|
+
// ../core/dist/docstore/interface.js
|
|
4201
3939
|
function documentIdKey(id) {
|
|
4202
3940
|
return `${id.table}:${id.internalId}`;
|
|
4203
3941
|
}
|
|
@@ -4212,6 +3950,7 @@ function getPrevRevQueryKey(query) {
|
|
|
4212
3950
|
function getExactRevQueryKey(query) {
|
|
4213
3951
|
return `${documentIdKey(query.id)}:${query.ts}:${query.prev_ts}`;
|
|
4214
3952
|
}
|
|
3953
|
+
// ../core/dist/docstore/sql/search-schema.js
|
|
4215
3954
|
var SEARCH_INDEXES_FTS_SCHEMA = `
|
|
4216
3955
|
CREATE VIRTUAL TABLE IF NOT EXISTS search_indexes USING fts5(
|
|
4217
3956
|
index_id UNINDEXED,
|
|
@@ -4244,6 +3983,8 @@ function extractSearchContent(docValue, searchField) {
|
|
|
4244
3983
|
}
|
|
4245
3984
|
return null;
|
|
4246
3985
|
}
|
|
3986
|
+
|
|
3987
|
+
// ../core/dist/docstore/sql/schema.js
|
|
4247
3988
|
var DOCUMENTS_TABLE_SCHEMA = `
|
|
4248
3989
|
CREATE TABLE IF NOT EXISTS documents (
|
|
4249
3990
|
id BLOB NOT NULL,
|
|
@@ -4276,7 +4017,7 @@ var GLOBALS_TABLE_SCHEMA = `
|
|
|
4276
4017
|
json_value TEXT NOT NULL
|
|
4277
4018
|
);
|
|
4278
4019
|
`;
|
|
4279
|
-
|
|
4020
|
+
// ../core/dist/utils/long.js
|
|
4280
4021
|
class Long {
|
|
4281
4022
|
low;
|
|
4282
4023
|
high;
|
|
@@ -4364,7 +4105,7 @@ var TWO_PWR_16_DBL = 1 << 16;
|
|
|
4364
4105
|
var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;
|
|
4365
4106
|
var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;
|
|
4366
4107
|
var MAX_UNSIGNED_VALUE = new Long(4294967295 | 0, 4294967295 | 0);
|
|
4367
|
-
|
|
4108
|
+
// ../core/dist/utils/timestamp.js
|
|
4368
4109
|
class TimestampOracle {
|
|
4369
4110
|
logicalClock;
|
|
4370
4111
|
allocationQueue = Promise.resolve();
|
|
@@ -4390,59 +4131,421 @@ class TimestampOracle {
|
|
|
4390
4131
|
if (this.logicalClock === 0n) {
|
|
4391
4132
|
return BigInt(Date.now());
|
|
4392
4133
|
}
|
|
4393
|
-
return this.logicalClock;
|
|
4134
|
+
return this.logicalClock;
|
|
4135
|
+
}
|
|
4136
|
+
observeTimestamp(ts) {
|
|
4137
|
+
if (ts > this.logicalClock) {
|
|
4138
|
+
this.logicalClock = ts;
|
|
4139
|
+
}
|
|
4140
|
+
}
|
|
4141
|
+
reset(ts = 0n) {
|
|
4142
|
+
this.logicalClock = ts;
|
|
4143
|
+
}
|
|
4144
|
+
}
|
|
4145
|
+
// ../core/dist/utils/keyspace.js
|
|
4146
|
+
var TABLE_PREFIX = "table";
|
|
4147
|
+
var INDEX_PREFIX = "index";
|
|
4148
|
+
function encodeComponent(component) {
|
|
4149
|
+
return encodeURIComponent(component);
|
|
4150
|
+
}
|
|
4151
|
+
function tableKeyspace(table) {
|
|
4152
|
+
return { kind: "table", table };
|
|
4153
|
+
}
|
|
4154
|
+
function indexKeyspace(table, index) {
|
|
4155
|
+
return { kind: "index", table, index };
|
|
4156
|
+
}
|
|
4157
|
+
function keyspaceId(namespace) {
|
|
4158
|
+
if (namespace.kind === "table") {
|
|
4159
|
+
return `${TABLE_PREFIX}:${encodeComponent(namespace.table)}`;
|
|
4160
|
+
}
|
|
4161
|
+
return `${INDEX_PREFIX}:${encodeComponent(namespace.table)}:${encodeComponent(namespace.index)}`;
|
|
4162
|
+
}
|
|
4163
|
+
function tableKeyspaceId(table) {
|
|
4164
|
+
return keyspaceId(tableKeyspace(table));
|
|
4165
|
+
}
|
|
4166
|
+
function indexKeyspaceId(table, index) {
|
|
4167
|
+
return keyspaceId(indexKeyspace(table, index));
|
|
4168
|
+
}
|
|
4169
|
+
function decodeIndexId(indexId) {
|
|
4170
|
+
const decoded = (() => {
|
|
4171
|
+
try {
|
|
4172
|
+
return hexToString(indexId);
|
|
4173
|
+
} catch {
|
|
4174
|
+
return indexId;
|
|
4175
|
+
}
|
|
4176
|
+
})();
|
|
4177
|
+
const separatorIndex = decoded.indexOf(":");
|
|
4178
|
+
if (separatorIndex === -1) {
|
|
4179
|
+
throw new Error(`Invalid index id: ${indexId}`);
|
|
4180
|
+
}
|
|
4181
|
+
return {
|
|
4182
|
+
table: decoded.slice(0, separatorIndex),
|
|
4183
|
+
index: decoded.slice(separatorIndex + 1)
|
|
4184
|
+
};
|
|
4185
|
+
}
|
|
4186
|
+
// ../core/dist/queryengine/indexing/index-key-codec.js
|
|
4187
|
+
var TypeTag;
|
|
4188
|
+
(function(TypeTag2) {
|
|
4189
|
+
TypeTag2[TypeTag2["Null"] = 0] = "Null";
|
|
4190
|
+
TypeTag2[TypeTag2["False"] = 16] = "False";
|
|
4191
|
+
TypeTag2[TypeTag2["True"] = 17] = "True";
|
|
4192
|
+
TypeTag2[TypeTag2["NegativeInfinity"] = 32] = "NegativeInfinity";
|
|
4193
|
+
TypeTag2[TypeTag2["NegativeNumber"] = 33] = "NegativeNumber";
|
|
4194
|
+
TypeTag2[TypeTag2["NegativeZero"] = 34] = "NegativeZero";
|
|
4195
|
+
TypeTag2[TypeTag2["Zero"] = 35] = "Zero";
|
|
4196
|
+
TypeTag2[TypeTag2["PositiveNumber"] = 36] = "PositiveNumber";
|
|
4197
|
+
TypeTag2[TypeTag2["PositiveInfinity"] = 37] = "PositiveInfinity";
|
|
4198
|
+
TypeTag2[TypeTag2["NaN"] = 38] = "NaN";
|
|
4199
|
+
TypeTag2[TypeTag2["NegativeBigInt"] = 48] = "NegativeBigInt";
|
|
4200
|
+
TypeTag2[TypeTag2["ZeroBigInt"] = 49] = "ZeroBigInt";
|
|
4201
|
+
TypeTag2[TypeTag2["PositiveBigInt"] = 50] = "PositiveBigInt";
|
|
4202
|
+
TypeTag2[TypeTag2["String"] = 64] = "String";
|
|
4203
|
+
TypeTag2[TypeTag2["Bytes"] = 80] = "Bytes";
|
|
4204
|
+
})(TypeTag || (TypeTag = {}));
|
|
4205
|
+
function encodeNumber(n) {
|
|
4206
|
+
const buffer = new ArrayBuffer(8);
|
|
4207
|
+
const view = new DataView(buffer);
|
|
4208
|
+
view.setFloat64(0, n, false);
|
|
4209
|
+
const bytes = new Uint8Array(buffer);
|
|
4210
|
+
if (n >= 0) {
|
|
4211
|
+
bytes[0] ^= 128;
|
|
4212
|
+
} else {
|
|
4213
|
+
for (let i2 = 0;i2 < 8; i2++) {
|
|
4214
|
+
bytes[i2] ^= 255;
|
|
4215
|
+
}
|
|
4216
|
+
}
|
|
4217
|
+
return bytes;
|
|
4218
|
+
}
|
|
4219
|
+
function encodeBigInt(n) {
|
|
4220
|
+
const INT64_MIN = -(2n ** 63n);
|
|
4221
|
+
const INT64_MAX = 2n ** 63n - 1n;
|
|
4222
|
+
if (n < INT64_MIN)
|
|
4223
|
+
n = INT64_MIN;
|
|
4224
|
+
if (n > INT64_MAX)
|
|
4225
|
+
n = INT64_MAX;
|
|
4226
|
+
const buffer = new ArrayBuffer(8);
|
|
4227
|
+
const view = new DataView(buffer);
|
|
4228
|
+
const unsigned = n < 0n ? n + 2n ** 64n : n;
|
|
4229
|
+
view.setBigUint64(0, unsigned, false);
|
|
4230
|
+
const bytes = new Uint8Array(buffer);
|
|
4231
|
+
bytes[0] ^= 128;
|
|
4232
|
+
return bytes;
|
|
4233
|
+
}
|
|
4234
|
+
function encodeString(s) {
|
|
4235
|
+
const encoder = new TextEncoder;
|
|
4236
|
+
const raw = encoder.encode(s);
|
|
4237
|
+
let nullCount = 0;
|
|
4238
|
+
for (const byte of raw) {
|
|
4239
|
+
if (byte === 0)
|
|
4240
|
+
nullCount++;
|
|
4241
|
+
}
|
|
4242
|
+
const result = new Uint8Array(raw.length + nullCount + 2);
|
|
4243
|
+
let writeIndex = 0;
|
|
4244
|
+
for (const byte of raw) {
|
|
4245
|
+
if (byte === 0) {
|
|
4246
|
+
result[writeIndex++] = 0;
|
|
4247
|
+
result[writeIndex++] = 1;
|
|
4248
|
+
} else {
|
|
4249
|
+
result[writeIndex++] = byte;
|
|
4250
|
+
}
|
|
4251
|
+
}
|
|
4252
|
+
result[writeIndex++] = 0;
|
|
4253
|
+
result[writeIndex++] = 0;
|
|
4254
|
+
return result;
|
|
4255
|
+
}
|
|
4256
|
+
function encodeValue(value) {
|
|
4257
|
+
if (value === null || value === undefined) {
|
|
4258
|
+
return new Uint8Array([TypeTag.Null]);
|
|
4259
|
+
}
|
|
4260
|
+
if (typeof value === "boolean") {
|
|
4261
|
+
return new Uint8Array([value ? TypeTag.True : TypeTag.False]);
|
|
4262
|
+
}
|
|
4263
|
+
if (typeof value === "number") {
|
|
4264
|
+
if (Number.isNaN(value)) {
|
|
4265
|
+
return new Uint8Array([TypeTag.NaN]);
|
|
4266
|
+
}
|
|
4267
|
+
if (!Number.isFinite(value)) {
|
|
4268
|
+
return new Uint8Array([value === -Infinity ? TypeTag.NegativeInfinity : TypeTag.PositiveInfinity]);
|
|
4269
|
+
}
|
|
4270
|
+
if (value === 0) {
|
|
4271
|
+
return new Uint8Array([Object.is(value, -0) ? TypeTag.NegativeZero : TypeTag.Zero]);
|
|
4272
|
+
}
|
|
4273
|
+
const tag = value > 0 ? TypeTag.PositiveNumber : TypeTag.NegativeNumber;
|
|
4274
|
+
const encoded = encodeNumber(value);
|
|
4275
|
+
const result = new Uint8Array(1 + encoded.length);
|
|
4276
|
+
result[0] = tag;
|
|
4277
|
+
result.set(encoded, 1);
|
|
4278
|
+
return result;
|
|
4279
|
+
}
|
|
4280
|
+
if (typeof value === "bigint") {
|
|
4281
|
+
if (value === 0n) {
|
|
4282
|
+
return new Uint8Array([TypeTag.ZeroBigInt]);
|
|
4283
|
+
}
|
|
4284
|
+
const tag = value > 0n ? TypeTag.PositiveBigInt : TypeTag.NegativeBigInt;
|
|
4285
|
+
const encoded = encodeBigInt(value);
|
|
4286
|
+
const result = new Uint8Array(1 + encoded.length);
|
|
4287
|
+
result[0] = tag;
|
|
4288
|
+
result.set(encoded, 1);
|
|
4289
|
+
return result;
|
|
4290
|
+
}
|
|
4291
|
+
if (typeof value === "string") {
|
|
4292
|
+
const encoded = encodeString(value);
|
|
4293
|
+
const result = new Uint8Array(1 + encoded.length);
|
|
4294
|
+
result[0] = TypeTag.String;
|
|
4295
|
+
result.set(encoded, 1);
|
|
4296
|
+
return result;
|
|
4297
|
+
}
|
|
4298
|
+
if (value instanceof ArrayBuffer || value instanceof Uint8Array) {
|
|
4299
|
+
const bytes = value instanceof Uint8Array ? value : new Uint8Array(value);
|
|
4300
|
+
const result = new Uint8Array(1 + bytes.length + 2);
|
|
4301
|
+
result[0] = TypeTag.Bytes;
|
|
4302
|
+
result.set(bytes, 1);
|
|
4303
|
+
result[result.length - 2] = 0;
|
|
4304
|
+
result[result.length - 1] = 0;
|
|
4305
|
+
return result;
|
|
4306
|
+
}
|
|
4307
|
+
throw new Error(`Cannot encode value of type ${typeof value} in index key`);
|
|
4308
|
+
}
|
|
4309
|
+
function encodeIndexKey(values) {
|
|
4310
|
+
if (values.length === 0) {
|
|
4311
|
+
return new ArrayBuffer(0);
|
|
4312
|
+
}
|
|
4313
|
+
const encoded = values.map(encodeValue);
|
|
4314
|
+
const totalLength = encoded.reduce((sum, arr) => sum + arr.length, 0);
|
|
4315
|
+
const result = new Uint8Array(totalLength);
|
|
4316
|
+
let offset = 0;
|
|
4317
|
+
for (const chunk of encoded) {
|
|
4318
|
+
result.set(chunk, offset);
|
|
4319
|
+
offset += chunk.length;
|
|
4320
|
+
}
|
|
4321
|
+
return result.buffer;
|
|
4322
|
+
}
|
|
4323
|
+
function compareIndexKeys(a, b) {
|
|
4324
|
+
const viewA = new Uint8Array(a);
|
|
4325
|
+
const viewB = new Uint8Array(b);
|
|
4326
|
+
const minLen = Math.min(viewA.length, viewB.length);
|
|
4327
|
+
for (let i2 = 0;i2 < minLen; i2++) {
|
|
4328
|
+
if (viewA[i2] < viewB[i2])
|
|
4329
|
+
return -1;
|
|
4330
|
+
if (viewA[i2] > viewB[i2])
|
|
4331
|
+
return 1;
|
|
4332
|
+
}
|
|
4333
|
+
if (viewA.length < viewB.length)
|
|
4334
|
+
return -1;
|
|
4335
|
+
if (viewA.length > viewB.length)
|
|
4336
|
+
return 1;
|
|
4337
|
+
return 0;
|
|
4338
|
+
}
|
|
4339
|
+
function indexKeysEqual(a, b) {
|
|
4340
|
+
return compareIndexKeys(a, b) === 0;
|
|
4341
|
+
}
|
|
4342
|
+
|
|
4343
|
+
// ../core/dist/queryengine/indexing/index-manager.js
|
|
4344
|
+
function getFieldValue(doc, fieldPath) {
|
|
4345
|
+
const parts = fieldPath.split(".");
|
|
4346
|
+
let current = doc;
|
|
4347
|
+
for (const part of parts) {
|
|
4348
|
+
if (current === null || current === undefined) {
|
|
4349
|
+
return;
|
|
4350
|
+
}
|
|
4351
|
+
if (typeof current !== "object" || Array.isArray(current)) {
|
|
4352
|
+
return;
|
|
4353
|
+
}
|
|
4354
|
+
current = current[part];
|
|
4355
|
+
}
|
|
4356
|
+
return current;
|
|
4357
|
+
}
|
|
4358
|
+
function extractIndexKey(doc, fields) {
|
|
4359
|
+
const values = [];
|
|
4360
|
+
for (const field of fields) {
|
|
4361
|
+
const value = getFieldValue(doc, field);
|
|
4362
|
+
if (value === undefined) {
|
|
4363
|
+
return null;
|
|
4364
|
+
}
|
|
4365
|
+
values.push(value);
|
|
4366
|
+
}
|
|
4367
|
+
return encodeIndexKey(values);
|
|
4368
|
+
}
|
|
4369
|
+
function generateIndexUpdates(tableName, docId, newValue, oldValue, indexes) {
|
|
4370
|
+
const updates = [];
|
|
4371
|
+
for (const index of indexes) {
|
|
4372
|
+
const indexId = stringToHex(`${tableName}:${index.name}`);
|
|
4373
|
+
const oldKey = oldValue !== null ? extractIndexKey(oldValue, index.fields) : null;
|
|
4374
|
+
const newKey = newValue !== null ? extractIndexKey(newValue, index.fields) : null;
|
|
4375
|
+
const keyChanged = oldKey === null && newKey !== null || oldKey !== null && newKey === null || oldKey !== null && newKey !== null && !indexKeysEqual(oldKey, newKey);
|
|
4376
|
+
if (!keyChanged) {
|
|
4377
|
+
continue;
|
|
4378
|
+
}
|
|
4379
|
+
if (oldKey !== null) {
|
|
4380
|
+
updates.push({
|
|
4381
|
+
index_id: indexId,
|
|
4382
|
+
key: oldKey,
|
|
4383
|
+
value: { type: "Deleted" }
|
|
4384
|
+
});
|
|
4385
|
+
}
|
|
4386
|
+
if (newKey !== null) {
|
|
4387
|
+
updates.push({
|
|
4388
|
+
index_id: indexId,
|
|
4389
|
+
key: newKey,
|
|
4390
|
+
value: {
|
|
4391
|
+
type: "NonClustered",
|
|
4392
|
+
doc_id: docId
|
|
4393
|
+
}
|
|
4394
|
+
});
|
|
4395
|
+
}
|
|
4396
|
+
}
|
|
4397
|
+
return updates;
|
|
4398
|
+
}
|
|
4399
|
+
function getStandardIndexes() {
|
|
4400
|
+
return [
|
|
4401
|
+
{
|
|
4402
|
+
name: "by_creation_time",
|
|
4403
|
+
fields: ["_creationTime", "_id"]
|
|
4404
|
+
},
|
|
4405
|
+
{
|
|
4406
|
+
name: "by_id",
|
|
4407
|
+
fields: ["_id"]
|
|
4408
|
+
}
|
|
4409
|
+
];
|
|
4410
|
+
}
|
|
4411
|
+
|
|
4412
|
+
// ../core/dist/kernel/schema-service.js
|
|
4413
|
+
init_validator2();
|
|
4414
|
+
init_module_loader();
|
|
4415
|
+
|
|
4416
|
+
class SchemaService {
|
|
4417
|
+
cachedSchemaDefinition = undefined;
|
|
4418
|
+
tableCache = new Map;
|
|
4419
|
+
schemaValidator;
|
|
4420
|
+
componentPath;
|
|
4421
|
+
constructor(componentPath) {
|
|
4422
|
+
this.componentPath = componentPath;
|
|
4423
|
+
this.schemaValidator = new SchemaValidator(componentPath);
|
|
4424
|
+
}
|
|
4425
|
+
async validate(tableName, document) {
|
|
4426
|
+
try {
|
|
4427
|
+
await this.schemaValidator.validateDocument(tableName, document);
|
|
4428
|
+
} catch (error) {
|
|
4429
|
+
if (error instanceof ValidatorError) {
|
|
4430
|
+
throw new Error(error.message);
|
|
4431
|
+
}
|
|
4432
|
+
throw error;
|
|
4433
|
+
}
|
|
4434
|
+
}
|
|
4435
|
+
async getTableSchema(tableName) {
|
|
4436
|
+
if (this.tableCache.has(tableName)) {
|
|
4437
|
+
return this.tableCache.get(tableName) ?? null;
|
|
4438
|
+
}
|
|
4439
|
+
const schemaDefinition = await this.getSchemaDefinition();
|
|
4440
|
+
const tableSchema = schemaDefinition?.tables?.[tableName] ?? null;
|
|
4441
|
+
this.tableCache.set(tableName, tableSchema);
|
|
4442
|
+
return tableSchema;
|
|
4443
|
+
}
|
|
4444
|
+
async getIndexFieldsForTable(tableName, indexDescriptor) {
|
|
4445
|
+
if (indexDescriptor === "by_creation_time") {
|
|
4446
|
+
return ["_creationTime", "_id"];
|
|
4447
|
+
}
|
|
4448
|
+
if (indexDescriptor === "by_id") {
|
|
4449
|
+
return ["_id"];
|
|
4450
|
+
}
|
|
4451
|
+
const tableSchema = await this.getTableSchema(tableName);
|
|
4452
|
+
const dbIndexes = tableSchema?.indexes;
|
|
4453
|
+
const matchingIndex = dbIndexes?.find((idx) => idx.indexDescriptor === indexDescriptor);
|
|
4454
|
+
if (!matchingIndex) {
|
|
4455
|
+
return null;
|
|
4456
|
+
}
|
|
4457
|
+
return [...matchingIndex.fields, "_creationTime", "_id"];
|
|
4458
|
+
}
|
|
4459
|
+
async getAllIndexesForTable(tableName) {
|
|
4460
|
+
const indexes = [...getStandardIndexes()];
|
|
4461
|
+
const tableSchema = await this.getTableSchema(tableName);
|
|
4462
|
+
const schemaIndexes = tableSchema?.indexes;
|
|
4463
|
+
if (schemaIndexes) {
|
|
4464
|
+
for (const idx of schemaIndexes) {
|
|
4465
|
+
indexes.push({
|
|
4466
|
+
name: idx.indexDescriptor,
|
|
4467
|
+
fields: [...idx.fields, "_creationTime", "_id"]
|
|
4468
|
+
});
|
|
4469
|
+
}
|
|
4470
|
+
}
|
|
4471
|
+
return indexes;
|
|
4472
|
+
}
|
|
4473
|
+
async getSearchIndexConfig(tableName, indexDescriptor) {
|
|
4474
|
+
const tableSchema = await this.getTableSchema(tableName);
|
|
4475
|
+
const searchIndexes = tableSchema?.searchIndexes;
|
|
4476
|
+
return searchIndexes?.find((idx) => idx.indexDescriptor === indexDescriptor) ?? null;
|
|
4477
|
+
}
|
|
4478
|
+
async getVectorIndexConfig(tableName, indexDescriptor) {
|
|
4479
|
+
const tableSchema = await this.getTableSchema(tableName);
|
|
4480
|
+
const vectorIndexes = tableSchema?.vectorIndexes;
|
|
4481
|
+
return vectorIndexes?.find((idx) => idx.indexDescriptor === indexDescriptor) ?? null;
|
|
4482
|
+
}
|
|
4483
|
+
async getAllVectorIndexes() {
|
|
4484
|
+
const schemaDefinition = await this.getSchemaDefinition();
|
|
4485
|
+
if (!schemaDefinition?.tables) {
|
|
4486
|
+
return [];
|
|
4487
|
+
}
|
|
4488
|
+
const allVectorIndexes = [];
|
|
4489
|
+
for (const [tableName, tableSchema] of Object.entries(schemaDefinition.tables)) {
|
|
4490
|
+
const vectorIndexes = tableSchema?.vectorIndexes;
|
|
4491
|
+
if (vectorIndexes) {
|
|
4492
|
+
for (const vectorIndex of vectorIndexes) {
|
|
4493
|
+
allVectorIndexes.push({
|
|
4494
|
+
tableName,
|
|
4495
|
+
indexDescriptor: vectorIndex.indexDescriptor,
|
|
4496
|
+
vectorField: vectorIndex.vectorField,
|
|
4497
|
+
filterFields: vectorIndex.filterFields ?? []
|
|
4498
|
+
});
|
|
4499
|
+
}
|
|
4500
|
+
}
|
|
4501
|
+
}
|
|
4502
|
+
return allVectorIndexes;
|
|
4394
4503
|
}
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4504
|
+
async getAllSearchIndexes() {
|
|
4505
|
+
const schemaDefinition = await this.getSchemaDefinition();
|
|
4506
|
+
if (!schemaDefinition?.tables) {
|
|
4507
|
+
return [];
|
|
4398
4508
|
}
|
|
4509
|
+
const allSearchIndexes = [];
|
|
4510
|
+
for (const [tableName, tableSchema] of Object.entries(schemaDefinition.tables)) {
|
|
4511
|
+
const searchIndexes = tableSchema?.searchIndexes;
|
|
4512
|
+
if (searchIndexes) {
|
|
4513
|
+
for (const searchIndex of searchIndexes) {
|
|
4514
|
+
allSearchIndexes.push({
|
|
4515
|
+
tableName,
|
|
4516
|
+
indexDescriptor: searchIndex.indexDescriptor,
|
|
4517
|
+
searchField: searchIndex.searchField,
|
|
4518
|
+
filterFields: searchIndex.filterFields ?? []
|
|
4519
|
+
});
|
|
4520
|
+
}
|
|
4521
|
+
}
|
|
4522
|
+
}
|
|
4523
|
+
return allSearchIndexes;
|
|
4399
4524
|
}
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
function encodeComponent(component) {
|
|
4407
|
-
return encodeURIComponent(component);
|
|
4408
|
-
}
|
|
4409
|
-
function tableKeyspace(table) {
|
|
4410
|
-
return { kind: "table", table };
|
|
4411
|
-
}
|
|
4412
|
-
function indexKeyspace(table, index) {
|
|
4413
|
-
return { kind: "index", table, index };
|
|
4414
|
-
}
|
|
4415
|
-
function keyspaceId(namespace) {
|
|
4416
|
-
if (namespace.kind === "table") {
|
|
4417
|
-
return `${TABLE_PREFIX}:${encodeComponent(namespace.table)}`;
|
|
4525
|
+
async getTableNames() {
|
|
4526
|
+
const schemaDefinition = await this.getSchemaDefinition();
|
|
4527
|
+
if (!schemaDefinition?.tables) {
|
|
4528
|
+
return [];
|
|
4529
|
+
}
|
|
4530
|
+
return Object.keys(schemaDefinition.tables);
|
|
4418
4531
|
}
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
}
|
|
4424
|
-
function indexKeyspaceId(table, index) {
|
|
4425
|
-
return keyspaceId(indexKeyspace(table, index));
|
|
4426
|
-
}
|
|
4427
|
-
function decodeIndexId(indexId) {
|
|
4428
|
-
const decoded = (() => {
|
|
4532
|
+
async getSchemaDefinition() {
|
|
4533
|
+
if (this.cachedSchemaDefinition !== undefined) {
|
|
4534
|
+
return this.cachedSchemaDefinition;
|
|
4535
|
+
}
|
|
4429
4536
|
try {
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4537
|
+
const schemaModule = await loadConvexModule("schema", { hint: "schema", componentPath: this.componentPath });
|
|
4538
|
+
this.cachedSchemaDefinition = schemaModule.default ?? null;
|
|
4539
|
+
} catch (error) {
|
|
4540
|
+
if (!isMissingSchemaModuleError(error)) {
|
|
4541
|
+
console.warn("Failed to load Convex schema definition:", error);
|
|
4542
|
+
}
|
|
4543
|
+
this.cachedSchemaDefinition = null;
|
|
4433
4544
|
}
|
|
4434
|
-
|
|
4435
|
-
const separatorIndex = decoded.indexOf(":");
|
|
4436
|
-
if (separatorIndex === -1) {
|
|
4437
|
-
throw new Error(`Invalid index id: ${indexId}`);
|
|
4545
|
+
return this.cachedSchemaDefinition;
|
|
4438
4546
|
}
|
|
4439
|
-
return {
|
|
4440
|
-
table: decoded.slice(0, separatorIndex),
|
|
4441
|
-
index: decoded.slice(separatorIndex + 1)
|
|
4442
|
-
};
|
|
4443
4547
|
}
|
|
4444
|
-
|
|
4445
|
-
init_index_key_codec();
|
|
4548
|
+
// ../core/dist/queryengine/filters.js
|
|
4446
4549
|
function isSimpleObject3(value) {
|
|
4447
4550
|
const isObject = typeof value === "object" && value !== null;
|
|
4448
4551
|
if (!isObject)
|
|
@@ -4463,9 +4566,13 @@ function evaluateFieldPath(fieldPath, document) {
|
|
|
4463
4566
|
}
|
|
4464
4567
|
return current;
|
|
4465
4568
|
}
|
|
4569
|
+
// ../core/dist/id-codec/index.js
|
|
4466
4570
|
init_base32();
|
|
4467
4571
|
init_document_id();
|
|
4572
|
+
|
|
4573
|
+
// ../core/dist/id-codec/id-conversion.js
|
|
4468
4574
|
init_document_id();
|
|
4575
|
+
// ../core/dist/queryengine/developer-id.js
|
|
4469
4576
|
function parseDeveloperId(developerId) {
|
|
4470
4577
|
if (isValidDocumentId(developerId)) {
|
|
4471
4578
|
try {
|
|
@@ -4499,10 +4606,12 @@ function parseStorageId(storageId) {
|
|
|
4499
4606
|
function isTablePlaceholder(table) {
|
|
4500
4607
|
return table.startsWith("#");
|
|
4501
4608
|
}
|
|
4609
|
+
// ../core/dist/query/planner.js
|
|
4502
4610
|
init_interface();
|
|
4611
|
+
// ../core/dist/query/actions.js
|
|
4503
4612
|
init_interface();
|
|
4504
|
-
init_index_key_codec();
|
|
4505
4613
|
|
|
4614
|
+
// ../core/dist/queryengine/indexing/read-write-set.js
|
|
4506
4615
|
class RangeSet {
|
|
4507
4616
|
ranges = new Map;
|
|
4508
4617
|
addDocument(docId) {
|
|
@@ -4612,6 +4721,7 @@ function deserializeKeyRange(serialized) {
|
|
|
4612
4721
|
};
|
|
4613
4722
|
}
|
|
4614
4723
|
|
|
4724
|
+
// ../core/dist/kernel/access-log.js
|
|
4615
4725
|
class AccessLog {
|
|
4616
4726
|
ranges = new RangeSet;
|
|
4617
4727
|
addDocument(docId) {
|
|
@@ -4635,6 +4745,7 @@ class AccessLog {
|
|
|
4635
4745
|
return this.ranges.getRanges().map(serializeKeyRange);
|
|
4636
4746
|
}
|
|
4637
4747
|
}
|
|
4748
|
+
// ../core/dist/tables/memory-table-registry.js
|
|
4638
4749
|
init_interface();
|
|
4639
4750
|
|
|
4640
4751
|
class MemoryTableRegistry {
|
|
@@ -4731,6 +4842,7 @@ function getGlobalTableRegistry() {
|
|
|
4731
4842
|
return globalRegistry;
|
|
4732
4843
|
}
|
|
4733
4844
|
|
|
4845
|
+
// ../core/dist/kernel/kernel-context.js
|
|
4734
4846
|
class KernelContext {
|
|
4735
4847
|
authContext;
|
|
4736
4848
|
componentPath;
|
|
@@ -4840,56 +4952,14 @@ class KernelContext {
|
|
|
4840
4952
|
return this.writeLog.serialize();
|
|
4841
4953
|
}
|
|
4842
4954
|
}
|
|
4843
|
-
var resolveAsyncLocalStorage = () => {
|
|
4844
|
-
if (typeof globalThis !== "undefined" && globalThis.AsyncLocalStorage) {
|
|
4845
|
-
return globalThis.AsyncLocalStorage;
|
|
4846
|
-
}
|
|
4847
|
-
try {
|
|
4848
|
-
const req = Function("return typeof require !== 'undefined' ? require : undefined")();
|
|
4849
|
-
if (!req) {
|
|
4850
|
-
return;
|
|
4851
|
-
}
|
|
4852
|
-
const mod = req("node:async_hooks");
|
|
4853
|
-
return mod.AsyncLocalStorage;
|
|
4854
|
-
} catch {
|
|
4855
|
-
return;
|
|
4856
|
-
}
|
|
4857
|
-
};
|
|
4858
|
-
var AsyncLocalStorageCtor = resolveAsyncLocalStorage();
|
|
4859
4955
|
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
stack = [];
|
|
4863
|
-
constructor() {
|
|
4864
|
-
if (AsyncLocalStorageCtor) {
|
|
4865
|
-
this.als = new AsyncLocalStorageCtor;
|
|
4866
|
-
}
|
|
4867
|
-
}
|
|
4868
|
-
getStore() {
|
|
4869
|
-
if (this.als) {
|
|
4870
|
-
return this.als.getStore() ?? undefined;
|
|
4871
|
-
}
|
|
4872
|
-
return this.stack.length > 0 ? this.stack[this.stack.length - 1] : undefined;
|
|
4873
|
-
}
|
|
4874
|
-
run(value, callback) {
|
|
4875
|
-
if (this.als) {
|
|
4876
|
-
return this.als.run(value, callback);
|
|
4877
|
-
}
|
|
4878
|
-
this.stack.push(value);
|
|
4879
|
-
const result = callback();
|
|
4880
|
-
if (result && typeof result.then === "function") {
|
|
4881
|
-
return result.finally(() => {
|
|
4882
|
-
this.stack.pop();
|
|
4883
|
-
});
|
|
4884
|
-
}
|
|
4885
|
-
this.stack.pop();
|
|
4886
|
-
return result;
|
|
4887
|
-
}
|
|
4888
|
-
}
|
|
4956
|
+
// ../core/dist/kernel/contexts.js
|
|
4957
|
+
init_context_storage();
|
|
4889
4958
|
var snapshotContext = new ContextStorage;
|
|
4890
4959
|
var transactionContext = new ContextStorage;
|
|
4891
4960
|
var idGeneratorContext = new ContextStorage;
|
|
4892
4961
|
|
|
4962
|
+
// ../core/dist/kernel/blob-store-gateway.js
|
|
4893
4963
|
class BlobStoreGateway {
|
|
4894
4964
|
context;
|
|
4895
4965
|
docStore;
|
|
@@ -4993,7 +5063,10 @@ class BlobStoreGateway {
|
|
|
4993
5063
|
return this.storage;
|
|
4994
5064
|
}
|
|
4995
5065
|
}
|
|
5066
|
+
|
|
5067
|
+
// ../core/dist/kernel/scheduler-gateway.js
|
|
4996
5068
|
init_values();
|
|
5069
|
+
// ../core/dist/kernel/syscalls/utils.js
|
|
4997
5070
|
init_values();
|
|
4998
5071
|
async function resolveTableName(docId, tableRegistry) {
|
|
4999
5072
|
if (docId.tableNumber !== undefined) {
|
|
@@ -5131,6 +5204,7 @@ function evaluatePatchValue(value) {
|
|
|
5131
5204
|
return jsonToConvex(value);
|
|
5132
5205
|
}
|
|
5133
5206
|
|
|
5207
|
+
// ../core/dist/kernel/scheduler-gateway.js
|
|
5134
5208
|
class SchedulerGateway {
|
|
5135
5209
|
context;
|
|
5136
5210
|
docStore;
|
|
@@ -5199,9 +5273,12 @@ class SchedulerGateway {
|
|
|
5199
5273
|
this.context.recordLocalWrite(id, tableName, resolvedDocument.value, docId);
|
|
5200
5274
|
}
|
|
5201
5275
|
}
|
|
5276
|
+
|
|
5277
|
+
// ../core/dist/udf/module-loader/call-context.js
|
|
5278
|
+
init_context_storage();
|
|
5202
5279
|
var CALL_CONTEXT_SYMBOL = Symbol.for("@concavejs/core/call-context");
|
|
5203
5280
|
var globalCallContext = globalThis;
|
|
5204
|
-
var callContext = globalCallContext[CALL_CONTEXT_SYMBOL] ?? new
|
|
5281
|
+
var callContext = globalCallContext[CALL_CONTEXT_SYMBOL] ?? new ContextStorage;
|
|
5205
5282
|
if (!globalCallContext[CALL_CONTEXT_SYMBOL]) {
|
|
5206
5283
|
globalCallContext[CALL_CONTEXT_SYMBOL] = callContext;
|
|
5207
5284
|
}
|
|
@@ -5209,6 +5286,7 @@ async function runAsServerCall(fn, functionPath) {
|
|
|
5209
5286
|
return callContext.run({ caller: "server", functionPath }, fn);
|
|
5210
5287
|
}
|
|
5211
5288
|
|
|
5289
|
+
// ../core/dist/kernel/udf-invocation-manager.js
|
|
5212
5290
|
class UdfInvocationManager {
|
|
5213
5291
|
context;
|
|
5214
5292
|
udfExecutor;
|
|
@@ -5235,6 +5313,7 @@ class UdfInvocationManager {
|
|
|
5235
5313
|
}
|
|
5236
5314
|
}
|
|
5237
5315
|
|
|
5316
|
+
// ../core/dist/kernel/syscalls/action-syscalls.js
|
|
5238
5317
|
class ActionSyscalls {
|
|
5239
5318
|
context;
|
|
5240
5319
|
queryRuntime;
|
|
@@ -5284,8 +5363,9 @@ class ActionSyscalls {
|
|
|
5284
5363
|
return this.queryRuntime.runSearchAction(args.query);
|
|
5285
5364
|
}
|
|
5286
5365
|
}
|
|
5366
|
+
|
|
5367
|
+
// ../core/dist/kernel/syscalls/database-syscalls.js
|
|
5287
5368
|
init_values();
|
|
5288
|
-
init_index_manager();
|
|
5289
5369
|
init_interface();
|
|
5290
5370
|
|
|
5291
5371
|
class DatabaseSyscalls {
|
|
@@ -5509,6 +5589,8 @@ class DatabaseSyscalls {
|
|
|
5509
5589
|
return {};
|
|
5510
5590
|
}
|
|
5511
5591
|
}
|
|
5592
|
+
|
|
5593
|
+
// ../core/dist/auth/jwt.js
|
|
5512
5594
|
function claims2identity(claims) {
|
|
5513
5595
|
const {
|
|
5514
5596
|
sub,
|
|
@@ -5598,6 +5680,7 @@ function decodeJwtUnsafe(token) {
|
|
|
5598
5680
|
return decodeJwtClaimsToken(token);
|
|
5599
5681
|
}
|
|
5600
5682
|
|
|
5683
|
+
// ../core/dist/kernel/syscalls/identity-syscalls.js
|
|
5601
5684
|
class IdentitySyscalls {
|
|
5602
5685
|
context;
|
|
5603
5686
|
constructor(options) {
|
|
@@ -5630,6 +5713,7 @@ class IdentitySyscalls {
|
|
|
5630
5713
|
}
|
|
5631
5714
|
}
|
|
5632
5715
|
|
|
5716
|
+
// ../core/dist/kernel/syscalls/js-router.js
|
|
5633
5717
|
class JsSyscallRouter {
|
|
5634
5718
|
handlers = new Map;
|
|
5635
5719
|
register(op, handler) {
|
|
@@ -5650,6 +5734,7 @@ class JsSyscallRouter {
|
|
|
5650
5734
|
}
|
|
5651
5735
|
}
|
|
5652
5736
|
|
|
5737
|
+
// ../core/dist/kernel/syscalls/query-syscalls.js
|
|
5653
5738
|
class QuerySyscalls {
|
|
5654
5739
|
queryRuntime;
|
|
5655
5740
|
nextQueryId = 1;
|
|
@@ -5713,6 +5798,7 @@ class QuerySyscalls {
|
|
|
5713
5798
|
}
|
|
5714
5799
|
}
|
|
5715
5800
|
|
|
5801
|
+
// ../core/dist/kernel/syscalls/schedule-syscalls.js
|
|
5716
5802
|
class ScheduleSyscalls {
|
|
5717
5803
|
context;
|
|
5718
5804
|
scheduler;
|
|
@@ -5747,6 +5833,7 @@ class ScheduleSyscalls {
|
|
|
5747
5833
|
}
|
|
5748
5834
|
}
|
|
5749
5835
|
|
|
5836
|
+
// ../core/dist/kernel/syscalls/blobstore-syscalls.js
|
|
5750
5837
|
class BlobStoreSyscalls {
|
|
5751
5838
|
blobStore;
|
|
5752
5839
|
constructor(options) {
|
|
@@ -5810,6 +5897,8 @@ class BlobStoreSyscalls {
|
|
|
5810
5897
|
return "http://localhost:8799";
|
|
5811
5898
|
}
|
|
5812
5899
|
}
|
|
5900
|
+
|
|
5901
|
+
// ../core/dist/kernel/syscalls/router.js
|
|
5813
5902
|
init_values();
|
|
5814
5903
|
|
|
5815
5904
|
class SyscallRouter {
|
|
@@ -5851,6 +5940,7 @@ class SyscallRouter {
|
|
|
5851
5940
|
}
|
|
5852
5941
|
}
|
|
5853
5942
|
|
|
5943
|
+
// ../core/dist/kernel/syscalls/kernel-syscalls.js
|
|
5854
5944
|
class KernelSyscalls {
|
|
5855
5945
|
router = new SyscallRouter;
|
|
5856
5946
|
jsRouter = new JsSyscallRouter;
|
|
@@ -5901,9 +5991,8 @@ class KernelSyscalls {
|
|
|
5901
5991
|
return this.jsRouter.dispatch(op, args);
|
|
5902
5992
|
}
|
|
5903
5993
|
}
|
|
5904
|
-
|
|
5994
|
+
// ../core/dist/queryengine/convex-ops.js
|
|
5905
5995
|
var debug = () => {};
|
|
5906
|
-
|
|
5907
5996
|
class CfConvex {
|
|
5908
5997
|
syscall(op, jsonArgs) {
|
|
5909
5998
|
debug("CfConvex::syscall", op, jsonArgs);
|
|
@@ -5923,8 +6012,22 @@ class CfConvex {
|
|
|
5923
6012
|
}
|
|
5924
6013
|
}
|
|
5925
6014
|
var Convex2 = new CfConvex;
|
|
5926
|
-
|
|
5927
|
-
|
|
6015
|
+
// ../docstore-sqlite-base/dist/base.js
|
|
6016
|
+
function toSqlBlob(value) {
|
|
6017
|
+
return value instanceof Uint8Array ? value : new Uint8Array(value);
|
|
6018
|
+
}
|
|
6019
|
+
function toArrayBuffer(value) {
|
|
6020
|
+
if (value instanceof ArrayBuffer) {
|
|
6021
|
+
return value;
|
|
6022
|
+
}
|
|
6023
|
+
if (ArrayBuffer.isView(value)) {
|
|
6024
|
+
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength).slice().buffer;
|
|
6025
|
+
}
|
|
6026
|
+
if (Array.isArray(value)) {
|
|
6027
|
+
return new Uint8Array(value).buffer;
|
|
6028
|
+
}
|
|
6029
|
+
throw new Error("Expected SQL blob value to be an ArrayBuffer or typed array");
|
|
6030
|
+
}
|
|
5928
6031
|
|
|
5929
6032
|
class BaseSqliteDocStore {
|
|
5930
6033
|
adapter;
|
|
@@ -6026,9 +6129,9 @@ class BaseSqliteDocStore {
|
|
|
6026
6129
|
const insertIndexStmt = this.adapter.prepare(indexQuery);
|
|
6027
6130
|
for (const { ts, update } of indexes) {
|
|
6028
6131
|
if (update.value.type === "Deleted") {
|
|
6029
|
-
await insertIndexStmt.run(this.adapter.hexToBuffer(update.index_id), Number(ts),
|
|
6132
|
+
await insertIndexStmt.run(this.adapter.hexToBuffer(update.index_id), Number(ts), toSqlBlob(update.key), 1, new Uint8Array(0), new Uint8Array(0));
|
|
6030
6133
|
} else {
|
|
6031
|
-
await insertIndexStmt.run(this.adapter.hexToBuffer(update.index_id), Number(ts),
|
|
6134
|
+
await insertIndexStmt.run(this.adapter.hexToBuffer(update.index_id), Number(ts), toSqlBlob(update.key), 0, this.adapter.hexToBuffer(update.value.doc_id.table), this.adapter.hexToBuffer(update.value.doc_id.internalId));
|
|
6032
6135
|
}
|
|
6033
6136
|
}
|
|
6034
6137
|
}
|
|
@@ -6049,11 +6152,11 @@ class BaseSqliteDocStore {
|
|
|
6049
6152
|
const params = [this.adapter.hexToBuffer(indexId), Number(readTimestamp)];
|
|
6050
6153
|
if (start && start.byteLength > 0) {
|
|
6051
6154
|
query += ` AND key >= ?`;
|
|
6052
|
-
params.push(
|
|
6155
|
+
params.push(toSqlBlob(start));
|
|
6053
6156
|
}
|
|
6054
6157
|
if (end) {
|
|
6055
6158
|
query += ` AND key < ?`;
|
|
6056
|
-
params.push(
|
|
6159
|
+
params.push(toSqlBlob(end));
|
|
6057
6160
|
}
|
|
6058
6161
|
query += `
|
|
6059
6162
|
),
|
|
@@ -6087,7 +6190,7 @@ class BaseSqliteDocStore {
|
|
|
6087
6190
|
const stmt = this.adapter.prepare(query);
|
|
6088
6191
|
const rows = await stmt.all(...params);
|
|
6089
6192
|
for (const row of rows) {
|
|
6090
|
-
const key = row.key;
|
|
6193
|
+
const key = toArrayBuffer(row.key);
|
|
6091
6194
|
const tableId = this.adapter.bufferToHex(row.table_id);
|
|
6092
6195
|
const docId = this.adapter.bufferToHex(row.document_id);
|
|
6093
6196
|
const doc = {
|
|
@@ -6427,145 +6530,6 @@ class BaseSqliteDocStore {
|
|
|
6427
6530
|
return scored.slice(0, limit);
|
|
6428
6531
|
}
|
|
6429
6532
|
}
|
|
6430
|
-
// ../core/dist/utils/long.js
|
|
6431
|
-
class Long2 {
|
|
6432
|
-
low;
|
|
6433
|
-
high;
|
|
6434
|
-
__isUnsignedLong__;
|
|
6435
|
-
static isLong(obj) {
|
|
6436
|
-
return obj?.__isUnsignedLong__ === true;
|
|
6437
|
-
}
|
|
6438
|
-
constructor(low, high) {
|
|
6439
|
-
this.low = low | 0;
|
|
6440
|
-
this.high = high | 0;
|
|
6441
|
-
this.__isUnsignedLong__ = true;
|
|
6442
|
-
}
|
|
6443
|
-
static fromBytesLE(bytes) {
|
|
6444
|
-
return new Long2(bytes[0] | bytes[1] << 8 | bytes[2] << 16 | bytes[3] << 24, bytes[4] | bytes[5] << 8 | bytes[6] << 16 | bytes[7] << 24);
|
|
6445
|
-
}
|
|
6446
|
-
toBytesLE() {
|
|
6447
|
-
const hi = this.high;
|
|
6448
|
-
const lo = this.low;
|
|
6449
|
-
return [
|
|
6450
|
-
lo & 255,
|
|
6451
|
-
lo >>> 8 & 255,
|
|
6452
|
-
lo >>> 16 & 255,
|
|
6453
|
-
lo >>> 24,
|
|
6454
|
-
hi & 255,
|
|
6455
|
-
hi >>> 8 & 255,
|
|
6456
|
-
hi >>> 16 & 255,
|
|
6457
|
-
hi >>> 24
|
|
6458
|
-
];
|
|
6459
|
-
}
|
|
6460
|
-
static fromNumber(value) {
|
|
6461
|
-
if (Number.isNaN(value))
|
|
6462
|
-
return UZERO2;
|
|
6463
|
-
if (value < 0)
|
|
6464
|
-
return UZERO2;
|
|
6465
|
-
if (value >= TWO_PWR_64_DBL2)
|
|
6466
|
-
return MAX_UNSIGNED_VALUE2;
|
|
6467
|
-
return new Long2(value % TWO_PWR_32_DBL2 | 0, value / TWO_PWR_32_DBL2 | 0);
|
|
6468
|
-
}
|
|
6469
|
-
toString() {
|
|
6470
|
-
return (BigInt(this.high) * BigInt(TWO_PWR_32_DBL2) + BigInt(this.low)).toString();
|
|
6471
|
-
}
|
|
6472
|
-
equals(other) {
|
|
6473
|
-
if (!Long2.isLong(other))
|
|
6474
|
-
other = Long2.fromValue(other);
|
|
6475
|
-
if (this.high >>> 31 === 1 && other.high >>> 31 === 1)
|
|
6476
|
-
return false;
|
|
6477
|
-
return this.high === other.high && this.low === other.low;
|
|
6478
|
-
}
|
|
6479
|
-
notEquals(other) {
|
|
6480
|
-
return !this.equals(other);
|
|
6481
|
-
}
|
|
6482
|
-
comp(other) {
|
|
6483
|
-
if (!Long2.isLong(other))
|
|
6484
|
-
other = Long2.fromValue(other);
|
|
6485
|
-
if (this.equals(other))
|
|
6486
|
-
return 0;
|
|
6487
|
-
return other.high >>> 0 > this.high >>> 0 || other.high === this.high && other.low >>> 0 > this.low >>> 0 ? -1 : 1;
|
|
6488
|
-
}
|
|
6489
|
-
lessThanOrEqual(other) {
|
|
6490
|
-
return this.comp(other) <= 0;
|
|
6491
|
-
}
|
|
6492
|
-
static fromValue(val) {
|
|
6493
|
-
if (typeof val === "number")
|
|
6494
|
-
return Long2.fromNumber(val);
|
|
6495
|
-
if (typeof val === "bigint") {
|
|
6496
|
-
if (val < 0n)
|
|
6497
|
-
return UZERO2;
|
|
6498
|
-
const max = (1n << 64n) - 1n;
|
|
6499
|
-
if (val > max)
|
|
6500
|
-
return MAX_UNSIGNED_VALUE2;
|
|
6501
|
-
const low = Number(val & 0xffffffffn);
|
|
6502
|
-
const high = Number(val >> 32n & 0xffffffffn);
|
|
6503
|
-
return new Long2(low | 0, high | 0);
|
|
6504
|
-
}
|
|
6505
|
-
if (typeof val === "string") {
|
|
6506
|
-
try {
|
|
6507
|
-
return Long2.fromValue(BigInt(val));
|
|
6508
|
-
} catch {}
|
|
6509
|
-
}
|
|
6510
|
-
return new Long2(val.low, val.high);
|
|
6511
|
-
}
|
|
6512
|
-
}
|
|
6513
|
-
var UZERO2 = new Long2(0, 0);
|
|
6514
|
-
var TWO_PWR_16_DBL2 = 1 << 16;
|
|
6515
|
-
var TWO_PWR_32_DBL2 = TWO_PWR_16_DBL2 * TWO_PWR_16_DBL2;
|
|
6516
|
-
var TWO_PWR_64_DBL2 = TWO_PWR_32_DBL2 * TWO_PWR_32_DBL2;
|
|
6517
|
-
var MAX_UNSIGNED_VALUE2 = new Long2(4294967295 | 0, 4294967295 | 0);
|
|
6518
|
-
// ../core/dist/utils/timestamp.js
|
|
6519
|
-
class TimestampOracle2 {
|
|
6520
|
-
logicalClock;
|
|
6521
|
-
allocationQueue = Promise.resolve();
|
|
6522
|
-
constructor(initialTimestamp = 0n) {
|
|
6523
|
-
this.logicalClock = initialTimestamp;
|
|
6524
|
-
}
|
|
6525
|
-
getCurrentTimestamp() {
|
|
6526
|
-
return this.logicalClock;
|
|
6527
|
-
}
|
|
6528
|
-
allocateTimestamp() {
|
|
6529
|
-
const wallClock = BigInt(Date.now());
|
|
6530
|
-
this.logicalClock = this.logicalClock >= wallClock ? this.logicalClock + 1n : wallClock;
|
|
6531
|
-
return this.logicalClock;
|
|
6532
|
-
}
|
|
6533
|
-
async allocateTimestampAsync() {
|
|
6534
|
-
const result = this.allocationQueue.then(() => {
|
|
6535
|
-
return this.allocateTimestamp();
|
|
6536
|
-
});
|
|
6537
|
-
this.allocationQueue = result.then(() => {}, () => {});
|
|
6538
|
-
return result;
|
|
6539
|
-
}
|
|
6540
|
-
beginSnapshot() {
|
|
6541
|
-
if (this.logicalClock === 0n) {
|
|
6542
|
-
return BigInt(Date.now());
|
|
6543
|
-
}
|
|
6544
|
-
return this.logicalClock;
|
|
6545
|
-
}
|
|
6546
|
-
observeTimestamp(ts) {
|
|
6547
|
-
if (ts > this.logicalClock) {
|
|
6548
|
-
this.logicalClock = ts;
|
|
6549
|
-
}
|
|
6550
|
-
}
|
|
6551
|
-
reset(ts = 0n) {
|
|
6552
|
-
this.logicalClock = ts;
|
|
6553
|
-
}
|
|
6554
|
-
}
|
|
6555
|
-
// ../core/dist/utils/utils.js
|
|
6556
|
-
function hexToArrayBuffer3(hex) {
|
|
6557
|
-
if (hex === "") {
|
|
6558
|
-
return new Uint8Array(0).buffer;
|
|
6559
|
-
}
|
|
6560
|
-
const matches = hex.match(/.{1,2}/g);
|
|
6561
|
-
if (!matches) {
|
|
6562
|
-
throw new Error(`Invalid hex string: ${hex}`);
|
|
6563
|
-
}
|
|
6564
|
-
return new Uint8Array(matches.map((byte) => parseInt(byte, 16))).buffer;
|
|
6565
|
-
}
|
|
6566
|
-
function arrayBufferToHex3(buffer) {
|
|
6567
|
-
return Array.from(new Uint8Array(buffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
6568
|
-
}
|
|
6569
6533
|
// src/bun-adapter.ts
|
|
6570
6534
|
class BunPreparedStatement {
|
|
6571
6535
|
stmt;
|
|
@@ -6599,13 +6563,13 @@ class BunSqliteAdapter {
|
|
|
6599
6563
|
return txFn();
|
|
6600
6564
|
}
|
|
6601
6565
|
hexToBuffer(hex) {
|
|
6602
|
-
return Buffer.from(
|
|
6566
|
+
return Buffer.from(hexToArrayBuffer(hex));
|
|
6603
6567
|
}
|
|
6604
6568
|
bufferToHex(buffer) {
|
|
6605
6569
|
if (buffer instanceof Buffer) {
|
|
6606
|
-
return
|
|
6570
|
+
return arrayBufferToHex(buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength));
|
|
6607
6571
|
}
|
|
6608
|
-
return
|
|
6572
|
+
return arrayBufferToHex(buffer);
|
|
6609
6573
|
}
|
|
6610
6574
|
}
|
|
6611
6575
|
|