wabachi 0.1.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/README.md +84 -0
- package/dist/architecture/canon/authority.d.ts +35 -0
- package/dist/architecture/canon/authority.js +76 -0
- package/dist/architecture/canon/authority.js.map +1 -0
- package/dist/architecture/canon/boundaries.d.ts +31 -0
- package/dist/architecture/canon/boundaries.js +73 -0
- package/dist/architecture/canon/boundaries.js.map +1 -0
- package/dist/architecture/canon/codec.d.ts +10 -0
- package/dist/architecture/canon/codec.js +516 -0
- package/dist/architecture/canon/codec.js.map +1 -0
- package/dist/architecture/canon/constraints.d.ts +60 -0
- package/dist/architecture/canon/constraints.js +116 -0
- package/dist/architecture/canon/constraints.js.map +1 -0
- package/dist/architecture/canon/decisions.d.ts +62 -0
- package/dist/architecture/canon/decisions.js +192 -0
- package/dist/architecture/canon/decisions.js.map +1 -0
- package/dist/architecture/canon/deployment.d.ts +89 -0
- package/dist/architecture/canon/deployment.js +156 -0
- package/dist/architecture/canon/deployment.js.map +1 -0
- package/dist/architecture/canon/document.d.ts +60 -0
- package/dist/architecture/canon/document.js +106 -0
- package/dist/architecture/canon/document.js.map +1 -0
- package/dist/architecture/canon/elements.d.ts +21 -0
- package/dist/architecture/canon/elements.js +87 -0
- package/dist/architecture/canon/elements.js.map +1 -0
- package/dist/architecture/canon/flows.d.ts +37 -0
- package/dist/architecture/canon/flows.js +82 -0
- package/dist/architecture/canon/flows.js.map +1 -0
- package/dist/architecture/canon/identity.d.ts +45 -0
- package/dist/architecture/canon/identity.js +83 -0
- package/dist/architecture/canon/identity.js.map +1 -0
- package/dist/architecture/canon/relationships.d.ts +48 -0
- package/dist/architecture/canon/relationships.js +181 -0
- package/dist/architecture/canon/relationships.js.map +1 -0
- package/dist/architecture/canon/repository-mappings.d.ts +51 -0
- package/dist/architecture/canon/repository-mappings.js +134 -0
- package/dist/architecture/canon/repository-mappings.js.map +1 -0
- package/dist/architecture/canon/responsibilities.d.ts +40 -0
- package/dist/architecture/canon/responsibilities.js +89 -0
- package/dist/architecture/canon/responsibilities.js.map +1 -0
- package/dist/architecture/canon/validate.d.ts +14 -0
- package/dist/architecture/canon/validate.js +389 -0
- package/dist/architecture/canon/validate.js.map +1 -0
- package/dist/architecture/canon/views.d.ts +101 -0
- package/dist/architecture/canon/views.js +182 -0
- package/dist/architecture/canon/views.js.map +1 -0
- package/dist/architecture/cli.d.ts +2 -0
- package/dist/architecture/cli.js +158 -0
- package/dist/architecture/cli.js.map +1 -0
- package/dist/architecture/documentation/html.d.ts +3 -0
- package/dist/architecture/documentation/html.js +143 -0
- package/dist/architecture/documentation/html.js.map +1 -0
- package/dist/architecture/documentation/model.d.ts +46 -0
- package/dist/architecture/documentation/model.js +13 -0
- package/dist/architecture/documentation/model.js.map +1 -0
- package/dist/architecture/documentation/project.d.ts +4 -0
- package/dist/architecture/documentation/project.js +166 -0
- package/dist/architecture/documentation/project.js.map +1 -0
- package/dist/architecture/documentation/site.d.ts +43 -0
- package/dist/architecture/documentation/site.js +147 -0
- package/dist/architecture/documentation/site.js.map +1 -0
- package/dist/architecture/projection/structurizr-export.d.ts +65 -0
- package/dist/architecture/projection/structurizr-export.js +136 -0
- package/dist/architecture/projection/structurizr-export.js.map +1 -0
- package/dist/architecture/projection/structurizr.d.ts +34 -0
- package/dist/architecture/projection/structurizr.js +667 -0
- package/dist/architecture/projection/structurizr.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +143 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/correlation.d.ts +143 -0
- package/dist/runtime/correlation.js +919 -0
- package/dist/runtime/correlation.js.map +1 -0
- package/dist/runtime/facts.d.ts +138 -0
- package/dist/runtime/facts.js +614 -0
- package/dist/runtime/facts.js.map +1 -0
- package/dist/runtime/fixtureProvider.d.ts +10 -0
- package/dist/runtime/fixtureProvider.js +30 -0
- package/dist/runtime/fixtureProvider.js.map +1 -0
- package/dist/runtime/graftProvider.d.ts +8 -0
- package/dist/runtime/graftProvider.js +107 -0
- package/dist/runtime/graftProvider.js.map +1 -0
- package/dist/runtime/graftWiring.d.ts +30 -0
- package/dist/runtime/graftWiring.js +3 -0
- package/dist/runtime/graftWiring.js.map +1 -0
- package/dist/runtime/manifest.d.ts +17 -0
- package/dist/runtime/manifest.js +39 -0
- package/dist/runtime/manifest.js.map +1 -0
- package/dist/runtime/matrix.d.ts +337 -0
- package/dist/runtime/matrix.js +1485 -0
- package/dist/runtime/matrix.js.map +1 -0
- package/dist/runtime/observation.d.ts +36 -0
- package/dist/runtime/observation.js +3 -0
- package/dist/runtime/observation.js.map +1 -0
- package/dist/runtime/provider.d.ts +34 -0
- package/dist/runtime/provider.js +2 -0
- package/dist/runtime/provider.js.map +1 -0
- package/dist/runtime/repository.d.ts +20 -0
- package/dist/runtime/repository.js +55 -0
- package/dist/runtime/repository.js.map +1 -0
- package/dist/runtime/run.d.ts +21 -0
- package/dist/runtime/run.js +80 -0
- package/dist/runtime/run.js.map +1 -0
- package/dist/runtime/scipProvider.d.ts +11 -0
- package/dist/runtime/scipProvider.js +126 -0
- package/dist/runtime/scipProvider.js.map +1 -0
- package/dist/runtime/typescriptProvider.d.ts +10 -0
- package/dist/runtime/typescriptProvider.js +289 -0
- package/dist/runtime/typescriptProvider.js.map +1 -0
- package/dist/runtime/workflow.d.ts +30 -0
- package/dist/runtime/workflow.js +153 -0
- package/dist/runtime/workflow.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { validateArchitectureDocument } from "../canon/validate.js";
|
|
2
|
+
const SECTION_GROUP_KEYS = {
|
|
3
|
+
structure: ["elements", "interfaces", "relationships", "boundaries"],
|
|
4
|
+
responsibility: ["responsibilities"],
|
|
5
|
+
authority: ["authority", "ownership"],
|
|
6
|
+
constraints: ["constraints"],
|
|
7
|
+
flows: ["flows"],
|
|
8
|
+
deployment: ["runtimeEnvironments", "deploymentNodes", "deploymentInstances", "infrastructureReferences", "mappings"],
|
|
9
|
+
mappings: ["repositoryMappings"],
|
|
10
|
+
decisions: ["decisions"],
|
|
11
|
+
references: ["references", "attachments"],
|
|
12
|
+
views: ["views"],
|
|
13
|
+
};
|
|
14
|
+
function freezeArray(values) {
|
|
15
|
+
return Object.freeze([...values]);
|
|
16
|
+
}
|
|
17
|
+
function createAnchor(canonId) {
|
|
18
|
+
return Object.freeze({ canonId });
|
|
19
|
+
}
|
|
20
|
+
function createAnchors(ids) {
|
|
21
|
+
const seen = new Set();
|
|
22
|
+
const anchors = [];
|
|
23
|
+
for (const id of ids) {
|
|
24
|
+
if (id === undefined || seen.has(id))
|
|
25
|
+
continue;
|
|
26
|
+
seen.add(id);
|
|
27
|
+
anchors.push(createAnchor(id));
|
|
28
|
+
}
|
|
29
|
+
return freezeArray(anchors);
|
|
30
|
+
}
|
|
31
|
+
function createEntry(key, data, anchorIds) {
|
|
32
|
+
return Object.freeze({ key, anchors: createAnchors(anchorIds), data });
|
|
33
|
+
}
|
|
34
|
+
function compareEntries(left, right) {
|
|
35
|
+
if (left.key < right.key)
|
|
36
|
+
return -1;
|
|
37
|
+
if (left.key > right.key)
|
|
38
|
+
return 1;
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
function createGroup(key, entries) {
|
|
42
|
+
return Object.freeze({ key, entries: freezeArray([...entries].sort(compareEntries)) });
|
|
43
|
+
}
|
|
44
|
+
function createSection(key, groups) {
|
|
45
|
+
return Object.freeze({ key, groups: freezeArray(groups) });
|
|
46
|
+
}
|
|
47
|
+
function tupleKey(...parts) {
|
|
48
|
+
return JSON.stringify(parts);
|
|
49
|
+
}
|
|
50
|
+
function relationshipEntry(relationship) {
|
|
51
|
+
return createEntry(tupleKey(relationship.source, relationship.target, relationship.kind, relationship.interfaceId), relationship, [relationship.source, relationship.target, relationship.interfaceId]);
|
|
52
|
+
}
|
|
53
|
+
function authorityEntry(fact) {
|
|
54
|
+
return createEntry(tupleKey(fact.kind, fact.concern, fact.owner), fact, [fact.concern, fact.owner]);
|
|
55
|
+
}
|
|
56
|
+
function ownershipEntry(fact) {
|
|
57
|
+
return createEntry(tupleKey(fact.kind, fact.resource, fact.owner), fact, [fact.resource, fact.owner]);
|
|
58
|
+
}
|
|
59
|
+
function constraintEntry(constraint) {
|
|
60
|
+
switch (constraint.kind) {
|
|
61
|
+
case "single-authority":
|
|
62
|
+
return createEntry(tupleKey(constraint.kind, constraint.concern), constraint, [constraint.concern]);
|
|
63
|
+
case "must-go-through":
|
|
64
|
+
return createEntry(tupleKey(constraint.kind, constraint.source, constraint.target, constraint.through), constraint, [constraint.source, constraint.target, constraint.through]);
|
|
65
|
+
default:
|
|
66
|
+
return createEntry(tupleKey(constraint.kind, constraint.source, constraint.target), constraint, [
|
|
67
|
+
constraint.source,
|
|
68
|
+
constraint.target,
|
|
69
|
+
]);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function deploymentMappingEntry(mapping) {
|
|
73
|
+
return createEntry(tupleKey(mapping.softwareElementId, mapping.deploymentInstanceId), mapping, [
|
|
74
|
+
mapping.softwareElementId,
|
|
75
|
+
mapping.deploymentInstanceId,
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
function referenceAttachmentEntry(attachment) {
|
|
79
|
+
return createEntry(tupleKey(attachment.targetId, ...attachment.referenceIds), attachment, [
|
|
80
|
+
attachment.targetId,
|
|
81
|
+
...attachment.referenceIds,
|
|
82
|
+
]);
|
|
83
|
+
}
|
|
84
|
+
function viewEntry(view) {
|
|
85
|
+
const references = [...view.scope.include, ...view.scope.exclude];
|
|
86
|
+
return createEntry(view.key, view, references.map((reference) => reference.id));
|
|
87
|
+
}
|
|
88
|
+
function createSections(document) {
|
|
89
|
+
const structure = createSection("structure", [
|
|
90
|
+
createGroup("elements", document.elements.map((element) => createEntry(element.id, element, [element.id, element.parentId]))),
|
|
91
|
+
createGroup("interfaces", document.interfaces.map((contract) => createEntry(contract.id, contract, [contract.id, contract.owner]))),
|
|
92
|
+
createGroup("relationships", document.relationships.map(relationshipEntry)),
|
|
93
|
+
createGroup("boundaries", document.boundaries.map((boundary) => createEntry(boundary.id, boundary, [boundary.id, ...boundary.memberIds]))),
|
|
94
|
+
]);
|
|
95
|
+
const responsibility = createSection("responsibility", [
|
|
96
|
+
createGroup("responsibilities", document.responsibilities.responsibilities.map((fact) => createEntry(fact.id, fact, [fact.id, fact.target.id]))),
|
|
97
|
+
]);
|
|
98
|
+
const authority = createSection("authority", [
|
|
99
|
+
createGroup("authority", document.authority.authority.map(authorityEntry)),
|
|
100
|
+
createGroup("ownership", document.authority.ownership.map(ownershipEntry)),
|
|
101
|
+
]);
|
|
102
|
+
const constraints = createSection("constraints", [
|
|
103
|
+
createGroup("constraints", document.constraints.map(constraintEntry)),
|
|
104
|
+
]);
|
|
105
|
+
const flows = createSection("flows", [
|
|
106
|
+
createGroup("flows", document.flows.map((flow) => createEntry(flow.id, flow, [flow.id, ...flow.steps.flatMap((step) => [step.relationshipId, step.interfaceId])]))),
|
|
107
|
+
]);
|
|
108
|
+
const deployment = createSection("deployment", [
|
|
109
|
+
createGroup("runtimeEnvironments", document.deployment.runtimeEnvironments.map((environment) => createEntry(environment.id, environment, [environment.id]))),
|
|
110
|
+
createGroup("deploymentNodes", document.deployment.deploymentNodes.map((node) => createEntry(node.id, node, [node.id, node.environmentId]))),
|
|
111
|
+
createGroup("deploymentInstances", document.deployment.deploymentInstances.map((instance) => createEntry(instance.id, instance, [instance.id, instance.nodeId]))),
|
|
112
|
+
createGroup("infrastructureReferences", document.deployment.infrastructureReferences.map((reference) => createEntry(reference.id, reference, [reference.id]))),
|
|
113
|
+
createGroup("mappings", document.deployment.mappings.map(deploymentMappingEntry)),
|
|
114
|
+
]);
|
|
115
|
+
const mappings = createSection("mappings", [
|
|
116
|
+
createGroup("repositoryMappings", document.repositoryMappings.map((mapping) => createEntry(mapping.canonId, mapping, [mapping.canonId]))),
|
|
117
|
+
]);
|
|
118
|
+
const decisions = createSection("decisions", [
|
|
119
|
+
createGroup("decisions", document.decisions.decisions.map((decision) => createEntry(decision.id, decision, [
|
|
120
|
+
decision.id,
|
|
121
|
+
...decision.targetIds,
|
|
122
|
+
...decision.referenceIds,
|
|
123
|
+
...decision.supersedes,
|
|
124
|
+
]))),
|
|
125
|
+
]);
|
|
126
|
+
const references = createSection("references", [
|
|
127
|
+
createGroup("references", document.decisions.references.map((reference) => createEntry(reference.id, reference, [reference.id]))),
|
|
128
|
+
createGroup("attachments", document.decisions.referenceAttachments.map(referenceAttachmentEntry)),
|
|
129
|
+
]);
|
|
130
|
+
const views = createSection("views", [createGroup("views", document.views.map(viewEntry))]);
|
|
131
|
+
return freezeArray([
|
|
132
|
+
structure,
|
|
133
|
+
responsibility,
|
|
134
|
+
authority,
|
|
135
|
+
constraints,
|
|
136
|
+
flows,
|
|
137
|
+
deployment,
|
|
138
|
+
mappings,
|
|
139
|
+
decisions,
|
|
140
|
+
references,
|
|
141
|
+
views,
|
|
142
|
+
]);
|
|
143
|
+
}
|
|
144
|
+
function createNavigation(sections) {
|
|
145
|
+
return freezeArray(sections.map((section) => Object.freeze({
|
|
146
|
+
section: section.key,
|
|
147
|
+
groupKeys: freezeArray([...SECTION_GROUP_KEYS[section.key]]),
|
|
148
|
+
})));
|
|
149
|
+
}
|
|
150
|
+
/** Project a validated Architecture Canon into renderer-neutral documentation data. */
|
|
151
|
+
export function projectArchitectureDocument(document) {
|
|
152
|
+
const validation = validateArchitectureDocument(document);
|
|
153
|
+
if (!validation.valid) {
|
|
154
|
+
const diagnostics = validation.diagnostics.map(({ code, path }) => `${code} at ${path}`).join(", ");
|
|
155
|
+
throw new Error(`cannot project invalid Architecture Canon: ${diagnostics}`);
|
|
156
|
+
}
|
|
157
|
+
const sections = createSections(document);
|
|
158
|
+
return Object.freeze({
|
|
159
|
+
canonVersion: document.canonVersion,
|
|
160
|
+
documentId: document.documentId,
|
|
161
|
+
root: createAnchor(document.root.id),
|
|
162
|
+
navigation: createNavigation(sections),
|
|
163
|
+
sections,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../../src/architecture/documentation/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAapE,MAAM,kBAAkB,GAAG;IACzB,SAAS,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,CAAC;IACpE,cAAc,EAAE,CAAC,kBAAkB,CAAC;IACpC,SAAS,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC;IACrC,WAAW,EAAE,CAAC,aAAa,CAAC;IAC5B,KAAK,EAAE,CAAC,OAAO,CAAC;IAChB,UAAU,EAAE,CAAC,qBAAqB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,UAAU,CAAC;IACrH,QAAQ,EAAE,CAAC,oBAAoB,CAAC;IAChC,SAAS,EAAE,CAAC,WAAW,CAAC;IACxB,UAAU,EAAE,CAAC,YAAY,EAAE,aAAa,CAAC;IACzC,KAAK,EAAE,CAAC,OAAO,CAAC;CACqD,CAAC;AAExE,SAAS,WAAW,CAAI,MAAoB;IAC1C,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,YAAY,CAAC,OAAe;IACnC,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,aAAa,CAAC,GAAoC;IACzD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,OAAO,GAA0B,EAAE,CAAC;IAE1C,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACrB,IAAI,EAAE,KAA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UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,UAAU,EAAE,gBAAgB,CAAC,QAAQ,CAAC;QACtC,QAAQ;KACT,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { DocumentationModel } from "./model.js";
|
|
2
|
+
import { type StructurizrLauncher, type StructurizrStaticExportRequest, type StructurizrStaticExportResult } from "../projection/structurizr-export.js";
|
|
3
|
+
import type { ProjectionLoss, StructurizrProjection } from "../projection/structurizr.js";
|
|
4
|
+
export declare const ARCHITECTURE_SITE_LAYOUT: Readonly<{
|
|
5
|
+
indexHtml: "index.html";
|
|
6
|
+
workspaceDsl: "workspace.dsl";
|
|
7
|
+
projectionLosses: "projection-losses.json";
|
|
8
|
+
diagramsDirectory: "diagrams";
|
|
9
|
+
}>;
|
|
10
|
+
export type StructurizrStaticExportAdapter = (request: StructurizrStaticExportRequest) => Promise<StructurizrStaticExportResult>;
|
|
11
|
+
export interface ArchitectureSiteRequest {
|
|
12
|
+
/** An absolute, caller-owned directory for all site artifacts. */
|
|
13
|
+
readonly outputRoot: string;
|
|
14
|
+
readonly documentation: DocumentationModel;
|
|
15
|
+
readonly structurizr: StructurizrProjection;
|
|
16
|
+
readonly launcher: StructurizrLauncher;
|
|
17
|
+
readonly exportAdapter?: StructurizrStaticExportAdapter;
|
|
18
|
+
}
|
|
19
|
+
export interface ArchitectureSiteArtifacts {
|
|
20
|
+
readonly root: string;
|
|
21
|
+
readonly indexHtml: string;
|
|
22
|
+
readonly workspaceDsl: string;
|
|
23
|
+
readonly projectionLosses: string;
|
|
24
|
+
readonly diagramsDirectory: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ArchitectureSiteResult {
|
|
27
|
+
readonly status: "ok" | "export-failed";
|
|
28
|
+
readonly complete: boolean;
|
|
29
|
+
readonly outputRoot: string;
|
|
30
|
+
readonly canonVersion: DocumentationModel["canonVersion"];
|
|
31
|
+
readonly documentId: DocumentationModel["documentId"];
|
|
32
|
+
readonly losses: readonly ProjectionLoss[];
|
|
33
|
+
readonly artifacts: ArchitectureSiteArtifacts;
|
|
34
|
+
readonly export: StructurizrStaticExportResult;
|
|
35
|
+
}
|
|
36
|
+
export type ArchitectureSiteErrorCode = "invalid-input" | "generation-mismatch" | "unsafe-path" | "unsafe-overwrite";
|
|
37
|
+
export declare class ArchitectureSiteError extends Error {
|
|
38
|
+
readonly code: ArchitectureSiteErrorCode;
|
|
39
|
+
constructor(code: ArchitectureSiteErrorCode, message: string);
|
|
40
|
+
}
|
|
41
|
+
/** Assemble the independent documentation and Structurizr projections at one filesystem edge. */
|
|
42
|
+
export declare function buildArchitectureSite(request: ArchitectureSiteRequest): Promise<ArchitectureSiteResult>;
|
|
43
|
+
export declare const assembleArchitectureSite: typeof buildArchitectureSite;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { lstat, mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { renderDocumentationHtml } from "./html.js";
|
|
4
|
+
import { runStructurizrStaticExport, } from "../projection/structurizr-export.js";
|
|
5
|
+
export const ARCHITECTURE_SITE_LAYOUT = Object.freeze({
|
|
6
|
+
indexHtml: "index.html",
|
|
7
|
+
workspaceDsl: "workspace.dsl",
|
|
8
|
+
projectionLosses: "projection-losses.json",
|
|
9
|
+
diagramsDirectory: "diagrams",
|
|
10
|
+
});
|
|
11
|
+
export class ArchitectureSiteError extends Error {
|
|
12
|
+
code;
|
|
13
|
+
constructor(code, message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = "ArchitectureSiteError";
|
|
16
|
+
this.code = code;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async function entryKind(entryPath) {
|
|
20
|
+
try {
|
|
21
|
+
const stats = await lstat(entryPath);
|
|
22
|
+
if (stats.isSymbolicLink())
|
|
23
|
+
return "symlink";
|
|
24
|
+
if (stats.isDirectory())
|
|
25
|
+
return "directory";
|
|
26
|
+
if (stats.isFile())
|
|
27
|
+
return "file";
|
|
28
|
+
return "other";
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
32
|
+
return "missing";
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function assertInsideRoot(root, relativePath) {
|
|
37
|
+
const candidate = path.resolve(root, relativePath);
|
|
38
|
+
const prefix = root.endsWith(path.sep) ? root : `${root}${path.sep}`;
|
|
39
|
+
if (!candidate.startsWith(prefix)) {
|
|
40
|
+
throw new ArchitectureSiteError("unsafe-path", `site artifact path escapes output root: ${relativePath}`);
|
|
41
|
+
}
|
|
42
|
+
return candidate;
|
|
43
|
+
}
|
|
44
|
+
function artifactPaths(outputRoot) {
|
|
45
|
+
return Object.freeze({
|
|
46
|
+
root: outputRoot,
|
|
47
|
+
indexHtml: assertInsideRoot(outputRoot, ARCHITECTURE_SITE_LAYOUT.indexHtml),
|
|
48
|
+
workspaceDsl: assertInsideRoot(outputRoot, ARCHITECTURE_SITE_LAYOUT.workspaceDsl),
|
|
49
|
+
projectionLosses: assertInsideRoot(outputRoot, ARCHITECTURE_SITE_LAYOUT.projectionLosses),
|
|
50
|
+
diagramsDirectory: assertInsideRoot(outputRoot, ARCHITECTURE_SITE_LAYOUT.diagramsDirectory),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async function prepareOutput(artifacts) {
|
|
54
|
+
const rootKind = await entryKind(artifacts.root);
|
|
55
|
+
if (rootKind === "symlink") {
|
|
56
|
+
throw new ArchitectureSiteError("unsafe-path", "site output root must not be a symbolic link");
|
|
57
|
+
}
|
|
58
|
+
if (rootKind === "file" || rootKind === "other") {
|
|
59
|
+
throw new ArchitectureSiteError("invalid-input", "site output root must be a directory");
|
|
60
|
+
}
|
|
61
|
+
if (rootKind === "missing")
|
|
62
|
+
await mkdir(artifacts.root, { recursive: true });
|
|
63
|
+
const verifiedRootKind = await entryKind(artifacts.root);
|
|
64
|
+
if (verifiedRootKind !== "directory") {
|
|
65
|
+
throw new ArchitectureSiteError("unsafe-path", "site output root is not a stable directory");
|
|
66
|
+
}
|
|
67
|
+
for (const target of [artifacts.indexHtml, artifacts.workspaceDsl, artifacts.projectionLosses]) {
|
|
68
|
+
const kind = await entryKind(target);
|
|
69
|
+
if (kind !== "missing") {
|
|
70
|
+
throw new ArchitectureSiteError("unsafe-overwrite", `refusing to overwrite existing site artifact: ${target}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const diagramsKind = await entryKind(artifacts.diagramsDirectory);
|
|
74
|
+
if (diagramsKind !== "missing") {
|
|
75
|
+
throw new ArchitectureSiteError("unsafe-overwrite", `refusing to reuse existing diagrams directory: ${artifacts.diagramsDirectory}`);
|
|
76
|
+
}
|
|
77
|
+
await mkdir(artifacts.diagramsDirectory);
|
|
78
|
+
}
|
|
79
|
+
function assertCompatibleGeneration(documentation, structurizr) {
|
|
80
|
+
if (documentation.canonVersion !== structurizr.canonVersion || documentation.documentId !== structurizr.documentId) {
|
|
81
|
+
throw new ArchitectureSiteError("generation-mismatch", "documentation and Structurizr projections must originate from the same Canon generation");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function siteNavigation(lossCount) {
|
|
85
|
+
return `<aside id="architecture-site-navigation">
|
|
86
|
+
<h2>Wabachi architecture site</h2>
|
|
87
|
+
<nav aria-label="architecture-site"><ul>
|
|
88
|
+
<li><a href="index.html">Documentation</a></li>
|
|
89
|
+
<li><a href="diagrams/index.html">Structurizr diagrams</a></li>
|
|
90
|
+
<li><a href="projection-losses.json">Projection losses (${String(lossCount)})</a></li>
|
|
91
|
+
</ul></nav>
|
|
92
|
+
</aside>`;
|
|
93
|
+
}
|
|
94
|
+
function composeIndex(documentation, losses) {
|
|
95
|
+
const rendered = renderDocumentationHtml(documentation);
|
|
96
|
+
const closingBody = "</body>";
|
|
97
|
+
const insertionPoint = rendered.lastIndexOf(closingBody);
|
|
98
|
+
if (insertionPoint < 0) {
|
|
99
|
+
throw new ArchitectureSiteError("invalid-input", "documentation renderer did not return a complete HTML document");
|
|
100
|
+
}
|
|
101
|
+
return `${rendered.slice(0, insertionPoint)}${siteNavigation(losses.length)}\n${rendered.slice(insertionPoint)}`;
|
|
102
|
+
}
|
|
103
|
+
function projectionLossReport(projection) {
|
|
104
|
+
return `${JSON.stringify({
|
|
105
|
+
canonVersion: projection.canonVersion,
|
|
106
|
+
documentId: projection.documentId,
|
|
107
|
+
losses: projection.losses,
|
|
108
|
+
}, null, 2)}\n`;
|
|
109
|
+
}
|
|
110
|
+
/** Assemble the independent documentation and Structurizr projections at one filesystem edge. */
|
|
111
|
+
export async function buildArchitectureSite(request) {
|
|
112
|
+
if (!path.isAbsolute(request.outputRoot) || request.outputRoot.length === 0) {
|
|
113
|
+
throw new ArchitectureSiteError("invalid-input", "site output root must be a non-empty absolute path");
|
|
114
|
+
}
|
|
115
|
+
assertCompatibleGeneration(request.documentation, request.structurizr);
|
|
116
|
+
const outputRoot = path.resolve(request.outputRoot);
|
|
117
|
+
const artifacts = artifactPaths(outputRoot);
|
|
118
|
+
await prepareOutput(artifacts);
|
|
119
|
+
await writeFile(artifacts.indexHtml, composeIndex(request.documentation, request.structurizr.losses), {
|
|
120
|
+
encoding: "utf8",
|
|
121
|
+
flag: "wx",
|
|
122
|
+
});
|
|
123
|
+
await writeFile(artifacts.workspaceDsl, request.structurizr.dsl, { encoding: "utf8", flag: "wx" });
|
|
124
|
+
await writeFile(artifacts.projectionLosses, projectionLossReport(request.structurizr), {
|
|
125
|
+
encoding: "utf8",
|
|
126
|
+
flag: "wx",
|
|
127
|
+
});
|
|
128
|
+
const exportRequest = {
|
|
129
|
+
launcher: request.launcher,
|
|
130
|
+
workspacePath: artifacts.workspaceDsl,
|
|
131
|
+
outputDirectory: artifacts.diagramsDirectory,
|
|
132
|
+
};
|
|
133
|
+
const exportResult = await (request.exportAdapter ?? runStructurizrStaticExport)(exportRequest);
|
|
134
|
+
const complete = exportResult.status === "ok";
|
|
135
|
+
return Object.freeze({
|
|
136
|
+
status: complete ? "ok" : "export-failed",
|
|
137
|
+
complete,
|
|
138
|
+
outputRoot,
|
|
139
|
+
canonVersion: request.documentation.canonVersion,
|
|
140
|
+
documentId: request.documentation.documentId,
|
|
141
|
+
losses: request.structurizr.losses,
|
|
142
|
+
artifacts,
|
|
143
|
+
export: exportResult,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
export const assembleArchitectureSite = buildArchitectureSite;
|
|
147
|
+
//# sourceMappingURL=site.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site.js","sourceRoot":"","sources":["../../../src/architecture/documentation/site.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EACL,0BAA0B,GAI3B,MAAM,qCAAqC,CAAC;AAG7C,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,CAAC;IACpD,SAAS,EAAE,YAAY;IACvB,YAAY,EAAE,eAAe;IAC7B,gBAAgB,EAAE,wBAAwB;IAC1C,iBAAiB,EAAE,UAAU;CAC9B,CAAC,CAAC;AAoCH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IACrC,IAAI,CAA4B;IAEzC,YAAY,IAA+B,EAAE,OAAe;QAC1D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAID,KAAK,UAAU,SAAS,CAAC,SAAiB;IACxC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAA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IACF,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,IAAI,0BAA0B,CAAC,CAAC,aAAa,CAAC,CAAC;IAChG,MAAM,QAAQ,GAAG,YAAY,CAAC,MAAM,KAAK,IAAI,CAAC;IAE9C,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe;QACzC,QAAQ;QACR,UAAU;QACV,YAAY,EAAE,OAAO,CAAC,aAAa,CAAC,YAAY;QAChD,UAAU,EAAE,OAAO,CAAC,aAAa,CAAC,UAAU;QAC5C,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,MAAM;QAClC,SAAS;QACT,MAAM,EAAE,YAAY;KACrB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export interface StructurizrLauncher {
|
|
2
|
+
/** Executable used to start the Structurizr vNext CLI or launcher. */
|
|
3
|
+
readonly executable: string;
|
|
4
|
+
/** Arguments needed by a launcher before Structurizr's own arguments. */
|
|
5
|
+
readonly args?: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
export interface StructurizrStaticExportRequest {
|
|
8
|
+
readonly launcher: StructurizrLauncher;
|
|
9
|
+
/** Path to the already-generated Structurizr DSL or JSON workspace. */
|
|
10
|
+
readonly workspacePath: string;
|
|
11
|
+
/** Explicit caller-owned directory in which Structurizr writes the static site. */
|
|
12
|
+
readonly outputDirectory: string;
|
|
13
|
+
}
|
|
14
|
+
export interface StructurizrToolIdentity {
|
|
15
|
+
readonly id: "structurizr";
|
|
16
|
+
readonly executable: string;
|
|
17
|
+
readonly launcherArgs: readonly string[];
|
|
18
|
+
readonly version: string | null;
|
|
19
|
+
}
|
|
20
|
+
export interface StructurizrProcessInvocation {
|
|
21
|
+
readonly executable: string;
|
|
22
|
+
readonly args: readonly string[];
|
|
23
|
+
readonly shell: false;
|
|
24
|
+
}
|
|
25
|
+
export interface StructurizrProcessOutput {
|
|
26
|
+
readonly stdout: string;
|
|
27
|
+
readonly stderr: string;
|
|
28
|
+
}
|
|
29
|
+
export type StructurizrExportFailureCode = "invalid-input" | "unavailable" | "spawn-failed" | "non-zero-exit" | "version-output-missing";
|
|
30
|
+
export interface StructurizrExportDiagnostic {
|
|
31
|
+
readonly code: StructurizrExportFailureCode;
|
|
32
|
+
readonly phase: "version" | "export" | "input";
|
|
33
|
+
readonly message: string;
|
|
34
|
+
}
|
|
35
|
+
interface StructurizrExportResultBase {
|
|
36
|
+
readonly tool: StructurizrToolIdentity;
|
|
37
|
+
readonly workspacePath: string;
|
|
38
|
+
readonly outputDirectory: string;
|
|
39
|
+
readonly invocations: {
|
|
40
|
+
readonly version: StructurizrProcessInvocation;
|
|
41
|
+
readonly export: StructurizrProcessInvocation;
|
|
42
|
+
};
|
|
43
|
+
readonly versionOutput: StructurizrProcessOutput;
|
|
44
|
+
readonly output: StructurizrProcessOutput;
|
|
45
|
+
}
|
|
46
|
+
export interface StructurizrExportSuccess extends StructurizrExportResultBase {
|
|
47
|
+
readonly status: "ok";
|
|
48
|
+
readonly exitCode: 0;
|
|
49
|
+
readonly signal: null;
|
|
50
|
+
readonly diagnostic: null;
|
|
51
|
+
}
|
|
52
|
+
export interface StructurizrExportFailure extends StructurizrExportResultBase {
|
|
53
|
+
readonly status: "invalid-input" | "unavailable" | "spawn-failed" | "failed";
|
|
54
|
+
readonly exitCode: number | null;
|
|
55
|
+
readonly signal: NodeJS.Signals | null;
|
|
56
|
+
readonly diagnostic: StructurizrExportDiagnostic;
|
|
57
|
+
}
|
|
58
|
+
export type StructurizrStaticExportResult = StructurizrExportSuccess | StructurizrExportFailure;
|
|
59
|
+
/**
|
|
60
|
+
* Run the current Structurizr static export surface against an existing
|
|
61
|
+
* generated workspace. The adapter never creates or rewrites that workspace.
|
|
62
|
+
*/
|
|
63
|
+
export declare function runStructurizrStaticExport(request: StructurizrStaticExportRequest): Promise<StructurizrStaticExportResult>;
|
|
64
|
+
export declare const executeStructurizrStaticExport: typeof runStructurizrStaticExport;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
const EMPTY_OUTPUT = Object.freeze({ stdout: "", stderr: "" });
|
|
3
|
+
function processError(error) {
|
|
4
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
5
|
+
}
|
|
6
|
+
function isMissingExecutable(error) {
|
|
7
|
+
return "code" in error && error.code === "ENOENT";
|
|
8
|
+
}
|
|
9
|
+
function runArgv(executable, args) {
|
|
10
|
+
return new Promise((resolve) => {
|
|
11
|
+
let child;
|
|
12
|
+
try {
|
|
13
|
+
child = spawn(executable, [...args], {
|
|
14
|
+
shell: false,
|
|
15
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
resolve({ kind: "spawn-failed", error: processError(error), output: EMPTY_OUTPUT });
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
let stdout = "";
|
|
23
|
+
let stderr = "";
|
|
24
|
+
let settled = false;
|
|
25
|
+
child.stdout.setEncoding("utf8");
|
|
26
|
+
child.stderr.setEncoding("utf8");
|
|
27
|
+
child.stdout.on("data", (chunk) => {
|
|
28
|
+
stdout += chunk;
|
|
29
|
+
});
|
|
30
|
+
child.stderr.on("data", (chunk) => {
|
|
31
|
+
stderr += chunk;
|
|
32
|
+
});
|
|
33
|
+
child.once("error", (error) => {
|
|
34
|
+
if (settled)
|
|
35
|
+
return;
|
|
36
|
+
settled = true;
|
|
37
|
+
resolve({ kind: "spawn-failed", error, output: { stdout, stderr } });
|
|
38
|
+
});
|
|
39
|
+
child.once("close", (exitCode, signal) => {
|
|
40
|
+
if (settled)
|
|
41
|
+
return;
|
|
42
|
+
settled = true;
|
|
43
|
+
resolve({ kind: "exit", exitCode, signal, output: { stdout, stderr } });
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function invocation(executable, args) {
|
|
48
|
+
return Object.freeze({ executable, args: Object.freeze([...args]), shell: false });
|
|
49
|
+
}
|
|
50
|
+
function baseResult(request, launcherArgs, versionInvocation, exportInvocation, version, versionOutput, output) {
|
|
51
|
+
return {
|
|
52
|
+
tool: {
|
|
53
|
+
id: "structurizr",
|
|
54
|
+
executable: request.launcher.executable,
|
|
55
|
+
launcherArgs: Object.freeze([...launcherArgs]),
|
|
56
|
+
version,
|
|
57
|
+
},
|
|
58
|
+
workspacePath: request.workspacePath,
|
|
59
|
+
outputDirectory: request.outputDirectory,
|
|
60
|
+
invocations: { version: versionInvocation, export: exportInvocation },
|
|
61
|
+
versionOutput,
|
|
62
|
+
output,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function invalidInputResult(request, launcherArgs, versionInvocation, exportInvocation, message) {
|
|
66
|
+
return {
|
|
67
|
+
...baseResult(request, launcherArgs, versionInvocation, exportInvocation, null, EMPTY_OUTPUT, EMPTY_OUTPUT),
|
|
68
|
+
status: "invalid-input",
|
|
69
|
+
exitCode: null,
|
|
70
|
+
signal: null,
|
|
71
|
+
diagnostic: { code: "invalid-input", phase: "input", message },
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function failureResult(base, status, phase, code, message, exitCode, signal) {
|
|
75
|
+
return { ...base, status, exitCode, signal, diagnostic: { code, phase, message } };
|
|
76
|
+
}
|
|
77
|
+
function versionFromOutput(output) {
|
|
78
|
+
const version = output
|
|
79
|
+
.split(/\r?\n/u)
|
|
80
|
+
.map((line) => line.trim())
|
|
81
|
+
.find((line) => line.length > 0);
|
|
82
|
+
return version ?? null;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Run the current Structurizr static export surface against an existing
|
|
86
|
+
* generated workspace. The adapter never creates or rewrites that workspace.
|
|
87
|
+
*/
|
|
88
|
+
export async function runStructurizrStaticExport(request) {
|
|
89
|
+
const launcherArgs = request.launcher.args === undefined ? [] : [...request.launcher.args];
|
|
90
|
+
const versionArgs = [...launcherArgs, "--version"];
|
|
91
|
+
const exportArgs = [
|
|
92
|
+
...launcherArgs,
|
|
93
|
+
"export",
|
|
94
|
+
"-format",
|
|
95
|
+
"static",
|
|
96
|
+
"-workspace",
|
|
97
|
+
request.workspacePath,
|
|
98
|
+
"-output",
|
|
99
|
+
request.outputDirectory,
|
|
100
|
+
];
|
|
101
|
+
const versionInvocation = invocation(request.launcher.executable, versionArgs);
|
|
102
|
+
const exportInvocation = invocation(request.launcher.executable, exportArgs);
|
|
103
|
+
if (request.launcher.executable.length === 0 ||
|
|
104
|
+
launcherArgs.some((argument) => typeof argument !== "string") ||
|
|
105
|
+
request.workspacePath.length === 0 ||
|
|
106
|
+
request.outputDirectory.length === 0) {
|
|
107
|
+
return invalidInputResult(request, launcherArgs, versionInvocation, exportInvocation, "Structurizr executable, launcher arguments, workspace path, and output directory must be non-empty strings");
|
|
108
|
+
}
|
|
109
|
+
const versionResult = await runArgv(request.launcher.executable, versionArgs);
|
|
110
|
+
if (versionResult.kind === "spawn-failed") {
|
|
111
|
+
const base = baseResult(request, launcherArgs, versionInvocation, exportInvocation, null, versionResult.output, EMPTY_OUTPUT);
|
|
112
|
+
const missing = isMissingExecutable(versionResult.error);
|
|
113
|
+
return failureResult(base, missing ? "unavailable" : "spawn-failed", "version", missing ? "unavailable" : "spawn-failed", `Structurizr version process could not be started: ${versionResult.error.message}`, null, null);
|
|
114
|
+
}
|
|
115
|
+
const version = versionFromOutput(versionResult.output.stdout);
|
|
116
|
+
const versionBase = baseResult(request, launcherArgs, versionInvocation, exportInvocation, version, versionResult.output, EMPTY_OUTPUT);
|
|
117
|
+
if (versionResult.exitCode !== 0) {
|
|
118
|
+
return failureResult(versionBase, "failed", "version", "non-zero-exit", `Structurizr version process exited with code ${String(versionResult.exitCode)}`, versionResult.exitCode, versionResult.signal);
|
|
119
|
+
}
|
|
120
|
+
if (version === null) {
|
|
121
|
+
return failureResult(versionBase, "failed", "version", "version-output-missing", "Structurizr version process exited successfully without version output", versionResult.exitCode, versionResult.signal);
|
|
122
|
+
}
|
|
123
|
+
const exportResult = await runArgv(request.launcher.executable, exportArgs);
|
|
124
|
+
if (exportResult.kind === "spawn-failed") {
|
|
125
|
+
const base = baseResult(request, launcherArgs, versionInvocation, exportInvocation, version, versionResult.output, exportResult.output);
|
|
126
|
+
const missing = isMissingExecutable(exportResult.error);
|
|
127
|
+
return failureResult(base, missing ? "unavailable" : "spawn-failed", "export", missing ? "unavailable" : "spawn-failed", `Structurizr export process could not be started: ${exportResult.error.message}`, null, null);
|
|
128
|
+
}
|
|
129
|
+
const base = baseResult(request, launcherArgs, versionInvocation, exportInvocation, version, versionResult.output, exportResult.output);
|
|
130
|
+
if (exportResult.exitCode !== 0) {
|
|
131
|
+
return failureResult(base, "failed", "export", "non-zero-exit", `Structurizr export process exited with code ${String(exportResult.exitCode)}`, exportResult.exitCode, exportResult.signal);
|
|
132
|
+
}
|
|
133
|
+
return { ...base, status: "ok", exitCode: 0, signal: null, diagnostic: null };
|
|
134
|
+
}
|
|
135
|
+
export const executeStructurizrStaticExport = runStructurizrStaticExport;
|
|
136
|
+
//# sourceMappingURL=structurizr-export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structurizr-export.js","sourceRoot":"","sources":["../../../src/architecture/projection/structurizr-export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAuF3C,MAAM,YAAY,GAA6B,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;AAEzF,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,C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AAC,aAAa,CAAC,CAAC,CAAC,cAAc,EACxC,QAAQ,EACR,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc,EACxC,oDAAoD,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,EAChF,IAAI,EACJ,IAAI,CACL,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,UAAU,CACrB,OAAO,EACP,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,OAAO,EACP,aAAa,CAAC,MAAM,EACpB,YAAY,CAAC,MAAM,CACpB,CAAC;IACF,IAAI,YAAY,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,aAAa,CAClB,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,+CAA+C,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,EAC9E,YAAY,CAAC,QAAQ,EACrB,YAAY,CAAC,MAAM,CACpB,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;AAChF,CAAC;AAED,MAAM,CAAC,MAAM,8BAA8B,GAAG,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ArchitectureDocumentV1 } from "../canon/document.js";
|
|
2
|
+
import type { ViewSpec } from "../canon/views.js";
|
|
3
|
+
export declare const PROJECTION_LOSS_CODES: readonly ["unsupported-authority", "unsupported-ownership", "unsupported-boundary", "unsupported-responsibility", "unsupported-constraint", "unsupported-repository-mapping", "unsupported-decision", "unsupported-reference", "unsupported-reference-attachment", "unsupported-interface", "unsupported-containment", "unsupported-flow", "unsupported-deployment-instance", "unsupported-deployment-mapping", "unsupported-infrastructure-reference", "unsupported-view-reference", "unsupported-view-exclusion", "unsupported-view-scope", "unsupported-presentation", "ambiguous-flow-step"];
|
|
4
|
+
export type ProjectionLossCode = (typeof PROJECTION_LOSS_CODES)[number];
|
|
5
|
+
/** A machine-readable explanation of a Canon fact not represented losslessly by Structurizr. */
|
|
6
|
+
export interface ProjectionLoss {
|
|
7
|
+
readonly code: ProjectionLossCode;
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly canonIds: readonly string[];
|
|
10
|
+
readonly message: string;
|
|
11
|
+
}
|
|
12
|
+
export type StructurizrIdentityNamespace = "architecture" | "element" | "interface" | "responsibility" | "boundary" | "flow" | "decision" | "reference" | "runtime-environment" | "deployment-node" | "deployment-instance" | "infrastructure-reference";
|
|
13
|
+
export interface StructurizrIdentityMapping {
|
|
14
|
+
readonly canonId: string;
|
|
15
|
+
readonly namespace: StructurizrIdentityNamespace;
|
|
16
|
+
/** The deterministic identifier or metadata token used by the projection. */
|
|
17
|
+
readonly structurizrId: string;
|
|
18
|
+
}
|
|
19
|
+
export interface StructurizrViewMapping {
|
|
20
|
+
readonly canonKey: string;
|
|
21
|
+
readonly kind: ViewSpec["kind"];
|
|
22
|
+
readonly structurizrKey: string;
|
|
23
|
+
}
|
|
24
|
+
export interface StructurizrProjection {
|
|
25
|
+
readonly canonVersion: ArchitectureDocumentV1["canonVersion"];
|
|
26
|
+
readonly documentId: ArchitectureDocumentV1["documentId"];
|
|
27
|
+
readonly dsl: string;
|
|
28
|
+
readonly identityMappings: readonly StructurizrIdentityMapping[];
|
|
29
|
+
readonly viewMappings: readonly StructurizrViewMapping[];
|
|
30
|
+
readonly losses: readonly ProjectionLoss[];
|
|
31
|
+
}
|
|
32
|
+
/** Project a validated Architecture Canon into current Structurizr DSL plus explicit losses. */
|
|
33
|
+
export declare function projectArchitectureDocumentToStructurizr(document: ArchitectureDocumentV1): StructurizrProjection;
|
|
34
|
+
export declare const projectArchitectureToStructurizr: typeof projectArchitectureDocumentToStructurizr;
|