@gaganref/confect-test 10.3.1-fork.9 → 10.3.1-fork.90

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.
Files changed (71) hide show
  1. package/dist/TestConfect.d.ts +37 -11
  2. package/dist/TestConfect.d.ts.map +1 -1
  3. package/dist/TestConfect.js +22 -7
  4. package/dist/TestConfect.js.map +1 -1
  5. package/dist/internal/Attempt.d.ts +77 -0
  6. package/dist/internal/Attempt.d.ts.map +1 -0
  7. package/dist/internal/Attempt.js +154 -0
  8. package/dist/internal/Attempt.js.map +1 -0
  9. package/dist/internal/Clock.d.ts +29 -0
  10. package/dist/internal/Clock.d.ts.map +1 -0
  11. package/dist/internal/Clock.js +66 -0
  12. package/dist/internal/Clock.js.map +1 -0
  13. package/dist/internal/ConvexTest.d.ts +66 -0
  14. package/dist/internal/ConvexTest.d.ts.map +1 -0
  15. package/dist/internal/ConvexTest.js +62 -0
  16. package/dist/internal/ConvexTest.js.map +1 -0
  17. package/dist/internal/Execution.d.ts +247 -0
  18. package/dist/internal/Execution.d.ts.map +1 -0
  19. package/dist/internal/Execution.js +1024 -0
  20. package/dist/internal/Execution.js.map +1 -0
  21. package/dist/internal/Globals.d.ts +11 -0
  22. package/dist/internal/Globals.d.ts.map +1 -0
  23. package/dist/internal/Globals.js +88 -0
  24. package/dist/internal/Globals.js.map +1 -0
  25. package/dist/internal/Invocation.d.ts +68 -0
  26. package/dist/internal/Invocation.d.ts.map +1 -0
  27. package/dist/internal/Invocation.js +158 -0
  28. package/dist/internal/Invocation.js.map +1 -0
  29. package/dist/internal/Kernel.d.ts +95 -0
  30. package/dist/internal/Kernel.d.ts.map +1 -0
  31. package/dist/internal/Kernel.js +91 -0
  32. package/dist/internal/Kernel.js.map +1 -0
  33. package/dist/internal/KernelQuery.d.ts +55 -0
  34. package/dist/internal/KernelQuery.d.ts.map +1 -0
  35. package/dist/internal/KernelQuery.js +205 -0
  36. package/dist/internal/KernelQuery.js.map +1 -0
  37. package/dist/internal/KernelRefusal.d.ts +102 -0
  38. package/dist/internal/KernelRefusal.d.ts.map +1 -0
  39. package/dist/internal/KernelRefusal.js +94 -0
  40. package/dist/internal/KernelRefusal.js.map +1 -0
  41. package/dist/internal/KernelValues.d.ts +138 -0
  42. package/dist/internal/KernelValues.d.ts.map +1 -0
  43. package/dist/internal/KernelValues.js +281 -0
  44. package/dist/internal/KernelValues.js.map +1 -0
  45. package/dist/internal/MountedHttp.d.ts +1 -1
  46. package/dist/internal/MountedHttp.d.ts.map +1 -1
  47. package/dist/internal/MountedHttp.js +3 -3
  48. package/dist/internal/MountedHttp.js.map +1 -1
  49. package/dist/internal/ReadSet.d.ts +55 -0
  50. package/dist/internal/ReadSet.d.ts.map +1 -0
  51. package/dist/internal/ReadSet.js +29 -0
  52. package/dist/internal/ReadSet.js.map +1 -0
  53. package/dist/internal/Scheduling.d.ts +71 -0
  54. package/dist/internal/Scheduling.d.ts.map +1 -0
  55. package/dist/internal/Scheduling.js +60 -0
  56. package/dist/internal/Scheduling.js.map +1 -0
  57. package/package.json +5 -5
  58. package/src/TestConfect.ts +84 -19
  59. package/src/internal/Attempt.ts +185 -0
  60. package/src/internal/Clock.ts +95 -0
  61. package/src/internal/ConvexTest.ts +163 -0
  62. package/src/internal/Execution.ts +1795 -0
  63. package/src/internal/Globals.ts +113 -0
  64. package/src/internal/Invocation.ts +316 -0
  65. package/src/internal/Kernel.ts +190 -0
  66. package/src/internal/KernelQuery.ts +405 -0
  67. package/src/internal/KernelRefusal.ts +112 -0
  68. package/src/internal/KernelValues.ts +765 -0
  69. package/src/internal/MountedHttp.ts +13 -6
  70. package/src/internal/ReadSet.ts +108 -0
  71. package/src/internal/Scheduling.ts +126 -0
@@ -0,0 +1,94 @@
1
+ import * as Schema from "effect/Schema";
2
+ //#region src/internal/KernelRefusal.ts
3
+ /**
4
+ * The kernel never answers this operation in process. Only the binary does.
5
+ */
6
+ var RequiresBinary = class extends Schema.TaggedError()("RequiresBinary", {
7
+ operation: Schema.Literals(["textSearch", "vectorSearch"]),
8
+ message: Schema.String
9
+ }) {};
10
+ /**
11
+ * A later kernel row supplies this operation. Until then the kernel refuses it
12
+ * rather than answer with convex-test's behaviour.
13
+ */
14
+ var KernelRowPending = class extends Schema.TaggedError()("KernelRowPending", {
15
+ operation: Schema.String,
16
+ row: Schema.Int,
17
+ message: Schema.String
18
+ }) {};
19
+ /**
20
+ * A component was registered after the test backend opened, so its modules
21
+ * would load after a function had already run.
22
+ */
23
+ var RegisteredAfterOpen = class extends Schema.TaggedError()("RegisteredAfterOpen", {
24
+ componentPath: Schema.String,
25
+ message: Schema.String
26
+ }) {};
27
+ /**
28
+ * Every attempt of a mutation read data a commit changed before it could
29
+ * publish. The kernel gives up on attempt 5.
30
+ */
31
+ var OptimisticConcurrencyControlFailure = class extends Schema.TaggedError()("OptimisticConcurrencyControlFailure", {
32
+ attempts: Schema.Int,
33
+ message: Schema.String
34
+ }) {};
35
+ /**
36
+ * A syscall reached a mutation's attempt after the mutation returned and its
37
+ * syscalls drained, so the attempt was already held or published.
38
+ */
39
+ var ClosedAttempt = class extends Schema.TaggedError()("ClosedAttempt", {
40
+ operation: Schema.String,
41
+ message: Schema.String
42
+ }) {};
43
+ /**
44
+ * `apply` named an attempt the kernel does not hold: it was already applied, or
45
+ * never prepared.
46
+ */
47
+ var StaleAttempt = class extends Schema.TaggedError()("StaleAttempt", {
48
+ id: Schema.String,
49
+ message: Schema.String
50
+ }) {};
51
+ /**
52
+ * The runtime answered a commit timestamp no greater than the previous
53
+ * commit's.
54
+ */
55
+ var CommitTsNotIncreasing = class extends Schema.TaggedError()("CommitTsNotIncreasing", {
56
+ version: Schema.Int,
57
+ previous: Schema.BigInt,
58
+ commitTs: Schema.BigInt,
59
+ message: Schema.String
60
+ }) {};
61
+ /**
62
+ * Draining scheduled functions ran its budget of jobs and work still remained.
63
+ * A self-rescheduling function keeps the drain from ending unless its kit
64
+ * declares it standing.
65
+ */
66
+ var DrainBudgetExceeded = class extends Schema.TaggedError()("DrainBudgetExceeded", {
67
+ budget: Schema.Int,
68
+ pending: Schema.Array(Schema.Struct({
69
+ componentPath: Schema.String,
70
+ name: Schema.String
71
+ })),
72
+ message: Schema.String
73
+ }) {};
74
+ /**
75
+ * A component declared a standing source its modules do not export.
76
+ */
77
+ var UnknownStandingSource = class extends Schema.TaggedError()("UnknownStandingSource", {
78
+ componentPath: Schema.String,
79
+ name: Schema.String,
80
+ message: Schema.String
81
+ }) {};
82
+ const requiresBinary = (operation) => new RequiresBinary({
83
+ operation,
84
+ message: `The test kernel does not simulate ${operation}. Run this case against the Convex binary.`
85
+ });
86
+ const rowPending = (operation, row) => new KernelRowPending({
87
+ operation,
88
+ row,
89
+ message: `The test kernel supplies ${operation} in build-order row ${row}.`
90
+ });
91
+ //#endregion
92
+ export { ClosedAttempt, CommitTsNotIncreasing, DrainBudgetExceeded, KernelRowPending, OptimisticConcurrencyControlFailure, RegisteredAfterOpen, RequiresBinary, StaleAttempt, UnknownStandingSource, requiresBinary, rowPending };
93
+
94
+ //# sourceMappingURL=KernelRefusal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KernelRefusal.js","names":[],"sources":["../../src/internal/KernelRefusal.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\n/**\n * The kernel never answers this operation in process. Only the binary does.\n */\nexport class RequiresBinary extends Schema.TaggedError<RequiresBinary>()(\n \"RequiresBinary\",\n {\n operation: Schema.Literals([\"textSearch\", \"vectorSearch\"]),\n message: Schema.String,\n },\n) {}\n\n/**\n * A later kernel row supplies this operation. Until then the kernel refuses it\n * rather than answer with convex-test's behaviour.\n */\nexport class KernelRowPending extends Schema.TaggedError<KernelRowPending>()(\n \"KernelRowPending\",\n {\n operation: Schema.String,\n row: Schema.Int,\n message: Schema.String,\n },\n) {}\n\n/**\n * A component was registered after the test backend opened, so its modules\n * would load after a function had already run.\n */\nexport class RegisteredAfterOpen extends Schema.TaggedError<RegisteredAfterOpen>()(\n \"RegisteredAfterOpen\",\n { componentPath: Schema.String, message: Schema.String },\n) {}\n\n/**\n * Every attempt of a mutation read data a commit changed before it could\n * publish. The kernel gives up on attempt 5.\n */\nexport class OptimisticConcurrencyControlFailure extends Schema.TaggedError<OptimisticConcurrencyControlFailure>()(\n \"OptimisticConcurrencyControlFailure\",\n { attempts: Schema.Int, message: Schema.String },\n) {}\n\n/**\n * A syscall reached a mutation's attempt after the mutation returned and its\n * syscalls drained, so the attempt was already held or published.\n */\nexport class ClosedAttempt extends Schema.TaggedError<ClosedAttempt>()(\n \"ClosedAttempt\",\n { operation: Schema.String, message: Schema.String },\n) {}\n\n/**\n * `apply` named an attempt the kernel does not hold: it was already applied, or\n * never prepared.\n */\nexport class StaleAttempt extends Schema.TaggedError<StaleAttempt>()(\n \"StaleAttempt\",\n { id: Schema.String, message: Schema.String },\n) {}\n\n/**\n * The runtime answered a commit timestamp no greater than the previous\n * commit's.\n */\nexport class CommitTsNotIncreasing extends Schema.TaggedError<CommitTsNotIncreasing>()(\n \"CommitTsNotIncreasing\",\n {\n version: Schema.Int,\n previous: Schema.BigInt,\n commitTs: Schema.BigInt,\n message: Schema.String,\n },\n) {}\n\n/**\n * Draining scheduled functions ran its budget of jobs and work still remained.\n * A self-rescheduling function keeps the drain from ending unless its kit\n * declares it standing.\n */\nexport class DrainBudgetExceeded extends Schema.TaggedError<DrainBudgetExceeded>()(\n \"DrainBudgetExceeded\",\n {\n budget: Schema.Int,\n pending: Schema.Array(\n Schema.Struct({ componentPath: Schema.String, name: Schema.String }),\n ),\n message: Schema.String,\n },\n) {}\n\n/**\n * A component declared a standing source its modules do not export.\n */\nexport class UnknownStandingSource extends Schema.TaggedError<UnknownStandingSource>()(\n \"UnknownStandingSource\",\n { componentPath: Schema.String, name: Schema.String, message: Schema.String },\n) {}\n\nexport const requiresBinary = (operation: RequiresBinary[\"operation\"]) =>\n new RequiresBinary({\n operation,\n message: `The test kernel does not simulate ${operation}. Run this case against the Convex binary.`,\n });\n\nexport const rowPending = (operation: string, row: number) =>\n new KernelRowPending({\n operation,\n row,\n message: `The test kernel supplies ${operation} in build-order row ${row}.`,\n });\n"],"mappings":";;;;;AAKA,IAAa,iBAAb,cAAoC,OAAO,YAA4B,CAAC,CACtE,kBACA;CACE,WAAW,OAAO,SAAS,CAAC,cAAc,cAAc,CAAC;CACzD,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;;;;;AAMH,IAAa,mBAAb,cAAsC,OAAO,YAA8B,CAAC,CAC1E,oBACA;CACE,WAAW,OAAO;CAClB,KAAK,OAAO;CACZ,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;;;;;AAMH,IAAa,sBAAb,cAAyC,OAAO,YAAiC,CAAC,CAChF,uBACA;CAAE,eAAe,OAAO;CAAQ,SAAS,OAAO;AAAO,CACzD,CAAC,CAAC,CAAC;;;;;AAMH,IAAa,sCAAb,cAAyD,OAAO,YAAiD,CAAC,CAChH,uCACA;CAAE,UAAU,OAAO;CAAK,SAAS,OAAO;AAAO,CACjD,CAAC,CAAC,CAAC;;;;;AAMH,IAAa,gBAAb,cAAmC,OAAO,YAA2B,CAAC,CACpE,iBACA;CAAE,WAAW,OAAO;CAAQ,SAAS,OAAO;AAAO,CACrD,CAAC,CAAC,CAAC;;;;;AAMH,IAAa,eAAb,cAAkC,OAAO,YAA0B,CAAC,CAClE,gBACA;CAAE,IAAI,OAAO;CAAQ,SAAS,OAAO;AAAO,CAC9C,CAAC,CAAC,CAAC;;;;;AAMH,IAAa,wBAAb,cAA2C,OAAO,YAAmC,CAAC,CACpF,yBACA;CACE,SAAS,OAAO;CAChB,UAAU,OAAO;CACjB,UAAU,OAAO;CACjB,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;;;;;;AAOH,IAAa,sBAAb,cAAyC,OAAO,YAAiC,CAAC,CAChF,uBACA;CACE,QAAQ,OAAO;CACf,SAAS,OAAO,MACd,OAAO,OAAO;EAAE,eAAe,OAAO;EAAQ,MAAM,OAAO;CAAO,CAAC,CACrE;CACA,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;;;;AAKH,IAAa,wBAAb,cAA2C,OAAO,YAAmC,CAAC,CACpF,yBACA;CAAE,eAAe,OAAO;CAAQ,MAAM,OAAO;CAAQ,SAAS,OAAO;AAAO,CAC9E,CAAC,CAAC,CAAC;AAEH,MAAa,kBAAkB,cAC7B,IAAI,eAAe;CACjB;CACA,SAAS,qCAAqC,UAAU;AAC1D,CAAC;AAEH,MAAa,cAAc,WAAmB,QAC5C,IAAI,iBAAiB;CACnB;CACA;CACA,SAAS,4BAA4B,UAAU,sBAAsB,IAAI;AAC3E,CAAC"}
@@ -0,0 +1,138 @@
1
+ import type { GenericDocument } from "convex/server";
2
+ import { type GenericId, type JSONValue, type Value } from "convex/values";
3
+ /**
4
+ * A function address inside one test backend: its component and its
5
+ * `module:export` path.
6
+ */
7
+ export type FunctionPath = {
8
+ readonly componentPath: string;
9
+ readonly udfPath: string;
10
+ };
11
+ export type FilterJson = {
12
+ $eq: [FilterJson, FilterJson];
13
+ } | {
14
+ $field: string;
15
+ } | JSONValue;
16
+ export type QueryOperator = {
17
+ filter: FilterJson;
18
+ } | {
19
+ limit: number;
20
+ };
21
+ export type Source = {
22
+ type: "FullTableScan";
23
+ tableName: string;
24
+ order: "asc" | "desc" | null;
25
+ } | {
26
+ type: "IndexRange";
27
+ indexName: string;
28
+ range: ReadonlyArray<SerializedRangeExpression>;
29
+ order: "asc" | "desc" | null;
30
+ } | {
31
+ type: "Search";
32
+ indexName: string;
33
+ filters: ReadonlyArray<SerializedSearchFilter>;
34
+ };
35
+ export type SerializedQuery = {
36
+ source: Source;
37
+ operators: Array<QueryOperator>;
38
+ };
39
+ export type SerializedRangeExpression = {
40
+ type: "Eq" | "Gt" | "Gte" | "Lt" | "Lte";
41
+ fieldPath: string;
42
+ value: JSONValue;
43
+ };
44
+ export type SerializedSearchFilter = {
45
+ type: "Search";
46
+ fieldPath: string;
47
+ value: string;
48
+ } | {
49
+ type: "Eq";
50
+ fieldPath: string;
51
+ value: JSONValue;
52
+ };
53
+ export type StoredDocument = GenericDocument & {
54
+ _id: DocumentId;
55
+ _creationTime: number;
56
+ };
57
+ export type Index = {
58
+ indexDescriptor: string;
59
+ fields: string[];
60
+ };
61
+ export type TableName = string;
62
+ export type DocumentId = GenericId<TableName>;
63
+ export declare function tableNameFromId(id: string): string | null;
64
+ export declare function deserializeConvexErrorData(thrown: unknown): unknown;
65
+ export declare function isSimpleObject(value: unknown): boolean;
66
+ export declare const MAX_COMMIT_TS: bigint;
67
+ export declare function hasPendingValues(value: Value): boolean;
68
+ export declare function resolvePendingValues(value: Value): Value;
69
+ export declare function resolveCommittedValues<T extends Value>(value: T, commitTs: bigint): T;
70
+ export declare function substituteCommitTs<T extends Value>(value: T, commitTs: bigint): T;
71
+ export declare function evaluateFieldPath(fieldPath: string, document: any): Value | undefined;
72
+ export declare function evaluateFilter(document: GenericDocument, filter: any): Value | undefined;
73
+ export declare function evaluateRangeFilter(document: GenericDocument, expr: SerializedRangeExpression): boolean;
74
+ export declare function evaluateValue(value: JSONValue): Value | undefined;
75
+ export declare function evaluateQueryValue(value: JSONValue): Value | undefined;
76
+ export declare function validateIndexRangeExpression(source: Source & {
77
+ type: "IndexRange";
78
+ }, fields: string[]): void;
79
+ export declare function printIndexOperator(filter: SerializedRangeExpression): string;
80
+ export declare function validateFieldNames(validator: ValidatorJSON): void;
81
+ export declare function isValidIdentifier(name: string): boolean;
82
+ export type ObjectFieldType = {
83
+ fieldType: ValidatorJSON;
84
+ optional: boolean;
85
+ };
86
+ export type ValidatorJSON = {
87
+ type: "null";
88
+ } | {
89
+ type: "number";
90
+ } | {
91
+ type: "bigint";
92
+ } | {
93
+ type: "commitTs";
94
+ } | {
95
+ type: "boolean";
96
+ } | {
97
+ type: "string";
98
+ } | {
99
+ type: "bytes";
100
+ } | {
101
+ type: "any";
102
+ } | {
103
+ type: "literal";
104
+ value: JSONValue;
105
+ } | {
106
+ type: "id";
107
+ tableName: string;
108
+ } | {
109
+ type: "array";
110
+ value: ValidatorJSON;
111
+ } | {
112
+ type: "object";
113
+ value: Record<string, ObjectFieldType>;
114
+ } | {
115
+ type: "record";
116
+ keys: ValidatorJSON;
117
+ values: ObjectFieldType;
118
+ } | {
119
+ type: "function";
120
+ fnType?: string;
121
+ args?: ValidatorJSON;
122
+ returns?: ValidatorJSON;
123
+ } | {
124
+ type: "union";
125
+ value: ValidatorJSON[];
126
+ };
127
+ export declare function validateValidator(validator: ValidatorJSON, value: any): void;
128
+ export declare const JWT_CLAIM_BY_IDENTITY_ATTRIBUTE: Record<string, string>;
129
+ export declare function base64UrlEncode(value: string): string;
130
+ export declare function base64UrlEncodeBytes(bytes: Uint8Array): string;
131
+ export declare function createTestJwt(identity: Record<string, any>): string;
132
+ export declare function parseArgs(args: Record<string, Value> | undefined): Record<string, Value>;
133
+ export declare function validateFunctionArgs(argsValidator: ValidatorJSON, args: any, functionPath: FunctionPath, allowPendingValues: boolean): void;
134
+ export declare function validateReturnValue(returnsValidator: ValidatorJSON | null, result: any, functionType: "query" | "mutation" | "action", functionPath: FunctionPath): void;
135
+ export declare function createFunctionHandle(functionPath: FunctionPath): string;
136
+ export declare function parseFunctionHandle(handle: string): FunctionPath;
137
+ export declare function simpleHash(string: string): number;
138
+ //# sourceMappingURL=KernelValues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KernelValues.d.ts","sourceRoot":"","sources":["../../src/internal/KernelValues.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,KAAK,EAIX,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM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src/internal/KernelValues.ts
3
+ function tableNameFromId(id) {
4
+ const match = id.match(/^[0-9]+/);
5
+ if (!match || match[0].length === id.length) return null;
6
+ return id.slice(match[0].length);
7
+ }
8
+ function deserializeConvexErrorData(thrown) {
9
+ if (typeof thrown === "object" && thrown !== null && Symbol.for("ConvexError") in thrown && typeof thrown.data === "string") try {
10
+ thrown.data = jsonToConvex(JSON.parse(thrown.data));
11
+ } catch {}
12
+ return thrown;
13
+ }
14
+ function isSimpleObject(value) {
15
+ const isObject = typeof value === "object";
16
+ const prototype = Object.getPrototypeOf(value);
17
+ const isSimple = prototype === null || prototype === Object.prototype || prototype?.constructor?.name === "Object";
18
+ return isObject && isSimple;
19
+ }
20
+ const MAX_COMMIT_TS = 2n ** 63n - 1n;
21
+ function hasPendingValues(value) {
22
+ if (value instanceof CommitTsPlaceholder) return true;
23
+ if (Array.isArray(value)) return value.some(hasPendingValues);
24
+ if (value !== null && value !== void 0 && isSimpleObject(value)) return Object.values(value).some(hasPendingValues);
25
+ return false;
26
+ }
27
+ function resolvePendingValues(value) {
28
+ return substituteCommitTs(value, MAX_COMMIT_TS);
29
+ }
30
+ function resolveCommittedValues(value, commitTs) {
31
+ return substituteCommitTs(value, commitTs);
32
+ }
33
+ function substituteCommitTs(value, commitTs) {
34
+ if (!hasPendingValues(value)) return value;
35
+ if (value instanceof CommitTsPlaceholder) return commitTs;
36
+ if (Array.isArray(value)) return value.map((v) => substituteCommitTs(v, commitTs));
37
+ return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, substituteCommitTs(v, commitTs)]));
38
+ }
39
+ function evaluateFieldPath(fieldPath, document) {
40
+ const pathParts = fieldPath.split(".");
41
+ let result = document;
42
+ for (const p of pathParts) result = result !== void 0 && result !== null && isSimpleObject(result) ? result[p] : void 0;
43
+ return result === void 0 ? void 0 : resolvePendingValues(result);
44
+ }
45
+ function evaluateFilter(document, filter) {
46
+ if (filter.$eq !== void 0) return compareValues(evaluateFilter(document, filter.$eq[0]), evaluateFilter(document, filter.$eq[1])) === 0;
47
+ if (filter.$neq !== void 0) return compareValues(evaluateFilter(document, filter.$neq[0]), evaluateFilter(document, filter.$neq[1])) !== 0;
48
+ if (filter.$and !== void 0) return filter.$and.every((child) => evaluateFilter(document, child));
49
+ if (filter.$or !== void 0) return filter.$or.some((child) => evaluateFilter(document, child));
50
+ if (filter.$not !== void 0) return !evaluateFilter(document, filter.$not);
51
+ if (filter.$gt !== void 0) return evaluateFilter(document, filter.$gt[0]) > evaluateFilter(document, filter.$gt[1]);
52
+ if (filter.$gte !== void 0) return evaluateFilter(document, filter.$gte[0]) >= evaluateFilter(document, filter.$gte[1]);
53
+ if (filter.$lt !== void 0) return evaluateFilter(document, filter.$lt[0]) < evaluateFilter(document, filter.$lt[1]);
54
+ if (filter.$lte !== void 0) return evaluateFilter(document, filter.$lte[0]) <= evaluateFilter(document, filter.$lte[1]);
55
+ if (filter.$add !== void 0) return evaluateFilter(document, filter.$add[0]) + evaluateFilter(document, filter.$add[1]);
56
+ if (filter.$sub !== void 0) return evaluateFilter(document, filter.$sub[0]) - evaluateFilter(document, filter.$sub[1]);
57
+ if (filter.$mul !== void 0) return evaluateFilter(document, filter.$mul[0]) * evaluateFilter(document, filter.$mul[1]);
58
+ if (filter.$div !== void 0) return evaluateFilter(document, filter.$div[0]) / evaluateFilter(document, filter.$div[1]);
59
+ if (filter.$mod !== void 0) return evaluateFilter(document, filter.$mod[0]) % evaluateFilter(document, filter.$mod[1]);
60
+ if (filter.$field !== void 0) return evaluateFieldPath(filter.$field, document);
61
+ if (filter.$literal !== void 0) return evaluateQueryValue(filter.$literal);
62
+ throw new Error(`not implemented: ${JSON.stringify(filter)}`);
63
+ }
64
+ function evaluateRangeFilter(document, expr) {
65
+ const result = evaluateFieldPath(expr.fieldPath, document);
66
+ const value = evaluateQueryValue(expr.value);
67
+ switch (expr.type) {
68
+ case "Eq": return compareValues(result, value) === 0;
69
+ case "Gt": return compareValues(result, value) > 0;
70
+ case "Gte": return compareValues(result, value) >= 0;
71
+ case "Lt": return compareValues(result, value) < 0;
72
+ case "Lte": return compareValues(result, value) <= 0;
73
+ }
74
+ }
75
+ function evaluateValue(value) {
76
+ if (typeof value === "object" && value !== null && "$undefined" in value) return;
77
+ return jsonToConvex(value);
78
+ }
79
+ function evaluateQueryValue(value) {
80
+ const evaluatedValue = evaluateValue(value);
81
+ return evaluatedValue === void 0 ? void 0 : resolvePendingValues(evaluatedValue);
82
+ }
83
+ function validateIndexRangeExpression(source, fields) {
84
+ let fieldIndex = 0;
85
+ let state = "eq";
86
+ for (const [filterIndex, filter] of source.range.entries()) {
87
+ if (state === "done") throw new Error(`Incorrect operator used in \`withIndex\`, cannot chain more operators after both \`.gt\` and \`.lt\` were already used, got \`${printIndexOperator(filter)}\`.`);
88
+ const filterType = filter.type == "Gt" || filter.type == "Gte" ? "gt" : filter.type == "Lt" || filter.type == "Lte" ? "lt" : "eq";
89
+ switch (`${state}|${filterType}`) {
90
+ case "eq|eq":
91
+ case "eq|gt":
92
+ case "eq|lt":
93
+ if (filter.fieldPath === fields[fieldIndex]) {
94
+ fieldIndex += 1;
95
+ state = filterType;
96
+ continue;
97
+ }
98
+ throw new Error(`Incorrect field used in \`withIndex\`, expected "${fields[fieldIndex]}", got "${filter.fieldPath}"`);
99
+ case "lt|gt":
100
+ case "gt|lt":
101
+ if (fieldIndex > 0 && filter.fieldPath === fields[fieldIndex - 1]) {
102
+ state = "done";
103
+ continue;
104
+ }
105
+ throw new Error(`Incorrect field used in \`withIndex\`, \`.gt\` and \`.lt\` must operate on the same field, expected "${fields[fieldIndex - 1]}", got "${filter.fieldPath}"`);
106
+ default: throw new Error(`Incorrect operator used in \`withIndex\`, cannot chain \`.${filter.type.toLowerCase()}()\` after \`.${source.range[filterIndex - 1].type.toLowerCase()}()\``);
107
+ }
108
+ }
109
+ }
110
+ function printIndexOperator(filter) {
111
+ return `.${filter.type.toLowerCase()}(${filter.fieldPath}, ${JSON.stringify(filter.value)})`;
112
+ }
113
+ function validateFieldNames(validator) {
114
+ if (validator.type === "object") Object.keys(validator.value).forEach((fieldName) => {
115
+ if (!isValidIdentifier(fieldName)) throw new Error(`Field names must be valid identifiers, got "${fieldName}"`);
116
+ });
117
+ if (validator.type === "union") validator.value.forEach(validateFieldNames);
118
+ }
119
+ function isValidIdentifier(name) {
120
+ return /(^_(id|creationTime)$)|^[a-zA-Z][a-zA-Z0-9_]*$/.test(name);
121
+ }
122
+ function validateValidator(validator, value) {
123
+ switch (validator.type) {
124
+ case "null":
125
+ if (value !== null) throw new Error(`Validator error: Expected \`null\`, got \`${value}\``);
126
+ return;
127
+ case "number":
128
+ if (typeof value !== "number") throw new Error(`Validator error: Expected \`number\`, got \`${value}\``);
129
+ return;
130
+ case "bigint":
131
+ if (typeof value !== "bigint") throw new Error(`Validator error: Expected \`bigint\`, got \`${value}\``);
132
+ return;
133
+ case "commitTs":
134
+ if (typeof value !== "bigint" && !(value instanceof CommitTsPlaceholder)) throw new Error(`Validator error: Expected \`v.commitTs()\`, got \`${value}\``);
135
+ return;
136
+ case "boolean":
137
+ if (typeof value !== "boolean") throw new Error(`Validator error: Expected \`boolean\`, got \`${value}\``);
138
+ return;
139
+ case "string":
140
+ if (typeof value !== "string") throw new Error(`Validator error: Expected \`string\`, got \`${value}\``);
141
+ return;
142
+ case "bytes":
143
+ if (!(value instanceof ArrayBuffer)) throw new Error(`Validator error: Expected \`ArrayBuffer\`, got \`${value}\``);
144
+ return;
145
+ case "any": return;
146
+ case "literal":
147
+ if (value !== validator.value) throw new Error(`Validator error: Expected \`${validator.value}\`, got \`${value}\``);
148
+ return;
149
+ case "id":
150
+ if (typeof value !== "string") throw new Error(`Validator error: Expected \`string\`, got \`${value}\``);
151
+ if (tableNameFromId(value) !== validator.tableName) throw new Error(`Validator error: Expected ID for table "${validator.tableName}", got \`${value}\``);
152
+ return;
153
+ case "array":
154
+ if (!Array.isArray(value)) throw new Error(`Validator error: Expected \`Array\`, got \`${value}\``);
155
+ for (const v of value) validateValidator(validator.value, v);
156
+ return;
157
+ case "union": {
158
+ let isValid = false;
159
+ for (const v of validator.value) try {
160
+ validateValidator(v, value);
161
+ isValid = true;
162
+ break;
163
+ } catch {}
164
+ if (!isValid) throw new Error(`Validator error: Expected one of ${validator.value.map((v) => v.type).join(", ")}, got \`${JSON.stringify(convexToJson(value))}\``);
165
+ return;
166
+ }
167
+ case "object":
168
+ if (typeof value !== "object") throw new Error(`Validator error: Expected \`object\`, got \`${value}\``);
169
+ if (!isSimpleObject(value)) throw new Error(`Validator error: Expected a plain old JavaScript \`object\`, got \`${value}\``);
170
+ for (const [k, { fieldType, optional }] of Object.entries(validator.value)) if (value[k] === void 0) {
171
+ if (!optional) throw new Error(`Validator error: Missing required field \`${k}\` in object`);
172
+ } else validateValidator(fieldType, value[k]);
173
+ for (const k of Object.keys(value)) if (validator.value[k] === void 0) throw new Error(`Validator error: Unexpected field \`${k}\` in object`);
174
+ return;
175
+ case "function":
176
+ if (typeof value !== "string" || readFunctionHandle(value) === void 0) throw new Error(`Validator error: Expected a function handle, got \`${value}\``);
177
+ return;
178
+ case "record":
179
+ if (value === null || typeof value !== "object" || !isSimpleObject(value)) throw new Error(`Validator error: Expected a plain old JavaScript \`object\` for a record, got \`${value}\``);
180
+ for (const [k, fieldValue] of Object.entries(value)) {
181
+ validateValidator(validator.keys, k);
182
+ if (fieldValue !== void 0) validateValidator(validator.values.fieldType, fieldValue);
183
+ }
184
+ return;
185
+ default: throw new Error(`The test kernel cannot check a validator of type \`${validator.type}\`.`);
186
+ }
187
+ }
188
+ const JWT_CLAIM_BY_IDENTITY_ATTRIBUTE = {
189
+ subject: "sub",
190
+ issuer: "iss",
191
+ name: "name",
192
+ givenName: "given_name",
193
+ familyName: "family_name",
194
+ nickname: "nickname",
195
+ preferredUsername: "preferred_username",
196
+ profileUrl: "profile",
197
+ pictureUrl: "picture",
198
+ email: "email",
199
+ emailVerified: "email_verified",
200
+ gender: "gender",
201
+ birthday: "birthdate",
202
+ timezone: "zoneinfo",
203
+ language: "locale",
204
+ phoneNumber: "phone_number",
205
+ phoneNumberVerified: "phone_number_verified",
206
+ address: "address",
207
+ updatedAt: "updated_at"
208
+ };
209
+ function base64UrlEncode(value) {
210
+ return base64UrlEncodeBytes(new TextEncoder().encode(value));
211
+ }
212
+ function base64UrlEncodeBytes(bytes) {
213
+ let binary = "";
214
+ for (const byte of bytes) binary += String.fromCharCode(byte);
215
+ return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
216
+ }
217
+ function createTestJwt(identity) {
218
+ const claims = Object.create(null);
219
+ for (const [attribute, value] of Object.entries(identity)) {
220
+ if (value === void 0 || attribute === "tokenIdentifier") continue;
221
+ const claimName = Object.hasOwn(JWT_CLAIM_BY_IDENTITY_ATTRIBUTE, attribute) ? JWT_CLAIM_BY_IDENTITY_ATTRIBUTE[attribute] : attribute;
222
+ claims[claimName] = value;
223
+ }
224
+ claims.iss = identity.issuer;
225
+ claims.sub = identity.subject;
226
+ return `${base64UrlEncode(JSON.stringify({
227
+ alg: "none",
228
+ typ: "JWT"
229
+ }))}.${base64UrlEncode(JSON.stringify(claims))}.`;
230
+ }
231
+ function parseArgs(args) {
232
+ if (args === void 0) return {};
233
+ if (!isSimpleObject(args)) throw new Error(`The arguments to a Convex function must be an object. Received: ${args}`);
234
+ return args;
235
+ }
236
+ function validateFunctionArgs(argsValidator, args, functionPath, allowPendingValues) {
237
+ if (!allowPendingValues && hasPendingValues(args)) throw new Error(`Invalid arguments for "${functionPath.udfPath}": an unresolved placeholder value can only be passed to a query or mutation called from a mutation`);
238
+ validateValidator(argsValidator, resolvePendingValues(args));
239
+ }
240
+ function validateReturnValue(returnsValidator, result, functionType, functionPath) {
241
+ if (returnsValidator !== null) try {
242
+ validateValidator(returnsValidator, resolvePendingValues(result));
243
+ } catch (e) {
244
+ throw new Error(`Return value validation failed for ${functionType} "${functionPath.udfPath}":\n${e.message}`, { cause: e });
245
+ }
246
+ }
247
+ const FUNCTION_HANDLE_PREFIX = "function://";
248
+ function createFunctionHandle(functionPath) {
249
+ return `${FUNCTION_HANDLE_PREFIX}${functionPath.componentPath};${functionPath.udfPath}`;
250
+ }
251
+ /**
252
+ * The function a handle the kernel minted names, or `undefined` for a string
253
+ * that is not `function://<componentPath>;<udfPath>` with a function path.
254
+ */
255
+ function readFunctionHandle(handle) {
256
+ if (!handle.startsWith(FUNCTION_HANDLE_PREFIX)) return void 0;
257
+ const parts = handle.slice(11).split(";");
258
+ if (parts.length !== 2 || parts[1] === "") return void 0;
259
+ return {
260
+ componentPath: parts[0],
261
+ udfPath: parts[1]
262
+ };
263
+ }
264
+ function parseFunctionHandle(handle) {
265
+ const functionPath = readFunctionHandle(handle);
266
+ if (functionPath === void 0) throw new Error(`Invalid function handle \`${handle}\``);
267
+ return functionPath;
268
+ }
269
+ function simpleHash(string) {
270
+ let hash = 0;
271
+ for (let i = 0; i < string.length; i++) {
272
+ const char = string.charCodeAt(i);
273
+ hash = (hash << 5) - hash + char;
274
+ hash = hash & hash;
275
+ }
276
+ return hash;
277
+ }
278
+ //#endregion
279
+ export { JWT_CLAIM_BY_IDENTITY_ATTRIBUTE, MAX_COMMIT_TS, base64UrlEncode, base64UrlEncodeBytes, createFunctionHandle, createTestJwt, deserializeConvexErrorData, evaluateFieldPath, evaluateFilter, evaluateQueryValue, evaluateRangeFilter, evaluateValue, hasPendingValues, isSimpleObject, isValidIdentifier, parseArgs, parseFunctionHandle, printIndexOperator, resolveCommittedValues, resolvePendingValues, simpleHash, substituteCommitTs, tableNameFromId, validateFieldNames, validateFunctionArgs, validateIndexRangeExpression, validateReturnValue, validateValidator };
280
+
281
+ //# sourceMappingURL=KernelValues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KernelValues.js","names":["unknown"],"sources":["../../src/internal/KernelValues.ts"],"sourcesContent":["// Derived from convex-test 0.0.65 (index.ts), Copyright Convex, Inc.,\n// licensed under the Apache License, Version 2.0\n// (https://www.apache.org/licenses/LICENSE-2.0). The value, filter, range,\n// validator and argument rules are kept as convex-test states them, so the\n// kernel answers a function the way convex-test does. The storage, attempts\n// and execution around them are the kernel's own.\n\nimport type { GenericDocument } from \"convex/server\";\nimport {\n CommitTsPlaceholder,\n type GenericId,\n type JSONValue,\n type Value,\n compareValues,\n convexToJson,\n jsonToConvex,\n} from \"convex/values\";\n\n/**\n * A function address inside one test backend: its component and its\n * `module:export` path.\n */\nexport type FunctionPath = {\n readonly componentPath: string;\n readonly udfPath: string;\n};\n\nexport type FilterJson =\n | { $eq: [FilterJson, FilterJson] }\n | { $field: string }\n | JSONValue;\n\nexport type QueryOperator = { filter: FilterJson } | { limit: number };\nexport type Source =\n | { type: \"FullTableScan\"; tableName: string; order: \"asc\" | \"desc\" | null }\n | {\n type: \"IndexRange\";\n indexName: string;\n range: ReadonlyArray<SerializedRangeExpression>;\n order: \"asc\" | \"desc\" | null;\n }\n | {\n type: \"Search\";\n indexName: string;\n filters: ReadonlyArray<SerializedSearchFilter>;\n };\n\nexport type SerializedQuery = {\n source: Source;\n operators: Array<QueryOperator>;\n};\n\nexport type SerializedRangeExpression = {\n type: \"Eq\" | \"Gt\" | \"Gte\" | \"Lt\" | \"Lte\";\n fieldPath: string;\n value: JSONValue;\n};\n\nexport type SerializedSearchFilter =\n | {\n type: \"Search\";\n fieldPath: string;\n value: string;\n }\n | {\n type: \"Eq\";\n fieldPath: string;\n value: JSONValue;\n };\n\nexport type StoredDocument = GenericDocument & {\n _id: DocumentId;\n _creationTime: number;\n};\n\nexport type Index = {\n indexDescriptor: string;\n fields: string[];\n};\n\nexport type TableName = string;\n\nexport type DocumentId = GenericId<TableName>;\n\nexport function tableNameFromId(id: string) {\n const match = id.match(/^[0-9]+/);\n if (!match || match[0].length === id.length) {\n return null;\n }\n return id.slice(match[0].length);\n}\nexport function deserializeConvexErrorData(thrown: unknown) {\n if (\n typeof thrown === \"object\" &&\n thrown !== null &&\n Symbol.for(\"ConvexError\") in thrown &&\n typeof (thrown as { data: unknown }).data === \"string\"\n ) {\n try {\n (thrown as { data: unknown }).data = jsonToConvex(\n JSON.parse((thrown as { data: string }).data),\n );\n } catch {\n // Data wasn't a serialized JSON string — leave it untouched.\n }\n }\n return thrown;\n}\n\nexport function isSimpleObject(value: unknown) {\n const isObject = typeof value === \"object\";\n const prototype = Object.getPrototypeOf(value);\n const isSimple =\n prototype === null ||\n prototype === Object.prototype ||\n // Objects generated from other contexts (e.g. across Node.js `vm` modules) will not satisfy the previous\n // conditions but are still simple objects.\n prototype?.constructor?.name === \"Object\";\n return isObject && isSimple;\n}\n\n// Commit timestamp placeholders are resolved to `i64::MAX` before commit.\nexport const MAX_COMMIT_TS = 2n ** 63n - 1n;\n\nexport function hasPendingValues(value: Value): boolean {\n if (value instanceof CommitTsPlaceholder) {\n return true;\n }\n if (Array.isArray(value)) {\n return value.some(hasPendingValues);\n }\n if (value !== null && value !== undefined && isSimpleObject(value)) {\n return Object.values(value).some(hasPendingValues);\n }\n return false;\n}\n\n// The value as the transaction sees it before committing.\nexport function resolvePendingValues(value: Value): Value {\n return substituteCommitTs(value, MAX_COMMIT_TS);\n}\n\n// The value as it is committed.\nexport function resolveCommittedValues<T extends Value>(\n value: T,\n commitTs: bigint,\n): T {\n return substituteCommitTs(value, commitTs);\n}\n\nexport function substituteCommitTs<T extends Value>(\n value: T,\n commitTs: bigint,\n): T {\n if (!hasPendingValues(value)) {\n return value;\n }\n if (value instanceof CommitTsPlaceholder) {\n return commitTs as T;\n }\n if (Array.isArray(value)) {\n return value.map((v) => substituteCommitTs(v, commitTs)) as T;\n }\n return Object.fromEntries(\n Object.entries(value as object).map(([k, v]) => [\n k,\n substituteCommitTs(v, commitTs),\n ]),\n ) as T;\n}\n\nexport function evaluateFieldPath(fieldPath: string, document: any) {\n const pathParts = fieldPath.split(\".\");\n let result: Value | undefined = document;\n for (const p of pathParts) {\n result =\n result !== undefined && result !== null && isSimpleObject(result)\n ? (result as any)[p]\n : undefined;\n }\n return result === undefined ? undefined : resolvePendingValues(result);\n}\n\nexport function evaluateFilter(\n document: GenericDocument,\n filter: any,\n): Value | undefined {\n if (filter.$eq !== undefined) {\n return (\n compareValues(\n evaluateFilter(document, filter.$eq[0]),\n evaluateFilter(document, filter.$eq[1]),\n ) === 0\n );\n }\n if (filter.$neq !== undefined) {\n return (\n compareValues(\n evaluateFilter(document, filter.$neq[0]),\n evaluateFilter(document, filter.$neq[1]),\n ) !== 0\n );\n }\n if (filter.$and !== undefined) {\n return filter.$and.every((child: any) => evaluateFilter(document, child));\n }\n if (filter.$or !== undefined) {\n return filter.$or.some((child: any) => evaluateFilter(document, child));\n }\n if (filter.$not !== undefined) {\n return !evaluateFilter(document, filter.$not);\n }\n if (filter.$gt !== undefined) {\n return (\n evaluateFilter(document, filter.$gt[0])! >\n evaluateFilter(document, filter.$gt[1])!\n );\n }\n if (filter.$gte !== undefined) {\n return (\n evaluateFilter(document, filter.$gte[0])! >=\n evaluateFilter(document, filter.$gte[1])!\n );\n }\n if (filter.$lt !== undefined) {\n return (\n evaluateFilter(document, filter.$lt[0])! <\n evaluateFilter(document, filter.$lt[1])!\n );\n }\n if (filter.$lte !== undefined) {\n return (\n evaluateFilter(document, filter.$lte[0])! <=\n evaluateFilter(document, filter.$lte[1])!\n );\n }\n if (filter.$add !== undefined) {\n return (\n (evaluateFilter(document, filter.$add[0]) as number) +\n (evaluateFilter(document, filter.$add[1]) as number)\n );\n }\n if (filter.$sub !== undefined) {\n return (\n (evaluateFilter(document, filter.$sub[0]) as number) -\n (evaluateFilter(document, filter.$sub[1]) as number)\n );\n }\n if (filter.$mul !== undefined) {\n return (\n (evaluateFilter(document, filter.$mul[0]) as number) *\n (evaluateFilter(document, filter.$mul[1]) as number)\n );\n }\n if (filter.$div !== undefined) {\n return (\n (evaluateFilter(document, filter.$div[0]) as number) /\n (evaluateFilter(document, filter.$div[1]) as number)\n );\n }\n if (filter.$mod !== undefined) {\n return (\n (evaluateFilter(document, filter.$mod[0]) as number) %\n (evaluateFilter(document, filter.$mod[1]) as number)\n );\n }\n if (filter.$field !== undefined) {\n return evaluateFieldPath(filter.$field, document);\n }\n if (filter.$literal !== undefined) {\n return evaluateQueryValue(filter.$literal);\n }\n throw new Error(`not implemented: ${JSON.stringify(filter)}`);\n}\n\nexport function evaluateRangeFilter(\n document: GenericDocument,\n expr: SerializedRangeExpression,\n) {\n const result = evaluateFieldPath(expr.fieldPath, document);\n const value = evaluateQueryValue(expr.value);\n switch (expr.type) {\n case \"Eq\":\n return compareValues(result, value) === 0;\n case \"Gt\":\n return compareValues(result, value) > 0;\n case \"Gte\":\n return compareValues(result, value) >= 0;\n case \"Lt\":\n return compareValues(result, value) < 0;\n case \"Lte\":\n return compareValues(result, value) <= 0;\n }\n}\n\n// A value used as a written field.\nexport function evaluateValue(value: JSONValue) {\n if (typeof value === \"object\" && value !== null && \"$undefined\" in value) {\n return undefined;\n }\n return jsonToConvex(value);\n}\n\n// A value used as a query bound or literal.\nexport function evaluateQueryValue(value: JSONValue) {\n const evaluatedValue = evaluateValue(value);\n return evaluatedValue === undefined\n ? undefined\n : resolvePendingValues(evaluatedValue);\n}\n\n// An index range expression is always a chained list of:\n//\n// 0 or more equality expressions defined with .eq.\n// [Optionally] A lower bound expression defined with .gt or .gte.\n// [Optionally] An upper bound expression defined with .lt or .lte.\nexport function validateIndexRangeExpression(\n source: Source & { type: \"IndexRange\" },\n fields: string[],\n) {\n let fieldIndex = 0;\n let state: \"eq\" | \"gt\" | \"lt\" | \"done\" = \"eq\";\n for (const [filterIndex, filter] of source.range.entries()) {\n if (state === \"done\") {\n throw new Error(\n `Incorrect operator used in \\`withIndex\\`, cannot chain ` +\n `more operators after both \\`.gt\\` and \\`.lt\\` were already used, ` +\n `got \\`${printIndexOperator(filter)}\\`.`,\n );\n }\n\n const filterType: \"eq\" | \"gt\" | \"lt\" =\n filter.type == \"Gt\" || filter.type == \"Gte\"\n ? \"gt\"\n : filter.type == \"Lt\" || filter.type == \"Lte\"\n ? \"lt\"\n : \"eq\";\n\n switch (`${state}|${filterType}`) {\n // Allow to operate on the current indexed field\n case \"eq|eq\":\n case \"eq|gt\":\n case \"eq|lt\":\n if (filter.fieldPath === fields[fieldIndex]) {\n fieldIndex += 1;\n state = filterType;\n continue;\n }\n throw new Error(\n `Incorrect field used in \\`withIndex\\`, ` +\n `expected \"${fields[fieldIndex]}\", got \"${filter.fieldPath}\"`,\n );\n\n // Allow to operate on the previous field (gt and lt must operate on same field)\n case \"lt|gt\":\n case \"gt|lt\":\n if (fieldIndex > 0 && filter.fieldPath === fields[fieldIndex - 1]) {\n state = \"done\";\n continue;\n }\n throw new Error(\n `Incorrect field used in \\`withIndex\\`, ` +\n `\\`.gt\\` and \\`.lt\\` must operate on the same field, ` +\n `expected \"${fields[fieldIndex - 1]}\", got \"${filter.fieldPath}\"`,\n );\n\n default:\n throw new Error(\n `Incorrect operator used in \\`withIndex\\`, ` +\n `cannot chain \\`.${filter.type.toLowerCase()}()\\` ` +\n `after \\`.${source.range[filterIndex - 1].type.toLowerCase()}()\\``,\n );\n }\n }\n}\n\nexport function printIndexOperator(filter: SerializedRangeExpression) {\n return `.${filter.type.toLowerCase()}(${filter.fieldPath}, ${JSON.stringify(filter.value)})`;\n}\n\nexport function validateFieldNames(validator: ValidatorJSON) {\n if (validator.type === \"object\") {\n Object.keys(validator.value).forEach((fieldName) => {\n if (!isValidIdentifier(fieldName)) {\n throw new Error(\n `Field names must be valid identifiers, got \"${fieldName}\"`,\n );\n }\n });\n }\n\n if (validator.type === \"union\") {\n validator.value.forEach(validateFieldNames);\n }\n}\n\nexport function isValidIdentifier(name: string) {\n return /(^_(id|creationTime)$)|^[a-zA-Z][a-zA-Z0-9_]*$/.test(name);\n}\n\nexport type ObjectFieldType = { fieldType: ValidatorJSON; optional: boolean };\n\nexport type ValidatorJSON =\n | {\n type: \"null\";\n }\n | { type: \"number\" }\n | { type: \"bigint\" }\n | { type: \"commitTs\" }\n | { type: \"boolean\" }\n | { type: \"string\" }\n | { type: \"bytes\" }\n | { type: \"any\" }\n | {\n type: \"literal\";\n value: JSONValue;\n }\n | { type: \"id\"; tableName: string }\n | { type: \"array\"; value: ValidatorJSON }\n | { type: \"object\"; value: Record<string, ObjectFieldType> }\n | { type: \"record\"; keys: ValidatorJSON; values: ObjectFieldType }\n | {\n type: \"function\";\n fnType?: string;\n args?: ValidatorJSON;\n returns?: ValidatorJSON;\n }\n | { type: \"union\"; value: ValidatorJSON[] };\n\nexport function validateValidator(validator: ValidatorJSON, value: any) {\n switch (validator.type) {\n case \"null\": {\n if (value !== null) {\n throw new Error(`Validator error: Expected \\`null\\`, got \\`${value}\\``);\n }\n return;\n }\n case \"number\": {\n if (typeof value !== \"number\") {\n throw new Error(\n `Validator error: Expected \\`number\\`, got \\`${value}\\``,\n );\n }\n return;\n }\n case \"bigint\": {\n if (typeof value !== \"bigint\") {\n throw new Error(\n `Validator error: Expected \\`bigint\\`, got \\`${value}\\``,\n );\n }\n return;\n }\n case \"commitTs\": {\n if (\n typeof value !== \"bigint\" &&\n !(value instanceof CommitTsPlaceholder)\n ) {\n throw new Error(\n `Validator error: Expected \\`v.commitTs()\\`, got \\`${value}\\``,\n );\n }\n return;\n }\n case \"boolean\": {\n if (typeof value !== \"boolean\") {\n throw new Error(\n `Validator error: Expected \\`boolean\\`, got \\`${value}\\``,\n );\n }\n return;\n }\n case \"string\": {\n if (typeof value !== \"string\") {\n throw new Error(\n `Validator error: Expected \\`string\\`, got \\`${value}\\``,\n );\n }\n return;\n }\n case \"bytes\": {\n if (!(value instanceof ArrayBuffer)) {\n throw new Error(\n `Validator error: Expected \\`ArrayBuffer\\`, got \\`${value}\\``,\n );\n }\n return;\n }\n case \"any\": {\n return;\n }\n case \"literal\": {\n if (value !== validator.value) {\n throw new Error(\n `Validator error: Expected \\`${\n validator.value as any\n }\\`, got \\`${value}\\``,\n );\n }\n return;\n }\n case \"id\": {\n if (typeof value !== \"string\") {\n throw new Error(\n `Validator error: Expected \\`string\\`, got \\`${value}\\``,\n );\n }\n if (tableNameFromId(value) !== validator.tableName) {\n throw new Error(\n `Validator error: Expected ID for table \"${validator.tableName}\", got \\`${value}\\``,\n );\n }\n return;\n }\n case \"array\": {\n if (!Array.isArray(value)) {\n throw new Error(\n `Validator error: Expected \\`Array\\`, got \\`${value}\\``,\n );\n }\n for (const v of value) {\n validateValidator(validator.value, v);\n }\n return;\n }\n case \"union\": {\n let isValid = false;\n for (const v of validator.value) {\n try {\n validateValidator(v, value);\n isValid = true;\n break;\n } catch {\n // Ignore\n }\n }\n if (!isValid) {\n throw new Error(\n `Validator error: Expected one of ${validator.value.map((v) => v.type).join(\", \")}, got \\`${JSON.stringify(convexToJson(value))}\\``,\n );\n }\n return;\n }\n case \"object\": {\n if (typeof value !== \"object\") {\n throw new Error(\n `Validator error: Expected \\`object\\`, got \\`${value}\\``,\n );\n }\n if (!isSimpleObject(value)) {\n throw new Error(\n `Validator error: Expected a plain old JavaScript \\`object\\`, got \\`${value}\\``,\n );\n }\n for (const [k, { fieldType, optional }] of Object.entries(\n validator.value,\n )) {\n if (value[k] === undefined) {\n if (!optional) {\n throw new Error(\n `Validator error: Missing required field \\`${k}\\` in object`,\n );\n }\n } else {\n validateValidator(fieldType, value[k]);\n }\n }\n for (const k of Object.keys(value)) {\n if (validator.value[k] === undefined) {\n throw new Error(\n `Validator error: Unexpected field \\`${k}\\` in object`,\n );\n }\n }\n return;\n }\n case \"function\": {\n // The pinned binary, `precompiled-2026-10-28-cccbade`, accepts a string\n // that parses as a function handle\n // (`common/src/schemas/validator.rs:156-164`), and its parser requires a\n // document id after the prefix\n // (`common/src/bootstrap_model/components/handles.rs:100-112`). The\n // kernel mints convex-test's handle format instead, so it accepts a\n // string that parses as that format.\n if (\n typeof value !== \"string\" ||\n readFunctionHandle(value) === undefined\n ) {\n throw new Error(\n `Validator error: Expected a function handle, got \\`${value}\\``,\n );\n }\n return;\n }\n case \"record\": {\n if (\n value === null ||\n typeof value !== \"object\" ||\n !isSimpleObject(value)\n ) {\n throw new Error(\n `Validator error: Expected a plain old JavaScript \\`object\\` for a record, got \\`${value}\\``,\n );\n }\n for (const [k, fieldValue] of Object.entries(value)) {\n validateValidator(validator.keys, k);\n if (fieldValue !== undefined) {\n validateValidator(validator.values.fieldType, fieldValue);\n }\n }\n return;\n }\n default: {\n const unknown: never = validator;\n throw new Error(\n `The test kernel cannot check a validator of type \\`${(unknown as { type: string }).type}\\`.`,\n );\n }\n }\n}\n\nexport const JWT_CLAIM_BY_IDENTITY_ATTRIBUTE: Record<string, string> = {\n subject: \"sub\",\n issuer: \"iss\",\n name: \"name\",\n givenName: \"given_name\",\n familyName: \"family_name\",\n nickname: \"nickname\",\n preferredUsername: \"preferred_username\",\n profileUrl: \"profile\",\n pictureUrl: \"picture\",\n email: \"email\",\n emailVerified: \"email_verified\",\n gender: \"gender\",\n birthday: \"birthdate\",\n timezone: \"zoneinfo\",\n language: \"locale\",\n phoneNumber: \"phone_number\",\n phoneNumberVerified: \"phone_number_verified\",\n address: \"address\",\n updatedAt: \"updated_at\",\n};\n\nexport function base64UrlEncode(value: string) {\n return base64UrlEncodeBytes(new TextEncoder().encode(value));\n}\n\nexport function base64UrlEncodeBytes(bytes: Uint8Array) {\n let binary = \"\";\n for (const byte of bytes) {\n binary += String.fromCharCode(byte);\n }\n return btoa(binary)\n .replace(/\\+/g, \"-\")\n .replace(/\\//g, \"_\")\n .replace(/=+$/, \"\");\n}\n\n// Builds the token `withIdentity` pretends the request was authenticated with.\n// Real tokens are signed by an identity provider; this one is unsecured\n// (`\"alg\": \"none\"`, empty signature).\nexport function createTestJwt(identity: Record<string, any>) {\n const claims: Record<string, any> = Object.create(null);\n for (const [attribute, value] of Object.entries(identity)) {\n if (value === undefined || attribute === \"tokenIdentifier\") {\n continue;\n }\n // Custom claims are used as is, known attributes use their claim name.\n const claimName = Object.hasOwn(JWT_CLAIM_BY_IDENTITY_ATTRIBUTE, attribute)\n ? JWT_CLAIM_BY_IDENTITY_ATTRIBUTE[attribute]\n : attribute;\n claims[claimName] = value;\n }\n // The identity provider always determines who the user is.\n claims.iss = identity.issuer;\n claims.sub = identity.subject;\n const header = base64UrlEncode(JSON.stringify({ alg: \"none\", typ: \"JWT\" }));\n const payload = base64UrlEncode(JSON.stringify(claims));\n return `${header}.${payload}.`;\n}\n\n// Limits the backend puts on tokens from `ctx.auth.signJwt`.\nexport function parseArgs(\n args: Record<string, Value> | undefined,\n): Record<string, Value> {\n if (args === undefined) {\n return {};\n }\n if (!isSimpleObject(args)) {\n throw new Error(\n `The arguments to a Convex function must be an object. Received: ${\n args as any\n }`,\n );\n }\n return args;\n}\n\nexport function validateFunctionArgs(\n argsValidator: ValidatorJSON,\n args: any,\n functionPath: FunctionPath,\n allowPendingValues: boolean,\n) {\n if (!allowPendingValues && hasPendingValues(args)) {\n throw new Error(\n `Invalid arguments for \"${functionPath.udfPath}\": an unresolved ` +\n `placeholder value can only be passed to a query or mutation ` +\n `called from a mutation`,\n );\n }\n validateValidator(argsValidator, resolvePendingValues(args));\n}\n\nexport function validateReturnValue(\n returnsValidator: ValidatorJSON | null,\n result: any,\n functionType: \"query\" | \"mutation\" | \"action\",\n functionPath: FunctionPath,\n) {\n if (returnsValidator !== null) {\n try {\n validateValidator(returnsValidator, resolvePendingValues(result));\n } catch (e) {\n throw new Error(\n `Return value validation failed for ${functionType} \"${functionPath.udfPath}\":\\n${(e as Error).message}`,\n { cause: e },\n );\n }\n }\n}\n\nconst FUNCTION_HANDLE_PREFIX = \"function://\";\n\nexport function createFunctionHandle(functionPath: FunctionPath) {\n return `${FUNCTION_HANDLE_PREFIX}${functionPath.componentPath};${functionPath.udfPath}`;\n}\n\n/**\n * The function a handle the kernel minted names, or `undefined` for a string\n * that is not `function://<componentPath>;<udfPath>` with a function path.\n */\nfunction readFunctionHandle(handle: string): FunctionPath | undefined {\n if (!handle.startsWith(FUNCTION_HANDLE_PREFIX)) return undefined;\n const parts = handle.slice(FUNCTION_HANDLE_PREFIX.length).split(\";\");\n if (parts.length !== 2 || parts[1] === \"\") return undefined;\n return { componentPath: parts[0]!, udfPath: parts[1]! };\n}\n\nexport function parseFunctionHandle(handle: string): FunctionPath {\n const functionPath = readFunctionHandle(handle);\n if (functionPath === undefined) {\n throw new Error(`Invalid function handle \\`${handle}\\``);\n }\n return functionPath;\n}\nexport function simpleHash(string: string) {\n let hash = 0;\n for (let i = 0; i < string.length; i++) {\n const char = string.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash; // Convert to 32bit integer\n }\n return hash;\n}\n"],"mappings":";;AAoFA,SAAgB,gBAAgB,IAAY;CAC1C,MAAM,QAAQ,GAAG,MAAM,SAAS;CAChC,IAAI,CAAC,SAAS,MAAM,EAAE,CAAC,WAAW,GAAG,QACnC,OAAO;CAET,OAAO,GAAG,MAAM,MAAM,EAAE,CAAC,MAAM;AACjC;AACA,SAAgB,2BAA2B,QAAiB;CAC1D,IACE,OAAO,WAAW,YAClB,WAAW,QACX,OAAO,IAAI,aAAa,KAAK,UAC7B,OAAQ,OAA6B,SAAS,UAE9C,IAAI;EACF,OAA8B,OAAO,aACnC,KAAK,MAAO,OAA4B,IAAI,CAC9C;CACF,QAAQ,CAER;CAEF,OAAO;AACT;AAEA,SAAgB,eAAe,OAAgB;CAC7C,MAAM,WAAW,OAAO,UAAU;CAClC,MAAM,YAAY,OAAO,eAAe,KAAK;CAC7C,MAAM,WACJ,cAAc,QACd,cAAc,OAAO,aAGrB,WAAW,aAAa,SAAS;CACnC,OAAO,YAAY;AACrB;AAGA,MAAa,gBAAgB,MAAM,MAAM;AAEzC,SAAgB,iBAAiB,OAAuB;CACtD,IAAI,iBAAiB,qBACnB,OAAO;CAET,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,gBAAgB;CAEpC,IAAI,UAAU,QAAQ,UAAU,KAAA,KAAa,eAAe,KAAK,GAC/D,OAAO,OAAO,OAAO,KAAK,CAAC,CAAC,KAAK,gBAAgB;CAEnD,OAAO;AACT;AAGA,SAAgB,qBAAqB,OAAqB;CACxD,OAAO,mBAAmB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e,MAAM;EAAK,SAAS,MAAM;CAAI;AACxD;AAEA,SAAgB,oBAAoB,QAA8B;CAChE,MAAM,eAAe,mBAAmB,MAAM;CAC9C,IAAI,iBAAiB,KAAA,GACnB,MAAM,IAAI,MAAM,6BAA6B,OAAO,GAAG;CAEzD,OAAO;AACT;AACA,SAAgB,WAAW,QAAgB;CACzC,IAAI,OAAO;CACX,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACtC,MAAM,OAAO,OAAO,WAAW,CAAC;EAChC,QAAQ,QAAQ,KAAK,OAAO;EAC5B,OAAO,OAAO;CAChB;CACA,OAAO;AACT"}
@@ -2,7 +2,7 @@ import type { TestConvexForDataModel } from "convex-test";
2
2
  import type { GenericDataModel } from "convex/server";
3
3
  import type { HttpMount, RegisterComponent } from "../TestConfect.js";
4
4
  export declare const make: (mounts: ReadonlyArray<HttpMount>, registerComponent: RegisterComponent) => {
5
- register: (componentPath: string, schema: import("convex/server").SchemaDefinition<import("convex/server").GenericSchema, boolean>, glob: Record<string, () => Promise<any>>) => void;
5
+ register: RegisterComponent;
6
6
  fetch: <DataModel extends GenericDataModel>(accessor: TestConvexForDataModel<DataModel>, path: string, init?: RequestInit) => Promise<Response>;
7
7
  };
8
8
  //# sourceMappingURL=MountedHttp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MountedHttp.d.ts","sourceRoot":"","sources":["../../src/internal/MountedHttp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EACV,gBAAgB,EAKjB,MAAM,eAAe,CAAC;AAIvB,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAmFtE,eAAO,MAAM,IAAI,WACP,aAAa,CAAC,SAAS,CAAC,qBACb,iBAAiB;;YAoGrB,SAAS,SAAS,gBAAgB,YACrC,sBAAsB,CAAC,SAAS,CAAC,QACrC,MAAM,SACL,WAAW,KACjB,OAAO,CAAC,QAAQ,CAAC;CAgErB,CAAC"}
1
+ {"version":3,"file":"MountedHttp.d.ts","sourceRoot":"","sources":["../../src/internal/MountedHttp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EACV,gBAAgB,EAKjB,MAAM,eAAe,CAAC;AAIvB,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAmFtE,eAAO,MAAM,IAAI,WACP,aAAa,CAAC,SAAS,CAAC,qBACb,iBAAiB;;YA2GrB,SAAS,SAAS,gBAAgB,YACrC,sBAAsB,CAAC,SAAS,CAAC,QACrC,MAAM,SACL,WAAW,KACjB,OAAO,CAAC,QAAQ,CAAC;CAgErB,CAAC"}
@@ -42,9 +42,9 @@ const make = (mounts, registerComponent) => {
42
42
  if (Result.isFailure(normalized)) throw normalized.failure;
43
43
  const registered = /* @__PURE__ */ new Set();
44
44
  let tail = Promise.resolve();
45
- const register = (componentPath, schema, modules) => {
45
+ const register = (componentPath, schema, modules, options) => {
46
46
  if (!normalized.success.some((mount) => mount.componentPath === componentPath)) {
47
- registerComponent(componentPath, schema, modules);
47
+ registerComponent(componentPath, schema, modules, options);
48
48
  return;
49
49
  }
50
50
  const root = Object.keys(modules).find((key) => key.includes("_generated"))?.split("_generated", 2)[0];
@@ -98,7 +98,7 @@ const make = (mounts, registerComponent) => {
98
98
  registerComponent(componentPath, schema, {
99
99
  ...modules,
100
100
  [bridgePath]: () => Promise.resolve({ invoke })
101
- });
101
+ }, options);
102
102
  registered.add(componentPath);
103
103
  };
104
104
  const fetch = (accessor, path, init) => {