@shivaedev/contract 0.30.2 → 0.31.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 (53) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +29 -29
  3. package/dist/bind.d.ts +5 -5
  4. package/dist/bind.d.ts.map +1 -1
  5. package/dist/bind.js.map +1 -1
  6. package/dist/clientOptions.d.ts +3 -0
  7. package/dist/clientOptions.d.ts.map +1 -1
  8. package/dist/internal/changesSuccess.d.ts +2 -1
  9. package/dist/internal/changesSuccess.d.ts.map +1 -1
  10. package/dist/internal/changesSuccess.js +2 -0
  11. package/dist/internal/changesSuccess.js.map +1 -1
  12. package/dist/internal/liveAttempt.d.ts +13 -0
  13. package/dist/internal/liveAttempt.d.ts.map +1 -0
  14. package/dist/internal/liveAttempt.js +28 -0
  15. package/dist/internal/liveAttempt.js.map +1 -0
  16. package/dist/internal/queryDelivery.d.ts +2 -20
  17. package/dist/internal/queryDelivery.d.ts.map +1 -1
  18. package/dist/internal/queryDelivery.js.map +1 -1
  19. package/dist/internal/queryHints.d.ts +3 -2
  20. package/dist/internal/queryHints.d.ts.map +1 -1
  21. package/dist/internal/queryHints.js +1 -1
  22. package/dist/internal/queryHints.js.map +1 -1
  23. package/dist/live.d.ts +5 -3
  24. package/dist/live.d.ts.map +1 -1
  25. package/dist/live.js +16 -24
  26. package/dist/live.js.map +1 -1
  27. package/dist/makeLiveServer.d.ts +2 -2
  28. package/dist/makeLiveServer.d.ts.map +1 -1
  29. package/dist/makeLiveServer.js +4 -3
  30. package/dist/makeLiveServer.js.map +1 -1
  31. package/dist/publicConfig.d.ts +1 -1
  32. package/dist/publicConfig.d.ts.map +1 -1
  33. package/dist/querySubscription.d.ts +2 -1
  34. package/dist/querySubscription.d.ts.map +1 -1
  35. package/dist/querySubscription.js +4 -1
  36. package/dist/querySubscription.js.map +1 -1
  37. package/dist/queryUpdate.d.ts +3 -1
  38. package/dist/queryUpdate.d.ts.map +1 -1
  39. package/dist/testing.d.ts +4 -40
  40. package/dist/testing.d.ts.map +1 -1
  41. package/dist/testing.js.map +1 -1
  42. package/package.json +9 -9
  43. package/src/bind.ts +9 -8
  44. package/src/clientOptions.ts +3 -0
  45. package/src/internal/changesSuccess.ts +3 -1
  46. package/src/internal/liveAttempt.ts +44 -0
  47. package/src/internal/queryDelivery.ts +2 -3
  48. package/src/internal/queryHints.ts +3 -2
  49. package/src/live.ts +20 -27
  50. package/src/makeLiveServer.ts +11 -5
  51. package/src/querySubscription.ts +5 -1
  52. package/src/queryUpdate.ts +3 -1
  53. package/src/testing.ts +5 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.31.0 - 2026-11-02
4
+
5
+ ### Added
6
+
7
+ - Query subscriptions accept an optional `refresh` Effect supplying the context for each policy check and query rerun.
8
+
9
+ ### Breaking
10
+
11
+ - Contract change streams emit `QueryReadDenied` as a delivery when an established subscription loses read access, keeping the subscription open so a later hint can resume delivery after access returns. Custom consumers must handle this delivery alongside `Changed`, `Resync` and `Result`; use `SubscriptionHint` for hint consumers. Initial subscription refusals remain typed stream failures. Bound query atoms display the denial and recover on a later authorized hint.
12
+ - Query atom failure types include client-middleware errors and the contract's change-subscription errors. Consumers with exhaustive error handlers must handle the additional subscription failures, including `MissingReadPolicy`, `WebSocketRequired`, and rejections declared by other queries in the contract. Explicit `BoundQuery` annotations can pass the subscription RPC as the third type parameter or be replaced with inference from the bound API. Direct `run` failure types stay specific to their RPC.
13
+
3
14
  ## 0.30.2 - 2026-11-02
4
15
 
5
16
  ### Fixed
package/README.md CHANGED
@@ -227,7 +227,7 @@ const rename = runtime.fn(api.rename.run);
227
227
 
228
228
  Browsers send the session cookie at upgrade. Mounting a query opens its subscription before running its first authorized read; unmounting cancels that subscription without restarting the socket or another query. Changed keys rerun only their readers, and equal results retain the bound atom's value. Connection failures use Effect RPC's reconnect backoff; subscriptions resume and mounted queries read again because there is no retained key history. `LiveConnection.status` reports `connecting`, `live` or `reconnecting`.
229
229
 
230
- For a native WebView, pass the signed session credential as `bearerToken` to `makeClient`. The browser WebSocket constructor needs no upgrade headers. The client adds `auth=frame` to the RPC URL and sends `{"_tag":"Authenticate","token":"<credential>"}` as its first text frame on every connection, before native RPC traffic. The bearer never enters the URL. Use a host session provider that admits bearer sessions and configure the WebView's Origin on the host. Authentication failures close the socket with code 1008 and reason `Authentication required`; an unavailable session provider closes it with code 1011 and reason `Authentication unavailable`. Sign-out or session expiry also closes an established bearer socket. Bind the client's service with a native `resume` source as shown below to reconcile live reads when the shell resumes.
230
+ For a native WebView, pass the signed session credential as `bearerToken` to `makeClient`. The browser WebSocket constructor needs no upgrade headers. The client adds `auth=frame` to the RPC URL and sends `{"_tag":"Authenticate","token":"<credential>"}` as its first text frame on every connection, before native RPC traffic. The bearer never enters the URL. Use a host session provider that admits bearer sessions and configure the WebView's Origin on the host. Authentication failures close the socket with code 1008 and reason `Authentication required`; an unavailable session provider closes it with code 1011 and reason `Authentication unavailable`. Sign-out or session expiry also closes an established bearer socket. Pass a native `resume` source to `makeClient` as shown below to reconcile live reads when the shell resumes.
231
231
 
232
232
  `group` supplies a larger native RPC group containing the contract, such as an admin registry. The result is a native client Layer for `ManagedRuntime.make`, plus the native `Client` service, atom `runtime` and scoped `client` Effect. Session-scoped contracts require `registry`. For Node clients, supply upgrade `headers` and `webSocketConstructor: NodeSocket.layerWebSocketConstructorWS` from `@effect/platform-node`. A native `protocol` Layer selects another transport explicitly. A `protocol: (identity) => layer` factory follows the live session identity instead: the client rebuilds its transport when that identity changes. The scoped `client` Effect uses `undefined` as the factory identity. Return a shared Layer for clients that should share a socket within one session. Use `live: false` for ordinary clients without subscriptions.
233
233
 
@@ -335,10 +335,10 @@ Database hosts from `@shivaedev/server` serve the contract's reserved `<contract
335
335
 
336
336
  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
337
 
338
- A native shell supplies its lifecycle events through `bind`'s optional `resume` source:
338
+ A native shell supplies its lifecycle events through the optional `resume` source on `makeClient` or `bind`:
339
339
 
340
340
  ```ts
341
- import { bind } from "@shivaedev/contract/bind.ts";
341
+ import { makeClient } from "@shivaedev/contract/bind.ts";
342
342
  import type { ResumeSource } from "@shivaedev/contract/resume.ts";
343
343
  import { onAppResume, onNetworkReturn } from "./native-lifecycle.ts";
344
344
 
@@ -350,10 +350,10 @@ const resume: ResumeSource = (notify) => {
350
350
  stopNetwork();
351
351
  };
352
352
  };
353
- const api = bind(Notes, NotesClient, { resume });
353
+ const { api, runtime } = makeClient(Notes, { url: "https://app.example/rpc", resume });
354
354
  ```
355
355
 
356
- The application owns `onAppResume` and `onNetworkReturn`; each subscribes a callback and returns an unsubscribe function. The source joins the visible browser visibility and online defaults. Each notification reopens the live subscription and reconciles all reads tracked by the connection. The owning registry releases the source on disposal. Omitting `resume` keeps the browser defaults. Pass the same binding from React's `SessionBoundary.connect` to use it with automatic session subscriptions. An embedded browser can pass `resumeWindow` to observe that window’s visibility and online events.
356
+ The application owns `onAppResume` and `onNetworkReturn`; each subscribes a callback and returns an unsubscribe function. The source joins the visible browser visibility and online defaults. Each notification reopens the live subscription and reconciles all reads tracked by the connection. The owning registry releases the source on disposal. Omitting `resume` keeps the browser defaults. Pass the same binding from React's `SessionBoundary.connect` to use it with automatic session subscriptions. An embedded browser can pass `resumeWindow` to `makeClient` or `bind` to observe that window’s visibility and online events.
357
357
 
358
358
  For a direct subscription, configure the server and `NotesClient` with `RpcSerialization.layerNdjson` and use the client already typed from `Notes`:
359
359
 
@@ -440,7 +440,7 @@ const status = registry.get(updates.status);
440
440
 
441
441
  While paused, live coordination keeps observing hints and suppresses automatic refresh. `status.pending` saturates at 256 observations. Unpausing reconciles the explicit scope and resets the count. A resume signal also requests reconciliation: an injected native source and visible browser `online` and `visibilitychange` events request it, while hidden events do not.
442
442
 
443
- `status` exposes `connection`, `failure`, `needsResync` and `pending`. Expected stream rejections settle with `connection: "failed"` and their typed cause in `failure`. Typed rejections do not retry on a timer. A `QueryReadDenied` refusal stays settled through matching change invalidations and resume events; changing the query input or viewer identity starts a new subscription. Other expected rejections can reopen on matching invalidations. Low-level `live()` listens to `retryKeys`, defaulting to its `resyncKeys`, for matching invalidations. Transport errors and server defects reconnect with jittered exponential backoff, starting at `retryDelay` (one second by default) and capped at a nominal 30 seconds. A reconnection reconciles changes missed while disconnected, and successful delivery clears the stream failure. Native query atoms keep previous successful data during a read failure and reject stale responses after invalidation. Query failures remain in their own `AsyncResult`; stream failures appear in `status.failure`.
443
+ `status` exposes `connection`, `failure`, `needsResync` and `pending`. Expected stream rejections settle with `connection: "failed"` and their typed cause in `failure`. Typed rejections do not retry on a timer. An initial `QueryReadDenied` refusal stays settled through matching change invalidations and resume events; changing the query input or viewer identity starts a new subscription. A denial delivered on an established subscription also sets `connection: "failed"`, but the stream remains open and a later authorized hint restores the query and live status. Other expected rejections can reopen on matching invalidations. Low-level `live()` listens to `retryKeys`, defaulting to its `resyncKeys`, for matching invalidations. Transport errors and server defects reconnect with jittered exponential backoff, starting at `retryDelay` (one second by default) and capped at a nominal 30 seconds. A reconnection reconciles changes missed while disconnected, and successful delivery clears the stream failure. Native query atoms keep previous successful data during a read failure and reject stale responses after invalidation. Query failures remain in their own `AsyncResult`; stream failures appear in `status.failure`.
444
444
 
445
445
  A `$changes` request is authorized as a whole: one denied member rejects or ends the entire batch, including its other queries. Split queries with independent permissions into separate `$changes` requests. Automatic bound query atoms already subscribe separately.
446
446
 
@@ -460,7 +460,7 @@ Import `LiveServer` from `@shivaedev/contract/LiveServer.ts`. Provide `LiveServe
460
460
 
461
461
  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
462
 
463
- Each stream queues at most 256 hints. Overflow discards the pending hints and retains one `Resync`; further hints are absorbed until that reconciliation hint is pulled. A stalled consumer can then read current query results without replaying the write backlog. This bounds the helper's queue by hint count, not by bytes: each hint's keys depend on the subscription. Transport buffers remain the transport's responsibility.
463
+ Each stream queues at most 256 hints. Overflow discards the pending hints and retains one `Resync`; further hints are absorbed until that reconciliation hint is pulled. Hint consumers read current query results; rerun-and-compare subscriptions rerun on the server and push changed current results. The [PostgreSQL and React stories](https://github.com/ShivaeDev/platform/blob/main/packages/react/src/comparedPostgres.dom.spec.ts) prove compared delivery without client reads, suppression of equal and SQL-filtered results, and reconciliation into a rendered query after a real loopback WebSocket withholds RPC acknowledgements across 257 repository commits. The [in-memory slow-consumer stories](src/slowConsumer.spec.ts) cover hint reconciliation. The queue bound counts hints, not commits or bytes: each hint's keys depend on the subscription. Transport buffers remain the transport's responsibility; a client lagging by 256 commits does not necessarily overflow this queue. Browser suspension, proxy buffering and deployment delivery are not proven here.
464
464
 
465
465
  ### Query policies, record keys and buckets
466
466
 
@@ -565,11 +565,11 @@ A record key, `notes.item(id)`, names one record. A bucket, `notes.bucket.userId
565
565
 
566
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.
567
567
 
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 ends it with `QueryReadDenied`. 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.
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.
569
569
 
570
570
  ### Policy services
571
571
 
572
- Use the policy's `viewer` argument for the viewer ID. Read richer session context from Effect requirements. For example, a policy service can require `SessionUserWithProviderAccounts` from `@shivaedev/identity/identity.ts` and yield its `providerAccounts` Effect. Apply `AuthenticatedUserWithProviderAccounts` middleware to the contract and supply `authenticatedUserWithProviderAccountsLayer()` from `@shivaedev/identity/server/session.ts` alongside its handlers, with the shared `SessionPolicy` Layer provided once by the application host. The middleware provides this request-local context for both RPC calls and live change hints, including each policy recheck before a hint is delivered.
572
+ Use the policy's `viewer` argument for the viewer ID. Read richer session context from Effect requirements. For example, a policy service can require `SessionUserWithProviderAccounts` from `@shivaedev/identity/identity.ts` and yield its `providerAccounts` Effect. Apply `AuthenticatedUserWithProviderAccounts` middleware to the contract and supply `authenticatedUserWithProviderAccountsLayer()` from `@shivaedev/identity/server/session.ts` alongside its handlers, with the shared `SessionPolicy` Layer provided once by the application host. The middleware provides this request-local context for both RPC calls and live change hints, including each policy recheck before a hint is delivered. Session-backed hosts reload that context before each hint, and use the same snapshot for its policy and query rerun.
573
573
 
574
574
  Keep the policy service tag and query declaration browser-safe; put its implementation on the server. Its method retains the session service in its requirements so the session is read when the policy runs:
575
575
 
@@ -663,26 +663,26 @@ expect(yield* heard(bob, [notes.item(1)], { within: "50 millis" })).toBe(false);
663
663
 
664
664
  Import the module that defines the name; the package has no root entry.
665
665
 
666
- | Module | Functions and schemas |
667
- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
668
- | `operation.ts` | `query(name, { payload?, success?, rejections?, readPolicy, reads, serverReads? })`; `command(name, { payload?, success?, rejections?, invalidates })`; `stream(name, { payload?, success, rejections?, reads })`. |
669
- | `contract.ts` | `contract(name, { queries?, commands?, streams?, keyScope? })`, returning a native RPC group with `declaration: { name, queries, commands, streams, keyScope }`. |
670
- | `rejection.ts` | `fieldRejection(struct, fields?)`; lower-level `rejectionSet(specs)`, which constructs the rejection classes, union schema and failure helpers used by operations. |
671
- | `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? })`, which builds the shared WebSocket client and binds it. |
672
- | `queryCoalesceWindow.ts` | `queryCoalesceWindow(query)`, a writable atom for a bound query's live changed-hint window. |
673
- | `live.ts` | `LiveHint` schema; `live(runtime, { stream, resyncKeys, coalesceWindow?, initialResync?, keyContext?, resume?, retryDelay?, retryKeys? })`, exposing `connection`, `coalesceWindow`, `paused` and `status`. |
674
- | `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
- | `LiveServer.ts` | `LiveServer`, the shared live server service and its `.layer`, requiring `Reactivity`. |
676
- | `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`. |
678
- | `validateReadPolicies.ts` | `validateReadPolicies(group)`, an Effect that fails with `MissingReadPolicies` when any served or subscribable query omits its policy. |
679
- | `readPolicyErrors.ts` | `MissingReadPolicies` (boot), `MissingReadPolicy` (native-server request fallback) and `QueryReadDenied`. |
680
- | `serverMetadata.ts` | `KeyScope`, `QueryDefinition.definition`, `CommandInvalidation.invalidates`, `ChangesQueries.queries`, `ChangesQueries.resolve(references)` and `changesRpc(name, queries)` for server adapters. |
681
- | `queryKeys.ts` | `queryKeys(queries, references, viewer?)` authorizes references and resolves payload and server-derived keys using the provided services. |
682
- | `QueryServerReads.ts` | `QueryServerReads<Payload, E, R>`, the server-only resolver type. |
683
- | `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. |
666
+ | Module | Functions and schemas |
667
+ | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
668
+ | `operation.ts` | `query(name, { payload?, success?, rejections?, readPolicy, reads, serverReads? })`; `command(name, { payload?, success?, rejections?, invalidates })`; `stream(name, { payload?, success, rejections?, reads })`. |
669
+ | `contract.ts` | `contract(name, { queries?, commands?, streams?, keyScope? })`, returning a native RPC group with `declaration: { name, queries, commands, streams, keyScope }`. |
670
+ | `rejection.ts` | `fieldRejection(struct, fields?)`; lower-level `rejectionSet(specs)`, which constructs the rejection classes, union schema and failure helpers used by operations. |
671
+ | `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
+ | `queryCoalesceWindow.ts` | `queryCoalesceWindow(query)`, a writable atom for a bound query's live changed-hint window. |
673
+ | `live.ts` | `LiveHint` schema; `live(runtime, { stream, resyncKeys, coalesceWindow?, initialResync?, keyContext?, resume?, retryDelay?, retryKeys? })`, exposing `connection`, `coalesceWindow`, `paused` and `status`. |
674
+ | `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
+ | `LiveServer.ts` | `LiveServer`, the shared live server service and its `.layer`, requiring `Reactivity`. |
676
+ | `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`. |
678
+ | `validateReadPolicies.ts` | `validateReadPolicies(group)`, an Effect that fails with `MissingReadPolicies` when any served or subscribable query omits its policy. |
679
+ | `readPolicyErrors.ts` | `MissingReadPolicies` (boot), `MissingReadPolicy` (native-server request fallback) and `QueryReadDenied`. |
680
+ | `serverMetadata.ts` | `KeyScope`, `QueryDefinition.definition`, `CommandInvalidation.invalidates`, `ChangesQueries.queries`, `ChangesQueries.resolve(references)` and `changesRpc(name, queries)` for server adapters. |
681
+ | `queryKeys.ts` | `queryKeys(queries, references, viewer?)` authorizes references and resolves payload and server-derived keys using the provided services. |
682
+ | `QueryServerReads.ts` | `QueryServerReads<Payload, E, R>`, the server-only resolver type. |
683
+ | `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. |
686
686
 
687
687
  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
688
 
package/dist/bind.d.ts CHANGED
@@ -12,15 +12,15 @@ import type { ClientOptions, MadeClient } from "#clientOptions.ts";
12
12
  import type { Contract, Tag } from "#contract.ts";
13
13
  import type { CommandShape, QueryShape, StreamShape } from "#operation.ts";
14
14
  import type { ResumeSource, ResumeWindow } from "#resume.ts";
15
- export type Failure<R extends Rpc.Any> = R extends Rpc.Rpc<infer _Tag, infer _Payload, infer _Success, infer _Error, infer TMiddleware, infer _Requires> ? Rpc.ErrorExit<R> | TMiddleware["error"]["Type"] | RpcClientError : never;
16
- export type RunFailure<R extends Rpc.Any> = R extends Rpc.Rpc<infer _Tag, infer _Payload, infer _Success, infer _Error, infer TMiddleware, infer _Requires> ? Failure<R> | TMiddleware["~ClientError"] : never;
15
+ export type Failure<R extends Rpc.Any> = R extends Rpc.Rpc<infer _Tag, infer _Payload, infer _Success, infer _Error, infer TMiddleware, infer _Requires> ? Rpc.ErrorExit<R> | TMiddleware["error"]["Type"] | TMiddleware["~ClientError"] | RpcClientError : never;
16
+ export type RunFailure<R extends Rpc.Any> = Failure<R>;
17
17
  export interface QueryOptions {
18
18
  readonly headers?: Headers.Input;
19
19
  readonly serializationKey?: string;
20
20
  readonly timeToLive?: Duration.Input;
21
21
  }
22
- export interface BoundQuery<R extends Rpc.Any, TSelf> {
23
- readonly query: (payload: Rpc.Payload<R>, options?: QueryOptions) => Atom.Atom<AsyncResult.AsyncResult<Rpc.Success<R>, Failure<R>>>;
22
+ export interface BoundQuery<R extends Rpc.Any, TSelf, TSubscription extends Rpc.Any = never> {
23
+ readonly query: (payload: Rpc.Payload<R>, options?: QueryOptions) => Atom.Atom<AsyncResult.AsyncResult<Rpc.Success<R>, Failure<R | TSubscription>>>;
24
24
  readonly run: (payload: Rpc.Payload<R>) => Effect.Effect<Rpc.Success<R>, RunFailure<R>, TSelf>;
25
25
  }
26
26
  export interface BoundCommand<R extends Rpc.Any, TSelf> {
@@ -30,7 +30,7 @@ export interface BoundStream<R extends Rpc.Any, TSelf> {
30
30
  readonly run: (payload: Rpc.Payload<R>) => Stream.Stream<Rpc.SuccessChunk<R>, RunFailure<R>, TSelf | Rpc.ServicesClient<R>>;
31
31
  }
32
32
  export type Bound<TName extends string, TQueries extends readonly QueryShape[], TCommands extends readonly CommandShape[], TRpcs extends Rpc.Any, TSelf, TStreams extends readonly StreamShape[] = readonly []> = {
33
- readonly [TQuery in TQueries[number] as TQuery["name"]]: BoundQuery<Rpc.ExtractTag<TRpcs, Tag<TName, TQuery["name"]>>, TSelf>;
33
+ readonly [TQuery in TQueries[number] as TQuery["name"]]: BoundQuery<Rpc.ExtractTag<TRpcs, Tag<TName, TQuery["name"]>>, TSelf, Rpc.ExtractTag<TRpcs, Tag<TName, "$changes">>>;
34
34
  } & {
35
35
  readonly [TCommand in TCommands[number] as TCommand["name"]]: BoundCommand<Rpc.ExtractTag<TRpcs, Tag<TName, TCommand["name"]>>, TSelf>;
36
36
  } & {
@@ -1 +1 @@
1
- {"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../src/bind.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,KAAK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CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;AAC3C,CAAC"}
@@ -8,11 +8,14 @@ import type { LiveBound } from "#automaticLive.ts";
8
8
  import type { Bound } from "#bind.ts";
9
9
  import type { ActiveClient } from "#clientActivity.ts";
10
10
  import type { CommandShape, QueryShape, StreamShape } from "#operation.ts";
11
+ import type { ResumeSource, ResumeWindow } from "#resume.ts";
11
12
  export interface ClientOptions {
12
13
  readonly bearerToken?: string;
13
14
  readonly headers?: Readonly<Record<string, string>>;
14
15
  readonly live?: boolean;
15
16
  readonly protocol?: Layer.Layer<RpcClient.Protocol> | ((identity: string | undefined) => Layer.Layer<RpcClient.Protocol>);
17
+ readonly resume?: ResumeSource;
18
+ readonly resumeWindow?: ResumeWindow;
16
19
  readonly url: string;
17
20
  readonly webSocketConstructor?: Layer.Layer<Socket.WebSocketConstructor>;
18
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"clientOptions.d.ts","sourceRoot":"","sources":["../src/clientOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC5D,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,KAAK,MAAM,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE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W,EAAE,EACvC,MAAM,SAAS,GAAG,CAAC,GAAG,IACnB,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,CAAC,GACpD,YAAY,GAAG;IACd,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAC;IACnH,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,EAAE,GAAG,KAAK,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC,CAAC;IAChH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,GAAG,MAAM,EAAE,cAAc,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,gBAAgB,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC;IAC/I,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC;CACzE,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { Schema } from "effect";
2
2
  import { LiveHint } from "#live.ts";
3
3
  import type { QueryShape } from "#operation.ts";
4
+ import { QueryReadDenied } from "#readPolicyErrors.ts";
4
5
  type Rerun<TQuery extends QueryShape> = TQuery extends QueryShape ? ("rerun-and-compare" extends TQuery["live"] ? TQuery : never) : never;
5
6
  type ResultSchema<TQuery extends QueryShape> = TQuery extends QueryShape ? Schema.Struct<{
6
7
  _tag: Schema.Literal<"Result">;
@@ -8,6 +9,6 @@ type ResultSchema<TQuery extends QueryShape> = TQuery extends QueryShape ? Schem
8
9
  queryIndex: Schema.Number;
9
10
  value: TQuery["success"];
10
11
  }> : never;
11
- export declare function changesSuccess<const TQueries extends readonly QueryShape[]>(queries: TQueries): Schema.Union<readonly [typeof LiveHint, ...ResultSchema<Rerun<TQueries[number]>>[]]>;
12
+ export declare function changesSuccess<const TQueries extends readonly QueryShape[]>(queries: TQueries): Schema.Union<readonly [typeof LiveHint, typeof QueryReadDenied, ...ResultSchema<Rerun<TQueries[number]>>[]]>;
12
13
  export {};
13
14
  //# sourceMappingURL=changesSuccess.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"changesSuccess.d.ts","sourceRoot":"","sources":["../../src/internal/changesSuccess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,KAAK,KAAK,CAAC,MAAM,SAAS,UAAU,IAAI,MAAM,SAAS,UAAU,GAAG,CAAC,mBAAmB,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;AAC1I,KAAK,YAAY,CAAC,MAAM,SAAS,UAAU,IAAI,MAAM,SAAS,UAAU,GACrE,MAAM,CAAC,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACtC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;CACzB,CAAC,GACD,KAAK,CAAC;AAET,wBAAgB,cAAc,CAAC,KAAK,CAAC,QAAQ,SAAS,SAAS,UAAU,EAAE,EAC1E,OAAO,EAAE,QAAQ,GACf,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,QAAQ,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"changesSuccess.d.ts","sourceRoot":"","sources":["../../src/internal/changesSuccess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,KAAK,KAAK,CAAC,MAAM,SAAS,UAAU,IAAI,MAAM,SAAS,UAAU,GAAG,CAAC,mBAAmB,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;AAC1I,KAAK,YAAY,CAAC,MAAM,SAAS,UAAU,IAAI,MAAM,SAAS,UAAU,GACrE,MAAM,CAAC,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACtC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;CACzB,CAAC,GACD,KAAK,CAAC;AAET,wBAAgB,cAAc,CAAC,KAAK,CAAC,QAAQ,SAAS,SAAS,UAAU,EAAE,EAC1E,OAAO,EAAE,QAAQ,GACf,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,QAAQ,EAAE,OAAO,eAAe,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
@@ -1,8 +1,10 @@
1
1
  import { Schema } from "effect";
2
2
  import { LiveHint } from "#live.ts";
3
+ import { QueryReadDenied } from "#readPolicyErrors.ts";
3
4
  export function changesSuccess(queries) {
4
5
  return Schema.Union([
5
6
  LiveHint,
7
+ QueryReadDenied,
6
8
  ...queries
7
9
  .filter((query) => query.live === "rerun-and-compare")
8
10
  .map((query) => Schema.Struct({
@@ -1 +1 @@
1
- {"version":3,"file":"changesSuccess.js","sourceRoot":"","sources":["../../src/internal/changesSuccess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAgBpC,MAAM,UAAU,cAAc,CAAC,OAA8B;IAC5D,OAAO,MAAM,CAAC,KAAK,CAAC;QACnB,QAAQ;QACR,GAAG,OAAO;aACR,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,mBAAmB,CAAC;aACrD,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACd,MAAM,CAAC,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;YAC9B,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;YACjC,UAAU,EAAE,MAAM,CAAC,MAAM;YACzB,KAAK,EAAE,KAAK,CAAC,OAAO;SACpB,CAAC,CACF;KACF,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"changesSuccess.js","sourceRoot":"","sources":["../../src/internal/changesSuccess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAevD,MAAM,UAAU,cAAc,CAAC,OAA8B;IAC5D,OAAO,MAAM,CAAC,KAAK,CAAC;QACnB,QAAQ;QACR,eAAe;QACf,GAAG,OAAO;aACR,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,mBAAmB,CAAC;aACrD,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACd,MAAM,CAAC,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;YAC9B,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;YACjC,UAAU,EAAE,MAAM,CAAC,MAAM;YACzB,KAAK,EAAE,KAAK,CAAC,OAAO;SACpB,CAAC,CACF;KACF,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { Effect, Stream } from "effect";
2
+ import type { Key } from "@shivaedev/changes/keys.ts";
3
+ import type { SubscriptionHint } from "#queryUpdate.ts";
4
+ import type { QueryReadDenied } from "#readPolicyErrors.ts";
5
+ export declare function liveAttempt<E, R>(stream: Stream.Stream<SubscriptionHint, E, R>, observe: {
6
+ readonly changed: (keys: readonly Key[]) => void;
7
+ readonly denied: (denial: QueryReadDenied) => void;
8
+ readonly live: () => void;
9
+ readonly paused: () => boolean;
10
+ readonly queued: () => void;
11
+ readonly reconcile: (connected: boolean) => void;
12
+ }): Effect.Effect<void, E, Exclude<R, import("effect/Scope").Scope>>;
13
+ //# sourceMappingURL=liveAttempt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liveAttempt.d.ts","sourceRoot":"","sources":["../../src/internal/liveAttempt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,EAAE,CAAC,CAAC,EAC7C,OAAO,EAAE;IACR,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,KAAK,IAAI,CAAC;IACjD,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACjD,oEA6BD"}
@@ -0,0 +1,28 @@
1
+ import { Effect, Stream } from "effect";
2
+ export function liveAttempt(stream, observe) {
3
+ let connected = false;
4
+ return Effect.suspend(() => {
5
+ let first = true;
6
+ return stream.pipe(Stream.runForEach((hint) => Effect.sync(() => {
7
+ if (hint._tag === "QueryReadDenied") {
8
+ observe.denied(hint);
9
+ connected = true;
10
+ first = true;
11
+ return;
12
+ }
13
+ observe.live();
14
+ if (observe.paused()) {
15
+ observe.queued();
16
+ }
17
+ else if (first || hint._tag === "Resync") {
18
+ observe.reconcile(connected);
19
+ }
20
+ else {
21
+ observe.changed(hint.keys);
22
+ }
23
+ connected = true;
24
+ first = false;
25
+ })), Effect.scoped);
26
+ });
27
+ }
28
+ //# sourceMappingURL=liveAttempt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liveAttempt.js","sourceRoot":"","sources":["../../src/internal/liveAttempt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKxC,MAAM,UAAU,WAAW,CAC1B,MAA6C,EAC7C,OAOC;IAED,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1B,IAAI,KAAK,GAAG,IAAI,CAAC;QACjB,OAAO,MAAM,CAAC,IAAI,CACjB,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,EAAE,CAC1B,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;YAChB,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;gBACrC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACrB,SAAS,GAAG,IAAI,CAAC;gBACjB,KAAK,GAAG,IAAI,CAAC;gBACb,OAAO;YACR,CAAC;YACD,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;gBACtB,OAAO,CAAC,MAAM,EAAE,CAAC;YAClB,CAAC;iBAAM,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC5C,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;YAC9B,CAAC;iBAAM,CAAC;gBACP,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;YACD,SAAS,GAAG,IAAI,CAAC;YACjB,KAAK,GAAG,KAAK,CAAC;QACf,CAAC,CAAC,CACF,EACD,MAAM,CAAC,MAAM,CACb,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC"}
@@ -2,27 +2,9 @@ import { Stream } from "effect";
2
2
  import * as AsyncResult from "effect/reactivity/AsyncResult";
3
3
  import * as Atom from "effect/reactivity/Atom";
4
4
  import * as AtomRegistry from "effect/reactivity/AtomRegistry";
5
- import type { QueryUpdate } from "#queryUpdate.ts";
5
+ import type { QueryUpdate, SubscriptionHint } from "#queryUpdate.ts";
6
6
  export declare function queryDelivery<A, E>(atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>, decode: ((value: unknown) => A) | undefined, paused: Atom.Atom<boolean>): {
7
7
  atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>;
8
- stream: <TError, R>(stream: Stream.Stream<QueryUpdate, TError, R>) => 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
- }, TError, R | AtomRegistry.AtomRegistry>;
8
+ stream: <TError, R>(stream: Stream.Stream<QueryUpdate, TError, R>) => Stream.Stream<SubscriptionHint, TError, R | AtomRegistry.AtomRegistry>;
27
9
  };
28
10
  //# sourceMappingURL=queryDelivery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"queryDelivery.d.ts","sourceRoot":"","sources":["../../src/internal/queryDelivery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAE/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EACjC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAC9C,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,CAAC,GAAG,SAAS,EAC3C,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAczB,IAAI;IACJ,MAAM,GAAG,MAAM,EAAE,CAAC,UAAU,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;;;;;;;;;;;;;;;;;;;EAElE"}
1
+ {"version":3,"file":"queryDelivery.d.ts","sourceRoot":"","sources":["../../src/internal/queryDelivery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAErE,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EACjC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAC9C,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,CAAC,GAAG,SAAS,EAC3C,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAczB,IAAI;IACJ,MAAM,GAAG,MAAM,EAAE,CAAC,UAAU,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;EAElE"}
@@ -1 +1 @@
1
- {"version":3,"file":"queryDelivery.js","sourceRoot":"","sources":["../../src/internal/queryDelivery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAI/D,MAAM,UAAU,aAAa,CAC5B,IAA8C,EAC9C,MAA2C,EAC3C,MAA0B;IAE1B,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAgC,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC;IAC/E,MAAM,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,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAmB;QAC/D,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,MAAM,CAAC;QACf,CAAC;QACD,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC;QAClD,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACnD,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IACxD,CAAC,CAAC,CAAC;IACH,OAAO;QACN,IAAI,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM;QAC1C,MAAM,EAAE,CAAY,MAA6C,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;KACvG,CAAC;AACH,CAAC"}
@@ -1,8 +1,9 @@
1
1
  import { type Key } from "@shivaedev/changes/keys.ts";
2
2
  import type { LiveHint } from "#live.ts";
3
+ import type { SubscriptionHint } from "#queryUpdate.ts";
3
4
  export declare function localQueryKeys(keys: readonly Key[]): Key[];
4
- export declare function queryHint(hint: LiveHint, tracked: readonly {
5
+ export declare function queryHint(hint: SubscriptionHint, tracked: readonly {
5
6
  readonly keys: readonly Key[];
6
- }[]): LiveHint;
7
+ }[]): SubscriptionHint;
7
8
  export declare function changedHint(keys: readonly Key[], scopes?: readonly (readonly Key[])[]): LiveHint;
8
9
  //# sourceMappingURL=queryHints.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"queryHints.d.ts","sourceRoot":"","sources":["../../src/internal/queryHints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,GAAG,EAAY,MAAM,4BAA4B,CAAC;AAClF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,SAElD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,CAAA;CAAE,EAAE,GAAG,QAAQ,CAmBzG;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,SAAS,GAAG,EAAE,CAAC,EAAE,GAAG,QAAQ,CAShG"}
1
+ {"version":3,"file":"queryHints.d.ts","sourceRoot":"","sources":["../../src/internal/queryHints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,GAAG,EAAY,MAAM,4BAA4B,CAAC;AAClF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,SAElD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,CAAA;CAAE,EAAE,GAAG,gBAAgB,CAmBzH;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,SAAS,GAAG,EAAE,CAAC,EAAE,GAAG,QAAQ,CAShG"}
@@ -3,7 +3,7 @@ export function localQueryKeys(keys) {
3
3
  return keys.filter((key) => key.collection.startsWith("@query/"));
4
4
  }
5
5
  export function queryHint(hint, tracked) {
6
- if (hint._tag === "Resync") {
6
+ if (hint._tag !== "Changed") {
7
7
  return hint;
8
8
  }
9
9
  const invalidated = invalidationKeys(hint.keys);
@@ -1 +1 @@
1
- {"version":3,"file":"queryHints.js","sourceRoot":"","sources":["../../src/internal/queryHints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAY,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAGlF,MAAM,UAAU,cAAc,CAAC,IAAoB;IAClD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAc,EAAE,OAAqD;IAC9F,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACb,CAAC;IACD,MAAM,WAAW,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,OAAO;QACN,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACL,GAAG,IAAI,CAAC,IAAI;YACZ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE;gBACtC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC1E,MAAM,QAAQ,GACb,IAAI,CAAC,YAAY,KAAK,SAAS;oBAC9B,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,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AAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAChE,OAAO;QACN,IAAI,EAAE,SAAS;QACf,IAAI;QACJ,GAAG,CAAC,MAAM,KAAK,SAAS;YACvB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;KAC9H,CAAC;AACH,CAAC"}
package/dist/live.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import { type Cause, Duration, Option, Schema, Stream } from "effect";
1
+ import { Cause, Duration, Option, Schema, type Stream } from "effect";
2
2
  import * as Atom from "effect/reactivity/Atom";
3
3
  import type * as AtomRegistry from "effect/reactivity/AtomRegistry";
4
4
  import { Key, type KeyContext } from "@shivaedev/changes/keys.ts";
5
+ import type { SubscriptionHint } from "#queryUpdate.ts";
6
+ import type { QueryReadDenied } from "#readPolicyErrors.ts";
5
7
  export declare const LiveHint: Schema.Union<readonly [Schema.Struct<{
6
8
  readonly _tag: Schema.Literal<"Changed">;
7
9
  readonly keys: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
@@ -24,7 +26,7 @@ export declare const LiveHint: Schema.Union<readonly [Schema.Struct<{
24
26
  export type LiveHint = typeof LiveHint.Type;
25
27
  export interface LiveStatus<E> {
26
28
  readonly connection: "connecting" | "live" | "reconnecting" | "failed";
27
- readonly failure: Option.Option<Cause.Cause<E>>;
29
+ readonly failure: Option.Option<Cause.Cause<E | QueryReadDenied>>;
28
30
  readonly needsResync: boolean;
29
31
  readonly pending: number;
30
32
  }
@@ -36,7 +38,7 @@ export interface LiveOptions<E, R> {
36
38
  readonly resyncKeys: readonly Key[] | ((registry: AtomRegistry.AtomRegistry) => readonly Key[]);
37
39
  readonly retryDelay?: Duration.Input;
38
40
  readonly retryKeys?: readonly Key[];
39
- readonly stream: Stream.Stream<LiveHint, E, R>;
41
+ readonly stream: Stream.Stream<SubscriptionHint, E, R>;
40
42
  }
41
43
  export declare function live<R, E, TRuntimeError>(runtime: Atom.AtomRuntime<R, TRuntimeError>, options: LiveOptions<E, R>): {
42
44
  coalesceWindow: Atom.Writable<Duration.Input, Duration.Input>;
@@ -1 +1 @@
1
- {"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../src/live.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,QAAQ,EAAU,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9E,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,KAAK,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAoB,GAAG,EAAE,KAAK,UAAU,EAAY,MAAM,4BAA4B,CAAC;AAM9F,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;IAGnB,CAAC;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;AAC5C,MAAM,WAAW,UAAU,CAAC,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,YAAY,GAAG,MAAM,GAAG,cAAc,GAAG,QAAQ,CAAC;IACvE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB;AACD,MAAM,WAAW,WAAW,CAAC,CAAC,EAAE,CAAC;IAChC,QAAQ,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC;IACz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,CAAC,EAAE,CAAC,CAAC;;;;;EAkGhH"}
package/dist/live.js CHANGED
@@ -1,7 +1,8 @@
1
- import { Duration, Effect, Option, Schema, Stream } from "effect";
1
+ import { Cause, Duration, Effect, Option, Schema } from "effect";
2
2
  import * as Atom from "effect/reactivity/Atom";
3
3
  import * as Reactivity from "effect/reactivity/Reactivity";
4
4
  import { invalidationKeys, Key, readKeys } from "@shivaedev/changes/keys.ts";
5
+ import { liveAttempt } from "#internal/liveAttempt.ts";
5
6
  import { invalidateLive } from "#internal/liveInvalidation.ts";
6
7
  import { livePending } from "#internal/livePending.ts";
7
8
  import { liveRetry } from "#internal/liveRetry.ts";
@@ -77,32 +78,23 @@ export function live(runtime, options) {
77
78
  get.once(options.resume);
78
79
  get.subscribe(options.resume, resync);
79
80
  }
80
- let connected = false;
81
- function reconcile() {
82
- if (connected || options.initialResync !== false) {
83
- resync();
84
- }
85
- else {
86
- update({ needsResync: false });
87
- }
88
- }
89
- const attempt = Effect.suspend(() => {
90
- let isFirst = true;
91
- function observe(hint) {
92
- update({ connection: "live", failure: Option.none() });
93
- if (get.once(paused)) {
94
- update({ needsResync: true, pending: Math.min(MAX_PENDING, get.once(status).pending + 1) });
95
- }
96
- else if (isFirst || hint._tag === "Resync") {
97
- reconcile();
81
+ const attempt = liveAttempt(options.stream, {
82
+ changed,
83
+ denied: (denial) => {
84
+ pending.clear();
85
+ update({ connection: "failed", failure: Option.some(Cause.fail(denial)), needsResync: true, pending: 0 });
86
+ },
87
+ live: () => update({ connection: "live", failure: Option.none() }),
88
+ paused: () => get.once(paused),
89
+ queued: () => update({ needsResync: true, pending: Math.min(MAX_PENDING, get.once(status).pending + 1) }),
90
+ reconcile: (connected) => {
91
+ if (connected || options.initialResync !== false) {
92
+ resync();
98
93
  }
99
94
  else {
100
- changed(hint.keys);
95
+ update({ needsResync: false });
101
96
  }
102
- connected = true;
103
- isFirst = false;
104
- }
105
- return options.stream.pipe(Stream.runForEach((hint) => Effect.sync(() => observe(hint))), Effect.scoped);
97
+ },
106
98
  });
107
99
  yield* liveRetry(attempt, (failure, retry) => {
108
100
  update({ connection: retry ? "reconnecting" : "failed", failure, needsResync: true });