@shivaedev/contract 0.30.1 → 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.
- package/CHANGELOG.md +20 -0
- package/README.md +30 -30
- package/dist/automaticLive.d.ts +2 -1
- package/dist/automaticLive.d.ts.map +1 -1
- package/dist/automaticLive.js +2 -2
- package/dist/automaticLive.js.map +1 -1
- package/dist/bind.d.ts +5 -5
- package/dist/bind.d.ts.map +1 -1
- package/dist/bind.js +5 -4
- package/dist/bind.js.map +1 -1
- package/dist/clientOptions.d.ts +3 -0
- package/dist/clientOptions.d.ts.map +1 -1
- package/dist/internal/automaticQuery.d.ts.map +1 -1
- package/dist/internal/automaticQuery.js +6 -1
- package/dist/internal/automaticQuery.js.map +1 -1
- package/dist/internal/changesSuccess.d.ts +2 -1
- package/dist/internal/changesSuccess.d.ts.map +1 -1
- package/dist/internal/changesSuccess.js +2 -0
- package/dist/internal/changesSuccess.js.map +1 -1
- package/dist/internal/clientOperations.d.ts +14 -14
- package/dist/internal/clientOperations.d.ts.map +1 -1
- package/dist/internal/clientOperations.js +18 -5
- package/dist/internal/clientOperations.js.map +1 -1
- package/dist/internal/declarationError.d.ts.map +1 -1
- package/dist/internal/declarationError.js +3 -0
- package/dist/internal/declarationError.js.map +1 -1
- package/dist/internal/liveAttempt.d.ts +13 -0
- package/dist/internal/liveAttempt.d.ts.map +1 -0
- package/dist/internal/liveAttempt.js +28 -0
- package/dist/internal/liveAttempt.js.map +1 -0
- package/dist/internal/queryDelivery.d.ts +2 -20
- package/dist/internal/queryDelivery.d.ts.map +1 -1
- package/dist/internal/queryDelivery.js.map +1 -1
- package/dist/internal/queryHints.d.ts +3 -2
- package/dist/internal/queryHints.d.ts.map +1 -1
- package/dist/internal/queryHints.js +1 -1
- package/dist/internal/queryHints.js.map +1 -1
- package/dist/live.d.ts +5 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +16 -24
- package/dist/live.js.map +1 -1
- package/dist/makeLiveServer.d.ts +2 -2
- package/dist/makeLiveServer.d.ts.map +1 -1
- package/dist/makeLiveServer.js +4 -3
- package/dist/makeLiveServer.js.map +1 -1
- package/dist/publicConfig.d.ts +1 -1
- package/dist/publicConfig.d.ts.map +1 -1
- package/dist/querySubscription.d.ts +2 -1
- package/dist/querySubscription.d.ts.map +1 -1
- package/dist/querySubscription.js +4 -1
- package/dist/querySubscription.js.map +1 -1
- package/dist/queryUpdate.d.ts +3 -1
- package/dist/queryUpdate.d.ts.map +1 -1
- package/dist/testing.d.ts +4 -40
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js.map +1 -1
- package/package.json +11 -11
- package/src/automaticLive.ts +3 -1
- package/src/bind.ts +14 -12
- package/src/clientOptions.ts +3 -0
- package/src/internal/automaticQuery.ts +6 -1
- package/src/internal/changesSuccess.ts +3 -1
- package/src/internal/clientOperations.ts +26 -4
- package/src/internal/declarationError.ts +3 -0
- package/src/internal/liveAttempt.ts +44 -0
- package/src/internal/queryDelivery.ts +2 -3
- package/src/internal/queryHints.ts +3 -2
- package/src/live.ts +20 -27
- package/src/makeLiveServer.ts +11 -5
- package/src/querySubscription.ts +5 -1
- package/src/queryUpdate.ts +3 -1
- package/src/testing.ts +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
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
|
+
|
|
14
|
+
## 0.30.2 - 2026-11-02
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Keep per-query headers on automatic live subscriptions and rerun-and-compare reads.
|
|
19
|
+
- Reopen a denied hinted query's subscription on explicit refresh so it can return data after access is granted.
|
|
20
|
+
- Reject authored queries, commands and streams named `$changes` with a declaration error instead of silently replacing them with the built-in changes stream.
|
|
21
|
+
- Run session-owned streams through their owning registry's client, preserving its transport and headers and ending the streams when the session closes. Streams without a session owner continue to use the caller's client.
|
|
22
|
+
|
|
3
23
|
## 0.30.1 - 2026-11-01
|
|
4
24
|
|
|
5
25
|
### 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.
|
|
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
|
|
|
@@ -321,7 +321,7 @@ Preferences.application.toLayer({
|
|
|
321
321
|
|
|
322
322
|
`store` is the application's persistence service. No owner or client key scope is accepted from a request. The database app host of `@shivaedev/server` resolves the server key scope from that same request-local identity.
|
|
323
323
|
|
|
324
|
-
The registry is required for session-scoped bindings. Query atoms and live connections belong in it; command and one-off query Effects execute through it. A successful command invalidates its owner's keys, while a rejected command declares no invalidation. Ordinary contracts keep unscoped keys and the two-argument `bind` call.
|
|
324
|
+
The registry is required for session-scoped bindings. Query atoms and live connections belong in it; command and one-off query Effects execute through it. Explicit streams also run through its client, preserving the session transport and headers; disposing the registry ends those streams. Streams on ordinary contracts use the caller's client. A successful command invalidates its owner's keys, while a rejected command declares no invalidation. Ordinary contracts keep unscoped keys and the two-argument `bind` call.
|
|
325
325
|
|
|
326
326
|
`List` and `Item` are still the key shapes. `readKeys(keys, { scope })` and `invalidationKeys(keys, { scope })` resolve the extra dimension while preserving item, list and wildcard semantics. An item invalidation refreshes that scope's item and list; a wildcard reaches only that scope's items. The client's opaque scope comes from its registry and is never sent as an owner id.
|
|
327
327
|
|
|
@@ -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
|
|
338
|
+
A native shell supplies its lifecycle events through the optional `resume` source on `makeClient` or `bind`:
|
|
339
339
|
|
|
340
340
|
```ts
|
|
341
|
-
import {
|
|
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 =
|
|
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.
|
|
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.
|
|
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
|
|
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(
|
|
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/automaticLive.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Duration, type Schema } from "effect";
|
|
2
|
+
import type { Headers } from "effect/http";
|
|
2
3
|
import type * as AsyncResult from "effect/reactivity/AsyncResult";
|
|
3
4
|
import * as Atom from "effect/reactivity/Atom";
|
|
4
5
|
import type * as AtomRpc from "effect/reactivity/AtomRpc";
|
|
@@ -26,7 +27,7 @@ export type ChangesClient = AtomRpc.AtomRpcClient<unknown, string, Rpc.Rpc<`${st
|
|
|
26
27
|
}>>;
|
|
27
28
|
}>, RpcSchema.Stream<Schema.Schema<QueryUpdate>, Schema.Unknown>, Schema.Never>>;
|
|
28
29
|
export declare function automaticLive(service: ChangesClient, name: string, owner?: BindingOwner, resume?: ResumeSource, enabled?: boolean, resumeWindow?: ResumeWindow): {
|
|
29
|
-
query: <A, E>(atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>, reference: QueryReference, keys: readonly Key[], equivalent: (left: A, right: A) => boolean, decode?: (value: unknown) => A) => Atom.Atom<AsyncResult.AsyncResult<A, E>>;
|
|
30
|
+
query: <A, E>(atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>, reference: QueryReference, keys: readonly Key[], equivalent: (left: A, right: A) => boolean, decode?: (value: unknown) => A, headers?: Headers.Input) => Atom.Atom<AsyncResult.AsyncResult<A, E>>;
|
|
30
31
|
subscription: {
|
|
31
32
|
coalesceWindow: Atom.Writable<Duration.Input, Duration.Input>;
|
|
32
33
|
connection: Atom.Atom<LiveStatus<unknown>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automaticLive.d.ts","sourceRoot":"","sources":["../src/automaticLive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAU,KAAK,MAAM,EAAU,MAAM,QAAQ,CAAC;AACpE,OAAO,KAAK,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,KAAK,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AAGtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI9D,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAgB,MAAM,YAAY,CAAC;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIzD,eAAO,MAAM,cAAc,eAAmD,CAAC;AAC/E,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,CAAC,cAAc,CAAC,EAAE;QAC1B,QA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|
|
|
26
26
|
get.mount(service.runtime);
|
|
27
27
|
return get(status);
|
|
28
28
|
}).pipe(Atom.setIdleTTL(0));
|
|
29
|
-
function query(atom, reference, keys, equivalent, decode) {
|
|
29
|
+
function query(atom, reference, keys, equivalent, decode, headers) {
|
|
30
30
|
if (!enabled) {
|
|
31
31
|
return atom;
|
|
32
32
|
}
|
|
@@ -39,7 +39,7 @@ export function automaticLive(service, name, owner, resume, enabled = true, resu
|
|
|
39
39
|
resume: signal,
|
|
40
40
|
resyncKeys: decode === undefined ? localQueryKeys(keys) : [],
|
|
41
41
|
retryKeys: keys,
|
|
42
|
-
stream: Stream.unwrap(service.use((client) => Effect.succeed(client(`${name}.$changes`, { queries: [reference] })))).pipe(delivery.stream, Stream.map((hint) => queryHint(hint, [{ keys }]))),
|
|
42
|
+
stream: Stream.unwrap(service.use((client) => Effect.succeed(client(`${name}.$changes`, { queries: [reference] }, { headers })))).pipe(delivery.stream, Stream.map((hint) => queryHint(hint, [{ keys }]))),
|
|
43
43
|
});
|
|
44
44
|
const gated = automaticQuery({
|
|
45
45
|
assertOwner,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automaticLive.js","sourceRoot":"","sources":["../src/automaticLive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAe,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"automaticLive.js","sourceRoot":"","sources":["../src/automaticLive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAe,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGpE,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAI/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAA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AM,EAAE,EAAE,CAAC;AAC1G,CAAC"}
|
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> =
|
|
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
|
} & {
|
package/dist/bind.d.ts.map
CHANGED
|
@@ -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,WAAW,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,KAAK,YAAY,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK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QAAQ,SAAS,SAAS,UAAU,EAAE,EACtC,SAAS,SAAS,SAAS,YAAY,EAAE,EACzC,KAAK,SAAS,GAAG,CAAC,GAAG,EACrB,QAAQ,SAAS,SAAS,WAAW,EAAE,EACvC,MAAM,SAAS,SAAS,GAAG,SAAS,EACpC,MAAM,SAAS,GAAG,CAAC,GAAG,GAAG,KAAK,EAE9B,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,EACvE,OAAO,EAAE,aAAa,GAAG;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAAK,GAAG,MAAM,CAAC,CAAA;CAAE,GAAG,CAAC,SAAS,SAAS,MAAM,GACvG;IAAE,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,YAAY,CAAA;CAAE,CAAC,GACpD,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC"}
|
package/dist/bind.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { automaticLive, LiveConnection } from "#automaticLive.ts";
|
|
2
2
|
import { bindingOwner } from "#internal/bindingOwner.ts";
|
|
3
|
-
import {
|
|
3
|
+
import { clientOperations } from "#internal/clientOperations.ts";
|
|
4
4
|
import { rpcClient } from "#internal/rpcClient.ts";
|
|
5
5
|
export function bind(contract, service, options) {
|
|
6
6
|
return bindApi(contract, service, options);
|
|
@@ -9,10 +9,11 @@ function bindApi(contract, service, options) {
|
|
|
9
9
|
const { name, queries, commands, streams, keyScope } = contract.declaration;
|
|
10
10
|
const owner = bindingOwner(keyScope, options?.registry);
|
|
11
11
|
const automatic = automaticLive(service, name, owner, options?.resume, options?.live, options?.resumeWindow);
|
|
12
|
+
const operations = clientOperations(service, automatic, owner);
|
|
12
13
|
return Object.assign(Object.fromEntries([
|
|
13
|
-
...queries.map((query) => [query.name,
|
|
14
|
-
...commands.map((command) => [command.name,
|
|
15
|
-
...streams.map((stream) => [stream.name,
|
|
14
|
+
...queries.map((query) => [query.name, operations.query(`${name}.${query.name}`, query)]),
|
|
15
|
+
...commands.map((command) => [command.name, operations.command(`${name}.${command.name}`, command)]),
|
|
16
|
+
...streams.map((stream) => [stream.name, operations.stream(`${name}.${stream.name}`)]),
|
|
16
17
|
]), { [LiveConnection]: automatic.subscription });
|
|
17
18
|
}
|
|
18
19
|
export function makeClient(contract, options) {
|
package/dist/bind.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind.js","sourceRoot":"","sources":["../src/bind.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAkB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGlF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"bind.js","sourceRoot":"","sources":["../src/bind.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAkB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGlF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAkB,SAAS,EAAE,MAAM,wBAAwB,CAAC;AA6EnE,MAAM,UAAU,IAAI,CACnB,QAAmJ,EACnJ,OAAwD,EACxD,OAAqB;IAErB,OAAO,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,OAAO,CACf,QAAmJ,EACnJ,OAAwD,EACxD,OAAqB;IAErB,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,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C,CAAC;IAC5F,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1D,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;AAC3C,CAAC"}
|
package/dist/clientOptions.d.ts
CHANGED
|
@@ -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,O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,CAAC,EAAE,CAAC,CAAC,4CAuGnB"}
|
|
@@ -94,7 +94,12 @@ export function automaticQuery({ atom, assertOwner, coalesceWindow, equivalent,
|
|
|
94
94
|
return get.once(source);
|
|
95
95
|
}
|
|
96
96
|
return AsyncResult.initial();
|
|
97
|
-
}, (refresh) =>
|
|
97
|
+
}, (refresh) => {
|
|
98
|
+
if (!pushed) {
|
|
99
|
+
refresh(atom);
|
|
100
|
+
}
|
|
101
|
+
refresh(subscription.connection);
|
|
102
|
+
}).pipe(Atom.setIdleTTL(0));
|
|
98
103
|
return gated;
|
|
99
104
|
}
|
|
100
105
|
//# sourceMappingURL=automaticQuery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automaticQuery.js","sourceRoot":"","sources":["../../src/internal/automaticQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAiB,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACjE,OAAO,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAe9D,MAAM,UAAU,cAAc,CAAO,EACpC,IAAI,EACJ,WAAW,EACX,cAAc,EACd,UAAU,EACV,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,EACN,MAAM,EACN,QAAQ,EACR,YAAY,GACO;IACnB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAC1B,CAAC,GAAG,EAAE,EAAE;QACP,WAAW,CAAC,GAAG,CAAC,CAAC;QACjB,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;QAC9B,MAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,CAAC,cAAc,EAAE,CAAC;QAC5D,I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AAC;YACZ,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACjB,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC9B,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;gBAC/B,IAAI,CAAC,KAAK,EAAE,CAAC;oBACZ,MAAM,EAAE,CAAC;gBACV,CAAC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC;QACD,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QACnC,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACrB,KAAK,EAAE,CAAC;YACR,OAAO,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;QACD,OAAO,WAAW,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC,EACD,CAAC,OAAO,EAAE,EAAE;QACX,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,CAAC;QACf,CAAC;QACD,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC,CACD,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,OAAO,KAAK,CAAC;AACd,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;
|
|
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;
|
|
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"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { Effect,
|
|
1
|
+
import { Effect, Stream } from "effect";
|
|
2
|
+
import * as Atom from "effect/reactivity/Atom";
|
|
2
3
|
import type * as AtomRpc from "effect/reactivity/AtomRpc";
|
|
3
|
-
import type { Rpc
|
|
4
|
+
import type { Rpc } from "effect/rpc";
|
|
4
5
|
import type { automaticLive } from "#automaticLive.ts";
|
|
5
6
|
import type { QueryOptions } from "#bind.ts";
|
|
6
7
|
import type { CommandShape, QueryShape } from "#operation.ts";
|
|
7
8
|
import type { BindingOwner } from "./bindingOwner.ts";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export declare function clientOperations(service: AtomRpc.AtomRpcClient<unknown, string, Rpc.Any>, automatic: ReturnType<typeof automaticLive>, owner?: BindingOwner): {
|
|
10
|
+
command: (tag: string, command: CommandShape) => {
|
|
11
|
+
run: (payload: unknown) => Effect.Effect<unknown, unknown, unknown>;
|
|
12
|
+
};
|
|
13
|
+
query: (tag: string, query: QueryShape) => {
|
|
14
|
+
query: (payload: unknown, options?: QueryOptions) => Atom.Atom<import("effect/reactivity/AsyncResult").AsyncResult<unknown, unknown>>;
|
|
15
|
+
run: (payload: unknown) => Effect.Effect<unknown, unknown, unknown>;
|
|
16
|
+
};
|
|
17
|
+
stream: (tag: string) => {
|
|
18
|
+
run: (payload: unknown) => Stream.Stream<unknown, unknown, unknown>;
|
|
19
|
+
};
|
|
13
20
|
};
|
|
14
|
-
export declare function boundCommand(service: ErasedClient, tag: string, command: CommandShape, owner?: BindingOwner): {
|
|
15
|
-
run: (payload: unknown) => Effect.Effect<unknown, unknown, unknown>;
|
|
16
|
-
};
|
|
17
|
-
export declare function boundStream(service: ErasedStreamingClient, tag: string): {
|
|
18
|
-
run: (payload: unknown) => Stream.Stream<unknown, unknown, unknown>;
|
|
19
|
-
};
|
|
20
|
-
export {};
|
|
21
21
|
//# sourceMappingURL=clientOperations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientOperations.d.ts","sourceRoot":"","sources":["../../src/internal/clientOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"clientOperations.d.ts","sourceRoot":"","sources":["../../src/internal/clientOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAkB,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAE/C,OAAO,KAAK,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAE1D,OAAO,KAAK,EAAE,GAAG,EAAa,MAAM,YAAY,CAAC;AAEjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAgFtD,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,EACxD,SAAS,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,EAC3C,KAAK,CAAC,EAAE,YAAY;IAGnB,OAAO,QAAQ,MAAM,WAAW,YAAY;uBAzB7B,OAAO;;IA0BtB,KAAK,QAAQ,MAAM,SAAS,UAAU;yBAnErB,OAAO,YAAW,YAAY;uBAuBhC,OAAO;;IA6CtB,MAAM,QAAQ,MAAM;uBApBL,OAAO;;EAsBvB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Effect, Option, Schema, Stream } from "effect";
|
|
2
|
+
import * as Atom from "effect/reactivity/Atom";
|
|
2
3
|
import * as AtomRegistry from "effect/reactivity/AtomRegistry";
|
|
3
4
|
import * as Reactivity from "effect/reactivity/Reactivity";
|
|
4
5
|
import { invalidationKeys, readKeys } from "@shivaedev/changes/keys.ts";
|
|
@@ -7,7 +8,7 @@ import { queryReactivity } from "./queryReactivity.js";
|
|
|
7
8
|
function run(service, effect, owner) {
|
|
8
9
|
return owner === undefined ? effect : Effect.suspend(() => AtomRegistry.getResult(owner.registry, service.runtime.atom(effect)));
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
+
function boundQuery(service, tag, query, automatic, owner) {
|
|
11
12
|
const reactive = queryReactivity(service.runtime, clientActivities.get(service)?.queued);
|
|
12
13
|
const cached = new WeakMap();
|
|
13
14
|
return {
|
|
@@ -21,7 +22,7 @@ export function boundQuery(service, tag, query, automatic, owner) {
|
|
|
21
22
|
const keys = [...local, { _tag: "List", collection: `@query/${tag}/${crypto.randomUUID()}` }];
|
|
22
23
|
const dependencies = local.length === 0 ? [...keys, { _tag: "List", collection: `@query/${tag.slice(0, tag.lastIndexOf("."))}` }] : keys;
|
|
23
24
|
const reference = { payload, query: query.name };
|
|
24
|
-
const result = automatic.query(reactive(atom, readKeys(dependencies, owner?.context), owner?.registry), reference, keys, Schema.toEquivalence(query.success), query.live === "rerun-and-compare" ? Schema.decodeUnknownSync(Schema.toType(query.success)) : undefined);
|
|
25
|
+
const result = automatic.query(reactive(atom, readKeys(dependencies, owner?.context), owner?.registry), reference, keys, Schema.toEquivalence(query.success), query.live === "rerun-and-compare" ? Schema.decodeUnknownSync(Schema.toType(query.success)) : undefined, options.headers);
|
|
25
26
|
const tracked = clientActivities.get(service)?.watch(result) ?? result;
|
|
26
27
|
cached.set(atom, tracked);
|
|
27
28
|
return tracked;
|
|
@@ -29,7 +30,7 @@ export function boundQuery(service, tag, query, automatic, owner) {
|
|
|
29
30
|
run: (payload) => run(service, service.use((client) => client(tag, payload)), owner),
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
function boundCommand(service, tag, command, owner) {
|
|
33
34
|
function invalidate(payload, result) {
|
|
34
35
|
const keys = [
|
|
35
36
|
...command.invalidates(payload, result),
|
|
@@ -41,9 +42,21 @@ export function boundCommand(service, tag, command, owner) {
|
|
|
41
42
|
run: (payload) => run(service, service.use((client) => client(tag, payload)).pipe(Effect.tap((result) => invalidate(payload, result))), owner),
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
+
function boundStream(service, tag, owner) {
|
|
45
46
|
return {
|
|
46
|
-
run: (payload) =>
|
|
47
|
+
run: (payload) => {
|
|
48
|
+
const stream = Stream.unwrap(service.use((client) => Effect.succeed(client(tag, payload))));
|
|
49
|
+
return owner === undefined
|
|
50
|
+
? stream
|
|
51
|
+
: Stream.callback((queue) => AtomRegistry.getResult(owner.registry, service.runtime.atom(Stream.runIntoQueue(stream, queue)).pipe(Atom.setIdleTTL(0))), { bufferSize: 1 });
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export function clientOperations(service, automatic, owner) {
|
|
56
|
+
return {
|
|
57
|
+
command: (tag, command) => boundCommand(service, tag, command, owner),
|
|
58
|
+
query: (tag, query) => boundQuery(service, tag, query, automatic, owner),
|
|
59
|
+
stream: (tag) => boundStream(service, tag, owner),
|
|
47
60
|
};
|
|
48
61
|
}
|
|
49
62
|
//# sourceMappingURL=clientOperations.js.map
|