@fougere/schema 0.6.0-alpha.0 → 0.8.0-alpha.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 (435) hide show
  1. package/README.md +5 -4
  2. package/dist/{schema/Schema.d.ts → Schema.d.ts} +17 -27
  3. package/dist/Schema.d.ts.map +1 -0
  4. package/dist/{schema/Schema.js → Schema.js} +22 -62
  5. package/dist/Schema.js.map +1 -0
  6. package/dist/SchemaDefinition.d.ts +73 -0
  7. package/dist/SchemaDefinition.d.ts.map +1 -0
  8. package/dist/SchemaDefinition.js +184 -0
  9. package/dist/SchemaDefinition.js.map +1 -0
  10. package/dist/SchemaDerivation.d.ts +16 -0
  11. package/dist/SchemaDerivation.d.ts.map +1 -0
  12. package/dist/SchemaDerivation.js +31 -0
  13. package/dist/SchemaDerivation.js.map +1 -0
  14. package/dist/{schema/SchemaView.d.ts → SchemaView.d.ts} +9 -9
  15. package/dist/SchemaView.d.ts.map +1 -0
  16. package/dist/{schema/SchemaView.js.map → SchemaView.js.map} +1 -1
  17. package/dist/{schema/axis → axis}/Axis.d.ts +2 -2
  18. package/dist/axis/Axis.d.ts.map +1 -0
  19. package/dist/axis/Axis.js.map +1 -0
  20. package/dist/axis/Meta.d.ts.map +1 -0
  21. package/dist/{schema/axis → axis}/Meta.js.map +1 -1
  22. package/dist/axis/boundary/Boundaries.d.ts +21 -0
  23. package/dist/axis/boundary/Boundaries.d.ts.map +1 -0
  24. package/dist/axis/boundary/Boundaries.js +25 -0
  25. package/dist/axis/boundary/Boundaries.js.map +1 -0
  26. package/dist/{schema/axis → axis}/boundary/Boundary.d.ts +3 -1
  27. package/dist/axis/boundary/Boundary.d.ts.map +1 -0
  28. package/dist/{schema/axis → axis}/boundary/Boundary.js +8 -6
  29. package/dist/axis/boundary/Boundary.js.map +1 -0
  30. package/dist/axis/boundary/BoundaryAxis.d.ts.map +1 -0
  31. package/dist/{schema/axis → axis}/boundary/BoundaryAxis.js +4 -4
  32. package/dist/axis/boundary/BoundaryAxis.js.map +1 -0
  33. package/dist/{schema/axis → axis}/lifecycle/Clock.d.ts +1 -1
  34. package/dist/axis/lifecycle/Clock.d.ts.map +1 -0
  35. package/dist/{schema/axis → axis}/lifecycle/Clock.js +1 -1
  36. package/dist/axis/lifecycle/Clock.js.map +1 -0
  37. package/dist/axis/lifecycle/Generators.d.ts +10 -0
  38. package/dist/axis/lifecycle/Generators.d.ts.map +1 -0
  39. package/dist/axis/lifecycle/Generators.js +20 -0
  40. package/dist/axis/lifecycle/Generators.js.map +1 -0
  41. package/dist/axis/lifecycle/Lifecycle.d.ts.map +1 -0
  42. package/dist/axis/lifecycle/Lifecycle.js.map +1 -0
  43. package/dist/axis/lifecycle/LifecycleAxis.d.ts.map +1 -0
  44. package/dist/{schema/axis → axis}/lifecycle/LifecycleAxis.js +11 -6
  45. package/dist/axis/lifecycle/LifecycleAxis.js.map +1 -0
  46. package/dist/axis/lifecycle/apply.d.ts +15 -0
  47. package/dist/axis/lifecycle/apply.d.ts.map +1 -0
  48. package/dist/axis/lifecycle/apply.js +50 -0
  49. package/dist/axis/lifecycle/apply.js.map +1 -0
  50. package/dist/{schema/axis → axis}/role/Relation.d.ts +3 -2
  51. package/dist/axis/role/Relation.d.ts.map +1 -0
  52. package/dist/{schema/axis → axis}/role/Relation.js +6 -5
  53. package/dist/axis/role/Relation.js.map +1 -0
  54. package/dist/{schema/axis → axis}/role/Role.d.ts +6 -6
  55. package/dist/axis/role/Role.d.ts.map +1 -0
  56. package/dist/axis/role/Role.js +36 -0
  57. package/dist/axis/role/Role.js.map +1 -0
  58. package/dist/{schema/axis → axis}/role/RoleAxis.d.ts +1 -1
  59. package/dist/axis/role/RoleAxis.d.ts.map +1 -0
  60. package/dist/{schema/axis → axis}/role/RoleAxis.js +28 -36
  61. package/dist/axis/role/RoleAxis.js.map +1 -0
  62. package/dist/axis/shape/Formats.d.ts +11 -0
  63. package/dist/axis/shape/Formats.d.ts.map +1 -0
  64. package/dist/axis/shape/Formats.js +9 -0
  65. package/dist/axis/shape/Formats.js.map +1 -0
  66. package/dist/{schema/axis → axis}/shape/Shape.d.ts +12 -3
  67. package/dist/axis/shape/Shape.d.ts.map +1 -0
  68. package/dist/axis/shape/Shape.js +77 -0
  69. package/dist/axis/shape/Shape.js.map +1 -0
  70. package/dist/entity/EntityAdapterSet.d.ts +22 -0
  71. package/dist/entity/EntityAdapterSet.d.ts.map +1 -0
  72. package/dist/entity/EntityAdapterSet.js +63 -0
  73. package/dist/entity/EntityAdapterSet.js.map +1 -0
  74. package/dist/entity/EntityAdapters.d.ts +1 -24
  75. package/dist/entity/EntityAdapters.d.ts.map +1 -1
  76. package/dist/entity/EntityAdapters.js +1 -74
  77. package/dist/entity/EntityAdapters.js.map +1 -1
  78. package/dist/entity/EntityDeclarations.d.ts +1 -1
  79. package/dist/entity/EntityDeclarations.d.ts.map +1 -1
  80. package/dist/entity.d.ts +7 -2
  81. package/dist/entity.d.ts.map +1 -1
  82. package/dist/entity.js +6 -1
  83. package/dist/entity.js.map +1 -1
  84. package/dist/{schema/fields → field}/Field.d.ts +3 -5
  85. package/dist/field/Field.d.ts.map +1 -0
  86. package/dist/field/Field.js +35 -0
  87. package/dist/field/Field.js.map +1 -0
  88. package/dist/field/FieldSet.d.ts +22 -0
  89. package/dist/field/FieldSet.d.ts.map +1 -0
  90. package/dist/field/FieldSet.js +58 -0
  91. package/dist/field/FieldSet.js.map +1 -0
  92. package/dist/index.d.ts +26 -56
  93. package/dist/index.d.ts.map +1 -1
  94. package/dist/index.js +21 -47
  95. package/dist/index.js.map +1 -1
  96. package/dist/lib/Registry.d.ts +12 -0
  97. package/dist/lib/Registry.d.ts.map +1 -0
  98. package/dist/lib/Registry.js +29 -0
  99. package/dist/lib/Registry.js.map +1 -0
  100. package/dist/lib/index.d.ts +3 -0
  101. package/dist/lib/index.d.ts.map +1 -0
  102. package/dist/lib/index.js +3 -0
  103. package/dist/lib/index.js.map +1 -0
  104. package/dist/lib/utils.d.ts.map +1 -0
  105. package/dist/lib/utils.js.map +1 -0
  106. package/dist/projection/Cases.d.ts +9 -20
  107. package/dist/projection/Cases.d.ts.map +1 -1
  108. package/dist/projection/Cases.js +44 -39
  109. package/dist/projection/Cases.js.map +1 -1
  110. package/dist/projection/Visibility.d.ts +2 -1
  111. package/dist/projection/Visibility.d.ts.map +1 -1
  112. package/dist/projection/Visibility.js +4 -3
  113. package/dist/projection/Visibility.js.map +1 -1
  114. package/dist/projection/card/Bundle.d.ts +1 -1
  115. package/dist/projection/card/Bundle.d.ts.map +1 -1
  116. package/dist/projection/card/Bundle.js +7 -7
  117. package/dist/projection/card/Bundle.js.map +1 -1
  118. package/dist/projection/card/Card.d.ts +7 -13
  119. package/dist/projection/card/Card.d.ts.map +1 -1
  120. package/dist/projection/card/Card.js +101 -70
  121. package/dist/projection/card/Card.js.map +1 -1
  122. package/dist/projection/card/Descriptor.d.ts +7 -7
  123. package/dist/projection/card/Descriptor.d.ts.map +1 -1
  124. package/dist/projection/card/admission.d.ts +21 -5
  125. package/dist/projection/card/admission.d.ts.map +1 -1
  126. package/dist/projection/card/admission.js +33 -5
  127. package/dist/projection/card/admission.js.map +1 -1
  128. package/dist/projection/card/diff.d.ts +2 -2
  129. package/dist/projection/card/diff.d.ts.map +1 -1
  130. package/dist/{judge/result.d.ts → validation.d.ts} +1 -1
  131. package/dist/validation.d.ts.map +1 -0
  132. package/dist/validation.js +2 -0
  133. package/dist/validation.js.map +1 -0
  134. package/dist/validator/AdapterFieldValidator.d.ts +14 -0
  135. package/dist/validator/AdapterFieldValidator.d.ts.map +1 -0
  136. package/dist/validator/AdapterFieldValidator.js +36 -0
  137. package/dist/validator/AdapterFieldValidator.js.map +1 -0
  138. package/dist/validator/FieldDeclarationValidator.d.ts +9 -0
  139. package/dist/validator/FieldDeclarationValidator.d.ts.map +1 -0
  140. package/dist/{judge/FieldJudge.js → validator/FieldDeclarationValidator.js} +8 -8
  141. package/dist/validator/FieldDeclarationValidator.js.map +1 -0
  142. package/dist/validator/FieldValueValidator.d.ts +13 -0
  143. package/dist/validator/FieldValueValidator.d.ts.map +1 -0
  144. package/dist/{judge/ValueJudge.js → validator/FieldValueValidator.js} +12 -11
  145. package/dist/validator/FieldValueValidator.js.map +1 -0
  146. package/dist/validator/InputRefusal.d.ts +8 -0
  147. package/dist/validator/InputRefusal.d.ts.map +1 -0
  148. package/dist/validator/InputRefusal.js +8 -0
  149. package/dist/validator/InputRefusal.js.map +1 -0
  150. package/dist/validator/InputValidator.d.ts +15 -0
  151. package/dist/validator/InputValidator.d.ts.map +1 -0
  152. package/dist/{judge/RowJudge.js → validator/InputValidator.js} +25 -21
  153. package/dist/validator/InputValidator.js.map +1 -0
  154. package/dist/vocabulary/bool.d.ts +6 -1
  155. package/dist/vocabulary/bool.d.ts.map +1 -1
  156. package/dist/vocabulary/bool.js +6 -1
  157. package/dist/vocabulary/bool.js.map +1 -1
  158. package/dist/vocabulary/created.d.ts +6 -1
  159. package/dist/vocabulary/created.d.ts.map +1 -1
  160. package/dist/vocabulary/created.js +5 -0
  161. package/dist/vocabulary/created.js.map +1 -1
  162. package/dist/vocabulary/date.d.ts +6 -1
  163. package/dist/vocabulary/date.d.ts.map +1 -1
  164. package/dist/vocabulary/date.js +6 -1
  165. package/dist/vocabulary/date.js.map +1 -1
  166. package/dist/vocabulary/email.d.ts +6 -1
  167. package/dist/vocabulary/email.d.ts.map +1 -1
  168. package/dist/vocabulary/email.js +5 -0
  169. package/dist/vocabulary/email.js.map +1 -1
  170. package/dist/vocabulary/immutable.d.ts +6 -1
  171. package/dist/vocabulary/immutable.d.ts.map +1 -1
  172. package/dist/vocabulary/immutable.js +5 -0
  173. package/dist/vocabulary/immutable.js.map +1 -1
  174. package/dist/vocabulary/index.d.ts +23 -0
  175. package/dist/vocabulary/index.d.ts.map +1 -0
  176. package/dist/vocabulary/index.js +23 -0
  177. package/dist/vocabulary/index.js.map +1 -0
  178. package/dist/vocabulary/indexed.d.ts +6 -1
  179. package/dist/vocabulary/indexed.d.ts.map +1 -1
  180. package/dist/vocabulary/indexed.js +5 -0
  181. package/dist/vocabulary/indexed.js.map +1 -1
  182. package/dist/vocabulary/json.d.ts +2 -2
  183. package/dist/vocabulary/json.d.ts.map +1 -1
  184. package/dist/vocabulary/json.js +9 -4
  185. package/dist/vocabulary/json.js.map +1 -1
  186. package/dist/vocabulary/list.d.ts +6 -1
  187. package/dist/vocabulary/list.d.ts.map +1 -1
  188. package/dist/vocabulary/list.js +6 -1
  189. package/dist/vocabulary/list.js.map +1 -1
  190. package/dist/vocabulary/many.d.ts +7 -2
  191. package/dist/vocabulary/many.d.ts.map +1 -1
  192. package/dist/vocabulary/many.js +7 -2
  193. package/dist/vocabulary/many.js.map +1 -1
  194. package/dist/vocabulary/nullable.d.ts +6 -1
  195. package/dist/vocabulary/nullable.d.ts.map +1 -1
  196. package/dist/vocabulary/nullable.js +7 -2
  197. package/dist/vocabulary/nullable.js.map +1 -1
  198. package/dist/vocabulary/number.d.ts +6 -1
  199. package/dist/vocabulary/number.d.ts.map +1 -1
  200. package/dist/vocabulary/number.js +6 -1
  201. package/dist/vocabulary/number.js.map +1 -1
  202. package/dist/vocabulary/oneOf.d.ts +1 -1
  203. package/dist/vocabulary/oneOf.d.ts.map +1 -1
  204. package/dist/vocabulary/oneOf.js +6 -1
  205. package/dist/vocabulary/oneOf.js.map +1 -1
  206. package/dist/vocabulary/optional.d.ts +6 -1
  207. package/dist/vocabulary/optional.d.ts.map +1 -1
  208. package/dist/vocabulary/optional.js +7 -2
  209. package/dist/vocabulary/optional.js.map +1 -1
  210. package/dist/vocabulary/primary.d.ts +2 -2
  211. package/dist/vocabulary/primary.d.ts.map +1 -1
  212. package/dist/vocabulary/primary.js +7 -2
  213. package/dist/vocabulary/primary.js.map +1 -1
  214. package/dist/vocabulary/readOnly.d.ts +6 -1
  215. package/dist/vocabulary/readOnly.d.ts.map +1 -1
  216. package/dist/vocabulary/readOnly.js +6 -1
  217. package/dist/vocabulary/readOnly.js.map +1 -1
  218. package/dist/vocabulary/ref.d.ts +7 -2
  219. package/dist/vocabulary/ref.d.ts.map +1 -1
  220. package/dist/vocabulary/ref.js +7 -2
  221. package/dist/vocabulary/ref.js.map +1 -1
  222. package/dist/vocabulary/text.d.ts +7 -2
  223. package/dist/vocabulary/text.d.ts.map +1 -1
  224. package/dist/vocabulary/text.js +6 -1
  225. package/dist/vocabulary/text.js.map +1 -1
  226. package/dist/vocabulary/unique.d.ts +6 -1
  227. package/dist/vocabulary/unique.d.ts.map +1 -1
  228. package/dist/vocabulary/unique.js +7 -3
  229. package/dist/vocabulary/unique.js.map +1 -1
  230. package/dist/vocabulary/updated.d.ts +6 -1
  231. package/dist/vocabulary/updated.d.ts.map +1 -1
  232. package/dist/vocabulary/updated.js +5 -0
  233. package/dist/vocabulary/updated.js.map +1 -1
  234. package/dist/vocabulary/url.d.ts +6 -1
  235. package/dist/vocabulary/url.d.ts.map +1 -1
  236. package/dist/vocabulary/url.js +5 -0
  237. package/dist/vocabulary/url.js.map +1 -1
  238. package/dist/vocabulary/vocabulary.d.ts +6 -1
  239. package/dist/vocabulary/vocabulary.d.ts.map +1 -1
  240. package/dist/vocabulary/vocabulary.js +22 -12
  241. package/dist/vocabulary/vocabulary.js.map +1 -1
  242. package/dist/vocabulary/writeOnly.d.ts +6 -1
  243. package/dist/vocabulary/writeOnly.d.ts.map +1 -1
  244. package/dist/vocabulary/writeOnly.js +6 -1
  245. package/dist/vocabulary/writeOnly.js.map +1 -1
  246. package/package.json +1 -1
  247. package/src/{schema/Schema.ts → Schema.ts} +32 -75
  248. package/src/SchemaDefinition.ts +257 -0
  249. package/src/SchemaDerivation.ts +44 -0
  250. package/src/{schema/SchemaView.ts → SchemaView.ts} +9 -9
  251. package/src/{schema/axis → axis}/Axis.ts +2 -2
  252. package/src/axis/boundary/Boundaries.ts +37 -0
  253. package/src/{schema/axis → axis}/boundary/Boundary.ts +9 -7
  254. package/src/{schema/axis → axis}/boundary/BoundaryAxis.ts +4 -4
  255. package/src/{schema/axis → axis}/lifecycle/Clock.ts +1 -1
  256. package/src/axis/lifecycle/Generators.ts +29 -0
  257. package/src/{schema/axis → axis}/lifecycle/LifecycleAxis.ts +12 -7
  258. package/src/axis/lifecycle/apply.ts +53 -0
  259. package/src/{schema/axis → axis}/role/Relation.ts +6 -5
  260. package/src/axis/role/Role.ts +52 -0
  261. package/src/{schema/axis → axis}/role/RoleAxis.ts +28 -40
  262. package/src/axis/shape/Formats.ts +20 -0
  263. package/src/{schema/axis → axis}/shape/Shape.ts +45 -18
  264. package/src/entity/EntityAdapterSet.ts +81 -0
  265. package/src/entity/EntityAdapters.ts +4 -96
  266. package/src/entity/EntityDeclarations.ts +1 -1
  267. package/src/entity.ts +7 -2
  268. package/src/{schema/fields → field}/Field.ts +8 -28
  269. package/src/field/FieldSet.ts +75 -0
  270. package/src/index.ts +34 -91
  271. package/src/lib/Registry.ts +37 -0
  272. package/src/lib/index.ts +2 -0
  273. package/src/projection/Cases.ts +56 -55
  274. package/src/projection/Visibility.ts +5 -4
  275. package/src/projection/card/Bundle.ts +9 -9
  276. package/src/projection/card/Card.ts +109 -75
  277. package/src/projection/card/Descriptor.ts +7 -7
  278. package/src/projection/card/admission.ts +37 -6
  279. package/src/projection/card/diff.ts +2 -2
  280. package/src/validator/AdapterFieldValidator.ts +40 -0
  281. package/src/{judge/FieldJudge.ts → validator/FieldDeclarationValidator.ts} +10 -10
  282. package/src/{judge/ValueJudge.ts → validator/FieldValueValidator.ts} +14 -13
  283. package/src/validator/InputRefusal.ts +7 -0
  284. package/src/{judge/RowJudge.ts → validator/InputValidator.ts} +31 -24
  285. package/src/vocabulary/bool.ts +6 -1
  286. package/src/vocabulary/created.ts +6 -1
  287. package/src/vocabulary/date.ts +6 -1
  288. package/src/vocabulary/email.ts +6 -1
  289. package/src/vocabulary/immutable.ts +6 -1
  290. package/src/vocabulary/index.ts +22 -0
  291. package/src/vocabulary/indexed.ts +6 -1
  292. package/src/vocabulary/json.ts +10 -5
  293. package/src/vocabulary/list.ts +6 -1
  294. package/src/vocabulary/many.ts +7 -2
  295. package/src/vocabulary/nullable.ts +8 -3
  296. package/src/vocabulary/number.ts +6 -1
  297. package/src/vocabulary/oneOf.ts +6 -1
  298. package/src/vocabulary/optional.ts +8 -3
  299. package/src/vocabulary/primary.ts +7 -2
  300. package/src/vocabulary/readOnly.ts +7 -2
  301. package/src/vocabulary/ref.ts +7 -2
  302. package/src/vocabulary/text.ts +7 -2
  303. package/src/vocabulary/unique.ts +8 -4
  304. package/src/vocabulary/updated.ts +6 -1
  305. package/src/vocabulary/url.ts +6 -1
  306. package/src/vocabulary/vocabulary.ts +22 -12
  307. package/src/vocabulary/writeOnly.ts +7 -2
  308. package/dist/judge/FieldJudge.d.ts +0 -9
  309. package/dist/judge/FieldJudge.d.ts.map +0 -1
  310. package/dist/judge/FieldJudge.js.map +0 -1
  311. package/dist/judge/RowJudge.d.ts +0 -12
  312. package/dist/judge/RowJudge.d.ts.map +0 -1
  313. package/dist/judge/RowJudge.js.map +0 -1
  314. package/dist/judge/RowRefusal.d.ts +0 -17
  315. package/dist/judge/RowRefusal.d.ts.map +0 -1
  316. package/dist/judge/RowRefusal.js +0 -16
  317. package/dist/judge/RowRefusal.js.map +0 -1
  318. package/dist/judge/ValueJudge.d.ts +0 -12
  319. package/dist/judge/ValueJudge.d.ts.map +0 -1
  320. package/dist/judge/ValueJudge.js.map +0 -1
  321. package/dist/judge/options.d.ts +0 -4
  322. package/dist/judge/options.d.ts.map +0 -1
  323. package/dist/judge/options.js +0 -2
  324. package/dist/judge/options.js.map +0 -1
  325. package/dist/judge/result.d.ts.map +0 -1
  326. package/dist/judge/result.js +0 -2
  327. package/dist/judge/result.js.map +0 -1
  328. package/dist/projection/SchemaOrCard.d.ts +0 -7
  329. package/dist/projection/SchemaOrCard.d.ts.map +0 -1
  330. package/dist/projection/SchemaOrCard.js +0 -11
  331. package/dist/projection/SchemaOrCard.js.map +0 -1
  332. package/dist/projection/card/EntityTypeSource.d.ts +0 -12
  333. package/dist/projection/card/EntityTypeSource.d.ts.map +0 -1
  334. package/dist/projection/card/EntityTypeSource.js +0 -78
  335. package/dist/projection/card/EntityTypeSource.js.map +0 -1
  336. package/dist/projection/card/FacadeTypeSource.d.ts +0 -19
  337. package/dist/projection/card/FacadeTypeSource.d.ts.map +0 -1
  338. package/dist/projection/card/FacadeTypeSource.js +0 -40
  339. package/dist/projection/card/FacadeTypeSource.js.map +0 -1
  340. package/dist/schema/Schema.d.ts.map +0 -1
  341. package/dist/schema/Schema.js.map +0 -1
  342. package/dist/schema/SchemaDefinition.d.ts +0 -60
  343. package/dist/schema/SchemaDefinition.d.ts.map +0 -1
  344. package/dist/schema/SchemaDefinition.js +0 -85
  345. package/dist/schema/SchemaDefinition.js.map +0 -1
  346. package/dist/schema/SchemaDerivation.d.ts +0 -34
  347. package/dist/schema/SchemaDerivation.d.ts.map +0 -1
  348. package/dist/schema/SchemaDerivation.js +0 -51
  349. package/dist/schema/SchemaDerivation.js.map +0 -1
  350. package/dist/schema/SchemaView.d.ts.map +0 -1
  351. package/dist/schema/axis/Axis.d.ts.map +0 -1
  352. package/dist/schema/axis/Axis.js.map +0 -1
  353. package/dist/schema/axis/Meta.d.ts.map +0 -1
  354. package/dist/schema/axis/boundary/Boundaries.d.ts +0 -20
  355. package/dist/schema/axis/boundary/Boundaries.d.ts.map +0 -1
  356. package/dist/schema/axis/boundary/Boundaries.js +0 -31
  357. package/dist/schema/axis/boundary/Boundaries.js.map +0 -1
  358. package/dist/schema/axis/boundary/Boundary.d.ts.map +0 -1
  359. package/dist/schema/axis/boundary/Boundary.js.map +0 -1
  360. package/dist/schema/axis/boundary/BoundaryAxis.d.ts.map +0 -1
  361. package/dist/schema/axis/boundary/BoundaryAxis.js.map +0 -1
  362. package/dist/schema/axis/lifecycle/Clock.d.ts.map +0 -1
  363. package/dist/schema/axis/lifecycle/Clock.js.map +0 -1
  364. package/dist/schema/axis/lifecycle/Generators.d.ts +0 -18
  365. package/dist/schema/axis/lifecycle/Generators.d.ts.map +0 -1
  366. package/dist/schema/axis/lifecycle/Generators.js +0 -38
  367. package/dist/schema/axis/lifecycle/Generators.js.map +0 -1
  368. package/dist/schema/axis/lifecycle/Lifecycle.d.ts.map +0 -1
  369. package/dist/schema/axis/lifecycle/Lifecycle.js.map +0 -1
  370. package/dist/schema/axis/lifecycle/LifecycleAxis.d.ts.map +0 -1
  371. package/dist/schema/axis/lifecycle/LifecycleAxis.js.map +0 -1
  372. package/dist/schema/axis/lifecycle/apply.d.ts +0 -6
  373. package/dist/schema/axis/lifecycle/apply.d.ts.map +0 -1
  374. package/dist/schema/axis/lifecycle/apply.js +0 -34
  375. package/dist/schema/axis/lifecycle/apply.js.map +0 -1
  376. package/dist/schema/axis/role/Relation.d.ts.map +0 -1
  377. package/dist/schema/axis/role/Relation.js.map +0 -1
  378. package/dist/schema/axis/role/Role.d.ts.map +0 -1
  379. package/dist/schema/axis/role/Role.js +0 -40
  380. package/dist/schema/axis/role/Role.js.map +0 -1
  381. package/dist/schema/axis/role/RoleAxis.d.ts.map +0 -1
  382. package/dist/schema/axis/role/RoleAxis.js.map +0 -1
  383. package/dist/schema/axis/shape/Formats.d.ts +0 -8
  384. package/dist/schema/axis/shape/Formats.d.ts.map +0 -1
  385. package/dist/schema/axis/shape/Formats.js +0 -10
  386. package/dist/schema/axis/shape/Formats.js.map +0 -1
  387. package/dist/schema/axis/shape/Shape.d.ts.map +0 -1
  388. package/dist/schema/axis/shape/Shape.js +0 -52
  389. package/dist/schema/axis/shape/Shape.js.map +0 -1
  390. package/dist/schema/fields/Field.d.ts.map +0 -1
  391. package/dist/schema/fields/Field.js +0 -52
  392. package/dist/schema/fields/Field.js.map +0 -1
  393. package/dist/schema/fields/FieldSet.d.ts +0 -28
  394. package/dist/schema/fields/FieldSet.d.ts.map +0 -1
  395. package/dist/schema/fields/FieldSet.js +0 -55
  396. package/dist/schema/fields/FieldSet.js.map +0 -1
  397. package/dist/schema/fields/constraint/FieldGroup.d.ts +0 -21
  398. package/dist/schema/fields/constraint/FieldGroup.d.ts.map +0 -1
  399. package/dist/schema/fields/constraint/FieldGroup.js +0 -65
  400. package/dist/schema/fields/constraint/FieldGroup.js.map +0 -1
  401. package/dist/schema/fields/constraint/Unique.d.ts +0 -4
  402. package/dist/schema/fields/constraint/Unique.d.ts.map +0 -1
  403. package/dist/schema/fields/constraint/Unique.js +0 -4
  404. package/dist/schema/fields/constraint/Unique.js.map +0 -1
  405. package/dist/utils.d.ts.map +0 -1
  406. package/dist/utils.js.map +0 -1
  407. package/src/judge/RowRefusal.ts +0 -17
  408. package/src/judge/options.ts +0 -3
  409. package/src/projection/SchemaOrCard.ts +0 -18
  410. package/src/projection/card/EntityTypeSource.ts +0 -90
  411. package/src/projection/card/FacadeTypeSource.ts +0 -55
  412. package/src/schema/SchemaDefinition.ts +0 -150
  413. package/src/schema/SchemaDerivation.ts +0 -65
  414. package/src/schema/axis/boundary/Boundaries.ts +0 -44
  415. package/src/schema/axis/lifecycle/Generators.ts +0 -46
  416. package/src/schema/axis/lifecycle/apply.ts +0 -39
  417. package/src/schema/axis/role/Role.ts +0 -56
  418. package/src/schema/axis/shape/Formats.ts +0 -22
  419. package/src/schema/fields/FieldSet.ts +0 -63
  420. package/src/schema/fields/constraint/FieldGroup.ts +0 -84
  421. package/src/schema/fields/constraint/Unique.ts +0 -3
  422. /package/dist/{schema/SchemaView.js → SchemaView.js} +0 -0
  423. /package/dist/{schema/axis → axis}/Axis.js +0 -0
  424. /package/dist/{schema/axis → axis}/Meta.d.ts +0 -0
  425. /package/dist/{schema/axis → axis}/Meta.js +0 -0
  426. /package/dist/{schema/axis → axis}/boundary/BoundaryAxis.d.ts +0 -0
  427. /package/dist/{schema/axis → axis}/lifecycle/Lifecycle.d.ts +0 -0
  428. /package/dist/{schema/axis → axis}/lifecycle/Lifecycle.js +0 -0
  429. /package/dist/{schema/axis → axis}/lifecycle/LifecycleAxis.d.ts +0 -0
  430. /package/dist/{utils.d.ts → lib/utils.d.ts} +0 -0
  431. /package/dist/{utils.js → lib/utils.js} +0 -0
  432. /package/src/{schema/axis → axis}/Meta.ts +0 -0
  433. /package/src/{schema/axis → axis}/lifecycle/Lifecycle.ts +0 -0
  434. /package/src/{utils.ts → lib/utils.ts} +0 -0
  435. /package/src/{judge/result.ts → validation.ts} +0 -0
@@ -1,65 +0,0 @@
1
- export class FieldGroup {
2
- members;
3
- constructor(members) {
4
- this.members = members;
5
- }
6
- withMembers(members) {
7
- return new this.constructor(members);
8
- }
9
- get isSelf() {
10
- return this.members.length === 0;
11
- }
12
- resolvedOn(ownKey) {
13
- return this.isSelf ? this.withMembers([ownKey]) : this;
14
- }
15
- covers(key) {
16
- return this.members.includes(key);
17
- }
18
- equals(other) {
19
- return (this.constructor === other.constructor &&
20
- this.members.length === other.members.length &&
21
- this.members.every((member, i) => member === other.members[i]));
22
- }
23
- onto(fields) {
24
- const missing = this.members.filter((key) => !(key in fields));
25
- if (missing.length)
26
- throw new Error(`${this.constructor.name.toLowerCase()}: [${this.members.join(', ')}] names ` +
27
- `${missing.map((m) => `'${m}'`).join(', ')}, which the entity does not declare.`);
28
- const out = { ...fields };
29
- for (const key of this.members) {
30
- const field = out[key];
31
- out[key] = field.with({
32
- role: { ...field.role, rules: [...(field.role?.rules ?? []), this] },
33
- });
34
- }
35
- return out;
36
- }
37
- rename(map) {
38
- if (this.isSelf)
39
- return this;
40
- const carried = this.members.map(map);
41
- return carried.every((key) => key !== undefined)
42
- ? this.withMembers(carried)
43
- : null;
44
- }
45
- toJSON() {
46
- return [...this.members];
47
- }
48
- static normalize(groups, make) {
49
- if (!groups)
50
- return undefined;
51
- return groups.map((group) => group instanceof FieldGroup ? group : make(group));
52
- }
53
- static on(field, kind) {
54
- return (field.role?.rules ?? []).filter((rule) => rule instanceof kind);
55
- }
56
- static groupsOf(fields, kind) {
57
- const seen = new Map();
58
- for (const field of Object.values(fields))
59
- for (const rule of FieldGroup.on(field, kind))
60
- if (rule.members.length > 1)
61
- seen.set(rule.members.join(' '), rule);
62
- return [...seen.values()];
63
- }
64
- }
65
- //# sourceMappingURL=FieldGroup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FieldGroup.js","sourceRoot":"","sources":["../../../../src/schema/fields/constraint/FieldGroup.ts"],"names":[],"mappings":"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"}
@@ -1,4 +0,0 @@
1
- import { FieldGroup } from './FieldGroup.js';
2
- export declare class Unique extends FieldGroup {
3
- }
4
- //# sourceMappingURL=Unique.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Unique.d.ts","sourceRoot":"","sources":["../../../../src/schema/fields/constraint/Unique.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,qBAAa,MAAO,SAAQ,UAAU;CAAG"}
@@ -1,4 +0,0 @@
1
- import { FieldGroup } from './FieldGroup.js';
2
- export class Unique extends FieldGroup {
3
- }
4
- //# sourceMappingURL=Unique.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Unique.js","sourceRoot":"","sources":["../../../../src/schema/fields/constraint/Unique.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,OAAO,MAAO,SAAQ,UAAU;CAAG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAIlE;AAED,eAAO,MAAM,QAAQ,UAAW,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CACH,CAAC"}
package/dist/utils.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,KAAK,CAAoC,GAAM;IAC7D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;IAEhF,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CAC3E,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
@@ -1,17 +0,0 @@
1
- /**
2
- * Every way a row is refused for its STRUCTURE — the closed set, stated once.
3
- *
4
- * A value refused by its own shape carries the engine's message and a decoder refused by
5
- * user code carries that code's; neither is structural and neither belongs here. These
6
- * five are `RowJudge`'s own, and a table of cases enumerates them instead of reading the
7
- * text of a function — which a minifier rewrites without a word.
8
- */
9
- export const RowRefusal = {
10
- notAnObject: 'Expected an object',
11
- unknownField: 'Unknown field',
12
- required: 'Required',
13
- readOnly: 'Read-only',
14
- immutable: 'Immutable',
15
- } as const;
16
-
17
- export type RowRefusal = (typeof RowRefusal)[keyof typeof RowRefusal];
@@ -1,3 +0,0 @@
1
- export interface ValidateOptions {
2
- patch?: boolean;
3
- }
@@ -1,18 +0,0 @@
1
- import type { Fields } from '../schema/fields/Field.js';
2
- import type { SchemaView } from '../schema/SchemaView.js';
3
- import type { SchemaDescriptor } from './card/Descriptor.js';
4
- import { Card } from './card/Card.js';
5
-
6
- export type SchemaOrCard = SchemaView | SchemaDescriptor;
7
-
8
- function isDescriptor(source: SchemaOrCard): source is SchemaDescriptor {
9
- return typeof (source as SchemaView).getFields !== 'function';
10
- }
11
-
12
- export function schemaOf(source: SchemaOrCard): SchemaView {
13
- return isDescriptor(source) ? Card.fromDescriptor(source).toSchema() : source;
14
- }
15
-
16
- export function fieldsOf(source: SchemaOrCard): Fields {
17
- return schemaOf(source).getFields();
18
- }
@@ -1,90 +0,0 @@
1
- import { upperFirst } from '../../utils.js';
2
- import type { FieldDescriptor, SchemaDescriptor } from './Descriptor.js';
3
-
4
- function typeOf(field: FieldDescriptor): string {
5
- const types = Array.isArray(field.type) ? field.type : field.type ? [field.type] : [];
6
- const nullable = types.includes('null');
7
- const base = types.find((t) => t !== 'null');
8
- const inner = baseTypeOf(base, field);
9
- return nullable ? `${inner} | null` : inner;
10
- }
11
-
12
- function baseTypeOf(base: string | undefined, field: FieldDescriptor): string {
13
- if (field.enum?.length) {
14
- return field.enum.map((v) => (v === null ? 'null' : JSON.stringify(v))).join(' | ');
15
- }
16
- switch (base) {
17
- case 'string':
18
- return field.format === 'date-time' ? 'Date' : 'string';
19
- case 'number':
20
- case 'integer':
21
- return 'number';
22
- case 'boolean':
23
- return 'boolean';
24
- case 'array':
25
- return field.items ? `${typeOf(field.items)}[]` : 'string[]';
26
- case 'object':
27
- return field.properties ? objectTypeOf(field.properties, field.required ?? []) : 'Record<string, unknown>';
28
- default:
29
- return 'unknown';
30
- }
31
- }
32
-
33
- function objectTypeOf(properties: Record<string, FieldDescriptor>, required: readonly string[]): string {
34
- const members = Object.entries(properties).map(([name, field]) => {
35
- const optional = required.includes(name) ? '' : '?';
36
- return `${propertyKey(name)}${optional}: ${typeOf(field)}`;
37
- });
38
- return `{ ${members.join('; ')} }`;
39
- }
40
-
41
- function propertyKey(name: string): string {
42
- return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name) ? name : JSON.stringify(name);
43
- }
44
-
45
- function docCommentOf(text: string | undefined, indent: string): string {
46
- if (!text) return '';
47
- return `${indent}/** ${text.replace(/\*\//g, '*\\/')} */\n`;
48
- }
49
-
50
- export interface EntityTypeSourceOptions {
51
- name?: string;
52
- exported?: boolean;
53
- }
54
-
55
- function shapeTypeOf(descriptor: SchemaDescriptor, indent = ''): string {
56
- const entries = Object.entries(descriptor.properties ?? {});
57
- if (entries.length === 0) return '{}';
58
-
59
- const lines = entries.map(([key, field]) => {
60
- const doc = docCommentOf(field.description, `${indent} `);
61
- return `${doc}${indent} ${propertyKey(key)}: ${typeOf(field)};`;
62
- });
63
- return `{\n${lines.join('\n')}\n${indent}}`;
64
- }
65
-
66
- export class EntityTypeSource {
67
- private constructor(private readonly descriptor: SchemaDescriptor) {}
68
-
69
- static of(descriptor: SchemaDescriptor): EntityTypeSource {
70
- return new EntityTypeSource(descriptor);
71
- }
72
-
73
- render(options: EntityTypeSourceOptions = {}): string {
74
- const name = identifierOf(options.name ?? upperFirst(this.descriptor.title ?? 'Schema'));
75
- const exported = options.exported === false ? '' : 'export ';
76
- const card = JSON.stringify(this.descriptor, null, 2)
77
- .split('\n')
78
- .map((line, i) => (i === 0 ? line : ` ${line}`))
79
- .join('\n');
80
-
81
- return `${exported}class ${name} extends Card.fromDescriptor<${shapeTypeOf(this.descriptor)}>(${card}).toSchema() {}`;
82
- }
83
- }
84
-
85
- function identifierOf(name: string): string {
86
- if (!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name)) {
87
- throw new Error(`'${name}' is not a TypeScript identifier — it cannot name a generated declaration`);
88
- }
89
- return name;
90
- }
@@ -1,55 +0,0 @@
1
- import type { SchemaDescriptor } from './Descriptor.js';
2
-
3
- export interface FacadeTypeSourceOptions {
4
- name?: string;
5
- exported?: boolean;
6
- rowType?: string;
7
- }
8
-
9
- export interface OpDescriptor {
10
- name: string;
11
- description?: string;
12
- output?: SchemaDescriptor;
13
- cardinality?: 'one' | 'maybe' | 'many' | 'page' | 'none';
14
- }
15
-
16
- function propertyKey(name: string): string {
17
- return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name) ? name : JSON.stringify(name);
18
- }
19
-
20
- function docCommentOf(text: string | undefined, indent: string): string {
21
- if (!text) return '';
22
- return `${indent}/** ${text.replace(/\*\//g, '*\\/')} */\n`;
23
- }
24
-
25
- function returnTypeOf(op: OpDescriptor, rowType: string): string {
26
- switch (op.cardinality) {
27
- case 'many': return `${rowType}[]`;
28
- case 'page': return `${rowType}[] & { total?: number; endCursor?: string; hasMore?: boolean }`;
29
- case 'maybe': return `${rowType} | undefined`;
30
- case 'one': return rowType;
31
- case 'none': return 'unknown';
32
- default: return 'unknown';
33
- }
34
- }
35
-
36
- export class FacadeTypeSource {
37
- private constructor(private readonly operations: readonly OpDescriptor[]) {}
38
-
39
- static of(operations: readonly OpDescriptor[]): FacadeTypeSource {
40
- return new FacadeTypeSource(operations);
41
- }
42
-
43
- render(options: FacadeTypeSourceOptions = {}): string {
44
- const name = options.name ?? 'Facade';
45
- const exported = options.exported === false ? '' : 'export ';
46
- const rowType = options.rowType ?? 'unknown';
47
- const members = this.operations.map((operation) => {
48
- const doc = docCommentOf(operation.description, ' ');
49
- return `${doc} ${propertyKey(operation.name)}(invocation?: Invocation): Promise<${returnTypeOf(operation, rowType)}>;`;
50
- });
51
-
52
- if (members.length === 0) return `${exported}interface ${name} {}`;
53
- return `${exported}interface ${name} {\n${members.join('\n')}\n}`;
54
- }
55
- }
@@ -1,150 +0,0 @@
1
- import { type Fields } from './fields/Field.js';
2
- import { FieldSet } from './fields/FieldSet.js';
3
- import {
4
- type EntityDeclarations,
5
- type PreviousNames,
6
- } from '../entity/EntityDeclarations.js';
7
- import { EntityAdapterSet, type EntityAdapters } from '../entity/EntityAdapters.js';
8
- import { SchemaDerivation } from './SchemaDerivation.js';
9
- import { type ValidateOptions } from '../judge/options.js';
10
- import type { SchemaView } from './SchemaView.js';
11
-
12
- /**
13
- * Everything a schema IS, apart from being a class whose instances are rows.
14
- *
15
- * The members used to be that many statics assigned side by side, and every derivation
16
- * re-threaded them by hand — which is how one of them came to be dropped from a list
17
- * without anyone noticing. A transformation here returns a COMPLETE definition or it does
18
- * not compile, so no gesture can mix the fields of one with the options of another.
19
- *
20
- * Internal: it is not exported from the package and never appears on `SchemaConstructor`.
21
- * A user derives with `Order.pick(…)`, never `Order.definition.pick(…)`.
22
- */
23
- export class SchemaDefinition {
24
- private constructor(
25
- readonly fields: Fields,
26
- readonly adapters: EntityAdapters<Fields> | undefined,
27
- readonly opts: ValidateOptions,
28
- readonly previous: PreviousNames<Fields> | undefined,
29
- readonly derivation: SchemaDerivation | undefined,
30
- readonly anchored: boolean,
31
- ) {}
32
-
33
- static stated(said: {
34
- fields: Fields;
35
- adapters?: EntityAdapters<Fields>;
36
- opts?: ValidateOptions;
37
- previous?: PreviousNames<Fields>;
38
- derivation?: SchemaDerivation;
39
- anchored?: boolean;
40
- }): SchemaDefinition {
41
- return new SchemaDefinition(
42
- said.fields,
43
- EntityAdapterSet.of(said.adapters)?.stated,
44
- said.opts ?? {},
45
- said.previous,
46
- said.derivation,
47
- said.anchored ?? false,
48
- );
49
- }
50
-
51
- /**
52
- * What a schema states about ITSELF, folded into what it already states — one adapter
53
- * entry per field wins the later spelling, and a unique group is stamped on its members.
54
- */
55
- declaring(said: EntityDeclarations<Fields>): SchemaDefinition {
56
- return new SchemaDefinition(
57
- FieldSet.declared(this.fields, said.unique),
58
- EntityAdapterSet.merged([this.adapters, said.adapters])?.stated,
59
- this.opts,
60
- said.previous ?? this.previous,
61
- this.derivation,
62
- this.anchored,
63
- );
64
- }
65
-
66
- /**
67
- * The same schema, holding rows of its own. A derivation is an answer until it says this.
68
- */
69
- anchoring(): SchemaDefinition {
70
- return new SchemaDefinition(
71
- this.fields,
72
- this.adapters,
73
- this.opts,
74
- this.previous,
75
- this.derivation,
76
- true,
77
- );
78
- }
79
-
80
- /**
81
- * `pick`, `omit` and `rename` are one gesture: the fields that remain, and what became
82
- * of each name. What each adapter was handed follows the same correspondence, and so does the origin.
83
- */
84
- cut(
85
- fields: Fields,
86
- survives: (key: string) => string | undefined,
87
- root: SchemaView,
88
- ): SchemaDefinition {
89
- const renamed: Fields = {};
90
- for (const [key, field] of Object.entries(fields))
91
- renamed[key] = field.rename(survives);
92
- return new SchemaDefinition(
93
- renamed,
94
- EntityAdapterSet.of(this.adapters)?.cut(survives)?.stated,
95
- this.opts,
96
- undefined,
97
- this.origin(root).compose(survives),
98
- false,
99
- );
100
- }
101
-
102
- /** The same fields, judged as an update. */
103
- patched(root: SchemaView): SchemaDefinition {
104
- return new SchemaDefinition(
105
- { ...this.fields },
106
- this.adapters,
107
- { ...this.opts, patch: true },
108
- undefined,
109
- this.origin(root),
110
- false,
111
- );
112
- }
113
-
114
- /** The added fields have no origin, so the derivation is unchanged: it speaks of the root. */
115
- extended(extra: Fields, root: SchemaView): SchemaDefinition {
116
- return new SchemaDefinition(
117
- { ...this.fields, ...extra },
118
- this.adapters,
119
- this.opts,
120
- undefined,
121
- this.origin(root),
122
- false,
123
- );
124
- }
125
-
126
- /** Several views folded into one definition, which therefore has no single origin. */
127
- static merged(views: readonly SchemaView[]): SchemaDefinition {
128
- const fields: Fields = {};
129
- let opts: ValidateOptions = {};
130
- for (const view of views) {
131
- Object.assign(fields, view.getFields());
132
- opts = { ...opts, ...view.getOpts() };
133
- }
134
- const adapters = EntityAdapterSet.merged(
135
- views.map((view) => view.getAdapters()),
136
- )?.stated;
137
-
138
- return new SchemaDefinition(fields, adapters, opts, undefined, undefined, false);
139
- }
140
-
141
- /**
142
- * The origin this definition already carries, or the one `root` becomes. A schema that
143
- * is an ANCHOR holds rows of its own, so what is cut from it roots on IT and not on its own origin.
144
- */
145
- private origin(root: SchemaView): SchemaDerivation {
146
- if (!this.anchored && this.derivation) return this.derivation;
147
-
148
- return SchemaDerivation.first(root, this.fields);
149
- }
150
- }
@@ -1,65 +0,0 @@
1
- import { type Fields } from './fields/Field.js';
2
- import type { SchemaView } from './SchemaView.js';
3
-
4
- /**
5
- * What a derived schema says about its ORIGIN: the class it was cut from, and what the cut
6
- * left of each of that class's fields.
7
- *
8
- * The origin is the ROOT — `Post.pick(a, b).omit(b)` answers `Post` and never the
9
- * intermediate — so a chain is flattened rather than journalled, and the two halves cannot
10
- * disagree: a derivation always carries both, which `source` and `survived` as independent
11
- * properties could not promise.
12
- */
13
- export class SchemaDerivation {
14
- private constructor(
15
- readonly source: SchemaView,
16
- readonly survived: Readonly<Record<string, string | undefined>>,
17
- ) {}
18
-
19
- /** The first cut: every field of the origin still answers to its own name. */
20
- static first(source: SchemaView, fields: Fields): SchemaDerivation {
21
- return new SchemaDerivation(
22
- source,
23
- Object.fromEntries(Object.keys(fields).map((key) => [key, key])),
24
- );
25
- }
26
-
27
- /** The same origin, seen through one more cut. */
28
- compose(survives: (key: string) => string | undefined): SchemaDerivation {
29
- return new SchemaDerivation(
30
- this.source,
31
- Object.fromEntries(
32
- Object.entries(this.survived).map(([origin, here]) => [
33
- origin,
34
- here === undefined ? undefined : survives(here),
35
- ]),
36
- ),
37
- );
38
- }
39
-
40
- get sourceName(): string {
41
- return this.source.name;
42
- }
43
-
44
- /**
45
- * The anchor whose rows this describes — the nearest one going up, and a schema with no
46
- * origin of its own is one. An answer borrows its rows; this says from whom. Whether
47
- * those rows carry a key is a separate question: an anchor may have none.
48
- */
49
- get anchor(): SchemaView {
50
- const source = this.source;
51
-
52
- return source.anchored !== undefined || !source.derivation
53
- ? source
54
- : source.derivation.anchor;
55
- }
56
-
57
- /**
58
- * What the ROOT calls `key`, translated to the name it carries here — `undefined` when a
59
- * cut dropped it. A reader that needs something the root declared about a field asks the
60
- * root and comes back through this; it does not keep a copy of the answer.
61
- */
62
- hereFor(key: string): string | undefined {
63
- return this.survived[key];
64
- }
65
- }
@@ -1,44 +0,0 @@
1
- import type { BoundaryRules } from './Boundary.js';
2
-
3
- export type Decoder = (value: unknown) => { value: unknown } | { error: string };
4
- export type Encoder = (value: unknown) => unknown;
5
-
6
- export class Boundaries {
7
- private static readonly decoders = new Map<string, Decoder>();
8
- private static readonly encoders = new Map<string, Encoder>();
9
- private static readonly aliases = new Map<string, BoundaryRules>();
10
-
11
- static registerDecoder(name: string, fn: Decoder): void { this.decoders.set(name, fn); }
12
- static registerEncoder(name: string, fn: Encoder): void { this.encoders.set(name, fn); }
13
-
14
- static registerAlias(name: string, boundary: BoundaryRules): void { this.aliases.set(name, boundary); }
15
-
16
- static alias(name: string): BoundaryRules | undefined { return this.aliases.get(name); }
17
-
18
- static decoder(name: string): Decoder { return this.named(this.decoders, name, 'decoder'); }
19
- static encoder(name: string): Encoder { return this.named(this.encoders, name, 'encoder'); }
20
-
21
- private static named<T>(registry: Map<string, T>, name: string, kind: string): T {
22
- const fn = registry.get(name);
23
- if (!fn) {
24
- throw new Error(
25
- `Unknown boundary ${kind}: '${name}'. Register it with ` +
26
- `Boundaries.register${kind[0].toUpperCase()}${kind.slice(1)}('${name}', …).`,
27
- );
28
- }
29
- return fn;
30
- }
31
- }
32
-
33
- Boundaries.registerDecoder('isoDate', (value) => {
34
- if (value instanceof Date) return { value };
35
- if (typeof value === 'string') {
36
- const d = new Date(value);
37
- return Number.isNaN(d.getTime()) ? { error: 'Invalid date' } : { value: d };
38
- }
39
- return { error: 'Expected a date' };
40
- });
41
- Boundaries.registerEncoder('isoDate', (value) =>
42
- value instanceof Date ? value.toISOString() : value,
43
- );
44
- Boundaries.registerAlias('isoDate', { in: { decode: 'isoDate' }, out: { encode: 'isoDate' } });
@@ -1,46 +0,0 @@
1
- import { createId } from '@paralleldrive/cuid2';
2
-
3
- export type GeneratorRef = 'cuid2' | 'uuid' | 'nanoid' | (string & {});
4
-
5
- const NANOID_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
6
-
7
- function nanoid(): string {
8
- const bytes = new Uint8Array(21);
9
- globalThis.crypto.getRandomValues(bytes);
10
- return Array.from(bytes, (byte) => NANOID_ALPHABET[byte & 63]).join('');
11
- }
12
-
13
- /**
14
- * Who answers a `generate` by name — one registry per process, like `Formats` and
15
- * `Boundaries`.
16
- *
17
- * The three builtins are REGISTERED rather than switched on, which is what brings the
18
- * refusal back inside: a registry whose unknown name is refused by a `default:` branch in
19
- * its caller does not know what it holds, so it cannot say so.
20
- */
21
- export class Generators {
22
- private static readonly registry = new Map<string, () => string>([
23
- ['cuid2', createId],
24
- ['uuid', () => globalThis.crypto.randomUUID()],
25
- ['nanoid', nanoid],
26
- ]);
27
-
28
- static register(name: string, fn: () => string): void {
29
- this.registry.set(name, fn);
30
- }
31
-
32
- /** The generator this name stands for, refused by name when nothing does. */
33
- static resolve(ref: GeneratorRef): () => string {
34
- const found = this.registry.get(ref);
35
- if (found) return found;
36
- throw new Error(
37
- `Unknown generator '${ref}' — register it with Generators.register('${ref}', fn). ` +
38
- `This process answers ${[...this.registry.keys()].join(', ')}.`,
39
- );
40
- }
41
-
42
- /** Whether a name is answered, for a caller that must not throw to find out. */
43
- static answers(ref: GeneratorRef): boolean {
44
- return this.registry.has(ref);
45
- }
46
- }
@@ -1,39 +0,0 @@
1
- import { Lifecycle } from './Lifecycle.js';
2
- import { Generators } from './Generators.js';
3
- import { Clock } from './Clock.js';
4
- import { type Field, type Fields } from '../../fields/Field.js';
5
-
6
- type Row = Record<string, unknown>;
7
-
8
- export function applyCreate(fields: Fields, input: Row): Row {
9
- const out: Row = { ...input };
10
- const instant = Clock.now();
11
-
12
- for (const [name, field] of Object.entries(fields) as [string, Field][]) {
13
- if (name in out) continue;
14
- const rule = Lifecycle.of(field);
15
-
16
- if (rule.create === 'now') out[name] = new Date(instant);
17
- else if (rule.literal) out[name] = freshValue(rule.literal.value);
18
- else if (rule.generator) out[name] = Generators.resolve(rule.generator)();
19
- }
20
-
21
- return out;
22
- }
23
-
24
- function freshValue(value: unknown): unknown {
25
- if (value === null || typeof value !== 'object') return value;
26
- return structuredClone(value);
27
- }
28
-
29
- export function applyUpdate(fields: Fields, patch: Row): Row {
30
- const out: Row = { ...patch };
31
- const instant = Clock.now();
32
-
33
- for (const [name, field] of Object.entries(fields) as [string, Field][]) {
34
- if (Lifecycle.of(field).stampedOnUpdate && !(name in out))
35
- out[name] = new Date(instant);
36
- }
37
-
38
- return out;
39
- }