@fuzdev/fuz_app 0.168.1 → 0.170.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 +17 -19
- package/dist/actions/action_codegen.d.ts +32 -23
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +101 -80
- package/dist/actions/action_event.d.ts +0 -8
- package/dist/actions/action_event.d.ts.map +1 -1
- package/dist/actions/action_event.js +7 -6
- package/dist/actions/action_event_data.d.ts +18 -18
- package/dist/actions/action_rpc.d.ts +1 -1
- package/dist/actions/action_rpc.js +1 -1
- package/dist/actions/action_spec.d.ts +8 -10
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/action_spec.js +1 -1
- package/dist/actions/action_types.d.ts +4 -4
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/action_types.js +2 -2
- package/dist/actions/broadcast_api.d.ts +2 -2
- package/dist/actions/broadcast_api.js +4 -4
- package/dist/actions/compile_action_registry.d.ts +6 -7
- package/dist/actions/compile_action_registry.d.ts.map +1 -1
- package/dist/actions/compile_action_registry.js +8 -9
- package/dist/actions/perform_action.d.ts +6 -6
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +11 -10
- package/dist/actions/socket.svelte.d.ts +1 -1
- package/dist/actions/socket.svelte.js +2 -2
- package/dist/auth/CLAUDE.md +11 -11
- package/dist/auth/account_action_specs.d.ts +11 -11
- package/dist/auth/account_action_specs.js +1 -1
- package/dist/auth/account_route_schema.d.ts +18 -18
- package/dist/auth/account_route_schema.js +1 -1
- package/dist/auth/account_routes.js +1 -1
- package/dist/auth/account_schema.d.ts +38 -40
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +7 -8
- package/dist/auth/actor_lookup_action_specs.d.ts +7 -7
- package/dist/auth/actor_lookup_action_specs.js +1 -1
- package/dist/auth/actor_search_action_specs.d.ts +6 -6
- package/dist/auth/actor_search_action_specs.js +1 -1
- package/dist/auth/admin_action_specs.d.ts +166 -166
- package/dist/auth/admin_action_specs.js +1 -1
- package/dist/auth/app_settings_schema.d.ts +3 -3
- package/dist/auth/app_settings_schema.d.ts.map +1 -1
- package/dist/auth/app_settings_schema.js +1 -1
- package/dist/auth/audit_emitter.d.ts +6 -7
- package/dist/auth/audit_emitter.d.ts.map +1 -1
- package/dist/auth/audit_emitter.js +11 -22
- package/dist/auth/audit_log_ddl.d.ts +1 -1
- package/dist/auth/audit_log_ddl.js +1 -1
- package/dist/auth/audit_log_queries.d.ts +0 -13
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +3 -3
- package/dist/auth/audit_log_route_schema.d.ts +1 -1
- package/dist/auth/audit_log_route_schema.js +1 -1
- package/dist/auth/audit_log_schema.d.ts +69 -70
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +2 -2
- package/dist/auth/auth_ddl.d.ts +1 -1
- package/dist/auth/auth_ddl.js +1 -1
- package/dist/auth/bootstrap_route_schema.d.ts +4 -4
- package/dist/auth/bootstrap_route_schema.js +1 -1
- package/dist/auth/cell_action_specs.d.ts +466 -466
- package/dist/auth/cell_action_specs.js +1 -1
- package/dist/auth/cell_actions.d.ts +2 -2
- package/dist/auth/cell_actions.js +5 -5
- package/dist/auth/cell_audit_action_specs.d.ts +14 -14
- package/dist/auth/cell_audit_action_specs.js +1 -1
- package/dist/auth/cell_audit_metadata.d.ts +8 -8
- package/dist/auth/cell_audit_metadata.js +1 -1
- package/dist/auth/cell_field_action_specs.d.ts +55 -55
- package/dist/auth/cell_field_action_specs.js +1 -1
- package/dist/auth/cell_field_audit_metadata.d.ts +4 -4
- package/dist/auth/cell_field_audit_metadata.js +1 -1
- package/dist/auth/cell_grant_action_specs.d.ts +61 -61
- package/dist/auth/cell_grant_action_specs.js +1 -1
- package/dist/auth/cell_grant_audit_metadata.d.ts +10 -10
- package/dist/auth/cell_grant_audit_metadata.js +1 -1
- package/dist/auth/cell_item_action_specs.d.ts +76 -76
- package/dist/auth/cell_item_action_specs.js +1 -1
- package/dist/auth/cell_item_audit_metadata.d.ts +5 -5
- package/dist/auth/cell_item_audit_metadata.js +1 -1
- package/dist/auth/invite_schema.d.ts +11 -11
- package/dist/auth/invite_schema.d.ts.map +1 -1
- package/dist/auth/invite_schema.js +1 -1
- package/dist/auth/name_schema.js +1 -1
- package/dist/auth/password.js +1 -1
- package/dist/auth/request_context.js +2 -2
- package/dist/auth/role_grant_offer_action_specs.d.ts +182 -182
- package/dist/auth/role_grant_offer_action_specs.js +1 -1
- package/dist/auth/role_grant_offer_ddl.d.ts +1 -1
- package/dist/auth/role_grant_offer_ddl.js +1 -1
- package/dist/auth/role_grant_offer_notifications.d.ts +107 -107
- package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_notifications.js +3 -4
- package/dist/auth/role_grant_offer_schema.d.ts +9 -9
- package/dist/auth/role_grant_offer_schema.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_schema.js +1 -1
- package/dist/auth/self_service_role_action_specs.d.ts +2 -2
- package/dist/auth/self_service_role_action_specs.js +1 -1
- package/dist/auth/self_service_role_actions.d.ts +1 -1
- package/dist/auth/self_service_role_actions.js +1 -1
- package/dist/auth/signup_route_schema.d.ts +2 -2
- package/dist/auth/signup_route_schema.js +1 -1
- package/dist/auth/token_scope.d.ts +8 -8
- package/dist/db/file_fact_url.d.ts +1 -1
- package/dist/env/env_schemas.d.ts +1 -2
- package/dist/env/env_schemas.d.ts.map +1 -1
- package/dist/env/env_schemas.js +3 -4
- package/dist/http/CLAUDE.md +30 -32
- package/dist/http/auth_shape.d.ts +17 -52
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +19 -61
- package/dist/http/db_routes.d.ts +1 -1
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +1 -1
- package/dist/http/error_schemas.d.ts +36 -36
- package/dist/http/jsonrpc.d.ts +11 -11
- package/dist/http/jsonrpc_helpers.js +1 -1
- package/dist/http/route_error_check.d.ts +2 -2
- package/dist/http/route_error_check.d.ts.map +1 -1
- package/dist/http/route_error_check.js +2 -3
- package/dist/http/route_errors.d.ts +4 -4
- package/dist/http/route_errors.d.ts.map +1 -1
- package/dist/http/route_errors.js +0 -13
- package/dist/http/route_spec.d.ts +33 -36
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +21 -22
- package/dist/http/schema_helpers.d.ts +75 -67
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +54 -76
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +6 -8
- package/dist/primitive_schemas.d.ts +162 -112
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +129 -161
- package/dist/realtime/sse.d.ts +3 -3
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +2 -2
- package/dist/schema_issues.d.ts +41 -146
- package/dist/schema_issues.d.ts.map +1 -1
- package/dist/schema_issues.js +39 -322
- package/dist/schema_meta.d.ts +63 -136
- package/dist/schema_meta.d.ts.map +1 -1
- package/dist/schema_meta.js +37 -184
- package/dist/sensitivity.d.ts +3 -5
- package/dist/sensitivity.d.ts.map +1 -1
- package/dist/sensitivity.js +3 -5
- package/dist/server/serve_fact_route.js +1 -1
- package/dist/server/surface_route.js +1 -1
- package/dist/testing/CLAUDE.md +23 -25
- package/dist/testing/adversarial_headers.js +2 -2
- package/dist/testing/adversarial_input_cases.d.ts +19 -18
- package/dist/testing/adversarial_input_cases.d.ts.map +1 -1
- package/dist/testing/adversarial_input_cases.js +29 -42
- package/dist/testing/assertions.d.ts +2 -2
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +3 -3
- package/dist/testing/cross_backend/account_lifecycle.js +2 -2
- package/dist/testing/cross_backend/action_manifest.d.ts +10 -9
- package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest.js +4 -3
- package/dist/testing/cross_backend/cell_crud.js +1 -1
- package/dist/testing/cross_backend/conformance_case.d.ts +96 -114
- package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_case.js +0 -256
- package/dist/testing/cross_backend/conformance_rpc_auth.d.ts +0 -62
- package/dist/testing/cross_backend/conformance_rpc_auth.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +3 -3
- package/dist/testing/cross_backend/cross_rpc.d.ts +3 -4
- package/dist/testing/cross_backend/cross_rpc.d.ts.map +1 -1
- package/dist/testing/cross_backend/cross_rpc.js +4 -4
- package/dist/testing/cross_backend/differential.js +2 -2
- package/dist/testing/cross_backend/fact_serving.js +1 -1
- package/dist/testing/cross_backend/identity_parity.js +9 -9
- package/dist/testing/cross_backend/origin_conformance.d.ts +9 -9
- package/dist/testing/cross_backend/query_shape.js +1 -1
- package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +1 -1
- package/dist/testing/cross_backend/setup.d.ts +26 -4
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +7 -8
- package/dist/testing/cross_backend/sse_round_trip.js +2 -2
- package/dist/testing/cross_backend/testing_origin_check.d.ts +12 -12
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +608 -201
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +46 -55
- package/dist/testing/cross_backend/token_lifetime.js +3 -3
- package/dist/testing/cross_backend/wire_shapes.js +1 -1
- package/dist/testing/cross_backend/ws_outbound_overflow.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_outbound_overflow.js +35 -0
- package/dist/testing/cross_backend/ws_round_trip.js +1 -1
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +1 -1
- package/dist/testing/integration.js +2 -2
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +2 -2
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +2 -2
- package/dist/testing/rpc_attack_surface.js +1 -1
- package/dist/testing/rpc_envelope_cases.d.ts +3 -3
- package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
- package/dist/testing/rpc_envelope_cases.js +1 -1
- package/dist/testing/rpc_helpers.d.ts +12 -14
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +9 -11
- package/dist/testing/schema_generators.d.ts +67 -60
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +144 -151
- package/dist/testing/schema_introspect.d.ts +438 -78
- package/dist/testing/schema_introspect.d.ts.map +1 -1
- package/dist/testing/schema_introspect.js +26 -26
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +2 -2
- package/dist/testing/surface_invariants.d.ts +1 -1
- package/dist/testing/surface_invariants.js +1 -1
- package/dist/testing/transports/bootstrap.d.ts +1 -1
- package/dist/testing/transports/bootstrap.d.ts.map +1 -1
- package/dist/testing/transports/bootstrap.js +1 -1
- package/dist/ui/BootstrapForm.svelte +1 -2
- package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -1
- package/dist/ui/SignupForm.svelte +1 -2
- package/dist/ui/SignupForm.svelte.d.ts.map +1 -1
- package/dist/ui/admin_accounts_state.svelte.d.ts +5 -5
- package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_invites_state.svelte.d.ts +1 -1
- package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_sessions_state.svelte.d.ts +2 -2
- package/dist/ui/admin_sessions_state.svelte.d.ts.map +1 -1
- package/dist/ui/form_state.svelte.d.ts +1 -1
- package/dist/ui/form_state.svelte.js +1 -1
- package/dist/ui/role_grant_offers_state.svelte.d.ts +1 -1
- package/package.json +7 -9
- package/dist/primitive_schemas_fuz.d.ts +0 -178
- package/dist/primitive_schemas_fuz.d.ts.map +0 -1
- package/dist/primitive_schemas_fuz.js +0 -149
- package/dist/zod.d.ts +0 -101
- package/dist/zod.d.ts.map +0 -1
- package/dist/zod.js +0 -195
package/dist/actions/CLAUDE.md
CHANGED
|
@@ -17,9 +17,8 @@ ordering see the root ../../../CLAUDE.md §Action Spec System (SAES) and
|
|
|
17
17
|
to the code. This file documents the cross-cutting invariants and the
|
|
18
18
|
shapes that span multiple files.
|
|
19
19
|
|
|
20
|
-
Every exported
|
|
21
|
-
|
|
22
|
-
the pair invariant.
|
|
20
|
+
Every exported schema is a `@fuzdev/fuz_schema` schema paired with a
|
|
21
|
+
same-named `Infer` type export. New schemas keep the pair invariant.
|
|
23
22
|
|
|
24
23
|
## Action specs (`actions/action_spec.ts`)
|
|
25
24
|
|
|
@@ -27,14 +26,14 @@ Canonical source of truth. Specs are plain objects typed by TS interfaces
|
|
|
27
26
|
(`ActionSpec` and its three kinds, `ActionSpecUnion`), written with
|
|
28
27
|
`satisfies` so their literals survive; nothing parses a spec at runtime, so
|
|
29
28
|
every required field is spelled — no defaults. `input` / `output` are a
|
|
30
|
-
|
|
29
|
+
`@fuzdev/fuz_schema` schema (`AnySchema`). `ActionKind`,
|
|
31
30
|
`ActionInitiator` and `ActionEventPhase` are fuz_schema `one_of`s
|
|
32
31
|
(`ActionEventData` validates with them), built from the const lists `ACTION_KINDS`,
|
|
33
32
|
`ACTION_INITIATORS` and `ACTION_EVENT_PHASES`; `is_action_spec` reads
|
|
34
33
|
`ACTION_KINDS`. Three concrete kinds discriminate on `kind`:
|
|
35
34
|
|
|
36
35
|
- `request_response` — `auth: RouteAuth` (non-null), `side_effects` arbitrary, `output` arbitrary, `async: true`.
|
|
37
|
-
- `remote_notification` — `auth: null`, `side_effects: true`, `output`
|
|
36
|
+
- `remote_notification` — `auth: null`, `side_effects: true`, `output` fuz_schema's void schema, `s.void`, `async: true`.
|
|
38
37
|
- `local_call` — `auth: null`, `side_effects` arbitrary, `output` arbitrary, `async` boolean.
|
|
39
38
|
|
|
40
39
|
`RouteAuth` is the flat record
|
|
@@ -88,12 +87,12 @@ non-`remote_notification` kind.
|
|
|
88
87
|
`create_rpc_endpoint` and `register_action_ws`. Validates these checks in
|
|
89
88
|
order and returns the `Map<method, RpcAction>` the dispatchers use:
|
|
90
89
|
|
|
91
|
-
- **Schema slots** — `input` and `output` each hold a
|
|
90
|
+
- **Schema slots** — `input` and `output` each hold a fuz_schema schema (via `assert_validation_schema`, `schema_issues.ts`), on every spec; a value that is no schema throws naming the action and the slot.
|
|
92
91
|
- **Auth-shape cross-axis invariants** — roles imply a required actor, no accountless actor, nothing to gate on unrestricted auth (via `assert_route_auth_invariants`).
|
|
93
92
|
- **Auth-shape biconditional** — `actor !== 'none' ⟺ input declares acting?: ActingActor` (via `assert_route_auth_acting_biconditional`).
|
|
94
93
|
- **No `auth.required_scope`** — the slot is route-spec-only; nothing mounts a guard from it on an action, so declaring it would be a control that silently does nothing. Narrowed tokens are gated per method by the scope check in `perform_action`, which derives the `rpc:<method>` capability from `spec.method` rather than trusting a hand-written one.
|
|
95
94
|
- **Rate-limit account axis** — `rate_limit: 'account' | 'both'` requires `auth.account === 'required'`.
|
|
96
|
-
- **JSON-RPC §4.2 wire validity** — `request_response` specs with a handler may not use a null schema (`
|
|
95
|
+
- **JSON-RPC §4.2 wire validity** — `request_response` specs with a handler may not use a null schema (`literal(null)`) for input (use a void schema, `s.void`, for nullary), nor a void schema for output (a response always carries a `result`, which clients validate against `spec.output`; use a null schema when there's nothing to return). Both are detected by shape (`is_null_schema` / `is_void_schema`), so a `meta` copy counts.
|
|
97
96
|
- **Unique method names** across the array.
|
|
98
97
|
|
|
99
98
|
Only `request_response` specs with a handler reach the dispatch map;
|
|
@@ -138,11 +137,11 @@ and options on each function's TSDoc.
|
|
|
138
137
|
- `get_executor_phases(spec, executor)` — phases an executor participates in for the spec.
|
|
139
138
|
- `get_handler_return_type` — TS type a phase handler must return; side-effect imports `ActionOutputs`.
|
|
140
139
|
- `generate_phase_handlers` — per-action typed handler-map fragment.
|
|
141
|
-
- `generate_frontend_actions_api` — typed `FrontendActionsApi` interface. A void or null input
|
|
142
|
-
- `generate_action_method_enums` — up to nine `
|
|
140
|
+
- `generate_frontend_actions_api` — typed `FrontendActionsApi` interface. A void or null input (`is_void_schema`, `is_null_schema`) emits `input?: void`; otherwise each method's `input?:` follows `action_input_is_optional` (by `parse`) — the schema accepts `undefined`, or accepts `{}` and is not marked `meta(…, {empty_input_handler_guarded: true})` (read by `is_empty_input_handler_guarded` in `schema_meta.ts` — set on `cell_get`, `cell_field_list` and `cell_item_list`, whose `{}` reaches a handler guard that refuses it with a declared reason, so their input stays required; a consumer marks its own the same way); an input-shape invariant test reads the same rule. Each input is typed `ActionCallInputs[method]`, the schema's input type — what a caller passes before the parse, so a `with_default` field is optional at the call.
|
|
141
|
+
- `generate_action_method_enums` — up to nine `@fuzdev/fuz_schema` `one_of` + `Infer` pairs, importing `{one_of, type Infer}` from `@fuzdev/fuz_schema/schema.ts`; a const's `def` is its method array.
|
|
143
142
|
- `generate_typed_action_event_alias` — fixed-shape `TypedActionEvent<TMethod, TPhase, TStep>` alias.
|
|
144
143
|
- `generate_action_specs_record` — `ActionSpecs` runtime const + type + `action_specs` array. The const is annotated with the type (`readonly` members), so a consumer's declaration emit names the type instead of writing every spec's schema types out, which past enough specs is TS7056. The type is an alias, not an interface: an alias has an implicit index signature, so `Object.values(ActionSpecs)` stays typed and `action_specs` checks each spec against `ActionSpecUnion` (over an interface it is `any[]`).
|
|
145
|
-
- `generate_action_inputs_outputs` — `ActionInputs` + `ActionOutputs` runtime consts + interfaces,
|
|
144
|
+
- `generate_action_inputs_outputs` — `ActionInputs` + `ActionOutputs` runtime consts + interfaces, plus the `ActionCallInputs` interface, importing `Infer` and `InferInput`; a value that is no schema throws naming the method. The two sides of a call see one input schema differently, so its types split by side: `ActionInputs` is each input's output type (`Infer<typeof …>`) — the parsed value a handler, an action event (`ActionEventDatas`) or a notification receiver reads, defaults filled and transforms applied; `ActionCallInputs` is its input type (`InferInput<typeof …>`) — what a caller passes, which the call surfaces (`FrontendActionsApi`, `BackendActionsApi`) take, so a `with_default` field is optional there and required in `ActionInputs`. `ActionOutputs` is each output's output type, what a caller receives.
|
|
146
145
|
- `generate_action_event_datas` — `ActionEventDatas` interface; per-spec variants.
|
|
147
146
|
- `generate_frontend_action_handlers` — `FrontendActionHandlers` interface (Tier 2 only).
|
|
148
147
|
- `generate_backend_actions_api` — `BackendActionsApi` interface + `broadcast_action_specs` array.
|
|
@@ -260,9 +259,8 @@ interface RpcAction {
|
|
|
260
259
|
### `rpc_action(spec, handler)` — typed binder
|
|
261
260
|
|
|
262
261
|
`rpc_action<TSpec extends RequestResponseActionSpec>(spec, handler)` pins
|
|
263
|
-
the handler's input / output types to `
|
|
264
|
-
`
|
|
265
|
-
or Zod's `z.output`, per spec) and tightens `ctx.auth` per the conditional
|
|
262
|
+
the handler's input / output types to `Infer<TSpec['input']>` /
|
|
263
|
+
`Infer<TSpec['output']>` and tightens `ctx.auth` per the conditional
|
|
266
264
|
`HandlerForSpec<TSpec>`:
|
|
267
265
|
|
|
268
266
|
- `auth.actor === 'required'` → `ctx.auth: RequestActorContext`.
|
|
@@ -294,7 +292,7 @@ Pipeline (401 → authz → 403 → 429 → 400 → handler):
|
|
|
294
292
|
2. Authorization phase — `apply_authorization_phase` against `account_id` + `read_acting(auth, raw_params)`, which takes the selector off the raw params (malformed reads as omitted) since validation runs later. Test escape hatch via `preset.request_context`
|
|
295
293
|
3. Post-authorization auth (403) — credential-type gate, then token scope, then role
|
|
296
294
|
4. Rate limit (429) — throttle-requests semantics, ahead of validation so malformed params charge the budget and a throttled caller pays no schema work
|
|
297
|
-
5. Validate params (400) — first, object params holding an own `__proto__` key at any depth are refused on every input with `data.reason` `params_proto_key` (`json_has_own_proto_key` in `http/schema_helpers.ts`, an iterative walk; `ERROR_PARAMS_PROTO_KEY`; the Rust twin walks after its params-shape check, so a non-object `params` stays the schema's reasonless refusal); then `spec.input` parses them (`
|
|
295
|
+
5. Validate params (400) — first, object params holding an own `__proto__` key at any depth are refused on every input with `data.reason` `params_proto_key` (`json_has_own_proto_key` in `http/schema_helpers.ts`, an iterative walk; `ERROR_PARAMS_PROTO_KEY`; the Rust twin walks after its params-shape check, so a non-object `params` stays the schema's reasonless refusal); then `spec.input` parses them (`parse`) with void / `?? {}` rules; a void input (`is_void_schema`: `s.void`) reads absent, `null` (GET `?params=null`), and `{}` alike as the no-arg call (`to_input_params` in `http/schema_helpers.ts`, via `to_void_params`, the twin of the Rust `require_void_params`; the peer receive path in `ActionDispatcher` runs the same normalizer) and refuses any other shape. A refusal is `to_invalid_params_error`: the generic `invalid params`, `data.reason` when the first issue's field declares an `invalid_reason` in its `meta` and no issue sits on the input itself, such as an unknown key (`resolve_issues_invalid_reason`, `schema_meta.ts` — see ../../../docs/architecture.md §Error Schema System), and the issues DEV-only, as `WireIssue`s (`to_wire_issues`)
|
|
298
296
|
6. Dispatch + DEV output validation + error normalization — `spec.side_effects` picks transaction vs pool. `ThrownJsonrpcError` preserves code + data; generic throws become `internal_error`
|
|
299
297
|
|
|
300
298
|
`PerformActionInput` carries `auth` (the request's `ResolvedAuth`, `null` for
|
|
@@ -320,7 +318,7 @@ validation and produces the **same failure mode** as REST routes'
|
|
|
320
318
|
`wrap_output_validation` (`http/route_spec.ts`) — log an error, return
|
|
321
319
|
the response unchanged, do not throw, do not mutate status.
|
|
322
320
|
|
|
323
|
-
- HTTP RPC + WebSocket dispatch — `actions/perform_action.ts` `if (DEV) spec.output
|
|
321
|
+
- HTTP RPC + WebSocket dispatch — `actions/perform_action.ts` `if (DEV) parse(spec.output, output)` inside the shared dispatch core. Production hot path short-circuits (no parse).
|
|
324
322
|
|
|
325
323
|
Caller-facing `input` schemas are validated **always** (DEV + production)
|
|
326
324
|
— they're the contract with external callers. Server-authored `output`
|
|
@@ -1091,7 +1089,7 @@ high-level shapes that span modules:
|
|
|
1091
1089
|
- **Discriminated union** — `ActionEventDataUnion<TMethod, TInput, TOutput>` across `kind` + `phase` + `step`, a variant per lifecycle point of each kind. Narrows `input` / `output` / `error` / `request` / `response` / `notification` / `progress` at each lifecycle point.
|
|
1092
1090
|
- **Step transitions** — `initial → parsed | failed`, `parsed → handling | failed`, `handling → handled | failed`, `handled`/`failed` terminal. `validate_step_transition(from, to)` throws on illegal moves.
|
|
1093
1091
|
- **Phase transitions** — chained: `send_request → receive_response`, `receive_request → send_response`; everything else terminal. `validate_phase_transition` enforces.
|
|
1094
|
-
- **`ActionEvent.parse()`** — `initial → parsed` via `
|
|
1092
|
+
- **`ActionEvent.parse()`** — `initial → parsed` via `parse(spec.input, …)`. Input validation failures **fail immediately** without routing through an error phase (client-side programming errors, not runtime conditions with handlers); their `invalid_params` `data` is `{validation_errors, reason?}`, `reason` the declared `invalid_reason` the server would answer. Handler errors DO route through `send_error` / `receive_error`. On `receive_response` with error response, transitions to `receive_error` instead of failing; a success response's `result` is validated against `spec.output` (always, not DEV-only — it's inbound data; undeclared keys are dropped rather than refused, so an older client survives an added response field) and `output` becomes the parsed value, or the event moves to `receive_error` with an `internal_error` carrying `data: {reason: ERROR_RESPONSE_OUTPUT_INVALID, validation_errors}` — a remote contract break, deliberately distinct from the `invalid_params` / `validation_error` of bad caller input.
|
|
1095
1093
|
- **Handler throws** — `ThrownJsonrpcError` keeps code/message/data; any other throw becomes `internal_error` carrying the thrown message. When the error answers a remote caller (`receive_request` / `send_response`), the raw message goes through `dev_only` like the server dispatch core.
|
|
1096
1094
|
- **Protocol message creation is automatic** — transitioning `parsed → handling` on `send_request` materializes the outgoing `JsonrpcRequest` with a fresh `create_uuid()` id; on `send` (notification) it materializes the `JsonrpcNotification`.
|
|
1097
1095
|
|
|
@@ -1105,7 +1103,7 @@ methods) go to `environment.log`; unset falls back to `console_action_log`
|
|
|
1105
1103
|
(warn/error to `console`, debug dropped) so failures are never silent, and
|
|
1106
1104
|
`log: null` opts out (`resolve_action_log`). An inbound request or notification
|
|
1107
1105
|
reads its params through the server dispatch core's normalizer
|
|
1108
|
-
(`to_input_params`): for a void input (`
|
|
1106
|
+
(`to_input_params`): for a void input (`s.void`),
|
|
1109
1107
|
absent, `null`, and `{}` alike are the no-arg call; for any other input,
|
|
1110
1108
|
absent or `null` params are `{}` (so an all-optional object input accepts a
|
|
1111
1109
|
call that omits them).
|
|
@@ -1258,8 +1256,8 @@ specs. Counterpart to `register_action_ws`: that handles frontend-initiated
|
|
|
1258
1256
|
request-scoped dispatch, this handles backend-initiated broadcast.
|
|
1259
1257
|
Request-scoped streaming stays on `ctx.notify` inside a handler.
|
|
1260
1258
|
|
|
1261
|
-
Per-method call: validates input against `spec.input
|
|
1262
|
-
(`
|
|
1259
|
+
Per-method call: validates input against `spec.input`
|
|
1260
|
+
(`parse`; logs + returns on failure), wraps in `JsonrpcNotification`, and sends it on `registry` — a
|
|
1263
1261
|
`BroadcastTarget`, `Pick<ConnectionRegistry, 'broadcast' |
|
|
1264
1262
|
'broadcast_filtered'>`, typically `app_server.ws_endpoints[path]` or the
|
|
1265
1263
|
registry a `WsEndpointSpec` supplies. No `Transports` collection and no fallback:
|
|
@@ -120,33 +120,32 @@ export declare const generate_phase_handlers: (spec: ActionSpecUnion, executor:
|
|
|
120
120
|
/**
|
|
121
121
|
* Whether a caller may omit an action's input: its schema accepts `undefined`,
|
|
122
122
|
* or accepts `{}` (what an omitted input is validated as) and is not marked
|
|
123
|
-
* `empty_input_handler_guarded` (
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* `@fuzdev/fuz_schema` schema, parsed with `parse_any`.
|
|
123
|
+
* `empty_input_handler_guarded` (read by `is_empty_input_handler_guarded`).
|
|
124
|
+
* The rule codegen emits `input?:` by and the input-shape invariant tests
|
|
125
|
+
* read, parsed with `parse`.
|
|
127
126
|
*
|
|
128
127
|
* @param spec - the action spec
|
|
129
128
|
* @returns whether the typed surface makes the input optional
|
|
130
|
-
* @throws Error when the input is neither a Zod nor a fuz_schema schema
|
|
131
129
|
*/
|
|
132
130
|
export declare const action_input_is_optional: (spec: Pick<ActionSpecUnion, "input">) => boolean;
|
|
133
131
|
/** Discriminator for `generate_action_method_enums` — which method-set enums to emit. */
|
|
134
132
|
export type ActionMethodEnumKind = 'all' | 'request_response' | 'remote_notification' | 'local_call' | 'frontend' | 'backend' | 'frontend_handled' | 'backend_handled' | 'broadcast';
|
|
135
133
|
/**
|
|
136
|
-
* Emit one or more `
|
|
134
|
+
* Emit one or more `@fuzdev/fuz_schema` `one_of([...])` declarations for
|
|
135
|
+
* action method names —
|
|
137
136
|
* `ActionMethod`, `RequestResponseActionMethod`, `RemoteNotificationActionMethod`,
|
|
138
137
|
* `LocalCallActionMethod`, `FrontendActionMethod`, `BackendActionMethod`,
|
|
139
138
|
* `FrontendRequestResponseMethod`, `BackendRequestResponseMethod`,
|
|
140
|
-
* `BroadcastActionMethod`. Pairs each runtime const with
|
|
141
|
-
* alias under the same identifier.
|
|
139
|
+
* `BroadcastActionMethod`. Pairs each runtime const with an `Infer` type
|
|
140
|
+
* alias under the same identifier. A const's `def` is its array of methods.
|
|
142
141
|
*
|
|
143
142
|
* Protocol-action methods (`heartbeat`, `cancel`) are filtered out by
|
|
144
143
|
* default — pass `include_protocol_actions: true` if a consumer genuinely
|
|
145
|
-
* wants them on their typed surface. Empty kinds are skipped so
|
|
146
|
-
*
|
|
144
|
+
* wants them on their typed surface. Empty kinds are skipped, so every
|
|
145
|
+
* emitted const names at least one method.
|
|
147
146
|
*
|
|
148
|
-
* Adds `import {
|
|
149
|
-
* is emitted (idempotent).
|
|
147
|
+
* Adds `import {one_of, type Infer} from '@fuzdev/fuz_schema/schema.ts';` to
|
|
148
|
+
* `imports` only when at least one block is emitted (idempotent).
|
|
150
149
|
*
|
|
151
150
|
* @param options.emit - subset of enums to emit; defaults to every kind
|
|
152
151
|
* @param options.include_protocol_actions - when true, retains `heartbeat` /
|
|
@@ -199,22 +198,32 @@ export declare const generate_action_specs_record: (specs: ReadonlyArray<ActionS
|
|
|
199
198
|
include_protocol_actions?: boolean;
|
|
200
199
|
}) => string;
|
|
201
200
|
/**
|
|
202
|
-
* Emit `ActionInputs` + `ActionOutputs` runtime consts and matching
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
* Zod schema, `Infer` for a `@fuzdev/fuz_schema` one.
|
|
201
|
+
* Emit `ActionInputs` + `ActionOutputs` runtime consts and matching
|
|
202
|
+
* interfaces, plus the `ActionCallInputs` interface. The runtime consts
|
|
203
|
+
* reference `specs.{method}_action_spec.input` / `.output`.
|
|
206
204
|
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
205
|
+
* The two sides of a call see different types for one input schema, so the
|
|
206
|
+
* interfaces split by side:
|
|
207
|
+
*
|
|
208
|
+
* - `ActionInputs` types each input as its schema's output (`Infer`) — the
|
|
209
|
+
* parsed value a handler, an action event, or a notification receiver reads,
|
|
210
|
+
* with defaults filled and transforms applied.
|
|
211
|
+
* - `ActionCallInputs` types each input as its schema's input (`InferInput`)
|
|
212
|
+
* — what a caller passes, before the parse: a `with_default` field is
|
|
213
|
+
* optional there and required in `ActionInputs`. The call surfaces
|
|
214
|
+
* (`FrontendActionsApi`, `BackendActionsApi`) read it.
|
|
215
|
+
* - `ActionOutputs` types each output as its schema's output, what a caller
|
|
216
|
+
* receives.
|
|
217
|
+
*
|
|
218
|
+
* Adds `import type {Infer, InferInput} from '@fuzdev/fuz_schema/schema.ts';`
|
|
219
|
+
* and the `* as specs` namespace import.
|
|
210
220
|
*
|
|
211
221
|
* @param options.qualify_spec - per-spec qualified identifier callback for
|
|
212
222
|
* multi-source consumers. The helper appends `.input` / `.output` to the
|
|
213
223
|
* callback's return value. When set, the helper skips the default
|
|
214
224
|
* `* as specs` import — the consumer manages its own namespace imports —
|
|
215
225
|
* and `specs_module` is ignored. Single-source consumers omit it.
|
|
216
|
-
* @throws Error naming the method when an input or output is
|
|
217
|
-
* nor a fuz_schema schema
|
|
226
|
+
* @throws Error naming the method when an input or output is no schema
|
|
218
227
|
*/
|
|
219
228
|
export declare const generate_action_inputs_outputs: (specs: ReadonlyArray<ActionSpecUnion>, imports: ImportBuilder, options?: {
|
|
220
229
|
specs_module?: string;
|
|
@@ -254,7 +263,7 @@ export declare const generate_action_event_datas: (specs: ReadonlyArray<ActionSp
|
|
|
254
263
|
*
|
|
255
264
|
* Imports are registered per emitted line — only what the spec set actually references shows up on
|
|
256
265
|
* `imports`. A spec set with no async methods skips `RpcClientCallOptions`;
|
|
257
|
-
* one with no inputs skips `
|
|
266
|
+
* one with no inputs skips `ActionCallInputs`; sync `local_call` methods with
|
|
258
267
|
* `sync_returns_value: true` (the default) skip `Result` / `JsonrpcErrorObject`.
|
|
259
268
|
*
|
|
260
269
|
* The interface name is fixed at `FrontendActionsApi` — the symmetric counterpart
|
|
@@ -295,7 +304,7 @@ export declare const generate_frontend_action_handlers: (specs: ReadonlyArray<Ac
|
|
|
295
304
|
* exclusion list.
|
|
296
305
|
*
|
|
297
306
|
* Adds the `* as specs` namespace import (from `specs_module`), the
|
|
298
|
-
* `
|
|
307
|
+
* `ActionCallInputs` type import (from `collections_path`), and the
|
|
299
308
|
* `ActionSpecUnion` type import.
|
|
300
309
|
*
|
|
301
310
|
* Method signature shape today is `(input) => Promise<void>` — matches the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_codegen.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_codegen.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAG1E;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,+CAAgD,CAAC;AAErF,8FAA8F;AAC9F,MAAM,MAAM,oBAAoB,GAA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;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC9B,KAAG,MAYH,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { UnreachableError } from '@fuzdev/fuz_util/error.ts';
|
|
2
|
-
import {
|
|
2
|
+
import { parse } from '@fuzdev/fuz_schema/schema.ts';
|
|
3
3
|
import { is_empty_input_handler_guarded } from '../schema_meta.js';
|
|
4
4
|
import { is_null_schema, is_void_schema } from '../http/schema_helpers.js';
|
|
5
|
-
import {
|
|
5
|
+
import { assert_validation_schema } from '../schema_issues.js';
|
|
6
6
|
import { ActionRegistry } from './action_registry.js';
|
|
7
7
|
/**
|
|
8
8
|
* Method names of fuz_app's protocol actions — `heartbeat` (auth-aware client
|
|
@@ -323,35 +323,29 @@ const to_action_property_key = (method) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(met
|
|
|
323
323
|
/**
|
|
324
324
|
* Whether a caller may omit an action's input: its schema accepts `undefined`,
|
|
325
325
|
* or accepts `{}` (what an omitted input is validated as) and is not marked
|
|
326
|
-
* `empty_input_handler_guarded` (
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
* `@fuzdev/fuz_schema` schema, parsed with `parse_any`.
|
|
326
|
+
* `empty_input_handler_guarded` (read by `is_empty_input_handler_guarded`).
|
|
327
|
+
* The rule codegen emits `input?:` by and the input-shape invariant tests
|
|
328
|
+
* read, parsed with `parse`.
|
|
330
329
|
*
|
|
331
330
|
* @param spec - the action spec
|
|
332
331
|
* @returns whether the typed surface makes the input optional
|
|
333
|
-
* @throws Error when the input is neither a Zod nor a fuz_schema schema
|
|
334
332
|
*/
|
|
335
333
|
export const action_input_is_optional = (spec) => {
|
|
336
|
-
if (
|
|
334
|
+
if (parse(spec.input, undefined).ok)
|
|
337
335
|
return true;
|
|
338
336
|
if (is_empty_input_handler_guarded(spec.input))
|
|
339
337
|
return false;
|
|
340
|
-
return
|
|
338
|
+
return parse(spec.input, {}).ok;
|
|
341
339
|
};
|
|
342
340
|
/**
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
341
|
+
* Throw unless a spec's input or output is a `@fuzdev/fuz_schema` schema,
|
|
342
|
+
* naming the method and the slot — codegen reads specs nothing has
|
|
343
|
+
* registered, so it checks them itself.
|
|
346
344
|
*
|
|
347
|
-
* @throws Error naming the method and the
|
|
345
|
+
* @throws Error naming the method and the slot when it is no schema
|
|
348
346
|
*/
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
if (is_schema(schema))
|
|
352
|
-
return 'fuz_schema';
|
|
353
|
-
assert_zod_schema(schema, `action '${spec.method}' ${which}`);
|
|
354
|
-
return 'zod';
|
|
347
|
+
const assert_spec_schema = (spec, which) => {
|
|
348
|
+
assert_validation_schema(spec[which], `action '${spec.method}' ${which}`);
|
|
355
349
|
};
|
|
356
350
|
/**
|
|
357
351
|
* Generates one method line of the typed `FrontendActionsApi` interface for a
|
|
@@ -370,8 +364,12 @@ const to_spec_schema_library = (spec, which) => {
|
|
|
370
364
|
* failure). Earlier emit shapes declared notifications as `=> void` —
|
|
371
365
|
* regenerate consumer typed clients to pick up the corrected return.
|
|
372
366
|
*
|
|
367
|
+
* The input is typed by `ActionCallInputs` — the schema's input type, what
|
|
368
|
+
* the caller passes before the parse — so a defaulted field is optional at the
|
|
369
|
+
* call while the handler reads it filled in (`ActionInputs`).
|
|
370
|
+
*
|
|
373
371
|
* Registers exactly the imports the emitted line references on `imports`:
|
|
374
|
-
* `
|
|
372
|
+
* `ActionCallInputs` (when the spec has input), `ActionOutputs` (always),
|
|
375
373
|
* `RpcClientCallOptions` (async only), and `Result` + `JsonrpcErrorObject`
|
|
376
374
|
* (any return shape that wraps the value in `Result<{value}, {error}>` —
|
|
377
375
|
* every async method, plus sync `local_call` when `sync_returns_value:
|
|
@@ -381,46 +379,43 @@ const to_spec_schema_library = (spec, which) => {
|
|
|
381
379
|
*
|
|
382
380
|
* **Optional-input detection.** The emitted parameter is `input?:` (caller
|
|
383
381
|
* may omit the argument) when either (a) the schema accepts `undefined` —
|
|
384
|
-
* `
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
* non-`z.void()` schemas in `actions/action_rpc.ts` / `http/route_spec.ts`):
|
|
382
|
+
* `optional(object(...))` and similar wrappers — or (b) the schema accepts
|
|
383
|
+
* the empty object `{}` — `object({acting: ActingActor})` and other
|
|
384
|
+
* all-optional-fields strict objects. The second probe mirrors the
|
|
385
|
+
* dispatcher's HTTP convention (`raw_params ?? {}` for non-void schemas in `actions/action_rpc.ts` / `http/route_spec.ts`):
|
|
389
386
|
* if a request with no params reaches the handler, this is the value the
|
|
390
387
|
* schema is asked to validate. A schema with required fields fails both
|
|
391
|
-
* probes and stays `input:` (required at the typed surface).
|
|
392
|
-
*
|
|
388
|
+
* probes and stays `input:` (required at the typed surface). Checks and
|
|
389
|
+
* transforms run as part of the parse (`parse`), so their accept/reject
|
|
393
390
|
* decisions feed into the optional/required choice naturally. An input
|
|
394
391
|
* marked `empty_input_handler_guarded` is the exception: its schema accepts
|
|
395
392
|
* `{}` but the handler refuses it, so it stays `input:`
|
|
396
393
|
* (`action_input_is_optional` is the one rule).
|
|
397
394
|
*
|
|
398
|
-
* **No-input detection.** A void or null input — `
|
|
399
|
-
*
|
|
400
|
-
*
|
|
401
|
-
* and no `ActionInputs` import.
|
|
395
|
+
* **No-input detection.** A void or null input — `literal(undefined)`
|
|
396
|
+
* (`s.void`) or `literal(null)`, read by shape (`is_void_schema`, `is_null_schema`) — emits `input?: void`
|
|
397
|
+
* and no `ActionCallInputs` import.
|
|
402
398
|
*
|
|
403
399
|
* @param options.sync_returns_value - When true (default), sync `local_call`
|
|
404
400
|
* methods return the output value directly; when false they're wrapped in
|
|
405
401
|
* `Result<{value, error}>` like async methods. Set to `false` if your
|
|
406
402
|
* `FrontendActionsApi` treats every method uniformly.
|
|
407
|
-
* @param options.collections_path - Import path that `
|
|
403
|
+
* @param options.collections_path - Import path that `ActionCallInputs` /
|
|
408
404
|
* `ActionOutputs` resolve to. Defaults to `'./action_collections.ts'`.
|
|
409
|
-
* @returns one line like `foo: (input:
|
|
410
|
-
* @throws Error naming the method when the input is
|
|
411
|
-
* fuz_schema schema
|
|
405
|
+
* @returns one line like `foo: (input: ActionCallInputs['foo'], options?: RpcClientCallOptions) => Promise<Result<...>>;`
|
|
406
|
+
* @throws Error naming the method when the input is no schema
|
|
412
407
|
*/
|
|
413
408
|
const generate_actions_api_method_signature = (spec, imports, options) => {
|
|
414
409
|
const sync_returns_value = options?.sync_returns_value ?? true;
|
|
415
410
|
const collections_path = options?.collections_path ?? DEFAULT_COLLECTIONS_PATH;
|
|
416
|
-
|
|
411
|
+
assert_spec_schema(spec, 'input');
|
|
417
412
|
const has_input = !is_null_schema(spec.input) && !is_void_schema(spec.input);
|
|
418
413
|
const input_optional = has_input && action_input_is_optional(spec);
|
|
419
414
|
const input_param = has_input
|
|
420
|
-
? `input${input_optional ? '?' : ''}:
|
|
415
|
+
? `input${input_optional ? '?' : ''}: ActionCallInputs['${spec.method}']`
|
|
421
416
|
: 'input?: void';
|
|
422
417
|
if (has_input)
|
|
423
|
-
imports.add_type(collections_path, '
|
|
418
|
+
imports.add_type(collections_path, 'ActionCallInputs');
|
|
424
419
|
imports.add_type(collections_path, 'ActionOutputs');
|
|
425
420
|
const is_async = spec.kind === 'request_response' || spec.kind === 'remote_notification' || spec.async;
|
|
426
421
|
const options_param = is_async ? ', options?: RpcClientCallOptions' : '';
|
|
@@ -460,19 +455,20 @@ const generate_actions_api_method_signature = (spec, imports, options) => {
|
|
|
460
455
|
// `create_namespace_qualifier` automates the source-table → qualifier wiring.
|
|
461
456
|
// --------------------------------------------------------------------------
|
|
462
457
|
/**
|
|
463
|
-
* Format a `
|
|
464
|
-
* Caller is responsible for ensuring `methods` is
|
|
465
|
-
*
|
|
458
|
+
* Format a `@fuzdev/fuz_schema` `one_of([...])` runtime const + matching
|
|
459
|
+
* `Infer` type alias. Caller is responsible for ensuring `methods` is
|
|
460
|
+
* non-empty and registering the `one_of` and `Infer` imports on the
|
|
461
|
+
* `ImportBuilder`.
|
|
466
462
|
*/
|
|
467
463
|
const format_method_enum_block = (name, jsdoc, methods) => {
|
|
468
464
|
const lines = methods.map((m) => `\t'${m}',`).join('\n');
|
|
469
465
|
return `/**
|
|
470
466
|
* ${jsdoc}
|
|
471
467
|
*/
|
|
472
|
-
export const ${name} =
|
|
468
|
+
export const ${name} = one_of([
|
|
473
469
|
${lines}
|
|
474
470
|
]);
|
|
475
|
-
export type ${name} =
|
|
471
|
+
export type ${name} = Infer<typeof ${name}>;`;
|
|
476
472
|
};
|
|
477
473
|
/** Default emit set — every enum kind. */
|
|
478
474
|
const action_method_enum_kinds_all = new Set([
|
|
@@ -516,20 +512,21 @@ const resolve_spec_qualifier = (imports, options) => {
|
|
|
516
512
|
return (s) => `specs.${to_action_spec_identifier(s.method)}`;
|
|
517
513
|
};
|
|
518
514
|
/**
|
|
519
|
-
* Emit one or more `
|
|
515
|
+
* Emit one or more `@fuzdev/fuz_schema` `one_of([...])` declarations for
|
|
516
|
+
* action method names —
|
|
520
517
|
* `ActionMethod`, `RequestResponseActionMethod`, `RemoteNotificationActionMethod`,
|
|
521
518
|
* `LocalCallActionMethod`, `FrontendActionMethod`, `BackendActionMethod`,
|
|
522
519
|
* `FrontendRequestResponseMethod`, `BackendRequestResponseMethod`,
|
|
523
|
-
* `BroadcastActionMethod`. Pairs each runtime const with
|
|
524
|
-
* alias under the same identifier.
|
|
520
|
+
* `BroadcastActionMethod`. Pairs each runtime const with an `Infer` type
|
|
521
|
+
* alias under the same identifier. A const's `def` is its array of methods.
|
|
525
522
|
*
|
|
526
523
|
* Protocol-action methods (`heartbeat`, `cancel`) are filtered out by
|
|
527
524
|
* default — pass `include_protocol_actions: true` if a consumer genuinely
|
|
528
|
-
* wants them on their typed surface. Empty kinds are skipped so
|
|
529
|
-
*
|
|
525
|
+
* wants them on their typed surface. Empty kinds are skipped, so every
|
|
526
|
+
* emitted const names at least one method.
|
|
530
527
|
*
|
|
531
|
-
* Adds `import {
|
|
532
|
-
* is emitted (idempotent).
|
|
528
|
+
* Adds `import {one_of, type Infer} from '@fuzdev/fuz_schema/schema.ts';` to
|
|
529
|
+
* `imports` only when at least one block is emitted (idempotent).
|
|
533
530
|
*
|
|
534
531
|
* @param options.emit - subset of enums to emit; defaults to every kind
|
|
535
532
|
* @param options.include_protocol_actions - when true, retains `heartbeat` /
|
|
@@ -543,8 +540,9 @@ export const generate_action_method_enums = (specs, imports, options) => {
|
|
|
543
540
|
const emit_block = (kind, name, methods, jsdoc) => {
|
|
544
541
|
if (!emit.has(kind))
|
|
545
542
|
return;
|
|
546
|
-
//
|
|
547
|
-
// Consumers that need a kind to exist should check their
|
|
543
|
+
// skip empty kinds: an enum of no methods types as `never`, which no
|
|
544
|
+
// consumer wants. Consumers that need a kind to exist should check their
|
|
545
|
+
// spec set, not the helper
|
|
548
546
|
if (methods.length === 0)
|
|
549
547
|
return;
|
|
550
548
|
blocks.push(format_method_enum_block(name, jsdoc, methods));
|
|
@@ -564,7 +562,8 @@ export const generate_action_method_enums = (specs, imports, options) => {
|
|
|
564
562
|
emit_block('broadcast', 'BroadcastActionMethod', registry.broadcast_methods, "Names of remote_notification actions exposed by the broadcast API (backend-initiated, excluding request-scoped progress notifications named by another action's `streams`).");
|
|
565
563
|
if (blocks.length === 0)
|
|
566
564
|
return '';
|
|
567
|
-
imports.add('
|
|
565
|
+
imports.add('@fuzdev/fuz_schema/schema.ts', 'one_of');
|
|
566
|
+
imports.add_type('@fuzdev/fuz_schema/schema.ts', 'Infer');
|
|
568
567
|
return blocks.join('\n\n');
|
|
569
568
|
};
|
|
570
569
|
/**
|
|
@@ -651,27 +650,37 @@ ${type_lines}
|
|
|
651
650
|
export const action_specs: Array<ActionSpecUnion> = Object.values(ActionSpecs);`;
|
|
652
651
|
};
|
|
653
652
|
/**
|
|
654
|
-
* Emit `ActionInputs` + `ActionOutputs` runtime consts and matching
|
|
655
|
-
*
|
|
656
|
-
*
|
|
657
|
-
*
|
|
653
|
+
* Emit `ActionInputs` + `ActionOutputs` runtime consts and matching
|
|
654
|
+
* interfaces, plus the `ActionCallInputs` interface. The runtime consts
|
|
655
|
+
* reference `specs.{method}_action_spec.input` / `.output`.
|
|
656
|
+
*
|
|
657
|
+
* The two sides of a call see different types for one input schema, so the
|
|
658
|
+
* interfaces split by side:
|
|
659
|
+
*
|
|
660
|
+
* - `ActionInputs` types each input as its schema's output (`Infer`) — the
|
|
661
|
+
* parsed value a handler, an action event, or a notification receiver reads,
|
|
662
|
+
* with defaults filled and transforms applied.
|
|
663
|
+
* - `ActionCallInputs` types each input as its schema's input (`InferInput`)
|
|
664
|
+
* — what a caller passes, before the parse: a `with_default` field is
|
|
665
|
+
* optional there and required in `ActionInputs`. The call surfaces
|
|
666
|
+
* (`FrontendActionsApi`, `BackendActionsApi`) read it.
|
|
667
|
+
* - `ActionOutputs` types each output as its schema's output, what a caller
|
|
668
|
+
* receives.
|
|
658
669
|
*
|
|
659
|
-
* Adds `import {
|
|
660
|
-
*
|
|
661
|
-
* fuz_schema's, and the `* as specs` namespace import.
|
|
670
|
+
* Adds `import type {Infer, InferInput} from '@fuzdev/fuz_schema/schema.ts';`
|
|
671
|
+
* and the `* as specs` namespace import.
|
|
662
672
|
*
|
|
663
673
|
* @param options.qualify_spec - per-spec qualified identifier callback for
|
|
664
674
|
* multi-source consumers. The helper appends `.input` / `.output` to the
|
|
665
675
|
* callback's return value. When set, the helper skips the default
|
|
666
676
|
* `* as specs` import — the consumer manages its own namespace imports —
|
|
667
677
|
* and `specs_module` is ignored. Single-source consumers omit it.
|
|
668
|
-
* @throws Error naming the method when an input or output is
|
|
669
|
-
* nor a fuz_schema schema
|
|
678
|
+
* @throws Error naming the method when an input or output is no schema
|
|
670
679
|
*/
|
|
671
680
|
export const generate_action_inputs_outputs = (specs, imports, options) => {
|
|
672
681
|
const filtered = filter_protocol_actions(specs, options?.include_protocol_actions);
|
|
673
682
|
if (filtered.length === 0) {
|
|
674
|
-
// Empty spec list — emit minimal valid output and skip the `
|
|
683
|
+
// Empty spec list — emit minimal valid output and skip the `Infer` /
|
|
675
684
|
// `* as specs` imports that would have nothing to reference.
|
|
676
685
|
return `/**
|
|
677
686
|
* Action parameter schemas indexed by method name.
|
|
@@ -681,6 +690,12 @@ export const generate_action_inputs_outputs = (specs, imports, options) => {
|
|
|
681
690
|
export const ActionInputs = {} as const;
|
|
682
691
|
export interface ActionInputs {}
|
|
683
692
|
|
|
693
|
+
/**
|
|
694
|
+
* Action inputs as a caller passes them, indexed by method name:
|
|
695
|
+
* each input schema's input type, before the parse.
|
|
696
|
+
*/
|
|
697
|
+
export interface ActionCallInputs {}
|
|
698
|
+
|
|
684
699
|
/**
|
|
685
700
|
* Action result schemas indexed by method name.
|
|
686
701
|
* These represent the output data for each action,
|
|
@@ -689,28 +704,26 @@ export interface ActionInputs {}
|
|
|
689
704
|
export const ActionOutputs = {} as const;
|
|
690
705
|
export interface ActionOutputs {}`;
|
|
691
706
|
}
|
|
692
|
-
const
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
if (uses('zod'))
|
|
698
|
-
imports.add('zod', 'z');
|
|
699
|
-
if (uses('fuz_schema'))
|
|
700
|
-
imports.add_type('@fuzdev/fuz_schema/schema.ts', 'Infer');
|
|
707
|
+
for (const s of filtered) {
|
|
708
|
+
assert_spec_schema(s, 'input');
|
|
709
|
+
assert_spec_schema(s, 'output');
|
|
710
|
+
}
|
|
711
|
+
imports.add_types('@fuzdev/fuz_schema/schema.ts', 'Infer', 'InferInput');
|
|
701
712
|
const qualify = resolve_spec_qualifier(imports, options);
|
|
702
|
-
const infer = (library) => library === 'zod' ? 'z.infer' : 'Infer';
|
|
703
713
|
const inputs_value = filtered
|
|
704
714
|
.map((s) => `\t${to_action_property_key(s.method)}: ${qualify(s)}.input,`)
|
|
705
715
|
.join('\n');
|
|
706
716
|
const inputs_type = filtered
|
|
707
|
-
.map((s
|
|
717
|
+
.map((s) => `\t${to_action_property_key(s.method)}: Infer<typeof ${qualify(s)}.input>;`)
|
|
718
|
+
.join('\n');
|
|
719
|
+
const call_inputs_type = filtered
|
|
720
|
+
.map((s) => `\t${to_action_property_key(s.method)}: InferInput<typeof ${qualify(s)}.input>;`)
|
|
708
721
|
.join('\n');
|
|
709
722
|
const outputs_value = filtered
|
|
710
723
|
.map((s) => `\t${to_action_property_key(s.method)}: ${qualify(s)}.output,`)
|
|
711
724
|
.join('\n');
|
|
712
725
|
const outputs_type = filtered
|
|
713
|
-
.map((s
|
|
726
|
+
.map((s) => `\t${to_action_property_key(s.method)}: Infer<typeof ${qualify(s)}.output>;`)
|
|
714
727
|
.join('\n');
|
|
715
728
|
return `/**
|
|
716
729
|
* Action parameter schemas indexed by method name.
|
|
@@ -724,6 +737,14 @@ export interface ActionInputs {
|
|
|
724
737
|
${inputs_type}
|
|
725
738
|
}
|
|
726
739
|
|
|
740
|
+
/**
|
|
741
|
+
* Action inputs as a caller passes them, indexed by method name:
|
|
742
|
+
* each input schema's input type, before the parse.
|
|
743
|
+
*/
|
|
744
|
+
export interface ActionCallInputs {
|
|
745
|
+
${call_inputs_type}
|
|
746
|
+
}
|
|
747
|
+
|
|
727
748
|
/**
|
|
728
749
|
* Action result schemas indexed by method name.
|
|
729
750
|
* These represent the output data for each action,
|
|
@@ -802,7 +823,7 @@ ${lines.join('\n')}
|
|
|
802
823
|
*
|
|
803
824
|
* Imports are registered per emitted line — only what the spec set actually references shows up on
|
|
804
825
|
* `imports`. A spec set with no async methods skips `RpcClientCallOptions`;
|
|
805
|
-
* one with no inputs skips `
|
|
826
|
+
* one with no inputs skips `ActionCallInputs`; sync `local_call` methods with
|
|
806
827
|
* `sync_returns_value: true` (the default) skip `Result` / `JsonrpcErrorObject`.
|
|
807
828
|
*
|
|
808
829
|
* The interface name is fixed at `FrontendActionsApi` — the symmetric counterpart
|
|
@@ -892,7 +913,7 @@ ${lines};
|
|
|
892
913
|
* exclusion list.
|
|
893
914
|
*
|
|
894
915
|
* Adds the `* as specs` namespace import (from `specs_module`), the
|
|
895
|
-
* `
|
|
916
|
+
* `ActionCallInputs` type import (from `collections_path`), and the
|
|
896
917
|
* `ActionSpecUnion` type import.
|
|
897
918
|
*
|
|
898
919
|
* Method signature shape today is `(input) => Promise<void>` — matches the
|
|
@@ -922,18 +943,18 @@ export const generate_backend_actions_api = (specs, imports, options) => {
|
|
|
922
943
|
*/`;
|
|
923
944
|
if (broadcast.length === 0) {
|
|
924
945
|
// No backend-initiated remote_notifications — skip `* as specs` and
|
|
925
|
-
// `
|
|
946
|
+
// `ActionCallInputs` imports that would have nothing to reference.
|
|
926
947
|
return `${interface_doc}
|
|
927
948
|
export interface BackendActionsApi {}
|
|
928
949
|
|
|
929
950
|
export const broadcast_action_specs: ReadonlyArray<ActionSpecUnion> = [];`;
|
|
930
951
|
}
|
|
931
952
|
const collections_path = options?.collections_path ?? DEFAULT_COLLECTIONS_PATH;
|
|
932
|
-
imports.add_type(collections_path, '
|
|
953
|
+
imports.add_type(collections_path, 'ActionCallInputs');
|
|
933
954
|
const qualify = resolve_spec_qualifier(imports, options);
|
|
934
955
|
const interface_body = '\n' +
|
|
935
956
|
broadcast
|
|
936
|
-
.map((s) => `\t${to_action_property_key(s.method)}: (input:
|
|
957
|
+
.map((s) => `\t${to_action_property_key(s.method)}: (input: ActionCallInputs['${s.method}']) => Promise<void>;`)
|
|
937
958
|
.join('\n') +
|
|
938
959
|
'\n';
|
|
939
960
|
const array_body = '\n' + broadcast.map((s) => `\t${qualify(s)},`).join('\n') + '\n';
|