@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.
Files changed (131) hide show
  1. package/dist/actions/CLAUDE.md +27 -14
  2. package/dist/actions/action_codegen.d.ts +10 -3
  3. package/dist/actions/action_codegen.d.ts.map +1 -1
  4. package/dist/actions/action_codegen.js +52 -13
  5. package/dist/actions/action_event.d.ts.map +1 -1
  6. package/dist/actions/action_event.js +13 -11
  7. package/dist/actions/action_rpc.d.ts +4 -3
  8. package/dist/actions/action_rpc.d.ts.map +1 -1
  9. package/dist/actions/action_rpc.js +4 -3
  10. package/dist/actions/action_spec.d.ts +102 -206
  11. package/dist/actions/action_spec.d.ts.map +1 -1
  12. package/dist/actions/action_spec.js +18 -96
  13. package/dist/actions/action_types.d.ts +4 -4
  14. package/dist/actions/action_types.d.ts.map +1 -1
  15. package/dist/actions/action_types.js +2 -2
  16. package/dist/actions/broadcast_api.d.ts.map +1 -1
  17. package/dist/actions/broadcast_api.js +6 -5
  18. package/dist/actions/compile_action_registry.d.ts +11 -6
  19. package/dist/actions/compile_action_registry.d.ts.map +1 -1
  20. package/dist/actions/compile_action_registry.js +15 -9
  21. package/dist/actions/perform_action.d.ts +4 -4
  22. package/dist/actions/perform_action.d.ts.map +1 -1
  23. package/dist/actions/perform_action.js +11 -11
  24. package/dist/auth/CLAUDE.md +1 -1
  25. package/dist/auth/account_action_specs.d.ts +50 -23
  26. package/dist/auth/account_action_specs.d.ts.map +1 -1
  27. package/dist/auth/account_action_specs.js +18 -8
  28. package/dist/auth/account_route_schema.d.ts +10 -10
  29. package/dist/auth/account_schema.d.ts +21 -21
  30. package/dist/auth/actor_lookup_action_specs.d.ts +7 -7
  31. package/dist/auth/actor_search_action_specs.d.ts +6 -6
  32. package/dist/auth/admin_action_specs.d.ts +98 -98
  33. package/dist/auth/app_settings_schema.d.ts +2 -2
  34. package/dist/auth/audit_log_route_schema.d.ts +1 -1
  35. package/dist/auth/audit_log_schema.d.ts +44 -44
  36. package/dist/auth/auth_guard_resolver.d.ts +2 -2
  37. package/dist/auth/auth_guard_resolver.js +2 -2
  38. package/dist/auth/bootstrap_route_schema.d.ts +4 -4
  39. package/dist/auth/cell_action_specs.d.ts +241 -241
  40. package/dist/auth/cell_actions.js +3 -3
  41. package/dist/auth/cell_audit_action_specs.d.ts +14 -14
  42. package/dist/auth/cell_audit_metadata.d.ts +6 -6
  43. package/dist/auth/cell_field_action_specs.d.ts +38 -38
  44. package/dist/auth/cell_field_audit_metadata.d.ts +4 -4
  45. package/dist/auth/cell_grant_action_specs.d.ts +61 -61
  46. package/dist/auth/cell_grant_audit_metadata.d.ts +10 -10
  47. package/dist/auth/cell_item_action_specs.d.ts +50 -50
  48. package/dist/auth/cell_item_audit_metadata.d.ts +5 -5
  49. package/dist/auth/invite_schema.d.ts +6 -6
  50. package/dist/auth/role_grant_offer_action_specs.d.ts +120 -120
  51. package/dist/auth/role_grant_offer_notifications.d.ts +66 -66
  52. package/dist/auth/role_grant_offer_schema.d.ts +6 -6
  53. package/dist/auth/self_service_role_action_specs.d.ts +2 -2
  54. package/dist/auth/signup_route_schema.d.ts +2 -2
  55. package/dist/http/CLAUDE.md +9 -8
  56. package/dist/http/auth_shape.d.ts +54 -17
  57. package/dist/http/auth_shape.d.ts.map +1 -1
  58. package/dist/http/auth_shape.js +104 -52
  59. package/dist/http/error_schemas.d.ts +6 -4
  60. package/dist/http/error_schemas.d.ts.map +1 -1
  61. package/dist/http/error_schemas.js +4 -9
  62. package/dist/http/jsonrpc_errors.d.ts +11 -4
  63. package/dist/http/jsonrpc_errors.d.ts.map +1 -1
  64. package/dist/http/jsonrpc_errors.js +11 -4
  65. package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
  66. package/dist/http/jsonrpc_helpers.js +2 -1
  67. package/dist/http/route_spec.d.ts +3 -2
  68. package/dist/http/route_spec.d.ts.map +1 -1
  69. package/dist/http/route_spec.js +20 -8
  70. package/dist/http/schema_helpers.d.ts +24 -20
  71. package/dist/http/schema_helpers.d.ts.map +1 -1
  72. package/dist/http/schema_helpers.js +24 -19
  73. package/dist/primitive_schemas.d.ts +10 -3
  74. package/dist/primitive_schemas.d.ts.map +1 -1
  75. package/dist/primitive_schemas.js +10 -2
  76. package/dist/primitive_schemas_fuz.d.ts +69 -0
  77. package/dist/primitive_schemas_fuz.d.ts.map +1 -0
  78. package/dist/primitive_schemas_fuz.js +49 -0
  79. package/dist/realtime/sse.d.ts +3 -3
  80. package/dist/realtime/sse.d.ts.map +1 -1
  81. package/dist/realtime/sse.js +4 -4
  82. package/dist/schema_issues.d.ts +91 -4
  83. package/dist/schema_issues.d.ts.map +1 -1
  84. package/dist/schema_issues.js +262 -1
  85. package/dist/schema_meta.d.ts +24 -8
  86. package/dist/schema_meta.d.ts.map +1 -1
  87. package/dist/schema_meta.js +31 -10
  88. package/dist/server/serve_fact_route.d.ts.map +1 -1
  89. package/dist/server/serve_fact_route.js +2 -1
  90. package/dist/testing/CLAUDE.md +17 -11
  91. package/dist/testing/adversarial_input_cases.d.ts +18 -23
  92. package/dist/testing/adversarial_input_cases.d.ts.map +1 -1
  93. package/dist/testing/adversarial_input_cases.js +51 -46
  94. package/dist/testing/cross_backend/action_manifest.d.ts +2 -1
  95. package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
  96. package/dist/testing/cross_backend/action_manifest.js +3 -3
  97. package/dist/testing/cross_backend/cell_crud.d.ts.map +1 -1
  98. package/dist/testing/cross_backend/cell_crud.js +3 -8
  99. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  100. package/dist/testing/cross_backend/conformance_table.js +5 -4
  101. package/dist/testing/cross_backend/cross_rpc.d.ts +4 -2
  102. package/dist/testing/cross_backend/cross_rpc.d.ts.map +1 -1
  103. package/dist/testing/cross_backend/cross_rpc.js +6 -4
  104. package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
  105. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  106. package/dist/testing/cross_backend/sse_round_trip.js +3 -2
  107. package/dist/testing/cross_backend/testing_reset_actions.d.ts +8 -8
  108. package/dist/testing/integration_helpers.d.ts.map +1 -1
  109. package/dist/testing/integration_helpers.js +4 -3
  110. package/dist/testing/rpc_envelope_cases.d.ts +3 -3
  111. package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
  112. package/dist/testing/rpc_envelope_cases.js +1 -1
  113. package/dist/testing/rpc_helpers.d.ts +12 -8
  114. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  115. package/dist/testing/rpc_helpers.js +18 -15
  116. package/dist/testing/schema_generators.d.ts +75 -40
  117. package/dist/testing/schema_generators.d.ts.map +1 -1
  118. package/dist/testing/schema_generators.js +273 -99
  119. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  120. package/dist/testing/sse_round_trip.js +4 -3
  121. package/dist/ui/admin_accounts_state.svelte.d.ts +10 -10
  122. package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
  123. package/dist/ui/admin_invites_state.svelte.d.ts +1 -1
  124. package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -1
  125. package/dist/ui/admin_sessions_state.svelte.d.ts +2 -2
  126. package/dist/ui/admin_sessions_state.svelte.d.ts.map +1 -1
  127. package/dist/ui/role_grant_offers_state.svelte.d.ts +6 -6
  128. package/dist/zod.d.ts +23 -5
  129. package/dist/zod.d.ts.map +1 -1
  130. package/dist/zod.js +2 -2
  131. package/package.json +6 -6
@@ -4,12 +4,35 @@
4
4
  * wholly one library, so one parse's issues are all of one kind; these
5
5
  * helpers read either, so the dispatcher, `ActionEvent` and the
6
6
  * forward-compatible reads treat a spec the same whichever library it is
7
- * written in.
7
+ * written in, and an error response carries either library's issues in one
8
+ * shape, `WireIssue`.
8
9
  *
9
10
  * @module
10
11
  */
11
12
  import { z } from 'zod';
12
13
  import { format_issue, is_schema, parse, SchemaError } from '@fuzdev/fuz_schema/schema.ts';
14
+ /**
15
+ * Whether `value` is a Zod schema. Zod's `instanceof` reads the schema's
16
+ * traits, so a schema made by another copy of Zod is one too.
17
+ *
18
+ * @param value - any value
19
+ */
20
+ export const is_zod_schema = (value) => value instanceof z.ZodType;
21
+ /**
22
+ * Throw unless `value` is a Zod schema, naming `label` — what a reader of a
23
+ * spec's schema calls once it has ruled out a `@fuzdev/fuz_schema` schema
24
+ * (`is_schema`), so a value of neither library fails loudly where it is read,
25
+ * rather than as a `TypeError` deeper in or a silent `undefined`.
26
+ *
27
+ * @param value - the schema, known not to be a fuz_schema schema
28
+ * @param label - names the schema in the error, e.g. `` `action 'foo' input` ``
29
+ * @throws Error when `value` is not a Zod schema, saying it is of neither library
30
+ */
31
+ export function assert_zod_schema(value, label) {
32
+ if (is_zod_schema(value))
33
+ return;
34
+ throw new Error(`${label} is neither a Zod schema nor a @fuzdev/fuz_schema schema`);
35
+ }
13
36
  /**
14
37
  * Parse `value` with a schema of either library: `parse` for a fuz_schema
15
38
  * schema (`is_schema`), `safeParse` for a Zod one.
@@ -20,6 +43,7 @@ import { format_issue, is_schema, parse, SchemaError } from '@fuzdev/fuz_schema/
20
43
  * @param schema - a Zod or fuz_schema schema
21
44
  * @param value - the value to validate
22
45
  * @returns the output, or the issues
46
+ * @throws Error when `schema` is neither a Zod nor a fuz_schema schema
23
47
  */
24
48
  export const parse_any = (schema, value) => {
25
49
  if (is_schema(schema)) {
@@ -28,6 +52,7 @@ export const parse_any = (schema, value) => {
28
52
  ? { ok: true, value: result.value }
29
53
  : { ok: false, issues: result.issues };
30
54
  }
55
+ assert_zod_schema(schema, 'parse_any: the schema');
31
56
  const result = schema.safeParse(value);
32
57
  return result.success
33
58
  ? { ok: true, value: result.data }
@@ -108,3 +133,239 @@ export const format_issues = (issues) => {
108
133
  * @param err - a caught value
109
134
  */
110
135
  export const is_schema_validation_error = (err) => err instanceof z.ZodError || err instanceof SchemaError;
136
+ /**
137
+ * A validation issue as an error response carries it, for either schema
138
+ * library: `@fuzdev/fuz_schema`'s `SchemaIssue` as JSON, with `message` the
139
+ * text of the issue. `to_wire_issues` builds it from either library's issues.
140
+ *
141
+ * Loose: a client reads it, and a newer server may add fields.
142
+ */
143
+ export const WireIssue = z.looseObject({
144
+ /** The fuz_schema kind of the check that failed, or `unknown_key` / `missing_key`. */
145
+ kind: z.string(),
146
+ /** Keys from the root value to the one that failed, outermost first. */
147
+ path: z.array(z.union([z.string(), z.number()])),
148
+ /** Describes what was expected, as fuz_schema writes it. */
149
+ expected: z.string(),
150
+ /** The type of the value that failed: `'null'`, `'array'`, `'NaN'`, `'Infinity'`, `'-Infinity'`, or its `typeof`. */
151
+ received: z.string(),
152
+ /** The issue as text: `format_issue` for a fuz_schema issue, Zod's own message for a Zod one. */
153
+ message: z.string()
154
+ });
155
+ /**
156
+ * A failed parse's issues as `WireIssue`s, whichever library made them.
157
+ *
158
+ * A fuz_schema issue keeps its `kind`, `path`, `expected` and `received`, and
159
+ * its `message` is `format_issue`'s text, the path included.
160
+ *
161
+ * A Zod issue maps to the kind fuz_schema reports for the same check, its
162
+ * `message` Zod's own text, which names no path:
163
+ *
164
+ * - `invalid_type` — the type's kind (`string`, `number`, `boolean`,
165
+ * `bigint`, `object`, `record`, `array`); `int` is `integer`, a `tuple` an
166
+ * `array`, `null`, `undefined`, `void` and `nan` a `literal` of the value,
167
+ * `nonoptional` a `missing_key`, and a type fuz_schema has no kind for
168
+ * (`date`, `map`, `set`, `file`, `symbol`, `function`, `never`) a `check`
169
+ * expecting the type's name. A missing key is reported as fuz_schema
170
+ * reports it, as the type expected with `received: 'undefined'`.
171
+ * - `too_small` / `too_big` — `min_length` / `max_length` for a string,
172
+ * array, set or file (`length >= N`), `min_value` / `max_value` otherwise
173
+ * (`>= N`); an exclusive bound writes `>` or `<`, which fuz_schema has no
174
+ * check for, and an exact length is reported as the bound it broke.
175
+ * - `invalid_format` — `uuid` for a `uuid` or `guid`, `iso_datetime` for a
176
+ * `datetime`, `regex` for a `regex` (expecting its pattern), and a `check`
177
+ * expecting the format's name for every other format.
178
+ * - `unrecognized_keys` — an `unknown_key` per key, the key appended to the
179
+ * path, as fuz_schema reports them.
180
+ * - `invalid_union` — a `variant` expecting the options when Zod names a
181
+ * discriminator, else a `union` expecting each option as fuz_schema names
182
+ * it: by the type or the values it expected of the value, or by the
183
+ * value's type when the option took the type and failed a refinement or a
184
+ * field below. A union refused because more than one option matched is a
185
+ * `union` expecting `exactly one option`.
186
+ * - `invalid_value` — a `literal` of one value, a `one_of` of more.
187
+ * - `custom` — a `check`; `not_multiple_of` a `check` expecting
188
+ * `multiple of N`; `invalid_key` and `invalid_element` a `check` expecting
189
+ * `a valid key` / `a valid element`.
190
+ *
191
+ * A Zod issue holds no value, so `received` is read from `input` at the
192
+ * issue's path: `'undefined'` where a key is missing or the path leads
193
+ * through something that isn't an object. Where an earlier step of a Zod
194
+ * pipe replaced the value, it names the input's value, not the replacement.
195
+ *
196
+ * @param issues - a failed parse's issues, either library
197
+ * @param input - the value that was parsed
198
+ * @returns the issues, one per issue but for a Zod `unrecognized_keys`, which is one per key
199
+ */
200
+ export const to_wire_issues = (issues, input) => {
201
+ const wire = [];
202
+ for (const issue of issues) {
203
+ if (is_zod_issue(issue)) {
204
+ push_zod_wire_issues(wire, issue, input);
205
+ }
206
+ else {
207
+ wire.push({
208
+ kind: issue.kind,
209
+ path: to_wire_path(issue.path),
210
+ expected: issue.expected,
211
+ received: issue.received,
212
+ message: format_issue(issue)
213
+ });
214
+ }
215
+ }
216
+ return wire;
217
+ };
218
+ // a symbol key has no JSON form, so it goes as its text
219
+ const to_wire_path = (path) => path.map((key) => (typeof key === 'symbol' ? key.toString() : key));
220
+ // the type of a value as fuz_schema's `received` names it
221
+ const to_received = (value) => value === null
222
+ ? 'null'
223
+ : Array.isArray(value)
224
+ ? 'array'
225
+ : typeof value === 'number' && !Number.isFinite(value)
226
+ ? String(value)
227
+ : typeof value;
228
+ // the value at `path` of `value`, by own keys, `undefined` where a key is
229
+ // missing or the path leads through something that isn't an object
230
+ const get_at = (value, path) => {
231
+ let at = value;
232
+ for (const key of path) {
233
+ if (at === null || typeof at !== 'object')
234
+ return undefined;
235
+ at = Object.hasOwn(at, key) ? at[key] : undefined;
236
+ }
237
+ return at;
238
+ };
239
+ // literals as fuz_schema's `expected` writes them, strings quoted
240
+ const format_literals = (values) => values.map((v) => (typeof v === 'string' ? JSON.stringify(v) : String(v))).join(' | ');
241
+ // fuz_schema's kind and `expected` for a Zod `invalid_type` issue's `expected`,
242
+ // where they differ from the type's own name
243
+ const ZOD_TYPE_KINDS = {
244
+ string: { kind: 'string', expected: 'string' },
245
+ number: { kind: 'number', expected: 'number' },
246
+ boolean: { kind: 'boolean', expected: 'boolean' },
247
+ bigint: { kind: 'bigint', expected: 'bigint' },
248
+ int: { kind: 'integer', expected: 'integer' },
249
+ object: { kind: 'object', expected: 'object' },
250
+ record: { kind: 'record', expected: 'object' },
251
+ array: { kind: 'array', expected: 'array' },
252
+ tuple: { kind: 'array', expected: 'array' },
253
+ null: { kind: 'literal', expected: 'null' },
254
+ undefined: { kind: 'literal', expected: 'undefined' },
255
+ void: { kind: 'literal', expected: 'undefined' },
256
+ nan: { kind: 'literal', expected: 'NaN' },
257
+ nonoptional: { kind: 'missing_key', expected: 'a required key' }
258
+ };
259
+ // a Zod length origin, whose bounds fuz_schema checks as `min_length` / `max_length`
260
+ const ZOD_LENGTH_ORIGINS = new Set(['string', 'array', 'set', 'file']);
261
+ // fuz_schema's kind for a Zod `invalid_format` format, a `check` when absent
262
+ const ZOD_FORMAT_KINDS = {
263
+ uuid: 'uuid',
264
+ guid: 'uuid',
265
+ datetime: 'iso_datetime',
266
+ regex: 'regex'
267
+ };
268
+ // pushes the wire form of a Zod issue
269
+ const push_zod_wire_issues = (wire, issue, input) => {
270
+ const { path } = issue;
271
+ if (issue.code === 'unrecognized_keys') {
272
+ // the object holding the keys, read once so the cost is linear in keys
273
+ const holder = get_at(input, path);
274
+ for (const key of issue.keys) {
275
+ wire.push({
276
+ kind: 'unknown_key',
277
+ path: to_wire_path([...path, key]),
278
+ expected: 'no unknown keys',
279
+ received: to_received(get_at(holder, [key])),
280
+ // Zod's text names every key, so a key of several gets the one-key form
281
+ message: issue.keys.length === 1 ? issue.message : `Unrecognized key: ${JSON.stringify(key)}`
282
+ });
283
+ }
284
+ return;
285
+ }
286
+ const { kind, expected } = to_zod_kind(issue, input, path);
287
+ wire.push({
288
+ kind,
289
+ path: to_wire_path(path),
290
+ expected,
291
+ received: to_received(get_at(input, path)),
292
+ message: issue.message
293
+ });
294
+ };
295
+ // fuz_schema's kind and `expected` for a Zod issue other than `unrecognized_keys`
296
+ const to_zod_kind = (issue, input, path) => {
297
+ switch (issue.code) {
298
+ case 'invalid_type':
299
+ return ZOD_TYPE_KINDS[issue.expected] ?? { kind: 'check', expected: issue.expected };
300
+ case 'too_small': {
301
+ const op = issue.inclusive === false ? '>' : '>=';
302
+ return ZOD_LENGTH_ORIGINS.has(issue.origin)
303
+ ? { kind: 'min_length', expected: `length ${op} ${issue.minimum}` }
304
+ : { kind: 'min_value', expected: `${op} ${issue.minimum}` };
305
+ }
306
+ case 'too_big': {
307
+ const op = issue.inclusive === false ? '<' : '<=';
308
+ return ZOD_LENGTH_ORIGINS.has(issue.origin)
309
+ ? { kind: 'max_length', expected: `length ${op} ${issue.maximum}` }
310
+ : { kind: 'max_value', expected: `${op} ${issue.maximum}` };
311
+ }
312
+ case 'invalid_format': {
313
+ const kind = ZOD_FORMAT_KINDS[issue.format];
314
+ if (kind === undefined)
315
+ return { kind: 'check', expected: issue.format };
316
+ return {
317
+ kind,
318
+ expected: kind === 'regex' ? (issue.pattern ?? 'regex') : kind
319
+ };
320
+ }
321
+ case 'not_multiple_of':
322
+ return { kind: 'check', expected: `multiple of ${issue.divisor}` };
323
+ case 'invalid_union':
324
+ if (issue.inclusive === false)
325
+ return { kind: 'union', expected: 'exactly one option' };
326
+ if (issue.discriminator !== undefined && issue.options) {
327
+ return { kind: 'variant', expected: format_literals(issue.options) };
328
+ }
329
+ return {
330
+ kind: 'union',
331
+ expected: [...new Set(describe_union_options(issue, input, path))].join(' | ')
332
+ };
333
+ case 'invalid_key':
334
+ return { kind: 'check', expected: 'a valid key' };
335
+ case 'invalid_element':
336
+ return { kind: 'check', expected: 'a valid element' };
337
+ case 'invalid_value':
338
+ return {
339
+ kind: issue.values.length === 1 ? 'literal' : 'one_of',
340
+ expected: format_literals(issue.values)
341
+ };
342
+ case 'custom':
343
+ return { kind: 'check', expected: 'check' };
344
+ default: {
345
+ // a code a newer Zod added fails to compile here; at runtime it is a `check`
346
+ const unmapped = issue;
347
+ return { kind: 'check', expected: unmapped.code };
348
+ }
349
+ }
350
+ };
351
+ // each option of a failed Zod union as fuz_schema's `expected` names it: by
352
+ // the type or the values its issue on the value itself expected, a union's
353
+ // own options in its place (a discriminated one is an object), and else by
354
+ // the value's type, which the option matched: a refinement failed, or an
355
+ // issue below the value, as an object or array option's (an option's issues
356
+ // are relative to the union)
357
+ const describe_union_options = (issue, input, path) => issue.errors.flatMap((option_issues) => {
358
+ if (!option_issues.length)
359
+ return [];
360
+ const on_value = option_issues.find((i) => i.path.length === 0);
361
+ if (on_value?.code === 'invalid_union' && on_value.inclusive !== false) {
362
+ return on_value.discriminator === undefined
363
+ ? describe_union_options(on_value, input, path)
364
+ : ['object'];
365
+ }
366
+ if ((on_value?.code === 'invalid_type' && on_value.expected !== 'int') ||
367
+ on_value?.code === 'invalid_value') {
368
+ return [to_zod_kind(on_value, input, path).expected];
369
+ }
370
+ return [to_received(get_at(input, path))];
371
+ });
@@ -5,8 +5,10 @@
5
5
  * surface generation, and test helpers. The env schemas are
6
6
  * `@fuzdev/fuz_schema` and carry the same keys in its `meta`
7
7
  * (`sensitivity.ts`, `find_schema_sensitivity`); this module adds
8
- * `invalid_reason` to fuz_schema's `SchemaMeta`, so the declared refusal
9
- * reason of an action input reads the same whichever library its schema is.
8
+ * `invalid_reason` and `empty_input_handler_guarded` to fuz_schema's
9
+ * `SchemaMeta`, so the declared refusal reason of an action input, its
10
+ * handler-guarded marker, and its sensitivity read the same whichever library
11
+ * its schema is.
10
12
  *
11
13
  * @module
12
14
  */
@@ -22,6 +24,13 @@ declare module '@fuzdev/fuz_schema/meta.ts' {
22
24
  * declaration winning.
23
25
  */
24
26
  invalid_reason?: string;
27
+ /**
28
+ * Set on an action's input schema whose handler refuses the `{}` the
29
+ * schema admits, as `SchemaFieldMeta.empty_input_handler_guarded`
30
+ * declares it on a Zod input. Read from the input schema itself
31
+ * (`get_meta`), so a wrapper around it drops it, as in Zod.
32
+ */
33
+ empty_input_handler_guarded?: boolean;
25
34
  }
26
35
  }
27
36
  /** Zod `.meta()` shape for fuz_app schema metadata conventions. */
@@ -71,12 +80,15 @@ export interface SchemaFieldMeta {
71
80
  invalid_reason?: string;
72
81
  }
73
82
  /**
74
- * Whether `schema` carries `empty_input_handler_guarded: true` in its `.meta()`.
83
+ * Whether `schema` carries `empty_input_handler_guarded: true` in its
84
+ * metadata: a Zod schema's `.meta()`, a `@fuzdev/fuz_schema` schema's own
85
+ * `meta` (`get_meta`), read from the schema itself in both.
75
86
  *
76
- * @param schema - an action's input schema
87
+ * @param schema - an action's input schema, Zod or fuz_schema
77
88
  * @returns whether its handler refuses the `{}` the schema admits
89
+ * @throws Error when `schema` is neither a Zod nor a fuz_schema schema
78
90
  */
79
- export declare const is_empty_input_handler_guarded: (schema: z.ZodType) => boolean;
91
+ export declare const is_empty_input_handler_guarded: (schema: ValidationSchema) => boolean;
80
92
  /**
81
93
  * A `SchemaFieldMeta` key's value as a schema declares it, read through its
82
94
  * optional, nullable, default, prefault, transform and pipe layers — Zod
@@ -119,7 +131,10 @@ export declare const schema_sensitivity: (schema: z.ZodType) => Sensitivity | un
119
131
  * or `'personal'` on the schema itself or anywhere inside it: through its
120
132
  * wrappers (as `schema_sensitivity`), and into object fields, array and set
121
133
  * elements, tuple items, record and map keys and values, template literal
122
- * parts, union members and intersection sides.
134
+ * parts, union members and intersection sides. A `@fuzdev/fuz_schema` schema
135
+ * is read with `find_schema_meta` and `structural`: every layer, every step
136
+ * of a pipe, every option of a union or variant, a `lazy`'s schema, and the
137
+ * entries, rest, items and values of its objects, arrays and records.
123
138
  *
124
139
  * What keeps a read's input off the URL: `FrontendHttpTransport` sends a
125
140
  * read (`side_effects: false`) as a `GET` with the params in the query string,
@@ -127,10 +142,11 @@ export declare const schema_sensitivity: (schema: z.ZodType) => Sensitivity | un
127
142
  * value — that call goes as a `POST` (the transport walks each spec's input
128
143
  * once).
129
144
  *
130
- * @param schema - an action input schema
145
+ * @param schema - an action input schema, Zod or fuz_schema
131
146
  * @returns `true` when any value the schema admits may hold a sensitive field
147
+ * @throws Error when `schema` is neither a Zod nor a fuz_schema schema
132
148
  */
133
- export declare const schema_has_sensitive_field: (schema: z.ZodType) => boolean;
149
+ export declare const schema_has_sensitive_field: (schema: ValidationSchema) => boolean;
134
150
  /**
135
151
  * The `error.data.reason` an input validation failure at `path` carries: the
136
152
  * `invalid_reason` of the deepest field along `path` that declares one.
@@ -1 +1 @@
1
- {"version":3,"file":"schema_meta.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/schema_meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQ7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAqB,KAAK,QAAQ,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE7F,OAAO,QAAQ,4BAA4B,CAAC;IAC3C,UAAU,UAAU;QACnB;;;;;WAKG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;KACxB;CACD;AAED,mEAAmE;AACnE,MAAM,WAAW,eAAe;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;;;;;;;;OAUG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,OACkB,CAAC;AAEtF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,IAAI,SAAS,MAAM,eAAe,EACnE,QAAQ,CAAC,CAAC,OAAO,EACjB,KAAK,IAAI,KACP,eAAe,CAAC,IAAI,CAAC,GAAG,SAM1B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,MAAM,GAAG,SACvB,CAAC;AA4D7C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,WAAW,GAAG,SACrC,CAAC;AAEjC;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,0BAA0B,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,OAClB,CAAC;AAE9C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,GAClC,cAAc,gBAAgB,EAC9B,MAAM,aAAa,CAAC,WAAW,CAAC,KAC9B,MAAM,GAAG,SAaX,CAAC;AAoBF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,6BAA6B,GACzC,cAAc,gBAAgB,EAC9B,QAAQ,aAAa,CAAC,QAAQ,CAAC,EAC/B,OAAO,OAAO,KACZ,MAAM,GAAG,SAKX,CAAC"}
1
+ {"version":3,"file":"schema_meta.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/schema_meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAU7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAGN,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,QAAQ,4BAA4B,CAAC;IAC3C,UAAU,UAAU;QACnB;;;;;WAKG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB;;;;;WAKG;QACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;KACtC;CACD;AAED,mEAAmE;AACnE,MAAM,WAAW,eAAe;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;;;;;;;;OAUG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,8BAA8B,GAAI,QAAQ,gBAAgB,KAAG,OAIzE,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,IAAI,SAAS,MAAM,eAAe,EACnE,QAAQ,CAAC,CAAC,OAAO,EACjB,KAAK,IAAI,KACP,eAAe,CAAC,IAAI,CAAC,GAAG,SAM1B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,MAAM,GAAG,SACvB,CAAC;AA4D7C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,WAAW,GAAG,SACrC,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,0BAA0B,GAAI,QAAQ,gBAAgB,KAAG,OAMrE,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,GAClC,cAAc,gBAAgB,EAC9B,MAAM,aAAa,CAAC,WAAW,CAAC,KAC9B,MAAM,GAAG,SAaX,CAAC;AAoBF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,6BAA6B,GACzC,cAAc,gBAAgB,EAC9B,QAAQ,aAAa,CAAC,QAAQ,CAAC,EAC/B,OAAO,OAAO,KACZ,MAAM,GAAG,SAKX,CAAC"}
@@ -5,22 +5,33 @@
5
5
  * surface generation, and test helpers. The env schemas are
6
6
  * `@fuzdev/fuz_schema` and carry the same keys in its `meta`
7
7
  * (`sensitivity.ts`, `find_schema_sensitivity`); this module adds
8
- * `invalid_reason` to fuz_schema's `SchemaMeta`, so the declared refusal
9
- * reason of an action input reads the same whichever library its schema is.
8
+ * `invalid_reason` and `empty_input_handler_guarded` to fuz_schema's
9
+ * `SchemaMeta`, so the declared refusal reason of an action input, its
10
+ * handler-guarded marker, and its sensitivity read the same whichever library
11
+ * its schema is.
10
12
  *
11
13
  * @module
12
14
  */
13
15
  import { is_schema } from '@fuzdev/fuz_schema/schema.ts';
14
- import { get_schema_entries, get_schema_meta, unwrap_schema } from '@fuzdev/fuz_schema/introspect.ts';
16
+ import { find_schema_meta, get_schema_entries, get_schema_meta, unwrap_schema } from '@fuzdev/fuz_schema/introspect.ts';
17
+ import { get_meta } from '@fuzdev/fuz_schema/meta.ts';
15
18
  import { zod_get_schema_layers, zod_unwrap_to_object } from './zod.js';
16
- import { issue_is_on_input } from './schema_issues.js';
19
+ import { assert_zod_schema, issue_is_on_input } from './schema_issues.js';
17
20
  /**
18
- * Whether `schema` carries `empty_input_handler_guarded: true` in its `.meta()`.
21
+ * Whether `schema` carries `empty_input_handler_guarded: true` in its
22
+ * metadata: a Zod schema's `.meta()`, a `@fuzdev/fuz_schema` schema's own
23
+ * `meta` (`get_meta`), read from the schema itself in both.
19
24
  *
20
- * @param schema - an action's input schema
25
+ * @param schema - an action's input schema, Zod or fuz_schema
21
26
  * @returns whether its handler refuses the `{}` the schema admits
27
+ * @throws Error when `schema` is neither a Zod nor a fuz_schema schema
22
28
  */
23
- export const is_empty_input_handler_guarded = (schema) => schema.meta()?.empty_input_handler_guarded === true;
29
+ export const is_empty_input_handler_guarded = (schema) => {
30
+ if (is_schema(schema))
31
+ return get_meta(schema)?.empty_input_handler_guarded === true;
32
+ assert_zod_schema(schema, 'is_empty_input_handler_guarded: the input');
33
+ return schema.meta()?.empty_input_handler_guarded === true;
34
+ };
24
35
  /**
25
36
  * A `SchemaFieldMeta` key's value as a schema declares it, read through its
26
37
  * optional, nullable, default, prefault, transform and pipe layers — Zod
@@ -141,7 +152,10 @@ export const schema_sensitivity = (schema) => walk_sensitivity(schema, false);
141
152
  * or `'personal'` on the schema itself or anywhere inside it: through its
142
153
  * wrappers (as `schema_sensitivity`), and into object fields, array and set
143
154
  * elements, tuple items, record and map keys and values, template literal
144
- * parts, union members and intersection sides.
155
+ * parts, union members and intersection sides. A `@fuzdev/fuz_schema` schema
156
+ * is read with `find_schema_meta` and `structural`: every layer, every step
157
+ * of a pipe, every option of a union or variant, a `lazy`'s schema, and the
158
+ * entries, rest, items and values of its objects, arrays and records.
145
159
  *
146
160
  * What keeps a read's input off the URL: `FrontendHttpTransport` sends a
147
161
  * read (`side_effects: false`) as a `GET` with the params in the query string,
@@ -149,10 +163,17 @@ export const schema_sensitivity = (schema) => walk_sensitivity(schema, false);
149
163
  * value — that call goes as a `POST` (the transport walks each spec's input
150
164
  * once).
151
165
  *
152
- * @param schema - an action input schema
166
+ * @param schema - an action input schema, Zod or fuz_schema
153
167
  * @returns `true` when any value the schema admits may hold a sensitive field
168
+ * @throws Error when `schema` is neither a Zod nor a fuz_schema schema
154
169
  */
155
- export const schema_has_sensitive_field = (schema) => walk_sensitivity(schema, true) !== undefined;
170
+ export const schema_has_sensitive_field = (schema) => {
171
+ if (is_schema(schema)) {
172
+ return find_schema_meta(schema, 'sensitivity', { structural: true }).length > 0;
173
+ }
174
+ assert_zod_schema(schema, 'schema_has_sensitive_field: the input');
175
+ return walk_sensitivity(schema, true) !== undefined;
176
+ };
156
177
  /**
157
178
  * The `error.data.reason` an input validation failure at `path` carries: the
158
179
  * `invalid_reason` of the deepest field along `path` that declares one.
@@ -1 +1 @@
1
- {"version":3,"file":"serve_fact_route.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/serve_fact_route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmIG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAetD,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAS5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAoCjD,MAAM,WAAW,+BAA+B;IAC/C,kFAAkF;IAClF,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACZ;AAkJD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iCAAiC,GAC7C,SAAS,+BAA+B,KACtC,SA0DF,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,+BAA+B,KACtC,SA+CF,CAAC"}
1
+ {"version":3,"file":"serve_fact_route.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/serve_fact_route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmIG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAetD,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAU5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAoCjD,MAAM,WAAW,+BAA+B;IAC/C,kFAAkF;IAClF,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACZ;AAkJD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iCAAiC,GAC7C,SAAS,+BAA+B,KACtC,SA0DF,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,+BAA+B,KACtC,SA+CF,CAAC"}
@@ -141,6 +141,7 @@ import { ActingActor } from '../http/auth_shape.js';
141
141
  import { query_active_actors_by_account } from '../auth/account_queries.js';
142
142
  import { get_route_params } from '../http/route_spec.js';
143
143
  import { ERROR_INVALID_ROUTE_PARAMS } from '../http/error_schemas.js';
144
+ import { WireIssue } from '../schema_issues.js';
144
145
  import { query_get_fact, query_get_fact_meta } from '../db/fact_queries.js';
145
146
  import { to_uint8 } from '../db/fact_store.js';
146
147
  import { query_cell_get } from '../db/cell_queries.js';
@@ -176,7 +177,7 @@ const cell_fact_params_schema = z.strictObject({
176
177
  const params_400_error = {
177
178
  400: z.looseObject({
178
179
  error: z.literal(ERROR_INVALID_ROUTE_PARAMS),
179
- issues: z.array(z.unknown()).optional()
180
+ issues: z.array(WireIssue).optional()
180
181
  })
181
182
  };
182
183
  /**
@@ -263,8 +263,9 @@ per-method auth shape.
263
263
  - `cross_backend/action_manifest.ts` — `ActionManifest` / `ActionManifestEntry`
264
264
  Zod schema (the `_testing_action_manifest` wire validator) + `build_action_manifest(specs)`,
265
265
  which normalizes each spec to `{method, input, side_effects, account, actor, roles,
266
- credential_types, rate_limit}` (`input` is `'void'` for a `z.void()` input, by
267
- `is_void_schema`, else `'object'` — the Rust `InputShape`; auth axes pass through; `roles` /
266
+ credential_types, rate_limit}` (`input` is `'void'` for a `z.void()` or
267
+ fuz_schema `s.void` input, by `is_void_schema`, else `'object'` — the Rust
268
+ `InputShape`; auth axes pass through; `roles` /
268
269
  `credential_types` flatten to sorted arrays; `rate_limit` is the declared
269
270
  class or an explicit `null`, so a missing key reads as drift rather than a
270
271
  default). Twin of `schema_introspect.ts`. Excludes the protocol actions
@@ -382,7 +383,7 @@ difference. The same cases run again over
382
383
  WS, against `differential_ws_known_divergences` (the HTTP ledger without its
383
384
  header row). The multi-actor `conformance_acting_cases.ts` rows run with the
384
385
  generated rows on a keeper seeded with `extra_actors`, over both transports.
385
- The TS spine runs under `DEV` there, so its DEV-only diagnostics (Zod
386
+ The TS spine runs under `DEV` there, so its DEV-only diagnostics (the
386
387
  `issues` on `invalid_params`, the `X-Fuz-Auth-Debug` header) are ledger rows.
387
388
  The suite composition is `describe_spine_differential_suites`
388
389
  (`src/test/cross_backend/spine_differential.ts`), which takes the two
@@ -479,17 +480,22 @@ Support functions:
479
480
 
480
481
  ### `schema_generators.ts` — valid-value generation
481
482
 
482
- Walks Zod schemas to generate valid values for adversarial/round-trip tests.
483
+ Walks Zod and `@fuzdev/fuz_schema` schemas to generate valid values for
484
+ adversarial/round-trip tests. Every helper takes either library's schema
485
+ (`ValidationSchema`) and parses with `parse_any`; a schema of neither throws,
486
+ naming it.
487
+
488
+ - `to_object_schema_view(schema, label)` → `ObjectSchemaView` — the fields (`SchemaFieldInfo[]`, from `zod.ts`) of an object schema of either library through its wrappers, in Zod's type vocabulary (`zod_extract_fields` for Zod; a fuz_schema object of any strictness reads `'object'`, `literal(null)` `'null'`, `literal(undefined)` `'void'`, `one_of` `'enum'`, `variant` `'union'`), and each field's schema, throwing on a schema that is no object schema. `to_body_input(input_schema, label)` is the body generators' gate: `null` for a void or null input, else the object view, and a throw for any other input — no body is never silently what an unbuildable input yields.
483
489
 
484
490
  - `to_field_json_schema(field_schema)` — the field's JSON Schema rendered with `io: 'input'`, so a `.transform()` or pipe field (`Username`) yields its input-side bounds and pattern instead of throwing; a `.nullable()` / `.nullish()` field's one non-null `anyOf` branch (or one non-null `type` of a `type` array) is returned. Both libraries render with `unrepresentable: 'any'`, so it is never `null`: a part JSON Schema can't say (a `z.date()`, a `z.custom()`, a fuz_schema `check`) is left out or `{}` and the bounds around it still read; it throws on a schema an emitter refuses even then. A pipe yields its input stage only, and a `.refine()` never appears (a code-point length bound generates nothing). Every JSON Schema read in the generators goes through it.
485
491
  - `detect_format(field_schema)` — `detect_json_schema_format` over `to_field_json_schema`: the `format`, `'pattern'` for a regex, or `null`.
486
- - `generate_valid_value(field, field_schema)` — base-type switch producing a valid sample (UUIDs → nil UUID, strings → `'xxxxxxxxxx'`, numbers → `1`, objects → `generate_valid_object` against the field schema, so a nested refinement is satisfied too, enums → first entry, etc.). For branded-string refinements, walks a fallback chain synthesized from the `pattern` string the JSON Schema representation exposes: fixed-length hex (`^[0-9a-f]{N}$` — blake3 / sha256 / md5 digests; `0`.repeat(N)), prefix-lengthed slug (`^<prefix>_[A-Za-z0-9_-]{N}$` — `ApiTokenId`-style ids; `<prefix>_` + `x`.repeat(N)), absolute path prefix, URL prefix, two `/`-joined segments (an `owner/name` slug). First candidate that `safeParse` accepts is used.
492
+ - `generate_valid_value(field, field_schema)` — base-type switch producing a valid sample (UUIDs → nil UUID, strings → `'xxxxxxxxxx'`, numbers → `1`, objects → `generate_valid_object` against the field schema, so a nested refinement is satisfied too, enums → first entry, records → `{}`, a void field → `undefined`, etc.). For branded-string refinements, walks a fallback chain synthesized from the `pattern` string the JSON Schema representation exposes: fixed-length hex (`^[0-9a-f]{N}$` — blake3 / sha256 / md5 digests; `0`.repeat(N)), prefix-lengthed slug (`^<prefix>_[A-Za-z0-9_-]{N}$` — `ApiTokenId`-style ids; `<prefix>_` + `x`.repeat(N)), absolute path prefix, URL prefix, two `/`-joined segments (an `owner/name` slug). First candidate the field accepts is used.
487
493
  - `generate_valid_string_param(field, field_schema)` — a string a URL-sourced field (route param, query value) accepts: the nil UUID for a UUID field, else the first of `test_value`, the generated valid value as a string, `1`, `0`, `true`, `false`, the field's JSON Schema `default` or lower bound as a string (a preprocessed integer whose minimum is above one) and a synthesized string the field accepts; `null` when none does. The params and query case generators build their base from it.
488
494
  - `resolve_valid_path(path, params_schema?)` — swaps `:param` for a value the params schema accepts. Prefers `test_<name>` wherever the field schema admits it (the param name keeps failure messages readable); otherwise a UUID param takes the nil UUID and anything else is synthesized from the schema, percent-encoded. A synthesized value containing `/` is refused (it would route elsewhere) and falls back to `test_<name>`.
489
495
  - `to_route_content_type(route)` — the `Content-Type` a well-formed request to the route sends: `application/json`, or `application/octet-stream` for a `raw_body` route. Every `POST` route refuses anything else with 415 before its other gates, so every probe in the harnesses (auth, params and query fuzz, 404, data exposure, round trip) sends it, body or not.
490
- - `generate_valid_object(object_schema, schema) => {value, result}` — required and defaulted fields; when `schema` (refinements included) refuses those, each optional field alone in declaration order, the first that parses; failing that, the optional fields added cumulatively until it parses. Covers a `.refine()` over optional fields (at least one of, exactly one of, both of) at any depth, and, where one optional field suffices, keeps the others (an `acting` declared first) out. Returns the last `safeParse` result and leaves the throw to the caller. `format_zod_issues(error)` renders the issues for those errors.
496
+ - `generate_valid_object(object_schema, schema) => {value, result}` — required and defaulted fields; when `schema` (refinements included) refuses those, each optional field alone in declaration order, the first that parses; failing that, the optional fields added cumulatively until it parses. Covers a `.refine()` over optional fields (at least one of, exactly one of, both of) at any depth, and, where one optional field suffices, keeps the others (an `acting` declared first) out. Returns the last `parse_any` result (`GeneratedObject`) and leaves the throw to the caller, which renders its issues with `format_issues` (`schema_issues.ts`).
491
497
  - `generate_valid_object_with_field(object_schema, schema, base, field)` — a valid object carrying `field`, built from the valid `base`: `base` itself when it carries the field; else the field joins `base`, with the optional fields `base` omits filled as `generate_valid_object` fills them (a pair rule: `scope_kind` needs `scope_id`); failing that, the field replaces `base`'s optional fields, refilled around it (exactly one of: adding `slug` drops `id`). `null` when no object the generator builds carries the field. The body a single-fault case on a field the base omits changes.
492
- - `generate_valid_body(input_schema) => Record<string, unknown> | undefined` — builds a body satisfying the input schema (`generate_valid_object`). Throws with Zod `issues` if the generated body fails validation — surfaces broken generation logic with a descriptive error rather than a confusing 400 downstream.
498
+ - `generate_valid_body(input_schema) => Record<string, unknown> | undefined` — builds a body satisfying the input schema (`generate_valid_object`); `undefined` for a void or null input. Throws for an input that is no object, void or null schema (`to_body_input`), and with the parse's issues if the generated body fails validation — surfaces broken generation logic with a descriptive error rather than a confusing 400 downstream.
493
499
 
494
500
  ### `integration_helpers.ts` — route lookup + body checks
495
501
 
@@ -543,7 +549,7 @@ All cases expect 400 with one of `ERROR_INVALID_REQUEST_BODY` /
543
549
  The generators live in the hono-free `adversarial_input_cases.ts`, so the
544
550
  cross-process suites reuse them:
545
551
 
546
- - `generate_input_test_cases(input_schema, options?)` → `InputTestCase[]` — whole-body structural (non-object, extra key when `strictObject`), missing required fields, one wrong-type per field, null for required non-nullable, one format violation per constrained field, and boundary cases read from the field's input-side JSON Schema (`to_field_json_schema` — through a transform or pipe, and under a nullable's `anyOf`): the empty string, one under `minLength` (above one; a prefix of the valid value) and one over `maxLength`; below `minimum`, above `maximum`, at an exclusive bound, zero and negative for a positive-only field, a non-integer for an integer field and a value off a `multipleOf` grid (each half a step from the valid value, inside the range); the empty array, one under `minItems` (above one; the valid value's own items) and one over `maxItems`. A per-field case is emitted only when the field refuses its value (a `z.coerce` field given a wrong type, a pattern admitting the violation string, a preprocess that repairs the value: dropped), so no generated case is accidentally valid. Each per-field case is single-fault — valid but for the field it breaks: it changes one field of a valid base (`generate_valid_object`'s, or `options.base` (`InputTestCaseOptions`) for an input whose valid shape the generator can't reach), or, for a field that base omits, of the body `generate_valid_object_with_field` builds around it, so a case can't also break an object-level rule. A field no valid body carries keeps its wrong-type and null cases on the base and gets no format or boundary cases. Either base failing the schema throws, naming `options.label` (the method or route) when given. A per-field case names the field it breaks (`InputTestCase.field`; absent on the whole-body cases).
552
+ - `generate_input_test_cases(input_schema, options?)` → `InputTestCase[]` — whole-body structural (non-object, extra key when the input refuses unknown keys — a `z.strictObject` or a fuz_schema `object`), missing required fields, one wrong-type per field, null for required non-nullable, one format violation per constrained field, and boundary cases read from the field's input-side JSON Schema (`to_field_json_schema` — through a transform or pipe, and under a nullable's `anyOf`): the empty string, one under `minLength` (above one; a prefix of the valid value) and one over `maxLength`; below `minimum`, above `maximum`, at an exclusive bound, zero and negative for a positive-only field, a non-integer for an integer field and a value off a `multipleOf` grid (each half a step from the valid value, inside the range); the empty array, one under `minItems` (above one; the valid value's own items) and one over `maxItems`. A per-field case is emitted only when the field refuses its value (a `z.coerce` field given a wrong type, a pattern admitting the violation string, a preprocess that repairs the value: dropped), so no generated case is accidentally valid. Each per-field case is single-fault — valid but for the field it breaks: it changes one field of a valid base (`generate_valid_object`'s, or `options.base` (`InputTestCaseOptions`) for an input whose valid shape the generator can't reach), or, for a field that base omits, of the body `generate_valid_object_with_field` builds around it, so a case can't also break an object-level rule. A field no valid body carries keeps its wrong-type and null cases on the base and gets no format or boundary cases. Either base failing the schema throws, naming `options.label` (the method or route) when given. A per-field case names the field it breaks (`InputTestCase.field`; absent on the whole-body cases). A void or null input gets no cases; any other input that is no object schema throws (`to_body_input`).
547
553
  - `expected_invalid_reason(input_schema, test_case)` → `string | undefined` — the `data.reason` an RPC refusal of the case owes: the broken field's `invalid_reason` (`schema_meta.ts`), resolved by the same `resolve_invalid_reason` the dispatcher resolves through, or none for an undeclared field or a whole-body case.
548
554
  - `generate_params_test_cases(params_schema)` → `ParamsTestCase[]` — format violations only (unconstrained string params accept anything), each one the field refuses.
549
555
  - `generate_query_test_cases(query_schema)` → `QueryTestCase[]` — missing required fields the field refuses to go without (a preprocessed field with a default accepts its absence) + format violations the field refuses.
@@ -949,7 +955,7 @@ Request builders:
949
955
  Response assertions:
950
956
 
951
957
  - `assert_jsonrpc_error_response(body, expected_code?)` — validates `JsonrpcErrorResponse`; optional code check.
952
- - `assert_jsonrpc_success_response(body, output_schema?)` — validates `JsonrpcResponse`; optional `output_schema.safeParse(result)`.
958
+ - `assert_jsonrpc_success_response(body, output_schema?)` — validates `JsonrpcResponse`; optional `output_schema` check on `result`, Zod or fuz_schema (`parse_any`).
953
959
 
954
960
  One-shot transport:
955
961
 
@@ -960,7 +966,7 @@ One-shot transport:
960
966
  - `RpcCallArgs` — `{app, path, method, params?, params_json?, headers?, id?, verb?}`. `verb` defaults to `'POST'`; use `'GET'` for `side_effects: false` methods. `params_json` sends raw JSON text in place of `params` (exclusive with it) on either verb.
961
967
  - `rpc_call_raw(args)` — the same request as `rpc_call`, the response unparsed: `RpcCallRawResult` `{status, headers, body}` with the whole envelope. `parse_rpc_call_result(raw, method)` turns it into an `RpcCallResult`; `rpc_call` is the two composed.
962
968
  - `rpc_call(args)` — merges `RPC_CALL_DEFAULT_HEADERS` (`host: 'localhost'`, `origin: TEST_ORIGIN`, `Content-Type: 'application/json'`) under caller headers. Envelope-shape violations throw; JSON-RPC errors return `{ok: false, error}` so callers assert on `error.code` / `error.data.reason`.
963
- - `rpc_call_typed<T>(args, output_schema)` — parses the success `result` through the schema; throws on envelope failure, error response, or schema mismatch. Use `rpc_call` when the test needs to assert on error shapes.
969
+ - `rpc_call_typed<T>(args, output_schema)` — parses the success `result` through the schema, Zod or fuz_schema (`parse_any`); throws on envelope failure, error response, or schema mismatch. Use `rpc_call` when the test needs to assert on error shapes.
964
970
  - `rpc_call_for_spec<TSpec>(args)` — spec-bound variant: takes `{..., spec, params}` in place of `{..., method, params}`. `params` is typed from `spec.input` and the success `result` is typed from `spec.output` (runtime-validated, same contract as `rpc_call_typed`). Error branch stays untyped (JSON-RPC `error.data` shapes vary per call site). Use at happy-path + denial-path call sites; fall back to `rpc_call` for adversarial tests that send deliberately-malformed params.
965
971
 
966
972
  Registry lookups:
@@ -1930,7 +1936,7 @@ the option type states whether the bundle is read.
1930
1936
  pages tiling every row; a `data` that is no `CellData` — a non-object, or a
1931
1937
  non-string `label` / `summary` — refused 400 `invalid_params` with the
1932
1938
  generic message and no reason (no `data` beyond a TS spine's DEV-only
1933
- `issues`, an array of the schema library's issues) on `cell_create`, on `cell_update` of a
1939
+ `issues`, an array of `WireIssue`s) on `cell_create`, on `cell_update` of a
1934
1940
  missing and of a hidden cell, and, with `cell_relations`, on `cell_clone`'s
1935
1941
  `with_data_patch` — ahead of the 404 mask the same hidden-cell call answers
1936
1942
  when well-typed, with the keeper's cell count unchanged; those cases run as