@astrale-os/kernel-dsl 1.0.0-beta.26 → 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.
@@ -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
+ }
@@ -111,6 +111,7 @@ function compileEntry(schema, lookup) {
111
111
  origin: schema.origin,
112
112
  revision: revisionOfDomainSchema(schema),
113
113
  name: schema.name,
114
+ ...(schema.icon === undefined ? {} : { icon: schema.icon }),
114
115
  ...(schema.entrypoint === undefined ? {} : { entrypoint: schema.entrypoint }),
115
116
  dependencies: schema.dependencies,
116
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;
@@ -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';
@@ -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
+ }
@@ -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,
@@ -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,
@@ -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. A
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;
@@ -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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/kernel-dsl",
3
- "version": "1.0.0-beta.26",
3
+ "version": "1.0.0-beta.27",
4
4
  "description": "Astrale Kernel DSL - Schema authoring, inference, and IR serialization",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {