@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
@@ -1,149 +0,0 @@
1
- /**
2
- * `@fuzdev/fuz_schema` twins of the Zod `bounded_string`, `Username`,
3
- * `Email`, `Uuid`, `UuidWithDefault`, `FactHashSchema` (`primitive_schemas.ts`), and
4
- * `ActingActor` (`http/auth_shape.ts`), under the same names, for schemas
5
- * written in fuz_schema; `UsernameCanonical`, the username an output carries;
6
- * `UsernameProvided`, the username login and lookup take; `Timestamp`, a
7
- * timestamp on the wire; and `Blake3Hash`, a BLAKE3 hex hash. The last four
8
- * have no Zod twin.
9
- *
10
- * The output type is shared: the Zod `Uuid` outputs fuz_schema's
11
- * `Branded<string, 'Uuid'>` too, and both `FactHashSchema`s output fuz_util's
12
- * `FactHash`, so a value parsed by either twin goes where the other's is taken.
13
- *
14
- * Both twins have one grammar, RFC 9562's read case-insensitively as its §4
15
- * says, the max UUID included, and the Rust spine's: every input gets the same
16
- * verdict and output from both, and their JSON Schema is the same.
17
- *
18
- * The twins are `@nodocs` while the Zod schemas of the same names stay, as
19
- * the docs build refuses two exports of one name.
20
- *
21
- * @module
22
- */
23
- import { meta } from '@fuzdev/fuz_schema/meta.ts';
24
- import { brand, check, iso_datetime, max_length, message, min_length, optional, pipe, regex, string, to_lower_case, transform, uuid, with_default_fn } from '@fuzdev/fuz_schema/schema.ts';
25
- import { FACT_HASH_EXACT } from '@fuzdev/fuz_util/hash_schemas.ts';
26
- import { create_uuid, EMAIL_LENGTH_MAX, EMAIL_LENGTH_MESSAGE, EMAIL_REGEX, is_email_within_length_max, USERNAME_LENGTH_MAX, USERNAME_LENGTH_MIN, USERNAME_PROVIDED_LENGTH_MAX, USERNAME_REGEX } from './primitive_schemas.js';
27
- /**
28
- * A string schema whose length is bounded in UTF-16 code units, the twin of
29
- * the Zod `bounded_string`: fuz_schema's `min_length` / `max_length` read
30
- * `String.length`, the unit the Rust spine counts too, so no check beside them
31
- * is needed. Its JSON Schema carries `minLength` / `maxLength` as the Zod
32
- * one's does; `max_message` replaces fuz_schema's message on the over-`max`
33
- * issue.
34
- *
35
- * @param options - the bounds, in UTF-16 code units, and the max message
36
- * @returns the bounded string schema
37
- * @nodocs
38
- */
39
- export const bounded_string = (options) => {
40
- const { min, max, max_message } = options;
41
- const max_step = max_message === undefined ? max_length(max) : message(max_length(max), max_message);
42
- return min === undefined ? pipe(string, max_step) : pipe(string, min_length(min), max_step);
43
- };
44
- /**
45
- * Username for account creation, the twin of the Zod `Username`: the same
46
- * bounds and grammar, output in lowercase. Every input gets the same verdict
47
- * and output from both; a string outside the bounds and off the grammar gets
48
- * the length issue alone, where Zod adds the grammar issue after it.
49
- *
50
- * @nodocs
51
- */
52
- export const Username = pipe(bounded_string({ min: USERNAME_LENGTH_MIN, max: USERNAME_LENGTH_MAX }), regex(USERNAME_REGEX), to_lower_case);
53
- /**
54
- * A username's canonical grammar, `USERNAME_REGEX` in lowercase: a lowercase
55
- * letter, then lowercase letters, digits, `_` or `-`, ending in a lowercase
56
- * letter or digit. What `Username` outputs, and what an `account` row holds
57
- * (its `account_username_lowercase` CHECK).
58
- */
59
- export const USERNAME_CANONICAL_REGEX = /^[a-z][0-9a-z_-]*[0-9a-z]$/;
60
- /**
61
- * A username as an account row holds it, the `username` of an output: the
62
- * bounds of `Username` and `USERNAME_CANONICAL_REGEX`, no transform. A
63
- * username in any other case fails, where the Zod `Username` lowercased it.
64
- */
65
- export const UsernameCanonical = pipe(bounded_string({ min: USERNAME_LENGTH_MIN, max: USERNAME_LENGTH_MAX }), regex(USERNAME_CANONICAL_REGEX));
66
- /**
67
- * Username submitted for login or lookup — minimal validation, for
68
- * forward-compatibility if the creation grammar changes: at least one and at
69
- * most `USERNAME_PROVIDED_LENGTH_MAX` UTF-16 code units, measured before
70
- * trimming, holding a character that isn't whitespace.
71
- *
72
- * Canonicalized to `.trim().toLowerCase()` at parse time, so login's
73
- * per-account rate-limit key and its lookup see one value whatever the casing
74
- * or surrounding whitespace, as `Username` canonicalizes what is stored.
75
- *
76
- * A whitespace-only identifier is refused, not canonicalized to `""` and left
77
- * to fall through to a lookup-miss 401: an empty identifier is malformed
78
- * input, not a wrong credential, and the Rust spine's `account_login` refuses
79
- * it too. JS `\s` is exactly the set `trim` removes (ECMA-262's WhiteSpace and
80
- * LineTerminator), so the `regex` ahead of the transform refuses what would
81
- * trim to nothing.
82
- */
83
- export const UsernameProvided = pipe(bounded_string({ min: 1, max: USERNAME_PROVIDED_LENGTH_MAX }), message(regex(/\S/), 'Username must not be empty after trimming whitespace'), transform((s) => s.trim().toLowerCase()));
84
- /**
85
- * Email validation, the twin of the Zod `Email`: `EMAIL_REGEX` and at most
86
- * `EMAIL_LENGTH_MAX` UTF-8 bytes, no transform. The `max_length` ahead of the
87
- * grammar refuses a string past the bound in UTF-16 code units, which is past
88
- * it in bytes too, before the regex reads it, and the `check` after it the
89
- * multibyte address within the units but past the bytes, both with
90
- * `EMAIL_LENGTH_MESSAGE`. Every input gets the same verdict and output from
91
- * both; a string past the bound in code units gets the length issue as a
92
- * `max_length`, where Zod gives a `check`, and one within the bound in code
93
- * units but past it in bytes and off the grammar gets the grammar issue, where
94
- * Zod gives the length one.
95
- *
96
- * @nodocs
97
- */
98
- export const Email = pipe(string, message(max_length(EMAIL_LENGTH_MAX), EMAIL_LENGTH_MESSAGE), regex(EMAIL_REGEX), message(check(is_email_within_length_max), EMAIL_LENGTH_MESSAGE));
99
- /**
100
- * Branded UUID schema: a UUID of RFC 9562 in either case, output in
101
- * lowercase, the form Postgres renders a `uuid` in and every id the server
102
- * mints. The brand goes outside the `to_lower_case`, which outputs a new
103
- * string.
104
- *
105
- * @nodocs
106
- */
107
- export const Uuid = brand(pipe(string, uuid, to_lower_case), 'Uuid');
108
- /**
109
- * `Uuid` that defaults to a fresh `create_uuid()` when the input is `undefined`.
110
- *
111
- * @nodocs
112
- */
113
- export const UuidWithDefault = with_default_fn(Uuid, create_uuid);
114
- /**
115
- * A timestamp on the wire: a date and time of RFC 3339 in UTC, fuz_schema's
116
- * `iso_datetime`, which both spines' `YYYY-MM-DDTHH:MM:SSZ`
117
- * (`iso8601_timestamp_column`) and a `toISOString()` stamp satisfy. Not
118
- * branded, unlike the Zod `Datetime`.
119
- */
120
- export const Timestamp = pipe(string, iso_datetime);
121
- /**
122
- * A `blake3:`-prefixed fact hash on the wire, the twin of the Zod
123
- * `FactHashSchema`: `FACT_HASH_EXACT`, its output fuz_util's `FactHash`, which
124
- * `fact_hash_bytes`, `fact_hash_stream`, and `FactStore` take. The twins agree
125
- * on every input, and their JSON Schema is the same `pattern`.
126
- *
127
- * @nodocs
128
- */
129
- export const FactHashSchema = brand(pipe(string, regex(FACT_HASH_EXACT)), 'FactHash');
130
- /** A BLAKE3 hex hash's grammar: 64 lowercase hex characters (256-bit output). */
131
- export const BLAKE3_HASH_REGEX = /^[0-9a-f]{64}$/;
132
- /** The message of a string off `BLAKE3_HASH_REGEX`. */
133
- export const BLAKE3_HASH_MESSAGE = 'Expected a 64-character lowercase hex blake3 hash';
134
- /**
135
- * A BLAKE3 hex hash: `BLAKE3_HASH_REGEX`, whose issue carries
136
- * `BLAKE3_HASH_MESSAGE`. A value that is no string gets fuz_schema's message.
137
- */
138
- export const Blake3Hash = pipe(string, message(regex(BLAKE3_HASH_REGEX), BLAKE3_HASH_MESSAGE));
139
- /** The `description` both `ActingActor` twins carry. */
140
- export const ACTING_ACTOR_DESCRIPTION = 'Actor on the authenticated account that this request acts as. Omit on single-actor accounts; required on multi-actor.';
141
- /**
142
- * The `acting` field of an input that needs the caller's acting actor, the
143
- * twin of `ActingActor` in `http/auth_shape.ts`, whose doc has the resolution
144
- * rules. The dispatcher finds either twin by reference, so an input declares
145
- * this export, not a copy of it.
146
- *
147
- * @nodocs
148
- */
149
- export const ActingActor = meta(optional(Uuid), { description: ACTING_ACTOR_DESCRIPTION });
package/dist/zod.d.ts DELETED
@@ -1,101 +0,0 @@
1
- /**
2
- * Zod schema introspection utilities.
3
- *
4
- * Generic helpers for walking, unwrapping, and extracting field info from Zod schemas.
5
- * Used by adversarial input testing, test-data generation, and auth-shape
6
- * checks.
7
- *
8
- * @module
9
- */
10
- import type { z } from 'zod';
11
- /**
12
- * Unwrap Zod wrappers (optional, default, nullable, pipe, transform)
13
- * to get the base type definition.
14
- *
15
- * @returns the innermost non-wrapper type definition
16
- */
17
- export declare const zod_unwrap_def: (schema: z.ZodType) => z.core.$ZodTypeDef;
18
- /**
19
- * Get the base type name for a Zod schema, unwrapping all wrappers.
20
- *
21
- * @returns base type name (e.g. `'string'`, `'object'`, `'uuid'`)
22
- */
23
- export declare const zod_get_base_type: (schema: z.ZodType) => string;
24
- /**
25
- * Unwrap a schema through every wrapper type (optional, nullable, default,
26
- * transform, pipe, prefault) to reach the innermost schema. Like `zod_unwrap_def`
27
- * but returns the schema (so callers can `.shape`, `instanceof`-check, etc.)
28
- * instead of the def.
29
- *
30
- * @returns the innermost non-wrapper schema
31
- */
32
- export declare const zod_get_innermost_type: (schema: z.ZodType) => z.ZodType;
33
- /**
34
- * Every layer of a schema, from the schema itself through each wrapper
35
- * (optional, nullable, default, transform, pipe, prefault) to the innermost
36
- * non-wrapper — for reading `.meta()` a wrapper does not carry over from the
37
- * schema it wraps.
38
- *
39
- * @returns the layers, outermost first, ending at `zod_get_innermost_type(schema)`
40
- */
41
- export declare const zod_get_schema_layers: (schema: z.ZodType) => Array<z.ZodType>;
42
- /**
43
- * Get all property keys from an object schema, unwrapping wrappers.
44
- * Returns an empty array if the innermost type is not an object.
45
- *
46
- * @param schema - Zod schema (typically a `ZodObject` with possible wrappers)
47
- */
48
- export declare const zod_get_schema_keys: <T extends z.ZodType>(schema: T) => Array<keyof z.infer<T> & string>;
49
- /**
50
- * Get the field schema for a key in an object schema, returning `undefined` if
51
- * the schema is not an object or the key is not one of its own fields (a name
52
- * the shape only inherits, such as `constructor` or `toString`, included).
53
- *
54
- * @param schema - Zod schema (typically a `ZodObject` with possible wrappers)
55
- * @param key - the property name
56
- * @returns the field's schema, or `undefined`
57
- */
58
- export declare const zod_maybe_get_field_schema: (schema: z.ZodType, key: string) => z.ZodType | undefined;
59
- /**
60
- * Get the field schema for a key in an object schema.
61
- *
62
- * @param schema - Zod schema (typically a `ZodObject` with possible wrappers)
63
- * @throws Error if the schema is not an object or the key is missing
64
- */
65
- export declare const zod_get_field_schema: (schema: z.ZodType, key: string) => z.ZodType;
66
- /**
67
- * Unwrap a schema to find the inner `ZodObject`, or `null` if not an object schema.
68
- * Handles wrappers like `z.strictObject({...}).default({...})`.
69
- */
70
- export declare const zod_unwrap_to_object: (schema: z.ZodType) => z.ZodObject | null;
71
- /**
72
- * What the testing generators read of one field of an object schema, of
73
- * either library: `zod_extract_fields` reads a `ZodObject`'s, and
74
- * `to_object_schema_view` (`testing/schema_generators.ts`) a schema's of
75
- * either library.
76
- */
77
- export interface SchemaFieldInfo {
78
- /** The field's key. */
79
- name: string;
80
- /**
81
- * The innermost type's name in Zod's vocabulary (`zod_get_base_type`):
82
- * `'string'`, `'number'`, `'boolean'`, `'array'`, `'object'`, `'null'`,
83
- * `'void'`, `'union'`, `'literal'`, `'enum'`, and so on. A
84
- * `@fuzdev/fuz_schema` field reads its innermost kind, an object of any
85
- * strictness as `'object'`, a `literal(null)` as `'null'`, a
86
- * `literal(undefined)` (`s.void`) as `'void'`, a `one_of` as `'enum'`, and
87
- * a `variant` as `'union'`.
88
- */
89
- base_type: string;
90
- /** Whether the key must be present: no outermost `.optional()` in Zod, no `optional` layer in fuz_schema. */
91
- required: boolean;
92
- /** Whether the parse fills the key in when it is missing. */
93
- has_default: boolean;
94
- /** Whether a wrapping layer accepts `null`. */
95
- nullable: boolean;
96
- }
97
- /**
98
- * Extract field metadata from a Zod object schema.
99
- */
100
- export declare const zod_extract_fields: (schema: z.ZodObject) => Array<SchemaFieldInfo>;
101
- //# sourceMappingURL=zod.d.ts.map
package/dist/zod.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"zod.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/zod.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgC7B;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,CAAC,CAAC,IAAI,CAAC,WAOzD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,MAAqC,CAAC;AAgC5F;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,CAAC,CAAC,OAM5D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,KAAK,CAAC,CAAC,CAAC,OAAO,CAUxE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EACtD,QAAQ,CAAC,KACP,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAGjC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,GACtC,QAAQ,CAAC,CAAC,OAAO,EACjB,KAAK,MAAM,KACT,CAAC,CAAC,OAAO,GAAG,SAGd,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,CAAC,CAAC,OAAO,EAAE,KAAK,MAAM,KAAG,CAAC,CAAC,OAIvE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,CAAC,CAAC,SAAS,GAAG,IAUtE,CAAC;AAIF;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC/B,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;;;OAQG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,6GAA6G;IAC7G,QAAQ,EAAE,OAAO,CAAC;IAClB,6DAA6D;IAC7D,WAAW,EAAE,OAAO,CAAC;IACrB,+CAA+C;IAC/C,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,CAAC,CAAC,SAAS,KAAG,KAAK,CAAC,eAAe,CAa7E,CAAC"}
package/dist/zod.js DELETED
@@ -1,195 +0,0 @@
1
- /**
2
- * Zod schema introspection utilities.
3
- *
4
- * Generic helpers for walking, unwrapping, and extracting field info from Zod schemas.
5
- * Used by adversarial input testing, test-data generation, and auth-shape
6
- * checks.
7
- *
8
- * @module
9
- */
10
- //
11
- // Schema Introspection
12
- //
13
- /**
14
- * Unwrap nested schema types (optional, default, nullable, etc).
15
- *
16
- * @returns inner schema if wrapped, undefined otherwise
17
- */
18
- const zod_to_subschema = (def) => {
19
- if ('innerType' in def) {
20
- return def.innerType;
21
- }
22
- else if ('in' in def) {
23
- return def.in;
24
- }
25
- else if ('schema' in def) {
26
- return def.schema;
27
- }
28
- return undefined;
29
- };
30
- /** Zod wrapper type names that `zod_unwrap_def` traverses through. */
31
- const ZOD_WRAPPER_TYPES = new Set([
32
- 'optional',
33
- 'nullable',
34
- 'default',
35
- 'transform',
36
- 'pipe',
37
- 'prefault'
38
- ]);
39
- /**
40
- * Unwrap Zod wrappers (optional, default, nullable, pipe, transform)
41
- * to get the base type definition.
42
- *
43
- * @returns the innermost non-wrapper type definition
44
- */
45
- export const zod_unwrap_def = (schema) => {
46
- const { def } = schema;
47
- if (ZOD_WRAPPER_TYPES.has(def.type)) {
48
- const sub = zod_to_subschema(def);
49
- if (sub)
50
- return zod_unwrap_def(sub);
51
- }
52
- return def;
53
- };
54
- /**
55
- * Get the base type name for a Zod schema, unwrapping all wrappers.
56
- *
57
- * @returns base type name (e.g. `'string'`, `'object'`, `'uuid'`)
58
- */
59
- export const zod_get_base_type = (schema) => zod_unwrap_def(schema).type;
60
- /**
61
- * Check if a schema is optional at the outermost level.
62
- */
63
- const zod_is_optional = (schema) => schema.def.type === 'optional';
64
- /**
65
- * Check if a schema accepts null at any wrapping level.
66
- */
67
- const zod_is_nullable = (schema) => {
68
- const { def } = schema;
69
- if (def.type === 'nullable')
70
- return true;
71
- if (ZOD_WRAPPER_TYPES.has(def.type)) {
72
- const sub = zod_to_subschema(def);
73
- if (sub)
74
- return zod_is_nullable(sub);
75
- }
76
- return false;
77
- };
78
- /**
79
- * Check if a schema has a default value at any wrapping level.
80
- * Distinguishes "no default" from "default is undefined".
81
- */
82
- const zod_has_default = (schema) => {
83
- const { def } = schema;
84
- if ('defaultValue' in def)
85
- return true;
86
- const sub = zod_to_subschema(def);
87
- if (sub)
88
- return zod_has_default(sub);
89
- return false;
90
- };
91
- /**
92
- * Unwrap a schema through every wrapper type (optional, nullable, default,
93
- * transform, pipe, prefault) to reach the innermost schema. Like `zod_unwrap_def`
94
- * but returns the schema (so callers can `.shape`, `instanceof`-check, etc.)
95
- * instead of the def.
96
- *
97
- * @returns the innermost non-wrapper schema
98
- */
99
- export const zod_get_innermost_type = (schema) => {
100
- if (ZOD_WRAPPER_TYPES.has(schema.def.type)) {
101
- const sub = zod_to_subschema(schema.def);
102
- if (sub)
103
- return zod_get_innermost_type(sub);
104
- }
105
- return schema;
106
- };
107
- /**
108
- * Every layer of a schema, from the schema itself through each wrapper
109
- * (optional, nullable, default, transform, pipe, prefault) to the innermost
110
- * non-wrapper — for reading `.meta()` a wrapper does not carry over from the
111
- * schema it wraps.
112
- *
113
- * @returns the layers, outermost first, ending at `zod_get_innermost_type(schema)`
114
- */
115
- export const zod_get_schema_layers = (schema) => {
116
- const layers = [schema];
117
- let s = schema;
118
- while (ZOD_WRAPPER_TYPES.has(s.def.type)) {
119
- const sub = zod_to_subschema(s.def);
120
- if (!sub)
121
- break;
122
- layers.push(sub);
123
- s = sub;
124
- }
125
- return layers;
126
- };
127
- /**
128
- * Get all property keys from an object schema, unwrapping wrappers.
129
- * Returns an empty array if the innermost type is not an object.
130
- *
131
- * @param schema - Zod schema (typically a `ZodObject` with possible wrappers)
132
- */
133
- export const zod_get_schema_keys = (schema) => {
134
- const obj = zod_unwrap_to_object(schema);
135
- return obj ? Object.keys(obj.shape) : [];
136
- };
137
- /**
138
- * Get the field schema for a key in an object schema, returning `undefined` if
139
- * the schema is not an object or the key is not one of its own fields (a name
140
- * the shape only inherits, such as `constructor` or `toString`, included).
141
- *
142
- * @param schema - Zod schema (typically a `ZodObject` with possible wrappers)
143
- * @param key - the property name
144
- * @returns the field's schema, or `undefined`
145
- */
146
- export const zod_maybe_get_field_schema = (schema, key) => {
147
- const shape = zod_unwrap_to_object(schema)?.shape;
148
- return shape && Object.hasOwn(shape, key) ? shape[key] : undefined;
149
- };
150
- /**
151
- * Get the field schema for a key in an object schema.
152
- *
153
- * @param schema - Zod schema (typically a `ZodObject` with possible wrappers)
154
- * @throws Error if the schema is not an object or the key is missing
155
- */
156
- export const zod_get_field_schema = (schema, key) => {
157
- const field = zod_maybe_get_field_schema(schema, key);
158
- if (!field)
159
- throw new Error(`Field "${key}" not found in schema`);
160
- return field;
161
- };
162
- /**
163
- * Unwrap a schema to find the inner `ZodObject`, or `null` if not an object schema.
164
- * Handles wrappers like `z.strictObject({...}).default({...})`.
165
- */
166
- export const zod_unwrap_to_object = (schema) => {
167
- const def = zod_unwrap_def(schema);
168
- if (def.type !== 'object')
169
- return null;
170
- let s = schema;
171
- while (s.def.type !== 'object') {
172
- const sub = zod_to_subschema(s.def);
173
- if (!sub)
174
- return null;
175
- s = sub;
176
- }
177
- return s;
178
- };
179
- /**
180
- * Extract field metadata from a Zod object schema.
181
- */
182
- export const zod_extract_fields = (schema) => {
183
- const fields = [];
184
- for (const [name, field_schema] of Object.entries(schema.shape)) {
185
- const field = field_schema;
186
- fields.push({
187
- name,
188
- base_type: zod_get_base_type(field),
189
- required: !zod_is_optional(field),
190
- has_default: zod_has_default(field),
191
- nullable: zod_is_nullable(field)
192
- });
193
- }
194
- return fields;
195
- };