@astrale-os/kernel-dsl 0.2.0-beta.8 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (321) hide show
  1. package/dist/v1/addressing/class-key.js +5 -4
  2. package/dist/v1/addressing/method-key.js +3 -2
  3. package/dist/v1/addressing/patterns.d.ts +0 -5
  4. package/dist/v1/addressing/patterns.js +5 -5
  5. package/dist/v1/builder/callable/authoring.d.ts +87 -41
  6. package/dist/v1/builder/callable/authoring.js +29 -14
  7. package/dist/v1/builder/class/authoring.d.ts +311 -36
  8. package/dist/v1/builder/class/authoring.js +3 -4
  9. package/dist/v1/builder/class/property.d.ts +16 -8
  10. package/dist/v1/builder/class/property.js +21 -5
  11. package/dist/v1/builder/core/authoring.d.ts +28 -13
  12. package/dist/v1/builder/core/authoring.js +22 -2
  13. package/dist/v1/builder/index.d.ts +9 -8
  14. package/dist/v1/builder/index.js +2 -2
  15. package/dist/v1/builder/lowering/callable.d.ts +3 -1
  16. package/dist/v1/builder/lowering/callable.js +43 -51
  17. package/dist/v1/builder/lowering/class.d.ts +7 -0
  18. package/dist/v1/builder/lowering/class.js +79 -29
  19. package/dist/v1/builder/lowering/core.d.ts +3 -2
  20. package/dist/v1/builder/lowering/core.js +9 -6
  21. package/dist/v1/builder/lowering/policy.d.ts +8 -1
  22. package/dist/v1/builder/lowering/policy.js +35 -0
  23. package/dist/v1/builder/lowering/schema/capture.js +9 -4
  24. package/dist/v1/builder/lowering/schema/compile.d.ts +2 -2
  25. package/dist/v1/builder/lowering/schema/compile.js +15 -2
  26. package/dist/v1/builder/lowering/schema/context.d.ts +11 -8
  27. package/dist/v1/builder/lowering/schema/context.js +59 -29
  28. package/dist/v1/builder/lowering/schema/ownership.d.ts +3 -3
  29. package/dist/v1/builder/lowering/schema/ownership.js +2 -1
  30. package/dist/v1/builder/lowering/value/compile.js +14 -4
  31. package/dist/v1/builder/lowering/value/zod.d.ts +7 -6
  32. package/dist/v1/builder/lowering/value/zod.js +16 -7
  33. package/dist/v1/builder/lowering/view.d.ts +4 -3
  34. package/dist/v1/builder/lowering/view.js +2 -14
  35. package/dist/v1/builder/policy/authoring.d.ts +23 -6
  36. package/dist/v1/builder/policy/authoring.js +35 -8
  37. package/dist/v1/builder/schema/define.d.ts +8 -5
  38. package/dist/v1/builder/schema/diagnostic.d.ts +1 -1
  39. package/dist/v1/builder/schema/handle.d.ts +2 -1
  40. package/dist/v1/builder/schema/input.d.ts +9 -1
  41. package/dist/v1/builder/schema/projection/callable.d.ts +51 -0
  42. package/dist/v1/builder/schema/projection/callable.js +1 -0
  43. package/dist/v1/builder/schema/projection/class.d.ts +89 -0
  44. package/dist/v1/builder/schema/projection/class.js +1 -0
  45. package/dist/v1/builder/schema/projection/core-input.d.ts +32 -0
  46. package/dist/v1/builder/schema/projection/core-input.js +1 -0
  47. package/dist/v1/builder/schema/projection/domain.d.ts +59 -0
  48. package/dist/v1/builder/schema/projection/domain.js +1 -0
  49. package/dist/v1/builder/schema/projection/identity.d.ts +39 -0
  50. package/dist/v1/builder/schema/projection/identity.js +1 -0
  51. package/dist/v1/builder/schema/projection/model.d.ts +59 -0
  52. package/dist/v1/builder/schema/projection/model.js +1 -0
  53. package/dist/v1/builder/schema/projection/property.d.ts +32 -0
  54. package/dist/v1/builder/schema/projection/property.js +1 -0
  55. package/dist/v1/builder/schema/projection/resolved-class.d.ts +76 -0
  56. package/dist/v1/builder/schema/projection/resolved-class.js +1 -0
  57. package/dist/v1/builder/schema/projection.d.ts +4 -258
  58. package/dist/v1/builder/value/full-match.js +6 -3
  59. package/dist/v1/builder/value/path.d.ts +2 -2
  60. package/dist/v1/builder/value/path.js +2 -2
  61. package/dist/v1/builder/view/authoring.d.ts +6 -14
  62. package/dist/v1/builder/view/authoring.js +13 -5
  63. package/dist/v1/bundle/structure.d.ts +2 -1
  64. package/dist/v1/compiled/admission/accept.d.ts +1 -1
  65. package/dist/v1/compiled/admission/accept.js +11 -814
  66. package/dist/v1/compiled/admission/closure.d.ts +3 -0
  67. package/dist/v1/compiled/admission/closure.js +173 -0
  68. package/dist/v1/compiled/admission/diagnostic.d.ts +7 -0
  69. package/dist/v1/compiled/admission/diagnostic.js +13 -0
  70. package/dist/v1/compiled/admission/revision.js +9 -1
  71. package/dist/v1/compiled/admission/semantics/cardinality.d.ts +5 -0
  72. package/dist/v1/compiled/admission/semantics/cardinality.js +113 -0
  73. package/dist/v1/compiled/admission/semantics/class.d.ts +5 -0
  74. package/dist/v1/compiled/admission/semantics/class.js +125 -0
  75. package/dist/v1/compiled/admission/semantics/context.d.ts +60 -0
  76. package/dist/v1/compiled/admission/semantics/context.js +81 -0
  77. package/dist/v1/compiled/admission/semantics/core.d.ts +35 -0
  78. package/dist/v1/compiled/admission/semantics/core.js +123 -0
  79. package/dist/v1/compiled/admission/semantics/edge.d.ts +8 -0
  80. package/dist/v1/compiled/admission/semantics/edge.js +89 -0
  81. package/dist/v1/compiled/admission/semantics/policy/admit.d.ts +4 -0
  82. package/dist/v1/compiled/admission/semantics/policy/admit.js +63 -0
  83. package/dist/v1/compiled/admission/semantics/policy/callable.d.ts +5 -0
  84. package/dist/v1/compiled/admission/semantics/policy/callable.js +72 -0
  85. package/dist/v1/compiled/admission/semantics/policy/contracts.d.ts +24 -0
  86. package/dist/v1/compiled/admission/semantics/policy/contracts.js +45 -0
  87. package/dist/v1/compiled/admission/semantics/policy/equality.d.ts +8 -0
  88. package/dist/v1/compiled/admission/semantics/policy/equality.js +27 -0
  89. package/dist/v1/compiled/admission/semantics/policy/measure.d.ts +9 -0
  90. package/dist/v1/compiled/admission/semantics/policy/measure.js +81 -0
  91. package/dist/v1/compiled/admission/semantics/policy/parity.d.ts +4 -0
  92. package/dist/v1/compiled/admission/semantics/policy/parity.js +139 -0
  93. package/dist/v1/compiled/admission/semantics/policy/pattern.d.ts +8 -0
  94. package/dist/v1/compiled/admission/semantics/policy/pattern.js +78 -0
  95. package/dist/v1/compiled/admission/semantics/policy/typing.d.ts +28 -0
  96. package/dist/v1/compiled/admission/semantics/policy/typing.js +206 -0
  97. package/dist/v1/compiled/admission/semantics/policy/variants.d.ts +10 -0
  98. package/dist/v1/compiled/admission/semantics/policy/variants.js +65 -0
  99. package/dist/v1/compiled/admission/semantics.d.ts +1 -1
  100. package/dist/v1/compiled/admission/semantics.js +8 -1078
  101. package/dist/v1/compiled/admission/wire/callable.d.ts +6 -0
  102. package/dist/v1/compiled/admission/wire/callable.js +90 -0
  103. package/dist/v1/compiled/admission/wire/class.d.ts +4 -0
  104. package/dist/v1/compiled/admission/wire/class.js +133 -0
  105. package/dist/v1/compiled/admission/wire/core.d.ts +5 -0
  106. package/dist/v1/compiled/admission/wire/core.js +32 -0
  107. package/dist/v1/compiled/admission/wire/dependency.d.ts +14 -0
  108. package/dist/v1/compiled/admission/wire/dependency.js +43 -0
  109. package/dist/v1/compiled/admission/wire/entry.d.ts +5 -0
  110. package/dist/v1/compiled/admission/wire/entry.js +100 -0
  111. package/dist/v1/compiled/admission/wire/pattern.d.ts +12 -0
  112. package/dist/v1/compiled/admission/wire/pattern.js +111 -0
  113. package/dist/v1/compiled/admission/wire/policy.d.ts +10 -0
  114. package/dist/v1/compiled/admission/wire/policy.js +189 -0
  115. package/dist/v1/compiled/admission/wire/program.d.ts +4 -0
  116. package/dist/v1/compiled/admission/wire/program.js +52 -0
  117. package/dist/v1/compiled/admission/wire/property.d.ts +4 -0
  118. package/dist/v1/compiled/admission/wire/property.js +74 -0
  119. package/dist/v1/compiled/admission/wire/reference.d.ts +8 -0
  120. package/dist/v1/compiled/admission/wire/reference.js +33 -0
  121. package/dist/v1/compiled/admission/wire/value.d.ts +29 -0
  122. package/dist/v1/compiled/admission/wire/value.js +98 -0
  123. package/dist/v1/compiled/admission/wire/view.d.ts +3 -0
  124. package/dist/v1/compiled/admission/wire/view.js +17 -0
  125. package/dist/v1/compiled/compiler/compile.js +43 -11
  126. package/dist/v1/compiled/generated.d.ts +10 -0
  127. package/dist/v1/compiled/generated.js +15 -0
  128. package/dist/v1/compiled/loader/load.d.ts +5 -0
  129. package/dist/v1/compiled/loader/load.js +18 -4
  130. package/dist/v1/compiled/model/schema.d.ts +16 -7
  131. package/dist/v1/domain/create.js +18 -28
  132. package/dist/v1/domain/model/domain.d.ts +0 -1
  133. package/dist/v1/domain/model/input.d.ts +3 -0
  134. package/dist/v1/domain/projection/classes.js +13 -41
  135. package/dist/v1/domain/validation/create.d.ts +2 -0
  136. package/dist/v1/domain/validation/create.js +12 -0
  137. package/dist/v1/index.d.ts +5 -2
  138. package/dist/v1/index.js +3 -1
  139. package/dist/v1/language/callable/composition.d.ts +27 -0
  140. package/dist/v1/language/callable/composition.js +52 -0
  141. package/dist/v1/language/callable/executable.d.ts +6 -0
  142. package/dist/v1/language/callable/executable.js +4 -0
  143. package/dist/v1/language/callable/model/callable.d.ts +34 -9
  144. package/dist/v1/language/callable/model/callable.js +3 -1
  145. package/dist/v1/language/callable/resolved.d.ts +23 -8
  146. package/dist/v1/language/class/facets.d.ts +5 -2
  147. package/dist/v1/language/class/inheritance.d.ts +12 -0
  148. package/dist/v1/language/class/inheritance.js +25 -0
  149. package/dist/v1/language/class/lifetime.d.ts +17 -0
  150. package/dist/v1/language/class/lifetime.js +26 -0
  151. package/dist/v1/language/class/model/class.d.ts +8 -4
  152. package/dist/v1/language/class/model/property.d.ts +4 -2
  153. package/dist/v1/language/class/property-values.js +5 -2
  154. package/dist/v1/language/class/resolved.d.ts +25 -15
  155. package/dist/v1/language/core/model/core.d.ts +7 -1
  156. package/dist/v1/language/core/resolved.d.ts +6 -2
  157. package/dist/v1/language/definition/metadata.d.ts +8 -0
  158. package/dist/v1/language/definition/metadata.js +12 -0
  159. package/dist/v1/language/index.d.ts +9 -0
  160. package/dist/v1/language/index.js +6 -0
  161. package/dist/v1/language/policy/analysis/branches.d.ts +4 -3
  162. package/dist/v1/language/policy/analysis/branches.js +54 -12
  163. package/dist/v1/language/policy/analysis/budgets.js +1 -1
  164. package/dist/v1/language/policy/analysis/checks.d.ts +28 -0
  165. package/dist/v1/language/policy/analysis/checks.js +80 -0
  166. package/dist/v1/language/policy/index.d.ts +1 -0
  167. package/dist/v1/language/policy/index.js +1 -0
  168. package/dist/v1/language/policy/model/policy.d.ts +71 -5
  169. package/dist/v1/language/policy/model/policy.js +52 -1
  170. package/dist/v1/language/policy/normalization/normalize.d.ts +12 -1
  171. package/dist/v1/language/policy/normalization/normalize.js +178 -44
  172. package/dist/v1/language/state/index.d.ts +3 -0
  173. package/dist/v1/language/state/index.js +1 -0
  174. package/dist/v1/language/state/machine.d.ts +28 -0
  175. package/dist/v1/language/state/machine.js +40 -0
  176. package/dist/v1/language/state/topology.d.ts +14 -0
  177. package/dist/v1/language/state/topology.js +69 -0
  178. package/dist/v1/language/value/compile/fields.d.ts +1 -1
  179. package/dist/v1/language/value/compile/load.d.ts +4 -2
  180. package/dist/v1/language/value/compile/load.js +22 -1
  181. package/dist/v1/language/value/compile/model.d.ts +16 -1
  182. package/dist/v1/language/value/evaluate/assertions.d.ts +2 -0
  183. package/dist/v1/language/value/evaluate/assertions.js +13 -0
  184. package/dist/v1/language/value/evaluate/evaluator.js +111 -28
  185. package/dist/v1/language/value/evaluate/preparation.d.ts +10 -1
  186. package/dist/v1/language/value/evaluate/preparation.js +17 -26
  187. package/dist/v1/language/value/evaluate/program.js +1 -1
  188. package/dist/v1/language/value/evaluate/validate.d.ts +6 -2
  189. package/dist/v1/language/value/evaluate/validate.js +18 -11
  190. package/dist/v1/language/value/inclusion/includes.d.ts +9 -0
  191. package/dist/v1/language/value/inclusion/includes.js +777 -0
  192. package/dist/v1/language/value/model/blob.d.ts +31 -0
  193. package/dist/v1/language/value/model/blob.js +90 -0
  194. package/dist/v1/language/value/model/instant.d.ts +0 -2
  195. package/dist/v1/language/value/model/instant.js +1 -1
  196. package/dist/v1/language/value/model/schema.d.ts +2 -1
  197. package/dist/v1/language/value/model/schema.js +1 -5
  198. package/dist/v1/language/value/ordering.d.ts +2 -0
  199. package/dist/v1/language/value/ordering.js +4 -8
  200. package/dist/v1/language/value/profile/json.validate.js +1 -1
  201. package/dist/v1/language/value/profile/rules.js +48 -12
  202. package/dist/v1/language/value/reference/registry.d.ts +2 -1
  203. package/dist/v1/language/value/regexp/ast.js +3 -64
  204. package/dist/v1/language/value/regexp/compile.d.ts +32 -3
  205. package/dist/v1/language/value/regexp/compile.js +117 -21
  206. package/dist/v1/language/value/regexp/matcher.d.ts +6 -3
  207. package/dist/v1/language/value/regexp/matcher.js +185 -28
  208. package/dist/v1/language/value/regexp/syntax.d.ts +12 -1
  209. package/dist/v1/language/value/regexp/syntax.js +14 -2
  210. package/dist/v1/language/value/regexp/unicode.d.ts +32 -0
  211. package/dist/v1/language/value/regexp/unicode.js +139 -0
  212. package/dist/v1/language/value/syntax/full-match.js +8 -5
  213. package/dist/v1/language/value/syntax/node-path/validate.js +4 -6
  214. package/dist/v1/language/view/model/view.d.ts +2 -4
  215. package/dist/v1/language/view/resolved.d.ts +2 -2
  216. package/dist/v1/schema/analysis/class.d.ts +36 -6
  217. package/dist/v1/schema/analysis/class.js +31 -66
  218. package/dist/v1/schema/canonical/revision.d.ts +2 -1
  219. package/dist/v1/schema/canonical/revision.js +4 -1
  220. package/dist/v1/schema/compatibility/api.d.ts +3 -0
  221. package/dist/v1/schema/compatibility/api.js +2 -0
  222. package/dist/v1/schema/compatibility/comparators/callables.d.ts +39 -0
  223. package/dist/v1/schema/compatibility/comparators/callables.js +101 -0
  224. package/dist/v1/schema/compatibility/comparators/classes.d.ts +47 -0
  225. package/dist/v1/schema/compatibility/comparators/classes.js +160 -0
  226. package/dist/v1/schema/compatibility/comparators/index.d.ts +12 -0
  227. package/dist/v1/schema/compatibility/comparators/index.js +53 -0
  228. package/dist/v1/schema/compatibility/comparators/members.d.ts +4 -0
  229. package/dist/v1/schema/compatibility/comparators/members.js +49 -0
  230. package/dist/v1/schema/compatibility/comparators/values.d.ts +5 -0
  231. package/dist/v1/schema/compatibility/comparators/values.js +37 -0
  232. package/dist/v1/schema/compatibility/compare.d.ts +5 -0
  233. package/dist/v1/schema/compatibility/compare.js +23 -0
  234. package/dist/v1/schema/compatibility/context.d.ts +19 -0
  235. package/dist/v1/schema/compatibility/context.js +49 -0
  236. package/dist/v1/schema/compatibility/coordinate.d.ts +40 -0
  237. package/dist/v1/schema/compatibility/coordinate.js +38 -0
  238. package/dist/v1/schema/compatibility/diff.d.ts +12 -0
  239. package/dist/v1/schema/compatibility/diff.js +39 -0
  240. package/dist/v1/schema/compatibility/evidence.d.ts +16 -0
  241. package/dist/v1/schema/compatibility/evidence.js +62 -0
  242. package/dist/v1/schema/compatibility/fields.d.ts +194 -0
  243. package/dist/v1/schema/compatibility/fields.js +94 -0
  244. package/dist/v1/schema/compatibility/index.d.ts +6 -0
  245. package/dist/v1/schema/compatibility/index.js +3 -0
  246. package/dist/v1/schema/compatibility/meaning/footprint.d.ts +7 -0
  247. package/dist/v1/schema/compatibility/meaning/footprint.js +59 -0
  248. package/dist/v1/schema/compatibility/meaning/index.d.ts +3 -0
  249. package/dist/v1/schema/compatibility/meaning/index.js +16 -0
  250. package/dist/v1/schema/compatibility/model.d.ts +131 -0
  251. package/dist/v1/schema/compatibility/model.js +1 -0
  252. package/dist/v1/schema/compatibility/references.d.ts +38 -0
  253. package/dist/v1/schema/compatibility/references.js +149 -0
  254. package/dist/v1/schema/compatibility/report.d.ts +27 -0
  255. package/dist/v1/schema/compatibility/report.js +100 -0
  256. package/dist/v1/schema/compatibility/scope.d.ts +36 -0
  257. package/dist/v1/schema/compatibility/scope.js +110 -0
  258. package/dist/v1/schema/compatibility/structure/index.d.ts +3 -0
  259. package/dist/v1/schema/compatibility/structure/index.js +40 -0
  260. package/dist/v1/schema/compatibility/structure/inheritance.d.ts +7 -0
  261. package/dist/v1/schema/compatibility/structure/inheritance.js +68 -0
  262. package/dist/v1/schema/compatibility/structure/requirements.d.ts +7 -0
  263. package/dist/v1/schema/compatibility/structure/requirements.js +97 -0
  264. package/dist/v1/schema/compatibility/subjects.d.ts +39 -0
  265. package/dist/v1/schema/compatibility/subjects.js +143 -0
  266. package/dist/v1/schema/compatibility/versioning/index.d.ts +8 -0
  267. package/dist/v1/schema/compatibility/versioning/index.js +50 -0
  268. package/dist/v1/schema/compatibility/versioning/members.d.ts +12 -0
  269. package/dist/v1/schema/compatibility/versioning/members.js +47 -0
  270. package/dist/v1/schema/compatibility/versioning/surface.d.ts +11 -0
  271. package/dist/v1/schema/compatibility/versioning/surface.js +61 -0
  272. package/dist/v1/schema/diagnostic.d.ts +1 -1
  273. package/dist/v1/schema/fingerprint.d.ts +2 -0
  274. package/dist/v1/schema/fingerprint.js +1 -0
  275. package/dist/v1/schema/index.d.ts +4 -3
  276. package/dist/v1/schema/index.js +2 -1
  277. package/dist/v1/schema/model/schema.d.ts +8 -11
  278. package/dist/v1/schema/normalization/domain.js +57 -13
  279. package/dist/v1/schema/resolution/definition.index.d.ts +1 -2
  280. package/dist/v1/schema/resolution/definition.index.js +0 -3
  281. package/dist/v1/schema/resolution/domain.d.ts +4 -1
  282. package/dist/v1/schema/resolution/domain.js +26 -18
  283. package/dist/v1/schema/resolution/origins.d.ts +28 -5
  284. package/dist/v1/schema/resolution/origins.js +68 -31
  285. package/dist/v1/schema/validation/callable.d.ts +4 -0
  286. package/dist/v1/schema/validation/callable.js +39 -0
  287. package/dist/v1/schema/validation/class.d.ts +10 -0
  288. package/dist/v1/schema/validation/class.js +79 -60
  289. package/dist/v1/schema/validation/core.js +83 -55
  290. package/dist/v1/schema/validation/domain.d.ts +2 -1
  291. package/dist/v1/schema/validation/domain.js +2 -0
  292. package/dist/v1/schema/validation/domain.structure.d.ts +0 -2
  293. package/dist/v1/schema/validation/domain.structure.js +214 -171
  294. package/dist/v1/schema/validation/policy/budgets.js +36 -6
  295. package/dist/v1/schema/validation/policy/context.js +5 -16
  296. package/dist/v1/schema/validation/policy/objects.d.ts +4 -0
  297. package/dist/v1/schema/validation/policy/objects.js +71 -0
  298. package/dist/v1/schema/validation/policy/references.js +16 -4
  299. package/dist/v1/schema/validation/policy/typing.d.ts +2 -0
  300. package/dist/v1/schema/validation/policy/typing.js +55 -7
  301. package/dist/v1/schema/validation/policy/uses.js +73 -99
  302. package/dist/v1/schema/validation/value-api.d.ts +2 -0
  303. package/dist/v1/schema/validation/value-api.js +1 -0
  304. package/dist/v1/schema/validation/value.js +7 -1
  305. package/dist/v1/schema/validation/view.js +14 -9
  306. package/dist/value/accept.d.ts +9 -0
  307. package/dist/value/accept.js +106 -7
  308. package/dist/value/canonical.d.ts +3 -0
  309. package/dist/value/canonical.js +22 -6
  310. package/dist/value/immutable.optimization.d.ts +15 -0
  311. package/dist/value/immutable.optimization.js +34 -0
  312. package/dist/value/index.d.ts +1 -1
  313. package/dist/value/index.js +1 -1
  314. package/dist/value/json.d.ts +1 -1
  315. package/dist/value/json.js +1 -1
  316. package/dist/value/limits.d.ts +1 -1
  317. package/dist/value/unicode.d.ts +4 -1
  318. package/dist/value/unicode.js +28 -0
  319. package/package.json +20 -5
  320. package/dist/v1/schema/compatibility/meaning.d.ts +0 -29
  321. package/dist/v1/schema/compatibility/meaning.js +0 -605
@@ -1,10 +1,20 @@
1
+ import type { Value as PortableValue } from '@astrale-os/kernel-dsl/value';
2
+ import type { z } from 'zod';
1
3
  import type { ClassRef } from '../../addressing/index.js';
2
4
  import type { MethodRecord } from '../../language/callable/model/callable.js';
5
+ import type { ResolvedMethod } from '../../language/callable/resolved.js';
3
6
  import type { MediaType } from '../../language/class/model/data.js';
4
- import type { ResolvedClass } from '../../language/class/resolved.js';
5
- import type { Method } from '../callable/authoring.js';
7
+ import type { EdgeCount } from '../../language/class/model/edge.js';
8
+ import type { ResolvedClass, ResolvedProperty } from '../../language/class/resolved.js';
9
+ import type { ClassRuleChecks, ClassRuleObject } from '../../language/policy/model/policy.js';
10
+ import type { StateTopology, StateTopologyOf } from '../../language/state/topology.js';
11
+ import type { BlobReceipt, BlobRef, BlobSchema } from '../../language/value/model/blob.js';
12
+ import type { Method, PolicyCheckContext, ProjectionOfCallable } from '../callable/authoring.js';
6
13
  import type { Policy } from '../policy/authoring.js';
7
14
  import type { Lazy } from '../schema/lazy.js';
15
+ import type { ClassProjectionOfResolved } from '../schema/projection.js';
16
+ import type { TypedValueSchema } from '../value/schema.js';
17
+ import type { AutoProperty, Property, PropertyOptions, PropertyStateMachineOf, ValueSchemaInput } from './property.js';
8
18
  import type { PropertyRecordInput } from './property.js';
9
19
  import { type AUTHORING } from '../schema/handle.js';
10
20
  declare const CLASS_TYPE: unique symbol;
@@ -14,19 +24,38 @@ export type EdgeClassReferenceInput = Lazy<EdgeClass | ClassRef | ResolvedClass<
14
24
  export interface DirectedSourceInput {
15
25
  readonly as: string;
16
26
  readonly accepts: readonly NodeClassReferenceInput[];
17
- readonly outgoing: import('../../language/class/model/edge.js').EdgeCount;
27
+ readonly outgoing: EdgeCount;
18
28
  }
19
29
  export interface DirectedTargetInput {
20
30
  readonly as: string;
21
31
  readonly accepts: readonly NodeClassReferenceInput[];
22
- readonly incoming: import('../../language/class/model/edge.js').EdgeCount;
32
+ readonly incoming: EdgeCount;
23
33
  }
24
34
  export interface IncidentEndpointInput {
25
35
  readonly as: string;
26
36
  readonly accepts: readonly NodeClassReferenceInput[];
27
- readonly incident: import('../../language/class/model/edge.js').EdgeCount;
37
+ readonly incident: EdgeCount;
28
38
  }
29
39
  type ExactEndpointInput<Input, Shape> = Input & Record<Exclude<keyof Input, keyof Shape>, never>;
40
+ /** One observation slot: a local Policy, or its constant value. Absent means `true`. */
41
+ export type ClassPolicyInput = Lazy<Policy> | boolean;
42
+ export interface ClassPoliciesInput {
43
+ readonly read?: ClassPolicyInput;
44
+ readonly traverse?: ClassPolicyInput;
45
+ }
46
+ /**
47
+ * Policy checks deciding one Node Class observation. `self` is the observed Node; `ref` names one
48
+ * exact member, the same Node for every observed candidate.
49
+ */
50
+ export interface ClassRuleContext extends PolicyCheckContext<ClassRuleObject> {
51
+ }
52
+ export type ClassRuleBuilder = (context: ClassRuleContext) => ClassRuleChecks;
53
+ /** One Node Class observation slot: a local Policy, a constant value, or Policy checks. */
54
+ export type NodeClassPolicyInput = ClassPolicyInput | ClassRuleBuilder;
55
+ export interface NodeClassPoliciesInput {
56
+ readonly read?: NodeClassPolicyInput;
57
+ readonly traverse?: NodeClassPolicyInput;
58
+ }
30
59
  export interface NodeClassInput {
31
60
  readonly abstract?: boolean;
32
61
  readonly description?: string;
@@ -35,19 +64,16 @@ export interface NodeClassInput {
35
64
  readonly data?: MediaType;
36
65
  readonly methods?: Readonly<Record<string, Method>>;
37
66
  readonly icon?: string;
38
- readonly policies?: {
39
- readonly read?: Lazy<Policy>;
40
- readonly traverse?: Lazy<Policy>;
41
- };
67
+ /** Local observation Policies; inherited by no descendant and forbidden on abstract Classes. */
68
+ readonly policies?: NodeClassPoliciesInput;
42
69
  }
43
70
  export interface EdgeClassOptions {
44
71
  readonly abstract?: boolean;
45
72
  readonly description?: string;
46
73
  readonly extends?: readonly EdgeClassReferenceInput[];
47
74
  readonly properties?: PropertyRecordInput;
48
- readonly policies?: {
49
- readonly traverse?: Lazy<Policy>;
50
- };
75
+ /** Local observation Policies; inherited by no descendant and forbidden on abstract Classes. */
76
+ readonly policies?: ClassPoliciesInput;
51
77
  readonly constraints?: {
52
78
  readonly noSelf?: true;
53
79
  readonly acyclic?: true;
@@ -67,35 +93,274 @@ export interface UndirectedEdgeInput extends Omit<EdgeClassOptions, 'constraints
67
93
  }
68
94
  export type EdgeClassCommon = EdgeClassOptions;
69
95
  export type EdgeClassInput = DirectedEdgeInput | UndirectedEdgeInput;
70
- export type ClassInput = ({
71
- readonly kind: 'node';
72
- readonly abstract: boolean;
73
- } & NodeClassInput) | ({
74
- readonly kind: 'edge';
75
- readonly orientation: 'directed';
76
- readonly abstract: boolean;
77
- } & Omit<DirectedEdgeInput, 'orientation'>) | ({
78
- readonly kind: 'edge';
79
- readonly orientation: 'undirected';
80
- readonly abstract: boolean;
81
- } & Omit<UndirectedEdgeInput, 'orientation'>);
82
96
  export type Class = NodeClass | EdgeClass;
83
- export interface NodeClass<out Config extends NodeClassInput = NodeClassInput> {
97
+ 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> {
98
+ readonly input: Input;
99
+ readonly output: Output;
100
+ readonly required: Required;
101
+ readonly name: Name;
102
+ readonly owner: Owner;
103
+ readonly state?: State;
104
+ }
105
+ export interface AuthoredMethodProjection<out Value extends Method = Method, out Name extends string = string, out Owner = 'self'> {
106
+ readonly value: Value;
107
+ readonly name: Name;
108
+ readonly owner: Owner;
109
+ }
110
+ type PropertySchemaOf<Field> = Field extends AutoProperty<infer Value> ? PropertySchemaOf<Value> : Field extends Property<infer Schema, PropertyOptions, unknown> ? Schema : Field;
111
+ type PropertyOptionsOf<Field> = Field extends AutoProperty<infer Value> ? PropertyOptionsOf<Value> : Field extends Property<ValueSchemaInput, infer Options, unknown> ? Options : Record<never, never>;
112
+ type ValueInputOf<Schema> = Schema extends BlobSchema ? BlobReceipt : Schema extends TypedValueSchema<infer Value> ? Value : Schema extends z.ZodType ? z.input<Schema> : PortableValue;
113
+ type ValueOutputOf<Schema> = Schema extends BlobSchema ? BlobRef : Schema extends TypedValueSchema<infer Value> ? Value : Schema extends z.ZodType ? z.output<Schema> : PortableValue;
114
+ type PropertyRequiredOf<Field> = PropertyOptionsOf<Field> extends {
115
+ readonly required: infer Required extends boolean;
116
+ } ? Required : undefined extends ValueInputOf<PropertySchemaOf<Field>> ? false : true;
117
+ type PropertyProjectionOf<Name extends string, Field> = AuthoredPropertyProjection<Field extends AutoProperty ? never : ValueInputOf<PropertySchemaOf<Field>>, ValueOutputOf<PropertySchemaOf<Field>>, PropertyRequiredOf<Field>, Name, 'self', Field extends Property ? StateTopologyOf<PropertyStateMachineOf<Field>> : undefined>;
118
+ type PropertyProjectionsOf<Input> = Input extends Readonly<Record<string, unknown>> ? {
119
+ readonly [Name in keyof Input]: PropertyProjectionOf<Extract<Name, string>, Input[Name]>;
120
+ } : Readonly<Record<never, never>>;
121
+ type PropertyProjectionEntriesOf<Input> = PropertyProjectionsOf<Input>[keyof PropertyProjectionsOf<Input>];
122
+ type ResolveCompactLazy<Value, Depth extends readonly unknown[] = []> = Depth['length'] extends 32 ? Value : Value extends () => infer Resolved ? ResolveCompactLazy<Resolved, readonly [...Depth, unknown]> : Value;
123
+ type EffectivePropertiesOfReference<Value> = ResolveCompactLazy<Value> extends infer Resolved ? Resolved extends NodeClass<infer Config> ? Config extends {
124
+ readonly effectiveProperties: infer Properties;
125
+ } ? BindPropertyOwners<Properties, ClassOwnerProjectionOf<Resolved>> : never : Resolved extends DirectedEdgeClass<infer Config> | UndirectedEdgeClass<infer Config> ? Config extends {
126
+ readonly effectiveProperties: infer Properties;
127
+ } ? BindPropertyOwners<Properties, ClassOwnerProjectionOf<Resolved>> : never : Resolved extends ResolvedClass ? Resolved['properties']['byKey'][keyof Resolved['properties']['byKey']] extends infer Entry ? Entry extends ResolvedProperty ? Entry : never : never : never : never;
128
+ type ParentPropertyProjectionsOf<Input> = Input extends {
129
+ readonly extends?: readonly (infer Parent)[];
130
+ } ? EffectivePropertiesOfReference<Parent> : never;
131
+ type EffectivePropertyProjectionsOf<Input> = PropertyProjectionEntriesOf<'properties' extends keyof Input ? Input extends {
132
+ readonly properties?: infer Value;
133
+ } ? NonNullable<Value> : never : never> | ParentPropertyProjectionsOf<Input>;
134
+ 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;
135
+ type MethodFieldsOf<Input> = 'methods' extends keyof Input ? Input extends {
136
+ readonly methods?: infer Methods extends Readonly<Record<string, Method>>;
137
+ } ? NonNullable<Methods> : Readonly<Record<never, never>> : Readonly<Record<never, never>>;
138
+ type MethodIsStatic<Value extends Method> = ProjectionOfCallable<Value> extends {
139
+ readonly static: true;
140
+ } ? true : false;
141
+ type OwnMethodProjectionsOf<Input, Static extends boolean> = {
142
+ [Name in keyof MethodFieldsOf<Input>]: MethodFieldsOf<Input>[Name] extends infer Value extends Method ? MethodIsStatic<Value> extends Static ? AuthoredMethodProjection<Value, Extract<Name, string>> : never : never;
143
+ }[keyof MethodFieldsOf<Input>];
144
+ type BindMethodOwners<Entries, Owner> = Entries extends AuthoredMethodProjection<infer Value, infer Name, infer ExistingOwner> ? AuthoredMethodProjection<Value, Name, ExistingOwner extends 'self' ? Owner : ExistingOwner> : Entries;
145
+ type AbstractMethodEntries<Entry> = Entry extends AuthoredMethodProjection<infer Value> ? ProjectionOfCallable<Value> extends {
146
+ readonly abstract: true;
147
+ } ? Entry : never : Entry extends {
148
+ readonly abstract: true;
149
+ } ? Entry : never;
150
+ type AbstractMethodsOfReference<Value, Static extends boolean, Seen = never> = Value extends Seen ? never : ResolveCompactLazy<Value> extends infer Resolved ? Resolved extends NodeClass<infer Config> ? Config extends {
151
+ readonly abstractInstanceMethods: infer InstanceMethods;
152
+ readonly abstractStaticMethods: infer StaticMethods;
153
+ } ? BindMethodOwners<Static extends true ? StaticMethods : InstanceMethods, ClassOwnerProjectionOf<Resolved>> : never : Resolved extends ResolvedClass<'node'> ? ResolvedAbstractMethods<Resolved, Static, Seen | Value> : never : never;
154
+ type ResolvedOwnAbstractMethods<Value extends ResolvedClass<'node'>, Static extends boolean> = AbstractMethodEntries<Static extends true ? Value['self']['static']['methods']['byKey'][keyof Value['self']['static']['methods']['byKey']] : Value['self']['methods']['byKey'][keyof Value['self']['methods']['byKey']]>;
155
+ type ParentTupleMembers<Parents> = Parents extends readonly [infer Parent, ...infer Rest] ? Parent | ParentTupleMembers<Rest> : never;
156
+ type ResolvedParents<Value> = Value extends {
157
+ readonly extends: infer Parents;
158
+ } ? ParentTupleMembers<Parents> : never;
159
+ type ResolvedAbstractMethods<Value extends ResolvedClass<'node'>, Static extends boolean, Seen> = ResolvedOwnAbstractMethods<Value, Static> | WithoutMethodNames<AbstractMethodsOfReference<ResolvedParents<Value>, Static, Seen>, MethodNames<ResolvedOwnAbstractMethods<Value, Static>>>;
160
+ type ParentMethodProjectionsOf<Input, Static extends boolean> = Input extends {
161
+ readonly extends?: readonly (infer Parent)[];
162
+ } ? AbstractMethodsOfReference<Parent, Static> : never;
163
+ type MethodNames<Entry> = Entry extends {
164
+ readonly name: infer Name;
165
+ } ? Name : never;
166
+ type WithoutMethodNames<Entry, Names> = Entry extends {
167
+ readonly name: infer Name;
168
+ } ? Name extends Names ? never : Entry : never;
169
+ type AbstractMethodProjectionsOf<Input, Static extends boolean> = AbstractMethodEntries<OwnMethodProjectionsOf<Input, Static>> | WithoutMethodNames<ParentMethodProjectionsOf<Input, Static>, AbstractMethodEntries<OwnMethodProjectionsOf<Input, Static>>['name']>;
170
+ type EffectiveMethodProjectionsOf<Input, Static extends boolean> = OwnMethodProjectionsOf<Input, Static> | WithoutMethodNames<ParentMethodProjectionsOf<Input, Static>, keyof MethodFieldsOf<Input>>;
171
+ type ClassDepthOf<Value> = ResolveCompactLazy<Value> extends infer Resolved ? Resolved extends NodeClass<infer Config> ? Config extends {
172
+ readonly depth: infer Depth extends number;
173
+ } ? Depth : 0 : Resolved extends DirectedEdgeClass<infer Config> | UndirectedEdgeClass<infer Config> ? Config extends {
174
+ readonly depth: infer Depth extends number;
175
+ } ? Depth : 0 : 0 : 0;
176
+ type TupleOfLength<Length extends number, Values extends readonly unknown[] = []> = number extends Length ? readonly unknown[] : Values['length'] extends Length ? Values : TupleOfLength<Length, readonly [...Values, unknown]>;
177
+ type Increment<Depth extends number> = number extends Depth ? number : [...TupleOfLength<Depth>, unknown]['length'] & number;
178
+ type ClassDepthOfInput<Input> = Input extends {
179
+ readonly extends?: infer Parents extends readonly unknown[];
180
+ } ? Parents extends readonly [] ? 0 : Increment<ClassDepthOf<Parents[number]>> : 0;
181
+ export interface ClassIdentityProjection<out Kind extends 'node' | 'edge' = 'node' | 'edge', out Identity = unknown> {
182
+ readonly kind: Kind;
183
+ readonly identity: Identity;
184
+ }
185
+ 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> {
186
+ readonly properties: Properties;
187
+ readonly instanceMethods: InstanceMethods;
188
+ readonly staticMethods: StaticMethods;
189
+ }
190
+ 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> {
191
+ readonly effectiveProperties: EffectiveProperties;
192
+ readonly effectiveInstanceMethods: EffectiveInstanceMethods;
193
+ readonly effectiveStaticMethods: EffectiveStaticMethods;
194
+ }
195
+ type NodeClassIdentity<Config> = Config extends {
196
+ readonly abstract: infer Abstract;
197
+ readonly depth: infer Depth;
198
+ readonly properties: infer Properties;
199
+ readonly methods: infer Methods;
200
+ } ? {
201
+ readonly abstract: Abstract;
202
+ readonly depth: Depth;
203
+ readonly properties: Properties;
204
+ readonly methods: Methods;
205
+ } : never;
206
+ type DirectedEdgeClassIdentity<Config> = Config extends {
207
+ readonly abstract: infer Abstract;
208
+ readonly depth: infer Depth;
209
+ readonly properties: infer Properties;
210
+ readonly source: infer Source;
211
+ readonly target: infer Target;
212
+ readonly constraints: infer Constraints;
213
+ } ? {
214
+ readonly abstract: Abstract;
215
+ readonly depth: Depth;
216
+ readonly properties: Properties;
217
+ readonly source: Source;
218
+ readonly target: Target;
219
+ readonly constraints: Constraints;
220
+ } : never;
221
+ type UndirectedEdgeClassIdentity<Config> = Config extends {
222
+ readonly abstract: infer Abstract;
223
+ readonly depth: infer Depth;
224
+ readonly properties: infer Properties;
225
+ readonly endpoints: infer Endpoints;
226
+ readonly constraints: infer Constraints;
227
+ } ? {
228
+ readonly abstract: Abstract;
229
+ readonly depth: Depth;
230
+ readonly properties: Properties;
231
+ readonly endpoints: Endpoints;
232
+ readonly constraints: Constraints;
233
+ } : never;
234
+ 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> & {
235
+ readonly name: infer Name;
236
+ readonly key: infer Key;
237
+ } ? {
238
+ readonly value: Value;
239
+ readonly input: Input;
240
+ readonly required: Required;
241
+ readonly name: Name;
242
+ readonly key: Key;
243
+ readonly state?: State;
244
+ } : never;
245
+ 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> & {
246
+ readonly name: infer Name;
247
+ } ? {
248
+ readonly input: Input;
249
+ readonly output: Output;
250
+ readonly static: Static;
251
+ readonly abstract: Abstract;
252
+ readonly auth: Auth;
253
+ readonly name: Name;
254
+ readonly key: Key;
255
+ } : never;
256
+ 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;
257
+ export type ClassOwnerProjectionOf<Value> = Value extends NodeClass<infer Config> ? ClassOwnerProjection<'node', NodeClassIdentity<Config>, Config extends {
258
+ readonly effectiveProperties: infer Properties;
259
+ } ? OwnerErasedPropertyProjection<Properties> : never, Config extends {
260
+ readonly effectiveInstanceMethods: infer Methods;
261
+ } ? OwnerErasedMethodProjection<Methods> : never, Config extends {
262
+ readonly effectiveStaticMethods: infer Methods;
263
+ } ? OwnerErasedMethodProjection<Methods> : never> : Value extends DirectedEdgeClass<infer Config> ? ClassOwnerProjection<'edge', DirectedEdgeClassIdentity<Config>, Config extends {
264
+ readonly effectiveProperties: infer Properties;
265
+ } ? OwnerErasedPropertyProjection<Properties> : never, never, never> : Value extends UndirectedEdgeClass<infer Config> ? ClassOwnerProjection<'edge', UndirectedEdgeClassIdentity<Config>, Config extends {
266
+ readonly effectiveProperties: infer Properties;
267
+ } ? OwnerErasedPropertyProjection<Properties> : never, never, never> : never;
268
+ export type ClassReferenceProjectionOf<Value> = Value extends NodeClass<infer Config> ? ClassReferenceProjection<'node', NodeClassIdentity<Config>, Config extends {
269
+ readonly effectiveProperties: infer Properties;
270
+ } ? BindPropertyOwners<Properties, ClassOwnerProjectionOf<NodeClass<Config>>> : never, Config extends {
271
+ readonly effectiveInstanceMethods: infer Methods;
272
+ } ? BindMethodOwners<Methods, ClassOwnerProjectionOf<NodeClass<Config>>> : never, Config extends {
273
+ readonly effectiveStaticMethods: infer Methods;
274
+ } ? BindMethodOwners<Methods, ClassOwnerProjectionOf<NodeClass<Config>>> : never> : Value extends DirectedEdgeClass<infer Config> ? ClassReferenceProjection<'edge', DirectedEdgeClassIdentity<Config>, Config extends {
275
+ readonly effectiveProperties: infer Properties;
276
+ } ? BindPropertyOwners<Properties, ClassOwnerProjectionOf<DirectedEdgeClass<Config>>> : never, never, never> : Value extends UndirectedEdgeClass<infer Config> ? ClassReferenceProjection<'edge', UndirectedEdgeClassIdentity<Config>, Config extends {
277
+ readonly effectiveProperties: infer Properties;
278
+ } ? BindPropertyOwners<Properties, ClassOwnerProjectionOf<UndirectedEdgeClass<Config>>> : never, never, never> : never;
279
+ type CompactReference<Value> = Value extends () => infer Resolved ? () => CompactReference<Resolved> : Value extends ResolvedClass ? ClassProjectionOfResolved<Value> : Value extends Class ? ClassReferenceProjectionOf<Value> : Value;
280
+ type CompactReferences<Values extends readonly unknown[]> = Values extends readonly [] ? readonly [] : Values extends readonly [infer Value, ...infer Rest] ? readonly [CompactReference<Value>, ...CompactReferences<Rest>] : readonly CompactReference<Values[number]>[];
281
+ type CompactParentsOf<Input> = Input extends {
282
+ readonly extends?: infer Values extends readonly unknown[];
283
+ } ? 'extends' extends keyof Input ? CompactReferences<Values> : readonly [] : readonly [];
284
+ type CompactNodeInput<Input extends NodeClassInput> = {
285
+ readonly depth: ClassDepthOfInput<Input>;
286
+ readonly abstract: Input extends {
287
+ readonly abstract: infer Value extends boolean;
288
+ } ? Value : false;
289
+ readonly extends: CompactParentsOf<Input>;
290
+ readonly properties: PropertyProjectionsOf<'properties' extends keyof Input ? Input extends {
291
+ readonly properties?: infer Value;
292
+ } ? NonNullable<Value> : never : never>;
293
+ readonly methods: 'methods' extends keyof Input ? Input extends {
294
+ readonly methods?: infer Value;
295
+ } ? NonNullable<Value> : Readonly<Record<never, never>> : Readonly<Record<never, never>>;
296
+ readonly effectiveProperties: EffectivePropertyProjectionsOf<Input>;
297
+ readonly abstractInstanceMethods: AbstractMethodProjectionsOf<Input, false>;
298
+ readonly abstractStaticMethods: AbstractMethodProjectionsOf<Input, true>;
299
+ readonly effectiveInstanceMethods: EffectiveMethodProjectionsOf<Input, false>;
300
+ readonly effectiveStaticMethods: EffectiveMethodProjectionsOf<Input, true>;
301
+ };
302
+ type CompactDirectedInput<Input extends Omit<DirectedEdgeInput, 'orientation'>> = {
303
+ readonly depth: ClassDepthOfInput<Input>;
304
+ readonly abstract: Input extends {
305
+ readonly abstract: infer Value extends boolean;
306
+ } ? Value : false;
307
+ readonly extends: CompactParentsOf<Input>;
308
+ readonly properties: PropertyProjectionsOf<'properties' extends keyof Input ? Input extends {
309
+ readonly properties?: infer Value;
310
+ } ? NonNullable<Value> : never : never>;
311
+ readonly source: {
312
+ readonly as: Input['source']['as'];
313
+ readonly outgoing: Input['source']['outgoing'];
314
+ };
315
+ readonly target: {
316
+ readonly as: Input['target']['as'];
317
+ readonly incoming: Input['target']['incoming'];
318
+ };
319
+ readonly constraints: Input extends {
320
+ readonly constraints?: infer Value;
321
+ } ? NonNullable<Value> : Record<never, never>;
322
+ readonly effectiveProperties: EffectivePropertyProjectionsOf<Input>;
323
+ };
324
+ type CompactUndirectedInput<Input extends Omit<UndirectedEdgeInput, 'orientation'>> = {
325
+ readonly depth: ClassDepthOfInput<Input>;
326
+ readonly abstract: Input extends {
327
+ readonly abstract: infer Value extends boolean;
328
+ } ? Value : false;
329
+ readonly extends: CompactParentsOf<Input>;
330
+ readonly properties: PropertyProjectionsOf<'properties' extends keyof Input ? Input extends {
331
+ readonly properties?: infer Value;
332
+ } ? NonNullable<Value> : never : never>;
333
+ readonly endpoints: readonly [
334
+ {
335
+ readonly as: Input['endpoints'][0]['as'];
336
+ readonly incident: Input['endpoints'][0]['incident'];
337
+ },
338
+ {
339
+ readonly as: Input['endpoints'][1]['as'];
340
+ readonly incident: Input['endpoints'][1]['incident'];
341
+ }
342
+ ];
343
+ readonly constraints: Input extends {
344
+ readonly constraints?: infer Value;
345
+ } ? NonNullable<Value> : Record<never, never>;
346
+ readonly effectiveProperties: EffectivePropertyProjectionsOf<Input>;
347
+ };
348
+ export interface NodeClass<out Config = unknown> {
84
349
  readonly [AUTHORING]: 'definition';
85
350
  readonly kind: 'node';
86
- readonly [CLASS_TYPE]?: () => Config;
351
+ readonly [CLASS_TYPE]: () => Config;
87
352
  }
88
- export interface DirectedEdgeClass<out Input extends Omit<DirectedEdgeInput, 'orientation'> = Omit<DirectedEdgeInput, 'orientation'>> {
353
+ export interface DirectedEdgeClass<out Input = unknown> {
89
354
  readonly [AUTHORING]: 'definition';
90
355
  readonly kind: 'edge';
91
356
  readonly orientation: 'directed';
92
- readonly [CLASS_TYPE]?: () => Input;
357
+ readonly [CLASS_TYPE]: () => Input;
93
358
  }
94
- export interface UndirectedEdgeClass<out Input extends Omit<UndirectedEdgeInput, 'orientation'> = Omit<UndirectedEdgeInput, 'orientation'>> {
359
+ export interface UndirectedEdgeClass<out Input = unknown> {
95
360
  readonly [AUTHORING]: 'definition';
96
361
  readonly kind: 'edge';
97
362
  readonly orientation: 'undirected';
98
- readonly [CLASS_TYPE]?: () => Input;
363
+ readonly [CLASS_TYPE]: () => Input;
99
364
  }
100
365
  export type EdgeClass = DirectedEdgeClass | UndirectedEdgeClass;
101
366
  export declare function defineClass(config: {
@@ -112,17 +377,27 @@ export declare function defineClass(config: {
112
377
  readonly orientation: 'undirected';
113
378
  readonly abstract: boolean;
114
379
  } & Omit<UndirectedEdgeInput, 'orientation'>): UndirectedEdgeClass;
115
- export declare function nodeClass<const Config extends NodeClassInput = Record<never, never>>(config?: Config & Record<Exclude<keyof Config, keyof NodeClassInput>, never>): NodeClass<Config>;
380
+ export declare function nodeClass(): NodeClass<CompactNodeInput<Record<never, never>>>;
381
+ export declare function nodeClass<const Config extends NodeClassInput>(config: Config & Record<Exclude<keyof Config, keyof NodeClassInput>, never>): NodeClass<CompactNodeInput<Config>>;
116
382
  export declare const edgeClass: Readonly<{
117
383
  directed<const Input extends Omit<DirectedEdgeInput, 'orientation'>>(input: Input & {
118
384
  readonly source: ExactEndpointInput<Input['source'], DirectedSourceInput>;
119
385
  readonly target: ExactEndpointInput<Input['target'], DirectedTargetInput>;
120
- }): DirectedEdgeClass<Input>;
386
+ } & WithoutStateProperties<Input>): DirectedEdgeClass<CompactDirectedInput<Input>>;
121
387
  undirected<const Input extends Omit<UndirectedEdgeInput, 'orientation'>>(input: Input & {
122
388
  readonly endpoints: readonly [ExactEndpointInput<Input['endpoints'][0], IncidentEndpointInput>, ExactEndpointInput<Input['endpoints'][1], IncidentEndpointInput>];
123
- }): UndirectedEdgeClass<Input>;
389
+ } & WithoutStateProperties<Input>): UndirectedEdgeClass<CompactUndirectedInput<Input>>;
124
390
  }>;
125
- export type ClassAuthoringInput<Value extends Class> = Value extends NodeClass<infer Config> ? Config : Value extends DirectedEdgeClass<infer Input> ? Input : Value extends UndirectedEdgeClass<infer Input> ? Input : never;
126
- /** Internal lowering access; Class authoring handles expose no public configuration object. */
127
- export declare function classAuthoringInput<const Value extends Class>(value: Value): ClassAuthoringInput<Value>;
391
+ type WithoutStateProperties<Input> = Input extends {
392
+ readonly properties?: infer Properties extends Readonly<Record<string, unknown>>;
393
+ } ? {
394
+ readonly properties?: {
395
+ readonly [Name in keyof Properties]: Properties[Name] extends Property ? [PropertyStateMachineOf<Properties[Name]>] extends [never] ? Properties[Name] : never : Properties[Name];
396
+ };
397
+ } : unknown;
398
+ export type ProjectionOfClass<Value extends Class> = Value extends NodeClass<infer Config> ? Config : Value extends DirectedEdgeClass<infer Input> ? Input : Value extends UndirectedEdgeClass<infer Input> ? Input : never;
399
+ export declare function classConfiguration(value: NodeClass): NodeClassInput;
400
+ export declare function classConfiguration(value: DirectedEdgeClass): Omit<DirectedEdgeInput, 'orientation'>;
401
+ export declare function classConfiguration(value: UndirectedEdgeClass): Omit<UndirectedEdgeInput, 'orientation'>;
402
+ export declare function classConfiguration(value: EdgeClass): Omit<DirectedEdgeInput, 'orientation'> | Omit<UndirectedEdgeInput, 'orientation'>;
128
403
  export type { MethodRecord };
@@ -89,8 +89,7 @@ export const edgeClass = Object.freeze({
89
89
  return value;
90
90
  },
91
91
  });
92
- /** Internal lowering access; Class authoring handles expose no public configuration object. */
93
- export function classAuthoringInput(value) {
92
+ export function classConfiguration(value) {
94
93
  const input = classInputs.get(value);
95
94
  if (input === undefined)
96
95
  throw new TypeError('Unknown Class authoring handle.');
@@ -115,7 +114,7 @@ function validateEdgeClassOptions(value) {
115
114
  'constraints',
116
115
  ]);
117
116
  if (value.policies !== undefined)
118
- assertKnownKeys(value.policies, ['traverse']);
117
+ assertKnownKeys(value.policies, ['read', 'traverse']);
119
118
  if (value.constraints !== undefined)
120
119
  assertKnownKeys(value.constraints, ['noSelf', 'acyclic']);
121
120
  }
@@ -129,7 +128,7 @@ function validateUndirectedEdgeClassOptions(value) {
129
128
  'constraints',
130
129
  ]);
131
130
  if (value.policies !== undefined)
132
- assertKnownKeys(value.policies, ['traverse']);
131
+ assertKnownKeys(value.policies, ['read', 'traverse']);
133
132
  if (value.constraints !== undefined)
134
133
  assertKnownKeys(value.constraints, ['noSelf']);
135
134
  }
@@ -1,28 +1,32 @@
1
1
  import type { z } from 'zod';
2
- import type { AutoEvent, AutoSet } from '../../language/class/model/property.js';
2
+ import type { AutoEvent, AutoSet, PropertyImmutability } from '../../language/class/model/property.js';
3
+ import type { StateMachine } from '../../language/state/index.js';
3
4
  import type { JsonSchema } from '../../language/value/model/schema.js';
4
5
  import type { AUTHORING } from '../schema/handle.js';
5
6
  declare const PROPERTY_INPUT: unique symbol;
6
7
  declare const AUTO_INPUT: unique symbol;
7
8
  export type ValueSchemaInput = z.ZodType | JsonSchema;
8
9
  export interface PropertyOptions {
9
- readonly visibility?: 'public' | 'private';
10
10
  readonly required?: boolean;
11
11
  readonly description?: string;
12
+ /** `create` freezes the value at creation; `once` admits one write while absent. */
13
+ readonly immutable?: PropertyImmutability;
12
14
  }
13
15
  export interface AutoOptions {
14
16
  readonly on: AutoEvent | readonly AutoEvent[];
15
17
  readonly set: AutoSet;
16
18
  }
17
- export interface Property<out Schema extends ValueSchemaInput = ValueSchemaInput, out Options extends PropertyOptions = PropertyOptions> {
19
+ export interface Property<out Schema extends ValueSchemaInput = ValueSchemaInput, out Options extends PropertyOptions = PropertyOptions, out Machine = unknown> {
18
20
  readonly [AUTHORING]: 'property';
19
21
  readonly [PROPERTY_INPUT]: {
20
22
  readonly schema: Schema;
21
23
  readonly options: Options;
24
+ readonly machine?: Machine;
22
25
  };
23
26
  }
24
- export type PropertySchemaOf<Value extends Property> = Value extends Property<infer Schema, PropertyOptions> ? Schema : never;
25
- export type PropertyOptionsOf<Value extends Property> = Value extends Property<ValueSchemaInput, infer Options> ? Options : never;
27
+ export type PropertySchemaOf<Value extends Property> = Value extends Property<infer Schema, PropertyOptions, unknown> ? Schema : never;
28
+ export type PropertyOptionsOf<Value extends Property> = Value extends Property<ValueSchemaInput, infer Options, unknown> ? Options : never;
29
+ export type PropertyStateMachineOf<Value extends Property> = Value extends Property<ValueSchemaInput, PropertyOptions, infer Machine> ? Machine : never;
26
30
  export interface AutoProperty<out PropertyValue extends Property = Property> {
27
31
  readonly [AUTHORING]: 'auto';
28
32
  readonly [AUTO_INPUT]: {
@@ -33,9 +37,10 @@ export interface AutoProperty<out PropertyValue extends Property = Property> {
33
37
  };
34
38
  };
35
39
  }
36
- export type PropertyAuthoringInput<Value extends Property> = Value extends Property<infer Schema, infer Options> ? {
40
+ type PropertyAuthoringInput<Value extends Property> = Value extends Property<infer Schema, infer Options, infer Machine> ? {
37
41
  readonly schema: Schema;
38
42
  readonly options: Options;
43
+ readonly machine?: Machine;
39
44
  } : never;
40
45
  export declare function propertyAuthoringInput<const Value extends Property>(value: Value): PropertyAuthoringInput<Value>;
41
46
  export declare function autoPropertyAuthoringInput<const Value extends AutoProperty>(value: Value): Value extends AutoProperty<infer Property> ? {
@@ -47,6 +52,9 @@ export declare function autoPropertyAuthoringInput<const Value extends AutoPrope
47
52
  } : never;
48
53
  export type PropertyFieldInput = ValueSchemaInput | Property | AutoProperty;
49
54
  export type PropertyRecordInput = Readonly<Record<string, PropertyFieldInput>>;
50
- export declare function property<const Schema extends ValueSchemaInput, const Options extends PropertyOptions = Record<never, never>>(schema: Schema, options?: Options): Property<Schema, Options>;
51
- export declare function auto<const PropertyValue extends Property>(property: PropertyValue, options: AutoOptions): AutoProperty<PropertyValue>;
55
+ export declare function property<const Schema extends ValueSchemaInput, const Options extends PropertyOptions = Record<never, never>>(schema: Schema, options?: Options): Property<Schema, Options, never>;
56
+ export declare function stateProperty<const Machine extends StateMachine, const Options extends Omit<PropertyOptions, 'required'> = Record<never, never>>(machine: Machine, options?: Options & Record<Exclude<keyof Options, 'description'>, never>): Property<Machine['stateSchema'], Readonly<Options & {
57
+ readonly required: true;
58
+ }>, Machine>;
59
+ export declare function auto<const PropertyValue extends Property>(property: [PropertyStateMachineOf<PropertyValue>] extends [never] ? PropertyValue : never, options: AutoOptions): AutoProperty<PropertyValue>;
52
60
  export {};
@@ -10,14 +10,27 @@ export function autoPropertyAuthoringInput(value) {
10
10
  }
11
11
  export function property(schema, options) {
12
12
  const admitted = options ?? {};
13
- assertKnownKeys(admitted, ['visibility', 'required', 'description']);
13
+ assertKnownKeys(admitted, ['required', 'description', 'immutable']);
14
+ if (admitted.immutable !== undefined &&
15
+ admitted.immutable !== 'create' &&
16
+ admitted.immutable !== 'once') {
17
+ fail('BUILDER_PROPERTY_IMMUTABLE_INVALID', '/immutable', 'immutable is create or once.');
18
+ }
14
19
  return authoringValue('property', {
15
20
  [PROPERTY_INPUT]: {
16
21
  schema,
17
- options: {
18
- ...admitted,
19
- visibility: admitted.visibility ?? 'public',
20
- },
22
+ options: admitted,
23
+ },
24
+ });
25
+ }
26
+ export function stateProperty(machine, options) {
27
+ const admitted = options ?? {};
28
+ assertKnownKeys(admitted, ['description']);
29
+ return authoringValue('property', {
30
+ [PROPERTY_INPUT]: {
31
+ schema: machine.stateSchema,
32
+ options: { ...admitted, required: true },
33
+ machine,
21
34
  },
22
35
  });
23
36
  }
@@ -26,6 +39,9 @@ export function auto(property, options) {
26
39
  fail('BUILDER_AUTO_NESTED', '', 'auto(...) cannot wrap another auto Property.');
27
40
  }
28
41
  assertKnownKeys(options, ['on', 'set']);
42
+ if (propertyAuthoringInput(property).options.immutable !== undefined) {
43
+ fail('BUILDER_AUTO_IMMUTABLE', '', 'An auto Property cannot be immutable.');
44
+ }
29
45
  const authored = Array.isArray(options.on) ? options.on : [options.on];
30
46
  if (authored.length === 0)
31
47
  fail('BUILDER_AUTO_EVENT_INVALID', '/on', 'auto(...) requires an event.');
@@ -1,29 +1,44 @@
1
1
  import type { Object as JsonObject } from '@astrale-os/kernel-dsl/value';
2
- import type { CoreRef } from '../../addressing/index.js';
3
2
  import type { DomainEndpointRef } from '../../language/core/model/core.js';
3
+ import type { PolicyObjectInput } from '../callable/authoring.js';
4
4
  import type { EdgeClass, NodeClass } from '../class/authoring.js';
5
5
  import type { AUTHORING } from '../schema/handle.js';
6
6
  import type { Lazy } from '../schema/lazy.js';
7
- import type { CorePropertyInput } from '../schema/projection.js';
8
- export interface CoreNode<out Definition extends Lazy<NodeClass> = Lazy<NodeClass>, out Properties extends JsonObject = CorePropertyInput<Definition> & JsonObject> {
7
+ import type { CoreNamedPropertyInput } from '../schema/projection.js';
8
+ interface CoreNodeConfiguration {
9
+ readonly class: Lazy<NodeClass>;
10
+ readonly properties: JsonObject;
11
+ }
12
+ interface CoreEdgeConfiguration {
13
+ readonly source: CoreEndpoint;
14
+ readonly class: Lazy<EdgeClass>;
15
+ readonly target: CoreEndpoint;
16
+ readonly properties: JsonObject;
17
+ }
18
+ export interface CoreNode {
9
19
  readonly [AUTHORING]: 'core-node';
10
- readonly class: Definition;
11
- readonly properties: Properties;
12
20
  }
13
- export type CoreEndpoint = CoreNode | CoreRef | DomainEndpointRef;
14
- export interface CoreEdge<out Source extends CoreEndpoint = CoreEndpoint, out Definition extends Lazy<EdgeClass> = Lazy<EdgeClass>, out Target extends CoreEndpoint = CoreEndpoint, out Properties extends JsonObject = CorePropertyInput<Definition> & JsonObject> {
21
+ /**
22
+ * The owning Domain, or any local Definition of it: a Class, Function, Method, Policy, View, or
23
+ * Core Node, authored as a handle, a lazy handle, or its canonical ref. A lazy handle lets a Core
24
+ * Edge name a declaration that only exists later in a module cycle.
25
+ */
26
+ export type CoreEndpoint = PolicyObjectInput | DomainEndpointRef;
27
+ export interface CoreEdge {
15
28
  readonly [AUTHORING]: 'core-edge';
16
- readonly source: Source;
17
- readonly class: Definition;
18
- readonly target: Target;
19
- readonly properties: Properties;
20
29
  }
21
30
  export interface CoreInput {
22
31
  readonly nodes?: Readonly<Record<string, CoreNode>>;
23
32
  readonly edges?: readonly CoreEdge[];
24
33
  }
25
- declare function node<const Definition extends Lazy<NodeClass>, const Properties extends CorePropertyInput<Definition> & JsonObject>(definition: Definition, properties: Properties): CoreNode<Definition, Properties>;
26
- declare function edge<const Source extends CoreEndpoint, const Definition extends Lazy<EdgeClass>, const Target extends CoreEndpoint, const Properties extends CorePropertyInput<Definition> & JsonObject>(source: Source, definition: Definition, target: Target, properties: Properties): CoreEdge<Source, Definition, Target, Properties>;
34
+ /** Internal lowering access; Core Node handles expose no public configuration object. */
35
+ export declare function coreNodeConfiguration(value: CoreNode): CoreNodeConfiguration;
36
+ /** Internal lowering access; Core Edge handles expose no public configuration object. */
37
+ export declare function coreEdgeConfiguration(value: CoreEdge): CoreEdgeConfiguration;
38
+ declare function node(definition: () => NodeClass, properties: JsonObject): CoreNode;
39
+ declare function node<const Definition extends NodeClass, const Properties extends CoreNamedPropertyInput<Definition> & JsonObject>(definition: Definition, properties: Properties): CoreNode;
40
+ declare function edge(source: CoreEndpoint, definition: () => EdgeClass, target: CoreEndpoint, properties: JsonObject): CoreEdge;
41
+ declare function edge<const Definition extends EdgeClass, const Properties extends CoreNamedPropertyInput<Definition> & JsonObject>(source: CoreEndpoint, definition: Definition, target: CoreEndpoint, properties: Properties): CoreEdge;
27
42
  export declare const core: Readonly<{
28
43
  node: typeof node;
29
44
  edge: typeof edge;