@astrale-os/kernel-dsl 1.0.0-beta.2 → 1.0.0-beta.20

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 (307) 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 +4 -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 +31 -33
  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 +5 -2
  24. package/dist/v1/builder/lowering/callable.js +1 -0
  25. package/dist/v1/builder/lowering/class.d.ts +9 -1
  26. package/dist/v1/builder/lowering/class.js +62 -17
  27. package/dist/v1/builder/lowering/policy.js +2 -0
  28. package/dist/v1/builder/lowering/property-keys.d.ts +27 -0
  29. package/dist/v1/builder/lowering/property-keys.js +108 -0
  30. package/dist/v1/builder/lowering/schema/compile.js +11 -6
  31. package/dist/v1/builder/lowering/schema/context.d.ts +9 -1
  32. package/dist/v1/builder/lowering/schema/context.js +36 -4
  33. package/dist/v1/builder/lowering/schema/lifetime.d.ts +11 -0
  34. package/dist/v1/builder/lowering/schema/lifetime.js +55 -0
  35. package/dist/v1/builder/lowering/value/path.d.ts +1 -1
  36. package/dist/v1/builder/lowering/value/path.js +2 -4
  37. package/dist/v1/builder/lowering/value/zod.js +1 -3
  38. package/dist/v1/builder/policy/authoring.d.ts +85 -5
  39. package/dist/v1/builder/policy/authoring.js +107 -68
  40. package/dist/v1/builder/schema/define.d.ts +0 -1
  41. package/dist/v1/builder/schema/diagnostic.d.ts +3 -2
  42. package/dist/v1/builder/schema/diagnostic.js +5 -10
  43. package/dist/v1/builder/schema/input.d.ts +1 -1
  44. package/dist/v1/builder/schema/projection/callable.d.ts +7 -5
  45. package/dist/v1/builder/schema/projection/class.d.ts +118 -15
  46. package/dist/v1/builder/schema/projection/core-input.d.ts +2 -1
  47. package/dist/v1/builder/schema/projection/identity.d.ts +2 -1
  48. package/dist/v1/builder/schema/projection/model.d.ts +4 -2
  49. package/dist/v1/builder/schema/projection/property.d.ts +1 -1
  50. package/dist/v1/builder/schema/projection/resolved-class.d.ts +2 -1
  51. package/dist/v1/builder/schema/projection.d.ts +1 -1
  52. package/dist/v1/builder/value/full-match.d.ts +0 -1
  53. package/dist/v1/builder/value/full-match.js +0 -1
  54. package/dist/v1/builder/value/path-metadata.d.ts +1 -1
  55. package/dist/v1/builder/value/path.d.ts +1 -1
  56. package/dist/v1/bundle/codec.js +11 -13
  57. package/dist/v1/bundle/diagnostic.d.ts +2 -0
  58. package/dist/v1/bundle/diagnostic.js +9 -7
  59. package/dist/v1/bundle/model.js +1 -1
  60. package/dist/v1/bundle/structure.js +4 -6
  61. package/dist/v1/compiled/admission/accept.js +4 -10
  62. package/dist/v1/compiled/admission/closure.js +2 -2
  63. package/dist/v1/compiled/admission/diagnostic.d.ts +1 -1
  64. package/dist/v1/compiled/admission/diagnostic.js +1 -3
  65. package/dist/v1/compiled/admission/revision.d.ts +9 -1
  66. package/dist/v1/compiled/admission/revision.js +6 -3
  67. package/dist/v1/compiled/admission/semantics/class.d.ts +4 -1
  68. package/dist/v1/compiled/admission/semantics/class.js +37 -12
  69. package/dist/v1/compiled/admission/semantics/core.d.ts +1 -24
  70. package/dist/v1/compiled/admission/semantics/core.js +56 -24
  71. package/dist/v1/compiled/admission/semantics/edge.d.ts +2 -4
  72. package/dist/v1/compiled/admission/semantics/edge.js +6 -65
  73. package/dist/v1/compiled/admission/semantics/policy/callable.js +0 -2
  74. package/dist/v1/compiled/admission/semantics/policy/contracts.d.ts +5 -20
  75. package/dist/v1/compiled/admission/semantics/policy/contracts.js +8 -21
  76. package/dist/v1/compiled/admission/semantics/policy/parity.js +40 -43
  77. package/dist/v1/compiled/admission/semantics/policy/pattern.d.ts +4 -1
  78. package/dist/v1/compiled/admission/semantics/policy/pattern.js +4 -16
  79. package/dist/v1/compiled/admission/semantics/policy/typing.d.ts +2 -24
  80. package/dist/v1/compiled/admission/semantics/policy/typing.js +19 -201
  81. package/dist/v1/compiled/admission/wire/callable.js +11 -1
  82. package/dist/v1/compiled/admission/wire/class.js +73 -21
  83. package/dist/v1/compiled/admission/wire/policy.d.ts +4 -3
  84. package/dist/v1/compiled/admission/wire/policy.js +8 -7
  85. package/dist/v1/compiled/compiler/compile.js +8 -8
  86. package/dist/v1/compiled/diagnostic.js +2 -3
  87. package/dist/v1/compiled/loader/load.d.ts +3 -2
  88. package/dist/v1/compiled/loader/load.js +11 -45
  89. package/dist/v1/domain/create.js +5 -6
  90. package/dist/v1/domain/model/domain.d.ts +2 -7
  91. package/dist/v1/domain/model/input.d.ts +2 -1
  92. package/dist/v1/domain/namespace/member-collection.js +4 -6
  93. package/dist/v1/domain/projection/classes.js +4 -1
  94. package/dist/v1/domain/validation/create.d.ts +6 -3
  95. package/dist/v1/domain/validation/create.js +21 -69
  96. package/dist/v1/index.d.ts +2 -1
  97. package/dist/v1/language/.spec/schemas/draft-2020-12.schema.json +462 -0
  98. package/dist/v1/language/.spec/schemas/value-schema.schema.json +22 -0
  99. package/dist/v1/language/callable/admission.d.ts +15 -0
  100. package/dist/v1/language/callable/admission.js +43 -0
  101. package/dist/v1/language/callable/model/callable.d.ts +10 -0
  102. package/dist/v1/language/callable/resolved.d.ts +16 -3
  103. package/dist/v1/language/class/inheritance.d.ts +36 -5
  104. package/dist/v1/language/class/inheritance.js +87 -1
  105. package/dist/v1/language/class/lifetime.d.ts +50 -11
  106. package/dist/v1/language/class/lifetime.js +89 -20
  107. package/dist/v1/language/class/model/class.d.ts +45 -9
  108. package/dist/v1/language/class/model/edge.d.ts +31 -2
  109. package/dist/v1/language/class/model/property.d.ts +16 -7
  110. package/dist/v1/language/class/property-values.js +2 -4
  111. package/dist/v1/language/class/unique.d.ts +143 -0
  112. package/dist/v1/language/class/unique.js +264 -0
  113. package/dist/v1/language/core/facts.d.ts +85 -0
  114. package/dist/v1/language/core/facts.js +116 -0
  115. package/dist/v1/language/definition/metadata.d.ts +5 -0
  116. package/dist/v1/language/definition/metadata.js +7 -0
  117. package/dist/v1/language/freeze.d.ts +5 -0
  118. package/dist/v1/{schema/canonical → language}/freeze.js +4 -0
  119. package/dist/v1/language/index.d.ts +7 -2
  120. package/dist/v1/language/index.js +5 -1
  121. package/dist/v1/language/limits.d.ts +64 -0
  122. package/dist/v1/language/limits.js +60 -0
  123. package/dist/v1/language/policy/analysis/branches.d.ts +8 -0
  124. package/dist/v1/language/policy/analysis/branches.js +2 -1
  125. package/dist/v1/language/policy/analysis/budgets.d.ts +45 -12
  126. package/dist/v1/language/policy/analysis/budgets.js +133 -19
  127. package/dist/v1/language/policy/analysis/checks.js +3 -2
  128. package/dist/v1/language/policy/analysis/typing.d.ts +51 -0
  129. package/dist/v1/language/policy/analysis/typing.js +455 -0
  130. package/dist/v1/language/policy/model/policy.d.ts +49 -9
  131. package/dist/v1/language/policy/model/policy.js +14 -0
  132. package/dist/v1/language/policy/normalization/normalize.d.ts +6 -6
  133. package/dist/v1/language/policy/normalization/normalize.js +22 -21
  134. package/dist/v1/language/validation/diagnostic.d.ts +15 -1
  135. package/dist/v1/language/validation/diagnostic.js +21 -0
  136. package/dist/v1/language/validation/rule.d.ts +45 -0
  137. package/dist/v1/language/validation/rule.js +109 -0
  138. package/dist/v1/language/value/compile/fields.js +4 -8
  139. package/dist/v1/language/value/evaluate/program.d.ts +2 -1
  140. package/dist/v1/language/value/evaluate/program.js +2 -2
  141. package/dist/v1/language/value/evaluate/validate.d.ts +2 -2
  142. package/dist/v1/language/value/evaluate/validate.js +6 -2
  143. package/dist/v1/language/value/evaluate/validity.optimization.d.ts +14 -0
  144. package/dist/v1/language/value/evaluate/validity.optimization.js +342 -0
  145. package/dist/v1/language/value/inclusion/arrays.d.ts +3 -0
  146. package/dist/v1/language/value/inclusion/arrays.js +85 -0
  147. package/dist/v1/language/value/inclusion/assertions.d.ts +18 -0
  148. package/dist/v1/language/value/inclusion/assertions.js +29 -0
  149. package/dist/v1/language/value/inclusion/combinators.d.ts +3 -0
  150. package/dist/v1/language/value/inclusion/combinators.js +67 -0
  151. package/dist/v1/language/value/inclusion/equivalence.d.ts +4 -0
  152. package/dist/v1/language/value/inclusion/equivalence.js +74 -0
  153. package/dist/v1/language/value/inclusion/evidence.d.ts +34 -0
  154. package/dist/v1/language/value/inclusion/evidence.js +138 -0
  155. package/dist/v1/language/value/inclusion/includes.d.ts +17 -0
  156. package/dist/v1/language/value/inclusion/includes.js +25 -719
  157. package/dist/v1/language/value/inclusion/keywords.d.ts +5 -0
  158. package/dist/v1/language/value/inclusion/keywords.js +31 -0
  159. package/dist/v1/language/value/inclusion/kinds.d.ts +17 -0
  160. package/dist/v1/language/value/inclusion/kinds.js +57 -0
  161. package/dist/v1/language/value/inclusion/location.d.ts +24 -0
  162. package/dist/v1/language/value/inclusion/location.js +63 -0
  163. package/dist/v1/language/value/inclusion/numbers.d.ts +3 -0
  164. package/dist/v1/language/value/inclusion/numbers.js +41 -0
  165. package/dist/v1/language/value/inclusion/objects.d.ts +3 -0
  166. package/dist/v1/language/value/inclusion/objects.js +190 -0
  167. package/dist/v1/language/value/inclusion/strings.d.ts +3 -0
  168. package/dist/v1/language/value/inclusion/strings.js +29 -0
  169. package/dist/v1/language/value/inclusion/types.d.ts +3 -0
  170. package/dist/v1/language/value/inclusion/types.js +11 -0
  171. package/dist/v1/language/value/ordering.d.ts +14 -0
  172. package/dist/v1/language/value/ordering.js +86 -9
  173. package/dist/v1/language/value/profile/canonicalize.js +6 -5
  174. package/dist/v1/language/value/profile/json.validate.d.ts +3 -1
  175. package/dist/v1/language/value/profile/json.validate.js +3 -2
  176. package/dist/v1/language/value/profile/meta-schema.compiled.js +4 -1
  177. package/dist/v1/language/value/profile/rules.js +17 -43
  178. package/dist/v1/language/value/profile/validate.js +1 -10
  179. package/dist/v1/language/value/profile/vocabulary.d.ts +35 -2
  180. package/dist/v1/language/value/profile/vocabulary.js +52 -5
  181. package/dist/v1/language/value/reference/closure.js +3 -4
  182. package/dist/v1/language/value/reference/recursion.js +2 -22
  183. package/dist/v1/language/value/reference/registry.index.d.ts +2 -0
  184. package/dist/v1/language/value/reference/registry.index.js +33 -16
  185. package/dist/v1/language/value/regexp/ast.js +6 -7
  186. package/dist/v1/language/value/regexp/compile.d.ts +5 -11
  187. package/dist/v1/language/value/regexp/compile.js +14 -12
  188. package/dist/v1/language/value/regexp/syntax.js +3 -2
  189. package/dist/v1/language/value/syntax/keywords.d.ts +3 -3
  190. package/dist/v1/language/value/syntax/keywords.js +4 -20
  191. package/dist/v1/language/value/syntax/node-path/validate.js +2 -3
  192. package/dist/v1/language/value/syntax/pointer.d.ts +2 -0
  193. package/dist/v1/language/value/syntax/pointer.js +5 -2
  194. package/dist/v1/language/value/syntax/walk.d.ts +2 -0
  195. package/dist/v1/language/value/syntax/walk.js +19 -20
  196. package/dist/v1/schema/.spec/schemas/domain-schema.schema.json +2519 -0
  197. package/dist/v1/schema/admission/accept.js +3 -14
  198. package/dist/v1/schema/admission/callable.d.ts +21 -0
  199. package/dist/v1/schema/admission/callable.js +96 -0
  200. package/dist/v1/schema/analysis/class.js +33 -15
  201. package/dist/v1/schema/canonical/revision.js +4 -4
  202. package/dist/v1/schema/compatibility/api.d.ts +2 -1
  203. package/dist/v1/schema/compatibility/api.js +1 -0
  204. package/dist/v1/schema/compatibility/comparators/callables.js +1 -1
  205. package/dist/v1/schema/compatibility/comparators/classes.d.ts +9 -4
  206. package/dist/v1/schema/compatibility/comparators/classes.js +29 -8
  207. package/dist/v1/schema/compatibility/comparators/index.d.ts +1 -1
  208. package/dist/v1/schema/compatibility/comparators/members.js +1 -1
  209. package/dist/v1/schema/compatibility/comparators/values.js +2 -2
  210. package/dist/v1/schema/compatibility/coordinate.js +3 -3
  211. package/dist/v1/schema/compatibility/diff.js +2 -4
  212. package/dist/v1/schema/compatibility/extension.d.ts +11 -0
  213. package/dist/v1/schema/compatibility/extension.js +22 -0
  214. package/dist/v1/schema/compatibility/fields.d.ts +20 -4
  215. package/dist/v1/schema/compatibility/fields.js +13 -3
  216. package/dist/v1/schema/compatibility/meaning/footprint.js +16 -50
  217. package/dist/v1/schema/compatibility/model.d.ts +17 -5
  218. package/dist/v1/schema/compatibility/report.js +1 -1
  219. package/dist/v1/schema/compatibility/scope.d.ts +2 -0
  220. package/dist/v1/schema/compatibility/scope.js +4 -1
  221. package/dist/v1/schema/compatibility/structure/index.js +6 -4
  222. package/dist/v1/schema/compatibility/structure/requirements.js +57 -58
  223. package/dist/v1/schema/compatibility/versioning/index.js +1 -1
  224. package/dist/v1/schema/compatibility/versioning/surface.d.ts +1 -1
  225. package/dist/v1/schema/compatibility/versioning/surface.js +30 -2
  226. package/dist/v1/schema/compatibility/walk.d.ts +17 -0
  227. package/dist/v1/schema/compatibility/walk.js +41 -0
  228. package/dist/v1/schema/diagnostic.d.ts +17 -3
  229. package/dist/v1/schema/diagnostic.js +14 -11
  230. package/dist/v1/schema/index.d.ts +10 -1
  231. package/dist/v1/schema/index.js +4 -0
  232. package/dist/v1/schema/model/schema.d.ts +20 -1
  233. package/dist/v1/schema/model/schema.js +1 -1
  234. package/dist/v1/schema/normalization/domain.d.ts +2 -0
  235. package/dist/v1/schema/normalization/domain.js +29 -9
  236. package/dist/v1/schema/resolution/closure.js +2 -1
  237. package/dist/v1/schema/resolution/context.js +13 -13
  238. package/dist/v1/schema/resolution/domain.d.ts +5 -0
  239. package/dist/v1/schema/resolution/domain.js +2 -2
  240. package/dist/v1/schema/resolution/origins.js +3 -2
  241. package/dist/v1/schema/rule.d.ts +26 -0
  242. package/dist/v1/schema/rule.js +440 -0
  243. package/dist/v1/schema/validation/callable.d.ts +35 -2
  244. package/dist/v1/schema/validation/callable.js +65 -9
  245. package/dist/v1/schema/validation/class.d.ts +6 -2
  246. package/dist/v1/schema/validation/class.js +127 -104
  247. package/dist/v1/schema/validation/core.js +90 -168
  248. package/dist/v1/schema/validation/domain.js +4 -13
  249. package/dist/v1/schema/validation/domain.json-schema.d.ts +15 -0
  250. package/dist/v1/schema/validation/domain.json-schema.js +197 -0
  251. package/dist/v1/schema/validation/domain.route.d.ts +6 -1
  252. package/dist/v1/schema/validation/domain.route.js +18 -0
  253. package/dist/v1/schema/validation/domain.structure.d.ts +7780 -0
  254. package/dist/v1/schema/validation/domain.structure.js +398 -147
  255. package/dist/v1/schema/validation/json.json-schema.d.ts +40 -0
  256. package/dist/v1/schema/validation/json.json-schema.js +46 -0
  257. package/dist/v1/schema/validation/policy/budgets.d.ts +33 -2
  258. package/dist/v1/schema/validation/policy/budgets.js +87 -121
  259. package/dist/v1/schema/validation/policy/context.d.ts +6 -5
  260. package/dist/v1/schema/validation/policy/context.js +7 -10
  261. package/dist/v1/schema/validation/policy/objects.d.ts +1 -1
  262. package/dist/v1/schema/validation/policy/objects.js +6 -14
  263. package/dist/v1/schema/validation/policy/references.js +11 -27
  264. package/dist/v1/schema/validation/policy/typing.d.ts +3 -18
  265. package/dist/v1/schema/validation/policy/typing.js +22 -356
  266. package/dist/v1/schema/validation/policy/uses.d.ts +40 -3
  267. package/dist/v1/schema/validation/policy/uses.js +66 -89
  268. package/dist/v1/schema/validation/policy/validate.js +5 -5
  269. package/dist/v1/schema/validation/value-api.d.ts +22 -0
  270. package/dist/v1/schema/validation/value-api.js +34 -1
  271. package/dist/v1/schema/validation/value.d.ts +3 -0
  272. package/dist/v1/schema/validation/value.js +9 -17
  273. package/dist/v1/schema/validation/value.json-schema.d.ts +49 -0
  274. package/dist/v1/schema/validation/value.json-schema.js +137 -0
  275. package/dist/v1/schema/validation/view.js +4 -8
  276. package/dist/value/canonical.d.ts +6 -0
  277. package/dist/value/canonical.js +36 -0
  278. package/dist/value/decode.d.ts +7 -0
  279. package/dist/value/decode.js +159 -9
  280. package/dist/value/index.d.ts +1 -1
  281. package/dist/value/json.d.ts +2 -2
  282. package/dist/value/json.js +2 -2
  283. package/dist/value/types.d.ts +6 -0
  284. package/dist/value/unicode.d.ts +2 -1
  285. package/dist/value/unicode.js +2 -0
  286. package/package.json +8 -1
  287. package/dist/v1/builder/lowering/core-properties.d.ts +0 -10
  288. package/dist/v1/builder/lowering/core-properties.js +0 -76
  289. package/dist/v1/compiled/admission/semantics/cardinality.d.ts +0 -5
  290. package/dist/v1/compiled/admission/semantics/cardinality.js +0 -113
  291. package/dist/v1/compiled/admission/semantics/policy/equality.d.ts +0 -8
  292. package/dist/v1/compiled/admission/semantics/policy/equality.js +0 -27
  293. package/dist/v1/compiled/admission/semantics/policy/measure.d.ts +0 -9
  294. package/dist/v1/compiled/admission/semantics/policy/measure.js +0 -81
  295. package/dist/v1/compiled/admission/semantics/policy/variants.d.ts +0 -10
  296. package/dist/v1/compiled/admission/semantics/policy/variants.js +0 -65
  297. package/dist/v1/language/class/index.d.ts +0 -8
  298. package/dist/v1/language/class/index.js +0 -1
  299. package/dist/v1/language/core/index.d.ts +0 -2
  300. package/dist/v1/language/value/index.d.ts +0 -11
  301. package/dist/v1/language/value/index.js +0 -8
  302. package/dist/v1/schema/canonical/domain.d.ts +0 -3
  303. package/dist/v1/schema/canonical/domain.digest.d.ts +0 -3
  304. package/dist/v1/schema/canonical/domain.digest.js +0 -5
  305. package/dist/v1/schema/canonical/domain.js +0 -5
  306. package/dist/v1/schema/canonical/freeze.d.ts +0 -1
  307. /package/dist/v1/{language/core/index.js → builder/class/input.js} +0 -0
@@ -0,0 +1,159 @@
1
+ import type { ClassRef } from '../../addressing/index.js';
2
+ import type { Inheritance } from '../../language/class/model/class.js';
3
+ import type { MediaType } from '../../language/class/model/data.js';
4
+ import type { EdgeCount, EdgeLifetime } from '../../language/class/model/edge.js';
5
+ import type { ResolvedClass } from '../../language/class/resolved.js';
6
+ import type { ClassRuleChecks, ClassRuleObject, CreateRuleChecks, CreateRuleObject, EdgeRuleChecks } from '../../language/policy/model/policy.js';
7
+ import type { Method, PolicyCheckContext } from '../callable/authoring.js';
8
+ import type { Policy } from '../policy/authoring.js';
9
+ import type { Lazy } from '../schema/lazy.js';
10
+ import type { Class, EdgeClass, NodeClass } from './handle.js';
11
+ import type { PropertyRecordInput } from './property.js';
12
+ /** Reference to a Class: an authored handle, a ClassRef or a resolved Class, possibly lazy. */
13
+ export type ClassReferenceInput = Lazy<Class | ClassRef | ResolvedClass<'node'> | ResolvedClass<'edge'>>;
14
+ export type NodeClassReferenceInput = Lazy<NodeClass | ClassRef | ResolvedClass<'node'>>;
15
+ export type EdgeClassReferenceInput = Lazy<EdgeClass | ClassRef | ResolvedClass<'edge'>>;
16
+ /** Source side of a directed Edge Class. */
17
+ export interface DirectedSourceInput {
18
+ readonly as: string;
19
+ readonly accepts: readonly NodeClassReferenceInput[];
20
+ readonly outgoing: EdgeCount;
21
+ /** What deleting a Node at this endpoint does to the Edge; derived when omitted. */
22
+ readonly onDelete?: EdgeLifetime;
23
+ }
24
+ /** Target side of a directed Edge Class. */
25
+ export interface DirectedTargetInput {
26
+ readonly as: string;
27
+ readonly accepts: readonly NodeClassReferenceInput[];
28
+ readonly incoming: EdgeCount;
29
+ /** What deleting a Node at this endpoint does to the Edge; derived when omitted. */
30
+ readonly onDelete?: EdgeLifetime;
31
+ }
32
+ /** One endpoint of an undirected Edge Class. */
33
+ export interface IncidentEndpointInput {
34
+ readonly as: string;
35
+ readonly accepts: readonly NodeClassReferenceInput[];
36
+ readonly incident: EdgeCount;
37
+ /** What deleting a Node at this endpoint does to the Edge; derived when omitted. */
38
+ readonly onDelete?: EdgeLifetime;
39
+ }
40
+ /**
41
+ * One Class slot: a local Policy, or its constant value. An omitted observation admits every
42
+ * caller, as `true` does; an omitted write admits only the owning Domain, as `false` does.
43
+ */
44
+ export type ClassPolicyInput = Lazy<Policy> | boolean;
45
+ /**
46
+ * Policy checks deciding one Node Class slot. `self` is the observed or written Node; `ref` names
47
+ * one exact member, the same Node for every candidate.
48
+ */
49
+ export interface ClassRuleContext extends PolicyCheckContext<ClassRuleObject> {
50
+ }
51
+ export type ClassRuleBuilder = (context: ClassRuleContext) => ClassRuleChecks;
52
+ /** One Node Class slot: a local Policy, a constant value, or Policy checks. */
53
+ export type NodeClassPolicyInput = ClassPolicyInput | ClassRuleBuilder;
54
+ /**
55
+ * Policy checks deciding the creation of a Node. The Node is not yet, so it has no `self`: `ref`
56
+ * names each object, one exact member.
57
+ */
58
+ export interface CreateRuleContext extends Omit<PolicyCheckContext<CreateRuleObject>, 'self'> {
59
+ }
60
+ export type CreateRuleBuilder = (context: CreateRuleContext) => CreateRuleChecks;
61
+ /**
62
+ * The Node Class create slot: a constant value, or Policy checks over members. A Policy alone
63
+ * would have no object there.
64
+ */
65
+ export type NodeClassCreatePolicyInput = boolean | CreateRuleBuilder;
66
+ /** Local Policies of a Node Class. */
67
+ export interface NodeClassPoliciesInput {
68
+ readonly read?: NodeClassPolicyInput;
69
+ readonly traverse?: NodeClassPolicyInput;
70
+ readonly create?: NodeClassCreatePolicyInput;
71
+ readonly update?: NodeClassPolicyInput;
72
+ readonly delete?: NodeClassPolicyInput;
73
+ }
74
+ /**
75
+ * Policy checks deciding one Edge Class slot. `self` is the observed or written Edge, checked by a
76
+ * Policy whose `source` and `target` are its endpoints; `ref` names one exact member, the same Node
77
+ * for every candidate.
78
+ */
79
+ export interface EdgeRuleContext extends PolicyCheckContext<ClassRuleObject> {
80
+ }
81
+ export type EdgeRuleBuilder = (context: EdgeRuleContext) => EdgeRuleChecks;
82
+ /** One Edge Class slot: a local Policy, a constant value, or Policy checks. */
83
+ export type EdgeClassPolicyInput = ClassPolicyInput | EdgeRuleBuilder;
84
+ /** Local Policies of an Edge Class. */
85
+ export interface EdgeClassPoliciesInput {
86
+ readonly read?: EdgeClassPolicyInput;
87
+ readonly traverse?: EdgeClassPolicyInput;
88
+ readonly create?: EdgeClassPolicyInput;
89
+ readonly update?: EdgeClassPolicyInput;
90
+ readonly delete?: EdgeClassPolicyInput;
91
+ }
92
+ /** Authored Node Class. */
93
+ export interface NodeClassInput {
94
+ readonly abstract?: boolean;
95
+ /** Which Classes may extend this one; omitted, those of its own Domain only (`'internal'`). */
96
+ readonly inheritance?: Inheritance;
97
+ readonly description?: string;
98
+ readonly extends?: readonly NodeClassReferenceInput[];
99
+ readonly properties?: PropertyRecordInput;
100
+ readonly data?: MediaType;
101
+ readonly methods?: Readonly<Record<string, Method>>;
102
+ readonly icon?: string;
103
+ /** Local Policies; inherited by no descendant and forbidden on abstract Classes. */
104
+ readonly policies?: NodeClassPoliciesInput;
105
+ /**
106
+ * The tuples no two Nodes of this Class and of its active concrete descendants share while every
107
+ * Property is present; omitted, none. A descendant is covered without declaring them again.
108
+ */
109
+ readonly unique?: readonly NodeUniqueTupleInput[];
110
+ }
111
+ /**
112
+ * The distinct Properties of one Node key, in any order, each a Property of the Class, own or
113
+ * inherited, by its name or, when names collide, by its full key.
114
+ */
115
+ export type NodeUniqueTupleInput = readonly [string, ...string[]];
116
+ /** Members every authored Edge Class shares. */
117
+ export interface EdgeClassCommon {
118
+ readonly abstract?: boolean;
119
+ /** Which Classes may extend this one; omitted, those of its own Domain only (`'internal'`). */
120
+ readonly inheritance?: Inheritance;
121
+ readonly description?: string;
122
+ readonly extends?: readonly EdgeClassReferenceInput[];
123
+ readonly properties?: PropertyRecordInput;
124
+ /** Local Policies; inherited by no descendant and forbidden on abstract Classes. */
125
+ readonly policies?: EdgeClassPoliciesInput;
126
+ readonly constraints?: {
127
+ readonly noSelf?: true;
128
+ readonly acyclic?: true;
129
+ };
130
+ }
131
+ /**
132
+ * A key field as authored: an endpoint, the slug, or a Property of the Class, own or inherited, by
133
+ * its name or, when names collide, by its full key.
134
+ */
135
+ export type EdgeUniqueFieldInput = 'source' | 'target' | 'slug' | {
136
+ readonly property: string;
137
+ };
138
+ /** The distinct fields of one key, in any order. */
139
+ export type EdgeUniqueTupleInput = readonly [EdgeUniqueFieldInput, ...EdgeUniqueFieldInput[]];
140
+ /** Authored directed Edge Class. */
141
+ export interface DirectedEdgeInput extends EdgeClassCommon {
142
+ readonly orientation: 'directed';
143
+ readonly source: DirectedSourceInput;
144
+ readonly target: DirectedTargetInput;
145
+ /**
146
+ * The tuples no two Edges of this Class and of its active concrete descendants share while every
147
+ * field is present; omitted, none. A descendant is covered without declaring them again.
148
+ */
149
+ readonly unique?: readonly EdgeUniqueTupleInput[];
150
+ }
151
+ /** Authored undirected Edge Class. */
152
+ export interface UndirectedEdgeInput extends Omit<EdgeClassCommon, 'constraints'> {
153
+ readonly orientation: 'undirected';
154
+ readonly endpoints: readonly [IncidentEndpointInput, IncidentEndpointInput];
155
+ readonly constraints?: {
156
+ readonly noSelf?: true;
157
+ };
158
+ }
159
+ export type EdgeClassInput = DirectedEdgeInput | UndirectedEdgeInput;
@@ -0,0 +1,129 @@
1
+ import type { ResolvedMethod } from '../../language/callable/resolved.js';
2
+ import type { ResolvedProperty } from '../../language/class/resolved.js';
3
+ import type { StateTopology } from '../../language/state/topology.js';
4
+ import type { Method } from '../callable/authoring.js';
5
+ import type { DirectedEdgeClass, NodeClass, UndirectedEdgeClass } from './handle.js';
6
+ /** Compact type of one authored Property: values, requiredness, name, owner and state. */
7
+ export interface AuthoredPropertyProjection<out Input = unknown, out Output = unknown, out Required extends boolean = boolean, out Name extends string = string, out Owner = 'self', out State extends StateTopology | undefined = StateTopology | undefined> {
8
+ readonly input: Input;
9
+ readonly output: Output;
10
+ readonly required: Required;
11
+ readonly name: Name;
12
+ readonly owner: Owner;
13
+ readonly state?: State;
14
+ }
15
+ /** Compact type of one authored Method with its name and owner. */
16
+ export interface AuthoredMethodProjection<out Value extends Method = Method, out Name extends string = string, out Owner = 'self'> {
17
+ readonly value: Value;
18
+ readonly name: Name;
19
+ readonly owner: Owner;
20
+ }
21
+ /** Give `Owner` to every Property projection still owned by `self`. */
22
+ export type BindPropertyOwners<Entries, Owner> = Entries extends AuthoredPropertyProjection<infer Input, infer Output, infer Required, infer Name, infer ExistingOwner, infer State> ? AuthoredPropertyProjection<Input, Output, Required, Name, ExistingOwner extends 'self' ? Owner : ExistingOwner, State> : Entries;
23
+ /** Give `Owner` to every Method projection still owned by `self`. */
24
+ export type BindMethodOwners<Entries, Owner> = Entries extends AuthoredMethodProjection<infer Value, infer Name, infer ExistingOwner> ? AuthoredMethodProjection<Value, Name, ExistingOwner extends 'self' ? Owner : ExistingOwner> : Entries;
25
+ /** Kind and structural identity of an authored Class. */
26
+ export interface ClassIdentityProjection<out Kind extends 'node' | 'edge' = 'node' | 'edge', out Identity = unknown> {
27
+ readonly kind: Kind;
28
+ readonly identity: Identity;
29
+ }
30
+ /** An authored Class as the owner its Properties and Methods name. */
31
+ export interface ClassOwnerProjection<out Kind extends 'node' | 'edge' = 'node' | 'edge', out Identity = unknown, out Properties = unknown, out InstanceMethods = unknown, out StaticMethods = unknown> extends ClassIdentityProjection<Kind, Identity> {
32
+ readonly properties: Properties;
33
+ readonly instanceMethods: InstanceMethods;
34
+ readonly staticMethods: StaticMethods;
35
+ }
36
+ /** An authored Class as a reference, with its effective Properties and Methods. */
37
+ export interface ClassReferenceProjection<out Kind extends 'node' | 'edge' = 'node' | 'edge', out Identity = unknown, out EffectiveProperties = AuthoredPropertyProjection, out EffectiveInstanceMethods = unknown, out EffectiveStaticMethods = unknown> extends ClassIdentityProjection<Kind, Identity> {
38
+ readonly effectiveProperties: EffectiveProperties;
39
+ readonly effectiveInstanceMethods: EffectiveInstanceMethods;
40
+ readonly effectiveStaticMethods: EffectiveStaticMethods;
41
+ }
42
+ type NodeClassIdentity<Config> = Config extends {
43
+ readonly abstract: infer Abstract;
44
+ readonly depth: infer Depth;
45
+ readonly properties: infer Properties;
46
+ readonly methods: infer Methods;
47
+ } ? {
48
+ readonly abstract: Abstract;
49
+ readonly depth: Depth;
50
+ readonly properties: Properties;
51
+ readonly methods: Methods;
52
+ } : never;
53
+ type DirectedEdgeClassIdentity<Config> = Config extends {
54
+ readonly abstract: infer Abstract;
55
+ readonly depth: infer Depth;
56
+ readonly properties: infer Properties;
57
+ readonly source: infer Source;
58
+ readonly target: infer Target;
59
+ readonly constraints: infer Constraints;
60
+ } ? {
61
+ readonly abstract: Abstract;
62
+ readonly depth: Depth;
63
+ readonly properties: Properties;
64
+ readonly source: Source;
65
+ readonly target: Target;
66
+ readonly constraints: Constraints;
67
+ } : never;
68
+ type UndirectedEdgeClassIdentity<Config> = Config extends {
69
+ readonly abstract: infer Abstract;
70
+ readonly depth: infer Depth;
71
+ readonly properties: infer Properties;
72
+ readonly endpoints: infer Endpoints;
73
+ readonly constraints: infer Constraints;
74
+ } ? {
75
+ readonly abstract: Abstract;
76
+ readonly depth: Depth;
77
+ readonly properties: Properties;
78
+ readonly endpoints: Endpoints;
79
+ readonly constraints: Constraints;
80
+ } : never;
81
+ type OwnerErasedPropertyProjection<Entry> = Entry extends AuthoredPropertyProjection<infer Input, infer Output, infer Required, infer Name, unknown, infer State> ? AuthoredPropertyProjection<Input, Output, Required, Name, unknown, State> : Entry extends ResolvedProperty<infer Value, infer Required, infer State, infer Input> & {
82
+ readonly name: infer Name;
83
+ readonly key: infer Key;
84
+ } ? {
85
+ readonly value: Value;
86
+ readonly input: Input;
87
+ readonly required: Required;
88
+ readonly name: Name;
89
+ readonly key: Key;
90
+ readonly state?: State;
91
+ } : never;
92
+ type OwnerErasedMethodProjection<Entry> = Entry extends AuthoredMethodProjection<infer Value, infer Name, unknown> ? AuthoredMethodProjection<Value, Name, unknown> : Entry extends ResolvedMethod<infer Input, infer Output, infer Static, infer Abstract, infer Auth, infer _Policy, infer Key> & {
93
+ readonly name: infer Name;
94
+ } ? {
95
+ readonly input: Input;
96
+ readonly output: Output;
97
+ readonly static: Static;
98
+ readonly abstract: Abstract;
99
+ readonly auth: Auth;
100
+ readonly name: Name;
101
+ readonly key: Key;
102
+ } : never;
103
+ /** Identity projection of a Class handle. */
104
+ export type ClassIdentityProjectionOf<Value> = Value extends NodeClass<infer Config> ? ClassIdentityProjection<'node', NodeClassIdentity<Config>> : Value extends DirectedEdgeClass<infer Config> ? ClassIdentityProjection<'edge', DirectedEdgeClassIdentity<Config>> : Value extends UndirectedEdgeClass<infer Config> ? ClassIdentityProjection<'edge', UndirectedEdgeClassIdentity<Config>> : never;
105
+ /** Owner projection of a Class handle. */
106
+ export type ClassOwnerProjectionOf<Value> = Value extends NodeClass<infer Config> ? ClassOwnerProjection<'node', NodeClassIdentity<Config>, Config extends {
107
+ readonly effectiveProperties: infer Properties;
108
+ } ? OwnerErasedPropertyProjection<Properties> : never, Config extends {
109
+ readonly effectiveInstanceMethods: infer Methods;
110
+ } ? OwnerErasedMethodProjection<Methods> : never, Config extends {
111
+ readonly effectiveStaticMethods: infer Methods;
112
+ } ? OwnerErasedMethodProjection<Methods> : never> : Value extends DirectedEdgeClass<infer Config> ? ClassOwnerProjection<'edge', DirectedEdgeClassIdentity<Config>, Config extends {
113
+ readonly effectiveProperties: infer Properties;
114
+ } ? OwnerErasedPropertyProjection<Properties> : never, never, never> : Value extends UndirectedEdgeClass<infer Config> ? ClassOwnerProjection<'edge', UndirectedEdgeClassIdentity<Config>, Config extends {
115
+ readonly effectiveProperties: infer Properties;
116
+ } ? OwnerErasedPropertyProjection<Properties> : never, never, never> : never;
117
+ /** Reference projection of a Class handle. */
118
+ export type ClassReferenceProjectionOf<Value> = Value extends NodeClass<infer Config> ? ClassReferenceProjection<'node', NodeClassIdentity<Config>, Config extends {
119
+ readonly effectiveProperties: infer Properties;
120
+ } ? BindPropertyOwners<Properties, ClassOwnerProjectionOf<NodeClass<Config>>> : never, Config extends {
121
+ readonly effectiveInstanceMethods: infer Methods;
122
+ } ? BindMethodOwners<Methods, ClassOwnerProjectionOf<NodeClass<Config>>> : never, Config extends {
123
+ readonly effectiveStaticMethods: infer Methods;
124
+ } ? BindMethodOwners<Methods, ClassOwnerProjectionOf<NodeClass<Config>>> : never> : Value extends DirectedEdgeClass<infer Config> ? ClassReferenceProjection<'edge', DirectedEdgeClassIdentity<Config>, Config extends {
125
+ readonly effectiveProperties: infer Properties;
126
+ } ? BindPropertyOwners<Properties, ClassOwnerProjectionOf<DirectedEdgeClass<Config>>> : never, never, never> : Value extends UndirectedEdgeClass<infer Config> ? ClassReferenceProjection<'edge', UndirectedEdgeClassIdentity<Config>, Config extends {
127
+ readonly effectiveProperties: infer Properties;
128
+ } ? BindPropertyOwners<Properties, ClassOwnerProjectionOf<UndirectedEdgeClass<Config>>> : never, never, never> : never;
129
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import type { z } from 'zod';
2
- import type { AutoEvent, AutoSet, PropertyImmutability } from '../../language/class/model/property.js';
2
+ import type { AutoEvent, AutoSet, PropertyAuto, PropertyImmutability } from '../../language/class/model/property.js';
3
3
  import type { StateMachine } from '../../language/state/index.js';
4
4
  import type { JsonSchema } from '../../language/value/model/schema.js';
5
5
  import type { AUTHORING } from '../schema/handle.js';
@@ -31,10 +31,7 @@ export interface AutoProperty<out PropertyValue extends Property = Property> {
31
31
  readonly [AUTHORING]: 'auto';
32
32
  readonly [AUTO_INPUT]: {
33
33
  readonly property: PropertyValue;
34
- readonly options: {
35
- readonly on: readonly AutoEvent[];
36
- readonly set: AutoSet;
37
- };
34
+ readonly options: PropertyAuto;
38
35
  };
39
36
  }
40
37
  type PropertyAuthoringInput<Value extends Property> = Value extends Property<infer Schema, infer Options, infer Machine> ? {
@@ -45,10 +42,7 @@ type PropertyAuthoringInput<Value extends Property> = Value extends Property<inf
45
42
  export declare function propertyAuthoringInput<const Value extends Property>(value: Value): PropertyAuthoringInput<Value>;
46
43
  export declare function autoPropertyAuthoringInput<const Value extends AutoProperty>(value: Value): Value extends AutoProperty<infer Property> ? {
47
44
  readonly property: Property;
48
- readonly options: {
49
- readonly on: readonly AutoEvent[];
50
- readonly set: AutoSet;
51
- };
45
+ readonly options: PropertyAuto;
52
46
  } : never;
53
47
  export type PropertyFieldInput = ValueSchemaInput | Property | AutoProperty;
54
48
  export type PropertyRecordInput = Readonly<Record<string, PropertyFieldInput>>;
@@ -59,6 +59,7 @@ export function auto(property, options) {
59
59
  return authoringValue('auto', {
60
60
  [AUTO_INPUT]: {
61
61
  property,
62
+ // `events` holds at least the one authored event.
62
63
  options: { on: Object.freeze(events), set: options.set },
63
64
  },
64
65
  });
@@ -1,7 +1,7 @@
1
1
  import type { Object as JsonObject } from '@astrale-os/kernel-dsl/value';
2
2
  import type { DomainEndpointRef } from '../../language/core/model/core.js';
3
3
  import type { PolicyObjectInput } from '../callable/authoring.js';
4
- import type { EdgeClass, NodeClass } from '../class/authoring.js';
4
+ import type { EdgeClass, NodeClass } from '../class/handle.js';
5
5
  import type { AUTHORING } from '../schema/handle.js';
6
6
  import type { Lazy } from '../schema/lazy.js';
7
7
  import type { CoreNamedPropertyInput } from '../schema/projection.js';
@@ -14,10 +14,13 @@ export { BuilderError as Error } from './schema/diagnostic.js';
14
14
  export type { BuilderDiagnostic as Diagnostic, BuilderDiagnosticCode as DiagnosticCode, } from './schema/diagnostic.js';
15
15
  export type { CallableInputBase, CallableInput, BinaryInputAuthoring, CallableOutputInput, CallableProjection, CallablePolicyBuilder, CallablePolicyContext, PolicyCheckContext, BinaryOutput, Function, FunctionInput, Method, MethodInput, PolicyObjectInput, StreamOutput, } from './callable/authoring.js';
16
16
  export type { CoreEdge, CoreEndpoint, CoreInput, CoreNode } from './core/authoring.js';
17
- export type { AuthoredPropertyProjection, AuthoredMethodProjection, Class, ClassIdentityProjection, ClassOwnerProjection, ClassReferenceProjection, ClassReferenceInput as ClassReference, ClassRuleBuilder, ClassRuleContext, DirectedEdgeInput, DirectedEdgeClass, DirectedSourceInput, DirectedTargetInput, EdgeClassCommon, EdgeClassInput, EdgeClass, EdgeClassReferenceInput as EdgeClassReference, IncidentEndpointInput, NodeClass, NodeClassInput, NodeClassPoliciesInput, NodeClassPolicyInput, NodeClassReferenceInput as NodeClassReference, UndirectedEdgeInput, UndirectedEdgeClass, } from './class/authoring.js';
17
+ export type { Class, DirectedEdgeClass, EdgeClass, NodeClass, UndirectedEdgeClass, } from './class/handle.js';
18
+ export type { ClassReferenceInput as ClassReference, ClassRuleBuilder, ClassRuleContext, CreateRuleBuilder, CreateRuleContext, DirectedEdgeInput, DirectedSourceInput, DirectedTargetInput, EdgeClassCommon, EdgeClassInput, EdgeClassPoliciesInput, EdgeClassPolicyInput, EdgeClassReferenceInput as EdgeClassReference, EdgeRuleBuilder, EdgeRuleContext, EdgeUniqueFieldInput, EdgeUniqueTupleInput, IncidentEndpointInput, NodeClassCreatePolicyInput, NodeClassInput, NodeClassPoliciesInput, NodeClassPolicyInput, NodeClassReferenceInput as NodeClassReference, NodeUniqueTupleInput, UndirectedEdgeInput, } from './class/input.js';
19
+ export type { ClassRuleChecks, CreateRuleChecks, EdgeRuleChecks, } from '../language/policy/model/policy.js';
20
+ export type { AuthoredPropertyProjection, AuthoredMethodProjection, ClassIdentityProjection, ClassOwnerProjection, ClassReferenceProjection, } from './class/projection.js';
18
21
  export type { PathAuthoring } from './value/path.js';
19
22
  export type { Lazy } from './schema/lazy.js';
20
- export type { MatchPolicyInput, Policy, PolicyBuilder as PolicyFactory, PolicyEdgeInput, PolicyExistsContext, PolicyInput, PolicyNodeBinder, PolicyPatternContext, } from './policy/authoring.js';
23
+ export type { EdgeRolesOf, MatchPolicyInput, Policy, PolicyBuilder as PolicyFactory, PolicyEdgeClassInput, PolicyEdgeEnds, PolicyEdgeInput, PolicyEdgeOptions, PolicyEdgeRepeat, PolicyExistsContext, PolicyInput, PolicyNodeBinder, PolicyPatternContext, } from './policy/authoring.js';
21
24
  export type { AutoOptions, AutoProperty, Property, PropertyFieldInput as PropertyField, PropertyOptions, ValueSchemaInput, } from './class/property.js';
22
25
  export type { CorePropertyInput } from './schema/projection.js';
23
26
  export type { ClassProjection, FunctionProjection, MethodProjection, PropertyProjection, } from './schema/projection.js';
@@ -42,6 +42,7 @@ export class V1CallableCompiler {
42
42
  input,
43
43
  output,
44
44
  ...(config.execution === undefined ? {} : { execution: config.execution }),
45
+ ...(config.admission === undefined ? {} : { admission: config.admission }),
45
46
  };
46
47
  const contract = auth === 'authorized'
47
48
  ? { ...base, auth, ...(policy === undefined ? {} : { policy }) }
@@ -1,5 +1,5 @@
1
1
  import type { ClassDefinition } from '../../language/class/model/class.js';
2
- import type { Class } from '../class/authoring.js';
2
+ import type { Class } from '../class/handle.js';
3
3
  import type { CallableCompiler } from './callable.js';
4
4
  import type { PolicyCompiler } from './policy.js';
5
5
  import type { BuilderContext } from './schema/context.js';
@@ -13,13 +13,21 @@ export declare class V1DefinitionCompiler {
13
13
  compileClass(value: Class, name: string, pointer: string): ClassDefinition;
14
14
  private nodeClass;
15
15
  private edgeClass;
16
+ /**
17
+ * An omitted observation, like `true`, lowers to the absent slot a Schema reads as every caller
18
+ * (A18 defers X1). A write slot has the converse spelling: `false` and an omitted slot lower to
19
+ * the absent slot, owner only.
20
+ */
16
21
  private classPolicies;
17
22
  /**
18
23
  * A lazy Policy ignores the context it is called with; a rule builder returns Policy checks. Both
19
24
  * are functions, so the result tells them apart.
20
25
  */
21
26
  private classPolicy;
27
+ /** A Node create rule checks members only: the Node it creates is not yet. */
28
+ private createRule;
22
29
  private classRuleContext;
30
+ private createRuleContext;
23
31
  private endpointBase;
24
32
  private directedSource;
25
33
  private directedTarget;
@@ -1,6 +1,6 @@
1
1
  import { compareDefinitionRefs } from '../../addressing/ordering.js';
2
2
  import { isMethodExecutable } from '../../language/callable/executable.js';
3
- import { isClassRuleChecks } from '../../language/policy/model/policy.js';
3
+ import { CLASS_OPERATIONS, isClassObservation, isClassRuleChecks, } from '../../language/policy/model/policy.js';
4
4
  import { normalizeClassRule } from '../../language/policy/normalization/normalize.js';
5
5
  import { callableConfiguration } from '../callable/authoring.js';
6
6
  import { classConfiguration } from '../class/authoring.js';
@@ -31,6 +31,7 @@ export class V1DefinitionCompiler {
31
31
  ref: { origin: this.context.origin, kind: 'class', name },
32
32
  kind: 'node',
33
33
  abstract: input.abstract ?? false,
34
+ ...declaredInheritance(input.inheritance),
34
35
  ...(input.description === undefined ? {} : { description: input.description }),
35
36
  extends: this.parents(input.extends, 'node', `${pointer}/extends`),
36
37
  properties: facet,
@@ -38,10 +39,16 @@ export class V1DefinitionCompiler {
38
39
  ...(data === undefined ? {} : { data }),
39
40
  ...(input.icon === undefined ? {} : { icon: input.icon }),
40
41
  policies: this.classPolicies(input, 'node', `${pointer}/policies`),
42
+ // Property names stay as authored until `canonicalizeUniquePropertyKeys` qualifies them
43
+ // against the Class's effective Properties, once every Class is lowered.
44
+ ...(input.unique === undefined
45
+ ? {}
46
+ : { unique: input.unique }),
41
47
  };
42
48
  }
43
49
  edgeClass(value, name, pointer) {
44
50
  const input = classConfiguration(value);
51
+ // The authoring types give an Edge no State Property; the structure refuses an erased one.
45
52
  const facet = this.values.properties(input.properties, `${pointer}/properties`);
46
53
  const contract = (() => {
47
54
  if (value.orientation === 'directed') {
@@ -53,6 +60,13 @@ export class V1DefinitionCompiler {
53
60
  target: this.directedTarget(directed.target, `${pointer}/endpoints/target`),
54
61
  },
55
62
  constraints: directedConstraints(directed),
63
+ // Property names stay as authored until `canonicalizeUniquePropertyKeys` qualifies them
64
+ // against the Class's effective Properties, once every Class is lowered.
65
+ ...(directed.unique === undefined
66
+ ? {}
67
+ : {
68
+ unique: directed.unique,
69
+ }),
56
70
  };
57
71
  }
58
72
  const undirected = classConfiguration(value);
@@ -69,47 +83,62 @@ export class V1DefinitionCompiler {
69
83
  ref: { origin: this.context.origin, kind: 'class', name },
70
84
  kind: 'edge',
71
85
  abstract: input.abstract ?? false,
86
+ ...declaredInheritance(input.inheritance),
72
87
  ...(input.description === undefined ? {} : { description: input.description }),
73
88
  extends: this.parents(input.extends, 'edge', `${pointer}/extends`),
74
89
  properties: facet,
75
90
  ...contract,
76
- // classPolicy refuses Policy checks on an Edge Class, so only Class Policies remain.
77
91
  policies: this.classPolicies(input, 'edge', `${pointer}/policies`),
78
92
  };
79
93
  }
94
+ /**
95
+ * An omitted observation, like `true`, lowers to the absent slot a Schema reads as every caller
96
+ * (A18 defers X1). A write slot has the converse spelling: `false` and an omitted slot lower to
97
+ * the absent slot, owner only.
98
+ */
80
99
  classPolicies(input, kind, pointer) {
81
100
  const slot = (operation) => {
82
101
  const value = input.policies?.[operation];
102
+ const observation = isClassObservation(operation);
83
103
  if (value === undefined)
84
104
  return undefined;
85
105
  if (typeof value !== 'boolean')
86
- return this.classPolicy(value, kind, `${pointer}/${operation}`);
87
- // `true` on an abstract Class would otherwise lower to nothing and pass unnoticed.
106
+ return this.classPolicy(value, kind, operation, `${pointer}/${operation}`);
107
+ // A constant on an abstract Class would otherwise lower to nothing and pass unnoticed.
88
108
  if (input.abstract === true) {
89
- fail('BUILDER_ABSTRACT_POLICY', `${pointer}/${operation}`, 'Abstract Classes cannot declare observation Policies.');
109
+ fail('BUILDER_ABSTRACT_POLICY', `${pointer}/${operation}`, 'Abstract Classes cannot declare Class Policies.');
90
110
  }
91
- // `true` is the meaning of an absent observation Policy, so it lowers to none.
92
- return value ? undefined : false;
93
- };
94
- const read = slot('read');
95
- const traverse = slot('traverse');
96
- return {
97
- ...(read === undefined ? {} : { read }),
98
- ...(traverse === undefined ? {} : { traverse }),
111
+ // Each slot spells only the constant its absence does not mean.
112
+ if (observation)
113
+ return value ? undefined : false;
114
+ return value ? true : undefined;
99
115
  };
116
+ return Object.fromEntries(CLASS_OPERATIONS.flatMap((operation) => {
117
+ const policy = slot(operation);
118
+ return policy === undefined ? [] : [[operation, policy]];
119
+ }));
100
120
  }
101
121
  /**
102
122
  * A lazy Policy ignores the context it is called with; a rule builder returns Policy checks. Both
103
123
  * are functions, so the result tells them apart.
104
124
  */
105
- classPolicy(value, kind, pointer) {
125
+ classPolicy(value, kind, operation, pointer) {
126
+ if (kind === 'node' && operation === 'create')
127
+ return this.createRule(value, pointer);
106
128
  if (typeof value !== 'function')
107
129
  return this.policies.ref(value, pointer);
108
130
  const result = value(this.classRuleContext(pointer));
109
131
  if (!isClassRuleResult(result))
110
132
  return this.policies.ref(result, pointer);
111
- if (kind === 'edge') {
112
- fail('BUILDER_POLICY', pointer, 'An Edge Class observation names one Policy, true or false.');
133
+ return normalizeClassRule(result);
134
+ }
135
+ /** A Node create rule checks members only: the Node it creates is not yet. */
136
+ createRule(value, pointer) {
137
+ const result = typeof value === 'function'
138
+ ? value(this.createRuleContext(pointer))
139
+ : undefined;
140
+ if (!isClassRuleResult(result)) {
141
+ fail('BUILDER_POLICY', pointer, 'A Node create rule checks Policies of ref(...) members: a Policy alone has no object there.');
113
142
  }
114
143
  return normalizeClassRule(result);
115
144
  }
@@ -120,12 +149,24 @@ export class V1DefinitionCompiler {
120
149
  fail('BUILDER_POLICY_INPUT', pointer, 'A Class rule checks self or one ref(...) member.');
121
150
  });
122
151
  }
152
+ createRuleContext(pointer) {
153
+ return policyCheckContext(this.context, pointer, (object) => {
154
+ if (object?.kind === 'ref')
155
+ return object;
156
+ if (object?.kind === 'self') {
157
+ fail('BUILDER_POLICY', pointer, 'A Node create rule has no self: the Node is not yet.');
158
+ }
159
+ fail('BUILDER_POLICY_INPUT', pointer, 'A Node create rule checks one ref(...) member.');
160
+ });
161
+ }
123
162
  endpointBase(value, pointer) {
124
163
  return {
125
164
  role: value.as,
165
+ // An empty list stays as authored: the structure refuses it when it judges the candidate.
126
166
  accepts: value.accepts
127
167
  .map((entry, index) => this.context.resolveNodeClass(entry, `${pointer}/accepts/${index}`))
128
168
  .sort(compareDefinitionRefs),
169
+ ...(value.onDelete === undefined ? {} : { onDelete: value.onDelete }),
129
170
  };
130
171
  }
131
172
  directedSource(value, pointer) {
@@ -139,7 +180,7 @@ export class V1DefinitionCompiler {
139
180
  }
140
181
  parents(values, kind, pointer) {
141
182
  return (values ?? [])
142
- .map((entry, index) => this.context.resolveClass(entry, kind, `${pointer}/${index}`))
183
+ .map((entry, index) => this.context.resolveParent(entry, kind, `${pointer}/${index}`))
143
184
  .sort(compareDefinitionRefs);
144
185
  }
145
186
  methods(values, abstractOwner, pointer) {
@@ -158,6 +199,10 @@ export class V1DefinitionCompiler {
158
199
  }));
159
200
  }
160
201
  }
202
+ /** The default `'internal'` is never declared, so a Class that keeps it keeps its revision. */
203
+ function declaredInheritance(inheritance) {
204
+ return inheritance === undefined || inheritance === 'internal' ? {} : { inheritance };
205
+ }
161
206
  function dataDeclaration(mediaType) {
162
207
  return mediaType === undefined ? undefined : { mediaType };
163
208
  }
@@ -14,6 +14,7 @@ export class V1PolicyCompiler {
14
14
  const input = policyDeclaration(value);
15
15
  const ref = { origin: this.context.origin, kind: 'policy', name };
16
16
  if ('operator' in input) {
17
+ // One ref for each Policy of a non-empty composition.
17
18
  const refs = input.policies.map((policy, index) => this.context.resolvePolicy(policy, `${pointer}/${input.operator}/${index}`));
18
19
  return {
19
20
  ref,
@@ -23,6 +24,7 @@ export class V1PolicyCompiler {
23
24
  const match = input.match(createPatternContext({
24
25
  resolveObject: (member, refPointer) => this.context.resolvePolicyObject(member, refPointer),
25
26
  resolveEdgeClass: (definition, refPointer) => this.context.resolveEdgeClass(definition, refPointer),
27
+ edgeRoles: (ref) => this.context.edgeRoles(ref),
26
28
  resolveNodeClass: (definition, refPointer) => this.context.resolveNodeClass(definition, refPointer),
27
29
  pointer,
28
30
  }));
@@ -0,0 +1,27 @@
1
+ import type { ClassDefinition } from '../../language/class/model/class.js';
2
+ import type { CoreContent } from '../../language/core/model/core.js';
3
+ import type { DefinitionAnalysis } from '../../schema/analysis/class.js';
4
+ import type { DomainSchemaLookup } from '../../schema/dependency/lookup.js';
5
+ import type { DomainSchemaIR } from '../../schema/model/schema.js';
6
+ import type { UnqualifiedCoreContent } from './core.js';
7
+ type UnqualifiedDomainSchema = Omit<DomainSchemaIR, 'core'> & {
8
+ readonly core: UnqualifiedCoreContent;
9
+ };
10
+ /** The effective Properties of every Class `candidate` resolves, by `definitionRefIndex`. */
11
+ export type PropertyOwners = ReadonlyMap<string, DefinitionAnalysis>;
12
+ /**
13
+ * Analyze the already-canonical Definition surface of `candidate` once, so Property shorthand
14
+ * resolves against each Class's own and inherited Properties. Core values and key tuples take no
15
+ * part in Class composition, so they are left out of the analysis.
16
+ */
17
+ export declare function analyzePropertyOwners(candidate: UnqualifiedDomainSchema, lookup: DomainSchemaLookup): PropertyOwners;
18
+ /** Lower rich builder shorthand to the canonical full-key Core representation. */
19
+ export declare function canonicalizeCorePropertyKeys(core: UnqualifiedCoreContent, owners: PropertyOwners): CoreContent;
20
+ /**
21
+ * Lower each Property a key tuple names by its name to its full key among the Class's own and
22
+ * inherited Properties; a full key stays as authored. Ambiguity and absence are refused here, so a
23
+ * tuple never names a Property the author did not mean. A Node tuple names Properties only; an Edge
24
+ * tuple names them as `{ property }` beside its structural fields.
25
+ */
26
+ export declare function canonicalizeUniquePropertyKeys(classes: Readonly<Record<string, ClassDefinition>>, origin: string, owners: PropertyOwners): Readonly<Record<string, ClassDefinition>>;
27
+ export {};