nowity 1.5.0 → 1.7.0

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 (56) hide show
  1. package/README.md +81 -0
  2. package/dist/api/contract.d.ts +11 -0
  3. package/dist/api/contract.d.ts.map +1 -1
  4. package/dist/api/contract.js +5 -1
  5. package/dist/client/confirmed-store.d.ts +2 -11
  6. package/dist/client/confirmed-store.d.ts.map +1 -1
  7. package/dist/client/confirmed-store.js +5 -0
  8. package/dist/client/connection.d.ts.map +1 -1
  9. package/dist/client/connection.js +3 -1
  10. package/dist/client/nowity-client.d.ts +125 -2
  11. package/dist/client/nowity-client.d.ts.map +1 -1
  12. package/dist/client/nowity-client.js +252 -16
  13. package/dist/client/overlay.d.ts +2 -0
  14. package/dist/client/overlay.d.ts.map +1 -1
  15. package/dist/client/overlay.js +4 -0
  16. package/dist/client.d.ts +2 -1
  17. package/dist/client.d.ts.map +1 -1
  18. package/dist/client.js +10 -1
  19. package/dist/core/derived.d.ts +96 -0
  20. package/dist/core/derived.d.ts.map +1 -0
  21. package/dist/core/derived.js +127 -0
  22. package/dist/core/protocol.d.ts +23 -1
  23. package/dist/core/protocol.d.ts.map +1 -1
  24. package/dist/index.d.ts +2 -0
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +3 -1
  27. package/dist/server/api/bridge.d.ts +8 -0
  28. package/dist/server/api/bridge.d.ts.map +1 -1
  29. package/dist/server/api/bridge.js +20 -1
  30. package/dist/server/api/configure.d.ts.map +1 -1
  31. package/dist/server/api/configure.js +1 -0
  32. package/dist/server/api/derived.d.ts +143 -0
  33. package/dist/server/api/derived.d.ts.map +1 -0
  34. package/dist/server/api/derived.js +377 -0
  35. package/dist/server/api/execution.d.ts +6 -0
  36. package/dist/server/api/execution.d.ts.map +1 -1
  37. package/dist/server/api/execution.js +1 -0
  38. package/dist/server/api/read-keys.d.ts +20 -0
  39. package/dist/server/api/read-keys.d.ts.map +1 -1
  40. package/dist/server/api/read-keys.js +103 -0
  41. package/dist/server/api/runtime.d.ts +10 -0
  42. package/dist/server/api/runtime.d.ts.map +1 -1
  43. package/dist/server/api/runtime.js +1 -0
  44. package/dist/server/api/tracked-client.d.ts.map +1 -1
  45. package/dist/server/api/tracked-client.js +9 -0
  46. package/dist/server/evaluate.d.ts +2 -0
  47. package/dist/server/evaluate.d.ts.map +1 -1
  48. package/dist/server/evaluate.js +1 -0
  49. package/dist/server/mutator.d.ts +2 -0
  50. package/dist/server/mutator.d.ts.map +1 -1
  51. package/dist/server/query.d.ts +6 -0
  52. package/dist/server/query.d.ts.map +1 -1
  53. package/dist/server/sync-engine.d.ts +21 -0
  54. package/dist/server/sync-engine.d.ts.map +1 -1
  55. package/dist/server/sync-engine.js +74 -1
  56. package/package.json +1 -1
@@ -1,12 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NowityClient = void 0;
3
+ exports.NowityClient = exports.ConnectionLostError = exports.StrictOptimisticError = void 0;
4
4
  exports.subscriptionKey = subscriptionKey;
5
5
  const mobx_1 = require("mobx");
6
+ const derived_1 = require("../core/derived");
6
7
  const protocol_1 = require("../core/protocol");
7
8
  const confirmed_store_1 = require("./confirmed-store");
8
9
  const live_query_1 = require("./live-query");
9
10
  const overlay_1 = require("./overlay");
11
+ /** Thrown in strict mode by a mutation the client has no answer for. */
12
+ class StrictOptimisticError extends Error {
13
+ constructor(mutation) {
14
+ super(`Mutation "${mutation}" was called without an optimistic effect ` +
15
+ `(strictOptimistic is on). Register a client mutator for it — ` +
16
+ `{ name: "${mutation}", local(args, tx) { ... } } — or, if it ` +
17
+ `must wait for the server, declare it so: ` +
18
+ `{ name: "${mutation}", pessimistic: "<why>" }.`);
19
+ this.mutation = mutation;
20
+ this.name = "StrictOptimisticError";
21
+ }
22
+ }
23
+ exports.StrictOptimisticError = StrictOptimisticError;
24
+ /**
25
+ * A mutation that was waiting when the connection dropped, in `onDisconnect:
26
+ * "drop"` mode. It may or may not have reached the server; the data that
27
+ * arrives after the reconnect says which, and nothing resends it.
28
+ */
29
+ class ConnectionLostError extends Error {
30
+ constructor(mutation) {
31
+ super(`The connection dropped before "${mutation}" was confirmed. It was not resent.`);
32
+ this.mutation = mutation;
33
+ this.name = "ConnectionLostError";
34
+ }
35
+ }
36
+ exports.ConnectionLostError = ConnectionLostError;
10
37
  /** Shared empty result, so a query with no local inserts allocates nothing. */
11
38
  const EMPTY_IDS = [];
12
39
  /**
@@ -46,6 +73,12 @@ class NowityClient {
46
73
  * a row under "undefined" and turns its first patch into a fragment.
47
74
  */
48
75
  this.sentIdFields = new Map();
76
+ /** Derived mutators per subscription, by mutation name. */
77
+ this.derivedBySub = new Map();
78
+ /** Derived mutators the server's data contradicted; never used again here. */
79
+ this.derivedFallback = new Set();
80
+ /** Mutations the server declared `dedupe`. */
81
+ this.dedupe = new Set();
49
82
  this.pending = [];
50
83
  /**
51
84
  * Who is waiting for each mutation's answer. Separate from {@link pending}:
@@ -76,6 +109,8 @@ class NowityClient {
76
109
  this.reconnectTimer = null;
77
110
  this.intentionalClose = false;
78
111
  this.connected = false;
112
+ /** The current connection has been welcomed (its numbering is known). */
113
+ this.welcomed = false;
79
114
  this.everWelcomed = false;
80
115
  /** What this connection says it is looking at; resent after every reconnect. */
81
116
  this.context = null;
@@ -83,12 +118,32 @@ class NowityClient {
83
118
  this.rebase = (0, mobx_1.action)(() => {
84
119
  this.pendingBox.set(this.pending.length > 0);
85
120
  const overlay = new overlay_1.Overlay(this.confirmed, (entity) => this.idFieldOf(entity));
86
- for (const mutation of this.pending) {
121
+ for (const mutation of this.optimisticOn ? this.pending : []) {
87
122
  const def = this.mutators.get(mutation.name);
88
- if (!def)
89
- continue;
90
123
  try {
91
- def.local(mutation.args, overlay.tx());
124
+ if (def?.local) {
125
+ def.local(mutation.args, overlay.tx());
126
+ continue;
127
+ }
128
+ const derived = this.derivedOf(mutation.name);
129
+ if (!derived)
130
+ continue;
131
+ (0, derived_1.applyDerived)(derived, mutation.args, {
132
+ get: (entity, id) => overlay.get(entity, id),
133
+ stage: (entity, id, row) => overlay.write(entity, id, row),
134
+ // Per query instance: a row may change only if every
135
+ // subscription holding it was sent this mutator.
136
+ allows: (entity, id) => {
137
+ const holders = this.confirmed.holders(entity, id);
138
+ if (holders.size === 0)
139
+ return false;
140
+ for (const subId of holders) {
141
+ if (!this.derivedBySub.get(subId)?.has(mutation.name))
142
+ return false;
143
+ }
144
+ return true;
145
+ },
146
+ });
92
147
  }
93
148
  catch (err) {
94
149
  this.onError(err);
@@ -102,7 +157,12 @@ class NowityClient {
102
157
  this.opts = opts;
103
158
  this.onError = opts.onError ?? ((err) => console.error("[nowity/client]", err));
104
159
  this.context = opts.context ?? null;
160
+ this.strictOptimistic = opts.strictOptimistic ?? strictFromEnv();
161
+ this.optimisticOn = opts.optimistic ?? true;
105
162
  for (const mutator of opts.mutators ?? []) {
163
+ if (mutator.local === undefined && !mutator.pessimistic?.trim()) {
164
+ throw new Error(`Client mutator "${mutator.name}" has neither local() nor a pessimistic reason.`);
165
+ }
106
166
  this.mutators.set(mutator.name, mutator);
107
167
  }
108
168
  }
@@ -169,7 +229,10 @@ class NowityClient {
169
229
  }
170
230
  handleClose() {
171
231
  this.connected = false;
232
+ this.welcomed = false;
172
233
  (0, mobx_1.runInAction)(() => this.status.set(this.intentionalClose ? "idle" : "disconnected"));
234
+ if (this.opts.onDisconnect === "drop")
235
+ this.dropPending();
173
236
  if (this.intentionalClose)
174
237
  return;
175
238
  // Not "wrong", but possibly no longer current — the UI can dim it.
@@ -193,6 +256,21 @@ class NowityClient {
193
256
  send(message) {
194
257
  this.opts.transport.send(message);
195
258
  }
259
+ /**
260
+ * Forget every unconfirmed mutation: the connection they were bound to is
261
+ * gone. Their effect leaves the overlay now; whatever of it the server did
262
+ * apply comes back with the data after the reconnect.
263
+ */
264
+ dropPending() {
265
+ const callers = [...this.callers];
266
+ this.callers.clear();
267
+ (0, mobx_1.runInAction)(() => {
268
+ this.pending = [];
269
+ this.rebase();
270
+ });
271
+ for (const [, caller] of callers)
272
+ caller.reject(new ConnectionLostError(caller.name));
273
+ }
196
274
  // --------------------------------------------------------------- subscriptions
197
275
  /**
198
276
  * Seed the store with data rendered on the server (`readInitialData`).
@@ -257,6 +335,7 @@ class NowityClient {
257
335
  if (!sub)
258
336
  return;
259
337
  this.subs.delete(subId);
338
+ this.derivedBySub.delete(subId);
260
339
  this.send({ t: "unsubscribe", subId });
261
340
  this.resolveResync(subId);
262
341
  (0, mobx_1.runInAction)(() => {
@@ -272,17 +351,72 @@ class NowityClient {
272
351
  * endpoint returned. It rejects if the mutation was refused — by then the
273
352
  * optimistic effect is already undone.
274
353
  */
275
- mutate(name, args) {
354
+ mutate(name, args, callSite) {
276
355
  // A mutation with no local counterpart is legal: it simply has no
277
356
  // optimistic effect and lands when the server confirms it. Refusing it
278
- // here would make every write opt into optimism, which is backwards.
357
+ // here would make every write opt into optimism, which is backwards —
358
+ // unless a test asked for exactly that.
359
+ if (this.strictOptimistic && !this.mutators.has(name)) {
360
+ const error = new StrictOptimisticError(name);
361
+ // The stack of the caller, not of this frame: the proxy awaits the
362
+ // handshake before it gets here, which cuts the click off the stack.
363
+ if (callSite?.stack) {
364
+ error.stack = `${error.name}: ${error.message}\n${callSite.stack.split("\n").slice(1).join("\n")}`;
365
+ }
366
+ const report = globalThis.reportError;
367
+ if (typeof report === "function")
368
+ report(error);
369
+ else
370
+ this.onError(error);
371
+ return Promise.reject(error);
372
+ }
373
+ if (this.opts.onDisconnect === "drop" && this.everWelcomed && !this.welcomed) {
374
+ // Bound to a connection there is none of — or one that has not said
375
+ // yet where the numbering stands, which would number this call
376
+ // after mutations the server never received. Queued, it would go
377
+ // out after the reconnect: the resend this mode exists not to do.
378
+ return Promise.reject(new ConnectionLostError(name));
379
+ }
380
+ const dedupeKey = this.dedupe.has(name) ? subscriptionKey(name, args) : undefined;
381
+ if (dedupeKey !== undefined) {
382
+ for (const caller of this.callers.values()) {
383
+ if (caller.dedupeKey === dedupeKey && caller.promise)
384
+ return caller.promise;
385
+ }
386
+ }
279
387
  const mutationId = ++this.lastMutationId;
280
- return new Promise((resolve, reject) => {
281
- this.callers.set(mutationId, { resolve: resolve, reject });
282
- this.pending.push({ mutationId, name, args });
283
- (0, mobx_1.runInAction)(() => this.rebase());
284
- this.send({ t: "mutate", mutationId, name, args });
388
+ const caller = { resolve: () => { }, reject: () => { }, name, dedupeKey };
389
+ const promise = new Promise((resolve, reject) => {
390
+ caller.resolve = resolve;
391
+ caller.reject = reject;
285
392
  });
393
+ caller.promise = promise;
394
+ this.callers.set(mutationId, caller);
395
+ this.pending.push({ mutationId, name, args });
396
+ (0, mobx_1.runInAction)(() => this.rebase());
397
+ this.send({ t: "mutate", mutationId, name, args });
398
+ return promise;
399
+ }
400
+ /** See {@link NowityClientOptions.optimistic}. Takes effect immediately. */
401
+ get optimistic() {
402
+ return this.optimisticOn;
403
+ }
404
+ setOptimistic(on) {
405
+ if (this.optimisticOn === on)
406
+ return;
407
+ this.optimisticOn = on;
408
+ (0, mobx_1.runInAction)(() => this.rebase());
409
+ }
410
+ /**
411
+ * Whether something called here is not confirmed yet — observable, for a
412
+ * UI that marks an action as still in flight.
413
+ */
414
+ get hasPendingMutations() {
415
+ return this.pendingBox.get();
416
+ }
417
+ /** The derived mutators a subscription holds, for diagnostics and tests. */
418
+ derivedMutatorsOf(subId) {
419
+ return [...(this.derivedBySub.get(subId)?.values() ?? [])];
286
420
  }
287
421
  // -------------------------------------------------------------------- messages
288
422
  handleMessage(message) {
@@ -306,10 +440,17 @@ class NowityClient {
306
440
  for (const patch of message.patches) {
307
441
  this.applyPatch(patch);
308
442
  }
443
+ this.applyMutators(message.mutators);
309
444
  this.ackThrough(message.lastMutationId);
310
445
  this.rebase();
311
446
  });
312
447
  break;
448
+ case "mutators":
449
+ (0, mobx_1.runInAction)(() => {
450
+ this.applyMutators(message.subs);
451
+ this.rebase();
452
+ });
453
+ break;
313
454
  case "mutation-result":
314
455
  this.handleMutationResult(message.mutationId, message.ok, message.error, message.value);
315
456
  break;
@@ -324,6 +465,8 @@ class NowityClient {
324
465
  }
325
466
  handleWelcome(message) {
326
467
  const serverLastMutationId = message.lastMutationId;
468
+ this.welcomed = true;
469
+ this.dedupe = new Set((message.api?.contracts ?? []).flatMap((contract) => contract.endpoints.filter((e) => e.dedupe).map((e) => `${contract.name}.${e.method}`)));
327
470
  if (message.api?.entities) {
328
471
  this.serverEntities = message.api.entities;
329
472
  }
@@ -335,8 +478,14 @@ class NowityClient {
335
478
  (0, mobx_1.runInAction)(() => {
336
479
  // Mutation ids must keep climbing across reconnects, otherwise the
337
480
  // server sees a gap (or a replay) and rejects the numbering.
338
- this.lastMutationId = Math.max(this.lastMutationId, serverLastMutationId);
339
- this.ackThrough(serverLastMutationId);
481
+ // Dropping mode has nothing queued to keep numbering for, and its
482
+ // last numbers may never have reached the server: continue from
483
+ // the server's, or the next mutation would leave a gap.
484
+ this.lastMutationId =
485
+ this.opts.onDisconnect === "drop"
486
+ ? serverLastMutationId
487
+ : Math.max(this.lastMutationId, serverLastMutationId);
488
+ this.ackThrough(serverLastMutationId, false);
340
489
  this.rebase();
341
490
  });
342
491
  // A mutation already out of the queue is not re-sent, so its result —
@@ -402,8 +551,22 @@ class NowityClient {
402
551
  sub.filter.set(snapshot.filter);
403
552
  sub.status.set("ready");
404
553
  sub.error.set(null);
554
+ this.setDerived(snapshot.subId, snapshot.mutators ?? []);
405
555
  this.resolveResync(snapshot.subId);
406
556
  }
557
+ applyMutators(subs) {
558
+ for (const { subId, mutators } of subs ?? []) {
559
+ if (this.subs.has(subId))
560
+ this.setDerived(subId, mutators);
561
+ }
562
+ }
563
+ setDerived(subId, mutators) {
564
+ if (mutators.length === 0) {
565
+ this.derivedBySub.delete(subId);
566
+ return;
567
+ }
568
+ this.derivedBySub.set(subId, new Map(mutators.map((m) => [m.name, m])));
569
+ }
407
570
  applyPatch(patch) {
408
571
  const sub = this.subs.get(patch.subId);
409
572
  if (!sub)
@@ -435,6 +598,7 @@ class NowityClient {
435
598
  // Never wait for the server to say which rows to delete — drop the whole
436
599
  // slice of the store the subscription was responsible for.
437
600
  this.confirmed.releaseSub(subId);
601
+ this.derivedBySub.delete(subId);
438
602
  sub.ids.clear();
439
603
  sub.status.set("revoked");
440
604
  sub.error.set(reason);
@@ -481,8 +645,10 @@ class NowityClient {
481
645
  return;
482
646
  const deferred = this.deferredAck;
483
647
  this.deferredAck = -1;
648
+ // Not checked: after an outage an acknowledged number may belong to a
649
+ // mutation the server refused, its result lost with the old socket.
484
650
  if (deferred >= 0)
485
- this.ackThrough(deferred);
651
+ this.ackThrough(deferred, false);
486
652
  }
487
653
  /**
488
654
  * Forget mutations whose effect is already contained in confirmed data.
@@ -492,14 +658,79 @@ class NowityClient {
492
658
  * would make the UI fall back to the pre-mutation value until the snapshot
493
659
  * arrives — the same flicker the whole rebase mechanism exists to prevent.
494
660
  */
495
- ackThrough(lastMutationId) {
661
+ ackThrough(lastMutationId, check = true) {
496
662
  if (this.resyncPending.size > 0) {
497
663
  this.deferredAck = Math.max(this.deferredAck, lastMutationId);
498
664
  return;
499
665
  }
500
666
  if (this.pending.length === 0)
501
667
  return;
668
+ const acked = this.pending.filter((mutation) => mutation.mutationId <= lastMutationId);
669
+ if (acked.length === 0)
670
+ return;
502
671
  this.pending = this.pending.filter((mutation) => mutation.mutationId > lastMutationId);
672
+ if (check)
673
+ this.checkDerived(acked);
674
+ }
675
+ /**
676
+ * Compare what derived mutators predicted with what the server confirmed.
677
+ *
678
+ * The confirmed store already holds data that includes these mutations, so
679
+ * every value a derived mutator replaced must be there — unless a later
680
+ * mutation, still pending, writes the same field. A difference means the
681
+ * fingerprint was wrong (a value it took for a constant was computed, a
682
+ * write it took for unconditional was not), or that someone else wrote the
683
+ * same field in between: either way this client stops predicting it.
684
+ */
685
+ checkDerived(acked) {
686
+ if (!this.optimisticOn)
687
+ return;
688
+ const promised = new Map();
689
+ for (const mutation of acked) {
690
+ const derived = this.derivedOf(mutation.name);
691
+ if (!derived)
692
+ continue;
693
+ for (const p of (0, derived_1.derivedPredictions)(derived, mutation.args)) {
694
+ promised.set(`${p.entity}\u0000${p.id}\u0000${p.field}`, { name: mutation.name, ...p });
695
+ }
696
+ }
697
+ if (promised.size === 0)
698
+ return;
699
+ for (const mutation of this.pending) {
700
+ const derived = this.derivedOf(mutation.name);
701
+ if (!derived)
702
+ continue;
703
+ for (const p of (0, derived_1.derivedPredictions)(derived, mutation.args)) {
704
+ promised.delete(`${p.entity}\u0000${p.id}\u0000${p.field}`);
705
+ }
706
+ }
707
+ const contradicted = new Set();
708
+ for (const p of promised.values()) {
709
+ const row = this.confirmed.get(p.entity, p.id);
710
+ if (!row || !(p.field in row))
711
+ continue;
712
+ if (!(0, derived_1.sameValue)(row[p.field], p.value))
713
+ contradicted.add(p.name);
714
+ }
715
+ for (const name of contradicted) {
716
+ this.derivedFallback.add(name);
717
+ this.opts.onDerivedMismatch?.(name);
718
+ }
719
+ }
720
+ /**
721
+ * The derived mutator for a mutation, unless a hand-written one exists —
722
+ * `local()` and a declared `pessimistic` reason both win — or the server's
723
+ * data has contradicted it.
724
+ */
725
+ derivedOf(name) {
726
+ if (this.mutators.has(name) || this.derivedFallback.has(name))
727
+ return undefined;
728
+ for (const bySub of this.derivedBySub.values()) {
729
+ const derived = bySub.get(name);
730
+ if (derived)
731
+ return derived;
732
+ }
733
+ return undefined;
503
734
  }
504
735
  // --------------------------------------------------------------- MobX identity
505
736
  /** Observable identity map of an entity: id → live object. */
@@ -632,3 +863,8 @@ function stableStringify(value) {
632
863
  .map((key) => `${JSON.stringify(key)}:${stableStringify(value[key])}`);
633
864
  return `{${entries.join(",")}}`;
634
865
  }
866
+ function strictFromEnv() {
867
+ // No `process` in a browser bundle, and a bundler may define it partially.
868
+ const env = globalThis.process?.env;
869
+ return env?.NOWITY_STRICT_OPTIMISTIC === "1";
870
+ }
@@ -89,6 +89,8 @@ export declare class Overlay {
89
89
  entities(): string[];
90
90
  /** Confirmed rows with pending changes applied. */
91
91
  merged(entity: string): Map<EntityId, Row>;
92
+ /** Stage a whole row (or its removal) — the write a derived mutator makes. */
93
+ write(entity: string, id: EntityId, row: Row | null): void;
92
94
  private stage;
93
95
  }
94
96
  //# sourceMappingURL=overlay.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/client/overlay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;;;;;;GASG;AACH,MAAM,WAAW,aAAa;CAAG;AAEjC;;;;;;;GAOG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC;AAE3C,sDAAsD;AACtD,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG;IACzC,oFAAoF;IACpF,GAAG,CAAC,EAAE,EAAE,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IACxC,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAClB,8EAA8E;IAC9E,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC9B;AAED,gDAAgD;AAChD,MAAM,WAAW,OAAO;IACpB,wEAAwE;IACxE,EAAE,CAAC,CAAC,SAAS,MAAM,aAAa,EAAE,MAAM,EAAE,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IAC/E,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACrD,+CAA+C;IAC/C,GAAG,CAAC,MAAM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CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;IACpC,kDAAkD;IAClD,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC9C;AAED;;;;;;;;GAQG;AACH,qBAAa,OAAO;IAIZ,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAJ9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgD;gBAGnD,SAAS,EAAE,cAAc,EACzB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM;IAG1D,EAAE,IAAI,OAAO;IAkBb,OAAO,CAAC,QAAQ;IAShB;;;;;OAKG;IACH,OAAO,CAAC,KAAK;IA2Bb,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,GAAG,GAAG,GAAG,SAAS;IAMlD;;;;;;;OAOG;IACH,QAAQ,IAAI,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC;IAYnC,yEAAyE;IACzE,QAAQ,IAAI,MAAM,EAAE;IAIpB,mDAAmD;IACnD,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC;IAY1C,8EAA8E;IAC9E,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;IAI1D,OAAO,CAAC,KAAK;CAQhB"}
@@ -121,6 +121,10 @@ class Overlay {
121
121
  }
122
122
  return out;
123
123
  }
124
+ /** Stage a whole row (or its removal) — the write a derived mutator makes. */
125
+ write(entity, id, row) {
126
+ this.stage(entity, id, row === null ? null : { ...row });
127
+ }
124
128
  stage(entity, id, row) {
125
129
  let staged = this.changes.get(entity);
126
130
  if (!staged) {
package/dist/client.d.ts CHANGED
@@ -37,11 +37,12 @@ export type { QueryEntry, QueryError, QuerySource } from "./client/query-source"
37
37
  * bundle, so an application that wants the change on screen before the server
38
38
  * has answered states its effect here.
39
39
  */
40
- export type { ClientMutatorDef } from "./client/nowity-client";
40
+ export { ConnectionLostError, StrictOptimisticError, type ClientMutatorDef, type OptimisticMutatorDef, type PessimisticMutatorDef, } from "./client/nowity-client";
41
41
  export type { Draft, EntityTx, LocalEntities, LocalTx } from "./client/overlay";
42
42
  export { WebSocketTransport, type WebSocketTransportOptions } from "./client/ws-transport";
43
43
  export { configureNowityClient, type NowityClientContainerConfig } from "./ironbean/client";
44
44
  export { NowityClientToken } from "./ironbean/tokens";
45
45
  export type { EntityId, Row } from "./core/types";
46
46
  export type { HydrationPayload } from "./core/protocol";
47
+ export type { DerivedMutator, DerivedValue, DerivedWrite } from "./core/derived";
47
48
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EACH,GAAG,EACH,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,SAAS,EACT,UAAU,EACV,aAAa,EACb,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,YAAY,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAQ5E,OAAO,EACH,QAAQ,EACR,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,WAAW,EACX,cAAc;AACd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AY,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/client.js CHANGED
@@ -21,7 +21,7 @@
21
21
  * load this module at all.
22
22
  */
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.NowityClientToken = exports.configureNowityClient = exports.WebSocketTransport = exports.currentConnection = exports.activeConnection = exports.NowityConnection = exports.Restricted = exports.useQuerySource = exports.SourceScope = exports.NowityProvider = exports.useService = exports.DEFAULT_PAGE_SIZE = exports.LiveList = exports.List = exports.GridList = exports.useList = exports.useQuerySuspense = exports.observer = exports.isRejected = exports.isForbidden = exports.Rejected = exports.Forbidden = exports.buildManifest = exports.countQuery = exports.pageQuery = exports.endpointName = exports.resetContracts = exports.resolveContracts = exports.contractOf = exports.knownContracts = exports.mutation = exports.list = exports.query = exports.contract = exports.api = void 0;
24
+ exports.NowityClientToken = exports.configureNowityClient = exports.WebSocketTransport = exports.StrictOptimisticError = exports.ConnectionLostError = exports.currentConnection = exports.activeConnection = exports.NowityConnection = exports.Restricted = exports.useQuerySource = exports.SourceScope = exports.NowityProvider = exports.useService = exports.DEFAULT_PAGE_SIZE = exports.LiveList = exports.List = exports.GridList = exports.useList = exports.useQuerySuspense = exports.observer = exports.isRejected = exports.isForbidden = exports.Rejected = exports.Forbidden = exports.buildManifest = exports.countQuery = exports.pageQuery = exports.endpointName = exports.resetContracts = exports.resolveContracts = exports.contractOf = exports.knownContracts = exports.mutation = exports.list = exports.query = exports.contract = exports.api = void 0;
25
25
  // ------------------------------------------------------------------- contracts
26
26
  var contract_1 = require("./api/contract");
27
27
  Object.defineProperty(exports, "api", { enumerable: true, get: function () { return contract_1.api; } });
@@ -72,6 +72,15 @@ var connection_1 = require("./client/connection");
72
72
  Object.defineProperty(exports, "NowityConnection", { enumerable: true, get: function () { return connection_1.NowityConnection; } });
73
73
  Object.defineProperty(exports, "activeConnection", { enumerable: true, get: function () { return connection_1.activeConnection; } });
74
74
  Object.defineProperty(exports, "currentConnection", { enumerable: true, get: function () { return connection_1.currentConnection; } });
75
+ /**
76
+ * The optimistic half of a write, which is the one thing about an endpoint that
77
+ * cannot be derived: a mutation's body is server code and never reaches the
78
+ * bundle, so an application that wants the change on screen before the server
79
+ * has answered states its effect here.
80
+ */
81
+ var nowity_client_1 = require("./client/nowity-client");
82
+ Object.defineProperty(exports, "ConnectionLostError", { enumerable: true, get: function () { return nowity_client_1.ConnectionLostError; } });
83
+ Object.defineProperty(exports, "StrictOptimisticError", { enumerable: true, get: function () { return nowity_client_1.StrictOptimisticError; } });
75
84
  var ws_transport_1 = require("./client/ws-transport");
76
85
  Object.defineProperty(exports, "WebSocketTransport", { enumerable: true, get: function () { return ws_transport_1.WebSocketTransport; } });
77
86
  var client_1 = require("./ironbean/client");
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Client mutators the server derived from what a mutation wrote.
3
+ *
4
+ * A hand-written `local()` says what a mutation does to the rows a browser
5
+ * holds. For the simplest writes that is a restatement of the server code —
6
+ * `update Document set title = $2 where id = $1` — and a restatement is
7
+ * somewhere for the two to drift. So the server watches what each mutation
8
+ * writes (§ "Návrh mutátorů přes get"), and where every written value is one
9
+ * of the mutation's own arguments, a constant, or an increment, it describes
10
+ * the write as data and sends it with the live queries it can affect.
11
+ *
12
+ * Only the description travels, never code: a template naming argument
13
+ * positions. The browser fills them with the arguments of each call.
14
+ *
15
+ * Shared by both halves, so nothing here may touch `pg`, `mobx` or Node.
16
+ */
17
+ import type { EntityId, Row } from "./types";
18
+ /** Where a value of a derived write comes from. */
19
+ export type DerivedValue =
20
+ /** A leaf of the mutation's (positional) arguments, by path. */
21
+ {
22
+ arg: Array<string | number>;
23
+ }
24
+ /** The same value on every call. */
25
+ | {
26
+ const: string | number | boolean | null;
27
+ };
28
+ /** One row-level write of a derived mutator. */
29
+ export interface DerivedWrite {
30
+ /** Entity the row is filed under in the client store (the Prisma model). */
31
+ entity: string;
32
+ op: "update" | "delete";
33
+ /** The row's identity. */
34
+ id: DerivedValue;
35
+ /** Fields replaced by a value. */
36
+ set?: Record<string, DerivedValue>;
37
+ /** Numeric fields moved by an amount (a decrement is a negative amount). */
38
+ inc?: Record<string, DerivedValue>;
39
+ }
40
+ /** What the server sends for one mutation: its writes, as templates. */
41
+ export interface DerivedMutator {
42
+ /** Wire name of the mutation, `contract.method`. */
43
+ name: string;
44
+ writes: DerivedWrite[];
45
+ }
46
+ /** The value a template stands for in one call, or `undefined` if the path is not there. */
47
+ export declare function resolveDerived(value: DerivedValue, args: unknown): unknown;
48
+ /**
49
+ * A value as it appears in a row the server sent: dates as ISO strings, the
50
+ * rest as JSON has it. Arguments arrive as JSON already; this is for the rare
51
+ * caller that passes a `Date` directly.
52
+ */
53
+ export declare function canonical(value: unknown): unknown;
54
+ /** The part of the overlay a derived mutator writes through. */
55
+ export interface DerivedTarget {
56
+ get(entity: string, id: EntityId): Row | undefined;
57
+ stage(entity: string, id: EntityId, row: Row | null): void;
58
+ /**
59
+ * May this mutator touch this row?
60
+ *
61
+ * Rows are shared between live queries in the identity map, so a write is
62
+ * only safe when every query holding the row was told the mutator applies
63
+ * to it — a filtered list that was not told would show a row that no
64
+ * longer belongs to it.
65
+ */
66
+ allows(entity: string, id: EntityId): boolean;
67
+ }
68
+ /**
69
+ * Apply a derived mutator to the overlay.
70
+ *
71
+ * A row that is not loaded is skipped, not created: an update says nothing
72
+ * about the fields it does not write. A field the row does not carry is
73
+ * skipped too — the query selected it out, and adding it would hand the UI a
74
+ * field the server never sends for that query.
75
+ */
76
+ export declare function applyDerived(mutator: DerivedMutator, args: unknown, target: DerivedTarget): void;
77
+ /** The `(entity, id, field) → value` a derived mutator promises, for checking it afterwards. */
78
+ export interface DerivedPrediction {
79
+ entity: string;
80
+ id: EntityId;
81
+ field: string;
82
+ value: unknown;
83
+ }
84
+ /**
85
+ * What the confirmed row must say once the server has applied the mutation.
86
+ *
87
+ * Only replaced values: an increment's result depends on what the row held
88
+ * when the server applied it, which may legitimately be someone else's write
89
+ * later than anything this browser saw.
90
+ */
91
+ export declare function derivedPredictions(mutator: DerivedMutator, args: unknown): DerivedPrediction[];
92
+ /** Fields a derived mutator writes, per entity — what a filter must not depend on. */
93
+ export declare function derivedFields(mutator: DerivedMutator): Map<string, Set<string>>;
94
+ /** Structural equality of two JSON values, for comparing a prediction with the server. */
95
+ export declare function sameValue(a: unknown, b: unknown): boolean;
96
+ //# sourceMappingURL=derived.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derived.d.ts","sourceRoot":"","sources":["../../src/core/derived.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE7C,mDAAmD;AACnD,MAAM,MAAM,YAAY;AACpB,gEAAgE;AAC9D;IAAE,GAAG,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAA;CAAE;AACjC,oCAAoC;GAClC;IAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;CAAE,CAAC;AAElD,gDAAgD;AAChD,MAAM,WAAW,YAAY;IACzB,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACxB,0BAA0B;IAC1B,EAAE,EAAE,YAAY,CAAC;IACjB,kCAAkC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACnC,4EAA4E;IAC5E,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACtC;AAED,wEAAwE;AACxE,MAAM,WAAW,cAAc;IAC3B,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,EAAE,CAAC;CAC1B;AAED,4FAA4F;AAC5F,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO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