@shivaedev/contract 0.56.0 → 0.58.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 +38 -0
- package/README.md +24 -23
- package/dist/AutomaticQueryOptions.d.ts +1 -1
- package/dist/AutomaticQueryOptions.d.ts.map +1 -1
- package/dist/{bind.d.ts → Bound.d.ts} +1 -19
- package/dist/Bound.d.ts.map +1 -0
- package/dist/Bound.js +2 -0
- package/dist/Bound.js.map +1 -0
- package/dist/ClientOptions.d.ts +2 -2
- package/dist/ClientOptions.d.ts.map +1 -1
- package/dist/automaticLive.d.ts +2 -1
- package/dist/automaticLive.d.ts.map +1 -1
- package/dist/automaticLive.js +4 -9
- package/dist/automaticLive.js.map +1 -1
- package/dist/automaticQuery.js +2 -2
- package/dist/automaticQuery.js.map +1 -1
- package/dist/clientActivities.d.ts +1 -15
- package/dist/clientActivities.d.ts.map +1 -1
- package/dist/clientActivities.js +0 -1
- package/dist/clientActivities.js.map +1 -1
- package/dist/clientContract.d.ts +2 -15
- package/dist/clientContract.d.ts.map +1 -1
- package/dist/clientContract.js +6 -11
- package/dist/clientContract.js.map +1 -1
- package/dist/clientOperations.d.ts +3 -2
- package/dist/clientOperations.d.ts.map +1 -1
- package/dist/clientOperations.js +3 -4
- package/dist/clientOperations.js.map +1 -1
- package/dist/makeClient.d.ts +1 -1
- package/dist/makeClient.d.ts.map +1 -1
- package/dist/makeClient.js +3 -3
- package/dist/makeClient.js.map +1 -1
- package/dist/queryDelivery.d.ts +1 -1
- package/dist/queryDelivery.d.ts.map +1 -1
- package/dist/queryDelivery.js.map +1 -1
- package/dist/reflectCommand.d.ts.map +1 -1
- package/dist/reflectCommand.js +7 -18
- package/dist/reflectCommand.js.map +1 -1
- package/dist/reflectedStream.d.ts +3 -3
- package/dist/reflectedStream.d.ts.map +1 -1
- package/dist/reflectedStream.js +4 -5
- package/dist/reflectedStream.js.map +1 -1
- package/dist/reflection.d.ts +4 -0
- package/dist/reflection.d.ts.map +1 -1
- package/dist/reflection.js +4 -0
- package/dist/reflection.js.map +1 -1
- package/dist/rpcClient.d.ts +29 -12
- package/dist/rpcClient.d.ts.map +1 -1
- package/dist/rpcClient.js +2 -3
- package/dist/rpcClient.js.map +1 -1
- package/dist/servedHandlers.d.ts.map +1 -1
- package/dist/servedHandlers.js +3 -2
- package/dist/servedHandlers.js.map +1 -1
- package/dist/socketAuthentication.d.ts +1 -11
- package/dist/socketAuthentication.d.ts.map +1 -1
- package/dist/socketAuthentication.js +15 -7
- package/dist/socketAuthentication.js.map +1 -1
- package/dist/socketProtocol.js +4 -8
- package/dist/socketProtocol.js.map +1 -1
- package/package.json +6 -6
- package/src/AutomaticQueryOptions.ts +1 -1
- package/src/{bind.ts → Bound.ts} +0 -46
- package/src/ClientOptions.ts +2 -2
- package/src/automaticLive.ts +9 -10
- package/src/automaticQuery.ts +2 -2
- package/src/clientActivities.ts +1 -2
- package/src/clientContract.ts +12 -27
- package/src/clientOperations.ts +5 -4
- package/src/makeClient.ts +4 -4
- package/src/queryDelivery.ts +2 -2
- package/src/reflectCommand.ts +7 -18
- package/src/reflectedStream.ts +5 -5
- package/src/reflection.ts +5 -0
- package/src/rpcClient.ts +2 -3
- package/src/servedHandlers.ts +5 -4
- package/src/socketAuthentication.ts +22 -7
- package/src/socketProtocol.ts +5 -10
- package/dist/bind.d.ts.map +0 -1
- package/dist/bind.js +0 -11
- package/dist/bind.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.58.0 - 2026-11-21
|
|
4
|
+
|
|
5
|
+
### Breaking
|
|
6
|
+
|
|
7
|
+
- a browser contract built by `clientContract` carries no keys. Its definition names the module's queries and commands as lists, `queries: ["list"]` and `commands: ["create"]`, in place of records holding each query's `reads` and `readsCollections` and each command's `invalidates`, so `ClientContractDefinition`'s `queries` and `commands` are now `readonly string[]`. The host serves the module, whose keys decide which open queries a change reaches, and the browser's queries refresh from the server's announcements. An application runs `pnpm generate` and deletes nothing by hand; only a hand-written `clientContract` call changes, by replacing each record with the list of its operation names.
|
|
8
|
+
- `makeClient`'s `bearerToken` is an `Effect.Effect<string | null>` that the client runs each time its socket connects, instead of a fixed string. A credential Effect that answers `null` connects without the authentication frame. Replace `bearerToken: token` with `bearerToken: Effect.succeed(token)`; a native shell passes `Effect.provide(storedCredential, credentialLayer)` from identity.
|
|
9
|
+
- `authenticateSocket` from `@shivaedev/contract/socketAuthentication.ts` takes the socket URL, the credential Effect and optional upgrade headers and opens the WebSocket itself, adding `auth=frame` when a credential is sent. Replace `Layer.effect(Socket.Socket, authenticateSocket(token)).pipe(Layer.provide(Socket.layerWebSocket(framedUrl)))` with `Layer.effect(Socket.Socket, authenticateSocket(url, Effect.succeed(token)))` on the URL without `auth=frame`, provided with a `WebSocketConstructor`.
|
|
10
|
+
|
|
11
|
+
## 0.57.0 - 2026-11-21
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- a defined module's query that reads collections under a `permissionReadPolicy` opens its live subscription through `moduleHandlers`; the handler's copy of the policy now keeps the permission mark that collection reads require, where the subscription was refused with `QueryReadDenied`.
|
|
16
|
+
|
|
17
|
+
### Breaking
|
|
18
|
+
|
|
19
|
+
- `bind` is removed: `makeClient` is the one way to a bound API, so every bound command waits until its change is on the screen. A bound command over an `AtomRpc.Service` the caller built counted as reflected when its reply arrived. Make the client from the contract and pass the transport as `protocol`; a story kit passes the in-memory protocol from `@shivaedev/test-kits` with the same handlers. A kit that read
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
class Client extends AtomRpc.Service<Client>()("test/NotesClient", {
|
|
23
|
+
group: Notes,
|
|
24
|
+
makeEffect: RpcTest.makeClient(Notes, { flatten: true }),
|
|
25
|
+
protocol: handlers,
|
|
26
|
+
}) {}
|
|
27
|
+
const api = bind(Notes, Client, { registry });
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
becomes
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
const client = makeClient({ notes: Notes }, { protocol: layerMemoryProtocol(Notes).pipe(Layer.provide(handlers)), registry });
|
|
34
|
+
const api = client.api.notes;
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
with `layerMemoryProtocol` from `@shivaedev/test-kits/contract/testing.ts`, or `layerLiveMemoryProtocol(Notes, handlers)` from `@shivaedev/test-kits/contract/liveMemoryProtocol.ts` when the kit lets the live host serve `$changes`. `Client.runtime` becomes `client.runtime`, and an Effect that required `Client` requires `ContractsClient` from `@shivaedev/contract/makeClient.ts`. An HTTP-only client passes `RpcClient.layerProtocolHttp(...)` as `protocol`; its commands count as on the screen at their reply, because no live stream follows them.
|
|
38
|
+
- The binding types `Bound`, `BoundQuery`, `BoundCommand`, `BoundStream`, `Failure`, `RunFailure`, `QueryOptions` and `RunOptions` move from `@shivaedev/contract/bind.ts` to `@shivaedev/contract/Bound.ts`: `import type { Bound } from "@shivaedev/contract/bind.ts"` becomes `import type { Bound } from "@shivaedev/contract/Bound.ts"`.
|
|
39
|
+
- the internals a client is built from take the client's activity and reflection directly. `automaticLive` and `clientOperations` take the client's activity as their second argument, `rpcClient` returns `{ activity, connection }`, and the `clientActivities` WeakMap is removed in favour of the exported `ActivityTracker` type. `followReflection` returns an Effect that dies without a reflection, as `reflectCommand` now does through the new `reflectionScope`. `queryDelivery().stream` requires its follower and `AutomaticQueryOptions.clientStatuses` requires its statuses. Direct callers make the client with `makeClient` instead.
|
|
40
|
+
|
|
3
41
|
## 0.56.0 - 2026-11-21
|
|
4
42
|
|
|
5
43
|
### Added
|
package/README.md
CHANGED
|
@@ -177,7 +177,7 @@ export const Notes = defineModule({
|
|
|
177
177
|
});
|
|
178
178
|
```
|
|
179
179
|
|
|
180
|
-
Here `NotesStore` is an ordinary service, `StoredNote` the row it returns, and `Caller` an RPC middleware that sets the viewer. `defineModule` takes the operations written as payload and run, its `wire` (below), and optionally `middleware`, `subject` and `keyScope` as `contract` does. It returns the module's contract, so `makeClient
|
|
180
|
+
Here `NotesStore` is an ordinary service, `StoredNote` the row it returns, and `Caller` an RPC middleware that sets the viewer. `defineModule` takes the operations written as payload and run, its `wire` (below), and optionally `middleware`, `subject` and `keyScope` as `contract` does. It returns the module's contract, so `makeClient` and a host accept it as they accept any contract. Each of its RPCs carries the `DefinedModule` annotation from the same file with the module's name, so a host can tell a module's queries from a contract's. The module lists no services: its type carries, for each operation, the services that operation's `run` and read policy yield, less what its middleware and subject provide per call, and nothing reads them at run time. An operation that starts to yield another service changes only that operation. A definition without `wire` is a compile error that says the property is missing. Its generics check the definition on the `name` line, so the first line of the compiler's message names the operation and its problem, such as `OperationNameRepeated` when two operations share a name:
|
|
181
181
|
|
|
182
182
|
```
|
|
183
183
|
src/test-support/fixtures/invalid/moduleRepeatedName.ts(15,2): error TS2322: Type '"lists"' is not assignable to type '"lists" & NoInfer<OperationNameRepeated<"list">>'.
|
|
@@ -202,7 +202,7 @@ Each operation runs in a span named after the module and the operation, such as
|
|
|
202
202
|
|
|
203
203
|
Types are erased, so the success schema and rejection classes the server encodes with and the browser decodes with must exist as values. [`@shivaedev/build`](https://github.com/ShivaeDev/platform/tree/main/packages/build) writes them from each module's `run` types into one file per module under `src/generated/`, which stays out of Git; an application runs it as `pnpm generate`. The module file passes its wire, as `Notes` does above, and every operation is served with its wire entry's success and rejections, plus `InternalServerError` and `ServiceUnavailable`. A wire entry's success describes only the shape: its RPC carries `GeneratedSuccess` from `@shivaedev/errors/GeneratedSuccess.ts`, so the host neither collects sensitive names from it nor treats its fields as public. Mark a sensitive field on the server's model instead, as the [errors README](https://github.com/ShivaeDev/platform/tree/main/packages/errors#masking-secrets-in-failures) describes.
|
|
204
204
|
|
|
205
|
-
The file the generator writes exports the wire, the browser's contract built by `clientContract` from the wire, the
|
|
205
|
+
The file the generator writes exports the wire, the browser's contract built by `clientContract` from the wire, the names of the module's queries and commands, the copied payloads, and the module's name, middleware, subject and key scope, and it ends with a type-level assertion that the browser's contract and the server module have the same RPCs:
|
|
206
206
|
|
|
207
207
|
```ts
|
|
208
208
|
import { Schema } from "effect";
|
|
@@ -210,7 +210,7 @@ import { Unauthorized } from "@shivaedev/errors/taxonomy.ts";
|
|
|
210
210
|
import { clientContract } from "@shivaedev/contract/clientContract.ts";
|
|
211
211
|
import type { ClientMatchesModule } from "@shivaedev/contract/clientMatchesModule.ts";
|
|
212
212
|
import type { Notes as NotesModule } from "#modules/notes/Notes.ts";
|
|
213
|
-
import { Caller, NoteFields,
|
|
213
|
+
import { Caller, NoteFields, TitleTaken } from "#modules/notes/model.ts";
|
|
214
214
|
|
|
215
215
|
const Note = Schema.Struct({ createdAt: Schema.Date, id: Schema.Number, title: Schema.String });
|
|
216
216
|
|
|
@@ -220,24 +220,24 @@ export const notesWire = {
|
|
|
220
220
|
} as const;
|
|
221
221
|
|
|
222
222
|
export const Notes = clientContract({
|
|
223
|
-
commands:
|
|
223
|
+
commands: ["create"],
|
|
224
224
|
middleware: Caller,
|
|
225
225
|
name: "notes",
|
|
226
226
|
payloads: { create: NoteFields },
|
|
227
|
-
queries:
|
|
227
|
+
queries: ["list"],
|
|
228
228
|
wire: notesWire,
|
|
229
229
|
});
|
|
230
230
|
|
|
231
231
|
export const notesMatchModule: ClientMatchesModule<typeof Notes, typeof NotesModule> = true;
|
|
232
232
|
```
|
|
233
233
|
|
|
234
|
-
`clientContract` requires a wire entry for every query and command it
|
|
234
|
+
`clientContract` requires a wire entry for every query and command it names. The browser imports `Notes` from that file and puts it in its client's record like any contract; it carries no `run`, read policy, key or service, and its import graph reaches no server code. Its queries read no keys and its commands invalidate none: the host serves the module, whose keys decide which open queries each change reaches, and the browser's queries refresh from the server's announcements. Over RPC's JSON serialization, a `Schema.Date` field arrives as a `Date` equal to the one `run` returned, and a rejection the wire lists arrives as its class. Neither the browser's contract nor an operation without a read policy can be served: `contract()` requires one on every query, and a host refuses a query without one at start-up.
|
|
235
235
|
|
|
236
236
|
The compiler compares the wire with `run` on every type check, and a stale file is an error on the module's `name` line that names the operation, one problem per operation: `WireSuccessStale` when the entry's success differs from what `run` returns, `WireRejectionsStale` when its rejection tags or classes differ from what `run` and a query's read policy raise, other than infrastructure failures, and `OperationMissingFromWire` when an operation has no entry and its `run` returns a value or raises a rejection. A success differs when its type and `run`'s return type are not mutually assignable; when they differ only in array mutability, because `Schema.Array` decodes a readonly array; when an object that `run` returns and a `Schema.Struct` that the success holds in the same position, at the top or in an array, struct field, tuple, record, union or `Option`, have different keys, such as an optional property only one of them has, which the `Struct` would drop or never send; and when the success holds a `Schema.Class` in such a position and `run` returns something other than that class there, such as an object literal of its fields, which fails to encode. Rejections differ when `run` raises a tag the entry does not list, the entry lists a tag nothing raises or one of the automatic two, or a listed class and the class `run` raises under the same tag differ in shape, such as a local `NotFound` with other fields than the shared one.
|
|
237
237
|
|
|
238
238
|
TypeScript compares classes by shape, so two cases still compile: a rejection class whose twin of the same shape is what `run` raises, and a helper typed to return a readonly interface of the same shape where the success is a `Schema.Class`. Neither is silent at run time: the twin is not the listed class, so the boundary answers `InternalServerError` and reports it, and the plain object fails to encode. The generator resolves both by declaration. A `Schema.Struct` behind another schema, such as a transformation, a brand or `Schema.suspend`, is compared with `run` only by mutual assignability, so an optional property that only one side has still compiles there and is dropped or never sent.
|
|
239
239
|
|
|
240
|
-
The browser's assertion fails with `ClientDiffersFromModule`, naming the operations whose RPCs differ. `ClientMatchesModule` compares the operations
|
|
240
|
+
The browser's assertion fails with `ClientDiffersFromModule`, naming the operations whose RPCs differ. `ClientMatchesModule` compares the operations, their kinds and their payloads, successes and rejections, so a browser contract that leaves out an operation, declares a command as a query or carries a stale payload fails. A stale key scope in the generated file still compiles; the generator keeps it current, because a change to it makes `shivaedev-build generate --check` report the file stale. A stale wire and a stale browser contract read:
|
|
241
241
|
|
|
242
242
|
```
|
|
243
243
|
src/test-support/fixtures/invalid/moduleStaleRejection.ts(9,2): error TS2322: Type '"staleRejection"' is not assignable to type '"staleRejection" & NoInfer<WireRejectionsStale<"create", "the generated file is stale; run pnpm generate", "TitleTaken" | "Unauthorized", "Unauthorized">>'.
|
|
@@ -428,26 +428,27 @@ export const NotesRoutes = RpcServer.layerHttp({ group: Notes, path: "/rpc", pro
|
|
|
428
428
|
);
|
|
429
429
|
```
|
|
430
430
|
|
|
431
|
-
The server host provides `NotesRoutes` to its native HTTP router. In a separate client module,
|
|
431
|
+
The server host provides `NotesRoutes` to its native HTTP router. In a separate client module, make a client from the same contract and pass the native HTTP protocol:
|
|
432
432
|
|
|
433
433
|
```ts
|
|
434
434
|
import { Layer } from "effect";
|
|
435
435
|
import { FetchHttpClient } from "effect/http";
|
|
436
|
-
import * as AtomRpc from "effect/reactivity/AtomRpc";
|
|
437
436
|
import { RpcClient, RpcSerialization } from "effect/rpc";
|
|
438
|
-
import {
|
|
437
|
+
import { makeClient } from "@shivaedev/contract/makeClient.ts";
|
|
439
438
|
import { Notes } from "./notes.ts";
|
|
440
439
|
|
|
441
|
-
export
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
440
|
+
export const client = makeClient(
|
|
441
|
+
{ notes: Notes },
|
|
442
|
+
{
|
|
443
|
+
protocol: RpcClient.layerProtocolHttp({ url: "http://127.0.0.1:3000/rpc" }).pipe(
|
|
444
|
+
Layer.provide([FetchHttpClient.layer, RpcSerialization.layerJson]),
|
|
445
|
+
),
|
|
446
|
+
},
|
|
447
|
+
);
|
|
448
|
+
export const api = client.api.notes;
|
|
448
449
|
```
|
|
449
450
|
|
|
450
|
-
Over HTTP, each bound operation's `run` makes one call, so `api.rename.run(...)` and `api.get.run(...)` work. A bound query's atom subscribes to the server's change stream, which needs a WebSocket: over HTTP it fails with `WebSocketRequired`, so a screen that mounts queries uses the shared WebSocket client below. The [native RPC guide](https://github.com/ShivaeDev/platform/blob/main/docs/framework/native-rpc.md) covers hosting; the [feature guide](https://github.com/ShivaeDev/platform/blob/main/docs/framework/add-a-feature.md) composes a defined module, request identity, SQL and a rendered client in the starter.
|
|
451
|
+
Over HTTP, each bound operation's `run` makes one call, so `api.rename.run(...)` and `api.get.run(...)` work. A command's change counts as on the screen when its reply arrives, because no live stream follows it. A bound query's atom subscribes to the server's change stream, which needs a WebSocket: over HTTP it fails with `WebSocketRequired`, so a screen that mounts queries uses the shared WebSocket client below. The [native RPC guide](https://github.com/ShivaeDev/platform/blob/main/docs/framework/native-rpc.md) covers hosting; the [feature guide](https://github.com/ShivaeDev/platform/blob/main/docs/framework/add-a-feature.md) composes a defined module, request identity, SQL and a rendered client in the starter.
|
|
451
452
|
|
|
452
453
|
### Build a shared WebSocket client
|
|
453
454
|
|
|
@@ -481,7 +482,7 @@ On visible `visibilitychange`, `online` and `pageshow` events, or an injected na
|
|
|
481
482
|
|
|
482
483
|
`SocketClock` from `@shivaedev/contract/SocketClock.ts` supplies the default client’s network deadlines independently of application time. It defaults to the real Clock; provide another native Clock in the client runtime or client Layer to control socket and connection-wait time in stories.
|
|
483
484
|
|
|
484
|
-
For a native WebView, pass the signed session credential
|
|
485
|
+
For a native WebView, pass `bearerToken` to `makeClient`: an Effect that answers the signed session credential, or `null` for none, such as one reading the credential a native shell stored or `Effect.succeed(token)` for a fixed one. The browser WebSocket constructor needs no upgrade headers. The client runs that Effect each time the socket connects; with a credential it adds `auth=frame` to the RPC URL and sends `{"_tag":"Authenticate","token":"<credential>"}` as its first text frame, before native RPC traffic, and without one it connects as a plain socket. 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.
|
|
485
486
|
|
|
486
487
|
The result is a native client Layer for `ManagedRuntime.make`, plus `api`, the native `Client` service, atom `runtime`, `sync` and a scoped `client` Effect that calls every RPC of the record by its tag. A record that holds a session-scoped contract requires `registry`. For Node clients, supply upgrade `headers` and `webSocketConstructor: NodeWS.layerWebSocketConstructor` 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.
|
|
487
488
|
|
|
@@ -568,7 +569,7 @@ const move = ({ id, household }) =>
|
|
|
568
569
|
|
|
569
570
|
Here `audienceFor` reads household members and people who ate from the pot from the application's database, `movePot` performs the write, and `pots` declares a `viewerId` bucket. Read the audience after the write to include new readers, and retain the old audience when the write removes access. Each viewer's list reads its own bucket. Keep these reads and the write in the same transaction when they must describe one change.
|
|
570
571
|
|
|
571
|
-
Use this helper in hosts from `@shivaedev/server`, or a native RPC host wired with `guardCommands` and `commandGuardLayer`. Keys are isolated per command, deduplicated with declared keys, and published through the existing `@shivaedev/changes` command publication boundary after success. A failed handler discards them. They
|
|
572
|
+
Use this helper in hosts from `@shivaedev/server`, or a native RPC host wired with `guardCommands` and `commandGuardLayer`. Keys are isolated per command, deduplicated with declared keys, and published through the existing `@shivaedev/changes` command publication boundary after success. A failed handler discards them. They are published only on the server and never reach the browser; live subscriptions receive the server’s changed query results.
|
|
572
573
|
|
|
573
574
|
#### When a command's change is on the screen
|
|
574
575
|
|
|
@@ -774,7 +775,7 @@ The application supplies the permission checker through `permissionReadPolicy(pe
|
|
|
774
775
|
|
|
775
776
|
Collection reads reuse the bare repository table key, the same key as `notes.list`, even when the contract uses `keyScope: "session"`; record and bucket reads also use plain server keys. They add no wildcard matching or write-side work. Every committed repository insert, update, delete, upsert and bulk write already publishes that key. Generated-id inserts also publish the bare collection key alongside their generated record key, so `publishes` stories that check exact published keys must allow the bare key today. For a table named `notes`, that is `"notes"` alongside `"notes:<id>"` and any affected bucket keys. Mounting a collection subscriber adds **zero PostgreSQL NOTIFY messages per write**: it consumes the existing payloads. It adds a normal query subscription and an authorized reread when the collection changes.
|
|
776
777
|
|
|
777
|
-
For dependencies that need server data, add `serverReads(payload, viewer)`, an Effect returning extra keys.
|
|
778
|
+
For dependencies that need server data, add `serverReads(payload, viewer)`, an Effect returning extra keys. `reads` holds the keys that follow from the payload and the viewer alone, or returns `[]`; `serverReads` holds the keys that need server data. The server checks every referenced query's policy before it runs any `serverReads`, and resolves it with the owning query handler's services. Declare its failures in the query's `rejections`, as with policy failures. A denied subscription never runs the resolver.
|
|
778
779
|
|
|
779
780
|
```ts
|
|
780
781
|
import { Context, Effect, Schema } from "effect";
|
|
@@ -965,8 +966,8 @@ Import the module that defines the name; the package has no root entry.
|
|
|
965
966
|
| `clientContract.ts` | `clientContract({ name, wire, payloads?, queries?, commands?, middleware?, subject?, keyScope? })`, the browser's contract of a module that generated files build. |
|
|
966
967
|
| `clientMatchesModule.ts` | `ClientMatchesModule<Client, Module>`, `true` when the browser's contract and the server module have the same RPCs, else `ClientDiffersFromModule`. |
|
|
967
968
|
| `rejection.ts` | `fieldRejection(struct, fields?)`; lower-level `rejectionSet(specs)`, which constructs the rejection classes, union schema and failure helpers used by operations. |
|
|
968
|
-
| `
|
|
969
|
-
| `
|
|
969
|
+
| `makeClient.ts` | `makeClient(contracts, { url?, protocol?, headers?, bearerToken?, webSocketConstructor?, registry?, resume?, resumeWindow?, runtime? }?)`, one client over a record of contracts, on the shared WebSocket unless `protocol` names another transport, binding each under its key in `api`, with `sync` beside it; `ContractClient<Contract>`, a binding's type; `ContractsClient`, the clients' shared service identity. |
|
|
970
|
+
| `Bound.ts` | `Bound`, `BoundQuery`, `BoundCommand` and `BoundStream`, the types of a binding and its operations; `Failure`, a bound operation's failure; `QueryOptions` and `RunOptions`, a call's options. |
|
|
970
971
|
| `live.ts` | `LiveHint` schema; `live(runtime, { stream, resume?, retryDelay? })`, exposing `connection`, `paused` and `status`; `isLiveConnection(atom)` tells whether an atom is such a `connection`, which waits for as long as its subscription runs. |
|
|
971
972
|
| `querySubscription.ts` | `querySubscription(rpc, references, viewer)` checks each referenced query, resolves its payload and server-derived keys, and captures its scopes and ongoing authorization. |
|
|
972
973
|
| `live-server/service.ts` | `LiveServer`, the shared live server service. |
|
|
@@ -6,7 +6,7 @@ import type { QuerySignals } from "#querySignals.ts";
|
|
|
6
6
|
import type { StreamAnchor } from "#reflectedStream.ts";
|
|
7
7
|
export interface AutomaticQueryOptions<A, E> {
|
|
8
8
|
readonly anchor: (registry: object) => StreamAnchor;
|
|
9
|
-
readonly clientStatuses: Atom.Writable<ReadonlyMap<object, LiveStatus<unknown
|
|
9
|
+
readonly clientStatuses: Atom.Writable<ReadonlyMap<object, LiveStatus<unknown>>>;
|
|
10
10
|
readonly equivalent: (left: A, right: A) => boolean;
|
|
11
11
|
readonly paused: Atom.Writable<boolean>;
|
|
12
12
|
readonly ready: Atom.Writable<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutomaticQueryOptions.d.ts","sourceRoot":"","sources":["../src/AutomaticQueryOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,WAAW,qBAAqB,CAAC,CAAC,EAAE,CAAC;IAC1C,QAAQ,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,YAAY,CAAC;IACpD,QAAQ,CAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"AutomaticQue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C,YAAY,EAAE,SAAS,CAAC,OAAO,cAAc,CAAC,CAAC;IACxD,QAAQ,CAAC,mBAAmB,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;CAChD"}
|
|
@@ -2,16 +2,11 @@ import type { Effect, Stream } from "effect";
|
|
|
2
2
|
import type { Headers } from "effect/http";
|
|
3
3
|
import type * as AsyncResult from "effect/reactivity/AsyncResult";
|
|
4
4
|
import type * as Atom from "effect/reactivity/Atom";
|
|
5
|
-
import type * as AtomRegistry from "effect/reactivity/AtomRegistry";
|
|
6
|
-
import type * as AtomRpc from "effect/reactivity/AtomRpc";
|
|
7
5
|
import type * as Reactivity from "effect/reactivity/Reactivity";
|
|
8
6
|
import type { Rpc } from "effect/rpc";
|
|
9
7
|
import type { RpcClientError } from "effect/rpc/RpcClientError";
|
|
10
|
-
import { type LiveBound } from "#automaticLive.ts";
|
|
11
|
-
import type { Contract } from "#contract.ts";
|
|
12
8
|
import type { CommandShape, QueryShape, StreamShape } from "#operation.ts";
|
|
13
9
|
import type { Tag } from "#operationRpc.ts";
|
|
14
|
-
import type { ResumeSource, ResumeWindow } from "#resume.ts";
|
|
15
10
|
export type Failure<R> = 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
11
|
export type RunFailure<R> = Failure<R>;
|
|
17
12
|
export interface RunOptions {
|
|
@@ -46,18 +41,5 @@ export type Bound<TName extends string, TQueries extends readonly QueryShape[],
|
|
|
46
41
|
} & {
|
|
47
42
|
readonly [TStream in TStreams[number] as TStream["name"]]: BoundStream<Rpc.ExtractTag<TRpcs, Tag<TName, TStream["name"]>>, TSelf>;
|
|
48
43
|
};
|
|
49
|
-
type MatchingClient<TRpcs extends Rpc.Any, TClientRpcs extends Rpc.Any> = [TRpcs] extends [Extract<TClientRpcs, {
|
|
50
|
-
readonly _tag: TRpcs["_tag"];
|
|
51
|
-
}>] ? [Extract<TClientRpcs, {
|
|
52
|
-
readonly _tag: TRpcs["_tag"];
|
|
53
|
-
}>] extends [TRpcs] ? unknown : "Client must preserve the contract RPC types" : "Client must implement the contract RPCs";
|
|
54
|
-
interface BindOptions {
|
|
55
|
-
readonly registry?: AtomRegistry.AtomRegistry;
|
|
56
|
-
readonly resume?: ResumeSource;
|
|
57
|
-
readonly resumeWindow?: ResumeWindow;
|
|
58
|
-
}
|
|
59
|
-
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 & {
|
|
60
|
-
readonly registry: AtomRegistry.AtomRegistry;
|
|
61
|
-
}] : [options?: BindOptions]): Bound<TName, TQueries, TCommands, TRpcs, TSelf, TStreams> & LiveBound;
|
|
62
44
|
export {};
|
|
63
|
-
//# sourceMappingURL=
|
|
45
|
+
//# sourceMappingURL=Bound.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Bound.d.ts","sourceRoot":"","sources":["../src/Bound.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7C,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,UAAU,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,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Options.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { Layer } from "effect";
|
|
1
|
+
import type { Effect, Layer } from "effect";
|
|
2
2
|
import type * as Atom from "effect/reactivity/Atom";
|
|
3
3
|
import type * as AtomRegistry from "effect/reactivity/AtomRegistry";
|
|
4
4
|
import type { RpcClient } from "effect/rpc";
|
|
5
5
|
import type * as Socket from "effect/socket/Socket";
|
|
6
6
|
import type { ResumeSource, ResumeWindow } from "#resume.ts";
|
|
7
7
|
export interface ClientOptions {
|
|
8
|
-
readonly bearerToken?: string
|
|
8
|
+
readonly bearerToken?: Effect.Effect<string | null>;
|
|
9
9
|
readonly headers?: Readonly<Record<string, string>>;
|
|
10
10
|
readonly protocol?: Layer.Layer<RpcClient.Protocol> | ((identity: string | undefined) => Layer.Layer<RpcClient.Protocol>);
|
|
11
11
|
readonly registry?: AtomRegistry.AtomRegistry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientOptions.d.ts","sourceRoot":"","sources":["../src/ClientOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"ClientOptions.d.ts","sourceRoot":"","sources":["../src/ClientOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,KAAK,YAAY,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE7D,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACpD,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,KAAK,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1H,QAAQ,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,YAAY,CAAC;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC;IACvC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,oBAAoB,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;CACzE"}
|
package/dist/automaticLive.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import * as Atom from "effect/reactivity/Atom";
|
|
|
4
4
|
import type * as AtomRpc from "effect/reactivity/AtomRpc";
|
|
5
5
|
import type { Rpc } from "effect/rpc";
|
|
6
6
|
import type { BindingOwner } from "#adapters/bindingOwner.ts";
|
|
7
|
+
import type { ActivityTracker } from "#clientActivities.ts";
|
|
7
8
|
import { type LiveStatus } from "#live.ts";
|
|
8
9
|
import { type ResumeSource, type ResumeWindow } from "#resume.ts";
|
|
9
10
|
import type { QueryReference } from "#serverMetadata.ts";
|
|
@@ -16,7 +17,7 @@ export interface LiveBound {
|
|
|
16
17
|
readonly status: Atom.Atom<LiveStatus<unknown>>;
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
|
-
export declare function automaticLive(operations: AtomRpc.AtomRpcClient<unknown, string, Rpc.Any>, name: string, owner?: BindingOwner, resume?: ResumeSource, resumeWindow?: ResumeWindow): {
|
|
20
|
+
export declare function automaticLive(operations: AtomRpc.AtomRpcClient<unknown, string, Rpc.Any>, activity: ActivityTracker, name: string, owner?: BindingOwner, resume?: ResumeSource, resumeWindow?: ResumeWindow): {
|
|
20
21
|
query: <A, E>(atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>, reference: QueryReference, equivalent: (left: A, right: A) => boolean, decode: (value: unknown) => A, headers?: Headers.Input) => any;
|
|
21
22
|
subscription: {
|
|
22
23
|
connection: Atom.Atom<LiveStatus<unknown>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automaticLive.d.ts","sourceRoot":"","sources":["../src/automaticLive.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAE/C,OAAO,KAAK,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"automaticLive.d.ts","sourceRoot":"","sources":["../src/automaticLive.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAE/C,OAAO,KAAK,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI9D,OAAO,KAA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ANGED
|
@@ -4,7 +4,6 @@ import * as AtomRegistry from "effect/reactivity/AtomRegistry";
|
|
|
4
4
|
import { changesClient } from "#adapters/erasedClient.ts";
|
|
5
5
|
import { aggregateLiveStatus } from "#aggregateLiveStatus.ts";
|
|
6
6
|
import { automaticQuery } from "#automaticQuery.ts";
|
|
7
|
-
import { clientActivities } from "#clientActivities.ts";
|
|
8
7
|
import { live } from "#live.ts";
|
|
9
8
|
import { queryDelivery } from "#queryDelivery.ts";
|
|
10
9
|
import { querySignals, shareQuerySignals } from "#querySignals.ts";
|
|
@@ -13,7 +12,7 @@ import { resumeSignal } from "#resume.ts";
|
|
|
13
12
|
import { socketIdentity } from "#rpcClient.ts";
|
|
14
13
|
export const LiveConnection = Symbol.for("@shivaedev/contract/LiveConnection");
|
|
15
14
|
const pausedByRuntime = Atom.family((_runtime) => Atom.keepAlive(Atom.make(false)));
|
|
16
|
-
export function automaticLive(operations, name, owner, resume, resumeWindow) {
|
|
15
|
+
export function automaticLive(operations, activity, name, owner, resume, resumeWindow) {
|
|
17
16
|
const service = changesClient(operations);
|
|
18
17
|
function ownerFailure(get) {
|
|
19
18
|
return owner !== undefined && owner.registry !== get.registry ? new Error("A session-scoped query belongs to its binding registry") : undefined;
|
|
@@ -48,18 +47,14 @@ export function automaticLive(operations, name, owner, resume, resumeWindow) {
|
|
|
48
47
|
}
|
|
49
48
|
const subscription = live(service.runtime, {
|
|
50
49
|
resume: signal,
|
|
51
|
-
stream: Stream.unwrap(service.use((client) => Effect.
|
|
52
|
-
const reflected = followReflection(client, anchor(registry));
|
|
53
|
-
if (reflected === undefined) {
|
|
54
|
-
return delivery.stream(client(`${name}.$changes`, { queries: [reference] }, { headers }));
|
|
55
|
-
}
|
|
50
|
+
stream: Stream.unwrap(service.use((client) => Effect.flatMap(AtomRegistry.AtomRegistry, (registry) => Effect.map(followReflection(client, anchor(registry)), (reflected) => {
|
|
56
51
|
const opened = client(`${name}.$changes`, { queries: [reference] }, { headers: reflected.headers(headers) });
|
|
57
52
|
return delivery.stream(reflected.lifetime(opened), reflected.follower);
|
|
58
|
-
}))),
|
|
53
|
+
})))),
|
|
59
54
|
});
|
|
60
55
|
const gated = automaticQuery({
|
|
61
56
|
anchor,
|
|
62
|
-
clientStatuses:
|
|
57
|
+
clientStatuses: activity.statuses,
|
|
63
58
|
equivalent,
|
|
64
59
|
ownerFailure,
|
|
65
60
|
paused,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automaticLive.js","sourceRoot":"","sources":["../src/automaticLive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGvD,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAI/D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"automaticLive.js","sourceRoot":"","sources":["../src/automaticLive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGvD,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAI/D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAmB,IAAI,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,iBA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ACZ,MAAM;YACN,KAAK;YACL,OAAO;YACP,MAAM;YACN,QAAQ;YACR,YAAY;YACZ,mBAAmB,EAAE,QAAQ,CAAC,OAAO;SACrC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAC3B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EAC3C,KAAK,EACL,EAAE,kBAAkB,EAAE,IAAI,EAAE,EAC5B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAC7F,CAAC;QACF,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAChC,OAAO,MAAM,CAAC;IACf,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;AAC1F,CAAC"}
|
package/dist/automaticQuery.js
CHANGED
|
@@ -34,7 +34,7 @@ export function automaticQuery({ anchor, clientStatuses, equivalent, ownerFailur
|
|
|
34
34
|
get.set(signals, recordSubscription(get.once(signals), value));
|
|
35
35
|
dispatcher.scheduleTask(() => {
|
|
36
36
|
if (active) {
|
|
37
|
-
for (const state of
|
|
37
|
+
for (const state of [statuses, clientStatuses]) {
|
|
38
38
|
registry.update(state, (current) => new Map([...current, [token, value]]));
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -46,7 +46,7 @@ export function automaticQuery({ anchor, clientStatuses, equivalent, ownerFailur
|
|
|
46
46
|
}
|
|
47
47
|
get.addFinalizer(() => {
|
|
48
48
|
active = false;
|
|
49
|
-
for (const state of
|
|
49
|
+
for (const state of [statuses, clientStatuses]) {
|
|
50
50
|
if (registry.getNodes().has(state)) {
|
|
51
51
|
registry.update(state, (current) => {
|
|
52
52
|
const next = new Map(current);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automaticQuery.js","sourceRoot":"","sources":["../src/automaticQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAG/C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,MAAM,UAAU,cAAc,CAAO,EACpC,MAAM,EACN,cAAc,EACd,UAAU,EACV,YAAY,EACZ,MAAM,EACN,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,mBAAmB,GACA;IACnB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAC1B,CAAC,GAAG,EAAE,EAAE;QACP,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACnB,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;YACtD,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;YAC/D,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACrC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;QACvB,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE;YACrB,OAAO,CAAC,O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CAAC,CAAC;YACtC,CAAC;QACF,CAAC;QACD,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YAC/B,IAAI,CAAC,KAAK,EAAE,CAAC;gBACZ,MAAM,EAAE,CAAC;YACV,CAAC;QACF,CAAC,CAAC,CAAC;QACH,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,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC,EACD,CAAC,OAAO,EAAE,EAAE;QACX,OAAO,CAAC,KAAK,CAAC,CAAC;QACf,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,21 +1,7 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import * as AsyncResult from "effect/reactivity/AsyncResult";
|
|
3
3
|
import type * as Atom from "effect/reactivity/Atom";
|
|
4
|
-
export
|
|
5
|
-
activity: import("effect/Stream").Stream<import("./clientActivity.ts").ClientActivityState, never, never> & {
|
|
6
|
-
current: Effect.Effect<import("./clientActivity.ts").ClientActivityState, never, never>;
|
|
7
|
-
} & {
|
|
8
|
-
connectionStatus: Atom.Atom<import("./clientActivity.ts").ConnectionStatus>;
|
|
9
|
-
firstSettled: Atom.Atom<boolean>;
|
|
10
|
-
rendered: Effect.Effect<void, never, never>;
|
|
11
|
-
};
|
|
12
|
-
hint: () => void;
|
|
13
|
-
hold: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
14
|
-
reflecting: () => () => void;
|
|
15
|
-
statuses: Atom.Writable<ReadonlyMap<object, import("./live.ts").LiveStatus<unknown>>, ReadonlyMap<object, import("./live.ts").LiveStatus<unknown>>>;
|
|
16
|
-
track: <A, E, R>(effect: Effect.Effect<A, E, R>, command?: boolean) => Effect.Effect<A, E, R>;
|
|
17
|
-
watch: <A, E>(atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>, warm: (get: Atom.AtomContext) => boolean) => Atom.Atom<AsyncResult.AsyncResult<A, E>>;
|
|
18
|
-
}>;
|
|
4
|
+
export type ActivityTracker = ReturnType<typeof makeActivity>;
|
|
19
5
|
export declare function makeActivity(factory: Atom.RuntimeFactory): {
|
|
20
6
|
activity: import("effect/Stream").Stream<import("./clientActivity.ts").ClientActivityState, never, never> & {
|
|
21
7
|
current: Effect.Effect<import("./clientActivity.ts").ClientActivityState, never, never>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientActivities.d.ts","sourceRoot":"","sources":["../src/clientActivities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"clientActivities.d.ts","sourceRoot":"","sources":["../src/clientActivities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAMpD,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AAE9D,wBAAgB,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc;;;;;;;;;WAiFhD,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;;;YA1EhC,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YAwBvC,CAAC,EAAE,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,KAAK,OAAO;EAgE7G"}
|
package/dist/clientActivities.js
CHANGED
|
@@ -4,7 +4,6 @@ import { activityState } from "#adapters/activityState.ts";
|
|
|
4
4
|
import { clientConnection } from "#adapters/clientConnection.ts";
|
|
5
5
|
import { querySignals, shareQuerySignals } from "#querySignals.ts";
|
|
6
6
|
import { wrapAtom } from "#wrapAtom.ts";
|
|
7
|
-
export const clientActivities = new WeakMap();
|
|
8
7
|
export function makeActivity(factory) {
|
|
9
8
|
const { activity, change, excuse, hold, rendered, setConnection } = activityState();
|
|
10
9
|
const connection = clientConnection(factory, setConnection, activity);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientActivities.js","sourceRoot":"","sources":["../src/clientActivities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"clientActivities.js","sourceRoot":"","sources":["../src/clientActivities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,WAAW,MAAM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CAAC;YACjC,IAAI,CAAC,SAAS,EAAE,CAAC;gBAChB,OAAO,CAAC,KAAK,CAAC,CAAC;YAChB,CAAC;YACD,OAAO,KAAK,CAAC;QACd,CAAC,CAAC,CAAC;QACH,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACjC,OAAO,OAAO,CAAC;IAChB,CAAC;IACD,OAAO;QACN,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,gBAAgB,EAAE,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,UAAU,CAAC,YAAY,EAAE,QAAQ,EAAE,CAAC;QAC3H,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;QAClC,IAAI,EAAE,CAAU,MAA8B,EAAE,EAAE,CACjD,KAAK,CACJ,MAAM,CAAC,iBAAiB,CACvB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EACjB,GAAG,EAAE,CAAC,MAAM,EACZ,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CACzB,EACD,IAAI,CACJ;QACF,UAAU,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,qBAAqB,CAAC;QAC9C,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,KAAK;QACL,KAAK;KACL,CAAC;AACH,CAAC"}
|
package/dist/clientContract.d.ts
CHANGED
|
@@ -17,15 +17,6 @@ type Payloads<TWire> = {
|
|
|
17
17
|
};
|
|
18
18
|
type PayloadOf<TPayloads, TOperation> = PayloadSchema<TOperation extends keyof TPayloads ? NonNullable<TPayloads[TOperation]> : Schema.Void>;
|
|
19
19
|
type EntryOf<TWire, TOperation> = TOperation extends keyof TWire ? (TWire[TOperation] extends WireEntry ? TWire[TOperation] : never) : never;
|
|
20
|
-
interface QueryKeys<TPayload> {
|
|
21
|
-
readonly reads: (payload: TPayload, viewer: Option.Option<Viewer>) => readonly Key[];
|
|
22
|
-
readonly readsCollections?: readonly {
|
|
23
|
-
readonly name: string;
|
|
24
|
-
}[];
|
|
25
|
-
}
|
|
26
|
-
interface CommandKeys<TPayload> {
|
|
27
|
-
readonly invalidates?: (payload: TPayload, viewer?: Option.Option<Viewer>) => readonly Key[];
|
|
28
|
-
}
|
|
29
20
|
type ClientQueries<TWire, TPayloads, TQueries extends string> = {
|
|
30
21
|
readonly [TOperation in TQueries]: ClientQuery<TOperation, PayloadOf<TPayloads, TOperation>, EntryOf<TWire, TOperation>["success"], SpecsOf<EntryOf<TWire, TOperation>["rejections"]>>;
|
|
31
22
|
}[TQueries];
|
|
@@ -33,16 +24,12 @@ type ClientCommands<TWire, TPayloads, TCommands extends string> = {
|
|
|
33
24
|
readonly [TOperation in TCommands]: Command<TOperation, PayloadOf<TPayloads, TOperation>, EntryOf<TWire, TOperation>["success"], SpecsOf<EntryOf<TWire, TOperation>["rejections"]>>;
|
|
34
25
|
}[TCommands];
|
|
35
26
|
export interface ClientContractDefinition<TName extends string, TWire extends Wire, TPayloads extends Payloads<TWire>, TQueries extends keyof TWire & string, TCommands extends keyof TWire & string, TMiddleware extends RpcMiddleware.AnyService, TSubject extends SubjectDeclaration | undefined, TScope extends "session" | undefined> {
|
|
36
|
-
readonly commands?:
|
|
37
|
-
readonly [TOperation in TCommands]: CommandKeys<PayloadOf<TPayloads, TOperation>["Type"]>;
|
|
38
|
-
};
|
|
27
|
+
readonly commands?: readonly TCommands[];
|
|
39
28
|
readonly keyScope?: TScope;
|
|
40
29
|
readonly middleware?: TMiddleware;
|
|
41
30
|
readonly name: TName;
|
|
42
31
|
readonly payloads?: TPayloads;
|
|
43
|
-
readonly queries?:
|
|
44
|
-
readonly [TOperation in TQueries]: QueryKeys<PayloadOf<TPayloads, TOperation>["Type"]>;
|
|
45
|
-
};
|
|
32
|
+
readonly queries?: readonly TQueries[];
|
|
46
33
|
readonly subject?: TSubject;
|
|
47
34
|
readonly wire: TWire;
|
|
48
35
|
}
|
|
@@ -1 +1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