@likec4/core 1.8.0 → 1.9.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/dist/index.cjs +4368 -0
- package/dist/index.d.cts +781 -0
- package/dist/index.d.mts +781 -0
- package/dist/index.mjs +4296 -0
- package/dist/shared/core.9l7eW3pn.d.cts +817 -0
- package/dist/shared/core.9l7eW3pn.d.mts +817 -0
- package/dist/shared/core.DcPLm41i.cjs +304 -0
- package/dist/shared/core.DfUTsojZ.mjs +251 -0
- package/dist/types/index.cjs +53 -0
- package/dist/types/index.d.cts +1 -0
- package/dist/types/index.d.mts +1 -0
- package/dist/types/index.mjs +1 -0
- package/package.json +41 -33
- package/src/colors/index.ts +27 -1
- package/src/errors/index.ts +3 -95
- package/src/index.ts +5 -6
- package/src/model/LikeC4Model.ts +480 -0
- package/src/model/LikeC4ViewModel.ts +318 -0
- package/src/model/__test__/LikeC4Model.spec.ts +79 -0
- package/src/model/__test__/fixture.ts +333 -0
- package/src/model/index.ts +2 -0
- package/src/model/types.ts +10 -0
- package/src/types/_common.ts +4 -2
- package/src/types/element.ts +8 -8
- package/src/types/expression.ts +3 -3
- package/src/types/index.ts +0 -1
- package/src/types/model.ts +16 -6
- package/src/types/relation.ts +15 -5
- package/src/types/theme.ts +28 -12
- package/src/types/view-notation.ts +3 -4
- package/src/types/view.ts +14 -10
- package/src/utils/fqn.ts +7 -4
- package/src/utils/relations.spec.ts +1 -3
- package/src/utils/relations.ts +7 -17
- package/dist/colors/element.d.ts +0 -69
- package/dist/colors/element.js +0 -75
- package/dist/colors/index.d.ts +0 -133
- package/dist/colors/index.js +0 -9
- package/dist/colors/relationships.d.ts +0 -58
- package/dist/colors/relationships.js +0 -49
- package/dist/errors/errors.spec.d.ts +0 -2
- package/dist/errors/errors.spec.js +0 -69
- package/dist/errors/index.d.ts +0 -39
- package/dist/errors/index.js +0 -104
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -4
- package/dist/types/_common.d.ts +0 -9
- package/dist/types/_common.js +0 -1
- package/dist/types/element.d.ts +0 -55
- package/dist/types/element.js +0 -15
- package/dist/types/expression.d.ts +0 -119
- package/dist/types/expression.js +0 -67
- package/dist/types/index.d.ts +0 -14
- package/dist/types/index.js +0 -14
- package/dist/types/model.d.ts +0 -14
- package/dist/types/model.js +0 -1
- package/dist/types/opaque.d.ts +0 -103
- package/dist/types/opaque.js +0 -1
- package/dist/types/operators.d.ts +0 -44
- package/dist/types/operators.js +0 -59
- package/dist/types/overview-graph.d.ts +0 -41
- package/dist/types/overview-graph.js +0 -1
- package/dist/types/relation.d.ts +0 -30
- package/dist/types/relation.js +0 -3
- package/dist/types/theme.d.ts +0 -27
- package/dist/types/theme.js +0 -1
- package/dist/types/view-changes.d.ts +0 -26
- package/dist/types/view-changes.js +0 -1
- package/dist/types/view-notation.d.ts +0 -9
- package/dist/types/view-notation.js +0 -1
- package/dist/types/view.d.ts +0 -243
- package/dist/types/view.js +0 -50
- package/dist/utils/fqn.d.ts +0 -39
- package/dist/utils/fqn.js +0 -102
- package/dist/utils/fqn.spec.d.ts +0 -2
- package/dist/utils/fqn.spec.js +0 -82
- package/dist/utils/guards.d.ts +0 -5
- package/dist/utils/guards.js +0 -7
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/index.js +0 -4
- package/dist/utils/promises.d.ts +0 -2
- package/dist/utils/promises.js +0 -8
- package/dist/utils/relations.d.ts +0 -30
- package/dist/utils/relations.js +0 -79
- package/dist/utils/relations.spec.d.ts +0 -2
- package/dist/utils/relations.spec.js +0 -210
- package/src/errors/errors.spec.ts +0 -88
- package/src/reset.d.ts +0 -2
- package/src/types/opaque.ts +0 -108
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function nonNullable(value, message) {
|
|
4
|
+
if (typeof value === "undefined" || value == null) {
|
|
5
|
+
throw new Error(message ?? `Expected defined value, but received ${value}`);
|
|
6
|
+
}
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
function invariant(condition, message) {
|
|
10
|
+
if (condition) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
throw new Error(message ?? "Invariant failed");
|
|
14
|
+
}
|
|
15
|
+
function nonexhaustive(value) {
|
|
16
|
+
throw new Error(`NonExhaustive value: ${value}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function u$1(t,n,a){let o=r=>t(r,...n);return a===void 0?o:Object.assign(o,{lazy:a,lazyArgs:n})}
|
|
20
|
+
|
|
21
|
+
function u(r,n,a){let o=r.length-n.length;if(o===0)return r(...n);if(o===1)return u$1(r,n,a);throw new Error("Wrong number of arguments")}
|
|
22
|
+
|
|
23
|
+
function o(a){return t=>!a(t)}
|
|
24
|
+
|
|
25
|
+
function e$1(n){return n==null}
|
|
26
|
+
|
|
27
|
+
function t(...a){return u(e,a)}var e=(a,o)=>o.every(l=>l(a));
|
|
28
|
+
|
|
29
|
+
function y(...a){return u(r,a)}var r=(a,o)=>o.some(e=>e(a));
|
|
30
|
+
|
|
31
|
+
function AsFqn(name, parent) {
|
|
32
|
+
return parent ? parent + "." + name : name;
|
|
33
|
+
}
|
|
34
|
+
const BorderStyles = ["solid", "dashed", "dotted", "none"];
|
|
35
|
+
const ElementShapes = [
|
|
36
|
+
"rectangle",
|
|
37
|
+
"person",
|
|
38
|
+
"browser",
|
|
39
|
+
"mobile",
|
|
40
|
+
"cylinder",
|
|
41
|
+
"storage",
|
|
42
|
+
"queue"
|
|
43
|
+
];
|
|
44
|
+
const DefaultThemeColor = "primary";
|
|
45
|
+
const DefaultElementShape = "rectangle";
|
|
46
|
+
|
|
47
|
+
function isElementRef(expr) {
|
|
48
|
+
return "element" in expr;
|
|
49
|
+
}
|
|
50
|
+
function isExpandedElementExpr(expr) {
|
|
51
|
+
return "expanded" in expr;
|
|
52
|
+
}
|
|
53
|
+
function isCustomElement(expr) {
|
|
54
|
+
return "custom" in expr && (isElement(expr.custom.expr) || isElementWhere(expr.custom.expr));
|
|
55
|
+
}
|
|
56
|
+
function isWildcard(expr) {
|
|
57
|
+
return "wildcard" in expr;
|
|
58
|
+
}
|
|
59
|
+
function isElementKindExpr(expr) {
|
|
60
|
+
return "elementKind" in expr && "isEqual" in expr;
|
|
61
|
+
}
|
|
62
|
+
function isElementTagExpr(expr) {
|
|
63
|
+
return "elementTag" in expr && "isEqual" in expr;
|
|
64
|
+
}
|
|
65
|
+
function isElement(expr) {
|
|
66
|
+
return isElementRef(expr) || isWildcard(expr) || isElementKindExpr(expr) || isElementTagExpr(expr) || isExpandedElementExpr(expr);
|
|
67
|
+
}
|
|
68
|
+
function isElementWhere(expr) {
|
|
69
|
+
return "where" in expr && isElement(expr.where.expr);
|
|
70
|
+
}
|
|
71
|
+
function isElementPredicateExpr(expr) {
|
|
72
|
+
return isElement(expr) || isElementWhere(expr) || isCustomElement(expr);
|
|
73
|
+
}
|
|
74
|
+
function isRelation(expr) {
|
|
75
|
+
return "source" in expr && "target" in expr;
|
|
76
|
+
}
|
|
77
|
+
function isInOut(expr) {
|
|
78
|
+
return "inout" in expr;
|
|
79
|
+
}
|
|
80
|
+
function isIncoming(expr) {
|
|
81
|
+
return "incoming" in expr;
|
|
82
|
+
}
|
|
83
|
+
function isOutgoing(expr) {
|
|
84
|
+
return "outgoing" in expr;
|
|
85
|
+
}
|
|
86
|
+
function isRelationExpression(expr) {
|
|
87
|
+
return isRelation(expr) || isInOut(expr) || isIncoming(expr) || isOutgoing(expr);
|
|
88
|
+
}
|
|
89
|
+
function isRelationWhere(expr) {
|
|
90
|
+
return "where" in expr && isRelationExpression(expr.where.expr);
|
|
91
|
+
}
|
|
92
|
+
function isCustomRelationExpr(expr) {
|
|
93
|
+
return "customRelation" in expr;
|
|
94
|
+
}
|
|
95
|
+
function isRelationPredicateExpr(expr) {
|
|
96
|
+
return isRelationExpression(expr) || isRelationWhere(expr) || isCustomRelationExpr(expr);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const expression = {
|
|
100
|
+
__proto__: null,
|
|
101
|
+
isCustomElement: isCustomElement,
|
|
102
|
+
isCustomRelationExpr: isCustomRelationExpr,
|
|
103
|
+
isElement: isElement,
|
|
104
|
+
isElementKindExpr: isElementKindExpr,
|
|
105
|
+
isElementPredicateExpr: isElementPredicateExpr,
|
|
106
|
+
isElementRef: isElementRef,
|
|
107
|
+
isElementTagExpr: isElementTagExpr,
|
|
108
|
+
isElementWhere: isElementWhere,
|
|
109
|
+
isExpandedElementExpr: isExpandedElementExpr,
|
|
110
|
+
isInOut: isInOut,
|
|
111
|
+
isIncoming: isIncoming,
|
|
112
|
+
isOutgoing: isOutgoing,
|
|
113
|
+
isRelation: isRelation,
|
|
114
|
+
isRelationExpression: isRelationExpression,
|
|
115
|
+
isRelationPredicateExpr: isRelationPredicateExpr,
|
|
116
|
+
isRelationWhere: isRelationWhere,
|
|
117
|
+
isWildcard: isWildcard
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const isTagEqual = (operator) => {
|
|
121
|
+
return "tag" in operator;
|
|
122
|
+
};
|
|
123
|
+
const isKindEqual = (operator) => {
|
|
124
|
+
return "kind" in operator;
|
|
125
|
+
};
|
|
126
|
+
const isNotOperator = (operator) => {
|
|
127
|
+
return "not" in operator;
|
|
128
|
+
};
|
|
129
|
+
const isAndOperator = (operator) => {
|
|
130
|
+
return "and" in operator;
|
|
131
|
+
};
|
|
132
|
+
const isOrOperator = (operator) => {
|
|
133
|
+
return "or" in operator;
|
|
134
|
+
};
|
|
135
|
+
function whereOperatorAsPredicate(operator) {
|
|
136
|
+
switch (true) {
|
|
137
|
+
case isTagEqual(operator): {
|
|
138
|
+
if ("eq" in operator.tag) {
|
|
139
|
+
const tag2 = operator.tag.eq;
|
|
140
|
+
return (value) => {
|
|
141
|
+
return Array.isArray(value.tags) && value.tags.includes(tag2);
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
const tag = operator.tag.neq;
|
|
145
|
+
return (value) => {
|
|
146
|
+
return !Array.isArray(value.tags) || !value.tags.includes(tag);
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
case isKindEqual(operator): {
|
|
150
|
+
if ("eq" in operator.kind) {
|
|
151
|
+
const kind2 = operator.kind.eq;
|
|
152
|
+
return (value) => {
|
|
153
|
+
return value.kind === kind2;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const kind = operator.kind.neq;
|
|
157
|
+
return (value) => {
|
|
158
|
+
return e$1(value.kind) || value.kind !== kind;
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
case isNotOperator(operator): {
|
|
162
|
+
const predicate = whereOperatorAsPredicate(operator.not);
|
|
163
|
+
return o(predicate);
|
|
164
|
+
}
|
|
165
|
+
case isAndOperator(operator): {
|
|
166
|
+
const predicates = operator.and.map(whereOperatorAsPredicate);
|
|
167
|
+
return t(predicates);
|
|
168
|
+
}
|
|
169
|
+
case isOrOperator(operator): {
|
|
170
|
+
const predicates = operator.or.map(whereOperatorAsPredicate);
|
|
171
|
+
return y(predicates);
|
|
172
|
+
}
|
|
173
|
+
default:
|
|
174
|
+
nonexhaustive(operator);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const DefaultLineStyle = "dashed";
|
|
179
|
+
const DefaultArrowType = "normal";
|
|
180
|
+
const DefaultRelationshipColor = "gray";
|
|
181
|
+
|
|
182
|
+
const ThemeColors = [
|
|
183
|
+
"amber",
|
|
184
|
+
"blue",
|
|
185
|
+
"gray",
|
|
186
|
+
"slate",
|
|
187
|
+
"green",
|
|
188
|
+
"indigo",
|
|
189
|
+
"muted",
|
|
190
|
+
"primary",
|
|
191
|
+
"red",
|
|
192
|
+
"secondary",
|
|
193
|
+
"sky"
|
|
194
|
+
];
|
|
195
|
+
function isThemeColor(color) {
|
|
196
|
+
return color in ThemeColors;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function isViewRulePredicate(rule) {
|
|
200
|
+
return "include" in rule && Array.isArray(rule.include) || "exclude" in rule && Array.isArray(rule.exclude);
|
|
201
|
+
}
|
|
202
|
+
function isViewRuleStyle(rule) {
|
|
203
|
+
return "style" in rule && "targets" in rule;
|
|
204
|
+
}
|
|
205
|
+
function isViewRuleAutoLayout(rule) {
|
|
206
|
+
return "autoLayout" in rule;
|
|
207
|
+
}
|
|
208
|
+
function isDynamicViewIncludeRule(rule) {
|
|
209
|
+
return "include" in rule && Array.isArray(rule.include);
|
|
210
|
+
}
|
|
211
|
+
function isDynamicView(view) {
|
|
212
|
+
return view.__ === "dynamic";
|
|
213
|
+
}
|
|
214
|
+
function isElementView(view) {
|
|
215
|
+
return e$1(view.__) || view.__ === "element";
|
|
216
|
+
}
|
|
217
|
+
function isExtendsElementView(view) {
|
|
218
|
+
return isElementView(view) && "extends" in view;
|
|
219
|
+
}
|
|
220
|
+
function isScopedElementView(view) {
|
|
221
|
+
return isElementView(view) && "viewOf" in view;
|
|
222
|
+
}
|
|
223
|
+
function StepEdgeId(step) {
|
|
224
|
+
return `step-${String(step).padStart(3, "0")}`;
|
|
225
|
+
}
|
|
226
|
+
function isStepEdgeId(id) {
|
|
227
|
+
return id.startsWith("step-");
|
|
228
|
+
}
|
|
229
|
+
function extractStep(id) {
|
|
230
|
+
if (!isStepEdgeId(id)) {
|
|
231
|
+
throw new Error(`Invalid step edge id: ${id}`);
|
|
232
|
+
}
|
|
233
|
+
return Number(id.slice("step-".length));
|
|
234
|
+
}
|
|
235
|
+
function isComputedDynamicView(view) {
|
|
236
|
+
return view.__ === "dynamic";
|
|
237
|
+
}
|
|
238
|
+
function isComputedElementView(view) {
|
|
239
|
+
return e$1(view.__) || view.__ === "element";
|
|
240
|
+
}
|
|
241
|
+
function getBBoxCenter({
|
|
242
|
+
x,
|
|
243
|
+
y,
|
|
244
|
+
width,
|
|
245
|
+
height
|
|
246
|
+
}) {
|
|
247
|
+
return {
|
|
248
|
+
x: x + width / 2,
|
|
249
|
+
y: y + height / 2
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
exports.AsFqn = AsFqn;
|
|
254
|
+
exports.BorderStyles = BorderStyles;
|
|
255
|
+
exports.DefaultArrowType = DefaultArrowType;
|
|
256
|
+
exports.DefaultElementShape = DefaultElementShape;
|
|
257
|
+
exports.DefaultLineStyle = DefaultLineStyle;
|
|
258
|
+
exports.DefaultRelationshipColor = DefaultRelationshipColor;
|
|
259
|
+
exports.DefaultThemeColor = DefaultThemeColor;
|
|
260
|
+
exports.ElementShapes = ElementShapes;
|
|
261
|
+
exports.StepEdgeId = StepEdgeId;
|
|
262
|
+
exports.e = e$1;
|
|
263
|
+
exports.expression = expression;
|
|
264
|
+
exports.extractStep = extractStep;
|
|
265
|
+
exports.getBBoxCenter = getBBoxCenter;
|
|
266
|
+
exports.invariant = invariant;
|
|
267
|
+
exports.isAndOperator = isAndOperator;
|
|
268
|
+
exports.isComputedDynamicView = isComputedDynamicView;
|
|
269
|
+
exports.isComputedElementView = isComputedElementView;
|
|
270
|
+
exports.isCustomElement = isCustomElement;
|
|
271
|
+
exports.isCustomRelationExpr = isCustomRelationExpr;
|
|
272
|
+
exports.isDynamicView = isDynamicView;
|
|
273
|
+
exports.isDynamicViewIncludeRule = isDynamicViewIncludeRule;
|
|
274
|
+
exports.isElement = isElement;
|
|
275
|
+
exports.isElementKindExpr = isElementKindExpr;
|
|
276
|
+
exports.isElementPredicateExpr = isElementPredicateExpr;
|
|
277
|
+
exports.isElementRef = isElementRef;
|
|
278
|
+
exports.isElementTagExpr = isElementTagExpr;
|
|
279
|
+
exports.isElementView = isElementView;
|
|
280
|
+
exports.isElementWhere = isElementWhere;
|
|
281
|
+
exports.isExpandedElementExpr = isExpandedElementExpr;
|
|
282
|
+
exports.isExtendsElementView = isExtendsElementView;
|
|
283
|
+
exports.isInOut = isInOut;
|
|
284
|
+
exports.isIncoming = isIncoming;
|
|
285
|
+
exports.isKindEqual = isKindEqual;
|
|
286
|
+
exports.isNotOperator = isNotOperator;
|
|
287
|
+
exports.isOrOperator = isOrOperator;
|
|
288
|
+
exports.isOutgoing = isOutgoing;
|
|
289
|
+
exports.isRelation = isRelation;
|
|
290
|
+
exports.isRelationExpression = isRelationExpression;
|
|
291
|
+
exports.isRelationPredicateExpr = isRelationPredicateExpr;
|
|
292
|
+
exports.isRelationWhere = isRelationWhere;
|
|
293
|
+
exports.isScopedElementView = isScopedElementView;
|
|
294
|
+
exports.isStepEdgeId = isStepEdgeId;
|
|
295
|
+
exports.isTagEqual = isTagEqual;
|
|
296
|
+
exports.isThemeColor = isThemeColor;
|
|
297
|
+
exports.isViewRuleAutoLayout = isViewRuleAutoLayout;
|
|
298
|
+
exports.isViewRulePredicate = isViewRulePredicate;
|
|
299
|
+
exports.isViewRuleStyle = isViewRuleStyle;
|
|
300
|
+
exports.isWildcard = isWildcard;
|
|
301
|
+
exports.nonNullable = nonNullable;
|
|
302
|
+
exports.nonexhaustive = nonexhaustive;
|
|
303
|
+
exports.u = u;
|
|
304
|
+
exports.whereOperatorAsPredicate = whereOperatorAsPredicate;
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
function nonNullable(value, message) {
|
|
2
|
+
if (typeof value === "undefined" || value == null) {
|
|
3
|
+
throw new Error(message ?? `Expected defined value, but received ${value}`);
|
|
4
|
+
}
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
function invariant(condition, message) {
|
|
8
|
+
if (condition) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
throw new Error(message ?? "Invariant failed");
|
|
12
|
+
}
|
|
13
|
+
function nonexhaustive(value) {
|
|
14
|
+
throw new Error(`NonExhaustive value: ${value}`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function u$1(t,n,a){let o=r=>t(r,...n);return a===void 0?o:Object.assign(o,{lazy:a,lazyArgs:n})}
|
|
18
|
+
|
|
19
|
+
function u(r,n,a){let o=r.length-n.length;if(o===0)return r(...n);if(o===1)return u$1(r,n,a);throw new Error("Wrong number of arguments")}
|
|
20
|
+
|
|
21
|
+
function o(a){return t=>!a(t)}
|
|
22
|
+
|
|
23
|
+
function e$1(n){return n==null}
|
|
24
|
+
|
|
25
|
+
function t(...a){return u(e,a)}var e=(a,o)=>o.every(l=>l(a));
|
|
26
|
+
|
|
27
|
+
function y(...a){return u(r,a)}var r=(a,o)=>o.some(e=>e(a));
|
|
28
|
+
|
|
29
|
+
function AsFqn(name, parent) {
|
|
30
|
+
return parent ? parent + "." + name : name;
|
|
31
|
+
}
|
|
32
|
+
const BorderStyles = ["solid", "dashed", "dotted", "none"];
|
|
33
|
+
const ElementShapes = [
|
|
34
|
+
"rectangle",
|
|
35
|
+
"person",
|
|
36
|
+
"browser",
|
|
37
|
+
"mobile",
|
|
38
|
+
"cylinder",
|
|
39
|
+
"storage",
|
|
40
|
+
"queue"
|
|
41
|
+
];
|
|
42
|
+
const DefaultThemeColor = "primary";
|
|
43
|
+
const DefaultElementShape = "rectangle";
|
|
44
|
+
|
|
45
|
+
function isElementRef(expr) {
|
|
46
|
+
return "element" in expr;
|
|
47
|
+
}
|
|
48
|
+
function isExpandedElementExpr(expr) {
|
|
49
|
+
return "expanded" in expr;
|
|
50
|
+
}
|
|
51
|
+
function isCustomElement(expr) {
|
|
52
|
+
return "custom" in expr && (isElement(expr.custom.expr) || isElementWhere(expr.custom.expr));
|
|
53
|
+
}
|
|
54
|
+
function isWildcard(expr) {
|
|
55
|
+
return "wildcard" in expr;
|
|
56
|
+
}
|
|
57
|
+
function isElementKindExpr(expr) {
|
|
58
|
+
return "elementKind" in expr && "isEqual" in expr;
|
|
59
|
+
}
|
|
60
|
+
function isElementTagExpr(expr) {
|
|
61
|
+
return "elementTag" in expr && "isEqual" in expr;
|
|
62
|
+
}
|
|
63
|
+
function isElement(expr) {
|
|
64
|
+
return isElementRef(expr) || isWildcard(expr) || isElementKindExpr(expr) || isElementTagExpr(expr) || isExpandedElementExpr(expr);
|
|
65
|
+
}
|
|
66
|
+
function isElementWhere(expr) {
|
|
67
|
+
return "where" in expr && isElement(expr.where.expr);
|
|
68
|
+
}
|
|
69
|
+
function isElementPredicateExpr(expr) {
|
|
70
|
+
return isElement(expr) || isElementWhere(expr) || isCustomElement(expr);
|
|
71
|
+
}
|
|
72
|
+
function isRelation(expr) {
|
|
73
|
+
return "source" in expr && "target" in expr;
|
|
74
|
+
}
|
|
75
|
+
function isInOut(expr) {
|
|
76
|
+
return "inout" in expr;
|
|
77
|
+
}
|
|
78
|
+
function isIncoming(expr) {
|
|
79
|
+
return "incoming" in expr;
|
|
80
|
+
}
|
|
81
|
+
function isOutgoing(expr) {
|
|
82
|
+
return "outgoing" in expr;
|
|
83
|
+
}
|
|
84
|
+
function isRelationExpression(expr) {
|
|
85
|
+
return isRelation(expr) || isInOut(expr) || isIncoming(expr) || isOutgoing(expr);
|
|
86
|
+
}
|
|
87
|
+
function isRelationWhere(expr) {
|
|
88
|
+
return "where" in expr && isRelationExpression(expr.where.expr);
|
|
89
|
+
}
|
|
90
|
+
function isCustomRelationExpr(expr) {
|
|
91
|
+
return "customRelation" in expr;
|
|
92
|
+
}
|
|
93
|
+
function isRelationPredicateExpr(expr) {
|
|
94
|
+
return isRelationExpression(expr) || isRelationWhere(expr) || isCustomRelationExpr(expr);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const expression = {
|
|
98
|
+
__proto__: null,
|
|
99
|
+
isCustomElement: isCustomElement,
|
|
100
|
+
isCustomRelationExpr: isCustomRelationExpr,
|
|
101
|
+
isElement: isElement,
|
|
102
|
+
isElementKindExpr: isElementKindExpr,
|
|
103
|
+
isElementPredicateExpr: isElementPredicateExpr,
|
|
104
|
+
isElementRef: isElementRef,
|
|
105
|
+
isElementTagExpr: isElementTagExpr,
|
|
106
|
+
isElementWhere: isElementWhere,
|
|
107
|
+
isExpandedElementExpr: isExpandedElementExpr,
|
|
108
|
+
isInOut: isInOut,
|
|
109
|
+
isIncoming: isIncoming,
|
|
110
|
+
isOutgoing: isOutgoing,
|
|
111
|
+
isRelation: isRelation,
|
|
112
|
+
isRelationExpression: isRelationExpression,
|
|
113
|
+
isRelationPredicateExpr: isRelationPredicateExpr,
|
|
114
|
+
isRelationWhere: isRelationWhere,
|
|
115
|
+
isWildcard: isWildcard
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const isTagEqual = (operator) => {
|
|
119
|
+
return "tag" in operator;
|
|
120
|
+
};
|
|
121
|
+
const isKindEqual = (operator) => {
|
|
122
|
+
return "kind" in operator;
|
|
123
|
+
};
|
|
124
|
+
const isNotOperator = (operator) => {
|
|
125
|
+
return "not" in operator;
|
|
126
|
+
};
|
|
127
|
+
const isAndOperator = (operator) => {
|
|
128
|
+
return "and" in operator;
|
|
129
|
+
};
|
|
130
|
+
const isOrOperator = (operator) => {
|
|
131
|
+
return "or" in operator;
|
|
132
|
+
};
|
|
133
|
+
function whereOperatorAsPredicate(operator) {
|
|
134
|
+
switch (true) {
|
|
135
|
+
case isTagEqual(operator): {
|
|
136
|
+
if ("eq" in operator.tag) {
|
|
137
|
+
const tag2 = operator.tag.eq;
|
|
138
|
+
return (value) => {
|
|
139
|
+
return Array.isArray(value.tags) && value.tags.includes(tag2);
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
const tag = operator.tag.neq;
|
|
143
|
+
return (value) => {
|
|
144
|
+
return !Array.isArray(value.tags) || !value.tags.includes(tag);
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
case isKindEqual(operator): {
|
|
148
|
+
if ("eq" in operator.kind) {
|
|
149
|
+
const kind2 = operator.kind.eq;
|
|
150
|
+
return (value) => {
|
|
151
|
+
return value.kind === kind2;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
const kind = operator.kind.neq;
|
|
155
|
+
return (value) => {
|
|
156
|
+
return e$1(value.kind) || value.kind !== kind;
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
case isNotOperator(operator): {
|
|
160
|
+
const predicate = whereOperatorAsPredicate(operator.not);
|
|
161
|
+
return o(predicate);
|
|
162
|
+
}
|
|
163
|
+
case isAndOperator(operator): {
|
|
164
|
+
const predicates = operator.and.map(whereOperatorAsPredicate);
|
|
165
|
+
return t(predicates);
|
|
166
|
+
}
|
|
167
|
+
case isOrOperator(operator): {
|
|
168
|
+
const predicates = operator.or.map(whereOperatorAsPredicate);
|
|
169
|
+
return y(predicates);
|
|
170
|
+
}
|
|
171
|
+
default:
|
|
172
|
+
nonexhaustive(operator);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const DefaultLineStyle = "dashed";
|
|
177
|
+
const DefaultArrowType = "normal";
|
|
178
|
+
const DefaultRelationshipColor = "gray";
|
|
179
|
+
|
|
180
|
+
const ThemeColors = [
|
|
181
|
+
"amber",
|
|
182
|
+
"blue",
|
|
183
|
+
"gray",
|
|
184
|
+
"slate",
|
|
185
|
+
"green",
|
|
186
|
+
"indigo",
|
|
187
|
+
"muted",
|
|
188
|
+
"primary",
|
|
189
|
+
"red",
|
|
190
|
+
"secondary",
|
|
191
|
+
"sky"
|
|
192
|
+
];
|
|
193
|
+
function isThemeColor(color) {
|
|
194
|
+
return color in ThemeColors;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function isViewRulePredicate(rule) {
|
|
198
|
+
return "include" in rule && Array.isArray(rule.include) || "exclude" in rule && Array.isArray(rule.exclude);
|
|
199
|
+
}
|
|
200
|
+
function isViewRuleStyle(rule) {
|
|
201
|
+
return "style" in rule && "targets" in rule;
|
|
202
|
+
}
|
|
203
|
+
function isViewRuleAutoLayout(rule) {
|
|
204
|
+
return "autoLayout" in rule;
|
|
205
|
+
}
|
|
206
|
+
function isDynamicViewIncludeRule(rule) {
|
|
207
|
+
return "include" in rule && Array.isArray(rule.include);
|
|
208
|
+
}
|
|
209
|
+
function isDynamicView(view) {
|
|
210
|
+
return view.__ === "dynamic";
|
|
211
|
+
}
|
|
212
|
+
function isElementView(view) {
|
|
213
|
+
return e$1(view.__) || view.__ === "element";
|
|
214
|
+
}
|
|
215
|
+
function isExtendsElementView(view) {
|
|
216
|
+
return isElementView(view) && "extends" in view;
|
|
217
|
+
}
|
|
218
|
+
function isScopedElementView(view) {
|
|
219
|
+
return isElementView(view) && "viewOf" in view;
|
|
220
|
+
}
|
|
221
|
+
function StepEdgeId(step) {
|
|
222
|
+
return `step-${String(step).padStart(3, "0")}`;
|
|
223
|
+
}
|
|
224
|
+
function isStepEdgeId(id) {
|
|
225
|
+
return id.startsWith("step-");
|
|
226
|
+
}
|
|
227
|
+
function extractStep(id) {
|
|
228
|
+
if (!isStepEdgeId(id)) {
|
|
229
|
+
throw new Error(`Invalid step edge id: ${id}`);
|
|
230
|
+
}
|
|
231
|
+
return Number(id.slice("step-".length));
|
|
232
|
+
}
|
|
233
|
+
function isComputedDynamicView(view) {
|
|
234
|
+
return view.__ === "dynamic";
|
|
235
|
+
}
|
|
236
|
+
function isComputedElementView(view) {
|
|
237
|
+
return e$1(view.__) || view.__ === "element";
|
|
238
|
+
}
|
|
239
|
+
function getBBoxCenter({
|
|
240
|
+
x,
|
|
241
|
+
y,
|
|
242
|
+
width,
|
|
243
|
+
height
|
|
244
|
+
}) {
|
|
245
|
+
return {
|
|
246
|
+
x: x + width / 2,
|
|
247
|
+
y: y + height / 2
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export { AsFqn as A, BorderStyles as B, isNotOperator as C, DefaultElementShape as D, ElementShapes as E, isAndOperator as F, isOrOperator as G, whereOperatorAsPredicate as H, DefaultLineStyle as I, DefaultArrowType as J, DefaultRelationshipColor as K, isThemeColor as L, isViewRulePredicate as M, isViewRuleStyle as N, isViewRuleAutoLayout as O, isDynamicViewIncludeRule as P, isDynamicView as Q, isElementView as R, isExtendsElementView as S, isScopedElementView as T, StepEdgeId as U, isStepEdgeId as V, extractStep as W, isComputedDynamicView as X, isComputedElementView as Y, getBBoxCenter as Z, DefaultThemeColor as a, nonexhaustive as b, expression as c, isElementRef as d, e$1 as e, isExpandedElementExpr as f, isCustomElement as g, isWildcard as h, invariant as i, isElementKindExpr as j, isElementTagExpr as k, isElement as l, isElementWhere as m, nonNullable as n, isElementPredicateExpr as o, isRelation as p, isInOut as q, isIncoming as r, isOutgoing as s, isRelationExpression as t, u, isRelationWhere as v, isCustomRelationExpr as w, isRelationPredicateExpr as x, isTagEqual as y, isKindEqual as z };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const types_index = require('../shared/core.DcPLm41i.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
exports.AsFqn = types_index.AsFqn;
|
|
8
|
+
exports.BorderStyles = types_index.BorderStyles;
|
|
9
|
+
exports.DefaultArrowType = types_index.DefaultArrowType;
|
|
10
|
+
exports.DefaultElementShape = types_index.DefaultElementShape;
|
|
11
|
+
exports.DefaultLineStyle = types_index.DefaultLineStyle;
|
|
12
|
+
exports.DefaultRelationshipColor = types_index.DefaultRelationshipColor;
|
|
13
|
+
exports.DefaultThemeColor = types_index.DefaultThemeColor;
|
|
14
|
+
exports.ElementShapes = types_index.ElementShapes;
|
|
15
|
+
exports.Expr = types_index.expression;
|
|
16
|
+
exports.StepEdgeId = types_index.StepEdgeId;
|
|
17
|
+
exports.extractStep = types_index.extractStep;
|
|
18
|
+
exports.getBBoxCenter = types_index.getBBoxCenter;
|
|
19
|
+
exports.isAndOperator = types_index.isAndOperator;
|
|
20
|
+
exports.isComputedDynamicView = types_index.isComputedDynamicView;
|
|
21
|
+
exports.isComputedElementView = types_index.isComputedElementView;
|
|
22
|
+
exports.isCustomElement = types_index.isCustomElement;
|
|
23
|
+
exports.isCustomRelationExpr = types_index.isCustomRelationExpr;
|
|
24
|
+
exports.isDynamicView = types_index.isDynamicView;
|
|
25
|
+
exports.isDynamicViewIncludeRule = types_index.isDynamicViewIncludeRule;
|
|
26
|
+
exports.isElement = types_index.isElement;
|
|
27
|
+
exports.isElementKindExpr = types_index.isElementKindExpr;
|
|
28
|
+
exports.isElementPredicateExpr = types_index.isElementPredicateExpr;
|
|
29
|
+
exports.isElementRef = types_index.isElementRef;
|
|
30
|
+
exports.isElementTagExpr = types_index.isElementTagExpr;
|
|
31
|
+
exports.isElementView = types_index.isElementView;
|
|
32
|
+
exports.isElementWhere = types_index.isElementWhere;
|
|
33
|
+
exports.isExpandedElementExpr = types_index.isExpandedElementExpr;
|
|
34
|
+
exports.isExtendsElementView = types_index.isExtendsElementView;
|
|
35
|
+
exports.isInOut = types_index.isInOut;
|
|
36
|
+
exports.isIncoming = types_index.isIncoming;
|
|
37
|
+
exports.isKindEqual = types_index.isKindEqual;
|
|
38
|
+
exports.isNotOperator = types_index.isNotOperator;
|
|
39
|
+
exports.isOrOperator = types_index.isOrOperator;
|
|
40
|
+
exports.isOutgoing = types_index.isOutgoing;
|
|
41
|
+
exports.isRelation = types_index.isRelation;
|
|
42
|
+
exports.isRelationExpression = types_index.isRelationExpression;
|
|
43
|
+
exports.isRelationPredicateExpr = types_index.isRelationPredicateExpr;
|
|
44
|
+
exports.isRelationWhere = types_index.isRelationWhere;
|
|
45
|
+
exports.isScopedElementView = types_index.isScopedElementView;
|
|
46
|
+
exports.isStepEdgeId = types_index.isStepEdgeId;
|
|
47
|
+
exports.isTagEqual = types_index.isTagEqual;
|
|
48
|
+
exports.isThemeColor = types_index.isThemeColor;
|
|
49
|
+
exports.isViewRuleAutoLayout = types_index.isViewRuleAutoLayout;
|
|
50
|
+
exports.isViewRulePredicate = types_index.isViewRulePredicate;
|
|
51
|
+
exports.isViewRuleStyle = types_index.isViewRuleStyle;
|
|
52
|
+
exports.isWildcard = types_index.isWildcard;
|
|
53
|
+
exports.whereOperatorAsPredicate = types_index.whereOperatorAsPredicate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { aq as AndOperator, A as AsFqn, aP as AutoLayoutDirection, bh as BBox, aU as BasicElementView, aT as BasicView, o as BorderStyle, B as BorderStyles, e as Color, aE as ColorLiteral, be as ComputedDynamicView, f as ComputedEdge, bd as ComputedElementView, g as ComputedLikeC4Model, b as ComputedNode, C as ComputedView, m as CustomColor, b1 as CustomColorDefinitions, G as CustomElementExpr, ad as CustomRelationExpr, aA as DefaultArrowType, q as DefaultElementShape, az as DefaultLineStyle, aB as DefaultRelationshipColor, D as DefaultThemeColor, bk as DiagramEdge, bj as DiagramNode, bl as DiagramView, b0 as DynamicView, aZ as DynamicViewIncludeRule, a$ as DynamicViewRule, aY as DynamicViewStep, E as EdgeId, h as Element, U as ElementExpression, c as ElementKind, M as ElementKindExpr, v as ElementKindSpecification, u as ElementKindSpecificationStyle, bo as ElementNotation, $ as ElementPredicateExpression, w as ElementRefExpr, d as ElementShape, p as ElementShapes, r as ElementStyle, Q as ElementTagExpr, aG as ElementThemeColorValues, aH as ElementThemeColors, aX as ElementView, Z as ElementWhereExpr, aj as EqualOperator, y as ExpandedElementExpr, l as Expr, ah as Expression, aW as ExtendsElementView, F as Fqn, H as HexColorLiteral, I as IconUrl, a3 as InOutExpr, a5 as IncomingExpr, am as KindEqual, aK as LikeC4Theme, b2 as LikeC4View, t as Link, N as NodeId, k as NonEmptyArray, ao as NotOperator, as as OrOperator, a7 as OutgoingExpr, aw as OverviewGraph, ai as ParsedLikeC4Model, n as Point, i as Relation, a1 as RelationExpr, a9 as RelationExpression, R as RelationID, af as RelationPredicateExpression, ab as RelationWhereExpr, ay as RelationshipArrowType, j as RelationshipKind, aC as RelationshipKindSpecification, ax as RelationshipLineType, aI as RelationshipThemeColorValues, aJ as RelationshipThemeColors, aV as ScopedElementView, b8 as StepEdgeId, b7 as StepEdgeIdLiteral, a as Tag, ak as TagEqual, s as TagSpec, aD as ThemeColor, T as ThemeColorValues, bn as ViewChange, V as ViewID, bm as ViewManualLayout, aS as ViewRule, aQ as ViewRuleAutoLayout, aL as ViewRulePredicate, aN as ViewRuleStyle, bb as ViewWithHash, bc as ViewWithNotation, au as WhereOperator, W as WildcardExpr, X as XYPoint, ba as extractStep, bi as getBBoxCenter, ar as isAndOperator, bf as isComputedDynamicView, bg as isComputedElementView, J as isCustomElement, ae as isCustomRelationExpr, b3 as isDynamicView, a_ as isDynamicViewIncludeRule, Y as isElement, O as isElementKindExpr, a0 as isElementPredicateExpr, x as isElementRef, S as isElementTagExpr, b4 as isElementView, _ as isElementWhere, z as isExpandedElementExpr, b5 as isExtendsElementView, a4 as isInOut, a6 as isIncoming, an as isKindEqual, ap as isNotOperator, at as isOrOperator, a8 as isOutgoing, a2 as isRelation, aa as isRelationExpression, ag as isRelationPredicateExpr, ac as isRelationWhere, b6 as isScopedElementView, b9 as isStepEdgeId, al as isTagEqual, aF as isThemeColor, aR as isViewRuleAutoLayout, aM as isViewRulePredicate, aO as isViewRuleStyle, K as isWildcard, av as whereOperatorAsPredicate } from '../shared/core.9l7eW3pn.cjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { aq as AndOperator, A as AsFqn, aP as AutoLayoutDirection, bh as BBox, aU as BasicElementView, aT as BasicView, o as BorderStyle, B as BorderStyles, e as Color, aE as ColorLiteral, be as ComputedDynamicView, f as ComputedEdge, bd as ComputedElementView, g as ComputedLikeC4Model, b as ComputedNode, C as ComputedView, m as CustomColor, b1 as CustomColorDefinitions, G as CustomElementExpr, ad as CustomRelationExpr, aA as DefaultArrowType, q as DefaultElementShape, az as DefaultLineStyle, aB as DefaultRelationshipColor, D as DefaultThemeColor, bk as DiagramEdge, bj as DiagramNode, bl as DiagramView, b0 as DynamicView, aZ as DynamicViewIncludeRule, a$ as DynamicViewRule, aY as DynamicViewStep, E as EdgeId, h as Element, U as ElementExpression, c as ElementKind, M as ElementKindExpr, v as ElementKindSpecification, u as ElementKindSpecificationStyle, bo as ElementNotation, $ as ElementPredicateExpression, w as ElementRefExpr, d as ElementShape, p as ElementShapes, r as ElementStyle, Q as ElementTagExpr, aG as ElementThemeColorValues, aH as ElementThemeColors, aX as ElementView, Z as ElementWhereExpr, aj as EqualOperator, y as ExpandedElementExpr, l as Expr, ah as Expression, aW as ExtendsElementView, F as Fqn, H as HexColorLiteral, I as IconUrl, a3 as InOutExpr, a5 as IncomingExpr, am as KindEqual, aK as LikeC4Theme, b2 as LikeC4View, t as Link, N as NodeId, k as NonEmptyArray, ao as NotOperator, as as OrOperator, a7 as OutgoingExpr, aw as OverviewGraph, ai as ParsedLikeC4Model, n as Point, i as Relation, a1 as RelationExpr, a9 as RelationExpression, R as RelationID, af as RelationPredicateExpression, ab as RelationWhereExpr, ay as RelationshipArrowType, j as RelationshipKind, aC as RelationshipKindSpecification, ax as RelationshipLineType, aI as RelationshipThemeColorValues, aJ as RelationshipThemeColors, aV as ScopedElementView, b8 as StepEdgeId, b7 as StepEdgeIdLiteral, a as Tag, ak as TagEqual, s as TagSpec, aD as ThemeColor, T as ThemeColorValues, bn as ViewChange, V as ViewID, bm as ViewManualLayout, aS as ViewRule, aQ as ViewRuleAutoLayout, aL as ViewRulePredicate, aN as ViewRuleStyle, bb as ViewWithHash, bc as ViewWithNotation, au as WhereOperator, W as WildcardExpr, X as XYPoint, ba as extractStep, bi as getBBoxCenter, ar as isAndOperator, bf as isComputedDynamicView, bg as isComputedElementView, J as isCustomElement, ae as isCustomRelationExpr, b3 as isDynamicView, a_ as isDynamicViewIncludeRule, Y as isElement, O as isElementKindExpr, a0 as isElementPredicateExpr, x as isElementRef, S as isElementTagExpr, b4 as isElementView, _ as isElementWhere, z as isExpandedElementExpr, b5 as isExtendsElementView, a4 as isInOut, a6 as isIncoming, an as isKindEqual, ap as isNotOperator, at as isOrOperator, a8 as isOutgoing, a2 as isRelation, aa as isRelationExpression, ag as isRelationPredicateExpr, ac as isRelationWhere, b6 as isScopedElementView, b9 as isStepEdgeId, al as isTagEqual, aF as isThemeColor, aR as isViewRuleAutoLayout, aM as isViewRulePredicate, aO as isViewRuleStyle, K as isWildcard, av as whereOperatorAsPredicate } from '../shared/core.9l7eW3pn.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { A as AsFqn, B as BorderStyles, J as DefaultArrowType, D as DefaultElementShape, I as DefaultLineStyle, K as DefaultRelationshipColor, a as DefaultThemeColor, E as ElementShapes, c as Expr, U as StepEdgeId, W as extractStep, Z as getBBoxCenter, F as isAndOperator, X as isComputedDynamicView, Y as isComputedElementView, g as isCustomElement, w as isCustomRelationExpr, Q as isDynamicView, P as isDynamicViewIncludeRule, l as isElement, j as isElementKindExpr, o as isElementPredicateExpr, d as isElementRef, k as isElementTagExpr, R as isElementView, m as isElementWhere, f as isExpandedElementExpr, S as isExtendsElementView, q as isInOut, r as isIncoming, z as isKindEqual, C as isNotOperator, G as isOrOperator, s as isOutgoing, p as isRelation, t as isRelationExpression, x as isRelationPredicateExpr, v as isRelationWhere, T as isScopedElementView, V as isStepEdgeId, y as isTagEqual, L as isThemeColor, O as isViewRuleAutoLayout, M as isViewRulePredicate, N as isViewRuleStyle, h as isWildcard, H as whereOperatorAsPredicate } from '../shared/core.DfUTsojZ.mjs';
|