@astrale-os/kernel-dsl 1.0.0-beta.3 → 1.0.0-beta.31

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 (413) hide show
  1. package/dist/v1/addressing/class-key.js +3 -3
  2. package/dist/v1/addressing/definition-ref.js +21 -37
  3. package/dist/v1/addressing/domain-dependency.d.ts +0 -6
  4. package/dist/v1/addressing/domain-dependency.js +1 -6
  5. package/dist/v1/addressing/key.d.ts +4 -1
  6. package/dist/v1/addressing/key.js +23 -3
  7. package/dist/v1/addressing/ordering.d.ts +2 -0
  8. package/dist/v1/addressing/ordering.js +2 -0
  9. package/dist/v1/addressing/patterns.d.ts +1 -1
  10. package/dist/v1/addressing/patterns.js +2 -6
  11. package/dist/v1/builder/callable/authoring.d.ts +11 -5
  12. package/dist/v1/builder/callable/authoring.js +2 -0
  13. package/dist/v1/builder/class/authoring.d.ts +94 -224
  14. package/dist/v1/builder/class/authoring.js +30 -35
  15. package/dist/v1/builder/class/handle.d.ts +27 -0
  16. package/dist/v1/builder/class/handle.js +1 -0
  17. package/dist/v1/builder/class/input.d.ts +159 -0
  18. package/dist/v1/builder/class/projection.d.ts +129 -0
  19. package/dist/v1/builder/class/projection.js +1 -0
  20. package/dist/v1/builder/class/property.d.ts +3 -9
  21. package/dist/v1/builder/class/property.js +1 -0
  22. package/dist/v1/builder/core/authoring.d.ts +1 -1
  23. package/dist/v1/builder/index.d.ts +10 -2
  24. package/dist/v1/builder/index.js +2 -0
  25. package/dist/v1/builder/lowering/callable.js +1 -0
  26. package/dist/v1/builder/lowering/class.d.ts +9 -1
  27. package/dist/v1/builder/lowering/class.js +62 -17
  28. package/dist/v1/builder/lowering/policy.js +6 -24
  29. package/dist/v1/builder/lowering/property-keys.d.ts +27 -0
  30. package/dist/v1/builder/lowering/property-keys.js +108 -0
  31. package/dist/v1/builder/lowering/schema/compile.js +13 -6
  32. package/dist/v1/builder/lowering/schema/context.d.ts +9 -1
  33. package/dist/v1/builder/lowering/schema/context.js +36 -7
  34. package/dist/v1/builder/lowering/schema/lifetime.d.ts +11 -0
  35. package/dist/v1/builder/lowering/schema/lifetime.js +55 -0
  36. package/dist/v1/builder/lowering/value/compile.js +29 -22
  37. package/dist/v1/builder/lowering/value/file.d.ts +7 -0
  38. package/dist/v1/builder/lowering/value/file.js +14 -0
  39. package/dist/v1/builder/lowering/value/path.d.ts +1 -1
  40. package/dist/v1/builder/lowering/value/path.js +2 -4
  41. package/dist/v1/builder/lowering/value/zod.js +41 -7
  42. package/dist/v1/builder/policy/authoring.d.ts +80 -9
  43. package/dist/v1/builder/policy/authoring.js +99 -68
  44. package/dist/v1/builder/policy/legacy/edge.d.ts +28 -0
  45. package/dist/v1/builder/policy/legacy/edge.js +16 -0
  46. package/dist/v1/builder/schema/define.d.ts +0 -1
  47. package/dist/v1/builder/schema/diagnostic.d.ts +3 -2
  48. package/dist/v1/builder/schema/diagnostic.js +5 -10
  49. package/dist/v1/builder/schema/input.d.ts +4 -1
  50. package/dist/v1/builder/schema/projection/callable.d.ts +7 -5
  51. package/dist/v1/builder/schema/projection/class.d.ts +78 -16
  52. package/dist/v1/builder/schema/projection/core-input.d.ts +2 -1
  53. package/dist/v1/builder/schema/projection/domain.d.ts +13 -2
  54. package/dist/v1/builder/schema/projection/identity.d.ts +74 -9
  55. package/dist/v1/builder/schema/projection/model.d.ts +4 -2
  56. package/dist/v1/builder/schema/projection/property.d.ts +38 -4
  57. package/dist/v1/builder/schema/projection/resolved-class.d.ts +5 -4
  58. package/dist/v1/builder/schema/projection.d.ts +1 -1
  59. package/dist/v1/builder/schema/rule.d.ts +316 -0
  60. package/dist/v1/builder/schema/rule.js +192 -0
  61. package/dist/v1/builder/value/file.d.ts +34 -0
  62. package/dist/v1/builder/value/file.js +77 -0
  63. package/dist/v1/builder/value/full-match.d.ts +0 -1
  64. package/dist/v1/builder/value/full-match.js +0 -1
  65. package/dist/v1/builder/value/path-metadata.d.ts +1 -1
  66. package/dist/v1/builder/value/path.d.ts +1 -1
  67. package/dist/v1/bundle/codec.js +55 -74
  68. package/dist/v1/bundle/diagnostic.d.ts +3 -1
  69. package/dist/v1/bundle/diagnostic.js +9 -7
  70. package/dist/v1/bundle/index.d.ts +2 -0
  71. package/dist/v1/bundle/index.js +1 -0
  72. package/dist/v1/bundle/model.js +1 -1
  73. package/dist/v1/bundle/rule.d.ts +14 -0
  74. package/dist/v1/bundle/rule.js +41 -0
  75. package/dist/v1/bundle/structure.js +6 -8
  76. package/dist/v1/compiled/admission/accept.js +9 -15
  77. package/dist/v1/compiled/admission/closure.js +17 -34
  78. package/dist/v1/compiled/admission/diagnostic.d.ts +23 -1
  79. package/dist/v1/compiled/admission/diagnostic.js +40 -3
  80. package/dist/v1/compiled/admission/revision.d.ts +9 -1
  81. package/dist/v1/compiled/admission/revision.js +7 -3
  82. package/dist/v1/compiled/admission/semantics/class.d.ts +4 -1
  83. package/dist/v1/compiled/admission/semantics/class.js +48 -19
  84. package/dist/v1/compiled/admission/semantics/core.d.ts +1 -24
  85. package/dist/v1/compiled/admission/semantics/core.js +56 -24
  86. package/dist/v1/compiled/admission/semantics/edge.d.ts +2 -4
  87. package/dist/v1/compiled/admission/semantics/edge.js +6 -65
  88. package/dist/v1/compiled/admission/semantics/policy/admit.js +4 -19
  89. package/dist/v1/compiled/admission/semantics/policy/callable.js +2 -5
  90. package/dist/v1/compiled/admission/semantics/policy/contracts.d.ts +5 -20
  91. package/dist/v1/compiled/admission/semantics/policy/contracts.js +8 -21
  92. package/dist/v1/compiled/admission/semantics/policy/parity.js +44 -53
  93. package/dist/v1/compiled/admission/semantics/policy/pattern.d.ts +4 -1
  94. package/dist/v1/compiled/admission/semantics/policy/pattern.js +7 -21
  95. package/dist/v1/compiled/admission/semantics/policy/typing.d.ts +2 -24
  96. package/dist/v1/compiled/admission/semantics/policy/typing.js +19 -201
  97. package/dist/v1/compiled/admission/wire/callable.d.ts +5 -2
  98. package/dist/v1/compiled/admission/wire/callable.js +24 -20
  99. package/dist/v1/compiled/admission/wire/class.js +79 -30
  100. package/dist/v1/compiled/admission/wire/entry.d.ts +1 -1
  101. package/dist/v1/compiled/admission/wire/entry.js +36 -13
  102. package/dist/v1/compiled/admission/wire/policy.d.ts +4 -3
  103. package/dist/v1/compiled/admission/wire/policy.js +27 -20
  104. package/dist/v1/compiled/admission/wire/program.d.ts +13 -3
  105. package/dist/v1/compiled/admission/wire/program.js +39 -44
  106. package/dist/v1/compiled/admission/wire/property.d.ts +4 -1
  107. package/dist/v1/compiled/admission/wire/property.js +8 -5
  108. package/dist/v1/compiled/admission/wire/value.d.ts +0 -2
  109. package/dist/v1/compiled/admission/wire/value.js +0 -7
  110. package/dist/v1/compiled/codec/json.js +4 -3
  111. package/dist/v1/compiled/compiler/compile.js +15 -33
  112. package/dist/v1/compiled/diagnostic.d.ts +1 -1
  113. package/dist/v1/compiled/diagnostic.js +2 -3
  114. package/dist/v1/compiled/index.d.ts +2 -0
  115. package/dist/v1/compiled/index.js +1 -0
  116. package/dist/v1/compiled/loader/load.d.ts +3 -2
  117. package/dist/v1/compiled/loader/load.js +13 -52
  118. package/dist/v1/compiled/model/schema.d.ts +3 -0
  119. package/dist/v1/compiled/rule.d.ts +49 -0
  120. package/dist/v1/compiled/rule.js +169 -0
  121. package/dist/v1/domain/create.js +9 -10
  122. package/dist/v1/domain/model/domain.d.ts +2 -7
  123. package/dist/v1/domain/model/input.d.ts +19 -10
  124. package/dist/v1/domain/namespace/member-collection.js +8 -7
  125. package/dist/v1/domain/projection/classes.js +11 -8
  126. package/dist/v1/domain/validation/create.d.ts +7 -16
  127. package/dist/v1/domain/validation/create.js +35 -81
  128. package/dist/v1/index.d.ts +5 -3
  129. package/dist/v1/index.js +1 -1
  130. package/dist/v1/language/.spec/schemas/draft-2020-12.schema.json +462 -0
  131. package/dist/v1/language/.spec/schemas/value-schema.schema.json +23 -0
  132. package/dist/v1/language/callable/admission.d.ts +15 -0
  133. package/dist/v1/language/callable/admission.js +44 -0
  134. package/dist/v1/language/callable/model/callable.d.ts +10 -0
  135. package/dist/v1/language/callable/resolved.d.ts +26 -5
  136. package/dist/v1/language/chain.d.ts +7 -0
  137. package/dist/v1/language/chain.js +24 -0
  138. package/dist/v1/language/class/inheritance.d.ts +36 -5
  139. package/dist/v1/language/class/inheritance.js +85 -1
  140. package/dist/v1/language/class/lifetime.d.ts +50 -11
  141. package/dist/v1/language/class/lifetime.js +89 -20
  142. package/dist/v1/language/class/model/class.d.ts +45 -9
  143. package/dist/v1/language/class/model/edge.d.ts +31 -2
  144. package/dist/v1/language/class/model/property.d.ts +16 -7
  145. package/dist/v1/language/class/property-values.js +2 -4
  146. package/dist/v1/language/class/resolved.d.ts +9 -4
  147. package/dist/v1/language/class/unique.d.ts +143 -0
  148. package/dist/v1/language/class/unique.js +264 -0
  149. package/dist/v1/language/core/facts.d.ts +85 -0
  150. package/dist/v1/language/core/facts.js +116 -0
  151. package/dist/v1/language/cycle.d.ts +10 -0
  152. package/dist/v1/language/cycle.js +30 -0
  153. package/dist/v1/language/definition/metadata.d.ts +38 -0
  154. package/dist/v1/language/definition/metadata.js +51 -0
  155. package/dist/v1/language/freeze.d.ts +5 -0
  156. package/dist/v1/{schema/canonical → language}/freeze.js +4 -0
  157. package/dist/v1/language/index.d.ts +7 -2
  158. package/dist/v1/language/index.js +5 -1
  159. package/dist/v1/language/limits.d.ts +83 -0
  160. package/dist/v1/language/limits.js +77 -0
  161. package/dist/v1/language/policy/analysis/branches.d.ts +8 -0
  162. package/dist/v1/language/policy/analysis/branches.js +8 -8
  163. package/dist/v1/language/policy/analysis/budgets.d.ts +45 -12
  164. package/dist/v1/language/policy/analysis/budgets.js +140 -20
  165. package/dist/v1/language/policy/analysis/checks.js +8 -6
  166. package/dist/v1/language/policy/analysis/composition.d.ts +4 -0
  167. package/dist/v1/language/policy/analysis/composition.js +11 -0
  168. package/dist/v1/language/policy/analysis/typing.d.ts +51 -0
  169. package/dist/v1/language/policy/analysis/typing.js +456 -0
  170. package/dist/v1/language/policy/model/policy.d.ts +71 -9
  171. package/dist/v1/language/policy/model/policy.js +42 -4
  172. package/dist/v1/language/policy/normalization/normalize.d.ts +6 -6
  173. package/dist/v1/language/policy/normalization/normalize.js +46 -68
  174. package/dist/v1/language/suspended.d.ts +7 -0
  175. package/dist/v1/language/suspended.js +23 -0
  176. package/dist/v1/language/validation/diagnostic.d.ts +15 -1
  177. package/dist/v1/language/validation/diagnostic.js +21 -0
  178. package/dist/v1/language/validation/rule.d.ts +45 -0
  179. package/dist/v1/language/validation/rule.js +109 -0
  180. package/dist/v1/language/value/compile/fields.js +16 -16
  181. package/dist/v1/language/value/compile/load.d.ts +5 -0
  182. package/dist/v1/language/value/compile/load.js +13 -0
  183. package/dist/v1/language/value/evaluate/assertions.d.ts +5 -1
  184. package/dist/v1/language/value/evaluate/assertions.js +19 -8
  185. package/dist/v1/language/value/evaluate/evaluator.js +117 -120
  186. package/dist/v1/language/value/evaluate/preparation.d.ts +16 -0
  187. package/dist/v1/language/value/evaluate/preparation.js +100 -47
  188. package/dist/v1/language/value/evaluate/program.d.ts +2 -1
  189. package/dist/v1/language/value/evaluate/program.js +6 -6
  190. package/dist/v1/language/value/evaluate/validate.d.ts +3 -3
  191. package/dist/v1/language/value/evaluate/validate.js +15 -11
  192. package/dist/v1/language/value/evaluate/validity.optimization.d.ts +14 -0
  193. package/dist/v1/language/value/evaluate/validity.optimization.js +338 -0
  194. package/dist/v1/language/value/files.d.ts +44 -0
  195. package/dist/v1/language/value/files.js +151 -0
  196. package/dist/v1/language/value/inclusion/arrays.d.ts +3 -0
  197. package/dist/v1/language/value/inclusion/arrays.js +85 -0
  198. package/dist/v1/language/value/inclusion/assertions.d.ts +18 -0
  199. package/dist/v1/language/value/inclusion/assertions.js +28 -0
  200. package/dist/v1/language/value/inclusion/combinators.d.ts +3 -0
  201. package/dist/v1/language/value/inclusion/combinators.js +67 -0
  202. package/dist/v1/language/value/inclusion/equivalence.d.ts +4 -0
  203. package/dist/v1/language/value/inclusion/equivalence.js +76 -0
  204. package/dist/v1/language/value/inclusion/evidence.d.ts +34 -0
  205. package/dist/v1/language/value/inclusion/evidence.js +140 -0
  206. package/dist/v1/language/value/inclusion/includes.d.ts +29 -3
  207. package/dist/v1/language/value/inclusion/includes.js +58 -723
  208. package/dist/v1/language/value/inclusion/keywords.d.ts +5 -0
  209. package/dist/v1/language/value/inclusion/keywords.js +31 -0
  210. package/dist/v1/language/value/inclusion/kinds.d.ts +17 -0
  211. package/dist/v1/language/value/inclusion/kinds.js +57 -0
  212. package/dist/v1/language/value/inclusion/location.d.ts +24 -0
  213. package/dist/v1/language/value/inclusion/location.js +66 -0
  214. package/dist/v1/language/value/inclusion/numbers.d.ts +3 -0
  215. package/dist/v1/language/value/inclusion/numbers.js +41 -0
  216. package/dist/v1/language/value/inclusion/objects.d.ts +3 -0
  217. package/dist/v1/language/value/inclusion/objects.js +190 -0
  218. package/dist/v1/language/value/inclusion/strings.d.ts +3 -0
  219. package/dist/v1/language/value/inclusion/strings.js +29 -0
  220. package/dist/v1/language/value/inclusion/types.d.ts +3 -0
  221. package/dist/v1/language/value/inclusion/types.js +34 -0
  222. package/dist/v1/language/value/model/blob.d.ts +6 -0
  223. package/dist/v1/language/value/model/blob.js +8 -0
  224. package/dist/v1/language/value/model/file.d.ts +41 -0
  225. package/dist/v1/language/value/model/file.js +122 -0
  226. package/dist/v1/language/value/ordering.d.ts +14 -0
  227. package/dist/v1/language/value/ordering.js +144 -77
  228. package/dist/v1/language/value/profile/canonicalize.d.ts +6 -1
  229. package/dist/v1/language/value/profile/canonicalize.js +67 -87
  230. package/dist/v1/language/value/profile/json.validate.d.ts +12 -0
  231. package/dist/v1/language/value/profile/json.validate.js +18 -5
  232. package/dist/v1/language/value/profile/meta-schema.compiled.d.ts +1 -0
  233. package/dist/v1/language/value/profile/meta-schema.compiled.js +21 -5
  234. package/dist/v1/language/value/profile/rules.js +27 -44
  235. package/dist/v1/language/value/profile/validate.js +1 -10
  236. package/dist/v1/language/value/profile/vocabulary.d.ts +36 -2
  237. package/dist/v1/language/value/profile/vocabulary.js +58 -5
  238. package/dist/v1/language/value/reference/closure.js +6 -6
  239. package/dist/v1/language/value/reference/recursion.js +9 -48
  240. package/dist/v1/language/value/reference/references.d.ts +3 -1
  241. package/dist/v1/language/value/reference/references.js +7 -7
  242. package/dist/v1/language/value/reference/registry.index.d.ts +2 -0
  243. package/dist/v1/language/value/reference/registry.index.js +33 -16
  244. package/dist/v1/language/value/regexp/ast.js +6 -7
  245. package/dist/v1/language/value/regexp/compile.d.ts +5 -11
  246. package/dist/v1/language/value/regexp/compile.js +14 -12
  247. package/dist/v1/language/value/regexp/syntax.js +3 -2
  248. package/dist/v1/language/value/regexp/unicode.d.ts +1 -1
  249. package/dist/v1/language/value/regexp/unicode.js +1 -1
  250. package/dist/v1/language/value/syntax/keywords.d.ts +3 -3
  251. package/dist/v1/language/value/syntax/keywords.js +4 -20
  252. package/dist/v1/language/value/syntax/node-path/validate.js +2 -3
  253. package/dist/v1/language/value/syntax/pointer.d.ts +2 -0
  254. package/dist/v1/language/value/syntax/pointer.js +5 -2
  255. package/dist/v1/language/value/syntax/walk.d.ts +9 -0
  256. package/dist/v1/language/value/syntax/walk.js +37 -20
  257. package/dist/v1/schema/.spec/schemas/domain-schema.schema.json +2596 -0
  258. package/dist/v1/schema/admission/accept.d.ts +3 -1
  259. package/dist/v1/schema/admission/accept.js +6 -14
  260. package/dist/v1/schema/admission/callable.d.ts +21 -0
  261. package/dist/v1/schema/admission/callable.js +96 -0
  262. package/dist/v1/schema/analysis/class.d.ts +4 -0
  263. package/dist/v1/schema/analysis/class.js +57 -17
  264. package/dist/v1/schema/canonical/revision.d.ts +4 -1
  265. package/dist/v1/schema/canonical/revision.js +8 -5
  266. package/dist/v1/schema/compatibility/api.d.ts +4 -1
  267. package/dist/v1/schema/compatibility/api.js +2 -0
  268. package/dist/v1/schema/compatibility/comparators/callables.js +1 -1
  269. package/dist/v1/schema/compatibility/comparators/classes.d.ts +9 -4
  270. package/dist/v1/schema/compatibility/comparators/classes.js +50 -29
  271. package/dist/v1/schema/compatibility/comparators/index.d.ts +1 -1
  272. package/dist/v1/schema/compatibility/comparators/members.js +1 -1
  273. package/dist/v1/schema/compatibility/comparators/values.js +2 -2
  274. package/dist/v1/schema/compatibility/context.d.ts +5 -2
  275. package/dist/v1/schema/compatibility/context.js +8 -6
  276. package/dist/v1/schema/compatibility/coordinate.js +3 -3
  277. package/dist/v1/schema/compatibility/diff.js +2 -4
  278. package/dist/v1/schema/compatibility/extension.d.ts +11 -0
  279. package/dist/v1/schema/compatibility/extension.js +22 -0
  280. package/dist/v1/schema/compatibility/fields.d.ts +20 -4
  281. package/dist/v1/schema/compatibility/fields.js +13 -3
  282. package/dist/v1/schema/compatibility/meaning/footprint.js +16 -51
  283. package/dist/v1/schema/compatibility/model.d.ts +17 -5
  284. package/dist/v1/schema/compatibility/references.d.ts +0 -3
  285. package/dist/v1/schema/compatibility/references.js +1 -9
  286. package/dist/v1/schema/compatibility/report.js +1 -1
  287. package/dist/v1/schema/compatibility/rule.d.ts +13 -0
  288. package/dist/v1/schema/compatibility/rule.js +23 -0
  289. package/dist/v1/schema/compatibility/scope.d.ts +2 -0
  290. package/dist/v1/schema/compatibility/scope.js +4 -1
  291. package/dist/v1/schema/compatibility/structure/index.js +6 -4
  292. package/dist/v1/schema/compatibility/structure/requirements.js +58 -61
  293. package/dist/v1/schema/compatibility/versioning/index.js +1 -1
  294. package/dist/v1/schema/compatibility/versioning/surface.d.ts +1 -1
  295. package/dist/v1/schema/compatibility/versioning/surface.js +30 -2
  296. package/dist/v1/schema/compatibility/walk.d.ts +17 -0
  297. package/dist/v1/schema/compatibility/walk.js +41 -0
  298. package/dist/v1/schema/diagnostic.d.ts +17 -3
  299. package/dist/v1/schema/diagnostic.js +14 -11
  300. package/dist/v1/schema/enforcement/changes.d.ts +590 -0
  301. package/dist/v1/schema/enforcement/changes.js +566 -0
  302. package/dist/v1/schema/enforcement/derived.d.ts +236 -0
  303. package/dist/v1/schema/enforcement/derived.js +243 -0
  304. package/dist/v1/schema/enforcement/dispose.d.ts +308 -0
  305. package/dist/v1/schema/enforcement/dispose.js +275 -0
  306. package/dist/v1/schema/enforcement/facts.d.ts +89 -0
  307. package/dist/v1/schema/enforcement/facts.js +70 -0
  308. package/dist/v1/schema/enforcement/fields.d.ts +65 -0
  309. package/dist/v1/schema/enforcement/fields.js +36 -0
  310. package/dist/v1/schema/enforcement/index.d.ts +39 -0
  311. package/dist/v1/schema/enforcement/index.js +10 -0
  312. package/dist/v1/schema/enforcement/install.d.ts +1634 -0
  313. package/dist/v1/schema/enforcement/install.js +1223 -0
  314. package/dist/v1/schema/enforcement/lifecycle.d.ts +87 -0
  315. package/dist/v1/schema/enforcement/lifecycle.js +91 -0
  316. package/dist/v1/schema/enforcement/model.d.ts +253 -0
  317. package/dist/v1/schema/enforcement/model.js +1 -0
  318. package/dist/v1/schema/enforcement/obligations.d.ts +248 -0
  319. package/dist/v1/schema/enforcement/obligations.js +240 -0
  320. package/dist/v1/schema/enforcement/write.d.ts +1314 -0
  321. package/dist/v1/schema/enforcement/write.js +1017 -0
  322. package/dist/v1/schema/index.d.ts +11 -1
  323. package/dist/v1/schema/index.js +5 -0
  324. package/dist/v1/schema/model/schema.d.ts +23 -1
  325. package/dist/v1/schema/model/schema.js +1 -1
  326. package/dist/v1/schema/normalization/domain.d.ts +2 -0
  327. package/dist/v1/schema/normalization/domain.js +50 -13
  328. package/dist/v1/schema/resolution/closure.js +2 -1
  329. package/dist/v1/schema/resolution/context.js +17 -18
  330. package/dist/v1/schema/resolution/domain.d.ts +5 -0
  331. package/dist/v1/schema/resolution/domain.js +6 -12
  332. package/dist/v1/schema/resolution/origins.js +6 -8
  333. package/dist/v1/schema/rule.d.ts +25 -0
  334. package/dist/v1/schema/rule.js +459 -0
  335. package/dist/v1/schema/validation/callable.d.ts +35 -2
  336. package/dist/v1/schema/validation/callable.js +65 -9
  337. package/dist/v1/schema/validation/class.d.ts +6 -2
  338. package/dist/v1/schema/validation/class.js +128 -105
  339. package/dist/v1/schema/validation/core.js +103 -173
  340. package/dist/v1/schema/validation/domain.js +25 -15
  341. package/dist/v1/schema/validation/domain.json-schema.d.ts +15 -0
  342. package/dist/v1/schema/validation/domain.json-schema.js +222 -0
  343. package/dist/v1/schema/validation/domain.route.d.ts +6 -1
  344. package/dist/v1/schema/validation/domain.route.js +18 -0
  345. package/dist/v1/schema/validation/domain.structure.d.ts +7797 -0
  346. package/dist/v1/schema/validation/domain.structure.js +516 -160
  347. package/dist/v1/schema/validation/icon.d.ts +4 -0
  348. package/dist/v1/schema/validation/icon.js +29 -0
  349. package/dist/v1/schema/validation/json.json-schema.d.ts +40 -0
  350. package/dist/v1/schema/validation/json.json-schema.js +46 -0
  351. package/dist/v1/schema/validation/policy/budgets.d.ts +37 -2
  352. package/dist/v1/schema/validation/policy/budgets.js +94 -121
  353. package/dist/v1/schema/validation/policy/context.d.ts +6 -5
  354. package/dist/v1/schema/validation/policy/context.js +7 -10
  355. package/dist/v1/schema/validation/policy/objects.d.ts +1 -1
  356. package/dist/v1/schema/validation/policy/objects.js +6 -14
  357. package/dist/v1/schema/validation/policy/references.js +20 -62
  358. package/dist/v1/schema/validation/policy/typing.d.ts +3 -18
  359. package/dist/v1/schema/validation/policy/typing.js +22 -356
  360. package/dist/v1/schema/validation/policy/uses.d.ts +40 -3
  361. package/dist/v1/schema/validation/policy/uses.js +63 -91
  362. package/dist/v1/schema/validation/policy/validate.js +5 -5
  363. package/dist/v1/schema/validation/value-api.d.ts +27 -1
  364. package/dist/v1/schema/validation/value-api.js +37 -2
  365. package/dist/v1/schema/validation/value.d.ts +3 -0
  366. package/dist/v1/schema/validation/value.js +9 -17
  367. package/dist/v1/schema/validation/value.json-schema.d.ts +54 -0
  368. package/dist/v1/schema/validation/value.json-schema.js +163 -0
  369. package/dist/v1/schema/validation/view.js +4 -8
  370. package/dist/value/accept.d.ts +9 -3
  371. package/dist/value/accept.js +25 -1
  372. package/dist/value/canonical.d.ts +22 -1
  373. package/dist/value/canonical.js +114 -21
  374. package/dist/value/decode.d.ts +7 -0
  375. package/dist/value/decode.js +159 -9
  376. package/dist/value/equal.d.ts +9 -1
  377. package/dist/value/equal.js +37 -3
  378. package/dist/value/immutable.optimization.d.ts +2 -0
  379. package/dist/value/immutable.optimization.js +4 -0
  380. package/dist/value/index.d.ts +5 -3
  381. package/dist/value/index.js +2 -1
  382. package/dist/value/json.d.ts +2 -2
  383. package/dist/value/json.js +2 -2
  384. package/dist/value/limits.d.ts +11 -0
  385. package/dist/value/rule.d.ts +12 -0
  386. package/dist/value/rule.js +50 -0
  387. package/dist/value/types.d.ts +6 -0
  388. package/dist/value/unicode.d.ts +2 -1
  389. package/dist/value/unicode.js +2 -0
  390. package/package.json +15 -4
  391. package/dist/v1/builder/lowering/core-properties.d.ts +0 -10
  392. package/dist/v1/builder/lowering/core-properties.js +0 -76
  393. package/dist/v1/compiled/admission/semantics/cardinality.d.ts +0 -5
  394. package/dist/v1/compiled/admission/semantics/cardinality.js +0 -113
  395. package/dist/v1/compiled/admission/semantics/policy/equality.d.ts +0 -8
  396. package/dist/v1/compiled/admission/semantics/policy/equality.js +0 -27
  397. package/dist/v1/compiled/admission/semantics/policy/measure.d.ts +0 -9
  398. package/dist/v1/compiled/admission/semantics/policy/measure.js +0 -81
  399. package/dist/v1/compiled/admission/semantics/policy/variants.d.ts +0 -10
  400. package/dist/v1/compiled/admission/semantics/policy/variants.js +0 -65
  401. package/dist/v1/compiled/admission/wire/pattern.d.ts +0 -12
  402. package/dist/v1/compiled/admission/wire/pattern.js +0 -111
  403. package/dist/v1/language/class/index.d.ts +0 -8
  404. package/dist/v1/language/class/index.js +0 -1
  405. package/dist/v1/language/core/index.d.ts +0 -2
  406. package/dist/v1/language/value/index.d.ts +0 -11
  407. package/dist/v1/language/value/index.js +0 -8
  408. package/dist/v1/schema/canonical/domain.d.ts +0 -3
  409. package/dist/v1/schema/canonical/domain.digest.d.ts +0 -3
  410. package/dist/v1/schema/canonical/domain.digest.js +0 -5
  411. package/dist/v1/schema/canonical/domain.js +0 -5
  412. package/dist/v1/schema/canonical/freeze.d.ts +0 -1
  413. /package/dist/v1/{language/core/index.js → builder/class/input.js} +0 -0
@@ -0,0 +1,192 @@
1
+ import { deepFreeze } from '../../language/freeze.js';
2
+ const UNSAYABLE = { holds: 'unsayable' };
3
+ const UNEXAMINED = { holds: 'unexamined' };
4
+ /**
5
+ * Every diagnostic code the Builder owns with the rule it reports. A code added to the Builder does
6
+ * not compile until it is described here. A rule of the Language is in `schema.values.RULES`.
7
+ */
8
+ export const BUILDER_RULES = deepFreeze({
9
+ BUILDER_ABSTRACT_POLICY: {
10
+ statement: 'An abstract Class declares no Class Policy, and an abstract Method no Policy.',
11
+ document: UNEXAMINED,
12
+ },
13
+ BUILDER_AMBIGUOUS_OWNERSHIP: {
14
+ statement: 'One authoring handle is owned by one Definition.',
15
+ document: UNSAYABLE,
16
+ },
17
+ BUILDER_AUTO_EVENT_INVALID: {
18
+ statement: 'An automatic Property runs on at least one event, each of them create or update, and a required one runs on create.',
19
+ document: {
20
+ holds: 'refused',
21
+ admission: ['STRUCTURE_MINIMUM', 'STRUCTURE_VALUE', 'DV_PROPERTY_AUTO'],
22
+ },
23
+ },
24
+ BUILDER_AUTO_IMMUTABLE: {
25
+ statement: 'An automatic Property is not immutable.',
26
+ document: { holds: 'refused', admission: ['DV_PROPERTY_IMMUTABLE'] },
27
+ },
28
+ BUILDER_AUTO_NESTED: {
29
+ statement: '`auto(...)` wraps a Property which is not already automatic.',
30
+ document: UNSAYABLE,
31
+ },
32
+ BUILDER_AUTO_SET_INVALID: {
33
+ statement: 'The setter of an automatic Property is `instant`.',
34
+ document: { holds: 'refused', admission: ['STRUCTURE_VALUE'] },
35
+ },
36
+ BUILDER_CALLABLE_AUTH: {
37
+ statement: 'A Function declares its auth as anonymous, authenticated or authorized.',
38
+ document: UNEXAMINED,
39
+ },
40
+ BUILDER_CALLABLE_PLACEMENT: {
41
+ statement: 'A standalone Function declares no staticness or abstractness, and a Method takes a Value input.',
42
+ document: UNEXAMINED,
43
+ },
44
+ BUILDER_CALLABLE_POLICY_AUTH: {
45
+ statement: 'Only an authorized Function or Method declares a Policy check.',
46
+ document: UNEXAMINED,
47
+ },
48
+ BUILDER_CLASS_INHERITANCE: {
49
+ statement: 'A Class extends a Class of another Domain only where that Class is open in the revision it binds.',
50
+ document: {
51
+ holds: 'refused',
52
+ admission: ['DV_CLASS_INHERITANCE'],
53
+ install: 'DEPENDENCY_INCOMPATIBLE',
54
+ },
55
+ },
56
+ BUILDER_CORE_CLASS: {
57
+ statement: 'The Class of a Core Node or a Core Edge is local to the owning Domain.',
58
+ document: { holds: 'refused', admission: ['DV_CORE_NODE_CLASS', 'DV_CORE_EDGE_CLASS'] },
59
+ },
60
+ BUILDER_CORE_EDGE: {
61
+ statement: 'An entry of `core.edges` is created by `core.edge(...)`.',
62
+ document: UNSAYABLE,
63
+ },
64
+ BUILDER_CORE_NODE: {
65
+ statement: 'An entry of `core.nodes` is created by `core.node(...)`.',
66
+ document: UNSAYABLE,
67
+ },
68
+ BUILDER_CORE_PROPERTY: {
69
+ statement: 'A Core fact names a Property of its Class by name, each once, and its Class is concrete and resolves.',
70
+ document: { holds: 'refused', admission: ['DV_CORE_NODE_PROPERTIES'] },
71
+ },
72
+ BUILDER_CORE_REF: {
73
+ statement: 'An endpoint of a Core Edge names the owning Domain or one local Definition, Function, Method, Policy, View or Core Node.',
74
+ document: { holds: 'refused', admission: ['DV_CORE_REF'] },
75
+ },
76
+ BUILDER_DEFINITION: {
77
+ statement: 'An entry of `classes` is created by a Definition builder.',
78
+ document: UNSAYABLE,
79
+ },
80
+ BUILDER_DEPENDENCY_ALIAS: {
81
+ statement: 'A dependency alias is an ASCII lower-camel identifier and is not reserved.',
82
+ document: { holds: 'refused', admission: ['STRUCTURE_KEY', 'STRUCTURE_DEPENDENCY_ALIAS'] },
83
+ },
84
+ BUILDER_DEPENDENCY_CONFLICT: {
85
+ statement: 'One origin is declared under one dependency alias.',
86
+ document: { holds: 'refused', admission: ['DV_DEPENDENCY_UNIQUE'] },
87
+ },
88
+ BUILDER_DEPENDENCY_DIRECT: {
89
+ statement: 'A foreign Definition belongs to a direct dependency.',
90
+ document: { holds: 'refused', admission: ['DV_REF_RESOLVES', 'DV_DEPENDENCY_DIRECT'] },
91
+ },
92
+ BUILDER_EDGE_LIFETIME: {
93
+ statement: 'An Edge Class with an endpoint which can hold a Node of another Domain requires no Edge at any endpoint, and an Edge Class keeps the lifetimes of the Edge Classes it extends.',
94
+ document: { holds: 'nothing' },
95
+ },
96
+ BUILDER_FILE_INVALID: {
97
+ statement: 'A file field states valid constraints, within those of the blob it is copied from.',
98
+ document: { holds: 'refused', admission: ['DV_VALUE_SCHEMA'] },
99
+ },
100
+ BUILDER_FOREIGN_POLICY: {
101
+ statement: 'A Policy reference names a local Policy.',
102
+ document: UNEXAMINED,
103
+ },
104
+ BUILDER_FULL_MATCH_INVALID: {
105
+ statement: '`fullMatch(...)` takes a complete I-Regexp source within the state budget.',
106
+ document: { holds: 'refused', admission: ['DV_VALUE_SCHEMA'] },
107
+ },
108
+ BUILDER_FUNCTION: {
109
+ statement: 'An entry of `functions` is created by `func(...)`.',
110
+ document: UNEXAMINED,
111
+ },
112
+ BUILDER_METHOD: {
113
+ statement: 'An entry of `methods` is created by `method(...)`.',
114
+ document: UNEXAMINED,
115
+ },
116
+ BUILDER_PATH_DUPLICATE: {
117
+ statement: '`path(...)` names one Node Definition once. A path stands in a Zod input, so the refusal reaches the caller as `ZOD_SCHEMA_NOT_LOSSLESS`, whose message holds this code.',
118
+ document: { holds: 'refused', admission: ['DV_VALUE_SCHEMA'] },
119
+ },
120
+ BUILDER_PATH_EMPTY: {
121
+ statement: '`path(...)` names at least one Node Definition.',
122
+ document: { holds: 'refused', admission: ['DV_VALUE_SCHEMA'] },
123
+ },
124
+ BUILDER_POLICY: {
125
+ statement: 'A Policy is created by `policy(...)` and its operands take the object it checks.',
126
+ document: UNEXAMINED,
127
+ },
128
+ BUILDER_POLICY_COMPOSITION: {
129
+ statement: 'A Policy composition is created by `policy.allOf(...)` or `policy.anyOf(...)`.',
130
+ document: UNEXAMINED,
131
+ },
132
+ BUILDER_POLICY_CYCLE: {
133
+ statement: 'A Policy composition does not reach itself.',
134
+ document: UNEXAMINED,
135
+ },
136
+ BUILDER_POLICY_EMPTY_COMPOSITION: {
137
+ statement: 'A Policy composition has at least one operand.',
138
+ document: UNEXAMINED,
139
+ },
140
+ BUILDER_POLICY_EMPTY_EXISTS: {
141
+ statement: '`exists(...)` declares at least one variable Node.',
142
+ document: UNEXAMINED,
143
+ },
144
+ BUILDER_POLICY_INPUT: {
145
+ statement: 'A Policy input is one direct required field holding one Node path.',
146
+ document: UNEXAMINED,
147
+ },
148
+ BUILDER_POLICY_REF: {
149
+ statement: 'A Policy `ref(...)` names one local or direct-dependency Definition, Function, Method, Policy, View or Core Node.',
150
+ document: UNEXAMINED,
151
+ },
152
+ BUILDER_POLICY_SELF: {
153
+ statement: '`self` is available only to a non-static Node Method.',
154
+ document: UNEXAMINED,
155
+ },
156
+ BUILDER_PROPERTY_IMMUTABLE_INVALID: {
157
+ statement: '`immutable` is `create` or `once`.',
158
+ document: { holds: 'refused', admission: ['STRUCTURE_VALUE'] },
159
+ },
160
+ BUILDER_REFERENCE_CYCLE: {
161
+ statement: 'A lazy reference resolves without reaching itself.',
162
+ document: UNSAYABLE,
163
+ },
164
+ BUILDER_REFERENCE_KIND: {
165
+ statement: 'A reference names a Class of the kind its position takes.',
166
+ document: { holds: 'refused', admission: ['DV_CLASS_KIND'] },
167
+ },
168
+ BUILDER_REFERENCE_MISSING: {
169
+ statement: 'A local reference names a Definition the Domain declares.',
170
+ document: { holds: 'refused', admission: ['DV_REF_RESOLVES'] },
171
+ },
172
+ BUILDER_UNIQUE_PROPERTY: {
173
+ statement: 'A key names a Property its Class holds.',
174
+ document: { holds: 'refused', admission: ['DV_NODE_UNIQUE'] },
175
+ },
176
+ BUILDER_UNKNOWN_FIELD: {
177
+ statement: 'An authoring input holds no field its builder does not read.',
178
+ document: { holds: 'refused', admission: ['STRUCTURE_UNKNOWN_FIELD'] },
179
+ },
180
+ BUILDER_UNOWNED_REFERENCE: {
181
+ statement: 'A reference to an authoring handle names a handle some Domain owns.',
182
+ document: UNSAYABLE,
183
+ },
184
+ BUILDER_VIEW: {
185
+ statement: 'An entry of `views` is created by `view(...)`, which names no target.',
186
+ document: UNEXAMINED,
187
+ },
188
+ ZOD_SCHEMA_NOT_LOSSLESS: {
189
+ statement: 'A Zod schema is one Draft 2020-12 can state with the same acceptance. A document states a value schema directly.',
190
+ document: UNSAYABLE,
191
+ },
192
+ });
@@ -0,0 +1,34 @@
1
+ import { type z } from 'zod';
2
+ import type { BlobReceipt } from '../../language/value/model/blob.js';
3
+ import type { FileOptions } from '../../language/value/model/file.js';
4
+ declare const FILE_AUTHORING: unique symbol;
5
+ /**
6
+ * A file field of a callable input: an upload receipt on the wire, typed as the receipt an upload
7
+ * returns. Its schema is `schema.values.file(...)`.
8
+ */
9
+ export type FileAuthoring = z.ZodType<BlobReceipt, BlobReceipt> & {
10
+ readonly [FILE_AUTHORING]: true;
11
+ };
12
+ /**
13
+ * The blob Property whose constraints a file field copies: its schema (`schema.values.blob(...)`),
14
+ * the authored `property(...)`, any value carrying that schema as `schema`, as a DomainSchema
15
+ * Property definition does, or a function returning one, read when the schema is built.
16
+ */
17
+ export type FileSource = {
18
+ readonly 'x-astrale-value-kind': 'blob';
19
+ } | {
20
+ readonly schema: unknown;
21
+ } | object | (() => unknown);
22
+ /** A file field with no constraint, or with its own `maxBytes` and `mediaTypes`. */
23
+ export declare function file(options?: FileOptions): FileAuthoring;
24
+ /**
25
+ * A file field stating the constraints of one blob Property, copied when the schema is built;
26
+ * `tighten` may lower its `maxBytes` and narrow its `mediaTypes`, never loosen them.
27
+ */
28
+ export declare function file(source: FileSource, tighten?: FileOptions): FileAuthoring;
29
+ /**
30
+ * The constraints of an authored file field, resolved now; undefined for any other schema. A Zod
31
+ * clone of a file field, as `.describe()` or `.optional()` inner schemas make, is still one.
32
+ */
33
+ export declare function fileOptionsOfAuthoring(schema: z.ZodType): FileOptions | undefined;
34
+ export {};
@@ -0,0 +1,77 @@
1
+ import { string } from 'zod';
2
+ import { isBlobValueSchema } from '../../language/value/model/blob.js';
3
+ import { acceptFileOptions, blobFileOptions, tightenFileOptions, } from '../../language/value/model/file.js';
4
+ import { propertyAuthoringInput } from '../class/property.js';
5
+ import { fail } from '../schema/diagnostic.js';
6
+ import { isAuthoringValue } from '../schema/handle.js';
7
+ const fileInputs = new WeakMap();
8
+ export function file(input, tighten) {
9
+ const schema = string();
10
+ if (input === undefined || isFileOptions(input)) {
11
+ if (tighten !== undefined) {
12
+ fail('BUILDER_FILE_INVALID', '', 'file(options) takes no second argument.');
13
+ }
14
+ const options = admit(() => acceptFileOptions(input ?? {}));
15
+ fileInputs.set(schema, () => options);
16
+ }
17
+ else {
18
+ const narrowed = tighten === undefined ? undefined : admit(() => acceptFileOptions(tighten));
19
+ let resolved;
20
+ fileInputs.set(schema, () => {
21
+ resolved ??= admit(() => {
22
+ const base = blobFileOptions(blobSchemaOf(input));
23
+ return narrowed === undefined ? base : tightenFileOptions(base, narrowed);
24
+ });
25
+ return resolved;
26
+ });
27
+ }
28
+ return schema;
29
+ }
30
+ /**
31
+ * The constraints of an authored file field, resolved now; undefined for any other schema. A Zod
32
+ * clone of a file field, as `.describe()` or `.optional()` inner schemas make, is still one.
33
+ */
34
+ export function fileOptionsOfAuthoring(schema) {
35
+ for (let current = schema; current !== undefined; current = current._zod?.parent) {
36
+ const options = fileInputs.get(current);
37
+ if (options !== undefined)
38
+ return options();
39
+ }
40
+ return undefined;
41
+ }
42
+ function blobSchemaOf(input, depth = 0) {
43
+ if (typeof input === 'function' && depth === 0) {
44
+ return blobSchemaOf(input(), depth + 1);
45
+ }
46
+ if (isBlobValueSchema(input))
47
+ return input;
48
+ if (isAuthoringValue(input, 'property')) {
49
+ const authored = propertyAuthoringInput(input).schema;
50
+ if (isBlobValueSchema(authored))
51
+ return authored;
52
+ }
53
+ else if (input !== null && typeof input === 'object' && 'schema' in input) {
54
+ const schema = input.schema;
55
+ if (isBlobValueSchema(schema))
56
+ return schema;
57
+ }
58
+ throw new TypeError('file(source) requires a blob Property or its schema.');
59
+ }
60
+ function isFileOptions(input) {
61
+ return (typeof input === 'object' &&
62
+ input !== null &&
63
+ !isAuthoringValue(input, 'property') &&
64
+ !isBlobValueSchema(input) &&
65
+ !Object.hasOwn(input, 'schema') &&
66
+ Object.keys(input).every((key) => key === 'maxBytes' || key === 'mediaTypes'));
67
+ }
68
+ function admit(read) {
69
+ try {
70
+ return read();
71
+ }
72
+ catch (cause) {
73
+ if (!(cause instanceof TypeError))
74
+ throw cause;
75
+ fail('BUILDER_FILE_INVALID', '', `file(...): ${cause.message}`);
76
+ }
77
+ }
@@ -1,4 +1,3 @@
1
1
  import { type FullMatch } from '../../language/value/syntax/full-match.js';
2
- export { fullMatchSource, type FullMatch } from '../../language/value/syntax/full-match.js';
3
2
  /** Authoring facade preserving the Builder-owned diagnostic for invalid source syntax. */
4
3
  export declare function fullMatch(source: string): FullMatch;
@@ -1,7 +1,6 @@
1
1
  import { refuseIRegexp, stateBudgetMessage } from '../../language/value/regexp/syntax.js';
2
2
  import { fullMatch as languageFullMatch, } from '../../language/value/syntax/full-match.js';
3
3
  import { fail } from '../schema/diagnostic.js';
4
- export { fullMatchSource } from '../../language/value/syntax/full-match.js';
5
4
  /** Authoring facade preserving the Builder-owned diagnostic for invalid source syntax. */
6
5
  export function fullMatch(source) {
7
6
  const refusal = refuseIRegexp(source);
@@ -1,4 +1,4 @@
1
1
  import type { z } from 'zod';
2
- import type { NodeClassReferenceInput } from '../class/authoring.js';
2
+ import type { NodeClassReferenceInput } from '../class/input.js';
3
3
  export declare function rememberPath(schema: z.ZodType, accepts: readonly NodeClassReferenceInput[]): void;
4
4
  export declare function pathAccepts(schema: z.ZodType): readonly NodeClassReferenceInput[] | undefined;
@@ -1,5 +1,5 @@
1
1
  import { type ZodString } from 'zod';
2
- import type { NodeClassReferenceInput } from '../class/authoring.js';
2
+ import type { NodeClassReferenceInput } from '../class/input.js';
3
3
  declare const PATH_ACCEPTS: unique symbol;
4
4
  export type PathAuthoring<Accepts extends readonly NodeClassReferenceInput[] = readonly NodeClassReferenceInput[]> = ZodString & {
5
5
  readonly [PATH_ACCEPTS]: Accepts;
@@ -1,46 +1,41 @@
1
- import { accept as acceptJsonValue, BoundaryError as JsonBoundaryError, json, } from '@astrale-os/kernel-dsl/value';
2
- import { dependencyLimits } from '../addressing/domain-dependency.js';
1
+ import { acceptImmutable, BoundaryError as JsonBoundaryError, json, } from '@astrale-os/kernel-dsl/value';
3
2
  import { compareUnicode } from '../addressing/ordering.js';
4
- import { acceptDomainSchema } from '../schema/admission/accept.js';
3
+ import { closureDocument, limits } from '../language/limits.js';
4
+ import { escapePointerToken } from '../language/value/syntax/pointer.js';
5
+ import { acceptStructuredDomainSchema } from '../schema/admission/accept.js';
5
6
  import { canonicalDomainSchemaAfterValidation } from '../schema/canonical/revision.js';
6
7
  import { revisionOfDomainSchema } from '../schema/canonical/revision.js';
7
8
  import { MemoryDomainSchemaLookup } from '../schema/dependency/lookup.js';
8
9
  import { SchemaError } from '../schema/diagnostic.js';
9
- import { BundleError, diagnostic } from './diagnostic.js';
10
+ import { BundleError, diagnostic, schemaDiagnosticAt } from './diagnostic.js';
10
11
  import { asDomainSchemaBundle, } from './model.js';
11
12
  import { parseDomainSchemaBundleStructure } from './structure.js';
12
- function escapeToken(value) {
13
- return value.replaceAll('~', '~0').replaceAll('/', '~1');
14
- }
15
- export function acceptDomainSchemaBundle(input) {
16
- let admitted;
13
+ /** Cross the portable value boundary with a document at `at`, whose refusal is answered as one. */
14
+ function bundleDocument(cross, at = '') {
17
15
  try {
18
- admitted = acceptJsonValue(input);
16
+ return cross();
19
17
  }
20
18
  catch (error) {
21
19
  if (error instanceof JsonBoundaryError) {
22
- throw new BundleError([diagnostic('DV_JSON_VALUE', error.pointer, error.message)]);
20
+ throw new BundleError([diagnostic('DV_JSON_VALUE', `${at}${error.pointer}`, error.message)]);
23
21
  }
24
- throw error;
25
- }
26
- return acceptBundleValue(admitted);
27
- }
28
- export function decodeDomainSchemaBundle(input) {
29
- try {
30
- return acceptBundleValue(json.decode(input));
31
- }
32
- catch (error) {
33
22
  if (error instanceof json.DecodeError) {
34
- throw new BundleError([diagnostic('DV_JSON_VALUE', '', error.message)]);
23
+ throw new BundleError([diagnostic('DV_JSON_VALUE', at, error.message)]);
35
24
  }
36
25
  throw error;
37
26
  }
38
27
  }
28
+ export function acceptDomainSchemaBundle(input) {
29
+ return acceptBundleValue(bundleDocument(() => acceptImmutable(input, closureDocument)));
30
+ }
31
+ export function decodeDomainSchemaBundle(input) {
32
+ return acceptBundleValue(bundleDocument(() => json.decode(input, closureDocument)));
33
+ }
39
34
  export function serializeDomainSchemaBundle(bundle) {
40
- return json.serialize(bundle);
35
+ return bundleDocument(() => json.serialize(bundle, closureDocument));
41
36
  }
42
37
  export function encodeDomainSchemaBundle(bundle) {
43
- return json.encode(bundle);
38
+ return bundleDocument(() => json.encode(bundle, closureDocument));
44
39
  }
45
40
  function acceptBundleValue(input) {
46
41
  const structure = parseDomainSchemaBundleStructure(input);
@@ -48,13 +43,8 @@ function acceptBundleValue(input) {
48
43
  const closure = structure.closure.map((schema, index) => candidate(schema, `/closure/${index}`));
49
44
  const diagnostics = [];
50
45
  const candidates = new Map();
51
- if (closure.length + 1 > dependencyLimits.closure) {
52
- diagnostics.push(diagnostic('DV_DEPENDENCY_LIMITS', '/closure', `A dependency closure may contain at most ${dependencyLimits.closure} Domains.`));
53
- }
54
- for (const entry of [root, ...closure]) {
55
- if (Object.keys(entry.schema.dependencies).length > dependencyLimits.direct) {
56
- diagnostics.push(diagnostic('DV_DEPENDENCY_LIMITS', `${entry.pointer}/dependencies`, `A Domain may declare at most ${dependencyLimits.direct} direct dependency aliases.`));
57
- }
46
+ if (closure.length + 1 > limits.dependency.closure) {
47
+ diagnostics.push(diagnostic('DV_DEPENDENCY_LIMITS', '/closure', `A dependency closure may contain at most ${limits.dependency.closure} Domains.`));
58
48
  }
59
49
  for (const entry of closure) {
60
50
  if (entry.key === root.key) {
@@ -68,8 +58,7 @@ function acceptBundleValue(input) {
68
58
  }
69
59
  candidates.set(entry.key, entry);
70
60
  }
71
- const reachable = new Set();
72
- collectReachable(root, root, candidates, reachable, new Set(), new Map(), diagnostics, 0);
61
+ const reachable = collectReachable(root, candidates, diagnostics);
73
62
  for (const entry of candidates.values()) {
74
63
  if (!reachable.has(entry.key)) {
75
64
  diagnostics.push(diagnostic('BUNDLE_CLOSURE_EXTRA', entry.pointer, `Schema ${entry.schema.origin}@${entry.revision} is not reachable from the root.`));
@@ -88,20 +77,14 @@ function acceptBundleValue(input) {
88
77
  acceptCandidate(nested);
89
78
  }
90
79
  try {
91
- const schema = acceptDomainSchema(entry.schema, new MemoryDomainSchemaLookup([...accepted.values()]));
92
- const revision = revisionOfDomainSchema(schema);
93
- if (revision !== entry.revision) {
94
- throw new BundleError([
95
- diagnostic('BUNDLE_SCHEMA_REVISION', '', `Accepted schema revision ${revision} differs from indexed revision ${entry.revision}.`),
96
- ]);
97
- }
98
- accepted.set(entry.key, { schema, revision });
80
+ const schema = acceptStructuredDomainSchema(entry.schema, new MemoryDomainSchemaLookup([...accepted.values()]));
81
+ accepted.set(entry.key, { schema, revision: entry.revision });
99
82
  return schema;
100
83
  }
101
84
  catch (error) {
102
85
  if (!(error instanceof SchemaError))
103
86
  throw error;
104
- throw new BundleError(error.diagnostics.map((item) => diagnostic(item.code, `${entry.pointer}${item.pointer}`, item.message, item.ref)));
87
+ throw new BundleError(error.diagnostics.map((item) => schemaDiagnosticAt(entry.pointer, item)));
105
88
  }
106
89
  };
107
90
  for (const entry of candidates.values()) {
@@ -116,7 +99,7 @@ function acceptBundleValue(input) {
116
99
  return asDomainSchemaBundle(rootSchema, acceptedClosure);
117
100
  }
118
101
  function candidate(schema, pointer) {
119
- const canonical = canonicalDomainSchemaAfterValidation(schema);
102
+ const canonical = bundleDocument(() => canonicalDomainSchemaAfterValidation(schema), pointer);
120
103
  return {
121
104
  schema,
122
105
  revision: canonical.revision,
@@ -124,40 +107,38 @@ function candidate(schema, pointer) {
124
107
  pointer,
125
108
  };
126
109
  }
127
- function collectReachable(current, root, candidates, reachable, active, revisions, diagnostics, depth) {
128
- if (active.has(current.key)) {
129
- diagnostics.push(diagnostic('BUNDLE_CLOSURE_CYCLE', current.pointer, `Bundle dependency cycle reaches ${current.schema.origin}@${current.revision}.`));
130
- return;
131
- }
132
- active.add(current.key);
133
- if (depth > dependencyLimits.depth) {
134
- diagnostics.push(diagnostic('DV_DEPENDENCY_LIMITS', current.pointer, `Dependency depth ${depth} exceeds the maximum ${dependencyLimits.depth}.`));
135
- active.delete(current.key);
136
- return;
137
- }
138
- for (const [alias, dependency] of Object.entries(current.schema.dependencies)) {
139
- const pointer = `${current.pointer}/dependencies/${escapeToken(alias)}`;
140
- const dependencyKey = keyOf(dependency.origin, dependency.revision);
141
- if (dependencyKey === root.key) {
142
- diagnostics.push(diagnostic('BUNDLE_CLOSURE_CYCLE', pointer, 'Bundle dependency closure returns to its root.'));
143
- continue;
144
- }
145
- const previous = revisions.get(dependency.origin);
146
- if (previous !== undefined && previous !== dependency.revision) {
147
- diagnostics.push(diagnostic('BUNDLE_REVISION_COHERENCE', pointer, `Bundle requires ${dependency.origin} at both ${previous} and ${dependency.revision}.`));
148
- }
149
- else {
150
- revisions.set(dependency.origin, dependency.revision);
151
- }
152
- const nested = candidates.get(dependencyKey);
153
- if (nested === undefined) {
154
- diagnostics.push(diagnostic('BUNDLE_CLOSURE_MISSING', pointer, `Bundle has no exact ${dependency.origin}@${dependency.revision}.`));
155
- continue;
110
+ /**
111
+ * The keys of the Domains `root` reaches, with a refusal at each dependency the Bundle cannot serve.
112
+ * Each Domain is read once, however many chains share it: `pending` grows as the loop reads it. A
113
+ * revision covers its pins, so a dependency cannot name the root except as a missing one, and each
114
+ * Domain's admission below holds the graph to its direct and depth limits.
115
+ */
116
+ function collectReachable(root, candidates, diagnostics) {
117
+ const reachable = new Set();
118
+ const revisions = new Map();
119
+ const pending = [root];
120
+ for (const current of pending) {
121
+ for (const [alias, dependency] of Object.entries(current.schema.dependencies)) {
122
+ const pointer = `${current.pointer}/dependencies/${escapePointerToken(alias)}`;
123
+ const previous = revisions.get(dependency.origin);
124
+ if (previous !== undefined && previous !== dependency.revision) {
125
+ diagnostics.push(diagnostic('BUNDLE_REVISION_COHERENCE', pointer, `Bundle requires ${dependency.origin} at both ${previous} and ${dependency.revision}.`));
126
+ }
127
+ else {
128
+ revisions.set(dependency.origin, dependency.revision);
129
+ }
130
+ const nested = candidates.get(keyOf(dependency.origin, dependency.revision));
131
+ if (nested === undefined) {
132
+ diagnostics.push(diagnostic('BUNDLE_CLOSURE_MISSING', pointer, `Bundle has no exact ${dependency.origin}@${dependency.revision}.`));
133
+ continue;
134
+ }
135
+ if (!reachable.has(nested.key)) {
136
+ reachable.add(nested.key);
137
+ pending.push(nested);
138
+ }
156
139
  }
157
- reachable.add(nested.key);
158
- collectReachable(nested, root, candidates, reachable, active, revisions, diagnostics, depth + 1);
159
140
  }
160
- active.delete(current.key);
141
+ return reachable;
161
142
  }
162
143
  function compareSchemas(left, right) {
163
144
  return (compareUnicode(left.origin, right.origin) ||
@@ -1,9 +1,11 @@
1
1
  import type { SchemaDiagnostic, SchemaDiagnosticCode } from '../schema/diagnostic.js';
2
- export type BundleDiagnosticCode = SchemaDiagnosticCode | 'BUNDLE_CLOSURE_CYCLE' | 'BUNDLE_CLOSURE_EXTRA' | 'BUNDLE_CLOSURE_MISSING' | 'BUNDLE_REVISION_COHERENCE' | 'BUNDLE_ROOT_DUPLICATED' | 'BUNDLE_SCHEMA_DUPLICATED' | 'BUNDLE_SCHEMA_REVISION' | 'BUNDLE_STRUCTURE' | 'UNSUPPORTED_BUNDLE_FORMAT' | 'UNSUPPORTED_BUNDLE_VERSION';
2
+ export type BundleDiagnosticCode = SchemaDiagnosticCode | 'BUNDLE_CLOSURE_EXTRA' | 'BUNDLE_CLOSURE_MISSING' | 'BUNDLE_REVISION_COHERENCE' | 'BUNDLE_ROOT_DUPLICATED' | 'BUNDLE_SCHEMA_DUPLICATED' | 'BUNDLE_STRUCTURE' | 'UNSUPPORTED_BUNDLE_FORMAT' | 'UNSUPPORTED_BUNDLE_VERSION';
3
3
  export type BundleDiagnostic<Code extends BundleDiagnosticCode = BundleDiagnosticCode> = Omit<SchemaDiagnostic, 'code'> & {
4
4
  readonly code: Code;
5
5
  };
6
6
  export declare function diagnostic<const Code extends BundleDiagnosticCode>(code: Code, pointer: string, message: string, ref?: string): BundleDiagnostic<Code>;
7
+ /** A refusal of one bundled schema, its pointer rebased under the schema's place in the bundle. */
8
+ export declare function schemaDiagnosticAt(pointer: string, refusal: SchemaDiagnostic): BundleDiagnostic;
7
9
  export declare class BundleError extends Error {
8
10
  readonly diagnostics: readonly BundleDiagnostic[];
9
11
  constructor(diagnostics: readonly BundleDiagnostic[]);
@@ -1,16 +1,18 @@
1
- import { compareUnicode } from '../addressing/ordering.js';
1
+ import { formatDiagnostics, orderDiagnostics } from '../language/validation/diagnostic.js';
2
2
  export function diagnostic(code, pointer, message, ref) {
3
3
  return Object.freeze({ code, pointer, message, ...(ref === undefined ? {} : { ref }) });
4
4
  }
5
+ /** A refusal of one bundled schema, its pointer rebased under the schema's place in the bundle. */
6
+ export function schemaDiagnosticAt(pointer, refusal) {
7
+ // Acceptance refuses a document with Schema codes only, never with comparison request codes.
8
+ const code = refusal.code;
9
+ return Object.freeze({ ...refusal, code, pointer: `${pointer}${refusal.pointer}` });
10
+ }
5
11
  export class BundleError extends Error {
6
12
  diagnostics;
7
13
  constructor(diagnostics) {
8
- const ordered = [...diagnostics].sort((left, right) => compareUnicode(left.pointer, right.pointer) ||
9
- compareUnicode(left.code, right.code) ||
10
- compareUnicode(left.message, right.message));
11
- super(ordered
12
- .map(({ code, pointer, message }) => `${pointer || '/'} [${code}] ${message}`)
13
- .join('\n'));
14
+ const ordered = orderDiagnostics(diagnostics);
15
+ super(formatDiagnostics(ordered));
14
16
  this.name = 'BundleError';
15
17
  this.diagnostics = Object.freeze(ordered);
16
18
  }
@@ -14,5 +14,7 @@ export declare function decode(input: string | Uint8Array): Bundle;
14
14
  export declare function encode(bundle: Bundle): Uint8Array;
15
15
  export declare function serialize(bundle: Bundle): string;
16
16
  export { DOMAIN_BUNDLE_FORMAT as FORMAT, DOMAIN_BUNDLE_VERSION as VERSION } from './model.js';
17
+ export { BUNDLE_RULES as RULES } from './rule.js';
18
+ export type { BundleRule as Rule } from './rule.js';
17
19
  export { BundleError as Error } from './diagnostic.js';
18
20
  export type { BundleDiagnostic as Diagnostic, BundleDiagnosticCode as DiagnosticCode, } from './diagnostic.js';
@@ -17,4 +17,5 @@ export function serialize(bundle) {
17
17
  return serializeDomainSchemaBundle(bundle);
18
18
  }
19
19
  export { DOMAIN_BUNDLE_FORMAT as FORMAT, DOMAIN_BUNDLE_VERSION as VERSION } from './model.js';
20
+ export { BUNDLE_RULES as RULES } from './rule.js';
20
21
  export { BundleError as Error } from './diagnostic.js';
@@ -1,4 +1,4 @@
1
- import { deepFreeze } from '../schema/canonical/freeze.js';
1
+ import { deepFreeze } from '../language/freeze.js';
2
2
  export const DOMAIN_BUNDLE_FORMAT = 'astrale.dsl.bundle';
3
3
  export const DOMAIN_BUNDLE_VERSION = 'v1';
4
4
  export function asDomainSchemaBundle(root, closure) {
@@ -0,0 +1,14 @@
1
+ import type { SchemaDiagnosticCode } from '../schema/diagnostic.js';
2
+ import type { BundleDiagnosticCode } from './diagnostic.js';
3
+ /** The rule one diagnostic code of a Bundle reports. */
4
+ export interface BundleRule {
5
+ /** The positions its diagnostics point at, as the positions of `schema.Rule`. */
6
+ readonly positions: readonly [string, ...string[]];
7
+ /** The rule, in one plain sentence. */
8
+ readonly statement: string;
9
+ }
10
+ /**
11
+ * Every diagnostic code a Bundle owns with the rule it reports, frozen. A refused Schema of a
12
+ * Bundle answers with the codes of `schema.RULES`, rebased under its place in the Bundle.
13
+ */
14
+ export declare const BUNDLE_RULES: Readonly<Record<Exclude<BundleDiagnosticCode, SchemaDiagnosticCode>, BundleRule>>;
@@ -0,0 +1,41 @@
1
+ import { deepFreeze } from '../language/freeze.js';
2
+ import { DOMAIN_BUNDLE_FORMAT, DOMAIN_BUNDLE_VERSION } from './model.js';
3
+ const PIN = ['/root/dependencies/{alias}', '/closure/{index}/dependencies/{alias}'];
4
+ /**
5
+ * Every diagnostic code a Bundle owns with the rule it reports, frozen. A refused Schema of a
6
+ * Bundle answers with the codes of `schema.RULES`, rebased under its place in the Bundle.
7
+ */
8
+ export const BUNDLE_RULES = deepFreeze({
9
+ BUNDLE_STRUCTURE: {
10
+ positions: ['', '/{field}'],
11
+ statement: 'A Bundle is an object holding `format`, `version`, `root` and `closure` and no other field, its `closure` an array.',
12
+ },
13
+ UNSUPPORTED_BUNDLE_FORMAT: {
14
+ positions: ['/format'],
15
+ statement: `The \`format\` of a Bundle is \`${DOMAIN_BUNDLE_FORMAT}\`.`,
16
+ },
17
+ UNSUPPORTED_BUNDLE_VERSION: {
18
+ positions: ['/version'],
19
+ statement: `The \`version\` of a Bundle is \`${DOMAIN_BUNDLE_VERSION}\`.`,
20
+ },
21
+ BUNDLE_ROOT_DUPLICATED: {
22
+ positions: ['/closure/{index}'],
23
+ statement: 'The closure of a Bundle does not hold its root.',
24
+ },
25
+ BUNDLE_SCHEMA_DUPLICATED: {
26
+ positions: ['/closure/{index}'],
27
+ statement: 'The closure of a Bundle holds each origin at each revision once.',
28
+ },
29
+ BUNDLE_CLOSURE_EXTRA: {
30
+ positions: ['/closure/{index}'],
31
+ statement: 'The closure of a Bundle holds only Schemas its root reaches through exact pins.',
32
+ },
33
+ BUNDLE_CLOSURE_MISSING: {
34
+ positions: PIN,
35
+ statement: 'The closure of a Bundle holds the exact revision of every pin its root reaches.',
36
+ },
37
+ BUNDLE_REVISION_COHERENCE: {
38
+ positions: PIN,
39
+ statement: 'The pins a root reaches ask one revision of each origin.',
40
+ },
41
+ });