@fuzdev/fuz_app 0.168.1 → 0.170.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/dist/actions/CLAUDE.md +17 -19
  2. package/dist/actions/action_codegen.d.ts +32 -23
  3. package/dist/actions/action_codegen.d.ts.map +1 -1
  4. package/dist/actions/action_codegen.js +101 -80
  5. package/dist/actions/action_event.d.ts +0 -8
  6. package/dist/actions/action_event.d.ts.map +1 -1
  7. package/dist/actions/action_event.js +7 -6
  8. package/dist/actions/action_event_data.d.ts +18 -18
  9. package/dist/actions/action_rpc.d.ts +1 -1
  10. package/dist/actions/action_rpc.js +1 -1
  11. package/dist/actions/action_spec.d.ts +8 -10
  12. package/dist/actions/action_spec.d.ts.map +1 -1
  13. package/dist/actions/action_spec.js +1 -1
  14. package/dist/actions/action_types.d.ts +4 -4
  15. package/dist/actions/action_types.d.ts.map +1 -1
  16. package/dist/actions/action_types.js +2 -2
  17. package/dist/actions/broadcast_api.d.ts +2 -2
  18. package/dist/actions/broadcast_api.js +4 -4
  19. package/dist/actions/compile_action_registry.d.ts +6 -7
  20. package/dist/actions/compile_action_registry.d.ts.map +1 -1
  21. package/dist/actions/compile_action_registry.js +8 -9
  22. package/dist/actions/perform_action.d.ts +6 -6
  23. package/dist/actions/perform_action.d.ts.map +1 -1
  24. package/dist/actions/perform_action.js +11 -10
  25. package/dist/actions/socket.svelte.d.ts +1 -1
  26. package/dist/actions/socket.svelte.js +2 -2
  27. package/dist/auth/CLAUDE.md +11 -11
  28. package/dist/auth/account_action_specs.d.ts +11 -11
  29. package/dist/auth/account_action_specs.js +1 -1
  30. package/dist/auth/account_route_schema.d.ts +18 -18
  31. package/dist/auth/account_route_schema.js +1 -1
  32. package/dist/auth/account_routes.js +1 -1
  33. package/dist/auth/account_schema.d.ts +38 -40
  34. package/dist/auth/account_schema.d.ts.map +1 -1
  35. package/dist/auth/account_schema.js +7 -8
  36. package/dist/auth/actor_lookup_action_specs.d.ts +7 -7
  37. package/dist/auth/actor_lookup_action_specs.js +1 -1
  38. package/dist/auth/actor_search_action_specs.d.ts +6 -6
  39. package/dist/auth/actor_search_action_specs.js +1 -1
  40. package/dist/auth/admin_action_specs.d.ts +166 -166
  41. package/dist/auth/admin_action_specs.js +1 -1
  42. package/dist/auth/app_settings_schema.d.ts +3 -3
  43. package/dist/auth/app_settings_schema.d.ts.map +1 -1
  44. package/dist/auth/app_settings_schema.js +1 -1
  45. package/dist/auth/audit_emitter.d.ts +6 -7
  46. package/dist/auth/audit_emitter.d.ts.map +1 -1
  47. package/dist/auth/audit_emitter.js +11 -22
  48. package/dist/auth/audit_log_ddl.d.ts +1 -1
  49. package/dist/auth/audit_log_ddl.js +1 -1
  50. package/dist/auth/audit_log_queries.d.ts +0 -13
  51. package/dist/auth/audit_log_queries.d.ts.map +1 -1
  52. package/dist/auth/audit_log_queries.js +3 -3
  53. package/dist/auth/audit_log_route_schema.d.ts +1 -1
  54. package/dist/auth/audit_log_route_schema.js +1 -1
  55. package/dist/auth/audit_log_schema.d.ts +69 -70
  56. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  57. package/dist/auth/audit_log_schema.js +2 -2
  58. package/dist/auth/auth_ddl.d.ts +1 -1
  59. package/dist/auth/auth_ddl.js +1 -1
  60. package/dist/auth/bootstrap_route_schema.d.ts +4 -4
  61. package/dist/auth/bootstrap_route_schema.js +1 -1
  62. package/dist/auth/cell_action_specs.d.ts +466 -466
  63. package/dist/auth/cell_action_specs.js +1 -1
  64. package/dist/auth/cell_actions.d.ts +2 -2
  65. package/dist/auth/cell_actions.js +5 -5
  66. package/dist/auth/cell_audit_action_specs.d.ts +14 -14
  67. package/dist/auth/cell_audit_action_specs.js +1 -1
  68. package/dist/auth/cell_audit_metadata.d.ts +8 -8
  69. package/dist/auth/cell_audit_metadata.js +1 -1
  70. package/dist/auth/cell_field_action_specs.d.ts +55 -55
  71. package/dist/auth/cell_field_action_specs.js +1 -1
  72. package/dist/auth/cell_field_audit_metadata.d.ts +4 -4
  73. package/dist/auth/cell_field_audit_metadata.js +1 -1
  74. package/dist/auth/cell_grant_action_specs.d.ts +61 -61
  75. package/dist/auth/cell_grant_action_specs.js +1 -1
  76. package/dist/auth/cell_grant_audit_metadata.d.ts +10 -10
  77. package/dist/auth/cell_grant_audit_metadata.js +1 -1
  78. package/dist/auth/cell_item_action_specs.d.ts +76 -76
  79. package/dist/auth/cell_item_action_specs.js +1 -1
  80. package/dist/auth/cell_item_audit_metadata.d.ts +5 -5
  81. package/dist/auth/cell_item_audit_metadata.js +1 -1
  82. package/dist/auth/invite_schema.d.ts +11 -11
  83. package/dist/auth/invite_schema.d.ts.map +1 -1
  84. package/dist/auth/invite_schema.js +1 -1
  85. package/dist/auth/name_schema.js +1 -1
  86. package/dist/auth/password.js +1 -1
  87. package/dist/auth/request_context.js +2 -2
  88. package/dist/auth/role_grant_offer_action_specs.d.ts +182 -182
  89. package/dist/auth/role_grant_offer_action_specs.js +1 -1
  90. package/dist/auth/role_grant_offer_ddl.d.ts +1 -1
  91. package/dist/auth/role_grant_offer_ddl.js +1 -1
  92. package/dist/auth/role_grant_offer_notifications.d.ts +107 -107
  93. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
  94. package/dist/auth/role_grant_offer_notifications.js +3 -4
  95. package/dist/auth/role_grant_offer_schema.d.ts +9 -9
  96. package/dist/auth/role_grant_offer_schema.d.ts.map +1 -1
  97. package/dist/auth/role_grant_offer_schema.js +1 -1
  98. package/dist/auth/self_service_role_action_specs.d.ts +2 -2
  99. package/dist/auth/self_service_role_action_specs.js +1 -1
  100. package/dist/auth/self_service_role_actions.d.ts +1 -1
  101. package/dist/auth/self_service_role_actions.js +1 -1
  102. package/dist/auth/signup_route_schema.d.ts +2 -2
  103. package/dist/auth/signup_route_schema.js +1 -1
  104. package/dist/auth/token_scope.d.ts +8 -8
  105. package/dist/db/file_fact_url.d.ts +1 -1
  106. package/dist/env/env_schemas.d.ts +1 -2
  107. package/dist/env/env_schemas.d.ts.map +1 -1
  108. package/dist/env/env_schemas.js +3 -4
  109. package/dist/http/CLAUDE.md +30 -32
  110. package/dist/http/auth_shape.d.ts +17 -52
  111. package/dist/http/auth_shape.d.ts.map +1 -1
  112. package/dist/http/auth_shape.js +19 -61
  113. package/dist/http/db_routes.d.ts +1 -1
  114. package/dist/http/db_routes.d.ts.map +1 -1
  115. package/dist/http/db_routes.js +1 -1
  116. package/dist/http/error_schemas.d.ts +36 -36
  117. package/dist/http/jsonrpc.d.ts +11 -11
  118. package/dist/http/jsonrpc_helpers.js +1 -1
  119. package/dist/http/route_error_check.d.ts +2 -2
  120. package/dist/http/route_error_check.d.ts.map +1 -1
  121. package/dist/http/route_error_check.js +2 -3
  122. package/dist/http/route_errors.d.ts +4 -4
  123. package/dist/http/route_errors.d.ts.map +1 -1
  124. package/dist/http/route_errors.js +0 -13
  125. package/dist/http/route_spec.d.ts +33 -36
  126. package/dist/http/route_spec.d.ts.map +1 -1
  127. package/dist/http/route_spec.js +21 -22
  128. package/dist/http/schema_helpers.d.ts +75 -67
  129. package/dist/http/schema_helpers.d.ts.map +1 -1
  130. package/dist/http/schema_helpers.js +54 -76
  131. package/dist/http/surface.d.ts.map +1 -1
  132. package/dist/http/surface.js +6 -8
  133. package/dist/primitive_schemas.d.ts +162 -112
  134. package/dist/primitive_schemas.d.ts.map +1 -1
  135. package/dist/primitive_schemas.js +129 -161
  136. package/dist/realtime/sse.d.ts +3 -3
  137. package/dist/realtime/sse.d.ts.map +1 -1
  138. package/dist/realtime/sse.js +2 -2
  139. package/dist/schema_issues.d.ts +41 -146
  140. package/dist/schema_issues.d.ts.map +1 -1
  141. package/dist/schema_issues.js +39 -322
  142. package/dist/schema_meta.d.ts +63 -136
  143. package/dist/schema_meta.d.ts.map +1 -1
  144. package/dist/schema_meta.js +37 -184
  145. package/dist/sensitivity.d.ts +3 -5
  146. package/dist/sensitivity.d.ts.map +1 -1
  147. package/dist/sensitivity.js +3 -5
  148. package/dist/server/serve_fact_route.js +1 -1
  149. package/dist/server/surface_route.js +1 -1
  150. package/dist/testing/CLAUDE.md +23 -25
  151. package/dist/testing/adversarial_headers.js +2 -2
  152. package/dist/testing/adversarial_input_cases.d.ts +19 -18
  153. package/dist/testing/adversarial_input_cases.d.ts.map +1 -1
  154. package/dist/testing/adversarial_input_cases.js +29 -42
  155. package/dist/testing/assertions.d.ts +2 -2
  156. package/dist/testing/assertions.d.ts.map +1 -1
  157. package/dist/testing/assertions.js +3 -3
  158. package/dist/testing/cross_backend/account_lifecycle.js +2 -2
  159. package/dist/testing/cross_backend/action_manifest.d.ts +10 -9
  160. package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
  161. package/dist/testing/cross_backend/action_manifest.js +4 -3
  162. package/dist/testing/cross_backend/cell_crud.js +1 -1
  163. package/dist/testing/cross_backend/conformance_case.d.ts +96 -114
  164. package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
  165. package/dist/testing/cross_backend/conformance_case.js +0 -256
  166. package/dist/testing/cross_backend/conformance_rpc_auth.d.ts +0 -62
  167. package/dist/testing/cross_backend/conformance_rpc_auth.d.ts.map +1 -1
  168. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  169. package/dist/testing/cross_backend/conformance_table.js +3 -3
  170. package/dist/testing/cross_backend/cross_rpc.d.ts +3 -4
  171. package/dist/testing/cross_backend/cross_rpc.d.ts.map +1 -1
  172. package/dist/testing/cross_backend/cross_rpc.js +4 -4
  173. package/dist/testing/cross_backend/differential.js +2 -2
  174. package/dist/testing/cross_backend/fact_serving.js +1 -1
  175. package/dist/testing/cross_backend/identity_parity.js +9 -9
  176. package/dist/testing/cross_backend/origin_conformance.d.ts +9 -9
  177. package/dist/testing/cross_backend/query_shape.js +1 -1
  178. package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
  179. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +1 -1
  180. package/dist/testing/cross_backend/setup.d.ts +26 -4
  181. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  182. package/dist/testing/cross_backend/setup.js +7 -8
  183. package/dist/testing/cross_backend/sse_round_trip.js +2 -2
  184. package/dist/testing/cross_backend/testing_origin_check.d.ts +12 -12
  185. package/dist/testing/cross_backend/testing_reset_actions.d.ts +608 -201
  186. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  187. package/dist/testing/cross_backend/testing_reset_actions.js +46 -55
  188. package/dist/testing/cross_backend/token_lifetime.js +3 -3
  189. package/dist/testing/cross_backend/wire_shapes.js +1 -1
  190. package/dist/testing/cross_backend/ws_outbound_overflow.d.ts.map +1 -1
  191. package/dist/testing/cross_backend/ws_outbound_overflow.js +35 -0
  192. package/dist/testing/cross_backend/ws_round_trip.js +1 -1
  193. package/dist/testing/data_exposure.d.ts.map +1 -1
  194. package/dist/testing/data_exposure.js +1 -1
  195. package/dist/testing/integration.js +2 -2
  196. package/dist/testing/integration_helpers.d.ts.map +1 -1
  197. package/dist/testing/integration_helpers.js +2 -2
  198. package/dist/testing/middleware.d.ts.map +1 -1
  199. package/dist/testing/middleware.js +2 -2
  200. package/dist/testing/rpc_attack_surface.js +1 -1
  201. package/dist/testing/rpc_envelope_cases.d.ts +3 -3
  202. package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
  203. package/dist/testing/rpc_envelope_cases.js +1 -1
  204. package/dist/testing/rpc_helpers.d.ts +12 -14
  205. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  206. package/dist/testing/rpc_helpers.js +9 -11
  207. package/dist/testing/schema_generators.d.ts +67 -60
  208. package/dist/testing/schema_generators.d.ts.map +1 -1
  209. package/dist/testing/schema_generators.js +144 -151
  210. package/dist/testing/schema_introspect.d.ts +438 -78
  211. package/dist/testing/schema_introspect.d.ts.map +1 -1
  212. package/dist/testing/schema_introspect.js +26 -26
  213. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  214. package/dist/testing/sse_round_trip.js +2 -2
  215. package/dist/testing/surface_invariants.d.ts +1 -1
  216. package/dist/testing/surface_invariants.js +1 -1
  217. package/dist/testing/transports/bootstrap.d.ts +1 -1
  218. package/dist/testing/transports/bootstrap.d.ts.map +1 -1
  219. package/dist/testing/transports/bootstrap.js +1 -1
  220. package/dist/ui/BootstrapForm.svelte +1 -2
  221. package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -1
  222. package/dist/ui/SignupForm.svelte +1 -2
  223. package/dist/ui/SignupForm.svelte.d.ts.map +1 -1
  224. package/dist/ui/admin_accounts_state.svelte.d.ts +5 -5
  225. package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
  226. package/dist/ui/admin_invites_state.svelte.d.ts +1 -1
  227. package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -1
  228. package/dist/ui/admin_sessions_state.svelte.d.ts +2 -2
  229. package/dist/ui/admin_sessions_state.svelte.d.ts.map +1 -1
  230. package/dist/ui/form_state.svelte.d.ts +1 -1
  231. package/dist/ui/form_state.svelte.js +1 -1
  232. package/dist/ui/role_grant_offers_state.svelte.d.ts +1 -1
  233. package/package.json +7 -9
  234. package/dist/primitive_schemas_fuz.d.ts +0 -178
  235. package/dist/primitive_schemas_fuz.d.ts.map +0 -1
  236. package/dist/primitive_schemas_fuz.js +0 -149
  237. package/dist/zod.d.ts +0 -101
  238. package/dist/zod.d.ts.map +0 -1
  239. package/dist/zod.js +0 -195
@@ -9,12 +9,10 @@ import './assert_dev_env.js';
9
9
  * @module
10
10
  */
11
11
  import { assert } from 'vitest';
12
- import { z } from 'zod';
13
12
  import { is, parse } from '@fuzdev/fuz_schema/schema.ts';
14
13
  import { JSONRPC_VERSION, JsonrpcErrorResponse, JsonrpcResponse } from '../http/jsonrpc.js';
15
14
  import { create_stub_app_server_context } from './stubs.js';
16
15
  import { TEST_ORIGIN } from './test_origin.js';
17
- import { parse_any } from '../schema_issues.js';
18
16
  /**
19
17
  * Resolve a suite's `rpc_endpoints` option to an array for setup-time
20
18
  * inspection (path lookup, action presence checks).
@@ -63,7 +61,7 @@ export const resolve_rpc_endpoints_for_setup = (rpc_endpoints, session_options)
63
61
  * @param params - params (omit for parameterless methods; `null` is also
64
62
  * stripped for ergonomic call sites — JSON-RPC 2.0 §4.2
65
63
  * forbids `"params": null` on the wire, and `create_rpc_endpoint`
66
- * rejects `z.null()` action input schemas at registration).
64
+ * rejects `literal(null)` action input schemas at registration).
67
65
  * Tests that need to construct a literal `"params": null`
68
66
  * envelope (e.g. asserting envelope-level rejection) should
69
67
  * build the body inline rather than route through this helper.
@@ -132,13 +130,13 @@ export const assert_jsonrpc_error_response = (body, expected_code) => {
132
130
  * is provided, also validates the `result` field against the declared
133
131
  * output schema — matching the REST round-trip's `assert_response_matches_spec`.
134
132
  *
135
- * @param output_schema - optional Zod or `@fuzdev/fuz_schema` schema to validate the `result` field against
133
+ * @param output_schema - optional schema to validate the `result` field against
136
134
  */
137
135
  export const assert_jsonrpc_success_response = (body, output_schema) => {
138
136
  const result = parse(JsonrpcResponse, body);
139
137
  assert.ok(result.ok, `not a valid JSON-RPC success response: ${JSON.stringify(body)}`);
140
138
  if (output_schema) {
141
- const output_result = parse_any(output_schema, result.value.result);
139
+ const output_result = parse(output_schema, result.value.result);
142
140
  if (!output_result.ok) {
143
141
  assert.fail(`JSON-RPC result does not match output schema: ${JSON.stringify(output_result.issues)}`);
144
142
  }
@@ -279,8 +277,8 @@ export const rpc_call = async (args) => parse_rpc_call_result(await rpc_call_raw
279
277
  export const rpc_call_non_browser = (args) => rpc_call({ ...args, suppress_default_origin: true });
280
278
  /**
281
279
  * Typed wrapper over `rpc_call` — binds `params` and the success `result` to
282
- * the output types of `spec.input` and `spec.output` (`ValidationOutput`) via
283
- * the generic, for a Zod or a fuz_schema spec.
280
+ * the output types of `spec.input` and `spec.output` (`Infer`) via
281
+ * the generic.
284
282
  *
285
283
  * Success results are validated at runtime against `spec.output` (same
286
284
  * contract as `rpc_call_typed`); a mismatch throws. Error responses come
@@ -298,7 +296,7 @@ export const rpc_call_for_spec = async (args) => {
298
296
  if (!res.ok) {
299
297
  return res;
300
298
  }
301
- const parsed = parse_any(spec.output, res.result);
299
+ const parsed = parse(spec.output, res.result);
302
300
  if (!parsed.ok) {
303
301
  throw new Error(`rpc_call_for_spec(${spec.method}) result did not match spec.output: ${JSON.stringify(parsed.issues)}`);
304
302
  }
@@ -316,15 +314,15 @@ export const rpc_call_for_spec = async (args) => {
316
314
  * assert on specific error shapes.
317
315
  *
318
316
  * @throws Error if the response is a JSON-RPC error, if `rpc_call` throws
319
- * on an envelope violation, or if the result fails `output_schema` (a Zod or
320
- * `@fuzdev/fuz_schema` schema, parsed with `parse_any`).
317
+ * on an envelope violation, or if the result fails `output_schema` (parsed with
318
+ * `parse`).
321
319
  */
322
320
  export const rpc_call_typed = async (args, output_schema) => {
323
321
  const res = await rpc_call(args);
324
322
  if (!res.ok) {
325
323
  throw new Error(`rpc_call_typed(${args.method}) returned error: code=${res.error.code} message=${res.error.message} data=${JSON.stringify(res.error.data)}`);
326
324
  }
327
- const parsed = parse_any(output_schema, res.result);
325
+ const parsed = parse(output_schema, res.result);
328
326
  if (!parsed.ok) {
329
327
  throw new Error(`rpc_call_typed(${args.method}) result did not match output schema: ${JSON.stringify(parsed.issues)}`);
330
328
  }
@@ -1,40 +1,49 @@
1
1
  import './assert_dev_env.js';
2
- import { type SchemaFieldInfo } from '../zod.js';
3
- import { type ParseAnyResult, type ValidationSchema } from '../schema_issues.js';
2
+ /**
3
+ * Schema-driven value generation helpers for testing.
4
+ *
5
+ * Walks `@fuzdev/fuz_schema` schemas to generate valid values for route
6
+ * params, request bodies, and URL paths. Used by adversarial input,
7
+ * adversarial 404, and round-trip validation test suites. A value that is no
8
+ * schema throws, and so does an input no body can be generated for, rather
9
+ * than yielding no body.
10
+ *
11
+ * @module
12
+ */
13
+ import { type AnySchema, type SchemaResult } from '@fuzdev/fuz_schema/schema.ts';
14
+ import { type SchemaFieldInfo } from '../http/schema_helpers.js';
4
15
  /**
5
16
  * The JSON Schema of a field's input side — where its format, pattern and
6
- * bounds live. Takes a Zod or a `@fuzdev/fuz_schema` field.
17
+ * bounds live.
7
18
  *
8
- * Rendered with `io: 'input'`, so a field carrying a `.transform()` or a pipe
19
+ * Rendered with `io: 'input'`, so a field carrying a `transform` in a pipe
9
20
  * (`Username`) still yields the constraints its input is checked against;
10
21
  * the default output side throws on a transform. A pipe yields its input
11
22
  * side only, so constraints of the stage after it are not here. A
12
- * `.nullable()` / `.nullish()` field renders as
13
- * `anyOf: [{…}, {type: 'null'}]`, or a bare type as `type: [type, 'null']`;
23
+ * `nullable` field renders as `anyOf: [{…}, {type: 'null'}]`, or a bare
24
+ * type as `type: [type, 'null']`;
14
25
  * its one non-null branch or type is returned, so the bounds, pattern and
15
26
  * `type` read the same as on the bare field. A union of two or more non-null
16
27
  * branches returns the whole schema — its branches' bounds are no single
17
28
  * field's bounds.
18
29
  *
19
- * Either library renders with `unrepresentable: 'any'`: a part JSON Schema
20
- * can't say (a `z.date()`, a `z.custom()`, a fuz_schema `check` or `bigint`)
21
- * is left out or `{}`, and the bounds around it still read, so a
22
- * `pipe(string, max_length(n), check(…))` keeps its `maxLength` and a union
23
- * with a `z.date()` branch keeps its other branches — every case the
24
- * generators build from it is checked against the field itself before it's
25
- * used. What an emitter refuses even then (a fuz_schema entry named like a
30
+ * It renders with `unrepresentable: 'any'`: a part JSON Schema can't say (a
31
+ * `check` or a `bigint`) is left out or `{}`, and the bounds around it still
32
+ * read, so a `pipe(string, max_length(n), check(…))` keeps its `maxLength` —
33
+ * every case the generators build from it is checked against the field itself
34
+ * before it's used. What the emitter refuses even then (an entry named like a
26
35
  * member of `Object.prototype`, metadata that isn't JSON) throws: a mistake in
27
36
  * the schema, not a gap in JSON Schema.
28
37
  *
29
- * A `.refine()` is never here: JSON Schema can't express one, so a bound a
30
- * refinement enforces (a code-point length, a cross-field rule) generates no
31
- * boundary case.
38
+ * A `check` is never here: JSON Schema can't express one, so a bound a check
39
+ * enforces (a code-point length, a cross-field rule) generates no boundary
40
+ * case.
32
41
  *
33
42
  * @param field_schema - the field to read
34
43
  * @returns the field's input-side JSON Schema
35
44
  * @throws Error when the emitter refuses `field_schema` with `unrepresentable: 'any'`
36
45
  */
37
- export declare const to_field_json_schema: (field_schema: ValidationSchema) => Record<string, unknown>;
46
+ export declare const to_field_json_schema: (field_schema: AnySchema) => Record<string, unknown>;
38
47
  /**
39
48
  * The format constraint a field's input-side JSON Schema carries: its
40
49
  * `format` (e.g. `'uuid'`, `'email'`), `'pattern'` for a regex, or `null`.
@@ -51,39 +60,37 @@ export declare const detect_json_schema_format: (json: Record<string, unknown>)
51
60
  * (`to_field_json_schema`). Returns the format string (e.g. `'uuid'`,
52
61
  * `'email'`), `'pattern'` for a regex, or `null`.
53
62
  */
54
- export declare const detect_format: (field_schema: ValidationSchema) => string | null;
55
- /** An object schema's fields and the schema of each, of either library. */
63
+ export declare const detect_format: (field_schema: AnySchema) => string | null;
64
+ /** An object schema's fields and the schema of each. */
56
65
  export interface ObjectSchemaView {
57
66
  /** The fields, in declaration order. */
58
67
  fields: Array<SchemaFieldInfo>;
59
68
  /** The schema of the field named `name`, or `undefined` when there is none. */
60
- field_schema: (name: string) => ValidationSchema | undefined;
69
+ field_schema: (name: string) => AnySchema | undefined;
61
70
  }
62
71
  /**
63
- * The fields of an object schema of either library and the schema of each,
64
- * through its wrappers: the `ZodObject` inside a Zod schema
65
- * (`zod_unwrap_to_object`, `zod_extract_fields`), or a `@fuzdev/fuz_schema`
66
- * schema whose innermost layer is an object schema (`get_schema_entries`,
67
- * `get_schema_fields`).
72
+ * The fields of an object schema and the schema of each, through its
73
+ * wrappers: a schema whose innermost layer is an object schema
74
+ * (`get_schema_entries`, `get_schema_fields`).
68
75
  *
69
- * @param schema - an object schema, possibly wrapped, Zod or fuz_schema
76
+ * @param schema - an object schema, possibly wrapped
70
77
  * @param label - names the schema in the error
71
- * @throws Error naming `label` when `schema` is no object schema, or of neither library
78
+ * @throws Error naming `label` when `schema` is no object schema, or no schema
72
79
  */
73
- export declare const to_object_schema_view: (schema: ValidationSchema, label: string) => ObjectSchemaView;
80
+ export declare const to_object_schema_view: (schema: AnySchema, label: string) => ObjectSchemaView;
74
81
  /**
75
82
  * Generate a valid-ish value for a field based on its base type.
76
83
  *
77
- * @param field - the field's info, from `to_object_schema_view` or `zod_extract_fields`
78
- * @param field_schema - the field's schema, Zod or `@fuzdev/fuz_schema`
84
+ * @param field - the field's info, from `to_object_schema_view`
85
+ * @param field_schema - the field's schema
79
86
  * @returns the value, checked by the caller against the whole schema
80
87
  */
81
- export declare const generate_valid_value: (field: SchemaFieldInfo, field_schema: ValidationSchema) => unknown;
88
+ export declare const generate_valid_value: (field: SchemaFieldInfo, field_schema: AnySchema) => unknown;
82
89
  /** What `generate_valid_object` returns: the object and its last parse. */
83
90
  export interface GeneratedObject {
84
91
  value: Record<string, unknown>;
85
- /** The last `parse_any` of `value` against the schema — the caller decides whether a failure throws. */
86
- result: ParseAnyResult<unknown>;
92
+ /** The last `parse` of `value` against the schema — the caller decides whether a failure throws. */
93
+ result: SchemaResult<unknown>;
87
94
  }
88
95
  /**
89
96
  * Generate a valid object for an object schema: its required and defaulted
@@ -98,16 +105,15 @@ export interface GeneratedObject {
98
105
  * Shared by the top-level body generators and `generate_valid_value`'s
99
106
  * nested-object case, so a refined object validates the same way at any depth.
100
107
  *
101
- * @param object_schema - the object whose fields are generated: a Zod or
102
- * `@fuzdev/fuz_schema` object schema, possibly wrapped
108
+ * @param object_schema - the object whose fields are generated: an object
109
+ * schema, possibly wrapped
103
110
  * @param schema - the schema the object must satisfy, refinements included
104
111
  * (`object_schema` or a schema wrapping it)
105
- * @returns the generated object and its last `parse_any` result — the caller
112
+ * @returns the generated object and its last `parse` result — the caller
106
113
  * decides whether a failure throws
107
- * @throws Error when `object_schema` is no object schema, or either schema is
108
- * of neither library
114
+ * @throws Error when `object_schema` is no object schema, or no schema
109
115
  */
110
- export declare const generate_valid_object: (object_schema: ValidationSchema, schema: ValidationSchema) => GeneratedObject;
116
+ export declare const generate_valid_object: (object_schema: AnySchema, schema: AnySchema) => GeneratedObject;
111
117
  /**
112
118
  * A valid object that carries `field`, built from `base`, a valid object of
113
119
  * `object_schema` — the body a case breaking `field` changes, so the case
@@ -118,43 +124,44 @@ export declare const generate_valid_object: (object_schema: ValidationSchema, sc
118
124
  * replaces `base`'s optional fields, refilled the same way around it (an
119
125
  * exactly-one-of rule: adding `slug` means dropping `id`).
120
126
  *
121
- * @param object_schema - the object schema `base` is an instance of, Zod or
122
- * `@fuzdev/fuz_schema`, possibly wrapped
127
+ * @param object_schema - the object schema `base` is an instance of,
128
+ * possibly wrapped
123
129
  * @param schema - the schema the object must satisfy, refinements included
124
130
  * @param base - a valid object, the generated or seeded base
125
131
  * @param field - the field the object must carry
126
132
  * @returns the object, or `null` when no object the generator can build
127
133
  * carries the field and passes `schema`
128
- * @throws Error when `object_schema` is no object schema, or either schema is
129
- * of neither library
134
+ * @throws Error when `object_schema` is no object schema, or no schema
130
135
  */
131
- export declare const generate_valid_object_with_field: (object_schema: ValidationSchema, schema: ValidationSchema, base: Record<string, unknown>, field: SchemaFieldInfo) => Record<string, unknown> | null;
136
+ export declare const generate_valid_object_with_field: (object_schema: AnySchema, schema: AnySchema, base: Record<string, unknown>, field: SchemaFieldInfo) => Record<string, unknown> | null;
132
137
  /**
133
138
  * A string a URL-sourced field accepts — a route param or a query value, which
134
139
  * arrive as strings whatever the schema parses them into. The nil UUID for a
135
140
  * UUID field; else the first the field accepts of `test_value`, the generated
136
141
  * valid value written as a string, `1`, `0`, `true` and `false`, the field's
137
- * JSON Schema `default` or lower bound written as a string (a preprocessed
138
- * integer whose minimum is above one), and a string synthesized from the
139
- * field's constraints.
140
- *
141
- * @param field - the field's info, from `to_object_schema_view` or `zod_extract_fields`
142
- * @param field_schema - the field's schema, Zod or `@fuzdev/fuz_schema`
142
+ * JSON Schema `default` or lower bound written as a string, each
143
+ * `min_value` and `max_value` bound anywhere in the schema written as an
144
+ * integer (a string parsed into an integer whose range excludes the small
145
+ * candidates, `to_numeric_bounds`), and a string synthesized from the field's
146
+ * constraints.
147
+ *
148
+ * @param field - the field's info, from `to_object_schema_view`
149
+ * @param field_schema - the field's schema
143
150
  * @returns the string, or `null` when no candidate passes
144
151
  */
145
- export declare const generate_valid_string_param: (field: SchemaFieldInfo, field_schema: ValidationSchema) => string | null;
152
+ export declare const generate_valid_string_param: (field: SchemaFieldInfo, field_schema: AnySchema) => string | null;
146
153
  /**
147
154
  * The input a body is generated for: `null` for a void or null input
148
155
  * (`is_void_schema`, `is_null_schema`), which takes no body, else its object
149
156
  * view (`to_object_schema_view`).
150
157
  *
151
- * @param input_schema - a route's or action's input schema, Zod or `@fuzdev/fuz_schema`
158
+ * @param input_schema - a route's or action's input schema
152
159
  * @param label - names the input in the error
153
- * @throws Error naming `label` when the input is of neither library, or is
160
+ * @throws Error naming `label` when the input is no schema, or is
154
161
  * neither void, null, nor an object schema — no body can be generated for
155
162
  * it, and no body is not the same as one the generator can't build
156
163
  */
157
- export declare const to_body_input: (input_schema: ValidationSchema, label: string) => ObjectSchemaView | null;
164
+ export declare const to_body_input: (input_schema: AnySchema, label: string) => ObjectSchemaView | null;
158
165
  /**
159
166
  * The `Content-Type` a well-formed request to a route sends: `application/json`,
160
167
  * or `application/octet-stream` for a `raw_body` route. Every `POST` route
@@ -211,25 +218,25 @@ export type RouteParamValues = Readonly<Record<string, Readonly<Record<string, s
211
218
  * (`''`, `.`, `..`) is refused by name.
212
219
  *
213
220
  * @param path - the route's path template
214
- * @param params_schema - the route's params schema, a Zod or `@fuzdev/fuz_schema` object schema
221
+ * @param params_schema - the route's params schema, an object schema
215
222
  * @param param_values - the route's supplied param values by name, its entry of `RouteParamValues`
216
- * @throws Error when `params_schema` is no object schema, or of neither library;
223
+ * @throws Error when `params_schema` is no object schema, or no schema;
217
224
  * when `param_values` names no param of the path; when a supplied value is
218
225
  * `''`, `.` or `..`, or holds a lone surrogate, which can't be encoded; and
219
226
  * when a `{re}` param's value is one its pattern refuses, naming the route
220
227
  * and the param
221
228
  */
222
- export declare const resolve_valid_path: (path: string, params_schema?: ValidationSchema, param_values?: Readonly<Record<string, string>>) => string;
229
+ export declare const resolve_valid_path: (path: string, params_schema?: AnySchema, param_values?: Readonly<Record<string, string>>) => string;
223
230
  /**
224
231
  * Generate a valid request body for a route's or action's input schema.
225
232
  *
226
- * @param input_schema - the input schema, Zod or `@fuzdev/fuz_schema`
233
+ * @param input_schema - the input schema
227
234
  * @returns a generated body that passes the schema, or `undefined` for a void
228
235
  * or null input, which takes no body
229
- * @throws Error if the input is of neither library, or is neither void, null,
236
+ * @throws Error if the input is no schema, or is neither void, null,
230
237
  * nor an object schema, or if the generated body fails the input — catching
231
238
  * broken `generate_valid_value` logic early with the parse's issues instead
232
239
  * of a confusing 400 in downstream tests
233
240
  */
234
- export declare const generate_valid_body: (input_schema: ValidationSchema) => Record<string, unknown> | undefined;
241
+ export declare const generate_valid_body: (input_schema: AnySchema) => Record<string, unknown> | undefined;
235
242
  //# sourceMappingURL=schema_generators.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema_generators.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/schema_generators.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAsB7B,OAAO,EAKN,KAAK,eAAe,EACpB,MAAM,WAAW,CAAC;AASnB,OAAO,EAIN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,oBAAoB,GAAI,cAAc,gBAAgB,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAe3F,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,GAAI,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,MAAM,GAAG,IAWlF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,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