@fuzdev/fuz_app 0.48.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/dist/actions/CLAUDE.md +128 -50
- package/dist/actions/action_codegen.d.ts +196 -37
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +297 -59
- package/dist/actions/action_registry.d.ts +41 -9
- package/dist/actions/action_registry.d.ts.map +1 -1
- package/dist/actions/action_registry.js +109 -32
- package/dist/actions/action_types.d.ts +2 -2
- package/dist/actions/action_types.js +2 -2
- package/dist/actions/cancel.d.ts +13 -11
- package/dist/actions/cancel.d.ts.map +1 -1
- package/dist/actions/cancel.js +13 -11
- package/dist/actions/frontend_rpc_client.d.ts +9 -0
- package/dist/actions/frontend_rpc_client.d.ts.map +1 -1
- package/dist/actions/heartbeat.d.ts +11 -8
- package/dist/actions/heartbeat.d.ts.map +1 -1
- package/dist/actions/heartbeat.js +11 -8
- package/dist/actions/protocol.d.ts +47 -0
- package/dist/actions/protocol.d.ts.map +1 -0
- package/dist/actions/protocol.js +46 -0
- package/dist/actions/register_action_ws.d.ts +4 -3
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +1 -1
- package/dist/auth/account_action_specs.d.ts +1 -1
- package/dist/auth/account_action_specs.js +1 -1
- package/dist/auth/account_actions.d.ts +2 -2
- package/dist/auth/account_actions.js +2 -2
- package/dist/auth/admin_action_specs.d.ts +1 -1
- package/dist/auth/admin_action_specs.js +1 -1
- package/dist/auth/admin_actions.d.ts +2 -2
- package/dist/auth/admin_actions.js +2 -2
- package/dist/auth/permit_offer_action_specs.d.ts +1 -1
- package/dist/auth/permit_offer_action_specs.js +1 -1
- package/dist/auth/permit_offer_actions.d.ts +1 -1
- package/dist/auth/permit_offer_actions.js +1 -1
- package/dist/auth/standard_action_specs.d.ts +1 -1
- package/dist/auth/standard_action_specs.js +1 -1
- package/package.json +1 -1
package/dist/actions/CLAUDE.md
CHANGED
|
@@ -68,11 +68,45 @@ throws on any non-`remote_notification` kind.
|
|
|
68
68
|
|
|
69
69
|
## Registry + codegen (`action_registry.ts`, `action_codegen.ts`)
|
|
70
70
|
|
|
71
|
+
**Symmetric design — universal calling abstraction.** SAES is one spec
|
|
72
|
+
shape that drives dispatch across (a) network boundaries (frontend ⇄
|
|
73
|
+
backend over HTTP / WS) and (b) within the same runtime (`local_call`
|
|
74
|
+
actions). `ActionPeer` is symmetric on both sides (`send` + `receive`).
|
|
75
|
+
The two typed surfaces are paired: `FrontendActionsApi` is "what the
|
|
76
|
+
frontend can call" (typed Proxy from `create_rpc_client`);
|
|
77
|
+
`BackendActionsApi` is "what the backend can call" (typed object from
|
|
78
|
+
`create_broadcast_api` today; broader runtime constructors will join).
|
|
79
|
+
The remaining asymmetry today is runtime: there is no
|
|
80
|
+
`create_backend_rpc_client` and `create_broadcast_api` returns
|
|
81
|
+
`Promise<void>` (fire-and-forget broadcast) rather than the
|
|
82
|
+
`Promise<Result<{value}, {error}>>` shape `FrontendActionsApi` methods
|
|
83
|
+
return. Closing those gaps is captured in the SAES quest's API
|
|
84
|
+
review III deferred set — wait for a second backend runtime case.
|
|
85
|
+
|
|
71
86
|
`ActionRegistry(specs)` is a query/filter wrapper over `ActionSpecUnion[]`.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
`
|
|
75
|
-
|
|
87
|
+
Codegen-used getter groups:
|
|
88
|
+
|
|
89
|
+
- Identity: `spec_by_method`, `methods`.
|
|
90
|
+
- Kind-narrow specs + matching `_methods`: `request_response_specs`,
|
|
91
|
+
`remote_notification_specs`, `local_call_specs`.
|
|
92
|
+
- Narrow handler-side (request_response only, `initiator` excludes own
|
|
93
|
+
side, drives the typed `BackendActionHandlers` map):
|
|
94
|
+
`frontend_handled_specs`, `frontend_handled_methods`,
|
|
95
|
+
`backend_handled_specs`, `backend_handled_methods`.
|
|
96
|
+
- Loose "relevant to this side" (everything the side might encounter,
|
|
97
|
+
drives the typed-Proxy method enums `FrontendActionMethod` and
|
|
98
|
+
`BackendActionMethod`): `specs_relevant_to_frontend`,
|
|
99
|
+
`methods_relevant_to_frontend`, `specs_relevant_to_backend`,
|
|
100
|
+
`methods_relevant_to_backend`.
|
|
101
|
+
- Broadcast (kind-narrow `remote_notification`, `initiator !== 'frontend'`,
|
|
102
|
+
excludes `streams` targets): `broadcast_specs`, `broadcast_methods`.
|
|
103
|
+
- Backend-initiated (forward-looking kind-agnostic version of broadcast;
|
|
104
|
+
same content today, will widen when local_calls or backend
|
|
105
|
+
`request_response` join): `backend_initiated_specs`,
|
|
106
|
+
`backend_initiated_methods`.
|
|
107
|
+
|
|
108
|
+
Other getters (auth, initiator-direction) are pre-built stubs flagged
|
|
109
|
+
`@action-system-review`.
|
|
76
110
|
|
|
77
111
|
`action_codegen.ts` provides gen helpers (used by consumer `*.gen.ts` files,
|
|
78
112
|
not the runtime):
|
|
@@ -83,29 +117,31 @@ not the runtime):
|
|
|
83
117
|
- `get_executor_phases(spec, executor)` — phases a given executor (`'frontend' | 'backend'`) participates in for the spec. Deduplicates via `Set` (handles `initiator: 'both'` overlap).
|
|
84
118
|
- `get_handler_return_type(spec, phase, imports, collections_path?)` — the TS type a phase handler must return; triggers the `ActionOutputs` import (sourced from `collections_path`, default `'./action_collections.js'`) as a side effect.
|
|
85
119
|
- `generate_phase_handlers(spec, executor, imports, {action_event_type?, collections_path?})` — emits the typed handler-map fragment for one action; consumers compose these into `ActionHandlers` types.
|
|
86
|
-
- `generate_actions_api_method_signature(spec, {sync_returns_value?})` — single source of truth for the typed `
|
|
120
|
+
- `generate_actions_api_method_signature(spec, {sync_returns_value?})` — single source of truth for the typed `FrontendActionsApi` method shape. Threads `options?: RpcClientCallOptions` (`{signal?, transport_name?, queue?}`) onto every async method — `request_response`, `remote_notification`, and async `local_call` — and wraps the return in `Promise<Result<...>>`. Notifications were previously emitted as `=> void`, mismatching the runtime (`create_remote_notification_method` returns a Promise that resolves to `Result<{value: void}>`); regenerate consumer typed clients to pick up the corrected shape.
|
|
87
121
|
- `create_banner(origin_path)` — gen banner comment.
|
|
88
122
|
- `to_action_spec_identifier(method)` / `to_action_spec_input_identifier` / `to_action_spec_output_identifier` — naming convention helpers (emit `foo_action_spec` / `foo_action_spec.input` / `foo_action_spec.output`).
|
|
89
|
-
- `
|
|
90
|
-
- `
|
|
123
|
+
- `PROTOCOL_ACTION_METHODS` (+ `ProtocolActionMethod` type) — readonly tuple `['heartbeat', 'cancel']`. Pairs with `protocol_actions` / `protocol_action_specs` in `actions/protocol.ts` (the runtime bundles). Consumers spread when filtering backend `request_response` methods so dispatcher-owned protocol actions don't leak into `BackendRequestResponseMethod` / handler maps.
|
|
124
|
+
- `is_protocol_action_method(method)` — type predicate paired with `PROTOCOL_ACTION_METHODS`; use this in `method_filter` callbacks instead of `PROTOCOL_ACTION_METHODS.includes(s.method as never)`.
|
|
91
125
|
- `DEFAULT_COLLECTIONS_PATH = './action_collections.js'` — shared default for every helper that takes a `collections_path?`.
|
|
92
126
|
- `DEFAULT_SPECS_MODULE = './action_specs.js'` — shared default for helpers that emit `specs.{method}_action_spec` and need a `* as specs` namespace import.
|
|
93
127
|
- `DEFAULT_METATYPES_PATH = './action_metatypes.js'` — shared default for the sibling module carrying the generated `ActionMethod` enum.
|
|
94
128
|
|
|
95
|
-
### High-level helpers
|
|
129
|
+
### High-level helpers
|
|
96
130
|
|
|
97
131
|
Each accepts `(specs, imports, options?)` and returns one block of declarations.
|
|
98
132
|
Composed by consumer `*.gen.ts` producers; outputs do not include the banner or
|
|
99
|
-
surrounding `imports.build()`.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
`
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
133
|
+
surrounding `imports.build()`. Use `compose_gen_file` to assemble the block
|
|
134
|
+
list + banner + imports into the final file body in one call.
|
|
135
|
+
|
|
136
|
+
**Protocol actions are filtered by default.** Every spec-iterating helper
|
|
137
|
+
accepts `{include_protocol_actions?: boolean}` (default `false`) and drops
|
|
138
|
+
`heartbeat` / `cancel` from the emitted output. Protocol actions ship from
|
|
139
|
+
fuz_app and are spread into each consumer's `actions` array at
|
|
140
|
+
registration time (via `protocol_actions` from `actions/protocol.ts`) —
|
|
141
|
+
they should not appear in consumer-owned typed surfaces (`ActionMethod`,
|
|
142
|
+
`FrontendActionsApi`, `ActionInputs`, `FrontendActionHandlers`, etc.).
|
|
143
|
+
Pass `include_protocol_actions: true` only if a consumer genuinely owns
|
|
144
|
+
protocol actions in their typed API.
|
|
109
145
|
|
|
110
146
|
**Consumer tiers and namespace handling.** Single-source consumers (zzz,
|
|
111
147
|
undying — every spec lives in one local `action_specs.ts`) drop straight
|
|
@@ -113,32 +149,40 @@ into the helpers and accept the default `* as specs from specs_module`
|
|
|
113
149
|
namespace import. Multi-source consumers (tx, visiones — which stitch
|
|
114
150
|
local specs together with `all_admin_action_specs` /
|
|
115
151
|
`all_permit_offer_action_specs` / `all_account_action_specs` /
|
|
116
|
-
`all_self_service_role_action_specs` from fuz_app)
|
|
117
|
-
`
|
|
152
|
+
`all_self_service_role_action_specs` from fuz_app) call
|
|
153
|
+
`create_namespace_qualifier(sources, imports)` once, then pass the
|
|
154
|
+
returned `qualify_spec` callback to the multi-source helpers
|
|
118
155
|
(`generate_action_specs_record`, `generate_action_inputs_outputs`,
|
|
119
156
|
`generate_backend_actions_api`). When `qualify_spec` is set, the helper
|
|
120
157
|
emits the callback's return value (e.g.
|
|
121
158
|
`admin_specs.account_list_action_spec`) and skips the default `* as specs`
|
|
122
|
-
import — the consumer
|
|
123
|
-
appends `.input` / `.output` to the
|
|
124
|
-
`generate_action_inputs_outputs` automatically;
|
|
125
|
-
bare spec identifier.
|
|
159
|
+
import — the consumer (or the namespace-qualifier helper) owns the
|
|
160
|
+
multi-namespace imports. The helper appends `.input` / `.output` to the
|
|
161
|
+
qualified identifier in `generate_action_inputs_outputs` automatically;
|
|
162
|
+
the callback returns the bare spec identifier.
|
|
126
163
|
|
|
127
164
|
Tier 1 (HTTP-only, e.g. tx/visiones) emits a smaller surface — typically just
|
|
128
|
-
`ActionMethod` + `
|
|
129
|
-
and never calls `generate_typed_action_event_alias` or
|
|
165
|
+
`ActionMethod` + `FrontendActionsApi` + `ActionInputs` / `ActionOutputs`
|
|
166
|
+
interfaces — and never calls `generate_typed_action_event_alias` or
|
|
130
167
|
`generate_frontend_action_handlers`. Tier 2 (`TypedActionEvent`-aware, e.g.
|
|
131
|
-
zzz) emits the full set including `ActionEventDatas`, `TypedActionEvent`,
|
|
132
|
-
`FrontendActionHandlers`.
|
|
168
|
+
zzz) emits the full set including `ActionEventDatas`, `TypedActionEvent`,
|
|
169
|
+
and `FrontendActionHandlers`.
|
|
133
170
|
|
|
134
|
-
- `generate_action_method_enums(specs, imports, {emit?})` — up to
|
|
171
|
+
- `generate_action_method_enums(specs, imports, {emit?, include_protocol_actions?})` — up to nine `z.enum` + `z.infer` pairs (`ActionMethod`, `RequestResponseActionMethod`, `RemoteNotificationActionMethod`, `LocalCallActionMethod`, `FrontendActionMethod`, `BackendActionMethod`, `FrontendRequestResponseMethod`, `BackendRequestResponseMethod`, `BroadcastActionMethod`). `emit: ReadonlySet<ActionMethodEnumKind>` restricts to a subset (Tier 1 HTTP-only consumers don't need all nine). Skips kinds whose method list is empty (`z.enum([])` is invalid) and skips the `zod` import when no blocks are emitted. Adds `import {z} from 'zod'` only when at least one block is produced. The `frontend_handled` / `backend_handled` / `broadcast` kinds use the registry's narrow handler-side / streams-aware getters; the loose `frontend` / `backend` kinds preserve the everything-relevant-to-this-side semantic for the typed-Proxy method enum.
|
|
172
|
+
- `generate_action_method_enum_block(specs, imports, {name, jsdoc, predicate, include_protocol_actions?})` — lower-level escape hatch for genuinely cross-product enums the discriminator doesn't cover. Caller owns the predicate, name, and jsdoc.
|
|
135
173
|
- `generate_typed_action_event_alias(imports, {collections_path?, metatypes_path?})` — fixed-shape `TypedActionEvent<TMethod, TPhase, TStep>` alias narrowing `ActionEvent.data` against `ActionEventDatas`. Adds the three fuz_app type imports + `ActionEventDatas` (from `collections_path`) + `ActionMethod` (from `metatypes_path`).
|
|
136
|
-
- `generate_action_specs_record(specs, imports, {specs_module?, qualify_spec?})` — `ActionSpecs` runtime const + interface + `action_specs: Array<ActionSpecUnion>` value. Adds `* as specs` from `specs_module` unless `qualify_spec` is set (then `specs_module` is ignored and the consumer owns namespace imports).
|
|
137
|
-
- `generate_action_inputs_outputs(specs, imports, {specs_module?, qualify_spec?})` — `ActionInputs` and `ActionOutputs` runtime consts + interfaces. Same `qualify_spec` semantics as `generate_action_specs_record`; the helper appends `.input` / `.output` to the qualified identifier.
|
|
138
|
-
- `generate_action_event_datas(specs, imports, {same_file?, collections_path?})` — `ActionEventDatas` interface; per-spec variant by kind (`ActionEventRequestResponseData` / `ActionEventRemoteNotificationData` / `ActionEventLocalCallData`). `same_file` (default `true`) is the file-layout switch: when `true`, assumes `ActionInputs` / `ActionOutputs` are in the same module and adds no import (the zzz pattern); when `false`, adds the type imports from `collections_path` (default `'./action_collections.js'`). `collections_path` alone is a no-op — the surprising omit-vs-default behavior of earlier versions has been replaced.
|
|
139
|
-
- `
|
|
140
|
-
- `generate_frontend_action_handlers(specs, imports, {collections_path?})` — `FrontendActionHandlers` interface (Tier 2 only — wraps `generate_phase_handlers` with `action_event_type: 'TypedActionEvent'`). Pair with `generate_typed_action_event_alias`.
|
|
141
|
-
- `generate_backend_actions_api(specs, imports, {specs_module?, collections_path?, qualify_spec?})` — `BackendActionsApi` interface AND `broadcast_action_specs: ReadonlyArray<ActionSpecUnion>` array. Filter: `kind === 'remote_notification' && initiator !== 'frontend'
|
|
174
|
+
- `generate_action_specs_record(specs, imports, {specs_module?, qualify_spec?, include_protocol_actions?})` — `ActionSpecs` runtime const + interface + `action_specs: Array<ActionSpecUnion>` value. Adds `* as specs` from `specs_module` unless `qualify_spec` is set (then `specs_module` is ignored and the consumer owns namespace imports).
|
|
175
|
+
- `generate_action_inputs_outputs(specs, imports, {specs_module?, qualify_spec?, include_protocol_actions?})` — `ActionInputs` and `ActionOutputs` runtime consts + interfaces. Same `qualify_spec` semantics as `generate_action_specs_record`; the helper appends `.input` / `.output` to the qualified identifier.
|
|
176
|
+
- `generate_action_event_datas(specs, imports, {same_file?, collections_path?, include_protocol_actions?})` — `ActionEventDatas` interface; per-spec variant by kind (`ActionEventRequestResponseData` / `ActionEventRemoteNotificationData` / `ActionEventLocalCallData`). `same_file` (default `true`) is the file-layout switch: when `true`, assumes `ActionInputs` / `ActionOutputs` are in the same module and adds no import (the zzz pattern); when `false`, adds the type imports from `collections_path` (default `'./action_collections.js'`). `collections_path` alone is a no-op — the surprising omit-vs-default behavior of earlier versions has been replaced.
|
|
177
|
+
- `generate_frontend_actions_api(specs, imports, {interface_name?, method_filter?, collections_path?, sync_returns_value?, include_protocol_actions?})` — emits the typed `FrontendActionsApi` interface (configurable via `interface_name`, default `'FrontendActionsApi'`). One method signature per spec via `generate_actions_api_method_signature`. Protocol actions filtered by default; `method_filter: (spec) => boolean` runs after the protocol-action filter. Renamed from `generate_actions_api` in API review III to make the side-of-the-wire intent visible at every consumer site.
|
|
178
|
+
- `generate_frontend_action_handlers(specs, imports, {collections_path?, include_protocol_actions?})` — `FrontendActionHandlers` interface (Tier 2 only — wraps `generate_phase_handlers` with `action_event_type: 'TypedActionEvent'`). Pair with `generate_typed_action_event_alias`.
|
|
179
|
+
- `generate_backend_actions_api(specs, imports, {interface_name?, spec_array_name?, specs_module?, collections_path?, qualify_spec?, include_protocol_actions?})` — `BackendActionsApi` interface AND `broadcast_action_specs: ReadonlyArray<ActionSpecUnion>` array (both names configurable). Filter: `kind === 'remote_notification' && initiator !== 'frontend'`, with `streams`-target methods (request-scoped progress notifications invoked via `ctx.notify`) excluded — the discriminator is `ActionSpec.streams`, not a manual list. Adds `ActionInputs` (from `collections_path`) + `ActionSpecUnion`, plus `* as specs` from `specs_module` unless `qualify_spec` is set. Method shape today is `(input) => Promise<void>` (matches `create_broadcast_api`'s fire-and-forget runtime); generalizing to per-kind shapes via `generate_actions_api_method_signature` is deferred until a second backend runtime constructor lands (see SAES quest § API review III deferred set).
|
|
180
|
+
- `generate_backend_action_handlers_map(imports, options?)` — emits the `BackendActionHandlers` mapped type (`{[K in BackendRequestResponseMethod]: (input: ActionInputs[K], ctx: BackendHandlerContext) => ActionOutputs[K] | Promise<ActionOutputs[K]>}`). Replaces the hand-maintained `Exclude<>` + parallel mapped-type pattern (zzz had this at `zzz/src/lib/server/zzz_action_handlers.ts:42-66`). Configurable type name, method enum name, and context type name; configurable `collections_path` / `metatypes_path` for the type imports.
|
|
181
|
+
|
|
182
|
+
### Wrapper + multi-source helper
|
|
183
|
+
|
|
184
|
+
- `compose_gen_file({origin_path, imports, blocks})` — encapsulates the per-`*.gen.ts` boilerplate (banner + `imports.build()` + blocks join + template literal). Returns the full file body. Each consumer producer collapses to one `compose_gen_file` call wrapping the helper invocations.
|
|
185
|
+
- `create_namespace_qualifier(sources, imports)` — multi-source consumer helper. Takes `ReadonlyArray<{ns, module, specs}>`, registers `import * as ns from module` for each on `imports`, builds the `method_to_ns` lookup with duplicate-method detection, returns `{qualify_spec, all_specs}` ready to thread through the high-level helpers. Closes the per-file boilerplate gap that kept tx + visiones on hand-rolled template strings even after the `qualify_spec?` callback landed (the per-call callback wasn't enough — the import dance + dup-check was the real boilerplate).
|
|
142
186
|
|
|
143
187
|
## HTTP bridge (`action_bridge.ts`)
|
|
144
188
|
|
|
@@ -535,12 +579,46 @@ interface ActionPeerSendOptions extends TransportSendOptions {
|
|
|
535
579
|
Currently partial: `#receive_request`'s `send_response` transition step has
|
|
536
580
|
a known sharp edge ("shouldn't need the guard" TODO).
|
|
537
581
|
|
|
538
|
-
##
|
|
582
|
+
## Protocol actions (`heartbeat.ts`, `cancel.ts`, `protocol.ts`)
|
|
539
583
|
|
|
540
584
|
Two shared `{spec, handler}` tuples that every consumer spreads into both
|
|
541
585
|
sides' `actions` arrays — disconnect detection and per-request cancel work
|
|
542
586
|
identically across every repo without per-consumer ping plumbing.
|
|
543
587
|
|
|
588
|
+
The category is wire-protocol concerns shipped by fuz_app, not consumer
|
|
589
|
+
domain logic. The contrast that matters is protocol vs domain: a future
|
|
590
|
+
clock-skew probe or reconnect-resume token belongs in this bundle; a
|
|
591
|
+
`payment_charge` action does not. Avoid the framing "composable vs
|
|
592
|
+
non-composable" — every `Action` is composable by the same mechanism
|
|
593
|
+
(spread into the `actions` array), so the distinction would not carve
|
|
594
|
+
nature at the joints.
|
|
595
|
+
|
|
596
|
+
### Canonical bundles (`protocol.ts`)
|
|
597
|
+
|
|
598
|
+
Two const arrays declare the canonical protocol-action set so consumers
|
|
599
|
+
spread one symbol per side instead of importing each primitive
|
|
600
|
+
individually:
|
|
601
|
+
|
|
602
|
+
- `protocol_actions: ReadonlyArray<Action>` — for the server's
|
|
603
|
+
`register_action_ws` `actions` array. Spread before consumer-owned
|
|
604
|
+
actions: `actions: [...protocol_actions, ...consumer_actions]`.
|
|
605
|
+
- `protocol_action_specs: ReadonlyArray<ActionSpecUnion>` — derived via
|
|
606
|
+
`.map(a => a.spec)` so the two arrays cannot drift. For the frontend
|
|
607
|
+
`ActionRegistry`. Spread before consumer-owned specs:
|
|
608
|
+
`new ActionRegistry([...protocol_action_specs, ...action_specs])`.
|
|
609
|
+
|
|
610
|
+
The asymmetry is intentional — the server runs handlers (heartbeat echo +
|
|
611
|
+
cancel stub), the frontend registry only stores specs. Both bundles plus
|
|
612
|
+
the codegen `include_protocol_actions: false` default form a three-leg
|
|
613
|
+
contract: codegen excludes protocol actions from generated typed surfaces
|
|
614
|
+
because consumers spread these bundles in at registration time.
|
|
615
|
+
|
|
616
|
+
The bundles are **not** auto-spread by `create_frontend_rpc_client` or
|
|
617
|
+
`register_ws_endpoint` — bundled helpers stay pure factories so the
|
|
618
|
+
dispatch surface stays grep-traceable at every consumer registration site
|
|
619
|
+
and consumers can override individual protocol actions (custom heartbeat,
|
|
620
|
+
etc.) without an opt-out flag.
|
|
621
|
+
|
|
544
622
|
### `heartbeat_action`
|
|
545
623
|
|
|
546
624
|
Method `'heartbeat'`, `request_response`, `initiator: 'frontend'`, `auth:
|
|
@@ -642,12 +720,12 @@ zzz's `Actions` cell calls its own `add_from_json` +
|
|
|
642
720
|
`listen_to_action_event` here so the history plumbing stays inside zzz
|
|
643
721
|
instead of leaking onto the rpc_client surface. `event.spec.method` and
|
|
644
722
|
`event.data.method` narrow to `keyof TApi & string` so consumers passing
|
|
645
|
-
a generated `
|
|
646
|
-
`as ActionMethod` cast at the call site.
|
|
723
|
+
a generated `FrontendActionsApi` get the literal method-name union without
|
|
724
|
+
an `as ActionMethod` cast at the call site.
|
|
647
725
|
|
|
648
|
-
Cast the return to a generated `
|
|
649
|
-
codegen via `generate_actions_api_method_signature` keeps the
|
|
650
|
-
consistent. See ../../docs/usage.md §Typed Client Codegen.
|
|
726
|
+
Cast the return to a generated `FrontendActionsApi` interface for full
|
|
727
|
+
typing: codegen via `generate_actions_api_method_signature` keeps the
|
|
728
|
+
shape consistent. See ../../docs/usage.md §Typed Client Codegen.
|
|
651
729
|
|
|
652
730
|
### Throwing variants — `create_throwing_rpc_call` + `create_throwing_api`
|
|
653
731
|
|
|
@@ -658,10 +736,10 @@ is spec-level optional). Same hardening on both: only `{code, data}` cross
|
|
|
658
736
|
onto the Error, leaving `name` / `stack` as the native Error's own so
|
|
659
737
|
attacker-shaped `result.error` payloads cannot overwrite them.
|
|
660
738
|
|
|
661
|
-
| Helper | Shape
|
|
662
|
-
| -------------------------- |
|
|
663
|
-
| `create_throwing_rpc_call` | `(method, input?) => Promise<T>`
|
|
664
|
-
| `create_throwing_api` | typed Proxy over `
|
|
739
|
+
| Helper | Shape | Use at |
|
|
740
|
+
| -------------------------- | ------------------------------------- | -------------------------------------------------------------------------- |
|
|
741
|
+
| `create_throwing_rpc_call` | `(method, input?) => Promise<T>` | adapter wiring (e.g. `ui/admin_rpc_adapters.ts`) — method comes from a map |
|
|
742
|
+
| `create_throwing_api` | typed Proxy over `FrontendActionsApi` | direct call sites — `await api.foo(input)` keeps full inference |
|
|
665
743
|
|
|
666
744
|
**Layered design.** Result is the protocol primitive — `create_rpc_client`
|
|
667
745
|
returns `Result<{value}, {error}>` per call with no Error allocation. The
|
|
@@ -675,12 +753,12 @@ ritual.
|
|
|
675
753
|
|
|
676
754
|
`create_frontend_rpc_client` ships both shapes by default — see
|
|
677
755
|
[Frontend factory](#frontend-factory-frontend_rpc_clientts) below. Direct
|
|
678
|
-
consumers of `create_rpc_client` pass their typed `
|
|
679
|
-
generic to get the typed Result-shaped Proxy without casts, then
|
|
680
|
-
the throwing form on top:
|
|
756
|
+
consumers of `create_rpc_client` pass their typed `FrontendActionsApi`
|
|
757
|
+
as the generic to get the typed Result-shaped Proxy without casts, then
|
|
758
|
+
build the throwing form on top:
|
|
681
759
|
|
|
682
760
|
```ts
|
|
683
|
-
const api_result = create_rpc_client<
|
|
761
|
+
const api_result = create_rpc_client<FrontendActionsApi>({peer, environment});
|
|
684
762
|
const api = create_throwing_api(api_result);
|
|
685
763
|
// hot path: await api.foo(input)
|
|
686
764
|
// rare branch: const r = await api_result.foo(input); if (!r.ok) { … }
|
|
@@ -724,7 +802,7 @@ Returns both Proxy shapes from one factory call:
|
|
|
724
802
|
- `peer`, `environment` — exposed for advanced consumers that want to register more transports or share the environment with a separate dispatcher.
|
|
725
803
|
|
|
726
804
|
```ts
|
|
727
|
-
const {api, api_result} = create_frontend_rpc_client<
|
|
805
|
+
const {api, api_result} = create_frontend_rpc_client<FrontendActionsApi>({
|
|
728
806
|
specs: all_standard_action_specs,
|
|
729
807
|
});
|
|
730
808
|
// hot path: await api.account_verify()
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import type { ActionSpecUnion, ActionEventPhase } from './action_spec.js';
|
|
2
2
|
/**
|
|
3
|
-
* Method names of
|
|
4
|
-
*
|
|
5
|
-
* this list when filtering backend request_response methods so the
|
|
6
|
-
*
|
|
3
|
+
* Method names of fuz_app's protocol actions — `heartbeat` (auth-aware client
|
|
4
|
+
* liveness probe) and `cancel` (request-scoped abort signal). Consumers spread
|
|
5
|
+
* this list when filtering backend request_response methods so the
|
|
6
|
+
* dispatcher-owned protocol actions don't show up in
|
|
7
|
+
* `BackendRequestResponseMethod` / handler maps. Pairs with `protocol_actions`
|
|
8
|
+
* / `protocol_action_specs` from `actions/protocol.ts` (the runtime bundles).
|
|
7
9
|
*/
|
|
8
|
-
export declare const
|
|
10
|
+
export declare const PROTOCOL_ACTION_METHODS: readonly ["heartbeat", "cancel"];
|
|
9
11
|
/** Methods that ship from fuz_app, kept out of consumer-owned method enums + handler maps. */
|
|
10
|
-
export type
|
|
12
|
+
export type ProtocolActionMethod = (typeof PROTOCOL_ACTION_METHODS)[number];
|
|
11
13
|
/**
|
|
12
|
-
* Type predicate for filtering
|
|
13
|
-
* `method_filter`. Avoids the `(... as never)` cast
|
|
14
|
-
* `Array.prototype.includes` on the readonly tuple at narrow
|
|
14
|
+
* Type predicate for filtering protocol-action methods out of a typed
|
|
15
|
+
* `FrontendActionsApi` `method_filter`. Avoids the `(... as never)` cast
|
|
16
|
+
* required to call `Array.prototype.includes` on the readonly tuple at narrow
|
|
17
|
+
* string types.
|
|
15
18
|
*
|
|
16
19
|
* @example
|
|
17
|
-
*
|
|
18
|
-
* method_filter: (s) => !
|
|
20
|
+
* generate_frontend_actions_api(specs, imports, {
|
|
21
|
+
* method_filter: (s) => !is_protocol_action_method(s.method),
|
|
19
22
|
* });
|
|
20
23
|
*/
|
|
21
|
-
export declare const
|
|
24
|
+
export declare const is_protocol_action_method: (method: string) => method is ProtocolActionMethod;
|
|
22
25
|
/**
|
|
23
26
|
* Represents an import item with its kind (type, value, or namespace).
|
|
24
27
|
*/
|
|
@@ -132,10 +135,10 @@ export declare const to_action_spec_identifier: (method: string) => string;
|
|
|
132
135
|
export declare const to_action_spec_input_identifier: (method: string) => string;
|
|
133
136
|
export declare const to_action_spec_output_identifier: (method: string) => string;
|
|
134
137
|
/**
|
|
135
|
-
* Generates one method line of the typed `
|
|
136
|
-
* spec. Encapsulates the input/options/return-type signature shape so
|
|
137
|
-
* surface evolves in one place when fields like `signal` or
|
|
138
|
-
* are added to per-call options.
|
|
138
|
+
* Generates one method line of the typed `FrontendActionsApi` interface for a
|
|
139
|
+
* single spec. Encapsulates the input/options/return-type signature shape so
|
|
140
|
+
* the surface evolves in one place when fields like `signal` or
|
|
141
|
+
* `transport_name` are added to per-call options.
|
|
139
142
|
*
|
|
140
143
|
* Async methods (`request_response`, `remote_notification`, async
|
|
141
144
|
* `local_call`) get an optional second `options?: RpcClientCallOptions` arg
|
|
@@ -156,37 +159,64 @@ export declare const to_action_spec_output_identifier: (method: string) => strin
|
|
|
156
159
|
* @param options.sync_returns_value - when true (default), sync local_call
|
|
157
160
|
* methods return the output value directly; when false they're wrapped in
|
|
158
161
|
* `Result<{value, error}>` like async methods. Set to `false` if your
|
|
159
|
-
*
|
|
162
|
+
* FrontendActionsApi treats every method uniformly.
|
|
160
163
|
* @returns one line like `foo: (input: ActionInputs['foo'], options?: RpcClientCallOptions) => Promise<Result<...>>;`
|
|
161
164
|
*/
|
|
162
165
|
export declare const generate_actions_api_method_signature: (spec: ActionSpecUnion, options?: {
|
|
163
166
|
sync_returns_value?: boolean;
|
|
164
167
|
}) => string;
|
|
165
168
|
/** Discriminator for `generate_action_method_enums` — which method-set enums to emit. */
|
|
166
|
-
export type ActionMethodEnumKind = 'all' | 'request_response' | 'remote_notification' | 'local_call' | 'frontend' | 'backend';
|
|
169
|
+
export type ActionMethodEnumKind = 'all' | 'request_response' | 'remote_notification' | 'local_call' | 'frontend' | 'backend' | 'frontend_handled' | 'backend_handled' | 'broadcast';
|
|
167
170
|
/** Default emit set — every enum kind. */
|
|
168
171
|
export declare const ACTION_METHOD_ENUM_KINDS_ALL: ReadonlySet<ActionMethodEnumKind>;
|
|
169
172
|
/**
|
|
170
173
|
* Emit one or more `z.enum([...])` declarations for action method names —
|
|
171
174
|
* `ActionMethod`, `RequestResponseActionMethod`, `RemoteNotificationActionMethod`,
|
|
172
|
-
* `LocalCallActionMethod`, `FrontendActionMethod`, `BackendActionMethod
|
|
173
|
-
*
|
|
175
|
+
* `LocalCallActionMethod`, `FrontendActionMethod`, `BackendActionMethod`,
|
|
176
|
+
* `FrontendRequestResponseMethod`, `BackendRequestResponseMethod`,
|
|
177
|
+
* `BroadcastActionMethod`. Pairs each runtime const with a `z.infer` type
|
|
178
|
+
* alias under the same identifier.
|
|
174
179
|
*
|
|
175
|
-
*
|
|
176
|
-
* pass `
|
|
177
|
-
* their typed surface. Empty kinds are skipped so the helper
|
|
178
|
-
* `z.enum([])` (zod runtime-throws on that).
|
|
180
|
+
* Protocol-action methods (`heartbeat`, `cancel`) are filtered out by
|
|
181
|
+
* default — pass `include_protocol_actions: true` if a consumer genuinely
|
|
182
|
+
* wants them on their typed surface. Empty kinds are skipped so the helper
|
|
183
|
+
* never emits `z.enum([])` (zod runtime-throws on that).
|
|
179
184
|
*
|
|
180
185
|
* Adds `import {z} from 'zod';` to `imports` only when at least one block
|
|
181
186
|
* is emitted (idempotent).
|
|
182
187
|
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
188
|
+
* For genuinely cross-product enums the discriminator doesn't cover, use
|
|
189
|
+
* `generate_action_method_enum_block` — caller owns the predicate, name,
|
|
190
|
+
* and jsdoc.
|
|
191
|
+
*
|
|
192
|
+
* @param options.emit - subset of enums to emit; defaults to all nine.
|
|
193
|
+
* @param options.include_protocol_actions - when true, retains `heartbeat` /
|
|
185
194
|
* `cancel` in the emitted enums. Default `false`.
|
|
186
195
|
*/
|
|
187
196
|
export declare const generate_action_method_enums: (specs: ReadonlyArray<ActionSpecUnion>, imports: ImportBuilder, options?: {
|
|
188
197
|
emit?: ReadonlySet<ActionMethodEnumKind>;
|
|
189
|
-
|
|
198
|
+
include_protocol_actions?: boolean;
|
|
199
|
+
}) => string;
|
|
200
|
+
/**
|
|
201
|
+
* Emit a single named `z.enum([...])` + `z.infer` block for an arbitrary
|
|
202
|
+
* spec subset. Lower-level escape hatch from `generate_action_method_enums` —
|
|
203
|
+
* for cross-product or domain-specific enums the built-in discriminator
|
|
204
|
+
* doesn't cover.
|
|
205
|
+
*
|
|
206
|
+
* Mirrors the built-in helper's contract: protocol actions filtered by
|
|
207
|
+
* default, empty subsets return `''` (skip rather than emit `z.enum([])`),
|
|
208
|
+
* `zod` import registered idempotently only when at least one method
|
|
209
|
+
* qualifies.
|
|
210
|
+
*
|
|
211
|
+
* The cross-product space is open-ended; rather than grow the
|
|
212
|
+
* `ActionMethodEnumKind` discriminator one cross-product at a time, callers
|
|
213
|
+
* own the subset shape — name, jsdoc, predicate.
|
|
214
|
+
*/
|
|
215
|
+
export declare const generate_action_method_enum_block: (specs: ReadonlyArray<ActionSpecUnion>, imports: ImportBuilder, options: {
|
|
216
|
+
name: string;
|
|
217
|
+
jsdoc: string;
|
|
218
|
+
predicate: (spec: ActionSpecUnion) => boolean;
|
|
219
|
+
include_protocol_actions?: boolean;
|
|
190
220
|
}) => string;
|
|
191
221
|
/**
|
|
192
222
|
* Emit the fixed-shape `TypedActionEvent` alias used by `FrontendActionHandlers`
|
|
@@ -219,7 +249,7 @@ export declare const generate_typed_action_event_alias: (imports: ImportBuilder,
|
|
|
219
249
|
export declare const generate_action_specs_record: (specs: ReadonlyArray<ActionSpecUnion>, imports: ImportBuilder, options?: {
|
|
220
250
|
specs_module?: string;
|
|
221
251
|
qualify_spec?: (spec: ActionSpecUnion) => string;
|
|
222
|
-
|
|
252
|
+
include_protocol_actions?: boolean;
|
|
223
253
|
}) => string;
|
|
224
254
|
/**
|
|
225
255
|
* Emit `ActionInputs` + `ActionOutputs` runtime consts and matching interfaces.
|
|
@@ -237,7 +267,7 @@ export declare const generate_action_specs_record: (specs: ReadonlyArray<ActionS
|
|
|
237
267
|
export declare const generate_action_inputs_outputs: (specs: ReadonlyArray<ActionSpecUnion>, imports: ImportBuilder, options?: {
|
|
238
268
|
specs_module?: string;
|
|
239
269
|
qualify_spec?: (spec: ActionSpecUnion) => string;
|
|
240
|
-
|
|
270
|
+
include_protocol_actions?: boolean;
|
|
241
271
|
}) => string;
|
|
242
272
|
/**
|
|
243
273
|
* Emit the `ActionEventDatas` interface — one `ActionEvent*Data` variant per
|
|
@@ -262,21 +292,28 @@ export declare const generate_action_inputs_outputs: (specs: ReadonlyArray<Actio
|
|
|
262
292
|
export declare const generate_action_event_datas: (specs: ReadonlyArray<ActionSpecUnion>, imports: ImportBuilder, options?: {
|
|
263
293
|
same_file?: boolean;
|
|
264
294
|
collections_path?: string;
|
|
265
|
-
|
|
295
|
+
include_protocol_actions?: boolean;
|
|
266
296
|
}) => string;
|
|
267
297
|
/**
|
|
268
|
-
* Emit the `
|
|
298
|
+
* Emit the `FrontendActionsApi` interface — one method signature per spec via
|
|
269
299
|
* `generate_actions_api_method_signature`. Optionally filter the spec set
|
|
270
|
-
* (e.g. omit
|
|
300
|
+
* (e.g. omit additional methods alongside the default protocol-action
|
|
301
|
+
* filter) via `method_filter`.
|
|
271
302
|
*
|
|
272
303
|
* Adds the `Result`, `JsonrpcErrorObject`, and `RpcClientCallOptions` type
|
|
273
304
|
* imports plus `ActionInputs` / `ActionOutputs` (sourced from `collections_path`).
|
|
305
|
+
*
|
|
306
|
+
* The interface name is fixed at `FrontendActionsApi` — the symmetric counterpart
|
|
307
|
+
* of `BackendActionsApi`. Earlier consumer-named variants (`MyActionsApi`,
|
|
308
|
+
* `VisionesActionsApi`) were retired in API review III to make the side-of-the-wire
|
|
309
|
+
* intent visible at every call site. If a consumer needs a different name they
|
|
310
|
+
* hand-roll the interface (the helper's job is the standard symmetric shape).
|
|
274
311
|
*/
|
|
275
|
-
export declare const
|
|
312
|
+
export declare const generate_frontend_actions_api: (specs: ReadonlyArray<ActionSpecUnion>, imports: ImportBuilder, options?: {
|
|
276
313
|
method_filter?: (spec: ActionSpecUnion) => boolean;
|
|
277
314
|
collections_path?: string;
|
|
278
315
|
sync_returns_value?: boolean;
|
|
279
|
-
|
|
316
|
+
include_protocol_actions?: boolean;
|
|
280
317
|
}) => string;
|
|
281
318
|
/**
|
|
282
319
|
* Emit the `FrontendActionHandlers` interface — wraps `generate_phase_handlers`
|
|
@@ -286,7 +323,7 @@ export declare const generate_actions_api: (specs: ReadonlyArray<ActionSpecUnion
|
|
|
286
323
|
*/
|
|
287
324
|
export declare const generate_frontend_action_handlers: (specs: ReadonlyArray<ActionSpecUnion>, imports: ImportBuilder, options?: {
|
|
288
325
|
collections_path?: string;
|
|
289
|
-
|
|
326
|
+
include_protocol_actions?: boolean;
|
|
290
327
|
}) => string;
|
|
291
328
|
/**
|
|
292
329
|
* Emit BOTH the typed `BackendActionsApi` interface AND the
|
|
@@ -295,12 +332,23 @@ export declare const generate_frontend_action_handlers: (specs: ReadonlyArray<Ac
|
|
|
295
332
|
* each `(input) => Promise<void>`. The array bundles the matching specs as a
|
|
296
333
|
* `ReadonlyArray<ActionSpecUnion>`.
|
|
297
334
|
*
|
|
298
|
-
* Filter: `kind === 'remote_notification' && initiator !== 'frontend'
|
|
335
|
+
* Filter: `kind === 'remote_notification' && initiator !== 'frontend'`,
|
|
336
|
+
* additionally excluding methods that are the target of another spec's
|
|
337
|
+
* `streams` field. Streams targets (e.g. `completion_progress`,
|
|
338
|
+
* `ollama_progress`) are request-scoped notifications invoked via
|
|
339
|
+
* `ctx.notify` inside their parent handler — they're never callable through
|
|
340
|
+
* the broadcast API. The discriminator is `ActionSpec.streams`, not a manual
|
|
341
|
+
* exclusion list.
|
|
299
342
|
*
|
|
300
343
|
* Adds the `* as specs` namespace import (from `specs_module`), the
|
|
301
344
|
* `ActionInputs` type import (from `collections_path`), and the
|
|
302
345
|
* `ActionSpecUnion` type import.
|
|
303
346
|
*
|
|
347
|
+
* Method signature shape today is `(input) => Promise<void>` — matches the
|
|
348
|
+
* fire-and-forget runtime of `create_broadcast_api`. Generalizing per-kind
|
|
349
|
+
* via `generate_actions_api_method_signature` is deferred until a second
|
|
350
|
+
* backend runtime constructor lands (see SAES quest § API review III).
|
|
351
|
+
*
|
|
304
352
|
* @param options.qualify_spec - per-spec qualified identifier callback for
|
|
305
353
|
* multi-source consumers. When set, the helper emits the callback's return
|
|
306
354
|
* value instead of ``specs.${method}_action_spec`` in the broadcast array
|
|
@@ -312,7 +360,118 @@ export declare const generate_backend_actions_api: (specs: ReadonlyArray<ActionS
|
|
|
312
360
|
specs_module?: string;
|
|
313
361
|
collections_path?: string;
|
|
314
362
|
qualify_spec?: (spec: ActionSpecUnion) => string;
|
|
315
|
-
|
|
363
|
+
include_protocol_actions?: boolean;
|
|
364
|
+
}) => string;
|
|
365
|
+
/**
|
|
366
|
+
* Emit the `BackendActionHandlers` mapped type — one entry per
|
|
367
|
+
* `BackendRequestResponseMethod`, each `(input, ctx) => output | Promise<output>`.
|
|
368
|
+
* Replaces the hand-maintained `Exclude<>` + parallel mapped-type pattern
|
|
369
|
+
* (zzz had this at `zzz/src/lib/server/zzz_action_handlers.ts:42-66`).
|
|
370
|
+
*
|
|
371
|
+
* The context type is consumer-defined (e.g. zzz's `ZzzHandlerContext`). Pass
|
|
372
|
+
* `context_type` to name it; the helper assumes it's importable or defined
|
|
373
|
+
* in the emitted module's scope (consumer's responsibility).
|
|
374
|
+
*
|
|
375
|
+
* Adds `ActionInputs` / `ActionOutputs` type imports from `collections_path`
|
|
376
|
+
* and the `BackendRequestResponseMethod` import from `metatypes_path`.
|
|
377
|
+
*
|
|
378
|
+
* @param options.type_name - default `'BackendActionHandlers'`.
|
|
379
|
+
* @param options.method_enum_name - default `'BackendRequestResponseMethod'`.
|
|
380
|
+
* Pair with `generate_action_method_enums` emitting the `'backend_handled'` kind.
|
|
381
|
+
* @param options.context_type - default `'BackendHandlerContext'`. Caller's
|
|
382
|
+
* handler context type — must be in scope at the emit site.
|
|
383
|
+
* @param options.collections_path - default `'./action_collections.js'`.
|
|
384
|
+
* @param options.metatypes_path - default `'./action_metatypes.js'`.
|
|
385
|
+
*/
|
|
386
|
+
export declare const generate_backend_action_handlers_map: (imports: ImportBuilder, options?: {
|
|
387
|
+
type_name?: string;
|
|
388
|
+
method_enum_name?: string;
|
|
389
|
+
context_type?: string;
|
|
390
|
+
collections_path?: string;
|
|
391
|
+
metatypes_path?: string;
|
|
392
|
+
}) => string;
|
|
393
|
+
/**
|
|
394
|
+
* One source in a multi-source consumer's namespace map. `ns` is the local
|
|
395
|
+
* alias used inside the generated file; `module` is the import path; `specs`
|
|
396
|
+
* is the runtime spec array. `create_namespace_qualifier` consumes a list of
|
|
397
|
+
* these.
|
|
398
|
+
*/
|
|
399
|
+
export interface SpecSource {
|
|
400
|
+
ns: string;
|
|
401
|
+
module: string;
|
|
402
|
+
specs: ReadonlyArray<ActionSpecUnion>;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Multi-source consumer helper. Takes a list of `{ns, module, specs}` rows,
|
|
406
|
+
* registers `import * as ns from module` for each on `imports`, builds the
|
|
407
|
+
* `method_to_ns` lookup with duplicate-method detection, and returns
|
|
408
|
+
* `{qualify_spec, all_specs}` ready to thread through the high-level
|
|
409
|
+
* helpers.
|
|
410
|
+
*
|
|
411
|
+
* Closes the per-file boilerplate gap that kept tx + visiones on hand-rolled
|
|
412
|
+
* template strings even after `qualify_spec?` landed in API review II — the
|
|
413
|
+
* per-call callback wasn't enough; the import dance + dup-check was the
|
|
414
|
+
* real boilerplate.
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* ```ts
|
|
418
|
+
* const sources = [
|
|
419
|
+
* {ns: 'tx_specs', module: './action_specs.js', specs: all_tx_action_specs},
|
|
420
|
+
* {ns: 'admin_specs', module: '@fuzdev/fuz_app/auth/admin_action_specs.js', specs: all_admin_action_specs},
|
|
421
|
+
* ];
|
|
422
|
+
*
|
|
423
|
+
* export const gen: Gen = ({origin_path}) => {
|
|
424
|
+
* const imports = new ImportBuilder();
|
|
425
|
+
* const {qualify_spec, all_specs} = create_namespace_qualifier(sources, imports);
|
|
426
|
+
* return compose_gen_file({
|
|
427
|
+
* origin_path,
|
|
428
|
+
* imports,
|
|
429
|
+
* blocks: [
|
|
430
|
+
* generate_action_specs_record(all_specs, imports, {qualify_spec}),
|
|
431
|
+
* generate_action_inputs_outputs(all_specs, imports, {qualify_spec}),
|
|
432
|
+
* ],
|
|
433
|
+
* });
|
|
434
|
+
* };
|
|
435
|
+
* ```
|
|
436
|
+
*
|
|
437
|
+
* @throws if two sources contain the same method name (same-method detection
|
|
438
|
+
* is the consumer's primary debugging signal).
|
|
439
|
+
*/
|
|
440
|
+
export declare const create_namespace_qualifier: (sources: ReadonlyArray<SpecSource>, imports: ImportBuilder) => {
|
|
441
|
+
qualify_spec: (spec: ActionSpecUnion) => string;
|
|
442
|
+
all_specs: ReadonlyArray<ActionSpecUnion>;
|
|
443
|
+
};
|
|
444
|
+
/**
|
|
445
|
+
* Wrap the per-`*.gen.ts` boilerplate (banner + `imports.build()` +
|
|
446
|
+
* blocks join + template literal) into one call. Returns the full file body
|
|
447
|
+
* as a string ready to return from a `Gen` function.
|
|
448
|
+
*
|
|
449
|
+
* Each consumer producer collapses to one `compose_gen_file` call wrapping
|
|
450
|
+
* the helper invocations.
|
|
451
|
+
*
|
|
452
|
+
* @example
|
|
453
|
+
* ```ts
|
|
454
|
+
* export const gen: Gen = ({origin_path}) => {
|
|
455
|
+
* const imports = new ImportBuilder();
|
|
456
|
+
* return compose_gen_file({
|
|
457
|
+
* origin_path,
|
|
458
|
+
* imports,
|
|
459
|
+
* blocks: [
|
|
460
|
+
* generate_action_specs_record(all_action_specs, imports),
|
|
461
|
+
* generate_action_inputs_outputs(all_action_specs, imports),
|
|
462
|
+
* generate_action_event_datas(all_action_specs, imports),
|
|
463
|
+
* ],
|
|
464
|
+
* });
|
|
465
|
+
* };
|
|
466
|
+
* ```
|
|
467
|
+
*
|
|
468
|
+
* Empty blocks (`''`) are filtered out so helpers that short-circuit on
|
|
469
|
+
* empty spec sets don't introduce stray double blank lines.
|
|
470
|
+
*/
|
|
471
|
+
export declare const compose_gen_file: (input: {
|
|
472
|
+
origin_path: string;
|
|
473
|
+
imports: ImportBuilder;
|
|
474
|
+
blocks: ReadonlyArray<string>;
|
|
316
475
|
}) => string;
|
|
317
476
|
export {};
|
|
318
477
|
//# sourceMappingURL=action_codegen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_codegen.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_codegen.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAGxE
|
|
1
|
+
{"version":3,"file":"action_codegen.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_codegen.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAGxE;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,kCAAmC,CAAC;AAExE,8FAA8F;AAC9F,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAI5E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,MAAM,KAAG,MAAM,IAAI,oBACrC,CAAC;AAEjC;;GAEG;AACH,UAAU,UAAU;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,WAAW,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,aAAa;;IACzB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAa;IAE1D;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAQrC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,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