@oddington/sdk 0.1.57 → 0.1.59

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.
package/README.md CHANGED
@@ -391,17 +391,29 @@ const proposed = await accounting.transact(tx => {
391
391
  await accounting.changes.publish(proposed, { summary: 'Invoice paid' });
392
392
  // Or discard an exact current owned selection before publication:
393
393
  // await accounting.changes.discard(proposed);
394
+
395
+ const unsubscribe = accounting.subscribe(({ records, changes }) => {
396
+ if (records) void reloadRecords(); // Ordinary reads now see the committed state.
397
+ if (changes) void reloadChanges();
398
+ });
399
+ // When this view leaves:
400
+ unsubscribe();
394
401
  ```
395
402
 
396
- Initialization confirms current access and the available artifact, reuses an
397
- exact complete artifact-and-Changes installation or installs the validated
398
- download and relevant Changes together. Published Changes are materialized before
403
+ Initialization confirms current access before opening local customer data. If
404
+ a complete artifact-and-Changes installation is already local, it returns
405
+ that coherent state without waiting for hosted freshness and reconciles once in
406
+ the background. A cold initialization installs the validated download and
407
+ relevant Changes together before returning. Published Changes are materialized before
399
408
  querying or exact reads. Stored Changes without publication information remain
400
409
  in `changes.list()` and never alter Records.
401
410
  `records.query`, `records.pages` and `records.all(query, { maxRecords })` use the existing query language and generated-schema inference.
402
411
  They read locally and expose the initialized version in `$meta.version`. The
403
- handle incorporates its own successful mutations; explicitly call `data.init`
404
- again to observe another client's later Changes or an operator-built snapshot. Single-ref `records.read(ref)`
412
+ handle incorporates its own successful mutations. Subscribe to observe another
413
+ client's later Changes or an operator-built snapshot. A listener attached before
414
+ warm background reconciliation commits receives the same namespace notification;
415
+ after that reconciliation, a handle without listeners stays fixed except for its
416
+ own successful operations. Single-ref `records.read(ref)`
405
417
  returns the complete structured Record or `null` from that same pinned state.
406
418
  Initialization never refreshes the hosted artifact. Sign-out, context replacement and expiry invalidate local reads.
407
419
  Snapshot initialization requires a hosted browser app; Node, routines and local
@@ -416,7 +428,24 @@ transact changes only shared unpublished work. Publish and discard require exact
416
428
  current owned Change IDs and versions. Publication uses the canonical writer and
417
429
  applies its confirmed effects to local Records and the same Changes before
418
430
  resolving, without waiting for hosted projection settlement. No operation
419
- refreshes the artifact or adds a client subscription or unpublished query overlay.
431
+ refreshes the artifact or adds an unpublished query overlay.
432
+
433
+ `subscribe(listener)` has no initial callback and returns a synchronous,
434
+ idempotent unsubscribe function. Listeners on one handle share a connection;
435
+ removing the last listener releases it. Each callback receives exactly
436
+ `{ records: boolean, changes: boolean }`, with at least one true, after atomic
437
+ local persistence. Callback-triggered ordinary reads see that committed state;
438
+ already-started reads remain pinned to their earlier installation. Unpublished
439
+ transact/discard affect Changes only; publication affects both namespaces. A
440
+ new artifact affects Records and also Changes when its relevant set changes.
441
+ Own successful operations notify once, including when their remote hint races
442
+ the response. Repeated hints and unchanged state do not notify.
443
+
444
+ The SDK reconciles on connection, reconnection and update hints, with bounded
445
+ reconnect backoff and no healthy-connection polling. Changes-only updates reuse
446
+ the unchanged artifact bytes. Subscription never builds or refreshes a snapshot.
447
+ Sign-out, context replacement and expiry stop live delivery and invalidate the
448
+ handle under the same local-operation rules.
420
449
 
421
450
  After a lost transact/discard response, `DataOperationError.effect` is
422
451
  `uncertain`, `retryable` is false, and that handle is invalid. Explicitly