@astrale-os/kernel-dsl 1.0.0-beta.25 → 1.0.0-beta.27
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/builder/lowering/schema/compile.js +2 -0
- package/dist/v1/builder/schema/input.d.ts +3 -0
- package/dist/v1/compiled/admission/revision.js +1 -0
- package/dist/v1/compiled/admission/wire/entry.js +29 -1
- package/dist/v1/compiled/compiler/compile.js +5 -12
- package/dist/v1/compiled/model/schema.d.ts +3 -0
- package/dist/v1/index.d.ts +1 -0
- package/dist/v1/language/class/inheritance.js +0 -2
- package/dist/v1/language/definition/metadata.d.ts +33 -0
- package/dist/v1/language/definition/metadata.js +44 -0
- package/dist/v1/language/value/inclusion/assertions.js +7 -8
- package/dist/v1/schema/.spec/schemas/domain-schema.schema.json +36 -0
- 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/dist/v1/schema/diagnostic.d.ts +1 -1
- package/dist/v1/schema/model/schema.d.ts +3 -0
- package/dist/v1/schema/normalization/domain.js +13 -0
- package/dist/v1/schema/rule.d.ts +2 -2
- package/dist/v1/schema/rule.js +6 -0
- package/dist/v1/schema/validation/domain.js +2 -0
- package/dist/v1/schema/validation/domain.structure.d.ts +14 -0
- package/dist/v1/schema/validation/domain.structure.js +15 -0
- package/dist/v1/schema/validation/icon.d.ts +4 -0
- package/dist/v1/schema/validation/icon.js +29 -0
- 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
|
},
|
|
@@ -34,6 +34,7 @@ export function compileSchema(origin, input) {
|
|
|
34
34
|
function assembleDomainSchema(origin, input, lookup) {
|
|
35
35
|
assertKnownKeys(input, [
|
|
36
36
|
'name',
|
|
37
|
+
'icon',
|
|
37
38
|
'entrypoint',
|
|
38
39
|
'dependencies',
|
|
39
40
|
'classes',
|
|
@@ -66,6 +67,7 @@ function assembleDomainSchema(origin, input, lookup) {
|
|
|
66
67
|
version: 'v1',
|
|
67
68
|
origin,
|
|
68
69
|
name: input.name,
|
|
70
|
+
...(input.icon === undefined ? {} : { icon: input.icon }),
|
|
69
71
|
...(input.entrypoint === undefined
|
|
70
72
|
? {}
|
|
71
73
|
: { entrypoint: { origin, kind: 'view', name: input.entrypoint } }),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DomainIcon } from '../../language/definition/metadata.js';
|
|
1
2
|
import type { DomainSchema } from '../../schema/model/schema.js';
|
|
2
3
|
import type { Function } from '../callable/authoring.js';
|
|
3
4
|
import type { Class } from '../class/handle.js';
|
|
@@ -8,6 +9,8 @@ import type { View } from '../view/authoring.js';
|
|
|
8
9
|
export interface DomainSchemaInput {
|
|
9
10
|
/** Display name of the Domain, one trimmed line of 1 to 100 characters. */
|
|
10
11
|
readonly name: string;
|
|
12
|
+
/** Presentation icon: up to three hand-drawn sizes of inline SVG, at least one present. */
|
|
13
|
+
readonly icon?: DomainIcon;
|
|
11
14
|
/** Name of the one declared View this Domain opens by default. */
|
|
12
15
|
readonly entrypoint?: string;
|
|
13
16
|
readonly dependencies?: Readonly<Record<string, DomainSchema<string>>>;
|
|
@@ -10,6 +10,7 @@ function revisionPreimage(entry) {
|
|
|
10
10
|
version: 'v1',
|
|
11
11
|
origin: entry.origin,
|
|
12
12
|
name: entry.name,
|
|
13
|
+
...(entry.icon === undefined ? {} : { icon: entry.icon }),
|
|
13
14
|
...(entry.entrypoint === undefined ? {} : { entrypoint: entry.entrypoint }),
|
|
14
15
|
dependencies: entry.dependencies,
|
|
15
16
|
classes: Object.fromEntries(entry.definitions.classes.map((definition) => [
|
|
@@ -17,13 +17,14 @@ import { compiledView } from './view.js';
|
|
|
17
17
|
/** Decode one closure entry and verify its exact semantic revision. */
|
|
18
18
|
export function entry(input, entryIndex, path, machines) {
|
|
19
19
|
const value = object(input, `closure[${entryIndex}]`, path);
|
|
20
|
-
exact(value, ['origin', 'revision', 'name', 'dependencies', 'definitions', 'facts', 'values'], 'entry', path, ['entrypoint', 'patterns']);
|
|
20
|
+
exact(value, ['origin', 'revision', 'name', 'dependencies', 'definitions', 'facts', 'values'], 'entry', path, ['icon', 'entrypoint', 'patterns']);
|
|
21
21
|
const origin = originValue(value.origin, 'entry origin', `${path}/origin`);
|
|
22
22
|
const name = string(value.name, 'entry name', `${path}/name`);
|
|
23
23
|
if (name.length < metadata.name.minLength ||
|
|
24
24
|
name.length > metadata.name.maxLength ||
|
|
25
25
|
!metadata.isDomainNameText(name))
|
|
26
26
|
invalid('entry name', undefined, `${path}/name`);
|
|
27
|
+
const icon = value.icon === undefined ? undefined : domainIcon(value.icon, `${path}/icon`);
|
|
27
28
|
const entrypoint = value.entrypoint === undefined
|
|
28
29
|
? undefined
|
|
29
30
|
: definitionRef(value.entrypoint, 'view', 'entry entrypoint', `${path}/entrypoint`);
|
|
@@ -56,6 +57,7 @@ export function entry(input, entryIndex, path, machines) {
|
|
|
56
57
|
origin,
|
|
57
58
|
revision,
|
|
58
59
|
name,
|
|
60
|
+
...(icon === undefined ? {} : { icon }),
|
|
59
61
|
...(entrypoint === undefined ? {} : { entrypoint }),
|
|
60
62
|
dependencies,
|
|
61
63
|
definitions: {
|
|
@@ -93,3 +95,29 @@ export function entry(input, entryIndex, path, machines) {
|
|
|
93
95
|
}
|
|
94
96
|
return accepted;
|
|
95
97
|
}
|
|
98
|
+
/** Decode the source Domain icon under the same admission as its source schema (DV_DOMAIN_ICON). */
|
|
99
|
+
function domainIcon(input, path) {
|
|
100
|
+
const value = object(input, 'entry icon', path);
|
|
101
|
+
exact(value, [], 'entry icon', path, metadata.DOMAIN_ICON_SIZES);
|
|
102
|
+
const icon = {};
|
|
103
|
+
for (const size of metadata.DOMAIN_ICON_SIZES) {
|
|
104
|
+
if (value[size] === undefined)
|
|
105
|
+
continue;
|
|
106
|
+
const sizePath = `${path}/${size}`;
|
|
107
|
+
const art = object(value[size], 'entry icon size', sizePath);
|
|
108
|
+
exact(art, ['svg'], 'entry icon size', sizePath, ['dark']);
|
|
109
|
+
const drawing = (variant) => {
|
|
110
|
+
const text = string(art[variant], 'entry icon drawing', `${sizePath}/${variant}`);
|
|
111
|
+
if (metadata.domainIconSvgIssue(text, size) !== undefined)
|
|
112
|
+
invalid('entry icon drawing', undefined, `${sizePath}/${variant}`);
|
|
113
|
+
return text;
|
|
114
|
+
};
|
|
115
|
+
icon[size] = {
|
|
116
|
+
svg: drawing('svg'),
|
|
117
|
+
...(art.dark === undefined ? {} : { dark: drawing('dark') }),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
if (Object.keys(icon).length === 0)
|
|
121
|
+
invalid('entry icon', undefined, path);
|
|
122
|
+
return icon;
|
|
123
|
+
}
|
|
@@ -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`
|
|
@@ -119,6 +111,7 @@ function compileEntry(schema, lookup) {
|
|
|
119
111
|
origin: schema.origin,
|
|
120
112
|
revision: revisionOfDomainSchema(schema),
|
|
121
113
|
name: schema.name,
|
|
114
|
+
...(schema.icon === undefined ? {} : { icon: schema.icon }),
|
|
122
115
|
...(schema.entrypoint === undefined ? {} : { entrypoint: schema.entrypoint }),
|
|
123
116
|
dependencies: schema.dependencies,
|
|
124
117
|
definitions: Object.freeze({
|
|
@@ -5,6 +5,7 @@ import type { MethodDefinition } from '../../language/callable/model/callable.js
|
|
|
5
5
|
import type { ClassDefinition } from '../../language/class/model/class.js';
|
|
6
6
|
import type { PropertyDefinition } from '../../language/class/model/property.js';
|
|
7
7
|
import type { CoreDefinition, CoreEdge } from '../../language/core/model/core.js';
|
|
8
|
+
import type { DomainIcon } from '../../language/definition/metadata.js';
|
|
8
9
|
import type { PolicyDefinition } from '../../language/policy/model/policy.js';
|
|
9
10
|
import type { IndexedValueProgram, Pattern, RunPattern } from '../../language/value/compile/model.js';
|
|
10
11
|
import type { OrderingKind } from '../../language/value/ordering.js';
|
|
@@ -55,6 +56,8 @@ export interface CompiledSchemaEntry {
|
|
|
55
56
|
readonly revision: Revision;
|
|
56
57
|
/** The source Domain display name. */
|
|
57
58
|
readonly name: string;
|
|
59
|
+
/** The source Domain presentation icon. */
|
|
60
|
+
readonly icon?: DomainIcon;
|
|
58
61
|
/** The source Domain entrypoint View. */
|
|
59
62
|
readonly entrypoint?: ViewRef;
|
|
60
63
|
readonly dependencies: DomainDependencyMap;
|
package/dist/v1/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { isBinaryInput } from './language/callable/model/callable.js';
|
|
|
5
5
|
export type { EventOf, StateMachine, StateOf } from './language/state/index.js';
|
|
6
6
|
export { PropertyValues } from './language/index.js';
|
|
7
7
|
export * as metadata from './language/definition/metadata.js';
|
|
8
|
+
export type { DomainIcon, DomainIconArt } from './language/definition/metadata.js';
|
|
8
9
|
export type { AnyResolvedClass, BoundMethodOf, BoundMethodShortcutsOf, CallableResultOf, CallableInputOf, CallableInputModeOf, CallableOutputOf, ClassSatisfactionKeysOf, ClassDefinition, CoreDefinition, CoreEdge, FunctionAuth, FunctionDefinition, Inheritance, BinaryInput, BinaryInputProjection, CallableInputContract, MethodDefinition, MethodOwnerKeyOf, CallablePolicy, ClassPolicy, ClassRuleChecks, ClassRuleObject, ClassWritePolicy, CreateRuleChecks, EdgeClassPolicy, EdgeClassWritePolicy, EdgeRuleChecks, NodeClassCreatePolicy, NodeClassPolicy, NodeClassWritePolicy, PolicyCheckExpression, PolicyDefinition, PropertyImmutability, PropertyInputOf, PropertyAccessOf, PropertyOutputOf, PropertyShortcutsOf, PropertyValuesOf, ResolvedClass, ResolvedCoreDefinition, ResolvedCoreEndpoint, ResolvedData, ResolvedFunction, ExecutableMethod, ResolvedMethod, ResolvedMethodCollection, ResolvedPolicy, ResolvedProperty, ResolvedView, MethodAccessOf, SelfMethodsOf, SelfPropertiesOf, SelfStaticMethodsOf, StaticMethodsOf, ViewDefinition, } from './language/index.js';
|
|
9
10
|
export { acceptDefinitionRef, callableAddress, ClassKey, equalDefinitionRefs, isDefinitionRef, Key, MethodKey, PropertyKey, } from './addressing/index.js';
|
|
10
11
|
export type { ClassRef, CoreRef, DefinitionBase, DefinitionKey, DefinitionRef, FunctionRef, MethodAddress, PolicyRef, Revision, ViewRef, } from './addressing/index.js';
|
|
@@ -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)
|
|
@@ -23,3 +23,36 @@ export declare function isDomainNameText(value: string): boolean;
|
|
|
23
23
|
* character `trim` removes, spelled out since `\s` differs between regular expression engines.
|
|
24
24
|
*/
|
|
25
25
|
export declare const DOMAIN_NAME_TEXT_PATTERN: RegExp;
|
|
26
|
+
/** One drawing of a Domain icon size: inline SVG text, with an optional dark-theme variant. */
|
|
27
|
+
export interface DomainIconArt {
|
|
28
|
+
/** The light-theme drawing, always present. */
|
|
29
|
+
readonly svg: string;
|
|
30
|
+
/** The dark-theme drawing, when the Domain draws one. */
|
|
31
|
+
readonly dark?: string;
|
|
32
|
+
}
|
|
33
|
+
/** A Domain presentation icon: up to three hand-drawn sizes, at least one present. */
|
|
34
|
+
export interface DomainIcon {
|
|
35
|
+
/** Drawn for 16 to 24 px, on a 24 x 24 artboard. */
|
|
36
|
+
readonly small?: DomainIconArt;
|
|
37
|
+
/** Drawn for 28 to 96 px, on a 64 x 64 artboard. */
|
|
38
|
+
readonly medium?: DomainIconArt;
|
|
39
|
+
/** Drawn for 128 px and more, on a 512 x 512 artboard. */
|
|
40
|
+
readonly large?: DomainIconArt;
|
|
41
|
+
}
|
|
42
|
+
/** The sizes of a Domain icon, smallest first: the canonical order of its members. */
|
|
43
|
+
export declare const DOMAIN_ICON_SIZES: readonly ["small", "medium", "large"];
|
|
44
|
+
/** A Domain icon size. */
|
|
45
|
+
export type DomainIconSize = (typeof DOMAIN_ICON_SIZES)[number];
|
|
46
|
+
/** Exact V1 bound, in bytes of UTF-8, of each SVG text of one Domain icon size. */
|
|
47
|
+
export declare const domainIcon: Readonly<{
|
|
48
|
+
readonly small: 8192;
|
|
49
|
+
readonly medium: 32768;
|
|
50
|
+
readonly large: 262144;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Why one SVG text is no admissible Domain icon drawing of `size`, or undefined when it is one:
|
|
54
|
+
* within the size's UTF-8 bound, one complete `<svg>` root with a visible vector element, no
|
|
55
|
+
* executable, external or styling content, and no `url(` but a local `url(#id)`. A lexical check,
|
|
56
|
+
* not a parser: a Shell renders the drawing only as an image, never inline.
|
|
57
|
+
*/
|
|
58
|
+
export declare function domainIconSvgIssue(svg: string, size: DomainIconSize): string | undefined;
|
|
@@ -29,3 +29,47 @@ export function isDomainNameText(value) {
|
|
|
29
29
|
export const DOMAIN_NAME_TEXT_PATTERN =
|
|
30
30
|
// oxlint-disable-next-line no-control-regex
|
|
31
31
|
/^(?:[^\u0000-\u001f\u007f-\u009f\u0020\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff](?:[^\u0000-\u001f\u007f-\u009f\u2028\u2029]*[^\u0000-\u001f\u007f-\u009f\u0020\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])?)?$/u;
|
|
32
|
+
/** The sizes of a Domain icon, smallest first: the canonical order of its members. */
|
|
33
|
+
export const DOMAIN_ICON_SIZES = Object.freeze(['small', 'medium', 'large']);
|
|
34
|
+
/** Exact V1 bound, in bytes of UTF-8, of each SVG text of one Domain icon size. */
|
|
35
|
+
export const domainIcon = Object.freeze({ small: 8192, medium: 32768, large: 262144 });
|
|
36
|
+
const SVG_ROOT = /^<svg(?:\s[^>]*)?>[\s\S]*<\/svg>$/u;
|
|
37
|
+
const SVG_ROOT_OPEN = /<svg(?:\s|>)/gu;
|
|
38
|
+
const SVG_ROOT_CLOSE = /<\/svg\s*>/gu;
|
|
39
|
+
const SVG_GRAPHIC = /<(?:circle|ellipse|line|path|polygon|polyline|rect)\b/iu;
|
|
40
|
+
const SVG_UNSAFE = /<\s*(?:animate|discard|embed|foreignObject|iframe|image|object|script|set|style|use)\b|<!DOCTYPE\b|<!ENTITY\b|\son[a-z][\w:.-]*\s*=|\sstyle\s*=|(?:href|xlink:href)\s*=|javascript\s*:/iu;
|
|
41
|
+
// The one admitted `url(`: a reference to an element of the same drawing, by its id.
|
|
42
|
+
const SVG_LOCAL_URL = /url\(#[A-Za-z][A-Za-z0-9_-]*\)/gu;
|
|
43
|
+
const SVG_URL = /url\s*\(/iu;
|
|
44
|
+
/**
|
|
45
|
+
* Why one SVG text is no admissible Domain icon drawing of `size`, or undefined when it is one:
|
|
46
|
+
* within the size's UTF-8 bound, one complete `<svg>` root with a visible vector element, no
|
|
47
|
+
* executable, external or styling content, and no `url(` but a local `url(#id)`. A lexical check,
|
|
48
|
+
* not a parser: a Shell renders the drawing only as an image, never inline.
|
|
49
|
+
*/
|
|
50
|
+
export function domainIconSvgIssue(svg, size) {
|
|
51
|
+
const bytes = utf8Length(svg);
|
|
52
|
+
if (bytes === 0)
|
|
53
|
+
return 'is empty';
|
|
54
|
+
if (bytes > domainIcon[size])
|
|
55
|
+
return `exceeds ${domainIcon[size]} bytes of UTF-8`;
|
|
56
|
+
if (!SVG_ROOT.test(svg) ||
|
|
57
|
+
(svg.match(SVG_ROOT_OPEN)?.length ?? 0) !== 1 ||
|
|
58
|
+
(svg.match(SVG_ROOT_CLOSE)?.length ?? 0) !== 1) {
|
|
59
|
+
return 'is not one complete <svg> element';
|
|
60
|
+
}
|
|
61
|
+
if (SVG_UNSAFE.test(svg) || SVG_URL.test(svg.replace(SVG_LOCAL_URL, ''))) {
|
|
62
|
+
return 'holds executable, external or styling content';
|
|
63
|
+
}
|
|
64
|
+
if (!SVG_GRAPHIC.test(svg))
|
|
65
|
+
return 'has no visible vector element';
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
function utf8Length(text) {
|
|
69
|
+
let bytes = 0;
|
|
70
|
+
for (const character of text) {
|
|
71
|
+
const point = character.codePointAt(0);
|
|
72
|
+
bytes += point < 0x80 ? 1 : point < 0x800 ? 2 : point < 0x10000 ? 3 : 4;
|
|
73
|
+
}
|
|
74
|
+
return bytes;
|
|
75
|
+
}
|
|
@@ -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
|
}
|
|
@@ -118,6 +118,9 @@
|
|
|
118
118
|
"name": {
|
|
119
119
|
"$ref": "#/$defs/domain-name"
|
|
120
120
|
},
|
|
121
|
+
"icon": {
|
|
122
|
+
"$ref": "#/$defs/domain-icon"
|
|
123
|
+
},
|
|
121
124
|
"entrypoint": {
|
|
122
125
|
"$ref": "#/$defs/view-ref"
|
|
123
126
|
},
|
|
@@ -833,6 +836,39 @@
|
|
|
833
836
|
],
|
|
834
837
|
"additionalProperties": false
|
|
835
838
|
},
|
|
839
|
+
"domain-icon": {
|
|
840
|
+
"type": "object",
|
|
841
|
+
"properties": {
|
|
842
|
+
"small": {
|
|
843
|
+
"$ref": "#/$defs/domain-icon-art"
|
|
844
|
+
},
|
|
845
|
+
"medium": {
|
|
846
|
+
"$ref": "#/$defs/domain-icon-art"
|
|
847
|
+
},
|
|
848
|
+
"large": {
|
|
849
|
+
"$ref": "#/$defs/domain-icon-art"
|
|
850
|
+
}
|
|
851
|
+
},
|
|
852
|
+
"additionalProperties": false,
|
|
853
|
+
"description": "The presentation icon of the Domain: up to three hand-drawn sizes of inline SVG."
|
|
854
|
+
},
|
|
855
|
+
"domain-icon-art": {
|
|
856
|
+
"type": "object",
|
|
857
|
+
"properties": {
|
|
858
|
+
"svg": {
|
|
859
|
+
"type": "string",
|
|
860
|
+
"minLength": 1
|
|
861
|
+
},
|
|
862
|
+
"dark": {
|
|
863
|
+
"type": "string",
|
|
864
|
+
"minLength": 1
|
|
865
|
+
}
|
|
866
|
+
},
|
|
867
|
+
"required": [
|
|
868
|
+
"svg"
|
|
869
|
+
],
|
|
870
|
+
"additionalProperties": false
|
|
871
|
+
},
|
|
836
872
|
"domain-name": {
|
|
837
873
|
"type": "string",
|
|
838
874
|
"minLength": 1,
|
|
@@ -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',
|
|
@@ -2,7 +2,7 @@ import type { DiagnosticCode as LanguageDiagnosticCode } from '../language/valid
|
|
|
2
2
|
import type { Diagnostic as LanguageDiagnostic } from '../language/validation/diagnostic.js';
|
|
3
3
|
import type { DiagnosticCode as CompatibilityDiagnosticCode } from './compatibility/model.js';
|
|
4
4
|
/** The codes a Schema document is refused with, one per rule of `RULES`. */
|
|
5
|
-
export type SchemaDiagnosticCode = 'DV_ACCEPTANCE_CONTEXT' | 'DV_CALLABLE_ADMISSION' | 'DV_CALLABLE_AUTH' | 'DV_CALLABLE_IO' | 'DV_CLASS_ABSTRACT' | 'DV_CLASS_ACYCLIC' | 'DV_CLASS_INHERITANCE' | 'DV_CLASS_KIND' | 'DV_CORE_EDGE_CLASS' | 'DV_CORE_EDGE_CONSTRAINTS' | 'DV_CORE_EDGE_KEY' | 'DV_CORE_EDGE_PROPERTIES' | 'DV_CORE_EDGE_UNIQUE' | 'DV_CORE_NODE_CLASS' | 'DV_CORE_NODE_PROPERTIES' | 'DV_CORE_NODE_UNIQUE' | 'DV_CORE_REF' | 'DV_DATA_COMPOSITION' | 'DV_DEPENDENCY_ACYCLIC' | 'DV_DEPENDENCY_DIRECT' | 'DV_DEPENDENCY_EXACT' | 'DV_DEPENDENCY_LIMITS' | 'DV_DEPENDENCY_REVISION_COHERENCE' | 'DV_DEPENDENCY_UNIQUE' | 'DV_EDGE_ACCEPTS' | 'DV_EDGE_CLASS_COMPOSITION' | 'DV_EDGE_FOREIGN_MINIMUM' | 'DV_EDGE_LIFETIME' | 'DV_EDGE_ROLE' | 'DV_EDGE_UNIQUE' | 'DV_ENTRYPOINT' | 'DV_INHERITANCE_LIMITS' | 'DV_JSON_VALUE' | 'DV_METHOD_ABSTRACT' | 'DV_METHOD_COMPOSITION' | 'DV_NODE_UNIQUE' | 'DV_PROPERTY_AUTO' | 'DV_PROPERTY_IMMUTABLE' | 'DV_PROPERTY_STATE' | 'DV_REF_RESOLVES' | 'DV_VALUE_SCHEMA' | 'PL_BUDGET' | 'PL_COMPOSITION' | 'PL_CONNECTIVITY' | 'PL_REF' | 'PL_REPEAT' | 'PL_TARGET' | 'PL_TYPING' | 'PL_USE' | 'PL_VARIABLE_SCOPE' | 'STRUCTURE_BINARY_INPUT' | 'STRUCTURE_CALLABLE_POLICY_AUTH' | 'STRUCTURE_DEPENDENCY_ALIAS' | 'STRUCTURE_DOMAIN_NAME' | 'STRUCTURE_DUPLICATE_ITEM' | 'STRUCTURE_EDGE_BLOB' | 'STRUCTURE_EDGE_ORIENTATION' | 'STRUCTURE_FORMAT' | 'STRUCTURE_KEY' | 'STRUCTURE_MAXIMUM' | 'STRUCTURE_MINIMUM' | 'STRUCTURE_PROPERTY_KEY' | 'STRUCTURE_PROTO_KEY' | 'STRUCTURE_REQUIRED' | 'STRUCTURE_STATE_TRANSITIONS' | 'STRUCTURE_TYPE' | 'STRUCTURE_UNION' | 'STRUCTURE_UNKNOWN_FIELD' | 'STRUCTURE_VALUE' | 'UNSUPPORTED_DOCUMENT_FORMAT' | 'UNSUPPORTED_DSL_VERSION';
|
|
5
|
+
export type SchemaDiagnosticCode = 'DV_ACCEPTANCE_CONTEXT' | 'DV_CALLABLE_ADMISSION' | 'DV_CALLABLE_AUTH' | 'DV_CALLABLE_IO' | 'DV_CLASS_ABSTRACT' | 'DV_CLASS_ACYCLIC' | 'DV_CLASS_INHERITANCE' | 'DV_CLASS_KIND' | 'DV_CORE_EDGE_CLASS' | 'DV_CORE_EDGE_CONSTRAINTS' | 'DV_CORE_EDGE_KEY' | 'DV_CORE_EDGE_PROPERTIES' | 'DV_CORE_EDGE_UNIQUE' | 'DV_CORE_NODE_CLASS' | 'DV_CORE_NODE_PROPERTIES' | 'DV_CORE_NODE_UNIQUE' | 'DV_CORE_REF' | 'DV_DATA_COMPOSITION' | 'DV_DEPENDENCY_ACYCLIC' | 'DV_DEPENDENCY_DIRECT' | 'DV_DEPENDENCY_EXACT' | 'DV_DEPENDENCY_LIMITS' | 'DV_DEPENDENCY_REVISION_COHERENCE' | 'DV_DEPENDENCY_UNIQUE' | 'DV_DOMAIN_ICON' | 'DV_EDGE_ACCEPTS' | 'DV_EDGE_CLASS_COMPOSITION' | 'DV_EDGE_FOREIGN_MINIMUM' | 'DV_EDGE_LIFETIME' | 'DV_EDGE_ROLE' | 'DV_EDGE_UNIQUE' | 'DV_ENTRYPOINT' | 'DV_INHERITANCE_LIMITS' | 'DV_JSON_VALUE' | 'DV_METHOD_ABSTRACT' | 'DV_METHOD_COMPOSITION' | 'DV_NODE_UNIQUE' | 'DV_PROPERTY_AUTO' | 'DV_PROPERTY_IMMUTABLE' | 'DV_PROPERTY_STATE' | 'DV_REF_RESOLVES' | 'DV_VALUE_SCHEMA' | 'PL_BUDGET' | 'PL_COMPOSITION' | 'PL_CONNECTIVITY' | 'PL_REF' | 'PL_REPEAT' | 'PL_TARGET' | 'PL_TYPING' | 'PL_USE' | 'PL_VARIABLE_SCOPE' | 'STRUCTURE_BINARY_INPUT' | 'STRUCTURE_CALLABLE_POLICY_AUTH' | 'STRUCTURE_DEPENDENCY_ALIAS' | 'STRUCTURE_DOMAIN_NAME' | 'STRUCTURE_DUPLICATE_ITEM' | 'STRUCTURE_EDGE_BLOB' | 'STRUCTURE_EDGE_ORIENTATION' | 'STRUCTURE_FORMAT' | 'STRUCTURE_KEY' | 'STRUCTURE_MAXIMUM' | 'STRUCTURE_MINIMUM' | 'STRUCTURE_PROPERTY_KEY' | 'STRUCTURE_PROTO_KEY' | 'STRUCTURE_REQUIRED' | 'STRUCTURE_STATE_TRANSITIONS' | 'STRUCTURE_TYPE' | 'STRUCTURE_UNION' | 'STRUCTURE_UNKNOWN_FIELD' | 'STRUCTURE_VALUE' | 'UNSUPPORTED_DOCUMENT_FORMAT' | 'UNSUPPORTED_DSL_VERSION';
|
|
6
6
|
/**
|
|
7
7
|
* A Schema refuses a document with its own codes, and a comparison request with the
|
|
8
8
|
* compatibility codes. `pointer` names the position the refused rule applies to, in the document
|
|
@@ -6,6 +6,7 @@ import type { FunctionDefinition } from '../../language/callable/model/callable.
|
|
|
6
6
|
import type { ClassDefinition } from '../../language/class/model/class.js';
|
|
7
7
|
import type { PropertyValues } from '../../language/class/property-values.js';
|
|
8
8
|
import type { CoreContent } from '../../language/core/model/core.js';
|
|
9
|
+
import type { DomainIcon } from '../../language/definition/metadata.js';
|
|
9
10
|
import type { PolicyDefinition } from '../../language/policy/model/policy.js';
|
|
10
11
|
import type { ViewDefinition } from '../../language/view/model/view.js';
|
|
11
12
|
export interface DomainSchemaIR {
|
|
@@ -14,6 +15,8 @@ export interface DomainSchemaIR {
|
|
|
14
15
|
readonly origin: Key.Origin;
|
|
15
16
|
/** Human-facing display name of the Domain, projected as its Domain Node `name`. */
|
|
16
17
|
readonly name: string;
|
|
18
|
+
/** Presentation icon of the Domain, projected as its Domain Node `iconSmall`, `iconMedium` and `iconLarge`. */
|
|
19
|
+
readonly icon?: DomainIcon;
|
|
17
20
|
/** The one View this Domain opens by default, projected as its `entrypoint` Edge. */
|
|
18
21
|
readonly entrypoint?: ViewRef;
|
|
19
22
|
readonly dependencies: DomainDependencyMap;
|
|
@@ -2,6 +2,7 @@ import { json } from '@astrale-os/kernel-dsl/value';
|
|
|
2
2
|
import { compareDefinitionRefs, compareUnicode } from '../../addressing/ordering.js';
|
|
3
3
|
import { isBinaryInput } from '../../language/callable/model/callable.js';
|
|
4
4
|
import { compareEdgeUniqueFields, compareEdgeUniqueTuples, compareNodeUniqueTuples, } from '../../language/class/unique.js';
|
|
5
|
+
import { DOMAIN_ICON_SIZES } from '../../language/definition/metadata.js';
|
|
5
6
|
import { CLASS_OPERATIONS } from '../../language/policy/model/policy.js';
|
|
6
7
|
import { normalizeClassRule, normalizePolicyChecks, normalizePolicyExpression, } from '../../language/policy/normalization/normalize.js';
|
|
7
8
|
import { canonicalizeValueSchema } from '../../language/value/profile/canonicalize.js';
|
|
@@ -15,6 +16,7 @@ export function normalizeDomainSchema(schema) {
|
|
|
15
16
|
version: 'v1',
|
|
16
17
|
origin: schema.origin,
|
|
17
18
|
name: schema.name,
|
|
19
|
+
...(schema.icon === undefined ? {} : { icon: canonicalizeDomainIcon(schema.icon) }),
|
|
18
20
|
...(schema.entrypoint === undefined
|
|
19
21
|
? {}
|
|
20
22
|
: {
|
|
@@ -42,6 +44,17 @@ export function normalizeDomainSchema(schema) {
|
|
|
42
44
|
};
|
|
43
45
|
return copyJsonValue(normalized);
|
|
44
46
|
}
|
|
47
|
+
/** Sizes smallest first, and each drawing as `svg` then `dark`: one icon has one canonical form. */
|
|
48
|
+
function canonicalizeDomainIcon(icon) {
|
|
49
|
+
const canonical = {};
|
|
50
|
+
for (const size of DOMAIN_ICON_SIZES) {
|
|
51
|
+
const art = icon[size];
|
|
52
|
+
if (art === undefined)
|
|
53
|
+
continue;
|
|
54
|
+
canonical[size] = { svg: art.svg, ...(art.dark === undefined ? {} : { dark: art.dark }) };
|
|
55
|
+
}
|
|
56
|
+
return canonical;
|
|
57
|
+
}
|
|
45
58
|
function canonicalizePolicy(value) {
|
|
46
59
|
return {
|
|
47
60
|
ref: value.ref,
|
package/dist/v1/schema/rule.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ export type SchemaRuleStage = 'structure' | 'rule' | 'context';
|
|
|
11
11
|
/**
|
|
12
12
|
* The rule one Schema diagnostic code reports. A final `{/path*}` of its positions stands for any
|
|
13
13
|
* further tokens; `{endpoint}` is `source`, `target`, `0` or `1`; `{count}` is `outgoing`,
|
|
14
|
-
* `incoming` or `incident`; `{operation}` is `read` or `traverse`; `{key}` is a Property key
|
|
15
|
-
* condition is a fragment such as `#/$defs/edge-class/if`.
|
|
14
|
+
* `incoming` or `incident`; `{operation}` is `read` or `traverse`; `{key}` is a Property key;
|
|
15
|
+
* `{size}` is `small`, `medium` or `large`. A condition is a fragment such as `#/$defs/edge-class/if`.
|
|
16
16
|
*/
|
|
17
17
|
export interface SchemaRule extends DiagnosticRule {
|
|
18
18
|
readonly stage: SchemaRuleStage;
|
package/dist/v1/schema/rule.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defaultLimits } from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import * as metadata from '../language/definition/metadata.js';
|
|
2
3
|
import { deepFreeze } from '../language/freeze.js';
|
|
3
4
|
import { limits } from '../language/limits.js';
|
|
4
5
|
const ANY = ['{/path*}'];
|
|
@@ -144,6 +145,11 @@ export const RULES = deepFreeze({
|
|
|
144
145
|
positions: ['/dependencies/{alias}/origin'],
|
|
145
146
|
statement: 'A Domain depends on each origin through one alias, and never on its own origin.',
|
|
146
147
|
},
|
|
148
|
+
DV_DOMAIN_ICON: {
|
|
149
|
+
stage: 'rule',
|
|
150
|
+
positions: ['/icon', '/icon/{size}/svg', '/icon/{size}/dark'],
|
|
151
|
+
statement: `A Domain icon draws at least one size, and each of its SVG texts is within the bound of its size in bytes of UTF-8 (small ${count(metadata.domainIcon.small)}, medium ${count(metadata.domainIcon.medium)}, large ${count(metadata.domainIcon.large)}): one complete <svg> element with a visible vector element, no script, foreignObject, iframe, embed, object, image, use, style, animate, set or discard element, no DOCTYPE or ENTITY, no on* or style attribute, no href, no javascript: and no url( but a local url(#id).`,
|
|
152
|
+
},
|
|
147
153
|
DV_EDGE_ACCEPTS: {
|
|
148
154
|
stage: 'context',
|
|
149
155
|
positions: ['/classes/{class}/endpoints/{endpoint}/accepts/{index}'],
|
|
@@ -5,6 +5,7 @@ import { createValueSchemaRegistry } from '../resolution/value.registry.js';
|
|
|
5
5
|
import { validateContracts } from './callable.js';
|
|
6
6
|
import { validateDefinitions } from './class.js';
|
|
7
7
|
import { validateCore } from './core.js';
|
|
8
|
+
import { validateDomainIcon } from './icon.js';
|
|
8
9
|
import { validatePolicies } from './policy/validate.js';
|
|
9
10
|
import { validateEmbeddedValueSchemas } from './value.js';
|
|
10
11
|
import { validateViews } from './view.js';
|
|
@@ -31,6 +32,7 @@ export function validateDomainSchemaSemantics(schema, lookup) {
|
|
|
31
32
|
...validateContracts(schema, registry),
|
|
32
33
|
...validatePolicies(context, analysis),
|
|
33
34
|
...validateViews(context),
|
|
35
|
+
...validateDomainIcon(schema),
|
|
34
36
|
...(readable
|
|
35
37
|
? [
|
|
36
38
|
...validateDefinitions(context, analysis, registry),
|
|
@@ -76,6 +76,20 @@ export declare const domainSchemaStructure: import("zod").ZodObject<{
|
|
|
76
76
|
version: import("zod").ZodLiteral<"v1">;
|
|
77
77
|
origin: import("zod").ZodString;
|
|
78
78
|
name: import("zod").ZodString;
|
|
79
|
+
icon: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
80
|
+
small: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
81
|
+
svg: import("zod").ZodString;
|
|
82
|
+
dark: import("zod").ZodOptional<import("zod").ZodString>;
|
|
83
|
+
}, zodCore.$strict>>;
|
|
84
|
+
medium: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
85
|
+
svg: import("zod").ZodString;
|
|
86
|
+
dark: import("zod").ZodOptional<import("zod").ZodString>;
|
|
87
|
+
}, zodCore.$strict>>;
|
|
88
|
+
large: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
89
|
+
svg: import("zod").ZodString;
|
|
90
|
+
dark: import("zod").ZodOptional<import("zod").ZodString>;
|
|
91
|
+
}, zodCore.$strict>>;
|
|
92
|
+
}, zodCore.$strict>>;
|
|
79
93
|
entrypoint: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
80
94
|
origin: import("zod").ZodString;
|
|
81
95
|
kind: import("zod").ZodLiteral<"view">;
|
|
@@ -77,6 +77,20 @@ const domainNameSchema = boundedString(metadata.name.minLength, metadata.name.ma
|
|
|
77
77
|
description: 'The display name of the Domain: one trimmed line of text.',
|
|
78
78
|
pattern: metadata.DOMAIN_NAME_TEXT_PATTERN.source,
|
|
79
79
|
});
|
|
80
|
+
// The shape of a Domain icon. Its UTF-8 bounds, its SVG grammar and that it draws at least one size
|
|
81
|
+
// are the rule DV_DOMAIN_ICON, which reads each text whole.
|
|
82
|
+
const domainIconArtSchema = strictObject({
|
|
83
|
+
svg: boundedString(1),
|
|
84
|
+
dark: boundedString(1).optional(),
|
|
85
|
+
}).register(documentJsonSchema, { id: 'domain-icon-art' });
|
|
86
|
+
const domainIconSchema = strictObject({
|
|
87
|
+
small: domainIconArtSchema.optional(),
|
|
88
|
+
medium: domainIconArtSchema.optional(),
|
|
89
|
+
large: domainIconArtSchema.optional(),
|
|
90
|
+
}).register(documentJsonSchema, {
|
|
91
|
+
id: 'domain-icon',
|
|
92
|
+
description: 'The presentation icon of the Domain: up to three hand-drawn sizes of inline SVG.',
|
|
93
|
+
});
|
|
80
94
|
// The parsed document cannot keep a `__proto__` member, which the structure therefore refuses: a
|
|
81
95
|
// closed object reports it as an unknown key, and a record, which skips it, by `lostProtoKeys`. The
|
|
82
96
|
// JSON Schema refuses it by the fields of a closed object and the pattern of a record's names; a
|
|
@@ -501,6 +515,7 @@ export const domainSchemaStructure = strictObject({
|
|
|
501
515
|
version: literal(DOMAIN_VERSION),
|
|
502
516
|
origin: originSchema,
|
|
503
517
|
name: domainNameSchema,
|
|
518
|
+
icon: domainIconSchema.optional(),
|
|
504
519
|
entrypoint: viewRefSchema.optional(),
|
|
505
520
|
dependencies: record(dependencyAliasSchema, domainDependencySchema),
|
|
506
521
|
classes: record(memberNameSchema, classDeclarationSchema),
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SchemaDiagnostic } from '../diagnostic.js';
|
|
2
|
+
import type { DomainSchemaIR } from '../model/schema.js';
|
|
3
|
+
/** The Domain icon draws at least one size, each SVG text admissible for its size (DV_DOMAIN_ICON). */
|
|
4
|
+
export declare function validateDomainIcon(schema: DomainSchemaIR): readonly SchemaDiagnostic[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DOMAIN_ICON_SIZES, domainIconSvgIssue } from '../../language/definition/metadata.js';
|
|
2
|
+
import { diagnostic } from '../diagnostic.js';
|
|
3
|
+
/** The Domain icon draws at least one size, each SVG text admissible for its size (DV_DOMAIN_ICON). */
|
|
4
|
+
export function validateDomainIcon(schema) {
|
|
5
|
+
const { icon } = schema;
|
|
6
|
+
if (icon === undefined)
|
|
7
|
+
return Object.freeze([]);
|
|
8
|
+
const diagnostics = [];
|
|
9
|
+
let drawn = 0;
|
|
10
|
+
for (const size of DOMAIN_ICON_SIZES) {
|
|
11
|
+
const art = icon[size];
|
|
12
|
+
if (art === undefined)
|
|
13
|
+
continue;
|
|
14
|
+
drawn += 1;
|
|
15
|
+
for (const variant of ['svg', 'dark']) {
|
|
16
|
+
const text = art[variant];
|
|
17
|
+
if (text === undefined)
|
|
18
|
+
continue;
|
|
19
|
+
const issue = domainIconSvgIssue(text, size);
|
|
20
|
+
if (issue !== undefined) {
|
|
21
|
+
diagnostics.push(diagnostic('DV_DOMAIN_ICON', `/icon/${size}/${variant}`, `Domain icon ${size} ${variant === 'svg' ? 'drawing' : 'dark drawing'} ${issue}.`));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (drawn === 0) {
|
|
26
|
+
diagnostics.push(diagnostic('DV_DOMAIN_ICON', '/icon', 'Domain icon draws no size.'));
|
|
27
|
+
}
|
|
28
|
+
return Object.freeze(diagnostics);
|
|
29
|
+
}
|