@shivaedev/contract 0.20.0 → 0.21.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 +21 -0
- package/README.md +18 -16
- package/dist/automaticLive.d.ts +4 -2
- package/dist/automaticLive.d.ts.map +1 -1
- package/dist/automaticLive.js +17 -20
- package/dist/automaticLive.js.map +1 -1
- package/dist/bind.d.ts +2 -1
- package/dist/bind.d.ts.map +1 -1
- package/dist/bind.js +1 -1
- package/dist/bind.js.map +1 -1
- package/dist/internal/aggregateLiveStatus.d.ts +3 -0
- package/dist/internal/aggregateLiveStatus.d.ts.map +1 -0
- package/dist/internal/aggregateLiveStatus.js +17 -0
- package/dist/internal/aggregateLiveStatus.js.map +1 -0
- package/package.json +10 -10
- package/src/automaticLive.ts +26 -20
- package/src/bind.ts +3 -2
- package/src/internal/aggregateLiveStatus.ts +18 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.21.0 - 2026-10-30
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Work Board file edits refresh authorized contract queries over Platform's shared WebSocket, including the Claude plugin's overview. Unrelated document reads retain their values.
|
|
8
|
+
- Forwarding proxy fixtures can disconnect and resume real client traffic at the same address.
|
|
9
|
+
- Automatic contract live connections expose a `paused` atom; resuming reconciles their mounted queries. Bindings can supply a `resumeWindow` for embedded browser lifecycle events.
|
|
10
|
+
- Live status notifications use the registry's asynchronous scheduler, so mounting a query during React rendering does not update another component.
|
|
11
|
+
- Require Effect 4.0.6 and align the Effect companion package peers and generated starter catalog to the same exact release. Install the 4.0.6 Effect stack together.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- Register hosted RPC cache-control handling through Effect 4.0.6's request-scoped pre-response API so responses keep `private, no-store`.
|
|
16
|
+
- Accept native RPC's `application/x-ndjson` media type while preserving `application/ndjson` callers at the transport guard.
|
|
17
|
+
- Keep subscriptions open after their HTTP request body completes; closing the socket still cancels them.
|
|
18
|
+
|
|
19
|
+
### Breaking
|
|
20
|
+
|
|
21
|
+
- Work Board removes its `subscribe` RPC. Consumers bind its contract queries with Platform's default WebSocket client instead of consuming Board-specific change hints.
|
|
22
|
+
- `WorkspaceConfig.indexing` supplies a progress snapshot Effect. Replace indexing Stream overrides with an Effect that reads current progress.
|
|
23
|
+
|
|
3
24
|
## 0.20.0 - 2026-10-29
|
|
4
25
|
|
|
5
26
|
### Added
|
package/README.md
CHANGED
|
@@ -320,6 +320,8 @@ Server adapters read the RPC's `KeyScope` annotation. For `"session"`, they must
|
|
|
320
320
|
|
|
321
321
|
### 4. Live invalidation and resume
|
|
322
322
|
|
|
323
|
+
The automatic live connection exposed at `api[LiveConnection]` includes a writable `paused` atom. Set it in the binding’s registry to pause refreshes; clearing it reconciles the mounted queries. Bindings on the same client runtime share this pause state.
|
|
324
|
+
|
|
323
325
|
Database hosts from `@shivaedev/server` serve the contract's reserved `<contract>.$changes` stream automatically. With the native WebSocket protocol, `bind` and a React `SessionBoundary` connect query atoms without an application subscribe operation or `live()` call. The boundary finds bound APIs returned directly by `connect` or as properties such as `client.api`. See [automatic changes](https://github.com/ShivaeDev/platform/blob/main/docs/framework/changes.md) for defaults.
|
|
324
326
|
|
|
325
327
|
A native shell supplies its lifecycle events through `bind`'s optional `resume` source:
|
|
@@ -340,7 +342,7 @@ const resume: ResumeSource = (notify) => {
|
|
|
340
342
|
const api = bind(Notes, NotesClient, { resume });
|
|
341
343
|
```
|
|
342
344
|
|
|
343
|
-
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.
|
|
345
|
+
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.
|
|
344
346
|
|
|
345
347
|
For a direct subscription, configure the server and `NotesClient` with `RpcSerialization.layerNdjson` and use the client already typed from `Notes`:
|
|
346
348
|
|
|
@@ -485,21 +487,21 @@ expect(yield* heard(bob, [notes.item(1)], { within: "50 millis" })).toBe(false);
|
|
|
485
487
|
|
|
486
488
|
Import the module that defines the name; the package has no root entry.
|
|
487
489
|
|
|
488
|
-
| Module | Functions and schemas
|
|
489
|
-
| ------------------------ |
|
|
490
|
-
| `operation.ts` | `query(name, { payload?, success?, rejections?, readPolicy?, reads })`; `command(name, { payload?, success?, rejections?, invalidates })`; `stream(name, { payload?, success, rejections?, reads })`.
|
|
491
|
-
| `contract.ts` | `contract(name, { queries?, commands?, streams?, keyScope? })`, returning a native RPC group with `declaration: { name, queries, commands, streams, keyScope }`.
|
|
492
|
-
| `rejection.ts` | `fieldRejection(struct, fields?)`; lower-level `rejectionSet(specs)`, which constructs the rejection classes, union schema and failure helpers used by operations.
|
|
493
|
-
| `bind.ts` | `bind(contract, atomRpcService, { registry?, live?, resume? }?)`, 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. |
|
|
494
|
-
| `queryCoalesceWindow.ts` | `queryCoalesceWindow(query)`, a writable atom for a bound query's live changed-hint window.
|
|
495
|
-
| `live.ts` | `LiveHint` schema; `live(runtime, { stream, resyncKeys, coalesceWindow?, initialResync?, keyContext?, resume?, retryDelay? })`, exposing `connection`, `coalesceWindow`, `paused` and `status`.
|
|
496
|
-
| `querySubscription.ts` | `querySubscription(requests, viewer)` checks each referenced query and captures its scopes and ongoing authorization.
|
|
497
|
-
| `makeLiveServer.ts` | `makeLiveServer`, an Effect requiring `Reactivity` that creates scoped server hint streams and a `resync` Effect.
|
|
498
|
-
| `readPolicy.ts` | `QueryReadPolicy`, `Viewer`, `authorizeReads(effect, request, viewer)`, `CurrentViewer`.
|
|
499
|
-
| `readPolicyErrors.ts` | `MissingReadPolicy` and `QueryReadDenied`.
|
|
500
|
-
| `serverMetadata.ts` | `KeyScope`, `QueryDefinition.definition`, `CommandInvalidation.invalidates`, `ChangesQueries.resolve(references)`, the Effect `queryKeys(queries, references)` and `changesRpc(name, queries)` for server adapters.
|
|
501
|
-
| `resume.ts` | `resumeSignal({ window?, native? })`, returning a native numeric signal atom.
|
|
502
|
-
| `testing.ts` | `watchHints(stream)` starts a scoped viewer subscription; `heard(viewer, keys, { within? }?)` waits for matching changed keys.
|
|
490
|
+
| Module | Functions and schemas |
|
|
491
|
+
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
492
|
+
| `operation.ts` | `query(name, { payload?, success?, rejections?, readPolicy?, reads })`; `command(name, { payload?, success?, rejections?, invalidates })`; `stream(name, { payload?, success, rejections?, reads })`. |
|
|
493
|
+
| `contract.ts` | `contract(name, { queries?, commands?, streams?, keyScope? })`, returning a native RPC group with `declaration: { name, queries, commands, streams, keyScope }`. |
|
|
494
|
+
| `rejection.ts` | `fieldRejection(struct, fields?)`; lower-level `rejectionSet(specs)`, which constructs the rejection classes, union schema and failure helpers used by operations. |
|
|
495
|
+
| `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. |
|
|
496
|
+
| `queryCoalesceWindow.ts` | `queryCoalesceWindow(query)`, a writable atom for a bound query's live changed-hint window. |
|
|
497
|
+
| `live.ts` | `LiveHint` schema; `live(runtime, { stream, resyncKeys, coalesceWindow?, initialResync?, keyContext?, resume?, retryDelay? })`, exposing `connection`, `coalesceWindow`, `paused` and `status`. |
|
|
498
|
+
| `querySubscription.ts` | `querySubscription(requests, viewer)` checks each referenced query and captures its scopes and ongoing authorization. |
|
|
499
|
+
| `makeLiveServer.ts` | `makeLiveServer`, an Effect requiring `Reactivity` that creates scoped server hint streams and a `resync` Effect. |
|
|
500
|
+
| `readPolicy.ts` | `QueryReadPolicy`, `Viewer`, `authorizeReads(effect, request, viewer)`, `CurrentViewer`. |
|
|
501
|
+
| `readPolicyErrors.ts` | `MissingReadPolicy` and `QueryReadDenied`. |
|
|
502
|
+
| `serverMetadata.ts` | `KeyScope`, `QueryDefinition.definition`, `CommandInvalidation.invalidates`, `ChangesQueries.resolve(references)`, the Effect `queryKeys(queries, references)` and `changesRpc(name, queries)` for server adapters. |
|
|
503
|
+
| `resume.ts` | `resumeSignal({ window?, native? })`, returning a native numeric signal atom. |
|
|
504
|
+
| `testing.ts` | `watchHints(stream)` starts a scoped viewer subscription; `heard(viewer, keys, { within? }?)` waits for matching changed keys. |
|
|
503
505
|
|
|
504
506
|
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.
|
|
505
507
|
|
package/dist/automaticLive.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type * as AtomRpc from "effect/reactivity/AtomRpc";
|
|
|
5
5
|
import type { Key } from "@shivaedev/changes/keys.ts";
|
|
6
6
|
import type { BindingOwner } from "#internal/bindingOwner.ts";
|
|
7
7
|
import { type LiveStatus } from "#live.ts";
|
|
8
|
-
import { type ResumeSource } from "#resume.ts";
|
|
8
|
+
import { type ResumeSource, type ResumeWindow } from "#resume.ts";
|
|
9
9
|
import type { changesRpc, QueryReference } from "#serverMetadata.ts";
|
|
10
10
|
export declare const LiveConnection: unique symbol;
|
|
11
11
|
export interface LiveBound {
|
|
@@ -13,16 +13,18 @@ export interface LiveBound {
|
|
|
13
13
|
readonly coalesceWindow: Atom.Writable<Duration.Input>;
|
|
14
14
|
readonly connection: Atom.Atom<unknown>;
|
|
15
15
|
readonly identity?: Atom.Writable<string | undefined>;
|
|
16
|
+
readonly paused: Atom.Writable<boolean>;
|
|
16
17
|
readonly status: Atom.Atom<LiveStatus<unknown>>;
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
export type ChangesClient = AtomRpc.AtomRpcClient<unknown, string, ReturnType<typeof changesRpc>>;
|
|
20
|
-
export declare function automaticLive(service: ChangesClient, name: string, owner?: BindingOwner, resume?: ResumeSource, enabled?: boolean): {
|
|
21
|
+
export declare function automaticLive(service: ChangesClient, name: string, owner?: BindingOwner, resume?: ResumeSource, enabled?: boolean, resumeWindow?: ResumeWindow): {
|
|
21
22
|
query: <A, E>(atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>, reference: QueryReference, keys: readonly Key[], equivalent: (left: A, right: A) => boolean) => Atom.Atom<AsyncResult.AsyncResult<A, E>>;
|
|
22
23
|
subscription: {
|
|
23
24
|
coalesceWindow: Atom.Writable<Duration.Input, Duration.Input>;
|
|
24
25
|
connection: Atom.Atom<LiveStatus<unknown>>;
|
|
25
26
|
identity: Atom.Writable<string | undefined, string | undefined>;
|
|
27
|
+
paused: Atom.Writable<boolean, boolean>;
|
|
26
28
|
status: Atom.Writable<LiveStatus<unknown>, ReadonlyMap<object, LiveStatus<unknown>>>;
|
|
27
29
|
};
|
|
28
30
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automaticLive.d.ts","sourceRoot":"","sources":["../src/automaticLive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAA0B,MAAM,QAAQ,CAAC;AAC/D,OAAO,KAAK,WAAW,MAAM,+BA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E,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;KAChD,CAAC;CACF;AAID,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC;AAElG,wBAAgB,aAAa,CAC5B,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,YAAY,EACpB,MAAM,CAAC,EAAE,YAAY,EACrB,OAAO,UAAO,EACd,YAAY,CAAC,EAAE,YAAY;YAkBZ,CAAC,EAAE,CAAC,QACZ,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aACnC,cAAc,QACnB,SAAS,GAAG,EAAE,cACR,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,OAAO;;;;;;;;EAsF3C"}
|
package/dist/automaticLive.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Effect, Option, Stream } from "effect";
|
|
2
2
|
import * as AsyncResult from "effect/reactivity/AsyncResult";
|
|
3
3
|
import * as Atom from "effect/reactivity/Atom";
|
|
4
|
+
import { aggregateLiveStatus } from "#internal/aggregateLiveStatus.ts";
|
|
4
5
|
import { localQueryKeys, queryHint } from "#internal/queryHints.ts";
|
|
5
6
|
import { queryResult } from "#internal/queryResult.ts";
|
|
6
7
|
import { socketIdentity } from "#internal/rpcClient.ts";
|
|
@@ -8,31 +9,19 @@ import { live } from "#live.ts";
|
|
|
8
9
|
import { queryCoalesceWindow } from "#queryCoalesceWindow.ts";
|
|
9
10
|
import { resumeSignal } from "#resume.ts";
|
|
10
11
|
export const LiveConnection = Symbol.for("@shivaedev/contract/LiveConnection");
|
|
11
|
-
|
|
12
|
+
const pausedByRuntime = Atom.family((_runtime) => Atom.keepAlive(Atom.make(false)));
|
|
13
|
+
export function automaticLive(service, name, owner, resume, enabled = true, resumeWindow) {
|
|
12
14
|
function assertOwner(get) {
|
|
13
15
|
if (owner !== undefined && owner.registry !== get.registry) {
|
|
14
16
|
throw new Error("A session-scoped query belongs to its binding registry");
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
const coalesceWindow = Atom.keepAlive(Atom.make("20 millis"));
|
|
20
|
+
const paused = pausedByRuntime(service.runtime);
|
|
18
21
|
const statuses = Atom.make(new Map());
|
|
19
|
-
const status = Atom.map(statuses, (current) =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (values.some((value) => value.connection === "connecting")) {
|
|
23
|
-
connection = "connecting";
|
|
24
|
-
}
|
|
25
|
-
if (values.some((value) => value.connection === "reconnecting")) {
|
|
26
|
-
connection = "reconnecting";
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
connection,
|
|
30
|
-
failure: values.find((value) => Option.isSome(value.failure))?.failure ?? Option.none(),
|
|
31
|
-
needsResync: values.some((value) => value.needsResync),
|
|
32
|
-
pending: values.reduce((sum, value) => sum + value.pending, 0),
|
|
33
|
-
};
|
|
34
|
-
});
|
|
35
|
-
const signal = resumeSignal({ ...(typeof window === "undefined" ? {} : { window }), ...(resume === undefined ? {} : { native: resume }) });
|
|
22
|
+
const status = Atom.map(statuses, (current) => aggregateLiveStatus([...current.values()]));
|
|
23
|
+
const target = resumeWindow ?? (typeof window === "undefined" ? undefined : window);
|
|
24
|
+
const signal = resumeSignal({ ...(target === undefined ? {} : { window: target }), ...(resume === undefined ? {} : { native: resume }) });
|
|
36
25
|
const connection = Atom.make((get) => {
|
|
37
26
|
assertOwner(get);
|
|
38
27
|
get.mount(service.runtime);
|
|
@@ -53,17 +42,24 @@ export function automaticLive(service, name, owner, resume, enabled = true) {
|
|
|
53
42
|
const gated = Atom.readable((get) => {
|
|
54
43
|
assertOwner(get);
|
|
55
44
|
const registry = get.registry;
|
|
45
|
+
const dispatcher = registry.schedulerAsync.makeDispatcher();
|
|
56
46
|
get.set(ready, false);
|
|
57
47
|
get.once(queryCoalesceWindow(gated));
|
|
58
48
|
get.subscribe(queryCoalesceWindow(gated), (value) => get.set(queryCoalesceWindow(atom), value), { immediate: true });
|
|
59
49
|
const token = {};
|
|
50
|
+
let active = true;
|
|
60
51
|
function observe(value) {
|
|
61
|
-
|
|
52
|
+
dispatcher.scheduleTask(() => {
|
|
53
|
+
if (active) {
|
|
54
|
+
registry.update(statuses, (current) => new Map([...current, [token, value]]));
|
|
55
|
+
}
|
|
56
|
+
}, 0);
|
|
62
57
|
if (value.connection === "live") {
|
|
63
58
|
registry.set(ready, true);
|
|
64
59
|
}
|
|
65
60
|
}
|
|
66
61
|
get.addFinalizer(() => {
|
|
62
|
+
active = false;
|
|
67
63
|
if (registry.getNodes().has(statuses)) {
|
|
68
64
|
registry.update(statuses, (current) => {
|
|
69
65
|
const next = new Map(current);
|
|
@@ -96,6 +92,7 @@ export function automaticLive(service, name, owner, resume, enabled = true) {
|
|
|
96
92
|
get.setSelf(AsyncResult.failure(value.failure.value));
|
|
97
93
|
}
|
|
98
94
|
});
|
|
95
|
+
get.addFinalizer(registry.subscribe(paused, (value) => registry.set(subscription.paused, value), { immediate: true }));
|
|
99
96
|
get.mount(subscription.connection);
|
|
100
97
|
if (get.once(ready)) {
|
|
101
98
|
start();
|
|
@@ -109,6 +106,6 @@ export function automaticLive(service, name, owner, resume, enabled = true) {
|
|
|
109
106
|
}
|
|
110
107
|
return gated;
|
|
111
108
|
}
|
|
112
|
-
return { query, subscription: { coalesceWindow, connection, identity: socketIdentity, status } };
|
|
109
|
+
return { query, subscription: { coalesceWindow, connection, identity: socketIdentity, paused, status } };
|
|
113
110
|
}
|
|
114
111
|
//# sourceMappingURL=automaticLive.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automaticLive.js","sourceRoot":"","sources":["../src/automaticLive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM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,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YACvH,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;YACnC,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBACrB,KAAK,EAAE,CAAC;gBACR,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC;YACD,OAAO,WAAW,CAAC,OAAO,EAAE,CAAC;QAC9B,CAAC,EACD,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAC1B,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,IAAI,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/B,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;QACpF,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;AAC1G,CAAC"}
|
package/dist/bind.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ 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 { MissingReadPolicy } from "#readPolicyErrors.ts";
|
|
15
|
-
import type { ResumeSource } from "#resume.ts";
|
|
15
|
+
import type { ResumeSource, ResumeWindow } from "#resume.ts";
|
|
16
16
|
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;
|
|
17
17
|
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;
|
|
18
18
|
export interface QueryOptions {
|
|
@@ -46,6 +46,7 @@ interface BindOptions {
|
|
|
46
46
|
readonly live?: boolean;
|
|
47
47
|
readonly registry?: AtomRegistry.AtomRegistry;
|
|
48
48
|
readonly resume?: ResumeSource;
|
|
49
|
+
readonly resumeWindow?: ResumeWindow;
|
|
49
50
|
}
|
|
50
51
|
export declare function bind<TName extends string, TQueries extends readonly QueryShape[], TCommands extends readonly CommandShape[], TRpcs extends Rpc.Any, TSelf, TId extends string, TClientRpcs extends Rpc.Any, TStreams extends readonly StreamShape[], TScope extends "session" | undefined>(contract: Contract<TName, TQueries, TCommands, TRpcs, TStreams, TScope>, service: AtomRpc.AtomRpcClient<TSelf, TId, TClientRpcs> & MatchingClient<NoInfer<TRpcs>, TClientRpcs>, ...options: "session" extends TScope ? [options: BindOptions & {
|
|
51
52
|
readonly registry: AtomRegistry.AtomRegistry;
|
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,C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AQ,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
|
@@ -8,7 +8,7 @@ export function bind(contract, service, options) {
|
|
|
8
8
|
function bindApi(contract, service, options) {
|
|
9
9
|
const { name, queries, commands, streams, keyScope } = contract.declaration;
|
|
10
10
|
const owner = bindingOwner(keyScope, options?.registry);
|
|
11
|
-
const automatic = automaticLive(service, name, owner, options?.resume, options?.live);
|
|
11
|
+
const automatic = automaticLive(service, name, owner, options?.resume, options?.live, options?.resumeWindow);
|
|
12
12
|
return Object.assign(Object.fromEntries([
|
|
13
13
|
...queries.map((query) => [query.name, boundQuery(service, `${name}.${query.name}`, query, automatic, owner)]),
|
|
14
14
|
...commands.map((command) => [command.name, boundCommand(service, `${name}.${command.name}`, command, owner)]),
|
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,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,EAAkB,SAAS,EAAE,MAAM,wBAAwB,CAAC;
|
|
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,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,EAAkB,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAgFnE,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,QAAQ,CAAC,WAAW,CAAC;IAC5E,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACxD,MAAM,SAAS,GAAG,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IAC7G,OAAO,MAAM,CAAC,MAAM,CACnB,MAAM,CAAC,WAAW,C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AU,CAAC;AAE3C,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,UAAU,CAAC,OAAO,CAAC,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,CAc/F"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Option } from "effect";
|
|
2
|
+
export function aggregateLiveStatus(values) {
|
|
3
|
+
let connection = "live";
|
|
4
|
+
if (values.some((value) => value.connection === "connecting")) {
|
|
5
|
+
connection = "connecting";
|
|
6
|
+
}
|
|
7
|
+
if (values.some((value) => value.connection === "reconnecting")) {
|
|
8
|
+
connection = "reconnecting";
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
connection,
|
|
12
|
+
failure: values.find((value) => Option.isSome(value.failure))?.failure ?? Option.none(),
|
|
13
|
+
needsResync: values.some((value) => value.needsResync),
|
|
14
|
+
pending: values.reduce((sum, value) => sum + value.pending, 0),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=aggregateLiveStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aggregateLiveStatus.js","sourceRoot":"","sources":["../../src/internal/aggregateLiveStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,MAAM,UAAU,mBAAmB,CAAC,MAAsC;IACzE,IAAI,UAAU,GAAsC,MAAM,CAAC;IAC3D,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,KAAK,YAAY,CAAC,EAAE,CAAC;QAC/D,UAAU,GAAG,YAAY,CAAC;IAC3B,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,KAAK,cAAc,CAAC,EAAE,CAAC;QACjE,UAAU,GAAG,cAAc,CAAC;IAC7B,CAAC;IACD,OAAO;QACN,UAAU;QACV,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,IAAI,MAAM,CAAC,IAAI,EAAE;QACvF,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC;QACtD,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;KAC9D,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/contract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Typed query and command contracts over native Effect RPC and reactivity",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"effect"
|
|
@@ -44,25 +44,25 @@
|
|
|
44
44
|
"README.md"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@shivaedev/changes": "0.5.
|
|
47
|
+
"@shivaedev/changes": "0.5.1",
|
|
48
48
|
"@shivaedev/types": "0.3.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@effect/platform-node": "4.0.
|
|
52
|
-
"@effect/vitest": "4.0.
|
|
53
|
-
"@shivaedev/quality": "0.
|
|
54
|
-
"@shivaedev/test": "0.10.
|
|
55
|
-
"@shivaedev/test-sql": "0.
|
|
56
|
-
"@shivaedev/test-story": "0.
|
|
51
|
+
"@effect/platform-node": "4.0.6",
|
|
52
|
+
"@effect/vitest": "4.0.6",
|
|
53
|
+
"@shivaedev/quality": "0.45.0",
|
|
54
|
+
"@shivaedev/test": "0.10.1",
|
|
55
|
+
"@shivaedev/test-sql": "0.11.0",
|
|
56
|
+
"@shivaedev/test-story": "0.24.0",
|
|
57
57
|
"@types/node": "24.19.2",
|
|
58
|
-
"effect": "4.0.
|
|
58
|
+
"effect": "4.0.6",
|
|
59
59
|
"esbuild": "0.28.2",
|
|
60
60
|
"happy-dom": "21.0.4",
|
|
61
61
|
"typescript": "7.0.2",
|
|
62
62
|
"vitest": "5.0.5"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"effect": "4.0.
|
|
65
|
+
"effect": "4.0.6"
|
|
66
66
|
},
|
|
67
67
|
"engines": {
|
|
68
68
|
"node": ">=24"
|
package/src/automaticLive.ts
CHANGED
|
@@ -3,6 +3,7 @@ import * as AsyncResult from "effect/reactivity/AsyncResult";
|
|
|
3
3
|
import * as Atom from "effect/reactivity/Atom";
|
|
4
4
|
import type * as AtomRpc from "effect/reactivity/AtomRpc";
|
|
5
5
|
import type { Key } from "@shivaedev/changes/keys.ts";
|
|
6
|
+
import { aggregateLiveStatus } from "#internal/aggregateLiveStatus.ts";
|
|
6
7
|
import type { BindingOwner } from "#internal/bindingOwner.ts";
|
|
7
8
|
import { localQueryKeys, queryHint } from "#internal/queryHints.ts";
|
|
8
9
|
import { queryResult } from "#internal/queryResult.ts";
|
|
@@ -20,37 +21,34 @@ export interface LiveBound {
|
|
|
20
21
|
readonly coalesceWindow: Atom.Writable<Duration.Input>;
|
|
21
22
|
readonly connection: Atom.Atom<unknown>;
|
|
22
23
|
readonly identity?: Atom.Writable<string | undefined>;
|
|
24
|
+
readonly paused: Atom.Writable<boolean>;
|
|
23
25
|
readonly status: Atom.Atom<LiveStatus<unknown>>;
|
|
24
26
|
};
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
const pausedByRuntime = Atom.family((_runtime: object) => Atom.keepAlive(Atom.make(false)));
|
|
30
|
+
|
|
27
31
|
export type ChangesClient = AtomRpc.AtomRpcClient<unknown, string, ReturnType<typeof changesRpc>>;
|
|
28
32
|
|
|
29
|
-
export function automaticLive(
|
|
33
|
+
export function automaticLive(
|
|
34
|
+
service: ChangesClient,
|
|
35
|
+
name: string,
|
|
36
|
+
owner?: BindingOwner,
|
|
37
|
+
resume?: ResumeSource,
|
|
38
|
+
enabled = true,
|
|
39
|
+
resumeWindow?: ResumeWindow,
|
|
40
|
+
) {
|
|
30
41
|
function assertOwner(get: Atom.AtomContext) {
|
|
31
42
|
if (owner !== undefined && owner.registry !== get.registry) {
|
|
32
43
|
throw new Error("A session-scoped query belongs to its binding registry");
|
|
33
44
|
}
|
|
34
45
|
}
|
|
35
46
|
const coalesceWindow = Atom.keepAlive(Atom.make<Duration.Input>("20 millis"));
|
|
47
|
+
const paused = pausedByRuntime(service.runtime);
|
|
36
48
|
const statuses = Atom.make<ReadonlyMap<object, LiveStatus<unknown>>>(new Map());
|
|
37
|
-
const status = Atom.map(statuses, (current)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (values.some((value) => value.connection === "connecting")) {
|
|
41
|
-
connection = "connecting";
|
|
42
|
-
}
|
|
43
|
-
if (values.some((value) => value.connection === "reconnecting")) {
|
|
44
|
-
connection = "reconnecting";
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
connection,
|
|
48
|
-
failure: values.find((value) => Option.isSome(value.failure))?.failure ?? Option.none(),
|
|
49
|
-
needsResync: values.some((value) => value.needsResync),
|
|
50
|
-
pending: values.reduce((sum, value) => sum + value.pending, 0),
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
const signal = resumeSignal({ ...(typeof window === "undefined" ? {} : { window }), ...(resume === undefined ? {} : { native: resume }) });
|
|
49
|
+
const status = Atom.map(statuses, (current) => aggregateLiveStatus([...current.values()]));
|
|
50
|
+
const target = resumeWindow ?? (typeof window === "undefined" ? undefined : window);
|
|
51
|
+
const signal = resumeSignal({ ...(target === undefined ? {} : { window: target }), ...(resume === undefined ? {} : { native: resume }) });
|
|
54
52
|
const connection = Atom.make((get) => {
|
|
55
53
|
assertOwner(get);
|
|
56
54
|
get.mount(service.runtime);
|
|
@@ -79,17 +77,24 @@ export function automaticLive(service: ChangesClient, name: string, owner?: Bind
|
|
|
79
77
|
(get) => {
|
|
80
78
|
assertOwner(get);
|
|
81
79
|
const registry = get.registry;
|
|
80
|
+
const dispatcher = registry.schedulerAsync.makeDispatcher();
|
|
82
81
|
get.set(ready, false);
|
|
83
82
|
get.once(queryCoalesceWindow(gated));
|
|
84
83
|
get.subscribe(queryCoalesceWindow(gated), (value) => get.set(queryCoalesceWindow(atom), value), { immediate: true });
|
|
85
84
|
const token = {};
|
|
85
|
+
let active = true;
|
|
86
86
|
function observe(value: LiveStatus<unknown>) {
|
|
87
|
-
|
|
87
|
+
dispatcher.scheduleTask(() => {
|
|
88
|
+
if (active) {
|
|
89
|
+
registry.update(statuses, (current) => new Map([...current, [token, value]]));
|
|
90
|
+
}
|
|
91
|
+
}, 0);
|
|
88
92
|
if (value.connection === "live") {
|
|
89
93
|
registry.set(ready, true);
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
96
|
get.addFinalizer(() => {
|
|
97
|
+
active = false;
|
|
93
98
|
if (registry.getNodes().has(statuses)) {
|
|
94
99
|
registry.update(statuses, (current) => {
|
|
95
100
|
const next = new Map(current);
|
|
@@ -122,6 +127,7 @@ export function automaticLive(service: ChangesClient, name: string, owner?: Bind
|
|
|
122
127
|
get.setSelf(AsyncResult.failure(value.failure.value));
|
|
123
128
|
}
|
|
124
129
|
});
|
|
130
|
+
get.addFinalizer(registry.subscribe(paused, (value) => registry.set(subscription.paused, value), { immediate: true }));
|
|
125
131
|
get.mount(subscription.connection);
|
|
126
132
|
if (get.once(ready)) {
|
|
127
133
|
start();
|
|
@@ -137,5 +143,5 @@ export function automaticLive(service: ChangesClient, name: string, owner?: Bind
|
|
|
137
143
|
}
|
|
138
144
|
return gated;
|
|
139
145
|
}
|
|
140
|
-
return { query, subscription: { coalesceWindow, connection, identity: socketIdentity, status } };
|
|
146
|
+
return { query, subscription: { coalesceWindow, connection, identity: socketIdentity, paused, status } };
|
|
141
147
|
}
|
package/src/bind.ts
CHANGED
|
@@ -15,7 +15,7 @@ import { boundCommand, boundQuery, boundStream } from "#internal/clientOperation
|
|
|
15
15
|
import { type RpcSource, rpcClient } from "#internal/rpcClient.ts";
|
|
16
16
|
import type { CommandShape, QueryShape, StreamShape } from "#operation.ts";
|
|
17
17
|
import type { MissingReadPolicy } from "#readPolicyErrors.ts";
|
|
18
|
-
import type { ResumeSource } from "#resume.ts";
|
|
18
|
+
import type { ResumeSource, ResumeWindow } from "#resume.ts";
|
|
19
19
|
|
|
20
20
|
export type Failure<R extends Rpc.Any> =
|
|
21
21
|
R extends Rpc.Rpc<infer _Tag, infer _Payload, infer _Success, infer _Error, infer TMiddleware, infer _Requires>
|
|
@@ -74,6 +74,7 @@ interface BindOptions {
|
|
|
74
74
|
readonly live?: boolean;
|
|
75
75
|
readonly registry?: AtomRegistry.AtomRegistry;
|
|
76
76
|
readonly resume?: ResumeSource;
|
|
77
|
+
readonly resumeWindow?: ResumeWindow;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
export function bind<
|
|
@@ -106,7 +107,7 @@ function bindApi(
|
|
|
106
107
|
) {
|
|
107
108
|
const { name, queries, commands, streams, keyScope } = contract.declaration;
|
|
108
109
|
const owner = bindingOwner(keyScope, options?.registry);
|
|
109
|
-
const automatic = automaticLive(service, name, owner, options?.resume, options?.live);
|
|
110
|
+
const automatic = automaticLive(service, name, owner, options?.resume, options?.live, options?.resumeWindow);
|
|
110
111
|
return Object.assign(
|
|
111
112
|
Object.fromEntries([
|
|
112
113
|
...queries.map((query) => [query.name, boundQuery(service, `${name}.${query.name}`, query, automatic, owner)] as const),
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Option } from "effect";
|
|
2
|
+
import type { LiveStatus } from "#live.ts";
|
|
3
|
+
|
|
4
|
+
export function aggregateLiveStatus(values: readonly LiveStatus<unknown>[]): LiveStatus<unknown> {
|
|
5
|
+
let connection: LiveStatus<unknown>["connection"] = "live";
|
|
6
|
+
if (values.some((value) => value.connection === "connecting")) {
|
|
7
|
+
connection = "connecting";
|
|
8
|
+
}
|
|
9
|
+
if (values.some((value) => value.connection === "reconnecting")) {
|
|
10
|
+
connection = "reconnecting";
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
connection,
|
|
14
|
+
failure: values.find((value) => Option.isSome(value.failure))?.failure ?? Option.none(),
|
|
15
|
+
needsResync: values.some((value) => value.needsResync),
|
|
16
|
+
pending: values.reduce((sum, value) => sum + value.pending, 0),
|
|
17
|
+
};
|
|
18
|
+
}
|