@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.
- 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 +22 -0
- package/dist/compute-view/index.d.ts +22 -0
- package/dist/compute-view/index.js +78 -0
- package/dist/index.d.mts +10 -919
- package/dist/index.d.ts +10 -919
- package/dist/{index.mjs → index.js} +7 -1688
- package/dist/model/index.d.mts +254 -0
- package/dist/model/index.d.ts +254 -0
- 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.CoLQkcYL.d.cts → core.C05RDLhi.d.ts} +460 -362
- package/dist/shared/{core.CoLQkcYL.d.mts → core.CmYMqgha.d.mts} +460 -362
- 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/{core.BXTs-8n7.mjs → view.CyZrG8BJ.js} +108 -47
- package/dist/types/index.d.mts +71 -1
- package/dist/types/index.d.ts +71 -1
- 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 +59 -47
- 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 +224 -0
- package/src/builder/Builder.deploymentModel.ts +385 -0
- package/src/builder/Builder.element.ts +19 -19
- package/src/builder/Builder.model.ts +67 -42
- package/src/builder/Builder.ts +533 -367
- 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 +113 -18
- package/src/builder/index.ts +10 -4
- package/src/colors/index.ts +2 -2
- package/src/compute-view/compute-view.ts +83 -0
- package/src/compute-view/deployment-view/__test__/TestHelper.ts +236 -0
- package/src/compute-view/deployment-view/__test__/fixture.ts +198 -0
- package/src/compute-view/deployment-view/_types.ts +37 -0
- package/src/compute-view/deployment-view/clean-connections.ts +238 -0
- package/src/compute-view/deployment-view/compute.ts +125 -0
- 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 +237 -0
- package/src/compute-view/deployment-view/predicates/relation-in-out.ts +61 -0
- package/src/compute-view/deployment-view/predicates/relation-incoming.ts +95 -0
- package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +88 -0
- package/src/compute-view/deployment-view/predicates/wildcard.ts +29 -0
- 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 +276 -0
- package/src/compute-view/dynamic-view/__test__/fixture.ts +58 -0
- package/src/compute-view/dynamic-view/compute.ts +324 -0
- package/src/compute-view/element-view/__test__/TestHelper.ts +258 -0
- package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +458 -0
- package/src/compute-view/element-view/__test__/fixture.ts +675 -0
- 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 +315 -0
- 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 +4 -0
- 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/__snapshots__/sortNodes.spec.ts.snap +113 -0
- package/src/compute-view/utils/ancestorsOfNode.ts +19 -0
- package/src/compute-view/utils/applyCustomElementProperties.ts +66 -0
- package/src/compute-view/utils/applyCustomRelationProperties.ts +41 -0
- package/src/compute-view/utils/applyViewRuleStyles.ts +53 -0
- package/src/compute-view/utils/buildComputedNodes.ts +148 -0
- package/src/compute-view/utils/buildElementNotations.ts +63 -0
- package/src/compute-view/utils/elementExpressionToPredicate.ts +50 -0
- package/src/compute-view/utils/link-nodes-with-edges.ts +54 -0
- package/src/compute-view/utils/merge-props-from-relationships.ts +128 -0
- package/src/compute-view/utils/relationExpressionToPredicates.ts +55 -0
- package/src/compute-view/utils/resolve-extended-views.ts +69 -0
- package/src/compute-view/utils/resolve-global-rules.ts +83 -0
- package/src/compute-view/utils/topological-sort.ts +256 -0
- package/src/compute-view/utils/uniqueTags.test.ts +42 -0
- package/src/compute-view/utils/uniqueTags.ts +21 -0
- package/src/compute-view/utils/view-hash.ts +27 -0
- package/src/compute-view/utils/with-readable-edges.ts +36 -0
- package/src/index.ts +22 -12
- package/src/model/DeploymentElementModel.ts +599 -0
- package/src/model/DeploymentModel.ts +370 -0
- package/src/model/ElementModel.ts +221 -0
- package/src/model/LikeC4Model.test-d.ts +152 -0
- package/src/model/LikeC4Model.ts +336 -457
- package/src/model/RelationModel.ts +85 -0
- package/src/model/__test__/fixture.ts +149 -338
- package/src/model/connection/Connection.ts +72 -0
- package/src/model/connection/deployment/DeploymentConnectionModel.ts +178 -0
- package/src/model/connection/deployment/find.ts +120 -0
- 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/find.ts +117 -0
- 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 +46 -2
- package/src/model/types.ts +112 -15
- package/src/model/view/EdgeModel.ts +103 -0
- package/src/model/view/LikeC4ViewModel.ts +226 -0
- package/src/model/view/NodeModel.ts +229 -0
- package/src/types/_common.ts +55 -1
- package/src/types/deployments.ts +169 -0
- package/src/types/element.ts +9 -5
- package/src/types/expression-v2.ts +172 -0
- package/src/types/expression.ts +17 -11
- package/src/types/global.ts +3 -3
- package/src/types/index.ts +220 -12
- package/src/types/model.ts +75 -12
- package/src/types/operators.ts +1 -1
- package/src/types/overview-graph.ts +2 -2
- package/src/types/relation.ts +18 -14
- package/src/types/theme.ts +0 -1
- package/src/types/view-notation.ts +2 -2
- package/src/types/view.ts +117 -41
- package/src/utils/{commonHead.ts → common-head.ts} +2 -0
- package/src/utils/const.ts +1 -0
- package/src/utils/fqn.ts +203 -56
- package/src/utils/getOrCreate.ts +42 -0
- package/src/utils/graphlib.ts +10 -0
- package/src/utils/index.ts +74 -6
- 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/object-hash.ts +3 -0
- package/src/utils/relations.ts +3 -64
- package/src/utils/set.ts +78 -0
- package/src/utils/string-hash.ts +16 -0
- package/dist/index.cjs +0 -5452
- package/dist/index.d.cts +0 -1053
- package/dist/shared/core.CoLQkcYL.d.ts +0 -734
- package/dist/shared/core.DIYZvpVg.cjs +0 -353
- package/dist/types/index.cjs +0 -70
- package/dist/types/index.d.cts +0 -2
- package/dist/types/index.mjs +0 -1
- package/src/builder/Builder.test-d.ts +0 -69
- package/src/builder/Builder.view.ts +0 -358
- package/src/model/LikeC4DiagramModel.ts +0 -338
- package/src/model/LikeC4ViewModel.ts +0 -320
|
@@ -0,0 +1,871 @@
|
|
|
1
|
+
import { l, L as LikeC4Model, i, d } from '../shared/index.-BdzdI2C.js';
|
|
2
|
+
import { t, m, p as parentFqn, a as isSameHierarchy, n as nameFromFqn, i as i$1, l as l$1, b as t$1 } from '../shared/object_hash.CE_oF3I3.js';
|
|
3
|
+
import { b as isElementPredicateExpr, o, c as isScopedElementView, D as DeploymentElement, n as n$1, d as DefaultThemeColor, e as DefaultElementShape } from '../shared/view.CyZrG8BJ.js';
|
|
4
|
+
import { u, i as invariant } from '../shared/chunk-RAAYCPUM.M-JWF7SS.js';
|
|
5
|
+
|
|
6
|
+
function n(...r){return u(Object.fromEntries,r)}
|
|
7
|
+
|
|
8
|
+
function isPlainObject(value) {
|
|
9
|
+
if (value === null || typeof value !== "object") {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
const prototype = Object.getPrototypeOf(value);
|
|
13
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (Symbol.iterator in value) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
if (Symbol.toStringTag in value) {
|
|
20
|
+
return Object.prototype.toString.call(value) === "[object Module]";
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
26
|
+
if (!isPlainObject(defaults)) {
|
|
27
|
+
return _defu(baseObject, {}, namespace, merger);
|
|
28
|
+
}
|
|
29
|
+
const object = Object.assign({}, defaults);
|
|
30
|
+
for (const key in baseObject) {
|
|
31
|
+
if (key === "__proto__" || key === "constructor") {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const value = baseObject[key];
|
|
35
|
+
if (value === null || value === void 0) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (merger && merger(object, key, value, namespace)) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
42
|
+
object[key] = [...value, ...object[key]];
|
|
43
|
+
} else if (isPlainObject(value) && isPlainObject(object[key])) {
|
|
44
|
+
object[key] = _defu(
|
|
45
|
+
value,
|
|
46
|
+
object[key],
|
|
47
|
+
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
48
|
+
merger
|
|
49
|
+
);
|
|
50
|
+
} else {
|
|
51
|
+
object[key] = value;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return object;
|
|
55
|
+
}
|
|
56
|
+
function createDefu(merger) {
|
|
57
|
+
return (...arguments_) => (
|
|
58
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
59
|
+
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
const defu = createDefu();
|
|
63
|
+
|
|
64
|
+
function parseWhere(where) {
|
|
65
|
+
if (t(where)) {
|
|
66
|
+
const op = where;
|
|
67
|
+
switch (true) {
|
|
68
|
+
case op.startsWith("tag is not #"):
|
|
69
|
+
return {
|
|
70
|
+
tag: {
|
|
71
|
+
neq: op.replace("tag is not #", "")
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
case op.startsWith("tag is #"):
|
|
75
|
+
return {
|
|
76
|
+
tag: {
|
|
77
|
+
eq: op.replace("tag is #", "")
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
case op.startsWith("kind is not "):
|
|
81
|
+
return {
|
|
82
|
+
kind: {
|
|
83
|
+
neq: op.replace("kind is not ", "")
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
case op.startsWith("kind is "):
|
|
87
|
+
return {
|
|
88
|
+
kind: {
|
|
89
|
+
eq: op.replace("kind is ", "")
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
default:
|
|
93
|
+
throw new Error(`Unknown where operator: ${where}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (where.and) {
|
|
97
|
+
return {
|
|
98
|
+
and: m(where.and, parseWhere)
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (where.or) {
|
|
102
|
+
return {
|
|
103
|
+
or: m(where.or, parseWhere)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
if (where.not) {
|
|
107
|
+
return {
|
|
108
|
+
not: parseWhere(where.not)
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
throw new Error(`Unknown where operator: ${where}`);
|
|
112
|
+
}
|
|
113
|
+
function $include(...args) {
|
|
114
|
+
return (b) => {
|
|
115
|
+
let expr = b.$expr(args[0]);
|
|
116
|
+
if (args.length === 2) {
|
|
117
|
+
const condition = args[1].where ? parseWhere(args[1].where) : void 0;
|
|
118
|
+
if (condition) {
|
|
119
|
+
expr = {
|
|
120
|
+
where: {
|
|
121
|
+
expr,
|
|
122
|
+
condition
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
const custom = args[1].with;
|
|
127
|
+
if (custom) {
|
|
128
|
+
const isElement = isElementPredicateExpr(expr);
|
|
129
|
+
if (isElement) {
|
|
130
|
+
expr = {
|
|
131
|
+
custom: {
|
|
132
|
+
...custom,
|
|
133
|
+
expr
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
} else {
|
|
137
|
+
expr = {
|
|
138
|
+
customRelation: {
|
|
139
|
+
...custom,
|
|
140
|
+
relation: expr
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
b.include(expr);
|
|
147
|
+
return b;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function $exclude(...args) {
|
|
151
|
+
return (b) => {
|
|
152
|
+
let expr = b.$expr(args[0]);
|
|
153
|
+
if (args.length === 2 && args[1].where) {
|
|
154
|
+
const condition = parseWhere(args[1].where);
|
|
155
|
+
expr = {
|
|
156
|
+
where: {
|
|
157
|
+
expr,
|
|
158
|
+
condition
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
b.exclude(expr);
|
|
163
|
+
return b;
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function $style(element, { notation, ...style }) {
|
|
167
|
+
return (b) => b.style({
|
|
168
|
+
targets: (o(element) ? element : [element]).map((e) => b.$expr(e)),
|
|
169
|
+
...notation ? { notation } : {},
|
|
170
|
+
style: {
|
|
171
|
+
...style
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function $autoLayout(layout) {
|
|
176
|
+
return (b) => b.autoLayout(layout);
|
|
177
|
+
}
|
|
178
|
+
function $rules(...rules) {
|
|
179
|
+
return (b) => rules.reduce((b2, rule) => rule(b2), b);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function $deploymentExpr(expr) {
|
|
183
|
+
if (!t(expr)) {
|
|
184
|
+
return expr;
|
|
185
|
+
}
|
|
186
|
+
const asTypedDeploymentExpression = (expr2) => {
|
|
187
|
+
return expr2;
|
|
188
|
+
};
|
|
189
|
+
if (expr === "*") {
|
|
190
|
+
return asTypedDeploymentExpression({ wildcard: true });
|
|
191
|
+
}
|
|
192
|
+
if (expr.startsWith("->")) {
|
|
193
|
+
if (expr.endsWith("->")) {
|
|
194
|
+
return asTypedDeploymentExpression({
|
|
195
|
+
inout: $deploymentExpr(expr.replace(/->/g, "").trim())
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
return asTypedDeploymentExpression({
|
|
199
|
+
incoming: $deploymentExpr(expr.replace("-> ", ""))
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
if (expr.endsWith(" ->")) {
|
|
203
|
+
return asTypedDeploymentExpression({
|
|
204
|
+
outgoing: $deploymentExpr(expr.replace(" ->", ""))
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
if (expr.includes(" <-> ")) {
|
|
208
|
+
const [source, target] = expr.split(" <-> ");
|
|
209
|
+
return asTypedDeploymentExpression({
|
|
210
|
+
source: $deploymentExpr(source),
|
|
211
|
+
target: $deploymentExpr(target),
|
|
212
|
+
isBidirectional: true
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
if (expr.includes(" -> ")) {
|
|
216
|
+
const [source, target] = expr.split(" -> ");
|
|
217
|
+
return asTypedDeploymentExpression({
|
|
218
|
+
source: $deploymentExpr(source),
|
|
219
|
+
target: $deploymentExpr(target)
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
if (expr.endsWith("._")) {
|
|
223
|
+
return asTypedDeploymentExpression({
|
|
224
|
+
ref: {
|
|
225
|
+
deployment: expr.replace("._", "")
|
|
226
|
+
},
|
|
227
|
+
selector: "expanded"
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
if (expr.endsWith(".**")) {
|
|
231
|
+
return asTypedDeploymentExpression({
|
|
232
|
+
ref: {
|
|
233
|
+
deployment: expr.replace(".**", "")
|
|
234
|
+
},
|
|
235
|
+
selector: "descendants"
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
if (expr.endsWith(".*")) {
|
|
239
|
+
return asTypedDeploymentExpression({
|
|
240
|
+
ref: {
|
|
241
|
+
deployment: expr.replace(".*", "")
|
|
242
|
+
},
|
|
243
|
+
selector: "children"
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
return asTypedDeploymentExpression({
|
|
247
|
+
ref: {
|
|
248
|
+
deployment: expr
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const asTypedExpr = (expr) => {
|
|
254
|
+
return expr;
|
|
255
|
+
};
|
|
256
|
+
function $expr(expr) {
|
|
257
|
+
if (!t(expr)) {
|
|
258
|
+
return expr;
|
|
259
|
+
}
|
|
260
|
+
if (expr === "*") {
|
|
261
|
+
return asTypedExpr({ wildcard: true });
|
|
262
|
+
}
|
|
263
|
+
if (expr.startsWith("->")) {
|
|
264
|
+
if (expr.endsWith("->")) {
|
|
265
|
+
return asTypedExpr({
|
|
266
|
+
inout: $expr(expr.replace(/->/g, "").trim())
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
return asTypedExpr({
|
|
270
|
+
incoming: $expr(expr.replace("-> ", ""))
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
if (expr.endsWith(" ->")) {
|
|
274
|
+
return asTypedExpr({
|
|
275
|
+
outgoing: $expr(expr.replace(" ->", ""))
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
if (expr.includes(" <-> ")) {
|
|
279
|
+
const [source, target] = expr.split(" <-> ");
|
|
280
|
+
return asTypedExpr({
|
|
281
|
+
source: $expr(source),
|
|
282
|
+
target: $expr(target),
|
|
283
|
+
isBidirectional: true
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
if (expr.includes(" -> ")) {
|
|
287
|
+
const [source, target] = expr.split(" -> ");
|
|
288
|
+
return asTypedExpr({
|
|
289
|
+
source: $expr(source),
|
|
290
|
+
target: $expr(target)
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
if (expr.endsWith("._")) {
|
|
294
|
+
return asTypedExpr({
|
|
295
|
+
expanded: expr.replace("._", "")
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
if (expr.endsWith(".*")) {
|
|
299
|
+
return asTypedExpr({
|
|
300
|
+
element: expr.replace(".*", ""),
|
|
301
|
+
isChildren: true
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
if (expr.endsWith(".**")) {
|
|
305
|
+
return asTypedExpr({
|
|
306
|
+
element: expr.replace(".**", ""),
|
|
307
|
+
isDescendants: true
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
return asTypedExpr({
|
|
311
|
+
element: expr
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function mkViewBuilder(view) {
|
|
316
|
+
const viewBuilder = {
|
|
317
|
+
$expr: view.__ === "deployment" ? $deploymentExpr : $expr,
|
|
318
|
+
autoLayout(autoLayout) {
|
|
319
|
+
view.rules.push({
|
|
320
|
+
direction: autoLayout
|
|
321
|
+
});
|
|
322
|
+
return viewBuilder;
|
|
323
|
+
},
|
|
324
|
+
exclude(expr) {
|
|
325
|
+
view.rules.push({
|
|
326
|
+
exclude: [expr]
|
|
327
|
+
});
|
|
328
|
+
return viewBuilder;
|
|
329
|
+
},
|
|
330
|
+
include(expr) {
|
|
331
|
+
view.rules.push({
|
|
332
|
+
include: [expr]
|
|
333
|
+
});
|
|
334
|
+
return viewBuilder;
|
|
335
|
+
},
|
|
336
|
+
style(rule) {
|
|
337
|
+
view.rules.push(rule);
|
|
338
|
+
return viewBuilder;
|
|
339
|
+
}
|
|
340
|
+
// title(title: string) {
|
|
341
|
+
// view.title = title
|
|
342
|
+
// return viewBuilder
|
|
343
|
+
// },
|
|
344
|
+
// description(description: string) {
|
|
345
|
+
// view.description = description
|
|
346
|
+
// return viewBuilder
|
|
347
|
+
// }
|
|
348
|
+
};
|
|
349
|
+
return viewBuilder;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _views = /* @__PURE__ */ new Map(), _globals = {
|
|
353
|
+
predicates: {},
|
|
354
|
+
dynamicPredicates: {},
|
|
355
|
+
styles: {}
|
|
356
|
+
}, _deployments = /* @__PURE__ */ new Map(), _deploymentRelations = []) {
|
|
357
|
+
const toLikeC4Specification = () => ({
|
|
358
|
+
elements: {
|
|
359
|
+
...structuredClone(spec.elements)
|
|
360
|
+
},
|
|
361
|
+
deployments: {
|
|
362
|
+
...structuredClone(spec.deployments)
|
|
363
|
+
},
|
|
364
|
+
relationships: {
|
|
365
|
+
...structuredClone(spec.relationships)
|
|
366
|
+
},
|
|
367
|
+
tags: spec.tags ?? []
|
|
368
|
+
});
|
|
369
|
+
const mapLinks = (links) => {
|
|
370
|
+
if (!links || !i$1(links, 1)) {
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
return m(links, (l) => typeof l === "string" ? { url: l } : l);
|
|
374
|
+
};
|
|
375
|
+
const createGenericView = (id, _props, builder2) => {
|
|
376
|
+
if (t$1(_props)) {
|
|
377
|
+
builder2 = _props;
|
|
378
|
+
_props = {};
|
|
379
|
+
}
|
|
380
|
+
_props ??= {};
|
|
381
|
+
const {
|
|
382
|
+
links: _links = [],
|
|
383
|
+
title = null,
|
|
384
|
+
description = null,
|
|
385
|
+
tags = null,
|
|
386
|
+
...props
|
|
387
|
+
} = typeof _props === "string" ? { title: _props } : { ..._props };
|
|
388
|
+
const links = mapLinks(_links);
|
|
389
|
+
return [{
|
|
390
|
+
id,
|
|
391
|
+
title,
|
|
392
|
+
description,
|
|
393
|
+
tags,
|
|
394
|
+
links,
|
|
395
|
+
customColorDefinitions: {},
|
|
396
|
+
...props
|
|
397
|
+
}, builder2];
|
|
398
|
+
};
|
|
399
|
+
const self = {
|
|
400
|
+
get Types() {
|
|
401
|
+
throw new Error("Types are not available in runtime");
|
|
402
|
+
},
|
|
403
|
+
clone: () => {
|
|
404
|
+
return builder(
|
|
405
|
+
structuredClone(spec),
|
|
406
|
+
structuredClone(_elements),
|
|
407
|
+
structuredClone(_relations),
|
|
408
|
+
structuredClone(_views),
|
|
409
|
+
structuredClone(_globals),
|
|
410
|
+
structuredClone(_deployments),
|
|
411
|
+
structuredClone(_deploymentRelations)
|
|
412
|
+
);
|
|
413
|
+
},
|
|
414
|
+
__addElement: (element) => {
|
|
415
|
+
const parent = parentFqn(element.id);
|
|
416
|
+
if (parent) {
|
|
417
|
+
invariant(
|
|
418
|
+
_elements.get(parent),
|
|
419
|
+
`Parent element with id "${parent}" not found for element with id "${element.id}"`
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
if (_elements.has(element.id)) {
|
|
423
|
+
throw new Error(`Element with id "${element.id}" already exists`);
|
|
424
|
+
}
|
|
425
|
+
_elements.set(element.id, element);
|
|
426
|
+
return self;
|
|
427
|
+
},
|
|
428
|
+
__addRelation(relation) {
|
|
429
|
+
const sourceEl = _elements.get(relation.source);
|
|
430
|
+
invariant(sourceEl, `Element with id "${relation.source}" not found`);
|
|
431
|
+
const targetEl = _elements.get(relation.target);
|
|
432
|
+
invariant(targetEl, `Element with id "${relation.target}" not found`);
|
|
433
|
+
invariant(
|
|
434
|
+
!isSameHierarchy(sourceEl, targetEl),
|
|
435
|
+
"Cannot create relationship between elements in the same hierarchy"
|
|
436
|
+
);
|
|
437
|
+
_relations.push({
|
|
438
|
+
id: `rel${_relations.length + 1}`,
|
|
439
|
+
...relation
|
|
440
|
+
});
|
|
441
|
+
return self;
|
|
442
|
+
},
|
|
443
|
+
/**
|
|
444
|
+
* Fully qualified name for nested elements
|
|
445
|
+
*/
|
|
446
|
+
__fqn(id) {
|
|
447
|
+
invariant(id.trim() !== "", "Id must be non-empty");
|
|
448
|
+
return id;
|
|
449
|
+
},
|
|
450
|
+
__addSourcelessRelation() {
|
|
451
|
+
throw new Error("Can be called only in nested model");
|
|
452
|
+
},
|
|
453
|
+
__addView: (view) => {
|
|
454
|
+
if (_views.has(view.id)) {
|
|
455
|
+
throw new Error(`View with id "${view.id}" already exists`);
|
|
456
|
+
}
|
|
457
|
+
if (isScopedElementView(view)) {
|
|
458
|
+
invariant(
|
|
459
|
+
_elements.get(view.viewOf),
|
|
460
|
+
`Invalid scoped view ${view.id}, wlement with id "${view.viewOf}" not found`
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
_views.set(view.id, view);
|
|
464
|
+
return self;
|
|
465
|
+
},
|
|
466
|
+
__addDeployment: (node) => {
|
|
467
|
+
if (_deployments.has(node.id)) {
|
|
468
|
+
throw new Error(`Deployment with id "${node.id}" already exists`);
|
|
469
|
+
}
|
|
470
|
+
const parent = parentFqn(node.id);
|
|
471
|
+
if (parent) {
|
|
472
|
+
invariant(
|
|
473
|
+
_deployments.get(parent),
|
|
474
|
+
`Parent element with id "${parent}" not found for node with id "${node.id}"`
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
if (DeploymentElement.isInstance(node)) {
|
|
478
|
+
invariant(parent, `Instance ${node.id} of ${node.element} must be deployed under a parent node`);
|
|
479
|
+
invariant(
|
|
480
|
+
_elements.get(node.element),
|
|
481
|
+
`Instance "${node.id}" references non-existing element "${node.element}"`
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
_deployments.set(node.id, node);
|
|
485
|
+
return self;
|
|
486
|
+
},
|
|
487
|
+
__addDeploymentRelation: (relation) => {
|
|
488
|
+
invariant(
|
|
489
|
+
!isSameHierarchy(relation.source.id, relation.target.id),
|
|
490
|
+
"Cannot create relationship between elements in the same hierarchy"
|
|
491
|
+
);
|
|
492
|
+
invariant(
|
|
493
|
+
_deployments.has(relation.source.id),
|
|
494
|
+
`Relation "${relation.source.id} -> ${relation.target.id}" references non-existing source`
|
|
495
|
+
);
|
|
496
|
+
invariant(
|
|
497
|
+
_deployments.has(relation.target.id),
|
|
498
|
+
`Relation "${relation.source.id} -> ${relation.target.id}" references non-existing target`
|
|
499
|
+
);
|
|
500
|
+
_deploymentRelations.push({
|
|
501
|
+
id: `deploy_rel${_deploymentRelations.length + 1}`,
|
|
502
|
+
...relation
|
|
503
|
+
});
|
|
504
|
+
return self;
|
|
505
|
+
},
|
|
506
|
+
build: () => ({
|
|
507
|
+
specification: toLikeC4Specification(),
|
|
508
|
+
elements: n(
|
|
509
|
+
structuredClone(
|
|
510
|
+
Array.from(_elements.entries())
|
|
511
|
+
)
|
|
512
|
+
),
|
|
513
|
+
relations: l(_relations, (r) => [r.id, structuredClone(r)]),
|
|
514
|
+
globals: structuredClone(_globals),
|
|
515
|
+
deployments: {
|
|
516
|
+
elements: n(
|
|
517
|
+
structuredClone(
|
|
518
|
+
Array.from(_deployments.entries())
|
|
519
|
+
)
|
|
520
|
+
),
|
|
521
|
+
relations: l(_deploymentRelations, (r) => [r.id, structuredClone(r)])
|
|
522
|
+
},
|
|
523
|
+
views: n(
|
|
524
|
+
structuredClone(
|
|
525
|
+
Array.from(_views.entries())
|
|
526
|
+
)
|
|
527
|
+
)
|
|
528
|
+
}),
|
|
529
|
+
toLikeC4Model: () => {
|
|
530
|
+
const parsed = self.build();
|
|
531
|
+
return LikeC4Model.compute(parsed);
|
|
532
|
+
},
|
|
533
|
+
helpers: () => ({
|
|
534
|
+
model: {
|
|
535
|
+
model: (...ops) => {
|
|
536
|
+
return (b) => {
|
|
537
|
+
return ops.reduce((b2, op) => op(b2), b);
|
|
538
|
+
};
|
|
539
|
+
},
|
|
540
|
+
rel: (source, target, _props) => {
|
|
541
|
+
return (b) => {
|
|
542
|
+
const {
|
|
543
|
+
title = "",
|
|
544
|
+
links: _links = [],
|
|
545
|
+
...props
|
|
546
|
+
} = defu(
|
|
547
|
+
typeof _props === "string" ? { title: _props } : { ..._props },
|
|
548
|
+
{ title: null, links: null }
|
|
549
|
+
);
|
|
550
|
+
const links = mapLinks(_links);
|
|
551
|
+
b.__addRelation({
|
|
552
|
+
source,
|
|
553
|
+
target,
|
|
554
|
+
title,
|
|
555
|
+
...links && { links },
|
|
556
|
+
...props
|
|
557
|
+
});
|
|
558
|
+
return b;
|
|
559
|
+
};
|
|
560
|
+
},
|
|
561
|
+
relTo: (target, _props) => {
|
|
562
|
+
return (b) => {
|
|
563
|
+
const {
|
|
564
|
+
title = "",
|
|
565
|
+
links: _links = [],
|
|
566
|
+
...props
|
|
567
|
+
} = defu(
|
|
568
|
+
typeof _props === "string" ? { title: _props } : { ..._props },
|
|
569
|
+
{ title: null, links: null }
|
|
570
|
+
);
|
|
571
|
+
const links = mapLinks(_links);
|
|
572
|
+
b.__addSourcelessRelation({
|
|
573
|
+
target,
|
|
574
|
+
title,
|
|
575
|
+
...links && { links },
|
|
576
|
+
...props
|
|
577
|
+
});
|
|
578
|
+
return b;
|
|
579
|
+
};
|
|
580
|
+
},
|
|
581
|
+
...i(
|
|
582
|
+
spec.elements,
|
|
583
|
+
({ style: specStyle, ...spec2 }, kind) => (id, _props) => {
|
|
584
|
+
const add = (b) => {
|
|
585
|
+
const {
|
|
586
|
+
links: _links,
|
|
587
|
+
icon: _icon,
|
|
588
|
+
style,
|
|
589
|
+
title,
|
|
590
|
+
...props
|
|
591
|
+
} = typeof _props === "string" ? { title: _props } : { ..._props };
|
|
592
|
+
const links = mapLinks(_links);
|
|
593
|
+
const icon = _icon ?? specStyle?.icon;
|
|
594
|
+
const _id = b.__fqn(id);
|
|
595
|
+
b.__addElement({
|
|
596
|
+
id: _id,
|
|
597
|
+
kind,
|
|
598
|
+
title: title ?? nameFromFqn(_id),
|
|
599
|
+
description: null,
|
|
600
|
+
technology: null,
|
|
601
|
+
tags: null,
|
|
602
|
+
color: specStyle?.color ?? DefaultThemeColor,
|
|
603
|
+
shape: specStyle?.shape ?? DefaultElementShape,
|
|
604
|
+
style: d({
|
|
605
|
+
border: specStyle?.border,
|
|
606
|
+
opacity: specStyle?.opacity,
|
|
607
|
+
...style
|
|
608
|
+
}, l$1),
|
|
609
|
+
links,
|
|
610
|
+
...icon && { icon },
|
|
611
|
+
...spec2,
|
|
612
|
+
...props
|
|
613
|
+
});
|
|
614
|
+
return b;
|
|
615
|
+
};
|
|
616
|
+
add.with = (...ops) => (b) => {
|
|
617
|
+
add(b);
|
|
618
|
+
const { __fqn, __addSourcelessRelation } = b;
|
|
619
|
+
try {
|
|
620
|
+
b.__fqn = (child) => `${__fqn(id)}.${child}`;
|
|
621
|
+
b.__addSourcelessRelation = (relation) => {
|
|
622
|
+
return b.__addRelation({
|
|
623
|
+
...relation,
|
|
624
|
+
source: __fqn(id)
|
|
625
|
+
});
|
|
626
|
+
};
|
|
627
|
+
ops.reduce((b2, op) => op(b2), b);
|
|
628
|
+
} finally {
|
|
629
|
+
b.__fqn = __fqn;
|
|
630
|
+
b.__addSourcelessRelation = __addSourcelessRelation;
|
|
631
|
+
}
|
|
632
|
+
return b;
|
|
633
|
+
};
|
|
634
|
+
return add;
|
|
635
|
+
}
|
|
636
|
+
)
|
|
637
|
+
},
|
|
638
|
+
views: {
|
|
639
|
+
views: (...ops) => {
|
|
640
|
+
return (b) => {
|
|
641
|
+
return ops.reduce((b2, op) => op(b2), b);
|
|
642
|
+
};
|
|
643
|
+
},
|
|
644
|
+
view: (id, _props, _builder) => {
|
|
645
|
+
const [generic, builder2] = createGenericView(id, _props, _builder);
|
|
646
|
+
const view = {
|
|
647
|
+
...generic,
|
|
648
|
+
__: "element",
|
|
649
|
+
rules: []
|
|
650
|
+
};
|
|
651
|
+
const add = (b) => {
|
|
652
|
+
b.__addView(view);
|
|
653
|
+
if (builder2) {
|
|
654
|
+
builder2(mkViewBuilder(view));
|
|
655
|
+
}
|
|
656
|
+
return b;
|
|
657
|
+
};
|
|
658
|
+
add.with = (...ops) => (b) => {
|
|
659
|
+
add(b);
|
|
660
|
+
const elementViewBuilder = mkViewBuilder(view);
|
|
661
|
+
for (const op of ops) {
|
|
662
|
+
op(elementViewBuilder);
|
|
663
|
+
}
|
|
664
|
+
return b;
|
|
665
|
+
};
|
|
666
|
+
return add;
|
|
667
|
+
},
|
|
668
|
+
viewOf: (id, viewOf, _props, _builder) => {
|
|
669
|
+
const [generic, builder2] = createGenericView(id, _props, _builder);
|
|
670
|
+
const view = {
|
|
671
|
+
...generic,
|
|
672
|
+
viewOf,
|
|
673
|
+
__: "element",
|
|
674
|
+
rules: []
|
|
675
|
+
};
|
|
676
|
+
const add = (b) => {
|
|
677
|
+
b.__addView(view);
|
|
678
|
+
if (builder2) {
|
|
679
|
+
builder2(mkViewBuilder(view));
|
|
680
|
+
}
|
|
681
|
+
return b;
|
|
682
|
+
};
|
|
683
|
+
add.with = (...ops) => (b) => {
|
|
684
|
+
add(b);
|
|
685
|
+
const elementViewBuilder = mkViewBuilder(view);
|
|
686
|
+
for (const op of ops) {
|
|
687
|
+
op(elementViewBuilder);
|
|
688
|
+
}
|
|
689
|
+
return b;
|
|
690
|
+
};
|
|
691
|
+
return add;
|
|
692
|
+
},
|
|
693
|
+
deploymentView: (id, _props, _builder) => {
|
|
694
|
+
const [generic, builder2] = createGenericView(id, _props, _builder);
|
|
695
|
+
const view = {
|
|
696
|
+
...generic,
|
|
697
|
+
__: "deployment",
|
|
698
|
+
rules: []
|
|
699
|
+
};
|
|
700
|
+
const add = (b) => {
|
|
701
|
+
b.__addView(view);
|
|
702
|
+
if (builder2) {
|
|
703
|
+
builder2(mkViewBuilder(view));
|
|
704
|
+
}
|
|
705
|
+
return b;
|
|
706
|
+
};
|
|
707
|
+
add.with = (...ops) => (b) => {
|
|
708
|
+
add(b);
|
|
709
|
+
const elementViewBuilder = mkViewBuilder(view);
|
|
710
|
+
for (const op of ops) {
|
|
711
|
+
op(elementViewBuilder);
|
|
712
|
+
}
|
|
713
|
+
return b;
|
|
714
|
+
};
|
|
715
|
+
return add;
|
|
716
|
+
},
|
|
717
|
+
$autoLayout,
|
|
718
|
+
$exclude,
|
|
719
|
+
$include,
|
|
720
|
+
$rules,
|
|
721
|
+
$style
|
|
722
|
+
},
|
|
723
|
+
deployment: {
|
|
724
|
+
deployment: (...ops) => {
|
|
725
|
+
return (b) => {
|
|
726
|
+
return ops.reduce((b2, op) => op(b2), b);
|
|
727
|
+
};
|
|
728
|
+
},
|
|
729
|
+
instanceOf: (id, target, _props) => {
|
|
730
|
+
return (b) => {
|
|
731
|
+
if (n$1(target)) {
|
|
732
|
+
target = id;
|
|
733
|
+
id = nameFromFqn(id);
|
|
734
|
+
} else if (typeof target === "string") {
|
|
735
|
+
_props ??= {};
|
|
736
|
+
} else {
|
|
737
|
+
_props = target;
|
|
738
|
+
target = id;
|
|
739
|
+
id = nameFromFqn(id);
|
|
740
|
+
}
|
|
741
|
+
const {
|
|
742
|
+
links,
|
|
743
|
+
title,
|
|
744
|
+
...props
|
|
745
|
+
} = typeof _props === "string" ? { title: _props } : { ..._props };
|
|
746
|
+
const _id = b.__fqn(id);
|
|
747
|
+
invariant(_elements.has(target), `Target element with id "${target}" not found`);
|
|
748
|
+
b.__addDeployment({
|
|
749
|
+
id: _id,
|
|
750
|
+
element: target,
|
|
751
|
+
...title && { title },
|
|
752
|
+
...links && { links: mapLinks(links) },
|
|
753
|
+
...props
|
|
754
|
+
});
|
|
755
|
+
return b;
|
|
756
|
+
};
|
|
757
|
+
},
|
|
758
|
+
rel: (source, target, _props) => {
|
|
759
|
+
return (b) => {
|
|
760
|
+
const {
|
|
761
|
+
title,
|
|
762
|
+
links,
|
|
763
|
+
...props
|
|
764
|
+
} = typeof _props === "string" ? { title: _props } : { ..._props };
|
|
765
|
+
b.__addDeploymentRelation({
|
|
766
|
+
source: {
|
|
767
|
+
id: source
|
|
768
|
+
},
|
|
769
|
+
target: {
|
|
770
|
+
id: target
|
|
771
|
+
},
|
|
772
|
+
...title && { title },
|
|
773
|
+
...links && { links: mapLinks(links) },
|
|
774
|
+
...props
|
|
775
|
+
});
|
|
776
|
+
return b;
|
|
777
|
+
};
|
|
778
|
+
},
|
|
779
|
+
...i(
|
|
780
|
+
spec.deployments ?? {},
|
|
781
|
+
({ style: specStyle, ...spec2 }, kind) => (id, _props) => {
|
|
782
|
+
const add = (b) => {
|
|
783
|
+
const {
|
|
784
|
+
links,
|
|
785
|
+
icon: _icon,
|
|
786
|
+
style,
|
|
787
|
+
title,
|
|
788
|
+
...props
|
|
789
|
+
} = typeof _props === "string" ? { title: _props } : { ..._props };
|
|
790
|
+
const icon = _icon ?? specStyle?.icon;
|
|
791
|
+
const _id = b.__fqn(id);
|
|
792
|
+
b.__addDeployment({
|
|
793
|
+
id: _id,
|
|
794
|
+
kind,
|
|
795
|
+
title: title ?? nameFromFqn(_id),
|
|
796
|
+
description: null,
|
|
797
|
+
technology: null,
|
|
798
|
+
tags: null,
|
|
799
|
+
color: specStyle?.color ?? DefaultThemeColor,
|
|
800
|
+
shape: specStyle?.shape ?? DefaultElementShape,
|
|
801
|
+
style: d({
|
|
802
|
+
border: specStyle?.border,
|
|
803
|
+
opacity: specStyle?.opacity,
|
|
804
|
+
...style
|
|
805
|
+
}, l$1),
|
|
806
|
+
...links && { links: mapLinks(links) },
|
|
807
|
+
...icon && { icon },
|
|
808
|
+
...spec2,
|
|
809
|
+
...props
|
|
810
|
+
});
|
|
811
|
+
return b;
|
|
812
|
+
};
|
|
813
|
+
add.with = (...ops) => (b) => {
|
|
814
|
+
add(b);
|
|
815
|
+
const { __fqn } = b;
|
|
816
|
+
try {
|
|
817
|
+
b.__fqn = (child) => `${__fqn(id)}.${child}`;
|
|
818
|
+
ops.reduce((b2, op) => op(b2), b);
|
|
819
|
+
} finally {
|
|
820
|
+
b.__fqn = __fqn;
|
|
821
|
+
}
|
|
822
|
+
return b;
|
|
823
|
+
};
|
|
824
|
+
return add;
|
|
825
|
+
}
|
|
826
|
+
)
|
|
827
|
+
}
|
|
828
|
+
}),
|
|
829
|
+
with: (...ops) => {
|
|
830
|
+
return ops.reduce((b, op) => op(b), self).clone();
|
|
831
|
+
},
|
|
832
|
+
model: (cb) => {
|
|
833
|
+
const b = self.clone();
|
|
834
|
+
const helpers = b.helpers().model;
|
|
835
|
+
const _ = helpers.model;
|
|
836
|
+
return cb({ ...helpers, _ }, _)(b);
|
|
837
|
+
},
|
|
838
|
+
deployment: (cb) => {
|
|
839
|
+
const b = self.clone();
|
|
840
|
+
const helpers = b.helpers().deployment;
|
|
841
|
+
const _ = helpers.deployment;
|
|
842
|
+
return cb({ ...helpers, _ }, _)(b);
|
|
843
|
+
},
|
|
844
|
+
views: (cb) => {
|
|
845
|
+
const b = self.clone();
|
|
846
|
+
const helpers = b.helpers().views;
|
|
847
|
+
return cb({
|
|
848
|
+
...helpers,
|
|
849
|
+
_: helpers.views
|
|
850
|
+
}, helpers.views)(b);
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
return self;
|
|
854
|
+
}
|
|
855
|
+
var Builder;
|
|
856
|
+
((Builder2) => {
|
|
857
|
+
function forSpecification(spec) {
|
|
858
|
+
const b = builder(spec);
|
|
859
|
+
return {
|
|
860
|
+
...b.helpers(),
|
|
861
|
+
builder: b
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
Builder2.forSpecification = forSpecification;
|
|
865
|
+
function specification(spec) {
|
|
866
|
+
return builder(spec);
|
|
867
|
+
}
|
|
868
|
+
Builder2.specification = specification;
|
|
869
|
+
})(Builder || (Builder = {}));
|
|
870
|
+
|
|
871
|
+
export { Builder };
|