@fougere/schema 0.12.0-alpha.0 → 0.12.2-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 (348) hide show
  1. package/dist/FougereFieldAxes.d.ts +3 -0
  2. package/dist/FougereFieldAxes.d.ts.map +1 -0
  3. package/dist/FougereFieldAxes.js +2 -0
  4. package/dist/FougereFieldAxes.js.map +1 -0
  5. package/dist/Schema.d.ts +4 -3
  6. package/dist/Schema.d.ts.map +1 -1
  7. package/dist/Schema.js +3 -0
  8. package/dist/Schema.js.map +1 -1
  9. package/dist/SchemaConstraints.d.ts +13 -10
  10. package/dist/SchemaConstraints.d.ts.map +1 -1
  11. package/dist/SchemaConstraints.js +32 -20
  12. package/dist/SchemaConstraints.js.map +1 -1
  13. package/dist/SchemaDefinition.d.ts.map +1 -1
  14. package/dist/SchemaDefinition.js +6 -5
  15. package/dist/SchemaDefinition.js.map +1 -1
  16. package/dist/SchemaError.d.ts +4 -1
  17. package/dist/SchemaError.d.ts.map +1 -1
  18. package/dist/SchemaError.js +6 -3
  19. package/dist/SchemaError.js.map +1 -1
  20. package/dist/SchemaView.d.ts +3 -2
  21. package/dist/SchemaView.d.ts.map +1 -1
  22. package/dist/axis/Axes.d.ts +16 -0
  23. package/dist/axis/Axes.d.ts.map +1 -0
  24. package/dist/axis/Axes.js +27 -0
  25. package/dist/axis/Axes.js.map +1 -0
  26. package/dist/axis/Axis.d.ts +15 -9
  27. package/dist/axis/Axis.d.ts.map +1 -1
  28. package/dist/axis/Axis.js +1 -10
  29. package/dist/axis/Axis.js.map +1 -1
  30. package/dist/axis/boundary/Boundary.d.ts +38 -5
  31. package/dist/axis/boundary/Boundary.d.ts.map +1 -1
  32. package/dist/axis/boundary/Boundary.js +18 -11
  33. package/dist/axis/boundary/Boundary.js.map +1 -1
  34. package/dist/axis/boundary/Decoder.d.ts +8 -2
  35. package/dist/axis/boundary/Decoder.d.ts.map +1 -1
  36. package/dist/axis/boundary/Decoder.js.map +1 -1
  37. package/dist/axis/lifecycle/Lifecycle.d.ts +29 -8
  38. package/dist/axis/lifecycle/Lifecycle.d.ts.map +1 -1
  39. package/dist/axis/lifecycle/Lifecycle.js +26 -11
  40. package/dist/axis/lifecycle/Lifecycle.js.map +1 -1
  41. package/dist/axis/lifecycle/apply.d.ts.map +1 -1
  42. package/dist/axis/lifecycle/apply.js +3 -4
  43. package/dist/axis/lifecycle/apply.js.map +1 -1
  44. package/dist/axis/role/Role.d.ts +31 -12
  45. package/dist/axis/role/Role.d.ts.map +1 -1
  46. package/dist/axis/role/Role.js +56 -22
  47. package/dist/axis/role/Role.js.map +1 -1
  48. package/dist/axis/shape/Shape.d.ts +32 -9
  49. package/dist/axis/shape/Shape.d.ts.map +1 -1
  50. package/dist/axis/shape/Shape.js +43 -12
  51. package/dist/axis/shape/Shape.js.map +1 -1
  52. package/dist/axis/shape/ShapeFormat.d.ts +10 -0
  53. package/dist/axis/shape/ShapeFormat.d.ts.map +1 -0
  54. package/dist/axis/shape/ShapeFormat.js +32 -0
  55. package/dist/axis/shape/ShapeFormat.js.map +1 -0
  56. package/dist/axis/shape/{Formats.d.ts → StringFormats.d.ts} +3 -3
  57. package/dist/axis/shape/StringFormats.d.ts.map +1 -0
  58. package/dist/axis/shape/{Formats.js → StringFormats.js} +3 -3
  59. package/dist/axis/shape/StringFormats.js.map +1 -0
  60. package/dist/entity/EntityDeclarations.d.ts +3 -2
  61. package/dist/entity/EntityDeclarations.d.ts.map +1 -1
  62. package/dist/entity/FieldGroups.d.ts +9 -0
  63. package/dist/entity/FieldGroups.d.ts.map +1 -0
  64. package/dist/entity/FieldGroups.js +2 -0
  65. package/dist/entity/FieldGroups.js.map +1 -0
  66. package/dist/field/Field.d.ts +37 -12
  67. package/dist/field/Field.d.ts.map +1 -1
  68. package/dist/field/Field.js +55 -8
  69. package/dist/field/Field.js.map +1 -1
  70. package/dist/field/FieldFormat.d.ts +9 -0
  71. package/dist/field/FieldFormat.d.ts.map +1 -0
  72. package/dist/field/FieldFormat.js +12 -0
  73. package/dist/field/FieldFormat.js.map +1 -0
  74. package/dist/field/FieldSet.d.ts +12 -3
  75. package/dist/field/FieldSet.d.ts.map +1 -1
  76. package/dist/field/FieldSet.js +22 -15
  77. package/dist/field/FieldSet.js.map +1 -1
  78. package/dist/index.d.ts +7 -3
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +4 -3
  81. package/dist/index.js.map +1 -1
  82. package/dist/lib/Format.d.ts +75 -0
  83. package/dist/lib/Format.d.ts.map +1 -0
  84. package/dist/lib/Format.js +123 -0
  85. package/dist/lib/Format.js.map +1 -0
  86. package/dist/lib/JsonSchema.d.ts +2 -0
  87. package/dist/lib/JsonSchema.d.ts.map +1 -0
  88. package/dist/lib/JsonSchema.js +2 -0
  89. package/dist/lib/JsonSchema.js.map +1 -0
  90. package/dist/lib/Registry.d.ts +4 -2
  91. package/dist/lib/Registry.d.ts.map +1 -1
  92. package/dist/lib/Registry.js +11 -5
  93. package/dist/lib/Registry.js.map +1 -1
  94. package/dist/lib/UnionToIntersection.d.ts +7 -0
  95. package/dist/lib/UnionToIntersection.d.ts.map +1 -0
  96. package/dist/lib/UnionToIntersection.js +2 -0
  97. package/dist/lib/UnionToIntersection.js.map +1 -0
  98. package/dist/lib/ValidationResult.d.ts +2 -0
  99. package/dist/lib/ValidationResult.d.ts.map +1 -1
  100. package/dist/lib/ValidationResult.js +6 -0
  101. package/dist/lib/ValidationResult.js.map +1 -1
  102. package/dist/lib/utils.d.ts +1 -1
  103. package/dist/lib/utils.d.ts.map +1 -1
  104. package/dist/lib/utils.js +1 -1
  105. package/dist/lib/utils.js.map +1 -1
  106. package/dist/projection/Cases.d.ts +1 -1
  107. package/dist/projection/Cases.d.ts.map +1 -1
  108. package/dist/projection/Cases.js +20 -8
  109. package/dist/projection/Cases.js.map +1 -1
  110. package/dist/projection/Visibility.d.ts +11 -0
  111. package/dist/projection/Visibility.d.ts.map +1 -1
  112. package/dist/projection/Visibility.js +28 -6
  113. package/dist/projection/Visibility.js.map +1 -1
  114. package/dist/projection/card/Bundle.d.ts.map +1 -1
  115. package/dist/projection/card/Bundle.js.map +1 -1
  116. package/dist/projection/card/Card.d.ts.map +1 -1
  117. package/dist/projection/card/Card.js +24 -30
  118. package/dist/projection/card/Card.js.map +1 -1
  119. package/dist/projection/card/CardForm.d.ts +7 -0
  120. package/dist/projection/card/CardForm.d.ts.map +1 -0
  121. package/dist/projection/card/CardForm.js +2 -0
  122. package/dist/projection/card/CardForm.js.map +1 -0
  123. package/dist/projection/card/CardForms.d.ts +10 -0
  124. package/dist/projection/card/CardForms.d.ts.map +1 -0
  125. package/dist/projection/card/CardForms.js +12 -0
  126. package/dist/projection/card/CardForms.js.map +1 -0
  127. package/dist/projection/card/Change.d.ts +2 -2
  128. package/dist/projection/card/Change.d.ts.map +1 -1
  129. package/dist/projection/card/Diff.js +2 -2
  130. package/dist/projection/card/Diff.js.map +1 -1
  131. package/dist/projection/card/FieldExtension.d.ts +4 -2
  132. package/dist/projection/card/FieldExtension.d.ts.map +1 -1
  133. package/dist/projection/card/RoleDescriptor.d.ts +15 -3
  134. package/dist/projection/card/RoleDescriptor.d.ts.map +1 -1
  135. package/dist/projection/card/RoleDescriptor.js +40 -1
  136. package/dist/projection/card/RoleDescriptor.js.map +1 -1
  137. package/dist/projection/card/ShapeKeywords.d.ts +1 -1
  138. package/dist/projection/card/ShapeKeywords.d.ts.map +1 -1
  139. package/dist/projection/card/admission.d.ts +0 -14
  140. package/dist/projection/card/admission.d.ts.map +1 -1
  141. package/dist/projection/card/admission.js +0 -20
  142. package/dist/projection/card/admission.js.map +1 -1
  143. package/dist/validator/FieldDeclarationValidator.d.ts.map +1 -1
  144. package/dist/validator/FieldDeclarationValidator.js +10 -25
  145. package/dist/validator/FieldDeclarationValidator.js.map +1 -1
  146. package/dist/validator/FieldValueValidator.d.ts.map +1 -1
  147. package/dist/validator/FieldValueValidator.js +9 -29
  148. package/dist/validator/FieldValueValidator.js.map +1 -1
  149. package/dist/validator/InputValidator.d.ts +7 -1
  150. package/dist/validator/InputValidator.d.ts.map +1 -1
  151. package/dist/validator/InputValidator.js +15 -14
  152. package/dist/validator/InputValidator.js.map +1 -1
  153. package/dist/validator/JsonSchemaValidator.d.ts +23 -0
  154. package/dist/validator/JsonSchemaValidator.d.ts.map +1 -0
  155. package/dist/validator/JsonSchemaValidator.js +113 -0
  156. package/dist/validator/JsonSchemaValidator.js.map +1 -0
  157. package/dist/vocabulary/preset/created.d.ts +2 -2
  158. package/dist/vocabulary/preset/created.d.ts.map +1 -1
  159. package/dist/vocabulary/preset/created.js +2 -2
  160. package/dist/vocabulary/preset/created.js.map +1 -1
  161. package/dist/vocabulary/preset/updated.d.ts +2 -2
  162. package/dist/vocabulary/preset/updated.d.ts.map +1 -1
  163. package/dist/vocabulary/preset/updated.js +2 -2
  164. package/dist/vocabulary/preset/updated.js.map +1 -1
  165. package/dist/vocabulary/primitive/bool.d.ts +2 -5
  166. package/dist/vocabulary/primitive/bool.d.ts.map +1 -1
  167. package/dist/vocabulary/primitive/bool.js +1 -5
  168. package/dist/vocabulary/primitive/bool.js.map +1 -1
  169. package/dist/vocabulary/primitive/date.d.ts +2 -3
  170. package/dist/vocabulary/primitive/date.d.ts.map +1 -1
  171. package/dist/vocabulary/primitive/date.js +2 -3
  172. package/dist/vocabulary/primitive/date.js.map +1 -1
  173. package/dist/vocabulary/primitive/json.d.ts +3 -3
  174. package/dist/vocabulary/primitive/json.d.ts.map +1 -1
  175. package/dist/vocabulary/primitive/json.js +11 -11
  176. package/dist/vocabulary/primitive/json.js.map +1 -1
  177. package/dist/vocabulary/primitive/list.d.ts +6 -5
  178. package/dist/vocabulary/primitive/list.d.ts.map +1 -1
  179. package/dist/vocabulary/primitive/list.js +13 -7
  180. package/dist/vocabulary/primitive/list.js.map +1 -1
  181. package/dist/vocabulary/primitive/many.d.ts +2 -4
  182. package/dist/vocabulary/primitive/many.d.ts.map +1 -1
  183. package/dist/vocabulary/primitive/many.js +2 -4
  184. package/dist/vocabulary/primitive/many.js.map +1 -1
  185. package/dist/vocabulary/primitive/number.d.ts +2 -4
  186. package/dist/vocabulary/primitive/number.d.ts.map +1 -1
  187. package/dist/vocabulary/primitive/number.js +1 -3
  188. package/dist/vocabulary/primitive/number.js.map +1 -1
  189. package/dist/vocabulary/primitive/oneOf.d.ts +4 -7
  190. package/dist/vocabulary/primitive/oneOf.d.ts.map +1 -1
  191. package/dist/vocabulary/primitive/oneOf.js +19 -11
  192. package/dist/vocabulary/primitive/oneOf.js.map +1 -1
  193. package/dist/vocabulary/primitive/primary.d.ts +2 -2
  194. package/dist/vocabulary/primitive/primary.d.ts.map +1 -1
  195. package/dist/vocabulary/primitive/primary.js +2 -3
  196. package/dist/vocabulary/primitive/primary.js.map +1 -1
  197. package/dist/vocabulary/primitive/ref.d.ts +2 -6
  198. package/dist/vocabulary/primitive/ref.d.ts.map +1 -1
  199. package/dist/vocabulary/primitive/ref.js +1 -1
  200. package/dist/vocabulary/primitive/ref.js.map +1 -1
  201. package/dist/vocabulary/primitive/text.d.ts +2 -4
  202. package/dist/vocabulary/primitive/text.d.ts.map +1 -1
  203. package/dist/vocabulary/primitive/text.js +1 -3
  204. package/dist/vocabulary/primitive/text.js.map +1 -1
  205. package/dist/vocabulary/rule/nullable.d.ts +0 -1
  206. package/dist/vocabulary/rule/nullable.d.ts.map +1 -1
  207. package/dist/vocabulary/rule/nullable.js +0 -1
  208. package/dist/vocabulary/rule/nullable.js.map +1 -1
  209. package/dist/vocabulary/rule/optional.d.ts +0 -1
  210. package/dist/vocabulary/rule/optional.d.ts.map +1 -1
  211. package/dist/vocabulary/rule/optional.js +0 -1
  212. package/dist/vocabulary/rule/optional.js.map +1 -1
  213. package/dist/vocabulary/rule/readOnly.d.ts +0 -2
  214. package/dist/vocabulary/rule/readOnly.d.ts.map +1 -1
  215. package/dist/vocabulary/rule/readOnly.js +0 -2
  216. package/dist/vocabulary/rule/readOnly.js.map +1 -1
  217. package/dist/vocabulary/rule/writeOnly.d.ts +0 -2
  218. package/dist/vocabulary/rule/writeOnly.d.ts.map +1 -1
  219. package/dist/vocabulary/rule/writeOnly.js +0 -2
  220. package/dist/vocabulary/rule/writeOnly.js.map +1 -1
  221. package/dist/vocabulary/vocabulary.d.ts +2 -3
  222. package/dist/vocabulary/vocabulary.d.ts.map +1 -1
  223. package/dist/vocabulary/vocabulary.js +18 -20
  224. package/dist/vocabulary/vocabulary.js.map +1 -1
  225. package/package.json +1 -1
  226. package/src/FougereFieldAxes.ts +2 -0
  227. package/src/Schema.ts +11 -8
  228. package/src/SchemaConstraints.ts +40 -22
  229. package/src/SchemaDefinition.ts +7 -5
  230. package/src/SchemaError.ts +9 -3
  231. package/src/SchemaView.ts +3 -2
  232. package/src/axis/Axes.ts +34 -0
  233. package/src/axis/Axis.ts +15 -19
  234. package/src/axis/boundary/Boundary.ts +39 -13
  235. package/src/axis/boundary/Decoder.ts +3 -1
  236. package/src/axis/lifecycle/Lifecycle.ts +42 -14
  237. package/src/axis/lifecycle/apply.ts +12 -6
  238. package/src/axis/role/Role.ts +73 -25
  239. package/src/axis/shape/Shape.ts +89 -23
  240. package/src/axis/shape/ShapeFormat.ts +37 -0
  241. package/src/axis/shape/{Formats.ts → StringFormats.ts} +2 -2
  242. package/src/entity/EntityDeclarations.ts +3 -2
  243. package/src/entity/FieldGroups.ts +9 -0
  244. package/src/field/Field.ts +89 -16
  245. package/src/field/FieldFormat.ts +18 -0
  246. package/src/field/FieldSet.ts +27 -19
  247. package/src/index.ts +7 -3
  248. package/src/lib/Format.ts +172 -0
  249. package/src/lib/JsonSchema.ts +1 -0
  250. package/src/lib/Registry.ts +14 -6
  251. package/src/lib/UnionToIntersection.ts +10 -0
  252. package/src/lib/ValidationResult.ts +8 -0
  253. package/src/lib/utils.ts +5 -1
  254. package/src/projection/Cases.ts +25 -8
  255. package/src/projection/Visibility.ts +31 -6
  256. package/src/projection/card/Bundle.ts +2 -0
  257. package/src/projection/card/Card.ts +29 -27
  258. package/src/projection/card/CardForm.ts +8 -0
  259. package/src/projection/card/CardForms.ts +13 -0
  260. package/src/projection/card/Change.ts +2 -2
  261. package/src/projection/card/Diff.ts +6 -2
  262. package/src/projection/card/FieldExtension.ts +5 -2
  263. package/src/projection/card/RoleDescriptor.ts +54 -3
  264. package/src/projection/card/ShapeKeywords.ts +1 -1
  265. package/src/projection/card/admission.ts +0 -33
  266. package/src/validator/FieldDeclarationValidator.ts +10 -25
  267. package/src/validator/FieldValueValidator.ts +13 -36
  268. package/src/validator/InputValidator.ts +17 -12
  269. package/src/validator/JsonSchemaValidator.ts +142 -0
  270. package/src/vocabulary/preset/created.ts +3 -3
  271. package/src/vocabulary/preset/updated.ts +4 -3
  272. package/src/vocabulary/primitive/bool.ts +3 -8
  273. package/src/vocabulary/primitive/date.ts +5 -4
  274. package/src/vocabulary/primitive/json.ts +27 -12
  275. package/src/vocabulary/primitive/list.ts +16 -9
  276. package/src/vocabulary/primitive/many.ts +3 -4
  277. package/src/vocabulary/primitive/number.ts +3 -8
  278. package/src/vocabulary/primitive/oneOf.ts +40 -24
  279. package/src/vocabulary/primitive/primary.ts +9 -5
  280. package/src/vocabulary/primitive/ref.ts +3 -7
  281. package/src/vocabulary/primitive/text.ts +3 -8
  282. package/src/vocabulary/rule/nullable.ts +0 -1
  283. package/src/vocabulary/rule/optional.ts +0 -1
  284. package/src/vocabulary/rule/readOnly.ts +0 -2
  285. package/src/vocabulary/rule/writeOnly.ts +0 -2
  286. package/src/vocabulary/vocabulary.ts +19 -21
  287. package/dist/axis/boundary/BoundaryAxis.d.ts +0 -4
  288. package/dist/axis/boundary/BoundaryAxis.d.ts.map +0 -1
  289. package/dist/axis/boundary/BoundaryAxis.js +0 -30
  290. package/dist/axis/boundary/BoundaryAxis.js.map +0 -1
  291. package/dist/axis/boundary/BoundaryRef.d.ts +0 -3
  292. package/dist/axis/boundary/BoundaryRef.d.ts.map +0 -1
  293. package/dist/axis/boundary/BoundaryRef.js +0 -2
  294. package/dist/axis/boundary/BoundaryRef.js.map +0 -1
  295. package/dist/axis/boundary/BoundaryRules.d.ts +0 -9
  296. package/dist/axis/boundary/BoundaryRules.d.ts.map +0 -1
  297. package/dist/axis/boundary/BoundaryRules.js +0 -2
  298. package/dist/axis/boundary/BoundaryRules.js.map +0 -1
  299. package/dist/axis/lifecycle/Clock.d.ts +0 -10
  300. package/dist/axis/lifecycle/Clock.d.ts.map +0 -1
  301. package/dist/axis/lifecycle/Clock.js +0 -19
  302. package/dist/axis/lifecycle/Clock.js.map +0 -1
  303. package/dist/axis/lifecycle/LifecycleAxis.d.ts +0 -4
  304. package/dist/axis/lifecycle/LifecycleAxis.d.ts.map +0 -1
  305. package/dist/axis/lifecycle/LifecycleAxis.js +0 -52
  306. package/dist/axis/lifecycle/LifecycleAxis.js.map +0 -1
  307. package/dist/axis/lifecycle/LifecycleRules.d.ts +0 -12
  308. package/dist/axis/lifecycle/LifecycleRules.d.ts.map +0 -1
  309. package/dist/axis/lifecycle/LifecycleRules.js +0 -3
  310. package/dist/axis/lifecycle/LifecycleRules.js.map +0 -1
  311. package/dist/axis/role/RoleAxis.d.ts +0 -5
  312. package/dist/axis/role/RoleAxis.d.ts.map +0 -1
  313. package/dist/axis/role/RoleAxis.js +0 -93
  314. package/dist/axis/role/RoleAxis.js.map +0 -1
  315. package/dist/axis/role/RoleRules.d.ts +0 -8
  316. package/dist/axis/role/RoleRules.d.ts.map +0 -1
  317. package/dist/axis/role/RoleRules.js +0 -2
  318. package/dist/axis/role/RoleRules.js.map +0 -1
  319. package/dist/axis/shape/Formats.d.ts.map +0 -1
  320. package/dist/axis/shape/Formats.js.map +0 -1
  321. package/dist/entity/CompositeUnique.d.ts +0 -4
  322. package/dist/entity/CompositeUnique.d.ts.map +0 -1
  323. package/dist/entity/CompositeUnique.js +0 -2
  324. package/dist/entity/CompositeUnique.js.map +0 -1
  325. package/dist/field/Meta.d.ts +0 -4
  326. package/dist/field/Meta.d.ts.map +0 -1
  327. package/dist/field/Meta.js +0 -2
  328. package/dist/field/Meta.js.map +0 -1
  329. package/dist/projection/card/RelationDescriptor.d.ts +0 -5
  330. package/dist/projection/card/RelationDescriptor.d.ts.map +0 -1
  331. package/dist/projection/card/RelationDescriptor.js +0 -2
  332. package/dist/projection/card/RelationDescriptor.js.map +0 -1
  333. package/dist/validator/AdapterFieldValidator.d.ts +0 -14
  334. package/dist/validator/AdapterFieldValidator.d.ts.map +0 -1
  335. package/dist/validator/AdapterFieldValidator.js +0 -37
  336. package/dist/validator/AdapterFieldValidator.js.map +0 -1
  337. package/src/axis/boundary/BoundaryAxis.ts +0 -32
  338. package/src/axis/boundary/BoundaryRef.ts +0 -3
  339. package/src/axis/boundary/BoundaryRules.ts +0 -4
  340. package/src/axis/lifecycle/Clock.ts +0 -22
  341. package/src/axis/lifecycle/LifecycleAxis.ts +0 -55
  342. package/src/axis/lifecycle/LifecycleRules.ts +0 -9
  343. package/src/axis/role/RoleAxis.ts +0 -104
  344. package/src/axis/role/RoleRules.ts +0 -8
  345. package/src/entity/CompositeUnique.ts +0 -6
  346. package/src/field/Meta.ts +0 -3
  347. package/src/projection/card/RelationDescriptor.ts +0 -3
  348. package/src/validator/AdapterFieldValidator.ts +0 -41
@@ -1 +0,0 @@
1
- {"version":3,"file":"RelationDescriptor.js","sourceRoot":"","sources":["../../../src/projection/card/RelationDescriptor.ts"],"names":[],"mappings":""}
@@ -1,14 +0,0 @@
1
- import type { Shape } from '../axis/shape/Shape.js';
2
- /**
3
- * The format is DATA, not a TypeScript interface: an interface is erased before a JS
4
- * caller, a config or a card from another language could be measured against it.
5
- */
6
- export declare class AdapterFieldValidator {
7
- private readonly validator;
8
- private constructor();
9
- /** Compiled once, at the adapter's own module load. */
10
- static of(format: Shape): AdapterFieldValidator;
11
- /** `Post.adapters.sql.body.columnType: Property "postgre" does not match …` */
12
- assert(entries: unknown, path: string): void;
13
- }
14
- //# sourceMappingURL=AdapterFieldValidator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AdapterFieldValidator.d.ts","sourceRoot":"","sources":["../../src/validator/AdapterFieldValidator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAIpD;;;GAGG;AACH,qBAAa,qBAAqB;IACZ,OAAO,CAAC,QAAQ,CAAC,SAAS;IAA9C,OAAO,eAAsD;IAE7D,uDAAuD;IACvD,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,GAAG,qBAAqB,CAE9C;IAED,+EAA+E;IAC/E,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAqB3C;CACF"}
@@ -1,37 +0,0 @@
1
- import { Validator } from '@cfworker/json-schema';
2
- import { isObject } from '../lib/utils.js';
3
- import { SchemaError } from '../SchemaError.js';
4
- /**
5
- * The format is DATA, not a TypeScript interface: an interface is erased before a JS
6
- * caller, a config or a card from another language could be measured against it.
7
- */
8
- export class AdapterFieldValidator {
9
- validator;
10
- constructor(validator) {
11
- this.validator = validator;
12
- }
13
- /** Compiled once, at the adapter's own module load. */
14
- static of(format) {
15
- return new AdapterFieldValidator(new Validator(format, '2020-12', true));
16
- }
17
- /** `Post.adapters.sql.body.columnType: Property "postgre" does not match …` */
18
- assert(entries, path) {
19
- if (entries === undefined)
20
- return;
21
- if (!isObject(entries)) {
22
- throw new SchemaError(`${path}: expected an object keyed by field name, got ${typeof entries}.`);
23
- }
24
- for (const [field, entry] of Object.entries(entries)) {
25
- const verdict = this.validator.validate(entry);
26
- if (verdict.valid)
27
- continue;
28
- // The engine reports outermost first and ends on `False boolean schema`, which names
29
- // nothing. The last unit above that one is the one carrying the offending key.
30
- const units = verdict.errors.filter((unit) => unit.keyword !== 'false');
31
- const failure = units[units.length - 1] ?? verdict.errors[0];
32
- const nested = (failure?.instanceLocation ?? '#').slice(1).replaceAll('/', '.');
33
- throw new SchemaError(`${path}.${field}${nested}: ${failure?.error ?? 'does not match the format'}`);
34
- }
35
- }
36
- }
37
- //# sourceMappingURL=AdapterFieldValidator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AdapterFieldValidator.js","sourceRoot":"","sources":["../../src/validator/AdapterFieldValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IACK,SAAS;IAA9C,YAAqC,SAAoB;yBAApB,SAAS;IAAc,CAAC;IAE7D,uDAAuD;IACvD,MAAM,CAAC,EAAE,CAAC,MAAa;QACrB,OAAO,IAAI,qBAAqB,CAAC,IAAI,SAAS,CAAC,MAAgB,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IACrF,CAAC;IAED,+EAA+E;IAC/E,MAAM,CAAC,OAAgB,EAAE,IAAY;QACnC,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO;QAElC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,WAAW,CACnB,GAAG,IAAI,iDAAiD,OAAO,OAAO,GAAG,CAC1E,CAAC;QACJ,CAAC;QAED,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACrD,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC/C,IAAI,OAAO,CAAC,KAAK;gBAAE,SAAS;YAE5B,qFAAqF;YACrF,+EAA+E;YAC/E,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;YACxE,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC7D,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,gBAAgB,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YAEhF,MAAM,IAAI,WAAW,CAAC,GAAG,IAAI,IAAI,KAAK,GAAG,MAAM,KAAK,OAAO,EAAE,KAAK,IAAI,2BAA2B,EAAE,CAAC,CAAC;QACvG,CAAC;IACH,CAAC;CACF"}
@@ -1,32 +0,0 @@
1
- import type { Axis } from '../Axis.js';
2
- import { admitWire } from '../../projection/card/admission.js';
3
- import { isObject, shown } from '../../lib/utils.js';
4
- import type { BoundaryRef } from './BoundaryRef.js';
5
-
6
- export const boundaryAxis: Axis<BoundaryRef, BoundaryRef> = {
7
- slot: 'boundary',
8
-
9
- validator(value, errors) {
10
- if (typeof value === 'string') return;
11
- if (!isObject(value)) {
12
- errors.push({
13
- path: ['boundary'],
14
- message: `Expected an alias name or { in, out } — got ${shown(value)}`,
15
- });
16
- return;
17
- }
18
- for (const [side, verb] of [['in', 'decode'], ['out', 'encode']] as const) {
19
- const rule = value[side];
20
- if (rule === undefined || rule === 'closed') continue;
21
- if (!isObject(rule) || typeof rule[verb] !== 'string') {
22
- errors.push({ path: ['boundary', side], message: `Expected 'closed' or { ${verb}: <name> }` });
23
- }
24
- }
25
- },
26
-
27
- describe: (value) => value,
28
- reconstruct: (wire) => {
29
- admitWire(boundaryAxis.validator, wire, 'boundary');
30
- return wire;
31
- },
32
- };
@@ -1,3 +0,0 @@
1
- import type { BoundaryRules } from './BoundaryRules.js';
2
-
3
- export type BoundaryRef = 'isoDate' | (string & {}) | BoundaryRules;
@@ -1,4 +0,0 @@
1
- export interface BoundaryRules {
2
- in?: 'closed' | { decode: string };
3
- out?: 'closed' | { encode: string };
4
- }
@@ -1,22 +0,0 @@
1
- export class Clock {
2
- private static reading: () => number = Date.now;
3
-
4
- static now(): number {
5
- return this.reading();
6
- }
7
-
8
- /**
9
- *
10
- * @returns function to restore the clock
11
- */
12
- static freeze(at: number | Date): () => void {
13
- const previous = this.reading;
14
- const instant = at instanceof Date ? at.getTime() : at;
15
-
16
- this.reading = () => instant;
17
-
18
- return () => {
19
- this.reading = previous;
20
- };
21
- }
22
- }
@@ -1,55 +0,0 @@
1
- import type { Axis } from '../Axis.js';
2
- import type { ValidationError } from '../../lib/ValidationError.js';
3
- import { admitWire, oneOfTokens } from '../../projection/card/admission.js';
4
- import { isObject, shown } from '../../lib/utils.js';
5
- import { CREATE_TOKENS, UPDATE_TOKENS } from './LifecycleRules.js';
6
- import { type LifecycleRules } from './LifecycleRules.js';
7
-
8
- export const lifecycleAxis: Axis<LifecycleRules, LifecycleRules> = {
9
- slot: 'lifecycle',
10
-
11
- validator(value, errors) {
12
- if (!isObject(value)) {
13
- errors.push({ path: ['lifecycle'], message: `Expected an object — got ${shown(value)}` });
14
- return;
15
- }
16
- if (value.create !== undefined) validateCreate(value.create, errors);
17
- if (value.update !== undefined && !oneOfTokens(value.update, UPDATE_TOKENS)) {
18
- errors.push({
19
- path: ['lifecycle', 'update'],
20
- message: `Expected 'now' or 'forbidden' — got ${shown(value.update)}`,
21
- });
22
- }
23
- },
24
-
25
- describe: (value) => value,
26
- reconstruct: (wire) => {
27
- admitWire(lifecycleAxis.validator, wire, 'lifecycle');
28
- return wire;
29
- },
30
- };
31
-
32
- /**
33
- * Judges the create rule, whose four legal forms are stated here and nowhere else.
34
- * FR : juge la règle de création, dont les quatre formes légales sont énoncées ici seulement.
35
- * `create: 3` → `Expected 'now', 'optional', { value } or { generate } — got 3`
36
- */
37
- function validateCreate(rule: unknown, errors: ValidationError[]): void {
38
- if (oneOfTokens(rule, CREATE_TOKENS)) return;
39
- if (isObject(rule)) {
40
- if ('value' in rule) return;
41
- if ('generate' in rule) {
42
- if (typeof rule.generate !== 'string') {
43
- errors.push({
44
- path: ['lifecycle', 'create', 'generate'],
45
- message: `Expected a generator name — got ${shown(rule.generate)}`,
46
- });
47
- }
48
- return;
49
- }
50
- }
51
- errors.push({
52
- path: ['lifecycle', 'create'],
53
- message: `Expected 'now', 'optional', { value } or { generate } — got ${shown(rule)}`,
54
- });
55
- }
@@ -1,9 +0,0 @@
1
- import type { GeneratorRef } from './Generators.js';
2
-
3
- export const CREATE_TOKENS = ['now', 'optional'] as const;
4
- export const UPDATE_TOKENS = ['now', 'forbidden'] as const;
5
-
6
- export interface LifecycleRules {
7
- create?: { value: unknown } | { generate: GeneratorRef } | (typeof CREATE_TOKENS)[number];
8
- update?: (typeof UPDATE_TOKENS)[number];
9
- }
@@ -1,104 +0,0 @@
1
- import type { Axis } from '../Axis.js';
2
- import type { Resolver } from '../Resolver.js';
3
- import { refuse, oneOfTokens } from '../../projection/card/admission.js';
4
- import { isObject, lowerFirst, shown } from '../../lib/utils.js';
5
- import type { ValidationError } from '../../lib/ValidationError.js';
6
- import { type EntityConstructor } from './EntityConstructor.js';
7
- import { ON_DELETE, RELATION_KINDS, type Relation } from './Relation.js';
8
- import { type RoleRules } from './RoleRules.js';
9
- import type { RoleDescriptor } from '../../projection/card/RoleDescriptor.js';
10
-
11
- export const roleAxis: Axis<RoleRules, RoleDescriptor> = {
12
- slot: 'role',
13
-
14
- validator(value, errors) {
15
- if (!isObject(value)) {
16
- errors.push({ path: ['role'], message: `Expected an object — got ${shown(value)}` });
17
- return;
18
- }
19
- for (const flag of ['primary', 'index', 'unique'] as const) {
20
- if (value[flag] !== undefined && typeof value[flag] !== 'boolean') {
21
- errors.push({
22
- path: ['role', flag],
23
- message: `Expected a boolean — got ${shown(value[flag])}`,
24
- });
25
- }
26
- }
27
- if (value.relation !== undefined) validateRelation(value.relation, errors);
28
- },
29
-
30
- /** A card carries the target's NAME: a class cannot cross a process boundary. */
31
- describe(role, key) {
32
- const descriptor: Mutable<RoleDescriptor> = {};
33
- if (role.primary) descriptor.primary = true;
34
- if (role.unique) descriptor.unique = [[key]];
35
- if (role.index) descriptor.index = true;
36
- if (role.relation) {
37
- const target = role.relation.to() as { name?: string };
38
- descriptor.relation = {
39
- to: lowerFirst(target.name ?? ''),
40
- kind: role.relation.kind,
41
- ...(role.relation.onDelete ? { onDelete: role.relation.onDelete } : {}),
42
- };
43
- }
44
- return Object.keys(descriptor).length ? descriptor : undefined;
45
- },
46
-
47
- reconstruct(wire, resolve?: Resolver) {
48
- const rules: RoleRules = {};
49
- if (wire.primary) rules.primary = true;
50
- if (wire.unique?.some((group) => group.length === 1)) rules.unique = true;
51
- if (wire.index) rules.index = true;
52
- if (wire.relation) {
53
- // `validator` cannot serve here: it demands `() => Post` where a card carries a name.
54
- if (!oneOfTokens(wire.relation.kind, RELATION_KINDS)) {
55
- refuse(
56
- `role.relation.kind is ${JSON.stringify(wire.relation.kind)}`,
57
- `Expected one of ${RELATION_KINDS.join(', ')}.`,
58
- );
59
- }
60
- if (wire.relation.onDelete !== undefined && !oneOfTokens(wire.relation.onDelete, ON_DELETE)) {
61
- refuse(
62
- `role.relation.onDelete is ${JSON.stringify(wire.relation.onDelete)}`,
63
- `Expected one of ${ON_DELETE.join(', ')}.`,
64
- );
65
- }
66
- const name = wire.relation.to;
67
- rules.relation = {
68
- to: () => (resolve?.(name) ?? ({ name } as unknown)) as EntityConstructor,
69
- kind: wire.relation.kind as Relation['kind'],
70
- ...(wire.relation.onDelete ? { onDelete: wire.relation.onDelete as Relation['onDelete'] } : {}),
71
- } as RoleRules['relation'];
72
- }
73
- return rules;
74
- },
75
- };
76
-
77
- /**
78
- * Judges a relation where `to` is a thunk; a card states a NAME, resolved by `toSchema` first.
79
- * FR : juge une relation dont `to` est une fonction ; une carte y met un NOM, résolu avant.
80
- * `{ to: User, kind: 'one' }` → `Expected a function returning the target entity, … () => Post`
81
- */
82
- function validateRelation(relation: unknown, errors: ValidationError[]): void {
83
- if (!isObject(relation)) {
84
- errors.push({ path: ['role', 'relation'], message: `Expected an object — got ${shown(relation)}` });
85
- return;
86
- }
87
- if (!oneOfTokens(relation.kind, RELATION_KINDS)) {
88
- errors.push({
89
- path: ['role', 'relation', 'kind'],
90
- message: `Expected 'one' or 'many' — got ${shown(relation.kind)}`,
91
- });
92
- }
93
- if (typeof relation.to !== 'function') {
94
- errors.push({ path: ['role', 'relation', 'to'], message: 'Expected a function returning the target entity, such as () => Post' });
95
- }
96
- if (relation.onDelete !== undefined && !oneOfTokens(relation.onDelete, ON_DELETE)) {
97
- errors.push({
98
- path: ['role', 'relation', 'onDelete'],
99
- message: `Expected 'cascade', 'restrict' or 'set null' — got ${shown(relation.onDelete)}`,
100
- });
101
- }
102
- }
103
-
104
- type Mutable<T> = { -readonly [K in keyof T]: T[K] };
@@ -1,8 +0,0 @@
1
- import type { Relation } from './Relation.js';
2
-
3
- export interface RoleRules {
4
- primary?: boolean;
5
- index?: boolean;
6
- unique?: boolean;
7
- relation?: Relation;
8
- }
@@ -1,6 +0,0 @@
1
- import type { FieldName } from '../field/FieldName.js';
2
- import type { Fields } from '../field/Fields.js';
3
-
4
- // Ex: [['title', 'name'], ['id']]
5
- export type CompositeUnique<TFields extends Fields> =
6
- readonly (readonly FieldName<TFields>[])[];
package/src/field/Meta.ts DELETED
@@ -1,3 +0,0 @@
1
- export interface Meta {
2
- description?: string;
3
- }
@@ -1,3 +0,0 @@
1
- import type { Relation } from '../../axis/role/Relation.js';
2
-
3
- export type RelationDescriptor = Pick<Relation, 'kind' | 'onDelete'> & { to: string };
@@ -1,41 +0,0 @@
1
- import { Validator } from '@cfworker/json-schema';
2
- import type { Shape } from '../axis/shape/Shape.js';
3
- import { isObject } from '../lib/utils.js';
4
- import { SchemaError } from '../SchemaError.js';
5
-
6
- /**
7
- * The format is DATA, not a TypeScript interface: an interface is erased before a JS
8
- * caller, a config or a card from another language could be measured against it.
9
- */
10
- export class AdapterFieldValidator {
11
- private constructor(private readonly validator: Validator) {}
12
-
13
- /** Compiled once, at the adapter's own module load. */
14
- static of(format: Shape): AdapterFieldValidator {
15
- return new AdapterFieldValidator(new Validator(format as object, '2020-12', true));
16
- }
17
-
18
- /** `Post.adapters.sql.body.columnType: Property "postgre" does not match …` */
19
- assert(entries: unknown, path: string): void {
20
- if (entries === undefined) return;
21
-
22
- if (!isObject(entries)) {
23
- throw new SchemaError(
24
- `${path}: expected an object keyed by field name, got ${typeof entries}.`,
25
- );
26
- }
27
-
28
- for (const [field, entry] of Object.entries(entries)) {
29
- const verdict = this.validator.validate(entry);
30
- if (verdict.valid) continue;
31
-
32
- // The engine reports outermost first and ends on `False boolean schema`, which names
33
- // nothing. The last unit above that one is the one carrying the offending key.
34
- const units = verdict.errors.filter((unit) => unit.keyword !== 'false');
35
- const failure = units[units.length - 1] ?? verdict.errors[0];
36
- const nested = (failure?.instanceLocation ?? '#').slice(1).replaceAll('/', '.');
37
-
38
- throw new SchemaError(`${path}.${field}${nested}: ${failure?.error ?? 'does not match the format'}`);
39
- }
40
- }
41
- }