@sentropic/diagram-core 0.4.1 → 0.6.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/README.md +13 -0
- package/dist/connector-registry.d.ts +64 -0
- package/dist/connector-registry.js +98 -0
- package/dist/fold.d.ts +3 -2
- package/dist/fold.js +4 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/layout-hints-v2.d.ts +204 -0
- package/dist/layout-hints-v2.js +508 -0
- package/dist/presentation-catalog.d.ts +3 -3
- package/dist/presentation-catalog.js +2 -2
- package/dist/presentation-pinned-adapter.d.ts +1 -1
- package/dist/presentation-pinned-adapter.js +1 -1
- package/dist/presentation-relations.js +81 -13
- package/dist/presentation.d.ts +4 -3
- package/dist/validate.js +85 -0
- package/dist/view-schema-pin.d.ts +4 -1
- package/dist/view-schema-pin.js +42 -2
- package/dist/view.d.ts +18 -5
- package/package.json +6 -2
- package/schemas/diagram-view-schema-4.json +1 -0
- package/schemas/diagram-view-schema-4.sha256 +1 -0
- package/schemas/ds-layout-hints-2.json +1 -0
- package/schemas/ds-layout-hints-2.sha256 +1 -0
|
@@ -1,25 +1,90 @@
|
|
|
1
|
-
/** Resolve document relation refinements
|
|
1
|
+
/** Resolve document relation refinements, diagram-presentation@2 and DE-2 connector words at the boundary of the frozen presentation adapter. */
|
|
2
|
+
import { isArrowheadKind, isLinkEmphasis } from "./connector-registry.js";
|
|
3
|
+
import { diagnostic } from "./diagnostics.js";
|
|
2
4
|
import { DIAGRAM_PRESENTATION_CONTRACT_PIN, isPresentationContractV2Pin, } from "./presentation.js";
|
|
3
5
|
import { validateDiagramPresentation as validatePinnedPresentation } from "./presentation-validate.js";
|
|
4
6
|
import { relationBaseType } from "./relation-types.js";
|
|
5
7
|
function isRecord(value) {
|
|
6
8
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7
9
|
}
|
|
8
|
-
function
|
|
10
|
+
function shapeInvalid(path) {
|
|
11
|
+
return diagnostic({
|
|
12
|
+
code: "occurrence-endpoint-mismatch",
|
|
13
|
+
severity: "error",
|
|
14
|
+
path,
|
|
15
|
+
message: "diagram presentation fails check presentation-shape-invalid",
|
|
16
|
+
refs: [],
|
|
17
|
+
details: { check: "presentation-shape-invalid" },
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function normalizeViewForPinnedAdapter(view) {
|
|
9
21
|
const diagram = view.presentation.diagram;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
22
|
+
const hasDiagram = isRecord(diagram);
|
|
23
|
+
const isV2 = hasDiagram &&
|
|
24
|
+
isRecord(diagram["contractPin"]) &&
|
|
25
|
+
isPresentationContractV2Pin(diagram["contractPin"]);
|
|
26
|
+
const isFrozenV1 = hasDiagram && !isV2;
|
|
27
|
+
const ALLOWED_RELATION_OCCURRENCE_KEYS = new Set([
|
|
28
|
+
"id",
|
|
29
|
+
"relation",
|
|
30
|
+
"endpoints",
|
|
31
|
+
"waypoints",
|
|
32
|
+
"strokeStyle",
|
|
33
|
+
"arrowhead",
|
|
34
|
+
"emphasis",
|
|
35
|
+
]);
|
|
36
|
+
const connectorDiagnostics = [];
|
|
37
|
+
let relationOccurrencesChanged = false;
|
|
38
|
+
const normalizedRelations = {};
|
|
39
|
+
for (const key of Object.keys(view.relationOccurrences).sort()) {
|
|
40
|
+
const occurrence = view.relationOccurrences[key];
|
|
41
|
+
for (const field of Object.keys(occurrence).sort()) {
|
|
42
|
+
if (!ALLOWED_RELATION_OCCURRENCE_KEYS.has(field)) {
|
|
43
|
+
connectorDiagnostics.push(shapeInvalid(`relationOccurrences.${key}.${field}`));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const arrowhead = occurrence["arrowhead"];
|
|
47
|
+
if (arrowhead !== undefined && (isFrozenV1 || !isArrowheadKind(arrowhead))) {
|
|
48
|
+
connectorDiagnostics.push(shapeInvalid(`relationOccurrences.${key}.arrowhead`));
|
|
49
|
+
}
|
|
50
|
+
const emphasis = occurrence["emphasis"];
|
|
51
|
+
if (emphasis !== undefined && (isFrozenV1 || !isLinkEmphasis(emphasis))) {
|
|
52
|
+
connectorDiagnostics.push(shapeInvalid(`relationOccurrences.${key}.emphasis`));
|
|
53
|
+
}
|
|
54
|
+
// Frozen diagram-presentation@1 keeps its exact @1 strokeStyle check
|
|
55
|
+
// ("solid" | "dashed"); diagram-presentation@2 admits the DE-2 "dotted" word.
|
|
56
|
+
if (isV2 && occurrence["strokeStyle"] === "dotted") {
|
|
57
|
+
normalizedRelations[key] = { ...occurrence, strokeStyle: "dashed" };
|
|
58
|
+
relationOccurrencesChanged = true;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
normalizedRelations[key] = occurrence;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (isFrozenV1 && isRecord(view.summaryLabels)) {
|
|
65
|
+
for (const id of Object.keys(view.summaryLabels).sort()) {
|
|
66
|
+
const summary = view.summaryLabels[id];
|
|
67
|
+
if (isRecord(summary) && summary["strokeStyle"] === "dotted") {
|
|
68
|
+
connectorDiagnostics.push(shapeInvalid(`summaryLabels.${id}.strokeStyle`));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
let nextView = relationOccurrencesChanged
|
|
73
|
+
? { ...view, relationOccurrences: normalizedRelations }
|
|
74
|
+
: view;
|
|
75
|
+
if (!isV2 || !isRecord(diagram)) {
|
|
76
|
+
return { view: nextView, connectorDiagnostics };
|
|
77
|
+
}
|
|
14
78
|
const rawEntities = diagram["entities"];
|
|
15
79
|
if (!isRecord(rawEntities)) {
|
|
16
|
-
|
|
17
|
-
...
|
|
80
|
+
nextView = {
|
|
81
|
+
...nextView,
|
|
18
82
|
presentation: {
|
|
19
|
-
...
|
|
83
|
+
...nextView.presentation,
|
|
20
84
|
diagram: { ...diagram, contractPin: { ...DIAGRAM_PRESENTATION_CONTRACT_PIN } },
|
|
21
85
|
},
|
|
22
86
|
};
|
|
87
|
+
return { view: nextView, connectorDiagnostics };
|
|
23
88
|
}
|
|
24
89
|
const entities = {};
|
|
25
90
|
for (const [key, entry] of Object.entries(rawEntities)) {
|
|
@@ -34,10 +99,10 @@ function normalizeV2View(view) {
|
|
|
34
99
|
}
|
|
35
100
|
entities[key] = entry;
|
|
36
101
|
}
|
|
37
|
-
|
|
38
|
-
...
|
|
102
|
+
nextView = {
|
|
103
|
+
...nextView,
|
|
39
104
|
presentation: {
|
|
40
|
-
...
|
|
105
|
+
...nextView.presentation,
|
|
41
106
|
diagram: {
|
|
42
107
|
...diagram,
|
|
43
108
|
contractPin: { ...DIAGRAM_PRESENTATION_CONTRACT_PIN },
|
|
@@ -45,6 +110,7 @@ function normalizeV2View(view) {
|
|
|
45
110
|
},
|
|
46
111
|
},
|
|
47
112
|
};
|
|
113
|
+
return { view: nextView, connectorDiagnostics };
|
|
48
114
|
}
|
|
49
115
|
export function validateDiagramPresentation(...args) {
|
|
50
116
|
const [document, view, options] = args;
|
|
@@ -57,6 +123,8 @@ export function validateDiagramPresentation(...args) {
|
|
|
57
123
|
changed = true;
|
|
58
124
|
return [id, { ...relation, type }];
|
|
59
125
|
}));
|
|
60
|
-
|
|
126
|
+
const normalized = normalizeViewForPinnedAdapter(view);
|
|
127
|
+
const pinned = validatePinnedPresentation(changed ? { ...document, relations } : document, normalized.view, options);
|
|
128
|
+
return normalized.connectorDiagnostics.length === 0 ? pinned : [...normalized.connectorDiagnostics, ...pinned];
|
|
61
129
|
}
|
|
62
130
|
//# sourceMappingURL=presentation-relations.js.map
|
package/dist/presentation.d.ts
CHANGED
|
@@ -15,7 +15,8 @@ export interface PresentationPin {
|
|
|
15
15
|
readonly version: string;
|
|
16
16
|
readonly contentDigest: string;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
import type { StrokeStyle } from "./connector-registry.js";
|
|
19
|
+
export type { StrokeStyle };
|
|
19
20
|
export type DiagramForm = "card" | "container" | "legend" | "legend-key";
|
|
20
21
|
/** Text/header alignment governed by `diagram-presentation@2` (DE-1). */
|
|
21
22
|
export type PresentationAlign = "left" | "center";
|
|
@@ -119,8 +120,8 @@ export declare const DIAGRAM_PRESENTATION_RECORD: {
|
|
|
119
120
|
};
|
|
120
121
|
/** Qualified executor/adapter refs from Engram catalog entry 2. */
|
|
121
122
|
export declare const DIAGRAM_PRESENTATION_COMPATIBILITY: {
|
|
122
|
-
readonly renderer: "ds:rhanka/sent-tech-design-system/packages/diagram-core/src/presentation-apply.ts@
|
|
123
|
-
readonly adapter: "ds:rhanka/sent-tech-design-system/packages/diagram-core/src/presentation-validate.ts@
|
|
123
|
+
readonly renderer: "ds:rhanka/sent-tech-design-system/packages/diagram-core/src/presentation-apply.ts@ab7d1a7fd0142217672b5be6d40465b3e5309e50#sha256=28c3607e5c4868d44c137b66fe8e6f6ed99cb578fc52a52f67442cca41802cd8";
|
|
124
|
+
readonly adapter: "ds:rhanka/sent-tech-design-system/packages/diagram-core/src/presentation-validate.ts@ab7d1a7fd0142217672b5be6d40465b3e5309e50#sha256=488d8499b8f4e624af56d0c4f4c07496cc09863ec1e65e9f522c6fc05a4db06e";
|
|
124
125
|
};
|
|
125
126
|
/**
|
|
126
127
|
* Resolved contract catalog entry used by application authentication.
|
package/dist/validate.js
CHANGED
|
@@ -24,6 +24,7 @@ import { hashContent } from "./hash.js";
|
|
|
24
24
|
import { entityTypeOf, portTypeOf, qualifyAttributeSchema, relationTypeOf, roleOf, selectGroupingHierarchy, validateProfile, } from "./profile.js";
|
|
25
25
|
import { parseRef, refKindOf, } from "./refs.js";
|
|
26
26
|
import { createTypeResolver } from "./resolver.js";
|
|
27
|
+
import { isArrowheadKind, isLinkEmphasis, isStrokeStyle } from "./connector-registry.js";
|
|
27
28
|
import { isPresentationContractProfileId } from "./presentation.js";
|
|
28
29
|
import { validateDiagramPresentation } from "./presentation-relations.js";
|
|
29
30
|
import { analyzeSummaries, classifyInternalRelations, collapsedOf, drawnTargetOf, hiddenByFold, parentOccurrenceOf, portRepresentativeOf, representativeOf, } from "./fold.js";
|
|
@@ -1879,6 +1880,60 @@ export function validateView(view, document, options, hidden) {
|
|
|
1879
1880
|
for (const [index, waypoint] of (occurrence.waypoints ?? []).entries()) {
|
|
1880
1881
|
diagnostics.push(...finiteNumbers([["x", waypoint.x], ["y", waypoint.y]], `${path}.waypoints[${index}]`));
|
|
1881
1882
|
}
|
|
1883
|
+
if (view.presentation.diagram === undefined) {
|
|
1884
|
+
const allowedKeys = new Set([
|
|
1885
|
+
"id",
|
|
1886
|
+
"relation",
|
|
1887
|
+
"endpoints",
|
|
1888
|
+
"waypoints",
|
|
1889
|
+
"strokeStyle",
|
|
1890
|
+
"arrowhead",
|
|
1891
|
+
"emphasis",
|
|
1892
|
+
]);
|
|
1893
|
+
const raw = occurrence;
|
|
1894
|
+
for (const field of Object.keys(raw).sort()) {
|
|
1895
|
+
if (!allowedKeys.has(field)) {
|
|
1896
|
+
diagnostics.push(diagnostic({
|
|
1897
|
+
code: "occurrence-endpoint-mismatch",
|
|
1898
|
+
severity: "error",
|
|
1899
|
+
path: `${path}.${field}`,
|
|
1900
|
+
message: `relation occurrence field ${field} is not part of the closed connector vocabulary`,
|
|
1901
|
+
refs: [occurrence.id],
|
|
1902
|
+
details: { check: "presentation-shape-invalid" },
|
|
1903
|
+
}));
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
if (raw["strokeStyle"] !== undefined && !isStrokeStyle(raw["strokeStyle"])) {
|
|
1907
|
+
diagnostics.push(diagnostic({
|
|
1908
|
+
code: "occurrence-endpoint-mismatch",
|
|
1909
|
+
severity: "error",
|
|
1910
|
+
path: `${path}.strokeStyle`,
|
|
1911
|
+
message: `strokeStyle ${String(raw["strokeStyle"])} must be a closed dash-pattern word`,
|
|
1912
|
+
refs: [occurrence.id],
|
|
1913
|
+
details: { check: "presentation-shape-invalid" },
|
|
1914
|
+
}));
|
|
1915
|
+
}
|
|
1916
|
+
if (raw["arrowhead"] !== undefined && !isArrowheadKind(raw["arrowhead"])) {
|
|
1917
|
+
diagnostics.push(diagnostic({
|
|
1918
|
+
code: "occurrence-endpoint-mismatch",
|
|
1919
|
+
severity: "error",
|
|
1920
|
+
path: `${path}.arrowhead`,
|
|
1921
|
+
message: `arrowhead ${String(raw["arrowhead"])} must be a closed arrowhead word`,
|
|
1922
|
+
refs: [occurrence.id],
|
|
1923
|
+
details: { check: "presentation-shape-invalid" },
|
|
1924
|
+
}));
|
|
1925
|
+
}
|
|
1926
|
+
if (raw["emphasis"] !== undefined && !isLinkEmphasis(raw["emphasis"])) {
|
|
1927
|
+
diagnostics.push(diagnostic({
|
|
1928
|
+
code: "occurrence-endpoint-mismatch",
|
|
1929
|
+
severity: "error",
|
|
1930
|
+
path: `${path}.emphasis`,
|
|
1931
|
+
message: `emphasis ${String(raw["emphasis"])} must be a closed link-emphasis word`,
|
|
1932
|
+
refs: [occurrence.id],
|
|
1933
|
+
details: { check: "presentation-shape-invalid" },
|
|
1934
|
+
}));
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1882
1937
|
}
|
|
1883
1938
|
// Drawn representatives of projected endpoints: their container capability
|
|
1884
1939
|
// is reported once at the endpoint (`representative-not-container`), so the
|
|
@@ -1965,6 +2020,17 @@ export function validateView(view, document, options, hidden) {
|
|
|
1965
2020
|
message: `record key ${id} is not the summary definition id ${definition.id}`,
|
|
1966
2021
|
}));
|
|
1967
2022
|
}
|
|
2023
|
+
const rawStyle = definition["strokeStyle"];
|
|
2024
|
+
if (rawStyle !== undefined && !isStrokeStyle(rawStyle)) {
|
|
2025
|
+
diagnostics.push(diagnostic({
|
|
2026
|
+
code: "occurrence-endpoint-mismatch",
|
|
2027
|
+
severity: "error",
|
|
2028
|
+
path: `summaryLabels.${id}.strokeStyle`,
|
|
2029
|
+
message: `strokeStyle ${String(rawStyle)} must be a closed dash-pattern word`,
|
|
2030
|
+
refs: [id],
|
|
2031
|
+
details: { check: "presentation-shape-invalid" },
|
|
2032
|
+
}));
|
|
2033
|
+
}
|
|
1968
2034
|
}
|
|
1969
2035
|
const analysis = analyzeSummaries(view, document, {
|
|
1970
2036
|
registry: options.registry,
|
|
@@ -2026,6 +2092,25 @@ export function validateView(view, document, options, hidden) {
|
|
|
2026
2092
|
details: { check: "presentation-shape-invalid" },
|
|
2027
2093
|
}));
|
|
2028
2094
|
}
|
|
2095
|
+
const entityAnatomy = view.presentation.entityAnatomy;
|
|
2096
|
+
if (entityAnatomy !== undefined && (entityAnatomy === null || typeof entityAnatomy !== "object" || Array.isArray(entityAnatomy))) {
|
|
2097
|
+
diagnostics.push(diagnostic({
|
|
2098
|
+
code: "occurrence-endpoint-mismatch",
|
|
2099
|
+
path: "presentation.entityAnatomy",
|
|
2100
|
+
message: "entity anatomy overrides must be keyed by occurrence",
|
|
2101
|
+
}));
|
|
2102
|
+
}
|
|
2103
|
+
else {
|
|
2104
|
+
for (const [id, anatomy] of Object.entries(entityAnatomy ?? {})) {
|
|
2105
|
+
if (Object.hasOwn(view.entityOccurrences, id) && (anatomy === "v1" || anatomy === "v2"))
|
|
2106
|
+
continue;
|
|
2107
|
+
diagnostics.push(diagnostic({
|
|
2108
|
+
code: "occurrence-endpoint-mismatch",
|
|
2109
|
+
path: `presentation.entityAnatomy.${id}`,
|
|
2110
|
+
message: "anatomy must be v1 or v2 and reference an entity occurrence",
|
|
2111
|
+
}));
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2029
2114
|
if (view.presentation.diagram !== undefined) {
|
|
2030
2115
|
diagnostics.push(...validateDiagramPresentation(document, view, options));
|
|
2031
2116
|
}
|
|
@@ -21,7 +21,7 @@ export interface ViewSchemaPin {
|
|
|
21
21
|
readonly version: string;
|
|
22
22
|
readonly contentDigest: string;
|
|
23
23
|
}
|
|
24
|
-
export type ViewSchemaVersion = "1" | "2" | "3";
|
|
24
|
+
export type ViewSchemaVersion = "1" | "2" | "3" | "4";
|
|
25
25
|
export declare const DIAGRAM_VIEW_SCHEMA_ID: "diagram-view-schema";
|
|
26
26
|
export declare const DIAGRAM_VIEW_SCHEMA_V1: Record<string, unknown>;
|
|
27
27
|
export declare const DIAGRAM_VIEW_SCHEMA_V1_DIGEST: string;
|
|
@@ -46,6 +46,9 @@ export type ViewSchemaResolution = {
|
|
|
46
46
|
export declare const DIAGRAM_VIEW_SCHEMA_V3: Record<string, unknown>;
|
|
47
47
|
export declare const DIAGRAM_VIEW_SCHEMA_V3_DIGEST: string;
|
|
48
48
|
export declare const DIAGRAM_VIEW_SCHEMA_V3_PIN: ViewSchemaPin;
|
|
49
|
+
export declare const DIAGRAM_VIEW_SCHEMA_V4: Record<string, unknown>;
|
|
50
|
+
export declare const DIAGRAM_VIEW_SCHEMA_V4_DIGEST: string;
|
|
51
|
+
export declare const DIAGRAM_VIEW_SCHEMA_V4_PIN: ViewSchemaPin;
|
|
49
52
|
/**
|
|
50
53
|
* Resolve a view schema by exact pin only. Never throws: every failure is a
|
|
51
54
|
* typed refusal. No "latest", no fallback, no reverse migration.
|
package/dist/view-schema-pin.js
CHANGED
|
@@ -87,6 +87,38 @@ export const DIAGRAM_VIEW_SCHEMA_V3_DIGEST = sha256Hex(canonicalBytes(PRIVATE_V3
|
|
|
87
87
|
export const DIAGRAM_VIEW_SCHEMA_V3_PIN = deepFreezeValue({
|
|
88
88
|
id: DIAGRAM_VIEW_SCHEMA_ID, version: "3", contentDigest: DIAGRAM_VIEW_SCHEMA_V3_DIGEST,
|
|
89
89
|
});
|
|
90
|
+
/**
|
|
91
|
+
* Additive successor (DE-2): closed connector presentation registries
|
|
92
|
+
* (`strokeStyle: solid | dashed | dotted`, `arrowhead: arrow | none`,
|
|
93
|
+
* `emphasis: default | emphasis`) plus DE-1 `presentation.anatomy` and `diagram-presentation@2`
|
|
94
|
+
* (`align`). `@1/@2/@3` bytes and digests remain untouched; additional arrowheads are reserved for N2.
|
|
95
|
+
*/
|
|
96
|
+
const PRIVATE_V4_SCHEMA = (() => {
|
|
97
|
+
const schema = deepCloneValue(PRIVATE_V3_SCHEMA);
|
|
98
|
+
schema["$id"] = "engram:diagram-view-schema/4";
|
|
99
|
+
const rootProps = schema["properties"];
|
|
100
|
+
const presentationProps = rootProps["presentation"]["properties"];
|
|
101
|
+
presentationProps["anatomy"] = { enum: ["v1", "v2"] };
|
|
102
|
+
presentationProps["entityAnatomy"] = { type: "object", additionalProperties: { enum: ["v1", "v2"] } };
|
|
103
|
+
const diagramProps = presentationProps["diagram"]["properties"];
|
|
104
|
+
const pinProps = diagramProps["contractPin"]["properties"];
|
|
105
|
+
pinProps["version"] = { enum: ["1", "2"] };
|
|
106
|
+
const entityProps = diagramProps["entities"]["additionalProperties"]["properties"];
|
|
107
|
+
entityProps["align"] = { enum: ["left", "center"] };
|
|
108
|
+
const relOccProps = rootProps["relationOccurrences"]["additionalProperties"]["properties"];
|
|
109
|
+
relOccProps["strokeStyle"] = { enum: ["solid", "dashed", "dotted"] };
|
|
110
|
+
relOccProps["arrowhead"] = { enum: ["arrow", "none"] };
|
|
111
|
+
relOccProps["emphasis"] = { enum: ["default", "emphasis"] };
|
|
112
|
+
const summaryProps = rootProps["summaryLabels"]["additionalProperties"]["properties"];
|
|
113
|
+
summaryProps["strokeStyle"] = { enum: ["solid", "dashed", "dotted"] };
|
|
114
|
+
return schema;
|
|
115
|
+
})();
|
|
116
|
+
deepFreezeValue(PRIVATE_V4_SCHEMA);
|
|
117
|
+
export const DIAGRAM_VIEW_SCHEMA_V4 = frozenCopy(PRIVATE_V4_SCHEMA);
|
|
118
|
+
export const DIAGRAM_VIEW_SCHEMA_V4_DIGEST = sha256Hex(canonicalBytes(PRIVATE_V4_SCHEMA));
|
|
119
|
+
export const DIAGRAM_VIEW_SCHEMA_V4_PIN = deepFreezeValue({
|
|
120
|
+
id: DIAGRAM_VIEW_SCHEMA_ID, version: "4", contentDigest: DIAGRAM_VIEW_SCHEMA_V4_DIGEST,
|
|
121
|
+
});
|
|
90
122
|
const ALLOWED_PIN_KEYS = new Set(["id", "version", "contentDigest"]);
|
|
91
123
|
/**
|
|
92
124
|
* Exact-key shape gate, mirroring `isWellFormedPin` in
|
|
@@ -146,9 +178,15 @@ export function resolveViewSchema(pin) {
|
|
|
146
178
|
return { ok: false, refusal: { code: "pin-malformed" } };
|
|
147
179
|
if (id !== DIAGRAM_VIEW_SCHEMA_ID)
|
|
148
180
|
return { ok: false, refusal: { code: "unknown-schema-id" } };
|
|
149
|
-
if (version !== "1" && version !== "2" && version !== "3")
|
|
181
|
+
if (version !== "1" && version !== "2" && version !== "3" && version !== "4")
|
|
150
182
|
return { ok: false, refusal: { code: "unknown-schema-version" } };
|
|
151
|
-
const expected = version === "1"
|
|
183
|
+
const expected = version === "1"
|
|
184
|
+
? DIAGRAM_VIEW_SCHEMA_V1_DIGEST
|
|
185
|
+
: version === "2"
|
|
186
|
+
? DIAGRAM_VIEW_SCHEMA_V2_DIGEST
|
|
187
|
+
: version === "3"
|
|
188
|
+
? DIAGRAM_VIEW_SCHEMA_V3_DIGEST
|
|
189
|
+
: DIAGRAM_VIEW_SCHEMA_V4_DIGEST;
|
|
152
190
|
if (contentDigest !== expected)
|
|
153
191
|
return { ok: false, refusal: { code: "schema-digest-mismatch" } };
|
|
154
192
|
if (version === "1") {
|
|
@@ -158,6 +196,8 @@ export function resolveViewSchema(pin) {
|
|
|
158
196
|
}
|
|
159
197
|
if (version === "3")
|
|
160
198
|
return { ok: true, version: "3", pin: frozenCopy(DIAGRAM_VIEW_SCHEMA_V3_PIN), schema: DIAGRAM_VIEW_SCHEMA_V3 };
|
|
199
|
+
if (version === "4")
|
|
200
|
+
return { ok: true, version: "4", pin: frozenCopy(DIAGRAM_VIEW_SCHEMA_V4_PIN), schema: DIAGRAM_VIEW_SCHEMA_V4 };
|
|
161
201
|
if (DIAGRAM_VIEW_SCHEMA_V2 === undefined)
|
|
162
202
|
return { ok: false, refusal: { code: "schema-bytes-unavailable" } };
|
|
163
203
|
return { ok: true, version: "2", pin: frozenCopy(DIAGRAM_VIEW_SCHEMA_V2_PIN), schema: DIAGRAM_VIEW_SCHEMA_V2 };
|
package/dist/view.d.ts
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
* occurrence id is unique across the three (checked as `duplicate-id`).
|
|
18
18
|
*/
|
|
19
19
|
import type { DocumentRef, EntityRef, OccurrenceRef, PortRef, RelationRef, ViewRef } from "./refs.js";
|
|
20
|
-
import type {
|
|
20
|
+
import type { ArrowheadKind, LinkEmphasis, StrokeStyle } from "./connector-registry.js";
|
|
21
|
+
import type { DiagramPresentation } from "./presentation.js";
|
|
21
22
|
export interface Point {
|
|
22
23
|
readonly x: number;
|
|
23
24
|
readonly y: number;
|
|
@@ -76,10 +77,20 @@ export interface RelationOccurrence {
|
|
|
76
77
|
/** Persisted route hints. An empty/absent list means "the renderer routes it". */
|
|
77
78
|
readonly waypoints?: readonly Point[];
|
|
78
79
|
/**
|
|
79
|
-
*
|
|
80
|
-
* from explicit solid and is preserved byte-for-byte.
|
|
80
|
+
* Dash-pattern registry word (`solid | dashed | dotted`; `dashed` means "proposed").
|
|
81
|
+
* Absent is distinct from explicit solid and is preserved byte-for-byte.
|
|
81
82
|
*/
|
|
82
83
|
readonly strokeStyle?: StrokeStyle;
|
|
84
|
+
/**
|
|
85
|
+
* Arrowhead registry word (`arrow | none`, DE-2; further heads reserved for N2).
|
|
86
|
+
* Absent means default arrow and is preserved byte-for-byte.
|
|
87
|
+
*/
|
|
88
|
+
readonly arrowhead?: ArrowheadKind;
|
|
89
|
+
/**
|
|
90
|
+
* Link emphasis word (`default | emphasis`, DE-2): distinct colour + width,
|
|
91
|
+
* never a dash style. Absent is preserved byte-for-byte.
|
|
92
|
+
*/
|
|
93
|
+
readonly emphasis?: LinkEmphasis;
|
|
83
94
|
}
|
|
84
95
|
export type PortSide = "north" | "east" | "south" | "west";
|
|
85
96
|
/**
|
|
@@ -130,8 +141,8 @@ export interface SummaryDefinition {
|
|
|
130
141
|
readonly label: string;
|
|
131
142
|
/** Sorted, distinct, non-empty semantic relation ids of the selected set. */
|
|
132
143
|
readonly relationIds: readonly RelationRef[];
|
|
133
|
-
/** Absent selects solid only.
|
|
134
|
-
readonly strokeStyle?:
|
|
144
|
+
/** Absent selects solid only. Distinct dash styles never aggregate together. */
|
|
145
|
+
readonly strokeStyle?: StrokeStyle;
|
|
135
146
|
/**
|
|
136
147
|
* Complete selected candidate occurrence set for the scope/style. Absent
|
|
137
148
|
* means the scope/style must select at most one occurrence per relation
|
|
@@ -186,6 +197,8 @@ export interface PresentationState {
|
|
|
186
197
|
readonly theme?: string;
|
|
187
198
|
/** Pinned card/zone anatomy (`diagram-anatomy/v1 | v2`). Absent means legacy `"v1"`; `"v2"` is opt-in. */
|
|
188
199
|
readonly anatomy?: DiagramAnatomyVersion;
|
|
200
|
+
/** Per-occurrence anatomy overrides for mixed full-size and compact scenes. */
|
|
201
|
+
readonly entityAnatomy?: Readonly<Record<string, DiagramAnatomyVersion>>;
|
|
189
202
|
/** Typed presentation fragment (M3 §3.2.2). Absent means no presentation contract. */
|
|
190
203
|
readonly diagram?: DiagramPresentation;
|
|
191
204
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentropic/diagram-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Typed semantic core for diagrams: versioned documents and profiles, views with occurrences, transactional commands with logical inverses. No runtime dependency, no DOM, no framework.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -25,8 +25,12 @@
|
|
|
25
25
|
},
|
|
26
26
|
"./schemas/diagram-view-schema-3.json": "./schemas/diagram-view-schema-3.json",
|
|
27
27
|
"./schemas/diagram-view-schema-3.sha256": "./schemas/diagram-view-schema-3.sha256",
|
|
28
|
+
"./schemas/diagram-view-schema-4.json": "./schemas/diagram-view-schema-4.json",
|
|
29
|
+
"./schemas/diagram-view-schema-4.sha256": "./schemas/diagram-view-schema-4.sha256",
|
|
28
30
|
"./schemas/ds-layout-hints-1.json": "./schemas/ds-layout-hints-1.json",
|
|
29
|
-
"./schemas/ds-layout-hints-1.sha256": "./schemas/ds-layout-hints-1.sha256"
|
|
31
|
+
"./schemas/ds-layout-hints-1.sha256": "./schemas/ds-layout-hints-1.sha256",
|
|
32
|
+
"./schemas/ds-layout-hints-2.json": "./schemas/ds-layout-hints-2.json",
|
|
33
|
+
"./schemas/ds-layout-hints-2.sha256": "./schemas/ds-layout-hints-2.sha256"
|
|
30
34
|
},
|
|
31
35
|
"types": "./dist/index.d.ts",
|
|
32
36
|
"main": "./dist/index.js",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"$id":"engram:diagram-view-schema/4","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"entityOccurrences":{"additionalProperties":{"additionalProperties":false,"properties":{"entity":{"type":"string"},"geometry":{"additionalProperties":false,"properties":{"height":{"type":"number"},"width":{"type":"number"},"x":{"type":"number"},"y":{"type":"number"}},"required":["x","y","width","height"],"type":"object"},"group":{"type":"string"},"id":{"type":"string"},"z":{"type":"number"}},"required":["id","entity","geometry"],"type":"object"},"type":"object"},"filters":{"items":{"anyOf":[{"additionalProperties":false,"properties":{"id":{"type":"string"},"kind":{"const":"entity-type"},"mode":{"enum":["include","exclude"]},"types":{"items":{"type":"string"},"type":"array"}},"required":["id","kind","types","mode"],"type":"object"},{"additionalProperties":false,"properties":{"id":{"type":"string"},"kind":{"const":"relation-type"},"mode":{"enum":["include","exclude"]},"types":{"items":{"type":"string"},"type":"array"}},"required":["id","kind","types","mode"],"type":"object"},{"additionalProperties":false,"properties":{"attribute":{"type":"string"},"id":{"type":"string"},"kind":{"const":"attribute-equals"},"mode":{"enum":["include","exclude"]},"value":{"type":"string"}},"required":["id","kind","attribute","value","mode"],"type":"object"}]},"type":"array"},"groups":{"additionalProperties":{"additionalProperties":false,"properties":{"collapsed":{"type":"boolean"},"id":{"type":"string"},"label":{"type":"string"},"occurrence":{"type":"string"}},"required":["id"],"type":"object"},"type":"object"},"portOccurrences":{"additionalProperties":{"additionalProperties":false,"properties":{"anchor":{"maximum":1,"minimum":0,"type":"number"},"id":{"type":"string"},"order":{"type":"number"},"ownerOccurrence":{"type":"string"},"port":{"type":"string"},"side":{"enum":["north","east","south","west"]}},"required":["id","port","ownerOccurrence","side","order","anchor"],"type":"object"},"type":"object"},"presentation":{"additionalProperties":false,"properties":{"anatomy":{"enum":["v1","v2"]},"camera":{"additionalProperties":false,"properties":{"x":{"type":"number"},"y":{"type":"number"},"zoom":{"type":"number"}},"required":["x","y","zoom"],"type":"object"},"diagram":{"additionalProperties":false,"properties":{"categoryTokens":{"items":{"additionalProperties":false,"properties":{"category":{"maxLength":40,"minLength":1,"pattern":"^[a-z][a-z0-9-]*$","type":"string"},"legendRef":{"minLength":1,"type":"string"},"token":{"maxLength":80,"minLength":1,"pattern":"^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)*$","type":"string"}},"required":["legendRef","category","token"],"type":"object"},"type":"array"},"contractPin":{"additionalProperties":false,"properties":{"contentDigest":{"pattern":"^[0-9a-f]{64}$","type":"string"},"id":{"const":"diagram-presentation"},"version":{"enum":["1","2"]}},"required":["id","version","contentDigest"],"type":"object"},"entities":{"additionalProperties":{"additionalProperties":false,"allOf":[{"if":{"properties":{"form":{"const":"legend-key"}},"required":["form"]},"then":{"properties":{"text":{"properties":{"title":{"maxLength":120,"type":"string"}},"type":"object"}}}}],"properties":{"align":{"enum":["left","center"]},"categoryRef":{"minLength":1,"type":"string"},"form":{"enum":["card","container","legend","legend-key"]},"icon":{"maxLength":40,"minLength":1,"pattern":"^[a-z][a-z0-9-]*$","type":"string"},"text":{"additionalProperties":false,"properties":{"body":{"maxLength":400,"type":"string"},"detail":{"maxLength":400,"type":"string"},"footer":{"maxLength":120,"type":"string"},"kicker":{"maxLength":80,"type":"string"},"subtitle":{"maxLength":600,"type":"string"},"title":{"maxLength":200,"type":"string"}},"type":"object"}},"required":["form","text"],"type":"object"},"type":"object"},"legends":{"additionalProperties":{"additionalProperties":false,"properties":{"order":{"items":{"minLength":1,"type":"string"},"type":"array","uniqueItems":true}},"required":["order"],"type":"object"},"type":"object"}},"required":["contractPin","entities","legends","categoryTokens"],"type":"object"},"entityAnatomy":{"additionalProperties":{"enum":["v1","v2"]},"type":"object"},"grid":{"additionalProperties":false,"properties":{"size":{"type":"number"},"snap":{"type":"boolean"}},"required":["size","snap"],"type":"object"},"theme":{"type":"string"}},"required":["camera"],"type":"object"},"relationOccurrences":{"additionalProperties":{"additionalProperties":false,"properties":{"arrowhead":{"enum":["arrow","none"]},"emphasis":{"enum":["default","emphasis"]},"endpoints":{"items":{"additionalProperties":false,"dependentRequired":{"chainProvenance":["semanticTarget"],"sourceOccurrence":["semanticTarget"]},"dependentSchemas":{"semanticTarget":{"oneOf":[{"properties":{"chainProvenance":false,"sourceOccurrence":true},"required":["sourceOccurrence"]},{"properties":{"chainProvenance":true,"sourceOccurrence":false},"required":["chainProvenance"]}]}},"properties":{"chainProvenance":{"additionalProperties":false,"properties":{"hops":{"items":{"type":"string"},"type":"array"},"members":{"items":{"type":"string"},"type":"array"},"predicateId":{"minLength":1,"type":"string"}},"required":["predicateId","hops"],"type":"object"},"occurrence":{"type":"string"},"role":{"type":"string"},"semanticTarget":{"type":"string"},"sourceOccurrence":{"type":"string"}},"required":["role","occurrence"],"type":"object"},"type":"array"},"id":{"type":"string"},"relation":{"type":"string"},"strokeStyle":{"enum":["solid","dashed","dotted"]},"waypoints":{"items":{"additionalProperties":false,"properties":{"x":{"type":"number"},"y":{"type":"number"}},"required":["x","y"],"type":"object"},"type":"array"}},"required":["id","relation","endpoints"],"type":"object"},"type":"object"},"revision":{"minimum":0,"type":"integer"},"semanticDocumentId":{"type":"string"},"summaryLabels":{"additionalProperties":{"additionalProperties":false,"properties":{"id":{"type":"string"},"label":{"type":"string"},"relationIds":{"items":{"type":"string"},"minItems":1,"type":"array"},"relationOccurrences":{"items":{"type":"string"},"type":"array"},"sourceOccurrence":{"type":"string"},"strokeStyle":{"enum":["solid","dashed","dotted"]},"targetOccurrence":{"type":"string"}},"required":["id","sourceOccurrence","targetOccurrence","label","relationIds"],"type":"object"},"type":"object"},"viewId":{"type":"string"}},"required":["viewId","semanticDocumentId","revision","entityOccurrences","relationOccurrences","portOccurrences","groups","filters","presentation"],"type":"object"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fca61a87490d5ba7ed0f10c5144d6871e0087a68f2f19b1025c18dacfcdb8916
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"$defs":{"align":{"enum":["start","center","end","stretch"]},"axis":{"enum":["rows","columns"]},"band":{"additionalProperties":false,"properties":{"id":{"$ref":"#/$defs/id"},"items":{"items":{"$ref":"#/$defs/entityRef"},"maxItems":32,"minItems":0,"type":"array"}},"required":["id","items"],"type":"object"},"cell":{"additionalProperties":false,"properties":{"align":{"$ref":"#/$defs/align"},"column":{"$ref":"#/$defs/id"},"justify":{"$ref":"#/$defs/align"},"to_band":{"$ref":"#/$defs/id"},"to_column":{"$ref":"#/$defs/id"}},"type":"object"},"entityRef":{"pattern":"^entity:[A-Za-z0-9][A-Za-z0-9._-]*$","type":"string"},"entityRefList":{"items":{"$ref":"#/$defs/entityRef"},"type":"array","uniqueItems":true},"forbiddenHint":{"enum":["cardGapX","cardGapY","density","edge_label_orientation","gapAfter","height","rankGap","width","x","y","zoneGapX","zoneGapY","anchor","bottom","dc","dx","dy","gap","gutter","labelAt","label_at","left","margin","offset","padding","pin","pins","points","position","right","scale","size","top","via","waypoints","zoom"]},"futureBandValue":{"enum":["inherit"]},"futureHint":{"enum":["compared_panels","loop_corridor","foldable","direction","rotate_labels"]},"futureMode":{"enum":["tree"]},"grid":{"additionalProperties":false,"properties":{"cells":{"additionalProperties":false,"patternProperties":{"^entity:[A-Za-z0-9][A-Za-z0-9._-]*$":{"$ref":"#/$defs/cell"}},"type":"object"},"peripheral_columns":{"items":{"$ref":"#/$defs/peripheralColumn"},"minItems":0,"type":"array"},"stage_columns":{"anyOf":[{"items":{"$ref":"#/$defs/id"},"maxItems":16,"minItems":1,"type":"array"},{"const":"inherit"}]},"transverse_bands":{"items":{"$ref":"#/$defs/band"},"maxItems":24,"minItems":1,"type":"array"}},"required":["transverse_bands"],"type":"object"},"grids":{"additionalProperties":false,"patternProperties":{"^entity:[A-Za-z0-9][A-Za-z0-9._-]*$":{"$ref":"#/$defs/grid"}},"properties":{"root":{"$ref":"#/$defs/grid"}},"required":["root"],"type":"object"},"group":{"additionalProperties":false,"properties":{"direction":{"$ref":"#/$defs/axis"},"id":{"maxLength":80,"minLength":1,"type":"string"},"items":{"items":{"anyOf":[{"$ref":"#/$defs/entityRef"},{"$ref":"#/$defs/group"}]},"minItems":1,"type":"array"},"stretch":{"type":"boolean"}},"required":["id","direction","items"],"type":"object"},"id":{"pattern":"^[a-z][a-z0-9-]{0,39}$","type":"string"},"layeredFlowScope":{"properties":{"diagramPresentation":{"const":false},"presentationVocabulary":false,"profiles":{"items":{"const":"generic@1"},"minItems":1,"type":"array"}},"required":["profiles","diagramPresentation"],"type":"object"},"measuredHint":{"enum":["grouping","grouping_axis","ordering","rootOrder","stretch"]},"mode":{"enum":["auto-pack","layered-flow","stage-columns"]},"modeScope":{"auto-pack":{"enum":["grids","stacks","aspect","fanIn","fanOut","legend"]},"layered-flow":{"enum":["grouping","grouping_axis","ordering","rootOrder","stretch","grids","stacks","aspect","fanIn","fanOut","legend"]},"stage-columns":{"enum":["grouping","grouping_axis","stretch"]}},"peripheralColumn":{"additionalProperties":false,"properties":{"from_band":{"$ref":"#/$defs/id"},"id":{"$ref":"#/$defs/id"},"items":{"items":{"$ref":"#/$defs/entityRef"},"maxItems":16,"minItems":1,"type":"array"},"side":{"enum":["start","end"]}},"required":["id","side","items"],"type":"object"},"stack":{"additionalProperties":false,"properties":{"align":{"$ref":"#/$defs/align"},"axis":{"enum":["row","column"]}},"required":["axis"],"type":"object"},"supersededMode":{"enum":["lane-stack","matrix-grid"]}},"$id":"https://sentropic.dev/schemas/diagram/layout-hints/v2","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"allOf":[{"if":{"properties":{"mode":{"const":"auto-pack"}},"required":["mode"]},"then":{"properties":{"aspect":false,"fanIn":false,"fanOut":false,"grids":false,"legend":false,"stacks":false}}},{"if":{"properties":{"mode":{"const":"layered-flow"}},"required":["mode"]},"then":{"properties":{"aspect":false,"fanIn":false,"fanOut":false,"grids":false,"grouping":false,"grouping_axis":false,"legend":false,"ordering":false,"rootOrder":false,"stacks":false,"stretch":false}}},{"if":{"properties":{"mode":{"const":"stage-columns"}},"required":["mode"]},"then":{"properties":{"grids":{"$ref":"#/$defs/grids"},"grouping":false,"grouping_axis":false,"stretch":false},"required":["grids"]}}],"dependentSchemas":{"grouping":{"properties":{"grouping_axis":false}}},"properties":{"aspect":{"enum":["16:9","free"]},"fanIn":{"enum":["comb","separate"]},"fanOut":{"enum":["comb","separate"]},"grids":{"$ref":"#/$defs/grids"},"grouping":{"items":{"$ref":"#/$defs/group"},"type":"array"},"grouping_axis":{"$ref":"#/$defs/axis"},"legend":{"enum":["right","bottom","free-cell","none"]},"mode":{"$ref":"#/$defs/mode"},"ordering":{"additionalProperties":{"$ref":"#/$defs/entityRefList"},"propertyNames":{"$ref":"#/$defs/entityRef"},"type":"object"},"rootOrder":{"$ref":"#/$defs/entityRefList"},"stacks":{"additionalProperties":false,"patternProperties":{"^entity:[A-Za-z0-9][A-Za-z0-9._-]*$":{"$ref":"#/$defs/stack"}},"type":"object"},"stretch":{"type":"boolean"},"vocabulary":{"const":"ds-layout-hints@2"}},"required":["vocabulary","mode"],"title":"ds-layout-hints@2","type":"object"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
f67182ff68bbd5119575c7cb482f2115616b033b59af4455d03fca6f7b64b4a7
|