@versionzero/schema 1.0.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 (401) hide show
  1. package/LICENSE +177 -0
  2. package/README.md +246 -0
  3. package/package.json +84 -0
  4. package/src/compilation/handler-compilation.js +28 -0
  5. package/src/compilation/metadata-compilation.js +35 -0
  6. package/src/compilation/schema-compilation.js +142 -0
  7. package/src/compilation/selection-compilation.js +84 -0
  8. package/src/compilation/union-compilation.js +510 -0
  9. package/src/compilation/values-compilation.js +35 -0
  10. package/src/compiled-schema.js +1709 -0
  11. package/src/constants.js +1 -0
  12. package/src/core-library/index.js +32 -0
  13. package/src/core-library/processors/aggregation-operators.js +75 -0
  14. package/src/core-library/processors/alpha-constraint.js +20 -0
  15. package/src/core-library/processors/alphanum-constraint.js +20 -0
  16. package/src/core-library/processors/array-operator.js +51 -0
  17. package/src/core-library/processors/assert-constraint.js +75 -0
  18. package/src/core-library/processors/base64-constraint.js +26 -0
  19. package/src/core-library/processors/camel-case-operator.js +24 -0
  20. package/src/core-library/processors/capitalize-operator.js +16 -0
  21. package/src/core-library/processors/cardnum-constraint.js +193 -0
  22. package/src/core-library/processors/ceil-operator.js +44 -0
  23. package/src/core-library/processors/collapse-operator.js +29 -0
  24. package/src/core-library/processors/compact-operator.js +34 -0
  25. package/src/core-library/processors/compile-operator.js +65 -0
  26. package/src/core-library/processors/concat-operator.js +51 -0
  27. package/src/core-library/processors/conditional-operators.js +301 -0
  28. package/src/core-library/processors/constant-case-operator.js +16 -0
  29. package/src/core-library/processors/data-size-operator.js +86 -0
  30. package/src/core-library/processors/date-object-operator.js +54 -0
  31. package/src/core-library/processors/date-operator.js +67 -0
  32. package/src/core-library/processors/date-range-constraint.js +76 -0
  33. package/src/core-library/processors/defined-constraint.js +30 -0
  34. package/src/core-library/processors/each-operator.js +57 -0
  35. package/src/core-library/processors/email-constraint.js +112 -0
  36. package/src/core-library/processors/entries-operator.js +25 -0
  37. package/src/core-library/processors/eq-constraint.js +37 -0
  38. package/src/core-library/processors/filter-operator.js +74 -0
  39. package/src/core-library/processors/find-schema-operator.js +45 -0
  40. package/src/core-library/processors/flatten-operator.js +40 -0
  41. package/src/core-library/processors/floor-operator.js +47 -0
  42. package/src/core-library/processors/get-operator.js +44 -0
  43. package/src/core-library/processors/group-by-operator.js +84 -0
  44. package/src/core-library/processors/has-prefix-constraint.js +37 -0
  45. package/src/core-library/processors/has-suffix-constraint.js +35 -0
  46. package/src/core-library/processors/hex-constraint.js +20 -0
  47. package/src/core-library/processors/hostname-constraint.js +22 -0
  48. package/src/core-library/processors/http-url-constraint.js +27 -0
  49. package/src/core-library/processors/in-constraint.js +66 -0
  50. package/src/core-library/processors/index-by-operator.js +98 -0
  51. package/src/core-library/processors/index.js +131 -0
  52. package/src/core-library/processors/input-operator.js +23 -0
  53. package/src/core-library/processors/instanceof-constraint.js +38 -0
  54. package/src/core-library/processors/integer-constraint.js +22 -0
  55. package/src/core-library/processors/invoke-operator.js +33 -0
  56. package/src/core-library/processors/ipv4-constraint.js +188 -0
  57. package/src/core-library/processors/ipv6-constraint.js +205 -0
  58. package/src/core-library/processors/is-array-constraint.js +21 -0
  59. package/src/core-library/processors/is-date-constraint.js +22 -0
  60. package/src/core-library/processors/is-number-constraint.js +21 -0
  61. package/src/core-library/processors/is-object-constraint.js +21 -0
  62. package/src/core-library/processors/is-string-constraint.js +21 -0
  63. package/src/core-library/processors/join-operator.js +41 -0
  64. package/src/core-library/processors/json-constraint.js +22 -0
  65. package/src/core-library/processors/json-decode-operator.js +25 -0
  66. package/src/core-library/processors/json-encode-operator.js +35 -0
  67. package/src/core-library/processors/kebab-case-operator.js +23 -0
  68. package/src/core-library/processors/keys-operator.js +20 -0
  69. package/src/core-library/processors/length-constraint.js +85 -0
  70. package/src/core-library/processors/lookup-operator.js +84 -0
  71. package/src/core-library/processors/lowercase-operator.js +14 -0
  72. package/src/core-library/processors/map-operator.js +84 -0
  73. package/src/core-library/processors/match-operator.js +64 -0
  74. package/src/core-library/processors/matches-constraint.js +54 -0
  75. package/src/core-library/processors/math-operators.js +151 -0
  76. package/src/core-library/processors/merge-deep-operator.js +61 -0
  77. package/src/core-library/processors/merge-operator.js +54 -0
  78. package/src/core-library/processors/metadata-operator.js +100 -0
  79. package/src/core-library/processors/negative-constraint.js +23 -0
  80. package/src/core-library/processors/never-constraint.js +69 -0
  81. package/src/core-library/processors/non-empty-constraint.js +59 -0
  82. package/src/core-library/processors/not-constraint.js +71 -0
  83. package/src/core-library/processors/number-operator.js +24 -0
  84. package/src/core-library/processors/numeric-constraint.js +22 -0
  85. package/src/core-library/processors/object-operator.js +38 -0
  86. package/src/core-library/processors/omit-operator.js +57 -0
  87. package/src/core-library/processors/parallel-operator.js +64 -0
  88. package/src/core-library/processors/pascal-case-operator.js +16 -0
  89. package/src/core-library/processors/phone-constraint.js +235 -0
  90. package/src/core-library/processors/pick-operator.js +62 -0
  91. package/src/core-library/processors/pipeline-operator.js +63 -0
  92. package/src/core-library/processors/port-constraint.js +22 -0
  93. package/src/core-library/processors/positive-constraint.js +23 -0
  94. package/src/core-library/processors/process-operator.js +55 -0
  95. package/src/core-library/processors/property-operator.js +49 -0
  96. package/src/core-library/processors/range-constraint.js +72 -0
  97. package/src/core-library/processors/reference-operator.js +79 -0
  98. package/src/core-library/processors/require-constraint.js +74 -0
  99. package/src/core-library/processors/reverse-operator.js +20 -0
  100. package/src/core-library/processors/round-operator.js +53 -0
  101. package/src/core-library/processors/schema-handler-operators.js +54 -0
  102. package/src/core-library/processors/semver-constraint.js +282 -0
  103. package/src/core-library/processors/sequence-processors.js +406 -0
  104. package/src/core-library/processors/sort-operator.js +52 -0
  105. package/src/core-library/processors/split-operator.js +43 -0
  106. package/src/core-library/processors/string-extra-operators.js +141 -0
  107. package/src/core-library/processors/string-operator.js +34 -0
  108. package/src/core-library/processors/target-operator.js +30 -0
  109. package/src/core-library/processors/template-operator.js +60 -0
  110. package/src/core-library/processors/title-case-operator.js +17 -0
  111. package/src/core-library/processors/trim-operator.js +14 -0
  112. package/src/core-library/processors/truthy-constraint.js +35 -0
  113. package/src/core-library/processors/type-operator.js +24 -0
  114. package/src/core-library/processors/unique-operator.js +21 -0
  115. package/src/core-library/processors/uppercase-operator.js +14 -0
  116. package/src/core-library/processors/url-constraint.js +31 -0
  117. package/src/core-library/processors/url-decode-operator.js +50 -0
  118. package/src/core-library/processors/url-encode-operator.js +44 -0
  119. package/src/core-library/processors/uuid-constraint.js +31 -0
  120. package/src/core-library/processors/values-operator.js +20 -0
  121. package/src/core-library/schemas/any-schema.js +23 -0
  122. package/src/core-library/schemas/array-schema.js +8 -0
  123. package/src/core-library/schemas/boolean-schema.js +10 -0
  124. package/src/core-library/schemas/date-schema.js +12 -0
  125. package/src/core-library/schemas/function-schema.js +40 -0
  126. package/src/core-library/schemas/number-schema.js +9 -0
  127. package/src/core-library/schemas/object-schema.js +10 -0
  128. package/src/core-library/schemas/root-schema.js +21 -0
  129. package/src/core-library/schemas/string-schema.js +9 -0
  130. package/src/core-library-node/index.js +47 -0
  131. package/src/core-library-node/processors/base64-decode-operator.js +20 -0
  132. package/src/core-library-node/processors/base64-encode-operator.js +20 -0
  133. package/src/core-library-node/processors/buffer-operator.js +39 -0
  134. package/src/core-library-node/processors/directory-constraint.js +35 -0
  135. package/src/core-library-node/processors/executable-constraint.js +34 -0
  136. package/src/core-library-node/processors/file-constraint.js +34 -0
  137. package/src/core-library-node/processors/file-size-constraint.js +94 -0
  138. package/src/core-library-node/processors/is-buffer-constraint.js +21 -0
  139. package/src/core-library-node/processors/reachable-constraint.js +28 -0
  140. package/src/core-library-node/processors/readable-constraint.js +34 -0
  141. package/src/core-library-node/processors/writable-constraint.js +59 -0
  142. package/src/core-library-node/schemas/buffer-schema.js +10 -0
  143. package/src/errors.js +209 -0
  144. package/src/executor/array-executor.js +78 -0
  145. package/src/executor/conditional-executor.js +134 -0
  146. package/src/executor/each-executor.js +68 -0
  147. package/src/executor/executor.js +123 -0
  148. package/src/executor/object-executor.js +98 -0
  149. package/src/executor/parallel-executor.js +43 -0
  150. package/src/executor/pipeline-executor.js +65 -0
  151. package/src/executor/sequence-executor.js +206 -0
  152. package/src/executor/serial-executor.js +24 -0
  153. package/src/executor/step-executor.js +68 -0
  154. package/src/helpers/case.js +124 -0
  155. package/src/helpers/data-size.js +144 -0
  156. package/src/helpers/debug-sink.js +15 -0
  157. package/src/helpers/deep.js +280 -0
  158. package/src/helpers/format.js +121 -0
  159. package/src/helpers/has-string-properties.js +30 -0
  160. package/src/helpers/index.js +16 -0
  161. package/src/helpers/object.js +115 -0
  162. package/src/helpers/parse-date.js +75 -0
  163. package/src/helpers/path.js +28 -0
  164. package/src/helpers/regex.js +18 -0
  165. package/src/helpers/stringify.js +309 -0
  166. package/src/helpers/to-data.js +64 -0
  167. package/src/helpers/truthy.js +55 -0
  168. package/src/index.js +29 -0
  169. package/src/schema-compiler.js +531 -0
  170. package/src/schema-location.js +200 -0
  171. package/src/schema-resolver.js +546 -0
  172. package/src/schema.js +1182 -0
  173. package/src/traversal/executors/check-condition.js +42 -0
  174. package/src/traversal/executors/check-input.js +27 -0
  175. package/src/traversal/executors/check-required.js +19 -0
  176. package/src/traversal/executors/check-schema.js +45 -0
  177. package/src/traversal/executors/defaults.js +21 -0
  178. package/src/traversal/executors/enter-existing.js +25 -0
  179. package/src/traversal/executors/enter-input.js +25 -0
  180. package/src/traversal/executors/enter.js +37 -0
  181. package/src/traversal/executors/exit.js +74 -0
  182. package/src/traversal/executors/finalize.js +64 -0
  183. package/src/traversal/executors/index.js +42 -0
  184. package/src/traversal/executors/normalize.js +38 -0
  185. package/src/traversal/executors/prepare-existing.js +27 -0
  186. package/src/traversal/executors/prepare-pending.js +54 -0
  187. package/src/traversal/executors/resolve-union.js +50 -0
  188. package/src/traversal/executors/serialize.js +48 -0
  189. package/src/traversal/executors/transform-early.js +51 -0
  190. package/src/traversal/executors/transform.js +68 -0
  191. package/src/traversal/executors/traversal-state-executor.js +46 -0
  192. package/src/traversal/executors/validate.js +63 -0
  193. package/src/traversal/traversal-context.js +231 -0
  194. package/src/traversal/traversal-state.js +809 -0
  195. package/src/types.js +102 -0
  196. package/src/value-processor/composed-value-processor.js +43 -0
  197. package/src/value-processor/defined-value-processor.js +72 -0
  198. package/src/value-processor/function-value-processor.js +68 -0
  199. package/src/value-processor/parameterized-value-processor.js +45 -0
  200. package/src/value-processor/parameters-value-processor.js +178 -0
  201. package/src/value-processor/spec.js +89 -0
  202. package/src/value-processor/value-processor.js +105 -0
  203. package/types/compilation/handler-compilation.d.ts +13 -0
  204. package/types/compilation/metadata-compilation.d.ts +6 -0
  205. package/types/compilation/schema-compilation.d.ts +32 -0
  206. package/types/compilation/selection-compilation.d.ts +9 -0
  207. package/types/compilation/union-compilation.d.ts +42 -0
  208. package/types/compilation/values-compilation.d.ts +12 -0
  209. package/types/compiled-schema.d.ts +883 -0
  210. package/types/constants.d.ts +1 -0
  211. package/types/core-library/index.d.ts +7 -0
  212. package/types/core-library/processors/aggregation-operators.d.ts +24 -0
  213. package/types/core-library/processors/alpha-constraint.d.ts +9 -0
  214. package/types/core-library/processors/alphanum-constraint.d.ts +9 -0
  215. package/types/core-library/processors/array-operator.d.ts +12 -0
  216. package/types/core-library/processors/assert-constraint.d.ts +30 -0
  217. package/types/core-library/processors/base64-constraint.d.ts +11 -0
  218. package/types/core-library/processors/camel-case-operator.d.ts +17 -0
  219. package/types/core-library/processors/capitalize-operator.d.ts +11 -0
  220. package/types/core-library/processors/cardnum-constraint.d.ts +51 -0
  221. package/types/core-library/processors/ceil-operator.d.ts +30 -0
  222. package/types/core-library/processors/collapse-operator.d.ts +24 -0
  223. package/types/core-library/processors/compact-operator.d.ts +29 -0
  224. package/types/core-library/processors/compile-operator.d.ts +34 -0
  225. package/types/core-library/processors/concat-operator.d.ts +23 -0
  226. package/types/core-library/processors/conditional-operators.d.ts +219 -0
  227. package/types/core-library/processors/constant-case-operator.d.ts +9 -0
  228. package/types/core-library/processors/data-size-operator.d.ts +31 -0
  229. package/types/core-library/processors/date-object-operator.d.ts +16 -0
  230. package/types/core-library/processors/date-operator.d.ts +21 -0
  231. package/types/core-library/processors/date-range-constraint.d.ts +26 -0
  232. package/types/core-library/processors/defined-constraint.d.ts +20 -0
  233. package/types/core-library/processors/each-operator.d.ts +34 -0
  234. package/types/core-library/processors/email-constraint.d.ts +54 -0
  235. package/types/core-library/processors/entries-operator.d.ts +13 -0
  236. package/types/core-library/processors/eq-constraint.d.ts +20 -0
  237. package/types/core-library/processors/filter-operator.d.ts +35 -0
  238. package/types/core-library/processors/find-schema-operator.d.ts +28 -0
  239. package/types/core-library/processors/flatten-operator.d.ts +26 -0
  240. package/types/core-library/processors/floor-operator.d.ts +33 -0
  241. package/types/core-library/processors/get-operator.d.ts +31 -0
  242. package/types/core-library/processors/group-by-operator.d.ts +36 -0
  243. package/types/core-library/processors/has-prefix-constraint.d.ts +22 -0
  244. package/types/core-library/processors/has-suffix-constraint.d.ts +20 -0
  245. package/types/core-library/processors/hex-constraint.d.ts +9 -0
  246. package/types/core-library/processors/hostname-constraint.d.ts +11 -0
  247. package/types/core-library/processors/http-url-constraint.d.ts +9 -0
  248. package/types/core-library/processors/in-constraint.d.ts +27 -0
  249. package/types/core-library/processors/index-by-operator.d.ts +26 -0
  250. package/types/core-library/processors/index.d.ts +8 -0
  251. package/types/core-library/processors/input-operator.d.ts +20 -0
  252. package/types/core-library/processors/instanceof-constraint.d.ts +23 -0
  253. package/types/core-library/processors/integer-constraint.d.ts +9 -0
  254. package/types/core-library/processors/invoke-operator.d.ts +12 -0
  255. package/types/core-library/processors/ipv4-constraint.d.ts +37 -0
  256. package/types/core-library/processors/ipv6-constraint.d.ts +34 -0
  257. package/types/core-library/processors/is-array-constraint.d.ts +10 -0
  258. package/types/core-library/processors/is-date-constraint.d.ts +10 -0
  259. package/types/core-library/processors/is-number-constraint.d.ts +10 -0
  260. package/types/core-library/processors/is-object-constraint.d.ts +10 -0
  261. package/types/core-library/processors/is-string-constraint.d.ts +10 -0
  262. package/types/core-library/processors/join-operator.d.ts +29 -0
  263. package/types/core-library/processors/json-constraint.d.ts +10 -0
  264. package/types/core-library/processors/json-decode-operator.d.ts +9 -0
  265. package/types/core-library/processors/json-encode-operator.d.ts +27 -0
  266. package/types/core-library/processors/kebab-case-operator.d.ts +16 -0
  267. package/types/core-library/processors/keys-operator.d.ts +9 -0
  268. package/types/core-library/processors/length-constraint.d.ts +34 -0
  269. package/types/core-library/processors/lookup-operator.d.ts +36 -0
  270. package/types/core-library/processors/lowercase-operator.d.ts +9 -0
  271. package/types/core-library/processors/map-operator.d.ts +38 -0
  272. package/types/core-library/processors/match-operator.d.ts +34 -0
  273. package/types/core-library/processors/matches-constraint.d.ts +29 -0
  274. package/types/core-library/processors/math-operators.d.ts +91 -0
  275. package/types/core-library/processors/merge-deep-operator.d.ts +32 -0
  276. package/types/core-library/processors/merge-operator.d.ts +26 -0
  277. package/types/core-library/processors/metadata-operator.d.ts +56 -0
  278. package/types/core-library/processors/negative-constraint.d.ts +13 -0
  279. package/types/core-library/processors/never-constraint.d.ts +26 -0
  280. package/types/core-library/processors/non-empty-constraint.d.ts +28 -0
  281. package/types/core-library/processors/not-constraint.d.ts +28 -0
  282. package/types/core-library/processors/number-operator.d.ts +9 -0
  283. package/types/core-library/processors/numeric-constraint.d.ts +10 -0
  284. package/types/core-library/processors/object-operator.d.ts +10 -0
  285. package/types/core-library/processors/omit-operator.d.ts +24 -0
  286. package/types/core-library/processors/parallel-operator.d.ts +41 -0
  287. package/types/core-library/processors/pascal-case-operator.d.ts +9 -0
  288. package/types/core-library/processors/phone-constraint.d.ts +65 -0
  289. package/types/core-library/processors/pick-operator.d.ts +27 -0
  290. package/types/core-library/processors/pipeline-operator.d.ts +40 -0
  291. package/types/core-library/processors/port-constraint.d.ts +11 -0
  292. package/types/core-library/processors/positive-constraint.d.ts +13 -0
  293. package/types/core-library/processors/process-operator.d.ts +37 -0
  294. package/types/core-library/processors/property-operator.d.ts +34 -0
  295. package/types/core-library/processors/range-constraint.d.ts +30 -0
  296. package/types/core-library/processors/reference-operator.d.ts +38 -0
  297. package/types/core-library/processors/require-constraint.d.ts +29 -0
  298. package/types/core-library/processors/reverse-operator.d.ts +9 -0
  299. package/types/core-library/processors/round-operator.d.ts +34 -0
  300. package/types/core-library/processors/schema-handler-operators.d.ts +28 -0
  301. package/types/core-library/processors/semver-constraint.d.ts +43 -0
  302. package/types/core-library/processors/sequence-processors.d.ts +213 -0
  303. package/types/core-library/processors/sort-operator.d.ts +31 -0
  304. package/types/core-library/processors/split-operator.d.ts +33 -0
  305. package/types/core-library/processors/string-extra-operators.d.ts +83 -0
  306. package/types/core-library/processors/string-operator.d.ts +10 -0
  307. package/types/core-library/processors/target-operator.d.ts +27 -0
  308. package/types/core-library/processors/template-operator.d.ts +31 -0
  309. package/types/core-library/processors/title-case-operator.d.ts +12 -0
  310. package/types/core-library/processors/trim-operator.d.ts +9 -0
  311. package/types/core-library/processors/truthy-constraint.d.ts +23 -0
  312. package/types/core-library/processors/type-operator.d.ts +11 -0
  313. package/types/core-library/processors/unique-operator.d.ts +10 -0
  314. package/types/core-library/processors/uppercase-operator.d.ts +9 -0
  315. package/types/core-library/processors/url-constraint.d.ts +20 -0
  316. package/types/core-library/processors/url-decode-operator.d.ts +31 -0
  317. package/types/core-library/processors/url-encode-operator.d.ts +36 -0
  318. package/types/core-library/processors/uuid-constraint.d.ts +20 -0
  319. package/types/core-library/processors/values-operator.d.ts +9 -0
  320. package/types/core-library/schemas/any-schema.d.ts +2 -0
  321. package/types/core-library/schemas/array-schema.d.ts +2 -0
  322. package/types/core-library/schemas/boolean-schema.d.ts +2 -0
  323. package/types/core-library/schemas/date-schema.d.ts +2 -0
  324. package/types/core-library/schemas/function-schema.d.ts +2 -0
  325. package/types/core-library/schemas/number-schema.d.ts +2 -0
  326. package/types/core-library/schemas/object-schema.d.ts +2 -0
  327. package/types/core-library/schemas/root-schema.d.ts +2 -0
  328. package/types/core-library/schemas/string-schema.d.ts +2 -0
  329. package/types/core-library-node/index.d.ts +12 -0
  330. package/types/core-library-node/processors/base64-decode-operator.d.ts +9 -0
  331. package/types/core-library-node/processors/base64-encode-operator.d.ts +9 -0
  332. package/types/core-library-node/processors/buffer-operator.d.ts +15 -0
  333. package/types/core-library-node/processors/directory-constraint.d.ts +14 -0
  334. package/types/core-library-node/processors/executable-constraint.d.ts +17 -0
  335. package/types/core-library-node/processors/file-constraint.d.ts +13 -0
  336. package/types/core-library-node/processors/file-size-constraint.d.ts +43 -0
  337. package/types/core-library-node/processors/is-buffer-constraint.d.ts +10 -0
  338. package/types/core-library-node/processors/reachable-constraint.d.ts +13 -0
  339. package/types/core-library-node/processors/readable-constraint.d.ts +17 -0
  340. package/types/core-library-node/processors/writable-constraint.d.ts +18 -0
  341. package/types/core-library-node/schemas/buffer-schema.d.ts +2 -0
  342. package/types/errors.d.ts +58 -0
  343. package/types/executor/array-executor.d.ts +17 -0
  344. package/types/executor/conditional-executor.d.ts +45 -0
  345. package/types/executor/each-executor.d.ts +15 -0
  346. package/types/executor/executor.d.ts +84 -0
  347. package/types/executor/object-executor.d.ts +14 -0
  348. package/types/executor/parallel-executor.d.ts +27 -0
  349. package/types/executor/pipeline-executor.d.ts +11 -0
  350. package/types/executor/sequence-executor.d.ts +32 -0
  351. package/types/executor/serial-executor.d.ts +16 -0
  352. package/types/executor/step-executor.d.ts +14 -0
  353. package/types/helpers/case.d.ts +30 -0
  354. package/types/helpers/data-size.d.ts +25 -0
  355. package/types/helpers/debug-sink.d.ts +9 -0
  356. package/types/helpers/deep.d.ts +33 -0
  357. package/types/helpers/format.d.ts +14 -0
  358. package/types/helpers/has-string-properties.d.ts +5 -0
  359. package/types/helpers/index.d.ts +13 -0
  360. package/types/helpers/object.d.ts +46 -0
  361. package/types/helpers/parse-date.d.ts +6 -0
  362. package/types/helpers/path.d.ts +13 -0
  363. package/types/helpers/regex.d.ts +7 -0
  364. package/types/helpers/stringify.d.ts +33 -0
  365. package/types/helpers/to-data.d.ts +13 -0
  366. package/types/helpers/truthy.d.ts +26 -0
  367. package/types/index.d.ts +6 -0
  368. package/types/schema-compiler.d.ts +49 -0
  369. package/types/schema-location.d.ts +64 -0
  370. package/types/schema-resolver.d.ts +145 -0
  371. package/types/schema.d.ts +586 -0
  372. package/types/traversal/executors/check-condition.d.ts +8 -0
  373. package/types/traversal/executors/check-input.d.ts +6 -0
  374. package/types/traversal/executors/check-required.d.ts +6 -0
  375. package/types/traversal/executors/check-schema.d.ts +7 -0
  376. package/types/traversal/executors/defaults.d.ts +8 -0
  377. package/types/traversal/executors/enter-existing.d.ts +6 -0
  378. package/types/traversal/executors/enter-input.d.ts +8 -0
  379. package/types/traversal/executors/enter.d.ts +7 -0
  380. package/types/traversal/executors/exit.d.ts +6 -0
  381. package/types/traversal/executors/finalize.d.ts +6 -0
  382. package/types/traversal/executors/index.d.ts +15 -0
  383. package/types/traversal/executors/normalize.d.ts +7 -0
  384. package/types/traversal/executors/prepare-existing.d.ts +6 -0
  385. package/types/traversal/executors/prepare-pending.d.ts +6 -0
  386. package/types/traversal/executors/resolve-union.d.ts +6 -0
  387. package/types/traversal/executors/serialize.d.ts +11 -0
  388. package/types/traversal/executors/transform-early.d.ts +6 -0
  389. package/types/traversal/executors/transform.d.ts +6 -0
  390. package/types/traversal/executors/traversal-state-executor.d.ts +19 -0
  391. package/types/traversal/executors/validate.d.ts +6 -0
  392. package/types/traversal/traversal-context.d.ts +67 -0
  393. package/types/traversal/traversal-state.d.ts +97 -0
  394. package/types/types.d.ts +218 -0
  395. package/types/value-processor/composed-value-processor.d.ts +17 -0
  396. package/types/value-processor/defined-value-processor.d.ts +16 -0
  397. package/types/value-processor/function-value-processor.d.ts +15 -0
  398. package/types/value-processor/parameterized-value-processor.d.ts +14 -0
  399. package/types/value-processor/parameters-value-processor.d.ts +28 -0
  400. package/types/value-processor/spec.d.ts +22 -0
  401. package/types/value-processor/value-processor.d.ts +92 -0
@@ -0,0 +1 @@
1
+ export const EMPTY: unique symbol;
@@ -0,0 +1,7 @@
1
+ /** @import { SchemaResolver } from '../schema-resolver.js' */
2
+ /**
3
+ * @param {SchemaResolver} resolver
4
+ * @param {object} options
5
+ */
6
+ export default function coreLibrary(resolver: SchemaResolver, options: object): void;
7
+ import type { SchemaResolver } from '../schema-resolver.js';
@@ -0,0 +1,24 @@
1
+ /**
2
+ * ## $sum
3
+ *
4
+ * Returns the sum of an array of numbers. Returns `0` for an empty array.
5
+ *
6
+ * @type {import('../../value-processor/value-processor.js').ValueProcessorDefinition}
7
+ */
8
+ export const SUM_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
9
+ /**
10
+ * ## $min
11
+ *
12
+ * Returns the minimum value from an array of numbers. Returns `undefined` for an empty array.
13
+ *
14
+ * @type {import('../../value-processor/value-processor.js').ValueProcessorDefinition}
15
+ */
16
+ export const MIN_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
17
+ /**
18
+ * ## $max
19
+ *
20
+ * Returns the maximum value from an array of numbers. Returns `undefined` for an empty array.
21
+ *
22
+ * @type {import('../../value-processor/value-processor.js').ValueProcessorDefinition}
23
+ */
24
+ export const MAX_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * ## $alpha
3
+ *
4
+ * Validates that a string contains only alphabetic characters (a-z, A-Z).
5
+ * No spaces, numbers, punctuation, or special characters are allowed.
6
+ *
7
+ * @type {import('../../value-processor/value-processor.js').ValueProcessorDefinition}
8
+ */
9
+ export const ALPHA_CONSTRAINT: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * ## $alphanum
3
+ *
4
+ * Validates that a string contains only alphanumeric characters (A-Z, a-z, 0-9).
5
+ * No spaces, punctuation, or special characters are allowed.
6
+ *
7
+ * @type {import('../../value-processor/value-processor.js').ValueProcessorDefinition}
8
+ */
9
+ export const ALPHANUM_CONSTRAINT: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * ## $array
3
+ *
4
+ * Attempt to normalize the input value as an array.
5
+ *
6
+ * If the input value is "*", the array will expand to the "values" option defined in the current schema.
7
+ *
8
+ * See `$is-array` for strict array validation.
9
+ *
10
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
11
+ */
12
+ export const ARRAY_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * ## $assert
3
+ *
4
+ * Require that the provided processor returns a truthy value; return original input.
5
+ * Throws a constraint exception if not truthy.
6
+ *
7
+ * May be used inline in a pipeline without parameters, or can have a single processor argument.
8
+ *
9
+ * ### Parameters
10
+ * - `processor` (ProcessorSpec, optional): Processor specification to check for truthiness.
11
+ * If omitted, the input value itself is checked.
12
+ *
13
+ * ### Example
14
+ * ```js
15
+ * // Require the input value itself to be truthy
16
+ * new Schema('any').validator('$assert')
17
+ *
18
+ * // Assert that a referenced sibling field has a truthy value
19
+ * new Schema('object', {
20
+ * enabled: new Schema('boolean'),
21
+ * config: new Schema('object').validator({$assert: {$reference: 'enabled'}}),
22
+ * })
23
+ *
24
+ * // Assert that a custom function returns true
25
+ * new Schema('string').validator({$assert: (value) => value.startsWith('https://')})
26
+ * ```
27
+ *
28
+ * @type {import('../../value-processor/value-processor.js').ValueProcessorDefinition}
29
+ */
30
+ export const ASSERT_CONSTRAINT: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * ## $base64
3
+ *
4
+ * Validates that a string is properly formatted Base64 encoded data.
5
+ * Checks for valid Base64 character set (A-Z, a-z, 0-9, +, /) and proper
6
+ * padding with equals signs. If padding is present, the total length must
7
+ * be a multiple of 4.
8
+ *
9
+ * @type {import('../../value-processor/value-processor.js').ValueProcessorDefinition}
10
+ */
11
+ export const BASE64_CONSTRAINT: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * ## $camel-case
3
+ *
4
+ * Converts a string value to camelCase format. Words are identified by spaces,
5
+ * hyphens, underscores, or case changes. The first letter is lowercased, and
6
+ * subsequent words are capitalized with no separators.
7
+ * Safe to use in normalize phase (non-throwing).
8
+ *
9
+ * **Input examples**:
10
+ * - `"hello world"` → **Output**: `"helloWorld"`
11
+ * - `"foo-bar-baz"` → **Output**: `"fooBarBaz"`
12
+ * - `"user_name_id"` → **Output**: `"userNameId"`
13
+ * - `"HTTPSConnection"` → **Output**: `"httpsConnection"`
14
+ *
15
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
16
+ */
17
+ export const CAMEL_CASE_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * ## $capitalize
3
+ *
4
+ * Capitalizes the first letter of each word, separated by spaces. Words are split on
5
+ * non-alphanumeric boundaries (spaces, hyphens, underscores, camelCase transitions, etc.).
6
+ * Every word is capitalized unconditionally — see `$title-case` for proper title casing
7
+ * that respects articles and conjunctions.
8
+ *
9
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
10
+ */
11
+ export const CAPITALIZE_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * ## $cardnum
3
+ *
4
+ * Validates a payment card number (PAN) using the Luhn algorithm and normalizes
5
+ * its formatting based on the detected card network.
6
+ *
7
+ * **Processing steps:**
8
+ * 1. Strip formatting characters (spaces, dashes, dots)
9
+ * 2. Validate: digits only, length 12–19 (ISO 7812), Luhn checksum
10
+ * 3. Detect card network from IIN (Issuer Identification Number) prefix
11
+ * 4. Format with network-appropriate digit grouping
12
+ *
13
+ * **Recognized networks and their grouping:**
14
+ * - **Amex** (34, 37): `#### ###### #####`
15
+ * - **Diners Club** (300–305, 36, 38): `#### ###### ####`
16
+ * - **JCB** (3528–3589): `#### #### #### ####`
17
+ * - **Discover** (6011, 65, 644–649, 622126–622925): `#### #### #### ####`
18
+ * - **Mastercard** (51–55, 2221–2720): `#### #### #### ####`
19
+ * - **Visa** (4): `#### #### #### ####`
20
+ * - **Unrecognized**: `#### #### #### ####` (default grouping)
21
+ *
22
+ * Network detection is best-effort and does not affect validation — any number
23
+ * that passes the Luhn check with a valid length is accepted. Unrecognized
24
+ * prefixes receive default 4-4-4-4 grouping.
25
+ *
26
+ * ### Parameters
27
+ * - `mask` (boolean or string, default `false`): When truthy, replaces leading
28
+ * digits with a mask character, revealing only the trailing digits.
29
+ * `true` uses `'•'`; a string value uses its first character.
30
+ * - `reveal` (number, default `4`): Number of trailing digits to leave visible
31
+ * when `mask` is enabled.
32
+ *
33
+ * ### Example
34
+ * ```js
35
+ * // Validate and format
36
+ * new Schema('string').validator('$cardnum')
37
+ * // '4111111111111111' → '4111 1111 1111 1111'
38
+ * // '378282246310005' → '3782 822463 10005'
39
+ *
40
+ * // Masked for output (serializer — masking is a lossy presentation transform)
41
+ * new Schema('string').serializer({'$cardnum': {mask: true}})
42
+ * // '4111111111111111' → '•••• •••• •••• 1111'
43
+ *
44
+ * // Custom mask character, reveal 6 digits
45
+ * new Schema('string').serializer({'$cardnum': {mask: '*', reveal: 6}})
46
+ * // '4111111111111111' → '**** **** **11 1111'
47
+ * ```
48
+ *
49
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
50
+ */
51
+ export const CARDNUM_CONSTRAINT: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,30 @@
1
+ /** @import {ValueProcessorDefinition} from '../../value-processor/value-processor.js' */
2
+ /**
3
+ * ## $ceil
4
+ *
5
+ * Rounds a numeric value up to the nearest integer or specified decimal precision.
6
+ * Non-numeric values are passed through unchanged. Safe to use in normalize phase (non-throwing).
7
+ *
8
+ * ### Parameters
9
+ * - `precision` (number, optional): Number of decimal places to preserve. Defaults to 0 (round to integer).
10
+ *
11
+ * ### Example
12
+ * ```js
13
+ * // Round up to the nearest integer
14
+ * new Schema('number').transformer('$ceil')
15
+ * // 3.14 → 4, 9.01 → 10
16
+ *
17
+ * // Round up to 2 decimal places
18
+ * new Schema('number').transformer({$ceil: {precision: 2}})
19
+ * // 3.14159 → 3.15
20
+ *
21
+ * // Round up memory usage to the nearest MB boundary
22
+ * new Schema('object', {
23
+ * memoryMB: new Schema('number').transformer({$ceil: {precision: 0}}),
24
+ * })
25
+ * ```
26
+ *
27
+ * @type {ValueProcessorDefinition}
28
+ */
29
+ export const CEIL_OPERATOR: ValueProcessorDefinition;
30
+ import type { ValueProcessorDefinition } from '../../value-processor/value-processor.js';
@@ -0,0 +1,24 @@
1
+ /**
2
+ * ## $collapse
3
+ *
4
+ * Collapses runs of whitespace within a string to a single space, and trims
5
+ * leading and trailing whitespace. Useful for normalizing messy user input
6
+ * from forms, textareas, and configuration values.
7
+ *
8
+ * Compared to `$trim` (edges only) and `$compact` (removes all formatting),
9
+ * `$collapse` preserves word boundaries while normalizing irregular spacing.
10
+ *
11
+ * ### Example
12
+ * ```js
13
+ * // Clean up messy form input
14
+ * new Schema('string').normalizer('$collapse')
15
+ * // ' hello world\n' → 'hello world'
16
+ *
17
+ * // Normalize a multi-line address to single line
18
+ * new Schema('string').normalizer('$collapse')
19
+ * // '123 Main St\n Apt 4\n' → '123 Main St Apt 4'
20
+ * ```
21
+ *
22
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
23
+ */
24
+ export const COLLAPSE_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * ## $compact
3
+ *
4
+ * Strips common formatting characters from a string: whitespace, hyphens,
5
+ * dots, parentheses, and forward slashes. Useful for producing storage-ready
6
+ * representations of formatted values like phone numbers and card numbers.
7
+ *
8
+ * Characters removed: `\\s`, `-`, `.`, `(`, `)`, `/`
9
+ *
10
+ * Characters preserved: `+`, digits, letters, and all other characters.
11
+ *
12
+ * ### Example
13
+ * ```js
14
+ * // Compact a formatted phone number for storage
15
+ * new Schema('string').normalizer(['$phone', '$compact'])
16
+ * // '(212) 555-1234' → '2125551234'
17
+ *
18
+ * // Compact an international phone number (preserves +)
19
+ * new Schema('string').normalizer([{'$phone': {international: true}}, '$compact'])
20
+ * // '+1 212 555 1234' → '+12125551234'
21
+ *
22
+ * // Compact a card number for storage
23
+ * new Schema('string').normalizer(['$cardnum', '$compact'])
24
+ * // '4111 1111 1111 1111' → '4111111111111111'
25
+ * ```
26
+ *
27
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
28
+ */
29
+ export const COMPACT_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * ## $compile
3
+ *
4
+ * Compiles a `Schema` (or `CompiledSchema`) into a `CompiledSchema` ready for use
5
+ * in value processing. If a schema argument is provided, that schema is compiled and
6
+ * the input value is ignored. If no argument is given, the input value itself is treated
7
+ * as the schema to compile — useful when a schema is being passed through as data.
8
+ *
9
+ * Typically used together with `$process` to dynamically select and apply a schema.
10
+ *
11
+ * ### Parameters
12
+ * - `schema` (Schema|CompiledSchema, optional): The schema to compile. If omitted, the input
13
+ * value is compiled instead.
14
+ *
15
+ * ### Example
16
+ * ```js
17
+ * import { Schema } from '@versionzero/schema';
18
+ *
19
+ * // Compile a fixed schema and feed it into $process
20
+ * const portSchema = new Schema('number').validator({$range: {min: 1, max: 65535}});
21
+ *
22
+ * new Schema('object', {
23
+ * port: new Schema('any')
24
+ * .normalizer({$compile: portSchema})
25
+ * .transformer('$process'),
26
+ * })
27
+ *
28
+ * // Compile the input value itself when schemas arrive as data
29
+ * new Schema('any').transformer(['$compile', '$process'])
30
+ * ```
31
+ *
32
+ * @type {import('../../value-processor/value-processor.js').ValueProcessorDefinition}
33
+ */
34
+ export const COMPILE_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * ## $concat
3
+ *
4
+ * Returns a new array with the specified values appended to the input array.
5
+ * Throws `SchemaError` at compile time if no arguments are provided.
6
+ * Throws `ConstraintError` at runtime if the input is not an array.
7
+ *
8
+ * ### Parameters
9
+ * - Array of values to append (required, at least one).
10
+ *
11
+ * ### Example
12
+ * ```js
13
+ * // Append default scopes to a user-supplied scopes array
14
+ * new Schema('array').transformer({$concat: ['read:profile', 'read:email']})
15
+ * // ['custom:scope'] → ['custom:scope', 'read:profile', 'read:email']
16
+ *
17
+ * // Always include a sentinel value at the end of an array
18
+ * new Schema('array').transformer({$concat: [null]})
19
+ * ```
20
+ *
21
+ * @type {import('../../value-processor/value-processor.js').ValueProcessorDefinition}
22
+ */
23
+ export const CONCAT_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,219 @@
1
+ /**
2
+ * ## $if
3
+ *
4
+ * This is a conditional operator that evaluates a predicate for truthiness.
5
+ *
6
+ * If the predicate returns a truthy value, $if will invoke any provided success action
7
+ * with the original input. If not provided, the default success action will simply return the original input.
8
+ *
9
+ * If the predicate returns a falsey value or rejects/throws, $if will return the result of invoking the failure
10
+ * action on the original input. The default failure action will return undefined.
11
+ *
12
+ * This processor can act as a constraint if the success or failure actions throw when triggered.
13
+ *
14
+ * To pass the predicate results to the actions instead of the input, see $check.
15
+ * To test for success rather than truthiness, see $gate.
16
+ *
17
+ * ### Parameters
18
+ * - `predicate` (processor, optional): Evaluated for truthiness. If omitted, the input itself is used as the predicate.
19
+ * - `success` (processor, optional): Invoked with the original input on truthy predicate result. Default: returns input as-is.
20
+ * - `failure` (processor, optional): Invoked with the original input on falsey predicate result or throw. Default: returns undefined.
21
+ *
22
+ * Array form: `{$if: [predicate, success, failure]}`
23
+ * Object form: `{$if: {predicate: ..., success: ..., failure: ...}}`
24
+ * Aliases: `predicate` may also be written as `condition` or `cond`.
25
+ *
26
+ * ### Example
27
+ * ```js
28
+ * // Normalize an optional port — keep it if numeric, otherwise drop it
29
+ * new Schema('object', {
30
+ * port: new Schema('number').normalizer({
31
+ * $if: ['$numeric', '$number', null]
32
+ * }),
33
+ * })
34
+ *
35
+ * // Conditionally require an API key when a flag is set
36
+ * new Schema('object', {
37
+ * useApiKey: new Schema('boolean'),
38
+ * apiKey: new Schema('string').validator({
39
+ * $if: [
40
+ * {$reference: 'useApiKey'},
41
+ * '$non-empty',
42
+ * ]
43
+ * }),
44
+ * })
45
+ * ```
46
+ *
47
+ * @type {ValueProcessorDefinition}
48
+ */
49
+ export const IF_OPERATOR: ValueProcessorDefinition;
50
+ /**
51
+ * ## $gate
52
+ *
53
+ * This is a conditional operator that evaluates a predicate for whether it returns a defined value.
54
+ *
55
+ * If the predicate returns a defined value, $gate will return the result of invoking any provided success action
56
+ * with the original input. If not provided, the default success action will simply return the original input.
57
+ *
58
+ * If the predicate returns undefined or rejects/throws, $gate will return the result of invoking the failure
59
+ * action on the original input. The default failure action will return undefined.
60
+ *
61
+ * This processor can act as a constraint if the success or failure actions throw when triggered.
62
+ *
63
+ * To pass the original input to the actions instead of the predicate results, see $if.
64
+ *
65
+ * ### Parameters
66
+ * - `predicate` (processor, optional): Evaluated for defined-ness. If omitted, the input itself is tested.
67
+ * - `success` (processor, optional): Invoked with the original input when predicate returns a defined value. Default: returns input as-is.
68
+ * - `failure` (processor, optional): Invoked with the original input when predicate returns undefined or throws. Default: returns undefined.
69
+ *
70
+ * Array form: `{$gate: [predicate, success, failure]}`
71
+ * Object form: `{$gate: {predicate: ..., success: ..., failure: ...}}`
72
+ *
73
+ * ### Example
74
+ * ```js
75
+ * // Only process the value through $uppercase if it was provided
76
+ * new Schema('string').normalizer({
77
+ * $gate: ['$defined', '$uppercase']
78
+ * })
79
+ *
80
+ * // Use the first resolvable property as a value
81
+ * new Schema('object', {
82
+ * host: new Schema('string'),
83
+ * fallbackHost: new Schema('string'),
84
+ * }).transformer({
85
+ * $gate: [{$property: 'host'}, {$property: 'host'}, {$property: 'fallbackHost'}]
86
+ * })
87
+ * ```
88
+ *
89
+ * @type {ValueProcessorDefinition}
90
+ */
91
+ export const GATE_OPERATOR: ValueProcessorDefinition;
92
+ /**
93
+ * ## $check
94
+ *
95
+ * This is a conditional operator that evaluates a predicate for truthiness.
96
+ *
97
+ * If the predicate returns a truthy value, $check will return the result of invoking any provided success action
98
+ * with the predicate result. If not provided, the default success action will simply return the predicate result.
99
+ *
100
+ * If the predicate returns a falsey value or rejects/throws, $check will return the result of invoking the failure
101
+ * action on the predicate result. The default failure action will return undefined. Since the predicate result
102
+ * is already falsey, the failure action is best used to either return a default value or throw an error.
103
+ *
104
+ * This processor can act as a constraint if the success or failure actions throw when triggered.
105
+ *
106
+ * ### Parameters
107
+ * - `predicate` (processor, optional): Evaluated for truthiness. The predicate result (not the original input) is passed to success/failure.
108
+ * - `success` (processor, optional): Invoked with the predicate result on truthy outcome. Default: returns predicate result.
109
+ * - `failure` (processor, optional): Invoked with the predicate result on falsey outcome or throw. Default: returns undefined.
110
+ *
111
+ * Array form: `{$check: [predicate, success, failure]}`
112
+ * Object form: `{$check: {predicate: ..., success: ..., failure: ...}}`
113
+ *
114
+ * ### Example
115
+ * ```js
116
+ * // Extract and validate an environment key, returning the matched value or undefined
117
+ * new Schema('string').transformer({
118
+ * $check: [
119
+ * {$match: /^(production|staging|development)$/},
120
+ * ]
121
+ * })
122
+ *
123
+ * // Validate a regex match and throw on failure
124
+ * new Schema('string').validator({
125
+ * $check: [
126
+ * {$match: /^\d{4}-\d{2}-\d{2}$/},
127
+ * null,
128
+ * () => { throw new Error('Expected YYYY-MM-DD date format') }
129
+ * ]
130
+ * })
131
+ * ```
132
+ *
133
+ * @type {ValueProcessorDefinition}
134
+ */
135
+ export const CHECK_OPERATOR: ValueProcessorDefinition;
136
+ /**
137
+ * ## $when
138
+ *
139
+ * This is a conditional operator that evaluates a predicate for whether it returns a defined value.
140
+ *
141
+ * If the predicate returns a defined value, $when will return the result of invoking any provided success action
142
+ * with the predicate result. If not provided, the default success action will simply return the predicate result.
143
+ *
144
+ * If the predicate returns undefined or rejects/throws, $when will return the result of invoking the failure
145
+ * action on the predicate result. The default failure action will return undefined. Since the predicate result
146
+ * is undefined, the failure action is best used to either return a default value or throw an error.
147
+ *
148
+ * This processor can act as a constraint if the success or failure actions throw when triggered.
149
+ *
150
+ * To check truthiness instead of defined/undefined, see $check.
151
+ * To pass the original input to the actions instead of the predicate result, see $gate.
152
+ *
153
+ * ### Parameters
154
+ * - `predicate` (processor, optional): Evaluated for defined-ness. The predicate result (not the original input) is passed to success/failure.
155
+ * - `success` (processor, optional): Invoked with the predicate result when it is defined. Default: returns predicate result.
156
+ * - `failure` (processor, optional): Invoked with the predicate result (undefined) when predicate returns undefined or throws. Default: returns undefined.
157
+ *
158
+ * Array form: `{$when: [predicate, success, failure]}`
159
+ * Object form: `{$when: {predicate: ..., success: ..., failure: ...}}`
160
+ *
161
+ * ### Example
162
+ * ```js
163
+ * // Extract a nested value, providing a default when not found
164
+ * new Schema('object').transformer({
165
+ * $when: [
166
+ * {$get: 'config.timeout'},
167
+ * null,
168
+ * () => 5000 // default 5s when config.timeout not set
169
+ * ]
170
+ * })
171
+ *
172
+ * // Chain: extract the match groups object if the pattern matched, otherwise drop
173
+ * new Schema('string').transformer({
174
+ * $when: [{$match: /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/}]
175
+ * })
176
+ * ```
177
+ *
178
+ * @type {ValueProcessorDefinition}
179
+ */
180
+ export const WHEN_OPERATOR: ValueProcessorDefinition;
181
+ /**
182
+ * ## $try
183
+ *
184
+ * This is a conditional operator that evaluates a predicate for whether it throws/rejects.
185
+ *
186
+ * If the predicate does not throw, $try will return the result of invoking any provided success action
187
+ * with the predicate result. If not provided, the default success action will simply return the predicate result.
188
+ *
189
+ * If the predicate rejects/throws, $try will return the result of invoking the failure action with the error returned.
190
+ * The default failure action will return undefined. Since the predicate result is an error, the failure action is
191
+ * best used to either intercept errors and return a default value, or to propagate or wrap the error.
192
+ *
193
+ * This processor can act as a constraint if the success or failure actions throw when triggered.
194
+ *
195
+ * ### Parameters
196
+ * - `predicate` (processor, optional): Executed and observed for throw/rejection.
197
+ * - `success` (processor, optional): Invoked with the predicate result if it did not throw. Default: returns predicate result.
198
+ * - `failure` (processor, optional): Invoked with the thrown error if the predicate threw. Default: returns undefined.
199
+ *
200
+ * Array form: `{$try: [predicate, success, failure]}`
201
+ * Object form: `{$try: {predicate: ..., success: ..., failure: ...}}`
202
+ *
203
+ * ### Example
204
+ * ```js
205
+ * // Attempt JSON parsing, fall back to raw string on failure
206
+ * new Schema('string').normalizer({
207
+ * $try: ['$json-decode', null, (err) => err.input]
208
+ * })
209
+ *
210
+ * // Attempt to parse a number, silently drop value on error
211
+ * new Schema('string').normalizer({
212
+ * $try: ['$number']
213
+ * })
214
+ * ```
215
+ *
216
+ * @type {ValueProcessorDefinition}
217
+ */
218
+ export const TRY_OPERATOR: ValueProcessorDefinition;
219
+ import type { ValueProcessorDefinition } from '../../value-processor/value-processor.js';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * ## $constant-case
3
+ *
4
+ * Converts a string to CONSTANT_CASE format (uppercase letters with underscores).
5
+ * Safe to use in normalize phase (non-throwing).
6
+ *
7
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
8
+ */
9
+ export const CONSTANT_CASE_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * ## $data-size
3
+ *
4
+ * Parses data-size strings (e.g. `'20KiB'`, `'1.5 MB'`, `'512'`) into byte
5
+ * counts. Bare numbers and numeric strings without a suffix are treated as bytes.
6
+ *
7
+ * ### Parameters
8
+ * - `standard` (string, optional): Which unit standard to accept when parsing.
9
+ * `'iec'` (binary: KiB, MiB, ...), `'si'` (decimal: KB, MB, ...), or
10
+ * `'any'` (both). Default: `'any'`.
11
+ * - `format` (string, optional): When set, returns a formatted string instead
12
+ * of a byte count. Accepts `'iec'` or `'si'` to control the output standard.
13
+ *
14
+ * ### Example
15
+ * ```js
16
+ * // Parse to bytes (normalizer)
17
+ * new Schema().normalizer('$data-size')
18
+ *
19
+ * // Strict IEC only
20
+ * new Schema().normalizer({'$data-size': {standard: 'iec'}})
21
+ *
22
+ * // Parse and format back as SI string
23
+ * new Schema().normalizer({'$data-size': {format: 'si'}})
24
+ *
25
+ * // Use as normalizer ahead of number validation
26
+ * new Schema().normalizer(['$data-size']).validator('$is-number')
27
+ * ```
28
+ *
29
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
30
+ */
31
+ export const DATA_SIZE_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * ## $date-object
3
+ *
4
+ * Expands a Date into a plain object with named calendar fields.
5
+ *
6
+ * - `'$date-object'` or `{'$date-object': 'utc'}` — UTC fields (default)
7
+ * - `{'$date-object': 'local'}` — local-timezone fields
8
+ *
9
+ * Output shape: `{year, month, day, hour, minute, second, ms, zone}`
10
+ * where `month` is 1–12 (not 0-based), and `zone` is `'utc'` or `'local'`.
11
+ *
12
+ * The output is accepted by `$date` for round-trip reassembly.
13
+ *
14
+ * @type {import('../../value-processor/value-processor.js').ValueProcessorDefinition}
15
+ */
16
+ export const DATE_OBJECT_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * ## $date
3
+ *
4
+ * Normalize the input value as a Date. Accepts strings, numbers, Date instances, and
5
+ * date-field objects produced by `$date-object`.
6
+ *
7
+ * - `'now'` — returns the current timestamp
8
+ * - `'+1h'`, `'-30m'`, etc. — relative offsets from now
9
+ * - ISO strings and numeric epoch values are parsed automatically
10
+ * - `{year, month, day, ...zone}` — reassembled from a `$date-object` output
11
+ *
12
+ * Output type is inferred from the schema's `type` option:
13
+ * - `'string'` → ISO string
14
+ * - `'number'` → epoch milliseconds
15
+ * - otherwise → `Date` instance
16
+ *
17
+ * See `$is-date` for strict Date validation.
18
+ *
19
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
20
+ */
21
+ export const DATE_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;