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