@gaganref/confect-test 10.3.1-fork.88 → 10.3.1-fork.89

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 (46) hide show
  1. package/dist/internal/Attempt.d.ts +77 -0
  2. package/dist/internal/Attempt.d.ts.map +1 -0
  3. package/dist/internal/Attempt.js +154 -0
  4. package/dist/internal/Attempt.js.map +1 -0
  5. package/dist/internal/ConvexTest.d.ts +34 -0
  6. package/dist/internal/ConvexTest.d.ts.map +1 -0
  7. package/dist/internal/ConvexTest.js +59 -0
  8. package/dist/internal/ConvexTest.js.map +1 -0
  9. package/dist/internal/Execution.d.ts +167 -0
  10. package/dist/internal/Execution.d.ts.map +1 -0
  11. package/dist/internal/Execution.js +790 -0
  12. package/dist/internal/Execution.js.map +1 -0
  13. package/dist/internal/Globals.d.ts +11 -0
  14. package/dist/internal/Globals.d.ts.map +1 -0
  15. package/dist/internal/Globals.js +76 -0
  16. package/dist/internal/Globals.js.map +1 -0
  17. package/dist/internal/Kernel.d.ts +93 -0
  18. package/dist/internal/Kernel.d.ts.map +1 -0
  19. package/dist/internal/Kernel.js +91 -0
  20. package/dist/internal/Kernel.js.map +1 -0
  21. package/dist/internal/KernelQuery.d.ts +55 -0
  22. package/dist/internal/KernelQuery.d.ts.map +1 -0
  23. package/dist/internal/KernelQuery.js +205 -0
  24. package/dist/internal/KernelQuery.js.map +1 -0
  25. package/dist/internal/KernelRefusal.d.ts +77 -0
  26. package/dist/internal/KernelRefusal.d.ts.map +1 -0
  27. package/dist/internal/KernelRefusal.js +73 -0
  28. package/dist/internal/KernelRefusal.js.map +1 -0
  29. package/dist/internal/KernelValues.d.ts +136 -0
  30. package/dist/internal/KernelValues.d.ts.map +1 -0
  31. package/dist/internal/KernelValues.js +266 -0
  32. package/dist/internal/KernelValues.js.map +1 -0
  33. package/dist/internal/ReadSet.d.ts +55 -0
  34. package/dist/internal/ReadSet.d.ts.map +1 -0
  35. package/dist/internal/ReadSet.js +29 -0
  36. package/dist/internal/ReadSet.js.map +1 -0
  37. package/package.json +3 -3
  38. package/src/internal/Attempt.ts +185 -0
  39. package/src/internal/ConvexTest.ts +118 -0
  40. package/src/internal/Execution.ts +1430 -0
  41. package/src/internal/Globals.ts +93 -0
  42. package/src/internal/Kernel.ts +190 -0
  43. package/src/internal/KernelQuery.ts +405 -0
  44. package/src/internal/KernelRefusal.ts +88 -0
  45. package/src/internal/KernelValues.ts +725 -0
  46. package/src/internal/ReadSet.ts +108 -0
@@ -0,0 +1,77 @@
1
+ import type { Attempt as AttemptNumber } from "./Invocation.js";
2
+ import * as Kernel from "./Kernel.js";
3
+ import type { DocumentId, StoredDocument } from "./KernelValues.js";
4
+ import type * as ReadSet from "./ReadSet.js";
5
+ /**
6
+ * One frame of an attempt at a query or mutation: the committed state the
7
+ * attempt started from, its caller's frame and its own pending writes. The
8
+ * outermost frame belongs to the top-level function. Each nested mutation opens
9
+ * a child frame, which merges into its caller's frame when it returns and is
10
+ * dropped when it fails. Reads belong to the whole attempt and are never
11
+ * dropped: a failed nested mutation's reads stay in the attempt.
12
+ *
13
+ * Each frame has its own lifetime. A frame takes reads and writes until it is
14
+ * closed. A mutation's frame closes once its function has returned and no
15
+ * syscall it started is still running, so a write a detached fiber makes after
16
+ * the handler settled still lands in it, as on the binary. A nested mutation's
17
+ * frame closes before it merges into its caller's, so no write reaches it after
18
+ * its writes became its caller's.
19
+ *
20
+ * A frame belongs to one invocation, which alone writes to it, so a caller's
21
+ * write made while its nested mutation is in flight stays the caller's.
22
+ * `Kernel.apply` publishes the outermost frame's writes.
23
+ */
24
+ export declare class KernelAttempt {
25
+ readonly snapshot: Kernel.State;
26
+ readonly number: AttemptNumber;
27
+ private readonly parent?;
28
+ private readonly overlay;
29
+ private readonly life;
30
+ private readonly allReads;
31
+ constructor(snapshot: Kernel.State, number?: AttemptNumber, parent?: KernelAttempt | undefined);
32
+ get reads(): ReadonlyArray<ReadSet.Read>;
33
+ get closed(): boolean;
34
+ readDocument(componentPath: string, id: DocumentId): void;
35
+ /**
36
+ * Record a read of an interval. The returned function advances how far the
37
+ * query examined it.
38
+ */
39
+ readInterval(read: Omit<ReadSet.IntervalRead, "through">): (through: ReadSet.Key | "end") => void;
40
+ /**
41
+ * A syscall began. `end` runs when it settles.
42
+ */
43
+ begin(): () => void;
44
+ /**
45
+ * Resolves once a whole turn of the event loop passes with no syscall of this
46
+ * frame running or started. A nested call is a syscall of its caller's frame
47
+ * until it has drained.
48
+ */
49
+ drained(): Promise<void>;
50
+ close(): void;
51
+ /**
52
+ * The pending writes this frame sees, from the outermost frame to this one.
53
+ */
54
+ private overlays;
55
+ get(componentPath: string, id: DocumentId): StoredDocument | null;
56
+ /**
57
+ * The table as this frame sees it, committed rows under every pending write
58
+ * from the outermost frame to this one.
59
+ */
60
+ scan(componentPath: string, tableName: string): Array<StoredDocument>;
61
+ write(componentPath: string, id: DocumentId, doc: StoredDocument | null): void;
62
+ /**
63
+ * A nested mutation begins, in a frame of its own. Dropping a failed one is
64
+ * forgetting it.
65
+ */
66
+ child(): KernelAttempt;
67
+ /**
68
+ * A nested mutation returned and its frame closed. Its writes become its
69
+ * caller's.
70
+ */
71
+ merge(): void;
72
+ /**
73
+ * The outermost frame's writes, for `Kernel.apply`.
74
+ */
75
+ writes(): Array<Kernel.Write>;
76
+ }
77
+ //# sourceMappingURL=Attempt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Attempt.d.ts","sourceRoot":"","sources":["../../src/internal/Attempt.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEpE,OAAO,KAAK,KAAK,OAAO,MAAM,cAAc,CAAC;AAiB7C;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,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AED;;;OAGG;IACH,KAAK,SASJ;IAED;;OAEG;IACH,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAI5B;CACF"}
@@ -0,0 +1,154 @@
1
+ import { tableNameFromId } from "./KernelValues.js";
2
+ import { get, rows } from "./Kernel.js";
3
+ import { setImmediate } from "node:timers/promises";
4
+ //#region src/internal/Attempt.ts
5
+ /**
6
+ * One frame of an attempt at a query or mutation: the committed state the
7
+ * attempt started from, its caller's frame and its own pending writes. The
8
+ * outermost frame belongs to the top-level function. Each nested mutation opens
9
+ * a child frame, which merges into its caller's frame when it returns and is
10
+ * dropped when it fails. Reads belong to the whole attempt and are never
11
+ * dropped: a failed nested mutation's reads stay in the attempt.
12
+ *
13
+ * Each frame has its own lifetime. A frame takes reads and writes until it is
14
+ * closed. A mutation's frame closes once its function has returned and no
15
+ * syscall it started is still running, so a write a detached fiber makes after
16
+ * the handler settled still lands in it, as on the binary. A nested mutation's
17
+ * frame closes before it merges into its caller's, so no write reaches it after
18
+ * its writes became its caller's.
19
+ *
20
+ * A frame belongs to one invocation, which alone writes to it, so a caller's
21
+ * write made while its nested mutation is in flight stays the caller's.
22
+ * `Kernel.apply` publishes the outermost frame's writes.
23
+ */
24
+ var KernelAttempt = class KernelAttempt {
25
+ snapshot;
26
+ number;
27
+ parent;
28
+ overlay = /* @__PURE__ */ new Map();
29
+ life = {
30
+ running: 0,
31
+ started: 0,
32
+ open: true
33
+ };
34
+ allReads;
35
+ constructor(snapshot, number = 1, parent) {
36
+ this.snapshot = snapshot;
37
+ this.number = number;
38
+ this.parent = parent;
39
+ this.allReads = parent?.allReads ?? [];
40
+ }
41
+ get reads() {
42
+ return this.allReads;
43
+ }
44
+ get closed() {
45
+ return !this.life.open;
46
+ }
47
+ readDocument(componentPath, id) {
48
+ this.allReads.push({
49
+ kind: "document",
50
+ componentPath,
51
+ id
52
+ });
53
+ }
54
+ /**
55
+ * Record a read of an interval. The returned function advances how far the
56
+ * query examined it.
57
+ */
58
+ readInterval(read) {
59
+ const interval = {
60
+ ...read,
61
+ through: null
62
+ };
63
+ this.allReads.push(interval);
64
+ return (through) => {
65
+ interval.through = through;
66
+ };
67
+ }
68
+ /**
69
+ * A syscall began. `end` runs when it settles.
70
+ */
71
+ begin() {
72
+ const life = this.life;
73
+ life.running++;
74
+ life.started++;
75
+ return () => {
76
+ life.running--;
77
+ };
78
+ }
79
+ /**
80
+ * Resolves once a whole turn of the event loop passes with no syscall of this
81
+ * frame running or started. A nested call is a syscall of its caller's frame
82
+ * until it has drained.
83
+ */
84
+ drained() {
85
+ const before = this.life.started;
86
+ return setImmediate().then(() => this.life.running === 0 && this.life.started === before ? void 0 : this.drained());
87
+ }
88
+ close() {
89
+ this.life.open = false;
90
+ }
91
+ /**
92
+ * The pending writes this frame sees, from the outermost frame to this one.
93
+ */
94
+ overlays() {
95
+ return this.parent === void 0 ? [this.overlay] : [...this.parent.overlays(), this.overlay];
96
+ }
97
+ get(componentPath, id) {
98
+ for (const overlay of this.overlays().toReversed()) {
99
+ const write = overlay.get(componentPath)?.get(id);
100
+ if (write !== void 0) return write;
101
+ }
102
+ return get(this.snapshot, componentPath, id)?.doc ?? null;
103
+ }
104
+ /**
105
+ * The table as this frame sees it, committed rows under every pending write
106
+ * from the outermost frame to this one.
107
+ */
108
+ scan(componentPath, tableName) {
109
+ const ids = /* @__PURE__ */ new Set();
110
+ for (const row of rows(this.snapshot, componentPath, tableName)) ids.add(row.doc._id);
111
+ for (const overlay of this.overlays()) for (const id of overlay.get(componentPath)?.keys() ?? []) if (tableNameFromId(id) === tableName) ids.add(id);
112
+ const docs = [];
113
+ for (const id of ids) {
114
+ const doc = this.get(componentPath, id);
115
+ if (doc !== null) docs.push(doc);
116
+ }
117
+ return docs;
118
+ }
119
+ write(componentPath, id, doc) {
120
+ const writes = this.overlay.get(componentPath) ?? /* @__PURE__ */ new Map();
121
+ this.overlay.set(componentPath, writes);
122
+ writes.set(id, doc);
123
+ }
124
+ /**
125
+ * A nested mutation begins, in a frame of its own. Dropping a failed one is
126
+ * forgetting it.
127
+ */
128
+ child() {
129
+ return new KernelAttempt(this.snapshot, this.number, this);
130
+ }
131
+ /**
132
+ * A nested mutation returned and its frame closed. Its writes become its
133
+ * caller's.
134
+ */
135
+ merge() {
136
+ if (this.parent === void 0) throw new Error("The outermost frame of an attempt has no caller.");
137
+ if (this.life.open) throw new Error("A nested mutation's frame merges only once closed.");
138
+ for (const [componentPath, writes] of this.overlay) for (const [id, doc] of writes) this.parent.write(componentPath, id, doc);
139
+ }
140
+ /**
141
+ * The outermost frame's writes, for `Kernel.apply`.
142
+ */
143
+ writes() {
144
+ return Array.from(this.overlay, ([componentPath, writes]) => Array.from(writes, ([id, doc]) => ({
145
+ componentPath,
146
+ id,
147
+ doc
148
+ }))).flat();
149
+ }
150
+ };
151
+ //#endregion
152
+ export { KernelAttempt };
153
+
154
+ //# sourceMappingURL=Attempt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Attempt.js","names":["Kernel.get","Kernel.rows"],"sources":["../../src/internal/Attempt.ts"],"sourcesContent":["// oxlint-disable-next-line effecttsgo/node-builtin-import -- The drain waits a real turn of the event loop. Fake timers in a test replace the global `setImmediate`, not this one.\nimport { setImmediate } from \"node:timers/promises\";\nimport type { Attempt as AttemptNumber } from \"./Invocation.js\";\nimport * as Kernel from \"./Kernel.js\";\nimport type { DocumentId, StoredDocument } from \"./KernelValues.js\";\nimport { tableNameFromId } from \"./KernelValues.js\";\nimport type * as ReadSet from \"./ReadSet.js\";\n\n/**\n * Pending writes, keyed by component path, then document ID. `null` deletes.\n */\ntype Overlay = Map<string, Map<DocumentId, StoredDocument | null>>;\n\n/**\n * How long one frame takes syscalls: those it has running, those it has\n * started, and whether it still takes them.\n */\ninterface Life {\n running: number;\n started: number;\n open: boolean;\n}\n\n/**\n * One frame of an attempt at a query or mutation: the committed state the\n * attempt started from, its caller's frame and its own pending writes. The\n * outermost frame belongs to the top-level function. Each nested mutation opens\n * a child frame, which merges into its caller's frame when it returns and is\n * dropped when it fails. Reads belong to the whole attempt and are never\n * dropped: a failed nested mutation's reads stay in the attempt.\n *\n * Each frame has its own lifetime. A frame takes reads and writes until it is\n * closed. A mutation's frame closes once its function has returned and no\n * syscall it started is still running, so a write a detached fiber makes after\n * the handler settled still lands in it, as on the binary. A nested mutation's\n * frame closes before it merges into its caller's, so no write reaches it after\n * its writes became its caller's.\n *\n * A frame belongs to one invocation, which alone writes to it, so a caller's\n * write made while its nested mutation is in flight stays the caller's.\n * `Kernel.apply` publishes the outermost frame's writes.\n */\nexport class KernelAttempt {\n private readonly overlay: Overlay = new Map();\n private readonly life: Life = { running: 0, started: 0, open: true };\n private readonly allReads: Array<ReadSet.Read>;\n\n constructor(\n readonly snapshot: Kernel.State,\n readonly number: AttemptNumber = 1,\n private readonly parent?: KernelAttempt,\n ) {\n this.allReads = parent?.allReads ?? [];\n }\n\n get reads(): ReadonlyArray<ReadSet.Read> {\n return this.allReads;\n }\n\n get closed(): boolean {\n return !this.life.open;\n }\n\n readDocument(componentPath: string, id: DocumentId) {\n this.allReads.push({ kind: \"document\", componentPath, id });\n }\n\n /**\n * Record a read of an interval. The returned function advances how far the\n * query examined it.\n */\n readInterval(\n read: Omit<ReadSet.IntervalRead, \"through\">,\n ): (through: ReadSet.Key | \"end\") => void {\n const interval: ReadSet.IntervalRead = { ...read, through: null };\n this.allReads.push(interval);\n return (through) => {\n interval.through = through;\n };\n }\n\n /**\n * A syscall began. `end` runs when it settles.\n */\n begin(): () => void {\n const life = this.life;\n life.running++;\n life.started++;\n return () => {\n life.running--;\n };\n }\n\n /**\n * Resolves once a whole turn of the event loop passes with no syscall of this\n * frame running or started. A nested call is a syscall of its caller's frame\n * until it has drained.\n */\n drained(): Promise<void> {\n const before = this.life.started;\n return setImmediate().then(() =>\n this.life.running === 0 && this.life.started === before\n ? undefined\n : this.drained(),\n );\n }\n\n close() {\n this.life.open = false;\n }\n\n /**\n * The pending writes this frame sees, from the outermost frame to this one.\n */\n private overlays(): Array<Overlay> {\n return this.parent === undefined\n ? [this.overlay]\n : [...this.parent.overlays(), this.overlay];\n }\n\n get(componentPath: string, id: DocumentId): StoredDocument | null {\n for (const overlay of this.overlays().toReversed()) {\n const write = overlay.get(componentPath)?.get(id);\n if (write !== undefined) return write;\n }\n return Kernel.get(this.snapshot, componentPath, id)?.doc ?? null;\n }\n\n /**\n * The table as this frame sees it, committed rows under every pending write\n * from the outermost frame to this one.\n */\n scan(componentPath: string, tableName: string): Array<StoredDocument> {\n const ids = new Set<DocumentId>();\n for (const row of Kernel.rows(this.snapshot, componentPath, tableName))\n ids.add(row.doc._id);\n for (const overlay of this.overlays())\n for (const id of overlay.get(componentPath)?.keys() ?? [])\n if (tableNameFromId(id) === tableName) ids.add(id);\n const docs: Array<StoredDocument> = [];\n for (const id of ids) {\n const doc = this.get(componentPath, id);\n if (doc !== null) docs.push(doc);\n }\n return docs;\n }\n\n write(componentPath: string, id: DocumentId, doc: StoredDocument | null) {\n const writes = this.overlay.get(componentPath) ?? new Map();\n this.overlay.set(componentPath, writes);\n writes.set(id, doc);\n }\n\n /**\n * A nested mutation begins, in a frame of its own. Dropping a failed one is\n * forgetting it.\n */\n child(): KernelAttempt {\n return new KernelAttempt(this.snapshot, this.number, this);\n }\n\n /**\n * A nested mutation returned and its frame closed. Its writes become its\n * caller's.\n */\n merge() {\n if (this.parent === undefined) {\n throw new Error(\"The outermost frame of an attempt has no caller.\");\n }\n if (this.life.open) {\n throw new Error(\"A nested mutation's frame merges only once closed.\");\n }\n for (const [componentPath, writes] of this.overlay)\n for (const [id, doc] of writes) this.parent.write(componentPath, id, doc);\n }\n\n /**\n * The outermost frame's writes, for `Kernel.apply`.\n */\n writes(): Array<Kernel.Write> {\n return Array.from(this.overlay, ([componentPath, writes]) =>\n Array.from(writes, ([id, doc]) => ({ componentPath, id, doc })),\n ).flat();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAa,gBAAb,MAAa,cAAc;C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 +1,34 @@
1
+ import type { GenericSchema, SchemaDefinition } from "convex/server";
2
+ import * as Execution from "./Execution.js";
3
+ import type * as Kernel from "./Kernel.js";
4
+ type Modules = Record<string, () => Promise<any>>;
5
+ /**
6
+ * What the kernel adds to convex-test's surface, typed. The shim itself returns
7
+ * `any`, as convex-test's callers expect.
8
+ */
9
+ export interface KernelControls {
10
+ readonly query: (reference: any, args?: any) => Promise<any>;
11
+ readonly mutation: (reference: any, args?: any) => Promise<any>;
12
+ readonly action: (reference: any, args?: any) => Promise<any>;
13
+ readonly prepare: (reference: any, args?: any) => Promise<Execution.HeldAttempt>;
14
+ readonly apply: (id: string) => Promise<Execution.KernelApply>;
15
+ readonly held: () => ReadonlyArray<Execution.HeldAttempt>;
16
+ }
17
+ /**
18
+ * The test kernel under convex-test's `convexTest` signature. The fork's kernel
19
+ * lane aliases `convex-test` to this module, so every suite that calls
20
+ * `convexTest` directly, and `TestConfect` itself, runs on the kernel.
21
+ *
22
+ * Beyond convex-test, `prepare` runs a mutation to its commit point and holds
23
+ * it, and `apply` validates and publishes a held attempt. `mutation` applies
24
+ * each attempt it prepares at once and prepares the next on a conflict, up to
25
+ * attempt 5. `runtime` supplies the clock and commit timestamps.
26
+ */
27
+ export declare function convexTest(schemaOrOptions?: SchemaDefinition<GenericSchema, boolean> | {
28
+ readonly schema?: SchemaDefinition<GenericSchema, boolean>;
29
+ readonly modules?: Modules;
30
+ readonly transactionLimits?: unknown;
31
+ readonly runtime?: Kernel.KernelRuntime;
32
+ }, modules?: Modules): any;
33
+ export {};
34
+ //# sourceMappingURL=ConvexTest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConvexTest.d.ts","sourceRoot":"","sources":["../../src/internal/ConvexTest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAEjB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,KAAK,M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,GAChB,GAAG,CA8BL"}
@@ -0,0 +1,59 @@
1
+ import { rowPending } from "./KernelRefusal.js";
2
+ import { World, anonymous, withIdentity } from "./Execution.js";
3
+ import { componentsGeneric } from "convex/server";
4
+ //#region src/internal/ConvexTest.ts
5
+ const isSchemaDefinition = (value) => value !== null && typeof value === "object" && "tables" in value && typeof value.tables === "object";
6
+ const accessor = (world, caller) => ({
7
+ query: (reference, args) => world.query(caller, reference, args),
8
+ mutation: (reference, args) => world.mutation(caller, reference, args),
9
+ action: (reference, args) => world.action(caller, reference, args),
10
+ prepare: (reference, args) => world.prepare(caller, reference, args),
11
+ apply: (id) => world.apply(id),
12
+ held: () => world.held(),
13
+ run: (handler) => world.run(caller, "", handler),
14
+ runInComponent: (componentPath, handler) => world.run(caller, componentPath, handler),
15
+ withIdentity: (identity) => accessor(world, withIdentity(caller, identity)),
16
+ withRequestMetadata: (metadata) => accessor(world, {
17
+ ...caller,
18
+ ip: metadata.ip ?? null,
19
+ userAgent: metadata.userAgent ?? null
20
+ }),
21
+ fetch: () => Promise.reject(rowPending("HTTP routes", 6)),
22
+ jwks: () => Promise.reject(rowPending("JWT verification", 6)),
23
+ finishInProgressScheduledFunctions: () => Promise.reject(rowPending("the scheduler", 5)),
24
+ finishAllScheduledFunctions: () => Promise.reject(rowPending("the scheduler", 5))
25
+ });
26
+ /**
27
+ * The test kernel under convex-test's `convexTest` signature. The fork's kernel
28
+ * lane aliases `convex-test` to this module, so every suite that calls
29
+ * `convexTest` directly, and `TestConfect` itself, runs on the kernel.
30
+ *
31
+ * Beyond convex-test, `prepare` runs a mutation to its commit point and holds
32
+ * it, and `apply` validates and publishes a held attempt. `mutation` applies
33
+ * each attempt it prepares at once and prepares the next on a conflict, up to
34
+ * attempt 5. `runtime` supplies the clock and commit timestamps.
35
+ */
36
+ function convexTest(schemaOrOptions, modules) {
37
+ let schema;
38
+ let runtime;
39
+ if (isSchemaDefinition(schemaOrOptions)) schema = schemaOrOptions;
40
+ else if (schemaOrOptions !== void 0) {
41
+ if (schemaOrOptions.transactionLimits !== void 0) throw rowPending("transaction limits", 6);
42
+ schema = schemaOrOptions.schema;
43
+ modules = schemaOrOptions.modules;
44
+ runtime = schemaOrOptions.runtime;
45
+ }
46
+ if (modules === void 0) throw new Error("The test kernel needs the modules map: pass `import.meta.glob(...)` as the second argument.");
47
+ const world = new World(schema, modules, runtime);
48
+ return {
49
+ ...accessor(world, anonymous),
50
+ registerComponent: (componentPath, componentSchema, componentModules) => {
51
+ world.register(componentPath, componentSchema, componentModules);
52
+ return componentsGeneric()[componentPath];
53
+ }
54
+ };
55
+ }
56
+ //#endregion
57
+ export { convexTest };
58
+
59
+ //# sourceMappingURL=ConvexTest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConvexTest.js","names":["Execution.withIdentity","KernelRefusal.rowPending","Execution.World","Execution.anonymous"],"sources":["../../src/internal/ConvexTest.ts"],"sourcesContent":["import type {\n GenericSchema,\n SchemaDefinition,\n UserIdentity,\n} from \"convex/server\";\nimport { componentsGeneric } from \"convex/server\";\nimport * as Execution from \"./Execution.js\";\nimport type * as Kernel from \"./Kernel.js\";\nimport * as KernelRefusal from \"./KernelRefusal.js\";\n\ntype Modules = Record<string, () => Promise<any>>;\n\n/**\n * What the kernel adds to convex-test's surface, typed. The shim itself returns\n * `any`, as convex-test's callers expect.\n */\nexport interface KernelControls {\n readonly query: (reference: any, args?: any) => Promise<any>;\n readonly mutation: (reference: any, args?: any) => Promise<any>;\n readonly action: (reference: any, args?: any) => Promise<any>;\n readonly prepare: (\n reference: any,\n args?: any,\n ) => Promise<Execution.HeldAttempt>;\n readonly apply: (id: string) => Promise<Execution.KernelApply>;\n readonly held: () => ReadonlyArray<Execution.HeldAttempt>;\n}\n\nconst isSchemaDefinition = (\n value: unknown,\n): value is SchemaDefinition<GenericSchema, boolean> =>\n value !== null &&\n typeof value === \"object\" &&\n \"tables\" in value &&\n typeof (value as { tables: unknown }).tables === \"object\";\n\nconst accessor = (world: Execution.World, caller: Execution.Caller): any => ({\n query: (reference: any, args?: any) => world.query(caller, reference, args),\n mutation: (reference: any, args?: any) =>\n world.mutation(caller, reference, args),\n action: (reference: any, args?: any) => world.action(caller, reference, args),\n prepare: (reference: any, args?: any) =>\n world.prepare(caller, reference, args),\n apply: (id: string) => world.apply(id),\n held: () => world.held(),\n run: (handler: (ctx: any) => any) => world.run(caller, \"\", handler),\n runInComponent: (componentPath: string, handler: (ctx: any) => any) =>\n world.run(caller, componentPath, handler),\n withIdentity: (identity: Partial<UserIdentity>) =>\n accessor(world, Execution.withIdentity(caller, identity)),\n withRequestMetadata: (metadata: {\n readonly ip?: string | null;\n readonly userAgent?: string | null;\n }) =>\n accessor(world, {\n ...caller,\n ip: metadata.ip ?? null,\n userAgent: metadata.userAgent ?? null,\n }),\n fetch: () => Promise.reject(KernelRefusal.rowPending(\"HTTP routes\", 6)),\n jwks: () => Promise.reject(KernelRefusal.rowPending(\"JWT verification\", 6)),\n finishInProgressScheduledFunctions: () =>\n Promise.reject(KernelRefusal.rowPending(\"the scheduler\", 5)),\n finishAllScheduledFunctions: () =>\n Promise.reject(KernelRefusal.rowPending(\"the scheduler\", 5)),\n});\n\n/**\n * The test kernel under convex-test's `convexTest` signature. The fork's kernel\n * lane aliases `convex-test` to this module, so every suite that calls\n * `convexTest` directly, and `TestConfect` itself, runs on the kernel.\n *\n * Beyond convex-test, `prepare` runs a mutation to its commit point and holds\n * it, and `apply` validates and publishes a held attempt. `mutation` applies\n * each attempt it prepares at once and prepares the next on a conflict, up to\n * attempt 5. `runtime` supplies the clock and commit timestamps.\n */\nexport function convexTest(\n schemaOrOptions?:\n | SchemaDefinition<GenericSchema, boolean>\n | {\n readonly schema?: SchemaDefinition<GenericSchema, boolean>;\n readonly modules?: Modules;\n readonly transactionLimits?: unknown;\n readonly runtime?: Kernel.KernelRuntime;\n },\n modules?: Modules,\n): any {\n let schema: SchemaDefinition<GenericSchema, boolean> | undefined;\n let runtime: Kernel.KernelRuntime | undefined;\n if (isSchemaDefinition(schemaOrOptions)) {\n schema = schemaOrOptions;\n } else if (schemaOrOptions !== undefined) {\n if (schemaOrOptions.transactionLimits !== undefined) {\n throw KernelRefusal.rowPending(\"transaction limits\", 6);\n }\n schema = schemaOrOptions.schema;\n modules = schemaOrOptions.modules;\n runtime = schemaOrOptions.runtime;\n }\n if (modules === undefined) {\n throw new Error(\n \"The test kernel needs the modules map: pass `import.meta.glob(...)` as the second argument.\",\n );\n }\n const world = new Execution.World(schema, modules, runtime);\n return {\n ...accessor(world, Execution.anonymous),\n registerComponent: (\n componentPath: string,\n componentSchema: SchemaDefinition<GenericSchema, boolean>,\n componentModules: Modules,\n ) => {\n world.register(componentPath, componentSchema, componentModules);\n return (componentsGeneric() as any)[componentPath];\n },\n };\n}\n"],"mappings":";;;;AA4BA,MAAM,sBACJ,UAEA,UAAU,QACV,OAAO,UAAU,YACjB,YAAY,SACZ,OAAQ,MAA8B,WAAW;AAEnD,MAAM,YAAY,OAAwB,YAAmC;CAC3E,QAAQ,WAAgB,SAAe,MAAM,MAAM,QAAQ,WAAW,IAAI;CAC1E,WAAW,WAAgB,SACzB,MAAM,SAAS,QAAQ,WAAW,IAAI;CACxC,SAAS,WAAgB,SAAe,MAAM,OAAO,QAAQ,WAAW,IAAI;CAC5E,UAAU,WAAgB,SACxB,MAAM,QAAQ,QAAQ,WAAW,IAAI;CACvC,QAAQ,OAAe,MAAM,MAAM,EAAE;CACrC,YAAY,MAAM,KAAK;CACvB,MAAM,YAA+B,MAAM,IAAI,QAAQ,IAAI,OAAO;CAClE,iBAAiB,eAAuB,YACtC,MAAM,IAAI,QAAQ,eAAe,OAAO;CAC1C,eAAe,aACb,SAAS,OAAOA,aAAuB,QAAQ,QAAQ,CAAC;CAC1D,sBAAsB,aAIpB,SAAS,OAAO;EACd,GAAG;EACH,IAAI,SAAS,MAAM;EACnB,WAAW,SAAS,aAAa;CACnC,CAAC;CACH,aAAa,QAAQ,OAAOC,WAAyB,eAAe,CAAC,CAAC;CACtE,YAAY,QAAQ,OAAOA,WAAyB,oBAAoB,CAAC,CAAC;CAC1E,0CACE,QAAQ,OAAOA,WAAyB,iBAAiB,CAAC,CAAC;CAC7D,mCACE,QAAQ,OAAOA,WAAyB,iBAAiB,CAAC,CAAC;AAC/D;;;;;;;;;;;AAYA,SAAgB,WACd,iBAQA,SACK;CACL,IAAI;CACJ,IAAI;CACJ,IAAI,mBAAmB,eAAe,GACpC,SAAS;MACJ,IAAI,oBAAoB,KAAA,GAAW;EACxC,IAAI,gBAAgB,sBAAsB,KAAA,GACxC,MAAMA,WAAyB,sBAAsB,CAAC;EAExD,SAAS,gBAAgB;EACzB,UAAU,gBAAgB;EAC1B,UAAU,gBAAgB;CAC5B;CACA,IAAI,YAAY,KAAA,GACd,MAAM,IAAI,MACR,6FACF;CAEF,MAAM,QAAQ,IAAIC,MAAgB,QAAQ,SAAS,OAAO;CAC1D,OAAO;EACL,GAAG,SAAS,OAAOC,SAAmB;EACtC,oBACE,eACA,iBACA,qBACG;GACH,MAAM,SAAS,eAAe,iBAAiB,gBAAgB;GAC/D,OAAQ,kBAAkB,CAAC,CAAS;EACtC;CACF;AACF"}
@@ -0,0 +1,167 @@
1
+ import { type GenericSchema, type SchemaDefinition, type UserIdentity } from "convex/server";
2
+ import { type Value } from "convex/values";
3
+ import * as Invocation from "./Invocation.js";
4
+ import * as Kernel from "./Kernel.js";
5
+ import * as KernelQuery from "./KernelQuery.js";
6
+ import * as KernelRefusal from "./KernelRefusal.js";
7
+ import type * as ReadSet from "./ReadSet.js";
8
+ type Modules = Record<string, () => Promise<any>>;
9
+ /**
10
+ * One registered component: its schema and its function modules, each loaded
11
+ * once when the world opens.
12
+ */
13
+ interface Component {
14
+ readonly path: string;
15
+ readonly schema: KernelQuery.KernelSchema | null;
16
+ readonly loaders: ReadonlyMap<string, () => Promise<any>>;
17
+ readonly loaded: Map<string, any>;
18
+ }
19
+ /**
20
+ * Who is calling: the identity and the request attributes a test accessor set.
21
+ */
22
+ export interface Caller {
23
+ readonly identity: UserIdentity | null;
24
+ readonly token: string | null;
25
+ readonly ip: string | null;
26
+ readonly userAgent: string | null;
27
+ }
28
+ export declare const anonymous: Caller;
29
+ export declare const withIdentity: (caller: Caller, identity: Partial<UserIdentity>) => Caller;
30
+ /**
31
+ * How a prepared attempt's function ended.
32
+ */
33
+ export type Outcome = {
34
+ readonly _tag: "returned";
35
+ readonly value: Value;
36
+ } | {
37
+ readonly _tag: "failed";
38
+ readonly error: unknown;
39
+ };
40
+ /**
41
+ * A mutation attempt run to its commit point and held until `apply`.
42
+ */
43
+ export interface HeldAttempt {
44
+ readonly id: string;
45
+ readonly request: string;
46
+ readonly number: Invocation.Attempt;
47
+ readonly snapshot: Kernel.Version;
48
+ readonly reads: ReadonlyArray<ReadSet.Read>;
49
+ readonly outcome: Outcome;
50
+ }
51
+ /**
52
+ * What `apply` did with a held attempt. A conflict discards the attempt and
53
+ * holds exactly one next attempt, run against the latest commit. Nothing is
54
+ * retried until that one is applied in turn.
55
+ */
56
+ export type KernelApply = {
57
+ readonly kind: "applied";
58
+ readonly version: Kernel.Version;
59
+ readonly commitTs: bigint;
60
+ readonly result: Value;
61
+ } | {
62
+ readonly kind: "conflict";
63
+ readonly next: HeldAttempt;
64
+ } | {
65
+ readonly kind: "exhausted";
66
+ readonly error: KernelRefusal.OptimisticConcurrencyControlFailure;
67
+ } | {
68
+ readonly kind: "refused";
69
+ readonly tag: string;
70
+ readonly error: unknown;
71
+ };
72
+ /**
73
+ * A test backend: its registered components and the kernel state they share.
74
+ */
75
+ export declare class World {
76
+ private readonly runtime;
77
+ readonly components: Map<string, Component>;
78
+ state: Kernel.State;
79
+ private opened;
80
+ private nextDocId;
81
+ private lastCreationTime;
82
+ private nextQueryId;
83
+ private readonly queries;
84
+ private readonly holding;
85
+ private nextAttemptId;
86
+ constructor(schema: SchemaDefinition<GenericSchema, boolean> | null | undefined, modules: Modules, runtime?: Kernel.KernelRuntime);
87
+ register(componentPath: string, schema: SchemaDefinition<GenericSchema, boolean>, modules: Modules): void;
88
+ /**
89
+ * Load every registered module of every component, once, before any function
90
+ * runs.
91
+ */
92
+ open(): Promise<void>;
93
+ private component;
94
+ private resolve;
95
+ query(caller: Caller, reference: any, args: any): Promise<any>;
96
+ mutation(caller: Caller, reference: any, args: any): Promise<any>;
97
+ action(caller: Caller, reference: any, args: any): Promise<any>;
98
+ run(caller: Caller, componentPath: string, handler: (ctx: any) => any): Promise<any>;
99
+ /**
100
+ * Run a mutation to its commit point and hold it as attempt 1.
101
+ */
102
+ prepare(caller: Caller, reference: any, args: any): Promise<HeldAttempt>;
103
+ apply(id: string): Promise<KernelApply>;
104
+ /**
105
+ * The held attempts, oldest first.
106
+ */
107
+ held(): ReadonlyArray<HeldAttempt>;
108
+ private queryAt;
109
+ private mutationAt;
110
+ private actionAt;
111
+ private execution;
112
+ private runQuery;
113
+ private invokeMutation;
114
+ private runMutation;
115
+ /**
116
+ * Run one attempt of a top-level mutation against the latest commit, then
117
+ * hold it. The commit point is once the function has returned and every
118
+ * syscall it started has settled. A test invocation bound when the mutation
119
+ * was first called reaches each attempt's handler with that attempt's
120
+ * number.
121
+ */
122
+ private prepareMutation;
123
+ /**
124
+ * Validate a held attempt's reads against every commit since its snapshot,
125
+ * then publish its writes or prepare its next attempt. An attempt that wrote
126
+ * nothing publishes nothing and has nothing to validate. It answers its
127
+ * snapshot's version and commit timestamp.
128
+ */
129
+ private applyHeld;
130
+ /**
131
+ * Apply until the mutation publishes, is refused or is exhausted, as the
132
+ * binary retries a mutation that conflicts.
133
+ */
134
+ private publish;
135
+ private runAction;
136
+ private schema;
137
+ private view;
138
+ private generateId;
139
+ syscall(op: string, jsonArgs: string): string;
140
+ /**
141
+ * The binary queues a query's or mutation's async syscalls and runs them one
142
+ * at a time, oldest first (`start_async_syscall` and `run_inner` in
143
+ * `crates/isolate/src/environment/udf/mod.rs`, 1.49). A write and a nested
144
+ * call never share a batch (`AsyncSyscallBatch::can_push` in
145
+ * `async_syscall.rs`), and a nested call holds the queue until it has
146
+ * committed or rolled back its subtransaction (`run_udf` in
147
+ * `async_syscall.rs`). So a caller's write made after its nested call runs
148
+ * after that call, and a nested mutation sees every write made before it. An
149
+ * action's calls run side by side.
150
+ */
151
+ asyncSyscall(op: string, jsonArgs: string): Promise<string>;
152
+ private dispatchAsync;
153
+ jsSyscall(op: string): Promise<never>;
154
+ private get;
155
+ private insert;
156
+ private existing;
157
+ private fields;
158
+ private patch;
159
+ private replace;
160
+ private remove;
161
+ }
162
+ /**
163
+ * Whether `globalThis.Convex` is the kernel's, so no other backend answered.
164
+ */
165
+ export declare const ownsConvexGlobal: () => boolean;
166
+ export {};
167
+ //# sourceMappingURL=Execution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Execution.d.ts","sourceRoot":"","sources":["../../src/internal/Execution.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAA8B,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AAGvE,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,KAAK,OAAO,MAAM,cAAc,CAAC;AAyB7C,KAAK,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AAElD;;;GAGG;AACH,UAAU,SAAS;IACjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,YAAY,GAAG,IAAI,CAAC;IACjD,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC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