@fuzdev/fuz_app 0.155.0 → 0.156.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 +9 -8
- package/dist/http/auth_shape.d.ts +54 -17
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +104 -52
- package/dist/http/error_schemas.d.ts +6 -4
- 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 +3 -2
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +20 -8
- package/dist/http/schema_helpers.d.ts +24 -20
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +24 -19
- package/dist/primitive_schemas.d.ts +10 -3
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +10 -2
- package/dist/primitive_schemas_fuz.d.ts +69 -0
- package/dist/primitive_schemas_fuz.d.ts.map +1 -0
- package/dist/primitive_schemas_fuz.js +49 -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 +17 -11
- 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/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/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +4 -3
- 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
|
@@ -10,6 +10,7 @@ import { is_public_auth } from '../http/auth_shape.js';
|
|
|
10
10
|
import { ERROR_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 {
|
|
@@ -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":["../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CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC,MAAM,CAAgC,CAAC;AAEzF,wFAAwF;AACxF,eAAO,MAAM,2BAA2B,GAAI,QAAQ,MAAM,KAAG,MACL,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,yBAAyB,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_help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C,oBAAoB,CAAC,KAAK,CAAC,CAoBrC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GAAU,CAAC,EACrC,MAAM,WAAW,EACjB,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,KAC1C,OAAO,CAAC,CAAC,CAkBX,CAAC;AAIF;;;;GAIG;AACH,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
|
/**
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* Walks Zod schemas to generate valid values for route params, request bodies,
|
|
6
|
-
* and URL paths. Used by adversarial input, adversarial 404, and round-trip
|
|
7
|
-
* validation test suites.
|
|
8
|
-
*
|
|
9
|
-
* @module
|
|
10
|
-
*/
|
|
11
|
-
import { z } from 'zod';
|
|
12
|
-
import { type ZodFieldInfo } from '../zod.js';
|
|
13
|
-
import type { ValidationSchema } from '../schema_issues.js';
|
|
2
|
+
import { type SchemaFieldInfo } from '../zod.js';
|
|
3
|
+
import { type ParseAnyResult, type ValidationSchema } from '../schema_issues.js';
|
|
14
4
|
/**
|
|
15
5
|
* The JSON Schema of a field's input side — where its format, pattern and
|
|
16
6
|
* bounds live. Takes a Zod or a `@fuzdev/fuz_schema` field.
|
|
@@ -62,14 +52,45 @@ export declare const detect_json_schema_format: (json: Record<string, unknown>)
|
|
|
62
52
|
* `'email'`), `'pattern'` for a regex, or `null`.
|
|
63
53
|
*/
|
|
64
54
|
export declare const detect_format: (field_schema: ValidationSchema) => string | null;
|
|
65
|
-
/**
|
|
66
|
-
export
|
|
55
|
+
/** An object schema's fields and the schema of each, of either library. */
|
|
56
|
+
export interface ObjectSchemaView {
|
|
57
|
+
/** The fields, in declaration order. */
|
|
58
|
+
fields: Array<SchemaFieldInfo>;
|
|
59
|
+
/** The schema of the field named `name`, or `undefined` when there is none. */
|
|
60
|
+
field_schema: (name: string) => ValidationSchema | undefined;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The fields of an object schema of either library and the schema of each,
|
|
64
|
+
* through its wrappers: the `ZodObject` inside a Zod schema
|
|
65
|
+
* (`zod_unwrap_to_object`, `zod_extract_fields`), or a `@fuzdev/fuz_schema`
|
|
66
|
+
* schema whose innermost layer is an object schema (`get_schema_entries`,
|
|
67
|
+
* `get_schema_fields`).
|
|
68
|
+
*
|
|
69
|
+
* @param schema - an object schema, possibly wrapped, Zod or fuz_schema
|
|
70
|
+
* @param label - names the schema in the error
|
|
71
|
+
* @throws Error naming `label` when `schema` is no object schema, or of neither library
|
|
72
|
+
*/
|
|
73
|
+
export declare const to_object_schema_view: (schema: ValidationSchema, label: string) => ObjectSchemaView;
|
|
74
|
+
/**
|
|
75
|
+
* Generate a valid-ish value for a field based on its base type.
|
|
76
|
+
*
|
|
77
|
+
* @param field - the field's info, from `to_object_schema_view` or `zod_extract_fields`
|
|
78
|
+
* @param field_schema - the field's schema, Zod or `@fuzdev/fuz_schema`
|
|
79
|
+
* @returns the value, checked by the caller against the whole schema
|
|
80
|
+
*/
|
|
81
|
+
export declare const generate_valid_value: (field: SchemaFieldInfo, field_schema: ValidationSchema) => unknown;
|
|
82
|
+
/** What `generate_valid_object` returns: the object and its last parse. */
|
|
83
|
+
export interface GeneratedObject {
|
|
84
|
+
value: Record<string, unknown>;
|
|
85
|
+
/** The last `parse_any` of `value` against the schema — the caller decides whether a failure throws. */
|
|
86
|
+
result: ParseAnyResult<unknown>;
|
|
87
|
+
}
|
|
67
88
|
/**
|
|
68
89
|
* Generate a valid object for an object schema: its required and defaulted
|
|
69
90
|
* fields first; when `schema` still refuses it, each optional field alone on
|
|
70
91
|
* top of those, in declaration order, taking the first that parses; and
|
|
71
92
|
* failing that, the optional fields added one at a time, in declaration
|
|
72
|
-
* order, until it parses. The fill covers a
|
|
93
|
+
* order, until it parses. The fill covers a refine over optional fields
|
|
73
94
|
* (at least one of, exactly one of, both of), which the required-only object
|
|
74
95
|
* can't satisfy, and the single-field pass keeps an unrelated optional field
|
|
75
96
|
* declared ahead of the refined ones (an `acting`, a note) out of the object.
|
|
@@ -77,16 +98,16 @@ export declare const generate_valid_value: (field: ZodFieldInfo, field_schema: z
|
|
|
77
98
|
* Shared by the top-level body generators and `generate_valid_value`'s
|
|
78
99
|
* nested-object case, so a refined object validates the same way at any depth.
|
|
79
100
|
*
|
|
80
|
-
* @param object_schema - the
|
|
101
|
+
* @param object_schema - the object whose fields are generated: a Zod or
|
|
102
|
+
* `@fuzdev/fuz_schema` object schema, possibly wrapped
|
|
81
103
|
* @param schema - the schema the object must satisfy, refinements included
|
|
82
104
|
* (`object_schema` or a schema wrapping it)
|
|
83
|
-
* @returns the generated object and its last `
|
|
105
|
+
* @returns the generated object and its last `parse_any` result — the caller
|
|
84
106
|
* decides whether a failure throws
|
|
107
|
+
* @throws Error when `object_schema` is no object schema, or either schema is
|
|
108
|
+
* of neither library
|
|
85
109
|
*/
|
|
86
|
-
export declare const generate_valid_object: (object_schema:
|
|
87
|
-
value: Record<string, unknown>;
|
|
88
|
-
result: z.ZodSafeParseResult<unknown>;
|
|
89
|
-
};
|
|
110
|
+
export declare const generate_valid_object: (object_schema: ValidationSchema, schema: ValidationSchema) => GeneratedObject;
|
|
90
111
|
/**
|
|
91
112
|
* A valid object that carries `field`, built from `base`, a valid object of
|
|
92
113
|
* `object_schema` — the body a case breaking `field` changes, so the case
|
|
@@ -97,14 +118,17 @@ export declare const generate_valid_object: (object_schema: z.ZodObject, schema:
|
|
|
97
118
|
* replaces `base`'s optional fields, refilled the same way around it (an
|
|
98
119
|
* exactly-one-of rule: adding `slug` means dropping `id`).
|
|
99
120
|
*
|
|
100
|
-
* @param object_schema - the
|
|
121
|
+
* @param object_schema - the object schema `base` is an instance of, Zod or
|
|
122
|
+
* `@fuzdev/fuz_schema`, possibly wrapped
|
|
101
123
|
* @param schema - the schema the object must satisfy, refinements included
|
|
102
124
|
* @param base - a valid object, the generated or seeded base
|
|
103
125
|
* @param field - the field the object must carry
|
|
104
126
|
* @returns the object, or `null` when no object the generator can build
|
|
105
127
|
* carries the field and passes `schema`
|
|
128
|
+
* @throws Error when `object_schema` is no object schema, or either schema is
|
|
129
|
+
* of neither library
|
|
106
130
|
*/
|
|
107
|
-
export declare const generate_valid_object_with_field: (object_schema:
|
|
131
|
+
export declare const generate_valid_object_with_field: (object_schema: ValidationSchema, schema: ValidationSchema, base: Record<string, unknown>, field: SchemaFieldInfo) => Record<string, unknown> | null;
|
|
108
132
|
/**
|
|
109
133
|
* A string a URL-sourced field accepts — a route param or a query value, which
|
|
110
134
|
* arrive as strings whatever the schema parses them into. The nil UUID for a
|
|
@@ -114,18 +138,23 @@ export declare const generate_valid_object_with_field: (object_schema: z.ZodObje
|
|
|
114
138
|
* integer whose minimum is above one), and a string synthesized from the
|
|
115
139
|
* field's constraints.
|
|
116
140
|
*
|
|
117
|
-
* @param field - the field's info, from `zod_extract_fields`
|
|
118
|
-
* @param field_schema - the field's schema
|
|
141
|
+
* @param field - the field's info, from `to_object_schema_view` or `zod_extract_fields`
|
|
142
|
+
* @param field_schema - the field's schema, Zod or `@fuzdev/fuz_schema`
|
|
119
143
|
* @returns the string, or `null` when no candidate passes
|
|
120
144
|
*/
|
|
121
|
-
export declare const generate_valid_string_param: (field:
|
|
145
|
+
export declare const generate_valid_string_param: (field: SchemaFieldInfo, field_schema: ValidationSchema) => string | null;
|
|
122
146
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
147
|
+
* The input a body is generated for: `null` for a void or null input
|
|
148
|
+
* (`is_void_schema`, `is_null_schema`), which takes no body, else its object
|
|
149
|
+
* view (`to_object_schema_view`).
|
|
150
|
+
*
|
|
151
|
+
* @param input_schema - a route's or action's input schema, Zod or `@fuzdev/fuz_schema`
|
|
152
|
+
* @param label - names the input in the error
|
|
153
|
+
* @throws Error naming `label` when the input is of neither library, or is
|
|
154
|
+
* neither void, null, nor an object schema — no body can be generated for
|
|
155
|
+
* it, and no body is not the same as one the generator can't build
|
|
127
156
|
*/
|
|
128
|
-
export declare const
|
|
157
|
+
export declare const to_body_input: (input_schema: ValidationSchema, label: string) => ObjectSchemaView | null;
|
|
129
158
|
/**
|
|
130
159
|
* The `Content-Type` a well-formed request to a route sends: `application/json`,
|
|
131
160
|
* or `application/octet-stream` for a `raw_body` route. Every `POST` route
|
|
@@ -156,16 +185,22 @@ export declare const to_route_content_type: (route: {
|
|
|
156
185
|
* The synthesized value is percent-encoded, and a value containing `/` is
|
|
157
186
|
* refused (it would silently add a path segment and route elsewhere) —
|
|
158
187
|
* both fall back to `test_<name>`.
|
|
188
|
+
*
|
|
189
|
+
* @param path - the route path, its params as `:name`
|
|
190
|
+
* @param params_schema - the route's params schema, a Zod or `@fuzdev/fuz_schema` object schema
|
|
191
|
+
* @throws Error when `params_schema` is no object schema, or of neither library
|
|
159
192
|
*/
|
|
160
|
-
export declare const resolve_valid_path: (path: string, params_schema?:
|
|
193
|
+
export declare const resolve_valid_path: (path: string, params_schema?: ValidationSchema) => string;
|
|
161
194
|
/**
|
|
162
|
-
* Generate a valid request body for a route's input schema.
|
|
163
|
-
*
|
|
164
|
-
* @
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
195
|
+
* Generate a valid request body for a route's or action's input schema.
|
|
196
|
+
*
|
|
197
|
+
* @param input_schema - the input schema, Zod or `@fuzdev/fuz_schema`
|
|
198
|
+
* @returns a generated body that passes the schema, or `undefined` for a void
|
|
199
|
+
* or null input, which takes no body
|
|
200
|
+
* @throws Error if the input is of neither library, or is neither void, null,
|
|
201
|
+
* nor an object schema, or if the generated body fails the input — catching
|
|
202
|
+
* broken `generate_valid_value` logic early with the parse's issues instead
|
|
203
|
+
* of a confusing 400 in downstream tests
|
|
169
204
|
*/
|
|
170
|
-
export declare const generate_valid_body: (input_schema:
|
|
205
|
+
export declare const generate_valid_body: (input_schema: ValidationSchema) => Record<string, unknown> | undefined;
|
|
171
206
|
//# sourceMappingURL=schema_generators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema_generators.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/schema_generators.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"schema_generators.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/schema_generators.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAsB7B,OAAO,EAKN,KAAK,eA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