@agilewallaby/c4-model 3.0.0 → 4.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilewallaby/c4-model",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/index.cjs CHANGED
@@ -42,7 +42,6 @@ __export(index_exports, {
42
42
  SoftwareSystem: () => SoftwareSystem,
43
43
  SoftwareSystemGroup: () => SoftwareSystemGroup,
44
44
  StructurizrDSLWriter: () => StructurizrDSLWriter,
45
- View: () => View,
46
45
  Views: () => Views,
47
46
  buildModel: () => buildModel,
48
47
  exportWorkspaceJson: () => exportWorkspaceJson,
@@ -642,6 +641,10 @@ var View = class {
642
641
  addProperty(name, value) {
643
642
  this._properties.set(name, value);
644
643
  }
644
+ with(callback) {
645
+ callback(this);
646
+ return this;
647
+ }
645
648
  get scopes() {
646
649
  return this._scopes;
647
650
  }
@@ -1009,7 +1012,9 @@ var StructurizrDSLWriter = class {
1009
1012
  }
1010
1013
  writeView(view, viewType, level) {
1011
1014
  let viewDsl = this.writeLine(`${viewType}${view.subject ? ' "' + view.subject.canonicalName + '"' : ""} "${view.key}" {`, level);
1012
- viewDsl += this.writeLine(`description "${view.description}"`, level + 1);
1015
+ if (view.description) {
1016
+ viewDsl += this.writeLine(`description "${view.description}"`, level + 1);
1017
+ }
1013
1018
  if (view.title) {
1014
1019
  viewDsl += this.writeLine(`title "${view.title}"`, level + 1);
1015
1020
  }
@@ -1263,7 +1268,6 @@ async function exportWorkspaceJson(model, views) {
1263
1268
  SoftwareSystem,
1264
1269
  SoftwareSystemGroup,
1265
1270
  StructurizrDSLWriter,
1266
- View,
1267
1271
  Views,
1268
1272
  buildModel,
1269
1273
  exportWorkspaceJson,
package/src/index.d.ts CHANGED
@@ -155,11 +155,13 @@ export declare class Person extends Element$1 {
155
155
  constructor(name: string, definition?: PersonDefinition, archetype?: ElementArchetype, overrideDefinition?: TechnologyDefinition);
156
156
  getChildElements(): ReadonlyArray<Element$1>;
157
157
  }
158
- export interface ViewDefinition<T extends Element$1> {
159
- subject?: T;
160
- description: string;
158
+ export interface BaseViewDefinition {
159
+ description?: string;
161
160
  title?: string;
162
161
  }
162
+ export interface ScopedViewDefinition<T extends Element$1> extends BaseViewDefinition {
163
+ subject: T;
164
+ }
163
165
  export type AutoLayoutDirection = "tb" | "bt" | "lr" | "rl";
164
166
  export interface AutoLayout {
165
167
  direction?: AutoLayoutDirection;
@@ -200,16 +202,7 @@ export interface RelationshipStyleEntry {
200
202
  tag: string;
201
203
  definition: RelationshipStyleDefinition;
202
204
  }
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>);
205
+ export interface ViewBuilder {
213
206
  includeAll(): void;
214
207
  includeElement(element: Element$1): void;
215
208
  includeExpression(expression: string): void;
@@ -219,10 +212,17 @@ export declare class View<T extends Element$1> {
219
212
  autoLayout(direction?: AutoLayoutDirection, rankSeparation?: number, nodeSeparation?: number): void;
220
213
  setDefault(): void;
221
214
  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>;
215
+ }
216
+ export interface ReadonlyView<T extends Element$1> {
217
+ readonly key: string;
218
+ readonly subject?: T;
219
+ readonly description?: string;
220
+ readonly title?: string;
221
+ readonly scopes: ReadonlyArray<string>;
222
+ readonly autoLayoutConfig: AutoLayout | undefined;
223
+ readonly isDefault: boolean;
224
+ readonly properties: ReadonlyMap<string, string>;
225
+ with(callback: (builder: ViewBuilder) => void): ReadonlyView<T>;
226
226
  }
227
227
  export declare class Views {
228
228
  private readonly _systemLandscapeViews;
@@ -233,18 +233,18 @@ export declare class Views {
233
233
  private _relationshipStyles;
234
234
  private _themes;
235
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>;
236
+ addSystemLandscapeView(key: string, definition: BaseViewDefinition): ReadonlyView<Element$1>;
237
+ addSystemContextView(key: string, definition: ScopedViewDefinition<SoftwareSystem>): ReadonlyView<SoftwareSystem>;
238
+ addContainerView(key: string, definition: ScopedViewDefinition<SoftwareSystem>): ReadonlyView<SoftwareSystem>;
239
+ addComponentView(key: string, definition: ScopedViewDefinition<Container>): ReadonlyView<Container>;
240
240
  addElementStyle(tag: string, definition: ElementStyleDefinition): void;
241
241
  addRelationshipStyle(tag: string, definition: RelationshipStyleDefinition): void;
242
242
  addTheme(url: string): void;
243
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>>;
244
+ get systemLandscapeViews(): ReadonlyArray<ReadonlyView<Element$1>>;
245
+ get systemContextViews(): ReadonlyArray<ReadonlyView<SoftwareSystem>>;
246
+ get containerViews(): ReadonlyArray<ReadonlyView<SoftwareSystem>>;
247
+ get componentViews(): ReadonlyArray<ReadonlyView<Container>>;
248
248
  get elementStyles(): ReadonlyArray<ElementStyleEntry>;
249
249
  get relationshipStyles(): ReadonlyArray<RelationshipStyleEntry>;
250
250
  get themes(): ReadonlyArray<string>;
package/src/index.js CHANGED
@@ -587,6 +587,10 @@ var View = class {
587
587
  addProperty(name, value) {
588
588
  this._properties.set(name, value);
589
589
  }
590
+ with(callback) {
591
+ callback(this);
592
+ return this;
593
+ }
590
594
  get scopes() {
591
595
  return this._scopes;
592
596
  }
@@ -954,7 +958,9 @@ var StructurizrDSLWriter = class {
954
958
  }
955
959
  writeView(view, viewType, level) {
956
960
  let viewDsl = this.writeLine(`${viewType}${view.subject ? ' "' + view.subject.canonicalName + '"' : ""} "${view.key}" {`, level);
957
- viewDsl += this.writeLine(`description "${view.description}"`, level + 1);
961
+ if (view.description) {
962
+ viewDsl += this.writeLine(`description "${view.description}"`, level + 1);
963
+ }
958
964
  if (view.title) {
959
965
  viewDsl += this.writeLine(`title "${view.title}"`, level + 1);
960
966
  }
@@ -1206,7 +1212,6 @@ export {
1206
1212
  SoftwareSystem,
1207
1213
  SoftwareSystemGroup,
1208
1214
  StructurizrDSLWriter,
1209
- View,
1210
1215
  Views,
1211
1216
  buildModel,
1212
1217
  exportWorkspaceJson,
package/src/views.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import { Container } from './container';
2
2
  import { Element } from './core';
3
3
  import { SoftwareSystem } from './softwareSystem';
4
- interface ViewDefinition<T extends Element> {
5
- subject?: T;
6
- description: string;
4
+ interface BaseViewDefinition {
5
+ description?: string;
7
6
  title?: string;
8
7
  }
8
+ interface ScopedViewDefinition<T extends Element> extends BaseViewDefinition {
9
+ subject: T;
10
+ }
9
11
  export type AutoLayoutDirection = 'tb' | 'bt' | 'lr' | 'rl';
10
12
  export interface AutoLayout {
11
13
  direction?: AutoLayoutDirection;
@@ -46,16 +48,7 @@ export interface RelationshipStyleEntry {
46
48
  tag: string;
47
49
  definition: RelationshipStyleDefinition;
48
50
  }
49
- export declare class View<T extends Element> {
50
- readonly key: string;
51
- readonly subject?: T;
52
- readonly description: string;
53
- readonly title?: string;
54
- private _scopes;
55
- private _autoLayout?;
56
- private _isDefault;
57
- private _properties;
58
- constructor(key: string, viewDefinition: ViewDefinition<T>);
51
+ export interface ViewBuilder {
59
52
  includeAll(): void;
60
53
  includeElement(element: Element): void;
61
54
  includeExpression(expression: string): void;
@@ -65,10 +58,17 @@ export declare class View<T extends Element> {
65
58
  autoLayout(direction?: AutoLayoutDirection, rankSeparation?: number, nodeSeparation?: number): void;
66
59
  setDefault(): void;
67
60
  addProperty(name: string, value: string): void;
68
- get scopes(): ReadonlyArray<string>;
69
- get autoLayoutConfig(): AutoLayout | undefined;
70
- get isDefault(): boolean;
71
- get properties(): ReadonlyMap<string, string>;
61
+ }
62
+ export interface ReadonlyView<T extends Element> {
63
+ readonly key: string;
64
+ readonly subject?: T;
65
+ readonly description?: string;
66
+ readonly title?: string;
67
+ readonly scopes: ReadonlyArray<string>;
68
+ readonly autoLayoutConfig: AutoLayout | undefined;
69
+ readonly isDefault: boolean;
70
+ readonly properties: ReadonlyMap<string, string>;
71
+ with(callback: (builder: ViewBuilder) => void): ReadonlyView<T>;
72
72
  }
73
73
  export declare class Views {
74
74
  private readonly _systemLandscapeViews;
@@ -79,18 +79,18 @@ export declare class Views {
79
79
  private _relationshipStyles;
80
80
  private _themes;
81
81
  private _properties;
82
- addSystemLandscapeView(key: string, definition: ViewDefinition<Element>): View<Element>;
83
- addSystemContextView(key: string, definition: ViewDefinition<SoftwareSystem>): View<SoftwareSystem>;
84
- addContainerView(key: string, definition: ViewDefinition<SoftwareSystem>): View<SoftwareSystem>;
85
- addComponentView(key: string, definition: ViewDefinition<Container>): View<Container>;
82
+ addSystemLandscapeView(key: string, definition: BaseViewDefinition): ReadonlyView<Element>;
83
+ addSystemContextView(key: string, definition: ScopedViewDefinition<SoftwareSystem>): ReadonlyView<SoftwareSystem>;
84
+ addContainerView(key: string, definition: ScopedViewDefinition<SoftwareSystem>): ReadonlyView<SoftwareSystem>;
85
+ addComponentView(key: string, definition: ScopedViewDefinition<Container>): ReadonlyView<Container>;
86
86
  addElementStyle(tag: string, definition: ElementStyleDefinition): void;
87
87
  addRelationshipStyle(tag: string, definition: RelationshipStyleDefinition): void;
88
88
  addTheme(url: string): void;
89
89
  addProperty(name: string, value: string): void;
90
- get systemLandscapeViews(): ReadonlyArray<View<Element>>;
91
- get systemContextViews(): ReadonlyArray<View<SoftwareSystem>>;
92
- get containerViews(): ReadonlyArray<View<SoftwareSystem>>;
93
- get componentViews(): ReadonlyArray<View<Container>>;
90
+ get systemLandscapeViews(): ReadonlyArray<ReadonlyView<Element>>;
91
+ get systemContextViews(): ReadonlyArray<ReadonlyView<SoftwareSystem>>;
92
+ get containerViews(): ReadonlyArray<ReadonlyView<SoftwareSystem>>;
93
+ get componentViews(): ReadonlyArray<ReadonlyView<Container>>;
94
94
  get elementStyles(): ReadonlyArray<ElementStyleEntry>;
95
95
  get relationshipStyles(): ReadonlyArray<RelationshipStyleEntry>;
96
96
  get themes(): ReadonlyArray<string>;