@astrale-os/kernel-dsl 1.0.0-beta.7 → 1.0.0-beta.8
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.d.ts +29 -4
- package/dist/v1/builder/class/authoring.js +15 -5
- package/dist/v1/builder/index.d.ts +1 -1
- package/dist/v1/builder/lowering/class.js +11 -1
- package/dist/v1/builder/lowering/property-keys.d.ts +27 -0
- package/dist/v1/builder/lowering/property-keys.js +108 -0
- package/dist/v1/builder/lowering/schema/compile.js +8 -3
- package/dist/v1/builder/lowering/schema/lifetime.d.ts +11 -0
- package/dist/v1/builder/lowering/schema/lifetime.js +55 -0
- package/dist/v1/builder/schema/diagnostic.d.ts +1 -1
- package/dist/v1/compiled/admission/semantics/cardinality.d.ts +1 -1
- package/dist/v1/compiled/admission/semantics/cardinality.js +16 -1
- package/dist/v1/compiled/admission/semantics/class.js +23 -0
- package/dist/v1/compiled/admission/semantics/core.js +16 -0
- package/dist/v1/compiled/admission/wire/class.js +24 -4
- package/dist/v1/language/class/lifetime.d.ts +48 -11
- package/dist/v1/language/class/lifetime.js +86 -20
- package/dist/v1/language/class/model/class.d.ts +16 -1
- package/dist/v1/language/class/model/edge.d.ts +22 -6
- package/dist/v1/language/class/unique.d.ts +123 -13
- package/dist/v1/language/class/unique.js +238 -27
- package/dist/v1/language/index.d.ts +4 -4
- package/dist/v1/language/index.js +2 -2
- package/dist/v1/schema/diagnostic.d.ts +1 -1
- package/dist/v1/schema/normalization/domain.js +15 -4
- package/dist/v1/schema/validation/class.js +70 -1
- package/dist/v1/schema/validation/core.js +50 -0
- package/dist/v1/schema/validation/domain.structure.js +18 -4
- package/package.json +1 -1
- package/dist/v1/builder/lowering/core-properties.d.ts +0 -10
- package/dist/v1/builder/lowering/core-properties.js +0 -76
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { PropertyKey as admitPropertyKey } from '../../addressing/index.js';
|
|
2
|
-
import { definitionRefIndex } from '../../addressing/ordering.js';
|
|
3
|
-
import { createPropertyValues } from '../../language/class/property-values.js';
|
|
4
|
-
import { analyzeDefinitions } from '../../schema/analysis/class.js';
|
|
5
|
-
import { buildDomainResolutionContext } from '../../schema/resolution/context.js';
|
|
6
|
-
import { escapeToken, fail } from '../schema/diagnostic.js';
|
|
7
|
-
/** Lower rich builder shorthand to the canonical full-key Core representation. */
|
|
8
|
-
export function canonicalizeCorePropertyKeys(candidate, lookup) {
|
|
9
|
-
// Core Property values do not participate in Class composition. Analyze the
|
|
10
|
-
// already-canonical Definition surface, then admit Core values below.
|
|
11
|
-
const analysisCandidate = {
|
|
12
|
-
...candidate,
|
|
13
|
-
core: { nodes: {}, edges: [] },
|
|
14
|
-
};
|
|
15
|
-
const definitions = analyzeDefinitions(buildDomainResolutionContext(analysisCandidate, lookup)).definitions;
|
|
16
|
-
const nodes = Object.fromEntries(Object.entries(candidate.core.nodes).map(([slug, node]) => {
|
|
17
|
-
const definition = definitions.get(definitionRefIndex(node.class));
|
|
18
|
-
if (definition === undefined) {
|
|
19
|
-
fail('BUILDER_CORE_PROPERTY', `/core/nodes/${escapeToken(slug)}/class`, 'Core property shorthand requires a resolvable concrete Class.');
|
|
20
|
-
}
|
|
21
|
-
return [
|
|
22
|
-
slug,
|
|
23
|
-
{
|
|
24
|
-
...node,
|
|
25
|
-
properties: qualify(node.properties, definition, `/core/nodes/${escapeToken(slug)}/properties`),
|
|
26
|
-
},
|
|
27
|
-
];
|
|
28
|
-
}));
|
|
29
|
-
const edges = candidate.core.edges.map((edge, index) => {
|
|
30
|
-
const definition = definitions.get(definitionRefIndex(edge.class));
|
|
31
|
-
if (definition === undefined) {
|
|
32
|
-
fail('BUILDER_CORE_PROPERTY', `/core/edges/${index}/class`, 'Core property shorthand requires a resolvable concrete Class.');
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
...edge,
|
|
36
|
-
properties: qualify(edge.properties, definition, `/core/edges/${index}/properties`),
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
return { nodes, edges };
|
|
40
|
-
}
|
|
41
|
-
function qualify(input, definition, pointer) {
|
|
42
|
-
const byName = new Map();
|
|
43
|
-
for (const [key, field] of definition.properties) {
|
|
44
|
-
const candidates = byName.get(field.name) ?? [];
|
|
45
|
-
candidates.push(key);
|
|
46
|
-
byName.set(field.name, candidates);
|
|
47
|
-
}
|
|
48
|
-
const result = {};
|
|
49
|
-
const sourceByKey = new Map();
|
|
50
|
-
for (const [inputKey, value] of Object.entries(input)) {
|
|
51
|
-
const key = resolveInputKey(inputKey, definition, byName, `${pointer}/${escapeToken(inputKey)}`);
|
|
52
|
-
const previous = sourceByKey.get(key);
|
|
53
|
-
if (previous !== undefined) {
|
|
54
|
-
fail('BUILDER_CORE_PROPERTY', `${pointer}/${escapeToken(inputKey)}`, `Property is supplied twice through ${JSON.stringify(previous)} and ${JSON.stringify(inputKey)}.`);
|
|
55
|
-
}
|
|
56
|
-
sourceByKey.set(key, inputKey);
|
|
57
|
-
result[key] = value;
|
|
58
|
-
}
|
|
59
|
-
return createPropertyValues(Object.entries(result).map(([key, value]) => [admitPropertyKey(key), value]));
|
|
60
|
-
}
|
|
61
|
-
function resolveInputKey(input, definition, byName, pointer) {
|
|
62
|
-
if (admitPropertyKey.is(input)) {
|
|
63
|
-
const key = admitPropertyKey(input);
|
|
64
|
-
if (!definition.properties.has(key)) {
|
|
65
|
-
fail('BUILDER_CORE_PROPERTY', pointer, `Property ${input} is not present on the Core Class.`);
|
|
66
|
-
}
|
|
67
|
-
return key;
|
|
68
|
-
}
|
|
69
|
-
const candidates = byName.get(input) ?? [];
|
|
70
|
-
if (candidates.length === 1)
|
|
71
|
-
return candidates[0];
|
|
72
|
-
if (candidates.length === 0) {
|
|
73
|
-
fail('BUILDER_CORE_PROPERTY', pointer, `Property ${JSON.stringify(input)} does not exist.`);
|
|
74
|
-
}
|
|
75
|
-
fail('BUILDER_CORE_PROPERTY', pointer, `Property ${JSON.stringify(input)} is ambiguous; use one of: ${candidates.join(', ')}.`);
|
|
76
|
-
}
|