@likec4/core 1.47.0 → 1.49.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/THIRD-PARTY-LICENSES.md +1012 -0
- package/dist/_chunks/Builder.view-element.mjs +2 -0
- package/dist/_chunks/LikeC4Model.d.mts +1283 -0
- package/dist/_chunks/RichText.mjs +1 -0
- package/dist/_chunks/_types.d.mts +777 -0
- package/dist/_chunks/_types2.d.mts +36 -0
- package/dist/_chunks/assignTagColors.mjs +1 -0
- package/dist/_chunks/calcDriftsFromSnapshot.mjs +1 -0
- package/dist/_chunks/guards.d.mts +2026 -0
- package/dist/_chunks/guards.mjs +4 -0
- package/dist/_chunks/index.d.mts +288 -0
- package/dist/_chunks/libs/@mantine/colors-generator.mjs +15 -0
- package/dist/_chunks/libs/@radix-ui/colors.mjs +1 -0
- package/dist/_chunks/libs/@ungap/structured-clone.mjs +1 -0
- package/dist/_chunks/libs/bail.mjs +1 -0
- package/dist/_chunks/libs/ccount.mjs +1 -0
- package/dist/_chunks/libs/character-entities-html4.mjs +1 -0
- package/dist/_chunks/libs/character-entities-legacy.mjs +1 -0
- package/dist/_chunks/libs/character-entities.mjs +2 -0
- package/dist/_chunks/libs/comma-separated-tokens.mjs +1 -0
- package/dist/_chunks/libs/decode-named-character-reference.mjs +1 -0
- package/dist/_chunks/libs/defu.mjs +1 -0
- package/dist/_chunks/libs/devlop.mjs +1 -0
- package/dist/_chunks/libs/escape-string-regexp.mjs +1 -0
- package/dist/_chunks/libs/extend.mjs +1 -0
- package/dist/_chunks/libs/graphology-dag.mjs +1 -0
- package/dist/_chunks/libs/graphology.mjs +1 -0
- package/dist/_chunks/libs/hast-util-sanitize.mjs +1 -0
- package/dist/_chunks/libs/hast-util-to-html.mjs +9 -0
- package/dist/_chunks/libs/is-plain-obj.mjs +1 -0
- package/dist/_chunks/libs/longest-streak.mjs +1 -0
- package/dist/_chunks/libs/markdown-table.mjs +2 -0
- package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +1 -0
- package/dist/_chunks/libs/mdast-util-from-markdown.mjs +3 -0
- package/dist/_chunks/libs/mdast-util-gfm.mjs +15 -0
- package/dist/_chunks/libs/mdast-util-to-hast.mjs +11 -0
- package/dist/_chunks/libs/micromark-extension-gfm.mjs +1 -0
- package/dist/_chunks/libs/mnemonist.d.mts +164 -0
- package/dist/_chunks/libs/mnemonist.mjs +1 -0
- package/dist/_chunks/libs/natural-compare-lite.mjs +9 -0
- package/dist/_chunks/libs/ohash.mjs +1 -0
- package/dist/_chunks/libs/rehype-sanitize.mjs +1 -0
- package/dist/_chunks/libs/rehype-stringify.mjs +1 -0
- package/dist/_chunks/libs/remark-gfm.mjs +1 -0
- package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +3 -0
- package/dist/_chunks/libs/remark-parse.mjs +1 -0
- package/dist/_chunks/libs/remark-rehype.mjs +1 -0
- package/dist/_chunks/libs/remeda.mjs +1 -0
- package/dist/_chunks/libs/trough.mjs +1 -0
- package/dist/_chunks/libs/unified.mjs +1 -0
- package/dist/_chunks/rolldown-runtime.mjs +1 -0
- package/dist/_chunks/theme.d.mts +148 -0
- package/dist/_chunks/to-text.d.mts +404 -0
- package/dist/_chunks/to-text.mjs +1 -0
- package/dist/_chunks/vector.d.mts +198 -0
- package/dist/_chunks/vector.mjs +1 -0
- package/dist/builder/index.d.mts +5 -775
- package/dist/builder/index.mjs +1 -1053
- package/dist/compute-view/index.d.mts +156 -56
- package/dist/compute-view/index.mjs +2 -229
- package/dist/geometry/index.d.mts +2 -109
- package/dist/geometry/index.mjs +1 -328
- package/dist/index.d.mts +14 -20
- package/dist/index.mjs +1 -18
- package/dist/model/index.d.mts +5 -57
- package/dist/model/index.mjs +1 -4
- package/dist/styles/index.d.mts +3 -117
- package/dist/styles/index.mjs +1 -63
- package/dist/types/index.d.mts +3 -47
- package/dist/types/index.mjs +1 -17
- package/dist/utils/graphology/index.d.mts +2 -1864
- package/dist/utils/graphology/index.mjs +1 -1
- package/dist/utils/index.d.mts +4 -124
- package/dist/utils/index.mjs +1 -44
- package/package.json +20 -24
- package/compute-view/relationships/package.json +0 -4
- package/dist/compute-view/relationships-view/index.d.mts +0 -51
- package/dist/compute-view/relationships-view/index.mjs +0 -185
- package/dist/model/connection/deployment/index.d.mts +0 -15
- package/dist/model/connection/deployment/index.mjs +0 -2
- package/dist/model/connection/index.d.mts +0 -75
- package/dist/model/connection/index.mjs +0 -3
- package/dist/model/connection/model/index.d.mts +0 -15
- package/dist/model/connection/model/index.mjs +0 -2
- package/dist/shared/core.3ZhnKAlZ.mjs +0 -106
- package/dist/shared/core.78IWAHAE.mjs +0 -332
- package/dist/shared/core.B85MJLTf.mjs +0 -5
- package/dist/shared/core.BFd1lU9R.mjs +0 -29
- package/dist/shared/core.BKlholso.mjs +0 -3
- package/dist/shared/core.BNN-3vPH.mjs +0 -1255
- package/dist/shared/core.BPGOjone.d.mts +0 -46
- package/dist/shared/core.BP_QHEXs.mjs +0 -785
- package/dist/shared/core.BbE4y-yl.mjs +0 -177
- package/dist/shared/core.Bdy3hhTc.mjs +0 -28382
- package/dist/shared/core.BfCKSW-g.d.mts +0 -1266
- package/dist/shared/core.BhNcrwzK.mjs +0 -7
- package/dist/shared/core.BkVA6gjl.mjs +0 -5
- package/dist/shared/core.BoYfZOBm.mjs +0 -3
- package/dist/shared/core.BsSXS-_R.mjs +0 -7
- package/dist/shared/core.C3JowhaZ.mjs +0 -32
- package/dist/shared/core.C4x8aaWa.mjs +0 -27
- package/dist/shared/core.CAgYpDtM.d.mts +0 -98
- package/dist/shared/core.CHf8VEa3.mjs +0 -1206
- package/dist/shared/core.CLSZtnFh.mjs +0 -69
- package/dist/shared/core.C_3y3eqV.d.mts +0 -139
- package/dist/shared/core.CbT8JVYL.mjs +0 -5
- package/dist/shared/core.CdNCAwq7.mjs +0 -176
- package/dist/shared/core.CmGY9blO.mjs +0 -6717
- package/dist/shared/core.CmPXpJ8l.mjs +0 -21
- package/dist/shared/core.Coi_LOUZ.mjs +0 -7
- package/dist/shared/core.CqAJJpK_.mjs +0 -3
- package/dist/shared/core.CywrQs86.d.mts +0 -31
- package/dist/shared/core.D00YbOhQ.d.mts +0 -300
- package/dist/shared/core.D0WZutNd.mjs +0 -94
- package/dist/shared/core.D4npX2q8.mjs +0 -18
- package/dist/shared/core.DB0Ue5Wx.d.mts +0 -70
- package/dist/shared/core.DC5IAaDT.d.mts +0 -334
- package/dist/shared/core.DE9qzhn8.d.mts +0 -83
- package/dist/shared/core.DGcIbsj4.mjs +0 -3946
- package/dist/shared/core.DH7TXqXf.mjs +0 -136
- package/dist/shared/core.DKhRkHRN.d.mts +0 -41
- package/dist/shared/core.DRJma0Ol.mjs +0 -22
- package/dist/shared/core.DU5SRqNF.mjs +0 -2209
- package/dist/shared/core.DXhDWKFZ.d.mts +0 -3
- package/dist/shared/core.DbfO90vF.mjs +0 -434
- package/dist/shared/core.DcS-0zys.mjs +0 -10
- package/dist/shared/core.Dh119QSP.mjs +0 -4995
- package/dist/shared/core.DjcWextK.mjs +0 -1371
- package/dist/shared/core.Dojz4bvg.d.mts +0 -504
- package/dist/shared/core.FZ305VYd.mjs +0 -21
- package/dist/shared/core.OtRNdMxy.d.mts +0 -352
- package/dist/shared/core.RfnaEmgA.mjs +0 -7
- package/dist/shared/core.btEq3i3f.mjs +0 -300
- package/dist/shared/core.oSV6SRfk.mjs +0 -13
- package/dist/shared/core.om36dXXW.mjs +0 -41
- package/dist/shared/core.osFs8tU7.d.mts +0 -466
- package/dist/shared/core.q10OP9oJ.mjs +0 -5
- package/dist/shared/core.tpvDGvdC.d.mts +0 -87
- package/dist/shared/core.uFk_o9X6.mjs +0 -13
- package/dist/types/_aux.d.mts +0 -4
- package/dist/types/_aux.mjs +0 -8
- package/dist/types/expression-model.d.mts +0 -190
- package/dist/types/expression-model.mjs +0 -109
- package/dist/types/expression.d.mts +0 -6
- package/dist/types/expression.mjs +0 -113
- package/dist/types/fqnRef.d.mts +0 -60
- package/dist/types/fqnRef.mjs +0 -45
- package/dist/types/scalar.d.mts +0 -2
- package/dist/types/scalar.mjs +0 -4
- package/dist/utils/iterable/index.d.mts +0 -132
- package/dist/utils/iterable/index.mjs +0 -62
package/dist/builder/index.mjs
CHANGED
|
@@ -1,1053 +1 @@
|
|
|
1
|
-
import { d as defu } from '../shared/core.CLSZtnFh.mjs';
|
|
2
|
-
import { t as t$4 } from '../shared/core.3ZhnKAlZ.mjs';
|
|
3
|
-
import { t as t$1, a as t$8 } from '../shared/core.BsSXS-_R.mjs';
|
|
4
|
-
import { t as t$6 } from '../shared/core.Coi_LOUZ.mjs';
|
|
5
|
-
import { t as t$3, n } from '../shared/core.DjcWextK.mjs';
|
|
6
|
-
import { t as t$7 } from '../shared/core.DGcIbsj4.mjs';
|
|
7
|
-
import { k as e } from '../shared/core.om36dXXW.mjs';
|
|
8
|
-
import { e as e$3 } from '../shared/core.DRJma0Ol.mjs';
|
|
9
|
-
import { a as _type, u as e$2, _ as _stage, d as isDeployedInstance, p as isElementView } from '../shared/core.DH7TXqXf.mjs';
|
|
10
|
-
import { t as t$2 } from '../shared/core.CbT8JVYL.mjs';
|
|
11
|
-
import { a as t$5, d as computeLikeC4Model } from '../shared/core.Dh119QSP.mjs';
|
|
12
|
-
import { assignTagColors } from '../styles/index.mjs';
|
|
13
|
-
import { n as nameFromFqn, d as isSameHierarchy, p as parentFqn } from '../shared/core.CdNCAwq7.mjs';
|
|
14
|
-
import { e as e$1 } from '../shared/core.CqAJJpK_.mjs';
|
|
15
|
-
import { ModelFqnExpr } from '../types/expression-model.mjs';
|
|
16
|
-
import { D as DefaultMap } from '../shared/core.BbE4y-yl.mjs';
|
|
17
|
-
import { i as invariant } from '../shared/core.D4npX2q8.mjs';
|
|
18
|
-
import { e as exact } from '../shared/core.CHf8VEa3.mjs';
|
|
19
|
-
import { FqnRef } from '../types/fqnRef.mjs';
|
|
20
|
-
import { b as isGlobalFqn, c as splitGlobalFqn } from '../shared/core.D0WZutNd.mjs';
|
|
21
|
-
|
|
22
|
-
function t(...t){return t$1(Object.fromEntries,t)}
|
|
23
|
-
|
|
24
|
-
function parseWhere(where) {
|
|
25
|
-
if (e$1(where)) {
|
|
26
|
-
const op = where;
|
|
27
|
-
switch (true) {
|
|
28
|
-
case op.startsWith("tag is not #"):
|
|
29
|
-
return {
|
|
30
|
-
tag: {
|
|
31
|
-
neq: op.replace("tag is not #", "")
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
case op.startsWith("tag is #"):
|
|
35
|
-
return {
|
|
36
|
-
tag: {
|
|
37
|
-
eq: op.replace("tag is #", "")
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
case op.startsWith("kind is not "):
|
|
41
|
-
return {
|
|
42
|
-
kind: {
|
|
43
|
-
neq: op.replace("kind is not ", "")
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
case op.startsWith("kind is "):
|
|
47
|
-
return {
|
|
48
|
-
kind: {
|
|
49
|
-
eq: op.replace("kind is ", "")
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
case op.startsWith("source."):
|
|
53
|
-
return {
|
|
54
|
-
operator: parseWhere(
|
|
55
|
-
op.replace("source.", "")
|
|
56
|
-
),
|
|
57
|
-
participant: "source"
|
|
58
|
-
};
|
|
59
|
-
case op.startsWith("target."):
|
|
60
|
-
return {
|
|
61
|
-
operator: parseWhere(
|
|
62
|
-
op.replace("target.", "")
|
|
63
|
-
),
|
|
64
|
-
participant: "target"
|
|
65
|
-
};
|
|
66
|
-
default:
|
|
67
|
-
throw new Error(`Unknown where operator: ${where}`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
if (where.and) {
|
|
71
|
-
return {
|
|
72
|
-
and: t$2(where.and, parseWhere)
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
if (where.or) {
|
|
76
|
-
return {
|
|
77
|
-
or: t$2(where.or, parseWhere)
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
if (where.not) {
|
|
81
|
-
return {
|
|
82
|
-
not: parseWhere(where.not)
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
throw new Error(`Unknown where operator: ${where}`);
|
|
86
|
-
}
|
|
87
|
-
function $include(...args) {
|
|
88
|
-
return (b) => {
|
|
89
|
-
let expr = b.$expr(args[0]);
|
|
90
|
-
if (args.length === 2) {
|
|
91
|
-
const condition = args[1].where ? parseWhere(args[1].where) : void 0;
|
|
92
|
-
if (condition) {
|
|
93
|
-
expr = {
|
|
94
|
-
where: {
|
|
95
|
-
expr,
|
|
96
|
-
condition
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
const custom = args[1].with;
|
|
101
|
-
if (custom) {
|
|
102
|
-
const isElement = ModelFqnExpr.is(expr);
|
|
103
|
-
if (isElement) {
|
|
104
|
-
expr = {
|
|
105
|
-
custom: {
|
|
106
|
-
...custom,
|
|
107
|
-
expr
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
} else {
|
|
111
|
-
expr = {
|
|
112
|
-
customRelation: {
|
|
113
|
-
...custom,
|
|
114
|
-
expr
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
b.include(expr);
|
|
121
|
-
return b;
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
function $exclude(...args) {
|
|
125
|
-
return (b) => {
|
|
126
|
-
let expr = b.$expr(args[0]);
|
|
127
|
-
if (args.length === 2 && args[1].where) {
|
|
128
|
-
const condition = parseWhere(args[1].where);
|
|
129
|
-
expr = {
|
|
130
|
-
where: {
|
|
131
|
-
expr,
|
|
132
|
-
condition
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
b.exclude(expr);
|
|
137
|
-
return b;
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
function $style(element, { notation, ...style }) {
|
|
141
|
-
return (b) => b.style({
|
|
142
|
-
targets: (e(element) ? element : [element]).map((e) => b.$expr(e)),
|
|
143
|
-
...notation ? { notation } : {},
|
|
144
|
-
style: {
|
|
145
|
-
...style
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
function $autoLayout(layout) {
|
|
150
|
-
return (b) => b.autoLayout(layout);
|
|
151
|
-
}
|
|
152
|
-
function $rules(...rules) {
|
|
153
|
-
return (b) => rules.reduce((b2, rule) => rule(b2), b);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function $deploymentExpr(expr) {
|
|
157
|
-
if (!e$1(expr)) {
|
|
158
|
-
return expr;
|
|
159
|
-
}
|
|
160
|
-
const asTypedDeploymentExpression = (expr2) => {
|
|
161
|
-
return expr2;
|
|
162
|
-
};
|
|
163
|
-
if (expr === "*") {
|
|
164
|
-
return asTypedDeploymentExpression({ wildcard: true });
|
|
165
|
-
}
|
|
166
|
-
if (expr.startsWith("->")) {
|
|
167
|
-
if (expr.endsWith("->")) {
|
|
168
|
-
return asTypedDeploymentExpression({
|
|
169
|
-
inout: $deploymentExpr(expr.replace(/->/g, "").trim())
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
return asTypedDeploymentExpression({
|
|
173
|
-
incoming: $deploymentExpr(expr.replace("-> ", ""))
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
if (expr.endsWith(" ->")) {
|
|
177
|
-
return asTypedDeploymentExpression({
|
|
178
|
-
outgoing: $deploymentExpr(expr.replace(" ->", ""))
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
if (expr.includes(" <-> ")) {
|
|
182
|
-
const [source, target] = expr.split(" <-> ");
|
|
183
|
-
return asTypedDeploymentExpression({
|
|
184
|
-
source: $deploymentExpr(source),
|
|
185
|
-
target: $deploymentExpr(target),
|
|
186
|
-
isBidirectional: true
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
if (expr.includes(" -> ")) {
|
|
190
|
-
const [source, target] = expr.split(" -> ");
|
|
191
|
-
return asTypedDeploymentExpression({
|
|
192
|
-
source: $deploymentExpr(source),
|
|
193
|
-
target: $deploymentExpr(target)
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
if (expr.endsWith("._")) {
|
|
197
|
-
return asTypedDeploymentExpression({
|
|
198
|
-
ref: {
|
|
199
|
-
deployment: expr.replace("._", "")
|
|
200
|
-
},
|
|
201
|
-
selector: "expanded"
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
if (expr.endsWith(".**")) {
|
|
205
|
-
return asTypedDeploymentExpression({
|
|
206
|
-
ref: {
|
|
207
|
-
deployment: expr.replace(".**", "")
|
|
208
|
-
},
|
|
209
|
-
selector: "descendants"
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
if (expr.endsWith(".*")) {
|
|
213
|
-
return asTypedDeploymentExpression({
|
|
214
|
-
ref: {
|
|
215
|
-
deployment: expr.replace(".*", "")
|
|
216
|
-
},
|
|
217
|
-
selector: "children"
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
return asTypedDeploymentExpression({
|
|
221
|
-
ref: {
|
|
222
|
-
deployment: expr
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
const asTypedExpr = (expr) => {
|
|
228
|
-
return expr;
|
|
229
|
-
};
|
|
230
|
-
function $expr(expr) {
|
|
231
|
-
if (!e$1(expr)) {
|
|
232
|
-
return expr;
|
|
233
|
-
}
|
|
234
|
-
if (expr === "*") {
|
|
235
|
-
return asTypedExpr({ wildcard: true });
|
|
236
|
-
}
|
|
237
|
-
if (expr.startsWith("->")) {
|
|
238
|
-
if (expr.endsWith("->")) {
|
|
239
|
-
return asTypedExpr({
|
|
240
|
-
inout: $expr(expr.replace(/->/g, "").trim())
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
return asTypedExpr({
|
|
244
|
-
incoming: $expr(expr.replace("-> ", ""))
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
if (expr.endsWith(" ->")) {
|
|
248
|
-
return asTypedExpr({
|
|
249
|
-
outgoing: $expr(expr.replace(" ->", ""))
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
if (expr.includes(" <-> ")) {
|
|
253
|
-
const [source, target] = expr.split(" <-> ");
|
|
254
|
-
return asTypedExpr({
|
|
255
|
-
source: $expr(source),
|
|
256
|
-
target: $expr(target),
|
|
257
|
-
isBidirectional: true
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
if (expr.includes(" -> ")) {
|
|
261
|
-
const [source, target] = expr.split(" -> ");
|
|
262
|
-
return asTypedExpr({
|
|
263
|
-
source: $expr(source),
|
|
264
|
-
target: $expr(target)
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
if (expr.endsWith("._")) {
|
|
268
|
-
return asTypedExpr({
|
|
269
|
-
ref: {
|
|
270
|
-
model: expr.replace("._", "")
|
|
271
|
-
},
|
|
272
|
-
selector: "expanded"
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
if (expr.endsWith(".**")) {
|
|
276
|
-
return asTypedExpr({
|
|
277
|
-
ref: {
|
|
278
|
-
model: expr.replace(".**", "")
|
|
279
|
-
},
|
|
280
|
-
selector: "descendants"
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
if (expr.endsWith(".*")) {
|
|
284
|
-
return asTypedExpr({
|
|
285
|
-
ref: {
|
|
286
|
-
model: expr.replace(".*", "")
|
|
287
|
-
},
|
|
288
|
-
selector: "children"
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
return asTypedExpr({
|
|
292
|
-
ref: {
|
|
293
|
-
model: expr
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function mkViewBuilder(view) {
|
|
299
|
-
const viewBuilder = {
|
|
300
|
-
$expr: view[_type] === "deployment" ? $deploymentExpr : $expr,
|
|
301
|
-
autoLayout(autoLayout) {
|
|
302
|
-
view.rules.push({
|
|
303
|
-
direction: autoLayout
|
|
304
|
-
});
|
|
305
|
-
return viewBuilder;
|
|
306
|
-
},
|
|
307
|
-
exclude(expr) {
|
|
308
|
-
view.rules.push({
|
|
309
|
-
exclude: [expr]
|
|
310
|
-
});
|
|
311
|
-
return viewBuilder;
|
|
312
|
-
},
|
|
313
|
-
include(expr) {
|
|
314
|
-
view.rules.push({
|
|
315
|
-
include: [expr]
|
|
316
|
-
});
|
|
317
|
-
return viewBuilder;
|
|
318
|
-
},
|
|
319
|
-
style(rule) {
|
|
320
|
-
view.rules.push(rule);
|
|
321
|
-
return viewBuilder;
|
|
322
|
-
}
|
|
323
|
-
// title(title: string) {
|
|
324
|
-
// view.title = title
|
|
325
|
-
// return viewBuilder
|
|
326
|
-
// },
|
|
327
|
-
// description(description: string) {
|
|
328
|
-
// view.description = description
|
|
329
|
-
// return viewBuilder
|
|
330
|
-
// }
|
|
331
|
-
};
|
|
332
|
-
return viewBuilder;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
function ensureObj(value) {
|
|
336
|
-
return e(value) ? t$7(value, (_) => ({})) : value;
|
|
337
|
-
}
|
|
338
|
-
function validateSpec({ tags, elements, deployments, relationships, ...specification }) {
|
|
339
|
-
const spectags = {};
|
|
340
|
-
if (tags) {
|
|
341
|
-
Object.assign(
|
|
342
|
-
spectags,
|
|
343
|
-
ensureObj(tags)
|
|
344
|
-
);
|
|
345
|
-
}
|
|
346
|
-
const _elements = ensureObj(elements);
|
|
347
|
-
for (const [kind, spec] of t$6(_elements)) {
|
|
348
|
-
if (spec.tags) {
|
|
349
|
-
for (const tag of spec.tags) {
|
|
350
|
-
invariant(tag in spectags, `Invalid specification for element kind "${kind}": tag "${tag}" not found`);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
const _deployments = ensureObj(deployments ?? {});
|
|
355
|
-
for (const [kind, spec] of t$6(_deployments)) {
|
|
356
|
-
if (spec.tags) {
|
|
357
|
-
for (const tag of spec.tags) {
|
|
358
|
-
invariant(
|
|
359
|
-
tag in spectags,
|
|
360
|
-
`Invalid specification for deployment kind "${kind}": tag "${tag}" not found`
|
|
361
|
-
);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
return {
|
|
366
|
-
...specification,
|
|
367
|
-
tags: spectags,
|
|
368
|
-
elements: _elements,
|
|
369
|
-
deployments: _deployments,
|
|
370
|
-
relationships: ensureObj(relationships ?? {})
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
function toMarkdownOrString(input) {
|
|
374
|
-
if (e$2(input)) {
|
|
375
|
-
return null;
|
|
376
|
-
}
|
|
377
|
-
if (typeof input === "string") {
|
|
378
|
-
return { txt: input };
|
|
379
|
-
}
|
|
380
|
-
return input;
|
|
381
|
-
}
|
|
382
|
-
function builder(_spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _views = /* @__PURE__ */ new Map(), _globals = {
|
|
383
|
-
predicates: {},
|
|
384
|
-
dynamicPredicates: {},
|
|
385
|
-
styles: {}
|
|
386
|
-
}, _deployments = /* @__PURE__ */ new Map(), _deploymentRelations = [], _imports = new DefaultMap(() => /* @__PURE__ */ new Map())) {
|
|
387
|
-
const spec = validateSpec(_spec);
|
|
388
|
-
const toLikeC4Specification = () => {
|
|
389
|
-
return {
|
|
390
|
-
elements: structuredClone(spec.elements),
|
|
391
|
-
deployments: structuredClone(spec.deployments),
|
|
392
|
-
relationships: structuredClone(spec.relationships),
|
|
393
|
-
tags: assignTagColors(structuredClone(spec.tags)),
|
|
394
|
-
...spec.metadataKeys ? { metadataKeys: spec.metadataKeys } : {},
|
|
395
|
-
customColors: {}
|
|
396
|
-
};
|
|
397
|
-
};
|
|
398
|
-
const mapLinks = (links) => {
|
|
399
|
-
if (!links || !t$8(links, 1)) {
|
|
400
|
-
return void 0;
|
|
401
|
-
}
|
|
402
|
-
return t$2(links, (l) => typeof l === "string" ? { url: l } : l);
|
|
403
|
-
};
|
|
404
|
-
const createGenericView = (id, _props, builder2) => {
|
|
405
|
-
if (e$3(_props)) {
|
|
406
|
-
builder2 = _props;
|
|
407
|
-
_props = {};
|
|
408
|
-
}
|
|
409
|
-
_props ??= {};
|
|
410
|
-
const {
|
|
411
|
-
links: _links = [],
|
|
412
|
-
title = null,
|
|
413
|
-
description = null,
|
|
414
|
-
tags = [],
|
|
415
|
-
...props
|
|
416
|
-
} = typeof _props === "string" ? { title: _props } : { ..._props };
|
|
417
|
-
const links = mapLinks(_links);
|
|
418
|
-
return [
|
|
419
|
-
exact({
|
|
420
|
-
id,
|
|
421
|
-
title,
|
|
422
|
-
description: toMarkdownOrString(description),
|
|
423
|
-
tags,
|
|
424
|
-
links,
|
|
425
|
-
_stage: "parsed",
|
|
426
|
-
...props
|
|
427
|
-
}),
|
|
428
|
-
builder2
|
|
429
|
-
];
|
|
430
|
-
};
|
|
431
|
-
const checkElementExists = (id) => {
|
|
432
|
-
const [project, fqn] = splitGlobalFqn(id);
|
|
433
|
-
const lookup = project ? _imports.get(project) : _elements;
|
|
434
|
-
const el = lookup.get(fqn);
|
|
435
|
-
invariant(el, `Element with id "${id}" not found`);
|
|
436
|
-
return el;
|
|
437
|
-
};
|
|
438
|
-
const parseRelEndpoint = (endpoint) => {
|
|
439
|
-
if (typeof endpoint === "string") {
|
|
440
|
-
const [project, model] = splitGlobalFqn(endpoint);
|
|
441
|
-
if (project) {
|
|
442
|
-
return { project, model };
|
|
443
|
-
}
|
|
444
|
-
return { model };
|
|
445
|
-
}
|
|
446
|
-
if ("project" in endpoint || "deployment" in endpoint) {
|
|
447
|
-
return endpoint;
|
|
448
|
-
}
|
|
449
|
-
return parseRelEndpoint(endpoint.model);
|
|
450
|
-
};
|
|
451
|
-
const self = {
|
|
452
|
-
get Types() {
|
|
453
|
-
throw new Error("Types are not available in runtime");
|
|
454
|
-
},
|
|
455
|
-
clone: () => {
|
|
456
|
-
const imports = new DefaultMap(() => /* @__PURE__ */ new Map());
|
|
457
|
-
for (const [key, value] of _imports) {
|
|
458
|
-
imports.set(key, structuredClone(value));
|
|
459
|
-
}
|
|
460
|
-
return builder(
|
|
461
|
-
structuredClone(spec),
|
|
462
|
-
structuredClone(_elements),
|
|
463
|
-
structuredClone(_relations),
|
|
464
|
-
structuredClone(_views),
|
|
465
|
-
structuredClone(_globals),
|
|
466
|
-
structuredClone(_deployments),
|
|
467
|
-
structuredClone(_deploymentRelations),
|
|
468
|
-
imports
|
|
469
|
-
);
|
|
470
|
-
},
|
|
471
|
-
__addElement: (element) => {
|
|
472
|
-
const [project, fqn] = splitGlobalFqn(element.id);
|
|
473
|
-
const parent = parentFqn(fqn);
|
|
474
|
-
const lookup = project ? _imports.get(project) : _elements;
|
|
475
|
-
if (parent) {
|
|
476
|
-
invariant(
|
|
477
|
-
lookup.get(parent),
|
|
478
|
-
`Parent element with id "${parent}" not found for element with id "${element.id}"`
|
|
479
|
-
);
|
|
480
|
-
}
|
|
481
|
-
if (lookup.has(fqn)) {
|
|
482
|
-
throw new Error(`Element with id "${element.id}" already exists`);
|
|
483
|
-
}
|
|
484
|
-
lookup.set(fqn, project ? { ...element, id: fqn } : element);
|
|
485
|
-
return self;
|
|
486
|
-
},
|
|
487
|
-
__addRelation(relation) {
|
|
488
|
-
const source = parseRelEndpoint(relation.source);
|
|
489
|
-
const sourceFqn = FqnRef.flatten(source);
|
|
490
|
-
const target = parseRelEndpoint(relation.target);
|
|
491
|
-
const targetFqn = FqnRef.flatten(target);
|
|
492
|
-
const sourceEl = checkElementExists(sourceFqn);
|
|
493
|
-
const targetEl = checkElementExists(targetFqn);
|
|
494
|
-
if (isGlobalFqn(sourceFqn) && isGlobalFqn(targetFqn)) {
|
|
495
|
-
throw new Error("Cannot create relationship between global elements");
|
|
496
|
-
}
|
|
497
|
-
if (!isGlobalFqn(sourceFqn) && !isGlobalFqn(targetFqn)) {
|
|
498
|
-
invariant(
|
|
499
|
-
!isSameHierarchy(sourceEl, targetEl),
|
|
500
|
-
"Cannot create relationship between elements in the same hierarchy"
|
|
501
|
-
);
|
|
502
|
-
}
|
|
503
|
-
_relations.push({
|
|
504
|
-
id: `rel${_relations.length + 1}`,
|
|
505
|
-
...relation,
|
|
506
|
-
source,
|
|
507
|
-
target
|
|
508
|
-
});
|
|
509
|
-
return self;
|
|
510
|
-
},
|
|
511
|
-
__fqn(id) {
|
|
512
|
-
invariant(id.trim() !== "", "Id must be non-empty");
|
|
513
|
-
return id;
|
|
514
|
-
},
|
|
515
|
-
__deploymentFqn(id) {
|
|
516
|
-
invariant(id.trim() !== "", "Id must be non-empty");
|
|
517
|
-
return id;
|
|
518
|
-
},
|
|
519
|
-
__addSourcelessRelation() {
|
|
520
|
-
throw new Error("Can be called only in nested model");
|
|
521
|
-
},
|
|
522
|
-
__addView: (view) => {
|
|
523
|
-
if (_views.has(view.id)) {
|
|
524
|
-
throw new Error(`View with id "${view.id}" already exists`);
|
|
525
|
-
}
|
|
526
|
-
if (isElementView(view) && "viewOf" in view) {
|
|
527
|
-
invariant(
|
|
528
|
-
_elements.get(view.viewOf),
|
|
529
|
-
`Invalid scoped view ${view.id}, wlement with id "${view.viewOf}" not found`
|
|
530
|
-
);
|
|
531
|
-
}
|
|
532
|
-
_views.set(view.id, view);
|
|
533
|
-
return self;
|
|
534
|
-
},
|
|
535
|
-
__addDeployment: (node) => {
|
|
536
|
-
if (_deployments.has(node.id)) {
|
|
537
|
-
throw new Error(`Deployment with id "${node.id}" already exists`);
|
|
538
|
-
}
|
|
539
|
-
const parent = parentFqn(node.id);
|
|
540
|
-
if (parent) {
|
|
541
|
-
invariant(
|
|
542
|
-
_deployments.get(parent),
|
|
543
|
-
`Parent element with id "${parent}" not found for node with id "${node.id}"`
|
|
544
|
-
);
|
|
545
|
-
}
|
|
546
|
-
if (isDeployedInstance(node)) {
|
|
547
|
-
invariant(parent, `Instance ${node.id} of ${node.element} must be deployed under a parent node`);
|
|
548
|
-
invariant(
|
|
549
|
-
_elements.get(node.element),
|
|
550
|
-
`Instance "${node.id}" references non-existing element "${node.element}"`
|
|
551
|
-
);
|
|
552
|
-
}
|
|
553
|
-
_deployments.set(node.id, node);
|
|
554
|
-
return self;
|
|
555
|
-
},
|
|
556
|
-
__addDeploymentRelation: (relation) => {
|
|
557
|
-
invariant(
|
|
558
|
-
!isSameHierarchy(relation.source.deployment, relation.target.deployment),
|
|
559
|
-
"Cannot create relationship between elements in the same hierarchy"
|
|
560
|
-
);
|
|
561
|
-
invariant(
|
|
562
|
-
_deployments.has(relation.source.deployment),
|
|
563
|
-
`Relation "${relation.source.deployment} -> ${relation.target.deployment}" references non-existing source`
|
|
564
|
-
);
|
|
565
|
-
invariant(
|
|
566
|
-
_deployments.has(relation.target.deployment),
|
|
567
|
-
`Relation "${relation.source.deployment} -> ${relation.target.deployment}" references non-existing target`
|
|
568
|
-
);
|
|
569
|
-
_deploymentRelations.push({
|
|
570
|
-
id: `deploy_rel${_deploymentRelations.length + 1}`,
|
|
571
|
-
...relation
|
|
572
|
-
});
|
|
573
|
-
return self;
|
|
574
|
-
},
|
|
575
|
-
build: (project) => ({
|
|
576
|
-
[_stage]: "parsed",
|
|
577
|
-
projectId: typeof project === "string" ? project : project?.id ?? "from-builder",
|
|
578
|
-
project: {
|
|
579
|
-
id: typeof project === "string" ? project : "from-builder",
|
|
580
|
-
...typeof project === "object" && project !== null ? project : {}
|
|
581
|
-
},
|
|
582
|
-
specification: toLikeC4Specification(),
|
|
583
|
-
elements: t(
|
|
584
|
-
structuredClone(
|
|
585
|
-
Array.from(_elements.entries())
|
|
586
|
-
)
|
|
587
|
-
),
|
|
588
|
-
relations: t$5(_relations, (r) => [r.id, structuredClone(r)]),
|
|
589
|
-
globals: structuredClone(_globals),
|
|
590
|
-
deployments: {
|
|
591
|
-
elements: t(
|
|
592
|
-
structuredClone(
|
|
593
|
-
Array.from(_deployments.entries())
|
|
594
|
-
)
|
|
595
|
-
),
|
|
596
|
-
relations: t$5(_deploymentRelations, (r) => [r.id, structuredClone(r)])
|
|
597
|
-
},
|
|
598
|
-
views: t(
|
|
599
|
-
structuredClone(
|
|
600
|
-
Array.from(_views.entries())
|
|
601
|
-
)
|
|
602
|
-
),
|
|
603
|
-
imports: t$4(
|
|
604
|
-
Array.from(_imports.entries()),
|
|
605
|
-
t$2(([projectId, elementsMap]) => [projectId, structuredClone([...elementsMap.values()])]),
|
|
606
|
-
n(([_, elements]) => elements.length > 0),
|
|
607
|
-
t()
|
|
608
|
-
)
|
|
609
|
-
}),
|
|
610
|
-
toLikeC4Model: (project) => {
|
|
611
|
-
const parsed = self.build(project);
|
|
612
|
-
return computeLikeC4Model(parsed);
|
|
613
|
-
},
|
|
614
|
-
helpers: () => ({
|
|
615
|
-
model: {
|
|
616
|
-
model: (...ops) => {
|
|
617
|
-
return (b) => {
|
|
618
|
-
return ops.reduce((b2, op) => op(b2), b);
|
|
619
|
-
};
|
|
620
|
-
},
|
|
621
|
-
rel: (source, target, _props) => {
|
|
622
|
-
return (b) => {
|
|
623
|
-
const {
|
|
624
|
-
title = "",
|
|
625
|
-
links: _links = [],
|
|
626
|
-
description = null,
|
|
627
|
-
notes = null,
|
|
628
|
-
...props
|
|
629
|
-
} = defu(
|
|
630
|
-
typeof _props === "string" ? { title: _props } : { ..._props },
|
|
631
|
-
{ title: null, links: null }
|
|
632
|
-
);
|
|
633
|
-
const links = mapLinks(_links);
|
|
634
|
-
b.__addRelation(exact({
|
|
635
|
-
source: {
|
|
636
|
-
model: source
|
|
637
|
-
},
|
|
638
|
-
target: {
|
|
639
|
-
model: target
|
|
640
|
-
},
|
|
641
|
-
title,
|
|
642
|
-
...description && { description: toMarkdownOrString(description) },
|
|
643
|
-
...notes && { notes: toMarkdownOrString(notes) },
|
|
644
|
-
links,
|
|
645
|
-
...props
|
|
646
|
-
}));
|
|
647
|
-
return b;
|
|
648
|
-
};
|
|
649
|
-
},
|
|
650
|
-
relTo: (target, _props) => {
|
|
651
|
-
return (b) => {
|
|
652
|
-
const {
|
|
653
|
-
title = "",
|
|
654
|
-
links,
|
|
655
|
-
description = null,
|
|
656
|
-
notes = null,
|
|
657
|
-
...props
|
|
658
|
-
} = defu(
|
|
659
|
-
typeof _props === "string" ? { title: _props } : { ..._props },
|
|
660
|
-
{ title: null, links: null }
|
|
661
|
-
);
|
|
662
|
-
b.__addSourcelessRelation(exact({
|
|
663
|
-
target: {
|
|
664
|
-
model: target
|
|
665
|
-
},
|
|
666
|
-
title,
|
|
667
|
-
...description && { description: toMarkdownOrString(description) },
|
|
668
|
-
...notes && { notes: toMarkdownOrString(notes) },
|
|
669
|
-
links: mapLinks(links),
|
|
670
|
-
...props
|
|
671
|
-
}));
|
|
672
|
-
return b;
|
|
673
|
-
};
|
|
674
|
-
},
|
|
675
|
-
...t$3(
|
|
676
|
-
spec.elements,
|
|
677
|
-
({ style: specStyle, ...spec2 }, kind) => (id, _props) => {
|
|
678
|
-
const add = ((b) => {
|
|
679
|
-
const {
|
|
680
|
-
links,
|
|
681
|
-
icon: _icon,
|
|
682
|
-
color,
|
|
683
|
-
shape,
|
|
684
|
-
style,
|
|
685
|
-
title,
|
|
686
|
-
description,
|
|
687
|
-
summary,
|
|
688
|
-
...props
|
|
689
|
-
} = typeof _props === "string" ? { title: _props } : { ..._props };
|
|
690
|
-
const icon = _icon ?? specStyle?.icon;
|
|
691
|
-
const _id = b.__fqn(id);
|
|
692
|
-
b.__addElement(exact({
|
|
693
|
-
id: _id,
|
|
694
|
-
kind,
|
|
695
|
-
title: title ?? nameFromFqn(_id),
|
|
696
|
-
...description && { description: toMarkdownOrString(description) },
|
|
697
|
-
...summary && { summary: toMarkdownOrString(summary) },
|
|
698
|
-
style: exact({
|
|
699
|
-
icon,
|
|
700
|
-
color: color ?? specStyle?.color,
|
|
701
|
-
shape: shape ?? specStyle?.shape,
|
|
702
|
-
border: specStyle?.border,
|
|
703
|
-
opacity: specStyle?.opacity,
|
|
704
|
-
size: specStyle?.size,
|
|
705
|
-
padding: specStyle?.padding,
|
|
706
|
-
textSize: specStyle?.textSize,
|
|
707
|
-
...style
|
|
708
|
-
}),
|
|
709
|
-
links: mapLinks(links),
|
|
710
|
-
...spec2,
|
|
711
|
-
...props
|
|
712
|
-
}));
|
|
713
|
-
return b;
|
|
714
|
-
});
|
|
715
|
-
add.with = (...ops) => (b) => {
|
|
716
|
-
add(b);
|
|
717
|
-
const { __fqn, __addSourcelessRelation } = b;
|
|
718
|
-
try {
|
|
719
|
-
b.__fqn = (child) => `${__fqn(id)}.${child}`;
|
|
720
|
-
b.__addSourcelessRelation = (relation) => {
|
|
721
|
-
return b.__addRelation({
|
|
722
|
-
...relation,
|
|
723
|
-
source: {
|
|
724
|
-
model: __fqn(id)
|
|
725
|
-
}
|
|
726
|
-
});
|
|
727
|
-
};
|
|
728
|
-
ops.reduce((b2, op) => op(b2), b);
|
|
729
|
-
} finally {
|
|
730
|
-
b.__fqn = __fqn;
|
|
731
|
-
b.__addSourcelessRelation = __addSourcelessRelation;
|
|
732
|
-
}
|
|
733
|
-
return b;
|
|
734
|
-
};
|
|
735
|
-
return add;
|
|
736
|
-
}
|
|
737
|
-
)
|
|
738
|
-
},
|
|
739
|
-
views: {
|
|
740
|
-
views: (...ops) => {
|
|
741
|
-
return (b) => {
|
|
742
|
-
return ops.reduce((b2, op) => op(b2), b);
|
|
743
|
-
};
|
|
744
|
-
},
|
|
745
|
-
view: (id, _props, _builder) => {
|
|
746
|
-
const [generic, builder2] = createGenericView(id, _props, _builder);
|
|
747
|
-
const view = {
|
|
748
|
-
...generic,
|
|
749
|
-
[_type]: "element",
|
|
750
|
-
rules: []
|
|
751
|
-
};
|
|
752
|
-
const add = (b) => {
|
|
753
|
-
b.__addView(view);
|
|
754
|
-
if (builder2) {
|
|
755
|
-
builder2(mkViewBuilder(view));
|
|
756
|
-
}
|
|
757
|
-
return b;
|
|
758
|
-
};
|
|
759
|
-
add.with = (...ops) => (b) => {
|
|
760
|
-
add(b);
|
|
761
|
-
const elementViewBuilder = mkViewBuilder(view);
|
|
762
|
-
for (const op of ops) {
|
|
763
|
-
op(elementViewBuilder);
|
|
764
|
-
}
|
|
765
|
-
return b;
|
|
766
|
-
};
|
|
767
|
-
return add;
|
|
768
|
-
},
|
|
769
|
-
viewOf: (id, viewOf, _props, _builder) => {
|
|
770
|
-
const [generic, builder2] = createGenericView(id, _props, _builder);
|
|
771
|
-
const view = {
|
|
772
|
-
...generic,
|
|
773
|
-
viewOf,
|
|
774
|
-
[_type]: "element",
|
|
775
|
-
rules: []
|
|
776
|
-
};
|
|
777
|
-
const add = (b) => {
|
|
778
|
-
b.__addView(view);
|
|
779
|
-
if (builder2) {
|
|
780
|
-
builder2(mkViewBuilder(view));
|
|
781
|
-
}
|
|
782
|
-
return b;
|
|
783
|
-
};
|
|
784
|
-
add.with = (...ops) => (b) => {
|
|
785
|
-
add(b);
|
|
786
|
-
const elementViewBuilder = mkViewBuilder(view);
|
|
787
|
-
for (const op of ops) {
|
|
788
|
-
op(elementViewBuilder);
|
|
789
|
-
}
|
|
790
|
-
return b;
|
|
791
|
-
};
|
|
792
|
-
return add;
|
|
793
|
-
},
|
|
794
|
-
deploymentView: (id, _props, _builder) => {
|
|
795
|
-
const [generic, builder2] = createGenericView(id, _props, _builder);
|
|
796
|
-
const view = {
|
|
797
|
-
...generic,
|
|
798
|
-
[_type]: "deployment",
|
|
799
|
-
rules: []
|
|
800
|
-
};
|
|
801
|
-
const add = (b) => {
|
|
802
|
-
b.__addView(view);
|
|
803
|
-
if (builder2) {
|
|
804
|
-
builder2(mkViewBuilder(view));
|
|
805
|
-
}
|
|
806
|
-
return b;
|
|
807
|
-
};
|
|
808
|
-
add.with = (...ops) => (b) => {
|
|
809
|
-
add(b);
|
|
810
|
-
const elementViewBuilder = mkViewBuilder(view);
|
|
811
|
-
for (const op of ops) {
|
|
812
|
-
op(elementViewBuilder);
|
|
813
|
-
}
|
|
814
|
-
return b;
|
|
815
|
-
};
|
|
816
|
-
return add;
|
|
817
|
-
},
|
|
818
|
-
$autoLayout,
|
|
819
|
-
$exclude,
|
|
820
|
-
$include,
|
|
821
|
-
$rules,
|
|
822
|
-
$style
|
|
823
|
-
},
|
|
824
|
-
deployment: {
|
|
825
|
-
deployment: (...ops) => {
|
|
826
|
-
return (b) => {
|
|
827
|
-
return ops.reduce((b2, op) => op(b2), b);
|
|
828
|
-
};
|
|
829
|
-
},
|
|
830
|
-
instanceOf: (id, target, _props) => {
|
|
831
|
-
return (b) => {
|
|
832
|
-
if (e$2(target)) {
|
|
833
|
-
target = id;
|
|
834
|
-
id = nameFromFqn(id);
|
|
835
|
-
} else if (typeof target === "string") {
|
|
836
|
-
_props ??= {};
|
|
837
|
-
} else {
|
|
838
|
-
_props = target;
|
|
839
|
-
target = id;
|
|
840
|
-
id = nameFromFqn(id);
|
|
841
|
-
}
|
|
842
|
-
const {
|
|
843
|
-
links,
|
|
844
|
-
title,
|
|
845
|
-
description,
|
|
846
|
-
summary,
|
|
847
|
-
icon,
|
|
848
|
-
color,
|
|
849
|
-
shape,
|
|
850
|
-
style,
|
|
851
|
-
...props
|
|
852
|
-
} = typeof _props === "string" ? { title: _props } : { ..._props };
|
|
853
|
-
const _id = b.__deploymentFqn(id);
|
|
854
|
-
b.__addDeployment(
|
|
855
|
-
exact({
|
|
856
|
-
id: _id,
|
|
857
|
-
element: target,
|
|
858
|
-
...title && { title },
|
|
859
|
-
...summary && { summary: toMarkdownOrString(summary) },
|
|
860
|
-
...description && { description: toMarkdownOrString(description) },
|
|
861
|
-
style: exact({
|
|
862
|
-
icon,
|
|
863
|
-
color,
|
|
864
|
-
shape,
|
|
865
|
-
...style
|
|
866
|
-
}),
|
|
867
|
-
links: mapLinks(links),
|
|
868
|
-
...props
|
|
869
|
-
})
|
|
870
|
-
);
|
|
871
|
-
return b;
|
|
872
|
-
};
|
|
873
|
-
},
|
|
874
|
-
rel: (source, target, _props) => {
|
|
875
|
-
return (b) => {
|
|
876
|
-
const {
|
|
877
|
-
title = null,
|
|
878
|
-
links,
|
|
879
|
-
description = null,
|
|
880
|
-
notes = null,
|
|
881
|
-
...props
|
|
882
|
-
} = typeof _props === "string" ? { title: _props } : { ..._props };
|
|
883
|
-
b.__addDeploymentRelation(exact({
|
|
884
|
-
source: {
|
|
885
|
-
deployment: source
|
|
886
|
-
},
|
|
887
|
-
target: {
|
|
888
|
-
deployment: target
|
|
889
|
-
},
|
|
890
|
-
title,
|
|
891
|
-
...description && { description: toMarkdownOrString(description) },
|
|
892
|
-
...notes && { notes: toMarkdownOrString(notes) },
|
|
893
|
-
links: mapLinks(links),
|
|
894
|
-
...props
|
|
895
|
-
}));
|
|
896
|
-
return b;
|
|
897
|
-
};
|
|
898
|
-
},
|
|
899
|
-
...t$3(
|
|
900
|
-
spec.deployments ?? {},
|
|
901
|
-
({ style: specStyle, ...spec2 }, kind) => (id, _props) => {
|
|
902
|
-
const add = ((b) => {
|
|
903
|
-
const {
|
|
904
|
-
links,
|
|
905
|
-
icon: _icon,
|
|
906
|
-
style,
|
|
907
|
-
title,
|
|
908
|
-
description,
|
|
909
|
-
summary,
|
|
910
|
-
color,
|
|
911
|
-
shape,
|
|
912
|
-
...props
|
|
913
|
-
} = typeof _props === "string" ? { title: _props } : { ..._props };
|
|
914
|
-
const icon = _icon ?? specStyle?.icon;
|
|
915
|
-
const _id = b.__deploymentFqn(id);
|
|
916
|
-
b.__addDeployment(
|
|
917
|
-
exact({
|
|
918
|
-
id: _id,
|
|
919
|
-
kind,
|
|
920
|
-
title: title ?? nameFromFqn(_id),
|
|
921
|
-
...description && { description: toMarkdownOrString(description) },
|
|
922
|
-
...summary && { summary: toMarkdownOrString(summary) },
|
|
923
|
-
style: exact({
|
|
924
|
-
icon,
|
|
925
|
-
color: color ?? specStyle?.color,
|
|
926
|
-
shape: shape ?? specStyle?.shape,
|
|
927
|
-
border: specStyle?.border,
|
|
928
|
-
opacity: specStyle?.opacity,
|
|
929
|
-
size: specStyle?.size,
|
|
930
|
-
padding: specStyle?.padding,
|
|
931
|
-
textSize: specStyle?.textSize,
|
|
932
|
-
...style
|
|
933
|
-
}),
|
|
934
|
-
links: mapLinks(links),
|
|
935
|
-
...spec2,
|
|
936
|
-
...props
|
|
937
|
-
})
|
|
938
|
-
);
|
|
939
|
-
return b;
|
|
940
|
-
});
|
|
941
|
-
add.with = (...ops) => (b) => {
|
|
942
|
-
add(b);
|
|
943
|
-
const { __deploymentFqn } = b;
|
|
944
|
-
try {
|
|
945
|
-
b.__deploymentFqn = (child) => `${__deploymentFqn(id)}.${child}`;
|
|
946
|
-
ops.reduce((b2, op) => op(b2), b);
|
|
947
|
-
} finally {
|
|
948
|
-
b.__deploymentFqn = __deploymentFqn;
|
|
949
|
-
}
|
|
950
|
-
return b;
|
|
951
|
-
};
|
|
952
|
-
return add;
|
|
953
|
-
}
|
|
954
|
-
)
|
|
955
|
-
}
|
|
956
|
-
}),
|
|
957
|
-
with: (...ops) => {
|
|
958
|
-
const b = self.clone();
|
|
959
|
-
return ops.reduce((b2, op) => op(b2), b);
|
|
960
|
-
},
|
|
961
|
-
model: (cb) => {
|
|
962
|
-
const b = self.clone();
|
|
963
|
-
const helpers = b.helpers().model;
|
|
964
|
-
const _ = helpers.model;
|
|
965
|
-
return cb({ ...helpers, _ }, _)(b);
|
|
966
|
-
},
|
|
967
|
-
deployment: (cb) => {
|
|
968
|
-
const b = self.clone();
|
|
969
|
-
const helpers = b.helpers().deployment;
|
|
970
|
-
const _ = helpers.deployment;
|
|
971
|
-
return cb({ ...helpers, _ }, _)(b);
|
|
972
|
-
},
|
|
973
|
-
views: (cb) => {
|
|
974
|
-
const b = self.clone();
|
|
975
|
-
const helpers = b.helpers().views;
|
|
976
|
-
return cb({
|
|
977
|
-
...helpers,
|
|
978
|
-
_: helpers.views
|
|
979
|
-
}, helpers.views)(b);
|
|
980
|
-
}
|
|
981
|
-
};
|
|
982
|
-
return self;
|
|
983
|
-
}
|
|
984
|
-
const Builder = {
|
|
985
|
-
/**
|
|
986
|
-
* Creates a builder with compositional methods
|
|
987
|
-
*
|
|
988
|
-
* @example
|
|
989
|
-
* ```ts
|
|
990
|
-
* const {
|
|
991
|
-
* model: { model, system, component, relTo },
|
|
992
|
-
* deployment: { env, vm},
|
|
993
|
-
* views: { view, $include },
|
|
994
|
-
* builder,
|
|
995
|
-
* } = Builder.forSpecification({
|
|
996
|
-
* elements: {
|
|
997
|
-
* system: {},
|
|
998
|
-
* component: {},
|
|
999
|
-
* },
|
|
1000
|
-
* deployments: ['env', 'vm'],
|
|
1001
|
-
* })
|
|
1002
|
-
*
|
|
1003
|
-
* const b = builder
|
|
1004
|
-
* .with(
|
|
1005
|
-
* model(
|
|
1006
|
-
* system('cloud').with(
|
|
1007
|
-
* component('backend'),
|
|
1008
|
-
* component('backend.api'),
|
|
1009
|
-
* component('frontend').with(
|
|
1010
|
-
* relTo('cloud.backend.api'),
|
|
1011
|
-
* ),
|
|
1012
|
-
* ),
|
|
1013
|
-
* ),
|
|
1014
|
-
* )
|
|
1015
|
-
* ```
|
|
1016
|
-
*/
|
|
1017
|
-
forSpecification(spec) {
|
|
1018
|
-
const b = builder(spec);
|
|
1019
|
-
return {
|
|
1020
|
-
...b.helpers(),
|
|
1021
|
-
builder: b
|
|
1022
|
-
};
|
|
1023
|
-
},
|
|
1024
|
-
/**
|
|
1025
|
-
* Creates a builder with chainable methods
|
|
1026
|
-
*
|
|
1027
|
-
* @example
|
|
1028
|
-
* ```ts
|
|
1029
|
-
* const b = Builder
|
|
1030
|
-
* .specification({
|
|
1031
|
-
* elements: ['system', 'component'],
|
|
1032
|
-
* deployments: ['env', 'vm'],
|
|
1033
|
-
* })
|
|
1034
|
-
* .model(({ system, component, relTo }, _) =>
|
|
1035
|
-
* _(
|
|
1036
|
-
* system('cloud').with(
|
|
1037
|
-
* component('backend').with(
|
|
1038
|
-
* component('api'),
|
|
1039
|
-
* ),
|
|
1040
|
-
* component('frontend').with(
|
|
1041
|
-
* relTo('cloud.backend.api'),
|
|
1042
|
-
* )
|
|
1043
|
-
* )
|
|
1044
|
-
* )
|
|
1045
|
-
* )
|
|
1046
|
-
* ```
|
|
1047
|
-
*/
|
|
1048
|
-
specification(spec) {
|
|
1049
|
-
return builder(spec);
|
|
1050
|
-
}
|
|
1051
|
-
};
|
|
1052
|
-
|
|
1053
|
-
export { Builder };
|
|
1
|
+
import{t as defu}from"../_chunks/libs/defu.mjs";import{B as e$1,C as t$7,F as e$3,M as e$2,Q as t$3,T as t,U as t$1,W as t$4,X as t$2,Y as n,et as t$6,k as e,w as t$5}from"../_chunks/libs/remeda.mjs";import{B as isDeployedInstance,J as FqnRef,U as ModelFqnExpr,_t as _type,g as isElementView,gt as _stage,lt as isGlobalFqn,pt as splitGlobalFqn,xt as exact}from"../_chunks/RichText.mjs";import{B as parentFqn,Q as invariant,R as isSameHierarchy,z as nameFromFqn}from"../_chunks/to-text.mjs";import"../_chunks/libs/graphology-dag.mjs";import{t as import_default_map}from"../_chunks/libs/mnemonist.mjs";import"../_chunks/libs/natural-compare-lite.mjs";import"../_chunks/libs/extend.mjs";import"../_chunks/libs/@mantine/colors-generator.mjs";import{n as computeLikeC4Model,t as $expr}from"../_chunks/Builder.view-element.mjs";import"../_chunks/libs/graphology.mjs";import{t as assignTagColors}from"../_chunks/assignTagColors.mjs";function parseWhere(r){if(e(r)){let i=r;switch(!0){case i.startsWith(`tag is not #`):return{tag:{neq:i.replace(`tag is not #`,``)}};case i.startsWith(`tag is #`):return{tag:{eq:i.replace(`tag is #`,``)}};case i.startsWith(`kind is not `):return{kind:{neq:i.replace(`kind is not `,``)}};case i.startsWith(`kind is `):return{kind:{eq:i.replace(`kind is `,``)}};case i.startsWith(`source.`):return{operator:parseWhere(i.replace(`source.`,``)),participant:`source`};case i.startsWith(`target.`):return{operator:parseWhere(i.replace(`target.`,``)),participant:`target`};default:throw Error(`Unknown where operator: ${r}`)}}if(r.and)return{and:t(r.and,parseWhere)};if(r.or)return{or:t(r.or,parseWhere)};if(r.not)return{not:parseWhere(r.not)};throw Error(`Unknown where operator: ${r}`)}function $include(...r){return i=>{let a=i.$expr(r[0]);if(r.length===2){let i=r[1].where?parseWhere(r[1].where):void 0;i&&(a={where:{expr:a,condition:i}});let o=r[1].with;o&&(a=ModelFqnExpr.is(a)?{custom:{...o,expr:a}}:{customRelation:{...o,expr:a}})}return i.include(a),i}}function $exclude(...r){return i=>{let a=i.$expr(r[0]);if(r.length===2&&r[1].where){let i=parseWhere(r[1].where);a={where:{expr:a,condition:i}}}return i.exclude(a),i}}function $style(r,{notation:a,...o}){return s=>s.style({targets:(e$1(r)?r:[r]).map(r=>s.$expr(r)),...a?{notation:a}:{},style:{...o}})}function $autoLayout(r){return i=>i.autoLayout(r)}function $rules(...r){return i=>r.reduce((r,i)=>i(r),i)}function $deploymentExpr(r){if(!e(r))return r;let i=r=>r;if(r===`*`)return i({wildcard:!0});if(r.startsWith(`->`))return r.endsWith(`->`)?i({inout:$deploymentExpr(r.replace(/->/g,``).trim())}):i({incoming:$deploymentExpr(r.replace(`-> `,``))});if(r.endsWith(` ->`))return i({outgoing:$deploymentExpr(r.replace(` ->`,``))});if(r.includes(` <-> `)){let[a,o]=r.split(` <-> `);return i({source:$deploymentExpr(a),target:$deploymentExpr(o),isBidirectional:!0})}if(r.includes(` -> `)){let[a,o]=r.split(` -> `);return i({source:$deploymentExpr(a),target:$deploymentExpr(o)})}return r.endsWith(`._`)?i({ref:{deployment:r.replace(`._`,``)},selector:`expanded`}):r.endsWith(`.**`)?i({ref:{deployment:r.replace(`.**`,``)},selector:`descendants`}):r.endsWith(`.*`)?i({ref:{deployment:r.replace(`.*`,``)},selector:`children`}):i({ref:{deployment:r}})}function mkViewBuilder(r){let i={$expr:r[_type]===`deployment`?$deploymentExpr:$expr,autoLayout(a){return r.rules.push({direction:a}),i},exclude(a){return r.rules.push({exclude:[a]}),i},include(a){return r.rules.push({include:[a]}),i},style(a){return r.rules.push(a),i}};return i}function ensureObj(r){return e$1(r)?t$1(r,r=>({})):r}function validateSpec({tags:r,elements:i,deployments:a,relationships:o,...s}){let c={};r&&Object.assign(c,ensureObj(r));let l=ensureObj(i);for(let[r,i]of t$2(l))if(i.tags)for(let a of i.tags)invariant(a in c,`Invalid specification for element kind "${r}": tag "${a}" not found`);let u=ensureObj(a??{});for(let[r,i]of t$2(u))if(i.tags)for(let a of i.tags)invariant(a in c,`Invalid specification for deployment kind "${r}": tag "${a}" not found`);return{...s,tags:c,elements:l,deployments:u,relationships:ensureObj(o??{})}}function toMarkdownOrString(r){return e$2(r)?null:typeof r==`string`?{txt:r}:r}function builder(i,u=new Map,f=[],h=new Map,y={predicates:{},dynamicPredicates:{},styles:{}},b=new Map,x=[],S=new import_default_map.default(()=>new Map)){let C=validateSpec(i),w=()=>({elements:structuredClone(C.elements),deployments:structuredClone(C.deployments),relationships:structuredClone(C.relationships),tags:assignTagColors(structuredClone(C.tags)),...C.metadataKeys?{metadataKeys:C.metadataKeys}:{},customColors:{}}),T=r=>{if(!(!r||!t$3(r,1)))return t(r,r=>typeof r==`string`?{url:r}:r)},E=(r,i,a)=>{e$3(i)&&(a=i,i={}),i??={};let{links:s=[],title:c=null,description:l=null,tags:u=[],...d}=typeof i==`string`?{title:i}:{...i},f=T(s);return[exact({id:r,title:c,description:toMarkdownOrString(l),tags:u,links:f,_stage:`parsed`,...d}),a]},D=r=>{let[i,a]=splitGlobalFqn(r),o=(i?S.get(i):u).get(a);return invariant(o,`Element with id "${r}" not found`),o},O=r=>{if(typeof r==`string`){let[i,a]=splitGlobalFqn(r);return i?{project:i,model:a}:{model:a}}return`project`in r||`deployment`in r?r:O(r.model)},k={get Types(){throw Error(`Types are not available in runtime`)},clone:()=>{let r=new import_default_map.default(()=>new Map);for(let[i,a]of S)r.set(i,structuredClone(a));return builder(structuredClone(C),structuredClone(u),structuredClone(f),structuredClone(h),structuredClone(y),structuredClone(b),structuredClone(x),r)},__addElement:r=>{let[i,a]=splitGlobalFqn(r.id),o=parentFqn(a),s=i?S.get(i):u;if(o&&invariant(s.get(o),`Parent element with id "${o}" not found for element with id "${r.id}"`),s.has(a))throw Error(`Element with id "${r.id}" already exists`);return s.set(a,i?{...r,id:a}:r),k},__addRelation(r){let i=O(r.source),a=FqnRef.flatten(i),o=O(r.target),s=FqnRef.flatten(o),c=D(a),l=D(s);if(isGlobalFqn(a)&&isGlobalFqn(s))throw Error(`Cannot create relationship between global elements`);return!isGlobalFqn(a)&&!isGlobalFqn(s)&&invariant(!isSameHierarchy(c,l),`Cannot create relationship between elements in the same hierarchy`),f.push({id:`rel${f.length+1}`,...r,source:i,target:o}),k},__fqn(r){return invariant(r.trim()!==``,`Id must be non-empty`),r},__deploymentFqn(r){return invariant(r.trim()!==``,`Id must be non-empty`),r},__addSourcelessRelation(){throw Error(`Can be called only in nested model`)},__addView:r=>{if(h.has(r.id))throw Error(`View with id "${r.id}" already exists`);return isElementView(r)&&`viewOf`in r&&invariant(u.get(r.viewOf),`Invalid scoped view ${r.id}, wlement with id "${r.viewOf}" not found`),h.set(r.id,r),k},__addDeployment:r=>{if(b.has(r.id))throw Error(`Deployment with id "${r.id}" already exists`);let i=parentFqn(r.id);return i&&invariant(b.get(i),`Parent element with id "${i}" not found for node with id "${r.id}"`),isDeployedInstance(r)&&(invariant(i,`Instance ${r.id} of ${r.element} must be deployed under a parent node`),invariant(u.get(r.element),`Instance "${r.id}" references non-existing element "${r.element}"`)),b.set(r.id,r),k},__addDeploymentRelation:r=>(invariant(!isSameHierarchy(r.source.deployment,r.target.deployment),`Cannot create relationship between elements in the same hierarchy`),invariant(b.has(r.source.deployment),`Relation "${r.source.deployment} -> ${r.target.deployment}" references non-existing source`),invariant(b.has(r.target.deployment),`Relation "${r.source.deployment} -> ${r.target.deployment}" references non-existing target`),x.push({id:`deploy_rel${x.length+1}`,...r}),k),build:r=>({[_stage]:`parsed`,projectId:typeof r==`string`?r:r?.id??`from-builder`,project:{id:typeof r==`string`?r:`from-builder`,...typeof r==`object`&&r?r:{}},specification:w(),elements:t$4(structuredClone(Array.from(u.entries()))),relations:t$5(f,r=>[r.id,structuredClone(r)]),globals:structuredClone(y),deployments:{elements:t$4(structuredClone(Array.from(b.entries()))),relations:t$5(x,r=>[r.id,structuredClone(r)])},views:t$4(structuredClone(Array.from(h.entries()))),imports:t$6(Array.from(S.entries()),t(([r,i])=>[r,structuredClone([...i.values()])]),n(([r,i])=>i.length>0),t$4())}),toLikeC4Model:r=>computeLikeC4Model(k.build(r)),helpers:()=>({model:{model:(...r)=>i=>r.reduce((r,i)=>i(r),i),rel:(i,a,o)=>s=>{let{title:c=``,links:l=[],description:u=null,notes:d=null,...f}=defu(typeof o==`string`?{title:o}:{...o},{title:null,links:null}),p=T(l);return s.__addRelation(exact({source:{model:i},target:{model:a},title:c,...u&&{description:toMarkdownOrString(u)},...d&&{notes:toMarkdownOrString(d)},links:p,...f})),s},relTo:(i,a)=>o=>{let{title:s=``,links:c,description:l=null,notes:u=null,...d}=defu(typeof a==`string`?{title:a}:{...a},{title:null,links:null});return o.__addSourcelessRelation(exact({target:{model:i},title:s,...l&&{description:toMarkdownOrString(l)},...u&&{notes:toMarkdownOrString(u)},links:T(c),...d})),o},...t$7(C.elements,({style:r,...i},a)=>(o,s)=>{let c=(c=>{let{links:l,icon:u,color:d,shape:f,style:p,title:m,description:h,summary:g,..._}=typeof s==`string`?{title:s}:{...s},v=u??r?.icon,y=c.__fqn(o);return c.__addElement(exact({id:y,kind:a,title:m??nameFromFqn(y),...h&&{description:toMarkdownOrString(h)},...g&&{summary:toMarkdownOrString(g)},style:exact({icon:v,color:d??r?.color,shape:f??r?.shape,border:r?.border,opacity:r?.opacity,size:r?.size,padding:r?.padding,textSize:r?.textSize,...p}),links:T(l),...i,..._})),c});return c.with=(...r)=>i=>{c(i);let{__fqn:a,__addSourcelessRelation:s}=i;try{i.__fqn=r=>`${a(o)}.${r}`,i.__addSourcelessRelation=r=>i.__addRelation({...r,source:{model:a(o)}}),r.reduce((r,i)=>i(r),i)}finally{i.__fqn=a,i.__addSourcelessRelation=s}return i},c})},views:{views:(...r)=>i=>r.reduce((r,i)=>i(r),i),view:(r,i,a)=>{let[o,s]=E(r,i,a),c={...o,[_type]:`element`,rules:[]},l=r=>(r.__addView(c),s&&s(mkViewBuilder(c)),r);return l.with=(...r)=>i=>{l(i);let a=mkViewBuilder(c);for(let i of r)i(a);return i},l},viewOf:(r,i,a,o)=>{let[s,c]=E(r,a,o),l={...s,viewOf:i,[_type]:`element`,rules:[]},u=r=>(r.__addView(l),c&&c(mkViewBuilder(l)),r);return u.with=(...r)=>i=>{u(i);let a=mkViewBuilder(l);for(let i of r)i(a);return i},u},deploymentView:(r,i,a)=>{let[o,s]=E(r,i,a),c={...o,[_type]:`deployment`,rules:[]},l=r=>(r.__addView(c),s&&s(mkViewBuilder(c)),r);return l.with=(...r)=>i=>{l(i);let a=mkViewBuilder(c);for(let i of r)i(a);return i},l},$autoLayout,$exclude,$include,$rules,$style},deployment:{deployment:(...r)=>i=>r.reduce((r,i)=>i(r),i),instanceOf:(r,i,a)=>o=>{e$2(i)?(i=r,r=nameFromFqn(r)):typeof i==`string`?a??={}:(a=i,i=r,r=nameFromFqn(r));let{links:c,title:l,description:u,summary:d,icon:f,color:p,shape:m,style:h,...g}=typeof a==`string`?{title:a}:{...a},_=o.__deploymentFqn(r);return o.__addDeployment(exact({id:_,element:i,...l&&{title:l},...d&&{summary:toMarkdownOrString(d)},...u&&{description:toMarkdownOrString(u)},style:exact({icon:f,color:p,shape:m,...h}),links:T(c),...g})),o},rel:(r,i,a)=>o=>{let{title:s=null,links:c,description:l=null,notes:u=null,...d}=typeof a==`string`?{title:a}:{...a};return o.__addDeploymentRelation(exact({source:{deployment:r},target:{deployment:i},title:s,...l&&{description:toMarkdownOrString(l)},...u&&{notes:toMarkdownOrString(u)},links:T(c),...d})),o},...t$7(C.deployments??{},({style:r,...i},a)=>(o,s)=>{let c=(c=>{let{links:l,icon:u,style:d,title:f,description:p,summary:m,color:h,shape:g,..._}=typeof s==`string`?{title:s}:{...s},v=u??r?.icon,y=c.__deploymentFqn(o);return c.__addDeployment(exact({id:y,kind:a,title:f??nameFromFqn(y),...p&&{description:toMarkdownOrString(p)},...m&&{summary:toMarkdownOrString(m)},style:exact({icon:v,color:h??r?.color,shape:g??r?.shape,border:r?.border,opacity:r?.opacity,size:r?.size,padding:r?.padding,textSize:r?.textSize,...d}),links:T(l),...i,..._})),c});return c.with=(...r)=>i=>{c(i);let{__deploymentFqn:a}=i;try{i.__deploymentFqn=r=>`${a(o)}.${r}`,r.reduce((r,i)=>i(r),i)}finally{i.__deploymentFqn=a}return i},c})}}),with:(...r)=>{let i=k.clone();return r.reduce((r,i)=>i(r),i)},model:r=>{let i=k.clone(),a=i.helpers().model,o=a.model;return r({...a,_:o},o)(i)},deployment:r=>{let i=k.clone(),a=i.helpers().deployment,o=a.deployment;return r({...a,_:o},o)(i)},views:r=>{let i=k.clone(),a=i.helpers().views;return r({...a,_:a.views},a.views)(i)}};return k}const Builder={forSpecification(r){let i=builder(r);return{...i.helpers(),builder:i}},specification(r){return builder(r)}};export{Builder};
|