@astrale-os/kernel-dsl 1.0.0-beta.12 → 1.0.0-beta.13
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/addressing/definition-ref.js +21 -37
- package/dist/v1/addressing/ordering.d.ts +2 -0
- package/dist/v1/addressing/ordering.js +4 -0
- package/dist/v1/addressing/patterns.d.ts +0 -1
- package/dist/v1/addressing/patterns.js +0 -5
- package/dist/v1/builder/class/authoring.js +5 -28
- package/dist/v1/builder/lowering/schema/context.js +2 -4
- package/dist/v1/builder/lowering/value/path.js +2 -4
- package/dist/v1/builder/lowering/value/zod.js +1 -3
- package/dist/v1/builder/schema/define.d.ts +0 -1
- package/dist/v1/builder/schema/diagnostic.d.ts +2 -1
- package/dist/v1/builder/schema/diagnostic.js +5 -10
- package/dist/v1/builder/schema/projection.d.ts +1 -1
- package/dist/v1/builder/value/full-match.d.ts +0 -1
- package/dist/v1/builder/value/full-match.js +0 -1
- package/dist/v1/bundle/codec.js +2 -4
- package/dist/v1/bundle/diagnostic.js +3 -7
- package/dist/v1/bundle/structure.js +2 -4
- package/dist/v1/compiled/admission/diagnostic.d.ts +1 -1
- package/dist/v1/compiled/admission/diagnostic.js +1 -3
- package/dist/v1/compiled/admission/revision.d.ts +9 -1
- package/dist/v1/compiled/admission/revision.js +6 -3
- package/dist/v1/compiled/admission/semantics/class.d.ts +4 -1
- package/dist/v1/compiled/admission/semantics/class.js +4 -8
- package/dist/v1/compiled/admission/semantics/core.d.ts +1 -24
- package/dist/v1/compiled/admission/semantics/core.js +54 -34
- package/dist/v1/compiled/admission/semantics/edge.d.ts +2 -4
- package/dist/v1/compiled/admission/semantics/edge.js +6 -65
- package/dist/v1/compiled/admission/semantics/policy/callable.js +0 -2
- package/dist/v1/compiled/admission/semantics/policy/contracts.d.ts +5 -20
- package/dist/v1/compiled/admission/semantics/policy/contracts.js +8 -21
- package/dist/v1/compiled/admission/semantics/policy/parity.js +13 -22
- package/dist/v1/compiled/admission/semantics/policy/pattern.d.ts +4 -1
- package/dist/v1/compiled/admission/semantics/policy/pattern.js +4 -16
- package/dist/v1/compiled/admission/semantics/policy/typing.d.ts +2 -24
- package/dist/v1/compiled/admission/semantics/policy/typing.js +19 -201
- package/dist/v1/compiled/compiler/compile.js +6 -8
- package/dist/v1/compiled/diagnostic.js +2 -3
- package/dist/v1/compiled/loader/load.d.ts +3 -2
- package/dist/v1/compiled/loader/load.js +10 -44
- package/dist/v1/domain/create.js +3 -5
- package/dist/v1/domain/namespace/member-collection.js +4 -6
- package/dist/v1/domain/validation/create.d.ts +0 -1
- package/dist/v1/domain/validation/create.js +0 -35
- package/dist/v1/language/class/inheritance.d.ts +18 -0
- package/dist/v1/language/class/inheritance.js +73 -0
- package/dist/v1/language/class/property-values.js +2 -4
- package/dist/v1/language/core/facts.d.ts +72 -0
- package/dist/v1/language/core/facts.js +95 -0
- package/dist/v1/language/policy/analysis/branches.d.ts +8 -0
- package/dist/v1/language/policy/analysis/branches.js +2 -1
- package/dist/v1/language/policy/analysis/budgets.d.ts +13 -1
- package/dist/v1/language/policy/analysis/budgets.js +104 -0
- package/dist/v1/language/policy/analysis/typing.d.ts +48 -0
- package/dist/v1/language/policy/analysis/typing.js +338 -0
- package/dist/v1/language/validation/diagnostic.d.ts +14 -0
- package/dist/v1/language/validation/diagnostic.js +21 -0
- package/dist/v1/language/value/compile/fields.js +4 -8
- package/dist/v1/language/value/profile/rules.js +5 -7
- package/dist/v1/language/value/profile/validate.js +1 -10
- package/dist/v1/language/value/reference/recursion.js +2 -22
- package/dist/v1/language/value/syntax/pointer.d.ts +2 -0
- package/dist/v1/language/value/syntax/pointer.js +5 -2
- package/dist/v1/language/value/syntax/walk.d.ts +2 -0
- package/dist/v1/language/value/syntax/walk.js +19 -20
- package/dist/v1/schema/compatibility/diff.js +2 -4
- package/dist/v1/schema/compatibility/meaning/footprint.js +16 -50
- package/dist/v1/schema/compatibility/structure/requirements.js +26 -58
- package/dist/v1/schema/compatibility/walk.d.ts +17 -0
- package/dist/v1/schema/compatibility/walk.js +41 -0
- package/dist/v1/schema/diagnostic.js +3 -11
- package/dist/v1/schema/resolution/context.js +3 -5
- package/dist/v1/schema/validation/callable.js +3 -5
- package/dist/v1/schema/validation/class.js +10 -52
- package/dist/v1/schema/validation/core.js +65 -199
- package/dist/v1/schema/validation/domain.js +1 -10
- package/dist/v1/schema/validation/domain.structure.js +2 -4
- package/dist/v1/schema/validation/policy/budgets.js +5 -112
- package/dist/v1/schema/validation/policy/context.d.ts +5 -3
- package/dist/v1/schema/validation/policy/context.js +5 -3
- package/dist/v1/schema/validation/policy/objects.d.ts +1 -1
- package/dist/v1/schema/validation/policy/objects.js +6 -14
- package/dist/v1/schema/validation/policy/references.js +5 -6
- package/dist/v1/schema/validation/policy/typing.d.ts +3 -18
- package/dist/v1/schema/validation/policy/typing.js +22 -356
- package/dist/v1/schema/validation/policy/uses.d.ts +1 -1
- package/dist/v1/schema/validation/policy/uses.js +9 -22
- package/dist/v1/schema/validation/policy/validate.js +3 -2
- package/dist/v1/schema/validation/value-api.js +2 -2
- package/dist/v1/schema/validation/value.js +5 -7
- package/dist/v1/schema/validation/view.js +4 -8
- package/package.json +1 -1
- package/dist/v1/compiled/admission/semantics/cardinality.d.ts +0 -5
- package/dist/v1/compiled/admission/semantics/cardinality.js +0 -128
- package/dist/v1/compiled/admission/semantics/policy/equality.d.ts +0 -8
- package/dist/v1/compiled/admission/semantics/policy/equality.js +0 -27
- package/dist/v1/compiled/admission/semantics/policy/measure.d.ts +0 -9
- package/dist/v1/compiled/admission/semantics/policy/measure.js +0 -81
- package/dist/v1/compiled/admission/semantics/policy/variants.d.ts +0 -10
- package/dist/v1/compiled/admission/semantics/policy/variants.js +0 -65
- package/dist/v1/language/class/index.d.ts +0 -8
- package/dist/v1/language/class/index.js +0 -1
- package/dist/v1/language/core/index.d.ts +0 -2
- package/dist/v1/language/core/index.js +0 -1
- package/dist/v1/language/value/index.d.ts +0 -11
- package/dist/v1/language/value/index.js +0 -8
|
@@ -8,55 +8,39 @@ const DEFINITION_KINDS = new Set([
|
|
|
8
8
|
]);
|
|
9
9
|
/** Admit and detach one canonical DefinitionRef from an untrusted value. */
|
|
10
10
|
export function acceptDefinitionRef(input) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
return readDefinitionRef(input) ?? invalid(input);
|
|
12
|
+
}
|
|
13
|
+
/** Identify a canonical DefinitionRef-shaped value without retaining caller state. */
|
|
14
|
+
export function isDefinitionRef(input) {
|
|
15
|
+
return readDefinitionRef(input) !== undefined;
|
|
16
|
+
}
|
|
17
|
+
/** Compare exact Definition coordinates, independent of object identity. */
|
|
18
|
+
export function equalDefinitionRefs(left, right) {
|
|
19
|
+
return left.origin === right.origin && left.kind === right.kind && left.name === right.name;
|
|
20
|
+
}
|
|
21
|
+
function invalid(input) {
|
|
22
|
+
throw new TypeError(`Invalid DefinitionRef: ${JSON.stringify(input)}.`);
|
|
23
|
+
}
|
|
24
|
+
/** A detached copy of the canonical DefinitionRef `input` holds, reading each field once. */
|
|
25
|
+
function readDefinitionRef(input) {
|
|
26
|
+
if (input === null || typeof input !== 'object' || Array.isArray(input))
|
|
27
|
+
return undefined;
|
|
14
28
|
const value = input;
|
|
15
29
|
const keys = Reflect.ownKeys(value);
|
|
16
30
|
if (keys.length !== 3 ||
|
|
17
31
|
!keys.every((key) => key === 'origin' || key === 'kind' || key === 'name')) {
|
|
18
|
-
|
|
32
|
+
return undefined;
|
|
19
33
|
}
|
|
20
|
-
const origin = value
|
|
21
|
-
const kind = value.kind;
|
|
22
|
-
const name = value.name;
|
|
34
|
+
const { origin, kind, name } = value;
|
|
23
35
|
if (typeof origin !== 'string' ||
|
|
24
36
|
!DOMAIN_ORIGIN_PATTERN.test(origin) ||
|
|
25
37
|
typeof kind !== 'string' ||
|
|
26
38
|
!DEFINITION_KINDS.has(kind) ||
|
|
27
39
|
typeof name !== 'string' ||
|
|
28
40
|
!definitionNameMatches(kind, name)) {
|
|
29
|
-
|
|
41
|
+
return undefined;
|
|
30
42
|
}
|
|
31
|
-
return Object.freeze({
|
|
32
|
-
origin,
|
|
33
|
-
kind: kind,
|
|
34
|
-
name,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
/** Identify a canonical DefinitionRef-shaped value without retaining caller state. */
|
|
38
|
-
export function isDefinitionRef(input) {
|
|
39
|
-
if (input === null || typeof input !== 'object' || Array.isArray(input))
|
|
40
|
-
return false;
|
|
41
|
-
const value = input;
|
|
42
|
-
const keys = Reflect.ownKeys(value);
|
|
43
|
-
if (keys.length !== 3 ||
|
|
44
|
-
!keys.every((key) => key === 'origin' || key === 'kind' || key === 'name')) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
return (typeof value.origin === 'string' &&
|
|
48
|
-
DOMAIN_ORIGIN_PATTERN.test(value.origin) &&
|
|
49
|
-
typeof value.kind === 'string' &&
|
|
50
|
-
DEFINITION_KINDS.has(value.kind) &&
|
|
51
|
-
typeof value.name === 'string' &&
|
|
52
|
-
definitionNameMatches(value.kind, value.name));
|
|
53
|
-
}
|
|
54
|
-
/** Compare exact Definition coordinates, independent of object identity. */
|
|
55
|
-
export function equalDefinitionRefs(left, right) {
|
|
56
|
-
return left.origin === right.origin && left.kind === right.kind && left.name === right.name;
|
|
57
|
-
}
|
|
58
|
-
function invalid(input) {
|
|
59
|
-
throw new TypeError(`Invalid DefinitionRef: ${JSON.stringify(input)}.`);
|
|
43
|
+
return Object.freeze({ origin, kind: kind, name });
|
|
60
44
|
}
|
|
61
45
|
function definitionNameMatches(kind, name) {
|
|
62
46
|
return kind === 'core' ? CORE_SLUG_PATTERN.test(name) : MEMBER_NAME_PATTERN.test(name);
|
|
@@ -4,3 +4,5 @@ export declare function definitionRefIndex(ref: DefinitionRef): string;
|
|
|
4
4
|
export declare function compareDefinitionRefs(left: DefinitionRef, right: DefinitionRef): number;
|
|
5
5
|
/** Locale-independent Unicode code-point ordering for canonical DSL values. */
|
|
6
6
|
export declare function compareUnicode(left: string, right: string): number;
|
|
7
|
+
/** Order strings by UTF-16 code unit, the order `<` gives strings. */
|
|
8
|
+
export declare function compareCodeUnits(left: string, right: string): number;
|
|
@@ -18,3 +18,7 @@ export function compareUnicode(left, right) {
|
|
|
18
18
|
}
|
|
19
19
|
return a.length - b.length;
|
|
20
20
|
}
|
|
21
|
+
/** Order strings by UTF-16 code unit, the order `<` gives strings. */
|
|
22
|
+
export function compareCodeUnits(left, right) {
|
|
23
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
24
|
+
}
|
|
@@ -22,8 +22,3 @@ export const patterns = Object.freeze({
|
|
|
22
22
|
revision: DOMAIN_REVISION_PATTERN,
|
|
23
23
|
revisionFullMatch: DOMAIN_REVISION_FULL_MATCH,
|
|
24
24
|
});
|
|
25
|
-
export function assertMemberName(name) {
|
|
26
|
-
if (!MEMBER_NAME_PATTERN.test(name)) {
|
|
27
|
-
throw new TypeError(`Invalid member name: ${JSON.stringify(name)}.`);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -59,7 +59,7 @@ export const edgeClass = Object.freeze({
|
|
|
59
59
|
validateDirectedSourceInput(input.source);
|
|
60
60
|
validateDirectedTargetInput(input.target);
|
|
61
61
|
const { source, target, unique, ...options } = input;
|
|
62
|
-
validateEdgeClassOptions(options);
|
|
62
|
+
validateEdgeClassOptions(options, ['noSelf', 'acyclic']);
|
|
63
63
|
const value = authoringValue('definition', {
|
|
64
64
|
kind: 'edge',
|
|
65
65
|
orientation: 'directed',
|
|
@@ -94,7 +94,7 @@ export const edgeClass = Object.freeze({
|
|
|
94
94
|
validateIncidentEndpointInput(input.endpoints[0]);
|
|
95
95
|
validateIncidentEndpointInput(input.endpoints[1]);
|
|
96
96
|
const { endpoints, ...options } = input;
|
|
97
|
-
|
|
97
|
+
validateEdgeClassOptions(options, ['noSelf']);
|
|
98
98
|
const value = authoringValue('definition', {
|
|
99
99
|
kind: 'edge',
|
|
100
100
|
orientation: 'undirected',
|
|
@@ -122,33 +122,10 @@ function validateDirectedTargetInput(value) {
|
|
|
122
122
|
function validateIncidentEndpointInput(value) {
|
|
123
123
|
assertKnownKeys(value, ['as', 'accepts', 'incident', 'onDelete']);
|
|
124
124
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
'abstract',
|
|
128
|
-
'inheritance',
|
|
129
|
-
'description',
|
|
130
|
-
'extends',
|
|
131
|
-
'properties',
|
|
132
|
-
'policies',
|
|
133
|
-
'constraints',
|
|
134
|
-
]);
|
|
135
|
-
if (value.policies !== undefined)
|
|
136
|
-
assertKnownKeys(value.policies, ['read', 'traverse']);
|
|
137
|
-
if (value.constraints !== undefined)
|
|
138
|
-
assertKnownKeys(value.constraints, ['noSelf', 'acyclic']);
|
|
139
|
-
}
|
|
140
|
-
function validateUndirectedEdgeClassOptions(value) {
|
|
141
|
-
assertKnownKeys(value, [
|
|
142
|
-
'abstract',
|
|
143
|
-
'inheritance',
|
|
144
|
-
'description',
|
|
145
|
-
'extends',
|
|
146
|
-
'properties',
|
|
147
|
-
'policies',
|
|
148
|
-
'constraints',
|
|
149
|
-
]);
|
|
125
|
+
/** Check the nested Edge Class options; the caller has checked the option keys themselves. */
|
|
126
|
+
function validateEdgeClassOptions(value, constraints) {
|
|
150
127
|
if (value.policies !== undefined)
|
|
151
128
|
assertKnownKeys(value.policies, ['read', 'traverse']);
|
|
152
129
|
if (value.constraints !== undefined)
|
|
153
|
-
assertKnownKeys(value.constraints,
|
|
130
|
+
assertKnownKeys(value.constraints, constraints);
|
|
154
131
|
}
|
|
@@ -4,6 +4,7 @@ import { isMethodExecutable } from '../../../language/callable/executable.js';
|
|
|
4
4
|
import { admitsForeignSubclass, inheritanceOf } from '../../../language/class/inheritance.js';
|
|
5
5
|
import { policyObjectKey, policyObjectOrigin } from '../../../language/index.js';
|
|
6
6
|
import { graphNodePathSchema } from '../../../language/value/syntax/node-path/schema.js';
|
|
7
|
+
import { escapePointerToken } from '../../../language/value/syntax/pointer.js';
|
|
7
8
|
import { revisionOfDomainSchema } from '../../../schema/canonical/revision.js';
|
|
8
9
|
import { requireDomainClosure } from '../../../schema/resolution/closure.js';
|
|
9
10
|
import { collectUsedForeignOrigins } from '../../../schema/resolution/origins.js';
|
|
@@ -23,7 +24,7 @@ export class BuilderContext {
|
|
|
23
24
|
constructor(origin, dependencies) {
|
|
24
25
|
this.origin = origin;
|
|
25
26
|
for (const [alias, schema] of Object.entries(dependencies)) {
|
|
26
|
-
const pointer = `/dependencies/${
|
|
27
|
+
const pointer = `/dependencies/${escapePointerToken(alias)}`;
|
|
27
28
|
if (!DEPENDENCY_ALIAS_PATTERN.test(alias)) {
|
|
28
29
|
fail('BUILDER_DEPENDENCY_ALIAS', pointer, `Dependency alias ${JSON.stringify(alias)} must be an ASCII lower-camel identifier.`);
|
|
29
30
|
}
|
|
@@ -223,9 +224,6 @@ export class BuilderContext {
|
|
|
223
224
|
this.policyObjectRefs.add(policyObjectKey(ref));
|
|
224
225
|
}
|
|
225
226
|
}
|
|
226
|
-
function escapePointer(value) {
|
|
227
|
-
return value.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
228
|
-
}
|
|
229
227
|
function isResolvedClass(value) {
|
|
230
228
|
if (typeof value !== 'object' || value === null)
|
|
231
229
|
return false;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { escapePointerToken } from '../../../language/value/syntax/pointer.js';
|
|
1
2
|
import { pathAccepts } from '../../value/path-metadata.js';
|
|
2
3
|
export function lowerPathSchema(context, resolveAccepts, pointer) {
|
|
3
4
|
const inputs = pathAccepts(context.zodSchema);
|
|
4
5
|
if (inputs === undefined)
|
|
5
6
|
return;
|
|
6
|
-
const location = context.path.reduce((current, segment) => `${current}/${
|
|
7
|
+
const location = context.path.reduce((current, segment) => `${current}/${escapePointerToken(String(segment))}`, pointer);
|
|
7
8
|
for (const key of Object.keys(context.jsonSchema))
|
|
8
9
|
delete context.jsonSchema[key];
|
|
9
10
|
Object.assign(context.jsonSchema, {
|
|
@@ -15,6 +16,3 @@ export function lowerPathSchema(context, resolveAccepts, pointer) {
|
|
|
15
16
|
},
|
|
16
17
|
});
|
|
17
18
|
}
|
|
18
|
-
function escapeToken(value) {
|
|
19
|
-
return value.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
20
|
-
}
|
|
@@ -4,6 +4,7 @@ import { canonicalizeValueSchema } from '../../../language/value/profile/canonic
|
|
|
4
4
|
import { validateValueSchema } from '../../../language/value/profile/validate.js';
|
|
5
5
|
import { isIRegexp } from '../../../language/value/regexp/syntax.js';
|
|
6
6
|
import { fullMatchSource } from '../../../language/value/syntax/full-match.js';
|
|
7
|
+
import { escapePointerToken } from '../../../language/value/syntax/pointer.js';
|
|
7
8
|
import { diagnostic } from '../../schema/diagnostic.js';
|
|
8
9
|
/**
|
|
9
10
|
* Converts only Zod contracts whose JSON-value acceptance is represented
|
|
@@ -289,9 +290,6 @@ function getCheckDefinition(value) {
|
|
|
289
290
|
function isZodType(value) {
|
|
290
291
|
return value instanceof ZodType;
|
|
291
292
|
}
|
|
292
|
-
function escapePointerToken(value) {
|
|
293
|
-
return value.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
294
|
-
}
|
|
295
293
|
function isPlainRecord(value) {
|
|
296
294
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
297
295
|
}
|
|
@@ -2,7 +2,6 @@ import type { Domain } from '../../domain/model/domain.js';
|
|
|
2
2
|
import type { DomainSchema } from '../../schema/model/schema.js';
|
|
3
3
|
import type { DomainSchemaInput, EntrypointOf } from './input.js';
|
|
4
4
|
import type { ResolvedDomainOfInput } from './projection.js';
|
|
5
|
-
export type { DomainSchemaInput } from './input.js';
|
|
6
5
|
/** Exact named Schema produced from one authored input. */
|
|
7
6
|
export interface DefinedSchema<Origin extends string, Resolved extends Domain> extends DomainSchema<Origin, Resolved> {
|
|
8
7
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { DiagnosticCode as LanguageDiagnosticCode } from '../../language/validation/diagnostic.js';
|
|
2
|
+
import { escapePointerToken as escapeToken } from '../../language/value/syntax/pointer.js';
|
|
3
|
+
export { escapeToken };
|
|
2
4
|
export type BuilderDiagnosticCode = LanguageDiagnosticCode | 'BUILDER_ABSTRACT_POLICY' | 'BUILDER_AMBIGUOUS_OWNERSHIP' | 'BUILDER_AUTO_EVENT_INVALID' | 'BUILDER_AUTO_IMMUTABLE' | 'BUILDER_AUTO_NESTED' | 'BUILDER_AUTO_SET_INVALID' | 'BUILDER_CALLABLE_AUTH' | 'BUILDER_CALLABLE_PLACEMENT' | 'BUILDER_CALLABLE_POLICY_AUTH' | 'BUILDER_CLASS_INHERITANCE' | 'BUILDER_CORE_CLASS' | 'BUILDER_CORE_EDGE' | 'BUILDER_CORE_NODE' | 'BUILDER_CORE_PROPERTY' | 'BUILDER_CORE_REF' | 'BUILDER_DEFINITION' | 'BUILDER_DEPENDENCY_CONFLICT' | 'BUILDER_DEPENDENCY_ALIAS' | 'BUILDER_DEPENDENCY_DIRECT' | 'BUILDER_DUPLICATE_MEMBER' | 'BUILDER_EDGE_LIFETIME' | 'BUILDER_FOREIGN_POLICY' | 'BUILDER_FULL_MATCH_INVALID' | 'BUILDER_FUNCTION' | 'BUILDER_METHOD' | 'BUILDER_PATH_DUPLICATE' | 'BUILDER_PATH_EMPTY' | 'BUILDER_POLICY' | 'BUILDER_POLICY_COMPOSITION' | 'BUILDER_POLICY_CYCLE' | 'BUILDER_POLICY_EMPTY_COMPOSITION' | 'BUILDER_POLICY_EMPTY_EXISTS' | 'BUILDER_POLICY_INPUT' | 'BUILDER_POLICY_REF' | 'BUILDER_POLICY_SELF' | 'BUILDER_PROPERTY_IMMUTABLE_INVALID' | 'BUILDER_REFERENCE_CYCLE' | 'BUILDER_REFERENCE_KIND' | 'BUILDER_REFERENCE_MISSING' | 'BUILDER_UNIQUE_PROPERTY' | 'BUILDER_UNKNOWN_FIELD' | 'BUILDER_UNOWNED_REFERENCE' | 'BUILDER_VIEW' | 'ZOD_SCHEMA_NOT_LOSSLESS';
|
|
3
5
|
export interface BuilderDiagnostic<out Code extends BuilderDiagnosticCode = BuilderDiagnosticCode> {
|
|
4
6
|
readonly code: Code;
|
|
@@ -13,4 +15,3 @@ export declare class BuilderError extends Error {
|
|
|
13
15
|
}
|
|
14
16
|
export declare function assertKnownKeys(value: object, allowed: readonly string[], pointer?: string): void;
|
|
15
17
|
export declare function fail(code: BuilderDiagnosticCode, pointer: string, message: string): never;
|
|
16
|
-
export declare function escapeToken(value: string): string;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formatDiagnostics, orderDiagnostics } from '../../language/validation/diagnostic.js';
|
|
2
|
+
import { escapePointerToken as escapeToken } from '../../language/value/syntax/pointer.js';
|
|
3
|
+
export { escapeToken };
|
|
2
4
|
export function diagnostic(code, pointer, message, ref) {
|
|
3
5
|
return Object.freeze({ code, pointer, message, ...(ref === undefined ? {} : { ref }) });
|
|
4
6
|
}
|
|
5
7
|
export class BuilderError extends Error {
|
|
6
8
|
diagnostics;
|
|
7
9
|
constructor(diagnostics) {
|
|
8
|
-
const ordered =
|
|
9
|
-
|
|
10
|
-
compareUnicode(left.message, right.message));
|
|
11
|
-
super(ordered
|
|
12
|
-
.map(({ code, pointer, message }) => `${pointer || '/'} [${code}] ${message}`)
|
|
13
|
-
.join('\n'));
|
|
10
|
+
const ordered = orderDiagnostics(diagnostics);
|
|
11
|
+
super(formatDiagnostics(ordered));
|
|
14
12
|
this.name = 'BuilderError';
|
|
15
13
|
this.diagnostics = Object.freeze(ordered);
|
|
16
14
|
}
|
|
@@ -26,6 +24,3 @@ export function assertKnownKeys(value, allowed, pointer = '') {
|
|
|
26
24
|
export function fail(code, pointer, message) {
|
|
27
25
|
throw new BuilderError([diagnostic(code, pointer, message)]);
|
|
28
26
|
}
|
|
29
|
-
export function escapeToken(value) {
|
|
30
|
-
return value.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
31
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { PropertyProjection, MethodProjection, FunctionProjection, ClassProjection,
|
|
1
|
+
export type { PropertyProjection, MethodProjection, FunctionProjection, ClassProjection, } from './projection/model.js';
|
|
2
2
|
export type { ResolvedDomainOfInput } from './projection/domain.js';
|
|
3
3
|
export type { CoreNamedPropertyInput, CorePropertyInput } from './projection/core-input.js';
|
|
4
4
|
export type { ClassProjectionOfResolved } from './projection/resolved-class.js';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { type FullMatch } from '../../language/value/syntax/full-match.js';
|
|
2
|
-
export { fullMatchSource, type FullMatch } from '../../language/value/syntax/full-match.js';
|
|
3
2
|
/** Authoring facade preserving the Builder-owned diagnostic for invalid source syntax. */
|
|
4
3
|
export declare function fullMatch(source: string): FullMatch;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { refuseIRegexp, stateBudgetMessage } from '../../language/value/regexp/syntax.js';
|
|
2
2
|
import { fullMatch as languageFullMatch, } from '../../language/value/syntax/full-match.js';
|
|
3
3
|
import { fail } from '../schema/diagnostic.js';
|
|
4
|
-
export { fullMatchSource } from '../../language/value/syntax/full-match.js';
|
|
5
4
|
/** Authoring facade preserving the Builder-owned diagnostic for invalid source syntax. */
|
|
6
5
|
export function fullMatch(source) {
|
|
7
6
|
const refusal = refuseIRegexp(source);
|
package/dist/v1/bundle/codec.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { accept as acceptJsonValue, BoundaryError as JsonBoundaryError, json, } from '@astrale-os/kernel-dsl/value';
|
|
2
2
|
import { dependencyLimits } from '../addressing/domain-dependency.js';
|
|
3
3
|
import { compareUnicode } from '../addressing/ordering.js';
|
|
4
|
+
import { escapePointerToken } from '../language/value/syntax/pointer.js';
|
|
4
5
|
import { acceptDomainSchema } from '../schema/admission/accept.js';
|
|
5
6
|
import { canonicalDomainSchemaAfterValidation } from '../schema/canonical/revision.js';
|
|
6
7
|
import { revisionOfDomainSchema } from '../schema/canonical/revision.js';
|
|
@@ -9,9 +10,6 @@ import { SchemaError } from '../schema/diagnostic.js';
|
|
|
9
10
|
import { BundleError, diagnostic } from './diagnostic.js';
|
|
10
11
|
import { asDomainSchemaBundle, } from './model.js';
|
|
11
12
|
import { parseDomainSchemaBundleStructure } from './structure.js';
|
|
12
|
-
function escapeToken(value) {
|
|
13
|
-
return value.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
14
|
-
}
|
|
15
13
|
export function acceptDomainSchemaBundle(input) {
|
|
16
14
|
let admitted;
|
|
17
15
|
try {
|
|
@@ -136,7 +134,7 @@ function collectReachable(current, root, candidates, reachable, active, revision
|
|
|
136
134
|
return;
|
|
137
135
|
}
|
|
138
136
|
for (const [alias, dependency] of Object.entries(current.schema.dependencies)) {
|
|
139
|
-
const pointer = `${current.pointer}/dependencies/${
|
|
137
|
+
const pointer = `${current.pointer}/dependencies/${escapePointerToken(alias)}`;
|
|
140
138
|
const dependencyKey = keyOf(dependency.origin, dependency.revision);
|
|
141
139
|
if (dependencyKey === root.key) {
|
|
142
140
|
diagnostics.push(diagnostic('BUNDLE_CLOSURE_CYCLE', pointer, 'Bundle dependency closure returns to its root.'));
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formatDiagnostics, orderDiagnostics } from '../language/validation/diagnostic.js';
|
|
2
2
|
export function diagnostic(code, pointer, message, ref) {
|
|
3
3
|
return Object.freeze({ code, pointer, message, ...(ref === undefined ? {} : { ref }) });
|
|
4
4
|
}
|
|
5
5
|
export class BundleError extends Error {
|
|
6
6
|
diagnostics;
|
|
7
7
|
constructor(diagnostics) {
|
|
8
|
-
const ordered =
|
|
9
|
-
|
|
10
|
-
compareUnicode(left.message, right.message));
|
|
11
|
-
super(ordered
|
|
12
|
-
.map(({ code, pointer, message }) => `${pointer || '/'} [${code}] ${message}`)
|
|
13
|
-
.join('\n'));
|
|
8
|
+
const ordered = orderDiagnostics(diagnostics);
|
|
9
|
+
super(formatDiagnostics(ordered));
|
|
14
10
|
this.name = 'BundleError';
|
|
15
11
|
this.diagnostics = Object.freeze(ordered);
|
|
16
12
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { escapePointerToken } from '../language/value/syntax/pointer.js';
|
|
1
2
|
import { SchemaError } from '../schema/diagnostic.js';
|
|
2
3
|
import { routeDomainSchema } from '../schema/validation/domain.route.js';
|
|
3
4
|
import { BundleError, diagnostic } from './diagnostic.js';
|
|
@@ -12,7 +13,7 @@ export function parseDomainSchemaBundleStructure(input) {
|
|
|
12
13
|
const expected = new Set(['format', 'version', 'root', 'closure']);
|
|
13
14
|
for (const key of Object.keys(input)) {
|
|
14
15
|
if (!expected.has(key)) {
|
|
15
|
-
diagnostics.push(diagnostic('BUNDLE_STRUCTURE', `/${
|
|
16
|
+
diagnostics.push(diagnostic('BUNDLE_STRUCTURE', `/${escapePointerToken(key)}`, `Unknown bundle field ${key}.`));
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
for (const key of expected) {
|
|
@@ -66,6 +67,3 @@ function isObject(value) {
|
|
|
66
67
|
function describe(value) {
|
|
67
68
|
return value === undefined ? '(missing)' : JSON.stringify(value);
|
|
68
69
|
}
|
|
69
|
-
function escapeToken(value) {
|
|
70
|
-
return value.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
71
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CompiledDiagnosticCode } from '../diagnostic.js';
|
|
2
2
|
/** Append one escaped JSON Pointer segment. */
|
|
3
|
-
export
|
|
3
|
+
export { appendPointer as pointer } from '../../language/value/syntax/pointer.js';
|
|
4
4
|
/** Report a structural compiled-input violation with its stable diagnostic code. */
|
|
5
5
|
export declare function invalid(label: string, code?: CompiledDiagnosticCode, path?: string): never;
|
|
6
6
|
/** Report a contextual compiled-language violation at its original source pointer. */
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { invalidCompiled } from '../diagnostic.js';
|
|
2
2
|
/** Append one escaped JSON Pointer segment. */
|
|
3
|
-
export
|
|
4
|
-
return `${parent}/${String(member).replaceAll('~', '~0').replaceAll('/', '~1')}`;
|
|
5
|
-
}
|
|
3
|
+
export { appendPointer as pointer } from '../../language/value/syntax/pointer.js';
|
|
6
4
|
/** Report a structural compiled-input violation with its stable diagnostic code. */
|
|
7
5
|
export function invalid(label, code = 'COMPILED_STRUCTURE_INVALID', path = '') {
|
|
8
6
|
return invalidCompiled(code, `Invalid compiled Schema ${label}.`, path);
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { Revision } from '../../addressing/index.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { FunctionDefinition, MethodDefinition } from '../../language/callable/model/callable.js';
|
|
3
|
+
import type { JsonSchema } from '../../language/value/model/schema.js';
|
|
4
|
+
import type { CompiledFunction, CompiledMethod, CompiledSchemaEntry } from '../model/schema.js';
|
|
3
5
|
/** Derive the exact canonical source-revision preimage without constructing an authored Schema. */
|
|
4
6
|
export declare function revisionOfCompiledEntry(entry: CompiledSchemaEntry): Revision;
|
|
7
|
+
/** The source definition of a compiled Method: its value programs back to their schemas. */
|
|
8
|
+
export declare function sourceMethod(entry: CompiledSchemaEntry, method: CompiledMethod): MethodDefinition;
|
|
9
|
+
/** The source definition of a compiled Function: its value programs back to their schemas. */
|
|
10
|
+
export declare function sourceFunction(entry: CompiledSchemaEntry, definition: CompiledFunction): FunctionDefinition;
|
|
11
|
+
/** The schema of the root node of the entry's value program `index`. */
|
|
12
|
+
export declare function schemaOf(entry: CompiledSchemaEntry, index: number): JsonSchema;
|
|
@@ -44,7 +44,8 @@ function sourceClass(entry, definition) {
|
|
|
44
44
|
methods: Object.fromEntries(methods.map((method) => [method.name, sourceMethod(entry, method)])),
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
/** The source definition of a compiled Method: its value programs back to their schemas. */
|
|
48
|
+
export function sourceMethod(entry, method) {
|
|
48
49
|
const { name: _, input, fields: __, output, ...rest } = method;
|
|
49
50
|
return {
|
|
50
51
|
...rest,
|
|
@@ -52,7 +53,8 @@ function sourceMethod(entry, method) {
|
|
|
52
53
|
output: sourceOutput(entry, output),
|
|
53
54
|
};
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
/** The source definition of a compiled Function: its value programs back to their schemas. */
|
|
57
|
+
export function sourceFunction(entry, definition) {
|
|
56
58
|
const { input, fields: _, output, ...rest } = definition;
|
|
57
59
|
return {
|
|
58
60
|
...rest,
|
|
@@ -72,7 +74,8 @@ function sourceOutput(entry, output) {
|
|
|
72
74
|
const schema = schemaOf(entry, output.value);
|
|
73
75
|
return output.mode === 'value' ? { mode: 'value', schema } : { mode: 'stream', item: schema };
|
|
74
76
|
}
|
|
75
|
-
|
|
77
|
+
/** The schema of the root node of the entry's value program `index`. */
|
|
78
|
+
export function schemaOf(entry, index) {
|
|
76
79
|
const program = entry.values[index];
|
|
77
80
|
const root = program?.nodes[program.root];
|
|
78
81
|
if (root === undefined)
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type Located, type CompiledClass, type ClassAnalysis, type SemanticIndex } from './context.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Compose inherited Properties, Methods and Data ownership once per Class. The closure check has
|
|
4
|
+
* already proved every parent present and the inheritance graph acyclic.
|
|
5
|
+
*/
|
|
3
6
|
export declare function analyzeClasses(classes: ReadonlyMap<string, Located<CompiledClass>>): ReadonlyMap<string, ClassAnalysis>;
|
|
4
7
|
/** Check automatic Properties, immutability and abstract Class obligations. */
|
|
5
8
|
export declare function validateClassFacets(context: SemanticIndex): void;
|
|
@@ -7,22 +7,19 @@ import { bindValueProgram } from '../../../language/value/compile/load.js';
|
|
|
7
7
|
import {} from '../../model/schema.js';
|
|
8
8
|
import { fail } from '../diagnostic.js';
|
|
9
9
|
import {} from './context.js';
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Compose inherited Properties, Methods and Data ownership once per Class. The closure check has
|
|
12
|
+
* already proved every parent present and the inheritance graph acyclic.
|
|
13
|
+
*/
|
|
11
14
|
export function analyzeClasses(classes) {
|
|
12
15
|
const analyses = new Map();
|
|
13
|
-
const visiting = new Set();
|
|
14
16
|
const analyze = (located) => {
|
|
15
17
|
const classKey = Key.of(located.value.ref);
|
|
16
18
|
const cached = analyses.get(classKey);
|
|
17
19
|
if (cached !== undefined)
|
|
18
20
|
return cached;
|
|
19
|
-
if (visiting.has(classKey))
|
|
20
|
-
fail(`${located.pointer}/extends`, 'Class inheritance is cyclic.');
|
|
21
|
-
visiting.add(classKey);
|
|
22
21
|
const parents = located.value.extends.map((ref, index) => {
|
|
23
22
|
const parent = classes.get(Key.of(ref));
|
|
24
|
-
if (parent === undefined)
|
|
25
|
-
fail(`${located.pointer}/extends/${index}`, 'Parent Class is absent.');
|
|
26
23
|
if (parent.value.inheritance === 'final')
|
|
27
24
|
fail(`${located.pointer}/extends/${index}`, 'A final Class has no subclass.');
|
|
28
25
|
return analyze(parent);
|
|
@@ -71,7 +68,6 @@ export function analyzeClasses(classes) {
|
|
|
71
68
|
...(dataOwner === undefined ? {} : { dataOwner }),
|
|
72
69
|
};
|
|
73
70
|
analyses.set(classKey, analysis);
|
|
74
|
-
visiting.delete(classKey);
|
|
75
71
|
return analysis;
|
|
76
72
|
};
|
|
77
73
|
for (const value of classes.values())
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { type ClassRef } from '../../../addressing/index.js';
|
|
2
|
-
import { type CoreEdge } from '../../../language/core/model/core.js';
|
|
3
1
|
import { type CompiledSchemaEntry, type CompiledSchema } from '../../model/schema.js';
|
|
4
|
-
import { type Located, type CompiledClass, type ClassAnalysis, type
|
|
2
|
+
import { type Located, type CompiledClass, type ClassAnalysis, type SemanticIndex } from './context.js';
|
|
5
3
|
/** A local Core Node paired with its admitted Class analysis. */
|
|
6
4
|
export interface CoreNode {
|
|
7
5
|
readonly key: string;
|
|
@@ -10,26 +8,5 @@ export interface CoreNode {
|
|
|
10
8
|
readonly analysis: ClassAnalysis;
|
|
11
9
|
readonly pointer: string;
|
|
12
10
|
}
|
|
13
|
-
/**
|
|
14
|
-
* A local Definition other than a Core Node, or a Class-owned Method. The Domain projects it as a
|
|
15
|
-
* Kernel declaration Node, so `class` names that Kernel Class rather than an authored one.
|
|
16
|
-
*/
|
|
17
|
-
interface CoreMemberEndpoint {
|
|
18
|
-
readonly key: string;
|
|
19
|
-
readonly class: ClassRef;
|
|
20
|
-
readonly pointer: string;
|
|
21
|
-
}
|
|
22
|
-
type CoreEndpoint = CoreNode | CoreMemberEndpoint | {
|
|
23
|
-
readonly key: 'domain';
|
|
24
|
-
};
|
|
25
|
-
/** A Core Edge paired with resolved endpoints and its exact Class. */
|
|
26
|
-
export interface CoreEdgeValue {
|
|
27
|
-
readonly source: CoreEndpoint;
|
|
28
|
-
readonly target: CoreEndpoint;
|
|
29
|
-
readonly value: CoreEdge;
|
|
30
|
-
readonly class: Located<CompiledEdge>;
|
|
31
|
-
readonly pointer: string;
|
|
32
|
-
}
|
|
33
11
|
/** Admit local Core Nodes, Properties and Edge endpoint contracts. */
|
|
34
12
|
export declare function validateCore(candidate: CompiledSchema, context: SemanticIndex): void;
|
|
35
|
-
export {};
|