@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
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ActionEvent — state machine for action lifecycle management.
|
|
3
|
-
*
|
|
4
|
-
* Manages an action through its phases (send_request → receive_response, etc.)
|
|
5
|
-
* and steps (initial → parsed → handling → handled/failed).
|
|
6
|
-
*
|
|
7
|
-
* @module
|
|
8
|
-
*/
|
|
9
1
|
import type { ActionEventPhase, ActionSpecUnion } from './action_spec.js';
|
|
10
2
|
import type { JsonrpcRequest, JsonrpcResponseOrError, JsonrpcNotification } from '../http/jsonrpc.js';
|
|
11
3
|
import type { ActionEventEnvironment, ActionEventStep } from './action_event_types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_event.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_event.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"action_event.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_event.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,gBAAgB,EAAc,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAkBtF,OAAO,KAAK,EACX,cAAc,EACd,sBAAsB,EACtB,mBAAmB,EAEnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,KAAK,EAAmB,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAapF;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,EAAG,yBAAkC,CAAC;AAmB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;IAItB,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAIxC,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAQ1C,YAAY,CAAC,QAAQ,EAAE,sBAAsB,GAAG,IAAI;IAUpD,gBAAgB,CAAC,YAAY,EAAE,mBAAmB,GAAG,IAAI;CA+LzD;AAGD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,SAAS,MAAM,GAAG,MAAM,EAClE,aAAa,sBAAsB,EACnC,MAAM,eAAe,EACrB,OAAO,OAAO,EACd,gBAAgB,gBAAgB,KAC9B,WAAW,CAAC,OAAO,CAmBrB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,GAAI,OAAO,SAAS,MAAM,GAAG,MAAM,EAC5E,MAAM,oBAAoB,CAAC,OAAO,CAAC,EACnC,aAAa,sBAAsB,KACjC,WAAW,CAAC,OAAO,CAOrB,CAAC"}
|
|
@@ -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 {
|
|
@@ -11,15 +11,14 @@ import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
|
11
11
|
import { JsonrpcRequest, JsonrpcResponseOrError, JsonrpcNotification, JsonrpcErrorObject } from '../http/jsonrpc.js';
|
|
12
12
|
import { ActionExecutor } from './action_event_types.js';
|
|
13
13
|
export declare const ActionEventData: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
14
|
+
input: unknown;
|
|
15
|
+
kind: "request_response" | "remote_notification" | "local_call";
|
|
16
|
+
method: string;
|
|
14
17
|
error: ({
|
|
15
18
|
message: string;
|
|
16
19
|
code: -32700 | -32600 | -32601 | -32602 | -32603 | import("@fuzdev/fuz_schema/schema.ts").Branded<number, "JsonrpcServerErrorCode">;
|
|
17
20
|
data?: unknown;
|
|
18
21
|
} & Record<string, unknown>) | null;
|
|
19
|
-
output: unknown;
|
|
20
|
-
input: unknown;
|
|
21
|
-
kind: "request_response" | "remote_notification" | "local_call";
|
|
22
|
-
method: string;
|
|
23
22
|
request: ({
|
|
24
23
|
id: string | number;
|
|
25
24
|
method: string;
|
|
@@ -36,28 +35,28 @@ export declare const ActionEventData: import("@fuzdev/fuz_schema/schema.ts").Sch
|
|
|
36
35
|
jsonrpc: "2.0";
|
|
37
36
|
result: unknown;
|
|
38
37
|
} & Record<string, unknown>) | ({
|
|
38
|
+
id: string | number | null;
|
|
39
39
|
error: {
|
|
40
40
|
message: string;
|
|
41
41
|
code: -32700 | -32600 | -32601 | -32602 | -32603 | import("@fuzdev/fuz_schema/schema.ts").Branded<number, "JsonrpcServerErrorCode">;
|
|
42
42
|
data?: unknown;
|
|
43
43
|
} & Record<string, unknown>;
|
|
44
|
-
id: string | number | null;
|
|
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";
|
|
50
50
|
progress: unknown;
|
|
51
51
|
}, {
|
|
52
|
+
input: unknown;
|
|
53
|
+
kind: "request_response" | "remote_notification" | "local_call";
|
|
54
|
+
method: string;
|
|
52
55
|
error: ({
|
|
53
56
|
message: string;
|
|
54
57
|
code: number;
|
|
55
58
|
data?: unknown;
|
|
56
59
|
} & Record<string, unknown>) | null;
|
|
57
|
-
output: unknown;
|
|
58
|
-
input: unknown;
|
|
59
|
-
kind: "request_response" | "remote_notification" | "local_call";
|
|
60
|
-
method: string;
|
|
61
60
|
request: ({
|
|
62
61
|
id: string | number;
|
|
63
62
|
method: string;
|
|
@@ -74,14 +73,15 @@ export declare const ActionEventData: import("@fuzdev/fuz_schema/schema.ts").Sch
|
|
|
74
73
|
jsonrpc: "2.0";
|
|
75
74
|
result: unknown;
|
|
76
75
|
} & Record<string, unknown>) | ({
|
|
76
|
+
id: string | number | null;
|
|
77
77
|
error: {
|
|
78
78
|
message: string;
|
|
79
79
|
code: number;
|
|
80
80
|
data?: unknown;
|
|
81
81
|
} & Record<string, unknown>;
|
|
82
|
-
id: string | number | null;
|
|
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";
|
|
@@ -111,7 +111,7 @@ export declare const ActionEventData: import("@fuzdev/fuz_schema/schema.ts").Sch
|
|
|
111
111
|
code: number;
|
|
112
112
|
data?: unknown;
|
|
113
113
|
} & Record<string, unknown>, "loose_object", {
|
|
114
|
-
code: import("@fuzdev/fuz_schema/schema.ts").Schema<-32700 | -32600 | -32601 | -32602 | -32603 | import("@fuzdev/fuz_schema/schema.ts").Branded<number, "JsonrpcServerErrorCode">, number, "union", readonly [import("@fuzdev/fuz_schema/schema.ts").Schema<-32700 | -32600 | -32601 | -32602 | -32603, -32700 | -32600 | -32601 | -32602 | -32603, "one_of", readonly [-32700, -32600, -32601, -32602, -32603]>, import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<number, "JsonrpcServerErrorCode">, number, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"
|
|
114
|
+
code: import("@fuzdev/fuz_schema/schema.ts").Schema<-32700 | -32600 | -32601 | -32602 | -32603 | import("@fuzdev/fuz_schema/schema.ts").Branded<number, "JsonrpcServerErrorCode">, number, "union", readonly [import("@fuzdev/fuz_schema/schema.ts").Schema<-32700 | -32600 | -32601 | -32602 | -32603, -32700 | -32600 | -32601 | -32602 | -32603, "one_of", readonly [-32700, -32600, -32601, -32602, -32603]>, import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<number, "JsonrpcServerErrorCode">, number, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform">)[]> & {
|
|
115
115
|
readonly '~types'?: {
|
|
116
116
|
readonly input: number;
|
|
117
117
|
readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<number, number, "number", undefined>;
|
|
@@ -152,48 +152,48 @@ export declare const ActionEventData: import("@fuzdev/fuz_schema/schema.ts").Sch
|
|
|
152
152
|
jsonrpc: "2.0";
|
|
153
153
|
result: unknown;
|
|
154
154
|
} & Record<string, unknown>) | ({
|
|
155
|
+
id: string | number | null;
|
|
155
156
|
error: {
|
|
156
157
|
message: string;
|
|
157
158
|
code: -32700 | -32600 | -32601 | -32602 | -32603 | import("@fuzdev/fuz_schema/schema.ts").Branded<number, "JsonrpcServerErrorCode">;
|
|
158
159
|
data?: unknown;
|
|
159
160
|
} & Record<string, unknown>;
|
|
160
|
-
id: string | number | null;
|
|
161
161
|
jsonrpc: "2.0";
|
|
162
162
|
} & Record<string, unknown>) | null, ({
|
|
163
163
|
id: string | number;
|
|
164
164
|
jsonrpc: "2.0";
|
|
165
165
|
result: unknown;
|
|
166
166
|
} & Record<string, unknown>) | ({
|
|
167
|
+
id: string | number | null;
|
|
167
168
|
error: {
|
|
168
169
|
message: string;
|
|
169
170
|
code: number;
|
|
170
171
|
data?: unknown;
|
|
171
172
|
} & Record<string, unknown>;
|
|
172
|
-
id: string | number | null;
|
|
173
173
|
jsonrpc: "2.0";
|
|
174
174
|
} & Record<string, unknown>) | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<({
|
|
175
175
|
id: string | number;
|
|
176
176
|
jsonrpc: "2.0";
|
|
177
177
|
result: unknown;
|
|
178
178
|
} & Record<string, unknown>) | ({
|
|
179
|
+
id: string | number | null;
|
|
179
180
|
error: {
|
|
180
181
|
message: string;
|
|
181
182
|
code: -32700 | -32600 | -32601 | -32602 | -32603 | import("@fuzdev/fuz_schema/schema.ts").Branded<number, "JsonrpcServerErrorCode">;
|
|
182
183
|
data?: unknown;
|
|
183
184
|
} & Record<string, unknown>;
|
|
184
|
-
id: string | number | null;
|
|
185
185
|
jsonrpc: "2.0";
|
|
186
186
|
} & Record<string, unknown>), ({
|
|
187
187
|
id: string | number;
|
|
188
188
|
jsonrpc: "2.0";
|
|
189
189
|
result: unknown;
|
|
190
190
|
} & Record<string, unknown>) | ({
|
|
191
|
+
id: string | number | null;
|
|
191
192
|
error: {
|
|
192
193
|
message: string;
|
|
193
194
|
code: number;
|
|
194
195
|
data?: unknown;
|
|
195
196
|
} & Record<string, unknown>;
|
|
196
|
-
id: string | number | null;
|
|
197
197
|
jsonrpc: "2.0";
|
|
198
198
|
} & Record<string, unknown>), "union", readonly [import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
199
199
|
id: string | number;
|
|
@@ -208,20 +208,20 @@ export declare const ActionEventData: import("@fuzdev/fuz_schema/schema.ts").Sch
|
|
|
208
208
|
id: import("@fuzdev/fuz_schema/schema.ts").Schema<string | number, string | number, "union", readonly [import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>, import("@fuzdev/fuz_schema/schema.ts").Schema<number, number, "number", undefined>]>;
|
|
209
209
|
result: import("@fuzdev/fuz_schema/schema.ts").Schema<unknown, unknown, "unknown", undefined>;
|
|
210
210
|
}>, import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
211
|
+
id: string | number | null;
|
|
211
212
|
error: {
|
|
212
213
|
message: string;
|
|
213
214
|
code: -32700 | -32600 | -32601 | -32602 | -32603 | import("@fuzdev/fuz_schema/schema.ts").Branded<number, "JsonrpcServerErrorCode">;
|
|
214
215
|
data?: unknown;
|
|
215
216
|
} & Record<string, unknown>;
|
|
216
|
-
id: string | number | null;
|
|
217
217
|
jsonrpc: "2.0";
|
|
218
218
|
} & Record<string, unknown>, {
|
|
219
|
+
id: string | number | null;
|
|
219
220
|
error: {
|
|
220
221
|
message: string;
|
|
221
222
|
code: number;
|
|
222
223
|
data?: unknown;
|
|
223
224
|
} & Record<string, unknown>;
|
|
224
|
-
id: string | number | null;
|
|
225
225
|
jsonrpc: "2.0";
|
|
226
226
|
} & Record<string, unknown>, "loose_object", {
|
|
227
227
|
jsonrpc: import("@fuzdev/fuz_schema/schema.ts").Schema<"2.0", "2.0", "literal", "2.0">;
|
|
@@ -235,7 +235,7 @@ export declare const ActionEventData: import("@fuzdev/fuz_schema/schema.ts").Sch
|
|
|
235
235
|
code: number;
|
|
236
236
|
data?: unknown;
|
|
237
237
|
} & Record<string, unknown>, "loose_object", {
|
|
238
|
-
code: import("@fuzdev/fuz_schema/schema.ts").Schema<-32700 | -32600 | -32601 | -32602 | -32603 | import("@fuzdev/fuz_schema/schema.ts").Branded<number, "JsonrpcServerErrorCode">, number, "union", readonly [import("@fuzdev/fuz_schema/schema.ts").Schema<-32700 | -32600 | -32601 | -32602 | -32603, -32700 | -32600 | -32601 | -32602 | -32603, "one_of", readonly [-32700, -32600, -32601, -32602, -32603]>, import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<number, "JsonrpcServerErrorCode">, number, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"
|
|
238
|
+
code: import("@fuzdev/fuz_schema/schema.ts").Schema<-32700 | -32600 | -32601 | -32602 | -32603 | import("@fuzdev/fuz_schema/schema.ts").Branded<number, "JsonrpcServerErrorCode">, number, "union", readonly [import("@fuzdev/fuz_schema/schema.ts").Schema<-32700 | -32600 | -32601 | -32602 | -32603, -32700 | -32600 | -32601 | -32602 | -32603, "one_of", readonly [-32700, -32600, -32601, -32602, -32603]>, import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<number, "JsonrpcServerErrorCode">, number, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform">)[]> & {
|
|
239
239
|
readonly '~types'?: {
|
|
240
240
|
readonly input: number;
|
|
241
241
|
readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<number, number, "number", undefined>;
|
|
@@ -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
|
*/
|
|
@@ -80,7 +80,7 @@ const envelope_response = (c, envelope, status) => route_raw(c.body(JSON.stringi
|
|
|
80
80
|
* @returns route specs (GET + POST) ready for `apply_route_specs`
|
|
81
81
|
* @throws Error if two actions share the same `spec.method` (registration-time
|
|
82
82
|
* duplicate detection); also throws if any action's `spec.input` is a null
|
|
83
|
-
* schema (`
|
|
83
|
+
* schema (`literal(null)`; JSON-RPC 2.0 §4.2 forbids
|
|
84
84
|
* `params: null` on the wire — use a void schema for parameterless methods)
|
|
85
85
|
* or its `spec.output` is a void schema.
|
|
86
86
|
*/
|
|
@@ -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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,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,meAA8B,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -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
|
|
@@ -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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AM,MAAM,cAAc,CAAC,KAAK,SAAS,yBAAyB,IAAI;IACrE,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;CACtB,SAAS,CAAC,UAAU,CAAC,GACnB,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,GACjE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,SAAS,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
|
}
|
|
@@ -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
|