@fuzdev/fuz_app 0.155.1 → 0.157.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 +27 -14
- package/dist/actions/action_codegen.d.ts +10 -3
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +52 -13
- package/dist/actions/action_event.d.ts.map +1 -1
- package/dist/actions/action_event.js +13 -11
- package/dist/actions/action_rpc.d.ts +4 -3
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +4 -3
- package/dist/actions/action_spec.d.ts +102 -206
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/action_spec.js +18 -96
- 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.map +1 -1
- package/dist/actions/broadcast_api.js +6 -5
- package/dist/actions/compile_action_registry.d.ts +11 -6
- package/dist/actions/compile_action_registry.d.ts.map +1 -1
- package/dist/actions/compile_action_registry.js +15 -9
- package/dist/actions/perform_action.d.ts +4 -4
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +11 -11
- package/dist/auth/CLAUDE.md +1 -1
- package/dist/auth/account_action_specs.d.ts +50 -23
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_action_specs.js +18 -8
- package/dist/auth/account_route_schema.d.ts +10 -10
- package/dist/auth/account_schema.d.ts +21 -21
- package/dist/auth/actor_lookup_action_specs.d.ts +7 -7
- package/dist/auth/actor_search_action_specs.d.ts +6 -6
- package/dist/auth/admin_action_specs.d.ts +98 -98
- package/dist/auth/app_settings_schema.d.ts +2 -2
- package/dist/auth/audit_log_route_schema.d.ts +1 -1
- package/dist/auth/audit_log_schema.d.ts +44 -44
- package/dist/auth/auth_guard_resolver.d.ts +2 -2
- package/dist/auth/auth_guard_resolver.js +2 -2
- package/dist/auth/bootstrap_route_schema.d.ts +4 -4
- package/dist/auth/cell_action_specs.d.ts +241 -241
- package/dist/auth/cell_actions.js +3 -3
- package/dist/auth/cell_audit_action_specs.d.ts +14 -14
- package/dist/auth/cell_audit_metadata.d.ts +6 -6
- package/dist/auth/cell_field_action_specs.d.ts +38 -38
- package/dist/auth/cell_field_audit_metadata.d.ts +4 -4
- package/dist/auth/cell_grant_action_specs.d.ts +61 -61
- package/dist/auth/cell_grant_audit_metadata.d.ts +10 -10
- package/dist/auth/cell_item_action_specs.d.ts +50 -50
- package/dist/auth/cell_item_audit_metadata.d.ts +5 -5
- package/dist/auth/invite_schema.d.ts +6 -6
- package/dist/auth/role_grant_offer_action_specs.d.ts +120 -120
- package/dist/auth/role_grant_offer_notifications.d.ts +66 -66
- package/dist/auth/role_grant_offer_schema.d.ts +6 -6
- package/dist/auth/self_service_role_action_specs.d.ts +2 -2
- package/dist/auth/signup_route_schema.d.ts +2 -2
- package/dist/http/CLAUDE.md +26 -17
- package/dist/http/auth_shape.d.ts +51 -17
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +101 -52
- package/dist/http/error_schemas.d.ts +15 -8
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +4 -9
- package/dist/http/jsonrpc_errors.d.ts +11 -4
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +11 -4
- package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
- package/dist/http/jsonrpc_helpers.js +2 -1
- package/dist/http/route_spec.d.ts +37 -19
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +54 -24
- package/dist/http/schema_helpers.d.ts +27 -24
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +24 -19
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +7 -3
- package/dist/primitive_schemas.d.ts +16 -5
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +26 -4
- package/dist/primitive_schemas_fuz.d.ts +67 -0
- package/dist/primitive_schemas_fuz.d.ts.map +1 -0
- package/dist/primitive_schemas_fuz.js +47 -0
- package/dist/realtime/sse.d.ts +3 -3
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +4 -4
- package/dist/schema_issues.d.ts +91 -4
- package/dist/schema_issues.d.ts.map +1 -1
- package/dist/schema_issues.js +262 -1
- package/dist/schema_meta.d.ts +24 -8
- package/dist/schema_meta.d.ts.map +1 -1
- package/dist/schema_meta.js +31 -10
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +2 -1
- package/dist/testing/CLAUDE.md +23 -17
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +3 -2
- package/dist/testing/adversarial_404.d.ts +2 -2
- package/dist/testing/adversarial_404.d.ts.map +1 -1
- package/dist/testing/adversarial_404.js +8 -5
- package/dist/testing/adversarial_input.js +1 -1
- package/dist/testing/adversarial_input_cases.d.ts +18 -23
- package/dist/testing/adversarial_input_cases.d.ts.map +1 -1
- package/dist/testing/adversarial_input_cases.js +51 -46
- package/dist/testing/assertions.d.ts +6 -5
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +9 -4
- package/dist/testing/cross_backend/action_manifest.d.ts +2 -1
- package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest.js +3 -3
- package/dist/testing/cross_backend/cell_crud.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_crud.js +3 -8
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +5 -4
- package/dist/testing/cross_backend/cross_rpc.d.ts +4 -2
- package/dist/testing/cross_backend/cross_rpc.d.ts.map +1 -1
- package/dist/testing/cross_backend/cross_rpc.js +6 -4
- package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.js +3 -2
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +8 -8
- package/dist/testing/error_coverage.d.ts +9 -17
- package/dist/testing/error_coverage.d.ts.map +1 -1
- package/dist/testing/error_coverage.js +20 -3
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +7 -6
- 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 -8
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +18 -15
- package/dist/testing/schema_generators.d.ts +75 -40
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +273 -99
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +4 -3
- package/dist/ui/admin_accounts_state.svelte.d.ts +10 -10
- 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/role_grant_offers_state.svelte.d.ts +6 -6
- package/dist/zod.d.ts +23 -5
- package/dist/zod.d.ts.map +1 -1
- package/dist/zod.js +2 -2
- package/package.json +6 -6
|
@@ -5,235 +5,131 @@
|
|
|
5
5
|
* auth, side effects, and input/output schemas. `actions/action_bridge.ts`
|
|
6
6
|
* derives the SSE `EventSpec` of a notification from one.
|
|
7
7
|
*
|
|
8
|
+
* A spec is a plain object typed by these interfaces, written with
|
|
9
|
+
* `satisfies` (`satisfies RequestResponseActionSpec`) so its literal types
|
|
10
|
+
* survive; nothing parses a spec at runtime. Its `input` and `output` are
|
|
11
|
+
* schemas of either library, Zod or `@fuzdev/fuz_schema` (`ValidationSchema`).
|
|
12
|
+
* The registration-time checks live in `actions/compile_action_registry.ts`.
|
|
13
|
+
*
|
|
8
14
|
* @see `actions/action_rpc.ts` for the JSON-RPC dispatcher
|
|
9
15
|
* @see `actions/register_action_ws.ts` for the WebSocket dispatcher
|
|
10
16
|
*
|
|
11
17
|
* @module
|
|
12
18
|
*/
|
|
13
19
|
import { z } from 'zod';
|
|
20
|
+
import type { void as fuz_void } from '@fuzdev/fuz_schema/schema.ts';
|
|
21
|
+
import type { RateLimitKey } from '../http/error_schemas.js';
|
|
22
|
+
import type { RouteAuth } from '../http/auth_shape.js';
|
|
23
|
+
import type { ValidationSchema } from '../schema_issues.js';
|
|
24
|
+
/** The action kinds, in declaration order — what `ActionKind` and `is_action_spec` read. */
|
|
25
|
+
export declare const ACTION_KINDS: readonly ["request_response", "remote_notification", "local_call"];
|
|
14
26
|
export declare const ActionKind: z.ZodEnum<{
|
|
15
27
|
request_response: "request_response";
|
|
16
28
|
remote_notification: "remote_notification";
|
|
17
29
|
local_call: "local_call";
|
|
18
30
|
}>;
|
|
19
31
|
export type ActionKind = z.infer<typeof ActionKind>;
|
|
32
|
+
/** Which side initiates an action — what `ActionInitiator` reads. */
|
|
33
|
+
export declare const ACTION_INITIATORS: readonly ["frontend", "backend", "both"];
|
|
20
34
|
export declare const ActionInitiator: z.ZodEnum<{
|
|
21
35
|
both: "both";
|
|
22
36
|
frontend: "frontend";
|
|
23
37
|
backend: "backend";
|
|
24
38
|
}>;
|
|
25
39
|
export type ActionInitiator = z.infer<typeof ActionInitiator>;
|
|
26
|
-
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
async:
|
|
104
|
-
}
|
|
105
|
-
export type RequestResponseActionSpec = z.infer<typeof RequestResponseActionSpec>;
|
|
106
|
-
export declare const RemoteNotificationActionSpec: z.ZodObject<{
|
|
107
|
-
method: z.ZodString;
|
|
108
|
-
initiator: z.ZodEnum<{
|
|
109
|
-
both: "both";
|
|
110
|
-
frontend: "frontend";
|
|
111
|
-
backend: "backend";
|
|
112
|
-
}>;
|
|
113
|
-
input: z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
114
|
-
description: z.ZodString;
|
|
115
|
-
streams: z.ZodOptional<z.ZodString>;
|
|
116
|
-
error_reasons: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
117
|
-
rate_limit: z.ZodOptional<z.ZodEnum<{
|
|
118
|
-
account: "account";
|
|
119
|
-
ip: "ip";
|
|
120
|
-
both: "both";
|
|
121
|
-
}>>;
|
|
122
|
-
kind: z.ZodDefault<z.ZodLiteral<"remote_notification">>;
|
|
123
|
-
auth: z.ZodDefault<z.ZodNull>;
|
|
124
|
-
side_effects: z.ZodDefault<z.ZodLiteral<true>>;
|
|
125
|
-
output: z.ZodCustom<z.ZodVoid, z.ZodVoid>;
|
|
126
|
-
async: z.ZodDefault<z.ZodLiteral<true>>;
|
|
127
|
-
}, z.core.$strict>;
|
|
128
|
-
export type RemoteNotificationActionSpec = z.infer<typeof RemoteNotificationActionSpec>;
|
|
40
|
+
/** The fields every action spec carries; each kind narrows some of them. */
|
|
41
|
+
export interface ActionSpec {
|
|
42
|
+
method: string;
|
|
43
|
+
kind: ActionKind;
|
|
44
|
+
initiator: ActionInitiator;
|
|
45
|
+
/**
|
|
46
|
+
* The flat auth shape (canonical schema in `http/auth_shape.ts`).
|
|
47
|
+
* `null` for `remote_notification` and `local_call` — those don't
|
|
48
|
+
* dispatch through the request/response auth gate.
|
|
49
|
+
*
|
|
50
|
+
* See `http/auth_shape.ts` for the design rationale (orthogonal
|
|
51
|
+
* authentication / account-resolution / actor-resolution / role-and-
|
|
52
|
+
* credential authorization axes). `required_scope` is the one field an
|
|
53
|
+
* action may not set — `compile_action_registry` rejects it, since
|
|
54
|
+
* nothing on the RPC path mounts a guard from it; the dispatcher derives
|
|
55
|
+
* the same `rpc:<method>` capability from `spec.method` instead.
|
|
56
|
+
*/
|
|
57
|
+
auth: RouteAuth | null;
|
|
58
|
+
side_effects: boolean;
|
|
59
|
+
/** The input schema, Zod or `@fuzdev/fuz_schema`. */
|
|
60
|
+
input: ValidationSchema;
|
|
61
|
+
/** The output schema, Zod or `@fuzdev/fuz_schema`. */
|
|
62
|
+
output: ValidationSchema;
|
|
63
|
+
async: boolean;
|
|
64
|
+
description: string;
|
|
65
|
+
/**
|
|
66
|
+
* Names the notification method this action emits as request-scoped
|
|
67
|
+
* progress. Forward-compatible handshake — transport-agnostic, does not
|
|
68
|
+
* imply a specific delivery mechanism. Registry-time validation (e.g.,
|
|
69
|
+
* ensuring the named method is a `remote_notification` spec) is a
|
|
70
|
+
* consumer-side concern.
|
|
71
|
+
*/
|
|
72
|
+
streams?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Error reason codes this action may surface via `error.data.reason` on
|
|
75
|
+
* failure. Declarative metadata mirroring the `streams` precedent —
|
|
76
|
+
* codegen, UI form-state matching, and docs read it off the spec instead
|
|
77
|
+
* of scanning handler implementations. Reuses the same `as const` string
|
|
78
|
+
* constants the handler throws (e.g. `ERROR_ROLE_GRANT_OFFER_*`) so call sites can
|
|
79
|
+
* import either side. Optional — actions that surface only standard
|
|
80
|
+
* transport errors leave it unset.
|
|
81
|
+
*/
|
|
82
|
+
error_reasons?: ReadonlyArray<string>;
|
|
83
|
+
/**
|
|
84
|
+
* Rate limit key the RPC dispatcher consults for this action. Optional —
|
|
85
|
+
* actions without it skip the rate-limit hook entirely.
|
|
86
|
+
*
|
|
87
|
+
* - `'ip'` — keyed on the resolved client IP (`get_client_ip(c)`).
|
|
88
|
+
* - `'account'` — keyed on the post-auth account id (`request_context.account.id`).
|
|
89
|
+
* Registration-time error if paired with `auth.account !== 'required'`
|
|
90
|
+
* (no account to key on).
|
|
91
|
+
* - `'both'` — both checks run; either can block.
|
|
92
|
+
*
|
|
93
|
+
* Throttle-requests semantics — every invocation records, regardless of
|
|
94
|
+
* outcome (different from REST login's throttle-failures, which resets
|
|
95
|
+
* on success). Suits admin mutation oracles (`invite_create` account-
|
|
96
|
+
* existence probe) where the *successful* invocation is the threat.
|
|
97
|
+
*
|
|
98
|
+
* Today only `RequestResponseActionSpec` is consulted by the RPC
|
|
99
|
+
* dispatcher. The field is on the base for shape symmetry with
|
|
100
|
+
* `streams` and `error_reasons`; remote_notification / local_call
|
|
101
|
+
* dispatchers don't read it.
|
|
102
|
+
*/
|
|
103
|
+
rate_limit?: RateLimitKey;
|
|
104
|
+
}
|
|
105
|
+
/** A request answered with a response, through the auth gate. */
|
|
106
|
+
export interface RequestResponseActionSpec extends ActionSpec {
|
|
107
|
+
kind: 'request_response';
|
|
108
|
+
auth: RouteAuth;
|
|
109
|
+
async: true;
|
|
110
|
+
}
|
|
111
|
+
/** A one-way message; its output is a void schema, Zod's `z.void()` or fuz_schema's `s.void`. */
|
|
112
|
+
export interface RemoteNotificationActionSpec extends ActionSpec {
|
|
113
|
+
kind: 'remote_notification';
|
|
114
|
+
auth: null;
|
|
115
|
+
side_effects: true;
|
|
116
|
+
output: z.ZodVoid | typeof fuz_void;
|
|
117
|
+
async: true;
|
|
118
|
+
}
|
|
129
119
|
/**
|
|
130
120
|
* Local calls can wrap synchronous or asynchronous actions, and are the
|
|
131
121
|
* escape hatch for remote APIs that do not support SAES.
|
|
132
122
|
*/
|
|
133
|
-
export
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
side_effects: z.ZodBoolean;
|
|
141
|
-
input: z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
142
|
-
output: z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
143
|
-
async: z.ZodBoolean;
|
|
144
|
-
description: z.ZodString;
|
|
145
|
-
streams: z.ZodOptional<z.ZodString>;
|
|
146
|
-
error_reasons: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
147
|
-
rate_limit: z.ZodOptional<z.ZodEnum<{
|
|
148
|
-
account: "account";
|
|
149
|
-
ip: "ip";
|
|
150
|
-
both: "both";
|
|
151
|
-
}>>;
|
|
152
|
-
kind: z.ZodDefault<z.ZodLiteral<"local_call">>;
|
|
153
|
-
auth: z.ZodDefault<z.ZodNull>;
|
|
154
|
-
}, z.core.$strict>;
|
|
155
|
-
export type LocalCallActionSpec = z.infer<typeof LocalCallActionSpec>;
|
|
156
|
-
export declare const ActionSpecUnion: z.ZodUnion<readonly [z.ZodObject<{
|
|
157
|
-
method: z.ZodString;
|
|
158
|
-
initiator: z.ZodEnum<{
|
|
159
|
-
both: "both";
|
|
160
|
-
frontend: "frontend";
|
|
161
|
-
backend: "backend";
|
|
162
|
-
}>;
|
|
163
|
-
side_effects: z.ZodBoolean;
|
|
164
|
-
input: z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
165
|
-
output: z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
166
|
-
description: z.ZodString;
|
|
167
|
-
streams: z.ZodOptional<z.ZodString>;
|
|
168
|
-
error_reasons: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
169
|
-
rate_limit: z.ZodOptional<z.ZodEnum<{
|
|
170
|
-
account: "account";
|
|
171
|
-
ip: "ip";
|
|
172
|
-
both: "both";
|
|
173
|
-
}>>;
|
|
174
|
-
kind: z.ZodDefault<z.ZodLiteral<"request_response">>;
|
|
175
|
-
auth: z.ZodObject<{
|
|
176
|
-
account: z.ZodEnum<{
|
|
177
|
-
optional: "optional";
|
|
178
|
-
none: "none";
|
|
179
|
-
required: "required";
|
|
180
|
-
}>;
|
|
181
|
-
actor: z.ZodEnum<{
|
|
182
|
-
optional: "optional";
|
|
183
|
-
none: "none";
|
|
184
|
-
required: "required";
|
|
185
|
-
}>;
|
|
186
|
-
roles: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
187
|
-
credential_types: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
188
|
-
required_scope: z.ZodOptional<z.ZodString>;
|
|
189
|
-
}, z.core.$strict>;
|
|
190
|
-
async: z.ZodDefault<z.ZodLiteral<true>>;
|
|
191
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
192
|
-
method: z.ZodString;
|
|
193
|
-
initiator: z.ZodEnum<{
|
|
194
|
-
both: "both";
|
|
195
|
-
frontend: "frontend";
|
|
196
|
-
backend: "backend";
|
|
197
|
-
}>;
|
|
198
|
-
input: z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
199
|
-
description: z.ZodString;
|
|
200
|
-
streams: z.ZodOptional<z.ZodString>;
|
|
201
|
-
error_reasons: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
202
|
-
rate_limit: z.ZodOptional<z.ZodEnum<{
|
|
203
|
-
account: "account";
|
|
204
|
-
ip: "ip";
|
|
205
|
-
both: "both";
|
|
206
|
-
}>>;
|
|
207
|
-
kind: z.ZodDefault<z.ZodLiteral<"remote_notification">>;
|
|
208
|
-
auth: z.ZodDefault<z.ZodNull>;
|
|
209
|
-
side_effects: z.ZodDefault<z.ZodLiteral<true>>;
|
|
210
|
-
output: z.ZodCustom<z.ZodVoid, z.ZodVoid>;
|
|
211
|
-
async: z.ZodDefault<z.ZodLiteral<true>>;
|
|
212
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
213
|
-
method: z.ZodString;
|
|
214
|
-
initiator: z.ZodEnum<{
|
|
215
|
-
both: "both";
|
|
216
|
-
frontend: "frontend";
|
|
217
|
-
backend: "backend";
|
|
218
|
-
}>;
|
|
219
|
-
side_effects: z.ZodBoolean;
|
|
220
|
-
input: z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
221
|
-
output: z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
222
|
-
async: z.ZodBoolean;
|
|
223
|
-
description: z.ZodString;
|
|
224
|
-
streams: z.ZodOptional<z.ZodString>;
|
|
225
|
-
error_reasons: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
226
|
-
rate_limit: z.ZodOptional<z.ZodEnum<{
|
|
227
|
-
account: "account";
|
|
228
|
-
ip: "ip";
|
|
229
|
-
both: "both";
|
|
230
|
-
}>>;
|
|
231
|
-
kind: z.ZodDefault<z.ZodLiteral<"local_call">>;
|
|
232
|
-
auth: z.ZodDefault<z.ZodNull>;
|
|
233
|
-
}, z.core.$strict>]>;
|
|
234
|
-
export type ActionSpecUnion = z.infer<typeof ActionSpecUnion>;
|
|
235
|
-
/** Structural type guard for any `ActionSpecUnion` variant — checks `kind` is one of the three known values. */
|
|
123
|
+
export interface LocalCallActionSpec extends ActionSpec {
|
|
124
|
+
kind: 'local_call';
|
|
125
|
+
auth: null;
|
|
126
|
+
}
|
|
127
|
+
/** Any action spec, discriminated by `kind`. */
|
|
128
|
+
export type ActionSpecUnion = RequestResponseActionSpec | RemoteNotificationActionSpec | LocalCallActionSpec;
|
|
129
|
+
/** Structural type guard for any `ActionSpecUnion` variant — checks `kind` is one of `ACTION_KINDS`. */
|
|
236
130
|
export declare const is_action_spec: (value: unknown) => value is ActionSpecUnion;
|
|
131
|
+
/** The action event phases — what `ActionEventPhase` reads. */
|
|
132
|
+
export declare const ACTION_EVENT_PHASES: readonly ["send_request", "receive_request", "send_response", "receive_response", "send_error", "receive_error", "send", "receive", "execute"];
|
|
237
133
|
export declare const ActionEventPhase: z.ZodEnum<{
|
|
238
134
|
send_request: "send_request";
|
|
239
135
|
receive_request: "receive_request";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_spec.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_spec.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"action_spec.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,4FAA4F;AAC5F,eAAO,MAAM,YAAY,oEAAqE,CAAC;AAC/F,eAAO,MAAM,UAAU;;;;EAAuB,CAAC;AAC/C,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD,qEAAqE;AACrE,eAAO,MAAM,iBAAiB,0CAA2C,CAAC;AAC1E,eAAO,MAAM,eAAe;;;;EAA4B,CAAC;AACzD,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D,4EAA4E;AAC5E,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,CAAC;IACjB,SAAS,EAAE,eAAe,CAAC;IAC3B;;;;;;;;;;;OAWG;IACH,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,qDAAqD;IACrD,KAAK,EAAE,gBAAgB,CAAC;IACxB,sDAAsD;IACtD,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,UAAU,CAAC,EAAE,YAAY,CAAC;CAC1B;AAED,iEAAiE;AACjE,MAAM,WAAW,yBAA0B,SAAQ,UAAU;IAC5D,IAAI,EAAE,kBAAkB,CAAC;IACzB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC;CACZ;AAED,iGAAiG;AACjG,MAAM,WAAW,4BAA6B,SAAQ,UAAU;IAC/D,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,EAAE,IAAI,CAAC;IACnB,MAAM,EAAE,CAAC,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC;IACpC,KAAK,EAAE,IAAI,CAAC;CACZ;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACtD,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,IAAI,CAAC;CACX;AAED,gDAAgD;AAChD,MAAM,MAAM,eAAe,GAC1B,yBAAyB,GAAG,4BAA4B,GAAG,mBAAmB,CAAC;AAEhF,wGAAwG;AACxG,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,eAKK,CAAC;AAE/D,+DAA+D;AAC/D,eAAO,MAAM,mBAAmB,gJAUtB,CAAC;AACX,eAAO,MAAM,gBAAgB;;;;;;;;;;EAA8B,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -5,111 +5,32 @@
|
|
|
5
5
|
* auth, side effects, and input/output schemas. `actions/action_bridge.ts`
|
|
6
6
|
* derives the SSE `EventSpec` of a notification from one.
|
|
7
7
|
*
|
|
8
|
+
* A spec is a plain object typed by these interfaces, written with
|
|
9
|
+
* `satisfies` (`satisfies RequestResponseActionSpec`) so its literal types
|
|
10
|
+
* survive; nothing parses a spec at runtime. Its `input` and `output` are
|
|
11
|
+
* schemas of either library, Zod or `@fuzdev/fuz_schema` (`ValidationSchema`).
|
|
12
|
+
* The registration-time checks live in `actions/compile_action_registry.ts`.
|
|
13
|
+
*
|
|
8
14
|
* @see `actions/action_rpc.ts` for the JSON-RPC dispatcher
|
|
9
15
|
* @see `actions/register_action_ws.ts` for the WebSocket dispatcher
|
|
10
16
|
*
|
|
11
17
|
* @module
|
|
12
18
|
*/
|
|
13
19
|
import { z } from 'zod';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export const ActionKind = z.enum(
|
|
17
|
-
|
|
18
|
-
export const
|
|
19
|
-
export const
|
|
20
|
-
|
|
21
|
-
kind: ActionKind,
|
|
22
|
-
initiator: ActionInitiator,
|
|
23
|
-
/**
|
|
24
|
-
* The flat auth shape (canonical schema in `http/auth_shape.ts`).
|
|
25
|
-
* `null` for `remote_notification` and `local_call` — those don't
|
|
26
|
-
* dispatch through the request/response auth gate.
|
|
27
|
-
*
|
|
28
|
-
* See `http/auth_shape.ts` for the design rationale (orthogonal
|
|
29
|
-
* authentication / account-resolution / actor-resolution / role-and-
|
|
30
|
-
* credential authorization axes). `required_scope` is the one field an
|
|
31
|
-
* action may not set — `compile_action_registry` rejects it, since
|
|
32
|
-
* nothing on the RPC path mounts a guard from it; the dispatcher derives
|
|
33
|
-
* the same `rpc:<method>` capability from `spec.method` instead.
|
|
34
|
-
*/
|
|
35
|
-
auth: RouteAuth.nullable(),
|
|
36
|
-
side_effects: ActionSideEffects,
|
|
37
|
-
input: z.custom((v) => v instanceof z.ZodType),
|
|
38
|
-
output: z.custom((v) => v instanceof z.ZodType),
|
|
39
|
-
async: z.boolean(),
|
|
40
|
-
description: z.string(),
|
|
41
|
-
/**
|
|
42
|
-
* Names the notification method this action emits as request-scoped
|
|
43
|
-
* progress. Forward-compatible handshake — transport-agnostic, does not
|
|
44
|
-
* imply a specific delivery mechanism. Registry-time validation (e.g.,
|
|
45
|
-
* ensuring the named method is a `remote_notification` spec) is a
|
|
46
|
-
* consumer-side concern.
|
|
47
|
-
*/
|
|
48
|
-
streams: z.string().optional(),
|
|
49
|
-
/**
|
|
50
|
-
* Error reason codes this action may surface via `error.data.reason` on
|
|
51
|
-
* failure. Declarative metadata mirroring the `streams` precedent —
|
|
52
|
-
* codegen, UI form-state matching, and docs read it off the spec instead
|
|
53
|
-
* of scanning handler implementations. Reuses the same `as const` string
|
|
54
|
-
* constants the handler throws (e.g. `ERROR_ROLE_GRANT_OFFER_*`) so call sites can
|
|
55
|
-
* import either side. Optional — actions that surface only standard
|
|
56
|
-
* transport errors leave it unset.
|
|
57
|
-
*/
|
|
58
|
-
error_reasons: z.array(z.string()).readonly().optional(),
|
|
59
|
-
/**
|
|
60
|
-
* Rate limit key the RPC dispatcher consults for this action. Optional —
|
|
61
|
-
* actions without it skip the rate-limit hook entirely.
|
|
62
|
-
*
|
|
63
|
-
* - `'ip'` — keyed on the resolved client IP (`get_client_ip(c)`).
|
|
64
|
-
* - `'account'` — keyed on the post-auth account id (`request_context.account.id`).
|
|
65
|
-
* Registration-time error if paired with `auth.account !== 'required'`
|
|
66
|
-
* (no account to key on).
|
|
67
|
-
* - `'both'` — both checks run; either can block.
|
|
68
|
-
*
|
|
69
|
-
* Throttle-requests semantics — every invocation records, regardless of
|
|
70
|
-
* outcome (different from REST login's throttle-failures, which resets
|
|
71
|
-
* on success). Suits admin mutation oracles (`invite_create` account-
|
|
72
|
-
* existence probe) where the *successful* invocation is the threat.
|
|
73
|
-
*
|
|
74
|
-
* Today only `RequestResponseActionSpec` is consulted by the RPC
|
|
75
|
-
* dispatcher. The field is on the base for shape symmetry with
|
|
76
|
-
* `streams` and `error_reasons`; remote_notification / local_call
|
|
77
|
-
* dispatchers don't read it.
|
|
78
|
-
*/
|
|
79
|
-
rate_limit: RateLimitKey.optional()
|
|
80
|
-
});
|
|
81
|
-
export const RequestResponseActionSpec = ActionSpec.extend({
|
|
82
|
-
kind: z.literal('request_response').default('request_response'),
|
|
83
|
-
auth: RouteAuth,
|
|
84
|
-
async: z.literal(true).default(true)
|
|
85
|
-
});
|
|
86
|
-
export const RemoteNotificationActionSpec = ActionSpec.extend({
|
|
87
|
-
kind: z.literal('remote_notification').default('remote_notification'),
|
|
88
|
-
auth: z.null().default(null),
|
|
89
|
-
side_effects: z.literal(true).default(true),
|
|
90
|
-
output: z.custom((v) => v instanceof z.ZodVoid),
|
|
91
|
-
async: z.literal(true).default(true)
|
|
92
|
-
});
|
|
93
|
-
/**
|
|
94
|
-
* Local calls can wrap synchronous or asynchronous actions, and are the
|
|
95
|
-
* escape hatch for remote APIs that do not support SAES.
|
|
96
|
-
*/
|
|
97
|
-
export const LocalCallActionSpec = ActionSpec.extend({
|
|
98
|
-
kind: z.literal('local_call').default('local_call'),
|
|
99
|
-
auth: z.null().default(null)
|
|
100
|
-
});
|
|
101
|
-
export const ActionSpecUnion = z.union([
|
|
102
|
-
RequestResponseActionSpec,
|
|
103
|
-
RemoteNotificationActionSpec,
|
|
104
|
-
LocalCallActionSpec
|
|
105
|
-
]);
|
|
106
|
-
/** Structural type guard for any `ActionSpecUnion` variant — checks `kind` is one of the three known values. */
|
|
20
|
+
/** The action kinds, in declaration order — what `ActionKind` and `is_action_spec` read. */
|
|
21
|
+
export const ACTION_KINDS = ['request_response', 'remote_notification', 'local_call'];
|
|
22
|
+
export const ActionKind = z.enum(ACTION_KINDS);
|
|
23
|
+
/** Which side initiates an action — what `ActionInitiator` reads. */
|
|
24
|
+
export const ACTION_INITIATORS = ['frontend', 'backend', 'both'];
|
|
25
|
+
export const ActionInitiator = z.enum(ACTION_INITIATORS);
|
|
26
|
+
/** Structural type guard for any `ActionSpecUnion` variant — checks `kind` is one of `ACTION_KINDS`. */
|
|
107
27
|
export const is_action_spec = (value) => value !== null &&
|
|
108
28
|
typeof value === 'object' &&
|
|
109
29
|
'method' in value &&
|
|
110
30
|
'kind' in value &&
|
|
111
|
-
|
|
112
|
-
|
|
31
|
+
ACTION_KINDS.includes(value.kind);
|
|
32
|
+
/** The action event phases — what `ActionEventPhase` reads. */
|
|
33
|
+
export const ACTION_EVENT_PHASES = [
|
|
113
34
|
'send_request',
|
|
114
35
|
'receive_request',
|
|
115
36
|
'send_response',
|
|
@@ -119,4 +40,5 @@ export const ActionEventPhase = z.enum([
|
|
|
119
40
|
'send',
|
|
120
41
|
'receive',
|
|
121
42
|
'execute'
|
|
122
|
-
]
|
|
43
|
+
];
|
|
44
|
+
export const ActionEventPhase = z.enum(ACTION_EVENT_PHASES);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* narrowed tiers, the handler signatures, `RpcAction`, and the `rpc_action`
|
|
5
5
|
* binder.
|
|
6
6
|
*
|
|
7
|
-
* Sits above `actions/action_spec.ts` (
|
|
7
|
+
* Sits above `actions/action_spec.ts` (the spec interfaces) and below the
|
|
8
8
|
* dispatchers (`actions/register_action_ws.ts`, `actions/action_rpc.ts`,
|
|
9
9
|
* `actions/perform_action.ts`). Extracted so the shared protocol actions
|
|
10
10
|
* (e.g. `heartbeat_action`) and every action factory can name them without
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
*
|
|
19
19
|
* @module
|
|
20
20
|
*/
|
|
21
|
-
import type { z } from 'zod';
|
|
22
21
|
import type { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
23
22
|
import type { ActionSpecUnion, RequestResponseActionSpec } from './action_spec.js';
|
|
24
23
|
import type { Uuid } from '../primitive_schemas.js';
|
|
@@ -27,6 +26,7 @@ import type { BuiltinCredentialType } from '../auth/credential_type_schema.js';
|
|
|
27
26
|
import type { Db } from '../db/db.js';
|
|
28
27
|
import type { JsonrpcRequestId } from '../http/jsonrpc.js';
|
|
29
28
|
import type { RequestClient } from './peer_request.js';
|
|
29
|
+
import type { ValidationOutput } from '../schema_issues.js';
|
|
30
30
|
/**
|
|
31
31
|
* A spec paired with its optional handler — the composable unit passed to
|
|
32
32
|
* `register_action_ws` and `create_rpc_client`. The server uses both
|
|
@@ -210,7 +210,7 @@ export interface RpcAction {
|
|
|
210
210
|
*/
|
|
211
211
|
export type HandlerForSpec<TSpec extends RequestResponseActionSpec> = [
|
|
212
212
|
TSpec['auth']['actor']
|
|
213
|
-
] extends ['required'] ? ActorActionHandler<
|
|
213
|
+
] extends ['required'] ? ActorActionHandler<ValidationOutput<TSpec['input']>, ValidationOutput<TSpec['output']>> : [TSpec['auth']['account']] extends ['required'] ? AuthActionHandler<ValidationOutput<TSpec['input']>, ValidationOutput<TSpec['output']>> : ActionHandler<ValidationOutput<TSpec['input']>, ValidationOutput<TSpec['output']>>;
|
|
214
214
|
/**
|
|
215
215
|
* Pair a spec with a handler while preserving per-method input/output types
|
|
216
216
|
* and selecting the narrowest `ctx.auth` shape the spec literal admits.
|
|
@@ -219,7 +219,7 @@ export type HandlerForSpec<TSpec extends RequestResponseActionSpec> = [
|
|
|
219
219
|
* `ActionHandler<any, any>`, so spec/handler drift (renamed Zod schema,
|
|
220
220
|
* output field removal, input shape change) slips past the typechecker.
|
|
221
221
|
* `rpc_action(spec, handler)` binds the handler signature to
|
|
222
|
-
* `(input:
|
|
222
|
+
* `(input: ValidationOutput<spec.input>, ctx) => ValidationOutput<spec.output>` via the
|
|
223
223
|
* generic spec parameter — drift surfaces at the call site.
|
|
224
224
|
*
|
|
225
225
|
* The `ctx.auth` narrowing follows the spec's `auth.account` /
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_types.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"action_types.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_types.ts"],"names":[],"mappings":"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"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* narrowed tiers, the handler signatures, `RpcAction`, and the `rpc_action`
|
|
5
5
|
* binder.
|
|
6
6
|
*
|
|
7
|
-
* Sits above `actions/action_spec.ts` (
|
|
7
|
+
* Sits above `actions/action_spec.ts` (the spec interfaces) and below the
|
|
8
8
|
* dispatchers (`actions/register_action_ws.ts`, `actions/action_rpc.ts`,
|
|
9
9
|
* `actions/perform_action.ts`). Extracted so the shared protocol actions
|
|
10
10
|
* (e.g. `heartbeat_action`) and every action factory can name them without
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* `ActionHandler<any, any>`, so spec/handler drift (renamed Zod schema,
|
|
27
27
|
* output field removal, input shape change) slips past the typechecker.
|
|
28
28
|
* `rpc_action(spec, handler)` binds the handler signature to
|
|
29
|
-
* `(input:
|
|
29
|
+
* `(input: ValidationOutput<spec.input>, ctx) => ValidationOutput<spec.output>` via the
|
|
30
30
|
* generic spec parameter — drift surfaces at the call site.
|
|
31
31
|
*
|
|
32
32
|
* The `ctx.auth` narrowing follows the spec's `auth.account` /
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broadcast_api.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/broadcast_api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAU,KAAK,MAAM,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"broadcast_api.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/broadcast_api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAU,KAAK,MAAM,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAI5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEvF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,EAAE,WAAW,GAAG,oBAAoB,CAAC,CAAC;AAE3F;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GAAG,CAC7B,UAAU,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EACxC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,KACV,OAAO,CAAC;AAEb,0CAA0C;AAC1C,MAAM,WAAW,yBAAyB;IACzC;;;;OAIG;IACH,QAAQ,EAAE,eAAe,CAAC;IAC1B;;;;;OAKG;IACH,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IACtC,gFAAgF;IAChF,GAAG,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IACxB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,eAAe,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,oBAAoB,GAAI,IAAI,SAAS,MAAM,EACvD,SAAS,yBAAyB,KAChC,IAsCF,CAAC"}
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
21
21
|
import { create_jsonrpc_notification, to_jsonrpc_params } from '../http/jsonrpc_helpers.js';
|
|
22
|
+
import { parse_any } from '../schema_issues.js';
|
|
22
23
|
/**
|
|
23
24
|
* Builds a typed broadcast API from a set of action specs.
|
|
24
25
|
*
|
|
@@ -58,15 +59,15 @@ export const create_broadcast_api = (options) => {
|
|
|
58
59
|
for (const spec of specs) {
|
|
59
60
|
const { method } = spec;
|
|
60
61
|
const send = (input) => {
|
|
61
|
-
const parsed = spec.input
|
|
62
|
-
if (!parsed.
|
|
63
|
-
log?.error(`[${method}] input validation failed:`, parsed.
|
|
62
|
+
const parsed = parse_any(spec.input, input);
|
|
63
|
+
if (!parsed.ok) {
|
|
64
|
+
log?.error(`[${method}] input validation failed:`, parsed.issues);
|
|
64
65
|
return;
|
|
65
66
|
}
|
|
66
|
-
const notification = create_jsonrpc_notification(method, to_jsonrpc_params(parsed.
|
|
67
|
+
const notification = create_jsonrpc_notification(method, to_jsonrpc_params(parsed.value));
|
|
67
68
|
try {
|
|
68
69
|
if (should_deliver) {
|
|
69
|
-
registry.broadcast_filtered(notification, (identity) => should_deliver(identity, method, parsed.
|
|
70
|
+
registry.broadcast_filtered(notification, (identity) => should_deliver(identity, method, parsed.value));
|
|
70
71
|
}
|
|
71
72
|
else {
|
|
72
73
|
registry.broadcast(notification);
|