@fuzdev/fuz_app 0.155.1 → 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
|
@@ -2,17 +2,21 @@ import './assert_dev_env.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Schema-driven value generation helpers for testing.
|
|
4
4
|
*
|
|
5
|
-
* Walks Zod schemas to generate valid values for
|
|
6
|
-
* and URL paths. Used by adversarial input,
|
|
7
|
-
* validation test suites.
|
|
5
|
+
* Walks Zod and `@fuzdev/fuz_schema` schemas to generate valid values for
|
|
6
|
+
* route params, request bodies, and URL paths. Used by adversarial input,
|
|
7
|
+
* adversarial 404, and round-trip validation test suites. A schema of
|
|
8
|
+
* neither library throws, and so does an input no body can be generated
|
|
9
|
+
* for, rather than yielding no body.
|
|
8
10
|
*
|
|
9
11
|
* @module
|
|
10
12
|
*/
|
|
11
13
|
import { z } from 'zod';
|
|
12
14
|
import { is_schema } from '@fuzdev/fuz_schema/schema.ts';
|
|
15
|
+
import { get_schema_entries, get_schema_fields, unwrap_schema } from '@fuzdev/fuz_schema/introspect.ts';
|
|
13
16
|
import { to_json_schema } from '@fuzdev/fuz_schema/json_schema.ts';
|
|
14
17
|
import { zod_unwrap_def, zod_get_base_type, zod_unwrap_to_object, zod_extract_fields } from '../zod.js';
|
|
15
|
-
import { is_null_schema } from '../http/schema_helpers.js';
|
|
18
|
+
import { is_null_schema, is_void_schema } from '../http/schema_helpers.js';
|
|
19
|
+
import { assert_zod_schema, format_issues, parse_any } from '../schema_issues.js';
|
|
16
20
|
/**
|
|
17
21
|
* The JSON Schema of a field's input side — where its format, pattern and
|
|
18
22
|
* bounds live. Takes a Zod or a `@fuzdev/fuz_schema` field.
|
|
@@ -160,6 +164,117 @@ const generate_prefix_slug_pattern_value = (pattern) => {
|
|
|
160
164
|
return null;
|
|
161
165
|
return `${prefix}_${'x'.repeat(n)}`;
|
|
162
166
|
};
|
|
167
|
+
// --- reading a schema of either library ---
|
|
168
|
+
/** Whether `schema` accepts `value`, a parse of either library (`parse_any`). */
|
|
169
|
+
const accepts = (schema, value) => parse_any(schema, value).ok;
|
|
170
|
+
/**
|
|
171
|
+
* Every layer of a `@fuzdev/fuz_schema` schema, from the schema itself through
|
|
172
|
+
* each `optional`, `nullable`, `with_default`, `with_default_fn`, the first
|
|
173
|
+
* schema of a `pipe`, and a `lazy`'s schema, to what the value is — the
|
|
174
|
+
* layers `unwrap_schema` walks.
|
|
175
|
+
*/
|
|
176
|
+
const fuz_schema_layers = (schema) => {
|
|
177
|
+
const layers = [];
|
|
178
|
+
const seen = new Set();
|
|
179
|
+
let s = schema;
|
|
180
|
+
while (!seen.has(s)) {
|
|
181
|
+
seen.add(s);
|
|
182
|
+
layers.push(s);
|
|
183
|
+
if (s.kind === 'optional' ||
|
|
184
|
+
s.kind === 'nullable' ||
|
|
185
|
+
s.kind === 'with_default' ||
|
|
186
|
+
s.kind === 'with_default_fn') {
|
|
187
|
+
s = s.def.schema;
|
|
188
|
+
}
|
|
189
|
+
else if (s.kind === 'pipe') {
|
|
190
|
+
s = s.def[0];
|
|
191
|
+
}
|
|
192
|
+
else if (s.kind === 'lazy') {
|
|
193
|
+
s = s.def();
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return layers;
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* The type name the generators switch on for a `@fuzdev/fuz_schema` schema,
|
|
203
|
+
* in Zod's vocabulary (`zod_get_base_type`): its innermost layer's kind, with
|
|
204
|
+
* an object schema of any strictness `'object'`, a `literal(null)` `'null'`,
|
|
205
|
+
* a `literal(undefined)` (`s.void`) `'void'`, a `one_of` `'enum'`, and a
|
|
206
|
+
* `variant` `'union'`.
|
|
207
|
+
*/
|
|
208
|
+
const fuz_schema_base_type = (schema) => {
|
|
209
|
+
const base = unwrap_schema(schema);
|
|
210
|
+
switch (base.kind) {
|
|
211
|
+
case 'object':
|
|
212
|
+
case 'loose_object':
|
|
213
|
+
case 'strip_object':
|
|
214
|
+
case 'object_with_rest':
|
|
215
|
+
return 'object';
|
|
216
|
+
case 'literal':
|
|
217
|
+
return base.def === null ? 'null' : base.def === undefined ? 'void' : 'literal';
|
|
218
|
+
case 'one_of':
|
|
219
|
+
return 'enum';
|
|
220
|
+
case 'variant':
|
|
221
|
+
return 'union';
|
|
222
|
+
default:
|
|
223
|
+
return base.kind;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
// the type name the generators switch on, of either library
|
|
227
|
+
const to_base_type = (schema) => is_schema(schema) ? fuz_schema_base_type(schema) : zod_get_base_type(schema);
|
|
228
|
+
// the fields of `schema` when its innermost layer is an object schema, else `null`;
|
|
229
|
+
// throws for a schema of neither library
|
|
230
|
+
const to_object_view = (schema, label) => {
|
|
231
|
+
if (is_schema(schema)) {
|
|
232
|
+
const entries = get_schema_entries(schema);
|
|
233
|
+
if (!entries)
|
|
234
|
+
return null;
|
|
235
|
+
return {
|
|
236
|
+
fields: get_schema_fields(schema).map((field) => {
|
|
237
|
+
const layers = fuz_schema_layers(field.schema);
|
|
238
|
+
return {
|
|
239
|
+
name: field.name,
|
|
240
|
+
base_type: fuz_schema_base_type(field.schema),
|
|
241
|
+
required: !layers.some((l) => l.kind === 'optional'),
|
|
242
|
+
has_default: field.has_default,
|
|
243
|
+
nullable: layers.some((l) => l.kind === 'nullable')
|
|
244
|
+
};
|
|
245
|
+
}),
|
|
246
|
+
field_schema: (name) => (Object.hasOwn(entries, name) ? entries[name] : undefined)
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
assert_zod_schema(schema, label);
|
|
250
|
+
const object_schema = zod_unwrap_to_object(schema);
|
|
251
|
+
if (!object_schema)
|
|
252
|
+
return null;
|
|
253
|
+
const shape = object_schema.shape;
|
|
254
|
+
return {
|
|
255
|
+
fields: zod_extract_fields(object_schema),
|
|
256
|
+
field_schema: (name) => (Object.hasOwn(shape, name) ? shape[name] : undefined)
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
/**
|
|
260
|
+
* The fields of an object schema of either library and the schema of each,
|
|
261
|
+
* through its wrappers: the `ZodObject` inside a Zod schema
|
|
262
|
+
* (`zod_unwrap_to_object`, `zod_extract_fields`), or a `@fuzdev/fuz_schema`
|
|
263
|
+
* schema whose innermost layer is an object schema (`get_schema_entries`,
|
|
264
|
+
* `get_schema_fields`).
|
|
265
|
+
*
|
|
266
|
+
* @param schema - an object schema, possibly wrapped, Zod or fuz_schema
|
|
267
|
+
* @param label - names the schema in the error
|
|
268
|
+
* @throws Error naming `label` when `schema` is no object schema, or of neither library
|
|
269
|
+
*/
|
|
270
|
+
export const to_object_schema_view = (schema, label) => {
|
|
271
|
+
const view = to_object_view(schema, label);
|
|
272
|
+
if (!view) {
|
|
273
|
+
throw new Error(`${label} is not an object schema (its innermost type is '${to_base_type(schema)}')`);
|
|
274
|
+
}
|
|
275
|
+
return view;
|
|
276
|
+
};
|
|
277
|
+
// --- generating values ---
|
|
163
278
|
/** Generate a string that satisfies minLength/maxLength/pattern constraints via JSON Schema. */
|
|
164
279
|
const generate_valid_string = (field_schema) => {
|
|
165
280
|
let min_length = 0;
|
|
@@ -176,18 +291,18 @@ const generate_valid_string = (field_schema) => {
|
|
|
176
291
|
const base = 'x'.repeat(target) || 'test_value';
|
|
177
292
|
// Validate against the full schema (including refinements/brands).
|
|
178
293
|
// If the base string fails, try common patterns before giving up.
|
|
179
|
-
if (field_schema
|
|
294
|
+
if (accepts(field_schema, base))
|
|
180
295
|
return base;
|
|
181
296
|
// Fixed-length hex refinement (blake3, sha256, etc.)
|
|
182
297
|
if (pattern) {
|
|
183
298
|
const hex = generate_hex_pattern_value(pattern);
|
|
184
|
-
if (hex !== null && field_schema
|
|
299
|
+
if (hex !== null && accepts(field_schema, hex))
|
|
185
300
|
return hex;
|
|
186
301
|
}
|
|
187
302
|
// Prefix-lengthed slug refinement (e.g. ApiTokenId: tok_[A-Za-z0-9_-]{12})
|
|
188
303
|
if (pattern) {
|
|
189
304
|
const slug = generate_prefix_slug_pattern_value(pattern);
|
|
190
|
-
if (slug !== null && field_schema
|
|
305
|
+
if (slug !== null && accepts(field_schema, slug))
|
|
191
306
|
return slug;
|
|
192
307
|
}
|
|
193
308
|
// Email-shaped refinement (the `Email` primitive: loose `local@domain.tld`).
|
|
@@ -195,23 +310,74 @@ const generate_valid_string = (field_schema) => {
|
|
|
195
310
|
// candidate — the `z.string().regex()` form exposes a `pattern`, not the
|
|
196
311
|
// `format: 'email'` the `case 'email'` switch arm keys on.
|
|
197
312
|
const as_email = 'test@example.com';
|
|
198
|
-
if (field_schema
|
|
313
|
+
if (accepts(field_schema, as_email))
|
|
199
314
|
return as_email;
|
|
200
315
|
// Absolute path refinement (e.g. DiskfilePath)
|
|
201
316
|
const with_slash = '/' + base;
|
|
202
|
-
if (field_schema
|
|
317
|
+
if (accepts(field_schema, with_slash))
|
|
203
318
|
return with_slash;
|
|
204
319
|
// URL refinement
|
|
205
320
|
const as_url = 'https://example.com/' + base;
|
|
206
|
-
if (field_schema
|
|
321
|
+
if (accepts(field_schema, as_url))
|
|
207
322
|
return as_url;
|
|
208
323
|
// Two-segment path refinement (an `owner/name` repo slug)
|
|
209
324
|
const segments = `${base}/${base}`;
|
|
210
|
-
if (field_schema
|
|
325
|
+
if (accepts(field_schema, segments))
|
|
211
326
|
return segments;
|
|
212
327
|
return base; // fall through — generate_valid_body will report the failure
|
|
213
328
|
};
|
|
214
|
-
|
|
329
|
+
// the element schema of an array field, of either library
|
|
330
|
+
const to_array_element = (field_schema) => {
|
|
331
|
+
if (is_schema(field_schema)) {
|
|
332
|
+
const base = unwrap_schema(field_schema);
|
|
333
|
+
return base.kind === 'array' ? base.def : undefined;
|
|
334
|
+
}
|
|
335
|
+
return zod_unwrap_def(field_schema).element;
|
|
336
|
+
};
|
|
337
|
+
// the first option of a union field, of either library
|
|
338
|
+
const to_first_union_option = (field_schema) => {
|
|
339
|
+
if (is_schema(field_schema)) {
|
|
340
|
+
const base = unwrap_schema(field_schema);
|
|
341
|
+
if (base.kind === 'union')
|
|
342
|
+
return base.def[0];
|
|
343
|
+
if (base.kind === 'variant')
|
|
344
|
+
return base.def.options[0];
|
|
345
|
+
return undefined;
|
|
346
|
+
}
|
|
347
|
+
// Zod 4 represents `z.union` and `z.discriminatedUnion` alike, `def.type ===
|
|
348
|
+
// 'union'` with a `def.options` array
|
|
349
|
+
return zod_unwrap_def(field_schema).options?.[0];
|
|
350
|
+
};
|
|
351
|
+
// the values a literal or enum field accepts, of either library, in declared order
|
|
352
|
+
const to_literal_values = (field_schema) => {
|
|
353
|
+
if (is_schema(field_schema)) {
|
|
354
|
+
const base = unwrap_schema(field_schema);
|
|
355
|
+
if (base.kind === 'literal')
|
|
356
|
+
return [base.def];
|
|
357
|
+
if (base.kind === 'one_of')
|
|
358
|
+
return base.def;
|
|
359
|
+
return [];
|
|
360
|
+
}
|
|
361
|
+
const def = zod_unwrap_def(field_schema);
|
|
362
|
+
// Zod 4 stores literal values on `def.values` (always an array, even for
|
|
363
|
+
// single-valued literals), and enum entries as an object `{key: value}`
|
|
364
|
+
if ('values' in def && Array.isArray(def.values))
|
|
365
|
+
return def.values;
|
|
366
|
+
if ('entries' in def) {
|
|
367
|
+
const entries = def.entries;
|
|
368
|
+
if (entries && typeof entries === 'object') {
|
|
369
|
+
return Object.values(entries);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return [];
|
|
373
|
+
};
|
|
374
|
+
/**
|
|
375
|
+
* Generate a valid-ish value for a field based on its base type.
|
|
376
|
+
*
|
|
377
|
+
* @param field - the field's info, from `to_object_schema_view` or `zod_extract_fields`
|
|
378
|
+
* @param field_schema - the field's schema, Zod or `@fuzdev/fuz_schema`
|
|
379
|
+
* @returns the value, checked by the caller against the whole schema
|
|
380
|
+
*/
|
|
215
381
|
export const generate_valid_value = (field, field_schema) => {
|
|
216
382
|
const format = detect_format(field_schema);
|
|
217
383
|
switch (field.base_type) {
|
|
@@ -231,7 +397,7 @@ export const generate_valid_value = (field, field_schema) => {
|
|
|
231
397
|
case 'int': {
|
|
232
398
|
// 1, unless the schema's bounds rule it out (`.negative()`, `.min(10)`)
|
|
233
399
|
for (const candidate of [1, -1, 0]) {
|
|
234
|
-
if (field_schema
|
|
400
|
+
if (accepts(field_schema, candidate))
|
|
235
401
|
return candidate;
|
|
236
402
|
}
|
|
237
403
|
const json = to_field_json_schema(field_schema);
|
|
@@ -252,70 +418,50 @@ export const generate_valid_value = (field, field_schema) => {
|
|
|
252
418
|
const min_items = typeof json.minItems === 'number' ? json.minItems : 0;
|
|
253
419
|
if (min_items === 0)
|
|
254
420
|
return [];
|
|
255
|
-
const
|
|
256
|
-
const element_schema = def.element;
|
|
421
|
+
const element_schema = to_array_element(field_schema);
|
|
257
422
|
if (!element_schema)
|
|
258
423
|
return [];
|
|
259
|
-
const element_field = {
|
|
260
|
-
...field,
|
|
261
|
-
base_type: zod_get_base_type(element_schema)
|
|
262
|
-
};
|
|
424
|
+
const element_field = { ...field, base_type: to_base_type(element_schema) };
|
|
263
425
|
const item = generate_valid_value(element_field, element_schema);
|
|
264
426
|
return Array.from({ length: min_items }, () => item);
|
|
265
427
|
}
|
|
266
428
|
case 'object': {
|
|
267
429
|
// recurse with the same optional-field fallback as the top level, so a
|
|
268
|
-
// nested
|
|
430
|
+
// nested refine over optional fields (exactly-one-of) is satisfied;
|
|
269
431
|
// a nested object that still fails is returned as built, and the
|
|
270
432
|
// top-level parse reports it
|
|
271
|
-
const
|
|
272
|
-
if (
|
|
273
|
-
return
|
|
433
|
+
const view = to_object_view(field_schema, `generate_valid_value: field '${field.name}'`);
|
|
434
|
+
if (view)
|
|
435
|
+
return generate_valid_object_from_view(view, field_schema).value;
|
|
274
436
|
return {};
|
|
275
437
|
}
|
|
276
438
|
case 'null':
|
|
277
439
|
return null;
|
|
440
|
+
case 'void':
|
|
441
|
+
case 'undefined':
|
|
442
|
+
return undefined;
|
|
443
|
+
case 'record':
|
|
444
|
+
return {};
|
|
278
445
|
case 'union': {
|
|
279
|
-
// Pick the first variant and recurse.
|
|
280
|
-
// `z.discriminatedUnion` — Zod 4 represents both as `def.type ===
|
|
281
|
-
// 'union'` with a `def.options` array. Picking `options[0]` is a
|
|
446
|
+
// Pick the first variant and recurse. Picking the first option is a
|
|
282
447
|
// pragmatic default; consumers needing a specific branch can pass
|
|
283
448
|
// an override via the relevant test helper.
|
|
284
|
-
const
|
|
285
|
-
const first = def.options?.[0];
|
|
449
|
+
const first = to_first_union_option(field_schema);
|
|
286
450
|
if (first) {
|
|
287
|
-
|
|
288
|
-
...field,
|
|
289
|
-
base_type: zod_get_base_type(first)
|
|
290
|
-
};
|
|
291
|
-
return generate_valid_value(inner_field, first);
|
|
451
|
+
return generate_valid_value({ ...field, base_type: to_base_type(first) }, first);
|
|
292
452
|
}
|
|
293
453
|
return 'test_value';
|
|
294
454
|
}
|
|
295
455
|
case 'literal': {
|
|
296
|
-
//
|
|
297
|
-
//
|
|
298
|
-
//
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
const literal_def = zod_unwrap_def(field_schema);
|
|
302
|
-
if (literal_def.values && literal_def.values.length > 0) {
|
|
303
|
-
return literal_def.values[0];
|
|
304
|
-
}
|
|
305
|
-
return 'test_value';
|
|
456
|
+
// the first literal satisfies a literal field as well as a required
|
|
457
|
+
// discriminator of a discriminated union's variant — without this
|
|
458
|
+
// branch the literal would fall through to the default and break parse
|
|
459
|
+
const values = to_literal_values(field_schema);
|
|
460
|
+
return values.length > 0 ? values[0] : 'test_value';
|
|
306
461
|
}
|
|
307
462
|
case 'enum': {
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
const entries = enum_def.entries;
|
|
311
|
-
// Zod 4 enum entries is an object {key: value}, not an array
|
|
312
|
-
if (entries && typeof entries === 'object') {
|
|
313
|
-
const values = Object.values(entries);
|
|
314
|
-
if (values.length > 0)
|
|
315
|
-
return values[0];
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
return 'test';
|
|
463
|
+
const values = to_literal_values(field_schema);
|
|
464
|
+
return values.length > 0 ? values[0] : 'test';
|
|
319
465
|
}
|
|
320
466
|
default:
|
|
321
467
|
return 'test_value';
|
|
@@ -326,7 +472,7 @@ export const generate_valid_value = (field, field_schema) => {
|
|
|
326
472
|
* fields first; when `schema` still refuses it, each optional field alone on
|
|
327
473
|
* top of those, in declaration order, taking the first that parses; and
|
|
328
474
|
* failing that, the optional fields added one at a time, in declaration
|
|
329
|
-
* order, until it parses. The fill covers a
|
|
475
|
+
* order, until it parses. The fill covers a refine over optional fields
|
|
330
476
|
* (at least one of, exactly one of, both of), which the required-only object
|
|
331
477
|
* can't satisfy, and the single-field pass keeps an unrelated optional field
|
|
332
478
|
* declared ahead of the refined ones (an `acting`, a note) out of the object.
|
|
@@ -334,17 +480,21 @@ export const generate_valid_value = (field, field_schema) => {
|
|
|
334
480
|
* Shared by the top-level body generators and `generate_valid_value`'s
|
|
335
481
|
* nested-object case, so a refined object validates the same way at any depth.
|
|
336
482
|
*
|
|
337
|
-
* @param object_schema - the
|
|
483
|
+
* @param object_schema - the object whose fields are generated: a Zod or
|
|
484
|
+
* `@fuzdev/fuz_schema` object schema, possibly wrapped
|
|
338
485
|
* @param schema - the schema the object must satisfy, refinements included
|
|
339
486
|
* (`object_schema` or a schema wrapping it)
|
|
340
|
-
* @returns the generated object and its last `
|
|
487
|
+
* @returns the generated object and its last `parse_any` result — the caller
|
|
341
488
|
* decides whether a failure throws
|
|
489
|
+
* @throws Error when `object_schema` is no object schema, or either schema is
|
|
490
|
+
* of neither library
|
|
342
491
|
*/
|
|
343
|
-
export const generate_valid_object = (object_schema, schema) =>
|
|
492
|
+
export const generate_valid_object = (object_schema, schema) => generate_valid_object_from_view(to_object_schema_view(object_schema, 'generate_valid_object: the object schema'), schema);
|
|
493
|
+
const generate_valid_object_from_view = (view, schema) => {
|
|
344
494
|
const base = {};
|
|
345
495
|
const optional = [];
|
|
346
|
-
for (const field of
|
|
347
|
-
const value = generate_valid_value(field,
|
|
496
|
+
for (const field of view.fields) {
|
|
497
|
+
const value = generate_valid_value(field, view.field_schema(field.name));
|
|
348
498
|
if (is_optional_field(field))
|
|
349
499
|
optional.push([field.name, value]);
|
|
350
500
|
else
|
|
@@ -352,7 +502,7 @@ export const generate_valid_object = (object_schema, schema) => {
|
|
|
352
502
|
}
|
|
353
503
|
return fill_optional_fields(schema, base, optional);
|
|
354
504
|
};
|
|
355
|
-
/** A field the object may omit — optional and without a default
|
|
505
|
+
/** A field the object may omit — optional and without a default the parse fills. */
|
|
356
506
|
const is_optional_field = (field) => !field.required && !field.has_default;
|
|
357
507
|
/**
|
|
358
508
|
* `start` as is when `schema` accepts it; else `start` plus each candidate
|
|
@@ -362,25 +512,25 @@ const is_optional_field = (field) => !field.required && !field.has_default;
|
|
|
362
512
|
* @param schema - the schema the object must satisfy
|
|
363
513
|
* @param start - the fields every result keeps
|
|
364
514
|
* @param candidates - optional fields and their values, in declaration order
|
|
365
|
-
* @returns the object and its last
|
|
515
|
+
* @returns the object and its last parse
|
|
366
516
|
*/
|
|
367
517
|
const fill_optional_fields = (schema, start, candidates) => {
|
|
368
|
-
let result = schema
|
|
369
|
-
if (result.
|
|
518
|
+
let result = parse_any(schema, start);
|
|
519
|
+
if (result.ok)
|
|
370
520
|
return { value: start, result };
|
|
371
521
|
// each optional field alone, so one the refinement doesn't need stays out
|
|
372
522
|
for (const [name, field_value] of candidates) {
|
|
373
523
|
const value = { ...start, [name]: field_value };
|
|
374
|
-
const single_result = schema
|
|
375
|
-
if (single_result.
|
|
524
|
+
const single_result = parse_any(schema, value);
|
|
525
|
+
if (single_result.ok)
|
|
376
526
|
return { value, result: single_result };
|
|
377
527
|
}
|
|
378
528
|
// then cumulatively, for a refinement needing several
|
|
379
529
|
const value = { ...start };
|
|
380
530
|
for (const [name, field_value] of candidates) {
|
|
381
531
|
value[name] = field_value;
|
|
382
|
-
result = schema
|
|
383
|
-
if (result.
|
|
532
|
+
result = parse_any(schema, value);
|
|
533
|
+
if (result.ok)
|
|
384
534
|
break;
|
|
385
535
|
}
|
|
386
536
|
return { value, result };
|
|
@@ -395,27 +545,31 @@ const fill_optional_fields = (schema, start, candidates) => {
|
|
|
395
545
|
* replaces `base`'s optional fields, refilled the same way around it (an
|
|
396
546
|
* exactly-one-of rule: adding `slug` means dropping `id`).
|
|
397
547
|
*
|
|
398
|
-
* @param object_schema - the
|
|
548
|
+
* @param object_schema - the object schema `base` is an instance of, Zod or
|
|
549
|
+
* `@fuzdev/fuz_schema`, possibly wrapped
|
|
399
550
|
* @param schema - the schema the object must satisfy, refinements included
|
|
400
551
|
* @param base - a valid object, the generated or seeded base
|
|
401
552
|
* @param field - the field the object must carry
|
|
402
553
|
* @returns the object, or `null` when no object the generator can build
|
|
403
554
|
* carries the field and passes `schema`
|
|
555
|
+
* @throws Error when `object_schema` is no object schema, or either schema is
|
|
556
|
+
* of neither library
|
|
404
557
|
*/
|
|
405
558
|
export const generate_valid_object_with_field = (object_schema, schema, base, field) => {
|
|
406
559
|
if (Object.hasOwn(base, field.name))
|
|
407
560
|
return base;
|
|
408
|
-
const
|
|
561
|
+
const view = to_object_schema_view(object_schema, 'generate_valid_object_with_field: the object schema');
|
|
562
|
+
const fields = view.fields;
|
|
409
563
|
const value_of = (f) => Object.hasOwn(base, f.name)
|
|
410
564
|
? base[f.name]
|
|
411
|
-
: generate_valid_value(f,
|
|
565
|
+
: generate_valid_value(f, view.field_schema(f.name));
|
|
412
566
|
const field_value = value_of(field);
|
|
413
567
|
// the field joins the base, which keeps its optional fields
|
|
414
568
|
const absent = fields
|
|
415
569
|
.filter((f) => f.name !== field.name && is_optional_field(f) && !Object.hasOwn(base, f.name))
|
|
416
570
|
.map((f) => [f.name, value_of(f)]);
|
|
417
571
|
const joined = fill_optional_fields(schema, { ...base, [field.name]: field_value }, absent);
|
|
418
|
-
if (joined.result.
|
|
572
|
+
if (joined.result.ok)
|
|
419
573
|
return joined.value;
|
|
420
574
|
// the field in place of the base's optional fields, which are refilled around it
|
|
421
575
|
const optional_names = new Set(fields.filter(is_optional_field).map((f) => f.name));
|
|
@@ -429,7 +583,7 @@ export const generate_valid_object_with_field = (object_schema, schema, base, fi
|
|
|
429
583
|
.filter((f) => f.name !== field.name && is_optional_field(f))
|
|
430
584
|
.map((f) => [f.name, value_of(f)]);
|
|
431
585
|
const replaced = fill_optional_fields(schema, core, others);
|
|
432
|
-
return replaced.result.
|
|
586
|
+
return replaced.result.ok ? replaced.value : null;
|
|
433
587
|
};
|
|
434
588
|
const NIL_UUID = '00000000-0000-0000-0000-000000000000';
|
|
435
589
|
/**
|
|
@@ -441,8 +595,8 @@ const NIL_UUID = '00000000-0000-0000-0000-000000000000';
|
|
|
441
595
|
* integer whose minimum is above one), and a string synthesized from the
|
|
442
596
|
* field's constraints.
|
|
443
597
|
*
|
|
444
|
-
* @param field - the field's info, from `zod_extract_fields`
|
|
445
|
-
* @param field_schema - the field's schema
|
|
598
|
+
* @param field - the field's info, from `to_object_schema_view` or `zod_extract_fields`
|
|
599
|
+
* @param field_schema - the field's schema, Zod or `@fuzdev/fuz_schema`
|
|
446
600
|
* @returns the string, or `null` when no candidate passes
|
|
447
601
|
*/
|
|
448
602
|
export const generate_valid_string_param = (field, field_schema) => {
|
|
@@ -470,15 +624,31 @@ export const generate_valid_string_param = (field, field_schema) => {
|
|
|
470
624
|
candidates.push(String(Math.floor(json.exclusiveMinimum) + 1));
|
|
471
625
|
}
|
|
472
626
|
candidates.push(generate_valid_string(field_schema));
|
|
473
|
-
return candidates.find((c) => field_schema
|
|
627
|
+
return candidates.find((c) => accepts(field_schema, c)) ?? null;
|
|
474
628
|
};
|
|
475
629
|
/**
|
|
476
|
-
*
|
|
630
|
+
* The input a body is generated for: `null` for a void or null input
|
|
631
|
+
* (`is_void_schema`, `is_null_schema`), which takes no body, else its object
|
|
632
|
+
* view (`to_object_schema_view`).
|
|
477
633
|
*
|
|
478
|
-
* @param
|
|
479
|
-
* @
|
|
634
|
+
* @param input_schema - a route's or action's input schema, Zod or `@fuzdev/fuz_schema`
|
|
635
|
+
* @param label - names the input in the error
|
|
636
|
+
* @throws Error naming `label` when the input is of neither library, or is
|
|
637
|
+
* neither void, null, nor an object schema — no body can be generated for
|
|
638
|
+
* it, and no body is not the same as one the generator can't build
|
|
480
639
|
*/
|
|
481
|
-
export const
|
|
640
|
+
export const to_body_input = (input_schema, label) => {
|
|
641
|
+
if (is_null_schema(input_schema) || is_void_schema(input_schema))
|
|
642
|
+
return null;
|
|
643
|
+
const view = to_object_view(input_schema, label);
|
|
644
|
+
if (!view) {
|
|
645
|
+
if (to_base_type(input_schema) === 'void') {
|
|
646
|
+
throw new Error(`${label} is a void under wrappers, which dispatch does not read as void (\`is_void_schema\` is exact): absent params reach it as \`{}\`, which it refuses — declare the input as a bare \`z.void()\` or \`s.void\``);
|
|
647
|
+
}
|
|
648
|
+
throw new Error(`${label} is no object, void or null schema (its innermost type is '${to_base_type(input_schema)}'), so no body can be generated for it`);
|
|
649
|
+
}
|
|
650
|
+
return view;
|
|
651
|
+
};
|
|
482
652
|
/**
|
|
483
653
|
* The `Content-Type` a well-formed request to a route sends: `application/json`,
|
|
484
654
|
* or `application/octet-stream` for a `raw_body` route. Every `POST` route
|
|
@@ -507,24 +677,28 @@ export const to_route_content_type = (route) => route.raw_body ? 'application/oc
|
|
|
507
677
|
* The synthesized value is percent-encoded, and a value containing `/` is
|
|
508
678
|
* refused (it would silently add a path segment and route elsewhere) —
|
|
509
679
|
* both fall back to `test_<name>`.
|
|
680
|
+
*
|
|
681
|
+
* @param path - the route path, its params as `:name`
|
|
682
|
+
* @param params_schema - the route's params schema, a Zod or `@fuzdev/fuz_schema` object schema
|
|
683
|
+
* @throws Error when `params_schema` is no object schema, or of neither library
|
|
510
684
|
*/
|
|
511
685
|
export const resolve_valid_path = (path, params_schema) => {
|
|
512
686
|
if (!params_schema) {
|
|
513
687
|
return path.replace(/:(\w+)/g, 'test_$1');
|
|
514
688
|
}
|
|
689
|
+
const view = to_object_schema_view(params_schema, `resolve_valid_path(${path}): the params schema`);
|
|
515
690
|
return path.replace(/:(\w+)/g, (_match, name) => {
|
|
516
691
|
const fallback = `test_${name}`;
|
|
517
|
-
const field_schema =
|
|
692
|
+
const field_schema = view.field_schema(name);
|
|
518
693
|
if (!field_schema)
|
|
519
694
|
return fallback;
|
|
520
|
-
if (field_schema
|
|
695
|
+
if (accepts(field_schema, fallback))
|
|
521
696
|
return fallback;
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
return '00000000-0000-0000-0000-000000000000';
|
|
697
|
+
if (to_base_type(field_schema) === 'uuid')
|
|
698
|
+
return NIL_UUID;
|
|
525
699
|
const format = detect_format(field_schema);
|
|
526
700
|
if (format === 'uuid')
|
|
527
|
-
return
|
|
701
|
+
return NIL_UUID;
|
|
528
702
|
const generated = generate_valid_string(field_schema);
|
|
529
703
|
if (generated.includes('/'))
|
|
530
704
|
return fallback;
|
|
@@ -532,24 +706,24 @@ export const resolve_valid_path = (path, params_schema) => {
|
|
|
532
706
|
});
|
|
533
707
|
};
|
|
534
708
|
/**
|
|
535
|
-
* Generate a valid request body for a route's input schema.
|
|
709
|
+
* Generate a valid request body for a route's or action's input schema.
|
|
536
710
|
*
|
|
537
|
-
* @
|
|
538
|
-
*
|
|
539
|
-
*
|
|
540
|
-
*
|
|
541
|
-
*
|
|
711
|
+
* @param input_schema - the input schema, Zod or `@fuzdev/fuz_schema`
|
|
712
|
+
* @returns a generated body that passes the schema, or `undefined` for a void
|
|
713
|
+
* or null input, which takes no body
|
|
714
|
+
* @throws Error if the input is of neither library, or is neither void, null,
|
|
715
|
+
* nor an object schema, or if the generated body fails the input — catching
|
|
716
|
+
* broken `generate_valid_value` logic early with the parse's issues instead
|
|
717
|
+
* of a confusing 400 in downstream tests
|
|
542
718
|
*/
|
|
543
719
|
export const generate_valid_body = (input_schema) => {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
const object_schema = zod_unwrap_to_object(input_schema);
|
|
547
|
-
if (!object_schema)
|
|
720
|
+
const view = to_body_input(input_schema, 'generate_valid_body: the input');
|
|
721
|
+
if (!view)
|
|
548
722
|
return undefined;
|
|
549
|
-
const { value, result } =
|
|
550
|
-
if (!result.
|
|
723
|
+
const { value, result } = generate_valid_object_from_view(view, input_schema);
|
|
724
|
+
if (!result.ok) {
|
|
551
725
|
throw new Error(`generate_valid_body: generated body fails validation — ` +
|
|
552
|
-
`fix generate_valid_value for: ${
|
|
726
|
+
`fix generate_valid_value for: ${format_issues(result.issues)}`);
|
|
553
727
|
}
|
|
554
728
|
return value;
|
|
555
729
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse_round_trip.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/sse_round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAmB7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,oBAAoB,CAAC;AAGrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAGjE,OAAO,EAEN,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpE,OAAO,EAIN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"sse_round_trip.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/sse_round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAmB7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,oBAAoB,CAAC;AAGrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAGjE,OAAO,EAEN,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpE,OAAO,EAIN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AAQ1B,gDAAgD;AAChD,MAAM,WAAW,gBAAgB;IAChC,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,OAAO,EAAE,CAAC,GAAG,EAAE;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,WAAW,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7E;;;OAGG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC/B;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,8CAA8C;AAC9C,MAAM,WAAW,mBAAmB;IACnC,4CAA4C;IAC5C,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,qDAAqD;IACrD,kBAAkB,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAChE,iDAAiD;IACjD,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,gHAAgH;IAChH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAChC;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAChD;;;;;;;;;;;;OAYG;IACH,aAAa,EAAE,uBAAuB,CAAC;IACvC,8BAA8B;IAC9B,MAAM,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;CAChC;AAmDD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,GAAI,SAAS,mBAAmB,KAAG,IAkIvE,CAAC"}
|
|
@@ -25,6 +25,7 @@ import { run_migrations } from '../db/migrate.js';
|
|
|
25
25
|
import { AUTH_MIGRATION_NS } from '../auth/migrations.js';
|
|
26
26
|
import { account_session_revoke_all_action_spec } from '../auth/account_action_specs.js';
|
|
27
27
|
import { create_sse_frame_reader } from './transports/sse_frame_reader.js';
|
|
28
|
+
import { parse_any } from '../schema_issues.js';
|
|
28
29
|
/**
|
|
29
30
|
* Validate a decoded SSE `data:` frame as a JSON-RPC-style `{method, params}` payload.
|
|
30
31
|
*/
|
|
@@ -46,9 +47,9 @@ const parse_and_validate_sse_payload = (frame, event_specs, route_path) => {
|
|
|
46
47
|
if (event_specs) {
|
|
47
48
|
const spec = event_specs.find((s) => s.method === notification.method);
|
|
48
49
|
assert.ok(spec, `${route_path}: no EventSpec declared for method '${notification.method}' (declared: ${event_specs.map((s) => s.method).join(', ')})`);
|
|
49
|
-
const result = spec.params
|
|
50
|
-
if (!result.
|
|
51
|
-
throw new Error(`${route_path}: params mismatch for method '${notification.method}': ${JSON.stringify(result.
|
|
50
|
+
const result = parse_any(spec.params, notification.params);
|
|
51
|
+
if (!result.ok) {
|
|
52
|
+
throw new Error(`${route_path}: params mismatch for method '${notification.method}': ${JSON.stringify(result.issues)}`);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
return notification;
|