@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,15 +9,15 @@
9
9
  * which checks the handler's results against the route.
10
10
  *
11
11
  * Input/output schemas align with SAES `ActionSpec` conventions, and each is
12
- * a Zod or `@fuzdev/fuz_schema` schema (`ValidationSchema`):
13
- * - `input`: the request body schema (`z.null()` or `literal(null)` for no body)
12
+ * a `@fuzdev/fuz_schema` schema (`AnySchema`):
13
+ * - `input`: the request body schema (`literal(null)` for no body)
14
14
  * - `output`: the success response body schema
15
- * - a strict object for inputs (reject unknown keys): `z.strictObject()` or `object`
15
+ * - a strict object for inputs (reject unknown keys): `object`
16
16
  *
17
17
  * @module
18
18
  */
19
19
  import { DEV } from 'esm-env';
20
- import { is_schema } from '@fuzdev/fuz_schema/schema.ts';
20
+ import { is_schema, parse } from '@fuzdev/fuz_schema/schema.ts';
21
21
  import { get_schema_entries } from '@fuzdev/fuz_schema/introspect.ts';
22
22
  import { format_route_key } from './surface_query.js';
23
23
  import { is_db_checkout_error } from '../db/db_checkout_error.js';
@@ -28,7 +28,7 @@ import { is_null_schema } from './schema_helpers.js';
28
28
  import { is_json_response } from './route_error_check.js';
29
29
  import { dispatch_with_post_commit_rollback } from './pending_effects.js';
30
30
  import { assert_route_auth_acting_biconditional, assert_route_auth_invariants } from './auth_shape.js';
31
- import { assert_validation_schema, parse_any, to_wire_issues } from '../schema_issues.js';
31
+ import { assert_validation_schema, to_wire_issues } from '../schema_issues.js';
32
32
  /**
33
33
  * Define a route: its handler is checked against the route's `output`,
34
34
  * `errors`, `auth`, and `rate_limit` (`TypedRouteHandler`), and the spec is
@@ -151,11 +151,11 @@ const create_input_validation = (input_schema, method) => {
151
151
  if (typeof body !== 'object' || body === null || Array.isArray(body)) {
152
152
  return c.json({ error: ERROR_INVALID_JSON_BODY }, 400);
153
153
  }
154
- const result = parse_any(input_schema, body);
154
+ const result = parse(input_schema, body);
155
155
  if (!result.ok) {
156
156
  return c.json({
157
157
  error: ERROR_INVALID_REQUEST_BODY,
158
- issues: dev_only(() => to_wire_issues(result.issues, body))
158
+ issues: dev_only(() => to_wire_issues(result.issues))
159
159
  }, 400);
160
160
  }
161
161
  c.set('validated_input', result.value);
@@ -177,11 +177,11 @@ const create_params_validation = (params_schema) => {
177
177
  return [];
178
178
  const validate = async (c, next) => {
179
179
  const raw_params = c.req.param();
180
- const result = parse_any(params_schema, raw_params);
180
+ const result = parse(params_schema, raw_params);
181
181
  if (!result.ok) {
182
182
  return c.json({
183
183
  error: ERROR_INVALID_ROUTE_PARAMS,
184
- issues: dev_only(() => to_wire_issues(result.issues, raw_params))
184
+ issues: dev_only(() => to_wire_issues(result.issues))
185
185
  }, 400);
186
186
  }
187
187
  c.set('validated_params', result.value);
@@ -203,11 +203,11 @@ const create_query_validation = (query_schema) => {
203
203
  return [];
204
204
  const validate = async (c, next) => {
205
205
  const raw_query = c.req.query();
206
- const result = parse_any(query_schema, raw_query);
206
+ const result = parse(query_schema, raw_query);
207
207
  if (!result.ok) {
208
208
  return c.json({
209
209
  error: ERROR_INVALID_QUERY_PARAMS,
210
- issues: dev_only(() => to_wire_issues(result.issues, raw_query))
210
+ issues: dev_only(() => to_wire_issues(result.issues))
211
211
  }, 400);
212
212
  }
213
213
  c.set('validated_query', result.value);
@@ -223,8 +223,8 @@ const create_query_validation = (query_schema) => {
223
223
  * never throws. Non-2xx responses are the DEV error check's
224
224
  * (`create_dev_route_error_check`), which `create_app_server` mounts
225
225
  * outermost so it sees what every layer answers. Non-JSON responses (SSE,
226
- * binary) are skipped. The schema is Zod or `@fuzdev/fuz_schema`, parsed
227
- * with `parse_any`; the log carries the library's own issues. In production,
226
+ * binary) are skipped. The schema is parsed with `parse`; the log carries
227
+ * its issues. In production,
228
228
  * returns the handler unchanged.
229
229
  */
230
230
  const wrap_output_validation = (handler, output_schema, log) => {
@@ -247,7 +247,7 @@ const wrap_output_validation = (handler, output_schema, log) => {
247
247
  // clone() or json() failed on a response claiming application/json
248
248
  return response;
249
249
  }
250
- const result = parse_any(output_schema, body);
250
+ const result = parse(output_schema, body);
251
251
  if (!result.ok) {
252
252
  log.error(`Output schema mismatch: ${c.req.method} ${c.req.path}`, result.issues);
253
253
  }
@@ -399,10 +399,10 @@ const build_rest_error_body = (err) => {
399
399
  * registries (`compile_action_registry`) share the same helper with
400
400
  * `input` only — `ActionSpec` has no `query` shape.
401
401
  *
402
- * Every schema slot (`params`, `query`, `input`, `output`) must hold a Zod
403
- * or a `@fuzdev/fuz_schema` schema (`assert_validation_schema`), and every
402
+ * Every schema slot (`params`, `query`, `input`, `output`) must hold a
403
+ * `@fuzdev/fuz_schema` schema (`assert_validation_schema`), and every
404
404
  * `errors` entry an error definition (`rest_error`): anything else throws
405
- * naming the route and the slot. A `@fuzdev/fuz_schema` `params` or `query`
405
+ * naming the route and the slot. A `params` or `query`
406
406
  * must be an object schema (`get_schema_entries`), as the path params and
407
407
  * query string are an object: one that isn't throws naming the route.
408
408
  *
@@ -414,7 +414,7 @@ const build_rest_error_body = (err) => {
414
414
  * @param authorize - optional authorization phase; runs after the pre-authorization guards and before the post-authorization guards
415
415
  * @param db - used for transaction wrapping and `RouteContext`
416
416
  * @mutates `app`
417
- * @throws Error if two specs share the same `method` + `path` (each combination must be unique), if a schema slot holds a value of neither library or an `errors` entry is not a definition, if any spec violates a cross-axis auth invariant or the actor-acting biconditional, or if a fuz_schema `params` or `query` is not an object schema
417
+ * @throws Error if two specs share the same `method` + `path` (each combination must be unique), if a schema slot holds a value that is no schema or an `errors` entry is not a definition, if any spec violates a cross-axis auth invariant or the actor-acting biconditional, or if a `params` or `query` is not an object schema
418
418
  */
419
419
  export const apply_route_specs = (app, specs, resolve_auth_guards, log, db, authorize) => {
420
420
  const registered = new Set();
@@ -473,7 +473,7 @@ export const apply_route_specs = (app, specs, resolve_auth_guards, log, db, auth
473
473
  app.on(spec.method, [spec.path], ...content_type_check, ...params_validation, ...query_validation, ...pre_authorization_guards, ...authorization, ...post_authorization_guards, ...input_validation, handler);
474
474
  }
475
475
  };
476
- // throws unless every schema slot holds a Zod or fuz_schema schema and every
476
+ // throws unless every schema slot holds a fuz_schema schema and every
477
477
  // `errors` entry is a definition; `params` and `query` may be absent
478
478
  const assert_schema_slots = (spec, route_key) => {
479
479
  const label = `Route "${route_key}"`;
@@ -494,10 +494,9 @@ const assert_schema_slots = (spec, route_key) => {
494
494
  }
495
495
  }
496
496
  };
497
- // throws unless a fuz_schema `params` / `query` is an object schema under any
498
- // wrappers; a Zod one is a `z.ZodObject` by its type
497
+ // throws unless a `params` / `query` is an object schema under any wrappers
499
498
  const assert_object_slot = (schema, slot, route_key) => {
500
- if (schema === undefined || !is_schema(schema) || get_schema_entries(schema))
499
+ if (schema === undefined || get_schema_entries(schema))
501
500
  return;
502
501
  throw new Error(`Route "${route_key}": ${slot} is a @fuzdev/fuz_schema '${schema.kind}' schema, not an object schema`);
503
502
  };
@@ -7,29 +7,49 @@
7
7
  *
8
8
  * @module
9
9
  */
10
- import { type ParseAnyResult, type ValidationOutput, type ValidationSchema } from '../schema_issues.js';
10
+ import { type AnySchema, type Infer, type SchemaResult } from '@fuzdev/fuz_schema/schema.ts';
11
11
  /**
12
- * Check if a schema is exactly `z.null()`, or a `@fuzdev/fuz_schema`
13
- * `literal(null)`.
12
+ * What the testing generators read of one field of an object schema
13
+ * (`to_object_schema_view`, `testing/schema_generators.ts`).
14
+ */
15
+ export interface SchemaFieldInfo {
16
+ /** The field's key. */
17
+ name: string;
18
+ /**
19
+ * The innermost kind's name: `'string'`, `'number'`, `'boolean'`,
20
+ * `'array'`, `'literal'`, and so on, with an object of any strictness as
21
+ * `'object'`, a `literal(null)` as `'null'`, a `literal(undefined)`
22
+ * (`s.void`) as `'void'`, a `one_of` as `'enum'`, and a `variant` as
23
+ * `'union'`.
24
+ */
25
+ base_type: string;
26
+ /** Whether the key must be present: no `optional` layer. */
27
+ required: boolean;
28
+ /** Whether the parse fills the key in when it is missing. */
29
+ has_default: boolean;
30
+ /** Whether a wrapping layer accepts `null`. */
31
+ nullable: boolean;
32
+ }
33
+ /**
34
+ * Check if a schema is exactly `literal(null)`.
14
35
  *
15
36
  * Reads the schema's kind rather than parsing `null`, to avoid false
16
- * positives from `z.nullable(z.string())` or similar schemas that accept
17
- * null but also accept other values.
37
+ * positives from `nullable(string)` or similar schemas that accept null but
38
+ * also accept other values.
18
39
  */
19
- export declare const is_null_schema: (schema: ValidationSchema) => boolean;
40
+ export declare const is_null_schema: (schema: AnySchema) => boolean;
20
41
  /**
21
- * Check if a schema is exactly `z.void()`, or a `@fuzdev/fuz_schema`
22
- * `literal(undefined)` (what its `s.void` is, `meta` copies included).
42
+ * Check if a schema is exactly `literal(undefined)` (what `s.void` is,
43
+ * `meta` copies included).
23
44
  *
24
45
  * RPC action specs use a void schema to declare a parameterless method —
25
46
  * JSON-RPC 2.0 forbids `params: null` (params must be omitted or be a
26
47
  * Structured value), so void is the correct schema for "no params" and the
27
48
  * dispatcher maps absent params to `undefined` for these specs. Like
28
49
  * `is_null_schema`, it reads the schema's kind rather than parsing
29
- * `undefined`, so an optional schema is not void. `z.undefined()` is not
30
- * void either.
50
+ * `undefined`, so an optional schema is not void.
31
51
  */
32
- export declare const is_void_schema: (schema: ValidationSchema) => boolean;
52
+ export declare const is_void_schema: (schema: AnySchema) => boolean;
33
53
  /**
34
54
  * Normalize the raw `params` of a void input (`is_void_schema`): an absent
35
55
  * `params`, an empty object, and the `null` a GET `?params=null` parses to
@@ -49,18 +69,18 @@ export declare const is_void_schema: (schema: ValidationSchema) => boolean;
49
69
  export declare const to_void_params: (raw_params: unknown) => unknown;
50
70
  /**
51
71
  * Normalize the raw `params` of an RPC call for `input` to validate: for a
52
- * void input (`is_void_schema`, Zod or fuz_schema), `to_void_params`; for
72
+ * void input (`is_void_schema`), `to_void_params`; for
53
73
  * any other input, an absent or `null` `params` reads as `{}`, so an
54
74
  * all-optional object input accepts a call that omits them. Every receiving
55
75
  * end — the server dispatch (`perform_action`) and a peer receiving a
56
76
  * request or notification (`ActionDispatcher`) — reads params through this,
57
77
  * so a peer is never stricter than the server.
58
78
  *
59
- * @param input - the action's input schema, Zod or fuz_schema
79
+ * @param input - the action's input schema
60
80
  * @param raw_params - the call's `params` as parsed off the wire
61
- * @returns the value the input parse (`parse_any`) reads
81
+ * @returns the value the input parse (`parse`) reads
62
82
  */
63
- export declare const to_input_params: (input: ValidationSchema, raw_params: unknown) => unknown;
83
+ export declare const to_input_params: (input: AnySchema, raw_params: unknown) => unknown;
64
84
  /**
65
85
  * Check whether a parsed JSON value holds an own `__proto__` key in any
66
86
  * object, at any depth — what the dispatcher refuses in a request's `params`
@@ -83,9 +103,9 @@ export declare const to_input_params: (input: ValidationSchema, raw_params: unkn
83
103
  */
84
104
  export declare const json_has_own_proto_key: (value: unknown) => boolean;
85
105
  /**
86
- * `parse_any(schema, value)`, except that keys the schema doesn't declare are
106
+ * `parse(schema, value)`, except that keys the schema doesn't declare are
87
107
  * dropped rather than refused — the forward-compatible read of a payload a
88
- * remote authored. Takes a Zod or a `@fuzdev/fuz_schema` schema.
108
+ * remote authored.
89
109
  *
90
110
  * Output schemas are strict so the server's DEV output validation catches a
91
111
  * handler leaking fields it shouldn't. The receiving side, though, is often
@@ -98,56 +118,48 @@ export declare const json_has_own_proto_key: (value: unknown) => boolean;
98
118
  * never mutated. This matches serde's default on the Rust spine, which
99
119
  * ignores unknown fields.
100
120
  *
101
- * A fuz_schema parse reports at most a hundred issues, so a pass that only
121
+ * A parse reports at most a hundred issues, so a pass that only
102
122
  * deleted the reported keys would take a parse per hundred unknown keys,
103
123
  * quadratic in a payload of many. So after the first parse that reports
104
- * unknown keys, one schema-guided pass deletes every key a strict fuz_schema
105
- * `object` doesn't name anywhere the schema reaches — object entries, array
106
- * items, record values, the `variant` option the discriminator picks — and
107
- * the next parse usually succeeds. A key under a fuz_schema `union` is never
124
+ * unknown keys, one schema-guided pass deletes every key a strict `object`
125
+ * doesn't name anywhere the schema reaches — object entries, array items,
126
+ * record values, the `variant` option the discriminator picks — and the next
127
+ * parse usually succeeds. A key under a `union` is never
108
128
  * stripped: which option will match isn't known, and the union fails as one
109
129
  * issue of its own. A later `pipe` stage is stripped only as reported, as the
110
130
  * pass reads only a pipe's first schema, so keys a later stage refuses that
111
131
  * the first names still go a hundred a parse. A pass that finds
112
132
  * nothing to strip ends it, and the passes are capped at
113
- * `UNKNOWN_KEY_PASSES_MAX` for both libraries, past which the last failure is
133
+ * `UNKNOWN_KEY_PASSES_MAX`, past which the last failure is
114
134
  * returned, so the work stays linear in the payload whatever its shape.
115
135
  *
116
- * Unions differ by library. A Zod `z.union` of strict objects reports the
117
- * unknown key itself (`unrecognized_keys` on the object), so it is stripped,
118
- * as are a `z.discriminatedUnion`'s matched-branch keys. A fuz_schema `union`
119
- * reports one issue of its own, so a key inside one is not stripped and the
120
- * parse fails; a `variant` reports its matched option's issues, so those are.
136
+ * A `union` reports one issue of its own, so a key inside one is not
137
+ * stripped and the parse fails; a `variant` reports its matched option's
138
+ * issues, so those are.
121
139
  *
122
140
  * Used for a response's `result` (`ActionEvent`) and for a peer's reply to a
123
141
  * server-initiated request (`peer/ping`).
124
142
  *
125
- * @param schema - the declared shape, Zod or fuz_schema
143
+ * @param schema - the declared shape
126
144
  * @param value - the remote-authored payload
127
145
  * @returns the parse result, with undeclared keys dropped on success
128
146
  */
129
- export declare const safe_parse_dropping_unknown_keys: <T extends ValidationSchema>(schema: T, value: unknown) => ParseAnyResult<ValidationOutput<T>>;
147
+ export declare const safe_parse_dropping_unknown_keys: <T extends AnySchema>(schema: T, value: unknown) => SchemaResult<Infer<T>>;
130
148
  /**
131
149
  * The most parses after the first that `safe_parse_dropping_unknown_keys`
132
150
  * runs, each after stripping the keys the one before refused.
133
151
  */
134
152
  export declare const UNKNOWN_KEY_PASSES_MAX = 4;
135
153
  /**
136
- * Check if a schema is a strict object: `z.strictObject()`, or a
137
- * `@fuzdev/fuz_schema` `object` (which refuses unknown keys, where
138
- * `strip_object` drops them and `loose_object` keeps them).
139
- *
140
- * Strict Zod objects set `catchall` to `ZodNever` to reject unknown keys.
141
- * Regular `z.object()` has `catchall: undefined` (strips unknown keys in Zod 4).
142
- * A refined strict object reads strict in both libraries: Zod keeps a
143
- * `.refine()` on the `ZodObject`, and a fuz_schema `pipe` is read through to
144
- * its first schema when no stage of it is a `transform` (`message`, `flavor`,
145
- * `brand` and `meta` keep the kind they wrap). A transformed object is not a
146
- * strict object in either: Zod's is a `ZodPipe`. The two libraries differ on a
147
- * pipe without a transform: Zod's `O.pipe(O)` is a `ZodPipe` and reads not
148
- * strict, where fuz_schema's `pipe(F, F)` reads strict through to `F`.
154
+ * Check if a schema is a strict object: an `object` (which refuses unknown
155
+ * keys, where `strip_object` drops them and `loose_object` keeps them).
156
+ *
157
+ * A refined strict object reads strict: a `pipe` is read through to its first
158
+ * schema when no stage of it is a `transform` (`message`, `flavor`, `brand`
159
+ * and `meta` keep the kind they wrap), so `pipe(O, O)` reads strict through
160
+ * to `O`. A transformed object is not a strict object.
149
161
  */
150
- export declare const is_strict_object_schema: (schema: ValidationSchema) => boolean;
162
+ export declare const is_strict_object_schema: (schema: AnySchema) => boolean;
151
163
  /** Options of `schema_to_surface`. */
152
164
  export interface SchemaToSurfaceOptions {
153
165
  /**
@@ -161,16 +173,16 @@ export interface SchemaToSurfaceOptions {
161
173
  /** Names the schema in a thrown error, e.g. `POST /api/thing input`. */
162
174
  source?: string;
163
175
  /**
164
- * Called with the library's message when part of the schema has no JSON
176
+ * Called with the emitter's message when part of the schema has no JSON
165
177
  * Schema form and is left out or written as `{}` there.
166
178
  */
167
179
  on_unrepresentable?: (message: string) => void;
168
180
  }
169
181
  /**
170
- * Convert a Zod or `@fuzdev/fuz_schema` schema to its JSON Schema for the
171
- * surface, with `$schema` and `default` stripped at every depth.
182
+ * Convert a `@fuzdev/fuz_schema` schema to its JSON Schema for the surface
183
+ * (`to_json_schema`), with `$schema` and `default` stripped at every depth.
172
184
  *
173
- * A value of neither library throws first (`assert_validation_schema`),
185
+ * A value that is no schema throws first (`assert_validation_schema`),
174
186
  * naming `options.source`, so a slot that surface generation reads before
175
187
  * any registration does — a route's, an event's `params`, a `ws_endpoints`
176
188
  * action's — fails server assembly naming the slot, as registration refuses
@@ -178,32 +190,28 @@ export interface SchemaToSurfaceOptions {
178
190
  * write.
179
191
  *
180
192
  * Returns `null` for a null schema (`is_null_schema`) and a void schema
181
- * (`is_void_schema`), in either library: no body, no params. Any other
182
- * schema is written with its library's emitter (`to_json_schema` for fuz_schema, `z.toJSONSchema`
183
- * for Zod) on the side `options.io` names. A part JSON Schema can't say (a
184
- * transform on the output side, a `z.custom()`, a fuz_schema `check`) is left
185
- * out or written as `{}` (a `pipe(string, check(…))` writes as
186
- * `{type: 'string'}`), and `options.on_unrepresentable` hears the library's
187
- * message, so the surface describes what it can and records the gap.
193
+ * (`is_void_schema`): no body, no params. Any other schema is written on the
194
+ * side `options.io` names. A part JSON Schema can't say (a transform on the
195
+ * output side, a `check`) is left out or written as `{}` (a
196
+ * `pipe(string, check(…))` writes as `{type: 'string'}`), and
197
+ * `options.on_unrepresentable` hears the emitter's message, so the surface
198
+ * describes what it can and records the gap.
188
199
  *
189
200
  * It never answers `null` for a schema it failed to write, as that would
190
201
  * read as "takes no input" and drop the schema out of every suite reading the
191
202
  * surface: a schema with no JSON Schema form at all (`{}` where the schema
192
- * isn't `z.unknown()` or `z.any()`), and one either emitter refuses outright
193
- * (a fuz_schema entry named like a member of `Object.prototype`, metadata
194
- * that isn't JSON), throw. So an output whose root is a transform (a Zod
195
- * `.transform()`, a fuz_schema `pipe(object(…), transform(…))`), a
196
- * `z.custom()`, or a `z.date()` throws, and since `generate_app_surface`
197
- * runs at server assembly, a route or action declaring one fails the server
198
- * at boot. That includes `z.unknown().transform(f)`, though `{}` would
199
- * describe it: the output side of a transform is unknown, whatever its input.
200
- *
201
- * @param schema - the schema to describe, Zod or fuz_schema
203
+ * isn't `unknown`), and one the emitter refuses outright (an entry named like
204
+ * a member of `Object.prototype`, metadata that isn't JSON), throw. So an
205
+ * output whose root is a transform (`pipe(object(…), transform(…))`) throws,
206
+ * and since `generate_app_surface` runs at server assembly, a route or action
207
+ * declaring one fails the server at boot.
208
+ *
209
+ * @param schema - the schema to describe
202
210
  * @param options - the side to describe, the schema's name for errors, and a listener for gaps
203
211
  * @returns the JSON Schema, or `null` for a null or void schema
204
- * @throws Error naming `options.source` when the value is of neither library, when the schema can't be written, or when nothing of it can
212
+ * @throws Error naming `options.source` when the value is no schema, when the schema can't be written, or when nothing of it can
205
213
  */
206
- export declare const schema_to_surface: (schema: ValidationSchema, options?: SchemaToSurfaceOptions) => unknown;
214
+ export declare const schema_to_surface: (schema: AnySchema, options?: SchemaToSurfaceOptions) => unknown;
207
215
  /**
208
216
  * Check if a middleware path pattern applies to a route path.
209
217
  *
@@ -1 +1 @@
1
- {"version":3,"file":"schema_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/schema_helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,OAAO,EAIN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,gBAAgB,KAAG,OAEc,CAAC;AAEzE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,gBAAgB,KAAG,OAEmB,CAAC;AAE9E;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,GAAI,YAAY,OAAO,KAAG,OAUpD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,gBAAgB,EAAE,YAAY,OAAO,KAAG,OACP,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,OAAO,KAAG,OAavD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,gCAAgC,GAAI,CAAC,SAAS,gBAAgB,EAC1E,QAAQ,CAAC,EACT,OAAO,OAAO,KACZ,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC,CA0BpC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AA8FxC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,uBAAuB,GAAI,QAAQ,gBAAgB,KAAG,OAGW,CAAC;AAc/E,sCAAsC;AACtC,MAAM,WAAW,sBAAsB;IACtC;;;;;;OAMG;IACH,EAAE,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IACxB,wEAAwE;IACxE,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