@rotorsoft/act-http 1.11.2 → 1.12.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.
Files changed (41) hide show
  1. package/README.md +2 -5
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/@types/api/actor.d.ts +4 -6
  4. package/dist/@types/api/actor.d.ts.map +1 -1
  5. package/dist/@types/api/dispatch.d.ts +46 -1
  6. package/dist/@types/api/dispatch.d.ts.map +1 -1
  7. package/dist/@types/api/sse-wiring.d.ts +2 -2
  8. package/dist/@types/api/sse-wiring.d.ts.map +1 -1
  9. package/dist/@types/hono/index.d.ts +80 -13
  10. package/dist/@types/hono/index.d.ts.map +1 -1
  11. package/dist/@types/openapi/index.d.ts.map +1 -1
  12. package/dist/@types/sse/broadcast.d.ts +4 -2
  13. package/dist/@types/sse/broadcast.d.ts.map +1 -1
  14. package/dist/@types/trpc/index.d.ts +107 -35
  15. package/dist/@types/trpc/index.d.ts.map +1 -1
  16. package/dist/api/index.cjs +1 -3
  17. package/dist/api/index.cjs.map +1 -1
  18. package/dist/api/index.js +1 -1
  19. package/dist/{chunk-QM6YP2XH.js → chunk-QSH2Y3YR.js} +2 -2
  20. package/dist/chunk-QSH2Y3YR.js.map +1 -0
  21. package/dist/{chunk-75DA7NJI.js → chunk-YEDAY2PC.js} +2 -4
  22. package/dist/chunk-YEDAY2PC.js.map +1 -0
  23. package/dist/hono/index.cjs +1 -3
  24. package/dist/hono/index.cjs.map +1 -1
  25. package/dist/hono/index.js +2 -2
  26. package/dist/hono/index.js.map +1 -1
  27. package/dist/openapi/index.cjs +102 -34
  28. package/dist/openapi/index.cjs.map +1 -1
  29. package/dist/openapi/index.js +103 -35
  30. package/dist/openapi/index.js.map +1 -1
  31. package/dist/sse/index.cjs +2 -1
  32. package/dist/sse/index.cjs.map +1 -1
  33. package/dist/sse/index.js +2 -1
  34. package/dist/sse/index.js.map +1 -1
  35. package/dist/trpc/index.cjs +2 -8
  36. package/dist/trpc/index.cjs.map +1 -1
  37. package/dist/trpc/index.js +3 -7
  38. package/dist/trpc/index.js.map +1 -1
  39. package/package.json +2 -2
  40. package/dist/chunk-75DA7NJI.js.map +0 -1
  41. package/dist/chunk-QM6YP2XH.js.map +0 -1
@@ -6,15 +6,13 @@ import type { Actor } from "@rotorsoft/act";
6
6
  * for this single closure that every transport (tRPC, Hono, OpenAPI
7
7
  * docs) composes against.
8
8
  *
9
- * The `request` argument is intentionally generic. Each transport
10
- * narrows it at the call site (`IncomingMessage` for Hono, the tRPC
11
- * context object for tRPC, etc.) — keeping the contract here
12
- * transport-agnostic means one extractor implementation plugs into
13
- * every adapter unchanged.
9
+ * Each transport types `request` as what it hands over: the Hono
10
+ * `Context`, or the host's tRPC context. An extractor that takes
11
+ * `unknown` still plugs into every transport unchanged.
14
12
  *
15
13
  * Async is allowed so the extractor can verify a JWT against a
16
14
  * remote JWKS endpoint without forcing every host to synchronously
17
15
  * cache.
18
16
  */
19
- export type ActorExtractor = (request: unknown) => Actor | Promise<Actor>;
17
+ export type ActorExtractor<TRequest = unknown> = (request: TRequest) => Actor | Promise<Actor>;
20
18
  //# sourceMappingURL=actor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"actor.d.ts","sourceRoot":"","sources":["../../../src/api/actor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"actor.d.ts","sourceRoot":"","sources":["../../../src/api/actor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,cAAc,CAAC,QAAQ,GAAG,OAAO,IAAI,CAC/C,OAAO,EAAE,QAAQ,KACd,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC"}
@@ -1,5 +1,6 @@
1
- import type { Actor, Target } from "@rotorsoft/act";
1
+ import type { Act, Actor, Registry, Schema, Schemas, Snapshot, Target } from "@rotorsoft/act";
2
2
  import type { IdempotencyStore } from "@rotorsoft/act-ops/idempotency";
3
+ import type { ZodType } from "zod";
3
4
  /**
4
5
  * The Act surface the generated transports walk: the registry's action
5
6
  * name → owning-state map and `do(...)`. A structural bound lets `TApp`
@@ -11,10 +12,54 @@ export type ActSurface = {
11
12
  actions: Record<string, {
12
13
  readonly name: string;
13
14
  readonly actions: Record<string, unknown>;
15
+ /** The state's schema and its events', which the OpenAPI doc describes responses with. */
16
+ readonly state?: ZodType;
17
+ readonly events?: Readonly<Record<string, ZodType>>;
14
18
  }>;
15
19
  };
16
20
  do(action: string, target: Target, payload: unknown): Promise<unknown>;
17
21
  };
22
+ /**
23
+ * The registry types of a built app, read back so a generated API keeps
24
+ * them: each action's payload, the state it leaves, the events, and the
25
+ * state names. A bare {@link ActSurface} has none, so its actions take and
26
+ * return `unknown`.
27
+ */
28
+ type AppRegistry<TApp> = TApp extends {
29
+ readonly registry: Registry<infer S, infer E, infer A, infer N>;
30
+ } ? {
31
+ states: S;
32
+ events: E;
33
+ actions: A;
34
+ names: N;
35
+ } : {
36
+ states: Record<string, Schema>;
37
+ events: Schemas;
38
+ actions: Record<string, unknown>;
39
+ names: string;
40
+ };
41
+ /** The payload each action of `TApp` takes, by action name. */
42
+ export type AppActions<TApp> = AppRegistry<TApp>["actions"];
43
+ /** The state names of `TApp`. */
44
+ export type AppStateNames<TApp> = AppRegistry<TApp>["names"];
45
+ /** The state named `N` in `TApp`, as the SSE channel carries it. */
46
+ export type AppState<TApp, N> = (TApp extends Act<any, any, any, infer M, any> ? N extends keyof M ? M[N] : Schema : Schema) & {
47
+ _v: number;
48
+ };
49
+ /** What `app.do` returns for action `K` of `TApp`. */
50
+ export type ActionResult<TApp, K> = Snapshot<K extends keyof AppRegistry<TApp>["states"] ? AppRegistry<TApp>["states"][K] : Schema, AppRegistry<TApp>["events"]>[];
51
+ /**
52
+ * What a `stream` or `expectedVersion` resolver receives: the action's
53
+ * name, its parsed payload and the transport's context, as one tuple per
54
+ * action, so checking the name narrows the payload.
55
+ */
56
+ export type ResolverArgs<TApp, C> = {
57
+ [K in keyof AppActions<TApp> & string]: [
58
+ action_name: K,
59
+ input: AppActions<TApp>[K],
60
+ ctx: C
61
+ ];
62
+ }[keyof AppActions<TApp> & string];
18
63
  /** The target resolvers a generated transport takes, over its own context. */
19
64
  type TargetResolvers<C> = {
20
65
  readonly stream: (action_name: string, input: unknown, ctx: C) => string | Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../src/api/dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAIvE;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,QAAQ,EAAE;QACjB,OAAO,EAAE,MAAM,CACb,MAAM,EACN;YACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;YACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;SAC3C,CACF,CAAC;KACH,CAAC;IACF,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACxE,CAAC;AAEF,8EAA8E;AAC9E,KAAK,eAAe,CAAC,CAAC,IAAI;IACxB,QAAQ,CAAC,MAAM,EAAE,CACf,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,CAAC,KACH,MAAM,GAAG,OAA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AClB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,GACvB;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;AAEzB;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,GAAG,EAAE,UAAU,EACf,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,EAC7B,KAAK,EAAE,gBAAgB,GAAG,SAAS,iBAKpB,MAAM,SACZ,OAAO,WACL,OAAO,OACX,CAAC,SACC,KAAK,OACP,MAAM,MAAM,GAAG,SAAS,KAC5B,OAAO,CAAC,UAAU,CAAC,CAevB"}
@@ -1,5 +1,5 @@
1
1
  import type { BroadcastChannel } from "../sse/broadcast.js";
2
- import { type BroadcastState } from "../sse/types.js";
2
+ import { type BroadcastState, type PatchMessage } from "../sse/types.js";
3
3
  /**
4
4
  * SSE wiring options shared by the auto-generated `trpc` and `hono`
5
5
  * transports. When supplied, each transport emits one streaming
@@ -165,7 +165,7 @@ export type SseSubscriptionFrame<S> = {
165
165
  readonly data: S;
166
166
  } | {
167
167
  readonly kind: "patch";
168
- readonly data: unknown;
168
+ readonly data: S extends BroadcastState ? PatchMessage<S> : unknown;
169
169
  };
170
170
  /**
171
171
  * Subscription accounting hook. Implementations have a chance to
@@ -1 +1 @@
1
- {"version":3,"file":"sse-wiring.d.ts","sourceRoot":"","sources":["../../../src/api/sse-wiring.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EACL,KAAK,cAAc,EAIpB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;;;;OAKG;IAEH,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,GAAG,CA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oBAAoB,CAAC,CAAC,IAC9B;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAC5C;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,CAAC,SAAS,cAAc,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;CACrE,CAAC;AAEN;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,IAAI,OAAO,CAAC;IACnB,OAAO,IAAI,IAAI,CAAC;CACjB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,KAAK,CAAC;IACvC;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF;;;;;;;;;;GAUG;AAEH,wBAAuB,kBAAkB,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,GAAG,EACtE,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAC5B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,aAAa,GAAG,SAAS,EACrC,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,OAAO,CAAC,EAAE,aAAa,GACtB,cAAc,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CA2EzC"}
@@ -2,8 +2,10 @@ import type { Actor } from "@rotorsoft/act";
2
2
  import type { IdempotencyStore } from "@rotorsoft/act-ops/idempotency";
3
3
  import type { Context, MiddlewareHandler } from "hono";
4
4
  import { Hono } from "hono";
5
- import { type ActSurface } from "../api/dispatch.js";
6
- import { type ActorExtractor, type SseOptions } from "../api/index.js";
5
+ import type { MergePath, TypedResponse } from "hono/types";
6
+ import type { JSONParsed } from "hono/utils/types";
7
+ import { type ActionResult, type ActSurface, type AppActions, type AppStateNames, type ResolverArgs } from "../api/dispatch.js";
8
+ import { type ActorExtractor, type ApiError, type SseOptions } from "../api/index.js";
7
9
  /**
8
10
  * Hono context variables this subpath contributes. The generic on
9
11
  * the returned middleware threads it through so routes downstream
@@ -27,8 +29,8 @@ export type ActMiddlewareVariables = {
27
29
  * - `expectedVersion` (optional) — optimistic-concurrency resolver.
28
30
  * Hosts typically read it from an `If-Match` header on the
29
31
  * request, or from the client's last-known snapshot. Returning
30
- * `undefined` skips the check for that call — handy when only
31
- * some actions are concurrency-sensitive.
32
+ * `undefined` leaves the call to the version the action loads; a
33
+ * number pins it, and a pinned conflict is never retried.
32
34
  * - `idempotency` (optional) — when set, the route honors
33
35
  * `Idempotency-Key` via {@link withIdempotency}. The host
34
36
  * supplies the `IdempotencyStore`; `keyFrom` defaults to reading
@@ -42,10 +44,10 @@ export type ActMiddlewareVariables = {
42
44
  * - `basePath` (optional, default `"/api"`) — Hono basePath the
43
45
  * routes mount under.
44
46
  */
45
- export type HonoOptions = {
46
- readonly actor: ActorExtractor;
47
- readonly stream: (action_name: string, input: unknown, c: Context) => string | Promise<string>;
48
- readonly expectedVersion?: (action_name: string, input: unknown, c: Context) => number | undefined | Promise<number | undefined>;
47
+ export type HonoOptions<TApp = ActSurface> = {
48
+ readonly actor: ActorExtractor<Context>;
49
+ readonly stream: (...args: ResolverArgs<TApp, Context>) => string | Promise<string>;
50
+ readonly expectedVersion?: (...args: ResolverArgs<TApp, Context>) => number | undefined | Promise<number | undefined>;
49
51
  readonly idempotency?: {
50
52
  readonly store: IdempotencyStore;
51
53
  readonly keyFrom?: (c: Context) => string | undefined;
@@ -88,11 +90,13 @@ export type HonoOptions = {
88
90
  * ```
89
91
  *
90
92
  * Errors thrown by the extractor surface as `401 Unauthorized` with
91
- * the shared {@link ApiError} envelope.
93
+ * the shared {@link ApiError} envelope. Mounted on a route
94
+ * (`api.get("/me", authenticated(extract), handler)`), the `401` is in
95
+ * the route's type, so `hc` and `testClient` see it.
92
96
  */
93
- export declare function authenticated(extractor: ActorExtractor): MiddlewareHandler<{
97
+ export declare function authenticated(extractor: ActorExtractor<Context>): MiddlewareHandler<{
94
98
  Variables: ActMiddlewareVariables;
95
- }>;
99
+ }, string, {}, Response & TypedResponse<JSONParsed<ApiError>, 401, "json">>;
96
100
  /**
97
101
  * Build a typed Hono REST surface from a built `Act` instance.
98
102
  *
@@ -125,7 +129,70 @@ export declare function authenticated(extractor: ActorExtractor): MiddlewareHand
125
129
  * @returns A Hono app covering every registered action under
126
130
  * `<basePath>/actions/<name>`.
127
131
  */
128
- export declare function hono<TApp extends ActSurface = ActSurface>(app: TApp, options: HonoOptions): Hono<{
132
+ export declare function hono<TApp extends ActSurface = ActSurface, TBase extends string = "/api">(app: TApp, options: HonoOptions<TApp> & {
133
+ readonly basePath?: TBase;
134
+ readonly sse: NonNullable<HonoOptions["sse"]>;
135
+ }): Hono<{
129
136
  Variables: ActMiddlewareVariables;
130
- }>;
137
+ }, ActionRoutes<TApp, TBase> & SseRoutes<TApp, TBase>, TBase>;
138
+ export declare function hono<TApp extends ActSurface = ActSurface, TBase extends string = "/api">(app: TApp, options: HonoOptions<TApp> & {
139
+ readonly basePath?: TBase;
140
+ }): Hono<{
141
+ Variables: ActMiddlewareVariables;
142
+ }, ActionRoutes<TApp, TBase>, TBase>;
143
+ /**
144
+ * One `GET <basePath>/sse/<state>?stream=<id>` per state of `TApp`, with
145
+ * `sse`: an event stream on `200`, {@link ApiError} on an error status.
146
+ */
147
+ export type SseRoutes<TApp, TBase extends string> = {
148
+ [N in AppStateNames<TApp> as MergePath<TBase, `/sse/${N}`>]: {
149
+ $get: {
150
+ input: {
151
+ query: {
152
+ stream: string;
153
+ };
154
+ };
155
+ output: {};
156
+ outputFormat: "body";
157
+ status: 200;
158
+ } | {
159
+ input: {
160
+ query: {
161
+ stream: string;
162
+ };
163
+ };
164
+ output: ApiError;
165
+ outputFormat: "json";
166
+ status: 400 | 401 | 503;
167
+ };
168
+ };
169
+ };
170
+ /** Every status a generated action route answers with the error envelope. */
171
+ type ErrorStatus = 400 | 401 | 409 | 410 | 412 | 422 | 500 | 503;
172
+ /**
173
+ * The routes {@link hono} builds, one `POST <basePath>/actions/<name>` per
174
+ * action of `TApp`: the action's payload as the JSON body, the snapshots
175
+ * `app.do` returns (as JSON) on `200`, and {@link ApiError} on an error
176
+ * status. `hc<typeof api>` and `testClient(api)` read it.
177
+ */
178
+ export type ActionRoutes<TApp, TBase extends string> = {
179
+ [K in keyof AppActions<TApp> & string as MergePath<TBase, `/actions/${K}`>]: {
180
+ $post: {
181
+ input: {
182
+ json: AppActions<TApp>[K];
183
+ };
184
+ output: JSONParsed<ActionResult<TApp, K>>;
185
+ outputFormat: "json";
186
+ status: 200;
187
+ } | {
188
+ input: {
189
+ json: AppActions<TApp>[K];
190
+ };
191
+ output: ApiError;
192
+ outputFormat: "json";
193
+ status: ErrorStatus;
194
+ };
195
+ };
196
+ };
197
+ export {};
131
198
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hono/index.ts"],"names":[],"mappings":"AAiDA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,KAAK,UAAU,EAAiB,MAAM,oBAAoB,CAAC;AACpE,OAAO,EACL,KAAK,cAAc,EAMnB,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AAEzB;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,OAAO,CAAC,IAAI,SAAS,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,EAC/D,GAAG,EAAE,IAAI,EACT,OAAO,EAAE,cAAc,GACtB,eAAe,CA0CjB"}
@@ -1,3 +1,4 @@
1
+ import { type Patch } from "@rotorsoft/act-patch";
1
2
  import { StateCache } from "./state-cache.js";
2
3
  import { type BroadcastState, type PatchMessage, type Subscriber } from "./types.js";
3
4
  /**
@@ -96,9 +97,10 @@ export declare class BroadcastChannel<S extends BroadcastState = BroadcastState>
96
97
  *
97
98
  * @param streamId - The event store stream ID
98
99
  * @param state - Full state with `_v` set from `snap.event.version`
99
- * @param patches - Array of domain patches, one per emitted event
100
+ * @param patches - Array of domain patches, one per emitted event, as the
101
+ * snapshots carry them (`null` deletes a key)
100
102
  */
101
- publish(streamId: string, state: S, patches?: Partial<S>[]): PatchMessage<S>;
103
+ publish(streamId: string, state: S, patches?: Readonly<Patch<S>>[]): PatchMessage<S>;
102
104
  /**
103
105
  * Publish a state update that doesn't change the event version
104
106
  * (e.g. presence overlay, computed field refresh).
@@ -1 +1 @@
1
- {"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../../../src/sse/broadcast.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,YAAY,EAEjB,KAAK,UAAU,EAChB,MAAM,YAAY,CAAC;AA0GpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,gBAAgB,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc;IACrE,OAAO,CAAC,QAAQ,CAAyC;IACzD,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,mBAAmB,CAA6C;IACxE,OAAO,CAAC,eAAe,CAA6B;IAEpD,YAAY,OAAO,CAAC,EAAE;QACpB,sEAAsE;QACtE,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C,KAAK,CAAC,CAAC,CAAC,CAAC,EAAO,GACjC,YAAY,CAAC,CAAC,CAAC,CAkCjB;IAED;;;;OAIG;IACH,OAAO,CACL,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,GACxB,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CA8B7B;IAED;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CASzD;IAED,kDAAkD;IAClD,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAExC;IAED,8EAA8E;IAC9E,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAErC;IAED,4DAA4D;IAC5D,eAAe,CACb,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,GACxB,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAE7B;IAED,oEAAoE;IACpE,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE7C;IAED,0DAA0D;IAC1D,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAEzC;IAED,+EAA+E;IAC/E,IAAI,KAAK,IAAI,UAAU,CAAC,CAAC,CAAC,CAEzB;CACF"}
@@ -1,7 +1,60 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module act-http/trpc
4
+ *
5
+ * tRPC subpath of the auto-generated API. Walks the
6
+ * registry of a built `Act` once at function call and emits a typed
7
+ * router that exposes every registered action as a flat `mutation`,
8
+ * matching the shape hand-written tRPC routers in the Act ecosystem
9
+ * already use.
10
+ *
11
+ * Usage:
12
+ *
13
+ * ```ts
14
+ * import { trpc } from "@rotorsoft/act-http/trpc";
15
+ *
16
+ * type Ctx = { user: { id: string; name: string }; tenant: string };
17
+ *
18
+ * const router = trpc<Ctx, typeof app>(app, {
19
+ * actor: (ctx) => ({ id: ctx.user.id, name: ctx.user.name }),
20
+ * stream: (action, input, ctx) => `tenant-${ctx.tenant}`,
21
+ * });
22
+ *
23
+ * // Client sees:
24
+ * // appRouter.PressKey.mutate({ key: "5" })
25
+ * // appRouter.OpenTicket.mutate({ title: "..." })
26
+ * ```
27
+ *
28
+ * The route shape is flat: one procedure per registered action at
29
+ * the top level. Action names are the unique identifiers across
30
+ * the registry (the framework already enforces no duplicates), so
31
+ * an extra namespace tier would be overhead in the common case.
32
+ * See `libs/act-http/README.md` for the full surface walkthrough.
33
+ *
34
+ * **Actor lives on the context.** The generator wires an internal
35
+ * tRPC middleware that runs the host's
36
+ * {@link TrpcOptions.actor | actor extractor} once per call and
37
+ * injects the resolved {@link Actor} onto the downstream context as
38
+ * `ctx.actor`. Every generated mutation reads from there — auth
39
+ * resolves at the procedure boundary, not inside each action body,
40
+ * and any composed middleware (logging, tracing) sees the same
41
+ * `ctx.actor`. The middleware factory is also exported as
42
+ * {@link authenticated} for hosts that need to compose it into
43
+ * their own procedure chain.
44
+ *
45
+ * Composes the shared utilities at `@rotorsoft/act-http/api`:
46
+ * {@link ActorExtractor} for the auth seam, {@link toApiError} for
47
+ * the uniform error→status/code mapping, {@link withIdempotency}
48
+ * for `Idempotency-Key` dedup. Three transports (this one, Hono,
49
+ * OpenAPI) ride the same utilities so a client talking to two
50
+ * transports never sees two error shapes for the same framework
51
+ * error.
52
+ */
53
+ import { type Actor } from "@rotorsoft/act";
1
54
  import type { IdempotencyStore } from "@rotorsoft/act-ops/idempotency";
2
- import { type AnyTRPCMiddlewareFunction, type AnyTRPCMutationProcedure, type AnyTRPCRootTypes, type TRPCBuiltRouter } from "@trpc/server";
3
- import { type ActSurface } from "../api/dispatch.js";
4
- import { type ActorExtractor, type SseOptions } from "../api/index.js";
55
+ import { type TRPCBuiltRouter, type TRPCDefaultErrorShape, type TRPCMiddlewareFunction, type TRPCMutationProcedure, type TRPCSubscriptionProcedure } from "@trpc/server";
56
+ import { type ActionResult, type ActSurface, type AppActions, type AppState, type AppStateNames, type ResolverArgs } from "../api/dispatch.js";
57
+ import { type ActorExtractor, type SseOptions, type SseSubscriptionFrame } from "../api/index.js";
5
58
  /**
6
59
  * Per-call options for {@link trpc}. The host supplies the three
7
60
  * seams the package can't make decisions on:
@@ -18,9 +71,9 @@ import { type ActorExtractor, type SseOptions } from "../api/index.js";
18
71
  * `target.expectedVersion` so `app.do` refuses to commit if the
19
72
  * stream has moved. Hosts typically read it from an `If-Match`
20
73
  * header on the underlying HTTP request, or pull it from the
21
- * client's last-known snapshot. Returning `undefined` skips the
22
- * check for that call — handy when only some actions are
23
- * concurrency-sensitive.
74
+ * client's last-known snapshot. Returning `undefined` leaves the
75
+ * call to the version the action loads; a number pins it, and a
76
+ * pinned conflict is never retried.
24
77
  * - `idempotency` (optional) — when set, the procedure honors
25
78
  * `Idempotency-Key` via the shared
26
79
  * {@link withIdempotency} helper. The host supplies the
@@ -38,10 +91,10 @@ import { type ActorExtractor, type SseOptions } from "../api/index.js";
38
91
  * procedures see this exact context type (plus `actor`) at
39
92
  * runtime.
40
93
  */
41
- export type TrpcOptions<Ctx> = {
42
- readonly actor: ActorExtractor;
43
- readonly stream: (action_name: string, input: unknown, ctx: Ctx) => string | Promise<string>;
44
- readonly expectedVersion?: (action_name: string, input: unknown, ctx: Ctx) => number | undefined | Promise<number | undefined>;
94
+ export type TrpcOptions<Ctx, TApp = ActSurface> = {
95
+ readonly actor: ActorExtractor<Ctx>;
96
+ readonly stream: (...args: ResolverArgs<TApp, NoInfer<Ctx>>) => string | Promise<string>;
97
+ readonly expectedVersion?: (...args: ResolverArgs<TApp, NoInfer<Ctx>>) => number | undefined | Promise<number | undefined>;
45
98
  readonly idempotency?: {
46
99
  readonly store: IdempotencyStore;
47
100
  readonly keyFrom: (ctx: Ctx) => string | undefined;
@@ -94,25 +147,43 @@ export type TrpcOptions<Ctx> = {
94
147
  * (typically wrap them as `TRPCError({ code: "UNAUTHORIZED" })`
95
148
  * in the extractor body).
96
149
  */
97
- export declare function authenticated(extractor: ActorExtractor): AnyTRPCMiddlewareFunction;
150
+ export declare function authenticated<Ctx extends object = object>(extractor: ActorExtractor<Ctx>): TRPCMiddlewareFunction<Ctx, object, object, {
151
+ actor: Actor;
152
+ }, unknown>;
153
+ /** The root types of the router {@link trpc} builds over `Ctx`. */
154
+ type GeneratedRoot<Ctx extends object> = {
155
+ ctx: Ctx;
156
+ meta: object;
157
+ errorShape: TRPCDefaultErrorShape;
158
+ transformer: false;
159
+ };
98
160
  /**
99
- * Generated router type — one mutation procedure per action name in
100
- * `TApp`'s registry. Mapped over the concrete action keys so
101
- * `createTRPCReact<typeof router>()` sees specific procedure names
102
- * (`PressKey`, `Clear`, …) instead of a wide `Record<string, ...>`
103
- * index signature — which is what trips tRPC React's
104
- * "useContext / Provider / useUtils collides" check on widely-typed
105
- * routers.
106
- *
107
- * @internal
161
+ * One mutation per action of `TApp`: the action's payload in, the
162
+ * snapshots `app.do` returns out. Mapped over the concrete action names,
163
+ * so `createTRPCReact<typeof router>()` sees `PressKey`, `Clear`, …
164
+ * instead of an index signature, which trips tRPC React's collision check.
108
165
  */
109
- type GeneratedRouter<TApp> = TRPCBuiltRouter<AnyTRPCRootTypes, TApp extends {
110
- registry: {
111
- actions: infer TActions;
166
+ type ActionProcedures<TApp> = {
167
+ [K in keyof AppActions<TApp> & string]: TRPCMutationProcedure<{
168
+ input: AppActions<TApp>[K];
169
+ output: ActionResult<TApp, K>;
170
+ meta: object;
171
+ }>;
172
+ };
173
+ /** One subscription per state of `TApp`, yielding that state's frames. */
174
+ type SubscribeRouter<TApp> = {
175
+ subscribe: {
176
+ [N in AppStateNames<TApp>]: TRPCSubscriptionProcedure<{
177
+ input: {
178
+ stream: string;
179
+ };
180
+ output: AsyncIterable<SseSubscriptionFrame<AppState<TApp, N>>, void, any>;
181
+ meta: object;
182
+ }>;
112
183
  };
113
- } ? {
114
- [K in keyof TActions]: AnyTRPCMutationProcedure;
115
- } : Record<string, AnyTRPCMutationProcedure>>;
184
+ };
185
+ /** The router {@link trpc} builds: the actions, and the subscriptions with `sse`. */
186
+ export type GeneratedRouter<Ctx extends object, TApp, TRecord> = TRPCBuiltRouter<GeneratedRoot<Ctx>, ActionProcedures<TApp> & TRecord>;
116
187
  /**
117
188
  * Build a typed tRPC router from a built `Act` instance.
118
189
  *
@@ -133,12 +204,11 @@ type GeneratedRouter<TApp> = TRPCBuiltRouter<AnyTRPCRootTypes, TApp extends {
133
204
  * 5. Maps any thrown framework error onto a `TRPCError` via
134
205
  * {@link toApiError}.
135
206
  *
136
- * The returned router's procedure inputs come straight from each
137
- * action's Zod schema; outputs are the framework's
138
- * `Snapshot<TState, TEvents>[]` shape. Strong typing flows
139
- * end-to-end via tRPC's normal inference path — the client sees
140
- * `appRouter.Calculator.PressKey.mutate({ key: "5" })` as a typed
141
- * call without any codegen.
207
+ * The router is typed from `TApp`: each mutation takes its action's
208
+ * payload and returns the `Snapshot[]` `app.do` returns, and with `sse`
209
+ * each `subscribe.<state>` yields that state's frames, so a client sees
210
+ * `client.PressKey.mutate({ key: "5" })` as a typed call without
211
+ * codegen. Pass `TApp` whenever you pass `Ctx`.
142
212
  *
143
213
  * @template Ctx The tRPC context shape the host's runtime feeds in.
144
214
  * Flows through `actor`, `stream`, and `idempotency.keyFrom` so
@@ -148,9 +218,11 @@ type GeneratedRouter<TApp> = TRPCBuiltRouter<AnyTRPCRootTypes, TApp extends {
148
218
  *
149
219
  * @param app A built `Act` orchestrator.
150
220
  * @param options Auth, stream, and (optional) idempotency seams.
151
- * @returns A tRPC router covering every registered action, grouped
152
- * by owning state.
221
+ * @returns A tRPC router with one mutation per registered action.
153
222
  */
154
- export declare function trpc<Ctx extends object = object, TApp extends ActSurface = ActSurface>(app: TApp, options: TrpcOptions<Ctx>): GeneratedRouter<TApp>;
223
+ export declare function trpc<Ctx extends object = object, TApp extends ActSurface = ActSurface>(app: TApp, options: TrpcOptions<Ctx, TApp> & {
224
+ readonly sse: SseOptions;
225
+ }): GeneratedRouter<Ctx, TApp, SubscribeRouter<TApp>>;
226
+ export declare function trpc<Ctx extends object = object, TApp extends ActSurface = ActSurface>(app: TApp, options: TrpcOptions<Ctx, TApp>): GeneratedRouter<Ctx, TApp, unknown>;
155
227
  export {};
156
228
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/trpc/index.ts"],"names":[],"mappings":"AAwDA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EAErB,KAAK,eAAe,EAErB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,UAAU,EAAiB,MAAM,oBAAoB,CAAC;AACpE,OAAO,EACL,KAAK,cAAc,EAInB,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,MAAM,WAAW,CAAC,GAAG,IAAI;IAC7B,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,CACf,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,GAAG,KACL,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9B,QAAQ,CAAC,eAAe,CAAC,EAAE,CACzB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,GAAG,KACL,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACtD,QAAQ,CAAC,WAAW,CAAC,EAAE;QACrB,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;QACjC,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,GAAG,SAAS,C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AEpC,GAAG,EAAE,IAAI,EACT,OAAO,EAAE,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAA;CAAE,GAC7D,eAAe,CAAC,GAAG,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;AACrD,wBAAgB,IAAI,CAClB,GAAG,SAAS,MAAM,GAAG,MAAM,EAC3B,IAAI,SAAS,UAAU,GAAG,UAAU,EAEpC,GAAG,EAAE,IAAI,EACT,OAAO,EAAE,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,GAC9B,eAAe,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC"}
@@ -19890,9 +19890,7 @@ async function* runSseSubscription(channel, stream_id, accounting, signal, optio
19890
19890
  pending.push(msg);
19891
19891
  return;
19892
19892
  }
19893
- const versioned = pending.findIndex(
19894
- (m) => !is_version_neutral(m)
19895
- );
19893
+ const versioned = pending.findIndex((m) => !is_version_neutral(m));
19896
19894
  if (versioned >= 0) {
19897
19895
  pending.splice(versioned, 1);
19898
19896
  pending.push(msg);