@oddington/sdk 0.1.56 → 0.1.58
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
|
@@ -375,8 +375,8 @@ session subscription. Workspace existence and member access are checked by the
|
|
|
375
375
|
OS service. App modules use capability namespaces; routines and handlers receive
|
|
376
376
|
runtime context without calling `os.init`.
|
|
377
377
|
|
|
378
|
-
Hosted browser apps can initialize an existing named Data snapshot for local
|
|
379
|
-
|
|
378
|
+
Hosted browser apps can initialize an existing named Data snapshot for local
|
|
379
|
+
queries and shared Record Changes after host startup has installed that context:
|
|
380
380
|
|
|
381
381
|
```ts
|
|
382
382
|
const accounting = await data.init({ repository: 'general', snapshot: 'buchhaltung' });
|
|
@@ -385,22 +385,72 @@ const month = await accounting.records.query({
|
|
|
385
385
|
});
|
|
386
386
|
const transaction = await accounting.records.read('transactions/example');
|
|
387
387
|
const changes = await accounting.changes.list();
|
|
388
|
+
const proposed = await accounting.transact(tx => {
|
|
389
|
+
tx.transactions[transactionId].update({ payment: 'paid' }).link({ invoice: invoiceRef });
|
|
390
|
+
});
|
|
391
|
+
await accounting.changes.publish(proposed, { summary: 'Invoice paid' });
|
|
392
|
+
// Or discard an exact current owned selection before publication:
|
|
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();
|
|
388
401
|
```
|
|
389
402
|
|
|
390
403
|
Initialization confirms current access and the available artifact, reuses an
|
|
391
404
|
exact complete artifact-and-Changes installation or installs the validated
|
|
392
405
|
download and relevant Changes together. Published Changes are materialized before
|
|
393
406
|
querying or exact reads. Stored Changes without publication information remain
|
|
394
|
-
in
|
|
407
|
+
in `changes.list()` and never alter Records.
|
|
395
408
|
`records.query`, `records.pages` and `records.all(query, { maxRecords })` use the existing query language and generated-schema inference.
|
|
396
409
|
They read locally and expose the initialized version in `$meta.version`. The
|
|
397
|
-
handle
|
|
398
|
-
later
|
|
410
|
+
handle incorporates its own successful mutations. Subscribe to observe another
|
|
411
|
+
client's later Changes or an operator-built snapshot; without listeners the
|
|
412
|
+
handle stays fixed except for its own successful operations. Single-ref `records.read(ref)`
|
|
399
413
|
returns the complete structured Record or `null` from that same pinned state.
|
|
400
414
|
Initialization never refreshes the hosted artifact. Sign-out, context replacement and expiry invalidate local reads.
|
|
401
415
|
Snapshot initialization requires a hosted browser app; Node, routines and local
|
|
402
416
|
app contexts receive `DataOperationError` with `context_unavailable`.
|
|
403
417
|
|
|
418
|
+
`transact` captures a synchronous callback describing create, update, link,
|
|
419
|
+
unlink and delete operations across selected collections. Record methods chain;
|
|
420
|
+
create followed by edits folds into creation on the host. Generated schema
|
|
421
|
+
declarations refine fields and values, while the normalized runtime schemas and
|
|
422
|
+
host remain authoritative. Each call makes one authenticated hosted request;
|
|
423
|
+
transact changes only shared unpublished work. Publish and discard require exact
|
|
424
|
+
current owned Change IDs and versions. Publication uses the canonical writer and
|
|
425
|
+
applies its confirmed effects to local Records and the same Changes before
|
|
426
|
+
resolving, without waiting for hosted projection settlement. No operation
|
|
427
|
+
refreshes the artifact or adds an unpublished query overlay.
|
|
428
|
+
|
|
429
|
+
`subscribe(listener)` has no initial callback and returns a synchronous,
|
|
430
|
+
idempotent unsubscribe function. Listeners on one handle share a connection;
|
|
431
|
+
removing the last listener releases it. Each callback receives exactly
|
|
432
|
+
`{ records: boolean, changes: boolean }`, with at least one true, after atomic
|
|
433
|
+
local persistence. Callback-triggered ordinary reads see that committed state;
|
|
434
|
+
already-started reads remain pinned to their earlier installation. Unpublished
|
|
435
|
+
transact/discard affect Changes only; publication affects both namespaces. A
|
|
436
|
+
new artifact affects Records and also Changes when its relevant set changes.
|
|
437
|
+
Own successful operations notify once, including when their remote hint races
|
|
438
|
+
the response. Repeated hints and unchanged state do not notify.
|
|
439
|
+
|
|
440
|
+
The SDK reconciles on connection, reconnection and update hints, with bounded
|
|
441
|
+
reconnect backoff and no healthy-connection polling. Changes-only updates reuse
|
|
442
|
+
the unchanged artifact bytes. Subscription never builds or refreshes a snapshot.
|
|
443
|
+
Sign-out, context replacement and expiry stop live delivery and invalidate the
|
|
444
|
+
handle under the same local-operation rules.
|
|
445
|
+
|
|
446
|
+
After a lost transact/discard response, `DataOperationError.effect` is
|
|
447
|
+
`uncertain`, `retryable` is false, and that handle is invalid. Explicitly
|
|
448
|
+
initialize again to inspect authoritative work; do not replay the transaction.
|
|
449
|
+
A lost publication response may be retried on the same handle with the same
|
|
450
|
+
selection and summary; the SDK retains its canonical operation identity. If the
|
|
451
|
+
host accepted work but local persistence fails, the error reports `applied` and
|
|
452
|
+
invalidates the handle. Initialize again to recover coherent local state.
|
|
453
|
+
|
|
404
454
|
First-party Auth uses the handle without initializing workspace context. Its
|
|
405
455
|
bounded `browserAuth.authorization.get(id)`, `approve(id)` and `deny(id)` actions
|
|
406
456
|
support only the OS CLI request and fixed callback. Inspection/restoration never
|