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

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 (36) hide show
  1. package/dist/TestConfect.d.ts +26 -0
  2. package/dist/TestConfect.d.ts.map +1 -1
  3. package/dist/TestConfect.js +9 -1
  4. package/dist/TestConfect.js.map +1 -1
  5. package/dist/internal/ConvexTest.d.ts +26 -1
  6. package/dist/internal/ConvexTest.d.ts.map +1 -1
  7. package/dist/internal/ConvexTest.js +55 -27
  8. package/dist/internal/ConvexTest.js.map +1 -1
  9. package/dist/internal/Execution.d.ts +138 -1
  10. package/dist/internal/Execution.d.ts.map +1 -1
  11. package/dist/internal/Execution.js +595 -182
  12. package/dist/internal/Execution.js.map +1 -1
  13. package/dist/internal/KernelRefusal.d.ts +134 -0
  14. package/dist/internal/KernelRefusal.d.ts.map +1 -1
  15. package/dist/internal/KernelRefusal.js +134 -1
  16. package/dist/internal/KernelRefusal.js.map +1 -1
  17. package/dist/internal/Redaction.d.ts +142 -0
  18. package/dist/internal/Redaction.d.ts.map +1 -0
  19. package/dist/internal/Redaction.js +448 -0
  20. package/dist/internal/Redaction.js.map +1 -0
  21. package/dist/internal/Snapshot.d.ts +298 -0
  22. package/dist/internal/Snapshot.d.ts.map +1 -0
  23. package/dist/internal/Snapshot.js +532 -0
  24. package/dist/internal/Snapshot.js.map +1 -0
  25. package/dist/internal/Subscriptions.d.ts +13 -0
  26. package/dist/internal/Subscriptions.d.ts.map +1 -1
  27. package/dist/internal/Subscriptions.js +27 -3
  28. package/dist/internal/Subscriptions.js.map +1 -1
  29. package/package.json +3 -3
  30. package/src/TestConfect.ts +63 -4
  31. package/src/internal/ConvexTest.ts +135 -38
  32. package/src/internal/Execution.ts +886 -287
  33. package/src/internal/KernelRefusal.ts +160 -0
  34. package/src/internal/Redaction.ts +730 -0
  35. package/src/internal/Snapshot.ts +945 -0
  36. package/src/internal/Subscriptions.ts +34 -4
@@ -136,12 +136,14 @@ interface Live {
136
136
  * `authenticate` replaces, bumping the identity version.
137
137
  */
138
138
  export class Subscriber {
139
- private version = 0;
139
+ private version: number;
140
140
 
141
141
  constructor(
142
142
  private readonly registry: Registry,
143
143
  private who: Execution.Caller,
144
- ) {}
144
+ ) {
145
+ this.version = registry.identityEpoch();
146
+ }
145
147
 
146
148
  get caller(): Execution.Caller {
147
149
  return this.who;
@@ -164,7 +166,7 @@ export class Subscriber {
164
166
  identity === null
165
167
  ? { ...this.who, identity: null, token: null }
166
168
  : Execution.withIdentity(this.who, identity);
167
- this.version++;
169
+ this.version = this.registry.nextIdentityEpoch();
168
170
  }
169
171
  }
170
172
 
@@ -180,9 +182,32 @@ export class Registry {
180
182
  constructor(private readonly world: Execution.World) {}
181
183
 
182
184
  subscriber(caller: Execution.Caller): Subscriber {
185
+ this.world.registerSubscriber();
183
186
  return new Subscriber(this, caller);
184
187
  }
185
188
 
189
+ /**
190
+ * The reference a live subscription runs, for marking its diffs by the shape
191
+ * of what its query returns.
192
+ */
193
+ referenceOf(subscription: string): unknown {
194
+ return this.live.get(subscription)?.reference;
195
+ }
196
+
197
+ /**
198
+ * The world's identity epoch, where a new subscriber's version starts.
199
+ */
200
+ identityEpoch(): number {
201
+ return this.world.currentIdentityEpoch();
202
+ }
203
+
204
+ /**
205
+ * Advance the world's identity epoch for a subscriber whose identity changed.
206
+ */
207
+ nextIdentityEpoch(): number {
208
+ return this.world.nextIdentityEpoch();
209
+ }
210
+
186
211
  subscribe(
187
212
  subscriber: Subscriber,
188
213
  reference: unknown,
@@ -200,7 +225,12 @@ export class Registry {
200
225
  this.live.set(live.id, live);
201
226
  return {
202
227
  id: live.id,
203
- current: () => live.run,
228
+ // The run's value is the client's own, so it stays raw. Its read
229
+ // records are the kernel's, so they leave projected.
230
+ current: () => ({
231
+ ...live.run,
232
+ reads: this.world.projectReads(live.run.reads),
233
+ }),
204
234
  unsubscribe: () => {
205
235
  this.live.delete(live.id);
206
236
  },