@happyvertical/smrt-web 0.43.3 → 0.43.4
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 +29 -1
- package/README.md +77 -0
- package/dist/chunks/{src-D9RvoJSQ.js → src-n14q6RHC.js} +335 -43
- package/dist/chunks/src-n14q6RHC.js.map +1 -0
- package/dist/index.d.ts +77 -3
- package/dist/index.js +2 -2
- package/dist/webmcp.d.ts +59 -2
- package/dist/webmcp.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/src-D9RvoJSQ.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare function buildListQuery(params?: Record<string, unknown>): string
|
|
|
15
15
|
* instead of resolving with them. Typed/legacy 4xx detail is retained; 5xx
|
|
16
16
|
* failures stay opaque and payload-free.
|
|
17
17
|
*/
|
|
18
|
-
export declare function createDefinitionFetchers(definition: SmrtWebCollectionDefinition<object>, basePath?: string, fetchFn?: typeof fetch): SmrtCrudFetchers;
|
|
18
|
+
export declare function createDefinitionFetchers(definition: Pick<SmrtWebCollectionDefinition<object>, 'name' | 'endpoint'>, basePath?: string, fetchFn?: typeof fetch): SmrtCrudFetchers;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Create a typed client collection over a generated SMRT collection definition
|
|
@@ -250,6 +250,17 @@ export declare function getEngineCollection<TData extends object>(handle: SmrtWe
|
|
|
250
250
|
*/
|
|
251
251
|
export declare function getOutboxHandle(namespace: string): OutboxHandle | undefined;
|
|
252
252
|
|
|
253
|
+
/**
|
|
254
|
+
* Invalidate materialized collection caches through the opaque SMRT client.
|
|
255
|
+
*
|
|
256
|
+
* This is the public cache-coherence seam for transports that execute a write
|
|
257
|
+
* without constructing a {@link SmrtWebCollection} (for example, a tool-only
|
|
258
|
+
* WebMCP definition). Matching is by collection name across every scope on the
|
|
259
|
+
* shared client, mirroring settled collection mutations: over-invalidation is
|
|
260
|
+
* safe, while leaving a related page cache stale is not.
|
|
261
|
+
*/
|
|
262
|
+
export declare function invalidateSmrtWebCollections(client: SmrtWebClient, collectionNames: readonly string[]): void;
|
|
263
|
+
|
|
253
264
|
/**
|
|
254
265
|
* A thin per-collection capability that subscribes THIS collection to live
|
|
255
266
|
* signals for its `tableName`. On attach it registers `ctx.invalidate` (the
|
|
@@ -533,9 +544,9 @@ export declare function registerDurableResource(namespace: string, resource: Dur
|
|
|
533
544
|
* @returns a disposer that deregisters all tools this call registered. On a
|
|
534
545
|
* browser without WebMCP the call is a no-op and the disposer is inert.
|
|
535
546
|
*/
|
|
536
|
-
export declare function registerWebMcpTools(definitions:
|
|
547
|
+
export declare function registerWebMcpTools(definitions: readonly WebMcpRegistrationDefinition[], options?: RegisterWebMcpToolsOptions): WebMcpRegistrationDisposer;
|
|
537
548
|
|
|
538
|
-
export declare interface RegisterWebMcpToolsOptions {
|
|
549
|
+
export declare interface RegisterWebMcpToolsOptions extends WebMcpExposurePolicy {
|
|
539
550
|
/** REST base path for the fetchers (default `/api/v1`). */
|
|
540
551
|
basePath?: string;
|
|
541
552
|
/** Injectable fetch (tests / SSR-safe wrappers). */
|
|
@@ -550,8 +561,16 @@ export declare interface RegisterWebMcpToolsOptions {
|
|
|
550
561
|
* without a live server.
|
|
551
562
|
*/
|
|
552
563
|
resolveFetchers?: (definition: SmrtWebCollectionDefinition) => SmrtCrudFetchers;
|
|
564
|
+
/**
|
|
565
|
+
* Override direct REST fetchers for a canonical tool-only definition.
|
|
566
|
+
* Fetchers are optional because a get-only or custom-action-only model does
|
|
567
|
+
* not have a list or create route.
|
|
568
|
+
*/
|
|
569
|
+
resolveToolFetchers?: (definition: WebMcpToolDefinition) => Partial<SmrtCrudFetchers>;
|
|
553
570
|
/** Predicate to include/exclude individual tools (e.g. reads-only surfaces). */
|
|
554
571
|
filter?: (definition: SmrtWebCollectionDefinition, descriptor: NonNullable<SmrtWebCollectionDefinition['toolDescriptors']>[number]) => boolean;
|
|
572
|
+
/** Predicate for canonical per-tool definitions. */
|
|
573
|
+
filterTool?: (definition: WebMcpToolDefinition) => boolean;
|
|
555
574
|
}
|
|
556
575
|
|
|
557
576
|
/**
|
|
@@ -1198,6 +1217,9 @@ export declare interface SyncStateEvent {
|
|
|
1198
1217
|
error?: string;
|
|
1199
1218
|
}
|
|
1200
1219
|
|
|
1220
|
+
/** Reject generated REST error envelopes while preserving opaque successes. */
|
|
1221
|
+
export declare function throwIfSmrtWebError(result: unknown, context: string): unknown;
|
|
1222
|
+
|
|
1201
1223
|
/**
|
|
1202
1224
|
* Normalize a generated-client item result (create/update) to a row.
|
|
1203
1225
|
* `{ error }` payloads become failures — inside mutation handlers this is what
|
|
@@ -1279,6 +1301,52 @@ export declare interface UpdateStateConfig {
|
|
|
1279
1301
|
namespace: DurableStoreKey;
|
|
1280
1302
|
}
|
|
1281
1303
|
|
|
1304
|
+
/** Validate that an opaque cache handle came from {@link createSmrtWebClient}. */
|
|
1305
|
+
export declare function validateSmrtWebClient(client: SmrtWebClient): void;
|
|
1306
|
+
|
|
1307
|
+
export declare interface WebMcpExposurePolicy {
|
|
1308
|
+
/** Allowed effects. Omitted means read-only exposure. */
|
|
1309
|
+
effects?: readonly WebMcpToolEffect[];
|
|
1310
|
+
/** Prefix every registered tool name with `<namespace>_`. */
|
|
1311
|
+
namespace?: string;
|
|
1312
|
+
/** Optional maximum tools registered by one call. */
|
|
1313
|
+
maxTools?: number;
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
/** Accepted legacy collection definitions and canonical per-tool definitions. */
|
|
1317
|
+
export declare type WebMcpRegistrationDefinition = SmrtWebCollectionDefinition | WebMcpToolDefinition;
|
|
1318
|
+
|
|
1319
|
+
/** Disposes a registration and exposes completion of browser registration. */
|
|
1320
|
+
export declare interface WebMcpRegistrationDisposer {
|
|
1321
|
+
(): void;
|
|
1322
|
+
/** Rejects if the browser rejects any tool; all sibling tools are aborted. */
|
|
1323
|
+
readonly ready: Promise<void>;
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
/**
|
|
1327
|
+
* Canonical data-only definition for one API-backed browser tool. Unlike a
|
|
1328
|
+
* collection definition, this does not imply that a list route or client cache
|
|
1329
|
+
* exists. Generated definitions carry explicit semantics; manual legacy
|
|
1330
|
+
* literals may omit them and register with fail-closed defaults.
|
|
1331
|
+
*/
|
|
1332
|
+
export declare interface WebMcpToolDefinition extends WebToolDescriptor {
|
|
1333
|
+
/** Stable definition identity is `(collection, action)`. */
|
|
1334
|
+
collection: string;
|
|
1335
|
+
/** Canonical qualified row-model identity. */
|
|
1336
|
+
objectRef: string;
|
|
1337
|
+
/** Row-model class used by the shared MCP tool vocabulary. */
|
|
1338
|
+
className: string;
|
|
1339
|
+
endpoint: string;
|
|
1340
|
+
idField: string;
|
|
1341
|
+
idType: 'uuid' | 'text';
|
|
1342
|
+
/** Complete generated route metadata, including CRUD actions. */
|
|
1343
|
+
route: SmrtWebToolRouteDescriptor;
|
|
1344
|
+
/** Cache-invalidation edges for materialized sibling collections. */
|
|
1345
|
+
relationships: SmrtWebRelationship[];
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
export declare type WebMcpToolEffect = 'read' | 'write' | 'destructive';
|
|
1349
|
+
|
|
1282
1350
|
/**
|
|
1283
1351
|
* One generated collection definition: everything needed to construct a client
|
|
1284
1352
|
* collection over the generated REST surface. The `_row` property is a phantom
|
|
@@ -1302,6 +1370,12 @@ export declare interface WebToolDescriptor {
|
|
|
1302
1370
|
inputSchema: Record<string, unknown>;
|
|
1303
1371
|
/** True for non-mutating reads → WebMCP `annotations.readOnlyHint`. */
|
|
1304
1372
|
readOnly: boolean;
|
|
1373
|
+
/** Capability effect used by WebMCP exposure policy. */
|
|
1374
|
+
effect?: 'read' | 'write' | 'destructive';
|
|
1375
|
+
/** Whether repeating the tool with the same arguments is safe. */
|
|
1376
|
+
idempotent?: boolean;
|
|
1377
|
+
/** Whether the tool may interact outside the SMRT application. */
|
|
1378
|
+
openWorld?: boolean;
|
|
1305
1379
|
/** Generated custom-route transport metadata. */
|
|
1306
1380
|
route?: SmrtWebToolRouteDescriptor;
|
|
1307
1381
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { DEFAULT_PERSIST_DEBOUNCE_MS, MAX_SMRT_WEB_DATA_QUERY_CONTAINER_ITEMS, MAX_SMRT_WEB_DATA_QUERY_FACETS, MAX_SMRT_WEB_DATA_QUERY_FACET_VALUES, MAX_SMRT_WEB_DATA_QUERY_OFFSET, MAX_SMRT_WEB_DATA_QUERY_PAGE_LIMIT, MAX_SMRT_WEB_DATA_QUERY_RESULT_BYTES, MAX_SMRT_WEB_DATA_QUERY_ROWS, MAX_SMRT_WEB_DATA_QUERY_STRING_LENGTH, MAX_SMRT_WEB_DATA_QUERY_WARNINGS, SmrtWebRequestError, buildListQuery, createDefinitionFetchers, createSmrtCollection, createSmrtWebClient, createSmrtWebEventSubscriber, createSmrtWebQuery, createUpdateState, durableStoreNamespace, executeSmrtWebDataQuery, getEngineCollection, getOutboxHandle, liveInvalidation, newLocalId, normalizeSmrtWebDataQueryResult, offlineOutbox, persistCollection, registerDurableResource, registerWebMcpTools, runWrapMutation, unwrapItemResult, unwrapListResult, wipeDurableStore };
|
|
1
|
+
import { A as MAX_SMRT_WEB_DATA_QUERY_RESULT_BYTES, C as registerDurableResource, D as MAX_SMRT_WEB_DATA_QUERY_FACET_VALUES, E as MAX_SMRT_WEB_DATA_QUERY_FACETS, F as normalizeSmrtWebDataQueryResult, I as runWrapMutation, M as MAX_SMRT_WEB_DATA_QUERY_STRING_LENGTH, N as MAX_SMRT_WEB_DATA_QUERY_WARNINGS, O as MAX_SMRT_WEB_DATA_QUERY_OFFSET, P as executeSmrtWebDataQuery, S as durableStoreNamespace, T as MAX_SMRT_WEB_DATA_QUERY_CONTAINER_ITEMS, _ as createSmrtWebQuery, a as createSmrtWebClient, b as getOutboxHandle, c as newLocalId, d as unwrapListResult, f as validateSmrtWebClient, g as liveInvalidation, h as createSmrtWebEventSubscriber, i as createSmrtCollection, j as MAX_SMRT_WEB_DATA_QUERY_ROWS, k as MAX_SMRT_WEB_DATA_QUERY_PAGE_LIMIT, l as throwIfSmrtWebError, m as createUpdateState, n as buildListQuery, o as getEngineCollection, p as registerWebMcpTools, r as createDefinitionFetchers, s as invalidateSmrtWebCollections, t as SmrtWebRequestError, u as unwrapItemResult, v as DEFAULT_PERSIST_DEBOUNCE_MS, w as wipeDurableStore, x as offlineOutbox, y as persistCollection } from "./chunks/src-n14q6RHC.js";
|
|
2
|
+
export { DEFAULT_PERSIST_DEBOUNCE_MS, MAX_SMRT_WEB_DATA_QUERY_CONTAINER_ITEMS, MAX_SMRT_WEB_DATA_QUERY_FACETS, MAX_SMRT_WEB_DATA_QUERY_FACET_VALUES, MAX_SMRT_WEB_DATA_QUERY_OFFSET, MAX_SMRT_WEB_DATA_QUERY_PAGE_LIMIT, MAX_SMRT_WEB_DATA_QUERY_RESULT_BYTES, MAX_SMRT_WEB_DATA_QUERY_ROWS, MAX_SMRT_WEB_DATA_QUERY_STRING_LENGTH, MAX_SMRT_WEB_DATA_QUERY_WARNINGS, SmrtWebRequestError, buildListQuery, createDefinitionFetchers, createSmrtCollection, createSmrtWebClient, createSmrtWebEventSubscriber, createSmrtWebQuery, createUpdateState, durableStoreNamespace, executeSmrtWebDataQuery, getEngineCollection, getOutboxHandle, invalidateSmrtWebCollections, liveInvalidation, newLocalId, normalizeSmrtWebDataQueryResult, offlineOutbox, persistCollection, registerDurableResource, registerWebMcpTools, runWrapMutation, throwIfSmrtWebError, unwrapItemResult, unwrapListResult, validateSmrtWebClient, wipeDurableStore };
|
package/dist/webmcp.d.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* @returns a disposer that deregisters all tools this call registered. On a
|
|
5
5
|
* browser without WebMCP the call is a no-op and the disposer is inert.
|
|
6
6
|
*/
|
|
7
|
-
export declare function registerWebMcpTools(definitions:
|
|
7
|
+
export declare function registerWebMcpTools(definitions: readonly WebMcpRegistrationDefinition[], options?: RegisterWebMcpToolsOptions): WebMcpRegistrationDisposer;
|
|
8
8
|
|
|
9
|
-
export declare interface RegisterWebMcpToolsOptions {
|
|
9
|
+
export declare interface RegisterWebMcpToolsOptions extends WebMcpExposurePolicy {
|
|
10
10
|
/** REST base path for the fetchers (default `/api/v1`). */
|
|
11
11
|
basePath?: string;
|
|
12
12
|
/** Injectable fetch (tests / SSR-safe wrappers). */
|
|
@@ -21,8 +21,16 @@ export declare interface RegisterWebMcpToolsOptions {
|
|
|
21
21
|
* without a live server.
|
|
22
22
|
*/
|
|
23
23
|
resolveFetchers?: (definition: SmrtWebCollectionDefinition) => SmrtCrudFetchers;
|
|
24
|
+
/**
|
|
25
|
+
* Override direct REST fetchers for a canonical tool-only definition.
|
|
26
|
+
* Fetchers are optional because a get-only or custom-action-only model does
|
|
27
|
+
* not have a list or create route.
|
|
28
|
+
*/
|
|
29
|
+
resolveToolFetchers?: (definition: WebMcpToolDefinition) => Partial<SmrtCrudFetchers>;
|
|
24
30
|
/** Predicate to include/exclude individual tools (e.g. reads-only surfaces). */
|
|
25
31
|
filter?: (definition: SmrtWebCollectionDefinition, descriptor: NonNullable<SmrtWebCollectionDefinition['toolDescriptors']>[number]) => boolean;
|
|
32
|
+
/** Predicate for canonical per-tool definitions. */
|
|
33
|
+
filterTool?: (definition: WebMcpToolDefinition) => boolean;
|
|
26
34
|
}
|
|
27
35
|
|
|
28
36
|
/**
|
|
@@ -162,6 +170,49 @@ declare interface SmrtWebToolRouteDescriptor {
|
|
|
162
170
|
optionsBag?: boolean;
|
|
163
171
|
}
|
|
164
172
|
|
|
173
|
+
export declare interface WebMcpExposurePolicy {
|
|
174
|
+
/** Allowed effects. Omitted means read-only exposure. */
|
|
175
|
+
effects?: readonly WebMcpToolEffect[];
|
|
176
|
+
/** Prefix every registered tool name with `<namespace>_`. */
|
|
177
|
+
namespace?: string;
|
|
178
|
+
/** Optional maximum tools registered by one call. */
|
|
179
|
+
maxTools?: number;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Accepted legacy collection definitions and canonical per-tool definitions. */
|
|
183
|
+
export declare type WebMcpRegistrationDefinition = SmrtWebCollectionDefinition | WebMcpToolDefinition;
|
|
184
|
+
|
|
185
|
+
/** Disposes a registration and exposes completion of browser registration. */
|
|
186
|
+
export declare interface WebMcpRegistrationDisposer {
|
|
187
|
+
(): void;
|
|
188
|
+
/** Rejects if the browser rejects any tool; all sibling tools are aborted. */
|
|
189
|
+
readonly ready: Promise<void>;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Canonical data-only definition for one API-backed browser tool. Unlike a
|
|
194
|
+
* collection definition, this does not imply that a list route or client cache
|
|
195
|
+
* exists. Generated definitions carry explicit semantics; manual legacy
|
|
196
|
+
* literals may omit them and register with fail-closed defaults.
|
|
197
|
+
*/
|
|
198
|
+
declare interface WebMcpToolDefinition extends WebToolDescriptor {
|
|
199
|
+
/** Stable definition identity is `(collection, action)`. */
|
|
200
|
+
collection: string;
|
|
201
|
+
/** Canonical qualified row-model identity. */
|
|
202
|
+
objectRef: string;
|
|
203
|
+
/** Row-model class used by the shared MCP tool vocabulary. */
|
|
204
|
+
className: string;
|
|
205
|
+
endpoint: string;
|
|
206
|
+
idField: string;
|
|
207
|
+
idType: 'uuid' | 'text';
|
|
208
|
+
/** Complete generated route metadata, including CRUD actions. */
|
|
209
|
+
route: SmrtWebToolRouteDescriptor;
|
|
210
|
+
/** Cache-invalidation edges for materialized sibling collections. */
|
|
211
|
+
relationships: SmrtWebRelationship[];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export declare type WebMcpToolEffect = 'read' | 'write' | 'destructive';
|
|
215
|
+
|
|
165
216
|
/**
|
|
166
217
|
* One generated collection definition: everything needed to construct a client
|
|
167
218
|
* collection over the generated REST surface. The `_row` property is a phantom
|
|
@@ -185,6 +236,12 @@ declare interface WebToolDescriptor {
|
|
|
185
236
|
inputSchema: Record<string, unknown>;
|
|
186
237
|
/** True for non-mutating reads → WebMCP `annotations.readOnlyHint`. */
|
|
187
238
|
readOnly: boolean;
|
|
239
|
+
/** Capability effect used by WebMCP exposure policy. */
|
|
240
|
+
effect?: 'read' | 'write' | 'destructive';
|
|
241
|
+
/** Whether repeating the tool with the same arguments is safe. */
|
|
242
|
+
idempotent?: boolean;
|
|
243
|
+
/** Whether the tool may interact outside the SMRT application. */
|
|
244
|
+
openWorld?: boolean;
|
|
188
245
|
/** Generated custom-route transport metadata. */
|
|
189
246
|
route?: SmrtWebToolRouteDescriptor;
|
|
190
247
|
}
|
package/dist/webmcp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { p as registerWebMcpTools } from "./chunks/src-n14q6RHC.js";
|
|
2
2
|
export { registerWebMcpTools };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-web",
|
|
3
|
-
"version": "0.43.
|
|
3
|
+
"version": "0.43.4",
|
|
4
4
|
"description": "SMRT browser client data runtime: typed collection factory wrapping the client-data engine over generated REST clients",
|
|
5
5
|
"author": "HappyVertical",
|
|
6
6
|
"type": "module",
|