@astrale-os/kernel-dsl 1.0.0-beta.13 → 1.0.0-beta.15

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 (103) hide show
  1. package/dist/v1/addressing/domain-dependency.d.ts +0 -6
  2. package/dist/v1/addressing/domain-dependency.js +1 -6
  3. package/dist/v1/addressing/key.js +2 -1
  4. package/dist/v1/addressing/patterns.d.ts +1 -0
  5. package/dist/v1/addressing/patterns.js +2 -1
  6. package/dist/v1/builder/class/authoring.d.ts +43 -0
  7. package/dist/v1/builder/class/property.d.ts +3 -9
  8. package/dist/v1/builder/class/property.js +1 -0
  9. package/dist/v1/builder/index.d.ts +1 -1
  10. package/dist/v1/builder/lowering/class.js +5 -1
  11. package/dist/v1/builder/lowering/policy.js +2 -0
  12. package/dist/v1/builder/lowering/schema/context.d.ts +5 -0
  13. package/dist/v1/builder/lowering/schema/context.js +22 -0
  14. package/dist/v1/builder/policy/authoring.d.ts +84 -4
  15. package/dist/v1/builder/policy/authoring.js +44 -14
  16. package/dist/v1/builder/schema/projection/class.d.ts +116 -14
  17. package/dist/v1/bundle/codec.js +9 -9
  18. package/dist/v1/bundle/diagnostic.d.ts +2 -0
  19. package/dist/v1/bundle/diagnostic.js +6 -0
  20. package/dist/v1/bundle/structure.js +2 -2
  21. package/dist/v1/compiled/admission/accept.js +3 -3
  22. package/dist/v1/compiled/admission/closure.js +2 -2
  23. package/dist/v1/compiled/admission/semantics/core.js +3 -7
  24. package/dist/v1/compiled/admission/semantics/policy/parity.js +3 -10
  25. package/dist/v1/domain/validation/create.d.ts +4 -1
  26. package/dist/v1/domain/validation/create.js +21 -34
  27. package/dist/v1/language/.spec/schemas/value-schema.schema.json +22 -0
  28. package/dist/v1/language/class/model/class.d.ts +4 -4
  29. package/dist/v1/language/class/model/edge.d.ts +2 -2
  30. package/dist/v1/language/class/model/property.d.ts +16 -7
  31. package/dist/v1/language/core/facts.d.ts +17 -4
  32. package/dist/v1/language/core/facts.js +26 -5
  33. package/dist/v1/language/definition/metadata.d.ts +5 -0
  34. package/dist/v1/language/definition/metadata.js +7 -0
  35. package/dist/v1/language/limits.d.ts +64 -0
  36. package/dist/v1/language/limits.js +60 -0
  37. package/dist/v1/language/policy/analysis/budgets.d.ts +39 -18
  38. package/dist/v1/language/policy/analysis/budgets.js +30 -20
  39. package/dist/v1/language/policy/analysis/checks.js +3 -2
  40. package/dist/v1/language/policy/analysis/typing.js +4 -3
  41. package/dist/v1/language/policy/model/policy.d.ts +5 -5
  42. package/dist/v1/language/policy/normalization/normalize.js +17 -16
  43. package/dist/v1/language/validation/diagnostic.d.ts +1 -1
  44. package/dist/v1/language/validation/rule.d.ts +29 -0
  45. package/dist/v1/language/validation/rule.js +120 -0
  46. package/dist/v1/language/value/profile/meta-schema.compiled.js +4 -1
  47. package/dist/v1/language/value/profile/rules.js +13 -37
  48. package/dist/v1/language/value/profile/vocabulary.d.ts +35 -2
  49. package/dist/v1/language/value/profile/vocabulary.js +52 -5
  50. package/dist/v1/language/value/reference/registry.index.js +2 -1
  51. package/dist/v1/language/value/regexp/ast.js +6 -7
  52. package/dist/v1/language/value/regexp/compile.d.ts +5 -11
  53. package/dist/v1/language/value/regexp/compile.js +14 -12
  54. package/dist/v1/language/value/regexp/syntax.js +3 -2
  55. package/dist/v1/language/value/syntax/keywords.d.ts +3 -3
  56. package/dist/v1/language/value/syntax/keywords.js +4 -20
  57. package/dist/v1/language/value/syntax/node-path/validate.js +2 -3
  58. package/dist/v1/schema/.spec/schemas/domain-schema.schema.json +2336 -0
  59. package/dist/v1/schema/admission/accept.js +3 -14
  60. package/dist/v1/schema/admission/callable.d.ts +21 -0
  61. package/dist/v1/schema/admission/callable.js +96 -0
  62. package/dist/v1/schema/analysis/class.js +33 -15
  63. package/dist/v1/schema/compatibility/api.d.ts +1 -1
  64. package/dist/v1/schema/compatibility/coordinate.js +3 -3
  65. package/dist/v1/schema/compatibility/model.d.ts +5 -0
  66. package/dist/v1/schema/diagnostic.d.ts +17 -3
  67. package/dist/v1/schema/diagnostic.js +11 -0
  68. package/dist/v1/schema/index.d.ts +10 -1
  69. package/dist/v1/schema/index.js +4 -0
  70. package/dist/v1/schema/model/schema.d.ts +19 -1
  71. package/dist/v1/schema/normalization/domain.d.ts +2 -0
  72. package/dist/v1/schema/normalization/domain.js +2 -1
  73. package/dist/v1/schema/resolution/closure.js +2 -1
  74. package/dist/v1/schema/resolution/context.js +10 -8
  75. package/dist/v1/schema/resolution/domain.d.ts +5 -0
  76. package/dist/v1/schema/resolution/domain.js +1 -1
  77. package/dist/v1/schema/rule.d.ts +32 -0
  78. package/dist/v1/schema/rule.js +428 -0
  79. package/dist/v1/schema/validation/callable.d.ts +35 -2
  80. package/dist/v1/schema/validation/callable.js +51 -8
  81. package/dist/v1/schema/validation/class.js +36 -44
  82. package/dist/v1/schema/validation/core.js +19 -13
  83. package/dist/v1/schema/validation/domain.js +2 -2
  84. package/dist/v1/schema/validation/domain.json-schema.d.ts +15 -0
  85. package/dist/v1/schema/validation/domain.json-schema.js +183 -0
  86. package/dist/v1/schema/validation/domain.route.d.ts +6 -1
  87. package/dist/v1/schema/validation/domain.route.js +18 -0
  88. package/dist/v1/schema/validation/domain.structure.d.ts +4020 -0
  89. package/dist/v1/schema/validation/domain.structure.js +359 -153
  90. package/dist/v1/schema/validation/json.json-schema.d.ts +24 -0
  91. package/dist/v1/schema/validation/json.json-schema.js +36 -0
  92. package/dist/v1/schema/validation/policy/budgets.d.ts +33 -2
  93. package/dist/v1/schema/validation/policy/budgets.js +89 -16
  94. package/dist/v1/schema/validation/policy/references.js +6 -21
  95. package/dist/v1/schema/validation/policy/uses.d.ts +29 -0
  96. package/dist/v1/schema/validation/policy/uses.js +28 -51
  97. package/dist/v1/schema/validation/value-api.d.ts +12 -1
  98. package/dist/v1/schema/validation/value-api.js +10 -1
  99. package/dist/v1/schema/validation/value.d.ts +3 -0
  100. package/dist/v1/schema/validation/value.js +6 -12
  101. package/dist/v1/schema/validation/value.json-schema.d.ts +51 -0
  102. package/dist/v1/schema/validation/value.json-schema.js +126 -0
  103. package/package.json +3 -1
@@ -0,0 +1,126 @@
1
+ import { VALUE_SCHEMA_DIALECT } from '../../language/value/model/schema.js';
2
+ import { FORBIDDEN_KEYWORDS, SUBSCHEMA_KEYWORDS, VALUE_KEYWORDS, } from '../../language/value/profile/vocabulary.js';
3
+ /**
4
+ * The checks on value schemas JSON Schema cannot state, which the published document names with
5
+ * the positions it constrains. The Kernel reports each as `DV_VALUE_SCHEMA`, with its value code.
6
+ */
7
+ export const valueSchemaRules = {
8
+ 'value-blob': {
9
+ code: 'DV_VALUE_SCHEMA',
10
+ valueCode: 'VS_VALUE_KIND',
11
+ statement: 'A blob is declared only by the whole schema of a Property, exactly as values.blob writes it.',
12
+ },
13
+ 'value-path': {
14
+ code: 'DV_VALUE_SCHEMA',
15
+ valueCode: 'VS_PATH_EXTENSION',
16
+ statement: 'x-astrale-path annotates only a direct Property of a callable input object, beside exactly the $ref of the graph NodePath schema, and reads target node, cardinality one and a non-empty set of Node Class refs it accepts.',
17
+ },
18
+ 'value-recursion': {
19
+ code: 'DV_VALUE_SCHEMA',
20
+ valueCode: 'VS_RECURSION_PRODUCTIVE',
21
+ statement: 'Every reference cycle of a value schema crosses a keyword that steps into the value: to a member, a member name or an item.',
22
+ },
23
+ 'value-reference-form': {
24
+ code: 'DV_VALUE_SCHEMA',
25
+ valueCode: 'VS_REFERENCE_FORM',
26
+ statement: 'A $ref is a JSON Pointer fragment into its own value schema, or the id of the graph NodePath schema beside x-astrale-path.',
27
+ },
28
+ 'value-reference-resolution': {
29
+ code: 'DV_VALUE_SCHEMA',
30
+ valueCode: 'VS_REFERENCE_RESOLUTION',
31
+ statement: 'A $ref resolves to a location of its own value schema, and x-astrale-path accepts Node Classes of the Domain or of a direct dependency.',
32
+ },
33
+ 'value-regexp': {
34
+ code: 'DV_VALUE_SCHEMA',
35
+ valueCode: 'VS_REGEX_PORTABLE',
36
+ statement: 'Every pattern, fullMatch and patternProperties name is an RFC 9485 I-Regexp within the regular-expression limits.',
37
+ },
38
+ };
39
+ const KIND = 'x-astrale-value-kind';
40
+ const LOCATION = '#/$defs/value-location';
41
+ const SUBSCHEMA = '#/$defs/value-subschema';
42
+ /**
43
+ * The value language in JSON Schema, for the document that embeds value schemas: `root` constrains
44
+ * the `value-schema` definition with the published dialect and what the profile adds to it,
45
+ * `definitions` holds the locations it reaches, and `nodeProperty` constrains a Node Property
46
+ * definition. A named check leaves `x-astrale-rule` at the positions it constrains.
47
+ */
48
+ export function valueSchemaJsonSchema() {
49
+ return {
50
+ root: [
51
+ { $ref: VALUE_SCHEMA_DIALECT },
52
+ { $ref: LOCATION },
53
+ objectOrBoolean({
54
+ properties: {
55
+ $schema: { const: VALUE_SCHEMA_DIALECT },
56
+ [KIND]: {
57
+ enum: ['instant', 'blob'],
58
+ 'x-astrale-rule': 'value-blob',
59
+ },
60
+ },
61
+ }),
62
+ ],
63
+ definitions: {
64
+ // Every location, the root included: the closed vocabulary and the subschemas it holds.
65
+ 'value-location': objectOrBoolean({
66
+ propertyNames: {
67
+ enum: VALUE_KEYWORDS.filter((keyword) => !FORBIDDEN_KEYWORDS.includes(keyword)),
68
+ },
69
+ properties: {
70
+ $id: false,
71
+ $ref: {
72
+ type: 'string',
73
+ 'x-astrale-rule': [
74
+ 'value-recursion',
75
+ 'value-reference-form',
76
+ 'value-reference-resolution',
77
+ ],
78
+ },
79
+ enum: { type: 'array', uniqueItems: true },
80
+ fullMatch: { type: 'string', 'x-astrale-rule': 'value-regexp' },
81
+ pattern: { type: 'string', 'x-astrale-rule': 'value-regexp' },
82
+ 'x-astrale-path': { type: 'object', 'x-astrale-rule': 'value-path' },
83
+ ...Object.fromEntries(SUBSCHEMA_KEYWORDS.single.map((keyword) => [keyword, { $ref: SUBSCHEMA }])),
84
+ ...Object.fromEntries(SUBSCHEMA_KEYWORDS.array.map((keyword) => [
85
+ keyword,
86
+ { type: 'array', items: { $ref: SUBSCHEMA } },
87
+ ])),
88
+ ...Object.fromEntries(SUBSCHEMA_KEYWORDS.map.map((keyword) => [
89
+ keyword,
90
+ {
91
+ type: 'object',
92
+ additionalProperties: { $ref: SUBSCHEMA },
93
+ ...(keyword === 'patternProperties' ? { 'x-astrale-rule': 'value-regexp' } : {}),
94
+ },
95
+ ])),
96
+ },
97
+ // An instant is a string.
98
+ if: { required: [KIND], properties: { [KIND]: { const: 'instant' } } },
99
+ // oxlint-disable-next-line unicorn/no-thenable -- the JSON Schema keyword
100
+ then: { required: ['type'], properties: { type: { const: 'string' } } },
101
+ }),
102
+ // A location below the root: no $schema, and no blob.
103
+ 'value-subschema': {
104
+ allOf: [
105
+ { $ref: LOCATION },
106
+ objectOrBoolean({ properties: { $schema: false, [KIND]: { const: 'instant' } } }),
107
+ ],
108
+ },
109
+ },
110
+ // An automatic or State Property holds no blob.
111
+ nodeProperty: {
112
+ if: { anyOf: [{ required: ['auto'] }, { required: ['state'] }] },
113
+ // oxlint-disable-next-line unicorn/no-thenable -- the JSON Schema keyword
114
+ then: {
115
+ properties: {
116
+ schema: {
117
+ not: { type: 'object', required: [KIND], properties: { [KIND]: { const: 'blob' } } },
118
+ },
119
+ },
120
+ },
121
+ },
122
+ };
123
+ }
124
+ function objectOrBoolean(object) {
125
+ return { anyOf: [{ type: 'boolean' }, { type: 'object', ...object }] };
126
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/kernel-dsl",
3
- "version": "1.0.0-beta.13",
3
+ "version": "1.0.0-beta.15",
4
4
  "description": "Astrale Kernel DSL - Schema authoring, inference, and IR serialization",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -79,6 +79,8 @@
79
79
  "types": "./dist/v1/schema/revision.d.ts",
80
80
  "import": "./dist/v1/schema/revision.js"
81
81
  },
82
+ "./v1/schema/domain-schema.schema.json": "./dist/v1/schema/.spec/schemas/domain-schema.schema.json",
83
+ "./v1/schema/value-schema.schema.json": "./dist/v1/language/.spec/schemas/value-schema.schema.json",
82
84
  "./v1/value/full-match": {
83
85
  "types": "./dist/v1/value/full-match.d.ts",
84
86
  "import": "./dist/v1/value/full-match.js"