@shivaedev/contract 0.57.0 → 0.59.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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.59.0 - 2026-11-21
4
+
5
+ ### Added
6
+
7
+ - `forSubject(client, subject)` from `@shivaedev/contract/forSubject.ts` returns a client's `api`, one contract's client or any record of them with every query's, command's and stream's subject defaulted to `subject`, so a screen tree that acts for another account binds its client once instead of passing `{ subject }` on every call. A subject named on a call still wins. Anything else, such as the value `makeClient` returns, is a compile error. A query through the bound client is the same atom, with the same serialization and live-update keys, as the query that names the subject per call, and binding the same client to the same subject again returns the same operations, so React's action and form hooks send the subject with no change in the screen.
8
+
9
+ ## 0.58.0 - 2026-11-21
10
+
11
+ ### Breaking
12
+
13
+ - 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.
14
+ - `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.
15
+ - `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`.
16
+
3
17
  ## 0.57.0 - 2026-11-21
4
18
 
5
19
  ### Fixed
package/README.md CHANGED
@@ -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 copied payloads, `reads` and `invalidates`, 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:
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, notes, TitleTaken } from "#modules/notes/model.ts";
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: { create: { invalidates: () => [notes.list] } },
223
+ commands: ["create"],
224
224
  middleware: Caller,
225
225
  name: "notes",
226
226
  payloads: { create: NoteFields },
227
- queries: { list: { reads: () => [notes.list] } },
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 declares. The browser imports `Notes` from that file and binds it like any contract; it carries no `run`, read policy or service, and its import graph reaches no server code. 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.
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' payloads, successes and rejections; a stale copy of a query's `reads`, a command's `invalidates` or the key scope in the generated file still compiles; the generator keeps those current, because a change to them makes `shivaedev-build generate --check` report the file stale. A stale wire and a stale browser contract read:
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">>'.
@@ -325,6 +325,16 @@ export const Account = defineModule({ name: "account", operations: [Save], subje
325
325
 
326
326
  `PreferenceFields` is `Schema.Struct({ title: Schema.String })` and `Profiles` an application service whose `rename` takes the account's `SubjectId`. Contracts with declared subjects can be exported from published packages with TypeScript declaration output. The client calls `account.save` with only its title. For a delegated subject, the client names the account per call: a bound query takes `subject` in its options and a query's, command's or stream's `run` takes `{ subject }` as its second argument, as in `api.title.query(undefined, { subject: "bob" })` and `api.rename.run({ title }, { subject: "bob" })`. The option sets the call's `x-platform-subject` message header, so one client and its one socket serve the actor's own data and any number of subjects, each live query keeping its own subject on its changes stream. Queries with different subjects are different atoms, keep separate retained results, and serialize under separate keys when they share a `serializationKey`. The session host installs the resolver; operations read `Subject` from the request environment. See [identity's subject guide](https://github.com/ShivaeDev/platform/tree/main/packages/identity#declared-request-subjects) for delegated selection and refusal declarations.
327
327
 
328
+ A screen tree that acts for one other account binds its client once instead of naming the account on every call. `forSubject(client, subject)` from `@shivaedev/contract/forSubject.ts` takes a client's `api`, one contract's client from it, or any record of them, and returns the same shape with every query's, command's and stream's subject defaulted to `subject`. A subject named on a call still wins. It refuses at compile time anything else, such as the value `makeClient` returns or a function or Effect beside the operations, because a call through it would act for the actor's own account. A query made through the bound client is the same atom, with the same serialization key and live-update keys, as the query that names the subject per call, so a screen that mixes both forms reads one cache entry. The bound client shares the original's socket, so the plain client beside it still reads the actor's own data. Binding the same client to the same subject again returns the same operations, so React's action and form hooks keep their action across renders when a component binds its client while rendering:
329
+
330
+ ```ts
331
+ import { forSubject } from "@shivaedev/contract/forSubject.ts";
332
+
333
+ const client = forSubject(api, clientId);
334
+ const diary = useQuery(client.coaching.diary.query());
335
+ const save = useAction(client.coaching.write, { failures: { NotYourClient: "message" } });
336
+ ```
337
+
328
338
  ### Expected failures
329
339
 
330
340
  Import the shared expected failures from `@shivaedev/errors/taxonomy.ts`: `NotFound`, `Unauthorized`, `Forbidden`, `BadRequest`, `Conflict`, `PreconditionFailed`, `TooManyRequests`, `AuthUnavailable`, `InternalServerError` and `ServiceUnavailable`. Each class is a tagged error schema with a string `message`; `BadRequest` and `Conflict` also accept an optional string `field`. An operation written with `run` raises them and its wire lists them; the rest of this section is about RPCs that state their failures by hand, as native `Rpc` definitions and operations declared without run do. Declare only the failures an operation can return:
@@ -569,7 +579,7 @@ const move = ({ id, household }) =>
569
579
 
570
580
  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.
571
581
 
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 do not enter the browser's pure `invalidates` callback; live subscriptions receive the server’s changed query results.
582
+ 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.
573
583
 
574
584
  #### When a command's change is on the screen
575
585
 
@@ -775,7 +785,7 @@ The application supplies the permission checker through `permissionReadPolicy(pe
775
785
 
776
786
  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.
777
787
 
778
- For dependencies that need server data, add `serverReads(payload, viewer)`, an Effect returning extra keys. Keep `reads` for keys the browser can derive, or return `[]` there. 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.
788
+ 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.
779
789
 
780
790
  ```ts
781
791
  import { Context, Effect, Schema } from "effect";
@@ -994,6 +1004,7 @@ Import the module that defines the name; the package has no root entry.
994
1004
  | `syncHeader.ts` | `syncClient(headers)` and `syncToken(headers)` read the client name and the sync token a request carries. |
995
1005
  | `operationKind.ts` | `operationKind(rpc)`: `"read"` for a query, a changes stream or a stream, `"write"` for a command or an RPC no contract marked. |
996
1006
  | `subjectHeader.ts` | `subjectHeader(headers)` reads the account a call names; `withSubject(headers, subject)` and `subjectSerializationKey(key, headers)` are what bound operations use to send it and to keep serialized results apart. |
1007
+ | `forSubject.ts` | `forSubject(client, subject)` returns the client with every call's subject defaulted to `subject`; a subject named on a call wins. |
997
1008
  | `screenSync.ts` | `screenSync(client, registry)` runs a client's `sync` through a registry, for a screen driver's `sync` option. |
998
1009
 
999
1010
  A bound query’s optional second argument accepts `headers`, `subject` and `serializationKey`. Successful results remain in their owning registry for five minutes after the last reader leaves, up to 100 idle queries, evicting the least recently left first. Reopening a query immediately returns the retained success with native `waiting: true` while a new subscription or read supplies fresh data. Execution stops between readers. Configure the registry’s `queryRetention` atom from `@shivaedev/contract/queryRetention.ts` with `{ timeToLive: "1 minute", capacity: 50 }`, or set React’s `SessionBoundary` prop of the same name. Zero for either disables idle retention. Expiry runs on the query runtime’s Effect Clock. Registry disposal clears all retained results; applications outside `SessionBoundary` own that disposal when their session changes. A native resume source receives a callback and returns a cleanup function.
@@ -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 @@
1
- {"version":3,"file":"clientContract.d.ts","sourceRoot":"","sources":["../src/clientContract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAA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AAI,EAAE,KAAK,CAAC;CACrB;AAOD,wBAAgB,cAAc,CAC7B,KAAK,CAAC,KAAK,SAAS,MAAM,EAC1B,KAAK,CAAC,KAAK,SAAS,IAAI,EACxB,KAAK,CAAC,SAAS,SAAS,QAAQ,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAC9D,QAAQ,SAAS,MAAM,KAAK,GAAG,MAAM,GAAG,KAAK,EAC7C,SAAS,SAAS,MAAM,KAAK,GAAG,MAAM,GAAG,KAAK,EAC9C,WAAW,SAAS,aAAa,CAAC,UAAU,GAAG,KAAK,EACpD,KAAK,CAAC,QAAQ,SAAS,kBAAkB,GAAG,SAAS,GAAG,SAAS,EACjE,KAAK,CAAC,MAAM,SAAS,SAAS,GAAG,SAAS,GAAG,SAAS,EAEtD,UAAU,EAAE,wBAAwB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,CAAC,GAC/G,cAAc,CAChB,KAAK,EACL,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,GAAG,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,EAAE,EACpG,WAAW,EACX,QAAQ,EACR,MAAM,CACN,CAAC"}
@@ -1,6 +1,9 @@
1
1
  import { declaredGroup } from "#contract.ts";
2
2
  import { operation } from "#operationDeclaration.ts";
3
3
  import { wireRejections } from "#wire.ts";
4
+ function noKeys() {
5
+ return [];
6
+ }
4
7
  export function clientContract(definition) {
5
8
  function declared(name) {
6
9
  const entry = definition.wire[name];
@@ -10,17 +13,9 @@ export function clientContract(definition) {
10
13
  ...(entry === undefined ? {} : { rejections: wireRejections(entry.rejections), success: entry.success }),
11
14
  };
12
15
  }
13
- const queries = Object.entries(definition.queries ?? {}).map(([name, { reads, readsCollections = [] }]) => {
14
- const collections = readsCollections.map((collection) => ({ _tag: "List", collection: collection.name }));
15
- return {
16
- ...operation("query", name, declared(name)),
17
- reads: (payload, viewer) => [...reads(payload, viewer), ...collections],
18
- };
19
- });
20
- const commands = Object.entries(definition.commands ?? {}).map(([name, { invalidates }]) => ({
21
- ...operation("command", name, declared(name)),
22
- invalidates: (payload, _result, viewer) => invalidates?.(payload, viewer) ?? [],
23
- }));
16
+ // The server's module declares the keys and announces the changes; an operation's shape still names them, so the browser's are empty.
17
+ const queries = (definition.queries ?? []).map((name) => ({ ...operation("query", name, declared(name)), reads: noKeys }));
18
+ const commands = (definition.commands ?? []).map((name) => ({ ...operation("command", name, declared(name)), invalidates: noKeys }));
24
19
  const group = declaredGroup(definition.name, {
25
20
  commands,
26
21
  queries,
@@ -1 +1 @@
1
- {"version":3,"file":"clientContract.js","sourceRoot":"","sources":["../src/clientContract.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAKrD,OAAO,EAA6B,cAAc,EAAE,MAAM,UAAU,CAAC;AAgFrE,MAAM,UAAU,cAAc,CAAC,UAS9B;IACA,SAAS,QAAQ,CAAC,IAAY;QAC7B,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;QAC5C,OAAO;YACN,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;YAC7C,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;SACxG,CAAC;IACH,CAAC;IACD,MAAM,OAAO,GA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AC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC3H,MAAM,QAAQ,GAAG,CAAC,UAAU,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IACrI,MAAM,KAAK,GAAG,aAAa,CAAC,UAAU,CAAC,IAAI,EAAE;QAC5C,QAAQ;QACR,OAAO;QACP,GAAG,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC;QAC/E,GAAG,CAAC,UAAU,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC;KAC5E,CAAC,CAAC;IACH,OAAO,UAAU,CAAC,UAAU,EAAE,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AACnG,CAAC"}
@@ -7,6 +7,7 @@ import type { automaticLive } from "#automaticLive.ts";
7
7
  import type { QueryOptions, RunOptions } from "#Bound.ts";
8
8
  import type { ActivityTracker } from "#clientActivities.ts";
9
9
  import type { CommandShape, QueryShape } from "#operation.ts";
10
+ export declare function runSubject(options: unknown): string | undefined;
10
11
  export declare function clientOperations(service: AtomRpc.AtomRpcClient<unknown, string, Rpc.Any>, activity: ActivityTracker, automatic: ReturnType<typeof automaticLive>, owner?: BindingOwner): {
11
12
  command: (tag: string, command: CommandShape) => {
12
13
  payload: Schema.Top;
@@ -1 +1 @@
1
- {"version":3,"file":"clientOperations.d.ts","sourceRoot":"","sources":["../src/clientOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAE/C,OAAO,KAAK,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAE1D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAM5D,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAY9D,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,EACxD,QAAQ,EAAE,eAAe,EACzB,SAAS,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,EAC3C,KAAK,CAAC,EAAE,YAAY;mBA2GJ,MAAM,WAAW,YAAY;;uBAjC5B,OAAO,YAAY,UAAU,GAAG,IAAI,CAAC,SAAS;;;iBAkCjD,MAAM,SAAS,UAAU;yBAhFpB,OAAO,kDAAiD,YAAY;uBA2BtE,OAAO,YAAY,UAAU,GAAG,IAAI,CAAC,SAAS;;;kBAsDhD,MAAM;uBAlBJ,OAAO,YAAY,UAAU,GAAG,IAAI,CAAC,SAAS;;;;EAqB/D"}
1
+ {"version":3,"file":"clientOperations.d.ts","sourceRoot":"","sources":["../src/clientOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAE/C,OAAO,KAAK,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAE1D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAM5D,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAQ9D,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAE/D;AAED,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,EACxD,QAAQ,EAAE,eAAe,EACzB,SAAS,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,EAC3C,KAAK,CAAC,EAAE,YAAY;mBA2GJ,MAAM,WAAW,YAAY;;uBAjC5B,OAAO,YAAY,UAAU,GAAG,IAAI,CAAC,SAAS;;;iBAkCjD,MAAM,SAAS,UAAU;yBAhFpB,OAAO,kDAAiD,YAAY;uBA2BtE,OAAO,YAAY,UAAU,GAAG,IAAI,CAAC,SAAS;;;kBAsDhD,MAAM;uBAlBJ,OAAO,YAAY,UAAU,GAAG,IAAI,CAAC,SAAS;;;;EAqB/D"}
@@ -14,7 +14,7 @@ import { storedForm } from "#storedQueries.ts";
14
14
  import { inputSubject, subjectSerializationKey, withSubject } from "#subjectHeader.ts";
15
15
  import { warmQueries } from "#warmQueries.ts";
16
16
  // `runtime.fn(api.save.run)` passes its function context as the second argument, so only an options object selects a subject.
17
- function runSubject(options) {
17
+ export function runSubject(options) {
18
18
  return typeof options === "object" && options !== null && "subject" in options && typeof options.subject === "string" ? options.subject : undefined;
19
19
  }
20
20
  export function clientOperations(service, activity, automatic, owner) {
@@ -1 +1 @@
1
- {"version":3,"file":"clientOperations.js","sourceRoot":"","sources":["../src/clientOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAE/D,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAG3D,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAIzE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAwB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,8HAA8H;AAC9H,SAAS,UAAU,CAAC,OAAgB;IACnC,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAA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+ } ? unknown : TClient extends (...args: never) => unknown ? never : TClient extends object ? {
5
+ readonly [TKey in keyof TClient]: TKey extends string ? SubjectBindable<TClient[TKey]> : TClient[TKey];
6
+ } : never;
7
+ export declare function forSubject<TClient extends object>(client: TClient & SubjectBindable<TClient>, subject: string): TClient;
8
+ //# sourceMappingURL=forSubject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forSubject.d.ts","sourceRoot":"","sources":["../src/forSubject.ts"],"names":[],"mappings":"AAmBA,MAAM,MAAM,eAAe,CAAC,OAAO,IAAI,OAAO,SAAS;IAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAC5H,OAAO,GACP,OAAO,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,GAC1C,KAAK,GACL,OAAO,SAAS,MAAM,GACrB;IAAE,QAAQ,EAAE,IAAI,IAAI,MAAM,OAAO,GAAG,IAAI,SAAS,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAAE,GAC1G,KAAK,CAAC;AAuCX,wBAAgB,UAAU,CAAC,OAAO,SAAS,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { runSubject } from "#clientOperations.ts";
2
+ // React's action hooks take `run` as the action's identity, so each operation and record is bound once per subject, and a
3
+ // record is cached before its members so one that refers back to itself binds to its own copy.
4
+ const bindings = new WeakMap();
5
+ function isOperation(value) {
6
+ return "runtime" in value && "run" in value && typeof value.run === "function";
7
+ }
8
+ function boundOperation(operation, subject) {
9
+ const { query, run } = operation;
10
+ return {
11
+ ...operation,
12
+ ...(query === undefined ? {} : { query: (payload, options = {}) => query(payload, { ...options, subject: options.subject ?? subject }) }),
13
+ run: (payload, options) => run(payload, { subject: runSubject(options) ?? subject }),
14
+ };
15
+ }
16
+ function bind(value, subject) {
17
+ const bySubject = bindings.get(value) ?? new Map();
18
+ bindings.set(value, bySubject);
19
+ const existing = bySubject.get(subject);
20
+ if (existing !== undefined) {
21
+ return existing;
22
+ }
23
+ if (isOperation(value)) {
24
+ const bound = boundOperation(value, subject);
25
+ bySubject.set(subject, bound);
26
+ return bound;
27
+ }
28
+ const bound = { ...value };
29
+ bySubject.set(subject, bound);
30
+ for (const [name, member] of Object.entries(value)) {
31
+ bound[name] = bind(member, subject);
32
+ }
33
+ return bound;
34
+ }
35
+ export function forSubject(client, subject) {
36
+ return bind(client, subject);
37
+ }
38
+ //# sourceMappingURL=forSubject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forSubject.js","sourceRoot":"","sources":["../src/forSubject.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAyBlD,0HAA0H;AAC1H,+FAA+F;AAC/F,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAiC,CAAC;AAE9D,SAAS,WAAW,CAAC,KAAa;IACjC,OAAO,SAAS,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,UAAU,CAAC;AAChF,CAAC;AAED,SAAS,cAAc,CAAC,SAAoB,EAAE,OAAe;IAC5D,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;IACjC,OAAO;QACN,GAAG,SAAS;QACZ,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,OAAO,EA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1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/contract",
3
- "version": "0.57.0",
3
+ "version": "0.59.0",
4
4
  "description": "Typed query and command contracts over native Effect RPC and reactivity",
5
5
  "keywords": [
6
6
  "effect"
@@ -51,13 +51,13 @@
51
51
  "devDependencies": {
52
52
  "@effect/platform-node": "4.1.4",
53
53
  "@effect/vitest": "4.1.4",
54
- "@shivaedev/identity": "0.38.3",
55
- "@shivaedev/quality": "0.83.2",
56
- "@shivaedev/server": "0.41.2",
57
- "@shivaedev/sql": "0.54.0",
58
- "@shivaedev/test-kits": "0.16.3",
59
- "@shivaedev/test-sql": "0.26.0",
60
- "@shivaedev/test-story": "0.52.3",
54
+ "@shivaedev/identity": "0.44.1",
55
+ "@shivaedev/quality": "0.84.2",
56
+ "@shivaedev/server": "0.46.2",
57
+ "@shivaedev/sql": "0.55.0",
58
+ "@shivaedev/test-kits": "0.16.12",
59
+ "@shivaedev/test-sql": "0.26.1",
60
+ "@shivaedev/test-story": "0.52.6",
61
61
  "@types/node": "24.19.2",
62
62
  "effect": "4.1.4",
63
63
  "fake-indexeddb": "6.2.8",
@@ -21,15 +21,6 @@ type Payloads<TWire> = { readonly [TOperation in keyof TWire]?: Schema.Top | Sch
21
21
  type PayloadOf<TPayloads, TOperation> = PayloadSchema<TOperation extends keyof TPayloads ? NonNullable<TPayloads[TOperation]> : Schema.Void>;
22
22
  type EntryOf<TWire, TOperation> = TOperation extends keyof TWire ? (TWire[TOperation] extends WireEntry ? TWire[TOperation] : never) : never;
23
23
 
24
- interface QueryKeys<TPayload> {
25
- readonly reads: (payload: TPayload, viewer: Option.Option<Viewer>) => readonly Key[];
26
- readonly readsCollections?: readonly { readonly name: string }[];
27
- }
28
-
29
- interface CommandKeys<TPayload> {
30
- readonly invalidates?: (payload: TPayload, viewer?: Option.Option<Viewer>) => readonly Key[];
31
- }
32
-
33
24
  type ClientQueries<TWire, TPayloads, TQueries extends string> = {
34
25
  readonly [TOperation in TQueries]: ClientQuery<
35
26
  TOperation,
@@ -58,19 +49,21 @@ export interface ClientContractDefinition<
58
49
  TSubject extends SubjectDeclaration | undefined,
59
50
  TScope extends "session" | undefined,
60
51
  > {
61
- readonly commands?: {
62
- readonly [TOperation in TCommands]: CommandKeys<PayloadOf<TPayloads, TOperation>["Type"]>;
63
- };
52
+ readonly commands?: readonly TCommands[];
64
53
  readonly keyScope?: TScope;
65
54
  readonly middleware?: TMiddleware;
66
55
  readonly name: TName;
67
56
  readonly payloads?: TPayloads;
68
- readonly queries?: { readonly [TOperation in TQueries]: QueryKeys<PayloadOf<TPayloads, TOperation>["Type"]> };
57
+ readonly queries?: readonly TQueries[];
69
58
  readonly subject?: TSubject;
70
59
  readonly wire: TWire;
71
60
  }
72
61
 
73
- // Written by the generator: what the browser needs of a module as values, without its run, read policy or services.
62
+ function noKeys(): readonly Key[] {
63
+ return [];
64
+ }
65
+
66
+ // Written by the generator: what the browser needs of a module as values, without its run, read policy, keys or services.
74
67
  export function clientContract<
75
68
  const TName extends string,
76
69
  const TWire extends Wire,
@@ -90,12 +83,12 @@ export function clientContract<
90
83
  TScope
91
84
  >;
92
85
  export function clientContract(definition: {
93
- readonly commands?: { readonly [operation: string]: CommandKeys<unknown> };
86
+ readonly commands?: readonly string[];
94
87
  readonly keyScope?: "session";
95
88
  readonly middleware?: RpcMiddleware.AnyService;
96
89
  readonly name: string;
97
90
  readonly payloads?: { readonly [operation: string]: Schema.Top | Schema.Struct.Fields | undefined };
98
- readonly queries?: { readonly [operation: string]: QueryKeys<unknown> };
91
+ readonly queries?: readonly string[];
99
92
  readonly subject?: SubjectDeclaration;
100
93
  readonly wire: Wire;
101
94
  }): unknown {
@@ -107,17 +100,9 @@ export function clientContract(definition: {
107
100
  ...(entry === undefined ? {} : { rejections: wireRejections(entry.rejections), success: entry.success }),
108
101
  };
109
102
  }
110
- const queries = Object.entries(definition.queries ?? {}).map(([name, { reads, readsCollections = [] }]) => {
111
- const collections: readonly Key[] = readsCollections.map((collection) => ({ _tag: "List", collection: collection.name }));
112
- return {
113
- ...operation("query", name, declared(name)),
114
- reads: (payload: unknown, viewer: Option.Option<Viewer>) => [...reads(payload, viewer), ...collections],
115
- };
116
- });
117
- const commands = Object.entries(definition.commands ?? {}).map(([name, { invalidates }]) => ({
118
- ...operation("command", name, declared(name)),
119
- invalidates: (payload: unknown, _result: unknown, viewer?: Option.Option<Viewer>) => invalidates?.(payload, viewer) ?? [],
120
- }));
103
+ // The server's module declares the keys and announces the changes; an operation's shape still names them, so the browser's are empty.
104
+ const queries = (definition.queries ?? []).map((name) => ({ ...operation("query", name, declared(name)), reads: noKeys }));
105
+ const commands = (definition.commands ?? []).map((name) => ({ ...operation("command", name, declared(name)), invalidates: noKeys }));
121
106
  const group = declaredGroup(definition.name, {
122
107
  commands,
123
108
  queries,
@@ -22,7 +22,7 @@ import { inputSubject, subjectSerializationKey, withSubject } from "#subjectHead
22
22
  import { warmQueries } from "#warmQueries.ts";
23
23
 
24
24
  // `runtime.fn(api.save.run)` passes its function context as the second argument, so only an options object selects a subject.
25
- function runSubject(options: unknown): string | undefined {
25
+ export function runSubject(options: unknown): string | undefined {
26
26
  return typeof options === "object" && options !== null && "subject" in options && typeof options.subject === "string" ? options.subject : undefined;
27
27
  }
28
28
 
@@ -0,0 +1,68 @@
1
+ import type * as Atom from "effect/reactivity/Atom";
2
+ import type { QueryOptions, RunOptions } from "#Bound.ts";
3
+ import { runSubject } from "#clientOperations.ts";
4
+
5
+ interface Operation {
6
+ readonly query?: (payload: unknown, options?: QueryOptions) => unknown;
7
+ readonly run: (payload: unknown, options?: RunOptions | Atom.FnContext) => unknown;
8
+ readonly runtime: unknown;
9
+ }
10
+
11
+ interface BindableRecord {
12
+ readonly [name: string]: Bindable;
13
+ }
14
+
15
+ type Bindable = Operation | BindableRecord;
16
+
17
+ // A bound operation, or a record whose string-keyed members are bound operations or such records. Anything else, such as
18
+ // the Layer `makeClient` returns or a function beside the operations, is refused, because a call through it would silently
19
+ // act for the caller's own account.
20
+ export type SubjectBindable<TClient> = TClient extends { readonly run: (...args: never) => unknown; readonly runtime: unknown }
21
+ ? unknown
22
+ : TClient extends (...args: never) => unknown
23
+ ? never
24
+ : TClient extends object
25
+ ? { readonly [TKey in keyof TClient]: TKey extends string ? SubjectBindable<TClient[TKey]> : TClient[TKey] }
26
+ : never;
27
+
28
+ // React's action hooks take `run` as the action's identity, so each operation and record is bound once per subject, and a
29
+ // record is cached before its members so one that refers back to itself binds to its own copy.
30
+ const bindings = new WeakMap<object, Map<string, Bindable>>();
31
+
32
+ function isOperation(value: object): value is Operation {
33
+ return "runtime" in value && "run" in value && typeof value.run === "function";
34
+ }
35
+
36
+ function boundOperation(operation: Operation, subject: string): Operation {
37
+ const { query, run } = operation;
38
+ return {
39
+ ...operation,
40
+ ...(query === undefined ? {} : { query: (payload, options = {}) => query(payload, { ...options, subject: options.subject ?? subject }) }),
41
+ run: (payload, options) => run(payload, { subject: runSubject(options) ?? subject }),
42
+ };
43
+ }
44
+
45
+ function bind(value: Bindable, subject: string): Bindable {
46
+ const bySubject = bindings.get(value) ?? new Map<string, Bindable>();
47
+ bindings.set(value, bySubject);
48
+ const existing = bySubject.get(subject);
49
+ if (existing !== undefined) {
50
+ return existing;
51
+ }
52
+ if (isOperation(value)) {
53
+ const bound = boundOperation(value, subject);
54
+ bySubject.set(subject, bound);
55
+ return bound;
56
+ }
57
+ const bound: Record<string, Bindable> = { ...value };
58
+ bySubject.set(subject, bound);
59
+ for (const [name, member] of Object.entries(value)) {
60
+ bound[name] = bind(member, subject);
61
+ }
62
+ return bound;
63
+ }
64
+
65
+ export function forSubject<TClient extends object>(client: TClient & SubjectBindable<TClient>, subject: string): TClient;
66
+ export function forSubject(client: Bindable, subject: string): Bindable {
67
+ return bind(client, subject);
68
+ }