@likec4/core 1.18.0 → 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.
- package/LICENSE +1 -1
- package/dist/builder/index.d.mts +502 -0
- package/dist/builder/index.d.ts +502 -0
- package/dist/builder/index.js +871 -0
- package/dist/compute-view/index.d.mts +9 -78
- package/dist/compute-view/index.d.ts +9 -78
- package/dist/compute-view/index.js +78 -0
- package/dist/index.d.mts +9 -730
- package/dist/index.d.ts +9 -730
- package/dist/{index.mjs → index.js} +7 -784
- package/dist/model/index.d.mts +218 -606
- package/dist/model/index.d.ts +218 -606
- package/dist/model/index.js +1 -0
- package/dist/shared/chunk-RAAYCPUM.M-JWF7SS.js +21 -0
- package/dist/shared/core.BIfgabEw.d.ts +719 -0
- package/dist/shared/core.BZ9Msq7w.d.mts +719 -0
- package/dist/shared/{core.DMYY7C8s.d.mts → core.C05RDLhi.d.ts} +179 -230
- package/dist/shared/{core.DMYY7C8s.d.ts → core.CmYMqgha.d.mts} +179 -230
- package/dist/shared/core.D6-fWbM3.d.ts +127 -0
- package/dist/shared/core.D74xkKkG.d.mts +148 -0
- package/dist/shared/core.D74xkKkG.d.ts +148 -0
- package/dist/shared/core.sLaWHBjR.d.mts +127 -0
- package/dist/shared/index.-BdzdI2C.js +7443 -0
- package/dist/shared/object_hash.CE_oF3I3.js +1222 -0
- package/dist/shared/view.CyZrG8BJ.js +354 -0
- package/dist/types/index.d.mts +4 -2
- package/dist/types/index.d.ts +4 -2
- package/dist/types/index.js +20 -0
- package/dist/utils/index.d.mts +404 -0
- package/dist/utils/index.d.ts +404 -0
- package/dist/utils/index.js +330 -0
- package/package.json +47 -33
- package/src/builder/Builder-style1.test-d.ts +190 -0
- package/src/builder/Builder-style2.test-d.ts +175 -0
- package/src/builder/Builder.deployment.ts +25 -20
- package/src/builder/Builder.deploymentModel.ts +80 -55
- package/src/builder/Builder.element.ts +2 -0
- package/src/builder/Builder.model.ts +57 -43
- package/src/builder/Builder.ts +412 -431
- package/src/builder/Builder.view-common.ts +234 -0
- package/src/builder/Builder.view-deployment.ts +135 -0
- package/src/builder/Builder.view-element.ts +189 -0
- package/src/builder/Builder.views.ts +109 -33
- package/src/builder/Builder.with.ts +475 -0
- package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +374 -0
- package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +183 -0
- package/src/builder/__snapshots__/Builder.spec.ts.snap +374 -0
- package/src/builder/_types.ts +28 -5
- package/src/builder/index.ts +10 -4
- package/src/colors/index.ts +2 -2
- package/src/compute-view/compute-view.ts +45 -54
- package/src/compute-view/deployment-view/__test__/TestHelper.ts +236 -0
- package/src/compute-view/deployment-view/__test__/fixture.ts +50 -62
- package/src/compute-view/deployment-view/_types.ts +26 -18
- package/src/compute-view/deployment-view/clean-connections.ts +173 -164
- package/src/compute-view/deployment-view/compute.ts +51 -37
- package/src/compute-view/deployment-view/memory/index.ts +9 -0
- package/src/compute-view/deployment-view/memory/memory.ts +97 -0
- package/src/compute-view/deployment-view/predicates/elements.ts +144 -0
- package/src/compute-view/deployment-view/predicates/relation-direct.ts +183 -76
- package/src/compute-view/deployment-view/predicates/relation-in-out.ts +38 -20
- package/src/compute-view/deployment-view/predicates/relation-incoming.ts +72 -23
- package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +61 -22
- package/src/compute-view/deployment-view/predicates/wildcard.ts +15 -15
- package/src/compute-view/deployment-view/stages/stage-exclude.ts +5 -0
- package/src/compute-view/deployment-view/stages/stage-final.ts +245 -0
- package/src/compute-view/deployment-view/stages/stage-include.ts +95 -0
- package/src/compute-view/deployment-view/utils.ts +95 -31
- package/src/compute-view/dynamic-view/__test__/fixture.ts +4 -4
- package/src/compute-view/dynamic-view/compute.ts +59 -45
- package/src/compute-view/element-view/__test__/TestHelper.ts +258 -0
- package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +64 -62
- package/src/compute-view/element-view/__test__/fixture.ts +147 -117
- package/src/compute-view/element-view/_types.ts +48 -0
- package/src/compute-view/element-view/clean-connections.ts +113 -0
- package/src/compute-view/element-view/compute.ts +264 -683
- package/src/compute-view/element-view/memory/NodeGroup.ts +31 -0
- package/src/compute-view/element-view/memory/index.ts +10 -0
- package/src/compute-view/element-view/memory/memory.ts +177 -0
- package/src/compute-view/element-view/memory/stage-exclude.ts +59 -0
- package/src/compute-view/element-view/memory/stage-final.ts +129 -0
- package/src/compute-view/element-view/memory/stage-include.ts +128 -0
- package/src/compute-view/element-view/predicates/_utils.ts +86 -0
- package/src/compute-view/element-view/predicates/element-expand.ts +33 -0
- package/src/compute-view/element-view/predicates/element-kind-tag.ts +26 -0
- package/src/compute-view/element-view/predicates/element-ref.ts +37 -0
- package/src/compute-view/element-view/predicates/relation-direct.ts +309 -0
- package/src/compute-view/element-view/predicates/relation-in-out.ts +66 -0
- package/src/compute-view/element-view/predicates/relation-in.ts +118 -0
- package/src/compute-view/element-view/predicates/relation-out.ts +116 -0
- package/src/compute-view/element-view/predicates/wildcard.ts +88 -0
- package/src/compute-view/element-view/utils.ts +59 -0
- package/src/compute-view/index.ts +3 -4
- package/src/compute-view/memory/AbstractMemory.ts +45 -0
- package/src/compute-view/memory/AbstractStageExclude.ts +216 -0
- package/src/compute-view/memory/AbstractStageInclude.ts +200 -0
- package/src/compute-view/memory/_types.ts +147 -0
- package/src/compute-view/memory/index.ts +5 -0
- package/src/compute-view/memory/ops.ts +43 -0
- package/src/compute-view/utils/buildComputedNodes.ts +4 -4
- package/src/compute-view/utils/elementExpressionToPredicate.ts +1 -3
- package/src/compute-view/utils/link-nodes-with-edges.ts +3 -7
- package/src/compute-view/utils/{derive-edge-props-from-relationships.ts → merge-props-from-relationships.ts} +54 -23
- package/src/compute-view/utils/relationExpressionToPredicates.ts +2 -2
- package/src/compute-view/utils/resolve-extended-views.ts +44 -40
- package/src/compute-view/utils/resolve-global-rules.ts +6 -6
- package/src/compute-view/utils/topological-sort.ts +167 -71
- package/src/compute-view/utils/with-readable-edges.ts +14 -9
- package/src/index.ts +22 -16
- package/src/model/DeploymentElementModel.ts +150 -85
- package/src/model/DeploymentModel.ts +27 -21
- package/src/model/ElementModel.ts +51 -25
- package/src/model/LikeC4Model.test-d.ts +4 -3
- package/src/model/LikeC4Model.ts +98 -42
- package/src/model/RelationModel.ts +5 -4
- package/src/model/__test__/fixture.ts +5 -9
- package/src/model/connection/Connection.ts +72 -0
- package/src/model/connection/deployment/DeploymentConnectionModel.ts +178 -0
- package/src/model/connection/{deployment.ts → deployment/find.ts} +14 -18
- package/src/model/connection/deployment/index.ts +8 -0
- package/src/model/connection/index.ts +22 -0
- package/src/model/connection/model/ConnectionModel.ts +157 -0
- package/src/model/connection/{model.ts → model/find.ts} +43 -49
- package/src/model/connection/model/index.ts +8 -0
- package/src/model/connection/ops.ts +274 -0
- package/src/model/guards.ts +9 -0
- package/src/model/index.ts +45 -3
- package/src/model/types.ts +35 -18
- package/src/model/view/EdgeModel.ts +6 -6
- package/src/model/view/LikeC4ViewModel.ts +14 -8
- package/src/model/view/NodeModel.ts +6 -5
- package/src/types/_common.ts +53 -1
- package/src/types/deployments.ts +88 -156
- package/src/types/element.ts +2 -2
- package/src/types/expression-v2.ts +172 -0
- package/src/types/expression.ts +9 -5
- package/src/types/global.ts +3 -3
- package/src/types/index.ts +220 -13
- package/src/types/model.ts +28 -24
- package/src/types/operators.ts +1 -1
- package/src/types/relation.ts +14 -10
- package/src/types/theme.ts +0 -1
- package/src/types/view.ts +20 -18
- package/src/utils/const.ts +1 -0
- package/src/utils/fqn.ts +140 -49
- package/src/utils/getOrCreate.ts +1 -1
- package/src/utils/index.ts +74 -9
- package/src/utils/iterable/_types.ts +5 -0
- package/src/utils/iterable/filter.ts +55 -0
- package/src/utils/iterable/flat.ts +17 -0
- package/src/utils/iterable/index.ts +12 -0
- package/src/utils/iterable/map.ts +40 -0
- package/src/utils/iterable/reduce.ts +24 -0
- package/src/utils/iterable/some.ts +36 -0
- package/src/utils/iterable/to.ts +19 -0
- package/src/utils/iterable/unique.ts +29 -0
- package/src/utils/relations.ts +3 -64
- package/src/utils/set.ts +11 -9
- package/src/utils/string-hash.ts +1 -1
- package/dist/compute-view/index.mjs +0 -79
- package/dist/model/index.mjs +0 -2
- package/dist/shared/core.BBgiAAv1.mjs +0 -144
- package/dist/shared/core.BPyJvuMU.mjs +0 -2420
- package/dist/shared/core.BQ4AbfvB.mjs +0 -9228
- package/dist/shared/core.k12s_keD.mjs +0 -203
- package/dist/types/index.mjs +0 -21
- package/src/builder/Builder.test-d.ts +0 -124
- package/src/builder/Builder.view.ts +0 -543
- package/src/compute-view/LikeC4ModelGraph.ts +0 -330
- package/src/compute-view/deployment-view/Memory.ts +0 -108
- package/src/compute-view/deployment-view/Stage.ts +0 -145
- package/src/compute-view/deployment-view/predicates/deployment-ref.ts +0 -146
- package/src/compute-view/element-view/predicates.ts +0 -517
- package/src/compute-view/utils/sortNodes.ts +0 -101
- package/src/model/connection/ConnectionModel.ts +0 -94
- package/src/model/connection/DeploymentConnectionModel.ts +0 -99
|
@@ -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
|
+
`;
|
package/src/builder/_types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
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,
|
|
@@ -10,8 +11,11 @@ import type {
|
|
|
10
11
|
ParsedLikeC4Model,
|
|
11
12
|
RelationshipArrowType,
|
|
12
13
|
RelationshipKindSpecification,
|
|
13
|
-
RelationshipLineType
|
|
14
|
+
RelationshipLineType,
|
|
14
15
|
} from '../types'
|
|
16
|
+
import type { ExpressionV2 } from '../types/expression-v2'
|
|
17
|
+
import type { Builder } from './Builder'
|
|
18
|
+
import type { DeploymentRulesBuilderOp } from './Builder.view-deployment'
|
|
15
19
|
|
|
16
20
|
export type BuilderSpecification = {
|
|
17
21
|
elements: {
|
|
@@ -88,6 +92,12 @@ export type Invalid<Message extends string> = Tagged<Message, 'Error'>
|
|
|
88
92
|
export type Warn<Id, Existing> = IsLiteral<Existing> extends true ? Id extends Existing ? Invalid<'Already exists'> : Id
|
|
89
93
|
: Id
|
|
90
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
|
+
|
|
91
101
|
/**
|
|
92
102
|
* Auxilary type to keep track of the types in builder
|
|
93
103
|
*/
|
|
@@ -99,7 +109,7 @@ export interface Types<
|
|
|
99
109
|
Tag extends string,
|
|
100
110
|
MetadataKey extends string,
|
|
101
111
|
DeploymentKind extends string,
|
|
102
|
-
DeploymentFqn extends string
|
|
112
|
+
DeploymentFqn extends string,
|
|
103
113
|
> {
|
|
104
114
|
ElementKind: ElementKind
|
|
105
115
|
Fqn: Fqn
|
|
@@ -132,7 +142,7 @@ export interface TypesNested<
|
|
|
132
142
|
Tag extends string,
|
|
133
143
|
MetadataKey extends string,
|
|
134
144
|
DeploymentKind extends string,
|
|
135
|
-
DeploymentFqn extends string
|
|
145
|
+
DeploymentFqn extends string,
|
|
136
146
|
> extends
|
|
137
147
|
Types<
|
|
138
148
|
ElementKind,
|
|
@@ -261,7 +271,20 @@ export namespace Types {
|
|
|
261
271
|
T['RelationshipKind'],
|
|
262
272
|
T['Tag'],
|
|
263
273
|
T['Fqn'],
|
|
264
|
-
T['ViewId']
|
|
274
|
+
T['ViewId'],
|
|
275
|
+
T['DeploymentFqn']
|
|
265
276
|
>
|
|
266
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>>
|
|
267
290
|
}
|
package/src/builder/index.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type * from './_types'
|
|
2
2
|
export { Builder } from './Builder'
|
|
3
|
-
export type
|
|
4
|
-
export type
|
|
5
|
-
export type
|
|
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'
|
package/src/colors/index.ts
CHANGED
|
@@ -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
|
-
}
|
|
11
|
+
}
|
|
12
12
|
|
|
13
13
|
export function computeColorValues(color: HexColorLiteral): ThemeColorValues {
|
|
14
14
|
if (color.match(/^#([0-9a-f]{3}){1,2}$/i)) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { mapValues } from 'remeda'
|
|
2
|
-
import type { SetOptional } from 'type-fest'
|
|
3
2
|
import { nonexhaustive } from '../errors'
|
|
4
3
|
import { LikeC4Model } from '../model'
|
|
5
4
|
import {
|
|
6
|
-
type
|
|
5
|
+
type ComputedLikeC4Model,
|
|
7
6
|
type ComputedView,
|
|
8
7
|
isDeploymentView,
|
|
9
8
|
isDynamicView,
|
|
@@ -12,11 +11,10 @@ import {
|
|
|
12
11
|
type ParsedLikeC4Model
|
|
13
12
|
} from '../types'
|
|
14
13
|
import { computeDeploymentView } from './deployment-view/compute'
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { LikeC4ModelGraph } from './LikeC4ModelGraph'
|
|
14
|
+
import { computeDynamicView } from './dynamic-view/compute'
|
|
15
|
+
import { computeElementView } from './element-view/compute'
|
|
18
16
|
|
|
19
|
-
type ComputeViewResult<V extends ComputedView = ComputedView> =
|
|
17
|
+
export type ComputeViewResult<V extends ComputedView = ComputedView> =
|
|
20
18
|
| {
|
|
21
19
|
isSuccess: true
|
|
22
20
|
error?: undefined
|
|
@@ -28,56 +26,49 @@ type ComputeViewResult<V extends ComputedView = ComputedView> =
|
|
|
28
26
|
view: undefined
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
isSuccess: true,
|
|
48
|
-
view: computeDeploymentView(likec4model, viewsource)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
case isDynamicView(viewsource):
|
|
52
|
-
return {
|
|
53
|
-
isSuccess: true,
|
|
54
|
-
view: DynamicViewComputeCtx.compute(viewsource, index)
|
|
55
|
-
}
|
|
56
|
-
case isElementView(viewsource):
|
|
57
|
-
return {
|
|
58
|
-
isSuccess: true,
|
|
59
|
-
view: ComputeCtx.elementView(viewsource, index)
|
|
60
|
-
}
|
|
29
|
+
export function unsafeComputeView(
|
|
30
|
+
viewsource: LikeC4View,
|
|
31
|
+
likec4model: LikeC4Model
|
|
32
|
+
): ComputedView {
|
|
33
|
+
switch (true) {
|
|
34
|
+
case isDeploymentView(viewsource): {
|
|
35
|
+
return computeDeploymentView(likec4model, viewsource)
|
|
36
|
+
}
|
|
37
|
+
case isDynamicView(viewsource):
|
|
38
|
+
return computeDynamicView(likec4model, viewsource)
|
|
39
|
+
case isElementView(viewsource):
|
|
40
|
+
return computeElementView(likec4model, viewsource)
|
|
41
|
+
default:
|
|
42
|
+
nonexhaustive(viewsource)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
61
45
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
46
|
+
export function computeView<V extends LikeC4View>(
|
|
47
|
+
viewsource: V,
|
|
48
|
+
likec4model: LikeC4Model
|
|
49
|
+
): ComputeViewResult {
|
|
50
|
+
try {
|
|
51
|
+
return {
|
|
52
|
+
isSuccess: true,
|
|
53
|
+
view: unsafeComputeView(viewsource, likec4model)
|
|
54
|
+
}
|
|
55
|
+
} catch (e) {
|
|
56
|
+
return {
|
|
57
|
+
isSuccess: false,
|
|
58
|
+
error: e instanceof Error ? e : new Error(`Unknown error: ${e}`),
|
|
59
|
+
view: undefined
|
|
71
60
|
}
|
|
72
61
|
}
|
|
73
62
|
}
|
|
74
63
|
|
|
75
|
-
export function computeViews<
|
|
76
|
-
parsed
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
64
|
+
export function computeViews<P extends ParsedLikeC4Model>(parsed: P): ComputedLikeC4Model {
|
|
65
|
+
const { views, ...rest } = parsed as Omit<P, '__'>
|
|
66
|
+
const likec4model = LikeC4Model.create({
|
|
67
|
+
...rest,
|
|
68
|
+
views: {}
|
|
69
|
+
})
|
|
70
|
+
const compute = (source: LikeC4View): ComputedView => {
|
|
71
|
+
const result = computeView(source, likec4model)
|
|
81
72
|
if (result.isSuccess) {
|
|
82
73
|
return result.view
|
|
83
74
|
} else {
|
|
@@ -85,8 +76,8 @@ export function computeViews<const P extends ParsedLikeC4Model<any, any, any, an
|
|
|
85
76
|
}
|
|
86
77
|
}
|
|
87
78
|
return {
|
|
79
|
+
...rest,
|
|
88
80
|
__: 'computed',
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
} as any // TODO: fix this
|
|
81
|
+
views: mapValues(parsed.views, compute)
|
|
82
|
+
}
|
|
92
83
|
}
|