@agilewallaby/c4-model 2.7.0 → 3.0.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/package.json +1 -1
- package/src/archetype.d.ts +9 -1
- package/src/buildModel.d.ts +7 -4
- package/src/container.d.ts +8 -1
- package/src/exportWorkspaceJson.d.ts +4 -0
- package/src/generateDiagrams.d.ts +1 -3
- package/src/index.cjs +408 -97
- package/src/index.d.ts +147 -46
- package/src/index.js +403 -95
- package/src/model.d.ts +13 -3
- package/src/softwareSystem.d.ts +8 -1
- package/src/structurizrDslWriter.d.ts +5 -0
- package/src/validateModel.d.ts +3 -0
- package/src/views.d.ts +63 -2
package/src/index.d.ts
CHANGED
|
@@ -43,7 +43,13 @@ declare class Group<TChild extends Element$1 | Group = never> {
|
|
|
43
43
|
get canonicalName(): string;
|
|
44
44
|
with<TChildren extends Record<string, TChild>>(callback: (self: this) => TChildren): this & TChildren;
|
|
45
45
|
}
|
|
46
|
-
export
|
|
46
|
+
export declare const ELEMENT_KINDS: {
|
|
47
|
+
readonly person: "person";
|
|
48
|
+
readonly softwareSystem: "softwareSystem";
|
|
49
|
+
readonly container: "container";
|
|
50
|
+
readonly component: "component";
|
|
51
|
+
};
|
|
52
|
+
export type ElementKind = (typeof ELEMENT_KINDS)[keyof typeof ELEMENT_KINDS];
|
|
47
53
|
export declare class ElementArchetype {
|
|
48
54
|
readonly name: string;
|
|
49
55
|
readonly elementKind: ElementKind;
|
|
@@ -54,6 +60,7 @@ export declare class ElementArchetype {
|
|
|
54
60
|
readonly description?: string;
|
|
55
61
|
readonly technology?: string;
|
|
56
62
|
readonly tags: ReadonlyArray<string>;
|
|
63
|
+
get canonicalName(): string;
|
|
57
64
|
constructor(name: string, elementKind: ElementKind, definition?: TechnologyDefinition, parent?: ElementArchetype | undefined);
|
|
58
65
|
}
|
|
59
66
|
export declare class RelationshipArchetype {
|
|
@@ -65,6 +72,7 @@ export declare class RelationshipArchetype {
|
|
|
65
72
|
readonly description?: string;
|
|
66
73
|
readonly technology?: string;
|
|
67
74
|
readonly tags: ReadonlyArray<string>;
|
|
75
|
+
get canonicalName(): string;
|
|
68
76
|
constructor(name: string, definition?: TechnologyDefinition, parent?: RelationshipArchetype | undefined);
|
|
69
77
|
}
|
|
70
78
|
export declare function mergeArchetypeWithOverride(archetype: {
|
|
@@ -85,10 +93,17 @@ export interface DefineComponent {
|
|
|
85
93
|
export declare class ContainerGroup extends Group<Component> implements DefineComponent {
|
|
86
94
|
readonly name: string;
|
|
87
95
|
private readonly container;
|
|
96
|
+
private readonly pathSegments;
|
|
88
97
|
private _components;
|
|
89
|
-
|
|
98
|
+
private _groups;
|
|
99
|
+
constructor(name: string, container: DefineComponent, pathSegments?: string[]);
|
|
100
|
+
get canonicalName(): string;
|
|
101
|
+
get dslName(): string;
|
|
90
102
|
component(name: string, archetypeOrDef?: ElementArchetype | ComponentDefinition, override?: ComponentDefinition): Component;
|
|
103
|
+
group(groupName: string): ContainerGroup;
|
|
104
|
+
getGroups(): ReadonlyArray<ContainerGroup>;
|
|
91
105
|
getComponents(): ReadonlyArray<Component>;
|
|
106
|
+
getAllComponents(): ReadonlyArray<Component>;
|
|
92
107
|
}
|
|
93
108
|
export declare class Container extends TechnicalElement<Component> implements DefineComponent {
|
|
94
109
|
readonly name: string;
|
|
@@ -111,10 +126,17 @@ export interface SoftwareSystemReference {
|
|
|
111
126
|
export declare class SoftwareSystemGroup extends Group<Container> implements DefineContainer {
|
|
112
127
|
readonly name: string;
|
|
113
128
|
private readonly softwareSystem;
|
|
129
|
+
private readonly pathSegments;
|
|
114
130
|
private _containers;
|
|
115
|
-
|
|
131
|
+
private _groups;
|
|
132
|
+
constructor(name: string, softwareSystem: DefineContainer, pathSegments?: string[]);
|
|
133
|
+
get canonicalName(): string;
|
|
134
|
+
get dslName(): string;
|
|
116
135
|
container(name: string, archetypeOrDef?: ElementArchetype | ContainerDefinition, override?: ContainerDefinition): Container;
|
|
136
|
+
group(groupName: string): SoftwareSystemGroup;
|
|
137
|
+
getGroups(): ReadonlyArray<SoftwareSystemGroup>;
|
|
117
138
|
getContainers(): ReadonlyArray<Container>;
|
|
139
|
+
getAllContainers(): ReadonlyArray<Container>;
|
|
118
140
|
}
|
|
119
141
|
export declare class SoftwareSystem extends Element$1<Container> implements DefineContainer {
|
|
120
142
|
readonly name: string;
|
|
@@ -133,6 +155,101 @@ export declare class Person extends Element$1 {
|
|
|
133
155
|
constructor(name: string, definition?: PersonDefinition, archetype?: ElementArchetype, overrideDefinition?: TechnologyDefinition);
|
|
134
156
|
getChildElements(): ReadonlyArray<Element$1>;
|
|
135
157
|
}
|
|
158
|
+
export interface ViewDefinition<T extends Element$1> {
|
|
159
|
+
subject?: T;
|
|
160
|
+
description: string;
|
|
161
|
+
title?: string;
|
|
162
|
+
}
|
|
163
|
+
export type AutoLayoutDirection = "tb" | "bt" | "lr" | "rl";
|
|
164
|
+
export interface AutoLayout {
|
|
165
|
+
direction?: AutoLayoutDirection;
|
|
166
|
+
rankSeparation?: number;
|
|
167
|
+
nodeSeparation?: number;
|
|
168
|
+
}
|
|
169
|
+
export type ElementShape = "Box" | "RoundedBox" | "Circle" | "Ellipse" | "Hexagon" | "Diamond" | "Cylinder" | "Bucket" | "Pipe" | "Person" | "Robot" | "Folder" | "WebBrowser" | "Window" | "Terminal" | "Shell" | "MobileDevicePortrait" | "MobileDeviceLandscape" | "Component";
|
|
170
|
+
export interface ElementStyleDefinition {
|
|
171
|
+
shape?: ElementShape;
|
|
172
|
+
icon?: string;
|
|
173
|
+
width?: number;
|
|
174
|
+
height?: number;
|
|
175
|
+
background?: string;
|
|
176
|
+
color?: string;
|
|
177
|
+
stroke?: string;
|
|
178
|
+
strokeWidth?: number;
|
|
179
|
+
fontSize?: number;
|
|
180
|
+
border?: "solid" | "dashed" | "dotted";
|
|
181
|
+
opacity?: number;
|
|
182
|
+
metadata?: boolean;
|
|
183
|
+
description?: boolean;
|
|
184
|
+
}
|
|
185
|
+
export interface RelationshipStyleDefinition {
|
|
186
|
+
thickness?: number;
|
|
187
|
+
color?: string;
|
|
188
|
+
style?: "solid" | "dashed" | "dotted";
|
|
189
|
+
routing?: "Direct" | "Orthogonal" | "Curved";
|
|
190
|
+
fontSize?: number;
|
|
191
|
+
width?: number;
|
|
192
|
+
position?: number;
|
|
193
|
+
opacity?: number;
|
|
194
|
+
}
|
|
195
|
+
export interface ElementStyleEntry {
|
|
196
|
+
tag: string;
|
|
197
|
+
definition: ElementStyleDefinition;
|
|
198
|
+
}
|
|
199
|
+
export interface RelationshipStyleEntry {
|
|
200
|
+
tag: string;
|
|
201
|
+
definition: RelationshipStyleDefinition;
|
|
202
|
+
}
|
|
203
|
+
export declare class View<T extends Element$1> {
|
|
204
|
+
readonly key: string;
|
|
205
|
+
readonly subject?: T;
|
|
206
|
+
readonly description: string;
|
|
207
|
+
readonly title?: string;
|
|
208
|
+
private _scopes;
|
|
209
|
+
private _autoLayout?;
|
|
210
|
+
private _isDefault;
|
|
211
|
+
private _properties;
|
|
212
|
+
constructor(key: string, viewDefinition: ViewDefinition<T>);
|
|
213
|
+
includeAll(): void;
|
|
214
|
+
includeElement(element: Element$1): void;
|
|
215
|
+
includeExpression(expression: string): void;
|
|
216
|
+
excludeAll(): void;
|
|
217
|
+
excludeElement(element: Element$1): void;
|
|
218
|
+
excludeExpression(expression: string): void;
|
|
219
|
+
autoLayout(direction?: AutoLayoutDirection, rankSeparation?: number, nodeSeparation?: number): void;
|
|
220
|
+
setDefault(): void;
|
|
221
|
+
addProperty(name: string, value: string): void;
|
|
222
|
+
get scopes(): ReadonlyArray<string>;
|
|
223
|
+
get autoLayoutConfig(): AutoLayout | undefined;
|
|
224
|
+
get isDefault(): boolean;
|
|
225
|
+
get properties(): ReadonlyMap<string, string>;
|
|
226
|
+
}
|
|
227
|
+
export declare class Views {
|
|
228
|
+
private readonly _systemLandscapeViews;
|
|
229
|
+
private readonly _systemContextViews;
|
|
230
|
+
private readonly _containerViews;
|
|
231
|
+
private readonly _componentViews;
|
|
232
|
+
private _elementStyles;
|
|
233
|
+
private _relationshipStyles;
|
|
234
|
+
private _themes;
|
|
235
|
+
private _properties;
|
|
236
|
+
addSystemLandscapeView(key: string, definition: ViewDefinition<Element$1>): View<Element$1>;
|
|
237
|
+
addSystemContextView(key: string, definition: ViewDefinition<SoftwareSystem>): View<SoftwareSystem>;
|
|
238
|
+
addContainerView(key: string, definition: ViewDefinition<SoftwareSystem>): View<SoftwareSystem>;
|
|
239
|
+
addComponentView(key: string, definition: ViewDefinition<Container>): View<Container>;
|
|
240
|
+
addElementStyle(tag: string, definition: ElementStyleDefinition): void;
|
|
241
|
+
addRelationshipStyle(tag: string, definition: RelationshipStyleDefinition): void;
|
|
242
|
+
addTheme(url: string): void;
|
|
243
|
+
addProperty(name: string, value: string): void;
|
|
244
|
+
get systemLandscapeViews(): ReadonlyArray<View<Element$1>>;
|
|
245
|
+
get systemContextViews(): ReadonlyArray<View<SoftwareSystem>>;
|
|
246
|
+
get containerViews(): ReadonlyArray<View<SoftwareSystem>>;
|
|
247
|
+
get componentViews(): ReadonlyArray<View<Container>>;
|
|
248
|
+
get elementStyles(): ReadonlyArray<ElementStyleEntry>;
|
|
249
|
+
get relationshipStyles(): ReadonlyArray<RelationshipStyleEntry>;
|
|
250
|
+
get themes(): ReadonlyArray<string>;
|
|
251
|
+
get properties(): ReadonlyMap<string, string>;
|
|
252
|
+
}
|
|
136
253
|
export type CatalogKeyOf<TRoot, TModule> = {
|
|
137
254
|
[K in keyof TRoot]: TRoot[K] extends TModule ? K : never;
|
|
138
255
|
}[keyof TRoot];
|
|
@@ -140,7 +257,8 @@ export type Dependencies<TRoot, TModule> = Omit<TRoot, CatalogKeyOf<TRoot, TModu
|
|
|
140
257
|
export interface C4Module<TRoot, TLocal, TArchetypes = Record<string, ElementArchetype | RelationshipArchetype>> {
|
|
141
258
|
readonly key: CatalogKeyOf<TRoot, TLocal>;
|
|
142
259
|
registerDefinitions(model: Model, archetypes: TArchetypes): TLocal;
|
|
143
|
-
|
|
260
|
+
addRelationships(local: TLocal, dependencies: Dependencies<TRoot, TLocal>, archetypes: TArchetypes): void;
|
|
261
|
+
addViews?(views: Views, local: TLocal, dependencies: Dependencies<TRoot, TLocal>): void;
|
|
144
262
|
}
|
|
145
263
|
export interface DefineSoftwareSystem {
|
|
146
264
|
softwareSystem(name: string, archetypeOrDef?: ElementArchetype | SoftwareSystemDefinition, override?: SoftwareSystemDefinition): SoftwareSystem;
|
|
@@ -151,13 +269,21 @@ export interface DefinePerson {
|
|
|
151
269
|
export declare class ModelGroup extends Group<Person | SoftwareSystem> implements DefineSoftwareSystem, DefinePerson {
|
|
152
270
|
readonly name: string;
|
|
153
271
|
private readonly model;
|
|
272
|
+
private readonly pathSegments;
|
|
154
273
|
private softwareSystems;
|
|
155
274
|
private people;
|
|
156
|
-
|
|
275
|
+
private _groups;
|
|
276
|
+
constructor(name: string, model: DefineSoftwareSystem & DefinePerson, pathSegments?: string[]);
|
|
277
|
+
get canonicalName(): string;
|
|
278
|
+
get dslName(): string;
|
|
157
279
|
softwareSystem(name: string, archetypeOrDef?: ElementArchetype | SoftwareSystemDefinition, override?: SoftwareSystemDefinition): SoftwareSystem;
|
|
158
280
|
person(name: string, archetypeOrDef?: ElementArchetype | PersonDefinition, override?: PersonDefinition): Person;
|
|
281
|
+
group(groupName: string): ModelGroup;
|
|
282
|
+
getGroups(): ReadonlyArray<ModelGroup>;
|
|
159
283
|
getSoftwareSystems(): ReadonlyArray<SoftwareSystem>;
|
|
160
284
|
getPeople(): ReadonlyArray<Person>;
|
|
285
|
+
getAllSoftwareSystems(): ReadonlyArray<SoftwareSystem>;
|
|
286
|
+
getAllPeople(): ReadonlyArray<Person>;
|
|
161
287
|
}
|
|
162
288
|
export interface ModelDefinitions {
|
|
163
289
|
softwareSystem(name: string, archetypeOrDef?: ElementArchetype | SoftwareSystemDefinition, override?: SoftwareSystemDefinition): SoftwareSystem;
|
|
@@ -170,7 +296,7 @@ export declare class Model {
|
|
|
170
296
|
private people;
|
|
171
297
|
private groups;
|
|
172
298
|
softwareSystem(name: string, archetypeOrDef?: ElementArchetype | SoftwareSystemDefinition, override?: SoftwareSystemDefinition): SoftwareSystem;
|
|
173
|
-
group(groupName: string):
|
|
299
|
+
group(groupName: string): ModelGroup;
|
|
174
300
|
person(name: string, archetypeOrDef?: ElementArchetype | PersonDefinition, override?: PersonDefinition): Person;
|
|
175
301
|
validate(): void;
|
|
176
302
|
getPeople(): ReadonlyArray<Person>;
|
|
@@ -179,40 +305,6 @@ export declare class Model {
|
|
|
179
305
|
getSoftwareSystemsNotInGroups(): ReadonlyArray<SoftwareSystem>;
|
|
180
306
|
getGroups(): ReadonlyArray<ModelGroup>;
|
|
181
307
|
}
|
|
182
|
-
export interface ViewDefinition<T extends Element$1> {
|
|
183
|
-
subject?: T;
|
|
184
|
-
description: string;
|
|
185
|
-
title?: string;
|
|
186
|
-
}
|
|
187
|
-
export declare class View<T extends Element$1> {
|
|
188
|
-
readonly key: string;
|
|
189
|
-
readonly subject?: T;
|
|
190
|
-
readonly description: string;
|
|
191
|
-
readonly title?: string;
|
|
192
|
-
private _scopes;
|
|
193
|
-
constructor(key: string, viewDefinition: ViewDefinition<T>);
|
|
194
|
-
includeAll(): void;
|
|
195
|
-
includeElement(element: T): void;
|
|
196
|
-
includeExpression(expression: string): void;
|
|
197
|
-
excludeAll(): void;
|
|
198
|
-
excludeElement(element: T): void;
|
|
199
|
-
excludeExpression(expression: string): void;
|
|
200
|
-
get scopes(): ReadonlyArray<string>;
|
|
201
|
-
}
|
|
202
|
-
export declare class Views {
|
|
203
|
-
private readonly _systemLandscapeViews;
|
|
204
|
-
private readonly _systemContextViews;
|
|
205
|
-
private readonly _containerViews;
|
|
206
|
-
private readonly _componentViews;
|
|
207
|
-
addSystemLandscapeView(key: string, definition: ViewDefinition<Element$1>): View<Element$1>;
|
|
208
|
-
addSystemContextView(key: string, definition: ViewDefinition<SoftwareSystem>): View<SoftwareSystem>;
|
|
209
|
-
addContainerView(key: string, definition: ViewDefinition<SoftwareSystem>): View<SoftwareSystem>;
|
|
210
|
-
addComponentView(key: string, definition: ViewDefinition<Container>): View<Container>;
|
|
211
|
-
get systemLandscapeViews(): ReadonlyArray<View<Element$1>>;
|
|
212
|
-
get systemContextViews(): ReadonlyArray<View<SoftwareSystem>>;
|
|
213
|
-
get containerViews(): ReadonlyArray<View<SoftwareSystem>>;
|
|
214
|
-
get componentViews(): ReadonlyArray<View<Container>>;
|
|
215
|
-
}
|
|
216
308
|
export declare class StructurizrDSLWriter {
|
|
217
309
|
private readonly model;
|
|
218
310
|
private readonly views;
|
|
@@ -227,9 +319,14 @@ export declare class StructurizrDSLWriter {
|
|
|
227
319
|
private writeSoftwareSystem;
|
|
228
320
|
private writeRelationship;
|
|
229
321
|
private writeRelationships;
|
|
322
|
+
private hasNestedModelGroups;
|
|
323
|
+
private hasNestedSoftwareSystemGroups;
|
|
324
|
+
private hasNestedContainerGroups;
|
|
325
|
+
private hasNestedGroups;
|
|
230
326
|
private writeModelGroup;
|
|
231
327
|
private writeModel;
|
|
232
328
|
private writeView;
|
|
329
|
+
private writeStyles;
|
|
233
330
|
private writeViews;
|
|
234
331
|
write(): string;
|
|
235
332
|
private writeLine;
|
|
@@ -239,24 +336,28 @@ export type RootCatalog = Record<string, Catalog>;
|
|
|
239
336
|
export interface AnyC4Module {
|
|
240
337
|
readonly key: string;
|
|
241
338
|
registerDefinitions(model: Model, archetypes: Record<string, ElementArchetype | RelationshipArchetype>): Catalog;
|
|
242
|
-
|
|
339
|
+
addRelationships(local: Catalog, dependencies: RootCatalog, archetypes: Record<string, ElementArchetype | RelationshipArchetype>): void;
|
|
340
|
+
addViews?(views: Views, local: Catalog, dependencies: RootCatalog): void;
|
|
243
341
|
}
|
|
244
|
-
export interface BuildModelOptions {
|
|
342
|
+
export interface BuildModelOptions<TRoot = Record<string, unknown>> {
|
|
245
343
|
modelName?: string;
|
|
246
344
|
modules?: ReadonlyArray<AnyC4Module>;
|
|
247
345
|
globPath?: string;
|
|
248
346
|
searchRoot?: string;
|
|
249
347
|
archetypes?: Record<string, ElementArchetype | RelationshipArchetype>;
|
|
348
|
+
addViews?: (views: Views, catalog: TRoot) => void;
|
|
250
349
|
}
|
|
251
|
-
export declare function
|
|
350
|
+
export declare function buildModel<TRoot>(options?: BuildModelOptions<TRoot>): Promise<{
|
|
252
351
|
model: Model;
|
|
253
352
|
catalog: TRoot;
|
|
353
|
+
views: Views;
|
|
254
354
|
}>;
|
|
255
|
-
export
|
|
256
|
-
export interface GenerateDiagramsOptions<TRoot> extends BuildModelOptions {
|
|
257
|
-
views: (catalog: TRoot) => Views;
|
|
355
|
+
export interface GenerateDiagramsOptions<TRoot> extends BuildModelOptions<TRoot> {
|
|
258
356
|
outputDir: string;
|
|
259
357
|
}
|
|
260
358
|
export declare function generateDiagrams<TRoot>(options: GenerateDiagramsOptions<TRoot>): Promise<string[]>;
|
|
359
|
+
export declare function validateModel(model: Model, views: Views): Promise<void>;
|
|
360
|
+
export declare function exportWorkspaceJsonFromDsl(dsl: string): Promise<unknown>;
|
|
361
|
+
export declare function exportWorkspaceJson(model: Model, views: Views): Promise<unknown>;
|
|
261
362
|
|
|
262
363
|
export {};
|