@astrale-os/kernel-dsl 1.0.0-beta.25 → 1.0.0-beta.26
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.
- package/dist/v1/builder/class/authoring.js +0 -3
- package/dist/v1/compiled/compiler/compile.js +4 -12
- package/dist/v1/language/class/inheritance.js +0 -2
- package/dist/v1/language/value/inclusion/assertions.js +7 -8
- package/dist/v1/schema/compatibility/comparators/classes.js +22 -22
- package/dist/v1/schema/compatibility/meaning/footprint.js +1 -2
- package/dist/v1/schema/compatibility/references.d.ts +0 -3
- package/dist/v1/schema/compatibility/references.js +1 -9
- package/dist/v1/schema/compatibility/structure/requirements.js +2 -4
- package/package.json +1 -1
|
@@ -39,7 +39,6 @@ export function nodeClass(config) {
|
|
|
39
39
|
...(admitted.unique === undefined
|
|
40
40
|
? {}
|
|
41
41
|
: { unique: admitted.unique.map((tuple) => [...tuple]) }),
|
|
42
|
-
abstract: admitted.abstract ?? false,
|
|
43
42
|
});
|
|
44
43
|
return value;
|
|
45
44
|
}
|
|
@@ -75,7 +74,6 @@ export const edgeClass = Object.freeze({
|
|
|
75
74
|
unique: unique.map((tuple) => tuple.map((field) => typeof field === 'string' ? field : { property: field.property })),
|
|
76
75
|
}),
|
|
77
76
|
...options,
|
|
78
|
-
abstract: options.abstract ?? false,
|
|
79
77
|
});
|
|
80
78
|
return value;
|
|
81
79
|
},
|
|
@@ -103,7 +101,6 @@ export const edgeClass = Object.freeze({
|
|
|
103
101
|
classInputs.set(value, {
|
|
104
102
|
endpoints: [{ ...endpoints[0] }, { ...endpoints[1] }],
|
|
105
103
|
...options,
|
|
106
|
-
abstract: options.abstract ?? false,
|
|
107
104
|
});
|
|
108
105
|
return value;
|
|
109
106
|
},
|
|
@@ -36,9 +36,7 @@ function compileEntry(schema, lookup) {
|
|
|
36
36
|
};
|
|
37
37
|
const addProgram = (program) => programs.push(program) - 1;
|
|
38
38
|
const add = (contract, pointer) => addProgram(prepare(contract, pointer).program());
|
|
39
|
-
const properties = (definition, pointer) => Object.entries(definition.properties)
|
|
40
|
-
.sort(([left], [right]) => compareCodeUnits(left, right))
|
|
41
|
-
.map(([name, property]) => {
|
|
39
|
+
const properties = (definition, pointer) => Object.entries(definition.properties).map(([name, property]) => {
|
|
42
40
|
const prepared = prepare(property.schema, `${pointer}/properties/${name}/schema`);
|
|
43
41
|
const ordering = classifyPreparedOrdering(prepared);
|
|
44
42
|
return {
|
|
@@ -58,18 +56,14 @@ function compileEntry(schema, lookup) {
|
|
|
58
56
|
mode: value.mode,
|
|
59
57
|
value: add(value.mode === 'value' ? value.schema : value.item, pointer),
|
|
60
58
|
};
|
|
61
|
-
const classes = Object.values(schema.classes)
|
|
62
|
-
.sort((left, right) => compareCodeUnits(left.ref.name, right.ref.name))
|
|
63
|
-
.map((definition) => {
|
|
59
|
+
const classes = Object.values(schema.classes).map((definition) => {
|
|
64
60
|
const pointer = `/classes/${definition.ref.name}`;
|
|
65
61
|
if (definition.kind === 'edge') {
|
|
66
62
|
const { properties: _, ...rest } = definition;
|
|
67
63
|
return { ...rest, properties: properties(definition, pointer) };
|
|
68
64
|
}
|
|
69
65
|
const { properties: _, methods: __, ...rest } = definition;
|
|
70
|
-
const methods = Object.entries(definition.methods)
|
|
71
|
-
.sort(([left], [right]) => compareCodeUnits(left, right))
|
|
72
|
-
.map(([name, method]) => {
|
|
66
|
+
const methods = Object.entries(definition.methods).map(([name, method]) => {
|
|
73
67
|
const input = add(method.input, `${pointer}/methods/${name}/input`);
|
|
74
68
|
const fields = inputFieldNodes(programs[input]);
|
|
75
69
|
return {
|
|
@@ -88,9 +82,7 @@ function compileEntry(schema, lookup) {
|
|
|
88
82
|
});
|
|
89
83
|
return { ...rest, properties: properties(definition, pointer), methods };
|
|
90
84
|
});
|
|
91
|
-
const functions = Object.values(schema.functions)
|
|
92
|
-
.sort((left, right) => compareCodeUnits(left.ref.name, right.ref.name))
|
|
93
|
-
.map((definition) => {
|
|
85
|
+
const functions = Object.values(schema.functions).map((definition) => {
|
|
94
86
|
const binary = isBinaryInput(definition.input);
|
|
95
87
|
const inputIndex = add(binary ? definition.input.metadata : definition.input, binary
|
|
96
88
|
? `/functions/${definition.ref.name}/input/metadata`
|
|
@@ -44,8 +44,6 @@ export function admitsForeignSubclass(declaration) {
|
|
|
44
44
|
export function edgeContractRefines(child, parent, satisfies) {
|
|
45
45
|
if (isGraphRoot(parent))
|
|
46
46
|
return true;
|
|
47
|
-
if (child.orientation !== parent.orientation)
|
|
48
|
-
return false;
|
|
49
47
|
if (parent.constraints.noSelf === true && child.constraints.noSelf !== true)
|
|
50
48
|
return false;
|
|
51
49
|
if (parent.constraints.acyclic === true && child.constraints.acyclic !== true)
|
|
@@ -15,15 +15,14 @@ const RULES = new Map([
|
|
|
15
15
|
]);
|
|
16
16
|
/** Whether every keyword of the outer `schema` holds for the values `inner` admits. */
|
|
17
17
|
export function assertionsHold(inclusion, outer, schema, inner, evidence) {
|
|
18
|
-
//
|
|
19
|
-
|
|
18
|
+
// A keyword with no rule holds only when it asserts nothing. The annotation-dependent keywords,
|
|
19
|
+
// `unevaluatedProperties` and `unevaluatedItems`, have none: only equivalence decides them.
|
|
20
|
+
const keywords = Object.keys(schema);
|
|
21
|
+
if (!keywords.every((keyword) => RULES.has(keyword) || INERT.has(keyword)))
|
|
20
22
|
return false;
|
|
21
|
-
|
|
22
|
-
return false;
|
|
23
|
-
return Object.keys(schema).every((keyword) => {
|
|
23
|
+
return keywords.every((keyword) => {
|
|
24
24
|
const rule = RULES.get(keyword);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return rule({ inclusion, keyword, value: schema[keyword], outer, schema, inner, evidence });
|
|
25
|
+
return (rule === undefined ||
|
|
26
|
+
rule({ inclusion, keyword, value: schema[keyword], outer, schema, inner, evidence }));
|
|
28
27
|
});
|
|
29
28
|
}
|
|
@@ -27,31 +27,31 @@ export function classMeaning(context, coordinate, level, onto) {
|
|
|
27
27
|
ancestors,
|
|
28
28
|
});
|
|
29
29
|
const covering = coveringTuples(context, declaration);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
// The fields whose meaning is not their declared value; `CLASS_FIELDS` decides which count.
|
|
31
|
+
const normalized = {
|
|
32
|
+
...declaration,
|
|
33
|
+
extends: onto === undefined
|
|
34
|
+
? ancestors
|
|
35
|
+
: onto.ancestors.filter((ancestor) => ancestors.includes(ancestor)),
|
|
36
|
+
policies: Object.fromEntries(Object.entries(declaration.policies)
|
|
37
|
+
.filter(([, policy]) => policy !== undefined)
|
|
38
|
+
.map(([role, policy]) => [role, classPolicyMeaning(policy)])),
|
|
39
|
+
...(declaration.kind === 'node'
|
|
36
40
|
? {
|
|
37
|
-
|
|
38
|
-
?
|
|
39
|
-
:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
...(declaration.kind === 'node'
|
|
44
|
-
? {
|
|
45
|
-
data: analysis.data === undefined
|
|
46
|
-
? null
|
|
47
|
-
: {
|
|
48
|
-
owner: keyForDefinitionRef(analysis.data.owner),
|
|
49
|
-
declaration: analysis.data.declaration,
|
|
50
|
-
},
|
|
51
|
-
}
|
|
52
|
-
: { endpoints: declaration.endpoints, constraints: declaration.constraints }),
|
|
41
|
+
data: analysis.data === undefined
|
|
42
|
+
? null
|
|
43
|
+
: {
|
|
44
|
+
owner: keyForDefinitionRef(analysis.data.owner),
|
|
45
|
+
declaration: analysis.data.declaration,
|
|
46
|
+
},
|
|
53
47
|
}
|
|
54
48
|
: {}),
|
|
49
|
+
...(covering.length === 0 ? {} : { unique: covering }),
|
|
50
|
+
};
|
|
51
|
+
const meaning = {
|
|
52
|
+
coordinate: 'class',
|
|
53
|
+
level: level,
|
|
54
|
+
...fieldsOf({ declaration: normalized, roles: CLASS_FIELDS, level }),
|
|
55
55
|
};
|
|
56
56
|
return { meaning: deepFreeze(meaning), requirement };
|
|
57
57
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { callableReferences, classReferences, inherits, memberReferences
|
|
1
|
+
import { callableReferences, classReferences, inherits, memberReferences } from '../references.js';
|
|
2
2
|
import { walkReferences } from '../walk.js';
|
|
3
3
|
/** Meaning follows complete callable contracts through the exact authored reference closure. */
|
|
4
4
|
export function compareFootprint({ context, report, }) {
|
|
@@ -10,7 +10,6 @@ export function compareFootprint({ context, report, }) {
|
|
|
10
10
|
reach(...classReferences(subject, true));
|
|
11
11
|
return inherits(usage) ? 'class.inherit' : 'class.reference';
|
|
12
12
|
case 'property':
|
|
13
|
-
reach(...valueReferences(subject));
|
|
14
13
|
return 'property';
|
|
15
14
|
case 'method':
|
|
16
15
|
reach(...callableReferences(subject));
|
|
@@ -23,9 +23,6 @@ export declare function rootReferences(schema: DomainSchema): readonly Reference
|
|
|
23
23
|
*/
|
|
24
24
|
export declare function policyReliance(schema: DomainSchema, origin: Key.Origin): readonly Reference[];
|
|
25
25
|
/** Existing DSL collectors own reference syntax. These functions attach comparison provenance. */
|
|
26
|
-
export declare function valueReferences(subject: Extract<ResolvedSubject, {
|
|
27
|
-
kind: 'property';
|
|
28
|
-
}>): readonly Reference[];
|
|
29
26
|
export declare function callableReferences(subject: Extract<ResolvedSubject, {
|
|
30
27
|
kind: 'method';
|
|
31
28
|
}>): readonly Reference[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Key } from '../../addressing/index.js';
|
|
2
2
|
import { revisionOfDomainSchema } from '../canonical/revision.js';
|
|
3
|
-
import { collectCallableContractRefs, collectCallableRefs, collectClassPolicyRefs, collectCoreRefs, collectEndpointRefs, collectPolicyDefinitionRefs,
|
|
3
|
+
import { collectCallableContractRefs, collectCallableRefs, collectClassPolicyRefs, collectCoreRefs, collectEndpointRefs, collectPolicyDefinitionRefs, coreEndpointDefinitionRef, } from '../resolution/origins.js';
|
|
4
4
|
import { classCoordinate, keyForDefinitionRef, memberCoordinate, methodCoordinate, propertyCoordinate, } from './coordinate.js';
|
|
5
5
|
export function schemaIdentity(schema) {
|
|
6
6
|
return Object.freeze({ origin: schema.origin, revision: revisionOfDomainSchema(schema) });
|
|
@@ -31,9 +31,6 @@ export function rootReferences(schema) {
|
|
|
31
31
|
const key = keyForDefinitionRef(declaration.ref);
|
|
32
32
|
const add = collector(schema, result, key);
|
|
33
33
|
declaration.extends.forEach((ref) => add(ref, 'extends'));
|
|
34
|
-
for (const [name, field] of Object.entries(declaration.properties)) {
|
|
35
|
-
collectValueDefinitionRefs(field.schema, collector(schema, result, propertyCoordinate(declaration.ref, name).key));
|
|
36
|
-
}
|
|
37
34
|
collectClassPolicyRefs(declaration, add);
|
|
38
35
|
if (declaration.kind === 'edge')
|
|
39
36
|
collectEndpointRefs(declaration, add);
|
|
@@ -81,11 +78,6 @@ export function policyReliance(schema, origin) {
|
|
|
81
78
|
return [...result.values()];
|
|
82
79
|
}
|
|
83
80
|
/** Existing DSL collectors own reference syntax. These functions attach comparison provenance. */
|
|
84
|
-
export function valueReferences(subject) {
|
|
85
|
-
const result = [];
|
|
86
|
-
collectValueDefinitionRefs(subject.field.schema, collector(subject.schema, result, subject.coordinate.key));
|
|
87
|
-
return result;
|
|
88
|
-
}
|
|
89
81
|
export function callableReferences(subject) {
|
|
90
82
|
const result = [];
|
|
91
83
|
collectCallableContractRefs(subject.method.declaration, collector(subject.schema, result, subject.coordinate.key));
|
|
@@ -5,7 +5,7 @@ import { fingerprintMeaning } from '../comparators/values.js';
|
|
|
5
5
|
import { retainedContextDefect } from '../context.js';
|
|
6
6
|
import { methodCoordinate } from '../coordinate.js';
|
|
7
7
|
import { closedParents } from '../extension.js';
|
|
8
|
-
import { callableReferences, classReferences, inherits, memberReferences, usageOf,
|
|
8
|
+
import { callableReferences, classReferences, inherits, memberReferences, usageOf, } from '../references.js';
|
|
9
9
|
import { walkReferences } from '../walk.js';
|
|
10
10
|
/** Structure follows data and abstract obligations; concrete IO never expands its requirements. */
|
|
11
11
|
export function compareRequirements({ context, report, }) {
|
|
@@ -23,7 +23,6 @@ export function compareRequirements({ context, report, }) {
|
|
|
23
23
|
}
|
|
24
24
|
return inherits(usage) ? 'class.inherit' : 'class.reference';
|
|
25
25
|
case 'property':
|
|
26
|
-
reach(...valueReferences(subject));
|
|
27
26
|
return 'property';
|
|
28
27
|
case 'method':
|
|
29
28
|
if (usage.relation !== 'abstract')
|
|
@@ -79,12 +78,11 @@ function compareExtension({ context, report, }) {
|
|
|
79
78
|
if (closed.size === 0)
|
|
80
79
|
return;
|
|
81
80
|
for (const reference of context.roots) {
|
|
82
|
-
if (
|
|
81
|
+
if (!closed.has(reference.coordinate.key))
|
|
83
82
|
continue;
|
|
84
83
|
const pair = context.pair(reference.coordinate);
|
|
85
84
|
if (pair.target?.kind !== 'class')
|
|
86
85
|
continue;
|
|
87
|
-
report.note(reference);
|
|
88
86
|
report.record({
|
|
89
87
|
pair,
|
|
90
88
|
facet: 'class.inheritance',
|