@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,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The four-framework parity guard (§5.1): for each catalogued component, the
|
|
3
|
+
* names and JSON types of the catalogued props are compared against the
|
|
4
|
+
* public props types of the React, Vue and Angular packages. A mismatch
|
|
5
|
+
* FAILS generation (the stronger arm of §5.1); the outcome is recorded in
|
|
6
|
+
* `x-sentropic.parity` either way.
|
|
7
|
+
*
|
|
8
|
+
* React's `BarChartProps` intersects `React.HTMLAttributes<HTMLDivElement>`,
|
|
9
|
+
* so the guard first derives that DOM passthrough base mechanically (via the
|
|
10
|
+
* committed bridge `packages/elements/parity/react-html-attributes.ts`) and
|
|
11
|
+
* subtracts it: what remains must be the component's own members. The style
|
|
12
|
+
* hook is `class` everywhere except React, where the same hook is `className`
|
|
13
|
+
* — the alias is applied before the exclusion list is enforced.
|
|
14
|
+
*/
|
|
15
|
+
import { createGenerator } from "ts-json-schema-generator";
|
|
16
|
+
import { canonicalize } from "./canonical.js";
|
|
17
|
+
/** Annotation-only keywords never participate in parity. */
|
|
18
|
+
const ANNOTATION_KEYS = new Set(["description", "$comment", "title", "default", "examples", "$schema", "definitions"]);
|
|
19
|
+
function structuralSignature(node) {
|
|
20
|
+
if (Array.isArray(node))
|
|
21
|
+
return node.map((element) => structuralSignature(element));
|
|
22
|
+
if (node !== null && typeof node === "object") {
|
|
23
|
+
const stripped = {};
|
|
24
|
+
for (const [key, value] of Object.entries(node)) {
|
|
25
|
+
if (ANNOTATION_KEYS.has(key))
|
|
26
|
+
continue;
|
|
27
|
+
stripped[key] = structuralSignature(value);
|
|
28
|
+
}
|
|
29
|
+
return canonicalize(stripped);
|
|
30
|
+
}
|
|
31
|
+
return node;
|
|
32
|
+
}
|
|
33
|
+
function deleteMembers(node, members) {
|
|
34
|
+
if (Array.isArray(node))
|
|
35
|
+
return node.map((child) => deleteMembers(child, members));
|
|
36
|
+
if (node !== null && typeof node === "object") {
|
|
37
|
+
const copy = {};
|
|
38
|
+
for (const [key, value] of Object.entries(node)) {
|
|
39
|
+
if (key === "properties" && value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
40
|
+
const properties = {};
|
|
41
|
+
for (const [name, schema] of Object.entries(value)) {
|
|
42
|
+
if (!members.includes(name))
|
|
43
|
+
properties[name] = schema;
|
|
44
|
+
}
|
|
45
|
+
copy[key] = properties;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (key === "required" && Array.isArray(value)) {
|
|
49
|
+
copy[key] = value.filter((name) => typeof name === "string" && !members.includes(name));
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
copy[key] = deleteMembers(value, members);
|
|
53
|
+
}
|
|
54
|
+
return copy;
|
|
55
|
+
}
|
|
56
|
+
return node;
|
|
57
|
+
}
|
|
58
|
+
/** The guard's comparison rule, exported for its unit tests. */
|
|
59
|
+
export function compareJsonProps(catalogProps, frameworkPropsInput, options) {
|
|
60
|
+
const differences = [];
|
|
61
|
+
const frameworkProps = { ...frameworkPropsInput };
|
|
62
|
+
for (const drop of options.drops) {
|
|
63
|
+
const target = frameworkProps[drop.prop];
|
|
64
|
+
if (target === undefined) {
|
|
65
|
+
differences.push(`declared drop has no framework prop: ${drop.prop}`);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
frameworkProps[drop.prop] = deleteMembers(target, drop.members);
|
|
69
|
+
}
|
|
70
|
+
for (const excluded of options.excluded) {
|
|
71
|
+
if (!(excluded.prop in frameworkProps)) {
|
|
72
|
+
differences.push(`excluded prop no longer present in framework: ${excluded.prop}`);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
delete frameworkProps[excluded.prop];
|
|
76
|
+
}
|
|
77
|
+
const catalogNames = Object.keys(catalogProps).sort();
|
|
78
|
+
const frameworkNames = Object.keys(frameworkProps).sort();
|
|
79
|
+
for (const name of catalogNames) {
|
|
80
|
+
if (!(name in frameworkProps))
|
|
81
|
+
differences.push(`missing in framework: ${name}`);
|
|
82
|
+
}
|
|
83
|
+
for (const name of frameworkNames) {
|
|
84
|
+
if (!(name in catalogProps))
|
|
85
|
+
differences.push(`not catalogued, not excluded: ${name}`);
|
|
86
|
+
}
|
|
87
|
+
// Required-ness of the SHARED props is compared too: a prop required in
|
|
88
|
+
// the catalogue but optional in a framework adapter (or the reverse) is
|
|
89
|
+
// a drift even when the prop's JSON type matches. The framework set is
|
|
90
|
+
// filtered by membership in the post-exclusion surface, so excluded and
|
|
91
|
+
// dropped-away props do not count.
|
|
92
|
+
const frameworkRequired = new Set(options.frameworkRequired.filter((name) => name in frameworkProps));
|
|
93
|
+
for (const name of catalogNames) {
|
|
94
|
+
if (!(name in frameworkProps))
|
|
95
|
+
continue;
|
|
96
|
+
const left = JSON.stringify(structuralSignature(catalogProps[name]));
|
|
97
|
+
const right = JSON.stringify(structuralSignature(frameworkProps[name]));
|
|
98
|
+
if (left !== right) {
|
|
99
|
+
differences.push(`${name}: catalog ${left} != framework ${right}`);
|
|
100
|
+
}
|
|
101
|
+
const requiredInCatalog = options.catalogRequired.includes(name);
|
|
102
|
+
const requiredInFramework = frameworkRequired.has(name);
|
|
103
|
+
if (requiredInCatalog !== requiredInFramework) {
|
|
104
|
+
differences.push(`${name}: required in ${requiredInCatalog ? "catalog" : "framework"} but optional in ${requiredInCatalog ? "framework" : "catalog"}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return { status: differences.length === 0 ? "match" : "mismatch", differences };
|
|
108
|
+
}
|
|
109
|
+
/** Generation settings per compared framework (paths are workspace-relative). */
|
|
110
|
+
const FRAMEWORK_CONFIG = {
|
|
111
|
+
react: { tsconfig: "packages/components-react/tsconfig.json", skipTypeCheck: true, styleHook: "className" },
|
|
112
|
+
vue: { tsconfig: "packages/components-vue/tsconfig.json", skipTypeCheck: false, styleHook: "class" },
|
|
113
|
+
angular: { tsconfig: "packages/components-angular/tsconfig.json", skipTypeCheck: false, styleHook: "class" },
|
|
114
|
+
};
|
|
115
|
+
const REACT_BASE_BRIDGE = "packages/elements/parity/react-html-attributes.ts";
|
|
116
|
+
function generateSchema(input) {
|
|
117
|
+
const config = {
|
|
118
|
+
path: input.path,
|
|
119
|
+
type: input.type,
|
|
120
|
+
tsconfig: input.tsconfig,
|
|
121
|
+
expose: "none",
|
|
122
|
+
topRef: false,
|
|
123
|
+
jsDoc: "none",
|
|
124
|
+
skipTypeCheck: input.skipTypeCheck,
|
|
125
|
+
functions: "comment",
|
|
126
|
+
};
|
|
127
|
+
return createGenerator(config).createSchema(input.type);
|
|
128
|
+
}
|
|
129
|
+
function propertiesOf(schema) {
|
|
130
|
+
if (schema !== null && typeof schema === "object" && !Array.isArray(schema)) {
|
|
131
|
+
const properties = schema.properties;
|
|
132
|
+
if (properties !== null && typeof properties === "object" && !Array.isArray(properties)) {
|
|
133
|
+
return properties;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return {};
|
|
137
|
+
}
|
|
138
|
+
function requiredOf(schema) {
|
|
139
|
+
if (schema !== null && typeof schema === "object" && !Array.isArray(schema)) {
|
|
140
|
+
const required = schema.required;
|
|
141
|
+
if (Array.isArray(required)) {
|
|
142
|
+
return required.filter((name) => typeof name === "string");
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return [];
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Runs the whole guard for one contract module against the committed catalog
|
|
149
|
+
* entry's props (names, JSON types AND required-ness), and returns the
|
|
150
|
+
* `x-sentropic.parity` rows. Throws on any mismatch (§5.1: the guard fails)
|
|
151
|
+
* or on a stale contract declaration.
|
|
152
|
+
*/
|
|
153
|
+
export function runParityGuard(contract, catalogProps, catalogRequired, repoRoot) {
|
|
154
|
+
const rows = {};
|
|
155
|
+
for (const source of contract.frameworks) {
|
|
156
|
+
if (source.role === "source-of-truth") {
|
|
157
|
+
rows[source.framework] = {
|
|
158
|
+
status: "source-of-truth",
|
|
159
|
+
file: source.file,
|
|
160
|
+
type: source.typeName,
|
|
161
|
+
note: source.note ?? "Reference pilot (§3.1); the catalogue is derived from it.",
|
|
162
|
+
};
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
const frameworkPath = `${repoRoot}/${source.file}`;
|
|
166
|
+
if (source.role === "no-counterpart") {
|
|
167
|
+
rows[source.framework] = {
|
|
168
|
+
status: "no-counterpart",
|
|
169
|
+
file: source.file,
|
|
170
|
+
note: "No counterpart in this framework package (§5.1: components with no framework counterpart record that fact).",
|
|
171
|
+
};
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const config = FRAMEWORK_CONFIG[source.framework];
|
|
175
|
+
const schema = generateSchema({
|
|
176
|
+
path: frameworkPath,
|
|
177
|
+
type: source.typeName,
|
|
178
|
+
tsconfig: `${repoRoot}/${config.tsconfig}`,
|
|
179
|
+
skipTypeCheck: config.skipTypeCheck,
|
|
180
|
+
});
|
|
181
|
+
let frameworkProps = propertiesOf(schema);
|
|
182
|
+
if (source.framework === "react") {
|
|
183
|
+
// Subtract the DOM passthrough base; className and onSelect are Omit'd
|
|
184
|
+
// from the base and re-added by the own block, so they survive.
|
|
185
|
+
const base = propertiesOf(generateSchema({
|
|
186
|
+
path: `${repoRoot}/${REACT_BASE_BRIDGE}`,
|
|
187
|
+
type: "DivHTMLAttributes",
|
|
188
|
+
tsconfig: `${repoRoot}/${config.tsconfig}`,
|
|
189
|
+
skipTypeCheck: true,
|
|
190
|
+
}));
|
|
191
|
+
const baseNames = new Set(Object.keys(base));
|
|
192
|
+
frameworkProps = Object.fromEntries(Object.entries(frameworkProps).filter(([name]) => !(baseNames.has(name) && name !== "className" && name !== "onSelect")));
|
|
193
|
+
}
|
|
194
|
+
const excluded = contract.excluded.map((entry) => ({
|
|
195
|
+
prop: entry.prop === "class" && config.styleHook === "className" ? "className" : entry.prop,
|
|
196
|
+
}));
|
|
197
|
+
const drops = contract.narrowedUnions.map((entry) => ({ prop: entry.prop, members: entry.dropped }));
|
|
198
|
+
const result = compareJsonProps(catalogProps, frameworkProps, {
|
|
199
|
+
excluded,
|
|
200
|
+
drops,
|
|
201
|
+
catalogRequired,
|
|
202
|
+
frameworkRequired: requiredOf(schema),
|
|
203
|
+
});
|
|
204
|
+
rows[source.framework] = {
|
|
205
|
+
status: result.status,
|
|
206
|
+
file: source.file,
|
|
207
|
+
type: source.typeName,
|
|
208
|
+
comparedProps: Object.keys(catalogProps).length,
|
|
209
|
+
...(source.framework === "react"
|
|
210
|
+
? {
|
|
211
|
+
note: "Own members after subtracting React.HTMLAttributes<HTMLDivElement>; className is React's name for the class style hook.",
|
|
212
|
+
}
|
|
213
|
+
: {}),
|
|
214
|
+
...(result.status === "mismatch" ? { differences: result.differences } : {}),
|
|
215
|
+
};
|
|
216
|
+
if (result.status === "mismatch") {
|
|
217
|
+
throw new Error(`parity guard: ${contract.component} differs from ${source.framework} ${source.typeName}:\n` +
|
|
218
|
+
result.differences.map((difference) => ` - ${difference}`).join("\n"));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return rows;
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=parity.js.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package root: the catalogue registry and the envelope validator.
|
|
3
|
+
* Everything a renderer imports at runtime is here; the Node-side
|
|
4
|
+
* generator (src/generator) and the structure bridge it defaults to
|
|
5
|
+
* (src/structure) are reachable through the validate barrel and never
|
|
6
|
+
* re-exported separately.
|
|
7
|
+
*/
|
|
8
|
+
export { contracts, CATALOG_ID, ENVELOPE_ID, standaloneId, A2UI_COMMON_TYPES_ID, A2UI_PROTOCOL_VERSION, } from "./contracts/index.js";
|
|
9
|
+
export type { ContractModule } from "./contracts/index.js";
|
|
10
|
+
export * from "./validate/index.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package root: the catalogue registry and the envelope validator.
|
|
3
|
+
* Everything a renderer imports at runtime is here; the Node-side
|
|
4
|
+
* generator (src/generator) and the structure bridge it defaults to
|
|
5
|
+
* (src/structure) are reachable through the validate barrel and never
|
|
6
|
+
* re-exported separately.
|
|
7
|
+
*/
|
|
8
|
+
export { contracts, CATALOG_ID, ENVELOPE_ID, standaloneId, A2UI_COMMON_TYPES_ID, A2UI_PROTOCOL_VERSION, } from "./contracts/index.js";
|
|
9
|
+
export * from "./validate/index.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bpmn-canvas port (§4.3 item 2, §5.1): the typed seam to the BPMN
|
|
3
|
+
* engine's `hydrate`, which is the AUTHORITATIVE validator of the F1
|
|
4
|
+
* document. No BPMN engine is installed in this workspace, so nothing here
|
|
5
|
+
* imports one: L6's host injects the port bound to the real engine, and the
|
|
6
|
+
* workspace-side tests bind it to typed stubs. The result type is the part
|
|
7
|
+
* of the F1 surface the envelope contract needs: refuse, accept, or accept
|
|
8
|
+
* with warnings (e.g. `watermark-refused`), each with an optional pointer
|
|
9
|
+
* relative to the document.
|
|
10
|
+
*/
|
|
11
|
+
import type { SemanticPort } from "./types.js";
|
|
12
|
+
/** A non-blocking engine fact: rendered, but not exactly as asked. */
|
|
13
|
+
export interface BpmnHydrationWarning {
|
|
14
|
+
/** The engine's stable code, e.g. `watermark-refused` (§4.5). */
|
|
15
|
+
readonly code: string;
|
|
16
|
+
readonly message: string;
|
|
17
|
+
/** JSON Pointer relative to the document, when the engine can locate it. */
|
|
18
|
+
readonly pointer?: string;
|
|
19
|
+
}
|
|
20
|
+
/** What the engine's `hydrate` returns for one F1 document. */
|
|
21
|
+
export type BpmnHydrationResult = {
|
|
22
|
+
readonly ok: true;
|
|
23
|
+
readonly warnings?: readonly BpmnHydrationWarning[];
|
|
24
|
+
} | {
|
|
25
|
+
readonly ok: false;
|
|
26
|
+
readonly code: string;
|
|
27
|
+
readonly message: string;
|
|
28
|
+
readonly pointer?: string;
|
|
29
|
+
};
|
|
30
|
+
/** The engine binding the host injects: validate by hydrating. */
|
|
31
|
+
export type BpmnHydrate = (payload: unknown) => BpmnHydrationResult;
|
|
32
|
+
/** Wraps a hydrate binding as the injected `bpmn-canvas` semantic port. */
|
|
33
|
+
export declare function createBpmnCanvasPort(hydrate: BpmnHydrate): SemanticPort;
|
|
34
|
+
//# sourceMappingURL=bpmn-canvas.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bpmn-canvas port (§4.3 item 2, §5.1): the typed seam to the BPMN
|
|
3
|
+
* engine's `hydrate`, which is the AUTHORITATIVE validator of the F1
|
|
4
|
+
* document. No BPMN engine is installed in this workspace, so nothing here
|
|
5
|
+
* imports one: L6's host injects the port bound to the real engine, and the
|
|
6
|
+
* workspace-side tests bind it to typed stubs. The result type is the part
|
|
7
|
+
* of the F1 surface the envelope contract needs: refuse, accept, or accept
|
|
8
|
+
* with warnings (e.g. `watermark-refused`), each with an optional pointer
|
|
9
|
+
* relative to the document.
|
|
10
|
+
*/
|
|
11
|
+
/** Wraps a hydrate binding as the injected `bpmn-canvas` semantic port. */
|
|
12
|
+
export function createBpmnCanvasPort(hydrate) {
|
|
13
|
+
return {
|
|
14
|
+
source: "bpmn-canvas",
|
|
15
|
+
validate(payload) {
|
|
16
|
+
const result = hydrate(payload);
|
|
17
|
+
if (result.ok) {
|
|
18
|
+
return (result.warnings ?? []).map((warning) => ({
|
|
19
|
+
code: warning.code,
|
|
20
|
+
message: warning.message,
|
|
21
|
+
...(warning.pointer !== undefined ? { pointer: warning.pointer } : {}),
|
|
22
|
+
severity: "warning",
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
return [
|
|
26
|
+
{
|
|
27
|
+
code: result.code,
|
|
28
|
+
message: result.message,
|
|
29
|
+
...(result.pointer !== undefined ? { pointer: result.pointer } : {}),
|
|
30
|
+
severity: "error",
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=bpmn-canvas.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The focus port (§4.3 item 2, owner decision 2026-10-30): adapts
|
|
3
|
+
* `@sentropic/focus/validate`'s `validateDecisionDossierDocument` to the
|
|
4
|
+
* injected {@link SemanticPort} seam.
|
|
5
|
+
*
|
|
6
|
+
* The port is declared STRUCTURALLY (no import of `@sentropic/focus` here):
|
|
7
|
+
* the validator's pure half imports nothing, and the host passes the real
|
|
8
|
+
* validator it resolved — the pinned version is recorded by the
|
|
9
|
+
* DecisionDossier contract's `semantic` block, and the focus port factory
|
|
10
|
+
* accepts any function with the same shape. `@sentropic/focus/validate`
|
|
11
|
+
* validates legacy v1 by default (`schemaVersion` absent), which is the
|
|
12
|
+
* schema the catalogue embeds.
|
|
13
|
+
*/
|
|
14
|
+
import type { SemanticPort } from "./types.js";
|
|
15
|
+
/** One focus validation issue: `path` is focus's JSON-path style (`$.a[0].b`). */
|
|
16
|
+
export interface FocusValidationIssue {
|
|
17
|
+
/** JSON-path-style location, e.g. `$.sections[3].id`. */
|
|
18
|
+
readonly path: string;
|
|
19
|
+
/** Focus's stable machine code, e.g. `duplicate_id`. */
|
|
20
|
+
readonly code: string;
|
|
21
|
+
readonly message: string;
|
|
22
|
+
}
|
|
23
|
+
/** The shape of `validateDecisionDossierDocument` (matched structurally). */
|
|
24
|
+
export type FocusValidationResult = {
|
|
25
|
+
readonly ok: true;
|
|
26
|
+
readonly value: unknown;
|
|
27
|
+
} | {
|
|
28
|
+
readonly ok: false;
|
|
29
|
+
readonly issues: readonly FocusValidationIssue[];
|
|
30
|
+
};
|
|
31
|
+
/** Any function shaped like `@sentropic/focus/validate`'s default validator. */
|
|
32
|
+
export type FocusValidate = (value: unknown) => FocusValidationResult;
|
|
33
|
+
/**
|
|
34
|
+
* Converts focus's JSON-path pointer (`$.sections[3].id`) to an RFC 6901
|
|
35
|
+
* pointer relative to the payload (`/sections/3/id`).
|
|
36
|
+
*/
|
|
37
|
+
export declare function focusPathToPointer(path: string): string;
|
|
38
|
+
/** Wraps a focus validator as the injected `focus` semantic port. */
|
|
39
|
+
export declare function createFocusPort(validate: FocusValidate): SemanticPort;
|
|
40
|
+
//# sourceMappingURL=focus.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The focus port (§4.3 item 2, owner decision 2026-10-30): adapts
|
|
3
|
+
* `@sentropic/focus/validate`'s `validateDecisionDossierDocument` to the
|
|
4
|
+
* injected {@link SemanticPort} seam.
|
|
5
|
+
*
|
|
6
|
+
* The port is declared STRUCTURALLY (no import of `@sentropic/focus` here):
|
|
7
|
+
* the validator's pure half imports nothing, and the host passes the real
|
|
8
|
+
* validator it resolved — the pinned version is recorded by the
|
|
9
|
+
* DecisionDossier contract's `semantic` block, and the focus port factory
|
|
10
|
+
* accepts any function with the same shape. `@sentropic/focus/validate`
|
|
11
|
+
* validates legacy v1 by default (`schemaVersion` absent), which is the
|
|
12
|
+
* schema the catalogue embeds.
|
|
13
|
+
*/
|
|
14
|
+
/** Escapes one RFC 6901 token (`~` then `/`). */
|
|
15
|
+
function escapePointerToken(token) {
|
|
16
|
+
return token.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Converts focus's JSON-path pointer (`$.sections[3].id`) to an RFC 6901
|
|
20
|
+
* pointer relative to the payload (`/sections/3/id`).
|
|
21
|
+
*/
|
|
22
|
+
export function focusPathToPointer(path) {
|
|
23
|
+
const withoutRoot = path.startsWith("$") ? path.slice(1) : path;
|
|
24
|
+
const tokens = [];
|
|
25
|
+
for (const match of withoutRoot.matchAll(/([^.[\]]+)|\[(\d+)\]/g)) {
|
|
26
|
+
const token = match[1] ?? match[2];
|
|
27
|
+
if (token !== undefined)
|
|
28
|
+
tokens.push(escapePointerToken(token));
|
|
29
|
+
}
|
|
30
|
+
return tokens.length === 0 ? "" : `/${tokens.join("/")}`;
|
|
31
|
+
}
|
|
32
|
+
/** Wraps a focus validator as the injected `focus` semantic port. */
|
|
33
|
+
export function createFocusPort(validate) {
|
|
34
|
+
return {
|
|
35
|
+
source: "focus",
|
|
36
|
+
validate(payload) {
|
|
37
|
+
const result = validate(payload);
|
|
38
|
+
if (result.ok)
|
|
39
|
+
return [];
|
|
40
|
+
return result.issues.map((issue) => ({
|
|
41
|
+
code: issue.code,
|
|
42
|
+
message: issue.message,
|
|
43
|
+
pointer: focusPathToPointer(issue.path),
|
|
44
|
+
severity: "error",
|
|
45
|
+
}));
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=focus.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic ports (§4.3 item 2): the seam through which each component's
|
|
3
|
+
* OWNING RUNTIME validates the semantic payload. The validator never imports
|
|
4
|
+
* a runtime itself — the host injects the port for every `lazy:` engine, so
|
|
5
|
+
* the workspace-side validator stays pure and the engine chunk stays optional.
|
|
6
|
+
*
|
|
7
|
+
* `diagram-core` is reserved for lot L8 (§14): no port factory exists for it
|
|
8
|
+
* yet, but the source union names it so L8 can register one without touching
|
|
9
|
+
* the diagnostic contract.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* One finding of a semantic port: an engine-level fact about the payload.
|
|
13
|
+
* `pointer` is an RFC 6901 JSON Pointer RELATIVE TO THE PAYLOAD ("" for the
|
|
14
|
+
* payload itself); the envelope validator anchors it into the envelope.
|
|
15
|
+
*/
|
|
16
|
+
export interface SemanticFinding {
|
|
17
|
+
/** The owning runtime's stable code, e.g. `duplicate_id`, `watermark-refused`. */
|
|
18
|
+
readonly code: string;
|
|
19
|
+
readonly message: string;
|
|
20
|
+
readonly pointer?: string;
|
|
21
|
+
readonly severity: "error" | "warning";
|
|
22
|
+
}
|
|
23
|
+
/** The engines that can own a component's semantics (§4.3 item 2). */
|
|
24
|
+
export type EngineSource = "focus" | "bpmn-canvas" | "diagram-core";
|
|
25
|
+
/**
|
|
26
|
+
* A semantic port: the injected binding to one owning runtime. `validate`
|
|
27
|
+
* must be pure (no I/O, no mutation of the payload); a port that cannot run
|
|
28
|
+
* throws, and the envelope validator surfaces that as `engine-load-failed`
|
|
29
|
+
* (§4.5) — the host uses {@link engineLoadFailed} for the same fact when it
|
|
30
|
+
* fails BEFORE the port exists.
|
|
31
|
+
*/
|
|
32
|
+
export interface SemanticPort {
|
|
33
|
+
readonly source: EngineSource;
|
|
34
|
+
validate(payload: unknown): readonly SemanticFinding[];
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic ports (§4.3 item 2): the seam through which each component's
|
|
3
|
+
* OWNING RUNTIME validates the semantic payload. The validator never imports
|
|
4
|
+
* a runtime itself — the host injects the port for every `lazy:` engine, so
|
|
5
|
+
* the workspace-side validator stays pure and the engine chunk stays optional.
|
|
6
|
+
*
|
|
7
|
+
* `diagram-core` is reserved for lot L8 (§14): no port factory exists for it
|
|
8
|
+
* yet, but the source union names it so L8 can register one without touching
|
|
9
|
+
* the diagnostic contract.
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default structure seam (§4.3): ajv 8 (dist/2020) validating the
|
|
3
|
+
* envelope and each catalogue entry against JSON Schema 2020-12.
|
|
4
|
+
*
|
|
5
|
+
* This module is the Node/browser bridge OUTSIDE the pure half
|
|
6
|
+
* (src/{contracts,generated,ports,validate} import nothing but relative
|
|
7
|
+
* modules — that is pinned by tests/purity.test.ts): the validator core
|
|
8
|
+
* receives the compiled schemas through the StructureValidator interface,
|
|
9
|
+
* and the barrel (src/validate/index.ts) injects this implementation as the
|
|
10
|
+
* default. A host can substitute its own through the `structure` option.
|
|
11
|
+
*
|
|
12
|
+
* Registration set (all under their `$id`s, so every reference resolves
|
|
13
|
+
* without network or file access):
|
|
14
|
+
* - the vendored A2UI common types under the v0.9.1 URI the entries
|
|
15
|
+
* reference `ComponentCommon` by;
|
|
16
|
+
* - the BUILT sibling `catalog.json` stub under its URI — common_types'
|
|
17
|
+
* reachable graph ends at its `anyFunction` definition, the empty
|
|
18
|
+
* function set `{ "not": {} }` (§5.2 `functions: {}`), so every A2UI
|
|
19
|
+
* `FunctionCall` refuses (§4.1: the envelope never carries a function);
|
|
20
|
+
* - the catalogue itself, so each entry compiles through
|
|
21
|
+
* `<catalogId>#/components/<Name>`.
|
|
22
|
+
*/
|
|
23
|
+
import type { CatalogDocument } from "../validate/envelope.js";
|
|
24
|
+
import type { StructureValidator } from "../validate/structure.js";
|
|
25
|
+
export interface AjvStructureOptions {
|
|
26
|
+
readonly catalog: CatalogDocument;
|
|
27
|
+
readonly envelopeSchema: Record<string, unknown>;
|
|
28
|
+
/** The vendored A2UI common types (src/generated). */
|
|
29
|
+
readonly commonTypes: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Builds the 2020-12 structure validator for one catalogue. The options are
|
|
33
|
+
* strict-mode-agnostic on purpose: the committed documents carry vendor
|
|
34
|
+
* keywords (`components`, `functions`, `catalogId`, `x-sentropic`) outside
|
|
35
|
+
* ajv's known set, and their freshness is guarded by the generator's
|
|
36
|
+
* `--check`, so `strict: false` trades nothing away here. No registered
|
|
37
|
+
* document declares a `format` (measured: common_types and the built stub
|
|
38
|
+
* carry none), so none is declared known.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createAjvStructure(options: AjvStructureOptions): StructureValidator;
|
|
41
|
+
//# sourceMappingURL=ajv.d.ts.map
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default structure seam (§4.3): ajv 8 (dist/2020) validating the
|
|
3
|
+
* envelope and each catalogue entry against JSON Schema 2020-12.
|
|
4
|
+
*
|
|
5
|
+
* This module is the Node/browser bridge OUTSIDE the pure half
|
|
6
|
+
* (src/{contracts,generated,ports,validate} import nothing but relative
|
|
7
|
+
* modules — that is pinned by tests/purity.test.ts): the validator core
|
|
8
|
+
* receives the compiled schemas through the StructureValidator interface,
|
|
9
|
+
* and the barrel (src/validate/index.ts) injects this implementation as the
|
|
10
|
+
* default. A host can substitute its own through the `structure` option.
|
|
11
|
+
*
|
|
12
|
+
* Registration set (all under their `$id`s, so every reference resolves
|
|
13
|
+
* without network or file access):
|
|
14
|
+
* - the vendored A2UI common types under the v0.9.1 URI the entries
|
|
15
|
+
* reference `ComponentCommon` by;
|
|
16
|
+
* - the BUILT sibling `catalog.json` stub under its URI — common_types'
|
|
17
|
+
* reachable graph ends at its `anyFunction` definition, the empty
|
|
18
|
+
* function set `{ "not": {} }` (§5.2 `functions: {}`), so every A2UI
|
|
19
|
+
* `FunctionCall` refuses (§4.1: the envelope never carries a function);
|
|
20
|
+
* - the catalogue itself, so each entry compiles through
|
|
21
|
+
* `<catalogId>#/components/<Name>`.
|
|
22
|
+
*/
|
|
23
|
+
// Plain-Node-ESM witness (review 1): ajv ships no `exports` map, so a deep
|
|
24
|
+
// import must name the file — extensionless `ajv/dist/2020` loads under
|
|
25
|
+
// bundlers and vitest's resolver but fails with ERR_MODULE_NOT_FOUND in
|
|
26
|
+
// plain Node ESM (`dist/index.js` is imported with no toolchain).
|
|
27
|
+
import Ajv2020 from "ajv/dist/2020.js";
|
|
28
|
+
import { CATALOG_ID } from "../contracts/index.js";
|
|
29
|
+
import { a2uiSdkCatalogSchema } from "../generated/a2ui-common-types.js";
|
|
30
|
+
/** ajv errors become StructureIssues; the suffix params become token hints. */
|
|
31
|
+
function toIssues(compiled) {
|
|
32
|
+
const issues = [];
|
|
33
|
+
for (const error of (compiled.errors ?? [])) {
|
|
34
|
+
const params = error.params ?? {};
|
|
35
|
+
issues.push({
|
|
36
|
+
pointer: error.instancePath,
|
|
37
|
+
message: error.message ?? "the value does not satisfy the schema",
|
|
38
|
+
keyword: error.keyword,
|
|
39
|
+
...(typeof params.missingProperty === "string" ? { missingProperty: params.missingProperty } : {}),
|
|
40
|
+
...(typeof params.additionalProperty === "string" ? { additionalProperty: params.additionalProperty } : {}),
|
|
41
|
+
...(typeof params.unevaluatedProperty === "string" ? { additionalProperty: params.unevaluatedProperty } : {}),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return issues;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Builds the 2020-12 structure validator for one catalogue. The options are
|
|
48
|
+
* strict-mode-agnostic on purpose: the committed documents carry vendor
|
|
49
|
+
* keywords (`components`, `functions`, `catalogId`, `x-sentropic`) outside
|
|
50
|
+
* ajv's known set, and their freshness is guarded by the generator's
|
|
51
|
+
* `--check`, so `strict: false` trades nothing away here. No registered
|
|
52
|
+
* document declares a `format` (measured: common_types and the built stub
|
|
53
|
+
* carry none), so none is declared known.
|
|
54
|
+
*/
|
|
55
|
+
export function createAjvStructure(options) {
|
|
56
|
+
const catalogId = options.catalog.$id;
|
|
57
|
+
if (typeof catalogId !== "string" || catalogId.length === 0) {
|
|
58
|
+
throw new Error("the catalogue document must carry its $id (§5.2: $id = catalogId)");
|
|
59
|
+
}
|
|
60
|
+
if (catalogId !== CATALOG_ID && catalogId !== options.catalog.catalogId) {
|
|
61
|
+
// The committed catalogue satisfies $id === catalogId; a hand-built one
|
|
62
|
+
// may differ only if it is coherent (its entries' refs resolve through
|
|
63
|
+
// this base), which is what the guard below enforces.
|
|
64
|
+
if (typeof options.catalog.catalogId !== "string" || options.catalog.catalogId !== catalogId) {
|
|
65
|
+
throw new Error("the catalogue document's $id and catalogId disagree (§5.2)");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const ajv = new Ajv2020({ allErrors: true, strict: false });
|
|
69
|
+
ajv.addSchema(options.commonTypes);
|
|
70
|
+
ajv.addSchema(a2uiSdkCatalogSchema);
|
|
71
|
+
ajv.addSchema(options.catalog);
|
|
72
|
+
const envelopeValidate = ajv.compile(options.envelopeSchema);
|
|
73
|
+
const entries = new Map();
|
|
74
|
+
/** Compiles (and caches) one entry; undefined when it cannot compile. */
|
|
75
|
+
function entryOf(component) {
|
|
76
|
+
const cached = entries.get(component);
|
|
77
|
+
if (cached !== undefined)
|
|
78
|
+
return { compiled: cached };
|
|
79
|
+
try {
|
|
80
|
+
const compiled = ajv.compile({ $ref: `${catalogId}#/components/${component}` });
|
|
81
|
+
entries.set(component, compiled);
|
|
82
|
+
return { compiled };
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
return { error: error instanceof Error ? error.message : String(error) };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
validateEnvelope(value) {
|
|
90
|
+
return envelopeValidate(value) ? [] : toIssues(envelopeValidate);
|
|
91
|
+
},
|
|
92
|
+
validateComponent(component, root) {
|
|
93
|
+
const entry = entryOf(component);
|
|
94
|
+
if ("error" in entry) {
|
|
95
|
+
// Not a data pointer: it names the entry that failed to compile.
|
|
96
|
+
return [
|
|
97
|
+
{
|
|
98
|
+
pointer: "/component",
|
|
99
|
+
message: `the catalogued schema for ${component} could not be compiled: ${entry.error}`,
|
|
100
|
+
keyword: "$compile",
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
return entry.compiled(root) ? [] : toIssues(entry.compiled);
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=ajv.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The eval-free structure seam (§4.3, §6.4): a JSON Schema 2020-12
|
|
3
|
+
* interpreter over the same registered documents as the ajv bridge
|
|
4
|
+
* (`src/structure/ajv.ts`), for hosts whose CSP forbids `eval` and the
|
|
5
|
+
* `Function` constructor — the browser core chunk (§6.2, §6.4).
|
|
6
|
+
*
|
|
7
|
+
* ajv materialises every compiled validator through `new Function`, so the
|
|
8
|
+
* DEFAULT seam cannot run under the pilot and strict CSP rows of §6.4: the
|
|
9
|
+
* compiled meta-schema itself trips the policy at validator creation, before
|
|
10
|
+
* any envelope is seen. This module validates the SAME documents — the
|
|
11
|
+
* committed catalogue, the envelope schema, the vendored A2UI common types
|
|
12
|
+
* and the built `catalog.json` stub (§5.2) — with a plain recursive
|
|
13
|
+
* interpreter: no code generation, no host-global trick, nothing the CSP can
|
|
14
|
+
* refuse. It implements exactly the keyword surface the committed documents
|
|
15
|
+
* use (measured: `$ref`, `type`, `enum`, `const`, `pattern`, `properties`,
|
|
16
|
+
* `required`, `additionalProperties`, `unevaluatedProperties`, `items`,
|
|
17
|
+
* `minItems`, `maxItems`, `allOf`, `anyOf`, `oneOf`, `not`) and REFUSES
|
|
18
|
+
* CONSTRUCTION when a registered document grows a standard 2020-12 keyword
|
|
19
|
+
* outside that set, or any UNKNOWN keyword at all, so a catalogue change
|
|
20
|
+
* cannot silently weaken the browser validation. The only allowed
|
|
21
|
+
* non-standard keys are the explicitly allowlisted annotation and
|
|
22
|
+
* catalogue-container keys (`ANNOTATION_KEYWORDS`, including `x-*`);
|
|
23
|
+
* anything else throws at construction (review 1, B3) — never silently
|
|
24
|
+
* ignored.
|
|
25
|
+
*
|
|
26
|
+
* Equivalence with the ajv bridge is pinned by `tests/structure-interpreter
|
|
27
|
+
* .test.ts` (issue-for-issue on the catalogue corpus) and by
|
|
28
|
+
* `tests/structure-differential.test.ts` (same verdicts and same failing
|
|
29
|
+
* pointer/keyword sets on both seams over the examples, the catalogue-test
|
|
30
|
+
* mutations, the B1–B6 reproductions and a seeded generated corpus).
|
|
31
|
+
*/
|
|
32
|
+
import type { CatalogDocument } from "../validate/envelope.js";
|
|
33
|
+
import type { StructureValidator } from "../validate/structure.js";
|
|
34
|
+
export interface InterpreterStructureOptions {
|
|
35
|
+
readonly catalog: CatalogDocument;
|
|
36
|
+
readonly envelopeSchema: Record<string, unknown>;
|
|
37
|
+
/** The vendored A2UI common types (src/generated). */
|
|
38
|
+
readonly commonTypes: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Builds the eval-free structure validator for one catalogue, over the same
|
|
42
|
+
* documents the ajv bridge registers. Construction audits every document:
|
|
43
|
+
* a catalogue that grows past the implemented keyword surface fails loudly
|
|
44
|
+
* here, in the build and its tests — never as a silent browser weakening.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createInterpreterStructure(options: InterpreterStructureOptions): StructureValidator;
|
|
47
|
+
//# sourceMappingURL=interpreter.d.ts.map
|