@likec4/core 1.17.1 → 1.19.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.
Files changed (184) hide show
  1. package/LICENSE +1 -1
  2. package/dist/builder/index.d.mts +502 -0
  3. package/dist/builder/index.d.ts +502 -0
  4. package/dist/builder/index.js +871 -0
  5. package/dist/compute-view/index.d.mts +22 -0
  6. package/dist/compute-view/index.d.ts +22 -0
  7. package/dist/compute-view/index.js +78 -0
  8. package/dist/index.d.mts +10 -919
  9. package/dist/index.d.ts +10 -919
  10. package/dist/{index.mjs → index.js} +7 -1688
  11. package/dist/model/index.d.mts +254 -0
  12. package/dist/model/index.d.ts +254 -0
  13. package/dist/model/index.js +1 -0
  14. package/dist/shared/chunk-RAAYCPUM.M-JWF7SS.js +21 -0
  15. package/dist/shared/core.BIfgabEw.d.ts +719 -0
  16. package/dist/shared/core.BZ9Msq7w.d.mts +719 -0
  17. package/dist/shared/{core.CoLQkcYL.d.cts → core.C05RDLhi.d.ts} +460 -362
  18. package/dist/shared/{core.CoLQkcYL.d.mts → core.CmYMqgha.d.mts} +460 -362
  19. package/dist/shared/core.D6-fWbM3.d.ts +127 -0
  20. package/dist/shared/core.D74xkKkG.d.mts +148 -0
  21. package/dist/shared/core.D74xkKkG.d.ts +148 -0
  22. package/dist/shared/core.sLaWHBjR.d.mts +127 -0
  23. package/dist/shared/index.-BdzdI2C.js +7443 -0
  24. package/dist/shared/object_hash.CE_oF3I3.js +1222 -0
  25. package/dist/shared/{core.BXTs-8n7.mjs → view.CyZrG8BJ.js} +108 -47
  26. package/dist/types/index.d.mts +71 -1
  27. package/dist/types/index.d.ts +71 -1
  28. package/dist/types/index.js +20 -0
  29. package/dist/utils/index.d.mts +404 -0
  30. package/dist/utils/index.d.ts +404 -0
  31. package/dist/utils/index.js +330 -0
  32. package/package.json +59 -47
  33. package/src/builder/Builder-style1.test-d.ts +190 -0
  34. package/src/builder/Builder-style2.test-d.ts +175 -0
  35. package/src/builder/Builder.deployment.ts +224 -0
  36. package/src/builder/Builder.deploymentModel.ts +385 -0
  37. package/src/builder/Builder.element.ts +19 -19
  38. package/src/builder/Builder.model.ts +67 -42
  39. package/src/builder/Builder.ts +533 -367
  40. package/src/builder/Builder.view-common.ts +234 -0
  41. package/src/builder/Builder.view-deployment.ts +135 -0
  42. package/src/builder/Builder.view-element.ts +189 -0
  43. package/src/builder/Builder.views.ts +109 -33
  44. package/src/builder/Builder.with.ts +475 -0
  45. package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +374 -0
  46. package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +183 -0
  47. package/src/builder/__snapshots__/Builder.spec.ts.snap +374 -0
  48. package/src/builder/_types.ts +113 -18
  49. package/src/builder/index.ts +10 -4
  50. package/src/colors/index.ts +2 -2
  51. package/src/compute-view/compute-view.ts +83 -0
  52. package/src/compute-view/deployment-view/__test__/TestHelper.ts +236 -0
  53. package/src/compute-view/deployment-view/__test__/fixture.ts +198 -0
  54. package/src/compute-view/deployment-view/_types.ts +37 -0
  55. package/src/compute-view/deployment-view/clean-connections.ts +238 -0
  56. package/src/compute-view/deployment-view/compute.ts +125 -0
  57. package/src/compute-view/deployment-view/memory/index.ts +9 -0
  58. package/src/compute-view/deployment-view/memory/memory.ts +97 -0
  59. package/src/compute-view/deployment-view/predicates/elements.ts +144 -0
  60. package/src/compute-view/deployment-view/predicates/relation-direct.ts +237 -0
  61. package/src/compute-view/deployment-view/predicates/relation-in-out.ts +61 -0
  62. package/src/compute-view/deployment-view/predicates/relation-incoming.ts +95 -0
  63. package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +88 -0
  64. package/src/compute-view/deployment-view/predicates/wildcard.ts +29 -0
  65. package/src/compute-view/deployment-view/stages/stage-exclude.ts +5 -0
  66. package/src/compute-view/deployment-view/stages/stage-final.ts +245 -0
  67. package/src/compute-view/deployment-view/stages/stage-include.ts +95 -0
  68. package/src/compute-view/deployment-view/utils.ts +276 -0
  69. package/src/compute-view/dynamic-view/__test__/fixture.ts +58 -0
  70. package/src/compute-view/dynamic-view/compute.ts +324 -0
  71. package/src/compute-view/element-view/__test__/TestHelper.ts +258 -0
  72. package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +458 -0
  73. package/src/compute-view/element-view/__test__/fixture.ts +675 -0
  74. package/src/compute-view/element-view/_types.ts +48 -0
  75. package/src/compute-view/element-view/clean-connections.ts +113 -0
  76. package/src/compute-view/element-view/compute.ts +315 -0
  77. package/src/compute-view/element-view/memory/NodeGroup.ts +31 -0
  78. package/src/compute-view/element-view/memory/index.ts +10 -0
  79. package/src/compute-view/element-view/memory/memory.ts +177 -0
  80. package/src/compute-view/element-view/memory/stage-exclude.ts +59 -0
  81. package/src/compute-view/element-view/memory/stage-final.ts +129 -0
  82. package/src/compute-view/element-view/memory/stage-include.ts +128 -0
  83. package/src/compute-view/element-view/predicates/_utils.ts +86 -0
  84. package/src/compute-view/element-view/predicates/element-expand.ts +33 -0
  85. package/src/compute-view/element-view/predicates/element-kind-tag.ts +26 -0
  86. package/src/compute-view/element-view/predicates/element-ref.ts +37 -0
  87. package/src/compute-view/element-view/predicates/relation-direct.ts +309 -0
  88. package/src/compute-view/element-view/predicates/relation-in-out.ts +66 -0
  89. package/src/compute-view/element-view/predicates/relation-in.ts +118 -0
  90. package/src/compute-view/element-view/predicates/relation-out.ts +116 -0
  91. package/src/compute-view/element-view/predicates/wildcard.ts +88 -0
  92. package/src/compute-view/element-view/utils.ts +59 -0
  93. package/src/compute-view/index.ts +4 -0
  94. package/src/compute-view/memory/AbstractMemory.ts +45 -0
  95. package/src/compute-view/memory/AbstractStageExclude.ts +216 -0
  96. package/src/compute-view/memory/AbstractStageInclude.ts +200 -0
  97. package/src/compute-view/memory/_types.ts +147 -0
  98. package/src/compute-view/memory/index.ts +5 -0
  99. package/src/compute-view/memory/ops.ts +43 -0
  100. package/src/compute-view/utils/__snapshots__/sortNodes.spec.ts.snap +113 -0
  101. package/src/compute-view/utils/ancestorsOfNode.ts +19 -0
  102. package/src/compute-view/utils/applyCustomElementProperties.ts +66 -0
  103. package/src/compute-view/utils/applyCustomRelationProperties.ts +41 -0
  104. package/src/compute-view/utils/applyViewRuleStyles.ts +53 -0
  105. package/src/compute-view/utils/buildComputedNodes.ts +148 -0
  106. package/src/compute-view/utils/buildElementNotations.ts +63 -0
  107. package/src/compute-view/utils/elementExpressionToPredicate.ts +50 -0
  108. package/src/compute-view/utils/link-nodes-with-edges.ts +54 -0
  109. package/src/compute-view/utils/merge-props-from-relationships.ts +128 -0
  110. package/src/compute-view/utils/relationExpressionToPredicates.ts +55 -0
  111. package/src/compute-view/utils/resolve-extended-views.ts +69 -0
  112. package/src/compute-view/utils/resolve-global-rules.ts +83 -0
  113. package/src/compute-view/utils/topological-sort.ts +256 -0
  114. package/src/compute-view/utils/uniqueTags.test.ts +42 -0
  115. package/src/compute-view/utils/uniqueTags.ts +21 -0
  116. package/src/compute-view/utils/view-hash.ts +27 -0
  117. package/src/compute-view/utils/with-readable-edges.ts +36 -0
  118. package/src/index.ts +22 -12
  119. package/src/model/DeploymentElementModel.ts +599 -0
  120. package/src/model/DeploymentModel.ts +370 -0
  121. package/src/model/ElementModel.ts +221 -0
  122. package/src/model/LikeC4Model.test-d.ts +152 -0
  123. package/src/model/LikeC4Model.ts +336 -457
  124. package/src/model/RelationModel.ts +85 -0
  125. package/src/model/__test__/fixture.ts +149 -338
  126. package/src/model/connection/Connection.ts +72 -0
  127. package/src/model/connection/deployment/DeploymentConnectionModel.ts +178 -0
  128. package/src/model/connection/deployment/find.ts +120 -0
  129. package/src/model/connection/deployment/index.ts +8 -0
  130. package/src/model/connection/index.ts +22 -0
  131. package/src/model/connection/model/ConnectionModel.ts +157 -0
  132. package/src/model/connection/model/find.ts +117 -0
  133. package/src/model/connection/model/index.ts +8 -0
  134. package/src/model/connection/ops.ts +274 -0
  135. package/src/model/guards.ts +9 -0
  136. package/src/model/index.ts +46 -2
  137. package/src/model/types.ts +112 -15
  138. package/src/model/view/EdgeModel.ts +103 -0
  139. package/src/model/view/LikeC4ViewModel.ts +226 -0
  140. package/src/model/view/NodeModel.ts +229 -0
  141. package/src/types/_common.ts +55 -1
  142. package/src/types/deployments.ts +169 -0
  143. package/src/types/element.ts +9 -5
  144. package/src/types/expression-v2.ts +172 -0
  145. package/src/types/expression.ts +17 -11
  146. package/src/types/global.ts +3 -3
  147. package/src/types/index.ts +220 -12
  148. package/src/types/model.ts +75 -12
  149. package/src/types/operators.ts +1 -1
  150. package/src/types/overview-graph.ts +2 -2
  151. package/src/types/relation.ts +18 -14
  152. package/src/types/theme.ts +0 -1
  153. package/src/types/view-notation.ts +2 -2
  154. package/src/types/view.ts +117 -41
  155. package/src/utils/{commonHead.ts → common-head.ts} +2 -0
  156. package/src/utils/const.ts +1 -0
  157. package/src/utils/fqn.ts +203 -56
  158. package/src/utils/getOrCreate.ts +42 -0
  159. package/src/utils/graphlib.ts +10 -0
  160. package/src/utils/index.ts +74 -6
  161. package/src/utils/iterable/_types.ts +5 -0
  162. package/src/utils/iterable/filter.ts +55 -0
  163. package/src/utils/iterable/flat.ts +17 -0
  164. package/src/utils/iterable/index.ts +12 -0
  165. package/src/utils/iterable/map.ts +40 -0
  166. package/src/utils/iterable/reduce.ts +24 -0
  167. package/src/utils/iterable/some.ts +36 -0
  168. package/src/utils/iterable/to.ts +19 -0
  169. package/src/utils/iterable/unique.ts +29 -0
  170. package/src/utils/object-hash.ts +3 -0
  171. package/src/utils/relations.ts +3 -64
  172. package/src/utils/set.ts +78 -0
  173. package/src/utils/string-hash.ts +16 -0
  174. package/dist/index.cjs +0 -5452
  175. package/dist/index.d.cts +0 -1053
  176. package/dist/shared/core.CoLQkcYL.d.ts +0 -734
  177. package/dist/shared/core.DIYZvpVg.cjs +0 -353
  178. package/dist/types/index.cjs +0 -70
  179. package/dist/types/index.d.cts +0 -2
  180. package/dist/types/index.mjs +0 -1
  181. package/src/builder/Builder.test-d.ts +0 -69
  182. package/src/builder/Builder.view.ts +0 -358
  183. package/src/model/LikeC4DiagramModel.ts +0 -338
  184. package/src/model/LikeC4ViewModel.ts +0 -320
@@ -0,0 +1,374 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`Builder > should build nested elements and relTo 1`] = `
4
+ {
5
+ "deployments": {
6
+ "elements": {},
7
+ "relations": {},
8
+ },
9
+ "elements": {
10
+ "s1": {
11
+ "color": "green",
12
+ "description": null,
13
+ "id": "s1",
14
+ "kind": "system",
15
+ "links": null,
16
+ "shape": "rectangle",
17
+ "style": {
18
+ "opacity": 10,
19
+ },
20
+ "tags": null,
21
+ "technology": null,
22
+ "title": "s1",
23
+ },
24
+ "s1.1": {
25
+ "color": "primary",
26
+ "description": null,
27
+ "id": "s1.1",
28
+ "kind": "component",
29
+ "links": null,
30
+ "shape": "browser",
31
+ "style": {},
32
+ "tags": null,
33
+ "technology": null,
34
+ "title": "1",
35
+ },
36
+ "s2": {
37
+ "color": "green",
38
+ "description": null,
39
+ "id": "s2",
40
+ "kind": "system",
41
+ "links": null,
42
+ "shape": "rectangle",
43
+ "style": {
44
+ "opacity": 10,
45
+ },
46
+ "tags": null,
47
+ "technology": null,
48
+ "title": "s2",
49
+ },
50
+ "s2.1": {
51
+ "color": "primary",
52
+ "description": null,
53
+ "id": "s2.1",
54
+ "kind": "component",
55
+ "links": null,
56
+ "shape": "browser",
57
+ "style": {},
58
+ "tags": null,
59
+ "technology": null,
60
+ "title": "Component s2.1",
61
+ },
62
+ "s2.1.2": {
63
+ "color": "primary",
64
+ "description": null,
65
+ "id": "s2.1.2",
66
+ "kind": "component",
67
+ "links": null,
68
+ "shape": "browser",
69
+ "style": {},
70
+ "tags": null,
71
+ "technology": null,
72
+ "title": "Component s2.1.2",
73
+ },
74
+ "s2.1.2.3": {
75
+ "color": "primary",
76
+ "description": null,
77
+ "id": "s2.1.2.3",
78
+ "kind": "component",
79
+ "links": null,
80
+ "shape": "browser",
81
+ "style": {},
82
+ "tags": null,
83
+ "technology": null,
84
+ "title": "3",
85
+ },
86
+ },
87
+ "globals": {
88
+ "dynamicPredicates": {},
89
+ "predicates": {},
90
+ "styles": {},
91
+ },
92
+ "relations": {
93
+ "rel1": {
94
+ "id": "rel1",
95
+ "source": "s2.1.2.3",
96
+ "target": "s1.1",
97
+ "title": "relation from s2.1.2.3 to s1.1",
98
+ },
99
+ "rel2": {
100
+ "id": "rel2",
101
+ "source": "s2.1",
102
+ "target": "s1.1",
103
+ "title": "relation from s2.1 to s1.1",
104
+ },
105
+ "rel3": {
106
+ "id": "rel3",
107
+ "source": "s1.1",
108
+ "target": "s2.1.2",
109
+ "title": "relation from s1.1 to s2.1.2",
110
+ },
111
+ },
112
+ "specification": {
113
+ "deployments": {},
114
+ "elements": {
115
+ "component": {
116
+ "style": {
117
+ "shape": "browser",
118
+ },
119
+ },
120
+ "system": {
121
+ "style": {
122
+ "color": "green",
123
+ "opacity": 10,
124
+ },
125
+ },
126
+ },
127
+ "relationships": {},
128
+ "tags": [],
129
+ },
130
+ "views": {},
131
+ }
132
+ `;
133
+
134
+ exports[`Builder > should build view 1`] = `
135
+ {
136
+ "deployments": {
137
+ "elements": {},
138
+ "relations": {},
139
+ },
140
+ "elements": {
141
+ "1": {
142
+ "color": "primary",
143
+ "description": null,
144
+ "id": "1",
145
+ "kind": "component",
146
+ "links": null,
147
+ "shape": "rectangle",
148
+ "style": {},
149
+ "tags": null,
150
+ "technology": null,
151
+ "title": "1",
152
+ },
153
+ "2": {
154
+ "color": "primary",
155
+ "description": null,
156
+ "id": "2",
157
+ "kind": "component",
158
+ "links": null,
159
+ "shape": "rectangle",
160
+ "style": {},
161
+ "tags": null,
162
+ "technology": null,
163
+ "title": "2",
164
+ },
165
+ "3": {
166
+ "color": "primary",
167
+ "description": null,
168
+ "id": "3",
169
+ "kind": "component",
170
+ "links": null,
171
+ "shape": "rectangle",
172
+ "style": {},
173
+ "tags": null,
174
+ "technology": null,
175
+ "title": "3",
176
+ },
177
+ },
178
+ "globals": {
179
+ "dynamicPredicates": {},
180
+ "predicates": {},
181
+ "styles": {},
182
+ },
183
+ "relations": {},
184
+ "specification": {
185
+ "deployments": {},
186
+ "elements": {
187
+ "component": {},
188
+ },
189
+ "relationships": {},
190
+ "tags": [],
191
+ },
192
+ "views": {
193
+ "1": {
194
+ "__": "element",
195
+ "customColorDefinitions": {},
196
+ "description": null,
197
+ "id": "1",
198
+ "links": null,
199
+ "rules": [
200
+ {
201
+ "include": [
202
+ {
203
+ "wildcard": true,
204
+ },
205
+ ],
206
+ },
207
+ ],
208
+ "tags": null,
209
+ "title": "View 1",
210
+ },
211
+ "2": {
212
+ "__": "element",
213
+ "customColorDefinitions": {},
214
+ "description": null,
215
+ "id": "2",
216
+ "links": null,
217
+ "rules": [
218
+ {
219
+ "include": [
220
+ {
221
+ "wildcard": true,
222
+ },
223
+ ],
224
+ },
225
+ {
226
+ "include": [
227
+ {
228
+ "element": "2",
229
+ "isChildren": true,
230
+ },
231
+ ],
232
+ },
233
+ ],
234
+ "tags": null,
235
+ "title": "view 2",
236
+ },
237
+ "3": {
238
+ "__": "element",
239
+ "customColorDefinitions": {},
240
+ "description": null,
241
+ "id": "3",
242
+ "links": null,
243
+ "rules": [
244
+ {
245
+ "include": [
246
+ {
247
+ "expanded": "3",
248
+ },
249
+ ],
250
+ },
251
+ ],
252
+ "tags": null,
253
+ "title": "",
254
+ },
255
+ },
256
+ }
257
+ `;
258
+
259
+ exports[`Builder > should build viewOf 1`] = `
260
+ {
261
+ "deployments": {
262
+ "elements": {},
263
+ "relations": {},
264
+ },
265
+ "elements": {
266
+ "1": {
267
+ "color": "primary",
268
+ "description": null,
269
+ "id": "1",
270
+ "kind": "component",
271
+ "links": null,
272
+ "shape": "rectangle",
273
+ "style": {},
274
+ "tags": null,
275
+ "technology": null,
276
+ "title": "1",
277
+ },
278
+ "2": {
279
+ "color": "primary",
280
+ "description": null,
281
+ "id": "2",
282
+ "kind": "component",
283
+ "links": null,
284
+ "shape": "rectangle",
285
+ "style": {},
286
+ "tags": null,
287
+ "technology": null,
288
+ "title": "2",
289
+ },
290
+ "2.3": {
291
+ "color": "primary",
292
+ "description": null,
293
+ "id": "2.3",
294
+ "kind": "component",
295
+ "links": null,
296
+ "shape": "rectangle",
297
+ "style": {},
298
+ "tags": null,
299
+ "technology": null,
300
+ "title": "3",
301
+ },
302
+ "2.3.4": {
303
+ "color": "primary",
304
+ "description": null,
305
+ "id": "2.3.4",
306
+ "kind": "component",
307
+ "links": null,
308
+ "shape": "rectangle",
309
+ "style": {},
310
+ "tags": null,
311
+ "technology": null,
312
+ "title": "4",
313
+ },
314
+ },
315
+ "globals": {
316
+ "dynamicPredicates": {},
317
+ "predicates": {},
318
+ "styles": {},
319
+ },
320
+ "relations": {},
321
+ "specification": {
322
+ "deployments": {},
323
+ "elements": {
324
+ "component": {},
325
+ },
326
+ "relationships": {},
327
+ "tags": [],
328
+ },
329
+ "views": {
330
+ "1": {
331
+ "__": "element",
332
+ "customColorDefinitions": {},
333
+ "description": null,
334
+ "id": "1",
335
+ "links": null,
336
+ "rules": [
337
+ {
338
+ "include": [
339
+ {
340
+ "wildcard": true,
341
+ },
342
+ ],
343
+ },
344
+ {
345
+ "include": [
346
+ {
347
+ "inout": {
348
+ "element": "2.3",
349
+ "isChildren": true,
350
+ },
351
+ },
352
+ ],
353
+ },
354
+ {
355
+ "exclude": [
356
+ {
357
+ "source": {
358
+ "expanded": "1",
359
+ },
360
+ "target": {
361
+ "element": "2.3",
362
+ "isChildren": true,
363
+ },
364
+ },
365
+ ],
366
+ },
367
+ ],
368
+ "tags": null,
369
+ "title": "View 1",
370
+ "viewOf": "2",
371
+ },
372
+ },
373
+ }
374
+ `;
@@ -1,27 +1,37 @@
1
- import type { IfNever, IsLiteral, Tagged, TupleToUnion } from 'type-fest'
1
+ import type { IfNever, IsLiteral, IsStringLiteral, Tagged, TupleToUnion } from 'type-fest'
2
+ import type { LikeC4Model } from '../model/LikeC4Model'
2
3
  import type {
3
4
  BorderStyle,
4
5
  Color,
6
+ DeploymentNodeKindSpecification,
5
7
  ElementKindSpecification,
6
8
  ElementShape,
9
+ KeysOf,
10
+ NonEmptyArray,
7
11
  ParsedLikeC4Model,
8
12
  RelationshipArrowType,
9
13
  RelationshipKindSpecification,
10
- RelationshipLineType
14
+ RelationshipLineType,
11
15
  } from '../types'
12
-
13
- type KeysOf<T> = keyof T extends infer K extends string ? K : never
16
+ import type { ExpressionV2 } from '../types/expression-v2'
17
+ import type { Builder } from './Builder'
18
+ import type { DeploymentRulesBuilderOp } from './Builder.view-deployment'
14
19
 
15
20
  export type BuilderSpecification = {
16
21
  elements: {
17
22
  [kind: string]: Partial<ElementKindSpecification>
18
23
  }
19
- relationships?: Record<string, Partial<RelationshipKindSpecification>>
24
+ relationships?: {
25
+ [kind: string]: Partial<RelationshipKindSpecification>
26
+ }
27
+ deployments?: {
28
+ [kind: string]: Partial<DeploymentNodeKindSpecification>
29
+ }
20
30
  tags?: [string, ...string[]]
21
31
  metadataKeys?: [string, ...string[]]
22
32
  }
23
33
 
24
- type Metadata<MetadataKey extends string> = IfNever<MetadataKey, never, Record<MetadataKey, string>>
34
+ export type Metadata<MetadataKey extends string> = IfNever<MetadataKey, never, Record<MetadataKey, string>>
25
35
 
26
36
  export type NewElementProps<Tag, Metadata> = {
27
37
  title?: string
@@ -40,6 +50,23 @@ export type NewElementProps<Tag, Metadata> = {
40
50
  }
41
51
  }
42
52
 
53
+ export type NewDeploymentNodeProps<Tag, Metadata> = {
54
+ title?: string
55
+ description?: string
56
+ technology?: string
57
+ tags?: IfNever<Tag, never, [Tag, ...Tag[]]>
58
+ metadata?: Metadata
59
+ icon?: string
60
+ shape?: ElementShape
61
+ color?: Color
62
+ links?: NonEmptyArray<string | { title?: string; url: string }>
63
+ style?: {
64
+ border?: BorderStyle
65
+ // 0-100
66
+ opacity?: number
67
+ }
68
+ }
69
+
43
70
  export type NewViewProps<Tag> = {
44
71
  title?: string
45
72
  description?: string
@@ -58,13 +85,19 @@ export type NewRelationProps<Kind, Tag, Metadata> = {
58
85
  tail?: RelationshipArrowType
59
86
  line?: RelationshipLineType
60
87
  color?: Color
61
- links?: Array<string | { title?: string; url: string }>
88
+ links?: NonEmptyArray<string | { title?: string; url: string }>
62
89
  }
63
90
 
64
91
  export type Invalid<Message extends string> = Tagged<Message, 'Error'>
65
92
  export type Warn<Id, Existing> = IsLiteral<Existing> extends true ? Id extends Existing ? Invalid<'Already exists'> : Id
66
93
  : Id
67
94
 
95
+ export type ValidId<Id> =
96
+ // Id extends `${string}.${string}` ? Invalid<'Id must not contain dot'>
97
+ Id extends `${number}${string}` ? Invalid<'Id must not start with number'>
98
+ : IsStringLiteral<Id> extends true ? Id
99
+ : Invalid<'Id must be a literal'>
100
+
68
101
  /**
69
102
  * Auxilary type to keep track of the types in builder
70
103
  */
@@ -74,7 +107,9 @@ export interface Types<
74
107
  ViewId extends string,
75
108
  RelationshipKind extends string,
76
109
  Tag extends string,
77
- MetadataKey extends string
110
+ MetadataKey extends string,
111
+ DeploymentKind extends string,
112
+ DeploymentFqn extends string,
78
113
  > {
79
114
  ElementKind: ElementKind
80
115
  Fqn: Fqn
@@ -82,6 +117,8 @@ export interface Types<
82
117
  RelationshipKind: RelationshipKind
83
118
  Tag: Tag
84
119
  MetadataKey: MetadataKey
120
+ DeploymentKind: DeploymentKind
121
+ DeploymentFqn: DeploymentFqn
85
122
 
86
123
  Tags: IfNever<Tag, never, [Tag, ...Tag[]]>
87
124
  // Metadata: Metadata<MetadataKey>
@@ -89,6 +126,8 @@ export interface Types<
89
126
  NewElementProps: NewElementProps<Tag, Metadata<MetadataKey>>
90
127
  NewRelationshipProps: NewRelationProps<RelationshipKind, Tag, Metadata<MetadataKey>>
91
128
  NewViewProps: NewViewProps<Tag>
129
+
130
+ NewDeploymentNodeProps: NewDeploymentNodeProps<Tag, Metadata<MetadataKey>>
92
131
  }
93
132
 
94
133
  /**
@@ -101,7 +140,9 @@ export interface TypesNested<
101
140
  ViewId extends string,
102
141
  RelationshipKind extends string,
103
142
  Tag extends string,
104
- MetadataKey extends string
143
+ MetadataKey extends string,
144
+ DeploymentKind extends string,
145
+ DeploymentFqn extends string,
105
146
  > extends
106
147
  Types<
107
148
  ElementKind,
@@ -109,7 +150,9 @@ export interface TypesNested<
109
150
  ViewId,
110
151
  RelationshipKind,
111
152
  Tag,
112
- MetadataKey
153
+ MetadataKey,
154
+ DeploymentKind,
155
+ DeploymentFqn
113
156
  >
114
157
  {
115
158
  Parent: Parent
@@ -121,6 +164,8 @@ export type AnyTypes = Types<
121
164
  any,
122
165
  any,
123
166
  any,
167
+ any,
168
+ any,
124
169
  any
125
170
  >
126
171
 
@@ -131,6 +176,8 @@ export type AnyTypesNested = TypesNested<
131
176
  any,
132
177
  any,
133
178
  any,
179
+ any,
180
+ any,
134
181
  any
135
182
  >
136
183
 
@@ -141,18 +188,23 @@ export namespace Types {
141
188
  never,
142
189
  KeysOf<Spec['relationships']>,
143
190
  TupleToUnion<Spec['tags']>,
144
- TupleToUnion<Spec['metadataKeys']>
191
+ TupleToUnion<Spec['metadataKeys']>,
192
+ KeysOf<Spec['deployments']>,
193
+ never
145
194
  >
146
195
  : never
147
196
 
148
- export type AddFqn<T, Id extends string> = T extends TypesNested<infer P, any, any, any, any, any, any> ? TypesNested<
197
+ export type AddFqn<T, Id extends string> = T extends TypesNested<infer P, any, any, any, any, any, any, any, any>
198
+ ? TypesNested<
149
199
  P,
150
200
  T['ElementKind'],
151
201
  `${P}.${Id}` | T['Fqn'],
152
202
  T['ViewId'],
153
203
  T['RelationshipKind'],
154
204
  T['Tag'],
155
- T['MetadataKey']
205
+ T['MetadataKey'],
206
+ T['DeploymentKind'],
207
+ T['DeploymentFqn']
156
208
  >
157
209
  : T extends AnyTypes ? Types<
158
210
  T['ElementKind'],
@@ -160,11 +212,37 @@ export namespace Types {
160
212
  T['ViewId'],
161
213
  T['RelationshipKind'],
162
214
  T['Tag'],
163
- T['MetadataKey']
215
+ T['MetadataKey'],
216
+ T['DeploymentKind'],
217
+ T['DeploymentFqn']
218
+ >
219
+ : never
220
+
221
+ export type AddDeploymentFqn<T, Id extends string> = T extends
222
+ TypesNested<infer P, any, any, any, any, any, any, any, any> ? TypesNested<
223
+ P,
224
+ T['ElementKind'],
225
+ T['Fqn'],
226
+ T['ViewId'],
227
+ T['RelationshipKind'],
228
+ T['Tag'],
229
+ T['MetadataKey'],
230
+ T['DeploymentKind'],
231
+ `${P}.${Id}` | T['DeploymentFqn']
232
+ >
233
+ : T extends AnyTypes ? Types<
234
+ T['ElementKind'],
235
+ T['Fqn'],
236
+ T['ViewId'],
237
+ T['RelationshipKind'],
238
+ T['Tag'],
239
+ T['MetadataKey'],
240
+ T['DeploymentKind'],
241
+ Id | T['DeploymentFqn']
164
242
  >
165
243
  : never
166
244
 
167
- export type AddView<T, Id extends string> = T extends TypesNested<infer P, any, any, any, any, any, any>
245
+ export type AddView<T, Id extends string> = T extends TypesNested<infer P, any, any, any, any, any, any, any, any>
168
246
  ? TypesNested<
169
247
  P,
170
248
  T['ElementKind'],
@@ -172,7 +250,9 @@ export namespace Types {
172
250
  Id | T['ViewId'],
173
251
  T['RelationshipKind'],
174
252
  T['Tag'],
175
- T['MetadataKey']
253
+ T['MetadataKey'],
254
+ T['DeploymentKind'],
255
+ T['DeploymentFqn']
176
256
  >
177
257
  : T extends AnyTypes ? Types<
178
258
  T['ElementKind'],
@@ -180,7 +260,9 @@ export namespace Types {
180
260
  Id | T['ViewId'],
181
261
  T['RelationshipKind'],
182
262
  T['Tag'],
183
- T['MetadataKey']
263
+ T['MetadataKey'],
264
+ T['DeploymentKind'],
265
+ T['DeploymentFqn']
184
266
  >
185
267
  : never
186
268
 
@@ -189,7 +271,20 @@ export namespace Types {
189
271
  T['RelationshipKind'],
190
272
  T['Tag'],
191
273
  T['Fqn'],
192
- T['ViewId']
274
+ T['ViewId'],
275
+ T['DeploymentFqn']
193
276
  >
194
277
  : never
278
+
279
+ export type ToLikeC4Model<T extends AnyTypes> = LikeC4Model.Computed<
280
+ T['Fqn'],
281
+ T['DeploymentFqn'],
282
+ T['ViewId']
283
+ >
284
+
285
+ export type ToExpression<T> = T extends AnyTypes ? ExpressionV2<T['DeploymentFqn'], T['Fqn']> : never
286
+
287
+ export type From<B> = B extends Builder<infer T> ? B['Types'] extends AnyTypes ? T : AnyTypes : never
288
+
289
+ export type DeploymentRules<B> = DeploymentRulesBuilderOp<From<B>>
195
290
  }
@@ -1,5 +1,11 @@
1
- export type { AnyTypes, AnyTypesNested, BuilderSpecification, Types, TypesNested } from './_types'
1
+ export type * from './_types'
2
2
  export { Builder } from './Builder'
3
- export type { ModelBuilder, ModelHelpers } from './Builder.model'
4
- export type { ViewBuilder, ViewHelpers } from './Builder.view'
5
- export type { ViewsBuilder } from './Builder.views'
3
+ export type * from './Builder.deployment'
4
+ export type * from './Builder.deploymentModel'
5
+ export type * from './Builder.element'
6
+ export type * from './Builder.model'
7
+ export type * from './Builder.view-common'
8
+ export type * from './Builder.view-deployment'
9
+ export type * from './Builder.view-element'
10
+ export type * from './Builder.views'
11
+ export type * from './Builder.with'
@@ -3,12 +3,12 @@ import type { HexColorLiteral, LikeC4Theme, ThemeColorValues } from '../types/th
3
3
  import { ElementColors } from './element'
4
4
  import { RelationshipColors } from './relationships'
5
5
 
6
- export const defaultTheme = {
6
+ export const defaultTheme: LikeC4Theme = {
7
7
  elements: ElementColors,
8
8
  relationships: RelationshipColors,
9
9
  font: 'Arial',
10
10
  shadow: '#0a0a0a'
11
- } satisfies LikeC4Theme
11
+ }
12
12
 
13
13
  export function computeColorValues(color: HexColorLiteral): ThemeColorValues {
14
14
  if (color.match(/^#([0-9a-f]{3}){1,2}$/i)) {