@sentropic/design-system-elements 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/LICENSE.THIRD-PARTY.md +4734 -0
- package/README.md +189 -2
- package/catalog.json +1234 -0
- package/dist/browser/assets/bpmn-CZlEAdL6.ttf +0 -0
- package/dist/browser/assets/bpmn-DaGVGZ7K.woff +0 -0
- package/dist/browser/assets/bpmn-DaJ2be00.woff2 +0 -0
- package/dist/browser/chunks/BpmnRenderUtil-WMCgqGDs.js +1 -0
- package/dist/browser/chunks/BpmnUpdater-C-UNbzXl.js +1 -0
- package/dist/browser/chunks/LabelUtil-7QpE43Ed.js +1 -0
- package/dist/browser/chunks/LayoutUtil-hAMJmJFU.js +1 -0
- package/dist/browser/chunks/ModelUtil-CMh7LuN4.js +1 -0
- package/dist/browser/chunks/Modeler-BfAmwsmK.js +389 -0
- package/dist/browser/chunks/Viewer-eYLzc3fD.js +4 -0
- package/dist/browser/chunks/bpmn-canvas-DeAWdJFy.js +2207 -0
- package/dist/browser/chunks/colored-CSIQaGsQ.js +1 -0
- package/dist/browser/chunks/dist-Co2MgHWm.js +1 -0
- package/dist/browser/chunks/dist-O6_2ByYB.js +1 -0
- package/dist/browser/chunks/dist-kvAYI1vo.js +1 -0
- package/dist/browser/chunks/entropic-CM5BHERN.js +2173 -0
- package/dist/browser/chunks/focus-renderer-0elVToA2.js +10 -0
- package/dist/browser/chunks/forge-B8hrW4lA.js +2173 -0
- package/dist/browser/chunks/layout-q0TR9-aY.js +1 -0
- package/dist/browser/chunks/legend-CXdfCBh6.js +1 -0
- package/dist/browser/chunks/textMetrics-BrMS6-sA.js +2 -0
- package/dist/browser/chunks/tokens-DFPpCvf1.js +1 -0
- package/dist/browser/elements.js +2221 -0
- package/dist/browser/sri.json +166 -0
- package/dist/contracts/bar-chart.d.ts +158 -0
- package/dist/contracts/bar-chart.js +117 -0
- package/dist/contracts/bpmn-canvas.d.ts +39 -0
- package/dist/contracts/bpmn-canvas.js +77 -0
- package/dist/contracts/decision-dossier.d.ts +43 -0
- package/dist/contracts/decision-dossier.js +133 -0
- package/dist/contracts/index.d.ts +28 -0
- package/dist/contracts/index.js +35 -0
- package/dist/contracts/types.d.ts +129 -0
- package/dist/contracts/types.js +16 -0
- package/dist/element/f1/f1-to-xml.d.ts +51 -0
- package/dist/element/f1/f1-to-xml.js +220 -0
- package/dist/element/markdown/minimal-markdown.d.ts +31 -0
- package/dist/element/markdown/minimal-markdown.js +98 -0
- package/dist/element/theme/theme-scoping.d.ts +27 -0
- package/dist/element/theme/theme-scoping.js +39 -0
- package/dist/generated/a2ui-common-types.d.ts +25 -0
- package/dist/generated/a2ui-common-types.js +367 -0
- package/dist/generator/canonical.d.ts +21 -0
- package/dist/generator/canonical.js +36 -0
- package/dist/generator/emit.d.ts +48 -0
- package/dist/generator/emit.js +400 -0
- package/dist/generator/main.d.ts +19 -0
- package/dist/generator/main.js +67 -0
- package/dist/generator/parity.d.ts +55 -0
- package/dist/generator/parity.js +223 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +10 -0
- package/dist/ports/bpmn-canvas.d.ts +34 -0
- package/dist/ports/bpmn-canvas.js +36 -0
- package/dist/ports/focus.d.ts +40 -0
- package/dist/ports/focus.js +49 -0
- package/dist/ports/types.d.ts +36 -0
- package/dist/ports/types.js +12 -0
- package/dist/structure/ajv.d.ts +41 -0
- package/dist/structure/ajv.js +108 -0
- package/dist/structure/interpreter.d.ts +47 -0
- package/dist/structure/interpreter.js +576 -0
- package/dist/validate/diagnostics.d.ts +63 -0
- package/dist/validate/diagnostics.js +56 -0
- package/dist/validate/envelope.d.ts +92 -0
- package/dist/validate/envelope.js +306 -0
- package/dist/validate/index.d.ts +22 -0
- package/dist/validate/index.js +24 -0
- package/dist/validate/structure.d.ts +32 -0
- package/dist/validate/structure.js +13 -0
- package/envelope.json +43 -0
- package/package.json +54 -4
- package/schemas/BarChart.v1.json +556 -0
- package/schemas/BpmnCanvas.v1.json +139 -0
- package/schemas/DecisionDossier.v1.json +635 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diagnostics (§4.5): ONE shape for every refusal and warning the render
|
|
3
|
+
* pipeline can produce. `path` is an RFC 6901 JSON Pointer into the ENVELOPE
|
|
4
|
+
* (not into the component's own schema), so a host can always locate the
|
|
5
|
+
* offending value without knowing which layer produced the diagnostic.
|
|
6
|
+
*
|
|
7
|
+
* The ten codes are exactly the §4.5 list — nothing else may appear:
|
|
8
|
+
*
|
|
9
|
+
* unknown-component the envelope's root targets no catalogued entry
|
|
10
|
+
* component-unavailable the entry is a placeholder (x-sentropic.status)
|
|
11
|
+
* unsupported-contract envelope contract newer than the entry's (§4.4)
|
|
12
|
+
* unsupported-mode `preview` is reserved (§10.3)
|
|
13
|
+
* schema-violation structure: envelope or component did not conform
|
|
14
|
+
* semantic-invalid the owning runtime refused the payload (§4.3)
|
|
15
|
+
* payload-too-large over the 1 MiB UTF-8 budget (§4.3 item 3)
|
|
16
|
+
* host-capability-missing the host lacks an environment capability
|
|
17
|
+
* engine-load-failed a lazy engine chunk failed to load
|
|
18
|
+
* watermark-refused engine warning: rendered without the watermark
|
|
19
|
+
*
|
|
20
|
+
* `watermark-refused` is listed so the §4.5 set stays closed; engine
|
|
21
|
+
* warnings surface under their own engine code, and this is the one the
|
|
22
|
+
* spec names.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* A host-environment capability is missing (§4.5 `host-capability-missing`):
|
|
26
|
+
* the host calls this for facts it owns BEFORE the render pipeline runs
|
|
27
|
+
* (a missing canvas, a missing engine chunk before a port exists). The
|
|
28
|
+
* envelope validator produces the same code itself when an injected `lazy:`
|
|
29
|
+
* engine has no port.
|
|
30
|
+
*/
|
|
31
|
+
export function hostCapabilityMissing(capability) {
|
|
32
|
+
return {
|
|
33
|
+
code: "host-capability-missing",
|
|
34
|
+
path: "",
|
|
35
|
+
message: `the host environment is missing a required capability: ${capability}`,
|
|
36
|
+
severity: "error",
|
|
37
|
+
source: "host",
|
|
38
|
+
detail: { capability },
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A lazy engine chunk failed to load (§4.5 `engine-load-failed`): the host
|
|
43
|
+
* reports the chunk and the cause; the envelope validator produces the same
|
|
44
|
+
* code when an injected port throws instead of returning findings.
|
|
45
|
+
*/
|
|
46
|
+
export function engineLoadFailed(chunk, cause) {
|
|
47
|
+
return {
|
|
48
|
+
code: "engine-load-failed",
|
|
49
|
+
path: "",
|
|
50
|
+
message: `the ${chunk} engine failed to load: ${cause}`,
|
|
51
|
+
severity: "error",
|
|
52
|
+
source: "host",
|
|
53
|
+
detail: { chunk, cause },
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The envelope validator (§4.3–§4.5): one pure orchestrator that turns an
|
|
3
|
+
* unknown input into a list of §4.5 diagnostics, or an empty list when the
|
|
4
|
+
* envelope renders.
|
|
5
|
+
*
|
|
6
|
+
* The check order is deliberate and total:
|
|
7
|
+
*
|
|
8
|
+
* 1. JSON-serializable, then the 1 MiB UTF-8 budget (§4.3 item 3) — a
|
|
9
|
+
* payload over the budget is refused whole, before anything parses it;
|
|
10
|
+
* 2. envelope structure (§4.2: `catalogId`, `contract`, `mode`, `root`);
|
|
11
|
+
* 3. the envelope's OPTIONAL `catalogId`, when present, must name THIS
|
|
12
|
+
* catalogue (absent = the renderer's catalogue, §4.2);
|
|
13
|
+
* 4. `mode`: `preview` is reserved (§10.3) and refuses;
|
|
14
|
+
* 5. `root.component` must be catalogued (`unknown-component`);
|
|
15
|
+
* 6. a placeholder entry refuses (`component-unavailable`, §5.2 status);
|
|
16
|
+
* 7. the §4.4 contract rule: an envelope may be OLDER than the entry
|
|
17
|
+
* (minors are additive) but never newer, and never another major;
|
|
18
|
+
* 8. the root's structure against the targeted catalogue entry;
|
|
19
|
+
* 9. semantics — ONLY when the structure is clean — through the injected
|
|
20
|
+
* port of the entry's `lazy:` engine (§4.3 item 2). `core` engines have
|
|
21
|
+
* no owner runtime and no port.
|
|
22
|
+
*
|
|
23
|
+
* Every step that refuses returns immediately: a refusal is never partially
|
|
24
|
+
* validated, and no diagnostic hides an earlier one.
|
|
25
|
+
*/
|
|
26
|
+
import type { SemanticPort } from "../ports/types.js";
|
|
27
|
+
import type { Diagnostic } from "./diagnostics.js";
|
|
28
|
+
import type { StructureValidator } from "./structure.js";
|
|
29
|
+
/** The §4.3 item 3 budget: 1 MiB of UTF-8 (the limit itself is accepted). */
|
|
30
|
+
export declare const ENVELOPE_LIMIT_BYTES = 1048576;
|
|
31
|
+
/** One catalogue entry, read structurally (the committed artifact's shape). */
|
|
32
|
+
export interface CatalogComponentEntry {
|
|
33
|
+
readonly [property: string]: unknown;
|
|
34
|
+
}
|
|
35
|
+
/** The catalogue document the validator is created against (§5.2). */
|
|
36
|
+
export interface CatalogDocument {
|
|
37
|
+
/** Every keyword of the committed artifact stays reachable (§5.2). */
|
|
38
|
+
readonly [property: string]: unknown;
|
|
39
|
+
/** §5.2: `$id` = `catalogId`; the envelope must name exactly this value. */
|
|
40
|
+
readonly catalogId: string;
|
|
41
|
+
/** The catalogue's entries, by component name. */
|
|
42
|
+
readonly components: Record<string, CatalogComponentEntry>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The JSON-form contract (review 1, B1): the envelope IS a JSON value
|
|
46
|
+
* (§4.3) and the property channel (§6.2) feeds plain JS objects that may
|
|
47
|
+
* carry `undefined` values TypeScript callers routinely produce
|
|
48
|
+
* (`width: undefined`). `JSON.stringify` drops such keys, so the raw JS
|
|
49
|
+
* object and its serialized form disagree — and ajv itself is inconsistent
|
|
50
|
+
* on raw JS (`properties` skips an `undefined` value while
|
|
51
|
+
* `additionalProperties`/`unevaluatedProperties` iterate `Object.keys` and
|
|
52
|
+
* fire on it). The single JSON round-trip below defines the canonical form
|
|
53
|
+
* ONCE for both seams: size measurement and both validators judge exactly
|
|
54
|
+
* the bytes the host transmits. Chosen over ajv-mimicking `undefined`
|
|
55
|
+
* skips in the interpreter because the envelope's wire form is the only
|
|
56
|
+
* form both seams, the budget and the host ever share.
|
|
57
|
+
*/
|
|
58
|
+
export type NormalizedEnvelopeInput = {
|
|
59
|
+
readonly ok: true;
|
|
60
|
+
readonly value: unknown;
|
|
61
|
+
readonly text: string;
|
|
62
|
+
} | {
|
|
63
|
+
readonly ok: false;
|
|
64
|
+
readonly kind: "not-json-value" | "not-serializable";
|
|
65
|
+
readonly message: string;
|
|
66
|
+
};
|
|
67
|
+
export declare function normalizeEnvelopeInput(input: unknown): NormalizedEnvelopeInput;
|
|
68
|
+
/**
|
|
69
|
+
* UTF-8 byte length without TextEncoder (the pure half stays free of
|
|
70
|
+
* host-global identifiers; surrogates pair to 4 bytes like the encoder's).
|
|
71
|
+
*/
|
|
72
|
+
export declare function utf8ByteLength(text: string): number;
|
|
73
|
+
/** Options of the core factory; the barrel fills the default `structure`. */
|
|
74
|
+
export interface EnvelopeValidatorOptions {
|
|
75
|
+
readonly catalog: CatalogDocument;
|
|
76
|
+
readonly envelopeSchema: Record<string, unknown>;
|
|
77
|
+
/** The vendored A2UI common types (`ComponentCommon` et al.). */
|
|
78
|
+
readonly commonTypes: Record<string, unknown>;
|
|
79
|
+
/** Injected semantic ports, by engine chunk name (§4.3 item 2). */
|
|
80
|
+
readonly ports?: Readonly<Partial<Record<string, SemanticPort>>>;
|
|
81
|
+
/** The 2020-12 structure seam; defaults to the ajv bridge (src/structure). */
|
|
82
|
+
readonly structure?: StructureValidator;
|
|
83
|
+
}
|
|
84
|
+
/** A validator bound to one catalogue; `validate` is pure and reusable. */
|
|
85
|
+
export interface EnvelopeValidator {
|
|
86
|
+
validate(input: unknown): readonly Diagnostic[];
|
|
87
|
+
}
|
|
88
|
+
/** The core factory: `structure` is required here (see the barrel). */
|
|
89
|
+
export declare function createEnvelopeValidatorCore(options: EnvelopeValidatorOptions & {
|
|
90
|
+
readonly structure: StructureValidator;
|
|
91
|
+
}): EnvelopeValidator;
|
|
92
|
+
//# sourceMappingURL=envelope.d.ts.map
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The envelope validator (§4.3–§4.5): one pure orchestrator that turns an
|
|
3
|
+
* unknown input into a list of §4.5 diagnostics, or an empty list when the
|
|
4
|
+
* envelope renders.
|
|
5
|
+
*
|
|
6
|
+
* The check order is deliberate and total:
|
|
7
|
+
*
|
|
8
|
+
* 1. JSON-serializable, then the 1 MiB UTF-8 budget (§4.3 item 3) — a
|
|
9
|
+
* payload over the budget is refused whole, before anything parses it;
|
|
10
|
+
* 2. envelope structure (§4.2: `catalogId`, `contract`, `mode`, `root`);
|
|
11
|
+
* 3. the envelope's OPTIONAL `catalogId`, when present, must name THIS
|
|
12
|
+
* catalogue (absent = the renderer's catalogue, §4.2);
|
|
13
|
+
* 4. `mode`: `preview` is reserved (§10.3) and refuses;
|
|
14
|
+
* 5. `root.component` must be catalogued (`unknown-component`);
|
|
15
|
+
* 6. a placeholder entry refuses (`component-unavailable`, §5.2 status);
|
|
16
|
+
* 7. the §4.4 contract rule: an envelope may be OLDER than the entry
|
|
17
|
+
* (minors are additive) but never newer, and never another major;
|
|
18
|
+
* 8. the root's structure against the targeted catalogue entry;
|
|
19
|
+
* 9. semantics — ONLY when the structure is clean — through the injected
|
|
20
|
+
* port of the entry's `lazy:` engine (§4.3 item 2). `core` engines have
|
|
21
|
+
* no owner runtime and no port.
|
|
22
|
+
*
|
|
23
|
+
* Every step that refuses returns immediately: a refusal is never partially
|
|
24
|
+
* validated, and no diagnostic hides an earlier one.
|
|
25
|
+
*/
|
|
26
|
+
import { engineLoadFailed } from "./diagnostics.js";
|
|
27
|
+
/** The §4.3 item 3 budget: 1 MiB of UTF-8 (the limit itself is accepted). */
|
|
28
|
+
export const ENVELOPE_LIMIT_BYTES = 1048576;
|
|
29
|
+
/**
|
|
30
|
+
* The prop every semantic engine validates. Fixed for L1's two semantic
|
|
31
|
+
* components (DecisionDossier, BpmnCanvas): §5.1 names `document` the
|
|
32
|
+
* semantic payload.
|
|
33
|
+
*/
|
|
34
|
+
const SEMANTIC_PAYLOAD_PROP = "document";
|
|
35
|
+
/** Escape one RFC 6901 token (`~` first, then `/`). */
|
|
36
|
+
function escapePointerToken(token) {
|
|
37
|
+
return token.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
38
|
+
}
|
|
39
|
+
/** Appends one property token to an RFC 6901 pointer. */
|
|
40
|
+
function appendPointerToken(pointer, token) {
|
|
41
|
+
return `${pointer}/${escapePointerToken(token)}`;
|
|
42
|
+
}
|
|
43
|
+
export function normalizeEnvelopeInput(input) {
|
|
44
|
+
let text;
|
|
45
|
+
try {
|
|
46
|
+
const serialized = JSON.stringify(input);
|
|
47
|
+
if (typeof serialized !== "string") {
|
|
48
|
+
return {
|
|
49
|
+
ok: false,
|
|
50
|
+
kind: "not-json-value",
|
|
51
|
+
message: "the envelope is not a JSON value (§4.3)",
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
text = serialized;
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
return {
|
|
58
|
+
ok: false,
|
|
59
|
+
kind: "not-serializable",
|
|
60
|
+
message: `the envelope is not JSON-serializable (§4.3): ${error instanceof Error ? error.message : String(error)}`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return { ok: true, value: JSON.parse(text), text };
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* UTF-8 byte length without TextEncoder (the pure half stays free of
|
|
67
|
+
* host-global identifiers; surrogates pair to 4 bytes like the encoder's).
|
|
68
|
+
*/
|
|
69
|
+
export function utf8ByteLength(text) {
|
|
70
|
+
let total = 0;
|
|
71
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
72
|
+
const code = text.charCodeAt(index);
|
|
73
|
+
if (code <= 0x7f)
|
|
74
|
+
total += 1;
|
|
75
|
+
else if (code <= 0x7ff)
|
|
76
|
+
total += 2;
|
|
77
|
+
else if (code >= 0xd800 && code <= 0xdbff) {
|
|
78
|
+
total += 4;
|
|
79
|
+
index += 1;
|
|
80
|
+
}
|
|
81
|
+
else
|
|
82
|
+
total += 3;
|
|
83
|
+
}
|
|
84
|
+
return total;
|
|
85
|
+
}
|
|
86
|
+
function parseContract(value) {
|
|
87
|
+
const match = /^([0-9]+)\.([0-9]+)$/.exec(value);
|
|
88
|
+
if (match === undefined || match === null)
|
|
89
|
+
return undefined;
|
|
90
|
+
return { major: Number(match[1]), minor: Number(match[2]) };
|
|
91
|
+
}
|
|
92
|
+
/** Structure issues become §4.5 `schema-violation` diagnostics. */
|
|
93
|
+
function structureDiagnostics(issues, prefix) {
|
|
94
|
+
return issues.map((issue) => {
|
|
95
|
+
let path = `${prefix}${issue.pointer}`;
|
|
96
|
+
if (issue.keyword === "required" && issue.missingProperty !== undefined) {
|
|
97
|
+
path = appendPointerToken(path, issue.missingProperty);
|
|
98
|
+
}
|
|
99
|
+
else if ((issue.keyword === "unevaluatedProperties" || issue.keyword === "additionalProperties") &&
|
|
100
|
+
issue.additionalProperty !== undefined) {
|
|
101
|
+
path = appendPointerToken(path, issue.additionalProperty);
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
code: "schema-violation",
|
|
105
|
+
path,
|
|
106
|
+
message: issue.message,
|
|
107
|
+
severity: "error",
|
|
108
|
+
source: "catalog",
|
|
109
|
+
detail: { keyword: issue.keyword },
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/** The core factory: `structure` is required here (see the barrel). */
|
|
114
|
+
export function createEnvelopeValidatorCore(options) {
|
|
115
|
+
const { catalog, structure, ports } = options;
|
|
116
|
+
return {
|
|
117
|
+
validate(input) {
|
|
118
|
+
// 1. The JSON round-trip (B1): the canonical form for size AND
|
|
119
|
+
// validation. `undefined` keys vanish here, exactly as the wire sees
|
|
120
|
+
// them, so both structure seams judge the same value.
|
|
121
|
+
const normalized = normalizeEnvelopeInput(input);
|
|
122
|
+
if (!normalized.ok) {
|
|
123
|
+
return [
|
|
124
|
+
{
|
|
125
|
+
code: "schema-violation",
|
|
126
|
+
path: "",
|
|
127
|
+
message: normalized.message,
|
|
128
|
+
severity: "error",
|
|
129
|
+
source: "catalog",
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
const text = normalized.text;
|
|
134
|
+
const bytes = utf8ByteLength(text);
|
|
135
|
+
if (bytes > ENVELOPE_LIMIT_BYTES) {
|
|
136
|
+
return [
|
|
137
|
+
{
|
|
138
|
+
code: "payload-too-large",
|
|
139
|
+
path: "",
|
|
140
|
+
message: `the envelope is ${bytes} UTF-8 bytes, over the ${ENVELOPE_LIMIT_BYTES}-byte budget (§4.3 item 3)`,
|
|
141
|
+
severity: "error",
|
|
142
|
+
source: "catalog",
|
|
143
|
+
detail: { limitBytes: ENVELOPE_LIMIT_BYTES, actualBytes: bytes },
|
|
144
|
+
},
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
// 2. Envelope structure (§4.2), on the NORMALIZED value.
|
|
148
|
+
const envelopeIssues = structure.validateEnvelope(normalized.value);
|
|
149
|
+
if (envelopeIssues.length > 0)
|
|
150
|
+
return structureDiagnostics(envelopeIssues, "");
|
|
151
|
+
const envelope = normalized.value;
|
|
152
|
+
// 3. `catalogId` is optional (§4.2: default = the renderer's catalogue):
|
|
153
|
+
// absent names THIS catalogue; present, it must name THIS catalogue.
|
|
154
|
+
// A non-string value that survived step 2 still refuses here.
|
|
155
|
+
const envelopeCatalogId = envelope.catalogId;
|
|
156
|
+
if (envelopeCatalogId !== undefined && envelopeCatalogId !== catalog.catalogId) {
|
|
157
|
+
return [
|
|
158
|
+
{
|
|
159
|
+
code: "schema-violation",
|
|
160
|
+
path: "/catalogId",
|
|
161
|
+
message: `the envelope must name its catalogue (${String(catalog.catalogId)})`,
|
|
162
|
+
severity: "error",
|
|
163
|
+
source: "catalog",
|
|
164
|
+
detail: { expected: catalog.catalogId, found: envelopeCatalogId },
|
|
165
|
+
},
|
|
166
|
+
];
|
|
167
|
+
}
|
|
168
|
+
// 4. `preview` is reserved (§10.3).
|
|
169
|
+
if (envelope.mode === "preview") {
|
|
170
|
+
return [
|
|
171
|
+
{
|
|
172
|
+
code: "unsupported-mode",
|
|
173
|
+
path: "/mode",
|
|
174
|
+
message: 'mode "preview" is reserved and not rendered by this catalogue (§10.3)',
|
|
175
|
+
severity: "error",
|
|
176
|
+
source: "catalog",
|
|
177
|
+
detail: { mode: "preview" },
|
|
178
|
+
},
|
|
179
|
+
];
|
|
180
|
+
}
|
|
181
|
+
// 5. The targeted component must be catalogued.
|
|
182
|
+
const root = envelope.root;
|
|
183
|
+
const component = root.component;
|
|
184
|
+
if (typeof component !== "string" || !(component in catalog.components)) {
|
|
185
|
+
return [
|
|
186
|
+
{
|
|
187
|
+
code: "unknown-component",
|
|
188
|
+
path: "/root/component",
|
|
189
|
+
message: `no catalogued component is named ${String(component)}`,
|
|
190
|
+
severity: "error",
|
|
191
|
+
source: "catalog",
|
|
192
|
+
detail: { component },
|
|
193
|
+
},
|
|
194
|
+
];
|
|
195
|
+
}
|
|
196
|
+
// 6. A placeholder entry refuses (§5.2 x-sentropic.status).
|
|
197
|
+
const entry = catalog.components[component];
|
|
198
|
+
if (entry === undefined) {
|
|
199
|
+
return [
|
|
200
|
+
{
|
|
201
|
+
code: "unknown-component",
|
|
202
|
+
path: "/root/component",
|
|
203
|
+
message: `no catalogued component is named ${component}`,
|
|
204
|
+
severity: "error",
|
|
205
|
+
source: "catalog",
|
|
206
|
+
detail: { component },
|
|
207
|
+
},
|
|
208
|
+
];
|
|
209
|
+
}
|
|
210
|
+
const sentropic = entry["x-sentropic"];
|
|
211
|
+
if (sentropic?.status === "unknown") {
|
|
212
|
+
return [
|
|
213
|
+
{
|
|
214
|
+
code: "component-unavailable",
|
|
215
|
+
path: "/root/component",
|
|
216
|
+
message: `${component} is catalogued as a placeholder (x-sentropic.status "unknown") and cannot render`,
|
|
217
|
+
severity: "error",
|
|
218
|
+
source: "catalog",
|
|
219
|
+
detail: { component },
|
|
220
|
+
},
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
// 7. The §4.4 contract rule: never newer, never another major.
|
|
224
|
+
const envelopeContract = envelope.contract;
|
|
225
|
+
const entryContract = sentropic?.contract;
|
|
226
|
+
if (typeof entryContract !== "string") {
|
|
227
|
+
return [
|
|
228
|
+
{
|
|
229
|
+
code: "schema-violation",
|
|
230
|
+
path: "/root/component",
|
|
231
|
+
message: `the catalogued entry for ${component} declares no x-sentropic contract`,
|
|
232
|
+
severity: "error",
|
|
233
|
+
source: "catalog",
|
|
234
|
+
},
|
|
235
|
+
];
|
|
236
|
+
}
|
|
237
|
+
const parsedEntry = parseContract(entryContract);
|
|
238
|
+
const parsedEnvelope = typeof envelopeContract === "string" ? parseContract(envelopeContract) : undefined;
|
|
239
|
+
if (parsedEntry === undefined || parsedEnvelope === undefined) {
|
|
240
|
+
return [
|
|
241
|
+
{
|
|
242
|
+
code: "schema-violation",
|
|
243
|
+
path: "/contract",
|
|
244
|
+
message: `contract versions are "major.minor" strings (§4.4): envelope ${String(envelopeContract)}, entry ${entryContract}`,
|
|
245
|
+
severity: "error",
|
|
246
|
+
source: "catalog",
|
|
247
|
+
},
|
|
248
|
+
];
|
|
249
|
+
}
|
|
250
|
+
if (parsedEnvelope.major !== parsedEntry.major || parsedEnvelope.minor > parsedEntry.minor) {
|
|
251
|
+
return [
|
|
252
|
+
{
|
|
253
|
+
code: "unsupported-contract",
|
|
254
|
+
path: "/contract",
|
|
255
|
+
message: `the envelope targets contract ${String(envelopeContract)} but ${component} is at ${entryContract} (§4.4: an envelope may be older, never newer)`,
|
|
256
|
+
severity: "error",
|
|
257
|
+
source: "catalog",
|
|
258
|
+
detail: { expected: entryContract, found: envelopeContract },
|
|
259
|
+
},
|
|
260
|
+
];
|
|
261
|
+
}
|
|
262
|
+
// 8. The root's structure against the catalogue entry.
|
|
263
|
+
const componentIssues = structure.validateComponent(component, root);
|
|
264
|
+
if (componentIssues.length > 0)
|
|
265
|
+
return structureDiagnostics(componentIssues, "/root");
|
|
266
|
+
// 9. Semantics, only when the structure is clean (§4.3 item 2).
|
|
267
|
+
const engine = sentropic?.engine;
|
|
268
|
+
if (typeof engine !== "string" || !engine.startsWith("lazy:"))
|
|
269
|
+
return [];
|
|
270
|
+
const chunk = engine.slice("lazy:".length);
|
|
271
|
+
const port = ports?.[chunk];
|
|
272
|
+
const payloadPath = `/root/${SEMANTIC_PAYLOAD_PROP}`;
|
|
273
|
+
if (port === undefined) {
|
|
274
|
+
return [
|
|
275
|
+
{
|
|
276
|
+
code: "host-capability-missing",
|
|
277
|
+
path: payloadPath,
|
|
278
|
+
message: `the host did not inject the ${chunk} semantic port (engine ${engine}); the owning runtime validates this payload (§4.3 item 2)`,
|
|
279
|
+
severity: "error",
|
|
280
|
+
source: "host",
|
|
281
|
+
detail: { chunk, engine },
|
|
282
|
+
},
|
|
283
|
+
];
|
|
284
|
+
}
|
|
285
|
+
let findings;
|
|
286
|
+
try {
|
|
287
|
+
findings = port.validate(root[SEMANTIC_PAYLOAD_PROP]);
|
|
288
|
+
}
|
|
289
|
+
catch (error) {
|
|
290
|
+
const cause = error instanceof Error ? error.message : String(error);
|
|
291
|
+
return [{ ...engineLoadFailed(chunk, cause), path: payloadPath }];
|
|
292
|
+
}
|
|
293
|
+
return findings.map((finding) => ({
|
|
294
|
+
// Engine warnings surface under the engine's own code (the one §4.5
|
|
295
|
+
// names is `watermark-refused`); refusals are always `semantic-invalid`.
|
|
296
|
+
code: finding.severity === "warning" ? finding.code : "semantic-invalid",
|
|
297
|
+
path: `${payloadPath}${finding.pointer ?? ""}`,
|
|
298
|
+
message: finding.message,
|
|
299
|
+
severity: finding.severity,
|
|
300
|
+
source: port.source,
|
|
301
|
+
detail: { code: finding.code },
|
|
302
|
+
}));
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=envelope.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The validator barrel (§4.3–§4.5): the public surface of the pure half,
|
|
3
|
+
* plus the default wiring. `createEnvelopeValidator` fills in the ajv
|
|
4
|
+
* 2020-12 structure bridge (src/structure) when the caller does not
|
|
5
|
+
* inject its own — the core orchestrator stays dependency-free and every
|
|
6
|
+
* piece stays substitutable.
|
|
7
|
+
*/
|
|
8
|
+
import { type EnvelopeValidator, type EnvelopeValidatorOptions } from "./envelope.js";
|
|
9
|
+
export { hostCapabilityMissing, engineLoadFailed, type Diagnostic, type DiagnosticCode, type DiagnosticSource, } from "./diagnostics.js";
|
|
10
|
+
export type { StructureIssue, StructureValidator } from "./structure.js";
|
|
11
|
+
export { createEnvelopeValidatorCore, normalizeEnvelopeInput, type EnvelopeValidator, type EnvelopeValidatorOptions, type CatalogDocument, type CatalogComponentEntry, type NormalizedEnvelopeInput, } from "./envelope.js";
|
|
12
|
+
export { ENVELOPE_LIMIT_BYTES, utf8ByteLength } from "./envelope.js";
|
|
13
|
+
export { createFocusPort, focusPathToPointer, type FocusValidate, type FocusValidationResult } from "../ports/focus.js";
|
|
14
|
+
export { createBpmnCanvasPort, type BpmnHydrate, type BpmnHydrationResult, type BpmnHydrationWarning, } from "../ports/bpmn-canvas.js";
|
|
15
|
+
export type { SemanticFinding, SemanticPort, EngineSource } from "../ports/types.js";
|
|
16
|
+
/**
|
|
17
|
+
* Creates the envelope validator for one catalogue. `structure` defaults to
|
|
18
|
+
* the ajv 2020-12 bridge over the given catalogue, envelope schema and
|
|
19
|
+
* vendored common types (see src/structure/ajv.ts).
|
|
20
|
+
*/
|
|
21
|
+
export declare function createEnvelopeValidator(options: EnvelopeValidatorOptions): EnvelopeValidator;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The validator barrel (§4.3–§4.5): the public surface of the pure half,
|
|
3
|
+
* plus the default wiring. `createEnvelopeValidator` fills in the ajv
|
|
4
|
+
* 2020-12 structure bridge (src/structure) when the caller does not
|
|
5
|
+
* inject its own — the core orchestrator stays dependency-free and every
|
|
6
|
+
* piece stays substitutable.
|
|
7
|
+
*/
|
|
8
|
+
import { createAjvStructure } from "../structure/ajv.js";
|
|
9
|
+
import { createEnvelopeValidatorCore, } from "./envelope.js";
|
|
10
|
+
export { hostCapabilityMissing, engineLoadFailed, } from "./diagnostics.js";
|
|
11
|
+
export { createEnvelopeValidatorCore, normalizeEnvelopeInput, } from "./envelope.js";
|
|
12
|
+
export { ENVELOPE_LIMIT_BYTES, utf8ByteLength } from "./envelope.js";
|
|
13
|
+
export { createFocusPort, focusPathToPointer } from "../ports/focus.js";
|
|
14
|
+
export { createBpmnCanvasPort, } from "../ports/bpmn-canvas.js";
|
|
15
|
+
/**
|
|
16
|
+
* Creates the envelope validator for one catalogue. `structure` defaults to
|
|
17
|
+
* the ajv 2020-12 bridge over the given catalogue, envelope schema and
|
|
18
|
+
* vendored common types (see src/structure/ajv.ts).
|
|
19
|
+
*/
|
|
20
|
+
export function createEnvelopeValidator(options) {
|
|
21
|
+
const structure = options.structure ?? createAjvStructure(options);
|
|
22
|
+
return createEnvelopeValidatorCore({ ...options, structure });
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The structure seam (§4.3): JSON Schema 2020-12 validation of the envelope
|
|
3
|
+
* and of the targeted component, behind a dependency-free interface.
|
|
4
|
+
*
|
|
5
|
+
* The pure half of the package (validate, ports, contracts) defines and uses
|
|
6
|
+
* this interface; the default implementation is the ajv bridge in
|
|
7
|
+
* `src/structure/ajv.ts` (the generator is the other Node-side module).
|
|
8
|
+
* A host that compiles its schemas ahead of time, or ships a different
|
|
9
|
+
* 2020-12 implementation, can inject its own through
|
|
10
|
+
* `createEnvelopeValidator`'s `structure` option.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* One structure failure. `pointer` is an RFC 6901 JSON Pointer RELATIVE TO
|
|
14
|
+
* THE VALIDATED VALUE (the envelope, or the root component object), so the
|
|
15
|
+
* envelope validator can anchor it into the envelope.
|
|
16
|
+
*/
|
|
17
|
+
export interface StructureIssue {
|
|
18
|
+
readonly pointer: string;
|
|
19
|
+
readonly message: string;
|
|
20
|
+
/** The failing keyword, e.g. `type`, `required`, `unevaluatedProperties`. */
|
|
21
|
+
readonly keyword: string;
|
|
22
|
+
/** For `required`: the missing property name. */
|
|
23
|
+
readonly missingProperty?: string;
|
|
24
|
+
/** For `unevaluatedProperties`/`additionalProperties`: the stray name. */
|
|
25
|
+
readonly additionalProperty?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Structure validation of both layers (§4.3: envelope, then component). */
|
|
28
|
+
export interface StructureValidator {
|
|
29
|
+
validateEnvelope(value: unknown): readonly StructureIssue[];
|
|
30
|
+
validateComponent(component: string, root: unknown): readonly StructureIssue[];
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=structure.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The structure seam (§4.3): JSON Schema 2020-12 validation of the envelope
|
|
3
|
+
* and of the targeted component, behind a dependency-free interface.
|
|
4
|
+
*
|
|
5
|
+
* The pure half of the package (validate, ports, contracts) defines and uses
|
|
6
|
+
* this interface; the default implementation is the ajv bridge in
|
|
7
|
+
* `src/structure/ajv.ts` (the generator is the other Node-side module).
|
|
8
|
+
* A host that compiles its schemas ahead of time, or ships a different
|
|
9
|
+
* 2020-12 implementation, can inject its own through
|
|
10
|
+
* `createEnvelopeValidator`'s `structure` option.
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=structure.js.map
|
package/envelope.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "https://design-system.sent-tech.ca/catalogs/elements/v1/envelope.json",
|
|
3
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"description": "The render envelope of the JSON render standard (§4.2): one A2UI v0.9.1 component object under `root`, with the targeted component's contract version and an optional mode. The root interior is validated by the targeted component's catalogue entry, not by this schema.",
|
|
5
|
+
"properties": {
|
|
6
|
+
"catalogId": {
|
|
7
|
+
"type": "string"
|
|
8
|
+
},
|
|
9
|
+
"contract": {
|
|
10
|
+
"pattern": "^[0-9]+\\.[0-9]+$",
|
|
11
|
+
"type": "string"
|
|
12
|
+
},
|
|
13
|
+
"mode": {
|
|
14
|
+
"enum": [
|
|
15
|
+
"preview",
|
|
16
|
+
"snapshot"
|
|
17
|
+
],
|
|
18
|
+
"type": "string"
|
|
19
|
+
},
|
|
20
|
+
"root": {
|
|
21
|
+
"properties": {
|
|
22
|
+
"component": {
|
|
23
|
+
"type": "string"
|
|
24
|
+
},
|
|
25
|
+
"id": {
|
|
26
|
+
"const": "root"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"required": [
|
|
30
|
+
"component",
|
|
31
|
+
"id"
|
|
32
|
+
],
|
|
33
|
+
"type": "object"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"required": [
|
|
37
|
+
"contract",
|
|
38
|
+
"root"
|
|
39
|
+
],
|
|
40
|
+
"title": "Sentropic render envelope",
|
|
41
|
+
"type": "object",
|
|
42
|
+
"unevaluatedProperties": false
|
|
43
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentropic/design-system-elements",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"description": "Sentropic design system custom elements for the JSON render catalogue (BarChart, BpmnCanvas, DecisionDossier): envelope validator plus CDN browser bundle.",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/rhanka/sent-tech-design-system.git",
|
|
13
|
+
"directory": "packages/elements"
|
|
14
|
+
},
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"catalog.json",
|
|
19
|
+
"envelope.json",
|
|
20
|
+
"schemas",
|
|
21
|
+
"!dist/**/*.map",
|
|
22
|
+
"!dist/.srchash"
|
|
23
|
+
],
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./catalog.json": "./catalog.json",
|
|
30
|
+
"./envelope.json": "./envelope.json",
|
|
31
|
+
"./schemas/*": "./schemas/*"
|
|
32
|
+
},
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"main": "./dist/index.js",
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "npm run build:node && npm run build:browser",
|
|
37
|
+
"build:node": "tsc -p tsconfig.json",
|
|
38
|
+
"build:browser": "node scripts/build-browser.mjs",
|
|
39
|
+
"check": "tsc -p tsconfig.check.json && tsc -p tsconfig.dom.json",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"catalog:generate": "node dist/generator/main.js",
|
|
42
|
+
"catalog:check": "node dist/generator/main.js --check"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@sentropic/bpmn-canvas": "0.3.0",
|
|
46
|
+
"@sentropic/focus": "0.5.0",
|
|
47
|
+
"ajv": "8.20.0",
|
|
48
|
+
"dompurify": "3.4.17",
|
|
49
|
+
"svelte": "5.55.7"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@a2ui/web_core": "0.14.0",
|
|
53
|
+
"@json-render/svelte": "0.21.3",
|
|
54
|
+
"ts-json-schema-generator": "2.9.0"
|
|
55
|
+
}
|
|
56
|
+
}
|