@fuzdev/fuz_app 0.169.0 → 0.171.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 +19 -21
- package/dist/actions/action_codegen.d.ts +27 -18
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +90 -90
- 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 +4 -4
- package/dist/actions/action_rpc.d.ts +1 -1
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +6 -7
- 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/peer_ping.d.ts.map +1 -1
- package/dist/actions/peer_ping.js +3 -2
- 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/actions/ws_socket_session.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.js +2 -1
- package/dist/auth/CLAUDE.md +11 -11
- package/dist/auth/admin_action_specs.d.ts +24 -24
- 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_schema.d.ts +14 -15
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +1 -1
- package/dist/auth/auth_ddl.d.ts +1 -1
- package/dist/auth/auth_ddl.js +1 -1
- package/dist/auth/cell_action_specs.d.ts +54 -54
- package/dist/auth/cell_actions.d.ts +2 -2
- package/dist/auth/cell_actions.js +5 -5
- package/dist/auth/middleware.d.ts +6 -2
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +14 -2
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +7 -9
- package/dist/auth/role_grant_offer_action_specs.d.ts +6 -6
- 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.map +1 -1
- package/dist/auth/role_grant_offer_notifications.js +2 -3
- package/dist/auth/self_service_role_actions.d.ts +1 -1
- package/dist/auth/self_service_role_actions.js +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 -31
- package/dist/http/auth_shape.d.ts +14 -32
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +14 -49
- package/dist/http/error_schemas.d.ts +18 -18
- package/dist/http/json_text.d.ts +53 -0
- package/dist/http/json_text.d.ts.map +1 -0
- package/dist/http/json_text.js +152 -0
- 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_result.d.ts +2 -1
- package/dist/http/route_result.d.ts.map +1 -1
- package/dist/http/route_spec.d.ts +34 -37
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +31 -31
- package/dist/http/schema_helpers.d.ts +77 -68
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +54 -77
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +6 -8
- package/dist/primitive_schemas.d.ts +9 -17
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +9 -17
- 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 +39 -147
- package/dist/schema_issues.d.ts.map +1 -1
- package/dist/schema_issues.js +39 -352
- 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/testing/CLAUDE.md +20 -22
- 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 +31 -46
- 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_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/identity_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/identity_parity.js +16 -11
- 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 +25 -3
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +4 -4
- package/dist/testing/cross_backend/sse_round_trip.js +2 -2
- package/dist/testing/cross_backend/testing_origin_check.d.ts +4 -4
- 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_envelope.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_envelope.js +8 -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 +10 -3
- package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
- package/dist/testing/rpc_envelope_cases.js +22 -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 -10
- 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 +154 -159
- 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/ui/form_state.svelte.d.ts +1 -1
- package/dist/ui/form_state.svelte.js +1 -1
- package/package.json +5 -7
- package/dist/zod.d.ts +0 -116
- package/dist/zod.d.ts.map +0 -1
- package/dist/zod.js +0 -218
- package/dist/zod_schemas.d.ts +0 -100
- package/dist/zod_schemas.d.ts.map +0 -1
- package/dist/zod_schemas.js +0 -157
|
@@ -6,13 +6,14 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
+
import { parse } from '@fuzdev/fuz_schema/schema.ts';
|
|
9
10
|
import { create_uuid } from '../primitive_schemas.js';
|
|
10
11
|
import { to_error_message } from '@fuzdev/fuz_util/error.ts';
|
|
11
12
|
import { create_jsonrpc_request, create_jsonrpc_response, create_jsonrpc_error_response, create_jsonrpc_notification, to_jsonrpc_params, is_jsonrpc_error_response } from '../http/jsonrpc_helpers.js';
|
|
12
13
|
import { dev_only, jsonrpc_error_messages, to_thrown_jsonrpc_error, UNKNOWN_ERROR_MESSAGE } from '../http/jsonrpc_errors.js';
|
|
13
14
|
import { safe_parse_dropping_unknown_keys } from '../http/schema_helpers.js';
|
|
14
15
|
import { resolve_issues_invalid_reason } from '../schema_meta.js';
|
|
15
|
-
import { format_issues,
|
|
16
|
+
import { format_issues, to_wire_issues } from '../schema_issues.js';
|
|
16
17
|
import { validate_step_transition, validate_phase_transition, should_validate_output, is_action_complete, create_initial_data, get_initial_phase, is_request_response, is_send_request_with_parsed_input, is_notification_send_with_parsed_input } from './action_event_helpers.js';
|
|
17
18
|
/**
|
|
18
19
|
* `error.data.reason` on the `internal_error` a client reports when a
|
|
@@ -28,7 +29,7 @@ export const ERROR_RESPONSE_OUTPUT_INVALID = 'response_output_invalid';
|
|
|
28
29
|
*/
|
|
29
30
|
const to_local_invalid_params_data = (input, issues, value) => {
|
|
30
31
|
const reason = resolve_issues_invalid_reason(input, issues, value);
|
|
31
|
-
const validation_errors = to_wire_issues(issues
|
|
32
|
+
const validation_errors = to_wire_issues(issues);
|
|
32
33
|
return reason === undefined ? { validation_errors } : { validation_errors, reason };
|
|
33
34
|
};
|
|
34
35
|
/**
|
|
@@ -128,7 +129,7 @@ export class ActionEvent {
|
|
|
128
129
|
else {
|
|
129
130
|
this.#transition_to_error_phase('receive_error', jsonrpc_error_messages.internal_error(`response failed output validation for ${this.spec.method}: ${format_issues(parsed.issues)}`, {
|
|
130
131
|
reason: ERROR_RESPONSE_OUTPUT_INVALID,
|
|
131
|
-
validation_errors: to_wire_issues(parsed.issues
|
|
132
|
+
validation_errors: to_wire_issues(parsed.issues)
|
|
132
133
|
}));
|
|
133
134
|
}
|
|
134
135
|
return this;
|
|
@@ -139,7 +140,7 @@ export class ActionEvent {
|
|
|
139
140
|
return this;
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
|
-
const parsed =
|
|
143
|
+
const parsed = parse(this.spec.input, this.#data.input);
|
|
143
144
|
if (parsed.ok) {
|
|
144
145
|
this.#transition_step('parsed', { input: parsed.value });
|
|
145
146
|
}
|
|
@@ -372,12 +373,12 @@ export class ActionEvent {
|
|
|
372
373
|
}
|
|
373
374
|
#complete_handling(output) {
|
|
374
375
|
if (output !== undefined && should_validate_output(this.spec.kind, this.#data.phase)) {
|
|
375
|
-
const parsed =
|
|
376
|
+
const parsed = parse(this.spec.output, output);
|
|
376
377
|
if (parsed.ok) {
|
|
377
378
|
this.#transition_step('handled', { output: parsed.value });
|
|
378
379
|
}
|
|
379
380
|
else {
|
|
380
|
-
this.#fail(jsonrpc_error_messages.validation_error(`failed to parse output: ${format_issues(parsed.issues)}`, { output, validation_errors: to_wire_issues(parsed.issues
|
|
381
|
+
this.#fail(jsonrpc_error_messages.validation_error(`failed to parse output: ${format_issues(parsed.issues)}`, { output, validation_errors: to_wire_issues(parsed.issues) }));
|
|
381
382
|
}
|
|
382
383
|
}
|
|
383
384
|
else {
|
|
@@ -13,13 +13,12 @@ import { ActionExecutor } from './action_event_types.js';
|
|
|
13
13
|
export declare const ActionEventData: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
14
14
|
input: unknown;
|
|
15
15
|
kind: "request_response" | "remote_notification" | "local_call";
|
|
16
|
-
|
|
16
|
+
method: string;
|
|
17
17
|
error: ({
|
|
18
18
|
message: string;
|
|
19
19
|
code: -32700 | -32600 | -32601 | -32602 | -32603 | import("@fuzdev/fuz_schema/schema.ts").Branded<number, "JsonrpcServerErrorCode">;
|
|
20
20
|
data?: unknown;
|
|
21
21
|
} & Record<string, unknown>) | null;
|
|
22
|
-
method: string;
|
|
23
22
|
request: ({
|
|
24
23
|
id: string | number;
|
|
25
24
|
method: string;
|
|
@@ -44,6 +43,7 @@ export declare const ActionEventData: import("@fuzdev/fuz_schema/schema.ts").Sch
|
|
|
44
43
|
} & Record<string, unknown>;
|
|
45
44
|
jsonrpc: "2.0";
|
|
46
45
|
} & Record<string, unknown>) | null;
|
|
46
|
+
output: unknown;
|
|
47
47
|
phase: "send_request" | "receive_request" | "send_response" | "receive_response" | "send_error" | "receive_error" | "send" | "receive" | "execute";
|
|
48
48
|
step: "initial" | "parsed" | "handling" | "handled" | "failed";
|
|
49
49
|
executor: "frontend" | "backend";
|
|
@@ -51,13 +51,12 @@ export declare const ActionEventData: import("@fuzdev/fuz_schema/schema.ts").Sch
|
|
|
51
51
|
}, {
|
|
52
52
|
input: unknown;
|
|
53
53
|
kind: "request_response" | "remote_notification" | "local_call";
|
|
54
|
-
|
|
54
|
+
method: string;
|
|
55
55
|
error: ({
|
|
56
56
|
message: string;
|
|
57
57
|
code: number;
|
|
58
58
|
data?: unknown;
|
|
59
59
|
} & Record<string, unknown>) | null;
|
|
60
|
-
method: string;
|
|
61
60
|
request: ({
|
|
62
61
|
id: string | number;
|
|
63
62
|
method: string;
|
|
@@ -82,6 +81,7 @@ export declare const ActionEventData: import("@fuzdev/fuz_schema/schema.ts").Sch
|
|
|
82
81
|
} & Record<string, unknown>;
|
|
83
82
|
jsonrpc: "2.0";
|
|
84
83
|
} & Record<string, unknown>) | null;
|
|
84
|
+
output: unknown;
|
|
85
85
|
phase: "send_request" | "receive_request" | "send_response" | "receive_response" | "send_error" | "receive_error" | "send" | "receive" | "execute";
|
|
86
86
|
step: "initial" | "parsed" | "handling" | "handled" | "failed";
|
|
87
87
|
executor: "frontend" | "backend";
|
|
@@ -91,7 +91,7 @@ export interface CreateRpcEndpointOptions {
|
|
|
91
91
|
* @returns route specs (GET + POST) ready for `apply_route_specs`
|
|
92
92
|
* @throws Error if two actions share the same `spec.method` (registration-time
|
|
93
93
|
* duplicate detection); also throws if any action's `spec.input` is a null
|
|
94
|
-
* schema (`
|
|
94
|
+
* schema (`literal(null)`; JSON-RPC 2.0 §4.2 forbids
|
|
95
95
|
* `params: null` on the wire — use a void schema for parameterless methods)
|
|
96
96
|
* or its `spec.output` is a void schema.
|
|
97
97
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_rpc.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAmC,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAiBxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"action_rpc.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAmC,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAiBxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAItD;;;GAGG;AACH,eAAO,MAAM,qBAAqB,aAAa,CAAC;AAEhD,yCAAyC;AACzC,MAAM,WAAW,wBAAwB;IACxC,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1B,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;;OAQG;IACH,sBAAsB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C;;;;;;;OAOG;IACH,2BAA2B,EAAE,WAAW,GAAG,IAAI,CAAC;CAChD;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,wBAAwB,KAAG,KAAK,CAAC,SAAS,CAmOtF,CAAC"}
|
|
@@ -25,6 +25,7 @@ import { compile_action_registry } from './compile_action_registry.js';
|
|
|
25
25
|
import { jsonrpc_error_messages, jsonrpc_error_code_to_http_status, JSONRPC_ERROR_CODES } from '../http/jsonrpc_errors.js';
|
|
26
26
|
import { classify_jsonrpc_message, create_jsonrpc_error_response } from '../http/jsonrpc_helpers.js';
|
|
27
27
|
import { perform_action, serialize_action_result } from './perform_action.js';
|
|
28
|
+
import { parse_json_text, read_json_body } from '../http/json_text.js';
|
|
28
29
|
/**
|
|
29
30
|
* The `Cache-Control` every response of the RPC endpoint's `GET` route carries
|
|
30
31
|
* — a read is per caller and per moment, so nothing may store it.
|
|
@@ -80,7 +81,7 @@ const envelope_response = (c, envelope, status) => route_raw(c.body(JSON.stringi
|
|
|
80
81
|
* @returns route specs (GET + POST) ready for `apply_route_specs`
|
|
81
82
|
* @throws Error if two actions share the same `spec.method` (registration-time
|
|
82
83
|
* duplicate detection); also throws if any action's `spec.input` is a null
|
|
83
|
-
* schema (`
|
|
84
|
+
* schema (`literal(null)`; JSON-RPC 2.0 §4.2 forbids
|
|
84
85
|
* `params: null` on the wire — use a void schema for parameterless methods)
|
|
85
86
|
* or its `spec.output` is a void schema.
|
|
86
87
|
*/
|
|
@@ -153,14 +154,12 @@ export const create_rpc_endpoint = (options) => {
|
|
|
153
154
|
// POST handler — parse JSON-RPC envelope from body
|
|
154
155
|
const post_handler = async (c, route) => {
|
|
155
156
|
// step 1: parse envelope
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
body = await c.req.json();
|
|
159
|
-
}
|
|
160
|
-
catch {
|
|
157
|
+
const read = await read_json_body(c.req);
|
|
158
|
+
if (!read.ok) {
|
|
161
159
|
const error = create_jsonrpc_error_response(null, jsonrpc_error_messages.parse_error());
|
|
162
160
|
return envelope_response(c, error, 400);
|
|
163
161
|
}
|
|
162
|
+
const body = read.value;
|
|
164
163
|
// the classifier the WS path runs; HTTP issues no server-initiated
|
|
165
164
|
// requests and has no notification semantics, so a response or a
|
|
166
165
|
// notification answers `invalid_request` on `id: null`, as on the Rust spine
|
|
@@ -205,7 +204,7 @@ export const create_rpc_endpoint = (options) => {
|
|
|
205
204
|
let params;
|
|
206
205
|
if (params_raw !== undefined) {
|
|
207
206
|
try {
|
|
208
|
-
params =
|
|
207
|
+
params = parse_json_text(params_raw);
|
|
209
208
|
}
|
|
210
209
|
catch {
|
|
211
210
|
const error = create_jsonrpc_error_response(id, jsonrpc_error_messages.invalid_params('params query parameter is not valid JSON'));
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* A spec is a plain object typed by these interfaces, written with
|
|
9
9
|
* `satisfies` (`satisfies RequestResponseActionSpec`) so its literal types
|
|
10
10
|
* survive; nothing parses a spec at runtime. Its `input` and `output` are
|
|
11
|
-
*
|
|
11
|
+
* `@fuzdev/fuz_schema` schemas (`AnySchema`).
|
|
12
12
|
* The registration-time checks live in `actions/compile_action_registry.ts`.
|
|
13
13
|
*
|
|
14
14
|
* @see `actions/action_rpc.ts` for the JSON-RPC dispatcher
|
|
@@ -16,11 +16,9 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @module
|
|
18
18
|
*/
|
|
19
|
-
import type
|
|
20
|
-
import { type Infer, type void as fuz_void } from '@fuzdev/fuz_schema/schema.ts';
|
|
19
|
+
import { type Infer, type void as fuz_void, type AnySchema } from '@fuzdev/fuz_schema/schema.ts';
|
|
21
20
|
import type { RateLimitKey } from '../rate_limiter.js';
|
|
22
21
|
import type { RouteAuth } from '../http/auth_shape.js';
|
|
23
|
-
import type { ValidationSchema } from '../schema_issues.js';
|
|
24
22
|
/** The action kinds, in declaration order — what `ActionKind` and `is_action_spec` read. */
|
|
25
23
|
export declare const ACTION_KINDS: readonly ["request_response", "remote_notification", "local_call"];
|
|
26
24
|
export declare const ActionKind: import("@fuzdev/fuz_schema/schema.ts").Schema<"request_response" | "remote_notification" | "local_call", "request_response" | "remote_notification" | "local_call", "one_of", readonly ["request_response", "remote_notification", "local_call"]>;
|
|
@@ -48,10 +46,10 @@ export interface ActionSpec {
|
|
|
48
46
|
*/
|
|
49
47
|
auth: RouteAuth | null;
|
|
50
48
|
side_effects: boolean;
|
|
51
|
-
/** The input schema
|
|
52
|
-
input:
|
|
53
|
-
/** The output schema
|
|
54
|
-
output:
|
|
49
|
+
/** The input schema. */
|
|
50
|
+
input: AnySchema;
|
|
51
|
+
/** The output schema. */
|
|
52
|
+
output: AnySchema;
|
|
55
53
|
async: boolean;
|
|
56
54
|
description: string;
|
|
57
55
|
/**
|
|
@@ -100,12 +98,12 @@ export interface RequestResponseActionSpec extends ActionSpec {
|
|
|
100
98
|
auth: RouteAuth;
|
|
101
99
|
async: true;
|
|
102
100
|
}
|
|
103
|
-
/** A one-way message; its output is
|
|
101
|
+
/** A one-way message; its output is fuz_schema's void schema, `s.void`. */
|
|
104
102
|
export interface RemoteNotificationActionSpec extends ActionSpec {
|
|
105
103
|
kind: 'remote_notification';
|
|
106
104
|
auth: null;
|
|
107
105
|
side_effects: true;
|
|
108
|
-
output:
|
|
106
|
+
output: typeof fuz_void;
|
|
109
107
|
async: true;
|
|
110
108
|
}
|
|
111
109
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_spec.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"action_spec.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAEN,KAAK,KAAK,EACV,KAAK,IAAI,IAAI,QAAQ,EACrB,KAAK,SAAS,EACd,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,4FAA4F;AAC5F,eAAO,MAAM,YAAY,oEAAqE,CAAC;AAC/F,eAAO,MAAM,UAAU,mPAAuB,CAAC;AAC/C,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAElD,qEAAqE;AACrE,eAAO,MAAM,iBAAiB,0CAA2C,CAAC;AAC1E,eAAO,MAAM,eAAe,qKAA4B,CAAC;AACzD,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE5D,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,E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|
|
8
8
|
* A spec is a plain object typed by these interfaces, written with
|
|
9
9
|
* `satisfies` (`satisfies RequestResponseActionSpec`) so its literal types
|
|
10
10
|
* survive; nothing parses a spec at runtime. Its `input` and `output` are
|
|
11
|
-
*
|
|
11
|
+
* `@fuzdev/fuz_schema` schemas (`AnySchema`).
|
|
12
12
|
* The registration-time checks live in `actions/compile_action_registry.ts`.
|
|
13
13
|
*
|
|
14
14
|
* @see `actions/action_rpc.ts` for the JSON-RPC dispatcher
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* @module
|
|
20
20
|
*/
|
|
21
21
|
import type { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
22
|
+
import type { Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
22
23
|
import type { ActionSpecUnion, RequestResponseActionSpec } from './action_spec.js';
|
|
23
24
|
import type { Uuid } from '../primitive_schemas.js';
|
|
24
25
|
import type { RequestActorContext, RequestContext } from '../auth/request_context.js';
|
|
@@ -26,7 +27,6 @@ import type { BuiltinCredentialType } from '../auth/credential_type_schema.js';
|
|
|
26
27
|
import type { Db } from '../db/db.js';
|
|
27
28
|
import type { JsonrpcRequestId } from '../http/jsonrpc.js';
|
|
28
29
|
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,16 +210,16 @@ 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<Infer<TSpec['input']>, Infer<TSpec['output']>> : [TSpec['auth']['account']] extends ['required'] ? AuthActionHandler<Infer<TSpec['input']>, Infer<TSpec['output']>> : ActionHandler<Infer<TSpec['input']>, Infer<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.
|
|
217
217
|
*
|
|
218
218
|
* Constructing `{spec, handler}` literals widens `handler` to
|
|
219
|
-
* `ActionHandler<any, any>`, so spec/handler drift (renamed
|
|
219
|
+
* `ActionHandler<any, any>`, so spec/handler drift (renamed 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: Infer<spec.input>, ctx) => Infer<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,MAAM,EAAE,MAAM,yBAAyB,CAAC;
|
|
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,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACtF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;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CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,GAC9C,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,GAChE,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,SAAS,yBAAyB,EACjE,MAAM,KAAK,EACX,SAAS,cAAc,CAAC,KAAK,CAAC,KAC5B,SAGD,CAAC"}
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
* and selecting the narrowest `ctx.auth` shape the spec literal admits.
|
|
24
24
|
*
|
|
25
25
|
* Constructing `{spec, handler}` literals widens `handler` to
|
|
26
|
-
* `ActionHandler<any, any>`, so spec/handler drift (renamed
|
|
26
|
+
* `ActionHandler<any, any>`, so spec/handler drift (renamed 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: Infer<spec.input>, ctx) => Infer<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` /
|
|
@@ -79,8 +79,8 @@ export interface CreateBroadcastApiOptions {
|
|
|
79
79
|
*
|
|
80
80
|
* ```ts
|
|
81
81
|
* export interface BackendActionsApi {
|
|
82
|
-
* filer_change: (input:
|
|
83
|
-
* workspace_changed: (input:
|
|
82
|
+
* filer_change: (input: ActionCallInputs['filer_change']) => Promise<void>;
|
|
83
|
+
* workspace_changed: (input: ActionCallInputs['workspace_changed']) => Promise<void>;
|
|
84
84
|
* }
|
|
85
85
|
*
|
|
86
86
|
* const api = create_broadcast_api<BackendActionsApi>({
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
* @module
|
|
19
19
|
*/
|
|
20
20
|
import { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
21
|
+
import { parse } from '@fuzdev/fuz_schema/schema.ts';
|
|
21
22
|
import { create_jsonrpc_notification, to_jsonrpc_params } from '../http/jsonrpc_helpers.js';
|
|
22
|
-
import { parse_any } from '../schema_issues.js';
|
|
23
23
|
/**
|
|
24
24
|
* Builds a typed broadcast API from a set of action specs.
|
|
25
25
|
*
|
|
@@ -38,8 +38,8 @@ import { parse_any } from '../schema_issues.js';
|
|
|
38
38
|
*
|
|
39
39
|
* ```ts
|
|
40
40
|
* export interface BackendActionsApi {
|
|
41
|
-
* filer_change: (input:
|
|
42
|
-
* workspace_changed: (input:
|
|
41
|
+
* filer_change: (input: ActionCallInputs['filer_change']) => Promise<void>;
|
|
42
|
+
* workspace_changed: (input: ActionCallInputs['workspace_changed']) => Promise<void>;
|
|
43
43
|
* }
|
|
44
44
|
*
|
|
45
45
|
* const api = create_broadcast_api<BackendActionsApi>({
|
|
@@ -59,7 +59,7 @@ export const create_broadcast_api = (options) => {
|
|
|
59
59
|
for (const spec of specs) {
|
|
60
60
|
const { method } = spec;
|
|
61
61
|
const send = (input) => {
|
|
62
|
-
const parsed =
|
|
62
|
+
const parsed = parse(spec.input, input);
|
|
63
63
|
if (!parsed.ok) {
|
|
64
64
|
log?.error(`[${method}] input validation failed:`, parsed.issues);
|
|
65
65
|
return;
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* numbered — "registry-time invariant N" elsewhere in the codebase refers to
|
|
8
8
|
* the `RouteAuth` cross-axis set in `http/auth_shape.ts`, a different list):
|
|
9
9
|
*
|
|
10
|
-
* - **Schema slots** — `input` and `output` each hold a
|
|
11
|
-
* `@fuzdev/fuz_schema` schema (`assert_validation_schema`); a value
|
|
12
|
-
*
|
|
10
|
+
* - **Schema slots** — `input` and `output` each hold a
|
|
11
|
+
* `@fuzdev/fuz_schema` schema (`assert_validation_schema`); a value that
|
|
12
|
+
* is no schema throws naming the action and the slot. Fires for every
|
|
13
13
|
* spec, before the checks that read the schemas.
|
|
14
14
|
* - **Auth-shape cross-axis invariants** — per `assert_route_auth_invariants`
|
|
15
15
|
* in `http/auth_shape.ts`: roles imply a required actor, no accountless
|
|
@@ -33,9 +33,8 @@
|
|
|
33
33
|
* request there is no key for the per-account bucket.
|
|
34
34
|
* - **JSON-RPC §4.2 wire validity** — `request_response` specs whose
|
|
35
35
|
* handler will reach the dispatch map must not use a null schema
|
|
36
|
-
* (`
|
|
37
|
-
*
|
|
38
|
-
* `s.void`, for parameterless methods), nor a void schema for output (a
|
|
36
|
+
* (`literal(null)`) for input (the wire format forbids `"params": null`;
|
|
37
|
+
* use a void schema, `s.void`, for parameterless methods), nor a void schema for output (a
|
|
39
38
|
* response always carries a `result`, which clients validate against
|
|
40
39
|
* `spec.output`; use a null schema for methods with nothing to return).
|
|
41
40
|
* - **Duplicate method names** — JSON-RPC keys on `method`, so every
|
|
@@ -66,7 +65,7 @@ export interface ActionRegistryCompileResult {
|
|
|
66
65
|
*
|
|
67
66
|
* @param actions - polymorphic action array; HTTP RPC passes `RpcAction[]` (narrower), WebSocket passes `Action[]` (kind-polymorphic — handler-less notification specs are accepted)
|
|
68
67
|
* @param ctx_label - per-spec error-message prefix, e.g. `'RPC action'` or `'WS action'`. Combined with the spec method as `${ctx_label} "${method}"`.
|
|
69
|
-
* @throws Error on a schema slot holding a value
|
|
68
|
+
* @throws Error on a schema slot holding a value that is no schema, a cross-axis invariant or biconditional violation, rate-limit/account-axis mismatch, JSON-RPC null-input or void-output, or duplicate method.
|
|
70
69
|
*/
|
|
71
70
|
export declare const compile_action_registry: (actions: ReadonlyArray<Action>, ctx_label: string) => ActionRegistryCompileResult;
|
|
72
71
|
//# sourceMappingURL=compile_action_registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile_action_registry.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/compile_action_registry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"compile_action_registry.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/compile_action_registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAQ3D,oDAAoD;AACpD,MAAM,WAAW,2BAA2B;IAC3C;;;;;OAKG;IACH,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACnC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GACnC,SAAS,aAAa,CAAC,MAAM,CAAC,EAC9B,WAAW,MAAM,KACf,2BAuDF,CAAC"}
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* numbered — "registry-time invariant N" elsewhere in the codebase refers to
|
|
8
8
|
* the `RouteAuth` cross-axis set in `http/auth_shape.ts`, a different list):
|
|
9
9
|
*
|
|
10
|
-
* - **Schema slots** — `input` and `output` each hold a
|
|
11
|
-
* `@fuzdev/fuz_schema` schema (`assert_validation_schema`); a value
|
|
12
|
-
*
|
|
10
|
+
* - **Schema slots** — `input` and `output` each hold a
|
|
11
|
+
* `@fuzdev/fuz_schema` schema (`assert_validation_schema`); a value that
|
|
12
|
+
* is no schema throws naming the action and the slot. Fires for every
|
|
13
13
|
* spec, before the checks that read the schemas.
|
|
14
14
|
* - **Auth-shape cross-axis invariants** — per `assert_route_auth_invariants`
|
|
15
15
|
* in `http/auth_shape.ts`: roles imply a required actor, no accountless
|
|
@@ -33,9 +33,8 @@
|
|
|
33
33
|
* request there is no key for the per-account bucket.
|
|
34
34
|
* - **JSON-RPC §4.2 wire validity** — `request_response` specs whose
|
|
35
35
|
* handler will reach the dispatch map must not use a null schema
|
|
36
|
-
* (`
|
|
37
|
-
*
|
|
38
|
-
* `s.void`, for parameterless methods), nor a void schema for output (a
|
|
36
|
+
* (`literal(null)`) for input (the wire format forbids `"params": null`;
|
|
37
|
+
* use a void schema, `s.void`, for parameterless methods), nor a void schema for output (a
|
|
39
38
|
* response always carries a `result`, which clients validate against
|
|
40
39
|
* `spec.output`; use a null schema for methods with nothing to return).
|
|
41
40
|
* - **Duplicate method names** — JSON-RPC keys on `method`, so every
|
|
@@ -58,7 +57,7 @@ import { assert_validation_schema } from '../schema_issues.js';
|
|
|
58
57
|
*
|
|
59
58
|
* @param actions - polymorphic action array; HTTP RPC passes `RpcAction[]` (narrower), WebSocket passes `Action[]` (kind-polymorphic — handler-less notification specs are accepted)
|
|
60
59
|
* @param ctx_label - per-spec error-message prefix, e.g. `'RPC action'` or `'WS action'`. Combined with the spec method as `${ctx_label} "${method}"`.
|
|
61
|
-
* @throws Error on a schema slot holding a value
|
|
60
|
+
* @throws Error on a schema slot holding a value that is no schema, a cross-axis invariant or biconditional violation, rate-limit/account-axis mismatch, JSON-RPC null-input or void-output, or duplicate method.
|
|
62
61
|
*/
|
|
63
62
|
export const compile_action_registry = (actions, ctx_label) => {
|
|
64
63
|
const action_map = new Map();
|
|
@@ -90,10 +89,10 @@ export const compile_action_registry = (actions, ctx_label) => {
|
|
|
90
89
|
// stay registry-only and bypass JSON-RPC wire-validity checks.
|
|
91
90
|
if (spec.kind === 'request_response' && action.handler) {
|
|
92
91
|
if (is_null_schema(spec.input)) {
|
|
93
|
-
throw new Error(`${ctx} uses a null schema for input (
|
|
92
|
+
throw new Error(`${ctx} uses a null schema for input (literal(null)) — JSON-RPC 2.0 §4.2 forbids "params": null on the wire. Use a void schema (s.void) for parameterless methods.`);
|
|
94
93
|
}
|
|
95
94
|
if (is_void_schema(spec.output)) {
|
|
96
|
-
throw new Error(`${ctx} uses a void schema for output (
|
|
95
|
+
throw new Error(`${ctx} uses a void schema for output (s.void) — a JSON-RPC response always carries a result, and clients validate it against spec.output, so no response could match. Use a null schema (literal(null)) for methods with nothing to return.`);
|
|
97
96
|
}
|
|
98
97
|
action_map.set(spec.method, { spec, handler: action.handler });
|
|
99
98
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer_ping.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/peer_ping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EASN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAKtC,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGlE,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAIvC,kDAAkD;AAClD,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAClD,iDAAiD;AACjD,eAAO,MAAM,2BAA2B,yBAAyB,CAAC;AAClE,iHAAiH;AACjH,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAC5D,sEAAsE;AACtE,eAAO,MAAM,8BAA8B,4BAA4B,CAAC;AACxE,0EAA0E;AAC1E,eAAO,MAAM,8BAA8B,4BAA4B,CAAC;AACxE,qFAAqF;AACrF,eAAO,MAAM,+BAA+B,6BAA6B,CAAC;AAE1E;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"peer_ping.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/peer_ping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EASN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAKtC,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGlE,+EAA+E;AAC/E,eAAO,MAA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with_default(object({
|
|
|
74
74
|
// optional, so an empty invocation is valid (server-issued nonce, default
|
|
75
75
|
// timeout). The server reads absent `params` as `{}` before the schema; the
|
|
76
76
|
// client's pre-send parse of `app.api['peer/ping']()` reaches the default.
|
|
77
|
-
//
|
|
78
|
-
|
|
77
|
+
// `with_default` hands out one shared value, so it is frozen: a write to
|
|
78
|
+
// it throws rather than leaking into every later call
|
|
79
|
+
Object.freeze({}));
|
|
79
80
|
/** Params of the server→client `peer/ping` request frame. Twin of the Rust `PingRequest`. */
|
|
80
81
|
export const PingRequestParams = object({
|
|
81
82
|
nonce: pipe(number, safe_integer)
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* `__proto__` key at any depth (`json_has_own_proto_key`) are refused
|
|
32
32
|
* with `data.reason` `params_proto_key` (`ERROR_PARAMS_PROTO_KEY`), on
|
|
33
33
|
* every input schema, before it runs; then
|
|
34
|
-
* `spec.input` parses the params (`
|
|
34
|
+
* `spec.input` parses the params (`parse`) with
|
|
35
35
|
* void / `?? {}` rules (`to_input_params`). A refusal is the generic
|
|
36
36
|
* `invalid params`, with `data.reason` when the first issue's field
|
|
37
37
|
* declares an `invalid_reason` (`to_invalid_params_error`) and the
|
|
@@ -61,11 +61,11 @@
|
|
|
61
61
|
* @module
|
|
62
62
|
*/
|
|
63
63
|
import type { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
64
|
+
import { type SchemaIssue, type AnySchema } from '@fuzdev/fuz_schema/schema.ts';
|
|
64
65
|
import type { Uuid } from '../primitive_schemas.js';
|
|
65
66
|
import { type RequestContext } from '../auth/request_context.js';
|
|
66
67
|
import { type ResolvedAuth } from '../auth/resolved_auth.js';
|
|
67
68
|
import type { Db } from '../db/db.js';
|
|
68
|
-
import { type AnyIssue, type ValidationSchema } from '../schema_issues.js';
|
|
69
69
|
import { type JsonrpcRequestId, type JsonrpcErrorObject } from '../http/jsonrpc.js';
|
|
70
70
|
import type { RateLimiter } from '../rate_limiter.js';
|
|
71
71
|
import type { RpcAction } from './action_types.js';
|
|
@@ -77,7 +77,7 @@ import type { RequestClient } from './peer_request.js';
|
|
|
77
77
|
export interface PerformActionInput {
|
|
78
78
|
/** The resolved spec + handler (transport does method lookup). */
|
|
79
79
|
action: RpcAction;
|
|
80
|
-
/** Raw params from the wire envelope (validated by `JsonrpcRequest`, pre-`
|
|
80
|
+
/** Raw params from the wire envelope (validated by `JsonrpcRequest`, pre-`parse(spec.input, …)`). */
|
|
81
81
|
raw_params: unknown;
|
|
82
82
|
/** JSON-RPC request id — echoed onto the response. */
|
|
83
83
|
request_id: JsonrpcRequestId;
|
|
@@ -175,12 +175,12 @@ export declare const perform_action: (input: PerformActionInput, deps: PerformAc
|
|
|
175
175
|
* DEV only (`dev_only`). With no declared reason, production sends no `data` at
|
|
176
176
|
* all.
|
|
177
177
|
*
|
|
178
|
-
* @param input - the action's input schema
|
|
179
|
-
* @param issues - the failed parse's issues, in the
|
|
178
|
+
* @param input - the action's input schema
|
|
179
|
+
* @param issues - the failed parse's issues, in the parse's order
|
|
180
180
|
* @param params - the value that was parsed
|
|
181
181
|
* @returns the JSON-RPC error object
|
|
182
182
|
*/
|
|
183
|
-
export declare const to_invalid_params_error: (input:
|
|
183
|
+
export declare const to_invalid_params_error: (input: AnySchema, issues: ReadonlyArray<SchemaIssue>, params: unknown) => JsonrpcErrorObject;
|
|
184
184
|
/**
|
|
185
185
|
* The credential-type 403 — one builder, so the dispatcher's gate below and a
|
|
186
186
|
* handler that gates a credential channel on its input (`account_delete`'s
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perform_action.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/perform_action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAA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,EAChB,QAAQ,aAAa,CAAC,WAAW,CAAC,EAClC,QAAQ,OAAO,KACb,kBAOF,CAAC;AA6DF;;;;;;;;GAQG;AACH,eAAO,MAAM,8BAA8B,GAC1C,2BAA2B,aAAa,CAAC,MAAM,CAAC,KAC9C,kBAIA,CAAC;AAqEJ,0FAA0F;AAC1F,MAAM,WAAW,sBAAsB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,uBAAuB,GACnC,IAAI,gBAAgB,EACpB,QAAQ,mBAAmB,EAC3B,QAAQ,MAAM,EACd,KAAK,MAAM,KACT,sBAkBF,CAAC"}
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* `__proto__` key at any depth (`json_has_own_proto_key`) are refused
|
|
32
32
|
* with `data.reason` `params_proto_key` (`ERROR_PARAMS_PROTO_KEY`), on
|
|
33
33
|
* every input schema, before it runs; then
|
|
34
|
-
* `spec.input` parses the params (`
|
|
34
|
+
* `spec.input` parses the params (`parse`) with
|
|
35
35
|
* void / `?? {}` rules (`to_input_params`). A refusal is the generic
|
|
36
36
|
* `invalid params`, with `data.reason` when the first issue's field
|
|
37
37
|
* declares an `invalid_reason` (`to_invalid_params_error`) and the
|
|
@@ -61,11 +61,12 @@
|
|
|
61
61
|
* @module
|
|
62
62
|
*/
|
|
63
63
|
import { DEV } from 'esm-env';
|
|
64
|
+
import { parse } from '@fuzdev/fuz_schema/schema.ts';
|
|
64
65
|
import { apply_authorization_phase, has_any_scoped_role } from '../auth/request_context.js';
|
|
65
66
|
import { resolved_auth_scope, resolved_auth_session_hash } from '../auth/resolved_auth.js';
|
|
66
67
|
import { is_db_checkout_error } from '../db/db_checkout_error.js';
|
|
67
68
|
import { resolve_issues_invalid_reason } from '../schema_meta.js';
|
|
68
|
-
import {
|
|
69
|
+
import { to_wire_issues } from '../schema_issues.js';
|
|
69
70
|
import { json_has_own_proto_key, to_input_params } from '../http/schema_helpers.js';
|
|
70
71
|
import { rate_limit_ip_key } from '../http/ip_canonical.js';
|
|
71
72
|
import { dispatch_with_post_commit_rollback } from '../http/pending_effects.js';
|
|
@@ -169,12 +170,12 @@ export const perform_action = async (input, deps) => {
|
|
|
169
170
|
// step 5: validate params. JSON-RPC 2.0 §4.2 forbids `params: null`;
|
|
170
171
|
// registration sites reject null-schema inputs. Empty-body convention
|
|
171
172
|
// (`raw_params ?? {}`) lets all-optional-object methods omit `params`;
|
|
172
|
-
// a void input
|
|
173
|
+
// a void input reads every empty shape as the no-arg call — see
|
|
173
174
|
// `to_input_params`.
|
|
174
175
|
//
|
|
175
176
|
// An own `__proto__` key anywhere in object params is refused first, on
|
|
176
|
-
// every input:
|
|
177
|
-
//
|
|
177
|
+
// every input: a loose schema passes it through, so a schema alone would
|
|
178
|
+
// store it — a sink for
|
|
178
179
|
// any client that copies the value back with plain assignment. Only an
|
|
179
180
|
// object is walked, so a non-object `params` is the schema's refusal, as
|
|
180
181
|
// the Rust twin's shape check answers it ahead of its walk.
|
|
@@ -185,7 +186,7 @@ export const perform_action = async (input, deps) => {
|
|
|
185
186
|
return error_result(jsonrpc_error_messages.invalid_params('invalid params', { reason: ERROR_PARAMS_PROTO_KEY }));
|
|
186
187
|
}
|
|
187
188
|
const params = to_input_params(spec.input, raw_params);
|
|
188
|
-
const parse_result =
|
|
189
|
+
const parse_result = parse(spec.input, params);
|
|
189
190
|
if (!parse_result.ok) {
|
|
190
191
|
return error_result(to_invalid_params_error(spec.input, parse_result.issues, params));
|
|
191
192
|
}
|
|
@@ -211,7 +212,7 @@ export const perform_action = async (input, deps) => {
|
|
|
211
212
|
const output = await handler(validated_input, action_context);
|
|
212
213
|
// DEV-only output validation — logs on mismatch, never throws.
|
|
213
214
|
if (DEV) {
|
|
214
|
-
const output_result =
|
|
215
|
+
const output_result = parse(spec.output, output);
|
|
215
216
|
if (!output_result.ok) {
|
|
216
217
|
log.error(`action output schema mismatch: ${spec.method}`, output_result.issues);
|
|
217
218
|
}
|
|
@@ -263,14 +264,14 @@ const thrown_error_result = (err, context, log) => {
|
|
|
263
264
|
* DEV only (`dev_only`). With no declared reason, production sends no `data` at
|
|
264
265
|
* all.
|
|
265
266
|
*
|
|
266
|
-
* @param input - the action's input schema
|
|
267
|
-
* @param issues - the failed parse's issues, in the
|
|
267
|
+
* @param input - the action's input schema
|
|
268
|
+
* @param issues - the failed parse's issues, in the parse's order
|
|
268
269
|
* @param params - the value that was parsed
|
|
269
270
|
* @returns the JSON-RPC error object
|
|
270
271
|
*/
|
|
271
272
|
export const to_invalid_params_error = (input, issues, params) => {
|
|
272
273
|
const reason = resolve_issues_invalid_reason(input, issues, params);
|
|
273
|
-
const issues_data = dev_only(() => ({ issues: to_wire_issues(issues
|
|
274
|
+
const issues_data = dev_only(() => ({ issues: to_wire_issues(issues) }));
|
|
274
275
|
return jsonrpc_error_messages.invalid_params('invalid params', reason === undefined ? issues_data : { reason, ...issues_data });
|
|
275
276
|
};
|
|
276
277
|
const error_result = (error) => ({
|
|
@@ -327,7 +327,7 @@ export declare class FrontendWebsocketClient implements WebsocketConnection, Dis
|
|
|
327
327
|
*
|
|
328
328
|
* An `undefined` `params` is omitted from the frame rather than sent as
|
|
329
329
|
* `{}` — the absent form is the parameterless call every server admits
|
|
330
|
-
* for a
|
|
330
|
+
* for a void input, including servers that refuse `{}`.
|
|
331
331
|
*
|
|
332
332
|
* Callers supplying an explicit `options.id` are responsible for
|
|
333
333
|
* uniqueness — the pending map is keyed by id, and a duplicate silently
|