@principal-ai/subsystems-core 0.52.0 → 0.53.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 +30 -2
- package/dist/audit/boundary.d.ts +104 -0
- package/dist/audit/boundary.d.ts.map +1 -0
- package/dist/audit/boundary.js +363 -0
- package/dist/audit/boundary.js.map +1 -0
- package/dist/audit/c4.d.ts +41 -0
- package/dist/audit/c4.d.ts.map +1 -0
- package/dist/audit/c4.js +41 -0
- package/dist/audit/c4.js.map +1 -0
- package/dist/audit/engine.d.ts +135 -0
- package/dist/audit/engine.d.ts.map +1 -0
- package/dist/audit/engine.js +865 -0
- package/dist/audit/engine.js.map +1 -0
- package/dist/audit/fixes.d.ts +80 -0
- package/dist/audit/fixes.d.ts.map +1 -0
- package/dist/audit/fixes.js +162 -0
- package/dist/audit/fixes.js.map +1 -0
- package/dist/audit/graphify-provider.d.ts +51 -0
- package/dist/audit/graphify-provider.d.ts.map +1 -0
- package/dist/audit/graphify-provider.js +36 -0
- package/dist/audit/graphify-provider.js.map +1 -0
- package/dist/audit/hash.d.ts +25 -0
- package/dist/audit/hash.d.ts.map +1 -0
- package/dist/audit/hash.js +53 -0
- package/dist/audit/hash.js.map +1 -0
- package/dist/audit/index.d.ts +12 -0
- package/dist/audit/index.d.ts.map +1 -0
- package/dist/audit/index.js +40 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/audit/local-graphify.d.ts +75 -0
- package/dist/audit/local-graphify.d.ts.map +1 -0
- package/dist/audit/local-graphify.js +283 -0
- package/dist/audit/local-graphify.js.map +1 -0
- package/dist/audit/paths.d.ts +16 -0
- package/dist/audit/paths.d.ts.map +1 -0
- package/dist/audit/paths.js +31 -0
- package/dist/audit/paths.js.map +1 -0
- package/dist/audit/pure.d.ts +18 -0
- package/dist/audit/pure.d.ts.map +1 -0
- package/dist/audit/pure.js +50 -0
- package/dist/audit/pure.js.map +1 -0
- package/dist/audit/report-logic.d.ts +17 -0
- package/dist/audit/report-logic.d.ts.map +1 -0
- package/dist/audit/report-logic.js +206 -0
- package/dist/audit/report-logic.js.map +1 -0
- package/dist/audit/report.d.ts +140 -0
- package/dist/audit/report.d.ts.map +1 -0
- package/dist/audit/report.js +3 -0
- package/dist/audit/report.js.map +1 -0
- package/dist/audit/trail.d.ts +29 -0
- package/dist/audit/trail.d.ts.map +1 -0
- package/dist/audit/trail.js +59 -0
- package/dist/audit/trail.js.map +1 -0
- package/dist/audit/verification.d.ts +98 -0
- package/dist/audit/verification.d.ts.map +1 -0
- package/dist/audit/verification.js +11 -0
- package/dist/audit/verification.js.map +1 -0
- package/dist/audit/verify/component.d.ts +68 -0
- package/dist/audit/verify/component.d.ts.map +1 -0
- package/dist/audit/verify/component.js +500 -0
- package/dist/audit/verify/component.js.map +1 -0
- package/dist/audit/verify/declarations.d.ts +58 -0
- package/dist/audit/verify/declarations.d.ts.map +1 -0
- package/dist/audit/verify/declarations.js +227 -0
- package/dist/audit/verify/declarations.js.map +1 -0
- package/dist/audit/verify/grammar.d.ts +12 -0
- package/dist/audit/verify/grammar.d.ts.map +1 -0
- package/dist/audit/verify/grammar.js +57 -0
- package/dist/audit/verify/grammar.js.map +1 -0
- package/dist/audit/verify/index.d.ts +12 -0
- package/dist/audit/verify/index.d.ts.map +1 -0
- package/dist/audit/verify/index.js +31 -0
- package/dist/audit/verify/index.js.map +1 -0
- package/dist/audit/verify/parser.d.ts +19 -0
- package/dist/audit/verify/parser.d.ts.map +1 -0
- package/dist/audit/verify/parser.js +122 -0
- package/dist/audit/verify/parser.js.map +1 -0
- package/dist/audit/verify/span.d.ts +49 -0
- package/dist/audit/verify/span.d.ts.map +1 -0
- package/dist/audit/verify/span.js +377 -0
- package/dist/audit/verify/span.js.map +1 -0
- package/dist/graphify/anchor.d.ts +45 -0
- package/dist/graphify/anchor.d.ts.map +1 -0
- package/dist/graphify/anchor.js +179 -0
- package/dist/graphify/anchor.js.map +1 -0
- package/dist/graphify/consolidated.d.ts +259 -0
- package/dist/graphify/consolidated.d.ts.map +1 -0
- package/dist/graphify/consolidated.js +12 -0
- package/dist/graphify/consolidated.js.map +1 -0
- package/dist/graphify/construct.d.ts +41 -0
- package/dist/graphify/construct.d.ts.map +1 -0
- package/dist/graphify/construct.js +106 -0
- package/dist/graphify/construct.js.map +1 -0
- package/dist/graphify/ids.d.ts +19 -0
- package/dist/graphify/ids.d.ts.map +1 -0
- package/dist/graphify/ids.js +53 -0
- package/dist/graphify/ids.js.map +1 -0
- package/dist/graphify/index.d.ts +16 -0
- package/dist/graphify/index.d.ts.map +1 -0
- package/dist/graphify/index.js +32 -0
- package/dist/graphify/index.js.map +1 -0
- package/dist/graphify/resolve.d.ts +48 -0
- package/dist/graphify/resolve.d.ts.map +1 -0
- package/dist/graphify/resolve.js +89 -0
- package/dist/graphify/resolve.js.map +1 -0
- package/dist/graphify/signature.d.ts +87 -0
- package/dist/graphify/signature.d.ts.map +1 -0
- package/dist/graphify/signature.js +282 -0
- package/dist/graphify/signature.js.map +1 -0
- package/dist/graphify/types.d.ts +141 -0
- package/dist/graphify/types.d.ts.map +1 -0
- package/dist/graphify/types.js +9 -0
- package/dist/graphify/types.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/infra/c4.d.ts +59 -0
- package/dist/infra/c4.d.ts.map +1 -0
- package/dist/infra/c4.js +106 -0
- package/dist/infra/c4.js.map +1 -0
- package/dist/infra/index.d.ts +13 -0
- package/dist/infra/index.d.ts.map +1 -0
- package/dist/infra/index.js +22 -0
- package/dist/infra/index.js.map +1 -0
- package/dist/infra/jsonc.d.ts +10 -0
- package/dist/infra/jsonc.d.ts.map +1 -0
- package/dist/infra/jsonc.js +77 -0
- package/dist/infra/jsonc.js.map +1 -0
- package/dist/infra/terraform.d.ts +41 -0
- package/dist/infra/terraform.d.ts.map +1 -0
- package/dist/infra/terraform.js +208 -0
- package/dist/infra/terraform.js.map +1 -0
- package/dist/infra/types.d.ts +107 -0
- package/dist/infra/types.d.ts.map +1 -0
- package/dist/infra/types.js +47 -0
- package/dist/infra/types.js.map +1 -0
- package/dist/infra/wrangler.d.ts +32 -0
- package/dist/infra/wrangler.d.ts.map +1 -0
- package/dist/infra/wrangler.js +177 -0
- package/dist/infra/wrangler.js.map +1 -0
- package/dist/node.d.ts +3 -0
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +4 -1
- package/dist/node.js.map +1 -1
- package/dist/storage/topic-reference-links.d.ts +3 -3
- package/dist/storage/topic-reference-links.d.ts.map +1 -1
- package/dist/storage/topic-reference-links.js +23 -8
- package/dist/storage/topic-reference-links.js.map +1 -1
- package/dist/storage/topic-share.d.ts +69 -0
- package/dist/storage/topic-share.d.ts.map +1 -0
- package/dist/storage/topic-share.js +67 -0
- package/dist/storage/topic-share.js.map +1 -0
- package/dist/storage/topic-types.d.ts +5 -1
- package/dist/storage/topic-types.d.ts.map +1 -1
- package/dist/types/subsystem-model.d.ts +59 -0
- package/dist/types/subsystem-model.d.ts.map +1 -1
- package/dist/types/subsystem-model.js +50 -1
- package/dist/types/subsystem-model.js.map +1 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +25 -2
- package/dist/validation.js.map +1 -1
- package/package.json +22 -2
- package/schemas/subsystem-model.schema.json +35 -19
- package/src/audit/boundary.ts +447 -0
- package/src/audit/c4.ts +70 -0
- package/src/audit/engine.ts +1099 -0
- package/src/audit/fixes.ts +192 -0
- package/src/audit/graphify-provider.test.ts +58 -0
- package/src/audit/graphify-provider.ts +77 -0
- package/src/audit/hash.ts +58 -0
- package/src/audit/index.ts +34 -0
- package/src/audit/local-graphify.test.ts +163 -0
- package/src/audit/local-graphify.ts +354 -0
- package/src/audit/paths.ts +25 -0
- package/src/audit/pure.ts +91 -0
- package/src/audit/report-logic.test.ts +145 -0
- package/src/audit/report-logic.ts +245 -0
- package/src/audit/report.ts +207 -0
- package/src/audit/trail.ts +77 -0
- package/src/audit/verification.ts +104 -0
- package/src/audit/verify/component.ts +760 -0
- package/src/audit/verify/declarations.ts +284 -0
- package/src/audit/verify/grammar.ts +57 -0
- package/src/audit/verify/index.ts +41 -0
- package/src/audit/verify/parser.ts +124 -0
- package/src/audit/verify/span.ts +478 -0
- package/src/graphify/anchor.ts +206 -0
- package/src/graphify/consolidated.ts +298 -0
- package/src/graphify/construct.ts +153 -0
- package/src/graphify/ids.ts +48 -0
- package/src/graphify/index.ts +16 -0
- package/src/graphify/resolve.ts +115 -0
- package/src/graphify/signature.ts +354 -0
- package/src/graphify/types.ts +164 -0
- package/src/index.ts +10 -0
- package/src/infra/c4.ts +146 -0
- package/src/infra/index.ts +21 -0
- package/src/infra/infra.test.ts +360 -0
- package/src/infra/jsonc.ts +70 -0
- package/src/infra/terraform.ts +251 -0
- package/src/infra/types.ts +136 -0
- package/src/infra/wrangler.ts +203 -0
- package/src/node.ts +3 -0
- package/src/storage/topic-reference-links.test.ts +7 -1
- package/src/storage/topic-reference-links.ts +24 -8
- package/src/storage/topic-share.test.ts +91 -0
- package/src/storage/topic-share.ts +118 -0
- package/src/storage/topic-types.ts +3 -1
- package/src/storage/topicStore.test.ts +1 -0
- package/src/types/subsystem-model.test.ts +52 -2
- package/src/types/subsystem-model.ts +104 -0
- package/src/validation.test.ts +71 -7
- package/src/validation.ts +27 -2
|
@@ -6,9 +6,20 @@ function isReferenceId(id: string): boolean {
|
|
|
6
6
|
return id.length > 0 && id !== '.' && id !== '..' && !/[/\\\s\u0000-\u001f\u007f]/.test(id);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
function referenceId(reference: TopicReference): string {
|
|
10
|
+
switch (reference.kind) {
|
|
11
|
+
case 'topic':
|
|
12
|
+
return reference.topicId;
|
|
13
|
+
case 'c4-sketch':
|
|
14
|
+
return reference.sketchId;
|
|
15
|
+
case 'drawing':
|
|
16
|
+
return reference.drawingId;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
9
20
|
/** Format a Markdown-safe href. Does not attach or resolve the target. */
|
|
10
21
|
export function formatTopicReferenceLink(reference: TopicReference): string {
|
|
11
|
-
const id = reference
|
|
22
|
+
const id = referenceId(reference);
|
|
12
23
|
if (!isReferenceId(id)) throw new Error('Invalid topic reference id');
|
|
13
24
|
const encoded = encodeURIComponent(id).replace(
|
|
14
25
|
/[!'()*]/g,
|
|
@@ -18,12 +29,12 @@ export function formatTopicReferenceLink(reference: TopicReference): string {
|
|
|
18
29
|
}
|
|
19
30
|
|
|
20
31
|
/**
|
|
21
|
-
* Parse a local topic/sketch href without I/O. Unknown kinds, malformed
|
|
22
|
-
* extra path segments, queries, and fragments return null. Target
|
|
23
|
-
* navigation belong to the host. Parsing never creates an attachment.
|
|
32
|
+
* Parse a local topic/sketch/drawing href without I/O. Unknown kinds, malformed
|
|
33
|
+
* escapes, extra path segments, queries, and fragments return null. Target
|
|
34
|
+
* existence and navigation belong to the host. Parsing never creates an attachment.
|
|
24
35
|
*/
|
|
25
36
|
export function parseTopicReferenceLink(href: string): TopicReference | null {
|
|
26
|
-
const match = /^principal:\/\/(topic|c4-sketch)\/([^/?#]+)$/.exec(href);
|
|
37
|
+
const match = /^principal:\/\/(topic|c4-sketch|drawing)\/([^/?#]+)$/.exec(href);
|
|
27
38
|
if (!match) return null;
|
|
28
39
|
let id: string;
|
|
29
40
|
try {
|
|
@@ -32,7 +43,12 @@ export function parseTopicReferenceLink(href: string): TopicReference | null {
|
|
|
32
43
|
return null;
|
|
33
44
|
}
|
|
34
45
|
if (!isReferenceId(id)) return null;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
46
|
+
switch (match[1]) {
|
|
47
|
+
case 'topic':
|
|
48
|
+
return { kind: 'topic', topicId: id };
|
|
49
|
+
case 'c4-sketch':
|
|
50
|
+
return { kind: 'c4-sketch', sketchId: id };
|
|
51
|
+
default:
|
|
52
|
+
return { kind: 'drawing', drawingId: id };
|
|
53
|
+
}
|
|
38
54
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { toSharedTopic } from './topic-share';
|
|
3
|
+
import type { DraftTopic } from './topic-types';
|
|
4
|
+
|
|
5
|
+
const base: DraftTopic = {
|
|
6
|
+
id: 'topic-1-abc',
|
|
7
|
+
title: 'Sharing',
|
|
8
|
+
description: 'Brief with ',
|
|
9
|
+
repos: ['pkg:github/principal-ai/subsystem-modeling'],
|
|
10
|
+
createdAt: '2026-11-01T00:00:00.000Z',
|
|
11
|
+
updatedAt: '2026-11-02T00:00:00.000Z',
|
|
12
|
+
createdBy: { githubId: 1, githubLogin: 'octocat' },
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
describe('toSharedTopic', () => {
|
|
16
|
+
test('keeps the portable fields unchanged', () => {
|
|
17
|
+
const { topic, uploads } = toSharedTopic(base);
|
|
18
|
+
expect(topic).toEqual(base);
|
|
19
|
+
expect(uploads).toEqual([]);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('keeps model, sketch and topic references by id and drops drawings', () => {
|
|
23
|
+
const { topic } = toSharedTopic({
|
|
24
|
+
...base,
|
|
25
|
+
subsystemModels: [{ modelId: 'sg-1', trailIds: ['wt-a'] }, { modelId: 'sg-2', trailIds: [] }],
|
|
26
|
+
references: [
|
|
27
|
+
{ kind: 'c4-sketch', sketchId: 'c4s-1' },
|
|
28
|
+
{ kind: 'drawing', drawingId: 'd-1' },
|
|
29
|
+
{ kind: 'topic', topicId: 'topic-2' },
|
|
30
|
+
],
|
|
31
|
+
});
|
|
32
|
+
expect(topic.subsystemModels).toEqual([
|
|
33
|
+
{ modelId: 'sg-1', trailIds: ['wt-a'] },
|
|
34
|
+
{ modelId: 'sg-2' },
|
|
35
|
+
]);
|
|
36
|
+
expect(topic.references).toEqual([
|
|
37
|
+
{ kind: 'c4-sketch', sketchId: 'c4s-1' },
|
|
38
|
+
{ kind: 'topic', topicId: 'topic-2' },
|
|
39
|
+
]);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('omits empty reference lists', () => {
|
|
43
|
+
const { topic } = toSharedTopic({
|
|
44
|
+
...base,
|
|
45
|
+
subsystemModels: [],
|
|
46
|
+
references: [{ kind: 'drawing', drawingId: 'd-1' }],
|
|
47
|
+
});
|
|
48
|
+
expect(topic).not.toHaveProperty('subsystemModels');
|
|
49
|
+
expect(topic).not.toHaveProperty('references');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('splits inline bytes into uploads and strips local asset origin', () => {
|
|
53
|
+
const { topic, uploads } = toSharedTopic({
|
|
54
|
+
...base,
|
|
55
|
+
assets: [
|
|
56
|
+
{
|
|
57
|
+
id: 'hash-a',
|
|
58
|
+
mime: 'image/png',
|
|
59
|
+
data: 'AAAA',
|
|
60
|
+
alt: 'shot',
|
|
61
|
+
source: { storyId: 's', storybookUrl: 'http://localhost:6006' },
|
|
62
|
+
},
|
|
63
|
+
{ id: 'hash-b', mime: 'image/jpeg', url: 'https://example.com/b.jpg' },
|
|
64
|
+
],
|
|
65
|
+
});
|
|
66
|
+
expect(topic.assets).toEqual([
|
|
67
|
+
{ id: 'hash-a', mime: 'image/png', alt: 'shot' },
|
|
68
|
+
{ id: 'hash-b', mime: 'image/jpeg', url: 'https://example.com/b.jpg' },
|
|
69
|
+
]);
|
|
70
|
+
expect(uploads).toEqual([{ id: 'hash-a', mime: 'image/png', data: 'AAAA' }]);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('omits unresolvable and duplicate assets', () => {
|
|
74
|
+
const { topic, uploads } = toSharedTopic({
|
|
75
|
+
...base,
|
|
76
|
+
assets: [
|
|
77
|
+
{ id: 'hash-a', mime: 'image/png', data: 'AAAA' },
|
|
78
|
+
{ id: 'hash-a', mime: 'image/png', data: 'AAAA' },
|
|
79
|
+
{ id: 'hash-c', mime: 'image/png' },
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
expect(topic.assets).toEqual([{ id: 'hash-a', mime: 'image/png' }]);
|
|
83
|
+
expect(uploads).toHaveLength(1);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('does not alias the source arrays', () => {
|
|
87
|
+
const { topic } = toSharedTopic(base);
|
|
88
|
+
expect(topic.repos).not.toBe(base.repos);
|
|
89
|
+
expect(topic.createdBy).not.toBe(base.createdBy);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portable projection of a topic for sharing outside the machine that authored
|
|
3
|
+
* it. Browser-safe (no `node:*`).
|
|
4
|
+
*
|
|
5
|
+
* A {@link DraftTopic} carries fields that only mean something locally: inline
|
|
6
|
+
* image bytes, local asset origins and drawing references. {@link toSharedTopic}
|
|
7
|
+
* drops those and splits image bytes out so a host can upload each one
|
|
8
|
+
* separately.
|
|
9
|
+
*
|
|
10
|
+
* References to subsystem models, C4 sketches and other topics are kept as ids.
|
|
11
|
+
* A share is published under its local id, so a reader resolves the same id
|
|
12
|
+
* against the sharing service instead of the local store. A reference whose
|
|
13
|
+
* target was not shared (or not with the reader) is simply unavailable.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type {
|
|
17
|
+
DraftTopic,
|
|
18
|
+
TopicAsset,
|
|
19
|
+
TopicCreator,
|
|
20
|
+
TopicReference,
|
|
21
|
+
TopicSubsystemModelRef,
|
|
22
|
+
} from './topic-types';
|
|
23
|
+
|
|
24
|
+
/** A reference a shared topic can carry. Drawings have no shared form yet. */
|
|
25
|
+
export type SharedTopicReference = Exclude<TopicReference, { kind: 'drawing' }>;
|
|
26
|
+
|
|
27
|
+
/** An image a shared topic refers to. Bytes travel separately, keyed by `id`. */
|
|
28
|
+
export interface SharedTopicAsset {
|
|
29
|
+
/** Content hash; the `asset://<id>` target in the description. */
|
|
30
|
+
id: string;
|
|
31
|
+
/** MIME type, e.g. "image/png". */
|
|
32
|
+
mime: string;
|
|
33
|
+
/** Resolvable URL, when the bytes already live somewhere public. */
|
|
34
|
+
url?: string;
|
|
35
|
+
/** Markdown alt text. */
|
|
36
|
+
alt?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A topic as it leaves the authoring machine. No inline bytes; `description`
|
|
41
|
+
* is unchanged, so `asset://<id>` links still resolve against `assets`.
|
|
42
|
+
*/
|
|
43
|
+
export interface SharedTopic {
|
|
44
|
+
id: string;
|
|
45
|
+
title: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
/** Repositories as PURL strings. */
|
|
48
|
+
repos?: string[];
|
|
49
|
+
/** ISO 8601. */
|
|
50
|
+
createdAt: string;
|
|
51
|
+
/** ISO 8601. */
|
|
52
|
+
updatedAt: string;
|
|
53
|
+
createdBy?: TopicCreator;
|
|
54
|
+
assets?: SharedTopicAsset[];
|
|
55
|
+
/** Subsystem models the topic concerns, by share id (same as the local id). */
|
|
56
|
+
subsystemModels?: TopicSubsystemModelRef[];
|
|
57
|
+
/** Attached C4 sketches and related topics, by share id. */
|
|
58
|
+
references?: SharedTopicReference[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface SharedTopicProjection {
|
|
62
|
+
topic: SharedTopic;
|
|
63
|
+
/** Assets whose bytes must be uploaded alongside the topic (those with `data`). */
|
|
64
|
+
uploads: Array<{ id: string; mime: string; data: string }>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Project a local topic into its shared form.
|
|
69
|
+
*
|
|
70
|
+
* Dropped: drawing references (no shared form), each asset's `source` (local
|
|
71
|
+
* Storybook origin) and inline `data`. Assets with neither `data` nor `url`
|
|
72
|
+
* cannot be resolved by a reader and are omitted.
|
|
73
|
+
*/
|
|
74
|
+
export function toSharedTopic(topic: DraftTopic): SharedTopicProjection {
|
|
75
|
+
const assets: SharedTopicAsset[] = [];
|
|
76
|
+
const uploads: SharedTopicProjection['uploads'] = [];
|
|
77
|
+
const seen = new Set<string>();
|
|
78
|
+
|
|
79
|
+
for (const asset of topic.assets ?? []) {
|
|
80
|
+
if (seen.has(asset.id) || !isResolvable(asset)) continue;
|
|
81
|
+
seen.add(asset.id);
|
|
82
|
+
assets.push({
|
|
83
|
+
id: asset.id,
|
|
84
|
+
mime: asset.mime,
|
|
85
|
+
...(asset.url ? { url: asset.url } : {}),
|
|
86
|
+
...(asset.alt ? { alt: asset.alt } : {}),
|
|
87
|
+
});
|
|
88
|
+
if (asset.data) uploads.push({ id: asset.id, mime: asset.mime, data: asset.data });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const subsystemModels = (topic.subsystemModels ?? []).map((ref) => ({
|
|
92
|
+
modelId: ref.modelId,
|
|
93
|
+
...(ref.trailIds?.length ? { trailIds: [...ref.trailIds] } : {}),
|
|
94
|
+
}));
|
|
95
|
+
const references = (topic.references ?? []).filter(
|
|
96
|
+
(ref): ref is SharedTopicReference => ref.kind !== 'drawing',
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
topic: {
|
|
101
|
+
id: topic.id,
|
|
102
|
+
title: topic.title,
|
|
103
|
+
...(topic.description !== undefined ? { description: topic.description } : {}),
|
|
104
|
+
...(topic.repos?.length ? { repos: [...topic.repos] } : {}),
|
|
105
|
+
createdAt: topic.createdAt,
|
|
106
|
+
updatedAt: topic.updatedAt,
|
|
107
|
+
...(topic.createdBy ? { createdBy: { ...topic.createdBy } } : {}),
|
|
108
|
+
...(assets.length ? { assets } : {}),
|
|
109
|
+
...(subsystemModels.length ? { subsystemModels } : {}),
|
|
110
|
+
...(references.length ? { references: references.map((ref) => ({ ...ref })) } : {}),
|
|
111
|
+
},
|
|
112
|
+
uploads,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function isResolvable(asset: TopicAsset): boolean {
|
|
117
|
+
return Boolean(asset.data || asset.url);
|
|
118
|
+
}
|
|
@@ -60,9 +60,11 @@ export interface TopicSubsystemModelRef {
|
|
|
60
60
|
* A directional, local-only reference owned by a topic. Targets remain separate
|
|
61
61
|
* artifacts; their contents and titles are resolved by the host, not copied here.
|
|
62
62
|
* Referencing a C4 sketch does not make its authored hypothesis evidence.
|
|
63
|
+
* A drawing ID is the `.excalidraw` file stem under the host's drawings folder.
|
|
63
64
|
*/
|
|
64
65
|
export type TopicReference =
|
|
65
66
|
| { kind: 'c4-sketch'; sketchId: string }
|
|
67
|
+
| { kind: 'drawing'; drawingId: string }
|
|
66
68
|
| { kind: 'topic'; topicId: string };
|
|
67
69
|
|
|
68
70
|
/**
|
|
@@ -102,7 +104,7 @@ export interface DraftTopic {
|
|
|
102
104
|
*/
|
|
103
105
|
subsystemModels?: TopicSubsystemModelRef[];
|
|
104
106
|
/**
|
|
105
|
-
* Attached topics
|
|
107
|
+
* Attached topics, C4 sketches, and drawings. Whole-array replacement on update; `[]`
|
|
106
108
|
* clears attachments. Independent of links in `description`: neither edits
|
|
107
109
|
* the other. Hosts validate target existence and reject self-references.
|
|
108
110
|
*/
|
|
@@ -96,6 +96,7 @@ describe('CRUD', () => {
|
|
|
96
96
|
const store = makeStore();
|
|
97
97
|
const references: TopicReference[] = [
|
|
98
98
|
{ kind: 'c4-sketch', sketchId: 'c4s-1-abc' },
|
|
99
|
+
{ kind: 'drawing', drawingId: 'drawing-1' },
|
|
99
100
|
{ kind: 'topic', topicId: 'topic-related' },
|
|
100
101
|
];
|
|
101
102
|
const created = await store.createTopic({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
|
-
import { toPortableDocument } from "./subsystem-model";
|
|
4
|
+
import { isUnbuiltComponent, isUnbuiltStep, proposalAction, stepProposalAction, toPortableDocument } from "./subsystem-model";
|
|
5
5
|
|
|
6
6
|
const schema = JSON.parse(
|
|
7
7
|
readFileSync(
|
|
@@ -10,7 +10,7 @@ const schema = JSON.parse(
|
|
|
10
10
|
),
|
|
11
11
|
) as {
|
|
12
12
|
properties: Record<string, unknown>;
|
|
13
|
-
$defs: Record<string, { properties?: Record<string, unknown
|
|
13
|
+
$defs: Record<string, { properties?: Record<string, unknown>; enum?: string[] }>;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
describe("toPortableDocument", () => {
|
|
@@ -25,6 +25,17 @@ describe("toPortableDocument", () => {
|
|
|
25
25
|
expect(portable.verifiedAtCommits).toEqual({ "pkg:github/a/b": "def" });
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
+
test("keeps the description / notes split", () => {
|
|
29
|
+
const portable = toPortableDocument({
|
|
30
|
+
title: "t",
|
|
31
|
+
components: [],
|
|
32
|
+
description: "Short blurb.",
|
|
33
|
+
notes: "## Extended\n\nLonger context.",
|
|
34
|
+
} as unknown as Parameters<typeof toPortableDocument>[0]);
|
|
35
|
+
expect(portable.description).toBe("Short blurb.");
|
|
36
|
+
expect(portable.notes).toBe("## Extended\n\nLonger context.");
|
|
37
|
+
});
|
|
38
|
+
|
|
28
39
|
test("still drops store metadata", () => {
|
|
29
40
|
const portable = toPortableDocument({
|
|
30
41
|
title: "t",
|
|
@@ -46,6 +57,12 @@ describe("subsystem-model schema", () => {
|
|
|
46
57
|
expect(schema.properties.verifiedAtCommits).toBeDefined();
|
|
47
58
|
});
|
|
48
59
|
|
|
60
|
+
test("caps the short description and declares extended notes", () => {
|
|
61
|
+
const description = schema.properties.description as { maxLength?: number };
|
|
62
|
+
expect(description.maxLength).toBe(200);
|
|
63
|
+
expect(schema.properties.notes).toBeDefined();
|
|
64
|
+
});
|
|
65
|
+
|
|
49
66
|
test("declares a content-addressed source span", () => {
|
|
50
67
|
// The identity primitive: start + end + content hash. Replaces the old
|
|
51
68
|
// start-line-only `declarationRef`.
|
|
@@ -65,6 +82,39 @@ describe("subsystem-model schema", () => {
|
|
|
65
82
|
expect(schema.$defs.trailStep?.properties?.target).toBeDefined();
|
|
66
83
|
});
|
|
67
84
|
|
|
85
|
+
test("components and trail steps carry a lifecycle status", () => {
|
|
86
|
+
expect(schema.$defs.status?.enum).toEqual(["built", "proposed-add", "proposed-change", "proposed-remove"]);
|
|
87
|
+
const component = Object.values(schema.$defs).find(
|
|
88
|
+
(d) => (d as { properties?: { alias?: unknown } }).properties?.alias,
|
|
89
|
+
) as { properties: Record<string, unknown> };
|
|
90
|
+
expect(component.properties.status).toBeDefined();
|
|
91
|
+
expect(schema.$defs.trailStep?.properties?.status).toBeDefined();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test("a step's proposal follows its own status, then its ends", () => {
|
|
95
|
+
const byAlias = new Map([
|
|
96
|
+
["a", {}],
|
|
97
|
+
["new", { status: "proposed-add" as const }],
|
|
98
|
+
["going", { status: "proposed-remove" as const }],
|
|
99
|
+
["changing", { status: "proposed-change" as const }],
|
|
100
|
+
]);
|
|
101
|
+
expect(proposalAction(byAlias.get("new"))).toBe("add");
|
|
102
|
+
expect(proposalAction(byAlias.get("a"))).toBeUndefined();
|
|
103
|
+
expect(isUnbuiltComponent(byAlias.get("new"))).toBe(true);
|
|
104
|
+
// Changing or going away is still built.
|
|
105
|
+
expect(isUnbuiltComponent(byAlias.get("going"))).toBe(false);
|
|
106
|
+
expect(isUnbuiltComponent(byAlias.get("changing"))).toBe(false);
|
|
107
|
+
|
|
108
|
+
expect(stepProposalAction({ from: "a", to: "a" }, byAlias)).toBeUndefined();
|
|
109
|
+
expect(stepProposalAction({ from: "a", to: "new" }, byAlias)).toBe("add");
|
|
110
|
+
expect(stepProposalAction({ from: "going", to: "a" }, byAlias)).toBe("remove");
|
|
111
|
+
expect(stepProposalAction({ from: "a", to: "changing" }, byAlias)).toBeUndefined();
|
|
112
|
+
expect(stepProposalAction({ from: "a", to: "a", status: "proposed-remove" }, byAlias)).toBe("remove");
|
|
113
|
+
// Only an added step is unbuilt.
|
|
114
|
+
expect(isUnbuiltStep({ from: "a", to: "new" }, byAlias)).toBe(true);
|
|
115
|
+
expect(isUnbuiltStep({ from: "going", to: "a" }, byAlias)).toBe(false);
|
|
116
|
+
});
|
|
117
|
+
|
|
68
118
|
test("a store declares its own value type", () => {
|
|
69
119
|
// `additionalProperties: false` on the store declaration, so the field
|
|
70
120
|
// has to be declared here or every typed store would be rejected.
|
|
@@ -299,6 +299,78 @@ export type SubsystemConstructDeclaration =
|
|
|
299
299
|
| SubsystemStoreDeclaration
|
|
300
300
|
| SubsystemCustomEntityDeclaration;
|
|
301
301
|
|
|
302
|
+
/**
|
|
303
|
+
* Where a claim is in its life. Absent means `built`: the code exists, nothing
|
|
304
|
+
* is planned for it, and the claim is verified against it. The `proposed-*`
|
|
305
|
+
* values name what a proposal would do:
|
|
306
|
+
*
|
|
307
|
+
* - `proposed-add` — planned, not built. The claim keeps its real `construct`
|
|
308
|
+
* (and `role`, `declaration`, …) so it draws as the thing it will be, but
|
|
309
|
+
* there is no source yet, so verification skips it.
|
|
310
|
+
* - `proposed-change` — built, and planned to change. Still verified.
|
|
311
|
+
* - `proposed-remove` — built, and planned to go. Still verified until it does.
|
|
312
|
+
*/
|
|
313
|
+
export type SubsystemLifecycleStatus =
|
|
314
|
+
| 'built'
|
|
315
|
+
| 'proposed-add'
|
|
316
|
+
| 'proposed-change'
|
|
317
|
+
| 'proposed-remove';
|
|
318
|
+
|
|
319
|
+
/** What a proposal would do to a claim. */
|
|
320
|
+
export type SubsystemProposalAction = 'add' | 'change' | 'remove';
|
|
321
|
+
|
|
322
|
+
/** The action a claim's `status` proposes, or undefined when it is plainly built. */
|
|
323
|
+
export function proposalAction(
|
|
324
|
+
claim: { status?: SubsystemLifecycleStatus } | undefined,
|
|
325
|
+
): SubsystemProposalAction | undefined {
|
|
326
|
+
switch (claim?.status) {
|
|
327
|
+
case 'proposed-add':
|
|
328
|
+
return 'add';
|
|
329
|
+
case 'proposed-change':
|
|
330
|
+
return 'change';
|
|
331
|
+
case 'proposed-remove':
|
|
332
|
+
return 'remove';
|
|
333
|
+
default:
|
|
334
|
+
return undefined;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/** True when the component is planned but not built — there is no source to check. */
|
|
339
|
+
export function isUnbuiltComponent(
|
|
340
|
+
component: Pick<SubsystemComponent, 'status'> | undefined,
|
|
341
|
+
): boolean {
|
|
342
|
+
return proposalAction(component) === 'add';
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* What a proposal would do to a trail step. The step says so itself, or it
|
|
347
|
+
* follows from its ends: a seam into or out of a component that is not built
|
|
348
|
+
* cannot exist yet (`add`), and one touching a component that is going away
|
|
349
|
+
* goes with it (`remove`). A component that merely changes leaves its seams be.
|
|
350
|
+
*/
|
|
351
|
+
export function stepProposalAction(
|
|
352
|
+
step: Pick<SubsystemTrailStep, 'from' | 'to' | 'status'>,
|
|
353
|
+
componentByAlias: ReadonlyMap<string, Pick<SubsystemComponent, 'status'>>,
|
|
354
|
+
): SubsystemProposalAction | undefined {
|
|
355
|
+
const own = proposalAction(step);
|
|
356
|
+
if (own) return own;
|
|
357
|
+
const ends = [
|
|
358
|
+
proposalAction(componentByAlias.get(step.from)),
|
|
359
|
+
proposalAction(componentByAlias.get(step.to)),
|
|
360
|
+
];
|
|
361
|
+
if (ends.includes('add')) return 'add';
|
|
362
|
+
if (ends.includes('remove')) return 'remove';
|
|
363
|
+
return undefined;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/** True when a trail step is planned but not built — nothing in the code to check. */
|
|
367
|
+
export function isUnbuiltStep(
|
|
368
|
+
step: Pick<SubsystemTrailStep, 'from' | 'to' | 'status'>,
|
|
369
|
+
componentByAlias: ReadonlyMap<string, Pick<SubsystemComponent, 'status'>>,
|
|
370
|
+
): boolean {
|
|
371
|
+
return stepProposalAction(step, componentByAlias) === 'add';
|
|
372
|
+
}
|
|
373
|
+
|
|
302
374
|
/** A component node — the named unit, construct-tagged. */
|
|
303
375
|
export interface SubsystemComponent {
|
|
304
376
|
/**
|
|
@@ -324,6 +396,14 @@ export interface SubsystemComponent {
|
|
|
324
396
|
logo?: string;
|
|
325
397
|
purpose?: string;
|
|
326
398
|
role?: SubsystemComponentRole;
|
|
399
|
+
/**
|
|
400
|
+
* Lifecycle of the claim; absent means `built`. `proposed-add` is planned
|
|
401
|
+
* work: `file` and `symbol` say where it is meant to live (either may be
|
|
402
|
+
* empty), and verification skips it. `proposed-change` and `proposed-remove`
|
|
403
|
+
* mark a built component a proposal would alter or delete; both stay
|
|
404
|
+
* verified. Drop the field once the proposal lands.
|
|
405
|
+
*/
|
|
406
|
+
status?: SubsystemLifecycleStatus;
|
|
327
407
|
/**
|
|
328
408
|
* The claim was real but its source is gone — deleted or renamed upstream.
|
|
329
409
|
* Verification skips source checks so a model carrying deprecations is no
|
|
@@ -475,6 +555,15 @@ export interface SubsystemTrailStep {
|
|
|
475
555
|
* mechanism + filename fallback.
|
|
476
556
|
*/
|
|
477
557
|
symbol: string;
|
|
558
|
+
/**
|
|
559
|
+
* Lifecycle of the seam; absent means `built`. Mark a step `proposed-add`
|
|
560
|
+
* for a planned seam between two built components, `proposed-remove` for one
|
|
561
|
+
* a proposal would cut. A step that touches a `proposed-add` component is
|
|
562
|
+
* itself an addition without saying so (and one touching a `proposed-remove`
|
|
563
|
+
* component a removal). Verification skips added steps, and an added `calls`
|
|
564
|
+
* step need not carry a `site`.
|
|
565
|
+
*/
|
|
566
|
+
status?: SubsystemLifecycleStatus;
|
|
478
567
|
/**
|
|
479
568
|
* Free-text note anchored to this step's site line. Optional — informative
|
|
480
569
|
* only, never verified against source; viewers surface it via the codeview's
|
|
@@ -502,6 +591,9 @@ export interface SubsystemTrail {
|
|
|
502
591
|
*/
|
|
503
592
|
export type PurlCommit = string;
|
|
504
593
|
|
|
594
|
+
/** Maximum length of a model's authored description (short sidebar blurb). */
|
|
595
|
+
export const SUBSYSTEM_MODEL_DESCRIPTION_MAX = 200;
|
|
596
|
+
|
|
505
597
|
export interface SubsystemModelDocument {
|
|
506
598
|
/**
|
|
507
599
|
* Optional pointer to the JSON Schema that describes this file. Lets editors
|
|
@@ -510,7 +602,18 @@ export interface SubsystemModelDocument {
|
|
|
510
602
|
$schema?: string;
|
|
511
603
|
|
|
512
604
|
title: string;
|
|
605
|
+
/**
|
|
606
|
+
* Short description shown at the top of a model's sidebar. At most
|
|
607
|
+
* {@link SUBSYSTEM_MODEL_DESCRIPTION_MAX} characters; hosts reject longer
|
|
608
|
+
* values and point authors at `notes` instead.
|
|
609
|
+
*/
|
|
513
610
|
description?: string;
|
|
611
|
+
/**
|
|
612
|
+
* Extended Markdown notes about the model. The sidebar shows the short
|
|
613
|
+
* `description` (or a clamped preview of these notes when it is absent);
|
|
614
|
+
* `More` opens the full document in an Overview overlay.
|
|
615
|
+
*/
|
|
616
|
+
notes?: string;
|
|
514
617
|
components: SubsystemComponent[];
|
|
515
618
|
/** Runtime trails (ordered steps with sites). */
|
|
516
619
|
trails?: SubsystemTrail[];
|
|
@@ -570,6 +673,7 @@ export function toPortableDocument(
|
|
|
570
673
|
};
|
|
571
674
|
if (doc.$schema) out.$schema = doc.$schema;
|
|
572
675
|
if (doc.description) out.description = doc.description;
|
|
676
|
+
if (doc.notes) out.notes = doc.notes;
|
|
573
677
|
if (doc.trails) out.trails = doc.trails;
|
|
574
678
|
if (doc.createdAtCommits) out.createdAtCommits = doc.createdAtCommits;
|
|
575
679
|
if (doc.verifiedAtCommits) out.verifiedAtCommits = doc.verifiedAtCommits;
|
package/src/validation.test.ts
CHANGED
|
@@ -32,7 +32,7 @@ describe('validateSubsystemModelCrossField', () => {
|
|
|
32
32
|
{
|
|
33
33
|
id: 'w1',
|
|
34
34
|
title: 'flow',
|
|
35
|
-
steps: [{ from: 'a', to: 'b', mechanism: '
|
|
35
|
+
steps: [{ from: 'a', to: 'b', mechanism: 'uses', file: 'src/a.ts', purl: 'pkg:github/acme/app#src/a.ts', symbol: 'a' }],
|
|
36
36
|
},
|
|
37
37
|
],
|
|
38
38
|
});
|
|
@@ -55,7 +55,7 @@ describe('validateSubsystemModelCrossField', () => {
|
|
|
55
55
|
{
|
|
56
56
|
id: 'w1',
|
|
57
57
|
title: 'flow',
|
|
58
|
-
steps: [{ from: 'ghost', to: 'a', mechanism: '
|
|
58
|
+
steps: [{ from: 'ghost', to: 'a', mechanism: 'uses', file: 'src/a.ts', purl: 'pkg:github/acme/app#src/a.ts', symbol: 'ghost' }],
|
|
59
59
|
},
|
|
60
60
|
],
|
|
61
61
|
}),
|
|
@@ -72,7 +72,7 @@ describe('validateSubsystemModelCrossField', () => {
|
|
|
72
72
|
{
|
|
73
73
|
id: 'w1',
|
|
74
74
|
title: 'flow',
|
|
75
|
-
steps: [{ from: 'a', to: 'a', mechanism: '
|
|
75
|
+
steps: [{ from: 'a', to: 'a', mechanism: 'uses', file: 'src/a.ts', purl: 'pkg:github/acme/app#src/other.ts', symbol: 'a' }],
|
|
76
76
|
},
|
|
77
77
|
],
|
|
78
78
|
}),
|
|
@@ -126,7 +126,7 @@ describe('validateSubsystemModelCrossField', () => {
|
|
|
126
126
|
{
|
|
127
127
|
from: 'a',
|
|
128
128
|
to: 'b',
|
|
129
|
-
mechanism: '
|
|
129
|
+
mechanism: 'uses',
|
|
130
130
|
file: 'src/a.ts',
|
|
131
131
|
purl: 'pkg:github/acme/app#src/a.ts',
|
|
132
132
|
symbol: 'a',
|
|
@@ -219,7 +219,7 @@ describe('validateSubsystemModelCrossField', () => {
|
|
|
219
219
|
{
|
|
220
220
|
from: 'a',
|
|
221
221
|
to: 'a',
|
|
222
|
-
mechanism: '
|
|
222
|
+
mechanism: 'uses',
|
|
223
223
|
file: 'packages/react/node_modules/@pierre/diffs/dist/index.js',
|
|
224
224
|
purl: 'pkg:npm/@pierre/diffs#packages/react/node_modules/@pierre/diffs/dist/index.js',
|
|
225
225
|
symbol: 'a',
|
|
@@ -250,7 +250,7 @@ describe('validateSubsystemModelCrossField', () => {
|
|
|
250
250
|
{
|
|
251
251
|
from: 'a',
|
|
252
252
|
to: 'a',
|
|
253
|
-
mechanism: '
|
|
253
|
+
mechanism: 'uses',
|
|
254
254
|
file: 'src/a.ts',
|
|
255
255
|
purl: 'pkg:github/acme/app#src/a.ts',
|
|
256
256
|
symbol: 'a',
|
|
@@ -280,7 +280,7 @@ describe('validateSubsystemModelCrossField', () => {
|
|
|
280
280
|
{
|
|
281
281
|
from: 'a',
|
|
282
282
|
to: 'a',
|
|
283
|
-
mechanism: '
|
|
283
|
+
mechanism: 'uses',
|
|
284
284
|
file: 'src/a.ts',
|
|
285
285
|
purl: 'pkg:github/acme/app#src/a.ts',
|
|
286
286
|
symbol: 'a',
|
|
@@ -296,4 +296,68 @@ describe('validateSubsystemModelCrossField', () => {
|
|
|
296
296
|
expect(problems[0]!.message).toContain('precedes startLine');
|
|
297
297
|
expect(problems[1]!.path).toBe('/trails/0/steps/0/span');
|
|
298
298
|
});
|
|
299
|
+
|
|
300
|
+
test('a built calls step needs a site; a proposed one does not', () => {
|
|
301
|
+
const step = {
|
|
302
|
+
from: 'a',
|
|
303
|
+
to: 'b',
|
|
304
|
+
mechanism: 'calls' as const,
|
|
305
|
+
file: 'src/a.ts',
|
|
306
|
+
purl: 'pkg:github/acme/app#src/a.ts',
|
|
307
|
+
symbol: 'a',
|
|
308
|
+
};
|
|
309
|
+
const trails = (extra: object = {}) => [{ id: 'w1', title: 'flow', steps: [{ ...step, ...extra }] }];
|
|
310
|
+
|
|
311
|
+
const built = validateSubsystemModelCrossField(
|
|
312
|
+
doc({ components: [comp('a'), comp('b')], trails: trails() }),
|
|
313
|
+
);
|
|
314
|
+
expect(built.map((p) => p.path)).toEqual(['/trails/0/steps/0/site']);
|
|
315
|
+
|
|
316
|
+
// The step says so itself.
|
|
317
|
+
expect(
|
|
318
|
+
validateSubsystemModelCrossField(
|
|
319
|
+
doc({ components: [comp('a'), comp('b')], trails: trails({ status: 'proposed-add' }) }),
|
|
320
|
+
),
|
|
321
|
+
).toEqual([]);
|
|
322
|
+
// Or it reaches a proposed component.
|
|
323
|
+
expect(
|
|
324
|
+
validateSubsystemModelCrossField(
|
|
325
|
+
doc({
|
|
326
|
+
components: [comp('a'), comp('b', { status: 'proposed-add', file: '' })],
|
|
327
|
+
trails: trails(),
|
|
328
|
+
}),
|
|
329
|
+
),
|
|
330
|
+
).toEqual([]);
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
test('a proposed component may claim a module without a file', () => {
|
|
334
|
+
expect(
|
|
335
|
+
validateSubsystemModelCrossField(
|
|
336
|
+
doc({ components: [comp('a', { status: 'proposed-add', file: '', module: 'src/search.ts' })] }),
|
|
337
|
+
),
|
|
338
|
+
).toEqual([]);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
test('a component proposed for change or removal is still built: it needs its file and site', () => {
|
|
342
|
+
const problems = validateSubsystemModelCrossField(
|
|
343
|
+
doc({
|
|
344
|
+
components: [comp('a'), comp('b', { status: 'proposed-remove', file: '', module: 'src/b.ts' })],
|
|
345
|
+
trails: [
|
|
346
|
+
{
|
|
347
|
+
id: 'w1',
|
|
348
|
+
title: 'flow',
|
|
349
|
+
steps: [{ from: 'a', to: 'b', mechanism: 'calls', file: 'src/a.ts', purl: 'pkg:github/acme/app#src/a.ts', symbol: 'a' }],
|
|
350
|
+
},
|
|
351
|
+
],
|
|
352
|
+
}),
|
|
353
|
+
);
|
|
354
|
+
expect(problems.map((p) => p.path).sort()).toEqual(['/components/1/module', '/trails/0/steps/0/site']);
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
test('flags a component that is both proposed and deprecated', () => {
|
|
358
|
+
const problems = validateSubsystemModelCrossField(
|
|
359
|
+
doc({ components: [comp('a', { status: 'proposed-add', deprecated: true })] }),
|
|
360
|
+
);
|
|
361
|
+
expect(problems.map((p) => p.path)).toEqual(['/components/0/status']);
|
|
362
|
+
});
|
|
299
363
|
});
|