@shivaedev/contract 0.39.0 → 0.41.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 (152) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +39 -32
  3. package/dist/AutomaticQueryOptions.d.ts +22 -0
  4. package/dist/AutomaticQueryOptions.d.ts.map +1 -0
  5. package/dist/AutomaticQueryOptions.js +2 -0
  6. package/dist/AutomaticQueryOptions.js.map +1 -0
  7. package/dist/adapters/LiveDispatcher.d.ts +9 -0
  8. package/dist/adapters/LiveDispatcher.d.ts.map +1 -0
  9. package/dist/adapters/LiveDispatcher.js +5 -0
  10. package/dist/adapters/LiveDispatcher.js.map +1 -0
  11. package/dist/adapters/activityState.d.ts.map +1 -1
  12. package/dist/adapters/activityState.js +9 -1
  13. package/dist/adapters/activityState.js.map +1 -1
  14. package/dist/adapters/liveHintStream.d.ts +30 -0
  15. package/dist/adapters/liveHintStream.d.ts.map +1 -0
  16. package/dist/adapters/liveHintStream.js +10 -0
  17. package/dist/adapters/liveHintStream.js.map +1 -0
  18. package/dist/adapters/openLiveHints.d.ts +30 -0
  19. package/dist/adapters/openLiveHints.d.ts.map +1 -0
  20. package/dist/adapters/openLiveHints.js +59 -0
  21. package/dist/adapters/openLiveHints.js.map +1 -0
  22. package/dist/adapters/refreshSubscription.d.ts +4 -0
  23. package/dist/adapters/refreshSubscription.d.ts.map +1 -0
  24. package/dist/adapters/refreshSubscription.js +5 -0
  25. package/dist/adapters/refreshSubscription.js.map +1 -0
  26. package/dist/adapters/standaloneLiveServer.d.ts +32 -0
  27. package/dist/adapters/standaloneLiveServer.d.ts.map +1 -0
  28. package/dist/adapters/standaloneLiveServer.js +13 -0
  29. package/dist/adapters/standaloneLiveServer.js.map +1 -0
  30. package/dist/adapters/withClientProtocol.d.ts +4 -0
  31. package/dist/adapters/withClientProtocol.d.ts.map +1 -0
  32. package/dist/adapters/withClientProtocol.js +6 -0
  33. package/dist/adapters/withClientProtocol.js.map +1 -0
  34. package/dist/adapters/withPolicyContext.d.ts +4 -0
  35. package/dist/adapters/withPolicyContext.d.ts.map +1 -0
  36. package/dist/adapters/withPolicyContext.js +7 -0
  37. package/dist/adapters/withPolicyContext.js.map +1 -0
  38. package/dist/automaticLive.d.ts +1 -1
  39. package/dist/automaticLive.d.ts.map +1 -1
  40. package/dist/automaticLive.js +9 -7
  41. package/dist/automaticLive.js.map +1 -1
  42. package/dist/automaticQuery.d.ts +3 -17
  43. package/dist/automaticQuery.d.ts.map +1 -1
  44. package/dist/automaticQuery.js +12 -7
  45. package/dist/automaticQuery.js.map +1 -1
  46. package/dist/changesSuccess.d.ts +2 -3
  47. package/dist/changesSuccess.d.ts.map +1 -1
  48. package/dist/changesSuccess.js +2 -4
  49. package/dist/changesSuccess.js.map +1 -1
  50. package/dist/clientActivities.d.ts +2 -2
  51. package/dist/clientActivities.d.ts.map +1 -1
  52. package/dist/clientActivities.js +28 -12
  53. package/dist/clientActivities.js.map +1 -1
  54. package/dist/clientActivity.d.ts +4 -1
  55. package/dist/clientActivity.d.ts.map +1 -1
  56. package/dist/clientActivity.js +5 -2
  57. package/dist/clientActivity.js.map +1 -1
  58. package/dist/clientOperations.d.ts.map +1 -1
  59. package/dist/clientOperations.js +1 -1
  60. package/dist/clientOperations.js.map +1 -1
  61. package/dist/compareQueries.d.ts +1 -1
  62. package/dist/compareQueries.d.ts.map +1 -1
  63. package/dist/compareQueries.js +10 -4
  64. package/dist/compareQueries.js.map +1 -1
  65. package/dist/live-server/initialize.d.ts +6 -0
  66. package/dist/live-server/initialize.d.ts.map +1 -0
  67. package/dist/live-server/initialize.js +7 -0
  68. package/dist/live-server/initialize.js.map +1 -0
  69. package/dist/live-server/layer.d.ts +3 -0
  70. package/dist/live-server/layer.d.ts.map +1 -0
  71. package/dist/live-server/layer.js +5 -0
  72. package/dist/live-server/layer.js.map +1 -0
  73. package/dist/live-server/register.d.ts +26 -0
  74. package/dist/live-server/register.d.ts.map +1 -0
  75. package/dist/live-server/register.js +8 -0
  76. package/dist/live-server/register.js.map +1 -0
  77. package/dist/live-server/resync.d.ts +4 -3
  78. package/dist/live-server/resync.d.ts.map +1 -1
  79. package/dist/live-server/resync.js +8 -2
  80. package/dist/live-server/resync.js.map +1 -1
  81. package/dist/live-server/service.d.ts +49 -0
  82. package/dist/live-server/service.d.ts.map +1 -0
  83. package/dist/live-server/service.js +19 -0
  84. package/dist/live-server/service.js.map +1 -0
  85. package/dist/live-server/stream.d.ts +4 -4
  86. package/dist/live-server/stream.d.ts.map +1 -1
  87. package/dist/live-server/stream.js +6 -3
  88. package/dist/live-server/stream.js.map +1 -1
  89. package/dist/live-server/subscribe.d.ts +3 -4
  90. package/dist/live-server/subscribe.d.ts.map +1 -1
  91. package/dist/live-server/subscribe.js +28 -6
  92. package/dist/live-server/subscribe.js.map +1 -1
  93. package/dist/liveAttempt.d.ts.map +1 -1
  94. package/dist/liveAttempt.js +8 -2
  95. package/dist/liveAttempt.js.map +1 -1
  96. package/dist/makeLiveServer.d.ts +5 -10
  97. package/dist/makeLiveServer.d.ts.map +1 -1
  98. package/dist/makeLiveServer.js +3 -90
  99. package/dist/makeLiveServer.js.map +1 -1
  100. package/dist/publicConfig.d.ts +6 -1
  101. package/dist/publicConfig.d.ts.map +1 -1
  102. package/dist/queryDelivery.d.ts +3 -1
  103. package/dist/queryDelivery.d.ts.map +1 -1
  104. package/dist/queryDelivery.js +18 -5
  105. package/dist/queryDelivery.js.map +1 -1
  106. package/dist/queryHints.js +1 -1
  107. package/dist/queryHints.js.map +1 -1
  108. package/dist/querySubscription.js +5 -11
  109. package/dist/querySubscription.js.map +1 -1
  110. package/dist/readPolicy.d.ts.map +1 -1
  111. package/dist/readPolicy.js +2 -3
  112. package/dist/readPolicy.js.map +1 -1
  113. package/dist/rpcClient.d.ts +1 -1
  114. package/dist/rpcClient.d.ts.map +1 -1
  115. package/dist/rpcClient.js +6 -3
  116. package/dist/rpcClient.js.map +1 -1
  117. package/package.json +8 -8
  118. package/src/AutomaticQueryOptions.ts +22 -0
  119. package/src/adapters/LiveDispatcher.ts +10 -0
  120. package/src/adapters/activityState.ts +9 -1
  121. package/src/adapters/liveHintStream.ts +15 -0
  122. package/src/adapters/openLiveHints.ts +62 -0
  123. package/src/adapters/refreshSubscription.ts +6 -0
  124. package/src/adapters/standaloneLiveServer.ts +19 -0
  125. package/src/adapters/withClientProtocol.ts +10 -0
  126. package/src/adapters/withPolicyContext.ts +8 -0
  127. package/src/automaticLive.ts +11 -7
  128. package/src/automaticQuery.ts +16 -21
  129. package/src/changesSuccess.ts +11 -14
  130. package/src/clientActivities.ts +29 -12
  131. package/src/clientActivity.ts +8 -2
  132. package/src/clientOperations.ts +4 -2
  133. package/src/compareQueries.ts +10 -4
  134. package/src/live-server/initialize.ts +7 -0
  135. package/src/live-server/layer.ts +5 -0
  136. package/src/live-server/register.ts +10 -0
  137. package/src/live-server/resync.ts +9 -4
  138. package/src/live-server/service.ts +19 -0
  139. package/src/live-server/stream.ts +7 -4
  140. package/src/live-server/subscribe.ts +43 -12
  141. package/src/liveAttempt.ts +10 -2
  142. package/src/makeLiveServer.ts +3 -104
  143. package/src/queryDelivery.ts +22 -5
  144. package/src/queryHints.ts +1 -1
  145. package/src/querySubscription.ts +8 -11
  146. package/src/readPolicy.ts +2 -3
  147. package/src/rpcClient.ts +10 -8
  148. package/dist/LiveServer.d.ts +0 -27
  149. package/dist/LiveServer.d.ts.map +0 -1
  150. package/dist/LiveServer.js +0 -18
  151. package/dist/LiveServer.js.map +0 -1
  152. package/src/LiveServer.ts +0 -18
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.41.0 - 2026-11-06
4
+
5
+ ### Added
6
+
7
+ - Activity reports commands in flight and mounted queries awaiting their first result. `isClientSettled` checks these counts using the contract's command metadata.
8
+
9
+ ### Changed
10
+
11
+ - Live query subscriptions deliver their first authorized result after registering read keys, removing the separate initial query request for bound queries and route loaders. Later updates retain hint-then-read or the query's chosen rerun-and-compare behavior.
12
+
13
+ ### Breaking
14
+
15
+ - Every contract's `$changes` success type includes typed `Result` values. Custom stream consumers must handle results as well as hints; custom subscription hosts pass their authorized query runner to `subscribe(subscription, read)` to deliver the initial value.
16
+ - Direct `automaticLive().query` callers now supply a result decoder, comparison flag and reactive source factory. Direct `queryDelivery` callers supply the decoder and comparison flag, and `automaticQuery` callers pass the delivery's `version` as `resultVersion` and `updates` as `subscriptionVersion`. Use `bind` or `makeClient` to obtain this wiring automatically.
17
+ - Screen signals from `activityScreenSignal(activity)` now settle on commands and first query results, allowing live queries to remain open or await later refreshes. Code constructing `ClientActivityState` values must supply `commands` and `initialQueries`. To retain full finite-work settling, pass `isClientIdle` as the second argument. Start `nextLiveHint()` before an outside write when a story needs its next live change, then settle through that refresh with the full idle signal.
18
+
19
+ ## 0.40.0 - 2026-11-05
20
+
21
+ ### Added
22
+
23
+ - `LiveServer.register(keys)` returns a scoped registration stream whose read keys can be replaced while it is consumed.
24
+
25
+ ### Breaking
26
+
27
+ - Import `LiveServer` from `@shivaedev/contract/live-server/service.ts`. Replace `live.subscribe(subscription, read?)` with `subscribe(subscription, read?)` from `@shivaedev/contract/live-server/subscribe.ts`; replace `LiveServer.layer` with `liveServerLayer` from `@shivaedev/contract/live-server/layer.ts` and provide that one Layer. Unwrap the subscription Effect with `Stream.unwrap`. Reactivity remains bound by the Layer, and policy and query-runner requirements remain on the Stream. The `makeLiveServer` convenience API keeps its existing shape.
28
+
3
29
  ## 0.39.0 - 2026-11-05
4
30
 
5
31
  ### Breaking
package/README.md CHANGED
@@ -327,7 +327,11 @@ Use this helper in hosts from `@shivaedev/server`, or a native RPC host wired wi
327
327
 
328
328
  ### Client activity
329
329
 
330
- `clientActivity(client)` from `@shivaedev/contract/clientActivity.ts` returns a native Effect `Stream` with a `current` Effect for a client made by `makeClient`. Its state includes `connectionStatus`, a `"live" | "reconnecting" | "waiting-for-connection"` value aggregated across mounted queries from all bindings of the same client service, with live subscription changes debounced for 300 ms on the client runtime’s Clock and held commands reported immediately. Refused subscriptions do not count as reconnecting. The stream also exposes its native `connectionStatus` atom for React readers. 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, connectionStatus }`, 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.
330
+ `clientActivity(client)` from `@shivaedev/contract/clientActivity.ts` returns a native Effect `Stream` with a `current` Effect for a client made by `makeClient`. Its state includes `connectionStatus`, a `"live" | "reconnecting" | "waiting-for-connection"` value aggregated across mounted queries from all bindings of the same client service, with live subscription changes debounced for 300 ms on the client runtime’s Clock and held commands reported immediately. Refused subscriptions do not count as reconnecting. The stream also exposes its native `connectionStatus` atom for React readers.
331
+
332
+ For screen stories, pass `activityScreenSignal(clientActivity(client))` to a test-story screen driver's `activity` option. By default, `settle()` waits for commands in flight and the first result of each mounted query, then flushes the renderer. Contract identifies commands from its own RPC annotations; kits need no query-name exceptions. The activity state's `commands` count includes commands held for a connection, and `initialQueries` counts mounted queries until their first success or failure. Unmounting releases that query's pending activity. `isClientSettled(state)` checks these two counts. An open live query that has delivered its first result, including one awaiting a later refresh, does not keep a screen story pending.
333
+
334
+ `activityScreenSignal(activity)` projects the stream and its `current` Effect into `{ pending, hints, connectionStatus }`, with `hints` carrying the received live-hint count. The returned shape is structural and carries no test-story dependency. Stories that need a later live change start `nextLiveHint()` before the outside write, then settle with `activityScreenSignal(activity, isClientIdle)` to wait through its refresh. `isClientIdle(state)` retains the full finite-work check: `rpcCalls` for finite calls, `liveInvalidations` for queued live refreshes, and `refreshingAtoms` for mounted query atoms awaiting values must all be zero. Long-lived subscription streams themselves do not count as finite calls.
331
335
 
332
336
  ### Query completion
333
337
 
@@ -417,6 +421,8 @@ const connection = composeBindings(
417
421
 
418
422
  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.
419
423
 
424
+ Opening a live query checks its policies, registers its read keys, then runs the authorized query and sends its first `Result` on the subscription. The screen and route loaders receive data in one RPC request; they do not send an ordinary query after the first signal. Registration precedes the read because PostgreSQL notifications cannot be replayed. Later changes send hints followed by ordinary query reads, unless the query declares `live: "rerun-and-compare"` to push changed results and acknowledge equal values.
425
+
420
426
  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 nested in properties such as `client.api.notes`. See [automatic changes](https://github.com/ShivaeDev/platform/blob/main/docs/framework/changes.md) for defaults.
421
427
 
422
428
  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.
@@ -452,14 +458,14 @@ const changes = Stream.unwrap(
452
458
  );
453
459
  ```
454
460
 
455
- 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.
461
+ The contract includes the reserved stream's payload, hints, typed `Result` values 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 and authorized query runner to `subscribe(subscription, read)`. The runner uses the same query handlers and policies as ordinary reads. Omitting the runner keeps an explicit hint-only stream for custom transports. 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.
456
462
 
457
463
  Custom subscription handlers use `changesHandlerLayer` to derive the reserved handler Layer from the contract:
458
464
 
459
465
  ```ts
460
466
  import { Effect, Stream } from "effect";
461
467
  import { changesHandlerLayer } from "@shivaedev/contract/changesHandlerLayer.ts";
462
- import { LiveServer } from "@shivaedev/contract/LiveServer.ts";
468
+ import { subscribe } from "@shivaedev/contract/live-server/subscribe.ts";
463
469
  import { querySubscription } from "@shivaedev/contract/querySubscription.ts";
464
470
  import { CurrentViewer } from "@shivaedev/contract/readPolicy.ts";
465
471
  import { Notes } from "./notes.ts";
@@ -472,8 +478,7 @@ const changes = changesHandlerLayer(
472
478
  Effect.gen(function* () {
473
479
  const viewer = yield* CurrentViewer;
474
480
  const subscription = yield* querySubscription(rpc, queries, viewer);
475
- const live = yield* LiveServer;
476
- return yield* live.subscribe(subscription);
481
+ return yield* subscribe(subscription);
477
482
  }),
478
483
  ),
479
484
  );
@@ -569,7 +574,7 @@ Call the release functions and dispose the registry when the application's root
569
574
 
570
575
  ### Server hint streams
571
576
 
572
- 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.
577
+ Import `LiveServer` from `@shivaedev/contract/live-server/service.ts`. Import `liveServerLayer` from `@shivaedev/contract/live-server/layer.ts` and provide it 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)` with `Stream.unwrap`, and call `hints.resync()` to reconcile its active streams. For authorized query subscriptions, import `subscribe` from `@shivaedev/contract/live-server/subscribe.ts` and unwrap `subscribe(subscription, read?)`. This operation yields `LiveServer`; its Layer binds Reactivity, while subscription policy failures and query-runner requirements remain on the returned Stream. Each Layer build owns its resync identity and stream counter. The package Layer also provides its dispatcher service. `register(keys)` exposes a scoped stream registration with `replaceKeys` for updating its read scope; consumption and interruption own that registration.
573
578
 
574
579
  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.
575
580
 
@@ -758,7 +763,7 @@ const client = makeClient(Notes, {
758
763
  });
759
764
  ```
760
765
 
761
- The URL identifies the client configuration; the in-memory protocol opens no socket. The client's direct calls and bound query atoms use the real handlers, schema decoding and middleware. Live subscriptions deliver the server's initial resync and changed hints, and mounted queries refresh from those hints. Closing a subscription interrupts its server stream. The protocol does not add handlers or publish changes: provide the same live handlers and change source that the application serves over WebSocket.
766
+ The URL identifies the client configuration; the in-memory protocol opens no socket. The client's direct calls and bound query atoms use the real handlers, schema decoding and middleware. Live subscriptions use the supplied handlers and change source, and mounted queries refresh from their updates. Closing a subscription interrupts its server stream. The protocol does not add handlers or publish changes: provide the same live handlers and change source that the application serves over WebSocket.
762
767
 
763
768
  ### Settled queries in stories
764
769
 
@@ -778,7 +783,7 @@ const current = yield* results.latest;
778
783
 
779
784
  ### Live hints in stories
780
785
 
781
- 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.
786
+ 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 update, including an initial result, before returning the viewer handle.
782
787
 
783
788
  ```ts
784
789
  const alice = yield* watchHints(aliceChanges);
@@ -794,30 +799,32 @@ expect(yield* heard(bob, [notes.item(1)], { within: "50 millis" })).toBe(false);
794
799
 
795
800
  Import the module that defines the name; the package has no root entry.
796
801
 
797
- | Module | Functions and schemas |
798
- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
799
- | `operation.ts` | `query(name, { payload?, success?, rejections?, readPolicy, reads, serverReads? })`; `command(name, { payload?, success?, rejections?, invalidates })`; `stream(name, { payload?, success, rejections?, reads })`. |
800
- | `contract.ts` | `contract(name, { queries?, commands?, streams?, keyScope? })`, returning a native RPC group with `declaration: { name, queries, commands, streams, keyScope }`. |
801
- | `rejection.ts` | `fieldRejection(struct, fields?)`; lower-level `rejectionSet(specs)`, which constructs the rejection classes, union schema and failure helpers used by operations. |
802
- | `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. |
803
- | `queryCoalesceWindow.ts` | `queryCoalesceWindow(query)`, a writable atom for a bound query's live changed-hint window. |
804
- | `clientKeys.ts` | `KeyContext`, `clientReadKeys`, `clientInvalidationKeys`: registry-local cache keys for custom clients. |
805
- | `live.ts` | `LiveHint` schema; `live(runtime, { stream, resyncKeys, coalesceWindow?, initialResync?, keyContext?, resume?, retryDelay?, retryKeys? })`, exposing `connection`, `coalesceWindow`, `paused` and `status`. |
806
- | `querySubscription.ts` | `querySubscription(rpc, references, viewer)` checks each referenced query, resolves its payload and server-derived keys, and captures its scopes and ongoing authorization. |
807
- | `LiveServer.ts` | `LiveServer`, the shared live server service and its `.layer`, requiring `Reactivity`. |
808
- | `makeLiveServer.ts` | `makeLiveServer`, an Effect requiring `Reactivity` that creates scoped server hint streams and a `resync` Effect. |
809
- | `readPolicy.ts` | `QueryReadPolicy`, `Viewer`, `signedIn`, `CurrentViewer`; `authorizeReads(effect, request, viewer)` for direct handler reruns outside RPC middleware. |
810
- | `ReadPolicyGuard.ts` | `ReadPolicyGuard`, the defaulted middleware reference attached to contract queries; `readPolicyGuardLayer({ websocket? })`, an optional override that refuses HTTP `$changes` calls by default. |
811
- | `validateReadPolicies.ts` | `validateReadPolicies(group)`, an Effect that fails with `MissingReadPolicies` when any served or subscribable query omits its policy. |
812
- | `readPolicyErrors.ts` | `MissingReadPolicies` (boot), `MissingReadPolicy` (native-server request fallback) and `QueryReadDenied`. |
813
- | `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. |
814
- | `commandResult.ts` | `commandResult({ result, invalidates })` contributes server-only keys from a guarded command handler and returns only its success value. |
815
- | `serverMetadata.ts` | `KeyScope`, `QueryDefinition.definition`, `CommandInvalidation.invalidates`, `ChangesQueries.queries`, `ChangesQueries.resolve(references)` and `changesRpc(name, queries)` for server adapters. |
816
- | `queryKeys.ts` | `queryKeys(queries, references, viewer?)` authorizes references and resolves payload and server-derived keys using the provided services. |
817
- | `QueryServerReads.ts` | `QueryServerReads<Payload, E, R>`, the server-only resolver type. |
818
- | `resume.ts` | `resumeSignal({ window?, native? })`, returning a native numeric signal atom. |
819
- | `querySignals.ts` | `querySignals(query)` exposes completion counts and subscription status as a native atom. |
820
- | `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. |
802
+ | Module | Functions and schemas |
803
+ | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
804
+ | `operation.ts` | `query(name, { payload?, success?, rejections?, readPolicy, reads, serverReads? })`; `command(name, { payload?, success?, rejections?, invalidates })`; `stream(name, { payload?, success, rejections?, reads })`. |
805
+ | `contract.ts` | `contract(name, { queries?, commands?, streams?, keyScope? })`, returning a native RPC group with `declaration: { name, queries, commands, streams, keyScope }`. |
806
+ | `rejection.ts` | `fieldRejection(struct, fields?)`; lower-level `rejectionSet(specs)`, which constructs the rejection classes, union schema and failure helpers used by operations. |
807
+ | `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. |
808
+ | `queryCoalesceWindow.ts` | `queryCoalesceWindow(query)`, a writable atom for a bound query's live changed-hint window. |
809
+ | `clientKeys.ts` | `KeyContext`, `clientReadKeys`, `clientInvalidationKeys`: registry-local cache keys for custom clients. |
810
+ | `live.ts` | `LiveHint` schema; `live(runtime, { stream, resyncKeys, coalesceWindow?, initialResync?, keyContext?, resume?, retryDelay?, retryKeys? })`, exposing `connection`, `coalesceWindow`, `paused` and `status`. |
811
+ | `querySubscription.ts` | `querySubscription(rpc, references, viewer)` checks each referenced query, resolves its payload and server-derived keys, and captures its scopes and ongoing authorization. |
812
+ | `live-server/service.ts` | `LiveServer`, the shared live server service. |
813
+ | `live-server/layer.ts` | `liveServerLayer`, providing `LiveServer` and its dispatcher dependency, requiring `Reactivity`. |
814
+ | `live-server/subscribe.ts` | `subscribe(subscription, read?)`, an Effect requiring `LiveServer` that returns an authorized subscription Stream with its policy and query-runner requirements. |
815
+ | `makeLiveServer.ts` | `makeLiveServer`, an Effect requiring `Reactivity` that creates scoped server hint streams and a `resync` Effect. |
816
+ | `readPolicy.ts` | `QueryReadPolicy`, `Viewer`, `signedIn`, `CurrentViewer`; `authorizeReads(effect, request, viewer)` for direct handler reruns outside RPC middleware. |
817
+ | `ReadPolicyGuard.ts` | `ReadPolicyGuard`, the defaulted middleware reference attached to contract queries; `readPolicyGuardLayer({ websocket? })`, an optional override that refuses HTTP `$changes` calls by default. |
818
+ | `validateReadPolicies.ts` | `validateReadPolicies(group)`, an Effect that fails with `MissingReadPolicies` when any served or subscribable query omits its policy. |
819
+ | `readPolicyErrors.ts` | `MissingReadPolicies` (boot), `MissingReadPolicy` (native-server request fallback) and `QueryReadDenied`. |
820
+ | `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. |
821
+ | `commandResult.ts` | `commandResult({ result, invalidates })` contributes server-only keys from a guarded command handler and returns only its success value. |
822
+ | `serverMetadata.ts` | `KeyScope`, `QueryDefinition.definition`, `CommandInvalidation.invalidates`, `ChangesQueries.queries`, `ChangesQueries.resolve(references)` and `changesRpc(name, queries)` for server adapters. |
823
+ | `queryKeys.ts` | `queryKeys(queries, references, viewer?)` authorizes references and resolves payload and server-derived keys using the provided services. |
824
+ | `QueryServerReads.ts` | `QueryServerReads<Payload, E, R>`, the server-only resolver type. |
825
+ | `resume.ts` | `resumeSignal({ window?, native? })`, returning a native numeric signal atom. |
826
+ | `querySignals.ts` | `querySignals(query)` exposes completion counts and subscription status as a native atom. |
827
+ | `clientActivity.ts` | `clientActivity(client)` exposes a native activity Stream with a `current` Effect; `isClientSettled(state)` checks commands and first query results; `isClientIdle(state)` checks all finite work; `activityScreenSignal(activity, settled?)` projects pending work and hints for screen waits. |
821
828
 
822
829
  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.
823
830
 
@@ -0,0 +1,22 @@
1
+ import type { Duration } from "effect";
2
+ import type * as AsyncResult from "effect/reactivity/AsyncResult";
3
+ import type * as Atom from "effect/reactivity/Atom";
4
+ import type { LiveBound, LiveConnection } from "#automaticLive.ts";
5
+ import type { LiveStatus } from "#live.ts";
6
+ import type { QuerySignals } from "#querySignals.ts";
7
+ export interface AutomaticQueryOptions<A, E> {
8
+ readonly atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>;
9
+ readonly clientStatuses: Atom.Writable<ReadonlyMap<object, LiveStatus<unknown>>> | undefined;
10
+ readonly coalesceWindow: Atom.Writable<Duration.Input>;
11
+ readonly equivalent: (left: A, right: A) => boolean;
12
+ readonly paused: Atom.Writable<boolean>;
13
+ readonly pushed: boolean;
14
+ readonly ready: Atom.Writable<boolean>;
15
+ readonly resultVersion: Atom.Atom<number>;
16
+ readonly signals: Atom.Writable<QuerySignals>;
17
+ readonly source: Atom.Atom<AsyncResult.AsyncResult<A, E>>;
18
+ readonly statuses: Atom.Writable<ReadonlyMap<object, LiveStatus<unknown>>>;
19
+ readonly subscription: LiveBound[typeof LiveConnection];
20
+ readonly subscriptionVersion: Atom.Atom<number>;
21
+ }
22
+ //# sourceMappingURL=AutomaticQueryOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutomaticQueryOptions.d.ts","sourceRoot":"","sources":["../src/AutomaticQueryOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,KAAK,EAAE,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D,QAAQ,CAAC,mBAAmB,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;CAChD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AutomaticQueryOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutomaticQueryOptions.js","sourceRoot":"","sources":["../src/AutomaticQueryOptions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { Context, Layer, Scheduler } from "effect";
2
+ declare const LiveDispatcher_base: Context.ServiceClass<LiveDispatcher, "@shivaedev/contract/LiveDispatcher", {
3
+ readonly dispatcher: Scheduler.SchedulerDispatcher;
4
+ }>;
5
+ export declare class LiveDispatcher extends LiveDispatcher_base {
6
+ static readonly layer: Layer.Layer<LiveDispatcher, never, never>;
7
+ }
8
+ export {};
9
+ //# sourceMappingURL=LiveDispatcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveDispatcher.d.ts","sourceRoot":"","sources":["../../src/adapters/LiveDispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;;yBAEgC,SAAS,CAAC,mBAAmB;;AAAxH,qBAAa,cAAe,SAAQ,mBAEnC;IACA,MAAM,CAAC,QAAQ,CAAC,KAAK,4CAGnB;CACF"}
@@ -0,0 +1,5 @@
1
+ import { Context, Effect, Layer, Scheduler } from "effect";
2
+ export class LiveDispatcher extends Context.Service()("@shivaedev/contract/LiveDispatcher") {
3
+ static layer = Layer.effect(this, Effect.map(Scheduler.Scheduler, (scheduler) => ({ dispatcher: scheduler.makeDispatcher() })));
4
+ }
5
+ //# sourceMappingURL=LiveDispatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveDispatcher.js","sourceRoot":"","sources":["../../src/adapters/LiveDispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE3D,MAAM,OAAO,cAAe,SAAQ,OAAO,CAAC,OAAO,EAA0E,CAC5H,oCAAoC,CACpC;IACA,MAAM,CAAU,KAAK,GAAG,KAAK,CAAC,MAAM,CACnC,IAAI,EACJ,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,SAAS,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAC5F,CAAC;CACF"}
@@ -1 +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,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEhF,wBAAgB,aAAa;IAa3B,QAAQ;;;IACR,MAAM,QAAQ,OAAO,CAAC,MAAM,mBAAmB,EAAE,kBAAkB,CAAC,SAAS,MAAM;IAGnF,IAAI;IAQJ,aAAa,qBAAqB,gBAAgB;EAKnD"}
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,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEhF,wBAAgB,aAAa;IAqB3B,QAAQ;;;IACR,MAAM,QAAQ,OAAO,CAAC,MAAM,mBAAmB,EAAE,kBAAkB,CAAC,SAAS,MAAM;IAGnF,IAAI;IAQJ,aAAa,qBAAqB,gBAAgB;EAKnD"}
@@ -2,7 +2,15 @@ import { Effect, SubscriptionRef } from "effect";
2
2
  export function activityState() {
3
3
  let held = 0;
4
4
  let connection = "live";
5
- const state = Effect.runSync(SubscriptionRef.make({ connectionStatus: "live", liveHints: 0, liveInvalidations: 0, refreshingAtoms: 0, rpcCalls: 0 }));
5
+ const state = Effect.runSync(SubscriptionRef.make({
6
+ commands: 0,
7
+ connectionStatus: "live",
8
+ initialQueries: 0,
9
+ liveHints: 0,
10
+ liveInvalidations: 0,
11
+ refreshingAtoms: 0,
12
+ rpcCalls: 0,
13
+ }));
6
14
  function publish() {
7
15
  const connectionStatus = held > 0 ? "waiting-for-connection" : connection;
8
16
  Effect.runSync(SubscriptionRef.update(state, (current) => (current.connectionStatus === connectionStatus ? current : { ...current, connectionStatus })));
@@ -1 +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,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,UAAU,GAAqB,MAAM,CAAC;IAC1C,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAC3B,eAAe,CAAC,IAAI,CAAsB,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAC5I,CAAC;IACF,SAAS,OAAO;QACf,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,UAAU,CAAC;QAC1E,MAAM,CAAC,OAAO,CACb,eAAe,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,KAAK,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC,CACxI,CAAC;IACH,CAAC;IACD,OAAO;QACN,QAAQ,EAAE,MAAM,CAAC,MAAM,CAA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OAAO;QACf,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,UAAU,CAAC;QAC1E,MAAM,CAAC,OAAO,CACb,eAAe,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,KAAK,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC,CACxI,CAAC;IACH,CAAC;IACD,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,GAA2D,EAAE,KAAa,EAAE,EAAE;YACtF,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;QACD,IAAI,EAAE,GAAG,EAAE;YACV,IAAI,IAAI,CAAC,CAAC;YACV,OAAO,EAAE,CAAC;YACV,OAAO,GAAG,EAAE;gBACX,IAAI,IAAI,CAAC,CAAC;gBACV,OAAO,EAAE,CAAC;YACX,CAAC,CAAC;QACH,CAAC;QACD,aAAa,EAAE,CAAC,gBAAkC,EAAE,EAAE;YACrD,UAAU,GAAG,gBAAgB,CAAC;YAC9B,OAAO,EAAE,CAAC;QACX,CAAC;KACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { Effect, Stream } from "effect";
2
+ import * as Reactivity from "effect/reactivity/Reactivity";
3
+ import type { Key } from "@shivaedev/changes/keys.ts";
4
+ import { LiveDispatcher } from "./LiveDispatcher.ts";
5
+ export declare const liveHintStream: (state: {
6
+ openStreams: import("effect/Ref").Ref<number>;
7
+ resyncKey: string;
8
+ }, keys: readonly Key[]) => Effect.Effect<Stream.Stream<{
9
+ replaceKeys: (current: readonly Key[]) => void;
10
+ stream: Stream.Stream<{
11
+ readonly _tag: "Changed";
12
+ readonly keys: readonly ({
13
+ readonly _tag: "Bucket";
14
+ readonly collection: string;
15
+ readonly field: string;
16
+ readonly value: string | number;
17
+ } | {
18
+ readonly _tag: "List";
19
+ readonly collection: string;
20
+ } | {
21
+ readonly _tag: "Item";
22
+ readonly collection: string;
23
+ readonly id: string | number;
24
+ })[];
25
+ readonly queryIndexes?: readonly number[] | undefined;
26
+ } | {
27
+ readonly _tag: "Resync";
28
+ }, never, never>;
29
+ }, never, never>, never, LiveDispatcher | Reactivity.Reactivity>;
30
+ //# sourceMappingURL=liveHintStream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liveHintStream.d.ts","sourceRoot":"","sources":["../../src/adapters/liveHintStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;gEAOzB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Effect, Stream } from "effect";
2
+ import * as Reactivity from "effect/reactivity/Reactivity";
3
+ import { LiveDispatcher } from "./LiveDispatcher.js";
4
+ import { openLiveHints } from "./openLiveHints.js";
5
+ export const liveHintStream = Effect.fn("LiveServer.liveHintStream")(function* (state, keys) {
6
+ const reactivity = yield* Reactivity.Reactivity;
7
+ const dispatcher = yield* LiveDispatcher;
8
+ return Stream.unwrap(Effect.map(openLiveHints(state, keys), Stream.succeed)).pipe(Stream.provideService(Reactivity.Reactivity, reactivity), Stream.provideService(LiveDispatcher, dispatcher));
9
+ });
10
+ //# sourceMappingURL=liveHintStream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liveHintStream.js","sourceRoot":"","sources":["../../src/adapters/liveHintStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAG3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,EAAE,CAAC,2BAA2B,CAAC,CAAC,QAAQ,CAAC,EAAE,KAAwC,EAAE,IAAoB;IAC7I,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;IAChD,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,cAAc,CAAC;IACzC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAChF,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,EACxD,MAAM,CAAC,cAAc,CAAC,cAAc,EAAE,UAAU,CAAC,CACjD,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { Effect, Ref, Stream } from "effect";
2
+ import * as Reactivity from "effect/reactivity/Reactivity";
3
+ import { type Key } from "@shivaedev/changes/keys.ts";
4
+ import { LiveDispatcher } from "./LiveDispatcher.ts";
5
+ export declare const openLiveHints: (state: {
6
+ openStreams: Ref.Ref<number>;
7
+ resyncKey: string;
8
+ }, keys: readonly Key[]) => Effect.Effect<{
9
+ replaceKeys: (current: readonly Key[]) => void;
10
+ stream: Stream.Stream<{
11
+ readonly _tag: "Changed";
12
+ readonly keys: readonly ({
13
+ readonly _tag: "Bucket";
14
+ readonly collection: string;
15
+ readonly field: string;
16
+ readonly value: string | number;
17
+ } | {
18
+ readonly _tag: "List";
19
+ readonly collection: string;
20
+ } | {
21
+ readonly _tag: "Item";
22
+ readonly collection: string;
23
+ readonly id: string | number;
24
+ })[];
25
+ readonly queryIndexes?: readonly number[] | undefined;
26
+ } | {
27
+ readonly _tag: "Resync";
28
+ }, never, never>;
29
+ }, never, LiveDispatcher | Reactivity.Reactivity | import("effect/Scope").Scope>;
30
+ //# sourceMappingURL=openLiveHints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openLiveHints.d.ts","sourceRoot":"","sources":["../../src/adapters/openLiveHints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAS,GAAG,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,KAAK,GAAG,EAAY,MAAM,4BAA4B,CAAC;AAGhE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,eAAO,MAAM,aAAa;;;;2BAwBK,SAAS,GAAG,EAAE;;;;;;;;;;;;;;;;;;;;gFA8B3C,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { Effect, Queue, Ref, Stream } from "effect";
2
+ import * as Reactivity from "effect/reactivity/Reactivity";
3
+ import { readKeys } from "@shivaedev/changes/keys.ts";
4
+ import { liveHintQueue } from "#liveHintQueue.ts";
5
+ import { LiveDispatcher } from "./LiveDispatcher.js";
6
+ export const openLiveHints = Effect.fn("LiveServer.openLiveHints")(function* (state, keys) {
7
+ const reactivity = yield* Reactivity.Reactivity;
8
+ const { openStreams, resyncKey } = state;
9
+ const { dispatcher } = yield* LiveDispatcher;
10
+ const { offer, queue } = yield* liveHintQueue;
11
+ const pending = new Map();
12
+ let scheduled = false;
13
+ let resync = false;
14
+ let active = true;
15
+ function flush() {
16
+ if (scheduled) {
17
+ return;
18
+ }
19
+ scheduled = true;
20
+ dispatcher.scheduleTask(() => {
21
+ scheduled = false;
22
+ if (active) {
23
+ offer(resync ? { _tag: "Resync" } : { _tag: "Changed", keys: [...pending.values()] });
24
+ }
25
+ pending.clear();
26
+ resync = false;
27
+ }, 0);
28
+ }
29
+ let cancelKeys = [];
30
+ function replaceKeys(current) {
31
+ for (const stop of cancelKeys) {
32
+ stop();
33
+ }
34
+ cancelKeys = current.map((key) => {
35
+ const own = readKeys([key]);
36
+ return reactivity.registerUnsafe(own, () => {
37
+ pending.set(own[0] ?? "", key);
38
+ flush();
39
+ });
40
+ });
41
+ }
42
+ replaceKeys(keys);
43
+ const cancel = [
44
+ reactivity.registerUnsafe([resyncKey], () => {
45
+ resync = true;
46
+ flush();
47
+ }),
48
+ ];
49
+ yield* Ref.update(openStreams, (count) => count + 1);
50
+ yield* Effect.addFinalizer(() => Effect.sync(() => {
51
+ active = false;
52
+ for (const stop of [...cancelKeys, ...cancel]) {
53
+ stop();
54
+ }
55
+ }).pipe(Effect.andThen(Ref.update(openStreams, (count) => count - 1))));
56
+ yield* Queue.offer(queue, { _tag: "Resync" });
57
+ return { replaceKeys, stream: Stream.fromQueue(queue) };
58
+ });
59
+ //# sourceMappingURL=openLiveHints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openLiveHints.js","sourceRoot":"","sources":["../../src/adapters/openLiveHints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAY,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO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AAQ,EAAE,CAAC,CAAC;IAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;AACzD,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Effect } from "effect";
2
+ import type { QuerySubscription } from "#querySubscription.ts";
3
+ export declare function refreshSubscription<A, E, R>(subscription: QuerySubscription<E, R>, next: Effect.Effect<A, E, R>): Effect.Effect<A, E, R | Exclude<R, never>>;
4
+ //# sourceMappingURL=refreshSubscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refreshSubscription.d.ts","sourceRoot":"","sources":["../../src/adapters/refreshSubscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,8CAE/G"}
@@ -0,0 +1,5 @@
1
+ import { Effect } from "effect";
2
+ export function refreshSubscription(subscription, next) {
3
+ return Effect.flatMap(subscription.refresh ?? Effect.context(), (current) => Effect.provideContext(next, current));
4
+ }
5
+ //# sourceMappingURL=refreshSubscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refreshSubscription.js","sourceRoot":"","sources":["../../src/adapters/refreshSubscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,MAAM,UAAU,mBAAmB,CAAU,YAAqC,EAAE,IAA4B;IAC/G,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;AAC3H,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { Effect, Stream } from "effect";
2
+ import type { Key } from "@shivaedev/changes/keys.ts";
3
+ import type { QueryRerun, QuerySubscription } from "#querySubscription.ts";
4
+ import type { QueryUpdate, SubscriptionHint } from "#queryUpdate.ts";
5
+ import type { QueryReadDenied } from "#readPolicyErrors.ts";
6
+ export declare const standaloneLiveServer: Effect.Effect<{
7
+ resync: Effect.Effect<number, never, never>;
8
+ stream: (keys: readonly Key[]) => Stream.Stream<{
9
+ readonly _tag: "Changed";
10
+ readonly keys: readonly ({
11
+ readonly _tag: "Bucket";
12
+ readonly collection: string;
13
+ readonly field: string;
14
+ readonly value: string | number;
15
+ } | {
16
+ readonly _tag: "List";
17
+ readonly collection: string;
18
+ } | {
19
+ readonly _tag: "Item";
20
+ readonly collection: string;
21
+ readonly id: string | number;
22
+ })[];
23
+ readonly queryIndexes?: readonly number[] | undefined;
24
+ } | {
25
+ readonly _tag: "Resync";
26
+ }, never, never>;
27
+ subscribe: {
28
+ <E, R>(subscription: QuerySubscription<E, R>): Stream.Stream<SubscriptionHint, E | QueryReadDenied, R>;
29
+ <E, R>(subscription: QuerySubscription<E, R>, read: QueryRerun<E, R>): Stream.Stream<QueryUpdate, E | QueryReadDenied, R>;
30
+ };
31
+ }, never, import("effect/reactivity/Reactivity").Reactivity>;
32
+ //# sourceMappingURL=standaloneLiveServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standaloneLiveServer.d.ts","sourceRoot":"","sources":["../../src/adapters/standaloneLiveServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxD,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,oBAAoB;;mBAQiB,SAAS,GAAG,EAAE;;;;;;;;;;;;;;;;;;;;SAL5C,CAAC,EAAE,CAAC,gBAAgB,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,GAAG,eAAe,EAAE,CAAC,CAAC;SACrG,CAAC,EAAE,CAAC,gBAAgB,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,GAAG,eAAe,EAAE,CAAC,CAAC;;4DAK1I,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { Context, Effect, Layer, Stream } from "effect";
2
+ import { liveServerLayer } from "#live-server/layer.ts";
3
+ import { LiveServer } from "#live-server/service.ts";
4
+ import { subscribe as subscribeQueries } from "#live-server/subscribe.ts";
5
+ export const standaloneLiveServer = Effect.gen(function* () {
6
+ const context = yield* Effect.scoped(Layer.build(liveServerLayer));
7
+ const server = Context.get(context, LiveServer);
8
+ function subscribe(subscription, read) {
9
+ return Stream.unwrap(Effect.provideContext(subscribeQueries(subscription, read), context));
10
+ }
11
+ return { resync: server.resync(), stream: (keys) => Stream.unwrap(server.stream(keys)), subscribe };
12
+ });
13
+ //# sourceMappingURL=standaloneLiveServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standaloneLiveServer.js","sourceRoot":"","sources":["../../src/adapters/standaloneLiveServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAK1E,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACvD,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;IACnE,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAGhD,SAAS,SAAS,CAAO,YAAqC,EAAE,IAAuB;QACtF,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,IAAoB,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC;AACrH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Effect, Layer } from "effect";
2
+ import type { RpcClient } from "effect/rpc";
3
+ export declare const withClientProtocol: <A, E, R, TMakeError, TMakeRequirements>(protocol: Layer.Layer<RpcClient.Protocol, E, R>, make: Effect.Effect<A, TMakeError, TMakeRequirements>) => Effect.Effect<A, E | TMakeError, R | import("effect/Scope").Scope | Exclude<TMakeRequirements, RpcClient.Protocol>>;
4
+ //# sourceMappingURL=withClientProtocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withClientProtocol.d.ts","sourceRoot":"","sources":["../../src/adapters/withClientProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,eAAO,MAAM,kBAAkB,GAAwD,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,iBAAiB,gOAM3H,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Effect, Layer } from "effect";
2
+ export const withClientProtocol = Effect.fn("RpcClient.withClientProtocol")(function* (protocol, make) {
3
+ const context = yield* Layer.build(protocol);
4
+ return yield* Effect.provideContext(make, context);
5
+ });
6
+ //# sourceMappingURL=withClientProtocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withClientProtocol.js","sourceRoot":"","sources":["../../src/adapters/withClientProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAGvC,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC,8BAA8B,CAAC,CAAC,QAAQ,CAAC,EACpF,QAA+C,EAC/C,IAAqD;IAErD,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC7C,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Effect } from "effect";
2
+ import type { Rpc } from "effect/rpc";
3
+ export declare const withPolicyContext: <A, E, R>(rpc: Rpc.Any, effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, unknown>;
4
+ //# sourceMappingURL=withPolicyContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withPolicyContext.d.ts","sourceRoot":"","sources":["../../src/adapters/withPolicyContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAGtC,eAAO,MAAM,iBAAiB,GAAwD,CAAC,EAAE,CAAC,EAAE,CAAC,+EAG3F,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { Effect } from "effect";
2
+ import { policyContext } from "#policyContext.ts";
3
+ export const withPolicyContext = Effect.fn("ReadPolicy.withPolicyContext")(function* (rpc, effect) {
4
+ const context = yield* policyContext(rpc);
5
+ return yield* Effect.provideContext(effect, context);
6
+ });
7
+ //# sourceMappingURL=withPolicyContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withPolicyContext.js","sourceRoot":"","sources":["../../src/adapters/withPolicyContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,EAAE,CAAC,8BAA8B,CAAC,CAAC,QAAQ,CAAC,EAAW,GAAY,EAAE,MAA8B;IAC1I,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAC1C,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACtD,CAAC,CAAC,CAAC"}