@happyvertical/smrt-web 0.57.41 → 0.57.43
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/AGENTS.md +10 -0
- package/agents/offline-outbox.md +5 -2
- package/dist/chunks/{src-CG_-RoZq.js → src-1YdIJK9X.js} +30 -13
- package/dist/chunks/src-1YdIJK9X.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/webmcp.js +1 -1
- package/package.json +5 -5
- package/dist/chunks/src-CG_-RoZq.js.map +0 -1
package/AGENTS.md
CHANGED
|
@@ -63,6 +63,16 @@ module you are editing. This file keeps what holds in every module.
|
|
|
63
63
|
smrt-sites pages. Consumers load the runtime only on surfaces that use live
|
|
64
64
|
collections.
|
|
65
65
|
|
|
66
|
+
## Internal engine lifecycle (#4508)
|
|
67
|
+
|
|
68
|
+
TanStack DB and the Svelte binding share the 1.0 RC family; the query adapter
|
|
69
|
+
is 1.5+. Keep their peer requirements aligned when updating dependencies.
|
|
70
|
+
SMRT preserves `isPersisted.promise` through an adapter over `when('settled')`.
|
|
71
|
+
Online handlers await explicit refetch; queued writes await synced-store
|
|
72
|
+
confirmation instead. Hydration must await `writeUpsert` before dispatching a
|
|
73
|
+
mutation. Owned collection cleanup includes dependents so active live queries
|
|
74
|
+
are stopped before capability teardown.
|
|
75
|
+
|
|
66
76
|
## Conventions
|
|
67
77
|
|
|
68
78
|
- **WebMCP definition mirror** — `WebMcpToolDefinition` textually mirrors the
|
package/agents/offline-outbox.md
CHANGED
|
@@ -42,8 +42,11 @@ which would orphan the optimistic row the outbox is keeping; sync-apply's
|
|
|
42
42
|
strict-insert path preserves the client UUID, so replay reconciles the exact
|
|
43
43
|
optimistic row. `wrapMutation` enqueues then returns `{ handled: true, result:
|
|
44
44
|
envelope.data }`, and the factory suppresses the post-mutation refetch +
|
|
45
|
-
`invalidateRelated()
|
|
46
|
-
|
|
45
|
+
`invalidateRelated()`. The factory awaits `writeUpsert` / `writeDelete` to
|
|
46
|
+
confirm queued rows in the synced store before settling the transaction; a
|
|
47
|
+
mixed batch is confirmed locally if any member was handled. This keeps queued
|
|
48
|
+
rows after optimistic state is removed, without fetching a server list that
|
|
49
|
+
has never seen the offline write.
|
|
47
50
|
|
|
48
51
|
**Idempotency / no duplicates.** Rows carry client-generated UUIDs and the
|
|
49
52
|
endpoint is idempotent (`_insertOnly` create + no-op re-apply), so a batch that
|
|
@@ -3431,6 +3431,11 @@ function projectChanges(changes) {
|
|
|
3431
3431
|
return projected;
|
|
3432
3432
|
});
|
|
3433
3433
|
}
|
|
3434
|
+
function adaptTransaction(transaction) {
|
|
3435
|
+
const promise = transaction.when("settled");
|
|
3436
|
+
promise.catch(() => {});
|
|
3437
|
+
return { isPersisted: { promise } };
|
|
3438
|
+
}
|
|
3434
3439
|
function getBaseUpdatedAt(row) {
|
|
3435
3440
|
if (!row || typeof row !== "object") return void 0;
|
|
3436
3441
|
const record = row;
|
|
@@ -3577,7 +3582,7 @@ function createSmrtCollection(definition, options) {
|
|
|
3577
3582
|
retry,
|
|
3578
3583
|
queryFn: async () => unwrapListResult(await fetchers.list(), definition.name),
|
|
3579
3584
|
getKey: (row) => String(row[idField]),
|
|
3580
|
-
onInsert: async ({ transaction }) => {
|
|
3585
|
+
onInsert: async ({ transaction, collection: collection2 }) => {
|
|
3581
3586
|
let anyHandled = false;
|
|
3582
3587
|
for (const mutation of transaction.mutations) {
|
|
3583
3588
|
const modified = mutation.modified;
|
|
@@ -3593,10 +3598,14 @@ function createSmrtCollection(definition, options) {
|
|
|
3593
3598
|
mutationResults.set(envelope.key, outcome.result);
|
|
3594
3599
|
anyHandled = anyHandled || outcome.handled;
|
|
3595
3600
|
}
|
|
3596
|
-
if (anyHandled)
|
|
3601
|
+
if (anyHandled) {
|
|
3602
|
+
await collection2.utils.writeUpsert(transaction.mutations.map((mutation) => mutation.modified));
|
|
3603
|
+
return;
|
|
3604
|
+
}
|
|
3605
|
+
await collection2.utils.refetch();
|
|
3597
3606
|
invalidateRelated();
|
|
3598
3607
|
},
|
|
3599
|
-
onUpdate: fetchers.update ? async ({ transaction }) => {
|
|
3608
|
+
onUpdate: fetchers.update ? async ({ transaction, collection: collection2 }) => {
|
|
3600
3609
|
let anyHandled = false;
|
|
3601
3610
|
for (const mutation of transaction.mutations) {
|
|
3602
3611
|
const key = String(mutation.key);
|
|
@@ -3611,10 +3620,14 @@ function createSmrtCollection(definition, options) {
|
|
|
3611
3620
|
mutationResults.set(envelope.key, outcome.result);
|
|
3612
3621
|
anyHandled = anyHandled || outcome.handled;
|
|
3613
3622
|
}
|
|
3614
|
-
if (anyHandled)
|
|
3623
|
+
if (anyHandled) {
|
|
3624
|
+
await collection2.utils.writeUpsert(transaction.mutations.map((mutation) => mutation.modified));
|
|
3625
|
+
return;
|
|
3626
|
+
}
|
|
3627
|
+
await collection2.utils.refetch();
|
|
3615
3628
|
invalidateRelated();
|
|
3616
3629
|
} : void 0,
|
|
3617
|
-
onDelete: fetchers.delete ? async ({ transaction }) => {
|
|
3630
|
+
onDelete: fetchers.delete ? async ({ transaction, collection: collection2 }) => {
|
|
3618
3631
|
let anyHandled = false;
|
|
3619
3632
|
for (const mutation of transaction.mutations) {
|
|
3620
3633
|
const key = String(mutation.key);
|
|
@@ -3628,7 +3641,11 @@ function createSmrtCollection(definition, options) {
|
|
|
3628
3641
|
mutationResults.set(envelope.key, outcome.result);
|
|
3629
3642
|
anyHandled = anyHandled || outcome.handled;
|
|
3630
3643
|
}
|
|
3631
|
-
if (anyHandled)
|
|
3644
|
+
if (anyHandled) {
|
|
3645
|
+
await collection2.utils.writeDelete(transaction.mutations.map((mutation) => String(mutation.key)));
|
|
3646
|
+
return;
|
|
3647
|
+
}
|
|
3648
|
+
await collection2.utils.refetch();
|
|
3632
3649
|
invalidateRelated();
|
|
3633
3650
|
} : void 0
|
|
3634
3651
|
}));
|
|
@@ -3695,7 +3712,7 @@ function createSmrtCollection(definition, options) {
|
|
|
3695
3712
|
},
|
|
3696
3713
|
async cleanup() {
|
|
3697
3714
|
disposed = true;
|
|
3698
|
-
await collection.cleanup();
|
|
3715
|
+
await collection.cleanup({ dependents: true });
|
|
3699
3716
|
for (const capability of capabilities) try {
|
|
3700
3717
|
await capability.teardown?.(ctx);
|
|
3701
3718
|
} catch (error) {
|
|
@@ -3706,18 +3723,18 @@ function createSmrtCollection(definition, options) {
|
|
|
3706
3723
|
return subscribeWithListOrder(callback);
|
|
3707
3724
|
},
|
|
3708
3725
|
insert(row) {
|
|
3709
|
-
return collection.insert(row);
|
|
3726
|
+
return adaptTransaction(collection.insert(row));
|
|
3710
3727
|
},
|
|
3711
3728
|
update(key, changes) {
|
|
3712
3729
|
if (!fetchers.update) throw new Error(`${definition.name} has no update action`);
|
|
3713
3730
|
const { id: _id, ...safeChanges } = changes;
|
|
3714
|
-
return collection.update(key, (draft) => {
|
|
3731
|
+
return adaptTransaction(collection.update(key, (draft) => {
|
|
3715
3732
|
Object.assign(draft, safeChanges);
|
|
3716
|
-
});
|
|
3733
|
+
}));
|
|
3717
3734
|
},
|
|
3718
3735
|
delete(key) {
|
|
3719
3736
|
if (!fetchers.delete) throw new Error(`${definition.name} has no delete action`);
|
|
3720
|
-
return collection.delete(key);
|
|
3737
|
+
return adaptTransaction(collection.delete(key));
|
|
3721
3738
|
},
|
|
3722
3739
|
async action(action, args, route) {
|
|
3723
3740
|
if (!fetchers.custom) throw new Error(`${definition.name} has no custom action fetcher`);
|
|
@@ -3730,7 +3747,7 @@ function createSmrtCollection(definition, options) {
|
|
|
3730
3747
|
persistedMutationResults.set(handle, mutationResults);
|
|
3731
3748
|
mutationTargetHydrators.set(handle, async (row) => {
|
|
3732
3749
|
await collection.preload();
|
|
3733
|
-
collection.utils.writeUpsert(row);
|
|
3750
|
+
await collection.utils.writeUpsert(row);
|
|
3734
3751
|
});
|
|
3735
3752
|
engineCollections.set(handle, collection);
|
|
3736
3753
|
for (const capability of capabilities) try {
|
|
@@ -3743,4 +3760,4 @@ function createSmrtCollection(definition, options) {
|
|
|
3743
3760
|
//#endregion
|
|
3744
3761
|
export { wipeDurableStore as A, MAX_SMRT_WEB_DATA_QUERY_FACETS as B, getOutboxHandle as C, pruneDurableNamespace as D, listDurableNamespaces as E, classifySmrtWebDataSurfaceActionResult as F, MAX_SMRT_WEB_DATA_QUERY_ROWS as G, MAX_SMRT_WEB_DATA_QUERY_OFFSET as H, dataSurfaceActionCommandTransport as I, executeSmrtWebDataQuery as J, MAX_SMRT_WEB_DATA_QUERY_STRING_LENGTH as K, executeSmrtWebDataSurfaceAction as L, MAX_SMRT_WEB_DATA_SURFACE_ACTION_IDENTIFIER_LENGTH as M, MAX_SMRT_WEB_DATA_SURFACE_ACTION_JSON_DEPTH as N, durableStoreNamespace as O, MAX_SMRT_WEB_DATA_SURFACE_ACTION_RESULT_BYTES as P, normalizeSmrtWebDataSurfaceActionResult as R, persistDataSurface as S, offlineOutbox as T, MAX_SMRT_WEB_DATA_QUERY_PAGE_LIMIT as U, MAX_SMRT_WEB_DATA_QUERY_FACET_VALUES as V, MAX_SMRT_WEB_DATA_QUERY_RESULT_BYTES as W, runWrapMutation as X, normalizeSmrtWebDataQueryResult as Y, createSmrtWebEventSubscriber as _, createSmrtWebClient as a, DEFAULT_PERSIST_DEBOUNCE_MS as b, newLocalId as c, unwrapListResult as d, validateSmrtWebClient as f, createUpdateState as g, registerWebMcpTools as h, createSmrtCollection as i, MAX_SMRT_WEB_DATA_SURFACE_ACTION_CONTAINER_ITEMS as j, registerDurableResource as k, throwIfSmrtWebError as l, registerWebMcpBespokeTool as m, buildListQuery as n, getEngineCollection as o, registerViewIntent as p, MAX_SMRT_WEB_DATA_QUERY_WARNINGS as q, createDefinitionFetchers as r, invalidateSmrtWebCollections as s, SmrtWebRequestError as t, unwrapItemResult as u, liveInvalidation as v, offlineCommandQueue as w, persistCollection as x, createSmrtWebQuery as y, MAX_SMRT_WEB_DATA_QUERY_CONTAINER_ITEMS as z };
|
|
3745
3762
|
|
|
3746
|
-
//# sourceMappingURL=src-
|
|
3763
|
+
//# sourceMappingURL=src-1YdIJK9X.js.map
|