@shivaedev/contract 0.49.0 → 0.50.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,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.50.0 - 2026-11-20
4
+
5
+ ### Added
6
+
7
+ - `failureKind(error)` in `failureKind.ts` returns `"request"`, `"framework"` or `"app"`, with the `FrameworkFailure` and `AppRejection<E>` types and the `isFrameworkFailure` guard.
8
+ - a bound command carries `runtime`, the atom runtime of its client, and `payload`, its declared payload schema. Bound queries and streams carry `runtime` too.
9
+
10
+ ### Breaking
11
+
12
+ - `defineModule` no longer takes `requires`: delete the `requires` line from every `defineModule({ ... })`, and the imports only it used. The module's type now carries, for each operation, the services its `run` and read policy yield, less what its middleware and subject provide per call, and `moduleHandlers(module)` requires exactly those services. An operation that starts to yield another service needs no other edit.
13
+ - `OperationNeedsUndeclaredServices` and `Allowed` are removed from `@shivaedev/contract/moduleProof.ts`, and `NameProof` takes the operations and the wire only. A module's `"~requires"` is now a record from each operation's name to the services it needs, and `AnyModule["~requires"]` is `ModuleServices`.
14
+
3
15
  ## 0.49.0 - 2026-11-20
4
16
 
5
17
  ### Added
package/README.md CHANGED
@@ -30,7 +30,7 @@ const Rename = command("rename", {
30
30
  },
31
31
  });
32
32
 
33
- export const Notes = defineModule({ name: "notes", operations: [List, Rename], requires: [NotesStore], wire: notesWire });
33
+ export const Notes = defineModule({ name: "notes", operations: [List, Rename], wire: notesWire });
34
34
  ```
35
35
 
36
36
  `Notes` is a native RPC group with `notes.list` and `notes.rename`, served by the operations themselves. Nothing restates what `list` returns or how `rename` fails: [`@shivaedev/build`](https://github.com/ShivaeDev/platform/tree/main/packages/build) writes those schemas from `run`'s types into `notesWire`, and the compiler checks them against `run` on every type check. When a bound rename succeeds, the note's key refreshes its readers and the list; an item query for another note keeps its result. Handlers, middleware and transport use Effect's own APIs.
@@ -93,7 +93,9 @@ An operation written this way states no `success` or `rejections`: its module's
93
93
 
94
94
  `run` must not return `any`, such as the result of `JSON.parse`, which would otherwise pass every check: such an operation is a compile error that names it and `RunReturnsAny` (decode the value with a schema, or type it). While the declaration form is still accepted, that error starts with "No overload matches this call" and its last line names the problem. Biome's `useYield` refuses a `*run` that yields nothing, so a `run` that needs no service still yields an Effect.
95
95
 
96
- A field failure is an exported tagged class built from the payload's fields with `fieldRejection`, as `TitleTaken` above. `run` raises it with `yield* new TitleTaken({ field, message })`, and `@shivaedev/form`'s `rejecting` places its message on that field.
96
+ `failureKind(error)` from `@shivaedev/contract/failureKind.ts` sorts an operation's failure for its client: `"request"` for a shared request rejection (the `RequestRejection` type in `@shivaedev/errors/taxonomy.ts`), `"framework"` for a `ServerFailure`, an `RpcClientError` or the contract's own `MissingReadPolicy`, `MissingReadPolicies`, `QueryReadDenied` and `WebSocketRequired`, `"framework"` also for a failure without a string `_tag`, and `"app"` for any other tagged failure, which is a rejection the feature declared for itself. `AppRejection<E>` and `FrameworkFailure` are the matching types; `@shivaedev/react` requires a handler only for an `AppRejection`.
97
+
98
+ A field failure is an exported tagged class built from the payload's fields with `fieldRejection`, as `TitleTaken` above. `run` raises it with `yield* new TitleTaken({ field, message })`; `useCreate` and `useEditor` in `@shivaedev/react` place its message on that field, as `@shivaedev/form`'s `rejecting` does for a form used directly.
97
99
 
98
100
  #### A module defined from its operations
99
101
 
@@ -171,18 +173,17 @@ export const Notes = defineModule({
171
173
  middleware: Caller,
172
174
  name: "notes",
173
175
  operations: [List, Get, Create],
174
- requires: [NotesStore],
175
176
  wire: notesWire,
176
177
  });
177
178
  ```
178
179
 
179
- 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, the services they may use in `requires`, its `wire` (below), and optionally `middleware`, `subject` and `keyScope` as `contract` does. It returns the module's contract, so `bind`, `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 compiler checks `requires`, and the module does not keep the list at run time. 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: `OperationNeedsUndeclaredServices` when an operation's `run` or read policy uses a service that neither `requires` nor the middleware or subject provides, and `OperationNameRepeated` when two operations share a name:
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 `bind`, `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:
180
181
 
181
182
  ```
182
- src/test-support/fixtures/invalid/moduleUndeclaredService.ts(22,2): error TS2322: Type '"imports"' is not assignable to type '"imports" & NoInfer<OperationNeedsUndeclaredServices<"importTitle", NoteSource>>'.
183
+ src/test-support/fixtures/invalid/moduleRepeatedName.ts(15,2): error TS2322: Type '"lists"' is not assignable to type '"lists" & NoInfer<OperationNameRepeated<"list">>'.
183
184
  ```
184
185
 
185
- `moduleHandlers(Notes)` builds the module's handler Layer from its operations, and the Layer requires exactly the services in `requires`:
186
+ `moduleHandlers(Notes)` builds the module's handler Layer from its operations, and the Layer requires exactly the services the operations yield beyond the middleware and subject, here `NotesStore`, so serving it provides that service on the Layer:
186
187
 
187
188
  ```ts
188
189
  import { Layer } from "effect";
@@ -193,6 +194,8 @@ import { NotesStoreLive } from "./store.ts";
193
194
  export const NotesHandlers = moduleHandlers(Notes).pipe(Layer.provide(NotesStoreLive));
194
195
  ```
195
196
 
197
+ An application registers the module with the server instead, and the [server's `appModules`](https://github.com/ShivaeDev/platform/tree/main/packages/server#host-the-application) refuses a registration list that leaves a service unprovided, naming the module, the operation and the service.
198
+
196
199
  Each operation runs in a span named after the module and the operation, such as `Notes.create`. A query's read policy is checked inside its handler before `run`, with the module's services, so a policy reads a repository directly, as `Get` does above; a live subscription to the query checks the same policy. Failures pass the RPC boundary from `@shivaedev/errors`: a rejection the wire lists reaches the client as itself, an unlisted failure that states `isRetryable` answers `ServiceUnavailable`, and anything else answers `InternalServerError`, for the policy of a live subscription too. A command without `invalidates` publishes only the keys its writes announce.
197
200
 
198
201
  #### The wire and the browser's contract
@@ -471,7 +474,7 @@ const readOnce = api.get.run({ id: 1 });
471
474
  const rename = api.rename.run({ id: 1, title: "Uno" });
472
475
  ```
473
476
 
474
- `one` and `list` are native query atoms. `readOnce` and `rename` are Effects for individual calls. A query's Effect requires `NotesClient`; a command's Effect also requires native `Reactivity`. Commands expose `run`, and have no `query` member.
477
+ `one` and `list` are native query atoms. `readOnce` and `rename` are Effects for individual calls. A query's Effect requires `NotesClient`; a command's Effect also requires native `Reactivity`. Commands expose `run`, the atom `runtime` that provides those services and their declared `payload` schema, and have no `query` member; queries and streams also carry `runtime`. React's action and form hooks take a bound command as it is, as in `useAction(api.rename)`, and a form derives its fields from `payload`.
475
478
 
476
479
  Mount the atoms and run commands through the service's atom runtime in the same registry:
477
480
 
@@ -913,43 +916,43 @@ Observe raw result streams with `watchHints` from `@shivaedev/test-kits/contract
913
916
 
914
917
  Import the module that defines the name; the package has no root entry.
915
918
 
916
- | Module | Functions and schemas |
917
- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
918
- | `operation.ts` | `query(name, { payload?, *run, readPolicy?, reads?, serverReads?, readsCollections? })` and `command(name, { payload?, *run, invalidates?(payload, viewer?) })` with an Effect-returning `run`; declared without run: `query(name, { payload?, success?, rejections?, readPolicy, reads?, serverReads? })`, `command(name, { payload?, success?, rejections?, invalidates(payload, result, viewer?) })` and `stream(name, { payload?, success, rejections?, reads })`. |
919
- | `contract.ts` | `contract(name, { queries?, commands?, streams?, keyScope? })`, returning a native RPC group with `declaration: { name, queries, commands, streams, keyScope }`. |
920
- | `defineModule.ts` | `defineModule({ name, operations, requires, wire, middleware?, subject?, keyScope? })`, returning the module's contract. |
921
- | `moduleHandlers.ts` | `moduleHandlers(module)`, the module's handler Layer, requiring exactly its `requires`. |
922
- | `clientContract.ts` | `clientContract({ name, wire, payloads?, queries?, commands?, middleware?, subject?, keyScope? })`, the browser's contract of a module that generated files build. |
923
- | `clientMatchesModule.ts` | `ClientMatchesModule<Client, Module>`, `true` when the browser's contract and the server module have the same RPCs, else `ClientDiffersFromModule`. |
924
- | `rejection.ts` | `fieldRejection(struct, fields?)`; lower-level `rejectionSet(specs)`, which constructs the rejection classes, union schema and failure helpers used by operations. |
925
- | `bind.ts` | `bind(contract, atomRpcService, { registry?, live?, resume?, resumeWindow? }?)`, requiring the registry for session-scoped contracts and exposing `{ query, run }` for queries, `{ run }` Effects for commands and `{ run }` native Streams for streams; `makeClient(contract, { url, protocol?, headers?, webSocketConstructor?, group?, registry?, live?, resume?, resumeWindow? })`, which builds the shared WebSocket client and binds it, with `sync` beside `api`. |
926
- | `clientKeys.ts` | `KeyContext`, `clientReadKeys`, `clientInvalidationKeys`: registry-local cache keys for custom clients. |
927
- | `live.ts` | `LiveHint` schema; `live(runtime, { stream, keyContext?, resume?, retryDelay?, retryKeys? })`, exposing `connection`, `paused` and `status`; `isLiveConnection(atom)` tells whether an atom is such a `connection`, which waits for as long as its subscription runs. |
928
- | `querySubscription.ts` | `querySubscription(rpc, references, viewer)` checks each referenced query, resolves its payload and server-derived keys, and captures its scopes and ongoing authorization. |
929
- | `live-server/service.ts` | `LiveServer`, the shared live server service. |
930
- | `live-server/layer.ts` | `liveServerLayer`, providing `LiveServer` and its dispatcher dependency, requiring `Reactivity`. |
931
- | `live-server/subscribe.ts` | `subscribe(subscription, read?)`, an Effect requiring `LiveServer` that returns an authorized subscription Stream with its policy and query-runner requirements. |
932
- | `makeLiveServer.ts` | `makeLiveServer`, an Effect requiring `Reactivity` that creates scoped server hint streams, a `resync` Effect and `synced(token)`. |
933
- | `readPolicy.ts` | `QueryReadPolicy`, `Viewer`, `signedIn`, `CurrentViewer`; `authorizeReads(effect, request, viewer)` for direct handler reruns outside RPC middleware. |
934
- | `ReadPolicyGuard.ts` | `ReadPolicyGuard`, the defaulted middleware reference attached to contract queries; `readPolicyGuardLayer({ websocket? })`, an optional override that refuses HTTP `$changes` calls by default. |
935
- | `validateReadPolicies.ts` | `validateReadPolicies(group)`, an Effect that fails with `MissingReadPolicies` when any served or subscribable query omits its policy. |
936
- | `readPolicyErrors.ts` | `MissingReadPolicies` (boot), `MissingReadPolicy` (native-server request fallback) and `QueryReadDenied`. |
937
- | `CommandGuard.ts` | `guardCommands(group)` places command publication inside viewer-providing middleware; `commandGuardLayer(boundary)` evaluates declared invalidations for that viewer and delegates publication to the host boundary. |
938
- | `commandResult.ts` | `commandResult({ result, invalidates })` contributes server-only keys from a guarded command's `run` or handler and returns only its success value. |
939
- | `serverMetadata.ts` | `QueryDefinition.definition`, `CommandInvalidation.invalidates`, `ChangesQueries.queries`, `ChangesQueries.resolve(references)` and `changesRpc(name, queries)` for server adapters. |
940
- | `queryKeys.ts` | `queryKeys(queries, references, viewer?)` authorizes references and resolves payload and server-derived keys using the provided services. |
941
- | `QueryServerReads.ts` | `QueryServerReads<Payload, E, R>`, the server-only resolver type. |
942
- | `resume.ts` | `resumeSignal({ window?, native? })`, returning a native numeric signal atom. |
943
- | `querySignals.ts` | `querySignals(query)` exposes completion counts and subscription status as a native atom. |
944
- | `retainQuery.ts` | `queryRuntime(query)` returns the atom runtime a bound query runs on, so a reader can schedule work on the same Effect `Clock`. |
945
- | `clientActivity.ts` | `clientActivity(client)` exposes a native activity Stream with a `current` Effect; `isClientSettled(state)` checks commands, commands not yet reflected and first query results; `isClientIdle(state)` checks all finite work; `activityScreenSignal(activity, settled?)` projects pending work for screen waits. |
946
- | `commandSignal.ts` | `untilReflected(command)` completes a command's Effect when it is reflected; `CommandSignal` receives each `CommandState`. |
947
- | `LiveSync.ts` | `LiveSync`, the host's contract of the `platform.liveSync.request` command that carries a sync token and writes nothing. Browser code takes the same command from `liveSyncRpc.ts`. |
948
- | `liveSyncRpc.ts` | `liveSyncRpc`, the RPC group a client declares for that command without importing its operation file, and `LIVE_SYNC`, its tag. |
949
- | `syncHeader.ts` | `syncClient(headers)` and `syncToken(headers)` read the client name and the sync token a request carries. |
950
- | `operationKind.ts` | `operationKind(rpc)`: `"read"` for a query, a changes stream or a stream, `"write"` for a command or an RPC no contract marked. |
951
- | `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. |
952
- | `screenSync.ts` | `screenSync(client, registry)` runs a client's `sync` through a registry, for a screen driver's `sync` option. |
919
+ | Module | Functions and schemas |
920
+ | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
921
+ | `operation.ts` | `query(name, { payload?, *run, readPolicy?, reads?, serverReads?, readsCollections? })` and `command(name, { payload?, *run, invalidates?(payload, viewer?) })` with an Effect-returning `run`; declared without run: `query(name, { payload?, success?, rejections?, readPolicy, reads?, serverReads? })`, `command(name, { payload?, success?, rejections?, invalidates(payload, result, viewer?) })` and `stream(name, { payload?, success, rejections?, reads })`. |
922
+ | `contract.ts` | `contract(name, { queries?, commands?, streams?, keyScope? })`, returning a native RPC group with `declaration: { name, queries, commands, streams, keyScope }`. |
923
+ | `defineModule.ts` | `defineModule({ name, operations, wire, middleware?, subject?, keyScope? })`, returning the module's contract, whose type carries the services each operation yields. |
924
+ | `moduleHandlers.ts` | `moduleHandlers(module)`, the module's handler Layer, requiring exactly the services its operations yield beyond its middleware and subject. |
925
+ | `clientContract.ts` | `clientContract({ name, wire, payloads?, queries?, commands?, middleware?, subject?, keyScope? })`, the browser's contract of a module that generated files build. |
926
+ | `clientMatchesModule.ts` | `ClientMatchesModule<Client, Module>`, `true` when the browser's contract and the server module have the same RPCs, else `ClientDiffersFromModule`. |
927
+ | `rejection.ts` | `fieldRejection(struct, fields?)`; lower-level `rejectionSet(specs)`, which constructs the rejection classes, union schema and failure helpers used by operations. |
928
+ | `bind.ts` | `bind(contract, atomRpcService, { registry?, live?, resume?, resumeWindow? }?)`, requiring the registry for session-scoped contracts and exposing `{ query, run, runtime }` for queries, `{ run, payload, runtime }` for commands and `{ run, runtime }` with native Streams for streams; `makeClient(contract, { url, protocol?, headers?, webSocketConstructor?, group?, registry?, live?, resume?, resumeWindow? })`, which builds the shared WebSocket client and binds it, with `sync` beside `api`. |
929
+ | `clientKeys.ts` | `KeyContext`, `clientReadKeys`, `clientInvalidationKeys`: registry-local cache keys for custom clients. |
930
+ | `live.ts` | `LiveHint` schema; `live(runtime, { stream, keyContext?, resume?, retryDelay?, retryKeys? })`, exposing `connection`, `paused` and `status`; `isLiveConnection(atom)` tells whether an atom is such a `connection`, which waits for as long as its subscription runs. |
931
+ | `querySubscription.ts` | `querySubscription(rpc, references, viewer)` checks each referenced query, resolves its payload and server-derived keys, and captures its scopes and ongoing authorization. |
932
+ | `live-server/service.ts` | `LiveServer`, the shared live server service. |
933
+ | `live-server/layer.ts` | `liveServerLayer`, providing `LiveServer` and its dispatcher dependency, requiring `Reactivity`. |
934
+ | `live-server/subscribe.ts` | `subscribe(subscription, read?)`, an Effect requiring `LiveServer` that returns an authorized subscription Stream with its policy and query-runner requirements. |
935
+ | `makeLiveServer.ts` | `makeLiveServer`, an Effect requiring `Reactivity` that creates scoped server hint streams, a `resync` Effect and `synced(token)`. |
936
+ | `readPolicy.ts` | `QueryReadPolicy`, `Viewer`, `signedIn`, `CurrentViewer`; `authorizeReads(effect, request, viewer)` for direct handler reruns outside RPC middleware. |
937
+ | `ReadPolicyGuard.ts` | `ReadPolicyGuard`, the defaulted middleware reference attached to contract queries; `readPolicyGuardLayer({ websocket? })`, an optional override that refuses HTTP `$changes` calls by default. |
938
+ | `validateReadPolicies.ts` | `validateReadPolicies(group)`, an Effect that fails with `MissingReadPolicies` when any served or subscribable query omits its policy. |
939
+ | `readPolicyErrors.ts` | `MissingReadPolicies` (boot), `MissingReadPolicy` (native-server request fallback) and `QueryReadDenied`. |
940
+ | `CommandGuard.ts` | `guardCommands(group)` places command publication inside viewer-providing middleware; `commandGuardLayer(boundary)` evaluates declared invalidations for that viewer and delegates publication to the host boundary. |
941
+ | `commandResult.ts` | `commandResult({ result, invalidates })` contributes server-only keys from a guarded command's `run` or handler and returns only its success value. |
942
+ | `serverMetadata.ts` | `QueryDefinition.definition`, `CommandInvalidation.invalidates`, `ChangesQueries.queries`, `ChangesQueries.resolve(references)` and `changesRpc(name, queries)` for server adapters. |
943
+ | `queryKeys.ts` | `queryKeys(queries, references, viewer?)` authorizes references and resolves payload and server-derived keys using the provided services. |
944
+ | `QueryServerReads.ts` | `QueryServerReads<Payload, E, R>`, the server-only resolver type. |
945
+ | `resume.ts` | `resumeSignal({ window?, native? })`, returning a native numeric signal atom. |
946
+ | `querySignals.ts` | `querySignals(query)` exposes completion counts and subscription status as a native atom. |
947
+ | `retainQuery.ts` | `queryRuntime(query)` returns the atom runtime a bound query runs on, so a reader can schedule work on the same Effect `Clock`. |
948
+ | `clientActivity.ts` | `clientActivity(client)` exposes a native activity Stream with a `current` Effect; `isClientSettled(state)` checks commands, commands not yet reflected and first query results; `isClientIdle(state)` checks all finite work; `activityScreenSignal(activity, settled?)` projects pending work for screen waits. |
949
+ | `commandSignal.ts` | `untilReflected(command)` completes a command's Effect when it is reflected; `CommandSignal` receives each `CommandState`. |
950
+ | `LiveSync.ts` | `LiveSync`, the host's contract of the `platform.liveSync.request` command that carries a sync token and writes nothing. Browser code takes the same command from `liveSyncRpc.ts`. |
951
+ | `liveSyncRpc.ts` | `liveSyncRpc`, the RPC group a client declares for that command without importing its operation file, and `LIVE_SYNC`, its tag. |
952
+ | `syncHeader.ts` | `syncClient(headers)` and `syncToken(headers)` read the client name and the sync token a request carries. |
953
+ | `operationKind.ts` | `operationKind(rpc)`: `"read"` for a query, a changes stream or a stream, `"write"` for a command or an RPC no contract marked. |
954
+ | `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. |
955
+ | `screenSync.ts` | `screenSync(client, registry)` runs a client's `sync` through a registry, for a screen driver's `sync` option. |
953
956
 
954
957
  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.
955
958
 
package/dist/bind.d.ts CHANGED
@@ -23,15 +23,22 @@ export interface QueryOptions extends RunOptions {
23
23
  readonly serializationKey?: string;
24
24
  }
25
25
  type Run<TPayload, TResult> = (payload: TPayload, options?: RunOptions | Atom.FnContext) => TResult;
26
+ type DeclaredPayload<R> = R extends {
27
+ readonly payloadSchema: infer TPayload;
28
+ } ? TPayload : never;
26
29
  export interface BoundQuery<R, TSelf, TSubscription = never> {
27
30
  readonly query: (payload: Rpc.Payload<R>, options?: QueryOptions) => Atom.Atom<AsyncResult.AsyncResult<Rpc.Success<R>, Failure<R | TSubscription>>>;
28
31
  readonly run: Run<Rpc.Payload<R>, Effect.Effect<Rpc.Success<R>, RunFailure<R>, TSelf>>;
32
+ readonly runtime: Atom.AtomRuntime<TSelf>;
29
33
  }
30
34
  export interface BoundCommand<R, TSelf> {
35
+ readonly payload: DeclaredPayload<R>;
31
36
  readonly run: Run<Rpc.Payload<R>, Effect.Effect<Rpc.Success<R>, RunFailure<R>, TSelf | Reactivity.Reactivity>>;
37
+ readonly runtime: Atom.AtomRuntime<TSelf>;
32
38
  }
33
39
  export interface BoundStream<R, TSelf> {
34
40
  readonly run: Run<Rpc.Payload<R>, Stream.Stream<Rpc.SuccessChunk<R>, RunFailure<R>, TSelf | Rpc.ServicesClient<R>>>;
41
+ readonly runtime: Atom.AtomRuntime<TSelf>;
35
42
  }
36
43
  export type Bound<TName extends string, TQueries extends readonly QueryShape[], TCommands extends readonly CommandShape[], TRpcs extends Rpc.Any, TSelf, TStreams extends readonly StreamShape[] = readonly []> = {
37
44
  readonly [TQuery in TQueries[number] as TQuery["name"]]: BoundQuery<Rpc.ExtractTag<TRpcs, Tag<TName, TQuery["name"]>>, TSelf, Rpc.ExtractTag<TRpcs, Tag<TName, "$changes">>>;
@@ -1 +1 @@
1
- {"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../src/bind.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,KAAK,YAAY,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,C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.declaration.name, options.group ?? contract, options);
14
14
  const bindingOptions = options;
15
15
  const owner = bindingOwner(contract.declaration.keyScope, bindingOptions.registry);
16
- const automatic = automaticLive(connection.Client, contract.declaration.name, owner, bindingOptions.resume, bindingOptions.live, bindingOptions.resumeWindow);
16
+ const { live, resume, resumeWindow } = bindingOptions;
17
+ const automatic = automaticLive(connection.Client, contract.declaration.name, owner, resume, live, resumeWindow);
17
18
  const operations = clientOperations(connection.Client, automatic, owner);
18
19
  const api = bindOperations(contract.declaration, operations, automatic.subscription);
19
20
  return Object.assign(connection, { api, sync: operations.sync });
package/dist/bind.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bind.js","sourceRoot":"","sources":["../src/bind.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAkB,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAMxD,OAAO,EAAkB,SAAS,EAAE,MAAM,eAAe,CAAC;AAkF1D,MAAM,UAAU,IAAI,CACnB,QAAmJ,EACnJ,OAAwD,EACxD,OAAqB;IAErB,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC,WAAW,CAAC;IAChD,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACxD,MAAM,SAAS,GAAG,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IAC7G,OAAO,cAAc,CAAC,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;AACl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AU,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;AAClE,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Effect, Stream } from "effect";
1
+ import { Effect, Schema, Stream } from "effect";
2
2
  import * as Atom from "effect/reactivity/Atom";
3
3
  import type * as AtomRpc from "effect/reactivity/AtomRpc";
4
4
  import type { Rpc } from "effect/rpc";
@@ -8,14 +8,18 @@ import type { QueryOptions, RunOptions } from "#bind.ts";
8
8
  import type { CommandShape, QueryShape } from "#operation.ts";
9
9
  export declare function clientOperations(service: AtomRpc.AtomRpcClient<unknown, string, Rpc.Any>, automatic: ReturnType<typeof automaticLive>, owner?: BindingOwner): {
10
10
  command: (tag: string, command: CommandShape) => {
11
+ payload: Schema.Top;
11
12
  run: (payload: unknown, options?: RunOptions | Atom.FnContext) => Effect.Effect<unknown, unknown, unknown>;
13
+ runtime: Atom.AtomRuntime<unknown, never>;
12
14
  };
13
15
  query: (tag: string, query: QueryShape) => {
14
16
  query: (payload: unknown, { headers: given, serializationKey, subject }?: QueryOptions) => Atom.Atom<import("effect/reactivity/AsyncResult").AsyncResult<any, any> | import("effect/reactivity/AsyncResult").AsyncResult<unknown, unknown>>;
15
17
  run: (payload: unknown, options?: RunOptions | Atom.FnContext) => Effect.Effect<unknown, unknown, unknown>;
18
+ runtime: Atom.AtomRuntime<unknown, never>;
16
19
  };
17
20
  stream: (tag: string) => {
18
21
  run: (payload: unknown, options?: RunOptions | Atom.FnContext) => Stream.Stream<unknown, unknown, unknown>;
22
+ runtime: Atom.AtomRuntime<unknown, never>;
19
23
  };
20
24
  sync: Effect.Effect<void, unknown, unknown>;
21
25
  };
@@ -1 +1 @@
1
- {"version":3,"file":"clientOperations.d.ts","sourceRoot":"","sources":["../src/clientOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAkB,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,KAAK,IAAI,MAAM,wBAAw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mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAOzD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAW9D,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,EACxD,SAAS,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,EAC3C,KAAK,CAAC,EAAE,YAAY;mBA0GJ,MAAM,WAAW,YAAY;;uBAjC5B,OAAO,YAAY,UAAU,GAAG,IAAI,CAAC,SAAS;;;iBAkCjD,MAAM,SAAS,UAAU;yBA3FpB,OAAO,kDAAiD,YAAY;uBA8BtE,OAAO,YAAY,UAAU,GAAG,IAAI,CAAC,SAAS;;;kBA8DhD,MAAM;uBAlBJ,OAAO,YAAY,UAAU,GAAG,IAAI,CAAC,SAAS;;;;EAqB/D"}
@@ -50,6 +50,7 @@ export function clientOperations(service, automatic, owner) {
50
50
  return tracked;
51
51
  },
52
52
  run: (payload, options) => run(ordinaryClient.use((client) => client(tag, payload, { headers: withSubject(undefined, runSubject(options)) }))),
53
+ runtime: ordinaryClient.runtime,
53
54
  };
54
55
  }
55
56
  function boundCommand(tag, command) {
@@ -64,7 +65,9 @@ export function clientOperations(service, automatic, owner) {
64
65
  return ordinaryClient.use((client) => commandPayload(command, payload).pipe(Effect.tap(() => waitForConnection(client)), Effect.flatMap((validated) => reflectCommand(client, observer, (options) => client(tag, validated, { headers: withSubject(options?.headers, subject) }))), Effect.tap((result) => invalidate(payload, result))));
65
66
  }
66
67
  return {
68
+ payload: command.payload,
67
69
  run: (payload, options) => Effect.flatMap(observed, (observer) => run(send(observer, payload, runSubject(options)))),
70
+ runtime: ordinaryClient.runtime,
68
71
  };
69
72
  }
70
73
  function synchronize(observer) {
@@ -83,6 +86,7 @@ export function clientOperations(service, automatic, owner) {
83
86
  ? stream
84
87
  : Stream.callback((queue) => AtomRegistry.getResult(owner.registry, streaming.runtime.atom(Stream.runIntoQueue(stream, queue)).pipe(Atom.setIdleTTL(0))), { bufferSize: 1 });
85
88
  },
89
+ runtime: streaming.runtime,
86
90
  };
87
91
  }
88
92
  return {
@@ -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,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAE/D,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAI3D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,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,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAwB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEzE,8HAA8H;AAC9H,SAAS,UAAU,CAAC,OAAgB;IACnC,OAAO,OAAO,OAAO,KAA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";
2
2
  import type { Rpc, RpcMiddleware } from "effect/rpc";
3
- import type { RequirementRecord } from "@shivaedev/service/ServiceRequirements.ts";
4
3
  import { type Contract } from "#contract.ts";
5
- import type { Allowed, NameProof } from "#moduleProof.ts";
4
+ import type { ModuleRequirements, ModuleServices, NameProof } from "#moduleProof.ts";
6
5
  import type { CommandShape, QueryShape } from "#operation.ts";
7
6
  import type { OperationRpc } from "#operationRpc.ts";
8
7
  import type { ReadPolicyGuard } from "#ReadPolicyGuard.ts";
@@ -24,18 +23,17 @@ type CommandsOf<TOperations extends readonly (QueryShape | CommandShape)[]> = re
24
23
  type Served<TRpc> = TRpc extends Rpc.Rpc<infer TTag, infer TPayload, infer TSuccess, infer TError, infer TMiddleware, infer _TRequires> ? Rpc.Rpc<TTag, TPayload, TSuccess, TError, TMiddleware, never> : never;
25
24
  type WithMiddleware<TRpcs extends Rpc.Any, TMiddleware extends RpcMiddleware.AnyService> = [TMiddleware] extends [never] ? TRpcs : Rpc.AddMiddleware<TRpcs, TMiddleware>;
26
25
  export type ModuleContract<TName extends string, TOperations extends readonly (QueryShape | CommandShape)[], TMiddleware extends RpcMiddleware.AnyService = never, TSubject extends SubjectDeclaration | undefined = undefined, TScope extends "session" | undefined = undefined> = Contract<TName, QueriesOf<TOperations>, CommandsOf<TOperations>, WithMiddleware<WithSubject<Served<OperationRpc<TName, TOperations[number]> | Rpc.AddMiddleware<ReturnType<typeof changesRpc<TName, QueriesOf<TOperations>>>, typeof ReadPolicyGuard>>, TSubject>, TMiddleware>, readonly [], TScope>;
27
- export type Module<TName extends string, TOperations extends readonly ModuleOperation[], TRequirements extends RequirementRecord, TMiddleware extends RpcMiddleware.AnyService = never, TSubject extends SubjectDeclaration | undefined = undefined, TScope extends "session" | undefined = undefined> = ModuleContract<TName, TOperations, TMiddleware, TSubject, TScope> & {
26
+ export type Module<TName extends string, TOperations extends readonly ModuleOperation[], TRequirements extends ModuleServices, TMiddleware extends RpcMiddleware.AnyService = never, TSubject extends SubjectDeclaration | undefined = undefined, TScope extends "session" | undefined = undefined> = ModuleContract<TName, TOperations, TMiddleware, TSubject, TScope> & {
28
27
  readonly "~requires": TRequirements;
29
28
  };
30
- export interface ModuleDefinition<TName extends string, TOperations extends readonly ModuleOperation[], TRequirements extends RequirementRecord, TMiddleware extends RpcMiddleware.AnyService, TSubject extends SubjectDeclaration | undefined, TScope extends "session" | undefined, TWire extends Wire> {
29
+ export interface ModuleDefinition<TName extends string, TOperations extends readonly ModuleOperation[], TMiddleware extends RpcMiddleware.AnyService, TSubject extends SubjectDeclaration | undefined, TScope extends "session" | undefined, TWire extends Wire> {
31
30
  readonly keyScope?: TScope;
32
31
  readonly middleware?: TMiddleware;
33
- readonly name: TName & NoInfer<NameProof<TOperations, TWire, Allowed<TRequirements, TMiddleware, TSubject>>>;
32
+ readonly name: TName & NoInfer<NameProof<TOperations, TWire>>;
34
33
  readonly operations: TOperations;
35
- readonly requires: TRequirements;
36
34
  readonly subject?: TSubject;
37
35
  readonly wire: TWire;
38
36
  }
39
- export declare function defineModule<const TName extends string, const TOperations extends readonly ModuleOperation[], const TRequirements extends RequirementRecord, const TWire extends Wire, TMiddleware extends RpcMiddleware.AnyService = never, const TSubject extends SubjectDeclaration | undefined = undefined, const TScope extends "session" | undefined = undefined>(definition: ModuleDefinition<TName, TOperations, TRequirements, TMiddleware, TSubject, TScope, TWire>): Module<TName, WiredAll<TOperations, TWire> & readonly ModuleOperation[], TRequirements, TMiddleware, TSubject, TScope>;
37
+ export declare function defineModule<const TName extends string, const TOperations extends readonly ModuleOperation[], const TWire extends Wire, TMiddleware extends RpcMiddleware.AnyService = never, const TSubject extends SubjectDeclaration | undefined = undefined, const TScope extends "session" | undefined = undefined>(definition: ModuleDefinition<TName, TOperations, TMiddleware, TSubject, TScope, TWire>): Module<TName, WiredAll<TOperations, TWire> & readonly ModuleOperation[], ModuleRequirements<TOperations, TMiddleware, TSubject>, TMiddleware, TSubject, TScope>;
40
38
  export {};
41
39
  //# sourceMappingURL=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,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AAC9F,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { RpcClientError } from "effect/rpc/RpcClientError";
2
+ import { type RequestRejection, type ServerFailure } from "@shivaedev/errors/taxonomy.ts";
3
+ import { MissingReadPolicies, MissingReadPolicy, QueryReadDenied } from "#readPolicyErrors.ts";
4
+ import { WebSocketRequired } from "#WebSocketRequired.ts";
5
+ export type FrameworkFailure = ServerFailure | RpcClientError | MissingReadPolicy | MissingReadPolicies | QueryReadDenied | WebSocketRequired;
6
+ export type AppRejection<E> = Exclude<E, RequestRejection | FrameworkFailure>;
7
+ export type FailureKind = "app" | "framework" | "request";
8
+ export declare function isFrameworkFailure(value: unknown): value is FrameworkFailure;
9
+ export declare function failureKind(error: unknown): FailureKind;
10
+ //# sourceMappingURL=failureKind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failureKind.d.ts","sourceRoot":"","sources":["../src/failureKind.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAuC,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC/H,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG1D,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,cAAc,GAAG,iBAAiB,GAAG,mBAAmB,GAAG,eAAe,GAAG,iBAAiB,CAAC;AAI9I,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,CAAC,CAAC;AAE9E,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,WAAW,GAAG,SAAS,CAAC;AAE1D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAS5E;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAMvD"}
@@ -0,0 +1,20 @@
1
+ import { Predicate } from "effect";
2
+ import { isRequestRejection, isServerFailure } from "@shivaedev/errors/taxonomy.ts";
3
+ import { MissingReadPolicies, MissingReadPolicy, QueryReadDenied } from "#readPolicyErrors.ts";
4
+ import { WebSocketRequired } from "#WebSocketRequired.ts";
5
+ export function isFrameworkFailure(value) {
6
+ return (isServerFailure(value)
7
+ || Predicate.isTagged(value, "RpcClientError")
8
+ || value instanceof MissingReadPolicy
9
+ || value instanceof MissingReadPolicies
10
+ || value instanceof QueryReadDenied
11
+ || value instanceof WebSocketRequired);
12
+ }
13
+ export function failureKind(error) {
14
+ if (isRequestRejection(error)) {
15
+ return "request";
16
+ }
17
+ const tagged = Predicate.hasProperty(error, "_tag") && Predicate.isString(error._tag);
18
+ return tagged && !isFrameworkFailure(error) ? "app" : "framework";
19
+ }
20
+ //# sourceMappingURL=failureKind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failureKind.js","sourceRoot":"","sources":["../src/failureKind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAA6C,MAAM,+BAA+B,CAAC;AAC/H,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAW1D,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAChD,OAAO,CACN,eAAe,CAAC,KAAK,CAAC;WACnB,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;WAC3C,KAAK,YAAY,iBAAiB;WAClC,KAAK,YAAY,mBAAmB;WACpC,KAAK,YAAY,eAAe;WAChC,KAAK,YAAY,iBAAiB,CACrC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAc;IACzC,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACtF,OAAO,MAAM,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC;AACnE,CAAC"}
@@ -1,15 +1,15 @@
1
1
  import type { Layer } from "effect";
2
2
  import type { Rpc, RpcGroup } from "effect/rpc";
3
- import type { RequirementRecord, RequirementsOf } from "@shivaedev/service/ServiceRequirements.ts";
4
3
  import type { Declared } from "#contract.ts";
4
+ import type { ModuleServices } from "#moduleProof.ts";
5
5
  import type { CommandShape, QueryShape, StreamShape } from "#operation.ts";
6
6
  export interface AnyModule {
7
- readonly "~requires": RequirementRecord;
7
+ readonly "~requires": ModuleServices;
8
8
  readonly application: {
9
9
  readonly requests: ReadonlyMap<string, Rpc.Any>;
10
10
  };
11
11
  readonly declaration: Declared<string, readonly QueryShape[], readonly CommandShape[], readonly StreamShape[], "session" | undefined>;
12
12
  }
13
- export type ModuleHandlers<TModule extends AnyModule> = Layer.Layer<Rpc.ToHandler<RpcGroup.Rpcs<TModule["application"]>>, never, RequirementsOf<TModule["~requires"]>>;
13
+ export type ModuleHandlers<TModule extends AnyModule> = Layer.Layer<Rpc.ToHandler<RpcGroup.Rpcs<TModule["application"]>>, never, TModule["~requires"][keyof TModule["~requires"]]>;
14
14
  export declare function moduleHandlers<TModule extends AnyModule>(module: TModule): ModuleHandlers<TModule>;
15
15
  //# sourceMappingURL=moduleHandlers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"moduleHandlers.d.ts","sourceRoot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D,CAAC"}
1
+ {"version":3,"file":"moduleHandlers.js","sourceRoot":"","sources":["../src/moduleHandlers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAkB7D,MAAM,UAAU,cAAc,CAAC,MAAiB;IAC/C,OAAO,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;AAC/D,CAAC"}
@@ -1,17 +1,11 @@
1
1
  import type { Effect, Schema, Scope } from "effect";
2
2
  import type { RpcMiddleware } from "effect/rpc";
3
- import type { RequirementRecord, RequirementsOf } from "@shivaedev/service/ServiceRequirements.ts";
4
3
  import type { Duplicated } from "#declarationError.ts";
5
4
  import type { OperationShape } from "#operation.ts";
6
5
  import type { Raised } from "#runProof.ts";
7
6
  import type { SubjectDeclaration, SubjectProvides } from "#subject.ts";
8
7
  import type { WireEntry, WireEntryOf } from "#wire.ts";
9
8
  import type { RejectionsDiffer, SuccessDiffers } from "#wireProof.ts";
10
- export interface OperationNeedsUndeclaredServices<TOperation extends string, TMissing> {
11
- readonly missingServices: TMissing;
12
- readonly operation: TOperation;
13
- readonly problem: "run or readPolicy uses services that the module's requires and middleware do not provide";
14
- }
15
9
  type Regenerate = "the generated file is stale; run pnpm generate";
16
10
  export interface WireSuccessStale<TOperation extends string, TFix extends Regenerate, TRun, TWire> {
17
11
  readonly fix: TFix;
@@ -50,15 +44,19 @@ type Tags<E> = E extends {
50
44
  type NameOf<TOperation> = TOperation extends {
51
45
  readonly name: infer TName extends string;
52
46
  } ? TName : string;
53
- type Missing<TOperation, TAllowed> = Exclude<Effect.Services<Parts<TOperation>>, TAllowed | Scope.Scope>;
54
47
  type WireProblem<TOperation, TEntry extends WireEntry> = [SuccessDiffers<TEntry["success"], Returns<TOperation>>] extends [never] ? [RejectionsDiffer<TEntry["rejections"], Effect.Error<Parts<TOperation>>>] extends [never] ? never : WireRejectionsStale<NameOf<TOperation>, Regenerate, Tags<Raised<Effect.Error<Parts<TOperation>>>>, keyof TEntry["rejections"]> : WireSuccessStale<NameOf<TOperation>, Regenerate, Returns<TOperation>, TEntry["success"]["Type"]>;
55
48
  type EntryProblem<TOperation> = [SuccessDiffers<Schema.Void, Returns<TOperation>> | Raised<Effect.Error<Parts<TOperation>>>] extends [never] ? never : OperationMissingFromWire<NameOf<TOperation>, Regenerate>;
56
- type OperationProblem<TOperation, TWire, TAllowed> = [Missing<TOperation, TAllowed>] extends [never] ? WireEntryOf<TWire, NameOf<TOperation>> extends infer TEntry extends WireEntry ? WireProblem<TOperation, TEntry> : EntryProblem<TOperation> : OperationNeedsUndeclaredServices<NameOf<TOperation>, Missing<TOperation, TAllowed>>;
49
+ type OperationProblem<TOperation, TWire> = WireEntryOf<TWire, NameOf<TOperation>> extends infer TEntry extends WireEntry ? WireProblem<TOperation, TEntry> : EntryProblem<TOperation>;
57
50
  type SubjectServices<TSubject> = TSubject extends SubjectDeclaration ? SubjectProvides<TSubject> : never;
58
- export type Allowed<TRequirements extends RequirementRecord, TMiddleware extends RpcMiddleware.AnyService, TSubject> = RequirementsOf<TRequirements> | RpcMiddleware.Provides<TMiddleware["Identifier"]> | SubjectServices<TSubject>;
59
- type Problems<TOperations extends readonly OperationShape[], TWire, TAllowed> = {
60
- readonly [TIndex in keyof TOperations]: OperationProblem<TOperations[TIndex], TWire, TAllowed>;
51
+ export type ModuleServices = {
52
+ readonly [TOperation in string]: unknown;
53
+ };
54
+ export type ModuleRequirements<TOperations extends readonly OperationShape[], TMiddleware extends RpcMiddleware.AnyService, TSubject> = {
55
+ readonly [TOperation in TOperations[number] as NameOf<TOperation>]: Exclude<Effect.Services<Parts<TOperation>>, RpcMiddleware.Provides<TMiddleware["Identifier"]> | SubjectServices<TSubject> | Scope.Scope>;
56
+ };
57
+ type Problems<TOperations extends readonly OperationShape[], TWire> = {
58
+ readonly [TIndex in keyof TOperations]: OperationProblem<TOperations[TIndex], TWire>;
61
59
  }[number] | (Duplicated<TOperations> extends infer TName extends string ? (TName extends string ? OperationNameRepeated<TName> : never) : never);
62
- export type NameProof<TOperations extends readonly OperationShape[], TWire, TAllowed> = string extends keyof TWire ? unknown : [Problems<TOperations, TWire, TAllowed>] extends [never] ? unknown : Problems<TOperations, TWire, TAllowed>;
60
+ export type NameProof<TOperations extends readonly OperationShape[], TWire> = string extends keyof TWire ? unknown : [Problems<TOperations, TWire>] extends [never] ? unknown : Problems<TOperations, TWire>;
63
61
  export {};
64
62
  //# sourceMappingURL=moduleProof.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"moduleProof.d.ts","sourceRoot":"","sources":["../src/moduleProof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AACnG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEtE,MAAM,WAAW,gCAAgC,CAAC,UAAU,SAAS,MAAM,EAAE,QAAQ;IACpF,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,0FAA0F,CAAC;CAC7G;AAED,KAAK,UAAU,GAAG,gDAAgD,CAAC;AAEnE,MAAM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AAa,CAAC,QAAQ,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,GAAG,eAAe,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,KAAK,CAC3F;CACD,CAAC;AAEF,KAAK,QAAQ,CAAC,WAAW,SAAS,SAAS,cAAc,EAAE,EAAE,KAAK,IAC/D;IAAE,QAAQ,EAAE,MAAM,IAAI,MAAM,WAAW,GAAG,gBAAgB,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC;CAAE,CAAC,MAAM,CAAC,GAChG,CAAC,UAAU,CAAC,WAAW,CAAC,SAAS,MAAM,KAAK,SAAS,MAAM,GAAG,CAAC,KAAK,SAAS,MAAM,GAAG,qBAAqB,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;AAKxI,MAAM,MAAM,SAAS,CAAC,WAAW,SAAS,SAAS,cAAc,EAAE,EAAE,KAAK,IAAI,MAAM,SAAS,MAAM,KAAK,GACrG,OAAO,GACP,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAC7C,OAAO,GACP,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/contract",
3
- "version": "0.49.0",
3
+ "version": "0.50.0",
4
4
  "description": "Typed query and command contracts over native Effect RPC and reactivity",
5
5
  "keywords": [
6
6
  "effect"
@@ -44,20 +44,20 @@
44
44
  ],
45
45
  "dependencies": {
46
46
  "@shivaedev/changes": "0.14.1",
47
- "@shivaedev/errors": "0.13.1",
47
+ "@shivaedev/errors": "0.14.0",
48
48
  "@shivaedev/service": "0.9.2",
49
49
  "@shivaedev/types": "0.4.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@effect/platform-node": "4.1.4",
53
53
  "@effect/vitest": "4.1.4",
54
- "@shivaedev/identity": "0.34.0",
55
- "@shivaedev/quality": "0.78.5",
56
- "@shivaedev/server": "0.37.0",
57
- "@shivaedev/sql": "0.51.0",
58
- "@shivaedev/test-kits": "0.13.4",
59
- "@shivaedev/test-sql": "0.25.4",
60
- "@shivaedev/test-story": "0.49.0",
54
+ "@shivaedev/identity": "0.34.1",
55
+ "@shivaedev/quality": "0.78.6",
56
+ "@shivaedev/server": "0.38.0",
57
+ "@shivaedev/sql": "0.52.0",
58
+ "@shivaedev/test-kits": "0.13.5",
59
+ "@shivaedev/test-sql": "0.25.5",
60
+ "@shivaedev/test-story": "0.49.1",
61
61
  "@types/node": "24.19.2",
62
62
  "effect": "4.1.4",
63
63
  "happy-dom": "21.0.4",
package/src/bind.ts CHANGED
@@ -35,20 +35,26 @@ export interface QueryOptions extends RunOptions {
35
35
  readonly serializationKey?: string;
36
36
  }
37
37
 
38
- // `runtime.fn(api.save.run)` and `useAction(runtime, api.save.run)` call `run` with the atom's function context second, which selects no subject.
38
+ // `runtime.fn(api.save.run)` and the React action hooks call `run` with the atom's function context second, which selects no subject.
39
39
  type Run<TPayload, TResult> = (payload: TPayload, options?: RunOptions | Atom.FnContext) => TResult;
40
40
 
41
+ type DeclaredPayload<R> = R extends { readonly payloadSchema: infer TPayload } ? TPayload : never;
42
+
41
43
  export interface BoundQuery<R, TSelf, TSubscription = never> {
42
44
  readonly query: (payload: Rpc.Payload<R>, options?: QueryOptions) => Atom.Atom<AsyncResult.AsyncResult<Rpc.Success<R>, Failure<R | TSubscription>>>;
43
45
  readonly run: Run<Rpc.Payload<R>, Effect.Effect<Rpc.Success<R>, RunFailure<R>, TSelf>>;
46
+ readonly runtime: Atom.AtomRuntime<TSelf>;
44
47
  }
45
48
 
46
49
  export interface BoundCommand<R, TSelf> {
50
+ readonly payload: DeclaredPayload<R>;
47
51
  readonly run: Run<Rpc.Payload<R>, Effect.Effect<Rpc.Success<R>, RunFailure<R>, TSelf | Reactivity.Reactivity>>;
52
+ readonly runtime: Atom.AtomRuntime<TSelf>;
48
53
  }
49
54
 
50
55
  export interface BoundStream<R, TSelf> {
51
56
  readonly run: Run<Rpc.Payload<R>, Stream.Stream<Rpc.SuccessChunk<R>, RunFailure<R>, TSelf | Rpc.ServicesClient<R>>>;
57
+ readonly runtime: Atom.AtomRuntime<TSelf>;
52
58
  }
53
59
 
54
60
  export type Bound<
@@ -135,14 +141,8 @@ export function makeClient(
135
141
  const connection = rpcClient(contract.declaration.name, options.group ?? contract, options);
136
142
  const bindingOptions: BindOptions = options;
137
143
  const owner = bindingOwner(contract.declaration.keyScope, bindingOptions.registry);
138
- const automatic = automaticLive(
139
- connection.Client,
140
- contract.declaration.name,
141
- owner,
142
- bindingOptions.resume,
143
- bindingOptions.live,
144
- bindingOptions.resumeWindow,
145
- );
144
+ const { live, resume, resumeWindow } = bindingOptions;
145
+ const automatic = automaticLive(connection.Client, contract.declaration.name, owner, resume, live, resumeWindow);
146
146
  const operations = clientOperations(connection.Client, automatic, owner);
147
147
  const api = bindOperations(contract.declaration, operations, automatic.subscription);
148
148
  return Object.assign(connection, { api, sync: operations.sync });
@@ -78,6 +78,7 @@ export function clientOperations(
78
78
  },
79
79
  run: (payload: unknown, options?: RunOptions | Atom.FnContext) =>
80
80
  run(ordinaryClient.use((client) => client(tag, payload, { headers: withSubject(undefined, runSubject(options)) }))),
81
+ runtime: ordinaryClient.runtime,
81
82
  };
82
83
  }
83
84
 
@@ -101,8 +102,10 @@ export function clientOperations(
101
102
  );
102
103
  }
103
104
  return {
105
+ payload: command.payload,
104
106
  run: (payload: unknown, options?: RunOptions | Atom.FnContext) =>
105
107
  Effect.flatMap(observed, (observer) => run(send(observer, payload, runSubject(options)))),
108
+ runtime: ordinaryClient.runtime,
106
109
  };
107
110
  }
108
111
 
@@ -128,6 +131,7 @@ export function clientOperations(
128
131
  { bufferSize: 1 },
129
132
  );
130
133
  },
134
+ runtime: streaming.runtime,
131
135
  };
132
136
  }
133
137
 
@@ -1,8 +1,7 @@
1
1
  import { Context, type Effect } from "effect";
2
2
  import type { Rpc, RpcMiddleware } from "effect/rpc";
3
- import type { RequirementRecord } from "@shivaedev/service/ServiceRequirements.ts";
4
3
  import { type Contract, declaredGroup } from "#contract.ts";
5
- import type { Allowed, NameProof } from "#moduleProof.ts";
4
+ import type { ModuleRequirements, ModuleServices, NameProof } from "#moduleProof.ts";
6
5
  import type { CommandShape, QueryShape } from "#operation.ts";
7
6
  import type { OperationRpc } from "#operationRpc.ts";
8
7
  import type { ReadPolicyGuard } from "#ReadPolicyGuard.ts";
@@ -54,19 +53,18 @@ export type ModuleContract<
54
53
  export type Module<
55
54
  TName extends string,
56
55
  TOperations extends readonly ModuleOperation[],
57
- TRequirements extends RequirementRecord,
56
+ TRequirements extends ModuleServices,
58
57
  TMiddleware extends RpcMiddleware.AnyService = never,
59
58
  TSubject extends SubjectDeclaration | undefined = undefined,
60
59
  TScope extends "session" | undefined = undefined,
61
60
  > = ModuleContract<TName, TOperations, TMiddleware, TSubject, TScope> & {
62
- // The compiler checks the list and nothing reads it at run time, so, like Rpc's ~requires, it exists only in the type.
61
+ // The services each operation needs, inferred from its run and read policy. Like Rpc's ~requires, it exists only in the type.
63
62
  readonly "~requires": TRequirements;
64
63
  };
65
64
 
66
65
  export interface ModuleDefinition<
67
66
  TName extends string,
68
67
  TOperations extends readonly ModuleOperation[],
69
- TRequirements extends RequirementRecord,
70
68
  TMiddleware extends RpcMiddleware.AnyService,
71
69
  TSubject extends SubjectDeclaration | undefined,
72
70
  TScope extends "session" | undefined,
@@ -74,9 +72,8 @@ export interface ModuleDefinition<
74
72
  > {
75
73
  readonly keyScope?: TScope;
76
74
  readonly middleware?: TMiddleware;
77
- readonly name: TName & NoInfer<NameProof<TOperations, TWire, Allowed<TRequirements, TMiddleware, TSubject>>>;
75
+ readonly name: TName & NoInfer<NameProof<TOperations, TWire>>;
78
76
  readonly operations: TOperations;
79
- readonly requires: TRequirements;
80
77
  readonly subject?: TSubject;
81
78
  readonly wire: TWire;
82
79
  }
@@ -84,14 +81,20 @@ export interface ModuleDefinition<
84
81
  export function defineModule<
85
82
  const TName extends string,
86
83
  const TOperations extends readonly ModuleOperation[],
87
- const TRequirements extends RequirementRecord,
88
84
  const TWire extends Wire,
89
85
  TMiddleware extends RpcMiddleware.AnyService = never,
90
86
  const TSubject extends SubjectDeclaration | undefined = undefined,
91
87
  const TScope extends "session" | undefined = undefined,
92
88
  >(
93
- definition: ModuleDefinition<TName, TOperations, TRequirements, TMiddleware, TSubject, TScope, TWire>,
94
- ): Module<TName, WiredAll<TOperations, TWire> & readonly ModuleOperation[], TRequirements, TMiddleware, TSubject, TScope>;
89
+ definition: ModuleDefinition<TName, TOperations, TMiddleware, TSubject, TScope, TWire>,
90
+ ): Module<
91
+ TName,
92
+ WiredAll<TOperations, TWire> & readonly ModuleOperation[],
93
+ ModuleRequirements<TOperations, TMiddleware, TSubject>,
94
+ TMiddleware,
95
+ TSubject,
96
+ TScope
97
+ >;
95
98
  export function defineModule(definition: {
96
99
  readonly keyScope?: "session";
97
100
  readonly middleware?: RpcMiddleware.AnyService;
@@ -0,0 +1,33 @@
1
+ import { Predicate } from "effect";
2
+ import type { RpcClientError } from "effect/rpc/RpcClientError";
3
+ import { isRequestRejection, isServerFailure, type RequestRejection, type ServerFailure } from "@shivaedev/errors/taxonomy.ts";
4
+ import { MissingReadPolicies, MissingReadPolicy, QueryReadDenied } from "#readPolicyErrors.ts";
5
+ import { WebSocketRequired } from "#WebSocketRequired.ts";
6
+
7
+ // The transport, the server's own failures and the contract's middleware fail every operation alike; no screen chose them.
8
+ export type FrameworkFailure = ServerFailure | RpcClientError | MissingReadPolicy | MissingReadPolicies | QueryReadDenied | WebSocketRequired;
9
+
10
+ // What remains of an operation's failure once the shared request rejections and the framework's failures are taken out: the rejections its
11
+ // feature declared for itself.
12
+ export type AppRejection<E> = Exclude<E, RequestRejection | FrameworkFailure>;
13
+
14
+ export type FailureKind = "app" | "framework" | "request";
15
+
16
+ export function isFrameworkFailure(value: unknown): value is FrameworkFailure {
17
+ return (
18
+ isServerFailure(value)
19
+ || Predicate.isTagged(value, "RpcClientError")
20
+ || value instanceof MissingReadPolicy
21
+ || value instanceof MissingReadPolicies
22
+ || value instanceof QueryReadDenied
23
+ || value instanceof WebSocketRequired
24
+ );
25
+ }
26
+
27
+ export function failureKind(error: unknown): FailureKind {
28
+ if (isRequestRejection(error)) {
29
+ return "request";
30
+ }
31
+ const tagged = Predicate.hasProperty(error, "_tag") && Predicate.isString(error._tag);
32
+ return tagged && !isFrameworkFailure(error) ? "app" : "framework";
33
+ }
@@ -1,12 +1,12 @@
1
1
  import type { Layer } from "effect";
2
2
  import type { Rpc, RpcGroup } from "effect/rpc";
3
- import type { RequirementRecord, RequirementsOf } from "@shivaedev/service/ServiceRequirements.ts";
4
3
  import { servedHandlers } from "#adapters/servedHandlers.ts";
5
4
  import type { Declared } from "#contract.ts";
5
+ import type { ModuleServices } from "#moduleProof.ts";
6
6
  import type { CommandShape, QueryShape, StreamShape } from "#operation.ts";
7
7
 
8
8
  export interface AnyModule {
9
- readonly "~requires": RequirementRecord;
9
+ readonly "~requires": ModuleServices;
10
10
  readonly application: { readonly requests: ReadonlyMap<string, Rpc.Any> };
11
11
  readonly declaration: Declared<string, readonly QueryShape[], readonly CommandShape[], readonly StreamShape[], "session" | undefined>;
12
12
  }
@@ -14,7 +14,7 @@ export interface AnyModule {
14
14
  export type ModuleHandlers<TModule extends AnyModule> = Layer.Layer<
15
15
  Rpc.ToHandler<RpcGroup.Rpcs<TModule["application"]>>,
16
16
  never,
17
- RequirementsOf<TModule["~requires"]>
17
+ TModule["~requires"][keyof TModule["~requires"]]
18
18
  >;
19
19
 
20
20
  export function moduleHandlers<TModule extends AnyModule>(module: TModule): ModuleHandlers<TModule>;
@@ -1,6 +1,5 @@
1
1
  import type { Effect, Schema, Scope } from "effect";
2
2
  import type { RpcMiddleware } from "effect/rpc";
3
- import type { RequirementRecord, RequirementsOf } from "@shivaedev/service/ServiceRequirements.ts";
4
3
  import type { Duplicated } from "#declarationError.ts";
5
4
  import type { OperationShape } from "#operation.ts";
6
5
  import type { Raised } from "#runProof.ts";
@@ -8,12 +7,6 @@ import type { SubjectDeclaration, SubjectProvides } from "#subject.ts";
8
7
  import type { WireEntry, WireEntryOf } from "#wire.ts";
9
8
  import type { RejectionsDiffer, SuccessDiffers } from "#wireProof.ts";
10
9
 
11
- export interface OperationNeedsUndeclaredServices<TOperation extends string, TMissing> {
12
- readonly missingServices: TMissing;
13
- readonly operation: TOperation;
14
- readonly problem: "run or readPolicy uses services that the module's requires and middleware do not provide";
15
- }
16
-
17
10
  type Regenerate = "the generated file is stale; run pnpm generate";
18
11
 
19
12
  export interface WireSuccessStale<TOperation extends string, TFix extends Regenerate, TRun, TWire> {
@@ -51,8 +44,6 @@ type Returns<TOperation> = TOperation extends { readonly run: infer TRun extends
51
44
  type Tags<E> = E extends { readonly _tag: infer TTag } ? TTag : E;
52
45
  type NameOf<TOperation> = TOperation extends { readonly name: infer TName extends string } ? TName : string;
53
46
 
54
- type Missing<TOperation, TAllowed> = Exclude<Effect.Services<Parts<TOperation>>, TAllowed | Scope.Scope>;
55
-
56
47
  type WireProblem<TOperation, TEntry extends WireEntry> = [SuccessDiffers<TEntry["success"], Returns<TOperation>>] extends [never]
57
48
  ? [RejectionsDiffer<TEntry["rejections"], Effect.Error<Parts<TOperation>>>] extends [never]
58
49
  ? never
@@ -65,28 +56,29 @@ type EntryProblem<TOperation> = [SuccessDiffers<Schema.Void, Returns<TOperation>
65
56
  ? never
66
57
  : OperationMissingFromWire<NameOf<TOperation>, Regenerate>;
67
58
 
68
- type OperationProblem<TOperation, TWire, TAllowed> = [Missing<TOperation, TAllowed>] extends [never]
69
- ? WireEntryOf<TWire, NameOf<TOperation>> extends infer TEntry extends WireEntry
70
- ? WireProblem<TOperation, TEntry>
71
- : EntryProblem<TOperation>
72
- : OperationNeedsUndeclaredServices<NameOf<TOperation>, Missing<TOperation, TAllowed>>;
59
+ type OperationProblem<TOperation, TWire> =
60
+ WireEntryOf<TWire, NameOf<TOperation>> extends infer TEntry extends WireEntry ? WireProblem<TOperation, TEntry> : EntryProblem<TOperation>;
73
61
 
74
62
  type SubjectServices<TSubject> = TSubject extends SubjectDeclaration ? SubjectProvides<TSubject> : never;
75
63
 
76
- export type Allowed<TRequirements extends RequirementRecord, TMiddleware extends RpcMiddleware.AnyService, TSubject> =
77
- | RequirementsOf<TRequirements>
78
- | RpcMiddleware.Provides<TMiddleware["Identifier"]>
79
- | SubjectServices<TSubject>;
64
+ export type ModuleServices = { readonly [TOperation in string]: unknown };
65
+
66
+ export type ModuleRequirements<TOperations extends readonly OperationShape[], TMiddleware extends RpcMiddleware.AnyService, TSubject> = {
67
+ readonly [TOperation in TOperations[number] as NameOf<TOperation>]: Exclude<
68
+ Effect.Services<Parts<TOperation>>,
69
+ RpcMiddleware.Provides<TMiddleware["Identifier"]> | SubjectServices<TSubject> | Scope.Scope
70
+ >;
71
+ };
80
72
 
81
- type Problems<TOperations extends readonly OperationShape[], TWire, TAllowed> =
82
- | { readonly [TIndex in keyof TOperations]: OperationProblem<TOperations[TIndex], TWire, TAllowed> }[number]
73
+ type Problems<TOperations extends readonly OperationShape[], TWire> =
74
+ | { readonly [TIndex in keyof TOperations]: OperationProblem<TOperations[TIndex], TWire> }[number]
83
75
  | (Duplicated<TOperations> extends infer TName extends string ? (TName extends string ? OperationNameRepeated<TName> : never) : never);
84
76
 
85
77
  // The proof sits on the module's name, so the first line of the compiler's message names the operation and its problem.
86
78
  // A definition without a wire leaves TWire at its constraint, whose index signature has every name; proving nothing then
87
79
  // lets the compiler's own error say that wire is missing.
88
- export type NameProof<TOperations extends readonly OperationShape[], TWire, TAllowed> = string extends keyof TWire
80
+ export type NameProof<TOperations extends readonly OperationShape[], TWire> = string extends keyof TWire
89
81
  ? unknown
90
- : [Problems<TOperations, TWire, TAllowed>] extends [never]
82
+ : [Problems<TOperations, TWire>] extends [never]
91
83
  ? unknown
92
- : Problems<TOperations, TWire, TAllowed>;
84
+ : Problems<TOperations, TWire>;