@fuzdev/fuz_app 0.155.1 → 0.157.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/CLAUDE.md +27 -14
- package/dist/actions/action_codegen.d.ts +10 -3
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +52 -13
- package/dist/actions/action_event.d.ts.map +1 -1
- package/dist/actions/action_event.js +13 -11
- package/dist/actions/action_rpc.d.ts +4 -3
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +4 -3
- package/dist/actions/action_spec.d.ts +102 -206
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/action_spec.js +18 -96
- package/dist/actions/action_types.d.ts +4 -4
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/action_types.js +2 -2
- package/dist/actions/broadcast_api.d.ts.map +1 -1
- package/dist/actions/broadcast_api.js +6 -5
- package/dist/actions/compile_action_registry.d.ts +11 -6
- package/dist/actions/compile_action_registry.d.ts.map +1 -1
- package/dist/actions/compile_action_registry.js +15 -9
- package/dist/actions/perform_action.d.ts +4 -4
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +11 -11
- package/dist/auth/CLAUDE.md +1 -1
- package/dist/auth/account_action_specs.d.ts +50 -23
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_action_specs.js +18 -8
- package/dist/auth/account_route_schema.d.ts +10 -10
- package/dist/auth/account_schema.d.ts +21 -21
- package/dist/auth/actor_lookup_action_specs.d.ts +7 -7
- package/dist/auth/actor_search_action_specs.d.ts +6 -6
- package/dist/auth/admin_action_specs.d.ts +98 -98
- package/dist/auth/app_settings_schema.d.ts +2 -2
- package/dist/auth/audit_log_route_schema.d.ts +1 -1
- package/dist/auth/audit_log_schema.d.ts +44 -44
- package/dist/auth/auth_guard_resolver.d.ts +2 -2
- package/dist/auth/auth_guard_resolver.js +2 -2
- package/dist/auth/bootstrap_route_schema.d.ts +4 -4
- package/dist/auth/cell_action_specs.d.ts +241 -241
- package/dist/auth/cell_actions.js +3 -3
- package/dist/auth/cell_audit_action_specs.d.ts +14 -14
- package/dist/auth/cell_audit_metadata.d.ts +6 -6
- package/dist/auth/cell_field_action_specs.d.ts +38 -38
- package/dist/auth/cell_field_audit_metadata.d.ts +4 -4
- package/dist/auth/cell_grant_action_specs.d.ts +61 -61
- package/dist/auth/cell_grant_audit_metadata.d.ts +10 -10
- package/dist/auth/cell_item_action_specs.d.ts +50 -50
- package/dist/auth/cell_item_audit_metadata.d.ts +5 -5
- package/dist/auth/invite_schema.d.ts +6 -6
- package/dist/auth/role_grant_offer_action_specs.d.ts +120 -120
- package/dist/auth/role_grant_offer_notifications.d.ts +66 -66
- package/dist/auth/role_grant_offer_schema.d.ts +6 -6
- package/dist/auth/self_service_role_action_specs.d.ts +2 -2
- package/dist/auth/signup_route_schema.d.ts +2 -2
- package/dist/http/CLAUDE.md +26 -17
- package/dist/http/auth_shape.d.ts +51 -17
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +101 -52
- package/dist/http/error_schemas.d.ts +15 -8
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +4 -9
- package/dist/http/jsonrpc_errors.d.ts +11 -4
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +11 -4
- package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
- package/dist/http/jsonrpc_helpers.js +2 -1
- package/dist/http/route_spec.d.ts +37 -19
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +54 -24
- package/dist/http/schema_helpers.d.ts +27 -24
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +24 -19
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +7 -3
- package/dist/primitive_schemas.d.ts +16 -5
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +26 -4
- package/dist/primitive_schemas_fuz.d.ts +67 -0
- package/dist/primitive_schemas_fuz.d.ts.map +1 -0
- package/dist/primitive_schemas_fuz.js +47 -0
- package/dist/realtime/sse.d.ts +3 -3
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +4 -4
- package/dist/schema_issues.d.ts +91 -4
- package/dist/schema_issues.d.ts.map +1 -1
- package/dist/schema_issues.js +262 -1
- package/dist/schema_meta.d.ts +24 -8
- package/dist/schema_meta.d.ts.map +1 -1
- package/dist/schema_meta.js +31 -10
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +2 -1
- package/dist/testing/CLAUDE.md +23 -17
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +3 -2
- package/dist/testing/adversarial_404.d.ts +2 -2
- package/dist/testing/adversarial_404.d.ts.map +1 -1
- package/dist/testing/adversarial_404.js +8 -5
- package/dist/testing/adversarial_input.js +1 -1
- package/dist/testing/adversarial_input_cases.d.ts +18 -23
- package/dist/testing/adversarial_input_cases.d.ts.map +1 -1
- package/dist/testing/adversarial_input_cases.js +51 -46
- package/dist/testing/assertions.d.ts +6 -5
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +9 -4
- package/dist/testing/cross_backend/action_manifest.d.ts +2 -1
- package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest.js +3 -3
- package/dist/testing/cross_backend/cell_crud.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_crud.js +3 -8
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +5 -4
- package/dist/testing/cross_backend/cross_rpc.d.ts +4 -2
- package/dist/testing/cross_backend/cross_rpc.d.ts.map +1 -1
- package/dist/testing/cross_backend/cross_rpc.js +6 -4
- package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.js +3 -2
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +8 -8
- package/dist/testing/error_coverage.d.ts +9 -17
- package/dist/testing/error_coverage.d.ts.map +1 -1
- package/dist/testing/error_coverage.js +20 -3
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +7 -6
- package/dist/testing/rpc_envelope_cases.d.ts +3 -3
- package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
- package/dist/testing/rpc_envelope_cases.js +1 -1
- package/dist/testing/rpc_helpers.d.ts +12 -8
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +18 -15
- package/dist/testing/schema_generators.d.ts +75 -40
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +273 -99
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +4 -3
- package/dist/ui/admin_accounts_state.svelte.d.ts +10 -10
- package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_invites_state.svelte.d.ts +1 -1
- package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_sessions_state.svelte.d.ts +2 -2
- package/dist/ui/admin_sessions_state.svelte.d.ts.map +1 -1
- package/dist/ui/role_grant_offers_state.svelte.d.ts +6 -6
- package/dist/zod.d.ts +23 -5
- package/dist/zod.d.ts.map +1 -1
- package/dist/zod.js +2 -2
- package/package.json +6 -6
|
@@ -13,6 +13,7 @@ import '../assert_dev_env.js';
|
|
|
13
13
|
*/
|
|
14
14
|
import { assert } from 'vitest';
|
|
15
15
|
import { create_rpc_post_init } from '../rpc_helpers.js';
|
|
16
|
+
import { parse_any } from '../../schema_issues.js';
|
|
16
17
|
/** How much of a non-envelope reply body `cross_rpc_call`'s error quotes. */
|
|
17
18
|
const BODY_HEAD_LENGTH = 200;
|
|
18
19
|
/**
|
|
@@ -56,11 +57,12 @@ export const error_reason = (r) => r.error && typeof r.error.data === 'object' &
|
|
|
56
57
|
: undefined;
|
|
57
58
|
/**
|
|
58
59
|
* Assert the call succeeded and the `result` matches the verb's declared
|
|
59
|
-
* output schema — the wire-shape parity gate.
|
|
60
|
+
* output schema, Zod or `@fuzdev/fuz_schema` — the wire-shape parity gate.
|
|
61
|
+
* Returns the parsed output.
|
|
60
62
|
*/
|
|
61
63
|
export const expect_output = (r, schema) => {
|
|
62
64
|
assert.ok(r.ok, `expected success, got ${JSON.stringify(r.error)}`);
|
|
63
|
-
const parsed = schema
|
|
64
|
-
assert.ok(parsed.
|
|
65
|
-
return parsed.
|
|
65
|
+
const parsed = parse_any(schema, r.result);
|
|
66
|
+
assert.ok(parsed.ok, `result does not match output schema: ${parsed.ok ? '' : JSON.stringify(parsed.issues)} (got ${JSON.stringify(r.result)})`);
|
|
67
|
+
return parsed.value;
|
|
66
68
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc_success_fixtures.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/rpc_success_fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAqC9B,OAAO,KAAK,EAAqB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"rpc_success_fixtures.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/rpc_success_fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAqC9B,OAAO,KAAK,EAAqB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAQlF,uDAAuD;AACvD,MAAM,WAAW,8BAA8B;IAC9C,gGAAgG;IAChG,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iCAAiC,GAC7C,UAAS,8BAAmC,KAC1C,kBAwHF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse_round_trip.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/sse_round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"sse_round_trip.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/sse_round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAmF9B,OAAO,EAAE,KAAK,mBAAmB,EAAW,MAAM,mBAAmB,CAAC;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAO5C,4DAA4D;AAC5D,MAAM,WAAW,0BAA0B;IAC1C;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,wEAAwE;IACxE,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAC3C,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,wFAAwF;IACxF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,4FAA4F;IAC5F,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CAChC;AA0BD;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,GAAI,SAAS,0BAA0B,KAAG,IA0StF,CAAC"}
|
|
@@ -64,6 +64,7 @@ import { account_delete_action_spec, admin_session_revoke_all_action_spec } from
|
|
|
64
64
|
import { ROLE_ADMIN } from '../../auth/role_schema.js';
|
|
65
65
|
import { AUDIT_LOG_SSE_MAX_PER_SCOPE, audit_log_event_specs } from '../../realtime/audit_log_sse.js';
|
|
66
66
|
import { SSE_CONNECTED_COMMENT } from '../../realtime/sse_constants.js';
|
|
67
|
+
import { parse_any } from '../../schema_issues.js';
|
|
67
68
|
import { create_sse_transport } from '../transports/sse_transport.js';
|
|
68
69
|
import { create_rpc_post_init } from '../rpc_helpers.js';
|
|
69
70
|
import { DEFAULT_TEST_PASSWORD } from '../test_credentials.js';
|
|
@@ -82,8 +83,8 @@ const assert_audit_data_frame = (frame) => {
|
|
|
82
83
|
assert.strictEqual(typeof payload.method, 'string', 'audit data frame method must be a string');
|
|
83
84
|
const spec = audit_log_event_specs.find((s) => s.method === payload.method);
|
|
84
85
|
assert.ok(spec, `no EventSpec declared for audit method '${String(payload.method)}'`);
|
|
85
|
-
const result = spec.params
|
|
86
|
-
assert.ok(result.
|
|
86
|
+
const result = parse_any(spec.params, payload.params);
|
|
87
|
+
assert.ok(result.ok, `audit data frame params mismatch for '${String(payload.method)}': ${result.ok ? '' : JSON.stringify(result.issues)}`);
|
|
87
88
|
};
|
|
88
89
|
/**
|
|
89
90
|
* Register the cross-process SSE round-trip suite. Its cases run over a
|
|
@@ -131,27 +131,27 @@ export declare const testing_reset_action_spec: {
|
|
|
131
131
|
}, z.core.$strict>;
|
|
132
132
|
readonly output: z.ZodObject<{
|
|
133
133
|
account: z.ZodObject<{
|
|
134
|
-
id: z.
|
|
134
|
+
id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>;
|
|
135
135
|
username: z.ZodString;
|
|
136
136
|
}, z.core.$strict>;
|
|
137
137
|
actor: z.ZodObject<{
|
|
138
|
-
id: z.
|
|
138
|
+
id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>;
|
|
139
139
|
}, z.core.$strict>;
|
|
140
140
|
api_token: z.ZodString;
|
|
141
141
|
session_cookie: z.ZodString;
|
|
142
142
|
extra_accounts: z.ZodArray<z.ZodObject<{
|
|
143
143
|
account: z.ZodObject<{
|
|
144
|
-
id: z.
|
|
144
|
+
id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>;
|
|
145
145
|
username: z.ZodString;
|
|
146
146
|
}, z.core.$strict>;
|
|
147
147
|
actor: z.ZodObject<{
|
|
148
|
-
id: z.
|
|
148
|
+
id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>;
|
|
149
149
|
}, z.core.$strict>;
|
|
150
150
|
api_token: z.ZodString;
|
|
151
151
|
session_cookie: z.ZodString;
|
|
152
152
|
}, z.core.$strict>>;
|
|
153
153
|
extra_actors: z.ZodArray<z.ZodObject<{
|
|
154
|
-
id: z.
|
|
154
|
+
id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>;
|
|
155
155
|
name: z.ZodString;
|
|
156
156
|
}, z.core.$strict>>;
|
|
157
157
|
}, z.core.$strict>;
|
|
@@ -246,7 +246,7 @@ export declare const testing_mint_session_action_spec: {
|
|
|
246
246
|
};
|
|
247
247
|
readonly side_effects: true;
|
|
248
248
|
readonly input: z.ZodObject<{
|
|
249
|
-
account_id: z.
|
|
249
|
+
account_id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>;
|
|
250
250
|
expires_in_seconds: z.ZodNumber;
|
|
251
251
|
}, z.core.$strict>;
|
|
252
252
|
readonly output: z.ZodObject<{
|
|
@@ -299,7 +299,7 @@ export declare const testing_put_fact_action_spec: {
|
|
|
299
299
|
readonly input: z.ZodObject<{
|
|
300
300
|
content: z.ZodString;
|
|
301
301
|
content_type: z.ZodOptional<z.ZodString>;
|
|
302
|
-
holder: z.ZodOptional<z.
|
|
302
|
+
holder: z.ZodOptional<z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>>;
|
|
303
303
|
external_url: z.ZodOptional<z.ZodString>;
|
|
304
304
|
}, z.core.$strict>;
|
|
305
305
|
readonly output: z.ZodObject<{
|
|
@@ -535,7 +535,7 @@ export declare const testing_shorten_credential_expiry_action_spec: {
|
|
|
535
535
|
};
|
|
536
536
|
readonly side_effects: true;
|
|
537
537
|
readonly input: z.ZodObject<{
|
|
538
|
-
account_id: z.
|
|
538
|
+
account_id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>;
|
|
539
539
|
seconds: z.ZodNumber;
|
|
540
540
|
}, z.core.$strict>;
|
|
541
541
|
readonly output: z.ZodObject<{
|
|
@@ -1,30 +1,22 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
|
-
/**
|
|
3
|
-
* Error reachability coverage tracking.
|
|
4
|
-
*
|
|
5
|
-
* Tracks which declared error statuses (and specific error codes) are
|
|
6
|
-
* actually exercised in tests. `ErrorCoverageCollector` records status
|
|
7
|
-
* codes (optionally with body `error` codes) observed during test runs,
|
|
8
|
-
* then `assert_error_coverage` compares against declared error schemas
|
|
9
|
-
* to find uncovered error paths — reporting per-code when the declared
|
|
10
|
-
* schema is a literal or enum, per-status otherwise.
|
|
11
|
-
*
|
|
12
|
-
* @module
|
|
13
|
-
*/
|
|
14
|
-
import { z } from 'zod';
|
|
15
2
|
import type { RouteSpec } from '../http/route_spec.js';
|
|
3
|
+
import type { ValidationSchema } from '../schema_issues.js';
|
|
16
4
|
/**
|
|
17
5
|
* Extract declared error code values from an error response schema.
|
|
18
6
|
*
|
|
19
7
|
* Recognizes schemas shaped like `z.object({error: z.literal(...)})` or
|
|
20
|
-
* `z.object({error: z.enum([...])})` (incl. `looseObject`/`strictObject`)
|
|
21
|
-
*
|
|
22
|
-
*
|
|
8
|
+
* `z.object({error: z.enum([...])})` (incl. `looseObject`/`strictObject`),
|
|
9
|
+
* and the `@fuzdev/fuz_schema` forms `object({error: literal(...)})` or
|
|
10
|
+
* `object({error: one_of([...])})` (any object kind, under any wrappers —
|
|
11
|
+
* `get_schema_entries`; the `error` entry itself read as given, as the Zod
|
|
12
|
+
* field is). Returns the set of declared code values, or `null` if the schema
|
|
13
|
+
* doesn't expose a literal/enum `error` field (e.g., bare `ApiError` with
|
|
14
|
+
* `z.string()`).
|
|
23
15
|
*
|
|
24
16
|
* Used by coverage reporting to split a single declared status into per-code
|
|
25
17
|
* rows when the route's error schema names specific codes.
|
|
26
18
|
*/
|
|
27
|
-
export declare const extract_declared_error_codes: (schema:
|
|
19
|
+
export declare const extract_declared_error_codes: (schema: ValidationSchema) => Array<string> | null;
|
|
28
20
|
/** Uncovered entry — either a status-level row (no `code`) or a specific-code row. */
|
|
29
21
|
export interface UncoveredEntry {
|
|
30
22
|
method: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error_coverage.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/error_coverage.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"error_co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AC,IAAI,CAAC;IAgBhB;;;;;;;;OAQG;IACH,SAAS,CAAC,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,KAAK,CAAC,cAAc,CAAC;CAKhG;AAED;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,MAAM,CAAC;AAEtD,2CAA2C;AAC3C,MAAM,WAAW,oBAAqB,SAAQ,qBAAqB;IAClE,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAaD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,qBAAqB,GACjC,WAAW,sBAAsB,EACjC,aAAa,KAAK,CAAC,SAAS,CAAC,EAC7B,UAAU,oBAAoB,KAC5B,IAsBF,CAAC"}
|
|
@@ -13,20 +13,37 @@ import './assert_dev_env.js';
|
|
|
13
13
|
*/
|
|
14
14
|
import { z } from 'zod';
|
|
15
15
|
import { assert } from 'vitest';
|
|
16
|
+
import { is_schema } from '@fuzdev/fuz_schema/schema.ts';
|
|
17
|
+
import { get_schema_entries } from '@fuzdev/fuz_schema/introspect.ts';
|
|
16
18
|
import { merge_error_schemas } from '../http/schema_helpers.js';
|
|
17
19
|
import { find_route_spec, assert_response_matches_spec } from './integration_helpers.js';
|
|
18
20
|
/**
|
|
19
21
|
* Extract declared error code values from an error response schema.
|
|
20
22
|
*
|
|
21
23
|
* Recognizes schemas shaped like `z.object({error: z.literal(...)})` or
|
|
22
|
-
* `z.object({error: z.enum([...])})` (incl. `looseObject`/`strictObject`)
|
|
23
|
-
*
|
|
24
|
-
*
|
|
24
|
+
* `z.object({error: z.enum([...])})` (incl. `looseObject`/`strictObject`),
|
|
25
|
+
* and the `@fuzdev/fuz_schema` forms `object({error: literal(...)})` or
|
|
26
|
+
* `object({error: one_of([...])})` (any object kind, under any wrappers —
|
|
27
|
+
* `get_schema_entries`; the `error` entry itself read as given, as the Zod
|
|
28
|
+
* field is). Returns the set of declared code values, or `null` if the schema
|
|
29
|
+
* doesn't expose a literal/enum `error` field (e.g., bare `ApiError` with
|
|
30
|
+
* `z.string()`).
|
|
25
31
|
*
|
|
26
32
|
* Used by coverage reporting to split a single declared status into per-code
|
|
27
33
|
* rows when the route's error schema names specific codes.
|
|
28
34
|
*/
|
|
29
35
|
export const extract_declared_error_codes = (schema) => {
|
|
36
|
+
if (is_schema(schema)) {
|
|
37
|
+
const error_field = get_schema_entries(schema)?.error;
|
|
38
|
+
if (!error_field)
|
|
39
|
+
return null;
|
|
40
|
+
if (error_field.kind === 'literal')
|
|
41
|
+
return [String(error_field.def)];
|
|
42
|
+
if (error_field.kind === 'one_of') {
|
|
43
|
+
return error_field.def.map(String);
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
30
47
|
if (!(schema instanceof z.ZodObject))
|
|
31
48
|
return null;
|
|
32
49
|
const error_field = schema.shape.error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/integration_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAU7B,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"integration_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/integration_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAU7B,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAInD;;;;;;GAMG;AACH,eAAO,M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AUTHENTICATION_REQUIRED } from '../http/error_schemas.js';
|
|
11
11
|
import { ROLE_ADMIN } from '../auth/role_schema.js';
|
|
12
12
|
import { create_test_request_headers } from './test_origin.js';
|
|
13
|
+
import { parse_any } from '../schema_issues.js';
|
|
13
14
|
/**
|
|
14
15
|
* Find a route spec matching the given method and path.
|
|
15
16
|
*
|
|
@@ -100,9 +101,9 @@ export const assert_response_matches_spec = async (route_specs, method, path, re
|
|
|
100
101
|
return;
|
|
101
102
|
}
|
|
102
103
|
if (response.ok) {
|
|
103
|
-
const result = spec.output
|
|
104
|
-
if (!result.
|
|
105
|
-
throw new Error(`Output schema mismatch for ${method} ${path} (${response.status}): ${JSON.stringify(result.
|
|
104
|
+
const result = parse_any(spec.output, body);
|
|
105
|
+
if (!result.ok) {
|
|
106
|
+
throw new Error(`Output schema mismatch for ${method} ${path} (${response.status}): ${JSON.stringify(result.issues)}`);
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
else {
|
|
@@ -110,9 +111,9 @@ export const assert_response_matches_spec = async (route_specs, method, path, re
|
|
|
110
111
|
if (merged) {
|
|
111
112
|
const status_schema = merged[response.status];
|
|
112
113
|
if (status_schema) {
|
|
113
|
-
const result = status_schema
|
|
114
|
-
if (!result.
|
|
115
|
-
throw new Error(`Error schema mismatch for ${method} ${path} (${response.status}): ${JSON.stringify(result.
|
|
114
|
+
const result = parse_any(status_schema, body);
|
|
115
|
+
if (!result.ok) {
|
|
116
|
+
throw new Error(`Error schema mismatch for ${method} ${path} (${response.status}): ${JSON.stringify(result.issues)}`);
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
|
-
import type { z } from 'zod';
|
|
3
2
|
import type { AppSurfaceRpcEndpoint, AppSurfaceRpcMethod } from '../http/surface.js';
|
|
4
3
|
import type { JsonrpcErrorCode, JsonrpcRequestId } from '../http/jsonrpc.js';
|
|
4
|
+
import type { ValidationSchema } from '../schema_issues.js';
|
|
5
5
|
import { type InputTestCase, type InputTestCaseOptions } from './adversarial_input_cases.js';
|
|
6
6
|
/** The request id every envelope case sends where it sends one. */
|
|
7
7
|
export declare const RPC_ENVELOPE_PROBE_ID = "envelope_probe";
|
|
@@ -104,11 +104,11 @@ export declare const assert_rpc_envelope_refusal: (status: number, body: unknown
|
|
|
104
104
|
* (`invalid_request`) before params validation runs, and the envelope cases
|
|
105
105
|
* cover it. Every case returned owes 400 `invalid_params`.
|
|
106
106
|
*
|
|
107
|
-
* @param input - the method's input schema
|
|
107
|
+
* @param input - the method's input schema, Zod or `@fuzdev/fuz_schema`
|
|
108
108
|
* @param options - a valid base `params` to seed the cases (`InputTestCaseOptions.base`),
|
|
109
109
|
* and the method name for error messages
|
|
110
110
|
* @returns the cases, each a `params` object
|
|
111
111
|
* @throws Error if the base `params`, seeded or generated, fails the input schema
|
|
112
112
|
*/
|
|
113
|
-
export declare const generate_rpc_params_test_cases: (input:
|
|
113
|
+
export declare const generate_rpc_params_test_cases: (input: ValidationSchema, options?: InputTestCaseOptions) => Array<InputTestCase>;
|
|
114
114
|
//# sourceMappingURL=rpc_envelope_cases.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc_envelope_cases.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/rpc_envelope_cases.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"rpc_envelope_cases.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/rpc_envelope_cases.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAgB7B,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGrF,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,q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yB,GACrC,UAAU,qBAAqB,EAC/B,UAAS,sBAA2B,KAClC,KAAK,CAAC,eAAe,CA0KvB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GACnC,eAAe,MAAM,EACrB,GAAG,eAAe,EAClB,UAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,KAClC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAUgD,CAAC;AAEpF;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,GACvC,QAAQ,MAAM,EACd,MAAM,OAAO,EACb,GAAG,eAAe,KAChB,IAUF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,8BAA8B,GAC1C,OAAO,gBAAgB,EACvB,UAAU,oBAAoB,KAC5B,KAAK,CAAC,aAAa,CAGpB,CAAC"}
|
|
@@ -237,7 +237,7 @@ export const assert_rpc_envelope_refusal = (status, body, c) => {
|
|
|
237
237
|
* (`invalid_request`) before params validation runs, and the envelope cases
|
|
238
238
|
* cover it. Every case returned owes 400 `invalid_params`.
|
|
239
239
|
*
|
|
240
|
-
* @param input - the method's input schema
|
|
240
|
+
* @param input - the method's input schema, Zod or `@fuzdev/fuz_schema`
|
|
241
241
|
* @param options - a valid base `params` to seed the cases (`InputTestCaseOptions.base`),
|
|
242
242
|
* and the method name for error messages
|
|
243
243
|
* @returns the cases, each a `params` object
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
+
import type { Schema } from '@fuzdev/fuz_schema/schema.ts';
|
|
3
4
|
import { type JsonrpcErrorCode } from '../http/jsonrpc.js';
|
|
4
5
|
import type { RequestResponseActionSpec } from '../actions/action_spec.js';
|
|
5
6
|
import type { RpcAction } from '../actions/action_types.js';
|
|
6
7
|
import type { AppSurfaceRpcEndpoint, AppSurfaceRpcMethod, RpcEndpointSpec } from '../http/surface.js';
|
|
7
8
|
import type { AppServerContext } from '../server/app_server_context.js';
|
|
8
9
|
import type { SessionOptions } from '../auth/session_cookie.js';
|
|
10
|
+
import { type ValidationOutput, type ValidationSchema } from '../schema_issues.js';
|
|
9
11
|
/**
|
|
10
12
|
* Union accepted by the suite-level `rpc_endpoints` option — eager array or
|
|
11
13
|
* a factory that takes an `AppServerContext` and returns endpoint specs. The
|
|
@@ -91,9 +93,9 @@ export declare const assert_jsonrpc_error_response: (body: unknown, expected_cod
|
|
|
91
93
|
* is provided, also validates the `result` field against the declared
|
|
92
94
|
* output schema — matching the REST round-trip's `assert_response_matches_spec`.
|
|
93
95
|
*
|
|
94
|
-
* @param output_schema - optional Zod schema to validate the `result` field against
|
|
96
|
+
* @param output_schema - optional Zod or `@fuzdev/fuz_schema` schema to validate the `result` field against
|
|
95
97
|
*/
|
|
96
|
-
export declare const assert_jsonrpc_success_response: (body: unknown, output_schema?:
|
|
98
|
+
export declare const assert_jsonrpc_success_response: (body: unknown, output_schema?: ValidationSchema) => void;
|
|
97
99
|
/**
|
|
98
100
|
* Minimal transport surface — the duck type `Hono.request` already satisfies.
|
|
99
101
|
* Extracted so test setups that want an in-process / WS / mock path can plug
|
|
@@ -238,7 +240,7 @@ export type RpcCallResultForSpec<TSpec extends RequestResponseActionSpec> = {
|
|
|
238
240
|
ok: true;
|
|
239
241
|
status: number;
|
|
240
242
|
headers: Record<string, string>;
|
|
241
|
-
result:
|
|
243
|
+
result: ValidationOutput<TSpec['output']>;
|
|
242
244
|
} | {
|
|
243
245
|
ok: false;
|
|
244
246
|
status: number;
|
|
@@ -254,11 +256,12 @@ export type RpcCallForSpecArgs<TSpec extends RequestResponseActionSpec> = Omit<R
|
|
|
254
256
|
/** Action spec whose `method` drives the envelope and whose `input`/`output` types pin params + result. */
|
|
255
257
|
spec: TSpec;
|
|
256
258
|
/** Params, typed against `spec.input`. */
|
|
257
|
-
params:
|
|
259
|
+
params: ValidationOutput<TSpec['input']>;
|
|
258
260
|
};
|
|
259
261
|
/**
|
|
260
|
-
* Typed wrapper over `rpc_call` — binds `params`
|
|
261
|
-
*
|
|
262
|
+
* Typed wrapper over `rpc_call` — binds `params` and the success `result` to
|
|
263
|
+
* the output types of `spec.input` and `spec.output` (`ValidationOutput`) via
|
|
264
|
+
* the generic, for a Zod or a fuz_schema spec.
|
|
262
265
|
*
|
|
263
266
|
* Success results are validated at runtime against `spec.output` (same
|
|
264
267
|
* contract as `rpc_call_typed`); a mismatch throws. Error responses come
|
|
@@ -278,9 +281,10 @@ export declare const rpc_call_for_spec: <TSpec extends RequestResponseActionSpec
|
|
|
278
281
|
* assert on specific error shapes.
|
|
279
282
|
*
|
|
280
283
|
* @throws Error if the response is a JSON-RPC error, if `rpc_call` throws
|
|
281
|
-
* on an envelope violation, or if the result fails `output_schema
|
|
284
|
+
* on an envelope violation, or if the result fails `output_schema` (a Zod or
|
|
285
|
+
* `@fuzdev/fuz_schema` schema, parsed with `parse_any`).
|
|
282
286
|
*/
|
|
283
|
-
export declare const rpc_call_typed: <T>(args: RpcCallArgs, output_schema: z.ZodType<T>) => Promise<T>;
|
|
287
|
+
export declare const rpc_call_typed: <T>(args: RpcCallArgs, output_schema: z.ZodType<T> | Schema<T, any>) => Promise<T>;
|
|
284
288
|
/**
|
|
285
289
|
* Find the `RpcAction` for a method within a set of RPC endpoint specs.
|
|
286
290
|
* Returns both the endpoint path and the matched action. `undefined` when
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/rpc_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAa7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"rpc_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/rpc_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAa7B,OAAO,EAAE,CAAC,EAAE,MAAM,KA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eAAO,MAAM,eAAe,GAC3B,eAAe,aAAa,CAAC,eAAe,CAAC,EAC7C,QAAQ,MAAM,KACZ;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAE,GAAG,SAOxC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAC3B,eAAe,aAAa,CAAC,qBAAqB,CAAC,EACnD,QAAQ,MAAM,KACZ;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,mBAAmB,CAAA;CAAE,GAAG,SAOvD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB,GACrC,eAAe,aAAa,CAAC,eAAe,CAAC,KAC3C,MAcF,CAAC"}
|
|
@@ -13,6 +13,7 @@ import { z } from 'zod';
|
|
|
13
13
|
import { JSONRPC_VERSION, JsonrpcErrorResponse, JsonrpcResponse } from '../http/jsonrpc.js';
|
|
14
14
|
import { create_stub_app_server_context } from './stubs.js';
|
|
15
15
|
import { TEST_ORIGIN } from './test_origin.js';
|
|
16
|
+
import { parse_any } from '../schema_issues.js';
|
|
16
17
|
/**
|
|
17
18
|
* Resolve a suite's `rpc_endpoints` option to an array for setup-time
|
|
18
19
|
* inspection (path lookup, action presence checks).
|
|
@@ -130,15 +131,15 @@ export const assert_jsonrpc_error_response = (body, expected_code) => {
|
|
|
130
131
|
* is provided, also validates the `result` field against the declared
|
|
131
132
|
* output schema — matching the REST round-trip's `assert_response_matches_spec`.
|
|
132
133
|
*
|
|
133
|
-
* @param output_schema - optional Zod schema to validate the `result` field against
|
|
134
|
+
* @param output_schema - optional Zod or `@fuzdev/fuz_schema` schema to validate the `result` field against
|
|
134
135
|
*/
|
|
135
136
|
export const assert_jsonrpc_success_response = (body, output_schema) => {
|
|
136
137
|
const result = JsonrpcResponse.safeParse(body);
|
|
137
138
|
assert.ok(result.success, `not a valid JSON-RPC success response: ${JSON.stringify(body)}`);
|
|
138
139
|
if (output_schema) {
|
|
139
|
-
const output_result = output_schema
|
|
140
|
-
if (!output_result.
|
|
141
|
-
assert.fail(`JSON-RPC result does not match output schema: ${JSON.stringify(output_result.
|
|
140
|
+
const output_result = parse_any(output_schema, result.data.result);
|
|
141
|
+
if (!output_result.ok) {
|
|
142
|
+
assert.fail(`JSON-RPC result does not match output schema: ${JSON.stringify(output_result.issues)}`);
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
145
|
};
|
|
@@ -278,8 +279,9 @@ export const rpc_call = async (args) => parse_rpc_call_result(await rpc_call_raw
|
|
|
278
279
|
*/
|
|
279
280
|
export const rpc_call_non_browser = (args) => rpc_call({ ...args, suppress_default_origin: true });
|
|
280
281
|
/**
|
|
281
|
-
* Typed wrapper over `rpc_call` — binds `params`
|
|
282
|
-
*
|
|
282
|
+
* Typed wrapper over `rpc_call` — binds `params` and the success `result` to
|
|
283
|
+
* the output types of `spec.input` and `spec.output` (`ValidationOutput`) via
|
|
284
|
+
* the generic, for a Zod or a fuz_schema spec.
|
|
283
285
|
*
|
|
284
286
|
* Success results are validated at runtime against `spec.output` (same
|
|
285
287
|
* contract as `rpc_call_typed`); a mismatch throws. Error responses come
|
|
@@ -297,15 +299,15 @@ export const rpc_call_for_spec = async (args) => {
|
|
|
297
299
|
if (!res.ok) {
|
|
298
300
|
return res;
|
|
299
301
|
}
|
|
300
|
-
const parsed = spec.output
|
|
301
|
-
if (!parsed.
|
|
302
|
-
throw new Error(`rpc_call_for_spec(${spec.method}) result did not match spec.output: ${JSON.stringify(parsed.
|
|
302
|
+
const parsed = parse_any(spec.output, res.result);
|
|
303
|
+
if (!parsed.ok) {
|
|
304
|
+
throw new Error(`rpc_call_for_spec(${spec.method}) result did not match spec.output: ${JSON.stringify(parsed.issues)}`);
|
|
303
305
|
}
|
|
304
306
|
return {
|
|
305
307
|
ok: true,
|
|
306
308
|
status: res.status,
|
|
307
309
|
headers: res.headers,
|
|
308
|
-
result: parsed.
|
|
310
|
+
result: parsed.value
|
|
309
311
|
};
|
|
310
312
|
};
|
|
311
313
|
/**
|
|
@@ -315,18 +317,19 @@ export const rpc_call_for_spec = async (args) => {
|
|
|
315
317
|
* assert on specific error shapes.
|
|
316
318
|
*
|
|
317
319
|
* @throws Error if the response is a JSON-RPC error, if `rpc_call` throws
|
|
318
|
-
* on an envelope violation, or if the result fails `output_schema
|
|
320
|
+
* on an envelope violation, or if the result fails `output_schema` (a Zod or
|
|
321
|
+
* `@fuzdev/fuz_schema` schema, parsed with `parse_any`).
|
|
319
322
|
*/
|
|
320
323
|
export const rpc_call_typed = async (args, output_schema) => {
|
|
321
324
|
const res = await rpc_call(args);
|
|
322
325
|
if (!res.ok) {
|
|
323
326
|
throw new Error(`rpc_call_typed(${args.method}) returned error: code=${res.error.code} message=${res.error.message} data=${JSON.stringify(res.error.data)}`);
|
|
324
327
|
}
|
|
325
|
-
const parsed = output_schema
|
|
326
|
-
if (!parsed.
|
|
327
|
-
throw new Error(`rpc_call_typed(${args.method}) result did not match output schema: ${JSON.stringify(parsed.
|
|
328
|
+
const parsed = parse_any(output_schema, res.result);
|
|
329
|
+
if (!parsed.ok) {
|
|
330
|
+
throw new Error(`rpc_call_typed(${args.method}) result did not match output schema: ${JSON.stringify(parsed.issues)}`);
|
|
328
331
|
}
|
|
329
|
-
return parsed.
|
|
332
|
+
return parsed.value;
|
|
330
333
|
};
|
|
331
334
|
// -- registry/surface lookup helpers -----------------------------------------
|
|
332
335
|
/**
|