convex-cms 0.0.9-alpha.5 → 0.0.9-alpha.6
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/admin/src/embed/index.tsx +57 -67
- package/admin/src/embed/pages/Entry.tsx +4 -5
- package/admin/src/embed/pages/NewEntry.tsx +2 -1
- package/admin/src/embed/types.ts +0 -1
- package/admin-dist/nitro.json +1 -1
- package/admin-dist/public/assets/{CmsEmptyState-BM4e6N83.js → CmsEmptyState-la_kLGHv.js} +1 -1
- package/admin-dist/public/assets/{CmsPageHeader-uor3DPIk.js → CmsPageHeader-Cf0SafVG.js} +1 -1
- package/admin-dist/public/assets/{CmsStatusBadge-D8N18LJx.js → CmsStatusBadge-BovugIHH.js} +1 -1
- package/admin-dist/public/assets/{CmsSurface-BEcY-WpI.js → CmsSurface-Dp1TegU4.js} +1 -1
- package/admin-dist/public/assets/{CmsToolbar-DE-bu3W8.js → CmsToolbar-B1zdfMu0.js} +1 -1
- package/admin-dist/public/assets/{ContentEntryEditor-BdkIMCUk.js → ContentEntryEditor-CB--8SC3.js} +1 -1
- package/admin-dist/public/assets/{TaxonomyFilter-a1-O9DPs.js → TaxonomyFilter-fmZxxbdA.js} +1 -1
- package/admin-dist/public/assets/{_contentTypeId-XIkYOLyY.js → _contentTypeId-vT09P77i.js} +1 -1
- package/admin-dist/public/assets/{_entryId-DyP15QpI.js → _entryId-Dhq6ybYt.js} +1 -1
- package/admin-dist/public/assets/{alert-DHBQuuib.js → alert-DfdkD-ZZ.js} +1 -1
- package/admin-dist/public/assets/{badge-BOhWFWzb.js → badge-Cmc3T9vs.js} +1 -1
- package/admin-dist/public/assets/{circle-check-big-DjTNapen.js → circle-check-big-B8AJAcBi.js} +1 -1
- package/admin-dist/public/assets/{command-BIc5_8gL.js → command-BsmkQ6_j.js} +1 -1
- package/admin-dist/public/assets/{content-C3N8Ugra.js → content-DdQ1u7T4.js} +1 -1
- package/admin-dist/public/assets/{content-types-D0wh1eUF.js → content-types-QYcwm0Sy.js} +1 -1
- package/admin-dist/public/assets/{index-B-g3F_ri.js → index-kxLB3e43.js} +1 -1
- package/admin-dist/public/assets/main-BrFRroF1.js +107 -0
- package/admin-dist/public/assets/{media-8uh1MwDi.js → media-Cx9IyZvU.js} +1 -1
- package/admin-dist/public/assets/{new._contentTypeId-S96rFbgY.js → new._contentTypeId-2HsDwzy_.js} +1 -1
- package/admin-dist/public/assets/{pencil-DgaZav4e.js → pencil-PaJhpDeC.js} +1 -1
- package/admin-dist/public/assets/{refresh-cw-BBut4hAU.js → refresh-cw-D_KNzBUN.js} +1 -1
- package/admin-dist/public/assets/{rotate-ccw-DVCkojZZ.js → rotate-ccw-I3wzW1RQ.js} +1 -1
- package/admin-dist/public/assets/{scroll-area-DPC4uXzf.js → scroll-area-t72-FBB4.js} +1 -1
- package/admin-dist/public/assets/{search-CSyHHglh.js → search-BsuImjd-.js} +1 -1
- package/admin-dist/public/assets/{settings-cEqPsoJ0.js → settings-DB6TvceQ.js} +1 -1
- package/admin-dist/public/assets/{switch-O2BviO8Q.js → switch-DWN_fx2n.js} +1 -1
- package/admin-dist/public/assets/{tabs-p1MWhOqY.js → tabs-BG0vukFH.js} +1 -1
- package/admin-dist/public/assets/{tanstack-adapter-CDrxoPZD.js → tanstack-adapter-DHsy8Fjs.js} +1 -1
- package/admin-dist/public/assets/{taxonomies-DJ9UbjXW.js → taxonomies-WG8YV2pR.js} +1 -1
- package/admin-dist/public/assets/{trash-RnpP6lXF.js → trash-C3Lt5m9d.js} +1 -1
- package/admin-dist/public/assets/{useBreadcrumbLabel-zbIWXlkc.js → useBreadcrumbLabel-BC8wl3jQ.js} +1 -1
- package/admin-dist/public/assets/{usePermissions-4CTlK-vU.js → usePermissions-BM1Vv1YJ.js} +1 -1
- package/admin-dist/server/_libs/convex-helpers.mjs +37 -0
- package/admin-dist/server/_libs/convex.mjs +1357 -168
- package/admin-dist/server/_ssr/{CmsEmptyState-BA0Lc5xs.mjs → CmsEmptyState-NKmyUWD9.mjs} +1 -1
- package/admin-dist/server/_ssr/{CmsPageHeader-PMyecILZ.mjs → CmsPageHeader-CngxPIOg.mjs} +1 -1
- package/admin-dist/server/_ssr/{CmsStatusBadge-CInuN2bZ.mjs → CmsStatusBadge-D4fiHjJD.mjs} +2 -2
- package/admin-dist/server/_ssr/{CmsSurface-CH1PIfcS.mjs → CmsSurface-DN9I2iuX.mjs} +1 -1
- package/admin-dist/server/_ssr/{CmsToolbar-IuhSA7gR.mjs → CmsToolbar-ux-veU96.mjs} +1 -1
- package/admin-dist/server/_ssr/{ContentEntryEditor-Bzhir4fQ.mjs → ContentEntryEditor-BiY9bJr9.mjs} +9 -9
- package/admin-dist/server/_ssr/{TaxonomyFilter-r4izSMBh.mjs → TaxonomyFilter-BdtKJie2.mjs} +3 -3
- package/admin-dist/server/_ssr/{_contentTypeId-BWEbjqxY.mjs → _contentTypeId-CRo5WQVu.mjs} +12 -11
- package/admin-dist/server/_ssr/{_entryId-B5xoXoJf.mjs → _entryId-FnG3uc_Y.mjs} +12 -11
- package/admin-dist/server/_ssr/_tanstack-start-manifest_v-BbSNqRIw.mjs +4 -0
- package/admin-dist/server/_ssr/{badge-DXrjBRqZ.mjs → badge-D3SGS0Jp.mjs} +1 -1
- package/admin-dist/server/_ssr/{command-Cj90OdCX.mjs → command-2t7uTBKt.mjs} +1 -1
- package/admin-dist/server/_ssr/{content-DKRI-YqL.mjs → content-CCsSzXeb.mjs} +10 -9
- package/admin-dist/server/_ssr/{content-types-BzgRcS8K.mjs → content-types-CuVG3uSt.mjs} +7 -6
- package/admin-dist/server/_ssr/{index-BPf6_agY.mjs → index-CLwCLoco.mjs} +5 -4
- package/admin-dist/server/_ssr/index.mjs +2 -2
- package/admin-dist/server/_ssr/{media-MpjxOZL8.mjs → media-D3duVWkk.mjs} +11 -10
- package/admin-dist/server/_ssr/{new._contentTypeId-DSb4qR9j.mjs → new._contentTypeId-6uKYdgGO.mjs} +11 -10
- package/admin-dist/server/_ssr/router-D9Zk56-q.mjs +7979 -0
- package/admin-dist/server/_ssr/{scroll-area-JwVD_6MZ.mjs → scroll-area-vbjKsfFu.mjs} +1 -1
- package/admin-dist/server/_ssr/{settings-KVJNe0GM.mjs → settings-D7-vwjqD.mjs} +9 -8
- package/admin-dist/server/_ssr/{switch-DvREvRv4.mjs → switch-CbKuV4Qh.mjs} +1 -1
- package/admin-dist/server/_ssr/{tabs-B0h57pFf.mjs → tabs-C_IfqLiu.mjs} +2 -2
- package/admin-dist/server/_ssr/{tanstack-adapter-gmM64LnW.mjs → tanstack-adapter-yhyAcBi-.mjs} +1 -1
- package/admin-dist/server/_ssr/{taxonomies-BbBNx260.mjs → taxonomies-C15s_nvM.mjs} +9 -8
- package/admin-dist/server/_ssr/{trash-JAzYGh7A.mjs → trash-BPIjmAUh.mjs} +9 -8
- package/admin-dist/server/_ssr/{useBreadcrumbLabel-BWIujj97.mjs → useBreadcrumbLabel-BC7plG0L.mjs} +1 -1
- package/admin-dist/server/_ssr/{usePermissions-CcLDCSwa.mjs → usePermissions-DJ8a7bZU.mjs} +1 -1
- package/admin-dist/server/index.mjs +157 -157
- package/package.json +2 -1
- package/admin-dist/public/assets/main-BapBJgQD.js +0 -102
- package/admin-dist/server/_ssr/_tanstack-start-manifest_v-CBTan6ii.mjs +0 -4
- package/admin-dist/server/_ssr/router-Dk9ikPNc.mjs +0 -3055
|
@@ -347,7 +347,7 @@ function convexToJsonInternal(value, originalValue, context, includeTopLevelUnde
|
|
|
347
347
|
}
|
|
348
348
|
if (Array.isArray(value)) {
|
|
349
349
|
return value.map(
|
|
350
|
-
(value2, i) => convexToJsonInternal(value2, originalValue, context + `[${i}]
|
|
350
|
+
(value2, i) => convexToJsonInternal(value2, originalValue, context + `[${i}]`, false)
|
|
351
351
|
);
|
|
352
352
|
}
|
|
353
353
|
if (value instanceof Set) {
|
|
@@ -373,7 +373,14 @@ function convexToJsonInternal(value, originalValue, context, includeTopLevelUnde
|
|
|
373
373
|
for (const [k, v2] of entries) {
|
|
374
374
|
if (v2 !== void 0) {
|
|
375
375
|
validateObjectField(k);
|
|
376
|
-
out[k] = convexToJsonInternal(v2, originalValue, context + `.${k}
|
|
376
|
+
out[k] = convexToJsonInternal(v2, originalValue, context + `.${k}`, false);
|
|
377
|
+
} else if (includeTopLevelUndefined) {
|
|
378
|
+
validateObjectField(k);
|
|
379
|
+
out[k] = convexOrUndefinedToJsonInternal(
|
|
380
|
+
v2,
|
|
381
|
+
originalValue,
|
|
382
|
+
context + `.${k}`
|
|
383
|
+
);
|
|
377
384
|
}
|
|
378
385
|
}
|
|
379
386
|
return out;
|
|
@@ -391,12 +398,32 @@ function errorMessageForUnsupportedType(context, typeName, value, originalValue)
|
|
|
391
398
|
)} is not a supported Convex type.`;
|
|
392
399
|
}
|
|
393
400
|
}
|
|
401
|
+
function convexOrUndefinedToJsonInternal(value, originalValue, context) {
|
|
402
|
+
if (value === void 0) {
|
|
403
|
+
return { $undefined: null };
|
|
404
|
+
} else {
|
|
405
|
+
if (originalValue === void 0) {
|
|
406
|
+
throw new Error(
|
|
407
|
+
`Programming error. Current value is ${stringifyValueForError(
|
|
408
|
+
value
|
|
409
|
+
)} but original value is undefined`
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
return convexToJsonInternal(value, originalValue, context, false);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
394
415
|
function convexToJson(value) {
|
|
395
|
-
return convexToJsonInternal(value, value, "");
|
|
416
|
+
return convexToJsonInternal(value, value, "", false);
|
|
396
417
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
418
|
+
function convexOrUndefinedToJson(value) {
|
|
419
|
+
return convexOrUndefinedToJsonInternal(value, value, "");
|
|
420
|
+
}
|
|
421
|
+
function patchValueToJson(value) {
|
|
422
|
+
return convexToJsonInternal(value, value, "", true);
|
|
423
|
+
}
|
|
424
|
+
var __defProp$l = Object.defineProperty;
|
|
425
|
+
var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
426
|
+
var __publicField$l = (obj, key, value) => __defNormalProp$l(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
400
427
|
const UNDEFINED_VALIDATOR_ERROR_URL = "https://docs.convex.dev/error#undefined-validator";
|
|
401
428
|
function throwUndefinedValidatorError(context, fieldName) {
|
|
402
429
|
const fieldInfo = fieldName !== void 0 ? ` for field "${fieldName}"` : "";
|
|
@@ -406,10 +433,10 @@ function throwUndefinedValidatorError(context, fieldName) {
|
|
|
406
433
|
}
|
|
407
434
|
class BaseValidator {
|
|
408
435
|
constructor({ isOptional }) {
|
|
409
|
-
__publicField$
|
|
410
|
-
__publicField$
|
|
411
|
-
__publicField$
|
|
412
|
-
__publicField$
|
|
436
|
+
__publicField$l(this, "type");
|
|
437
|
+
__publicField$l(this, "fieldPaths");
|
|
438
|
+
__publicField$l(this, "isOptional");
|
|
439
|
+
__publicField$l(this, "isConvexValidator");
|
|
413
440
|
this.isOptional = isOptional;
|
|
414
441
|
this.isConvexValidator = true;
|
|
415
442
|
}
|
|
@@ -423,8 +450,8 @@ class VId extends BaseValidator {
|
|
|
423
450
|
tableName
|
|
424
451
|
}) {
|
|
425
452
|
super({ isOptional });
|
|
426
|
-
__publicField$
|
|
427
|
-
__publicField$
|
|
453
|
+
__publicField$l(this, "tableName");
|
|
454
|
+
__publicField$l(this, "kind", "id");
|
|
428
455
|
if (typeof tableName !== "string") {
|
|
429
456
|
throw new Error("v.id(tableName) requires a string");
|
|
430
457
|
}
|
|
@@ -445,7 +472,7 @@ class VId extends BaseValidator {
|
|
|
445
472
|
class VFloat64 extends BaseValidator {
|
|
446
473
|
constructor() {
|
|
447
474
|
super(...arguments);
|
|
448
|
-
__publicField$
|
|
475
|
+
__publicField$l(this, "kind", "float64");
|
|
449
476
|
}
|
|
450
477
|
/** @internal */
|
|
451
478
|
get json() {
|
|
@@ -461,7 +488,7 @@ class VFloat64 extends BaseValidator {
|
|
|
461
488
|
class VInt64 extends BaseValidator {
|
|
462
489
|
constructor() {
|
|
463
490
|
super(...arguments);
|
|
464
|
-
__publicField$
|
|
491
|
+
__publicField$l(this, "kind", "int64");
|
|
465
492
|
}
|
|
466
493
|
/** @internal */
|
|
467
494
|
get json() {
|
|
@@ -475,7 +502,7 @@ class VInt64 extends BaseValidator {
|
|
|
475
502
|
class VBoolean extends BaseValidator {
|
|
476
503
|
constructor() {
|
|
477
504
|
super(...arguments);
|
|
478
|
-
__publicField$
|
|
505
|
+
__publicField$l(this, "kind", "boolean");
|
|
479
506
|
}
|
|
480
507
|
/** @internal */
|
|
481
508
|
get json() {
|
|
@@ -491,7 +518,7 @@ class VBoolean extends BaseValidator {
|
|
|
491
518
|
class VBytes extends BaseValidator {
|
|
492
519
|
constructor() {
|
|
493
520
|
super(...arguments);
|
|
494
|
-
__publicField$
|
|
521
|
+
__publicField$l(this, "kind", "bytes");
|
|
495
522
|
}
|
|
496
523
|
/** @internal */
|
|
497
524
|
get json() {
|
|
@@ -505,7 +532,7 @@ class VBytes extends BaseValidator {
|
|
|
505
532
|
class VString extends BaseValidator {
|
|
506
533
|
constructor() {
|
|
507
534
|
super(...arguments);
|
|
508
|
-
__publicField$
|
|
535
|
+
__publicField$l(this, "kind", "string");
|
|
509
536
|
}
|
|
510
537
|
/** @internal */
|
|
511
538
|
get json() {
|
|
@@ -521,7 +548,7 @@ class VString extends BaseValidator {
|
|
|
521
548
|
class VNull extends BaseValidator {
|
|
522
549
|
constructor() {
|
|
523
550
|
super(...arguments);
|
|
524
|
-
__publicField$
|
|
551
|
+
__publicField$l(this, "kind", "null");
|
|
525
552
|
}
|
|
526
553
|
/** @internal */
|
|
527
554
|
get json() {
|
|
@@ -535,7 +562,7 @@ class VNull extends BaseValidator {
|
|
|
535
562
|
class VAny extends BaseValidator {
|
|
536
563
|
constructor() {
|
|
537
564
|
super(...arguments);
|
|
538
|
-
__publicField$
|
|
565
|
+
__publicField$l(this, "kind", "any");
|
|
539
566
|
}
|
|
540
567
|
/** @internal */
|
|
541
568
|
get json() {
|
|
@@ -559,8 +586,8 @@ class VObject extends BaseValidator {
|
|
|
559
586
|
fields
|
|
560
587
|
}) {
|
|
561
588
|
super({ isOptional });
|
|
562
|
-
__publicField$
|
|
563
|
-
__publicField$
|
|
589
|
+
__publicField$l(this, "fields");
|
|
590
|
+
__publicField$l(this, "kind", "object");
|
|
564
591
|
globalThis.Object.entries(fields).forEach(([fieldName, validator]) => {
|
|
565
592
|
if (validator === void 0) {
|
|
566
593
|
throwUndefinedValidatorError("v.object()", fieldName);
|
|
@@ -651,8 +678,8 @@ class VLiteral extends BaseValidator {
|
|
|
651
678
|
*/
|
|
652
679
|
constructor({ isOptional, value }) {
|
|
653
680
|
super({ isOptional });
|
|
654
|
-
__publicField$
|
|
655
|
-
__publicField$
|
|
681
|
+
__publicField$l(this, "value");
|
|
682
|
+
__publicField$l(this, "kind", "literal");
|
|
656
683
|
if (typeof value !== "string" && typeof value !== "boolean" && typeof value !== "number" && typeof value !== "bigint") {
|
|
657
684
|
throw new Error("v.literal(value) must be a string, number, or boolean");
|
|
658
685
|
}
|
|
@@ -682,8 +709,8 @@ class VArray extends BaseValidator {
|
|
|
682
709
|
element
|
|
683
710
|
}) {
|
|
684
711
|
super({ isOptional });
|
|
685
|
-
__publicField$
|
|
686
|
-
__publicField$
|
|
712
|
+
__publicField$l(this, "element");
|
|
713
|
+
__publicField$l(this, "kind", "array");
|
|
687
714
|
if (element === void 0) {
|
|
688
715
|
throwUndefinedValidatorError("v.array()");
|
|
689
716
|
}
|
|
@@ -714,9 +741,9 @@ class VRecord extends BaseValidator {
|
|
|
714
741
|
value
|
|
715
742
|
}) {
|
|
716
743
|
super({ isOptional });
|
|
717
|
-
__publicField$
|
|
718
|
-
__publicField$
|
|
719
|
-
__publicField$
|
|
744
|
+
__publicField$l(this, "key");
|
|
745
|
+
__publicField$l(this, "value");
|
|
746
|
+
__publicField$l(this, "kind", "record");
|
|
720
747
|
if (key === void 0) {
|
|
721
748
|
throwUndefinedValidatorError("v.record()", "key");
|
|
722
749
|
}
|
|
@@ -762,8 +789,8 @@ class VUnion extends BaseValidator {
|
|
|
762
789
|
*/
|
|
763
790
|
constructor({ isOptional, members }) {
|
|
764
791
|
super({ isOptional });
|
|
765
|
-
__publicField$
|
|
766
|
-
__publicField$
|
|
792
|
+
__publicField$l(this, "members");
|
|
793
|
+
__publicField$l(this, "kind", "union");
|
|
767
794
|
members.forEach((member, index) => {
|
|
768
795
|
if (member === void 0) {
|
|
769
796
|
throwUndefinedValidatorError("v.union()", `member at index ${index}`);
|
|
@@ -789,6 +816,16 @@ class VUnion extends BaseValidator {
|
|
|
789
816
|
});
|
|
790
817
|
}
|
|
791
818
|
}
|
|
819
|
+
function isValidator(v2) {
|
|
820
|
+
return !!v2.isConvexValidator;
|
|
821
|
+
}
|
|
822
|
+
function asObjectValidator(obj) {
|
|
823
|
+
if (isValidator(obj)) {
|
|
824
|
+
return obj;
|
|
825
|
+
} else {
|
|
826
|
+
return v.object(obj);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
792
829
|
const v = {
|
|
793
830
|
/**
|
|
794
831
|
* Validates that the value corresponds to an ID of a document in given table.
|
|
@@ -920,24 +957,24 @@ const v = {
|
|
|
920
957
|
return v.union(value, v.null());
|
|
921
958
|
}
|
|
922
959
|
};
|
|
923
|
-
var __defProp$
|
|
924
|
-
var __defNormalProp$
|
|
925
|
-
var __publicField$
|
|
960
|
+
var __defProp$k = Object.defineProperty;
|
|
961
|
+
var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
962
|
+
var __publicField$k = (obj, key, value) => __defNormalProp$k(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
926
963
|
var _a, _b;
|
|
927
964
|
const IDENTIFYING_FIELD = /* @__PURE__ */ Symbol.for("ConvexError");
|
|
928
965
|
class ConvexError extends (_b = Error, _a = IDENTIFYING_FIELD, _b) {
|
|
929
966
|
constructor(data) {
|
|
930
967
|
super(typeof data === "string" ? data : stringifyValueForError(data));
|
|
931
|
-
__publicField$
|
|
932
|
-
__publicField$
|
|
933
|
-
__publicField$
|
|
968
|
+
__publicField$k(this, "name", "ConvexError");
|
|
969
|
+
__publicField$k(this, "data");
|
|
970
|
+
__publicField$k(this, _a, true);
|
|
934
971
|
this.data = data;
|
|
935
972
|
}
|
|
936
973
|
}
|
|
937
974
|
const version = "1.31.6";
|
|
938
|
-
var __defProp$
|
|
939
|
-
var __defNormalProp$
|
|
940
|
-
var __publicField$
|
|
975
|
+
var __defProp$j = Object.defineProperty;
|
|
976
|
+
var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
977
|
+
var __publicField$j = (obj, key, value) => __defNormalProp$j(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
941
978
|
const INFO_COLOR = "color:rgb(0, 145, 255)";
|
|
942
979
|
function prefix_for_source(source) {
|
|
943
980
|
switch (source) {
|
|
@@ -953,8 +990,8 @@ function prefix_for_source(source) {
|
|
|
953
990
|
}
|
|
954
991
|
class DefaultLogger {
|
|
955
992
|
constructor(options) {
|
|
956
|
-
__publicField$
|
|
957
|
-
__publicField$
|
|
993
|
+
__publicField$j(this, "_onLogLineFuncs");
|
|
994
|
+
__publicField$j(this, "_verbose");
|
|
958
995
|
this._onLogLineFuncs = {};
|
|
959
996
|
this._verbose = options.verbose;
|
|
960
997
|
}
|
|
@@ -1086,21 +1123,21 @@ function serializePaginatedPathAndArgs(udfPath, args, options) {
|
|
|
1086
1123
|
});
|
|
1087
1124
|
return result;
|
|
1088
1125
|
}
|
|
1089
|
-
var __defProp$
|
|
1090
|
-
var __defNormalProp$
|
|
1091
|
-
var __publicField$
|
|
1126
|
+
var __defProp$i = Object.defineProperty;
|
|
1127
|
+
var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1128
|
+
var __publicField$i = (obj, key, value) => __defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1092
1129
|
class LocalSyncState {
|
|
1093
1130
|
constructor() {
|
|
1094
|
-
__publicField$
|
|
1095
|
-
__publicField$
|
|
1096
|
-
__publicField$
|
|
1097
|
-
__publicField$
|
|
1098
|
-
__publicField$
|
|
1099
|
-
__publicField$
|
|
1100
|
-
__publicField$
|
|
1101
|
-
__publicField$
|
|
1102
|
-
__publicField$
|
|
1103
|
-
__publicField$
|
|
1131
|
+
__publicField$i(this, "nextQueryId");
|
|
1132
|
+
__publicField$i(this, "querySetVersion");
|
|
1133
|
+
__publicField$i(this, "querySet");
|
|
1134
|
+
__publicField$i(this, "queryIdToToken");
|
|
1135
|
+
__publicField$i(this, "identityVersion");
|
|
1136
|
+
__publicField$i(this, "auth");
|
|
1137
|
+
__publicField$i(this, "outstandingQueriesOlderThanRestart");
|
|
1138
|
+
__publicField$i(this, "outstandingAuthOlderThanRestart");
|
|
1139
|
+
__publicField$i(this, "paused");
|
|
1140
|
+
__publicField$i(this, "pendingQuerySetModifications");
|
|
1104
1141
|
this.nextQueryId = 0;
|
|
1105
1142
|
this.querySetVersion = 0;
|
|
1106
1143
|
this.identityVersion = 0;
|
|
@@ -1374,17 +1411,17 @@ class LocalSyncState {
|
|
|
1374
1411
|
}
|
|
1375
1412
|
}
|
|
1376
1413
|
}
|
|
1377
|
-
var __defProp$
|
|
1378
|
-
var __defNormalProp$
|
|
1379
|
-
var __publicField$
|
|
1414
|
+
var __defProp$h = Object.defineProperty;
|
|
1415
|
+
var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1416
|
+
var __publicField$h = (obj, key, value) => __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1380
1417
|
class RequestManager {
|
|
1381
1418
|
constructor(logger, markConnectionStateDirty) {
|
|
1382
1419
|
this.logger = logger;
|
|
1383
1420
|
this.markConnectionStateDirty = markConnectionStateDirty;
|
|
1384
|
-
__publicField$
|
|
1385
|
-
__publicField$
|
|
1386
|
-
__publicField$
|
|
1387
|
-
__publicField$
|
|
1421
|
+
__publicField$h(this, "inflightRequests");
|
|
1422
|
+
__publicField$h(this, "requestsOlderThanRestart");
|
|
1423
|
+
__publicField$h(this, "inflightMutationsCount", 0);
|
|
1424
|
+
__publicField$h(this, "inflightActionsCount", 0);
|
|
1388
1425
|
this.inflightRequests = /* @__PURE__ */ new Map();
|
|
1389
1426
|
this.requestsOlderThanRestart = /* @__PURE__ */ new Set();
|
|
1390
1427
|
}
|
|
@@ -1662,13 +1699,13 @@ function createApi(pathParts = []) {
|
|
|
1662
1699
|
return new Proxy({}, handler);
|
|
1663
1700
|
}
|
|
1664
1701
|
const anyApi = createApi();
|
|
1665
|
-
var __defProp$
|
|
1666
|
-
var __defNormalProp$
|
|
1667
|
-
var __publicField$
|
|
1702
|
+
var __defProp$g = Object.defineProperty;
|
|
1703
|
+
var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1704
|
+
var __publicField$g = (obj, key, value) => __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1668
1705
|
class OptimisticLocalStoreImpl {
|
|
1669
1706
|
constructor(queryResults) {
|
|
1670
|
-
__publicField$
|
|
1671
|
-
__publicField$
|
|
1707
|
+
__publicField$g(this, "queryResults");
|
|
1708
|
+
__publicField$g(this, "modifiedQueries");
|
|
1672
1709
|
this.queryResults = queryResults;
|
|
1673
1710
|
this.modifiedQueries = [];
|
|
1674
1711
|
}
|
|
@@ -1731,8 +1768,8 @@ class OptimisticLocalStoreImpl {
|
|
|
1731
1768
|
}
|
|
1732
1769
|
class OptimisticQueryResults {
|
|
1733
1770
|
constructor() {
|
|
1734
|
-
__publicField$
|
|
1735
|
-
__publicField$
|
|
1771
|
+
__publicField$g(this, "queryResults");
|
|
1772
|
+
__publicField$g(this, "optimisticUpdates");
|
|
1736
1773
|
this.queryResults = /* @__PURE__ */ new Map();
|
|
1737
1774
|
this.optimisticUpdates = [];
|
|
1738
1775
|
}
|
|
@@ -1815,14 +1852,14 @@ class OptimisticQueryResults {
|
|
|
1815
1852
|
return query?.result?.logLines;
|
|
1816
1853
|
}
|
|
1817
1854
|
}
|
|
1818
|
-
var __defProp$
|
|
1819
|
-
var __defNormalProp$
|
|
1820
|
-
var __publicField$
|
|
1855
|
+
var __defProp$f = Object.defineProperty;
|
|
1856
|
+
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1857
|
+
var __publicField$f = (obj, key, value) => __defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1821
1858
|
class Long {
|
|
1822
1859
|
constructor(low, high) {
|
|
1823
|
-
__publicField$
|
|
1824
|
-
__publicField$
|
|
1825
|
-
__publicField$
|
|
1860
|
+
__publicField$f(this, "low");
|
|
1861
|
+
__publicField$f(this, "high");
|
|
1862
|
+
__publicField$f(this, "__isUnsignedLong__");
|
|
1826
1863
|
this.low = low | 0;
|
|
1827
1864
|
this.high = high | 0;
|
|
1828
1865
|
this.__isUnsignedLong__ = true;
|
|
@@ -1890,15 +1927,15 @@ const TWO_PWR_16_DBL = 1 << 16;
|
|
|
1890
1927
|
const TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;
|
|
1891
1928
|
const TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;
|
|
1892
1929
|
const MAX_UNSIGNED_VALUE = new Long(4294967295 | 0, 4294967295 | 0);
|
|
1893
|
-
var __defProp$
|
|
1894
|
-
var __defNormalProp$
|
|
1895
|
-
var __publicField$
|
|
1930
|
+
var __defProp$e = Object.defineProperty;
|
|
1931
|
+
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1932
|
+
var __publicField$e = (obj, key, value) => __defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1896
1933
|
class RemoteQuerySet {
|
|
1897
1934
|
constructor(queryPath, logger) {
|
|
1898
|
-
__publicField$
|
|
1899
|
-
__publicField$
|
|
1900
|
-
__publicField$
|
|
1901
|
-
__publicField$
|
|
1935
|
+
__publicField$e(this, "version");
|
|
1936
|
+
__publicField$e(this, "remoteQuerySet");
|
|
1937
|
+
__publicField$e(this, "queryPath");
|
|
1938
|
+
__publicField$e(this, "logger");
|
|
1902
1939
|
this.version = { querySet: 0, ts: Long.fromNumber(0), identity: 0 };
|
|
1903
1940
|
this.remoteQuerySet = /* @__PURE__ */ new Map();
|
|
1904
1941
|
this.queryPath = queryPath;
|
|
@@ -2024,9 +2061,9 @@ function encodeClientMessage(message) {
|
|
|
2024
2061
|
}
|
|
2025
2062
|
return void 0;
|
|
2026
2063
|
}
|
|
2027
|
-
var __defProp$
|
|
2028
|
-
var __defNormalProp$
|
|
2029
|
-
var __publicField$
|
|
2064
|
+
var __defProp$d = Object.defineProperty;
|
|
2065
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2066
|
+
var __publicField$d = (obj, key, value) => __defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2030
2067
|
const CLOSE_NORMAL = 1e3;
|
|
2031
2068
|
const CLOSE_GOING_AWAY = 1001;
|
|
2032
2069
|
const CLOSE_NO_STATUS = 1005;
|
|
@@ -2079,26 +2116,26 @@ class WebSocketManager {
|
|
|
2079
2116
|
constructor(uri, callbacks, webSocketConstructor, logger, markConnectionStateDirty, debug) {
|
|
2080
2117
|
this.markConnectionStateDirty = markConnectionStateDirty;
|
|
2081
2118
|
this.debug = debug;
|
|
2082
|
-
__publicField$
|
|
2083
|
-
__publicField$
|
|
2084
|
-
__publicField$
|
|
2085
|
-
__publicField$
|
|
2086
|
-
__publicField$
|
|
2087
|
-
__publicField$
|
|
2088
|
-
__publicField$
|
|
2089
|
-
__publicField$
|
|
2090
|
-
__publicField$
|
|
2091
|
-
__publicField$
|
|
2092
|
-
__publicField$
|
|
2093
|
-
__publicField$
|
|
2094
|
-
__publicField$
|
|
2095
|
-
__publicField$
|
|
2096
|
-
__publicField$
|
|
2097
|
-
__publicField$
|
|
2098
|
-
__publicField$
|
|
2099
|
-
__publicField$
|
|
2100
|
-
__publicField$
|
|
2101
|
-
__publicField$
|
|
2119
|
+
__publicField$d(this, "socket");
|
|
2120
|
+
__publicField$d(this, "connectionCount");
|
|
2121
|
+
__publicField$d(this, "_hasEverConnected", false);
|
|
2122
|
+
__publicField$d(this, "lastCloseReason");
|
|
2123
|
+
__publicField$d(this, "transitionChunkBuffer", null);
|
|
2124
|
+
__publicField$d(this, "defaultInitialBackoff");
|
|
2125
|
+
__publicField$d(this, "maxBackoff");
|
|
2126
|
+
__publicField$d(this, "retries");
|
|
2127
|
+
__publicField$d(this, "serverInactivityThreshold");
|
|
2128
|
+
__publicField$d(this, "reconnectDueToServerInactivityTimeout");
|
|
2129
|
+
__publicField$d(this, "scheduledReconnect", null);
|
|
2130
|
+
__publicField$d(this, "networkOnlineHandler", null);
|
|
2131
|
+
__publicField$d(this, "pendingNetworkRecoveryInfo", null);
|
|
2132
|
+
__publicField$d(this, "uri");
|
|
2133
|
+
__publicField$d(this, "onOpen");
|
|
2134
|
+
__publicField$d(this, "onResume");
|
|
2135
|
+
__publicField$d(this, "onMessage");
|
|
2136
|
+
__publicField$d(this, "webSocketConstructor");
|
|
2137
|
+
__publicField$d(this, "logger");
|
|
2138
|
+
__publicField$d(this, "onServerDisconnectError");
|
|
2102
2139
|
this.webSocketConstructor = webSocketConstructor;
|
|
2103
2140
|
this.socket = { state: "disconnected" };
|
|
2104
2141
|
this.connectionCount = 0;
|
|
@@ -2732,25 +2769,25 @@ function jwtDecode(token, options) {
|
|
|
2732
2769
|
);
|
|
2733
2770
|
}
|
|
2734
2771
|
}
|
|
2735
|
-
var __defProp$
|
|
2736
|
-
var __defNormalProp$
|
|
2737
|
-
var __publicField$
|
|
2772
|
+
var __defProp$c = Object.defineProperty;
|
|
2773
|
+
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2774
|
+
var __publicField$c = (obj, key, value) => __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2738
2775
|
const MAXIMUM_REFRESH_DELAY = 20 * 24 * 60 * 60 * 1e3;
|
|
2739
2776
|
const MAX_TOKEN_CONFIRMATION_ATTEMPTS = 2;
|
|
2740
2777
|
class AuthenticationManager {
|
|
2741
2778
|
constructor(syncState, callbacks, config) {
|
|
2742
|
-
__publicField$
|
|
2743
|
-
__publicField$
|
|
2744
|
-
__publicField$
|
|
2745
|
-
__publicField$
|
|
2746
|
-
__publicField$
|
|
2747
|
-
__publicField$
|
|
2748
|
-
__publicField$
|
|
2749
|
-
__publicField$
|
|
2750
|
-
__publicField$
|
|
2751
|
-
__publicField$
|
|
2752
|
-
__publicField$
|
|
2753
|
-
__publicField$
|
|
2779
|
+
__publicField$c(this, "authState", { state: "noAuth" });
|
|
2780
|
+
__publicField$c(this, "configVersion", 0);
|
|
2781
|
+
__publicField$c(this, "syncState");
|
|
2782
|
+
__publicField$c(this, "authenticate");
|
|
2783
|
+
__publicField$c(this, "stopSocket");
|
|
2784
|
+
__publicField$c(this, "tryRestartSocket");
|
|
2785
|
+
__publicField$c(this, "pauseSocket");
|
|
2786
|
+
__publicField$c(this, "resumeSocket");
|
|
2787
|
+
__publicField$c(this, "clearAuth");
|
|
2788
|
+
__publicField$c(this, "logger");
|
|
2789
|
+
__publicField$c(this, "refreshTokenLeewaySeconds");
|
|
2790
|
+
__publicField$c(this, "tokenConfirmationAttempts", 0);
|
|
2754
2791
|
this.syncState = syncState;
|
|
2755
2792
|
this.authenticate = callbacks.authenticate;
|
|
2756
2793
|
this.stopSocket = callbacks.stopSocket;
|
|
@@ -3066,9 +3103,9 @@ function getMarksReport(sessionId) {
|
|
|
3066
3103
|
}
|
|
3067
3104
|
return allMarks.map(performanceMarkToJson);
|
|
3068
3105
|
}
|
|
3069
|
-
var __defProp$
|
|
3070
|
-
var __defNormalProp$
|
|
3071
|
-
var __publicField$
|
|
3106
|
+
var __defProp$b = Object.defineProperty;
|
|
3107
|
+
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3108
|
+
var __publicField$b = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3072
3109
|
class BaseConvexClient {
|
|
3073
3110
|
/**
|
|
3074
3111
|
* @param address - The url of your Convex deployment, often provided
|
|
@@ -3079,25 +3116,25 @@ class BaseConvexClient {
|
|
|
3079
3116
|
* @param options - See {@link BaseConvexClientOptions} for a full description.
|
|
3080
3117
|
*/
|
|
3081
3118
|
constructor(address, onTransition, options) {
|
|
3082
|
-
__publicField$
|
|
3083
|
-
__publicField$
|
|
3084
|
-
__publicField$
|
|
3085
|
-
__publicField$
|
|
3086
|
-
__publicField$
|
|
3087
|
-
__publicField$
|
|
3088
|
-
__publicField$
|
|
3089
|
-
__publicField$
|
|
3090
|
-
__publicField$
|
|
3091
|
-
__publicField$
|
|
3092
|
-
__publicField$
|
|
3093
|
-
__publicField$
|
|
3094
|
-
__publicField$
|
|
3095
|
-
__publicField$
|
|
3096
|
-
__publicField$
|
|
3097
|
-
__publicField$
|
|
3098
|
-
__publicField$
|
|
3099
|
-
__publicField$
|
|
3100
|
-
__publicField$
|
|
3119
|
+
__publicField$b(this, "address");
|
|
3120
|
+
__publicField$b(this, "state");
|
|
3121
|
+
__publicField$b(this, "requestManager");
|
|
3122
|
+
__publicField$b(this, "webSocketManager");
|
|
3123
|
+
__publicField$b(this, "authenticationManager");
|
|
3124
|
+
__publicField$b(this, "remoteQuerySet");
|
|
3125
|
+
__publicField$b(this, "optimisticQueryResults");
|
|
3126
|
+
__publicField$b(this, "_transitionHandlerCounter", 0);
|
|
3127
|
+
__publicField$b(this, "_nextRequestId");
|
|
3128
|
+
__publicField$b(this, "_onTransitionFns", /* @__PURE__ */ new Map());
|
|
3129
|
+
__publicField$b(this, "_sessionId");
|
|
3130
|
+
__publicField$b(this, "firstMessageReceived", false);
|
|
3131
|
+
__publicField$b(this, "debug");
|
|
3132
|
+
__publicField$b(this, "logger");
|
|
3133
|
+
__publicField$b(this, "maxObservedTimestamp");
|
|
3134
|
+
__publicField$b(this, "connectionStateSubscribers", /* @__PURE__ */ new Map());
|
|
3135
|
+
__publicField$b(this, "nextConnectionStateSubscriberId", 0);
|
|
3136
|
+
__publicField$b(this, "_lastPublishedConnectionState");
|
|
3137
|
+
__publicField$b(this, "markConnectionStateDirty", () => {
|
|
3101
3138
|
void Promise.resolve().then(() => {
|
|
3102
3139
|
const curConnectionState = this.connectionState();
|
|
3103
3140
|
if (JSON.stringify(curConnectionState) !== JSON.stringify(this._lastPublishedConnectionState)) {
|
|
@@ -3108,7 +3145,7 @@ class BaseConvexClient {
|
|
|
3108
3145
|
}
|
|
3109
3146
|
});
|
|
3110
3147
|
});
|
|
3111
|
-
__publicField$
|
|
3148
|
+
__publicField$b(this, "mark", (name) => {
|
|
3112
3149
|
if (this.debug) {
|
|
3113
3150
|
mark(name, this.sessionId);
|
|
3114
3151
|
}
|
|
@@ -3776,15 +3813,15 @@ function asPaginationResult(value) {
|
|
|
3776
3813
|
}
|
|
3777
3814
|
return value;
|
|
3778
3815
|
}
|
|
3779
|
-
var __defProp$
|
|
3780
|
-
var __defNormalProp$
|
|
3781
|
-
var __publicField$
|
|
3816
|
+
var __defProp$a = Object.defineProperty;
|
|
3817
|
+
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3818
|
+
var __publicField$a = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3782
3819
|
class PaginatedQueryClient {
|
|
3783
3820
|
constructor(client, onTransition) {
|
|
3784
3821
|
this.client = client;
|
|
3785
3822
|
this.onTransition = onTransition;
|
|
3786
|
-
__publicField$
|
|
3787
|
-
__publicField$
|
|
3823
|
+
__publicField$a(this, "paginatedQuerySet", /* @__PURE__ */ new Map());
|
|
3824
|
+
__publicField$a(this, "lastTransitionTs");
|
|
3788
3825
|
this.lastTransitionTs = Long.fromNumber(0);
|
|
3789
3826
|
this.client.addOnTransitionHandler(
|
|
3790
3827
|
(transition) => this.onBaseTransition(transition)
|
|
@@ -4177,9 +4214,9 @@ function useSubscription({
|
|
|
4177
4214
|
}, [getCurrentValue, subscribe]);
|
|
4178
4215
|
return valueToReturn;
|
|
4179
4216
|
}
|
|
4180
|
-
var __defProp$
|
|
4181
|
-
var __defNormalProp$
|
|
4182
|
-
var __publicField$
|
|
4217
|
+
var __defProp$9 = Object.defineProperty;
|
|
4218
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4219
|
+
var __publicField$9 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4183
4220
|
const DEFAULT_EXTEND_SUBSCRIPTION_FOR = 5e3;
|
|
4184
4221
|
if (typeof React === "undefined") {
|
|
4185
4222
|
throw new Error("Required dependency 'react' not found");
|
|
@@ -4210,15 +4247,15 @@ class ConvexReactClient {
|
|
|
4210
4247
|
* @param options - See {@link ConvexReactClientOptions} for a full description.
|
|
4211
4248
|
*/
|
|
4212
4249
|
constructor(address, options) {
|
|
4213
|
-
__publicField$
|
|
4214
|
-
__publicField$
|
|
4215
|
-
__publicField$
|
|
4216
|
-
__publicField$
|
|
4217
|
-
__publicField$
|
|
4218
|
-
__publicField$
|
|
4219
|
-
__publicField$
|
|
4220
|
-
__publicField$
|
|
4221
|
-
__publicField$
|
|
4250
|
+
__publicField$9(this, "address");
|
|
4251
|
+
__publicField$9(this, "cachedSync");
|
|
4252
|
+
__publicField$9(this, "cachedPaginatedQueryClient");
|
|
4253
|
+
__publicField$9(this, "listeners");
|
|
4254
|
+
__publicField$9(this, "options");
|
|
4255
|
+
__publicField$9(this, "closed", false);
|
|
4256
|
+
__publicField$9(this, "_logger");
|
|
4257
|
+
__publicField$9(this, "adminAuth");
|
|
4258
|
+
__publicField$9(this, "fakeUserIdentity");
|
|
4222
4259
|
if (address === void 0) {
|
|
4223
4260
|
throw new Error(
|
|
4224
4261
|
"No address provided to ConvexReactClient.\nIf trying to deploy to production, make sure to follow all the instructions found at https://docs.convex.dev/production/hosting/\nIf running locally, make sure to run `convex dev` and ensure the .env.local file is populated."
|
|
@@ -4640,14 +4677,14 @@ function assertNotAccidentalArgument(value) {
|
|
|
4640
4677
|
);
|
|
4641
4678
|
}
|
|
4642
4679
|
}
|
|
4643
|
-
var __defProp = Object.defineProperty;
|
|
4644
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4645
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4680
|
+
var __defProp$8 = Object.defineProperty;
|
|
4681
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4682
|
+
var __publicField$8 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4646
4683
|
class QueriesObserver {
|
|
4647
4684
|
constructor(createWatch) {
|
|
4648
|
-
__publicField(this, "createWatch");
|
|
4649
|
-
__publicField(this, "queries");
|
|
4650
|
-
__publicField(this, "listeners");
|
|
4685
|
+
__publicField$8(this, "createWatch");
|
|
4686
|
+
__publicField$8(this, "queries");
|
|
4687
|
+
__publicField$8(this, "listeners");
|
|
4651
4688
|
this.createWatch = createWatch;
|
|
4652
4689
|
this.queries = {};
|
|
4653
4690
|
this.listeners = /* @__PURE__ */ new Set();
|
|
@@ -4808,6 +4845,961 @@ function useQueriesHelper(queries, createWatch) {
|
|
|
4808
4845
|
);
|
|
4809
4846
|
return useSubscription(subscription);
|
|
4810
4847
|
}
|
|
4848
|
+
function performSyscall(op, arg) {
|
|
4849
|
+
if (typeof Convex === "undefined" || Convex.syscall === void 0) {
|
|
4850
|
+
throw new Error(
|
|
4851
|
+
"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?"
|
|
4852
|
+
);
|
|
4853
|
+
}
|
|
4854
|
+
const resultStr = Convex.syscall(op, JSON.stringify(arg));
|
|
4855
|
+
return JSON.parse(resultStr);
|
|
4856
|
+
}
|
|
4857
|
+
async function performAsyncSyscall(op, arg) {
|
|
4858
|
+
if (typeof Convex === "undefined" || Convex.asyncSyscall === void 0) {
|
|
4859
|
+
throw new Error(
|
|
4860
|
+
"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?"
|
|
4861
|
+
);
|
|
4862
|
+
}
|
|
4863
|
+
let resultStr;
|
|
4864
|
+
try {
|
|
4865
|
+
resultStr = await Convex.asyncSyscall(op, JSON.stringify(arg));
|
|
4866
|
+
} catch (e) {
|
|
4867
|
+
if (e.data !== void 0) {
|
|
4868
|
+
const rethrown = new ConvexError(e.message);
|
|
4869
|
+
rethrown.data = jsonToConvex(e.data);
|
|
4870
|
+
throw rethrown;
|
|
4871
|
+
}
|
|
4872
|
+
throw new Error(e.message);
|
|
4873
|
+
}
|
|
4874
|
+
return JSON.parse(resultStr);
|
|
4875
|
+
}
|
|
4876
|
+
function validateArg(arg, idx, method, argName) {
|
|
4877
|
+
if (arg === void 0) {
|
|
4878
|
+
throw new TypeError(
|
|
4879
|
+
`Must provide arg ${idx} \`${argName}\` to \`${method}\``
|
|
4880
|
+
);
|
|
4881
|
+
}
|
|
4882
|
+
}
|
|
4883
|
+
function validateArgIsNonNegativeInteger(arg, idx, method, argName) {
|
|
4884
|
+
if (!Number.isInteger(arg) || arg < 0) {
|
|
4885
|
+
throw new TypeError(
|
|
4886
|
+
`Arg ${idx} \`${argName}\` to \`${method}\` must be a non-negative integer`
|
|
4887
|
+
);
|
|
4888
|
+
}
|
|
4889
|
+
}
|
|
4890
|
+
function setupAuth(requestId) {
|
|
4891
|
+
return {
|
|
4892
|
+
getUserIdentity: async () => {
|
|
4893
|
+
return await performAsyncSyscall("1.0/getUserIdentity", {
|
|
4894
|
+
requestId
|
|
4895
|
+
});
|
|
4896
|
+
}
|
|
4897
|
+
};
|
|
4898
|
+
}
|
|
4899
|
+
var __defProp$7 = Object.defineProperty;
|
|
4900
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4901
|
+
var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4902
|
+
class Expression {
|
|
4903
|
+
/**
|
|
4904
|
+
* @internal
|
|
4905
|
+
*/
|
|
4906
|
+
constructor() {
|
|
4907
|
+
__publicField$7(this, "_isExpression");
|
|
4908
|
+
__publicField$7(this, "_value");
|
|
4909
|
+
}
|
|
4910
|
+
}
|
|
4911
|
+
var __defProp$6 = Object.defineProperty;
|
|
4912
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4913
|
+
var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, key + "", value);
|
|
4914
|
+
class ExpressionImpl extends Expression {
|
|
4915
|
+
constructor(inner) {
|
|
4916
|
+
super();
|
|
4917
|
+
__publicField$6(this, "inner");
|
|
4918
|
+
this.inner = inner;
|
|
4919
|
+
}
|
|
4920
|
+
serialize() {
|
|
4921
|
+
return this.inner;
|
|
4922
|
+
}
|
|
4923
|
+
}
|
|
4924
|
+
function serializeExpression(expr) {
|
|
4925
|
+
if (expr instanceof ExpressionImpl) {
|
|
4926
|
+
return expr.serialize();
|
|
4927
|
+
} else {
|
|
4928
|
+
return { $literal: convexOrUndefinedToJson(expr) };
|
|
4929
|
+
}
|
|
4930
|
+
}
|
|
4931
|
+
const filterBuilderImpl = {
|
|
4932
|
+
// Comparisons /////////////////////////////////////////////////////////////
|
|
4933
|
+
eq(l, r) {
|
|
4934
|
+
return new ExpressionImpl({
|
|
4935
|
+
$eq: [serializeExpression(l), serializeExpression(r)]
|
|
4936
|
+
});
|
|
4937
|
+
},
|
|
4938
|
+
neq(l, r) {
|
|
4939
|
+
return new ExpressionImpl({
|
|
4940
|
+
$neq: [serializeExpression(l), serializeExpression(r)]
|
|
4941
|
+
});
|
|
4942
|
+
},
|
|
4943
|
+
lt(l, r) {
|
|
4944
|
+
return new ExpressionImpl({
|
|
4945
|
+
$lt: [serializeExpression(l), serializeExpression(r)]
|
|
4946
|
+
});
|
|
4947
|
+
},
|
|
4948
|
+
lte(l, r) {
|
|
4949
|
+
return new ExpressionImpl({
|
|
4950
|
+
$lte: [serializeExpression(l), serializeExpression(r)]
|
|
4951
|
+
});
|
|
4952
|
+
},
|
|
4953
|
+
gt(l, r) {
|
|
4954
|
+
return new ExpressionImpl({
|
|
4955
|
+
$gt: [serializeExpression(l), serializeExpression(r)]
|
|
4956
|
+
});
|
|
4957
|
+
},
|
|
4958
|
+
gte(l, r) {
|
|
4959
|
+
return new ExpressionImpl({
|
|
4960
|
+
$gte: [serializeExpression(l), serializeExpression(r)]
|
|
4961
|
+
});
|
|
4962
|
+
},
|
|
4963
|
+
// Arithmetic //////////////////////////////////////////////////////////////
|
|
4964
|
+
add(l, r) {
|
|
4965
|
+
return new ExpressionImpl({
|
|
4966
|
+
$add: [serializeExpression(l), serializeExpression(r)]
|
|
4967
|
+
});
|
|
4968
|
+
},
|
|
4969
|
+
sub(l, r) {
|
|
4970
|
+
return new ExpressionImpl({
|
|
4971
|
+
$sub: [serializeExpression(l), serializeExpression(r)]
|
|
4972
|
+
});
|
|
4973
|
+
},
|
|
4974
|
+
mul(l, r) {
|
|
4975
|
+
return new ExpressionImpl({
|
|
4976
|
+
$mul: [serializeExpression(l), serializeExpression(r)]
|
|
4977
|
+
});
|
|
4978
|
+
},
|
|
4979
|
+
div(l, r) {
|
|
4980
|
+
return new ExpressionImpl({
|
|
4981
|
+
$div: [serializeExpression(l), serializeExpression(r)]
|
|
4982
|
+
});
|
|
4983
|
+
},
|
|
4984
|
+
mod(l, r) {
|
|
4985
|
+
return new ExpressionImpl({
|
|
4986
|
+
$mod: [serializeExpression(l), serializeExpression(r)]
|
|
4987
|
+
});
|
|
4988
|
+
},
|
|
4989
|
+
neg(x) {
|
|
4990
|
+
return new ExpressionImpl({ $neg: serializeExpression(x) });
|
|
4991
|
+
},
|
|
4992
|
+
// Logic ///////////////////////////////////////////////////////////////////
|
|
4993
|
+
and(...exprs) {
|
|
4994
|
+
return new ExpressionImpl({ $and: exprs.map(serializeExpression) });
|
|
4995
|
+
},
|
|
4996
|
+
or(...exprs) {
|
|
4997
|
+
return new ExpressionImpl({ $or: exprs.map(serializeExpression) });
|
|
4998
|
+
},
|
|
4999
|
+
not(x) {
|
|
5000
|
+
return new ExpressionImpl({ $not: serializeExpression(x) });
|
|
5001
|
+
},
|
|
5002
|
+
// Other ///////////////////////////////////////////////////////////////////
|
|
5003
|
+
field(fieldPath) {
|
|
5004
|
+
return new ExpressionImpl({ $field: fieldPath });
|
|
5005
|
+
}
|
|
5006
|
+
};
|
|
5007
|
+
var __defProp$5 = Object.defineProperty;
|
|
5008
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5009
|
+
var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, key + "", value);
|
|
5010
|
+
class IndexRange {
|
|
5011
|
+
/**
|
|
5012
|
+
* @internal
|
|
5013
|
+
*/
|
|
5014
|
+
constructor() {
|
|
5015
|
+
__publicField$5(this, "_isIndexRange");
|
|
5016
|
+
}
|
|
5017
|
+
}
|
|
5018
|
+
var __defProp$4 = Object.defineProperty;
|
|
5019
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5020
|
+
var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5021
|
+
class IndexRangeBuilderImpl extends IndexRange {
|
|
5022
|
+
constructor(rangeExpressions) {
|
|
5023
|
+
super();
|
|
5024
|
+
__publicField$4(this, "rangeExpressions");
|
|
5025
|
+
__publicField$4(this, "isConsumed");
|
|
5026
|
+
this.rangeExpressions = rangeExpressions;
|
|
5027
|
+
this.isConsumed = false;
|
|
5028
|
+
}
|
|
5029
|
+
static new() {
|
|
5030
|
+
return new IndexRangeBuilderImpl([]);
|
|
5031
|
+
}
|
|
5032
|
+
consume() {
|
|
5033
|
+
if (this.isConsumed) {
|
|
5034
|
+
throw new Error(
|
|
5035
|
+
"IndexRangeBuilder has already been used! Chain your method calls like `q => q.eq(...).eq(...)`. See https://docs.convex.dev/using/indexes"
|
|
5036
|
+
);
|
|
5037
|
+
}
|
|
5038
|
+
this.isConsumed = true;
|
|
5039
|
+
}
|
|
5040
|
+
eq(fieldName, value) {
|
|
5041
|
+
this.consume();
|
|
5042
|
+
return new IndexRangeBuilderImpl(
|
|
5043
|
+
this.rangeExpressions.concat({
|
|
5044
|
+
type: "Eq",
|
|
5045
|
+
fieldPath: fieldName,
|
|
5046
|
+
value: convexOrUndefinedToJson(value)
|
|
5047
|
+
})
|
|
5048
|
+
);
|
|
5049
|
+
}
|
|
5050
|
+
gt(fieldName, value) {
|
|
5051
|
+
this.consume();
|
|
5052
|
+
return new IndexRangeBuilderImpl(
|
|
5053
|
+
this.rangeExpressions.concat({
|
|
5054
|
+
type: "Gt",
|
|
5055
|
+
fieldPath: fieldName,
|
|
5056
|
+
value: convexOrUndefinedToJson(value)
|
|
5057
|
+
})
|
|
5058
|
+
);
|
|
5059
|
+
}
|
|
5060
|
+
gte(fieldName, value) {
|
|
5061
|
+
this.consume();
|
|
5062
|
+
return new IndexRangeBuilderImpl(
|
|
5063
|
+
this.rangeExpressions.concat({
|
|
5064
|
+
type: "Gte",
|
|
5065
|
+
fieldPath: fieldName,
|
|
5066
|
+
value: convexOrUndefinedToJson(value)
|
|
5067
|
+
})
|
|
5068
|
+
);
|
|
5069
|
+
}
|
|
5070
|
+
lt(fieldName, value) {
|
|
5071
|
+
this.consume();
|
|
5072
|
+
return new IndexRangeBuilderImpl(
|
|
5073
|
+
this.rangeExpressions.concat({
|
|
5074
|
+
type: "Lt",
|
|
5075
|
+
fieldPath: fieldName,
|
|
5076
|
+
value: convexOrUndefinedToJson(value)
|
|
5077
|
+
})
|
|
5078
|
+
);
|
|
5079
|
+
}
|
|
5080
|
+
lte(fieldName, value) {
|
|
5081
|
+
this.consume();
|
|
5082
|
+
return new IndexRangeBuilderImpl(
|
|
5083
|
+
this.rangeExpressions.concat({
|
|
5084
|
+
type: "Lte",
|
|
5085
|
+
fieldPath: fieldName,
|
|
5086
|
+
value: convexOrUndefinedToJson(value)
|
|
5087
|
+
})
|
|
5088
|
+
);
|
|
5089
|
+
}
|
|
5090
|
+
export() {
|
|
5091
|
+
this.consume();
|
|
5092
|
+
return this.rangeExpressions;
|
|
5093
|
+
}
|
|
5094
|
+
}
|
|
5095
|
+
var __defProp$3 = Object.defineProperty;
|
|
5096
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5097
|
+
var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, key + "", value);
|
|
5098
|
+
class SearchFilter {
|
|
5099
|
+
/**
|
|
5100
|
+
* @internal
|
|
5101
|
+
*/
|
|
5102
|
+
constructor() {
|
|
5103
|
+
__publicField$3(this, "_isSearchFilter");
|
|
5104
|
+
}
|
|
5105
|
+
}
|
|
5106
|
+
var __defProp$2 = Object.defineProperty;
|
|
5107
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5108
|
+
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5109
|
+
class SearchFilterBuilderImpl extends SearchFilter {
|
|
5110
|
+
constructor(filters) {
|
|
5111
|
+
super();
|
|
5112
|
+
__publicField$2(this, "filters");
|
|
5113
|
+
__publicField$2(this, "isConsumed");
|
|
5114
|
+
this.filters = filters;
|
|
5115
|
+
this.isConsumed = false;
|
|
5116
|
+
}
|
|
5117
|
+
static new() {
|
|
5118
|
+
return new SearchFilterBuilderImpl([]);
|
|
5119
|
+
}
|
|
5120
|
+
consume() {
|
|
5121
|
+
if (this.isConsumed) {
|
|
5122
|
+
throw new Error(
|
|
5123
|
+
"SearchFilterBuilder has already been used! Chain your method calls like `q => q.search(...).eq(...)`."
|
|
5124
|
+
);
|
|
5125
|
+
}
|
|
5126
|
+
this.isConsumed = true;
|
|
5127
|
+
}
|
|
5128
|
+
search(fieldName, query) {
|
|
5129
|
+
validateArg(fieldName, 1, "search", "fieldName");
|
|
5130
|
+
validateArg(query, 2, "search", "query");
|
|
5131
|
+
this.consume();
|
|
5132
|
+
return new SearchFilterBuilderImpl(
|
|
5133
|
+
this.filters.concat({
|
|
5134
|
+
type: "Search",
|
|
5135
|
+
fieldPath: fieldName,
|
|
5136
|
+
value: query
|
|
5137
|
+
})
|
|
5138
|
+
);
|
|
5139
|
+
}
|
|
5140
|
+
eq(fieldName, value) {
|
|
5141
|
+
validateArg(fieldName, 1, "eq", "fieldName");
|
|
5142
|
+
if (arguments.length !== 2) {
|
|
5143
|
+
validateArg(value, 2, "search", "value");
|
|
5144
|
+
}
|
|
5145
|
+
this.consume();
|
|
5146
|
+
return new SearchFilterBuilderImpl(
|
|
5147
|
+
this.filters.concat({
|
|
5148
|
+
type: "Eq",
|
|
5149
|
+
fieldPath: fieldName,
|
|
5150
|
+
value: convexOrUndefinedToJson(value)
|
|
5151
|
+
})
|
|
5152
|
+
);
|
|
5153
|
+
}
|
|
5154
|
+
export() {
|
|
5155
|
+
this.consume();
|
|
5156
|
+
return this.filters;
|
|
5157
|
+
}
|
|
5158
|
+
}
|
|
5159
|
+
var __defProp$1 = Object.defineProperty;
|
|
5160
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5161
|
+
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5162
|
+
const MAX_QUERY_OPERATORS = 256;
|
|
5163
|
+
class QueryInitializerImpl {
|
|
5164
|
+
constructor(tableName) {
|
|
5165
|
+
__publicField$1(this, "tableName");
|
|
5166
|
+
this.tableName = tableName;
|
|
5167
|
+
}
|
|
5168
|
+
withIndex(indexName, indexRange) {
|
|
5169
|
+
validateArg(indexName, 1, "withIndex", "indexName");
|
|
5170
|
+
let rangeBuilder = IndexRangeBuilderImpl.new();
|
|
5171
|
+
if (indexRange !== void 0) {
|
|
5172
|
+
rangeBuilder = indexRange(rangeBuilder);
|
|
5173
|
+
}
|
|
5174
|
+
return new QueryImpl({
|
|
5175
|
+
source: {
|
|
5176
|
+
type: "IndexRange",
|
|
5177
|
+
indexName: this.tableName + "." + indexName,
|
|
5178
|
+
range: rangeBuilder.export(),
|
|
5179
|
+
order: null
|
|
5180
|
+
},
|
|
5181
|
+
operators: []
|
|
5182
|
+
});
|
|
5183
|
+
}
|
|
5184
|
+
withSearchIndex(indexName, searchFilter) {
|
|
5185
|
+
validateArg(indexName, 1, "withSearchIndex", "indexName");
|
|
5186
|
+
validateArg(searchFilter, 2, "withSearchIndex", "searchFilter");
|
|
5187
|
+
const searchFilterBuilder = SearchFilterBuilderImpl.new();
|
|
5188
|
+
return new QueryImpl({
|
|
5189
|
+
source: {
|
|
5190
|
+
type: "Search",
|
|
5191
|
+
indexName: this.tableName + "." + indexName,
|
|
5192
|
+
filters: searchFilter(searchFilterBuilder).export()
|
|
5193
|
+
},
|
|
5194
|
+
operators: []
|
|
5195
|
+
});
|
|
5196
|
+
}
|
|
5197
|
+
fullTableScan() {
|
|
5198
|
+
return new QueryImpl({
|
|
5199
|
+
source: {
|
|
5200
|
+
type: "FullTableScan",
|
|
5201
|
+
tableName: this.tableName,
|
|
5202
|
+
order: null
|
|
5203
|
+
},
|
|
5204
|
+
operators: []
|
|
5205
|
+
});
|
|
5206
|
+
}
|
|
5207
|
+
order(order) {
|
|
5208
|
+
return this.fullTableScan().order(order);
|
|
5209
|
+
}
|
|
5210
|
+
// This is internal API and should not be exposed to developers yet.
|
|
5211
|
+
async count() {
|
|
5212
|
+
const syscallJSON = await performAsyncSyscall("1.0/count", {
|
|
5213
|
+
table: this.tableName
|
|
5214
|
+
});
|
|
5215
|
+
const syscallResult = jsonToConvex(syscallJSON);
|
|
5216
|
+
return syscallResult;
|
|
5217
|
+
}
|
|
5218
|
+
filter(predicate) {
|
|
5219
|
+
return this.fullTableScan().filter(predicate);
|
|
5220
|
+
}
|
|
5221
|
+
limit(n) {
|
|
5222
|
+
return this.fullTableScan().limit(n);
|
|
5223
|
+
}
|
|
5224
|
+
collect() {
|
|
5225
|
+
return this.fullTableScan().collect();
|
|
5226
|
+
}
|
|
5227
|
+
take(n) {
|
|
5228
|
+
return this.fullTableScan().take(n);
|
|
5229
|
+
}
|
|
5230
|
+
paginate(paginationOpts) {
|
|
5231
|
+
return this.fullTableScan().paginate(paginationOpts);
|
|
5232
|
+
}
|
|
5233
|
+
first() {
|
|
5234
|
+
return this.fullTableScan().first();
|
|
5235
|
+
}
|
|
5236
|
+
unique() {
|
|
5237
|
+
return this.fullTableScan().unique();
|
|
5238
|
+
}
|
|
5239
|
+
[Symbol.asyncIterator]() {
|
|
5240
|
+
return this.fullTableScan()[Symbol.asyncIterator]();
|
|
5241
|
+
}
|
|
5242
|
+
}
|
|
5243
|
+
function throwClosedError(type) {
|
|
5244
|
+
throw new Error(
|
|
5245
|
+
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."
|
|
5246
|
+
);
|
|
5247
|
+
}
|
|
5248
|
+
class QueryImpl {
|
|
5249
|
+
constructor(query) {
|
|
5250
|
+
__publicField$1(this, "state");
|
|
5251
|
+
__publicField$1(this, "tableNameForErrorMessages");
|
|
5252
|
+
this.state = { type: "preparing", query };
|
|
5253
|
+
if (query.source.type === "FullTableScan") {
|
|
5254
|
+
this.tableNameForErrorMessages = query.source.tableName;
|
|
5255
|
+
} else {
|
|
5256
|
+
this.tableNameForErrorMessages = query.source.indexName.split(".")[0];
|
|
5257
|
+
}
|
|
5258
|
+
}
|
|
5259
|
+
takeQuery() {
|
|
5260
|
+
if (this.state.type !== "preparing") {
|
|
5261
|
+
throw new Error(
|
|
5262
|
+
"A query can only be chained once and can't be chained after iteration begins."
|
|
5263
|
+
);
|
|
5264
|
+
}
|
|
5265
|
+
const query = this.state.query;
|
|
5266
|
+
this.state = { type: "closed" };
|
|
5267
|
+
return query;
|
|
5268
|
+
}
|
|
5269
|
+
startQuery() {
|
|
5270
|
+
if (this.state.type === "executing") {
|
|
5271
|
+
throw new Error("Iteration can only begin on a query once.");
|
|
5272
|
+
}
|
|
5273
|
+
if (this.state.type === "closed" || this.state.type === "consumed") {
|
|
5274
|
+
throwClosedError(this.state.type);
|
|
5275
|
+
}
|
|
5276
|
+
const query = this.state.query;
|
|
5277
|
+
const { queryId } = performSyscall("1.0/queryStream", { query, version });
|
|
5278
|
+
this.state = { type: "executing", queryId };
|
|
5279
|
+
return queryId;
|
|
5280
|
+
}
|
|
5281
|
+
closeQuery() {
|
|
5282
|
+
if (this.state.type === "executing") {
|
|
5283
|
+
const queryId = this.state.queryId;
|
|
5284
|
+
performSyscall("1.0/queryCleanup", { queryId });
|
|
5285
|
+
}
|
|
5286
|
+
this.state = { type: "consumed" };
|
|
5287
|
+
}
|
|
5288
|
+
order(order) {
|
|
5289
|
+
validateArg(order, 1, "order", "order");
|
|
5290
|
+
const query = this.takeQuery();
|
|
5291
|
+
if (query.source.type === "Search") {
|
|
5292
|
+
throw new Error(
|
|
5293
|
+
"Search queries must always be in relevance order. Can not set order manually."
|
|
5294
|
+
);
|
|
5295
|
+
}
|
|
5296
|
+
if (query.source.order !== null) {
|
|
5297
|
+
throw new Error("Queries may only specify order at most once");
|
|
5298
|
+
}
|
|
5299
|
+
query.source.order = order;
|
|
5300
|
+
return new QueryImpl(query);
|
|
5301
|
+
}
|
|
5302
|
+
filter(predicate) {
|
|
5303
|
+
validateArg(predicate, 1, "filter", "predicate");
|
|
5304
|
+
const query = this.takeQuery();
|
|
5305
|
+
if (query.operators.length >= MAX_QUERY_OPERATORS) {
|
|
5306
|
+
throw new Error(
|
|
5307
|
+
`Can't construct query with more than ${MAX_QUERY_OPERATORS} operators`
|
|
5308
|
+
);
|
|
5309
|
+
}
|
|
5310
|
+
query.operators.push({
|
|
5311
|
+
filter: serializeExpression(predicate(filterBuilderImpl))
|
|
5312
|
+
});
|
|
5313
|
+
return new QueryImpl(query);
|
|
5314
|
+
}
|
|
5315
|
+
limit(n) {
|
|
5316
|
+
validateArg(n, 1, "limit", "n");
|
|
5317
|
+
const query = this.takeQuery();
|
|
5318
|
+
query.operators.push({ limit: n });
|
|
5319
|
+
return new QueryImpl(query);
|
|
5320
|
+
}
|
|
5321
|
+
[Symbol.asyncIterator]() {
|
|
5322
|
+
this.startQuery();
|
|
5323
|
+
return this;
|
|
5324
|
+
}
|
|
5325
|
+
async next() {
|
|
5326
|
+
if (this.state.type === "closed" || this.state.type === "consumed") {
|
|
5327
|
+
throwClosedError(this.state.type);
|
|
5328
|
+
}
|
|
5329
|
+
const queryId = this.state.type === "preparing" ? this.startQuery() : this.state.queryId;
|
|
5330
|
+
const { value, done } = await performAsyncSyscall("1.0/queryStreamNext", {
|
|
5331
|
+
queryId
|
|
5332
|
+
});
|
|
5333
|
+
if (done) {
|
|
5334
|
+
this.closeQuery();
|
|
5335
|
+
}
|
|
5336
|
+
const convexValue = jsonToConvex(value);
|
|
5337
|
+
return { value: convexValue, done };
|
|
5338
|
+
}
|
|
5339
|
+
return() {
|
|
5340
|
+
this.closeQuery();
|
|
5341
|
+
return Promise.resolve({ done: true, value: void 0 });
|
|
5342
|
+
}
|
|
5343
|
+
async paginate(paginationOpts) {
|
|
5344
|
+
validateArg(paginationOpts, 1, "paginate", "options");
|
|
5345
|
+
if (typeof paginationOpts?.numItems !== "number" || paginationOpts.numItems < 0) {
|
|
5346
|
+
throw new Error(
|
|
5347
|
+
`\`options.numItems\` must be a positive number. Received \`${paginationOpts?.numItems}\`.`
|
|
5348
|
+
);
|
|
5349
|
+
}
|
|
5350
|
+
const query = this.takeQuery();
|
|
5351
|
+
const pageSize = paginationOpts.numItems;
|
|
5352
|
+
const cursor = paginationOpts.cursor;
|
|
5353
|
+
const endCursor = paginationOpts?.endCursor ?? null;
|
|
5354
|
+
const maximumRowsRead = paginationOpts.maximumRowsRead ?? null;
|
|
5355
|
+
const { page, isDone, continueCursor, splitCursor, pageStatus } = await performAsyncSyscall("1.0/queryPage", {
|
|
5356
|
+
query,
|
|
5357
|
+
cursor,
|
|
5358
|
+
endCursor,
|
|
5359
|
+
pageSize,
|
|
5360
|
+
maximumRowsRead,
|
|
5361
|
+
maximumBytesRead: paginationOpts.maximumBytesRead,
|
|
5362
|
+
version
|
|
5363
|
+
});
|
|
5364
|
+
return {
|
|
5365
|
+
page: page.map((json) => jsonToConvex(json)),
|
|
5366
|
+
isDone,
|
|
5367
|
+
continueCursor,
|
|
5368
|
+
splitCursor,
|
|
5369
|
+
pageStatus
|
|
5370
|
+
};
|
|
5371
|
+
}
|
|
5372
|
+
async collect() {
|
|
5373
|
+
const out = [];
|
|
5374
|
+
for await (const item of this) {
|
|
5375
|
+
out.push(item);
|
|
5376
|
+
}
|
|
5377
|
+
return out;
|
|
5378
|
+
}
|
|
5379
|
+
async take(n) {
|
|
5380
|
+
validateArg(n, 1, "take", "n");
|
|
5381
|
+
validateArgIsNonNegativeInteger(n, 1, "take", "n");
|
|
5382
|
+
return this.limit(n).collect();
|
|
5383
|
+
}
|
|
5384
|
+
async first() {
|
|
5385
|
+
const first_array = await this.take(1);
|
|
5386
|
+
return first_array.length === 0 ? null : first_array[0];
|
|
5387
|
+
}
|
|
5388
|
+
async unique() {
|
|
5389
|
+
const first_two_array = await this.take(2);
|
|
5390
|
+
if (first_two_array.length === 0) {
|
|
5391
|
+
return null;
|
|
5392
|
+
}
|
|
5393
|
+
if (first_two_array.length === 2) {
|
|
5394
|
+
throw new Error(`unique() query returned more than one result from table ${this.tableNameForErrorMessages}:
|
|
5395
|
+
[${first_two_array[0]._id}, ${first_two_array[1]._id}, ...]`);
|
|
5396
|
+
}
|
|
5397
|
+
return first_two_array[0];
|
|
5398
|
+
}
|
|
5399
|
+
}
|
|
5400
|
+
async function get(table, id, isSystem) {
|
|
5401
|
+
validateArg(id, 1, "get", "id");
|
|
5402
|
+
if (typeof id !== "string") {
|
|
5403
|
+
throw new Error(
|
|
5404
|
+
`Invalid argument \`id\` for \`db.get\`, expected string but got '${typeof id}': ${id}`
|
|
5405
|
+
);
|
|
5406
|
+
}
|
|
5407
|
+
const args = {
|
|
5408
|
+
id: convexToJson(id),
|
|
5409
|
+
isSystem,
|
|
5410
|
+
version,
|
|
5411
|
+
table
|
|
5412
|
+
};
|
|
5413
|
+
const syscallJSON = await performAsyncSyscall("1.0/get", args);
|
|
5414
|
+
return jsonToConvex(syscallJSON);
|
|
5415
|
+
}
|
|
5416
|
+
function setupReader() {
|
|
5417
|
+
const reader = (isSystem = false) => {
|
|
5418
|
+
return {
|
|
5419
|
+
get: async (arg0, arg1) => {
|
|
5420
|
+
return arg1 !== void 0 ? await get(arg0, arg1, isSystem) : await get(void 0, arg0, isSystem);
|
|
5421
|
+
},
|
|
5422
|
+
query: (tableName) => {
|
|
5423
|
+
return new TableReader(tableName, isSystem).query();
|
|
5424
|
+
},
|
|
5425
|
+
normalizeId: (tableName, id) => {
|
|
5426
|
+
validateArg(tableName, 1, "normalizeId", "tableName");
|
|
5427
|
+
validateArg(id, 2, "normalizeId", "id");
|
|
5428
|
+
const accessingSystemTable = tableName.startsWith("_");
|
|
5429
|
+
if (accessingSystemTable !== isSystem) {
|
|
5430
|
+
throw new Error(
|
|
5431
|
+
`${accessingSystemTable ? "System" : "User"} tables can only be accessed from db.${isSystem ? "" : "system."}normalizeId().`
|
|
5432
|
+
);
|
|
5433
|
+
}
|
|
5434
|
+
const syscallJSON = performSyscall("1.0/db/normalizeId", {
|
|
5435
|
+
table: tableName,
|
|
5436
|
+
idString: id
|
|
5437
|
+
});
|
|
5438
|
+
const syscallResult = jsonToConvex(syscallJSON);
|
|
5439
|
+
return syscallResult.id;
|
|
5440
|
+
},
|
|
5441
|
+
// We set the system reader on the next line
|
|
5442
|
+
system: null,
|
|
5443
|
+
table: (tableName) => {
|
|
5444
|
+
return new TableReader(tableName, isSystem);
|
|
5445
|
+
}
|
|
5446
|
+
};
|
|
5447
|
+
};
|
|
5448
|
+
const { system: _, ...rest } = reader(true);
|
|
5449
|
+
const r = reader();
|
|
5450
|
+
r.system = rest;
|
|
5451
|
+
return r;
|
|
5452
|
+
}
|
|
5453
|
+
async function insert(tableName, value) {
|
|
5454
|
+
if (tableName.startsWith("_")) {
|
|
5455
|
+
throw new Error("System tables (prefixed with `_`) are read-only.");
|
|
5456
|
+
}
|
|
5457
|
+
validateArg(tableName, 1, "insert", "table");
|
|
5458
|
+
validateArg(value, 2, "insert", "value");
|
|
5459
|
+
const syscallJSON = await performAsyncSyscall("1.0/insert", {
|
|
5460
|
+
table: tableName,
|
|
5461
|
+
value: convexToJson(value)
|
|
5462
|
+
});
|
|
5463
|
+
const syscallResult = jsonToConvex(syscallJSON);
|
|
5464
|
+
return syscallResult._id;
|
|
5465
|
+
}
|
|
5466
|
+
async function patch(table, id, value) {
|
|
5467
|
+
validateArg(id, 1, "patch", "id");
|
|
5468
|
+
validateArg(value, 2, "patch", "value");
|
|
5469
|
+
await performAsyncSyscall("1.0/shallowMerge", {
|
|
5470
|
+
id: convexToJson(id),
|
|
5471
|
+
value: patchValueToJson(value),
|
|
5472
|
+
table
|
|
5473
|
+
});
|
|
5474
|
+
}
|
|
5475
|
+
async function replace(table, id, value) {
|
|
5476
|
+
validateArg(id, 1, "replace", "id");
|
|
5477
|
+
validateArg(value, 2, "replace", "value");
|
|
5478
|
+
await performAsyncSyscall("1.0/replace", {
|
|
5479
|
+
id: convexToJson(id),
|
|
5480
|
+
value: convexToJson(value),
|
|
5481
|
+
table
|
|
5482
|
+
});
|
|
5483
|
+
}
|
|
5484
|
+
async function delete_(table, id) {
|
|
5485
|
+
validateArg(id, 1, "delete", "id");
|
|
5486
|
+
await performAsyncSyscall("1.0/remove", {
|
|
5487
|
+
id: convexToJson(id),
|
|
5488
|
+
table
|
|
5489
|
+
});
|
|
5490
|
+
}
|
|
5491
|
+
function setupWriter() {
|
|
5492
|
+
const reader = setupReader();
|
|
5493
|
+
return {
|
|
5494
|
+
get: reader.get,
|
|
5495
|
+
query: reader.query,
|
|
5496
|
+
normalizeId: reader.normalizeId,
|
|
5497
|
+
system: reader.system,
|
|
5498
|
+
insert: async (table, value) => {
|
|
5499
|
+
return await insert(table, value);
|
|
5500
|
+
},
|
|
5501
|
+
patch: async (arg0, arg1, arg2) => {
|
|
5502
|
+
return arg2 !== void 0 ? await patch(arg0, arg1, arg2) : await patch(void 0, arg0, arg1);
|
|
5503
|
+
},
|
|
5504
|
+
replace: async (arg0, arg1, arg2) => {
|
|
5505
|
+
return arg2 !== void 0 ? await replace(arg0, arg1, arg2) : await replace(void 0, arg0, arg1);
|
|
5506
|
+
},
|
|
5507
|
+
delete: async (arg0, arg1) => {
|
|
5508
|
+
return arg1 !== void 0 ? await delete_(arg0, arg1) : await delete_(void 0, arg0);
|
|
5509
|
+
},
|
|
5510
|
+
table: (tableName) => {
|
|
5511
|
+
return new TableWriter(tableName, false);
|
|
5512
|
+
}
|
|
5513
|
+
};
|
|
5514
|
+
}
|
|
5515
|
+
class TableReader {
|
|
5516
|
+
constructor(tableName, isSystem) {
|
|
5517
|
+
this.tableName = tableName;
|
|
5518
|
+
this.isSystem = isSystem;
|
|
5519
|
+
}
|
|
5520
|
+
async get(id) {
|
|
5521
|
+
return get(this.tableName, id, this.isSystem);
|
|
5522
|
+
}
|
|
5523
|
+
query() {
|
|
5524
|
+
const accessingSystemTable = this.tableName.startsWith("_");
|
|
5525
|
+
if (accessingSystemTable !== this.isSystem) {
|
|
5526
|
+
throw new Error(
|
|
5527
|
+
`${accessingSystemTable ? "System" : "User"} tables can only be accessed from db.${this.isSystem ? "" : "system."}query().`
|
|
5528
|
+
);
|
|
5529
|
+
}
|
|
5530
|
+
return new QueryInitializerImpl(this.tableName);
|
|
5531
|
+
}
|
|
5532
|
+
}
|
|
5533
|
+
class TableWriter extends TableReader {
|
|
5534
|
+
async insert(value) {
|
|
5535
|
+
return insert(this.tableName, value);
|
|
5536
|
+
}
|
|
5537
|
+
async patch(id, value) {
|
|
5538
|
+
return patch(this.tableName, id, value);
|
|
5539
|
+
}
|
|
5540
|
+
async replace(id, value) {
|
|
5541
|
+
return replace(this.tableName, id, value);
|
|
5542
|
+
}
|
|
5543
|
+
async delete(id) {
|
|
5544
|
+
return delete_(this.tableName, id);
|
|
5545
|
+
}
|
|
5546
|
+
}
|
|
5547
|
+
function setupMutationScheduler() {
|
|
5548
|
+
return {
|
|
5549
|
+
runAfter: async (delayMs, functionReference, args) => {
|
|
5550
|
+
const syscallArgs = runAfterSyscallArgs(delayMs, functionReference, args);
|
|
5551
|
+
return await performAsyncSyscall("1.0/schedule", syscallArgs);
|
|
5552
|
+
},
|
|
5553
|
+
runAt: async (ms_since_epoch_or_date, functionReference, args) => {
|
|
5554
|
+
const syscallArgs = runAtSyscallArgs(
|
|
5555
|
+
ms_since_epoch_or_date,
|
|
5556
|
+
functionReference,
|
|
5557
|
+
args
|
|
5558
|
+
);
|
|
5559
|
+
return await performAsyncSyscall("1.0/schedule", syscallArgs);
|
|
5560
|
+
},
|
|
5561
|
+
cancel: async (id) => {
|
|
5562
|
+
validateArg(id, 1, "cancel", "id");
|
|
5563
|
+
const args = { id: convexToJson(id) };
|
|
5564
|
+
await performAsyncSyscall("1.0/cancel_job", args);
|
|
5565
|
+
}
|
|
5566
|
+
};
|
|
5567
|
+
}
|
|
5568
|
+
function runAfterSyscallArgs(delayMs, functionReference, args) {
|
|
5569
|
+
if (typeof delayMs !== "number") {
|
|
5570
|
+
throw new Error("`delayMs` must be a number");
|
|
5571
|
+
}
|
|
5572
|
+
if (!isFinite(delayMs)) {
|
|
5573
|
+
throw new Error("`delayMs` must be a finite number");
|
|
5574
|
+
}
|
|
5575
|
+
if (delayMs < 0) {
|
|
5576
|
+
throw new Error("`delayMs` must be non-negative");
|
|
5577
|
+
}
|
|
5578
|
+
const functionArgs = parseArgs(args);
|
|
5579
|
+
const address = getFunctionAddress(functionReference);
|
|
5580
|
+
const ts = (Date.now() + delayMs) / 1e3;
|
|
5581
|
+
return {
|
|
5582
|
+
...address,
|
|
5583
|
+
ts,
|
|
5584
|
+
args: convexToJson(functionArgs),
|
|
5585
|
+
version
|
|
5586
|
+
};
|
|
5587
|
+
}
|
|
5588
|
+
function runAtSyscallArgs(ms_since_epoch_or_date, functionReference, args) {
|
|
5589
|
+
let ts;
|
|
5590
|
+
if (ms_since_epoch_or_date instanceof Date) {
|
|
5591
|
+
ts = ms_since_epoch_or_date.valueOf() / 1e3;
|
|
5592
|
+
} else if (typeof ms_since_epoch_or_date === "number") {
|
|
5593
|
+
ts = ms_since_epoch_or_date / 1e3;
|
|
5594
|
+
} else {
|
|
5595
|
+
throw new Error("The invoke time must a Date or a timestamp");
|
|
5596
|
+
}
|
|
5597
|
+
const address = getFunctionAddress(functionReference);
|
|
5598
|
+
const functionArgs = parseArgs(args);
|
|
5599
|
+
return {
|
|
5600
|
+
...address,
|
|
5601
|
+
ts,
|
|
5602
|
+
args: convexToJson(functionArgs),
|
|
5603
|
+
version
|
|
5604
|
+
};
|
|
5605
|
+
}
|
|
5606
|
+
function setupStorageReader(requestId) {
|
|
5607
|
+
return {
|
|
5608
|
+
getUrl: async (storageId) => {
|
|
5609
|
+
validateArg(storageId, 1, "getUrl", "storageId");
|
|
5610
|
+
return await performAsyncSyscall("1.0/storageGetUrl", {
|
|
5611
|
+
requestId,
|
|
5612
|
+
version,
|
|
5613
|
+
storageId
|
|
5614
|
+
});
|
|
5615
|
+
},
|
|
5616
|
+
getMetadata: async (storageId) => {
|
|
5617
|
+
return await performAsyncSyscall("1.0/storageGetMetadata", {
|
|
5618
|
+
requestId,
|
|
5619
|
+
version,
|
|
5620
|
+
storageId
|
|
5621
|
+
});
|
|
5622
|
+
}
|
|
5623
|
+
};
|
|
5624
|
+
}
|
|
5625
|
+
function setupStorageWriter(requestId) {
|
|
5626
|
+
const reader = setupStorageReader(requestId);
|
|
5627
|
+
return {
|
|
5628
|
+
generateUploadUrl: async () => {
|
|
5629
|
+
return await performAsyncSyscall("1.0/storageGenerateUploadUrl", {
|
|
5630
|
+
requestId,
|
|
5631
|
+
version
|
|
5632
|
+
});
|
|
5633
|
+
},
|
|
5634
|
+
delete: async (storageId) => {
|
|
5635
|
+
await performAsyncSyscall("1.0/storageDelete", {
|
|
5636
|
+
requestId,
|
|
5637
|
+
version,
|
|
5638
|
+
storageId
|
|
5639
|
+
});
|
|
5640
|
+
},
|
|
5641
|
+
getUrl: reader.getUrl,
|
|
5642
|
+
getMetadata: reader.getMetadata
|
|
5643
|
+
};
|
|
5644
|
+
}
|
|
5645
|
+
async function invokeMutation(func, argsStr) {
|
|
5646
|
+
const requestId = "";
|
|
5647
|
+
const args = jsonToConvex(JSON.parse(argsStr));
|
|
5648
|
+
const mutationCtx = {
|
|
5649
|
+
db: setupWriter(),
|
|
5650
|
+
auth: setupAuth(requestId),
|
|
5651
|
+
storage: setupStorageWriter(requestId),
|
|
5652
|
+
scheduler: setupMutationScheduler(),
|
|
5653
|
+
runQuery: (reference, args2) => runUdf("query", reference, args2),
|
|
5654
|
+
runMutation: (reference, args2) => runUdf("mutation", reference, args2)
|
|
5655
|
+
};
|
|
5656
|
+
const result = await invokeFunction(func, mutationCtx, args);
|
|
5657
|
+
validateReturnValue(result);
|
|
5658
|
+
return JSON.stringify(convexToJson(result === void 0 ? null : result));
|
|
5659
|
+
}
|
|
5660
|
+
function validateReturnValue(v2) {
|
|
5661
|
+
if (v2 instanceof QueryInitializerImpl || v2 instanceof QueryImpl) {
|
|
5662
|
+
throw new Error(
|
|
5663
|
+
"Return value is a Query. Results must be retrieved with `.collect()`, `.take(n), `.unique()`, or `.first()`."
|
|
5664
|
+
);
|
|
5665
|
+
}
|
|
5666
|
+
}
|
|
5667
|
+
async function invokeFunction(func, ctx, args) {
|
|
5668
|
+
let result;
|
|
5669
|
+
try {
|
|
5670
|
+
result = await Promise.resolve(func(ctx, ...args));
|
|
5671
|
+
} catch (thrown) {
|
|
5672
|
+
throw serializeConvexErrorData(thrown);
|
|
5673
|
+
}
|
|
5674
|
+
return result;
|
|
5675
|
+
}
|
|
5676
|
+
function dontCallDirectly(funcType, handler) {
|
|
5677
|
+
return (ctx, args) => {
|
|
5678
|
+
globalThis.console.warn(
|
|
5679
|
+
`Convex functions should not directly call other Convex functions. Consider calling a helper function instead. e.g. \`export const foo = ${funcType}(...); await foo(ctx);\` is not supported. See https://docs.convex.dev/production/best-practices/#use-helper-functions-to-write-shared-code`
|
|
5680
|
+
);
|
|
5681
|
+
return handler(ctx, args);
|
|
5682
|
+
};
|
|
5683
|
+
}
|
|
5684
|
+
function serializeConvexErrorData(thrown) {
|
|
5685
|
+
if (typeof thrown === "object" && thrown !== null && /* @__PURE__ */ Symbol.for("ConvexError") in thrown) {
|
|
5686
|
+
const error = thrown;
|
|
5687
|
+
error.data = JSON.stringify(
|
|
5688
|
+
convexToJson(error.data === void 0 ? null : error.data)
|
|
5689
|
+
);
|
|
5690
|
+
error.ConvexErrorSymbol = /* @__PURE__ */ Symbol.for("ConvexError");
|
|
5691
|
+
return error;
|
|
5692
|
+
} else {
|
|
5693
|
+
return thrown;
|
|
5694
|
+
}
|
|
5695
|
+
}
|
|
5696
|
+
function assertNotBrowser() {
|
|
5697
|
+
if (typeof window === "undefined" || window.__convexAllowFunctionsInBrowser) {
|
|
5698
|
+
return;
|
|
5699
|
+
}
|
|
5700
|
+
const isRealBrowser = Object.getOwnPropertyDescriptor(globalThis, "window")?.get?.toString().includes("[native code]") ?? false;
|
|
5701
|
+
if (isRealBrowser) {
|
|
5702
|
+
console.error(
|
|
5703
|
+
"Convex functions should not be imported in the browser. This will throw an error in future versions of `convex`. If this is a false negative, please report it to Convex support."
|
|
5704
|
+
);
|
|
5705
|
+
}
|
|
5706
|
+
}
|
|
5707
|
+
function strictReplacer(key, value) {
|
|
5708
|
+
if (value === void 0) {
|
|
5709
|
+
throw new Error(
|
|
5710
|
+
`A validator is undefined for field "${key}". This is often caused by circular imports. See https://docs.convex.dev/error#undefined-validator for details.`
|
|
5711
|
+
);
|
|
5712
|
+
}
|
|
5713
|
+
return value;
|
|
5714
|
+
}
|
|
5715
|
+
function exportArgs(functionDefinition) {
|
|
5716
|
+
return () => {
|
|
5717
|
+
let args = v.any();
|
|
5718
|
+
if (typeof functionDefinition === "object" && functionDefinition.args !== void 0) {
|
|
5719
|
+
args = asObjectValidator(functionDefinition.args);
|
|
5720
|
+
}
|
|
5721
|
+
return JSON.stringify(args.json, strictReplacer);
|
|
5722
|
+
};
|
|
5723
|
+
}
|
|
5724
|
+
function exportReturns(functionDefinition) {
|
|
5725
|
+
return () => {
|
|
5726
|
+
let returns;
|
|
5727
|
+
if (typeof functionDefinition === "object" && functionDefinition.returns !== void 0) {
|
|
5728
|
+
returns = asObjectValidator(functionDefinition.returns);
|
|
5729
|
+
}
|
|
5730
|
+
return JSON.stringify(returns ? returns.json : null, strictReplacer);
|
|
5731
|
+
};
|
|
5732
|
+
}
|
|
5733
|
+
const mutationGeneric = ((functionDefinition) => {
|
|
5734
|
+
const handler = typeof functionDefinition === "function" ? functionDefinition : functionDefinition.handler;
|
|
5735
|
+
const func = dontCallDirectly("mutation", handler);
|
|
5736
|
+
assertNotBrowser();
|
|
5737
|
+
func.isMutation = true;
|
|
5738
|
+
func.isPublic = true;
|
|
5739
|
+
func.invokeMutation = (argsStr) => invokeMutation(handler, argsStr);
|
|
5740
|
+
func.exportArgs = exportArgs(functionDefinition);
|
|
5741
|
+
func.exportReturns = exportReturns(functionDefinition);
|
|
5742
|
+
func._handler = handler;
|
|
5743
|
+
return func;
|
|
5744
|
+
});
|
|
5745
|
+
const internalMutationGeneric = ((functionDefinition) => {
|
|
5746
|
+
const handler = typeof functionDefinition === "function" ? functionDefinition : functionDefinition.handler;
|
|
5747
|
+
const func = dontCallDirectly(
|
|
5748
|
+
"internalMutation",
|
|
5749
|
+
handler
|
|
5750
|
+
);
|
|
5751
|
+
assertNotBrowser();
|
|
5752
|
+
func.isMutation = true;
|
|
5753
|
+
func.isInternal = true;
|
|
5754
|
+
func.invokeMutation = (argsStr) => invokeMutation(handler, argsStr);
|
|
5755
|
+
func.exportArgs = exportArgs(functionDefinition);
|
|
5756
|
+
func.exportReturns = exportReturns(functionDefinition);
|
|
5757
|
+
func._handler = handler;
|
|
5758
|
+
return func;
|
|
5759
|
+
});
|
|
5760
|
+
async function invokeQuery(func, argsStr) {
|
|
5761
|
+
const requestId = "";
|
|
5762
|
+
const args = jsonToConvex(JSON.parse(argsStr));
|
|
5763
|
+
const queryCtx = {
|
|
5764
|
+
db: setupReader(),
|
|
5765
|
+
auth: setupAuth(requestId),
|
|
5766
|
+
storage: setupStorageReader(requestId),
|
|
5767
|
+
runQuery: (reference, args2) => runUdf("query", reference, args2)
|
|
5768
|
+
};
|
|
5769
|
+
const result = await invokeFunction(func, queryCtx, args);
|
|
5770
|
+
validateReturnValue(result);
|
|
5771
|
+
return JSON.stringify(convexToJson(result === void 0 ? null : result));
|
|
5772
|
+
}
|
|
5773
|
+
const queryGeneric = ((functionDefinition) => {
|
|
5774
|
+
const handler = typeof functionDefinition === "function" ? functionDefinition : functionDefinition.handler;
|
|
5775
|
+
const func = dontCallDirectly("query", handler);
|
|
5776
|
+
assertNotBrowser();
|
|
5777
|
+
func.isQuery = true;
|
|
5778
|
+
func.isPublic = true;
|
|
5779
|
+
func.invokeQuery = (argsStr) => invokeQuery(handler, argsStr);
|
|
5780
|
+
func.exportArgs = exportArgs(functionDefinition);
|
|
5781
|
+
func.exportReturns = exportReturns(functionDefinition);
|
|
5782
|
+
func._handler = handler;
|
|
5783
|
+
return func;
|
|
5784
|
+
});
|
|
5785
|
+
async function runUdf(udfType, f, args) {
|
|
5786
|
+
const queryArgs = parseArgs(args);
|
|
5787
|
+
const syscallArgs = {
|
|
5788
|
+
udfType,
|
|
5789
|
+
args: convexToJson(queryArgs),
|
|
5790
|
+
...getFunctionAddress(f)
|
|
5791
|
+
};
|
|
5792
|
+
const result = await performAsyncSyscall("1.0/runUdf", syscallArgs);
|
|
5793
|
+
return jsonToConvex(result);
|
|
5794
|
+
}
|
|
5795
|
+
const paginationOptsValidator = v.object({
|
|
5796
|
+
numItems: v.number(),
|
|
5797
|
+
cursor: v.union(v.string(), v.null()),
|
|
5798
|
+
endCursor: v.optional(v.union(v.string(), v.null())),
|
|
5799
|
+
id: v.optional(v.number()),
|
|
5800
|
+
maximumRowsRead: v.optional(v.number()),
|
|
5801
|
+
maximumBytesRead: v.optional(v.number())
|
|
5802
|
+
});
|
|
4811
5803
|
function createChildComponents(root, pathParts) {
|
|
4812
5804
|
const handler = {
|
|
4813
5805
|
get(_, prop) {
|
|
@@ -4830,12 +5822,209 @@ function createChildComponents(root, pathParts) {
|
|
|
4830
5822
|
return new Proxy({}, handler);
|
|
4831
5823
|
}
|
|
4832
5824
|
const componentsGeneric = () => createChildComponents("components", []);
|
|
5825
|
+
var __defProp = Object.defineProperty;
|
|
5826
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5827
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5828
|
+
class TableDefinition {
|
|
5829
|
+
/**
|
|
5830
|
+
* @internal
|
|
5831
|
+
*/
|
|
5832
|
+
constructor(documentType) {
|
|
5833
|
+
__publicField(this, "indexes");
|
|
5834
|
+
__publicField(this, "stagedDbIndexes");
|
|
5835
|
+
__publicField(this, "searchIndexes");
|
|
5836
|
+
__publicField(this, "stagedSearchIndexes");
|
|
5837
|
+
__publicField(this, "vectorIndexes");
|
|
5838
|
+
__publicField(this, "stagedVectorIndexes");
|
|
5839
|
+
__publicField(this, "validator");
|
|
5840
|
+
this.indexes = [];
|
|
5841
|
+
this.stagedDbIndexes = [];
|
|
5842
|
+
this.searchIndexes = [];
|
|
5843
|
+
this.stagedSearchIndexes = [];
|
|
5844
|
+
this.vectorIndexes = [];
|
|
5845
|
+
this.stagedVectorIndexes = [];
|
|
5846
|
+
this.validator = documentType;
|
|
5847
|
+
}
|
|
5848
|
+
/**
|
|
5849
|
+
* This API is experimental: it may change or disappear.
|
|
5850
|
+
*
|
|
5851
|
+
* Returns indexes defined on this table.
|
|
5852
|
+
* Intended for the advanced use cases of dynamically deciding which index to use for a query.
|
|
5853
|
+
* If you think you need this, please chime in on ths issue in the Convex JS GitHub repo.
|
|
5854
|
+
* https://github.com/get-convex/convex-js/issues/49
|
|
5855
|
+
*/
|
|
5856
|
+
" indexes"() {
|
|
5857
|
+
return this.indexes;
|
|
5858
|
+
}
|
|
5859
|
+
index(name, indexConfig) {
|
|
5860
|
+
if (Array.isArray(indexConfig)) {
|
|
5861
|
+
this.indexes.push({
|
|
5862
|
+
indexDescriptor: name,
|
|
5863
|
+
fields: indexConfig
|
|
5864
|
+
});
|
|
5865
|
+
} else if (indexConfig.staged) {
|
|
5866
|
+
this.stagedDbIndexes.push({
|
|
5867
|
+
indexDescriptor: name,
|
|
5868
|
+
fields: indexConfig.fields
|
|
5869
|
+
});
|
|
5870
|
+
} else {
|
|
5871
|
+
this.indexes.push({
|
|
5872
|
+
indexDescriptor: name,
|
|
5873
|
+
fields: indexConfig.fields
|
|
5874
|
+
});
|
|
5875
|
+
}
|
|
5876
|
+
return this;
|
|
5877
|
+
}
|
|
5878
|
+
searchIndex(name, indexConfig) {
|
|
5879
|
+
if (indexConfig.staged) {
|
|
5880
|
+
this.stagedSearchIndexes.push({
|
|
5881
|
+
indexDescriptor: name,
|
|
5882
|
+
searchField: indexConfig.searchField,
|
|
5883
|
+
filterFields: indexConfig.filterFields || []
|
|
5884
|
+
});
|
|
5885
|
+
} else {
|
|
5886
|
+
this.searchIndexes.push({
|
|
5887
|
+
indexDescriptor: name,
|
|
5888
|
+
searchField: indexConfig.searchField,
|
|
5889
|
+
filterFields: indexConfig.filterFields || []
|
|
5890
|
+
});
|
|
5891
|
+
}
|
|
5892
|
+
return this;
|
|
5893
|
+
}
|
|
5894
|
+
vectorIndex(name, indexConfig) {
|
|
5895
|
+
if (indexConfig.staged) {
|
|
5896
|
+
this.stagedVectorIndexes.push({
|
|
5897
|
+
indexDescriptor: name,
|
|
5898
|
+
vectorField: indexConfig.vectorField,
|
|
5899
|
+
dimensions: indexConfig.dimensions,
|
|
5900
|
+
filterFields: indexConfig.filterFields || []
|
|
5901
|
+
});
|
|
5902
|
+
} else {
|
|
5903
|
+
this.vectorIndexes.push({
|
|
5904
|
+
indexDescriptor: name,
|
|
5905
|
+
vectorField: indexConfig.vectorField,
|
|
5906
|
+
dimensions: indexConfig.dimensions,
|
|
5907
|
+
filterFields: indexConfig.filterFields || []
|
|
5908
|
+
});
|
|
5909
|
+
}
|
|
5910
|
+
return this;
|
|
5911
|
+
}
|
|
5912
|
+
/**
|
|
5913
|
+
* Work around for https://github.com/microsoft/TypeScript/issues/57035
|
|
5914
|
+
*/
|
|
5915
|
+
self() {
|
|
5916
|
+
return this;
|
|
5917
|
+
}
|
|
5918
|
+
/**
|
|
5919
|
+
* Export the contents of this definition.
|
|
5920
|
+
*
|
|
5921
|
+
* This is called internally by the Convex framework.
|
|
5922
|
+
* @internal
|
|
5923
|
+
*/
|
|
5924
|
+
export() {
|
|
5925
|
+
const documentType = this.validator.json;
|
|
5926
|
+
if (typeof documentType !== "object") {
|
|
5927
|
+
throw new Error(
|
|
5928
|
+
"Invalid validator: please make sure that the parameter of `defineTable` is valid (see https://docs.convex.dev/database/schemas)"
|
|
5929
|
+
);
|
|
5930
|
+
}
|
|
5931
|
+
return {
|
|
5932
|
+
indexes: this.indexes,
|
|
5933
|
+
stagedDbIndexes: this.stagedDbIndexes,
|
|
5934
|
+
searchIndexes: this.searchIndexes,
|
|
5935
|
+
stagedSearchIndexes: this.stagedSearchIndexes,
|
|
5936
|
+
vectorIndexes: this.vectorIndexes,
|
|
5937
|
+
stagedVectorIndexes: this.stagedVectorIndexes,
|
|
5938
|
+
documentType
|
|
5939
|
+
};
|
|
5940
|
+
}
|
|
5941
|
+
}
|
|
5942
|
+
function defineTable(documentSchema) {
|
|
5943
|
+
if (isValidator(documentSchema)) {
|
|
5944
|
+
return new TableDefinition(documentSchema);
|
|
5945
|
+
} else {
|
|
5946
|
+
return new TableDefinition(v.object(documentSchema));
|
|
5947
|
+
}
|
|
5948
|
+
}
|
|
5949
|
+
class SchemaDefinition {
|
|
5950
|
+
/**
|
|
5951
|
+
* @internal
|
|
5952
|
+
*/
|
|
5953
|
+
constructor(tables, options) {
|
|
5954
|
+
__publicField(this, "tables");
|
|
5955
|
+
__publicField(this, "strictTableNameTypes");
|
|
5956
|
+
__publicField(this, "schemaValidation");
|
|
5957
|
+
this.tables = tables;
|
|
5958
|
+
this.schemaValidation = options?.schemaValidation === void 0 ? true : options.schemaValidation;
|
|
5959
|
+
}
|
|
5960
|
+
/**
|
|
5961
|
+
* Export the contents of this definition.
|
|
5962
|
+
*
|
|
5963
|
+
* This is called internally by the Convex framework.
|
|
5964
|
+
* @internal
|
|
5965
|
+
*/
|
|
5966
|
+
export() {
|
|
5967
|
+
return JSON.stringify({
|
|
5968
|
+
tables: Object.entries(this.tables).map(([tableName, definition]) => {
|
|
5969
|
+
const {
|
|
5970
|
+
indexes,
|
|
5971
|
+
stagedDbIndexes,
|
|
5972
|
+
searchIndexes,
|
|
5973
|
+
stagedSearchIndexes,
|
|
5974
|
+
vectorIndexes,
|
|
5975
|
+
stagedVectorIndexes,
|
|
5976
|
+
documentType
|
|
5977
|
+
} = definition.export();
|
|
5978
|
+
return {
|
|
5979
|
+
tableName,
|
|
5980
|
+
indexes,
|
|
5981
|
+
stagedDbIndexes,
|
|
5982
|
+
searchIndexes,
|
|
5983
|
+
stagedSearchIndexes,
|
|
5984
|
+
vectorIndexes,
|
|
5985
|
+
stagedVectorIndexes,
|
|
5986
|
+
documentType
|
|
5987
|
+
};
|
|
5988
|
+
}),
|
|
5989
|
+
schemaValidation: this.schemaValidation
|
|
5990
|
+
});
|
|
5991
|
+
}
|
|
5992
|
+
}
|
|
5993
|
+
function defineSchema(schema, options) {
|
|
5994
|
+
return new SchemaDefinition(schema, options);
|
|
5995
|
+
}
|
|
5996
|
+
defineSchema({
|
|
5997
|
+
_scheduled_functions: defineTable({
|
|
5998
|
+
name: v.string(),
|
|
5999
|
+
args: v.array(v.any()),
|
|
6000
|
+
scheduledTime: v.float64(),
|
|
6001
|
+
completedTime: v.optional(v.float64()),
|
|
6002
|
+
state: v.union(
|
|
6003
|
+
v.object({ kind: v.literal("pending") }),
|
|
6004
|
+
v.object({ kind: v.literal("inProgress") }),
|
|
6005
|
+
v.object({ kind: v.literal("success") }),
|
|
6006
|
+
v.object({ kind: v.literal("failed"), error: v.string() }),
|
|
6007
|
+
v.object({ kind: v.literal("canceled") })
|
|
6008
|
+
)
|
|
6009
|
+
}),
|
|
6010
|
+
_storage: defineTable({
|
|
6011
|
+
sha256: v.string(),
|
|
6012
|
+
size: v.float64(),
|
|
6013
|
+
contentType: v.optional(v.string())
|
|
6014
|
+
})
|
|
6015
|
+
});
|
|
4833
6016
|
export {
|
|
4834
6017
|
ConvexReactClient as C,
|
|
4835
|
-
|
|
4836
|
-
|
|
6018
|
+
defineTable as a,
|
|
6019
|
+
ConvexProvider as b,
|
|
4837
6020
|
componentsGeneric as c,
|
|
4838
|
-
|
|
6021
|
+
defineSchema as d,
|
|
6022
|
+
anyApi as e,
|
|
6023
|
+
useMutation as f,
|
|
6024
|
+
internalMutationGeneric as i,
|
|
6025
|
+
mutationGeneric as m,
|
|
6026
|
+
paginationOptsValidator as p,
|
|
6027
|
+
queryGeneric as q,
|
|
4839
6028
|
useQuery as u,
|
|
4840
6029
|
v
|
|
4841
6030
|
};
|