@shivaedev/contract 0.31.0 → 0.33.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 (151) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +85 -17
  3. package/dist/CommandGuard.d.ts +10 -0
  4. package/dist/CommandGuard.d.ts.map +1 -0
  5. package/dist/CommandGuard.js +20 -0
  6. package/dist/CommandGuard.js.map +1 -0
  7. package/dist/LiveServer.d.ts +6 -4
  8. package/dist/LiveServer.d.ts.map +1 -1
  9. package/dist/LiveServer.js +10 -5
  10. package/dist/LiveServer.js.map +1 -1
  11. package/dist/ReadPolicyGuard.d.ts +19 -0
  12. package/dist/ReadPolicyGuard.d.ts.map +1 -0
  13. package/dist/ReadPolicyGuard.js +23 -0
  14. package/dist/ReadPolicyGuard.js.map +1 -0
  15. package/dist/adapters/activityState.d.ts +9 -0
  16. package/dist/adapters/activityState.d.ts.map +1 -0
  17. package/dist/adapters/activityState.js +11 -0
  18. package/dist/adapters/activityState.js.map +1 -0
  19. package/dist/{internal → adapters}/bindingOwner.d.ts +1 -1
  20. package/dist/{internal → adapters}/bindingOwner.d.ts.map +1 -1
  21. package/dist/{internal → adapters}/bindingOwner.js +2 -1
  22. package/dist/adapters/bindingOwner.js.map +1 -0
  23. package/dist/adapters/clientId.d.ts +2 -0
  24. package/dist/adapters/clientId.d.ts.map +1 -0
  25. package/dist/adapters/clientId.js +4 -0
  26. package/dist/adapters/clientId.js.map +1 -0
  27. package/dist/automaticLive.d.ts +1 -1
  28. package/dist/automaticLive.d.ts.map +1 -1
  29. package/dist/automaticLive.js +7 -2
  30. package/dist/automaticLive.js.map +1 -1
  31. package/dist/bind.d.ts.map +1 -1
  32. package/dist/bind.js +1 -1
  33. package/dist/bind.js.map +1 -1
  34. package/dist/changesHandlerLayer.d.ts +19 -0
  35. package/dist/changesHandlerLayer.d.ts.map +1 -0
  36. package/dist/changesHandlerLayer.js +15 -0
  37. package/dist/changesHandlerLayer.js.map +1 -0
  38. package/dist/clientActivity.d.ts +10 -1
  39. package/dist/clientActivity.d.ts.map +1 -1
  40. package/dist/clientActivity.js +7 -0
  41. package/dist/clientActivity.js.map +1 -1
  42. package/dist/clientKeys.d.ts +7 -0
  43. package/dist/clientKeys.d.ts.map +1 -0
  44. package/dist/clientKeys.js +11 -0
  45. package/dist/clientKeys.js.map +1 -0
  46. package/dist/composeBindings.d.ts +8 -0
  47. package/dist/composeBindings.d.ts.map +1 -0
  48. package/dist/composeBindings.js +18 -0
  49. package/dist/composeBindings.js.map +1 -0
  50. package/dist/contract.d.ts +5 -8
  51. package/dist/contract.d.ts.map +1 -1
  52. package/dist/contract.js +11 -7
  53. package/dist/contract.js.map +1 -1
  54. package/dist/internal/automaticQuery.d.ts +3 -1
  55. package/dist/internal/automaticQuery.d.ts.map +1 -1
  56. package/dist/internal/automaticQuery.js +9 -2
  57. package/dist/internal/automaticQuery.js.map +1 -1
  58. package/dist/internal/changesSuccess.d.ts +5 -1
  59. package/dist/internal/changesSuccess.d.ts.map +1 -1
  60. package/dist/internal/changesSuccess.js +10 -6
  61. package/dist/internal/changesSuccess.js.map +1 -1
  62. package/dist/internal/clientActivity.d.ts +5 -6
  63. package/dist/internal/clientActivity.d.ts.map +1 -1
  64. package/dist/internal/clientActivity.js +6 -18
  65. package/dist/internal/clientActivity.js.map +1 -1
  66. package/dist/internal/clientOperations.d.ts +1 -1
  67. package/dist/internal/clientOperations.d.ts.map +1 -1
  68. package/dist/internal/clientOperations.js +7 -4
  69. package/dist/internal/clientOperations.js.map +1 -1
  70. package/dist/internal/compareQueries.d.ts +2 -1
  71. package/dist/internal/compareQueries.d.ts.map +1 -1
  72. package/dist/internal/compareQueries.js +5 -7
  73. package/dist/internal/compareQueries.js.map +1 -1
  74. package/dist/internal/declarationError.d.ts +7 -1
  75. package/dist/internal/declarationError.d.ts.map +1 -1
  76. package/dist/internal/declarationError.js.map +1 -1
  77. package/dist/internal/prependMiddleware.d.ts +10 -0
  78. package/dist/internal/prependMiddleware.d.ts.map +1 -0
  79. package/dist/internal/prependMiddleware.js +12 -0
  80. package/dist/internal/prependMiddleware.js.map +1 -0
  81. package/dist/internal/queryDelivery.d.ts +2 -1
  82. package/dist/internal/queryDelivery.d.ts.map +1 -1
  83. package/dist/internal/queryDelivery.js +8 -1
  84. package/dist/internal/queryDelivery.js.map +1 -1
  85. package/dist/internal/queryReactivity.d.ts.map +1 -1
  86. package/dist/internal/queryReactivity.js +3 -11
  87. package/dist/internal/queryReactivity.js.map +1 -1
  88. package/dist/internal/querySignals.d.ts +8 -0
  89. package/dist/internal/querySignals.d.ts.map +1 -0
  90. package/dist/internal/querySignals.js +42 -0
  91. package/dist/internal/querySignals.js.map +1 -0
  92. package/dist/internal/wrapAtom.d.ts +3 -0
  93. package/dist/internal/wrapAtom.d.ts.map +1 -0
  94. package/dist/internal/wrapAtom.js +15 -0
  95. package/dist/internal/wrapAtom.js.map +1 -0
  96. package/dist/live.d.ts +2 -1
  97. package/dist/live.d.ts.map +1 -1
  98. package/dist/live.js +5 -4
  99. package/dist/live.js.map +1 -1
  100. package/dist/makeLiveServer.d.ts +22 -5
  101. package/dist/makeLiveServer.d.ts.map +1 -1
  102. package/dist/makeLiveServer.js +39 -24
  103. package/dist/makeLiveServer.js.map +1 -1
  104. package/dist/publicConfig.d.ts +19 -3
  105. package/dist/publicConfig.d.ts.map +1 -1
  106. package/dist/querySignals.d.ts +9 -0
  107. package/dist/querySignals.d.ts.map +1 -0
  108. package/dist/querySignals.js +14 -0
  109. package/dist/querySignals.js.map +1 -0
  110. package/dist/querySubscription.d.ts +1 -1
  111. package/dist/querySubscription.d.ts.map +1 -1
  112. package/dist/querySubscription.js +7 -4
  113. package/dist/querySubscription.js.map +1 -1
  114. package/dist/queryUpdate.d.ts +5 -1
  115. package/dist/queryUpdate.d.ts.map +1 -1
  116. package/package.json +11 -10
  117. package/src/CommandGuard.ts +25 -0
  118. package/src/LiveServer.ts +18 -9
  119. package/src/ReadPolicyGuard.ts +31 -0
  120. package/src/adapters/activityState.ts +12 -0
  121. package/src/{internal → adapters}/bindingOwner.ts +3 -2
  122. package/src/adapters/clientId.ts +3 -0
  123. package/src/automaticLive.ts +8 -3
  124. package/src/bind.ts +1 -1
  125. package/src/changesHandlerLayer.ts +51 -0
  126. package/src/clientActivity.ts +8 -1
  127. package/src/clientKeys.ts +17 -0
  128. package/src/composeBindings.ts +27 -0
  129. package/src/contract.ts +14 -20
  130. package/src/internal/automaticQuery.ts +11 -1
  131. package/src/internal/changesSuccess.ts +13 -8
  132. package/src/internal/clientActivity.ts +37 -52
  133. package/src/internal/clientOperations.ts +9 -5
  134. package/src/internal/compareQueries.ts +6 -8
  135. package/src/internal/declarationError.ts +12 -1
  136. package/src/internal/prependMiddleware.ts +15 -0
  137. package/src/internal/queryDelivery.ts +9 -0
  138. package/src/internal/queryReactivity.ts +4 -11
  139. package/src/internal/querySignals.ts +46 -0
  140. package/src/internal/wrapAtom.ts +14 -0
  141. package/src/live.ts +5 -4
  142. package/src/makeLiveServer.ts +64 -57
  143. package/src/querySignals.ts +22 -0
  144. package/src/querySubscription.ts +8 -7
  145. package/src/queryUpdate.ts +5 -1
  146. package/dist/internal/bindingOwner.js.map +0 -1
  147. package/dist/testing.d.ts +0 -17
  148. package/dist/testing.d.ts.map +0 -1
  149. package/dist/testing.js +0 -51
  150. package/dist/testing.js.map +0 -1
  151. package/src/testing.ts +0 -81
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.33.0 - 2026-11-03
4
+
5
+ ### Breaking
6
+
7
+ - Move `watchHints`, `heard`, `layerMemoryProtocol` and `HintViewer` from `@shivaedev/contract/testing.ts` to `@shivaedev/test-kits/contract/testing.ts`. Add test-kits as a development dependency.
8
+
9
+ ## 0.32.0 - 2026-11-03
10
+
11
+ ### Added
12
+
13
+ - `makeClient` accepts `resume` and `resumeWindow` so applications can supply native lifecycle signals and an embedded browser window directly, preserving the client's inferred API, failures and requirements.
14
+ - `composeBindings(client, bindings)` preserves the client's type and declares the bound APIs in one connection. `liveBindings(connection)` reads that composition while retaining support for direct bindings and object properties.
15
+ - Observe bound queries with `querySignals(query)`: a native atom reports completed reads, pending requests, and whether their subscription opened or was refused. Refreshes signal completion even when their result is unchanged.
16
+ - Supply `CommandGuard`, `CommandBoundary`, `guardCommands` and `commandGuardLayer` to evaluate declared command changes for the current viewer independently of authentication and tracing.
17
+ - Export `activityScreenSignal(activity)` from `clientActivity.ts`, projecting client activity into a native stream and current Effect of pending screen work and hint counts.
18
+ - Contract owns `ReadPolicyGuard`, `readPolicyGuardLayer()` and `guardReads(group)` in `@shivaedev/contract/ReadPolicyGuard.ts`. The guard checks each ordinary query's read policy once against the request's `CurrentViewer`.
19
+ - Derive custom subscription handlers with `changesHandlerLayer`, retaining query payloads, declared failures, read-policy services and stream requirements in a native Layer.
20
+
21
+ ### Fixed
22
+
23
+ - Schedule contract live hints through the Effect runtime's Scheduler, preserving batched changes, resyncs and stream cleanup. Isolate synchronous client identity and activity bridges in adapters and share atom wrapping across bindings.
24
+ - Refresh server-discovered read scopes on each live subscription rerun and replace their registrations, including when a pushed result is unchanged.
25
+ - `LiveServer.subscribe` preserves `SubscriptionHint` deliveries when no query runner is supplied, including an explicit `undefined`. Calls with a query runner keep `QueryUpdate` deliveries and retain the subscription's typed failures and service requirements.
26
+ - Contract groups enforce query read policies automatically in native Effect RPC hosts as well as the application host. A false policy returns `QueryReadDenied` without running the handler. Ordinary queries evaluate their policy once per request.
27
+
28
+ ### Breaking
29
+
30
+ - Rerun-and-compare subscriptions emit an `Unchanged` update with the query index when a completed read preserves its previous value. Consumers of raw `$changes` streams must handle this update; bound queries handle it automatically. Deploy clients and servers together so both understand the updated stream schema.
31
+ - Calls to `LiveServer.subscribe` that explicitly supply its error and service type arguments and a query runner must also supply the runner type as the third type argument, or omit the type arguments and let TypeScript infer them.
32
+ - Remove `guardReads` from `@shivaedev/contract/ReadPolicyGuard.ts`. Serve the contract group directly with `RpcServer`; remove any explicit read-policy Layer unless you use `readPolicyGuardLayer()` to refuse HTTP `$changes` calls with `WebSocketRequired`. `ReadPolicyGuard` is now a defaulted Context reference rather than a service class and requires no provision. Remove its former service type from Layer annotations.
33
+ - Custom authentication middleware must supply `CurrentViewer` after session validation and stop calling `authorizeReads`; the contract's attached guard performs that check. Keep `authorizeReads` only for direct handler reruns outside RPC dispatch.
34
+ - Ordinary query failures now include `MissingReadPolicy` and `WebSocketRequired` from the attached middleware. `MissingReadPolicy` refuses untyped declarations that omit a policy; `WebSocketRequired` belongs to the optional HTTP subscription restriction. Add these refusals to exhaustive error handlers.
35
+ - `makeLiveServer.stream` and `LiveServer.stream` accept keys only. Their `subscribe` methods now take `(subscription, authorizedRunner?)`; remove the former context argument. `QuerySubscription.globalKeys` is removed because all server keys share the repository namespace; remove it from custom subscription objects.
36
+
3
37
  ## 0.31.0 - 2026-11-02
4
38
 
5
39
  ### Added
package/README.md CHANGED
@@ -159,7 +159,7 @@ export const NotesHandlers = Notes.toLayer(
159
159
 
160
160
  Save this module as `handlers.ts`. An application can put repository and service calls in these handlers. The contract checks handler result and rejection types; it does not implement persistence, authorization or transactions. This in-memory server keeps the reserved change stream open without publishing hints. When a Platform host supplies that handler, build application handlers from `Notes.application` and keep `Notes` as the host and client group.
161
161
 
162
- To map unexpected failures once for a handler registration, declare `boundary = rpcBoundary(schema, options)` once and use `rpcBoundaryHandlers(Notes.application, boundary, handlers)` from [`@shivaedev/errors`](https://github.com/ShivaeDev/platform/tree/main/packages/errors#mapping-unexpected-failures-at-the-handler-edge), then pass the map to `Notes.application.toLayer`. Each operation declares the boundary's rejection schema; payloads, successful results and required services retain their native types.
162
+ To map unexpected failures once for a handler registration, use `rpcBoundaryHandlers(Notes.application, options, handlers)` from [`@shivaedev/errors`](https://github.com/ShivaeDev/platform/tree/main/packages/errors#mapping-unexpected-failures-at-the-handler-edge), then pass the map to `Notes.application.toLayer`. The helper derives each operation's rejection schema independently, and every operation declares the fallback returned by `options.unexpected`. Payloads, successful results and required services retain their native types.
163
163
 
164
164
  Native `.middleware(M)` returns a contract that retains its declarations. For example, a native middleware service can supply request identity:
165
165
 
@@ -277,7 +277,21 @@ Client invalidation follows RPC success. Database hosts from `@shivaedev/server`
277
277
 
278
278
  ### Client activity
279
279
 
280
- `clientActivity(client)` from `@shivaedev/contract/clientActivity.ts` returns a native Effect `Stream` with a `current` Effect for a client made by `makeClient`. Its state reports `rpcCalls` for finite calls, `liveInvalidations` for queued live refreshes, `refreshingAtoms` for mounted query atoms awaiting values, and a `liveHints` sequence for received subscription updates. Long-lived streams do not count as finite calls. `isClientIdle(state)` is true when all three work counts are zero. Observe its stream or pass it to a test-story screen driver's `pending` option and call `settle()` before screen assertions. Coalesced work stays pending until its refresh completes.
280
+ `clientActivity(client)` from `@shivaedev/contract/clientActivity.ts` returns a native Effect `Stream` with a `current` Effect for a client made by `makeClient`. Its state reports `rpcCalls` for finite calls, `liveInvalidations` for queued live refreshes, `refreshingAtoms` for mounted query atoms awaiting values, and a `liveHints` sequence for received subscription updates. Long-lived streams do not count as finite calls. `isClientIdle(state)` is true when all three work counts are zero. Observe its stream or pass `activityScreenSignal(clientActivity(client))` to a test-story screen driver's `pending` option and call `settle()` before screen assertions. `activityScreenSignal(activity)` projects the stream and its `current` Effect into `{ pending, hints }`, with `pending` true while finite work remains and `hints` carrying the received live-hint count. The returned shape is structural and carries no test-story dependency. Coalesced work stays pending until its refresh completes.
281
+
282
+ ### Query completion
283
+
284
+ `querySignals(query)` from `@shivaedev/contract/querySignals.ts` returns a native atom scoped to the query's registry. Its `completed` counter advances when the initial query or a refresh finishes, including typed failures and equal results. `pending` describes the query result awaiting completion. `subscription` is `disabled` for an ordinary query, `opening` while connecting, `open` once accepted, or `refused` after a terminal refusal. Read the query's `AsyncResult` for its value or typed failure.
285
+
286
+ ```ts
287
+ import { querySignals } from "@shivaedev/contract/querySignals.ts";
288
+
289
+ const signals = querySignals(one);
290
+ const before = registry.get(signals).completed;
291
+ const completions = AtomRegistry.toStream(registry, signals);
292
+ ```
293
+
294
+ Mount the query to start it. Wait on `completions` for `completed > before` after an action that refreshes it; compare the counter rather than the result's identity. A server-pushed equal result completes without changing the visible value. Raw rerun-and-compare `$changes` consumers receive an `Unchanged` update with `queryIndex` for these completed reads. Clients and servers must understand the same stream schema.
281
295
 
282
296
  ### Session-owned keys
283
297
 
@@ -319,19 +333,41 @@ Preferences.application.toLayer({
319
333
  });
320
334
  ```
321
335
 
322
- `store` is the application's persistence service. No owner or client key scope is accepted from a request. The database app host of `@shivaedev/server` resolves the server key scope from that same request-local identity.
336
+ `store` is the application's persistence service. No owner or client key scope is accepted from a request. The database app host uses plain repository keys for every subscriber and rechecks each subscriber’s read policy before delivery.
323
337
 
324
338
  The registry is required for session-scoped bindings. Query atoms and live connections belong in it; command and one-off query Effects execute through it. Explicit streams also run through its client, preserving the session transport and headers; disposing the registry ends those streams. Streams on ordinary contracts use the caller's client. A successful command invalidates its owner's keys, while a rejected command declares no invalidation. Ordinary contracts keep unscoped keys and the two-argument `bind` call.
325
339
 
326
- `List` and `Item` are still the key shapes. `readKeys(keys, { scope })` and `invalidationKeys(keys, { scope })` resolve the extra dimension while preserving item, list and wildcard semantics. An item invalidation refreshes that scope's item and list; a wildcard reaches only that scope's items. The client's opaque scope comes from its registry and is never sent as an owner id.
340
+ Server subscriptions and committed writes use the same plain record, list and bucket keys, including for `keyScope: "session"`. A background worker needs no request identity or account prefix to refresh a session's query. Matching keys trigger the query's own read policy; authorized reads remain responsible for filtering rows to the viewer. A shared key can therefore trigger authorized rechecks for several accounts. Use model buckets to narrow that fan-out.
341
+
342
+ Client cache isolation belongs to the owning registry. `bind` supplies its opaque context automatically. Custom client coordination uses these helpers and context type:
327
343
 
328
- Server adapters read the RPC's `KeyScope` annotation. For `"session"`, they must obtain scope from request-local authenticated identity, then pass the same `{ scope }` to dependency registration, invalidation and `makeLiveServer.stream(keys, context)`. A shared server Layer must not capture identity, accept a client-selected scope or fall back to unscoped keys. This package supplies metadata and contextual keys; it has no server or authentication dependency.
344
+ ```ts
345
+ import { clientInvalidationKeys, clientReadKeys, type KeyContext } from "@shivaedev/contract/clientKeys.ts";
346
+ ```
347
+
348
+ `clientReadKeys(keys, context)` registers client dependencies; `clientInvalidationKeys(keys, context)` announces client cache changes. The context has type `KeyContext`. Never publish contextual client keys on the server.
349
+
350
+ ### Compose feature bindings
351
+
352
+ Use `composeBindings(client, bindings)` when a connection contains several feature modules. The returned object keeps the client's fields and types and carries an explicit list of bound APIs. `liveBindings(connection)` reads this list; it also accepts a binding directly or an object with bound APIs as its own properties.
353
+
354
+ ```ts
355
+ import { composeBindings } from "@shivaedev/contract/composeBindings.ts";
356
+
357
+ const modules = [notesModule, tasksModule] as const;
358
+ const connection = composeBindings(
359
+ { modules },
360
+ modules.map((module) => module.api),
361
+ );
362
+ ```
363
+
364
+ `notesModule` and `tasksModule` are application modules whose `api` values come from `bind` or `makeClient`. Return `connection` from React's `SessionBoundary` connection callback to mount both bindings while keeping the modules nested.
329
365
 
330
366
  ### 4. Live invalidation and resume
331
367
 
332
368
  The automatic live connection exposed at `api[LiveConnection]` includes a writable `paused` atom. Set it in the binding’s registry to pause refreshes; clearing it reconciles the mounted queries. Bindings on the same client runtime share this pause state.
333
369
 
334
- Database hosts from `@shivaedev/server` serve the contract's reserved `<contract>.$changes` stream automatically. With the native WebSocket protocol, `bind` and a React `SessionBoundary` connect query atoms without an application subscribe operation or `live()` call. The boundary finds bound APIs returned directly by `connect` or as properties such as `client.api`. See [automatic changes](https://github.com/ShivaeDev/platform/blob/main/docs/framework/changes.md) for defaults.
370
+ Database hosts from `@shivaedev/server` serve the contract's reserved `<contract>.$changes` stream automatically. With the native WebSocket protocol, `bind` and a React `SessionBoundary` connect query atoms without an application subscribe operation or `live()` call. The boundary mounts the bindings declared with `composeBindings`, or finds bound APIs returned directly by `connect` or as properties such as `client.api`. See [automatic changes](https://github.com/ShivaeDev/platform/blob/main/docs/framework/changes.md) for defaults.
335
371
 
336
372
  Subscribing to the hosted `$changes` stream over HTTP fails with `WebSocketRequired` from `@shivaedev/contract/WebSocketRequired.ts`; its message names the stream and says it needs the WebSocket protocol.
337
373
 
@@ -366,7 +402,34 @@ const changes = Stream.unwrap(
366
402
  );
367
403
  ```
368
404
 
369
- The contract includes the reserved stream's payload, `LiveHint` elements and middleware failures in its native RPC type. The subscription uses the contract's middleware and needs no separate RPC group or cast. The caller owns stream consumption and interruption. References name declared queries and reuse their payload schemas; payloadless queries use `{ query: "list", payload: undefined }`. Custom subscription handlers call `querySubscription(rpc, references, viewer)` with the native changes RPC definition and pass its authorized result to `makeLiveServer.subscribe(subscription, context)`. Hosted applications use `resolveChanges` from identity to supply that subscription. Session-scoped bindings track mounted queries per registry and drop their references on unmount or disposal. Ordinary bindings track query references when atoms are created.
405
+ The contract includes the reserved stream's payload, `LiveHint` elements and middleware failures in its native RPC type. The subscription uses the contract's middleware and needs no separate RPC group or cast. The caller owns stream consumption and interruption. References name declared queries and reuse their payload schemas; payloadless queries use `{ query: "list", payload: undefined }`. Custom subscription handlers call `querySubscription(rpc, references, viewer)` with the native changes RPC definition and pass its authorized result to `makeLiveServer.subscribe(subscription)`. Hosted applications use `resolveChanges` from identity to supply that subscription. Session-scoped bindings track mounted queries per registry and drop their references on unmount or disposal. Ordinary bindings track query references when atoms are created.
406
+
407
+ Custom subscription handlers use `changesHandlerLayer` to derive the reserved handler Layer from the contract:
408
+
409
+ ```ts
410
+ import { Effect, Stream } from "effect";
411
+ import { changesHandlerLayer } from "@shivaedev/contract/changesHandlerLayer.ts";
412
+ import { LiveServer } from "@shivaedev/contract/LiveServer.ts";
413
+ import { querySubscription } from "@shivaedev/contract/querySubscription.ts";
414
+ import { CurrentViewer } from "@shivaedev/contract/readPolicy.ts";
415
+ import { Notes } from "./notes.ts";
416
+
417
+ const changes = changesHandlerLayer(
418
+ Notes,
419
+ (rpc) =>
420
+ ({ queries }) =>
421
+ Stream.unwrap(
422
+ Effect.gen(function* () {
423
+ const viewer = yield* CurrentViewer;
424
+ const subscription = yield* querySubscription(rpc, queries, viewer);
425
+ const live = yield* LiveServer;
426
+ return yield* live.subscribe(subscription);
427
+ }),
428
+ ),
429
+ );
430
+ ```
431
+
432
+ Merge this Layer with `Notes.application.toLayer(...)`. It retains the query read-policy and custom stream services as requirements, excluding services supplied by RPC middleware. The builder can also return an Effect to acquire services or fail during Layer construction. Declared stream failures remain in the contract's error channel. Pushed results are validated against the contract's decoded success types; custom handlers do not decode `changesSuccess` themselves.
370
433
 
371
434
  For a custom transport or explicit pause and status controls, use the native live APIs.
372
435
 
@@ -456,7 +519,7 @@ Call the release functions and dispose the registry when the application's root
456
519
 
457
520
  ### Server hint streams
458
521
 
459
- Import `LiveServer` from `@shivaedev/contract/LiveServer.ts`. Provide `LiveServer.layer` with the server's `Reactivity` Layer; PostgreSQL `appHost` apps already provide it. Yield `LiveServer` to obtain the shared service. Its methods return Effects: unwrap `hints.stream(keys, context)` or `hints.subscribe(subscription, context, read?)` with `Stream.unwrap`, and call `hints.resync()` to reconcile its active streams. Subscription policy failures and caller requirements remain on the returned Stream.
522
+ Import `LiveServer` from `@shivaedev/contract/LiveServer.ts`. Provide `LiveServer.layer` with the server's `Reactivity` Layer; PostgreSQL `appHost` apps already provide it. Yield `LiveServer` to obtain the shared service. Its methods return Effects: unwrap `hints.stream(keys)` or `hints.subscribe(subscription, read?)` with `Stream.unwrap`, and call `hints.resync()` to reconcile its active streams. Subscription policy failures and caller requirements remain on the returned Stream.
460
523
 
461
524
  Import `makeLiveServer` from `@shivaedev/contract/makeLiveServer.ts` and create it once with the server's `Reactivity` service. After application authorization, return `hints.stream([orders.item(id)])` from the native streaming RPC handler. Each subscription starts with `Resync`; invalidating its read keys produces `Changed` with those declared keys. `hints.resync` sends `Resync` to every live stream owned by that helper, including streams for otherwise unrelated keys. Independent helpers keep their resync scopes separate even when they share Reactivity. The native stream owns registration and interruption. Keep this server helper separate from the browser's `live` coordinator.
462
525
 
@@ -464,6 +527,8 @@ Each stream queues at most 256 hints. Overflow discards the pending hints and re
464
527
 
465
528
  ### Query policies, record keys and buckets
466
529
 
530
+ Contract groups carry their read-policy guard into native `RpcServer` hosts and Platform’s application host. An ordinary query evaluates its policy once per request, after identity middleware supplies `CurrentViewer` from its validated session. A false policy returns `QueryReadDenied` without running the handler. Native hosts need no policy middleware or guard Layer. Real HTTP stories exercise both hosts with allowed and denied counted policies; they prove this RPC boundary, not an application’s session or deployment policy. Platform’s application host refuses HTTP `$changes` calls with `WebSocketRequired`; subscriptions use its WebSocket protocol. Subscription delivery and pushed reruns continue to check current access.
531
+
467
532
  A query declares its decoded input, result, `readPolicy` and `reads` together. `readPolicy(payload, viewer)` returns an Effect boolean. `viewer` is the session's `Option<{ id: string }>`; the browser does not send the identity. `signedIn` from `readPolicy.ts` allows any signed-in viewer and refuses a signed-out viewer. `QueryReadPolicy<Payload, E, R>` preserves typed failures and required services. Declare policy errors in the query's `rejections`; a failing access check reaches the client as its declared error, including during live reads. Only a successful `false` denies access. [Policy services](#policy-services) explains richer session requirements and where to provide implementations.
468
533
 
469
534
  ```ts
@@ -504,7 +569,7 @@ const AllNotes = query("allNotes", {
504
569
 
505
570
  The application supplies the permission checker through `permissionReadPolicy(permission, check)`; `check` receives that permission and the current viewer, and must check the viewer's grant using server services. Its failures and service requirements flow through the query like any other read policy. Supply `SessionUser` with the application's identity middleware. The policy guards both calls and subscriptions, and runs again before changed hints are delivered. `readsCollections` requires this policy at declaration: a `signedIn` or ordinary boolean policy fails TypeScript checking, and building an untyped contract with that declaration throws an error explaining the required permission policy. The server also refuses collection queries changed to an ordinary policy after construction as `QueryReadDenied`. Tenant-facing queries use `notes.bucket.userId(viewerId)` instead.
506
571
 
507
- Collection reads reuse the bare repository table key, the same key as `notes.list`, even when the contract uses `keyScope: "session"`; ordinary reads keep their session scope. They add no wildcard matching or write-side work. Every committed repository insert, update, delete, upsert and bulk write already publishes that key. Generated-id inserts also publish the bare collection key alongside their generated record key, so `publishes` stories that check exact published keys must allow the bare key today. For a table named `notes`, that is `"notes"` alongside `"notes:<id>"` and any affected bucket keys. Mounting a collection subscriber adds **zero PostgreSQL NOTIFY messages per write**: it consumes the existing payloads. It adds a normal query subscription and an authorized reread when the collection changes.
572
+ Collection reads reuse the bare repository table key, the same key as `notes.list`, even when the contract uses `keyScope: "session"`; record and bucket reads also use plain server keys. They add no wildcard matching or write-side work. Every committed repository insert, update, delete, upsert and bulk write already publishes that key. Generated-id inserts also publish the bare collection key alongside their generated record key, so `publishes` stories that check exact published keys must allow the bare key today. For a table named `notes`, that is `"notes"` alongside `"notes:<id>"` and any affected bucket keys. Mounting a collection subscriber adds **zero PostgreSQL NOTIFY messages per write**: it consumes the existing payloads. It adds a normal query subscription and an authorized reread when the collection changes.
508
573
 
509
574
  For dependencies that need server data, add `serverReads(payload, viewer)`, an Effect returning extra keys. Keep `reads` for keys the browser can derive, or return `[]` there. The server checks every referenced query's policy before it runs any `serverReads`, and resolves it with the owning query handler's services. Declare its failures in the query's `rejections`, as with policy failures. A denied subscription never runs the resolver.
510
575
 
@@ -563,9 +628,9 @@ The server provides `NoteOwner`; the shared declaration holds only its browser-s
563
628
 
564
629
  A record key, `notes.item(id)`, names one record. A bucket, `notes.bucket.userId(id)`, names every row with that field value. Declare bucket fields on the collection model with their schemas. A list may add title, state or other filters to its input and handler, but those filters never narrow its bucket. It reruns whenever any row in that bucket changes, including a row excluded by the filter. Writers explicitly announce the record and affected buckets with the same constructors from `@shivaedev/changes/keys.ts`.
565
630
 
566
- The same query policy guards running the query and subscribing to it. A subscription is meant to carry one query. It names query references, never arbitrary record or bucket keys. If a subscription mixes queries the viewer may and may not read, the entire subscription is refused with `QueryReadDenied`; it delivers no partial set of hints. Every query requires `readPolicy` at declaration, including queries used only through one-off `run` calls. TypeScript rejects a policy-less declaration before handlers or a live server can be built. Platform’s application host validates the complete RPC group while building its Layer, before listening; untyped declarations missing policies fail with `MissingReadPolicies`, whose `queries` and `message` name every affected RPC. Native hosts can run `validateReadPolicies(group)` during their own Layer construction. `MissingReadPolicy` remains a request-time refusal for untyped declarations served through native servers that bypass that boot check, on plain calls and subscriptions alike. Reads outside a declared query acquire no automatic subscription.
631
+ The same query policy guards running the query and subscribing to it. A subscription is meant to carry one query. It names query references, never arbitrary record or bucket keys. If a subscription mixes queries the viewer may and may not read, the entire subscription is refused with `QueryReadDenied`; it delivers no partial set of hints. Every query requires `readPolicy` at declaration, including queries used only through one-off `run` calls. TypeScript rejects a policy-less declaration before handlers or a live server can be built. Platform’s application host validates the complete RPC group while building its Layer, before listening; untyped declarations missing policies fail with `MissingReadPolicies`, whose `queries` and `message` name every affected RPC. Native hosts enforce read policies automatically at request time. `MissingReadPolicy` remains a request-time refusal for untyped declarations served through native servers that bypass that boot check, on plain calls and subscriptions alike. Reads outside a declared query acquire no automatic subscription.
567
632
 
568
- The session middleware supplies the viewer and runs `authorizeReads(effect, request, viewer)`. Custom middleware calls that function after resolving its session and declares `MissingReadPolicy` and `QueryReadDenied` in its error schema. Before delivering changed keys, the stream rechecks the owning query's policy without memoization. In a session-backed host, a signed-out, revoked or expired session ends the subscription with `Unauthorized`; a signed-in viewer whose policy refuses receives a `QueryReadDenied` delivery while the established subscription stays open. A later authorized hint resumes delivery, including an unchanged pushed value. An initial subscription refusal still fails the stream with `QueryReadDenied`. Custom stream consumers handle the denial delivery alongside `Changed`, `Resync` and `Result`; `SubscriptionHint` from `queryUpdate.ts` types hint consumers. This distinction is the same whether a change hint or the session revalidation interval detects session removal. A client refresh runs the same authorized query that produced its first value; hints carry no row values.
633
+ Session middleware supplies `CurrentViewer`; the guard attached to each contract query owns policy evaluation. Custom authentication middleware provides that viewer after validating its session. Before delivering changed keys, the stream rechecks the owning query's policy without memoization. In a session-backed host, a signed-out, revoked or expired session ends the subscription with `Unauthorized`; a signed-in viewer whose policy refuses receives a `QueryReadDenied` delivery while the established subscription stays open. A later authorized hint resumes delivery, including an unchanged pushed value. An initial subscription refusal still fails the stream with `QueryReadDenied`. Custom stream consumers handle the denial delivery alongside `Changed`, `Resync` and `Result`; `SubscriptionHint` from `queryUpdate.ts` types hint consumers. This distinction is the same whether a change hint or the session revalidation interval detects session removal. A client refresh runs the same authorized query that produced its first value; hints carry no row values.
569
634
 
570
635
  ### Policy services
571
636
 
@@ -630,12 +695,12 @@ The generated subscription uses the owning query handler's captured services too
630
695
 
631
696
  ### In-memory clients in story kits
632
697
 
633
- `layerMemoryProtocol(group)` from `@shivaedev/contract/testing.ts` connects the native RPC client and server in the same process. Provide the group's handlers and middleware with `Layer.provide`, then pass the protocol to the application's client factory:
698
+ `layerMemoryProtocol(group)` from `@shivaedev/test-kits/contract/testing.ts` connects the native RPC client and server in the same process. Provide the group's handlers and middleware with `Layer.provide`, then pass the protocol to the application's client factory:
634
699
 
635
700
  ```ts
636
701
  import { Layer } from "effect";
637
702
  import { makeClient } from "@shivaedev/contract/bind.ts";
638
- import { layerMemoryProtocol } from "@shivaedev/contract/testing.ts";
703
+ import { layerMemoryProtocol } from "@shivaedev/test-kits/contract/testing.ts";
639
704
 
640
705
  const client = makeClient(Notes, {
641
706
  protocol: layerMemoryProtocol(Notes).pipe(Layer.provide(handlers)),
@@ -647,7 +712,7 @@ The URL identifies the client configuration; the in-memory protocol opens no soc
647
712
 
648
713
  ### Live hints in stories
649
714
 
650
- Use `watchHints` and `heard` from `@shivaedev/contract/testing.ts` in an application's story kit. Pass each viewer's authenticated live stream to `watchHints`; it starts a scoped subscription and waits for its first hint before returning the viewer handle.
715
+ Use `watchHints` and `heard` from `@shivaedev/test-kits/contract/testing.ts` in an application's story kit. Pass each viewer's authenticated live stream to `watchHints`; it starts a scoped subscription and waits for its first hint before returning the viewer handle.
651
716
 
652
717
  ```ts
653
718
  const alice = yield* watchHints(aliceChanges);
@@ -670,19 +735,22 @@ Import the module that defines the name; the package has no root entry.
670
735
  | `rejection.ts` | `fieldRejection(struct, fields?)`; lower-level `rejectionSet(specs)`, which constructs the rejection classes, union schema and failure helpers used by operations. |
671
736
  | `bind.ts` | `bind(contract, atomRpcService, { registry?, live?, resume?, resumeWindow? }?)`, requiring the registry for session-scoped contracts and exposing `{ query, run }` for queries, `{ run }` Effects for commands and `{ run }` native Streams for streams; `makeClient(contract, { url, protocol?, headers?, webSocketConstructor?, group?, registry?, live?, resume?, resumeWindow? })`, which builds the shared WebSocket client and binds it. |
672
737
  | `queryCoalesceWindow.ts` | `queryCoalesceWindow(query)`, a writable atom for a bound query's live changed-hint window. |
738
+ | `clientKeys.ts` | `KeyContext`, `clientReadKeys`, `clientInvalidationKeys`: registry-local cache keys for custom clients. |
673
739
  | `live.ts` | `LiveHint` schema; `live(runtime, { stream, resyncKeys, coalesceWindow?, initialResync?, keyContext?, resume?, retryDelay?, retryKeys? })`, exposing `connection`, `coalesceWindow`, `paused` and `status`. |
674
740
  | `querySubscription.ts` | `querySubscription(rpc, references, viewer)` checks each referenced query, resolves its payload and server-derived keys, and captures its scopes and ongoing authorization. |
675
741
  | `LiveServer.ts` | `LiveServer`, the shared live server service and its `.layer`, requiring `Reactivity`. |
676
742
  | `makeLiveServer.ts` | `makeLiveServer`, an Effect requiring `Reactivity` that creates scoped server hint streams and a `resync` Effect. |
677
- | `readPolicy.ts` | `QueryReadPolicy`, `Viewer`, `signedIn`, `authorizeReads(effect, request, viewer)`, `CurrentViewer`. |
743
+ | `readPolicy.ts` | `QueryReadPolicy`, `Viewer`, `signedIn`, `CurrentViewer`; `authorizeReads(effect, request, viewer)` for direct handler reruns outside RPC middleware. |
744
+ | `ReadPolicyGuard.ts` | `ReadPolicyGuard`, the defaulted middleware reference attached to contract queries; `readPolicyGuardLayer({ websocket? })`, an optional override that refuses HTTP `$changes` calls by default. |
678
745
  | `validateReadPolicies.ts` | `validateReadPolicies(group)`, an Effect that fails with `MissingReadPolicies` when any served or subscribable query omits its policy. |
679
746
  | `readPolicyErrors.ts` | `MissingReadPolicies` (boot), `MissingReadPolicy` (native-server request fallback) and `QueryReadDenied`. |
747
+ | `CommandGuard.ts` | `guardCommands(group)` places command publication inside viewer-providing middleware; `commandGuardLayer(boundary)` evaluates declared invalidations for that viewer and delegates publication to the host boundary. |
680
748
  | `serverMetadata.ts` | `KeyScope`, `QueryDefinition.definition`, `CommandInvalidation.invalidates`, `ChangesQueries.queries`, `ChangesQueries.resolve(references)` and `changesRpc(name, queries)` for server adapters. |
681
749
  | `queryKeys.ts` | `queryKeys(queries, references, viewer?)` authorizes references and resolves payload and server-derived keys using the provided services. |
682
750
  | `QueryServerReads.ts` | `QueryServerReads<Payload, E, R>`, the server-only resolver type. |
683
751
  | `resume.ts` | `resumeSignal({ window?, native? })`, returning a native numeric signal atom. |
684
- | `clientActivity.ts` | `clientActivity(client)` exposes a native activity Stream with a `current` Effect; `isClientIdle(state)` checks finite work. |
685
- | `testing.ts` | `layerMemoryProtocol(group)` supplies an in-memory native RPC protocol backed by the group’s handlers and middleware; `watchHints(stream)` starts a scoped viewer subscription; `heard(viewer, keys, { within? }?)` waits for matching changed keys. |
752
+ | `querySignals.ts` | `querySignals(query)` exposes completion counts and subscription status as a native atom. |
753
+ | `clientActivity.ts` | `clientActivity(client)` exposes a native activity Stream with a `current` Effect; `isClientIdle(state)` checks finite work; `activityScreenSignal(activity)` projects pending work and hints for screen waits. |
686
754
 
687
755
  A query atom takes native query options as its optional second argument, for example `api.get.query({ id: 1 }, { timeToLive: "1 minute" })`. A native resume source receives a callback and returns a cleanup function.
688
756
 
@@ -0,0 +1,10 @@
1
+ import { Effect, Layer } from "effect";
2
+ import { type Rpc, type RpcGroup, RpcMiddleware } from "effect/rpc";
3
+ export type CommandBoundary = <A, E, R>(effect: Effect.Effect<A, E, R>, keys: (result: A) => readonly unknown[]) => Effect.Effect<A, E, R>;
4
+ declare const CommandGuard_base: RpcMiddleware.ServiceClass<CommandGuard, "@shivaedev/contract/CommandGuard", never, import("effect/Schema").Never, never, never, false>;
5
+ export declare class CommandGuard extends CommandGuard_base {
6
+ }
7
+ export declare function commandGuardLayer(boundary: CommandBoundary): Layer.Layer<CommandGuard>;
8
+ export declare function guardCommands<R extends Rpc.Any>(group: RpcGroup.RpcGroup<R>): Effect.Effect<RpcGroup.RpcGroup<Rpc.AddMiddleware<R, typeof CommandGuard>>, never, never>;
9
+ export {};
10
+ //# sourceMappingURL=CommandGuard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandGuard.d.ts","sourceRoot":"","sources":["../src/CommandGuard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAE,KAAK,EAAU,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAMpE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,SAAS,OAAO,EAAE,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;;AAE3I,qBAAa,YAAa,SAAQ,iBAAyE;CAAG;AAE9G,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,eAAe,GAAG,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,CAStF;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,6FAE3E"}
@@ -0,0 +1,20 @@
1
+ import { Context, Effect, Layer, Option } from "effect";
2
+ import { RpcMiddleware } from "effect/rpc";
3
+ import { invalidationKeys } from "@shivaedev/changes/keys.ts";
4
+ import { prependMiddleware } from "#internal/prependMiddleware.ts";
5
+ import { CurrentViewer } from "#readPolicy.ts";
6
+ import { CommandInvalidation } from "#serverMetadata.ts";
7
+ export class CommandGuard extends RpcMiddleware.Service()("@shivaedev/contract/CommandGuard") {
8
+ }
9
+ export function commandGuardLayer(boundary) {
10
+ return Layer.succeed(CommandGuard, (effect, { rpc, payload }) => {
11
+ const declaration = Context.getOption(rpc.annotations, CommandInvalidation);
12
+ return Option.isNone(declaration)
13
+ ? effect
14
+ : Effect.flatMap(CurrentViewer, (viewer) => boundary(effect, (result) => invalidationKeys(declaration.value.invalidates(payload, result, viewer))));
15
+ });
16
+ }
17
+ export function guardCommands(group) {
18
+ return prependMiddleware(group.middleware(CommandGuard), CommandGuard.key);
19
+ }
20
+ //# sourceMappingURL=CommandGuard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandGuard.js","sourceRoot":"","sources":["../src/CommandGuard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAA2B,aAAa,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAIzD,MAAM,OAAO,YAAa,SAAQ,aAAa,CAAC,OAAO,EAAgB,CAAC,kCAAkC,CAAC;CAAG;AAE9G,MAAM,UAAU,iBAAiB,CAAC,QAAyB;IAC1D,OAAO,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;QAC/D,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;QAC5E,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;YAChC,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,MAAM,EAAE,EAAE,CACzC,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CACtG,CAAC;IACL,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAoB,KAA2B;IAC3E,OAAO,iBAAiB,CAAC,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;AAC5E,CAAC"}
@@ -1,10 +1,12 @@
1
- import { Effect } from "effect";
1
+ import { Effect, type Stream } from "effect";
2
2
  import * as Reactivity from "effect/reactivity/Reactivity";
3
- import type { Key, KeyContext } from "@shivaedev/changes/keys.ts";
3
+ import type { Key } from "@shivaedev/changes/keys.ts";
4
4
  import type { QueryRerun, QuerySubscription } from "#querySubscription.ts";
5
+ import type { QueryUpdate, SubscriptionHint } from "#queryUpdate.ts";
6
+ import type { QueryReadDenied } from "#readPolicyErrors.ts";
5
7
  export declare const LiveServer: import("effect/Context").Service<"@shivaedev/contract/LiveServer", Readonly<{
6
8
  readonly resync: () => Effect.Effect<number, never, never>;
7
- readonly stream: (keys: readonly Key[], context?: KeyContext | undefined) => Effect.Effect<import("effect/Stream").Stream<{
9
+ readonly stream: (keys: readonly Key[]) => Effect.Effect<Stream.Stream<{
8
10
  readonly _tag: "Changed";
9
11
  readonly keys: readonly ({
10
12
  readonly _tag: "Bucket";
@@ -23,7 +25,7 @@ export declare const LiveServer: import("effect/Context").Service<"@shivaedev/co
23
25
  } | {
24
26
  readonly _tag: "Resync";
25
27
  }, never, never>, never, never>;
26
- readonly subscribe: <E, R>(subscription: QuerySubscription<E, R>, context?: KeyContext, read?: QueryRerun<E, R>) => Effect.Effect<import("effect/Stream").Stream<import("./queryUpdate.ts").QueryUpdate, E | import("./readPolicyErrors.ts").QueryReadDenied, R>, never, never>;
28
+ readonly subscribe: <E, R, TRead extends QueryRerun<unknown, unknown> | undefined = undefined>(subscription: QuerySubscription<E, R>, read?: (TRead & (QueryRerun<E, R> | undefined)) | undefined) => Effect.Effect<Stream.Stream<TRead extends undefined ? SubscriptionHint : QueryUpdate, E | QueryReadDenied, R>>;
27
29
  }>> & {
28
30
  readonly layer: import("effect/Layer").Layer<"@shivaedev/contract/LiveServer", never, Reactivity.Reactivity>;
29
31
  };
@@ -1 +1 @@
1
- {"version":3,"file":"LiveServer.d.ts","sourceRoot":"","sources":["../src/LiveServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAIlE,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE3E,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;yBAMK,CAAC,EAAE,CAAC,gBAAgB,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,YAAY,UAAU,SAAS,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;;;CAKpH,CAAC"}
1
+ {"version":3,"file":"LiveServer.d.ts","sourceRoot":"","sources":["../src/LiveServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AAItD,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;yBAIF,CAAC,EAAE,CAAC,EAAE,KAAK,SAAS,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,SAAS,4BAChE,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,kEAEnC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,SAAS,SAAS,GAAG,gBAAgB,GAAG,WAAW,EAAE,CAAC,GAAG,eAAe,EAAE,CAAC,CAAC,CAAC;;;CAWjH,CAAC"}
@@ -6,11 +6,16 @@ import { makeLiveServer } from "#makeLiveServer.ts";
6
6
  export const LiveServer = defineService({
7
7
  id: "@shivaedev/contract/LiveServer",
8
8
  initialize: makeLiveServer,
9
- methods: (server) => ({
10
- resync: () => server.resync,
11
- stream: (keys, context) => Effect.succeed(server.stream(keys, context)),
12
- subscribe: genericMethod((subscription, context, read) => Effect.succeed(read === undefined ? server.subscribe(subscription, context) : server.subscribe(subscription, context, read))),
13
- }),
9
+ methods: (server) => {
10
+ function subscribe(subscription, read) {
11
+ return Effect.succeed(read === undefined ? server.subscribe(subscription) : server.subscribe(subscription, read));
12
+ }
13
+ return {
14
+ resync: () => server.resync,
15
+ stream: (keys) => Effect.succeed(server.stream(keys)),
16
+ subscribe: genericMethod(subscribe),
17
+ };
18
+ },
14
19
  requires: [Reactivity.Reactivity],
15
20
  });
16
21
  //# sourceMappingURL=LiveServer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LiveServer.js","sourceRoot":"","sources":["../src/LiveServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,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SAAS,CAAO,YAAqC,EAAE,IAAuB;YACtF,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;QACnH,CAAC;QACD,OAAO;YACN,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM;YAC3B,MAAM,EAAE,CAAC,IAAoB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACrE,SAAS,EAAE,aAAa,CAAC,SAAS,CAAC;SACnC,CAAC;IACH,CAAC;IACD,QAAQ,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;CACjC,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { Context, Effect, Layer, Schema, type Types } from "effect";
2
+ import { type Rpc } from "effect/rpc";
3
+ import { MissingReadPolicy, QueryReadDenied } from "#readPolicyErrors.ts";
4
+ import { WebSocketRequired } from "#WebSocketRequired.ts";
5
+ declare function readPolicyGuard<A, E, R>(effect: Effect.Effect<A, E, R>, request: {
6
+ readonly rpc: Rpc.Any;
7
+ readonly payload: unknown;
8
+ }): Effect.Effect<A, E | MissingReadPolicy | QueryReadDenied | WebSocketRequired | Types.unhandled, R>;
9
+ export declare const ReadPolicyGuard: Context.Reference<typeof readPolicyGuard> & {
10
+ "~effect/rpc/RpcMiddleware": "~effect/rpc/RpcMiddleware";
11
+ "~ClientError": never;
12
+ error: Schema.Union<readonly [typeof MissingReadPolicy, typeof QueryReadDenied, typeof WebSocketRequired]>;
13
+ requiredForClient: false;
14
+ };
15
+ export declare function readPolicyGuardLayer(options?: {
16
+ readonly websocket?: boolean;
17
+ }): Layer.Layer<never, never, never>;
18
+ export {};
19
+ //# sourceMappingURL=ReadPolicyGuard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadPolicyGuard.d.ts","sourceRoot":"","sources":["../src/ReadPolicyGuard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAE,KAAK,GAAG,EAAiB,MAAM,YAAY,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,iBAAS,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC9B,OAAO,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAC3D,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,iBAAiB,GAAG,eAAe,GAAG,iBAAiB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAEpG;AAMD,eAAO,MAAM,eAAe;;;;;CAK1B,CAAC;AAEH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE;IAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,oCAMlF"}
@@ -0,0 +1,23 @@
1
+ import { Context, Effect, Layer, Schema } from "effect";
2
+ import { RpcMiddleware } from "effect/rpc";
3
+ import { authorizeReads, CurrentViewer } from "#readPolicy.ts";
4
+ import { MissingReadPolicy, QueryReadDenied } from "#readPolicyErrors.ts";
5
+ import { WebSocketRequired } from "#WebSocketRequired.ts";
6
+ function readPolicyGuard(effect, request) {
7
+ return Effect.flatMap(CurrentViewer, (viewer) => authorizeReads(effect, request, viewer));
8
+ }
9
+ const middleware = RpcMiddleware.Service()("@shivaedev/contract/ReadPolicyGuard", {
10
+ error: Schema.Union([MissingReadPolicy, QueryReadDenied, WebSocketRequired]),
11
+ });
12
+ export const ReadPolicyGuard = Object.assign(Context.Reference("@shivaedev/contract/ReadPolicyGuard", { defaultValue: () => readPolicyGuard }), {
13
+ [RpcMiddleware.TypeId]: middleware[RpcMiddleware.TypeId],
14
+ "~ClientError": middleware["~ClientError"],
15
+ error: middleware.error,
16
+ requiredForClient: middleware.requiredForClient,
17
+ });
18
+ export function readPolicyGuardLayer(options = {}) {
19
+ return Layer.succeed(ReadPolicyGuard, (effect, request) => !options.websocket && request.rpc._tag.endsWith(".$changes")
20
+ ? Effect.fail(new WebSocketRequired({ message: `${request.rpc._tag} needs the WebSocket protocol` }))
21
+ : readPolicyGuard(effect, request));
22
+ }
23
+ //# sourceMappingURL=ReadPolicyGuard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadPolicyGuard.js","sourceRoot":"","sources":["../src/ReadPolicyGuard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,SAAS,eAAe,CACvB,MAA8B,EAC9B,OAA6D;IAE7D,OAAO,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAC3F,CAAC;AAED,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,EAAS,CAAC,qCAAqC,EAAE;IACxF,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,eAAe,EAAE,iBAAiB,CAAC,CAAC;CAC5E,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,qCAAqC,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,EAAE;IAC/I,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC;IACxD,cAAc,EAAE,UAAU,CAAC,cAAc,CAAC;IAC1C,KAAK,EAAE,UAAU,CAAC,KAAK;IACvB,iBAAiB,EAAE,UAAU,CAAC,iBAAiB;CAC/C,CAAC,CAAC;AAEH,MAAM,UAAU,oBAAoB,CAAC,OAAO,GAAqC,EAAE;IAClF,OAAO,KAAK,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CACzD,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC3D,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,iBAAiB,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,+BAA+B,EAAE,CAAC,CAAC;QACrG,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,CACnC,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { Effect } from "effect";
2
+ import type { ClientActivityState } from "#clientActivity.ts";
3
+ export declare function activityState(): {
4
+ activity: import("effect/Stream").Stream<ClientActivityState, never, never> & {
5
+ current: Effect.Effect<ClientActivityState, never, never>;
6
+ };
7
+ change: (key: keyof ClientActivityState, delta: number) => void;
8
+ };
9
+ //# sourceMappingURL=activityState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activityState.d.ts","sourceRoot":"","sources":["../../src/adapters/activityState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmB,MAAM,QAAQ,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,wBAAgB,aAAa;IAG3B,QAAQ;;;IACR,MAAM,QAAQ,MAAM,mBAAmB,SAAS,MAAM;EAIvD"}
@@ -0,0 +1,11 @@
1
+ import { Effect, SubscriptionRef } from "effect";
2
+ export function activityState() {
3
+ const state = Effect.runSync(SubscriptionRef.make({ liveHints: 0, liveInvalidations: 0, refreshingAtoms: 0, rpcCalls: 0 }));
4
+ return {
5
+ activity: Object.assign(SubscriptionRef.changes(state), { current: SubscriptionRef.get(state) }),
6
+ change: (key, delta) => {
7
+ Effect.runSync(SubscriptionRef.update(state, (current) => ({ ...current, [key]: current[key] + delta })));
8
+ },
9
+ };
10
+ }
11
+ //# sourceMappingURL=activityState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activityState.js","sourceRoot":"","sources":["../../src/adapters/activityState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAGjD,MAAM,UAAU,aAAa;IAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAsB,EAAE,SAAS,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACjJ,OAAO;QACN,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAChG,MAAM,EAAE,CAAC,GAA8B,EAAE,KAAa,EAAE,EAAE;YACzD,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3G,CAAC;KACD,CAAC;AACH,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type * as AtomRegistry from "effect/reactivity/AtomRegistry";
2
- import type { KeyContext } from "@shivaedev/changes/keys.ts";
2
+ import type { KeyContext } from "#clientKeys.ts";
3
3
  export interface BindingOwner {
4
4
  readonly context: KeyContext;
5
5
  readonly registry: AtomRegistry.AtomRegistry;
@@ -1 +1 @@
1
- {"version":3,"file":"bindingOwner.d.ts","sourceRoot":"","sources":["../../src/internal/bindingOwner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,YAAY,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAC;CAC7C;AAID,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,YAAY,CAAC,YAAY,GAAG,YAAY,GAAG,SAAS,CAazH"}
1
+ {"version":3,"file":"bindingOwner.d.ts","sourceRoot":"","sources":["../../src/adapters/bindingOwner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,YAAY,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAC;CAC7C;AAID,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,YAAY,CAAC,YAAY,GAAG,YAAY,GAAG,SAAS,CAazH"}
@@ -1,3 +1,4 @@
1
+ import { clientId } from "./clientId.js";
1
2
  const contexts = new WeakMap();
2
3
  export function bindingOwner(scope, registry) {
3
4
  if (scope === undefined) {
@@ -8,7 +9,7 @@ export function bindingOwner(scope, registry) {
8
9
  }
9
10
  let context = contexts.get(registry);
10
11
  if (context === undefined) {
11
- context = { scope: crypto.randomUUID() };
12
+ context = { scope: clientId() };
12
13
  contexts.set(registry, context);
13
14
  }
14
15
  return { context, registry };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bindingOwner.js","sourceRoot":"","sources":["../../src/adapters/bindingOwner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAOzC,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAyC,CAAC;AAEtE,MAAM,UAAU,YAAY,CAAC,KAA4B,EAAE,QAAoC;IAC9F,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACrC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC;QAChC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function clientId(): string;
2
+ //# sourceMappingURL=clientId.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientId.d.ts","sourceRoot":"","sources":["../../src/adapters/clientId.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,IAAI,MAAM,CAEjC"}
@@ -0,0 +1,4 @@
1
+ export function clientId() {
2
+ return crypto.randomUUID();
3
+ }
4
+ //# sourceMappingURL=clientId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientId.js","sourceRoot":"","sources":["../../src/adapters/clientId.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ;IACvB,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;AAC5B,CAAC"}
@@ -5,7 +5,7 @@ import * as Atom from "effect/reactivity/Atom";
5
5
  import type * as AtomRpc from "effect/reactivity/AtomRpc";
6
6
  import type { Rpc, RpcSchema } from "effect/rpc";
7
7
  import type { Key } from "@shivaedev/changes/keys.ts";
8
- import type { BindingOwner } from "#internal/bindingOwner.ts";
8
+ import type { BindingOwner } from "#adapters/bindingOwner.ts";
9
9
  import { type LiveStatus } from "#live.ts";
10
10
  import type { QueryUpdate } from "#queryUpdate.ts";
11
11
  import { type ResumeSource, type ResumeWindow } from "#resume.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"automaticLive.d.ts","sourceRoot":"","sources":["../src/automaticLive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAU,KAAK,MAAM,EAAU,MAAM,QAAQ,CAAC;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,KAAK,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AAGtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BA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