archidocs 0.0.0-stage → 1.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/README.md +181 -2
- package/dist/cli/commands.d.ts +322 -0
- package/dist/cli/commands.js +174 -0
- package/dist/cli/dev.d.ts +31 -0
- package/dist/cli/dev.js +156 -0
- package/dist/cli/diff-format.d.ts +9 -0
- package/dist/cli/diff-format.js +50 -0
- package/dist/cli/format.d.ts +15 -0
- package/dist/cli/format.js +64 -0
- package/dist/cli/init.d.ts +17 -0
- package/dist/cli/init.js +82 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +330 -0
- package/dist/core/adr.d.ts +28 -0
- package/dist/core/adr.js +88 -0
- package/dist/core/adrs.d.ts +20 -0
- package/dist/core/adrs.js +86 -0
- package/dist/core/catalogue.d.ts +7 -0
- package/dist/core/catalogue.js +35 -0
- package/dist/core/compare.d.ts +21 -0
- package/dist/core/compare.js +62 -0
- package/dist/core/deployment-views.d.ts +28 -0
- package/dist/core/deployment-views.js +108 -0
- package/dist/core/deployments.d.ts +18 -0
- package/dist/core/deployments.js +21 -0
- package/dist/core/diff.d.ts +44 -0
- package/dist/core/diff.js +138 -0
- package/dist/core/dynamic-views.d.ts +73 -0
- package/dist/core/dynamic-views.js +162 -0
- package/dist/core/files.d.ts +2 -0
- package/dist/core/files.js +1 -0
- package/dist/core/fs.d.ts +19 -0
- package/dist/core/fs.js +21 -0
- package/dist/core/history-scope.d.ts +40 -0
- package/dist/core/history-scope.js +63 -0
- package/dist/core/impact.d.ts +34 -0
- package/dist/core/impact.js +62 -0
- package/dist/core/index.d.ts +20 -0
- package/dist/core/index.js +18 -0
- package/dist/core/load.d.ts +32 -0
- package/dist/core/load.js +465 -0
- package/dist/core/model.d.ts +150 -0
- package/dist/core/model.js +1 -0
- package/dist/core/ownership.d.ts +34 -0
- package/dist/core/ownership.js +65 -0
- package/dist/core/paths.d.ts +47 -0
- package/dist/core/paths.js +115 -0
- package/dist/core/query.d.ts +51 -0
- package/dist/core/query.js +77 -0
- package/dist/core/refs.d.ts +31 -0
- package/dist/core/refs.js +50 -0
- package/dist/core/rules.d.ts +41 -0
- package/dist/core/rules.js +1033 -0
- package/dist/core/save-as-view.d.ts +45 -0
- package/dist/core/save-as-view.js +114 -0
- package/dist/core/saved-views.d.ts +48 -0
- package/dist/core/saved-views.js +243 -0
- package/dist/core/schema-check.d.ts +13 -0
- package/dist/core/schema-check.js +79 -0
- package/dist/core/search.d.ts +27 -0
- package/dist/core/search.js +63 -0
- package/dist/core/suggest.d.ts +3 -0
- package/dist/core/suggest.js +30 -0
- package/dist/core/views.d.ts +126 -0
- package/dist/core/views.js +217 -0
- package/dist/core/yaml.d.ts +16 -0
- package/dist/core/yaml.js +52 -0
- package/dist/git.d.ts +7 -0
- package/dist/git.js +23 -0
- package/dist/guide/index.d.ts +53 -0
- package/dist/guide/index.js +57 -0
- package/dist/history/git.d.ts +39 -0
- package/dist/history/git.js +126 -0
- package/dist/history/index.d.ts +118 -0
- package/dist/history/index.js +223 -0
- package/dist/history/migrate.d.ts +16 -0
- package/dist/history/migrate.js +30 -0
- package/dist/mcp/history.d.ts +36 -0
- package/dist/mcp/history.js +175 -0
- package/dist/mcp/http.d.ts +23 -0
- package/dist/mcp/http.js +85 -0
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/server.d.ts +54 -0
- package/dist/mcp/server.js +824 -0
- package/dist/mcp/source.d.ts +50 -0
- package/dist/mcp/source.js +132 -0
- package/dist/mcp/writes.d.ts +10 -0
- package/dist/mcp/writes.js +267 -0
- package/dist/render/font.d.ts +14 -0
- package/dist/render/font.js +11 -0
- package/dist/render/index.d.ts +8 -0
- package/dist/render/index.js +8 -0
- package/dist/render/layout.d.ts +53 -0
- package/dist/render/layout.js +199 -0
- package/dist/render/node.d.ts +3 -0
- package/dist/render/node.js +8 -0
- package/dist/render/png.d.ts +11 -0
- package/dist/render/png.js +29 -0
- package/dist/render/sequence-svg.d.ts +33 -0
- package/dist/render/sequence-svg.js +98 -0
- package/dist/render/sequence.d.ts +103 -0
- package/dist/render/sequence.js +142 -0
- package/dist/render/svg.d.ts +36 -0
- package/dist/render/svg.js +222 -0
- package/dist/render/teams.d.ts +12 -0
- package/dist/render/teams.js +31 -0
- package/dist/render/text.d.ts +15 -0
- package/dist/render/text.js +29 -0
- package/dist/render/tokens.d.ts +53 -0
- package/dist/render/tokens.js +71 -0
- package/dist/schema/adr.d.ts +36 -0
- package/dist/schema/adr.js +27 -0
- package/dist/schema/bundle.d.ts +726 -0
- package/dist/schema/bundle.js +171 -0
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.js +4 -0
- package/dist/schema/json-schema.d.ts +8 -0
- package/dist/schema/json-schema.js +19 -0
- package/dist/schema/workspace.d.ts +1066 -0
- package/dist/schema/workspace.js +271 -0
- package/dist/viewer/assets/index-DvKgCpBr.css +1 -0
- package/dist/viewer/assets/index-gucix3xm.js +113 -0
- package/dist/viewer/assets/index_bg-Blvrv-U2.wasm +0 -0
- package/dist/viewer/assets/index_bg-D3t31u3-.js +1 -0
- package/dist/viewer/assets/layout.worker-Bg-OaLVN.js +26 -0
- package/dist/viewer/assets/overpass-latin-QyaMbcmi.woff2 +0 -0
- package/dist/viewer/assets/overpass-latin-ext-DSRhPfzW.woff2 +0 -0
- package/dist/viewer/assets/overpass-mono-latin-BTquVRaO.woff2 +0 -0
- package/dist/viewer/assets/overpass-mono-latin-ext-D47EiU4_.woff2 +0 -0
- package/dist/viewer/assets/png-BDKIXtm5.js +1 -0
- package/dist/viewer/assets/svg-Bulv5YWn.js +2 -0
- package/dist/viewer/favicon.svg +1 -0
- package/dist/viewer/index.html +53 -0
- package/dist/writer/adrs.d.ts +21 -0
- package/dist/writer/adrs.js +72 -0
- package/dist/writer/deployments.d.ts +51 -0
- package/dist/writer/deployments.js +145 -0
- package/dist/writer/diff.d.ts +6 -0
- package/dist/writer/diff.js +77 -0
- package/dist/writer/document.d.ts +25 -0
- package/dist/writer/document.js +79 -0
- package/dist/writer/edit.d.ts +78 -0
- package/dist/writer/edit.js +63 -0
- package/dist/writer/index.d.ts +67 -0
- package/dist/writer/index.js +310 -0
- package/dist/writer/overlay.d.ts +7 -0
- package/dist/writer/overlay.js +26 -0
- package/dist/writer/views.d.ts +29 -0
- package/dist/writer/views.js +78 -0
- package/dist/writer/workspace.d.ts +25 -0
- package/dist/writer/workspace.js +56 -0
- package/guide/SKILL.md +36 -0
- package/guide/topics/add-service.md +30 -0
- package/guide/topics/bootstrap.md +28 -0
- package/guide/topics/change.md +32 -0
- package/guide/topics/deployments.md +36 -0
- package/guide/topics/dynamic-view.md +39 -0
- package/guide/topics/propose-adr.md +12 -0
- package/guide/topics/relationships.md +39 -0
- package/guide/topics/saved-view.md +36 -0
- package/package.json +75 -4
- package/schemas/adr.schema.json +82 -0
- package/schemas/model.schema.json +1381 -0
- package/schemas/project.schema.json +24 -0
- package/schemas/workspace.schema.json +72 -0
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
import { basename, dirname, join, relative, sep } from "node:path";
|
|
2
|
+
import { Bundle, SCHEMA_VERSION } from "../schema/bundle.js";
|
|
3
|
+
import { DynamicView, ProjectFile, StructuralView, WorkspaceFile, childKindOf, collectionOf, kindOfCollection, lensSchemaFor, selectorSchemaFor, shallow, workspaceOnlyKeys } from "../schema/workspace.js";
|
|
4
|
+
import { indexByQualifiedId, qualified, qualify, referenceResolver } from "./refs.js";
|
|
5
|
+
import { rules } from "./rules.js";
|
|
6
|
+
import { checkSchema } from "./schema-check.js";
|
|
7
|
+
import { bundleAdrs } from "./adrs.js";
|
|
8
|
+
import { PROJECT_TEMPLATE, readAdr } from "./adr.js";
|
|
9
|
+
import { parseYaml } from "./yaml.js";
|
|
10
|
+
const WORKSPACE_FILE = "workspace.yaml";
|
|
11
|
+
const PROJECT_FILE = "project.yaml";
|
|
12
|
+
const ADR_DIR = "adr";
|
|
13
|
+
/**
|
|
14
|
+
* Reads a Workspace: discovers Projects, parses and merges their files,
|
|
15
|
+
* resolves references and runs every check rule. The Bundle is always
|
|
16
|
+
* returned; callers must not publish it when `issues` holds an error.
|
|
17
|
+
*/
|
|
18
|
+
export async function load(options) {
|
|
19
|
+
const { bundle, issues } = await loadDetailed(options);
|
|
20
|
+
return { bundle, issues };
|
|
21
|
+
}
|
|
22
|
+
/** Load, also returning the declarations as read (with their paths in each file) and the repo root paths are relative to. For the YAML writer. */
|
|
23
|
+
export async function loadDetailed(options) {
|
|
24
|
+
const { fs, root } = options;
|
|
25
|
+
const repoRoot = options.repoRoot ?? (await findRepoRoot(fs, root));
|
|
26
|
+
const toRepoPath = (abs) => relative(repoRoot, abs).split(sep).join("/");
|
|
27
|
+
const { files: yamlPaths, markdown, dirs } = await walk(fs, root);
|
|
28
|
+
const projectDirs = dirs.filter((d) => yamlPaths.includes(join(d, PROJECT_FILE)));
|
|
29
|
+
const nearestProjectDir = (dir, strict) => projectDirs
|
|
30
|
+
.filter((p) => (strict ? dir.startsWith(p + sep) : dir === p || dir.startsWith(p + sep)))
|
|
31
|
+
.sort((a, b) => b.length - a.length)[0];
|
|
32
|
+
const ws = { files: [], projects: [], teams: [], environments: [], elements: [], relationships: [], targets: [], deployments: [], views: [], adrs: [] };
|
|
33
|
+
const projectByDir = new Map();
|
|
34
|
+
// Read every file; project.yaml files first so model files can find their Project.
|
|
35
|
+
const ordered = [...yamlPaths].sort((a, b) => Number(basename(b) === PROJECT_FILE) - Number(basename(a) === PROJECT_FILE) || cmp(a, b));
|
|
36
|
+
for (const abs of ordered) {
|
|
37
|
+
const parsed = parseYaml(await fs.readFile(abs));
|
|
38
|
+
const dir = dirname(abs);
|
|
39
|
+
const role = abs === join(root, WORKSPACE_FILE) ? "workspace" : basename(abs) === PROJECT_FILE ? "project" : nearestProjectDir(dir, false) ? "model" : "outside";
|
|
40
|
+
const file = { path: toRepoPath(abs), role, parsed, findings: [] };
|
|
41
|
+
ws.files.push(file);
|
|
42
|
+
if (parsed.data === undefined) {
|
|
43
|
+
if (role === "project")
|
|
44
|
+
projectByDir.set(dir, { name: "", folder: toRepoPath(dir), file });
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (role === "workspace")
|
|
48
|
+
readWorkspaceFile(file, ws);
|
|
49
|
+
else if (role === "project")
|
|
50
|
+
projectByDir.set(dir, readProjectFile(file, toRepoPath(dir)));
|
|
51
|
+
else if (role === "model") {
|
|
52
|
+
file.project = projectByDir.get(nearestProjectDir(dir, false));
|
|
53
|
+
readModelFile(file, ws);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
ws.files.sort((a, b) => cmp(a.path, b.path));
|
|
57
|
+
// ADRs: every `.md` directly in a Project's `adr/` folder, but its template.
|
|
58
|
+
for (const abs of markdown) {
|
|
59
|
+
const dir = dirname(abs);
|
|
60
|
+
const project = basename(dir) === ADR_DIR ? projectByDir.get(dirname(dir)) : undefined;
|
|
61
|
+
if (!project || basename(abs) === PROJECT_TEMPLATE)
|
|
62
|
+
continue;
|
|
63
|
+
ws.adrs.push(readAdr(await fs.readFile(abs), { project, path: toRepoPath(abs), filename: basename(abs) }));
|
|
64
|
+
}
|
|
65
|
+
// Projects in folder order: nesting and duplicate ids point back at the earlier one.
|
|
66
|
+
const firstById = new Map();
|
|
67
|
+
for (const [dir, project] of [...projectByDir].sort(([a], [b]) => cmp(a, b))) {
|
|
68
|
+
project.file.project = project;
|
|
69
|
+
const outer = nearestProjectDir(dir, true);
|
|
70
|
+
if (outer)
|
|
71
|
+
project.nestedIn = projectByDir.get(outer);
|
|
72
|
+
if (project.id !== undefined) {
|
|
73
|
+
const first = firstById.get(project.id);
|
|
74
|
+
if (first)
|
|
75
|
+
project.duplicateOf = first;
|
|
76
|
+
else
|
|
77
|
+
firstById.set(project.id, project);
|
|
78
|
+
}
|
|
79
|
+
ws.projects.push(project);
|
|
80
|
+
}
|
|
81
|
+
const byPosition = (a, b) => cmp(a.file.path, b.file.path) || a.line - b.line || a.column - b.column;
|
|
82
|
+
ws.elements.sort(byPosition);
|
|
83
|
+
ws.targets.sort(byPosition);
|
|
84
|
+
ws.deployments.sort(byPosition);
|
|
85
|
+
ws.relationships.sort(byPosition);
|
|
86
|
+
ws.views.sort(byPosition);
|
|
87
|
+
resolveParents(ws);
|
|
88
|
+
resolveDeployments(ws);
|
|
89
|
+
const bundle = toBundle(ws, options);
|
|
90
|
+
const issues = rules
|
|
91
|
+
.flatMap((rule) => rule.check(ws, bundle).map(({ file, line, column, message }) => ({ file, line, ...(column === undefined ? {} : { column }), rule: rule.id, severity: rule.severity, message })))
|
|
92
|
+
.sort((a, b) => cmp(a.file, b.file) || a.line - b.line || cmp(a.rule, b.rule) || (a.column ?? 0) - (b.column ?? 0) || cmp(a.message, b.message));
|
|
93
|
+
return { bundle, issues, workspace: ws, repoRoot };
|
|
94
|
+
}
|
|
95
|
+
/** Walks up from `start` to the folder holding `workspace.yaml`, also looking in each folder's `archidocs/`. */
|
|
96
|
+
export async function findWorkspaceRoot(fs, start) {
|
|
97
|
+
for (let dir = start;; dir = dirname(dir)) {
|
|
98
|
+
for (const candidate of [dir, join(dir, "archidocs")]) {
|
|
99
|
+
if (await fs.exists(join(candidate, WORKSPACE_FILE)))
|
|
100
|
+
return candidate;
|
|
101
|
+
}
|
|
102
|
+
if (dirname(dir) === dir)
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function findRepoRoot(fs, root) {
|
|
107
|
+
for (let dir = root;; dir = dirname(dir)) {
|
|
108
|
+
if (await fs.exists(join(dir, ".git")))
|
|
109
|
+
return dir;
|
|
110
|
+
if (dirname(dir) === dir)
|
|
111
|
+
return root;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function walk(fs, root) {
|
|
115
|
+
const files = [];
|
|
116
|
+
const markdown = [];
|
|
117
|
+
const dirs = [root];
|
|
118
|
+
for (let i = 0; i < dirs.length; i++) {
|
|
119
|
+
for (const entry of await fs.readDir(dirs[i])) {
|
|
120
|
+
if (entry.name.startsWith(".") || entry.name === "node_modules")
|
|
121
|
+
continue;
|
|
122
|
+
const path = join(dirs[i], entry.name);
|
|
123
|
+
if (entry.isDirectory)
|
|
124
|
+
dirs.push(path);
|
|
125
|
+
else if (entry.name.endsWith(".yaml"))
|
|
126
|
+
files.push(path);
|
|
127
|
+
else if (entry.name.endsWith(".md"))
|
|
128
|
+
markdown.push(path);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return { files: files.sort(cmp), markdown: markdown.sort(cmp), dirs: dirs.sort(cmp) };
|
|
132
|
+
}
|
|
133
|
+
function readWorkspaceFile(file, ws) {
|
|
134
|
+
const data = asRecord(file.parsed.data);
|
|
135
|
+
file.findings.push(...checkSchema(WorkspaceFile, data, file.parsed));
|
|
136
|
+
for (const [key, list] of [["teams", ws.teams], ["environments", ws.environments]]) {
|
|
137
|
+
for (const [id, value] of Object.entries(asRecord(data[key]))) {
|
|
138
|
+
list.push({ id, file, data: asRecord(value), ...file.parsed.positionOf([key, id], { key: true }) });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function readProjectFile(file, folder) {
|
|
143
|
+
const data = withoutWorkspaceKeys(file);
|
|
144
|
+
file.findings.push(...checkSchema(ProjectFile, data, file.parsed));
|
|
145
|
+
const valid = ProjectFile.safeParse(data);
|
|
146
|
+
return {
|
|
147
|
+
id: valid.success || typeof data.id === "string" ? String(data.id) : undefined,
|
|
148
|
+
name: typeof data.name === "string" ? data.name : "",
|
|
149
|
+
owner: typeof data.owner === "string" ? data.owner : undefined,
|
|
150
|
+
folder,
|
|
151
|
+
file,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function readModelFile(file, ws) {
|
|
155
|
+
const data = withoutWorkspaceKeys(file);
|
|
156
|
+
file.findings.push(...checkSchema(shallow.file, data, file.parsed));
|
|
157
|
+
readElements(file, ws, data, [], undefined);
|
|
158
|
+
readTargets(file, ws, data, [], undefined);
|
|
159
|
+
readDeployments(file, ws, data);
|
|
160
|
+
readViews(file, ws, data);
|
|
161
|
+
}
|
|
162
|
+
/** Registers every Saved View under `views: structural:` and `views: dynamic:`, checking each selector and the Lens against the form it is written in. */
|
|
163
|
+
function readViews(file, ws, data) {
|
|
164
|
+
for (const [id, value] of Object.entries(asRecord(asRecord(data.views).structural))) {
|
|
165
|
+
const path = ["views", "structural", id];
|
|
166
|
+
file.findings.push(...checkSchema(shallow.view, value, file.parsed, path));
|
|
167
|
+
const view = { kind: "structural", id, project: file.project, file, path, data: asRecord(value), ...file.parsed.positionOf(path, { key: true }) };
|
|
168
|
+
ws.views.push(view);
|
|
169
|
+
for (const key of ["include", "exclude"]) {
|
|
170
|
+
const list = view.data[key];
|
|
171
|
+
if (!Array.isArray(list))
|
|
172
|
+
continue;
|
|
173
|
+
list.forEach((selector, i) => {
|
|
174
|
+
const at = [...path, key, i];
|
|
175
|
+
const schema = selectorSchemaFor(selector);
|
|
176
|
+
if (schema)
|
|
177
|
+
file.findings.push(...checkSchema(schema, selector, file.parsed, at));
|
|
178
|
+
else
|
|
179
|
+
file.findings.push({ rule: "invalid-value", ...file.parsed.positionOf(at), message: `Invalid value for "${key}.${i}": a selector is an id, or a map with \`element\`, \`team\`, \`tag\` or \`from\` and \`to\`` });
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
if (view.data.lens !== undefined) {
|
|
183
|
+
const schema = lensSchemaFor(view.data.lens);
|
|
184
|
+
if (schema)
|
|
185
|
+
file.findings.push(...checkSchema(schema, view.data.lens, file.parsed, [...path, "lens"]));
|
|
186
|
+
else
|
|
187
|
+
file.findings.push({ rule: "invalid-value", ...file.parsed.positionOf([...path, "lens"]), message: 'Invalid value for "lens": a Lens is a map with `impact`, `team` or `path`' });
|
|
188
|
+
}
|
|
189
|
+
const deployment = view.data.level === "deployment";
|
|
190
|
+
if (deployment && view.data.environment === undefined) {
|
|
191
|
+
file.findings.push({ rule: "missing-field", ...file.parsed.positionOf(path, { key: true }), message: 'Missing required field "environment": a Deployment View names its Environment' });
|
|
192
|
+
}
|
|
193
|
+
for (const key of ["environment", "targets"]) {
|
|
194
|
+
if (!deployment && view.data[key] !== undefined) {
|
|
195
|
+
file.findings.push({ rule: "invalid-value", ...file.parsed.positionOf([...path, key], { key: true }), message: `Invalid value for "${key}": only a \`level: deployment\` View takes \`${key}\`` });
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
for (const [id, value] of Object.entries(asRecord(asRecord(data.views).dynamic))) {
|
|
200
|
+
const path = ["views", "dynamic", id];
|
|
201
|
+
file.findings.push(...checkSchema(shallow.dynamicView, value, file.parsed, path));
|
|
202
|
+
ws.views.push({ kind: "dynamic", id, project: file.project, file, path, data: asRecord(value), ...file.parsed.positionOf(path, { key: true }) });
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/** Registers every Deployment Target declared under `container`, recursing into nested `targets`. */
|
|
206
|
+
function readTargets(file, ws, container, at, parent) {
|
|
207
|
+
for (const [id, value] of Object.entries(asRecord(container.targets))) {
|
|
208
|
+
const path = [...at, "targets", id];
|
|
209
|
+
file.findings.push(...checkSchema(shallow.target, value, file.parsed, path));
|
|
210
|
+
const target = { id, project: file.project, file, path, data: asRecord(value), parent, ...file.parsed.positionOf(path, { key: true }) };
|
|
211
|
+
ws.targets.push(target);
|
|
212
|
+
readTargets(file, ws, target.data, path, target);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function readDeployments(file, ws, data) {
|
|
216
|
+
if (!Array.isArray(data.deployments))
|
|
217
|
+
return;
|
|
218
|
+
data.deployments.forEach((value, i) => {
|
|
219
|
+
const path = ["deployments", i];
|
|
220
|
+
file.findings.push(...checkSchema(shallow.deployment, value, file.parsed, path));
|
|
221
|
+
ws.deployments.push({ project: file.project, file, path, data: asRecord(value), ...file.parsed.positionOf(path) });
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
/** Resolves each Deployment's `service` and `target`, across Projects too. */
|
|
225
|
+
function resolveDeployments(ws) {
|
|
226
|
+
const elements = indexByQualifiedId(ws.elements);
|
|
227
|
+
const targets = indexByQualifiedId(ws.targets);
|
|
228
|
+
for (const d of ws.deployments) {
|
|
229
|
+
const service = qualify(d.data.service, d.project);
|
|
230
|
+
const target = qualify(d.data.target, d.project);
|
|
231
|
+
d.service = service === undefined ? undefined : elements.get(service);
|
|
232
|
+
d.target = target === undefined ? undefined : targets.get(target);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Registers every Element declared under `container` (a file's top level, or
|
|
237
|
+
* an Element), recursing into nested collections. A collection under the
|
|
238
|
+
* wrong kind (say `components` under a System) is still read, so its Elements
|
|
239
|
+
* keep their ids; `invalid-nesting` reports them.
|
|
240
|
+
*/
|
|
241
|
+
function readElements(file, ws, container, at, nestedIn) {
|
|
242
|
+
for (const [key, kind] of Object.entries(kindOfCollection)) {
|
|
243
|
+
for (const [id, value] of Object.entries(asRecord(container[key]))) {
|
|
244
|
+
const path = [...at, key, id];
|
|
245
|
+
const data = asRecord(value);
|
|
246
|
+
// Each Element is checked on its own, without collections that `invalid-nesting` reports; a bad one still registers its id.
|
|
247
|
+
const checked = value !== null && typeof value === "object" && !Array.isArray(value) ? withoutForeignCollections(kind, data) : value;
|
|
248
|
+
file.findings.push(...checkSchema(shallow[kind], checked, file.parsed, path));
|
|
249
|
+
const element = { kind, id, project: file.project, file, path, data, nestedIn, ...file.parsed.positionOf(path, { key: true }) };
|
|
250
|
+
ws.elements.push(element);
|
|
251
|
+
readRelationships(file, ws, element);
|
|
252
|
+
readElements(file, ws, data, path, element);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function readRelationships(file, ws, from) {
|
|
257
|
+
const list = from.data.relationships;
|
|
258
|
+
if (!Array.isArray(list))
|
|
259
|
+
return;
|
|
260
|
+
list.forEach((value, i) => {
|
|
261
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
262
|
+
return;
|
|
263
|
+
const path = [...from.path, "relationships", i];
|
|
264
|
+
ws.relationships.push({ from, file, path, data: value, ...file.parsed.positionOf(path) });
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
function withoutForeignCollections(kind, data) {
|
|
268
|
+
const own = childKindOf[kind] && collectionOf[childKindOf[kind]];
|
|
269
|
+
return Object.fromEntries(Object.entries(data).filter(([k]) => k === own || !(k in kindOfCollection)));
|
|
270
|
+
}
|
|
271
|
+
/** Sets each Element's parent: the Element it is nested under, else the one its `in:` names in its Project. */
|
|
272
|
+
function resolveParents(ws) {
|
|
273
|
+
const byId = new Map();
|
|
274
|
+
for (const e of ws.elements) {
|
|
275
|
+
const key = `${e.project.folder}\0${e.id}`;
|
|
276
|
+
if (!byId.has(key))
|
|
277
|
+
byId.set(key, e);
|
|
278
|
+
}
|
|
279
|
+
for (const e of ws.elements) {
|
|
280
|
+
const ref = e.data.in;
|
|
281
|
+
e.parent = e.nestedIn ?? (typeof ref === "string" ? byId.get(`${e.project.folder}\0${ref}`) : undefined);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/** Reports and drops `teams`/`environments` from a file other than `workspace.yaml`. */
|
|
285
|
+
function withoutWorkspaceKeys(file) {
|
|
286
|
+
const data = { ...asRecord(file.parsed.data) };
|
|
287
|
+
for (const key of workspaceOnlyKeys) {
|
|
288
|
+
if (!(key in data))
|
|
289
|
+
continue;
|
|
290
|
+
delete data[key];
|
|
291
|
+
const finding = {
|
|
292
|
+
rule: "definition-outside-workspace",
|
|
293
|
+
...file.parsed.positionOf([key], { key: true }),
|
|
294
|
+
message: `"${key}" may only be defined in workspace.yaml`,
|
|
295
|
+
};
|
|
296
|
+
file.findings.push(finding);
|
|
297
|
+
}
|
|
298
|
+
return data;
|
|
299
|
+
}
|
|
300
|
+
function toBundle(ws, options) {
|
|
301
|
+
const source = (l) => ({ file: l.file.path, line: l.line });
|
|
302
|
+
const str = (v) => (typeof v === "string" ? v : null);
|
|
303
|
+
const links = (v) => Array.isArray(v) ? v.map(asRecord).map((l) => ({ label: String(l.label ?? ""), url: String(l.url ?? "") })) : [];
|
|
304
|
+
const byId = (a, b) => cmp(a.id, b.id);
|
|
305
|
+
const projects = ws.projects.filter((p) => p.id !== undefined && !p.duplicateOf);
|
|
306
|
+
const elements = ws.elements
|
|
307
|
+
.filter((e) => e.project.id !== undefined && !e.project.duplicateOf)
|
|
308
|
+
.map((e) => {
|
|
309
|
+
const d = e.data;
|
|
310
|
+
const common = {
|
|
311
|
+
id: `${e.project.id}:${e.id}`,
|
|
312
|
+
parent: e.parent ? `${e.parent.project.id}:${e.parent.id}` : null,
|
|
313
|
+
name: str(d.name) ?? e.id,
|
|
314
|
+
description: str(d.description),
|
|
315
|
+
owner: str(d.owner) ?? e.project.owner ?? "",
|
|
316
|
+
tags: Array.isArray(d.tags) ? d.tags.map(String) : [],
|
|
317
|
+
links: links(d.links),
|
|
318
|
+
source: source(e),
|
|
319
|
+
};
|
|
320
|
+
const external = d.external === true;
|
|
321
|
+
const technology = str(d.technology);
|
|
322
|
+
switch (e.kind) {
|
|
323
|
+
case "person":
|
|
324
|
+
return { ...common, kind: e.kind };
|
|
325
|
+
case "system":
|
|
326
|
+
return { ...common, kind: e.kind, external };
|
|
327
|
+
case "service":
|
|
328
|
+
return { ...common, kind: e.kind, type: ["app", "datastore", "broker"].find((t) => t === d.type) ?? "app", technology, external };
|
|
329
|
+
case "component":
|
|
330
|
+
return { ...common, kind: e.kind, technology };
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
const inBundle = (p) => p.id !== undefined && !p.duplicateOf;
|
|
334
|
+
// Declared Relationships whose consumer and provider resolve; an unresolved `via` is left out.
|
|
335
|
+
const resolve = referenceResolver(ws);
|
|
336
|
+
const relationships = ws.relationships.flatMap((r) => {
|
|
337
|
+
const to = resolve(r.data.to, r.from.project);
|
|
338
|
+
if (!inBundle(r.from.project) || !to.ok)
|
|
339
|
+
return [];
|
|
340
|
+
const via = resolve(r.data.via, r.from.project);
|
|
341
|
+
const d = r.data;
|
|
342
|
+
return [
|
|
343
|
+
{
|
|
344
|
+
id: typeof d.id === "string" ? `${r.from.project.id}:${d.id}` : null,
|
|
345
|
+
from: qualified(r.from),
|
|
346
|
+
to: qualified(to.element),
|
|
347
|
+
description: str(d.description),
|
|
348
|
+
technology: str(d.technology),
|
|
349
|
+
interaction: d.interaction === "async" ? "async" : "sync",
|
|
350
|
+
via: via.ok ? qualified(via.element) : null,
|
|
351
|
+
channel: str(d.channel),
|
|
352
|
+
tags: Array.isArray(d.tags) ? d.tags.map(String) : [],
|
|
353
|
+
source: source(r),
|
|
354
|
+
},
|
|
355
|
+
];
|
|
356
|
+
});
|
|
357
|
+
const bySource = (a, b) => cmp(a.source.file, b.source.file) || a.source.line - b.source.line;
|
|
358
|
+
const ownerOf = (decl) => str(decl.data.owner) ?? decl.project.owner ?? "";
|
|
359
|
+
const targets = ws.targets.filter((t) => inBundle(t.project)).map((t) => ({
|
|
360
|
+
id: `${t.project.id}:${t.id}`,
|
|
361
|
+
parent: t.parent ? `${t.project.id}:${t.parent.id}` : null,
|
|
362
|
+
name: str(t.data.name) ?? t.id,
|
|
363
|
+
kind: str(t.data.kind) ?? "",
|
|
364
|
+
description: str(t.data.description),
|
|
365
|
+
owner: ownerOf(t),
|
|
366
|
+
tags: Array.isArray(t.data.tags) ? t.data.tags.map(String) : [],
|
|
367
|
+
links: links(t.data.links),
|
|
368
|
+
source: source(t),
|
|
369
|
+
}));
|
|
370
|
+
const deployments = ws.deployments.filter((d) => inBundle(d.project)).map((d) => ({
|
|
371
|
+
service: qualify(d.data.service, d.project) ?? String(d.data.service ?? ""),
|
|
372
|
+
environment: str(d.data.environment) ?? "",
|
|
373
|
+
target: qualify(d.data.target, d.project) ?? String(d.data.target ?? ""),
|
|
374
|
+
url: str(d.data.url),
|
|
375
|
+
endpoints: Array.isArray(d.data.endpoints) ? d.data.endpoints.map(asRecord).map((e) => ({ name: String(e.name ?? ""), url: String(e.url ?? "") })) : [],
|
|
376
|
+
owner: d.service ? ownerOf(d.service) : (d.project.owner ?? ""),
|
|
377
|
+
source: source(d),
|
|
378
|
+
}));
|
|
379
|
+
const views = ws.views.filter((v) => inBundle(v.project)).flatMap((v) => {
|
|
380
|
+
const ref = (r) => qualify(r, v.project) ?? r;
|
|
381
|
+
if (v.kind === "dynamic") {
|
|
382
|
+
const parsed = DynamicView.safeParse(v.data);
|
|
383
|
+
if (!parsed.success)
|
|
384
|
+
return [];
|
|
385
|
+
const d = parsed.data;
|
|
386
|
+
return [
|
|
387
|
+
{
|
|
388
|
+
id: `${v.project.id}:${v.id}`,
|
|
389
|
+
project: v.project.id,
|
|
390
|
+
kind: "dynamic",
|
|
391
|
+
title: d.title,
|
|
392
|
+
description: d.description ?? null,
|
|
393
|
+
tags: d.tags ?? [],
|
|
394
|
+
participants: d.participants ? d.participants.map(ref) : null,
|
|
395
|
+
steps: d.steps.map((s) => ({
|
|
396
|
+
from: ref(s.from),
|
|
397
|
+
to: ref(s.to),
|
|
398
|
+
relationship: s.relationship === undefined ? null : ref(s.relationship),
|
|
399
|
+
description: s.description ?? null,
|
|
400
|
+
note: s.note ?? null,
|
|
401
|
+
return: s.return === true,
|
|
402
|
+
})),
|
|
403
|
+
source: source(v),
|
|
404
|
+
},
|
|
405
|
+
];
|
|
406
|
+
}
|
|
407
|
+
const parsed = StructuralView.safeParse(v.data);
|
|
408
|
+
if (!parsed.success)
|
|
409
|
+
return [];
|
|
410
|
+
const d = parsed.data;
|
|
411
|
+
const selector = (s) => typeof s === "string" ? ref(s) : "element" in s ? { ...s, element: ref(s.element) } : "from" in s ? { ...s, from: ref(s.from), to: ref(s.to) } : s;
|
|
412
|
+
const lens = (l) => "impact" in l ? { impact: ref(l.impact), direction: l.direction ?? "both" } : "path" in l ? { path: { ...l.path, from: ref(l.path.from), to: ref(l.path.to) } } : l;
|
|
413
|
+
return [
|
|
414
|
+
{
|
|
415
|
+
id: `${v.project.id}:${v.id}`,
|
|
416
|
+
project: v.project.id,
|
|
417
|
+
kind: "structural",
|
|
418
|
+
title: d.title,
|
|
419
|
+
description: d.description ?? null,
|
|
420
|
+
tags: d.tags ?? [],
|
|
421
|
+
level: d.level,
|
|
422
|
+
include: d.include ? d.include.map(selector) : null,
|
|
423
|
+
exclude: (d.exclude ?? []).map(selector),
|
|
424
|
+
expand: (d.expand ?? []).map(ref),
|
|
425
|
+
collapse: (d.collapse ?? []).map(ref),
|
|
426
|
+
direction: d.direction ?? null,
|
|
427
|
+
lens: d.lens ? lens(d.lens) : null,
|
|
428
|
+
environment: d.environment ?? null,
|
|
429
|
+
targets: (d.targets ?? []).map(ref),
|
|
430
|
+
source: source(v),
|
|
431
|
+
},
|
|
432
|
+
];
|
|
433
|
+
});
|
|
434
|
+
// The first declaration of an id keeps it; `duplicate-view-id` reports the others.
|
|
435
|
+
const viewIds = new Set();
|
|
436
|
+
const uniqueViews = views.filter((v) => !viewIds.has(v.id) && viewIds.add(v.id));
|
|
437
|
+
const bundle = {
|
|
438
|
+
schemaVersion: SCHEMA_VERSION,
|
|
439
|
+
commit: options.commit ?? null,
|
|
440
|
+
builtAt: options.builtAt ?? null,
|
|
441
|
+
teams: ws.teams
|
|
442
|
+
.map((t) => ({ id: t.id, name: str(t.data.name) ?? t.id, description: str(t.data.description), links: links(t.data.links), source: source(t) }))
|
|
443
|
+
.sort(byId),
|
|
444
|
+
environments: ws.environments
|
|
445
|
+
.map((e) => ({ id: e.id, name: str(e.data.name) ?? e.id, description: str(e.data.description), source: source(e) }))
|
|
446
|
+
.sort(byId),
|
|
447
|
+
projects: projects
|
|
448
|
+
.map((p) => ({ id: p.id, name: p.name, owner: p.owner ?? "", folder: p.folder, source: { file: p.file.path, line: 1 } }))
|
|
449
|
+
.sort(byId),
|
|
450
|
+
elements: elements.sort(byId),
|
|
451
|
+
relationships: relationships.sort((a, b) => cmp(a.from, b.from) || cmp(a.to, b.to) || bySource(a, b)),
|
|
452
|
+
targets: targets.sort(byId),
|
|
453
|
+
deployments: deployments.sort((a, b) => cmp(a.service, b.service) || cmp(a.environment, b.environment) || cmp(a.target, b.target) || cmp(a.source.file, b.source.file) || a.source.line - b.source.line),
|
|
454
|
+
views: uniqueViews.sort(byId),
|
|
455
|
+
adrs: bundleAdrs(ws),
|
|
456
|
+
};
|
|
457
|
+
// Parsing fixes key order to the schema's.
|
|
458
|
+
return Bundle.parse(bundle);
|
|
459
|
+
}
|
|
460
|
+
/** The Bundle as written to `workspace.bundle.json`: stable key order, two-space indent. */
|
|
461
|
+
export function serializeBundle(bundle) {
|
|
462
|
+
return JSON.stringify(Bundle.parse(bundle), null, 2) + "\n";
|
|
463
|
+
}
|
|
464
|
+
const asRecord = (v) => v !== null && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
465
|
+
const cmp = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { ElementKind } from "../schema/workspace.ts";
|
|
2
|
+
import type { SchemaFinding } from "./schema-check.ts";
|
|
3
|
+
import type { ParsedYaml, Position } from "./yaml.ts";
|
|
4
|
+
export type Severity = "error" | "warning";
|
|
5
|
+
/** One problem found in a Workspace. `file` is relative to the repo root. */
|
|
6
|
+
export interface Issue {
|
|
7
|
+
file: string;
|
|
8
|
+
line: number;
|
|
9
|
+
column?: number;
|
|
10
|
+
rule: string;
|
|
11
|
+
severity: Severity;
|
|
12
|
+
message: string;
|
|
13
|
+
}
|
|
14
|
+
/** An issue as a rule's check reports it; the registry adds rule id and severity. */
|
|
15
|
+
export interface IssueDraft {
|
|
16
|
+
file: string;
|
|
17
|
+
line: number;
|
|
18
|
+
column?: number;
|
|
19
|
+
message: string;
|
|
20
|
+
}
|
|
21
|
+
export type FileRole = "workspace" | "project" | "model" | "outside";
|
|
22
|
+
export interface Finding extends Position {
|
|
23
|
+
rule: SchemaFinding["rule"] | "definition-outside-workspace";
|
|
24
|
+
message: string;
|
|
25
|
+
}
|
|
26
|
+
/** A `*.yaml` file found under the Workspace root. */
|
|
27
|
+
export interface SourceFile {
|
|
28
|
+
/** Repo-relative, with `/` separators. */
|
|
29
|
+
path: string;
|
|
30
|
+
role: FileRole;
|
|
31
|
+
project?: Project;
|
|
32
|
+
parsed: ParsedYaml;
|
|
33
|
+
/** Schema problems found while reading the file. */
|
|
34
|
+
findings: Finding[];
|
|
35
|
+
}
|
|
36
|
+
export interface Project {
|
|
37
|
+
/** Undefined when `project.yaml` has no usable id. */
|
|
38
|
+
id?: string;
|
|
39
|
+
name: string;
|
|
40
|
+
owner?: string;
|
|
41
|
+
ownerPosition?: Position;
|
|
42
|
+
/** Repo-relative folder. */
|
|
43
|
+
folder: string;
|
|
44
|
+
file: SourceFile;
|
|
45
|
+
/** The Project whose folder contains this one, if any. */
|
|
46
|
+
nestedIn?: Project;
|
|
47
|
+
/** An earlier Project (in path order) with the same id, if any. */
|
|
48
|
+
duplicateOf?: Project;
|
|
49
|
+
}
|
|
50
|
+
export interface Located<T> extends Position {
|
|
51
|
+
id: string;
|
|
52
|
+
file: SourceFile;
|
|
53
|
+
data: T;
|
|
54
|
+
}
|
|
55
|
+
export interface ElementDecl extends Position {
|
|
56
|
+
kind: ElementKind;
|
|
57
|
+
id: string;
|
|
58
|
+
project: Project;
|
|
59
|
+
file: SourceFile;
|
|
60
|
+
/** Where the declaration sits in its file, e.g. `["systems", "shop", "services", "web"]`. */
|
|
61
|
+
path: string[];
|
|
62
|
+
data: Record<string, unknown>;
|
|
63
|
+
/** The Element it is nested under in its file, if any. */
|
|
64
|
+
nestedIn?: ElementDecl;
|
|
65
|
+
/** Its parent: the Element it is nested under, or the one its `in:` names. Set once every file is read. */
|
|
66
|
+
parent?: ElementDecl;
|
|
67
|
+
}
|
|
68
|
+
/** One entry of an Element's `relationships`, as declared. */
|
|
69
|
+
export interface RelationshipDecl extends Position {
|
|
70
|
+
/** The consumer: the Element it is declared under. */
|
|
71
|
+
from: ElementDecl;
|
|
72
|
+
file: SourceFile;
|
|
73
|
+
/** Where the entry sits in its file, e.g. `["services", "web", "relationships", 0]`. */
|
|
74
|
+
path: (string | number)[];
|
|
75
|
+
data: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
export interface TargetDecl extends Position {
|
|
78
|
+
id: string;
|
|
79
|
+
project: Project;
|
|
80
|
+
file: SourceFile;
|
|
81
|
+
/** Where the declaration sits in its file, e.g. `["targets", "aws-eu", "targets", "eks-prod"]`. */
|
|
82
|
+
path: string[];
|
|
83
|
+
data: Record<string, unknown>;
|
|
84
|
+
/** The Target it is nested under, if any. */
|
|
85
|
+
parent?: TargetDecl;
|
|
86
|
+
}
|
|
87
|
+
export interface DeploymentDecl extends Position {
|
|
88
|
+
project: Project;
|
|
89
|
+
file: SourceFile;
|
|
90
|
+
/** `["deployments", index]` in its file. */
|
|
91
|
+
path: (string | number)[];
|
|
92
|
+
data: Record<string, unknown>;
|
|
93
|
+
/** What `service` and `target` resolve to, if anything. Set once every file is read. */
|
|
94
|
+
service?: ElementDecl;
|
|
95
|
+
target?: TargetDecl;
|
|
96
|
+
}
|
|
97
|
+
/** One Saved View under `views: structural:` or `views: dynamic:` in a Project file. */
|
|
98
|
+
export interface ViewDecl extends Position {
|
|
99
|
+
kind: "structural" | "dynamic";
|
|
100
|
+
id: string;
|
|
101
|
+
project: Project;
|
|
102
|
+
file: SourceFile;
|
|
103
|
+
/** `["views", kind, id]` in its file. */
|
|
104
|
+
path: string[];
|
|
105
|
+
data: Record<string, unknown>;
|
|
106
|
+
}
|
|
107
|
+
/** One ADR file in a Project's `adr/` folder (any `.md` there but `template.md`). */
|
|
108
|
+
export interface AdrDecl {
|
|
109
|
+
project: Project;
|
|
110
|
+
/** Repo-relative, with `/` separators. */
|
|
111
|
+
path: string;
|
|
112
|
+
filename: string;
|
|
113
|
+
/** The four-digit number, when the filename is `NNNN-slug.md`. */
|
|
114
|
+
number?: string;
|
|
115
|
+
/** The frontmatter's YAML, parsed; undefined when the file has no frontmatter. */
|
|
116
|
+
frontmatter?: ParsedYaml;
|
|
117
|
+
/** Lines before the frontmatter's YAML; a position in `frontmatter` is this many lines further down the file. */
|
|
118
|
+
lineOffset: number;
|
|
119
|
+
/** The frontmatter as plain data; empty when missing or unparsable. */
|
|
120
|
+
data: Record<string, unknown>;
|
|
121
|
+
/** The body's first `# ` heading, and its line in the file. */
|
|
122
|
+
title?: {
|
|
123
|
+
text: string;
|
|
124
|
+
line: number;
|
|
125
|
+
};
|
|
126
|
+
/** Everything after the frontmatter and the blank lines below it. */
|
|
127
|
+
body: string;
|
|
128
|
+
/** The line the body starts at. */
|
|
129
|
+
bodyLine: number;
|
|
130
|
+
}
|
|
131
|
+
/** Everything Load read from disk, before rules run and the Bundle is built. */
|
|
132
|
+
export interface LoadedWorkspace {
|
|
133
|
+
files: SourceFile[];
|
|
134
|
+
/** Sorted by folder. */
|
|
135
|
+
projects: Project[];
|
|
136
|
+
teams: Located<Record<string, unknown>>[];
|
|
137
|
+
environments: Located<Record<string, unknown>>[];
|
|
138
|
+
/** Sorted by file, then line. */
|
|
139
|
+
elements: ElementDecl[];
|
|
140
|
+
/** Sorted by file, then line. */
|
|
141
|
+
relationships: RelationshipDecl[];
|
|
142
|
+
/** Sorted by file, then line. */
|
|
143
|
+
targets: TargetDecl[];
|
|
144
|
+
/** Sorted by file, then line. */
|
|
145
|
+
deployments: DeploymentDecl[];
|
|
146
|
+
/** Sorted by file, then line. */
|
|
147
|
+
views: ViewDecl[];
|
|
148
|
+
/** Sorted by path. */
|
|
149
|
+
adrs: AdrDecl[];
|
|
150
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Bundle, BundleElement } from "../schema/bundle.ts";
|
|
2
|
+
export type OwnedKind = BundleElement["kind"] | "target";
|
|
3
|
+
/** One thing a Team owns, with how many other Teams sit upstream and downstream of it. */
|
|
4
|
+
export interface OwnedItem {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
parent: string | null;
|
|
8
|
+
upstreamTeams: number;
|
|
9
|
+
downstreamTeams: number;
|
|
10
|
+
}
|
|
11
|
+
export interface OwnedGroup {
|
|
12
|
+
kind: OwnedKind;
|
|
13
|
+
total: number;
|
|
14
|
+
items: OwnedItem[];
|
|
15
|
+
}
|
|
16
|
+
export interface OwnedResult {
|
|
17
|
+
team: string;
|
|
18
|
+
kind: OwnedKind | null;
|
|
19
|
+
total: number;
|
|
20
|
+
groups: OwnedGroup[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The Elements and Deployment Targets `team` owns, grouped by kind in the
|
|
24
|
+
* order Person, System, Service, Component, Target, each sorted by id. An
|
|
25
|
+
* Element is listed under its own Owner, whoever owns its parent.
|
|
26
|
+
*
|
|
27
|
+
* For an Element, Upstream Teams own the consumers of Relationships into it
|
|
28
|
+
* or its descendants, and Downstream Teams own their providers; a `via`
|
|
29
|
+
* broker is a provider of both the consumer and the provider. For a Target,
|
|
30
|
+
* Upstream Teams own the Deployments on it or the Targets beneath it, and
|
|
31
|
+
* Downstream Teams own the Targets above it. The Team itself is never
|
|
32
|
+
* counted.
|
|
33
|
+
*/
|
|
34
|
+
export declare function listOwned(bundle: Bundle, team: string, kind?: OwnedKind): OwnedResult;
|