@likec4/core 1.27.3 → 1.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/builder/index.d.mts +6 -6
  2. package/dist/builder/index.mjs +23 -13
  3. package/dist/compute-view/index.d.mts +3 -3
  4. package/dist/compute-view/index.mjs +3 -3
  5. package/dist/compute-view/relationships-view/index.d.mts +3 -3
  6. package/dist/index.d.mts +6 -6
  7. package/dist/index.mjs +2 -2
  8. package/dist/model/index.d.mts +6 -6
  9. package/dist/model/index.mjs +1 -1
  10. package/dist/shared/{core.RjpTh3vE.mjs → core.Bjl6Kmc8.mjs} +260 -168
  11. package/dist/shared/{core.BpuZeqlX.d.mts → core.CZR9J1Qx.d.mts} +2 -2
  12. package/dist/shared/{core.Djro-kuQ.d.mts → core.CiFKryGW.d.mts} +7 -2
  13. package/dist/shared/{core.HKn0jlo_.d.mts → core.D2830qgg.d.mts} +1 -1
  14. package/dist/shared/{core.CFDwncxs.d.mts → core.DJvmfnEi.d.mts} +481 -186
  15. package/dist/shared/{core.BMep80lJ.mjs → core.DgfwjBtu.mjs} +198 -87
  16. package/dist/shared/core.SjLhMA7a.d.mts +62 -0
  17. package/dist/types/index.d.mts +4 -4
  18. package/dist/types/index.mjs +1 -1
  19. package/dist/utils/index.d.mts +2 -2
  20. package/package.json +6 -6
  21. package/src/builder/Builder.ts +1 -0
  22. package/src/builder/Builder.view-common.ts +10 -10
  23. package/src/builder/Builder.view-element.ts +26 -14
  24. package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +23 -8
  25. package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +9 -4
  26. package/src/compute-view/deployment-view/predicates/deploymentRefs-where.ts +18 -0
  27. package/src/compute-view/deployment-view/predicates/relation-direct.ts +6 -0
  28. package/src/compute-view/deployment-view/predicates/relation-in-out.ts +3 -0
  29. package/src/compute-view/deployment-view/predicates/relation-incoming.ts +3 -0
  30. package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +3 -0
  31. package/src/compute-view/deployment-view/predicates/utils.ts +10 -3
  32. package/src/compute-view/deployment-view/utils.ts +7 -4
  33. package/src/compute-view/element-view/__test__/fixture.ts +72 -65
  34. package/src/compute-view/element-view/_types.ts +13 -9
  35. package/src/compute-view/element-view/compute.ts +27 -27
  36. package/src/compute-view/element-view/memory/NodeGroup.ts +4 -3
  37. package/src/compute-view/element-view/memory/memory.ts +3 -2
  38. package/src/compute-view/element-view/memory/stage-include.ts +2 -2
  39. package/src/compute-view/element-view/predicates/_utils.ts +25 -24
  40. package/src/compute-view/element-view/predicates/element-expand.ts +7 -10
  41. package/src/compute-view/element-view/predicates/element-kind-tag.ts +5 -3
  42. package/src/compute-view/element-view/predicates/element-ref.ts +7 -19
  43. package/src/compute-view/element-view/predicates/relation-direct.ts +15 -13
  44. package/src/compute-view/element-view/predicates/relation-in-out.ts +5 -6
  45. package/src/compute-view/element-view/predicates/relation-in.ts +36 -32
  46. package/src/compute-view/element-view/predicates/relation-out.ts +37 -33
  47. package/src/compute-view/element-view/predicates/wildcard.ts +2 -2
  48. package/src/compute-view/utils/applyCustomElementProperties.ts +9 -4
  49. package/src/compute-view/utils/applyCustomRelationProperties.ts +10 -7
  50. package/src/compute-view/utils/elementExpressionToPredicate.ts +27 -26
  51. package/src/compute-view/utils/link-nodes-with-edges.ts +1 -1
  52. package/src/compute-view/utils/relationExpressionToPredicates.ts +10 -17
  53. package/src/compute-view/utils/uniqueTags.ts +3 -3
  54. package/src/index.ts +0 -2
  55. package/src/model/ElementModel.ts +25 -6
  56. package/src/model/LikeC4Model.ts +44 -6
  57. package/src/model/RelationModel.ts +4 -2
  58. package/src/model/view/LikeC4ViewModel.ts +3 -2
  59. package/src/types/_common.ts +0 -4
  60. package/src/types/deployments.ts +3 -2
  61. package/src/types/element.ts +2 -10
  62. package/src/types/expression-v2-model.ts +314 -0
  63. package/src/types/expression-v2.ts +238 -30
  64. package/src/types/index.ts +15 -46
  65. package/src/types/model-data.ts +4 -1
  66. package/src/types/relation.ts +2 -1
  67. package/src/types/scalars.ts +39 -0
  68. package/src/types/view-changes.ts +2 -1
  69. package/src/types/view.ts +7 -8
  70. package/dist/shared/core.30yYKXcZ.d.mts +0 -186
  71. package/src/types/expression.ts +0 -207
@@ -1,6 +1,8 @@
1
1
  import { i as invariant, a as nonexhaustive } from './core.C-YXI-43.mjs';
2
2
  import { u } from './core.DbRvwARP.mjs';
3
3
 
4
+ function n$1(e){return !!e}
5
+
4
6
  function o$1(a){return t=>!a(t)}
5
7
 
6
8
  function n(e){return e==null}
@@ -11,19 +13,6 @@ function t(...a){return u(e,a)}var e=(a,o)=>o.every(l=>l(a));
11
13
 
12
14
  function y(...a){return u(r,a)}var r=(a,o)=>o.some(e=>e(a));
13
15
 
14
- var DeploymentElement;
15
- ((DeploymentElement2) => {
16
- DeploymentElement2.isDeploymentNode = (el) => {
17
- return "kind" in el && !("element" in el);
18
- };
19
- DeploymentElement2.isInstance = (el) => {
20
- return "element" in el && !("kind" in el);
21
- };
22
- })(DeploymentElement || (DeploymentElement = {}));
23
-
24
- function AsFqn(name, parent) {
25
- return parent ? parent + "." + name : name;
26
- }
27
16
  const BorderStyles = ["solid", "dashed", "dotted", "none"];
28
17
  var ElementKind;
29
18
  ((ElementKind2) => {
@@ -44,78 +33,38 @@ const DefaultShapeSize = "md";
44
33
  const DefaultPaddingSize = "md";
45
34
  const DefaultTextSize = "md";
46
35
 
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);
36
+ function AsFqn(name, parent) {
37
+ return parent ? parent + "." + name : name;
88
38
  }
89
- function isRelationWhere(expr) {
90
- return "where" in expr && isRelationExpression(expr.where.expr);
39
+ function GlobalFqn(projectId, name) {
40
+ invariant(n$1(projectId), "Project ID must start with @");
41
+ return "@" + projectId + "." + name;
91
42
  }
92
- function isCustomRelationExpr(expr) {
93
- return "customRelation" in expr;
43
+ function isGlobalFqn(fqn) {
44
+ return fqn.startsWith("@");
94
45
  }
95
- function isRelationPredicateExpr(expr) {
96
- return isRelationExpression(expr) || isRelationWhere(expr) || isCustomRelationExpr(expr);
46
+ function splitGlobalFqn(fqn) {
47
+ if (!fqn.startsWith("@")) {
48
+ return [null, fqn];
49
+ }
50
+ const firstDot = fqn.indexOf(".");
51
+ if (firstDot < 2) {
52
+ throw new Error("Invalid global FQN");
53
+ }
54
+ const projectId = fqn.slice(1, firstDot);
55
+ const name = fqn.slice(firstDot + 1);
56
+ return [projectId, name];
97
57
  }
98
58
 
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
- };
59
+ var DeploymentElement;
60
+ ((DeploymentElement2) => {
61
+ DeploymentElement2.isDeploymentNode = (el) => {
62
+ return "kind" in el && !("element" in el);
63
+ };
64
+ DeploymentElement2.isInstance = (el) => {
65
+ return "element" in el && !("kind" in el);
66
+ };
67
+ })(DeploymentElement || (DeploymentElement = {}));
119
68
 
120
69
  var FqnRef;
121
70
  ((FqnRef2) => {
@@ -126,10 +75,13 @@ var FqnRef;
126
75
  return "deployment" in ref && !("element" in ref);
127
76
  };
128
77
  FqnRef2.isDeploymentRef = (ref) => {
129
- return !(0, FqnRef2.isModelRef)(ref);
78
+ return !(0, FqnRef2.isModelRef)(ref) && !(0, FqnRef2.isImportRef)(ref);
130
79
  };
131
80
  FqnRef2.isModelRef = (ref) => {
132
- return "model" in ref;
81
+ return "model" in ref && !("project" in ref);
82
+ };
83
+ FqnRef2.isImportRef = (ref) => {
84
+ return "project" in ref && "model" in ref;
133
85
  };
134
86
  FqnRef2.toDeploymentRef = (ref) => {
135
87
  invariant((0, FqnRef2.isDeploymentRef)(ref), "Expected DeploymentRef");
@@ -140,6 +92,15 @@ var FqnRef;
140
92
  id: ref.deployment
141
93
  };
142
94
  };
95
+ FqnRef2.toModelFqn = (ref) => {
96
+ if ((0, FqnRef2.isImportRef)(ref)) {
97
+ return GlobalFqn(ref.project, ref.model);
98
+ }
99
+ if ((0, FqnRef2.isModelRef)(ref)) {
100
+ return ref.model;
101
+ }
102
+ throw new Error("Expected FqnRef.ModelRef or FqnRef.ImportRef");
103
+ };
143
104
  })(FqnRef || (FqnRef = {}));
144
105
  var FqnExpr;
145
106
  ((FqnExpr2) => {
@@ -147,11 +108,37 @@ var FqnExpr;
147
108
  return "wildcard" in expr && expr.wildcard === true;
148
109
  };
149
110
  FqnExpr2.isModelRef = (ref) => {
150
- return "ref" in ref && FqnRef.isModelRef(ref.ref);
111
+ return "ref" in ref && (FqnRef.isModelRef(ref.ref) || FqnRef.isImportRef(ref.ref));
151
112
  };
152
113
  FqnExpr2.isDeploymentRef = (ref) => {
153
114
  return "ref" in ref && FqnRef.isDeploymentRef(ref.ref);
154
115
  };
116
+ function isElementKindExpr(expr) {
117
+ return "elementKind" in expr && "isEqual" in expr;
118
+ }
119
+ FqnExpr2.isElementKindExpr = isElementKindExpr;
120
+ function isElementTagExpr(expr) {
121
+ return "elementTag" in expr && "isEqual" in expr;
122
+ }
123
+ FqnExpr2.isElementTagExpr = isElementTagExpr;
124
+ FqnExpr2.isWhere = (expr) => {
125
+ return "where" in expr && (0, FqnExpr2.is)(expr.where.expr);
126
+ };
127
+ FqnExpr2.isCustom = (expr) => {
128
+ return "custom" in expr && ((0, FqnExpr2.is)(expr.custom.expr) || (0, FqnExpr2.isWhere)(expr.custom.expr));
129
+ };
130
+ FqnExpr2.is = (expr) => {
131
+ return (0, FqnExpr2.isWildcard)(expr) || (0, FqnExpr2.isModelRef)(expr) || (0, FqnExpr2.isDeploymentRef)(expr) || isElementKindExpr(expr) || isElementTagExpr(expr);
132
+ };
133
+ FqnExpr2.unwrap = (expr) => {
134
+ if ((0, FqnExpr2.isCustom)(expr)) {
135
+ expr = expr.custom.expr;
136
+ }
137
+ if ((0, FqnExpr2.isWhere)(expr)) {
138
+ expr = expr.where.expr;
139
+ }
140
+ return expr;
141
+ };
155
142
  })(FqnExpr || (FqnExpr = {}));
156
143
  var RelationExpr;
157
144
  ((RelationExpr2) => {
@@ -168,19 +155,143 @@ var RelationExpr;
168
155
  return "inout" in expr;
169
156
  };
170
157
  RelationExpr2.isWhere = (expr) => {
171
- return "where" in expr;
158
+ return "where" in expr && ((0, RelationExpr2.isDirect)(expr.where.expr) || (0, RelationExpr2.isIncoming)(expr.where.expr) || (0, RelationExpr2.isOutgoing)(expr.where.expr) || (0, RelationExpr2.isInOut)(expr.where.expr));
159
+ };
160
+ RelationExpr2.isCustom = (expr) => {
161
+ return "customRelation" in expr;
162
+ };
163
+ RelationExpr2.is = (expr) => {
164
+ return (0, RelationExpr2.isDirect)(expr) || (0, RelationExpr2.isIncoming)(expr) || (0, RelationExpr2.isOutgoing)(expr) || (0, RelationExpr2.isInOut)(expr);
165
+ };
166
+ RelationExpr2.unwrap = (expr) => {
167
+ if ((0, RelationExpr2.isCustom)(expr)) {
168
+ expr = expr.customRelation.expr;
169
+ }
170
+ if ((0, RelationExpr2.isWhere)(expr)) {
171
+ expr = expr.where.expr;
172
+ }
173
+ return expr;
172
174
  };
173
175
  })(RelationExpr || (RelationExpr = {}));
174
176
  var ExpressionV2;
175
177
  ((ExpressionV22) => {
178
+ ExpressionV22.isWhere = (expr) => {
179
+ return "where" in expr;
180
+ };
181
+ ExpressionV22.isRelationWhere = (expr) => {
182
+ return RelationExpr.isWhere(expr);
183
+ };
184
+ ExpressionV22.isFqnExprWhere = (expr) => {
185
+ return FqnExpr.isWhere(expr);
186
+ };
176
187
  ExpressionV22.isFqnExpr = (expr) => {
177
- return FqnExpr.isWildcard(expr) || FqnExpr.isModelRef(expr) || FqnExpr.isDeploymentRef(expr);
188
+ return FqnExpr.is(expr) || FqnExpr.isWhere(expr) || FqnExpr.isCustom(expr);
178
189
  };
179
190
  ExpressionV22.isRelation = (expr) => {
180
- return RelationExpr.isDirect(expr) || RelationExpr.isIncoming(expr) || RelationExpr.isOutgoing(expr) || RelationExpr.isInOut(expr);
191
+ return RelationExpr.is(expr) || RelationExpr.isWhere(expr) || RelationExpr.isCustom(expr);
181
192
  };
182
193
  })(ExpressionV2 || (ExpressionV2 = {}));
183
194
 
195
+ var ModelLayer;
196
+ ((ModelLayer2) => {
197
+ ((FqnRef2) => {
198
+ FqnRef2.isModelRef = (ref) => {
199
+ return "model" in ref && !("project" in ref);
200
+ };
201
+ FqnRef2.isImportRef = (ref) => {
202
+ return "project" in ref && "model" in ref;
203
+ };
204
+ FqnRef2.toFqn = (ref) => {
205
+ if ((0, FqnRef2.isImportRef)(ref)) {
206
+ return GlobalFqn(ref.project, ref.model);
207
+ }
208
+ if ((0, FqnRef2.isModelRef)(ref)) {
209
+ return ref.model;
210
+ }
211
+ throw new Error("Expected FqnRef.ModelRef or FqnRef.ImportRef");
212
+ };
213
+ })(ModelLayer2.FqnRef || (ModelLayer2.FqnRef = {}));
214
+ let FqnExpr;
215
+ ((FqnExpr2) => {
216
+ FqnExpr2.isWildcard = (expr) => {
217
+ return "wildcard" in expr && expr.wildcard === true;
218
+ };
219
+ FqnExpr2.isModelRef = (ref) => {
220
+ return "ref" in ref;
221
+ };
222
+ function isElementKindExpr(expr) {
223
+ return "elementKind" in expr && "isEqual" in expr;
224
+ }
225
+ FqnExpr2.isElementKindExpr = isElementKindExpr;
226
+ function isElementTagExpr(expr) {
227
+ return "elementTag" in expr && "isEqual" in expr;
228
+ }
229
+ FqnExpr2.isElementTagExpr = isElementTagExpr;
230
+ FqnExpr2.isWhere = (expr) => {
231
+ return "where" in expr && (0, FqnExpr2.is)(expr.where.expr);
232
+ };
233
+ FqnExpr2.isCustom = (expr) => {
234
+ return "custom" in expr && ((0, FqnExpr2.is)(expr.custom.expr) || (0, FqnExpr2.isWhere)(expr.custom.expr));
235
+ };
236
+ FqnExpr2.is = (expr) => {
237
+ return (0, FqnExpr2.isWildcard)(expr) || (0, FqnExpr2.isModelRef)(expr) || isElementKindExpr(expr) || isElementTagExpr(expr);
238
+ };
239
+ })(FqnExpr = ModelLayer2.FqnExpr || (ModelLayer2.FqnExpr = {}));
240
+ function isAnyFqnExpr(expr) {
241
+ return FqnExpr.is(expr) || FqnExpr.isWhere(expr) || FqnExpr.isCustom(expr);
242
+ }
243
+ ModelLayer2.isAnyFqnExpr = isAnyFqnExpr;
244
+ let RelationExpr;
245
+ ((RelationExpr2) => {
246
+ RelationExpr2.isDirect = (expr) => {
247
+ return "source" in expr && "target" in expr;
248
+ };
249
+ RelationExpr2.isIncoming = (expr) => {
250
+ return "incoming" in expr;
251
+ };
252
+ RelationExpr2.isOutgoing = (expr) => {
253
+ return "outgoing" in expr;
254
+ };
255
+ RelationExpr2.isInOut = (expr) => {
256
+ return "inout" in expr;
257
+ };
258
+ RelationExpr2.isWhere = (expr) => {
259
+ return "where" in expr && (0, RelationExpr2.is)(expr.where.expr);
260
+ };
261
+ RelationExpr2.isCustom = (expr) => {
262
+ return "customRelation" in expr;
263
+ };
264
+ RelationExpr2.is = (expr) => {
265
+ return (0, RelationExpr2.isDirect)(expr) || (0, RelationExpr2.isIncoming)(expr) || (0, RelationExpr2.isOutgoing)(expr) || (0, RelationExpr2.isInOut)(expr);
266
+ };
267
+ })(RelationExpr = ModelLayer2.RelationExpr || (ModelLayer2.RelationExpr = {}));
268
+ function isAnyRelationExpr(expr) {
269
+ return RelationExpr.is(expr) || RelationExpr.isWhere(expr) || RelationExpr.isCustom(expr);
270
+ }
271
+ ModelLayer2.isAnyRelationExpr = isAnyRelationExpr;
272
+ function isExpression(expr) {
273
+ return isAnyFqnExpr(expr) || isAnyRelationExpr(expr);
274
+ }
275
+ ModelLayer2.isExpression = isExpression;
276
+ ((Expression2) => {
277
+ Expression2.isWhere = (expr) => {
278
+ return "where" in expr;
279
+ };
280
+ Expression2.isCustomFqnExpr = (expr) => {
281
+ return FqnExpr.isCustom(expr);
282
+ };
283
+ Expression2.isCustomRelationExpr = (expr) => {
284
+ return RelationExpr.isCustom(expr);
285
+ };
286
+ Expression2.isFqnExpr = (expr) => {
287
+ return FqnExpr.is(expr);
288
+ };
289
+ Expression2.isRelation = (expr) => {
290
+ return RelationExpr.is(expr);
291
+ };
292
+ })(ModelLayer2.Expression || (ModelLayer2.Expression = {}));
293
+ })(ModelLayer || (ModelLayer = {}));
294
+
184
295
  const isTagEqual = (operator) => {
185
296
  return "tag" in operator;
186
297
  };
@@ -381,4 +492,4 @@ var DiagramNode;
381
492
  DiagramNode2.isNodesGroup = isNodesGroup;
382
493
  })(DiagramNode || (DiagramNode = {}));
383
494
 
384
- export { isAutoLayoutDirection as $, AsFqn as A, BorderStyles as B, isRelationPredicateExpr as C, DefaultElementShape as D, ElementKind as E, isRelationWhere as F, isWildcard as G, ExpressionV2 as H, FqnExpr as I, FqnRef as J, isAndOperator as K, isKindEqual as L, isNotOperator as M, isOrOperator as N, isParticipantOperator as O, isTagEqual as P, whereOperatorAsPredicate as Q, RelationExpr as R, DefaultArrowType as S, DefaultLineStyle as T, DefaultRelationshipColor as U, ComputedNode as V, ComputedView as W, DiagramNode as X, extractStep as Y, getBBoxCenter as Z, getParallelStepsPrefix as _, isElementView as a, isDeploymentView as a0, isDynamicView as a1, isDynamicViewParallelSteps as a2, isStepEdgeId as a3, isViewRuleAutoLayout as a4, isViewRuleGlobalPredicateRef as a5, isViewRuleGlobalStyle as a6, isViewRuleGroup as a7, isViewRulePredicate as a8, isViewRuleStyle as a9, stepEdgeId as aa, o$1 as ab, y as ac, isElementPredicateExpr as b, DefaultThemeColor as c, DeploymentElement as d, isScopedElementView as e, expression as f, DefaultPaddingSize as g, DefaultShapeSize as h, isExtendsElementView as i, DefaultTextSize as j, ElementShapes as k, isCustomElement as l, isCustomRelationExpr as m, n, o, isElement as p, isElementKindExpr as q, isElementRef as r, isElementTagExpr as s, isElementWhere as t, isExpandedElementExpr as u, isIncoming as v, isInOut as w, isOutgoing as x, isRelation as y, isRelationExpression as z };
495
+ export { y as $, AsFqn as A, BorderStyles as B, ComputedNode as C, DefaultElementShape as D, ElementKind as E, FqnExpr as F, GlobalFqn as G, DiagramNode as H, extractStep as I, getBBoxCenter as J, getParallelStepsPrefix as K, isAutoLayoutDirection as L, ModelLayer as M, isDeploymentView as N, isDynamicView as O, isDynamicViewParallelSteps as P, isStepEdgeId as Q, RelationExpr as R, isViewRuleAutoLayout as S, isViewRuleGlobalPredicateRef as T, isViewRuleGlobalStyle as U, isViewRuleGroup as V, isViewRulePredicate as W, isViewRuleStyle as X, stepEdgeId as Y, n$1 as Z, o$1 as _, isElementView as a, DefaultThemeColor as b, DeploymentElement as c, isScopedElementView as d, isGlobalFqn as e, DefaultPaddingSize as f, DefaultShapeSize as g, DefaultTextSize as h, isExtendsElementView as i, ElementShapes as j, ExpressionV2 as k, FqnRef as l, isAndOperator as m, n, o, isKindEqual as p, isNotOperator as q, isOrOperator as r, splitGlobalFqn as s, isParticipantOperator as t, isTagEqual as u, DefaultArrowType as v, whereOperatorAsPredicate as w, DefaultLineStyle as x, DefaultRelationshipColor as y, ComputedView as z };
@@ -0,0 +1,62 @@
1
+ import { Simplify, UnionToIntersection, Tagged } from 'type-fest';
2
+
3
+ type NonEmptyArray<T> = [T, ...T[]];
4
+ type NonEmptyReadonlyArray<T> = readonly [T, ...T[]];
5
+ type CustomColor = string;
6
+ type Point = readonly [x: number, y: number];
7
+ interface XYPoint {
8
+ x: number;
9
+ y: number;
10
+ }
11
+ type KeysOf<T> = keyof T extends infer K extends string ? K : never;
12
+ type AllNever<Expressions> = UnionToIntersection<{
13
+ [Name in keyof Expressions]: {
14
+ -readonly [Key in keyof Expressions[Name]]?: never;
15
+ };
16
+ }[keyof Expressions]>;
17
+ /**
18
+ * @example
19
+ * type Variant1 = {
20
+ * a: string
21
+ * }
22
+ * type Variant2 = {
23
+ * b: number
24
+ * }
25
+ *
26
+ * type Variants = ExclusiveUnion<{
27
+ * Variant1: Variant1,
28
+ * Variant2: Variant2
29
+ * }>
30
+ *
31
+ * Fail here
32
+ * const variant1: Variants = {
33
+ * a: 'one',
34
+ * b: 1
35
+ * }
36
+ */
37
+ type ExclusiveUnion<Expressions> = Expressions extends object ? {
38
+ [Name in keyof Expressions]: Simplify<Omit<AllNever<Expressions>, keyof Expressions[Name]> & Expressions[Name]>;
39
+ }[keyof Expressions] : Expressions;
40
+ /**
41
+ * Copy from https://github.com/remeda/remeda/blob/main/src/internal/types/NTuple.ts
42
+ * An array with *exactly* N elements in it.
43
+ *
44
+ * Only literal N values are supported. For very large N the type might result
45
+ * in a recurse depth error. For negative N the type would result in an infinite
46
+ * recursion. None of these have protections because this is an internal type!
47
+ */
48
+ type NTuple<T, N extends number, Result extends Array<unknown> = []> = Result['length'] extends N ? Result : NTuple<T, N, [...Result, T]>;
49
+ type IteratorLike<T> = IteratorObject<T, BuiltinIteratorReturn>;
50
+ type Predicate<T> = (x: T) => boolean;
51
+
52
+ type ProjectId = Tagged<string, 'ProjectID'>;
53
+ type IconUrl = Tagged<string, 'IconUrl'> | 'none';
54
+ type Fqn<Id extends string = string> = Tagged<Id, 'Fqn'>;
55
+ type Tag<Tags extends string = string> = Tagged<Tags, 'Tag'>;
56
+ declare function AsFqn(name: string, parent?: Fqn | null): Fqn;
57
+ type GlobalFqn<Id extends string = string> = Tagged<Fqn<Id>, 'GlobalFqn'>;
58
+ declare function GlobalFqn(projectId: ProjectId, name: string): GlobalFqn;
59
+ declare function isGlobalFqn(fqn: string): fqn is GlobalFqn;
60
+ declare function splitGlobalFqn<Id extends string>(fqn: Fqn<Id> | GlobalFqn<Id>): [ProjectId | null, Fqn<Id>];
61
+
62
+ export { AsFqn as A, type CustomColor as C, type ExclusiveUnion as E, type Fqn as F, GlobalFqn as G, type IteratorLike as I, type KeysOf as K, type NonEmptyArray as N, type Point as P, type Tag as T, type XYPoint as X, type NonEmptyReadonlyArray as a, type NTuple as b, type Predicate as c, type IconUrl as d, type ProjectId as e, isGlobalFqn as i, splitGlobalFqn as s };
@@ -1,7 +1,7 @@
1
- import { X as XYPoint, N as NonEmptyArray, P as Point, l as BorderStyle, p as ElementShape, Q as ThemeColor, F as Fqn } from '../shared/core.30yYKXcZ.mjs';
2
- export { A as AsFqn, B as BorderStyles, x as Color, y as ColorLiteral, C as CustomColor, D as DefaultElementShape, f as DefaultPaddingSize, g as DefaultShapeSize, h as DefaultTextSize, i as DefaultThemeColor, m as Element, j as ElementKind, n as ElementKindSpecification, o as ElementKindSpecificationStyle, k as ElementShapes, q as ElementStyle, G as ElementThemeColorValues, z as ElementThemeColors, E as ExclusiveUnion, H as HexColorLiteral, I as IconUrl, a as IteratorLike, K as KeysOf, L as LikeC4Theme, r as Link, c as NTuple, b as NonEmptyReadonlyArray, d as Predicate, e as ProjectId, J as RelationshipThemeColorValues, R as RelationshipThemeColors, S as ShapeSize, M as SpacingSize, s as Tag, t as TagSpec, O as TextSize, T as ThemeColorValues, w as ThemeColors, u as TypedElement, v as isThemeColor } from '../shared/core.30yYKXcZ.mjs';
3
- import { bo as ViewId, a_ as BBox, bp as ViewManualLayout, aX as AutoLayoutDirection } from '../shared/core.CFDwncxs.mjs';
4
- export { aw as AbstractRelation, ah as AllNever, ai as AndOperator, a5 as AnyParsedLikeC4ModelData, aY as BasicElementView, aZ as BasicView, a$ as ComputedDeploymentView, b0 as ComputedDynamicView, b1 as ComputedEdge, b2 as ComputedElementView, C as ComputedLikeC4ModelData, aD as ComputedNode, a as ComputedView, b3 as CustomColorDefinitions, A as CustomElementExpr, B as CustomRelationExpr, at as DefaultArrowType, au as DefaultLineStyle, av as DefaultRelationshipColor, b as DeployedInstance, D as DeploymentElement, c as DeploymentElementStyle, d as DeploymentNode, f as DeploymentNodeKind, g as DeploymentNodeKindSpecification, h as DeploymentRef, i as DeploymentRelation, b4 as DeploymentView, b5 as DeploymentViewRule, b6 as DeploymentViewRulePredicate, b7 as DeploymentViewRuleStyle, b8 as DiagramEdge, aE as DiagramNode, b9 as DiagramView, E as DirectRelationExpr, ba as DynamicView, bb as DynamicViewIncludeRule, bc as DynamicViewParallelSteps, bd as DynamicViewRule, be as DynamicViewStep, bf as DynamicViewStepOrParallel, bg as EdgeId, F as ElementExpression, G as ElementKindExpr, bA as ElementNotation, H as ElementPredicateExpression, I as ElementRefExpr, J as ElementTagExpr, bh as ElementView, K as ElementWhereExpr, aj as EqualOperator, M as ExpandedElementExpr, N as Expression, X as ExpressionV2, bi as ExtendsElementView, ak as Filterable, Y as FqnExpr, Z as FqnRef, a6 as GenericLikeC4ModelData, $ as GlobalDynamicPredicates, a0 as GlobalPredicateId, a1 as GlobalPredicates, a2 as GlobalStyleID, a3 as GlobalStyles, Q as InOutExpr, O as IncomingExpr, al as KindEqual, a7 as LayoutedLikeC4ModelData, a8 as LikeC4ModelDump, L as LikeC4View, a4 as ModelGlobals, ax as ModelRelation, bj as NodeId, R as NonWilcard, am as NotOperator, an as OperatorPredicate, ao as OrOperator, S as OutgoingExpr, a9 as ParsedLikeC4ModelData, ap as Participant, aq as ParticipantOperator, P as PredicateSelector, _ as RelationExpr, T as RelationExpression, ay as RelationId, U as RelationPredicateExpression, V as RelationWhereExpr, az as RelationshipArrowType, aA as RelationshipKind, aB as RelationshipKindSpecification, aC as RelationshipLineType, bk as ScopedElementView, bl as StepEdgeId, bm as StepEdgeIdLiteral, ar as TagEqual, bn as ViewAutoLayout, bq as ViewRule, br as ViewRuleAutoLayout, bs as ViewRuleGlobalPredicateRef, bt as ViewRuleGlobalStyle, bu as ViewRuleGroup, bv as ViewRulePredicate, bw as ViewRuleStyle, bx as ViewRuleStyleOrGlobalRef, by as ViewWithHash, bz as ViewWithNotation, as as WhereOperator, W as WildcardExpr, aF as extractStep, aG as getBBoxCenter, aH as getParallelStepsPrefix, aa as isAndOperator, aI as isAutoLayoutDirection, j as isCustomElement, k as isCustomRelationExpr, aJ as isDeploymentView, aK as isDynamicView, aL as isDynamicViewParallelSteps, l as isElement, m as isElementKindExpr, n as isElementPredicateExpr, o as isElementRef, p as isElementTagExpr, aM as isElementView, q as isElementWhere, r as isExpandedElementExpr, aN as isExtendsElementView, t as isInOut, s as isIncoming, ab as isKindEqual, ac as isNotOperator, ad as isOrOperator, u as isOutgoing, ae as isParticipantOperator, v as isRelation, w as isRelationExpression, x as isRelationPredicateExpr, y as isRelationWhere, aO as isScopedElementView, aP as isStepEdgeId, af as isTagEqual, aQ as isViewRuleAutoLayout, aR as isViewRuleGlobalPredicateRef, aS as isViewRuleGlobalStyle, aT as isViewRuleGroup, aU as isViewRulePredicate, aV as isViewRuleStyle, z as isWildcard, aW as stepEdgeId, ag as whereOperatorAsPredicate } from '../shared/core.CFDwncxs.mjs';
1
+ import { X as XYPoint, N as NonEmptyArray, P as Point, F as Fqn } from '../shared/core.SjLhMA7a.mjs';
2
+ export { A as AsFqn, C as CustomColor, E as ExclusiveUnion, G as GlobalFqn, d as IconUrl, I as IteratorLike, K as KeysOf, b as NTuple, a as NonEmptyReadonlyArray, c as Predicate, e as ProjectId, T as Tag, i as isGlobalFqn, s as splitGlobalFqn } from '../shared/core.SjLhMA7a.mjs';
3
+ import { bk as ViewId, aW as BBox, p as BorderStyle, t as ElementShape, ay as ThemeColor, bl as ViewManualLayout, aT as AutoLayoutDirection } from '../shared/core.DJvmfnEi.mjs';
4
+ export { ag as AbstractRelation, a1 as AllNever, a2 as AndOperator, O as AnyParsedLikeC4ModelData, aU as BasicElementView, aV as BasicView, B as BorderStyles, ap as Color, aq as ColorLiteral, aX as ComputedDeploymentView, aY as ComputedDynamicView, aZ as ComputedEdge, a_ as ComputedElementView, C as ComputedLikeC4ModelData, az as ComputedNode, a as ComputedView, a$ as CustomColorDefinitions, ad as DefaultArrowType, j as DefaultElementShape, ae as DefaultLineStyle, k as DefaultPaddingSize, af as DefaultRelationshipColor, l as DefaultShapeSize, m as DefaultTextSize, n as DefaultThemeColor, c as DeployedInstance, D as DeploymentElement, d as DeploymentElementStyle, e as DeploymentNode, f as DeploymentNodeKind, g as DeploymentNodeKindSpecification, h as DeploymentRef, i as DeploymentRelation, b0 as DeploymentView, b1 as DeploymentViewRule, b2 as DeploymentViewRulePredicate, b3 as DeploymentViewRuleStyle, b4 as DiagramEdge, aA as DiagramNode, b5 as DiagramView, b6 as DynamicView, b7 as DynamicViewIncludeRule, b8 as DynamicViewParallelSteps, b9 as DynamicViewRule, ba as DynamicViewStep, bb as DynamicViewStepOrParallel, bc as EdgeId, q as Element, E as ElementKind, r as ElementKindSpecification, s as ElementKindSpecificationStyle, bw as ElementNotation, o as ElementShapes, u as ElementStyle, as as ElementThemeColorValues, ar as ElementThemeColors, bd as ElementView, a3 as EqualOperator, y as ExpressionV2, be as ExtendsElementView, a4 as Filterable, F as FqnExpr, z as FqnRef, Q as GenericLikeC4ModelData, G as GlobalDynamicPredicates, A as GlobalPredicateId, I as GlobalPredicates, J as GlobalStyleID, K as GlobalStyles, H as HexColorLiteral, a5 as KindEqual, S as LayoutedLikeC4ModelData, U as LikeC4ModelDump, b as LikeC4Theme, L as LikeC4View, v as Link, N as ModelGlobals, M as ModelLayer, ah as ModelRelation, bf as NodeId, a6 as NotOperator, a7 as OperatorPredicate, a8 as OrOperator, V as ParsedLikeC4ModelData, a9 as Participant, aa as ParticipantOperator, P as PredicateSelector, R as RelationExpr, ai as RelationId, aj as RelationshipArrowType, ak as RelationshipKind, al as RelationshipKindSpecification, am as RelationshipLineType, au as RelationshipThemeColorValues, at as RelationshipThemeColors, bg as ScopedElementView, av as ShapeSize, aw as SpacingSize, bh as StepEdgeId, bi as StepEdgeIdLiteral, ab as TagEqual, w as TagSpec, ax as TextSize, T as ThemeColorValues, ao as ThemeColors, x as TypedElement, bj as ViewAutoLayout, bm as ViewRule, bn as ViewRuleAutoLayout, bo as ViewRuleGlobalPredicateRef, bp as ViewRuleGlobalStyle, bq as ViewRuleGroup, br as ViewRulePredicate, bs as ViewRuleStyle, bt as ViewRuleStyleOrGlobalRef, bu as ViewWithHash, bv as ViewWithNotation, ac as WhereOperator, aB as extractStep, aC as getBBoxCenter, aD as getParallelStepsPrefix, W as isAndOperator, aE as isAutoLayoutDirection, aF as isDeploymentView, aG as isDynamicView, aH as isDynamicViewParallelSteps, aI as isElementView, aJ as isExtendsElementView, X as isKindEqual, Y as isNotOperator, Z as isOrOperator, _ as isParticipantOperator, aK as isScopedElementView, aL as isStepEdgeId, $ as isTagEqual, an as isThemeColor, aM as isViewRuleAutoLayout, aN as isViewRuleGlobalPredicateRef, aO as isViewRuleGlobalStyle, aP as isViewRuleGroup, aQ as isViewRulePredicate, aR as isViewRuleStyle, aS as stepEdgeId, a0 as whereOperatorAsPredicate } from '../shared/core.DJvmfnEi.mjs';
5
5
  import 'type-fest';
6
6
 
7
7
  /**
@@ -1,4 +1,4 @@
1
- export { A as AsFqn, B as BorderStyles, V as ComputedNode, W as ComputedView, S as DefaultArrowType, D as DefaultElementShape, T as DefaultLineStyle, g as DefaultPaddingSize, U as DefaultRelationshipColor, h as DefaultShapeSize, j as DefaultTextSize, c as DefaultThemeColor, d as DeploymentElement, X as DiagramNode, E as ElementKind, k as ElementShapes, H as ExpressionV2, I as FqnExpr, J as FqnRef, R as RelationExpr, Y as extractStep, Z as getBBoxCenter, _ as getParallelStepsPrefix, K as isAndOperator, $ as isAutoLayoutDirection, l as isCustomElement, m as isCustomRelationExpr, a0 as isDeploymentView, a1 as isDynamicView, a2 as isDynamicViewParallelSteps, p as isElement, q as isElementKindExpr, b as isElementPredicateExpr, r as isElementRef, s as isElementTagExpr, a as isElementView, t as isElementWhere, u as isExpandedElementExpr, i as isExtendsElementView, w as isInOut, v as isIncoming, L as isKindEqual, M as isNotOperator, N as isOrOperator, x as isOutgoing, O as isParticipantOperator, y as isRelation, z as isRelationExpression, C as isRelationPredicateExpr, F as isRelationWhere, e as isScopedElementView, a3 as isStepEdgeId, P as isTagEqual, a4 as isViewRuleAutoLayout, a5 as isViewRuleGlobalPredicateRef, a6 as isViewRuleGlobalStyle, a7 as isViewRuleGroup, a8 as isViewRulePredicate, a9 as isViewRuleStyle, G as isWildcard, aa as stepEdgeId, Q as whereOperatorAsPredicate } from '../shared/core.BMep80lJ.mjs';
1
+ export { A as AsFqn, B as BorderStyles, C as ComputedNode, z as ComputedView, v as DefaultArrowType, D as DefaultElementShape, x as DefaultLineStyle, f as DefaultPaddingSize, y as DefaultRelationshipColor, g as DefaultShapeSize, h as DefaultTextSize, b as DefaultThemeColor, c as DeploymentElement, H as DiagramNode, E as ElementKind, j as ElementShapes, k as ExpressionV2, F as FqnExpr, l as FqnRef, G as GlobalFqn, M as ModelLayer, R as RelationExpr, I as extractStep, J as getBBoxCenter, K as getParallelStepsPrefix, m as isAndOperator, L as isAutoLayoutDirection, N as isDeploymentView, O as isDynamicView, P as isDynamicViewParallelSteps, a as isElementView, i as isExtendsElementView, e as isGlobalFqn, p as isKindEqual, q as isNotOperator, r as isOrOperator, t as isParticipantOperator, d as isScopedElementView, Q as isStepEdgeId, u as isTagEqual, S as isViewRuleAutoLayout, T as isViewRuleGlobalPredicateRef, U as isViewRuleGlobalStyle, V as isViewRuleGroup, W as isViewRulePredicate, X as isViewRuleStyle, s as splitGlobalFqn, Y as stepEdgeId, w as whereOperatorAsPredicate } from '../shared/core.DgfwjBtu.mjs';
2
2
 
3
3
  const ThemeColors = [
4
4
  "amber",
@@ -1,5 +1,5 @@
1
- export { I as IterableContainer, R as ReorderedArray, a as ancestorsFqn, c as commonAncestor, b as compareByFqnHierarchically, d as compareFqnHierarchically, h as hierarchyDistance, e as hierarchyLevel, i as isAncestor, f as isDescendantOf, g as isSameHierarchy, n as nameFromFqn, p as parentFqn, s as sortByFqnHierarchically, j as sortNaturalByFqn, k as sortParentsFirst } from '../shared/core.HKn0jlo_.mjs';
2
- import { N as NonEmptyArray, a as IteratorLike } from '../shared/core.30yYKXcZ.mjs';
1
+ export { I as IterableContainer, R as ReorderedArray, a as ancestorsFqn, c as commonAncestor, b as compareByFqnHierarchically, d as compareFqnHierarchically, h as hierarchyDistance, e as hierarchyLevel, i as isAncestor, f as isDescendantOf, g as isSameHierarchy, n as nameFromFqn, p as parentFqn, s as sortByFqnHierarchically, j as sortNaturalByFqn, k as sortParentsFirst } from '../shared/core.D2830qgg.mjs';
2
+ import { N as NonEmptyArray, I as IteratorLike } from '../shared/core.SjLhMA7a.mjs';
3
3
  import { IsNumericLiteral } from 'type-fest';
4
4
 
5
5
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/core",
3
- "version": "1.27.3",
3
+ "version": "1.28.0",
4
4
  "license": "MIT",
5
5
  "homepage": "https://likec4.dev",
6
6
  "author": "Denis Davydkov <denis@davydkov.com>",
@@ -84,7 +84,7 @@
84
84
  "access": "public"
85
85
  },
86
86
  "dependencies": {
87
- "type-fest": "^4.38.0"
87
+ "type-fest": "^4.39.1"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@dagrejs/dagre": "1.1.4",
@@ -102,11 +102,11 @@
102
102
  "object-hash": "^3.0.0",
103
103
  "obliterator": "^2.0.5",
104
104
  "remeda": "^2.21.2",
105
- "turbo": "^2.4.4",
106
- "typescript": "^5.8.2",
105
+ "turbo": "^2.5.0",
106
+ "typescript": "^5.8.3",
107
107
  "unbuild": "^3.5.0",
108
- "vitest": "^3.0.9",
109
- "@likec4/tsconfig": "1.27.3"
108
+ "vitest": "^3.1.1",
109
+ "@likec4/tsconfig": "1.28.0"
110
110
  },
111
111
  "scripts": {
112
112
  "typecheck": "tsc --noEmit",
@@ -340,6 +340,7 @@ function builder<Spec extends BuilderSpecification, T extends AnyTypes>(
340
340
  Array.from(_views.entries()),
341
341
  ),
342
342
  ),
343
+ imports: {},
343
344
  } as any),
344
345
  toLikeC4Model: () => {
345
346
  const parsed = self.build()
@@ -2,15 +2,12 @@ import { isArray, isString, map } from 'remeda'
2
2
  import type { LiteralUnion, Simplify } from 'type-fest'
3
3
  import {
4
4
  type AutoLayoutDirection,
5
- type CustomElementExpr,
6
- type CustomRelationExpr,
7
- type ElementExpression as C4ElementExpression,
8
- type Expression as C4Expression,
5
+ type ExpressionV2,
9
6
  type NonEmptyArray,
10
7
  type ViewRuleStyle,
11
8
  type WhereOperator,
12
- isElementPredicateExpr,
13
9
  } from '../types'
10
+ import { ModelLayer } from '../types/expression-v2-model'
14
11
  import type { KindEqual, Participant, TagEqual } from '../types/operators'
15
12
  import type { AnyTypes, Types } from './_types'
16
13
 
@@ -87,7 +84,10 @@ export namespace ViewPredicate {
87
84
  export type Custom<Types extends AnyTypes> = {
88
85
  where?: ViewPredicate.WhereOperator<Types>
89
86
  with?: Simplify<
90
- Omit<CustomElementExpr['custom'] & CustomRelationExpr['customRelation'], 'expr' | 'relation' | 'navigateTo'> & {
87
+ Omit<
88
+ ModelLayer.FqnExpr.Custom['custom'] & ModelLayer.RelationExpr.Custom['customRelation'],
89
+ 'expr' | 'relation' | 'navigateTo'
90
+ > & {
91
91
  navigateTo?: Types['ViewId']
92
92
  }
93
93
  >
@@ -181,7 +181,7 @@ function $include<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(
181
181
 
182
182
  const custom = args[1].with
183
183
  if (custom) {
184
- const isElement = isElementPredicateExpr(expr)
184
+ const isElement = ModelLayer.FqnExpr.is(expr)
185
185
  if (isElement) {
186
186
  expr = {
187
187
  custom: {
@@ -193,7 +193,7 @@ function $include<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(
193
193
  expr = {
194
194
  customRelation: {
195
195
  ...custom,
196
- relation: expr as any,
196
+ expr: expr as any,
197
197
  },
198
198
  }
199
199
  }
@@ -212,7 +212,7 @@ function $exclude<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(
212
212
  | [B['TypedExpr'], ViewPredicate.Custom<B['Types']>]
213
213
  ): (b: B) => B {
214
214
  return (b) => {
215
- let expr = b.$expr(args[0]) as C4Expression
215
+ let expr = b.$expr(args[0]) as ExpressionV2
216
216
  if (args.length === 2 && args[1].where) {
217
217
  const condition = parseWhere(args[1].where)
218
218
  expr = {
@@ -233,7 +233,7 @@ function $style<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(
233
233
  ): (b: B) => B {
234
234
  return (b) =>
235
235
  b.style({
236
- targets: (isArray(element) ? element : [element]).map(e => b.$expr(e as any) as C4ElementExpression),
236
+ targets: (isArray(element) ? element : [element]).map(e => b.$expr(e as any) as ModelLayer.FqnExpr),
237
237
  ...(notation ? { notation } : {}),
238
238
  style: {
239
239
  ...style,