@agilewallaby/c4-model 2.8.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilewallaby/c4-model",
3
- "version": "2.8.0",
3
+ "version": "3.0.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1,5 +1,11 @@
1
1
  import { TechnologyDefinition } from './core';
2
- export type ElementKind = 'person' | 'softwareSystem' | 'container' | 'component';
2
+ export declare const ELEMENT_KINDS: {
3
+ readonly person: "person";
4
+ readonly softwareSystem: "softwareSystem";
5
+ readonly container: "container";
6
+ readonly component: "component";
7
+ };
8
+ export type ElementKind = (typeof ELEMENT_KINDS)[keyof typeof ELEMENT_KINDS];
3
9
  export declare class ElementArchetype {
4
10
  readonly name: string;
5
11
  readonly elementKind: ElementKind;
@@ -10,6 +16,7 @@ export declare class ElementArchetype {
10
16
  readonly description?: string;
11
17
  readonly technology?: string;
12
18
  readonly tags: ReadonlyArray<string>;
19
+ get canonicalName(): string;
13
20
  constructor(name: string, elementKind: ElementKind, definition?: TechnologyDefinition, parent?: ElementArchetype | undefined);
14
21
  }
15
22
  export declare class RelationshipArchetype {
@@ -21,6 +28,7 @@ export declare class RelationshipArchetype {
21
28
  readonly description?: string;
22
29
  readonly technology?: string;
23
30
  readonly tags: ReadonlyArray<string>;
31
+ get canonicalName(): string;
24
32
  constructor(name: string, definition?: TechnologyDefinition, parent?: RelationshipArchetype | undefined);
25
33
  }
26
34
  export declare function mergeArchetypeWithOverride(archetype: {
package/src/index.cjs CHANGED
@@ -33,6 +33,7 @@ __export(index_exports, {
33
33
  Component: () => Component,
34
34
  Container: () => Container,
35
35
  ContainerGroup: () => ContainerGroup,
36
+ ELEMENT_KINDS: () => ELEMENT_KINDS,
36
37
  ElementArchetype: () => ElementArchetype,
37
38
  Model: () => Model,
38
39
  ModelGroup: () => ModelGroup,
@@ -52,52 +53,6 @@ __export(index_exports, {
52
53
  });
53
54
  module.exports = __toCommonJS(index_exports);
54
55
 
55
- // libs/c4-model/src/archetype.ts
56
- var ElementArchetype = class {
57
- constructor(name, elementKind, definition, parent) {
58
- this.name = name;
59
- this.elementKind = elementKind;
60
- this.parent = parent;
61
- this.ownDescription = definition?.description;
62
- this.ownTechnology = definition?.technology;
63
- this.ownTags = definition?.tags ?? [];
64
- this.description = this.ownDescription ?? parent?.description;
65
- this.technology = this.ownTechnology ?? parent?.technology;
66
- this.tags = [...parent?.tags ?? [], ...this.ownTags];
67
- }
68
- ownDescription;
69
- ownTechnology;
70
- ownTags;
71
- description;
72
- technology;
73
- tags;
74
- };
75
- var RelationshipArchetype = class {
76
- constructor(name, definition, parent) {
77
- this.name = name;
78
- this.parent = parent;
79
- this.ownDescription = definition?.description;
80
- this.ownTechnology = definition?.technology;
81
- this.ownTags = definition?.tags ?? [];
82
- this.description = this.ownDescription ?? parent?.description;
83
- this.technology = this.ownTechnology ?? parent?.technology;
84
- this.tags = [...parent?.tags ?? [], ...this.ownTags];
85
- }
86
- ownDescription;
87
- ownTechnology;
88
- ownTags;
89
- description;
90
- technology;
91
- tags;
92
- };
93
- function mergeArchetypeWithOverride(archetype, override) {
94
- return {
95
- description: override?.description ?? archetype.description,
96
- technology: override?.technology ?? archetype.technology,
97
- tags: [...archetype.tags, ...override?.tags ?? []]
98
- };
99
- }
100
-
101
56
  // node_modules/.pnpm/change-case@5.4.4/node_modules/change-case/dist/index.js
102
57
  var SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
103
58
  var SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
@@ -184,6 +139,64 @@ function splitPrefixSuffix(input, options = {}) {
184
139
  ];
185
140
  }
186
141
 
142
+ // libs/c4-model/src/archetype.ts
143
+ var ELEMENT_KINDS = {
144
+ person: "person",
145
+ softwareSystem: "softwareSystem",
146
+ container: "container",
147
+ component: "component"
148
+ };
149
+ var ElementArchetype = class {
150
+ constructor(name, elementKind, definition, parent) {
151
+ this.name = name;
152
+ this.elementKind = elementKind;
153
+ this.parent = parent;
154
+ this.ownDescription = definition?.description;
155
+ this.ownTechnology = definition?.technology;
156
+ this.ownTags = definition?.tags ?? [];
157
+ this.description = this.ownDescription ?? parent?.description;
158
+ this.technology = this.ownTechnology ?? parent?.technology;
159
+ this.tags = [...parent?.tags ?? [], ...this.ownTags];
160
+ }
161
+ ownDescription;
162
+ ownTechnology;
163
+ ownTags;
164
+ description;
165
+ technology;
166
+ tags;
167
+ get canonicalName() {
168
+ return camelCase(this.name);
169
+ }
170
+ };
171
+ var RelationshipArchetype = class {
172
+ constructor(name, definition, parent) {
173
+ this.name = name;
174
+ this.parent = parent;
175
+ this.ownDescription = definition?.description;
176
+ this.ownTechnology = definition?.technology;
177
+ this.ownTags = definition?.tags ?? [];
178
+ this.description = this.ownDescription ?? parent?.description;
179
+ this.technology = this.ownTechnology ?? parent?.technology;
180
+ this.tags = [...parent?.tags ?? [], ...this.ownTags];
181
+ }
182
+ ownDescription;
183
+ ownTechnology;
184
+ ownTags;
185
+ description;
186
+ technology;
187
+ tags;
188
+ get canonicalName() {
189
+ return camelCase(this.name);
190
+ }
191
+ };
192
+ function mergeArchetypeWithOverride(archetype, override) {
193
+ return {
194
+ description: override?.description ?? archetype.description,
195
+ technology: override?.technology ?? archetype.technology,
196
+ tags: [...archetype.tags, ...override?.tags ?? []]
197
+ };
198
+ }
199
+
187
200
  // libs/c4-model/src/core.ts
188
201
  var Element = class {
189
202
  constructor(name, defaultTags = [], definition, archetype, overrideDefinition) {
@@ -762,7 +775,7 @@ var StructurizrDSLWriter = class {
762
775
  if (elementArchetypes.length === 0 && relationshipArchetypes.length === 0) return "";
763
776
  let dsl = this.writeLine(`archetypes {`, level);
764
777
  for (const arch of elementArchetypes) {
765
- const baseType = arch.parent ? arch.parent.name : arch.elementKind;
778
+ const baseType = arch.parent ? arch.parent.canonicalName : arch.elementKind;
766
779
  let inner = "";
767
780
  if (arch.ownDescription) {
768
781
  inner += this.writeLine(`description "${arch.ownDescription}"`, level + 2);
@@ -774,15 +787,15 @@ var StructurizrDSLWriter = class {
774
787
  inner += this.writeLine(`tags ${arch.ownTags.map((t) => `"${t}"`).join(" ")}`, level + 2);
775
788
  }
776
789
  if (inner) {
777
- dsl += this.writeLine(`${arch.name} = ${baseType} {`, level + 1);
790
+ dsl += this.writeLine(`${arch.canonicalName} = ${baseType} {`, level + 1);
778
791
  dsl += inner;
779
792
  dsl += this.writeLine(`}`, level + 1);
780
793
  } else {
781
- dsl += this.writeLine(`${arch.name} = ${baseType} {}`, level + 1);
794
+ dsl += this.writeLine(`${arch.canonicalName} = ${baseType} {}`, level + 1);
782
795
  }
783
796
  }
784
797
  for (const arch of relationshipArchetypes) {
785
- const arrow = arch.parent ? `--${arch.parent.name}->` : `->`;
798
+ const arrow = arch.parent ? `--${arch.parent.canonicalName}->` : `->`;
786
799
  let inner = "";
787
800
  if (arch.ownDescription) {
788
801
  inner += this.writeLine(`description "${arch.ownDescription}"`, level + 2);
@@ -794,11 +807,11 @@ var StructurizrDSLWriter = class {
794
807
  inner += this.writeLine(`tags ${arch.ownTags.map((t) => `"${t}"`).join(" ")}`, level + 2);
795
808
  }
796
809
  if (inner) {
797
- dsl += this.writeLine(`${arch.name} = ${arrow} {`, level + 1);
810
+ dsl += this.writeLine(`${arch.canonicalName} = ${arrow} {`, level + 1);
798
811
  dsl += inner;
799
812
  dsl += this.writeLine(`}`, level + 1);
800
813
  } else {
801
- dsl += this.writeLine(`${arch.name} = ${arrow} {}`, level + 1);
814
+ dsl += this.writeLine(`${arch.canonicalName} = ${arrow} {}`, level + 1);
802
815
  }
803
816
  }
804
817
  dsl += this.writeLine(`}`, level);
@@ -806,7 +819,7 @@ var StructurizrDSLWriter = class {
806
819
  }
807
820
  writeElement(elementType, element, level, closeElement = true) {
808
821
  let elementDsl = "";
809
- const type = element.archetype ? element.archetype.name : elementType;
822
+ const type = element.archetype ? element.archetype.canonicalName : elementType;
810
823
  elementDsl += this.writeLine(`${element.canonicalName} = ${type} "${element.name}" {`, level);
811
824
  if (element.archetype) {
812
825
  const ovr = element.overrideDefinition;
@@ -899,7 +912,7 @@ var StructurizrDSLWriter = class {
899
912
  writeRelationship(relationship, level) {
900
913
  let dsl = "";
901
914
  if (relationship.archetype) {
902
- const arrow = `--${relationship.archetype.name}->`;
915
+ const arrow = `--${relationship.archetype.canonicalName}->`;
903
916
  const ovr = relationship.overrideDefinition;
904
917
  const desc = ovr?.description ?? relationship.description ?? "uses";
905
918
  dsl += this.writeLine(
@@ -1241,6 +1254,7 @@ async function exportWorkspaceJson(model, views) {
1241
1254
  Component,
1242
1255
  Container,
1243
1256
  ContainerGroup,
1257
+ ELEMENT_KINDS,
1244
1258
  ElementArchetype,
1245
1259
  Model,
1246
1260
  ModelGroup,
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 type ElementKind = "person" | "softwareSystem" | "container" | "component";
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: {
package/src/index.js CHANGED
@@ -1,49 +1,3 @@
1
- // libs/c4-model/src/archetype.ts
2
- var ElementArchetype = class {
3
- constructor(name, elementKind, definition, parent) {
4
- this.name = name;
5
- this.elementKind = elementKind;
6
- this.parent = parent;
7
- this.ownDescription = definition?.description;
8
- this.ownTechnology = definition?.technology;
9
- this.ownTags = definition?.tags ?? [];
10
- this.description = this.ownDescription ?? parent?.description;
11
- this.technology = this.ownTechnology ?? parent?.technology;
12
- this.tags = [...parent?.tags ?? [], ...this.ownTags];
13
- }
14
- ownDescription;
15
- ownTechnology;
16
- ownTags;
17
- description;
18
- technology;
19
- tags;
20
- };
21
- var RelationshipArchetype = class {
22
- constructor(name, definition, parent) {
23
- this.name = name;
24
- this.parent = parent;
25
- this.ownDescription = definition?.description;
26
- this.ownTechnology = definition?.technology;
27
- this.ownTags = definition?.tags ?? [];
28
- this.description = this.ownDescription ?? parent?.description;
29
- this.technology = this.ownTechnology ?? parent?.technology;
30
- this.tags = [...parent?.tags ?? [], ...this.ownTags];
31
- }
32
- ownDescription;
33
- ownTechnology;
34
- ownTags;
35
- description;
36
- technology;
37
- tags;
38
- };
39
- function mergeArchetypeWithOverride(archetype, override) {
40
- return {
41
- description: override?.description ?? archetype.description,
42
- technology: override?.technology ?? archetype.technology,
43
- tags: [...archetype.tags, ...override?.tags ?? []]
44
- };
45
- }
46
-
47
1
  // node_modules/.pnpm/change-case@5.4.4/node_modules/change-case/dist/index.js
48
2
  var SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
49
3
  var SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
@@ -130,6 +84,64 @@ function splitPrefixSuffix(input, options = {}) {
130
84
  ];
131
85
  }
132
86
 
87
+ // libs/c4-model/src/archetype.ts
88
+ var ELEMENT_KINDS = {
89
+ person: "person",
90
+ softwareSystem: "softwareSystem",
91
+ container: "container",
92
+ component: "component"
93
+ };
94
+ var ElementArchetype = class {
95
+ constructor(name, elementKind, definition, parent) {
96
+ this.name = name;
97
+ this.elementKind = elementKind;
98
+ this.parent = parent;
99
+ this.ownDescription = definition?.description;
100
+ this.ownTechnology = definition?.technology;
101
+ this.ownTags = definition?.tags ?? [];
102
+ this.description = this.ownDescription ?? parent?.description;
103
+ this.technology = this.ownTechnology ?? parent?.technology;
104
+ this.tags = [...parent?.tags ?? [], ...this.ownTags];
105
+ }
106
+ ownDescription;
107
+ ownTechnology;
108
+ ownTags;
109
+ description;
110
+ technology;
111
+ tags;
112
+ get canonicalName() {
113
+ return camelCase(this.name);
114
+ }
115
+ };
116
+ var RelationshipArchetype = class {
117
+ constructor(name, definition, parent) {
118
+ this.name = name;
119
+ this.parent = parent;
120
+ this.ownDescription = definition?.description;
121
+ this.ownTechnology = definition?.technology;
122
+ this.ownTags = definition?.tags ?? [];
123
+ this.description = this.ownDescription ?? parent?.description;
124
+ this.technology = this.ownTechnology ?? parent?.technology;
125
+ this.tags = [...parent?.tags ?? [], ...this.ownTags];
126
+ }
127
+ ownDescription;
128
+ ownTechnology;
129
+ ownTags;
130
+ description;
131
+ technology;
132
+ tags;
133
+ get canonicalName() {
134
+ return camelCase(this.name);
135
+ }
136
+ };
137
+ function mergeArchetypeWithOverride(archetype, override) {
138
+ return {
139
+ description: override?.description ?? archetype.description,
140
+ technology: override?.technology ?? archetype.technology,
141
+ tags: [...archetype.tags, ...override?.tags ?? []]
142
+ };
143
+ }
144
+
133
145
  // libs/c4-model/src/core.ts
134
146
  var Element = class {
135
147
  constructor(name, defaultTags = [], definition, archetype, overrideDefinition) {
@@ -708,7 +720,7 @@ var StructurizrDSLWriter = class {
708
720
  if (elementArchetypes.length === 0 && relationshipArchetypes.length === 0) return "";
709
721
  let dsl = this.writeLine(`archetypes {`, level);
710
722
  for (const arch of elementArchetypes) {
711
- const baseType = arch.parent ? arch.parent.name : arch.elementKind;
723
+ const baseType = arch.parent ? arch.parent.canonicalName : arch.elementKind;
712
724
  let inner = "";
713
725
  if (arch.ownDescription) {
714
726
  inner += this.writeLine(`description "${arch.ownDescription}"`, level + 2);
@@ -720,15 +732,15 @@ var StructurizrDSLWriter = class {
720
732
  inner += this.writeLine(`tags ${arch.ownTags.map((t) => `"${t}"`).join(" ")}`, level + 2);
721
733
  }
722
734
  if (inner) {
723
- dsl += this.writeLine(`${arch.name} = ${baseType} {`, level + 1);
735
+ dsl += this.writeLine(`${arch.canonicalName} = ${baseType} {`, level + 1);
724
736
  dsl += inner;
725
737
  dsl += this.writeLine(`}`, level + 1);
726
738
  } else {
727
- dsl += this.writeLine(`${arch.name} = ${baseType} {}`, level + 1);
739
+ dsl += this.writeLine(`${arch.canonicalName} = ${baseType} {}`, level + 1);
728
740
  }
729
741
  }
730
742
  for (const arch of relationshipArchetypes) {
731
- const arrow = arch.parent ? `--${arch.parent.name}->` : `->`;
743
+ const arrow = arch.parent ? `--${arch.parent.canonicalName}->` : `->`;
732
744
  let inner = "";
733
745
  if (arch.ownDescription) {
734
746
  inner += this.writeLine(`description "${arch.ownDescription}"`, level + 2);
@@ -740,11 +752,11 @@ var StructurizrDSLWriter = class {
740
752
  inner += this.writeLine(`tags ${arch.ownTags.map((t) => `"${t}"`).join(" ")}`, level + 2);
741
753
  }
742
754
  if (inner) {
743
- dsl += this.writeLine(`${arch.name} = ${arrow} {`, level + 1);
755
+ dsl += this.writeLine(`${arch.canonicalName} = ${arrow} {`, level + 1);
744
756
  dsl += inner;
745
757
  dsl += this.writeLine(`}`, level + 1);
746
758
  } else {
747
- dsl += this.writeLine(`${arch.name} = ${arrow} {}`, level + 1);
759
+ dsl += this.writeLine(`${arch.canonicalName} = ${arrow} {}`, level + 1);
748
760
  }
749
761
  }
750
762
  dsl += this.writeLine(`}`, level);
@@ -752,7 +764,7 @@ var StructurizrDSLWriter = class {
752
764
  }
753
765
  writeElement(elementType, element, level, closeElement = true) {
754
766
  let elementDsl = "";
755
- const type = element.archetype ? element.archetype.name : elementType;
767
+ const type = element.archetype ? element.archetype.canonicalName : elementType;
756
768
  elementDsl += this.writeLine(`${element.canonicalName} = ${type} "${element.name}" {`, level);
757
769
  if (element.archetype) {
758
770
  const ovr = element.overrideDefinition;
@@ -845,7 +857,7 @@ var StructurizrDSLWriter = class {
845
857
  writeRelationship(relationship, level) {
846
858
  let dsl = "";
847
859
  if (relationship.archetype) {
848
- const arrow = `--${relationship.archetype.name}->`;
860
+ const arrow = `--${relationship.archetype.canonicalName}->`;
849
861
  const ovr = relationship.overrideDefinition;
850
862
  const desc = ovr?.description ?? relationship.description ?? "uses";
851
863
  dsl += this.writeLine(
@@ -1185,6 +1197,7 @@ export {
1185
1197
  Component,
1186
1198
  Container,
1187
1199
  ContainerGroup,
1200
+ ELEMENT_KINDS,
1188
1201
  ElementArchetype,
1189
1202
  Model,
1190
1203
  ModelGroup,