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

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 (34) hide show
  1. package/dist/internal/Attempt.d.ts +29 -1
  2. package/dist/internal/Attempt.d.ts.map +1 -1
  3. package/dist/internal/Attempt.js +45 -1
  4. package/dist/internal/Attempt.js.map +1 -1
  5. package/dist/internal/ConvexTest.d.ts +23 -2
  6. package/dist/internal/ConvexTest.d.ts.map +1 -1
  7. package/dist/internal/ConvexTest.js +11 -5
  8. package/dist/internal/ConvexTest.js.map +1 -1
  9. package/dist/internal/Execution.d.ts +43 -0
  10. package/dist/internal/Execution.d.ts.map +1 -1
  11. package/dist/internal/Execution.js +200 -41
  12. package/dist/internal/Execution.js.map +1 -1
  13. package/dist/internal/Invocation.d.ts.map +1 -1
  14. package/dist/internal/Invocation.js.map +1 -1
  15. package/dist/internal/KernelQuery.d.ts +8 -3
  16. package/dist/internal/KernelQuery.d.ts.map +1 -1
  17. package/dist/internal/KernelQuery.js +10 -3
  18. package/dist/internal/KernelQuery.js.map +1 -1
  19. package/dist/internal/Metering.d.ts +186 -0
  20. package/dist/internal/Metering.d.ts.map +1 -0
  21. package/dist/internal/Metering.js +401 -0
  22. package/dist/internal/Metering.js.map +1 -0
  23. package/dist/internal/Subscriptions.d.ts +116 -0
  24. package/dist/internal/Subscriptions.d.ts.map +1 -0
  25. package/dist/internal/Subscriptions.js +186 -0
  26. package/dist/internal/Subscriptions.js.map +1 -0
  27. package/package.json +3 -3
  28. package/src/internal/Attempt.ts +52 -0
  29. package/src/internal/ConvexTest.ts +33 -5
  30. package/src/internal/Execution.ts +375 -54
  31. package/src/internal/Invocation.ts +2 -1
  32. package/src/internal/KernelQuery.ts +17 -6
  33. package/src/internal/Metering.ts +520 -0
  34. package/src/internal/Subscriptions.ts +302 -0
@@ -1,6 +1,7 @@
1
1
  import type { Attempt as AttemptNumber } from "./Invocation.js";
2
2
  import * as Kernel from "./Kernel.js";
3
3
  import type { DocumentId, StoredDocument } from "./KernelValues.js";
4
+ import * as Metering from "./Metering.js";
4
5
  import type * as ReadSet from "./ReadSet.js";
5
6
  /**
6
7
  * One frame of an attempt at a query or mutation: the committed state the
@@ -28,8 +29,29 @@ export declare class KernelAttempt {
28
29
  private readonly overlay;
29
30
  private readonly life;
30
31
  private readonly allReads;
31
- constructor(snapshot: Kernel.State, number?: AttemptNumber, parent?: KernelAttempt | undefined);
32
+ /**
33
+ * The attempt's transaction-limit accounting. A nested mutation's frame
34
+ * meters into its own child, so its writes merge or drop with it while its
35
+ * reads stay.
36
+ */
37
+ readonly meter: Metering.Meter;
38
+ /**
39
+ * Whether the attempt asked for its caller's identity, and the time it read.
40
+ * Every frame of the attempt shares them, as it shares the reads.
41
+ */
42
+ private readonly observed;
43
+ constructor(snapshot: Kernel.State, number?: AttemptNumber, parent?: KernelAttempt | undefined, meter?: Metering.Meter);
32
44
  get reads(): ReadonlyArray<ReadSet.Read>;
45
+ /**
46
+ * Whether the function asked for its caller's identity.
47
+ */
48
+ get observedIdentity(): boolean;
49
+ /**
50
+ * The pinned time the function read, or `null` when it never read the time.
51
+ */
52
+ get observedTime(): number | null;
53
+ observeIdentity(): void;
54
+ observeTime(at: number): void;
33
55
  get closed(): boolean;
34
56
  readDocument(componentPath: string, id: DocumentId): void;
35
57
  /**
@@ -59,6 +81,12 @@ export declare class KernelAttempt {
59
81
  */
60
82
  scan(componentPath: string, tableName: string): Array<StoredDocument>;
61
83
  write(componentPath: string, id: DocumentId, doc: StoredDocument | null): void;
84
+ /**
85
+ * A query run on this attempt's snapshot rather than its pending writes. It
86
+ * reads and meters on its own, and its meter starts with this attempt's
87
+ * scheduling counters, as the binary's snapshot clone does.
88
+ */
89
+ staleSnapshot(): KernelAttempt;
62
90
  /**
63
91
  * A nested mutation begins, in a frame of its own. Dropping a failed one is
64
92
  * forgetting it.
@@ -1 +1 @@
1
- {"version":3,"file":"Attempt.d.ts","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G;IACH,KAAK,SAUJ;IAED;;OAEG;IACH,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAI5B;CACF"}
@@ -1,5 +1,6 @@
1
1
  import { tableNameFromId } from "./KernelValues.js";
2
2
  import { get, rows } from "./Kernel.js";
3
+ import { Meter } from "./Metering.js";
3
4
  import { setImmediate } from "node:timers/promises";
4
5
  //#region src/internal/Attempt.ts
5
6
  /**
@@ -32,15 +33,49 @@ var KernelAttempt = class KernelAttempt {
32
33
  open: true
33
34
  };
34
35
  allReads;
35
- constructor(snapshot, number = 1, parent) {
36
+ /**
37
+ * The attempt's transaction-limit accounting. A nested mutation's frame
38
+ * meters into its own child, so its writes merge or drop with it while its
39
+ * reads stay.
40
+ */
41
+ meter;
42
+ /**
43
+ * Whether the attempt asked for its caller's identity, and the time it read.
44
+ * Every frame of the attempt shares them, as it shares the reads.
45
+ */
46
+ observed;
47
+ constructor(snapshot, number = 1, parent, meter) {
36
48
  this.snapshot = snapshot;
37
49
  this.number = number;
38
50
  this.parent = parent;
39
51
  this.allReads = parent?.allReads ?? [];
52
+ this.meter = meter ?? parent?.meter.child() ?? new Meter();
53
+ this.observed = parent?.observed ?? {
54
+ identity: false,
55
+ time: null
56
+ };
40
57
  }
41
58
  get reads() {
42
59
  return this.allReads;
43
60
  }
61
+ /**
62
+ * Whether the function asked for its caller's identity.
63
+ */
64
+ get observedIdentity() {
65
+ return this.observed.identity;
66
+ }
67
+ /**
68
+ * The pinned time the function read, or `null` when it never read the time.
69
+ */
70
+ get observedTime() {
71
+ return this.observed.time;
72
+ }
73
+ observeIdentity() {
74
+ this.observed.identity = true;
75
+ }
76
+ observeTime(at) {
77
+ this.observed.time = at;
78
+ }
44
79
  get closed() {
45
80
  return !this.life.open;
46
81
  }
@@ -122,6 +157,14 @@ var KernelAttempt = class KernelAttempt {
122
157
  writes.set(id, doc);
123
158
  }
124
159
  /**
160
+ * A query run on this attempt's snapshot rather than its pending writes. It
161
+ * reads and meters on its own, and its meter starts with this attempt's
162
+ * scheduling counters, as the binary's snapshot clone does.
163
+ */
164
+ staleSnapshot() {
165
+ return new KernelAttempt(this.snapshot, this.number, void 0, this.meter.forStaleSnapshot());
166
+ }
167
+ /**
125
168
  * A nested mutation begins, in a frame of its own. Dropping a failed one is
126
169
  * forgetting it.
127
170
  */
@@ -136,6 +179,7 @@ var KernelAttempt = class KernelAttempt {
136
179
  if (this.parent === void 0) throw new Error("The outermost frame of an attempt has no caller.");
137
180
  if (this.life.open) throw new Error("A nested mutation's frame merges only once closed.");
138
181
  for (const [componentPath, writes] of this.overlay) for (const [id, doc] of writes) this.parent.write(componentPath, id, doc);
182
+ this.meter.merge();
139
183
  }
140
184
  /**
141
185
  * The outermost frame's writes, for `Kernel.apply`.
@@ -1 +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, no-restricted-imports -- An attempt's drain waits one real turn of the event loop, which is no deadline. 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;CAMd;CACA;CACQ;CAPnB,0BAAoC,IAAI,IAAI;CAC5C,OAA8B;EAAE,SAAS;EAAG,S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ourcesContent":["// oxlint-disable-next-line effecttsgo/node-builtin-import, no-restricted-imports -- An attempt's drain waits one real turn of the event loop, which is no deadline. 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 * as Metering from \"./Metering.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 * The attempt's transaction-limit accounting. A nested mutation's frame\n * meters into its own child, so its writes merge or drop with it while its\n * reads stay.\n */\n readonly meter: Metering.Meter;\n /**\n * Whether the attempt asked for its caller's identity, and the time it read.\n * Every frame of the attempt shares them, as it shares the reads.\n */\n private readonly observed: { identity: boolean; time: number | null };\n\n constructor(\n readonly snapshot: Kernel.State,\n readonly number: AttemptNumber = 1,\n private readonly parent?: KernelAttempt,\n meter?: Metering.Meter,\n ) {\n this.allReads = parent?.allReads ?? [];\n this.meter = meter ?? parent?.meter.child() ?? new Metering.Meter();\n this.observed = parent?.observed ?? { identity: false, time: null };\n }\n\n get reads(): ReadonlyArray<ReadSet.Read> {\n return this.allReads;\n }\n\n /**\n * Whether the function asked for its caller's identity.\n */\n get observedIdentity(): boolean {\n return this.observed.identity;\n }\n\n /**\n * The pinned time the function read, or `null` when it never read the time.\n */\n get observedTime(): number | null {\n return this.observed.time;\n }\n\n observeIdentity() {\n this.observed.identity = true;\n }\n\n observeTime(at: number) {\n this.observed.time = at;\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 query run on this attempt's snapshot rather than its pending writes. It\n * reads and meters on its own, and its meter starts with this attempt's\n * scheduling counters, as the binary's snapshot clone does.\n */\n staleSnapshot(): KernelAttempt {\n return new KernelAttempt(\n this.snapshot,\n this.number,\n undefined,\n this.meter.forStaleSnapshot(),\n );\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 this.meter.merge();\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}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B;CACF;;;;;CAMA,QAAuB;EACrB,OAAO,IAAI,cAAc,KAAK,UAAU,KAAK,QAAQ,IAAI;CAC3D;;;;;CAMA,QAAQ;EACN,IAAI,KAAK,WAAW,KAAA,GAClB,MAAM,IAAI,MAAM,kDAAkD;EAEpE,IAAI,KAAK,KAAK,MACZ,MAAM,IAAI,MAAM,oDAAoD;EAEtE,KAAK,MAAM,CAAC,eAAe,WAAW,KAAK,SACzC,KAAK,MAAM,CAAC,IAAI,QAAQ,QAAQ,KAAK,OAAO,MAAM,eAAe,IAAI,GAAG;EAC1E,KAAK,MAAM,MAAM;CACnB;;;;CAKA,SAA8B;EAC5B,OAAO,MAAM,KAAK,KAAK,UAAU,CAAC,eAAe,YAC/C,MAAM,KAAK,SAAS,CAAC,IAAI,UAAU;GAAE;GAAe;GAAI;EAAI,EAAE,CAChE,CAAC,CAAC,KAAK;CACT;AACF"}
@@ -1,6 +1,7 @@
1
- import type { GenericSchema, SchemaDefinition } from "convex/server";
1
+ import type { GenericSchema, SchemaDefinition, UserIdentity } from "convex/server";
2
2
  import * as Execution from "./Execution.js";
3
3
  import type * as Kernel from "./Kernel.js";
4
+ import * as Subscriptions from "./Subscriptions.js";
4
5
  import type * as Scheduling from "./Scheduling.js";
5
6
  type Modules = Record<string, () => Promise<any>>;
6
7
  /**
@@ -14,6 +15,24 @@ export interface KernelControls {
14
15
  readonly prepare: (reference: any, args?: any) => Promise<Execution.HeldAttempt>;
15
16
  readonly apply: (id: string) => Promise<Execution.KernelApply>;
16
17
  readonly held: () => ReadonlyArray<Execution.HeldAttempt>;
18
+ readonly withIdentity: (identity: Partial<UserIdentity>) => KernelControls;
19
+ readonly withRequestMetadata: (metadata: {
20
+ readonly ip?: string | null;
21
+ readonly userAgent?: string | null;
22
+ }) => KernelControls;
23
+ /**
24
+ * A client's query set under this accessor's caller.
25
+ */
26
+ readonly subscriber: () => Subscriptions.Subscriber;
27
+ /**
28
+ * Rerun every stale subscription. Lists each one whose value changed.
29
+ */
30
+ readonly refresh: () => Promise<ReadonlyArray<Subscriptions.Transition>>;
31
+ /**
32
+ * Rerun every subscription from scratch. Lists each one whose value differs
33
+ * from the full rerun.
34
+ */
35
+ readonly reference: () => Promise<ReadonlyArray<Subscriptions.Disagreement>>;
17
36
  /**
18
37
  * Move the kernel's clock forward, running each job due on the way at its
19
38
  * deadline.
@@ -54,7 +73,9 @@ export interface RegisterOptions {
54
73
  * it, and `apply` validates and publishes a held attempt. `mutation` applies
55
74
  * each attempt it prepares at once and prepares the next on a conflict, up to
56
75
  * attempt 5. `runtime` supplies the clock and commit timestamps. Scheduled
57
- * functions run on the kernel's clock, never on a host timer.
76
+ * functions run on the kernel's clock, never on a host timer. A subscriber's
77
+ * subscriptions go stale when a commit changes what they read or the identity
78
+ * they read changes, and `refresh` reruns them.
58
79
  */
59
80
  export declare function convexTest(schemaOrOptions?: SchemaDefinition<GenericSchema, boolean> | {
60
81
  readonly schema?: SchemaDefinition<GenericSchema, boolean>;
@@ -1 +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,MAAM,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAEnD,KAAK,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7D,QAAQ,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,IA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;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC3C;AAmDD;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CACxB,eAAe,CAAC,EACZ,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,GACxC;IACE,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC3D,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,aAAa,CAAC;CACzC,EACL,OAAO,CAAC,EAAE,OAAO,GAChB,GAAG,CAoCL"}
@@ -1,19 +1,23 @@
1
1
  import { rowPending } from "./KernelRefusal.js";
2
2
  import { World, anonymous, withIdentity } from "./Execution.js";
3
+ import { Registry } from "./Subscriptions.js";
3
4
  import { componentsGeneric } from "convex/server";
4
5
  //#region src/internal/ConvexTest.ts
5
6
  const isSchemaDefinition = (value) => value !== null && typeof value === "object" && "tables" in value && typeof value.tables === "object";
6
- const accessor = (world, caller) => ({
7
+ const accessor = (world, subscriptions, caller) => ({
7
8
  query: (reference, args) => world.query(caller, reference, args),
8
9
  mutation: (reference, args) => world.mutation(caller, reference, args),
9
10
  action: (reference, args) => world.action(caller, reference, args),
10
11
  prepare: (reference, args) => world.prepare(caller, reference, args),
11
12
  apply: (id) => world.apply(id),
12
13
  held: () => world.held(),
14
+ subscriber: () => subscriptions.subscriber(caller),
15
+ refresh: () => subscriptions.refresh(),
16
+ reference: () => subscriptions.reference(),
13
17
  run: (handler) => world.run(caller, "", handler),
14
18
  runInComponent: (componentPath, handler) => world.run(caller, componentPath, handler),
15
- withIdentity: (identity) => accessor(world, withIdentity(caller, identity)),
16
- withRequestMetadata: (metadata) => accessor(world, {
19
+ withIdentity: (identity) => accessor(world, subscriptions, withIdentity(caller, identity)),
20
+ withRequestMetadata: (metadata) => accessor(world, subscriptions, {
17
21
  ...caller,
18
22
  ip: metadata.ip ?? null,
19
23
  userAgent: metadata.userAgent ?? null
@@ -34,7 +38,9 @@ const accessor = (world, caller) => ({
34
38
  * it, and `apply` validates and publishes a held attempt. `mutation` applies
35
39
  * each attempt it prepares at once and prepares the next on a conflict, up to
36
40
  * attempt 5. `runtime` supplies the clock and commit timestamps. Scheduled
37
- * functions run on the kernel's clock, never on a host timer.
41
+ * functions run on the kernel's clock, never on a host timer. A subscriber's
42
+ * subscriptions go stale when a commit changes what they read or the identity
43
+ * they read changes, and `refresh` reruns them.
38
44
  */
39
45
  function convexTest(schemaOrOptions, modules) {
40
46
  let schema;
@@ -49,7 +55,7 @@ function convexTest(schemaOrOptions, modules) {
49
55
  if (modules === void 0) throw new Error("The test kernel needs the modules map: pass `import.meta.glob(...)` as the second argument.");
50
56
  const world = new World(schema, modules, runtime);
51
57
  return {
52
- ...accessor(world, anonymous),
58
+ ...accessor(world, new Registry(world), anonymous),
53
59
  registerComponent: (componentPath, componentSchema, componentModules, options) => {
54
60
  world.register(componentPath, componentSchema, componentModules, options?.standing);
55
61
  return componentsGeneric()[componentPath];
@@ -1 +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\";\nimport type * as Scheduling from \"./Scheduling.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 * Move the kernel's clock forward, running each job due on the way at its\n * deadline.\n */\n readonly advance: (ms: number) => Promise<void>;\n /**\n * The pending jobs, earliest deadline first.\n */\n readonly jobs: () => ReadonlyArray<Scheduling.Job>;\n /**\n * Run the jobs due now. No future deadline is crossed.\n */\n readonly finishInProgressScheduledFunctions: () => Promise<void>;\n /**\n * Run jobs at their deadlines until only standing jobs remain, or fail with\n * `DrainBudgetExceeded` after `maxIterations` jobs. The kernel keeps its own\n * clock, so it never calls `advanceTimers`.\n */\n readonly finishAllScheduledFunctions: (\n advanceTimers?: () => void,\n maxIterations?: number,\n ) => Promise<void>;\n}\n\n/**\n * How a kit registers a component beyond its schema and modules.\n */\nexport interface RegisterOptions {\n /**\n * The component's functions, as `module:export`, that schedule their own next\n * run, such as the crons component's `public:rescheduler`. A job that runs\n * one, or that one schedules, is never drain work.\n */\n readonly standing?: ReadonlyArray<string>;\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 advance: (ms: number) => world.advance(ms),\n jobs: () => world.jobs(),\n finishInProgressScheduledFunctions: () => world.advance(0),\n finishAllScheduledFunctions: (\n _advanceTimers?: () => void,\n maxIterations?: number,\n ) => world.drain(maxIterations),\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. Scheduled\n * functions run on the kernel's clock, never on a host timer.\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 options?: RegisterOptions,\n ) => {\n world.register(\n componentPath,\n componentSchema,\n componentModules,\n options?.standing,\n );\n return (componentsGeneric() as any)[componentPath];\n },\n };\n}\n"],"mappings":";;;;AA+DA,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,UAAU,OAAe,MAAM,QAAQ,EAAE;CACzC,YAAY,MAAM,KAAK;CACvB,0CAA0C,MAAM,QAAQ,CAAC;CACzD,8BACE,gBACA,kBACG,MAAM,MAAM,aAAa;AAChC;;;;;;;;;;;;AAaA,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,kBACA,YACG;GACH,MAAM,SACJ,eACA,iBACA,kBACA,SAAS,QACX;GACA,OAAQ,kBAAkB,CAAC,CAAS;EACtC;CACF;AACF"}
1
+ {"version":3,"file":"ConvexTest.js","names":["Execution.withIdentity","KernelRefusal.rowPending","Execution.World","Subscriptions.Registry","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\";\nimport * as Subscriptions from \"./Subscriptions.js\";\nimport type * as Scheduling from \"./Scheduling.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 readonly withIdentity: (identity: Partial<UserIdentity>) => KernelControls;\n readonly withRequestMetadata: (metadata: {\n readonly ip?: string | null;\n readonly userAgent?: string | null;\n }) => KernelControls;\n /**\n * A client's query set under this accessor's caller.\n */\n readonly subscriber: () => Subscriptions.Subscriber;\n /**\n * Rerun every stale subscription. Lists each one whose value changed.\n */\n readonly refresh: () => Promise<ReadonlyArray<Subscriptions.Transition>>;\n /**\n * Rerun every subscription from scratch. Lists each one whose value differs\n * from the full rerun.\n */\n readonly reference: () => Promise<ReadonlyArray<Subscriptions.Disagreement>>;\n /**\n * Move the kernel's clock forward, running each job due on the way at its\n * deadline.\n */\n readonly advance: (ms: number) => Promise<void>;\n /**\n * The pending jobs, earliest deadline first.\n */\n readonly jobs: () => ReadonlyArray<Scheduling.Job>;\n /**\n * Run the jobs due now. No future deadline is crossed.\n */\n readonly finishInProgressScheduledFunctions: () => Promise<void>;\n /**\n * Run jobs at their deadlines until only standing jobs remain, or fail with\n * `DrainBudgetExceeded` after `maxIterations` jobs. The kernel keeps its own\n * clock, so it never calls `advanceTimers`.\n */\n readonly finishAllScheduledFunctions: (\n advanceTimers?: () => void,\n maxIterations?: number,\n ) => Promise<void>;\n}\n\n/**\n * How a kit registers a component beyond its schema and modules.\n */\nexport interface RegisterOptions {\n /**\n * The component's functions, as `module:export`, that schedule their own next\n * run, such as the crons component's `public:rescheduler`. A job that runs\n * one, or that one schedules, is never drain work.\n */\n readonly standing?: ReadonlyArray<string>;\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 = (\n world: Execution.World,\n subscriptions: Subscriptions.Registry,\n caller: Execution.Caller,\n): 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 subscriber: () => subscriptions.subscriber(caller),\n refresh: () => subscriptions.refresh(),\n reference: () => subscriptions.reference(),\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, subscriptions, Execution.withIdentity(caller, identity)),\n withRequestMetadata: (metadata: {\n readonly ip?: string | null;\n readonly userAgent?: string | null;\n }) =>\n accessor(world, subscriptions, {\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 advance: (ms: number) => world.advance(ms),\n jobs: () => world.jobs(),\n finishInProgressScheduledFunctions: () => world.advance(0),\n finishAllScheduledFunctions: (\n _advanceTimers?: () => void,\n maxIterations?: number,\n ) => world.drain(maxIterations),\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. Scheduled\n * functions run on the kernel's clock, never on a host timer. A subscriber's\n * subscriptions go stale when a commit changes what they read or the identity\n * they read changes, and `refresh` reruns them.\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, new Subscriptions.Registry(world), Execution.anonymous),\n registerComponent: (\n componentPath: string,\n componentSchema: SchemaDefinition<GenericSchema, boolean>,\n componentModules: Modules,\n options?: RegisterOptions,\n ) => {\n world.register(\n componentPath,\n componentSchema,\n componentModules,\n options?.standing,\n );\n return (componentsGeneric() as any)[componentPath];\n },\n };\n}\n"],"mappings":";;;;;AAkFA,MAAM,sBACJ,UAEA,UAAU,QACV,OAAO,UAAU,YACjB,YAAY,SACZ,OAAQ,MAA8B,WAAW;AAEnD,MAAM,YACJ,OACA,eACA,YACS;CACT,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,kBAAkB,cAAc,WAAW,MAAM;CACjD,eAAe,cAAc,QAAQ;CACrC,iBAAiB,cAAc,UAAU;CACzC,MAAM,YAA+B,MAAM,IAAI,QAAQ,IAAI,OAAO;CAClE,iBAAiB,eAAuB,YACtC,MAAM,IAAI,QAAQ,eAAe,OAAO;CAC1C,eAAe,aACb,SAAS,OAAO,eAAeA,aAAuB,QAAQ,QAAQ,CAAC;CACzE,sBAAsB,aAIpB,SAAS,OAAO,eAAe;EAC7B,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,UAAU,OAAe,MAAM,QAAQ,EAAE;CACzC,YAAY,MAAM,KAAK;CACvB,0CAA0C,MAAM,QAAQ,CAAC;CACzD,8BACE,gBACA,kBACG,MAAM,MAAM,aAAa;AAChC;;;;;;;;;;;;;;AAeA,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,OAAO,IAAIC,SAAuB,KAAK,GAAGC,SAAmB;EACzE,oBACE,eACA,iBACA,kBACA,YACG;GACH,MAAM,SACJ,eACA,iBACA,kBACA,SAAS,QACX;GACA,OAAQ,kBAAkB,CAAC,CAAS;EACtC;CACF;AACF"}
@@ -75,6 +75,26 @@ export type KernelApply = {
75
75
  readonly tag: string;
76
76
  readonly error: unknown;
77
77
  };
78
+ /**
79
+ * One top-level query run and every dependency it took: the commit and reads it
80
+ * read, whether it asked for the caller's identity, the pinned time it read and
81
+ * the end of its paginated read.
82
+ */
83
+ export interface QueryRun {
84
+ readonly outcome: Outcome;
85
+ readonly snapshot: Kernel.Version;
86
+ readonly reads: ReadonlyArray<ReadSet.Read>;
87
+ readonly observedIdentity: boolean;
88
+ /**
89
+ * The pinned time the query read, or `null` when it never read the time.
90
+ */
91
+ readonly time: number | null;
92
+ /**
93
+ * Where the query's paginated read ended, or `null` when it ran none. A rerun
94
+ * ends its page there, as the binary's query journal does.
95
+ */
96
+ readonly journal: string | null;
97
+ }
78
98
  /**
79
99
  * A test backend: its registered components and the kernel state they share.
80
100
  */
@@ -126,6 +146,16 @@ export declare class World {
126
146
  * The held attempts, oldest first.
127
147
  */
128
148
  held(): ReadonlyArray<HeldAttempt>;
149
+ /**
150
+ * Run a query at the latest commit as a subscription runs it, under `caller`,
151
+ * and return its answer with every dependency it took. `time` pins the time
152
+ * it reads, the kernel's time now by default. `journal` ends its paginated
153
+ * read where an earlier run's ended.
154
+ */
155
+ subscribed(caller: Caller, reference: any, args: any, pinned: {
156
+ readonly time?: number;
157
+ readonly journal: string | null;
158
+ }): Promise<QueryRun>;
129
159
  /**
130
160
  * The committed pending jobs, earliest deadline first.
131
161
  */
@@ -209,6 +239,19 @@ export declare class World {
209
239
  private runAction;
210
240
  private schema;
211
241
  private view;
242
+ /**
243
+ * Read one document by ID, as the binary's `get_inner` does for a get and for
244
+ * the document a patch, replace, delete or cancel changes: it reads the ID's
245
+ * interval of the table's `by_id` index, then charges the document if there
246
+ * is one (`crates/database/src/transaction.rs:1188-1250`).
247
+ */
248
+ private readById;
249
+ /**
250
+ * Stage a write to a user table, counted against the execution's limits
251
+ * first. A write over a limit is not staged (`Writes::update`,
252
+ * `crates/database/src/writes.rs:241-310`).
253
+ */
254
+ private stage;
212
255
  private generateId;
213
256
  syscall(op: string, jsonArgs: string): string;
214
257
  /**
@@ -1 +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,MAA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