@likec4/core 1.48.0 → 1.50.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 (130) hide show
  1. package/dist/THIRD-PARTY-LICENSES.md +1034 -0
  2. package/dist/_chunks/Builder.view-element.mjs +2 -3284
  3. package/dist/_chunks/LikeC4Model.d.mts +21 -25
  4. package/dist/_chunks/_types.d.mts +1 -5
  5. package/dist/_chunks/_types2.d.mts +2 -4
  6. package/dist/_chunks/assignTagColors.mjs +1 -24
  7. package/dist/_chunks/geometry.mjs +1 -335
  8. package/dist/_chunks/index.d.mts +1995 -131
  9. package/dist/_chunks/index2.d.mts +153 -892
  10. package/dist/_chunks/index3.d.mts +15 -13
  11. package/dist/_chunks/index4.d.mts +229 -3
  12. package/dist/_chunks/index5.d.mts +392 -30
  13. package/dist/_chunks/libs/@mantine/colors-generator.mjs +2 -3403
  14. package/dist/_chunks/libs/@radix-ui/colors.mjs +1 -0
  15. package/dist/_chunks/libs/@ungap/structured-clone.mjs +1 -213
  16. package/dist/_chunks/libs/bail.mjs +1 -14
  17. package/dist/_chunks/libs/ccount.mjs +1 -25
  18. package/dist/_chunks/libs/character-entities-html4.mjs +1 -263
  19. package/dist/_chunks/libs/character-entities-legacy.mjs +1 -117
  20. package/dist/_chunks/libs/character-entities.mjs +2 -2136
  21. package/dist/_chunks/libs/comma-separated-tokens.mjs +1 -18
  22. package/dist/_chunks/libs/decode-named-character-reference.mjs +1 -21
  23. package/dist/_chunks/libs/defu.mjs +1 -42
  24. package/dist/_chunks/libs/devlop.mjs +1 -5
  25. package/dist/_chunks/libs/escape-string-regexp.mjs +1 -8
  26. package/dist/_chunks/libs/extend.mjs +1 -77
  27. package/dist/_chunks/libs/graphology-dag.mjs +1 -703
  28. package/dist/_chunks/libs/graphology.mjs +1 -4565
  29. package/dist/_chunks/libs/hast-util-sanitize.mjs +1 -863
  30. package/dist/_chunks/libs/hast-util-to-html.mjs +9 -2696
  31. package/dist/_chunks/libs/is-plain-obj.mjs +1 -9
  32. package/dist/_chunks/libs/longest-streak.mjs +1 -30
  33. package/dist/_chunks/libs/markdown-table.mjs +2 -290
  34. package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +1 -653
  35. package/dist/_chunks/libs/mdast-util-from-markdown.mjs +3 -8522
  36. package/dist/_chunks/libs/mdast-util-gfm.mjs +15 -2393
  37. package/dist/_chunks/libs/mdast-util-to-hast.mjs +11 -1803
  38. package/dist/_chunks/libs/micromark-extension-gfm.mjs +1 -2243
  39. package/dist/_chunks/libs/mnemonist.d.mts +1 -91
  40. package/dist/_chunks/libs/mnemonist.mjs +1 -1978
  41. package/dist/_chunks/libs/natural-compare-lite.mjs +9 -42
  42. package/dist/_chunks/libs/ohash.mjs +1 -0
  43. package/dist/_chunks/libs/rehype-sanitize.mjs +1 -29
  44. package/dist/_chunks/libs/rehype-stringify.mjs +1 -34
  45. package/dist/_chunks/libs/remark-gfm.mjs +1 -36
  46. package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +3 -100
  47. package/dist/_chunks/libs/remark-parse.mjs +1 -39
  48. package/dist/_chunks/libs/remark-rehype.mjs +1 -171
  49. package/dist/_chunks/libs/remeda.mjs +2 -702
  50. package/dist/_chunks/libs/trough.mjs +1 -158
  51. package/dist/_chunks/libs/unified.mjs +1 -2212
  52. package/dist/_chunks/manual-layout.mjs +1 -0
  53. package/dist/_chunks/model.mjs +4 -1898
  54. package/dist/_chunks/rolldown-runtime.mjs +1 -42
  55. package/dist/_chunks/types.mjs +1 -0
  56. package/dist/_chunks/utils.mjs +1 -483
  57. package/dist/builder/index.d.mts +3 -6
  58. package/dist/builder/index.mjs +1 -662
  59. package/dist/compute-view/index.d.mts +85 -13
  60. package/dist/compute-view/index.mjs +2 -262
  61. package/dist/geometry/index.d.mts +2 -2
  62. package/dist/geometry/index.mjs +1 -3
  63. package/dist/index.d.mts +7 -13
  64. package/dist/index.mjs +1 -27
  65. package/dist/model/index.d.mts +4 -11
  66. package/dist/model/index.mjs +1 -11
  67. package/dist/styles/index.d.mts +2 -7
  68. package/dist/styles/index.mjs +1 -30
  69. package/dist/types/index.d.mts +3 -9
  70. package/dist/types/index.mjs +1 -15
  71. package/dist/utils/graphology/index.d.mts +1 -1
  72. package/dist/utils/graphology/index.mjs +1 -3
  73. package/dist/utils/index.d.mts +5 -10
  74. package/dist/utils/index.mjs +1 -17
  75. package/package.json +14 -13
  76. package/dist/_chunks/LikeC4Styles.mjs +0 -691
  77. package/dist/_chunks/RichText.d.mts +0 -84
  78. package/dist/_chunks/RichText.mjs +0 -148
  79. package/dist/_chunks/_aux.d.mts +0 -289
  80. package/dist/_chunks/_aux.mjs +0 -18
  81. package/dist/_chunks/calcDriftsFromSnapshot.mjs +0 -379
  82. package/dist/_chunks/connection.mjs +0 -0
  83. package/dist/_chunks/const.d.mts +0 -43
  84. package/dist/_chunks/const.mjs +0 -33
  85. package/dist/_chunks/expression-model.d.mts +0 -192
  86. package/dist/_chunks/expression-model.mjs +0 -103
  87. package/dist/_chunks/expression.d.mts +0 -347
  88. package/dist/_chunks/expression.mjs +0 -107
  89. package/dist/_chunks/find.d.mts +0 -82
  90. package/dist/_chunks/find.mjs +0 -646
  91. package/dist/_chunks/find2.d.mts +0 -78
  92. package/dist/_chunks/find2.mjs +0 -287
  93. package/dist/_chunks/fqnRef.d.mts +0 -58
  94. package/dist/_chunks/fqnRef.mjs +0 -41
  95. package/dist/_chunks/index6.d.mts +0 -43
  96. package/dist/_chunks/index7.d.mts +0 -268
  97. package/dist/_chunks/index8.d.mts +0 -144
  98. package/dist/_chunks/invariant.mjs +0 -18
  99. package/dist/_chunks/iterable.mjs +0 -146
  100. package/dist/_chunks/libs/graphology-types.d.mts +0 -601
  101. package/dist/_chunks/libs/graphology.d.mts +0 -6
  102. package/dist/_chunks/mnemonist.mjs +0 -0
  103. package/dist/_chunks/model2.mjs +0 -0
  104. package/dist/_chunks/relationships-view.mjs +0 -132
  105. package/dist/_chunks/scalar.d.mts +0 -109
  106. package/dist/_chunks/scalar.mjs +0 -84
  107. package/dist/compute-view/relationships-view/index.d.mts +0 -16
  108. package/dist/compute-view/relationships-view/index.mjs +0 -7
  109. package/dist/model/connection/deployment/index.d.mts +0 -12
  110. package/dist/model/connection/deployment/index.mjs +0 -9
  111. package/dist/model/connection/index.d.mts +0 -14
  112. package/dist/model/connection/index.mjs +0 -10
  113. package/dist/model/connection/model/index.d.mts +0 -12
  114. package/dist/model/connection/model/index.mjs +0 -8
  115. package/dist/types/RichText.d.mts +0 -3
  116. package/dist/types/RichText.mjs +0 -7
  117. package/dist/types/_aux.d.mts +0 -3
  118. package/dist/types/_aux.mjs +0 -3
  119. package/dist/types/expression-model.d.mts +0 -6
  120. package/dist/types/expression-model.mjs +0 -7
  121. package/dist/types/expression.d.mts +0 -5
  122. package/dist/types/expression.mjs +0 -7
  123. package/dist/types/fqnRef.d.mts +0 -4
  124. package/dist/types/fqnRef.mjs +0 -7
  125. package/dist/types/scalar.d.mts +0 -2
  126. package/dist/types/scalar.mjs +0 -7
  127. package/dist/utils/iterable/index.d.mts +0 -9
  128. package/dist/utils/iterable/index.mjs +0 -3
  129. package/dist/utils/mnemonist.d.mts +0 -2
  130. package/dist/utils/mnemonist.mjs +0 -12
@@ -1,646 +0,0 @@
1
- import { n as __exportAll } from "./rolldown-runtime.mjs";
2
- import { D as e$1, F as e$2, I as e, i as n, k as t } from "./libs/remeda.mjs";
3
- import { I as exact } from "./LikeC4Styles.mjs";
4
- import { E as nameFromFqn, S as hierarchyLevel, T as isSameHierarchy, a as difference, c as intersection, h as memoizeProp, o as equals, r as stringHash, u as union, v as commonAncestor } from "./utils.mjs";
5
- import { n as nonNullable, t as invariant } from "./invariant.mjs";
6
- import { s as ihead } from "./iterable.mjs";
7
- import { n as preferSummary, t as preferDescription } from "./_aux.mjs";
8
- import { t as RichText } from "./RichText.mjs";
9
- import { t as customInspectSymbol } from "./const.mjs";
10
-
11
- //#region src/model/DeploymentElementModel.ts
12
- var AbstractDeploymentElementModel = class {
13
- /**
14
- * Don't use in runtime, only for type inference
15
- */
16
- Aux;
17
- get style() {
18
- return memoizeProp(this, "style", () => exact({
19
- shape: this.$model.$styles.defaults.shape,
20
- color: this.$model.$styles.defaults.color,
21
- border: this.$model.$styles.defaults.border,
22
- opacity: this.$model.$styles.defaults.opacity,
23
- size: this.$model.$styles.defaults.size,
24
- padding: this.$model.$styles.defaults.padding,
25
- textSize: this.$model.$styles.defaults.text,
26
- ...this.$node.style
27
- }));
28
- }
29
- get name() {
30
- return nameFromFqn(this.id);
31
- }
32
- get shape() {
33
- return this.style.shape;
34
- }
35
- get color() {
36
- return this.style.color;
37
- }
38
- get icon() {
39
- return this.style.icon ?? null;
40
- }
41
- /**
42
- * Short description of the element.
43
- * Falls back to description if summary is not provided.
44
- */
45
- get summary() {
46
- return RichText.memoize(this, "summary", /* @__PURE__ */ preferSummary(this.$node));
47
- }
48
- /**
49
- * Long description of the element.
50
- * Falls back to summary if description is not provided.
51
- */
52
- get description() {
53
- return RichText.memoize(this, "description", /* @__PURE__ */ preferDescription(this.$node));
54
- }
55
- get technology() {
56
- return this.$node.technology ?? null;
57
- }
58
- get links() {
59
- return this.$node.links ?? [];
60
- }
61
- /**
62
- * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
63
- * (from closest to root)
64
- */
65
- ancestors() {
66
- return this.$model.ancestors(this);
67
- }
68
- /**
69
- * Returns the common ancestor of this element and another element.
70
- */
71
- commonAncestor(another) {
72
- const common = commonAncestor(this.id, another.id);
73
- return common ? this.$model.node(common) : null;
74
- }
75
- /**
76
- * Get all sibling (i.e. same parent)
77
- */
78
- siblings() {
79
- return this.$model.siblings(this);
80
- }
81
- /**
82
- * Check if the element is a sibling of another element
83
- */
84
- isSibling(other) {
85
- return this.parent === other.parent;
86
- }
87
- /**
88
- * Resolve siblings of the element and its ancestors
89
- * (from closest to root)
90
- */
91
- *ascendingSiblings() {
92
- yield* this.siblings();
93
- for (const ancestor of this.ancestors()) yield* ancestor.siblings();
94
- }
95
- /**
96
- * Resolve siblings of the element and its ancestors
97
- * (from root to closest)
98
- */
99
- *descendingSiblings() {
100
- for (const ancestor of [...this.ancestors()].reverse()) yield* ancestor.siblings();
101
- yield* this.siblings();
102
- }
103
- incoming(filter = "all") {
104
- return this.$model.incoming(this, filter);
105
- }
106
- outgoing(filter = "all") {
107
- return this.$model.outgoing(this, filter);
108
- }
109
- *incomers(filter = "all") {
110
- const unique = /* @__PURE__ */ new Set();
111
- for (const r of this.incoming(filter)) {
112
- if (unique.has(r.source.id)) continue;
113
- unique.add(r.source.id);
114
- yield r.source;
115
- }
116
- }
117
- *outgoers(filter = "all") {
118
- const unique = /* @__PURE__ */ new Set();
119
- for (const r of this.outgoing(filter)) {
120
- if (unique.has(r.target.id)) continue;
121
- unique.add(r.target.id);
122
- yield r.target;
123
- }
124
- }
125
- /**
126
- * Iterate over all views that include this deployment element.
127
- */
128
- *views() {
129
- for (const view of this.$model.views()) {
130
- if (view._type !== "deployment") continue;
131
- if (view.includesDeployment(this.id)) yield view;
132
- }
133
- }
134
- isDeploymentNode() {
135
- return false;
136
- }
137
- isInstance() {
138
- return false;
139
- }
140
- get allOutgoing() {
141
- return memoizeProp(this, Symbol.for("allOutgoing"), () => RelationshipsAccum.from(new Set(this.outgoingModelRelationships()), new Set(this.outgoing())));
142
- }
143
- get allIncoming() {
144
- return memoizeProp(this, Symbol.for("allIncoming"), () => RelationshipsAccum.from(new Set(this.incomingModelRelationships()), new Set(this.incoming())));
145
- }
146
- hasMetadata() {
147
- return !!this.$node.metadata && !e(this.$node.metadata);
148
- }
149
- getMetadata(field) {
150
- if (field) return this.$node.metadata?.[field];
151
- return this.$node.metadata ?? {};
152
- }
153
- /**
154
- * Checks if the deployment element has the given tag.
155
- */
156
- isTagged(tag) {
157
- return this.tags.includes(tag);
158
- }
159
- };
160
- var DeploymentNodeModel = class extends AbstractDeploymentElementModel {
161
- id;
162
- _literalId;
163
- title;
164
- hierarchyLevel;
165
- constructor($model, $node) {
166
- super();
167
- this.$model = $model;
168
- this.$node = $node;
169
- this.id = $node.id;
170
- this._literalId = $node.id;
171
- this.title = $node.title;
172
- this.hierarchyLevel = hierarchyLevel($node.id);
173
- }
174
- get parent() {
175
- return this.$model.parent(this);
176
- }
177
- get kind() {
178
- return this.$node.kind;
179
- }
180
- get tags() {
181
- return memoizeProp(this, Symbol.for("tags"), () => {
182
- return n([...this.$node.tags ?? [], ...this.$model.$model.specification.deployments[this.kind]?.tags ?? []]);
183
- });
184
- }
185
- children() {
186
- return this.$model.children(this);
187
- }
188
- descendants(sort = "desc") {
189
- return this.$model.descendants(this, sort);
190
- }
191
- isDeploymentNode() {
192
- return true;
193
- }
194
- /**
195
- * Iterate over all instances nested in this deployment node.
196
- */
197
- *instances() {
198
- for (const nested of this.descendants("desc")) if (nested.isInstance()) yield nested;
199
- }
200
- /**
201
- * Returns deployed instance inside this deployment node
202
- * if only there are no more instances
203
- */
204
- onlyOneInstance() {
205
- const children = this.children();
206
- if (children.size !== 1) return null;
207
- const child = ihead(children);
208
- if (!child) return null;
209
- return child.isInstance() ? child : child.onlyOneInstance();
210
- }
211
- /**
212
- * Cached result of relationships from instances
213
- */
214
- _relationshipsFromInstances = null;
215
- relationshipsFromInstances() {
216
- if (this._relationshipsFromInstances) return this._relationshipsFromInstances;
217
- const { outgoing, incoming } = this._relationshipsFromInstances = {
218
- outgoing: /* @__PURE__ */ new Set(),
219
- incoming: /* @__PURE__ */ new Set()
220
- };
221
- for (const instance of this.instances()) {
222
- for (const r of instance.element.outgoing()) outgoing.add(r);
223
- for (const r of instance.element.incoming()) incoming.add(r);
224
- }
225
- return this._relationshipsFromInstances;
226
- }
227
- /**
228
- * We return only relationships that are not already present in nested instances
229
- */
230
- outgoingModelRelationships() {
231
- return this.relationshipsFromInstances().outgoing.values();
232
- }
233
- /**
234
- * We return only relationships that are not already present in nested instances
235
- */
236
- incomingModelRelationships() {
237
- return this.relationshipsFromInstances().incoming.values();
238
- }
239
- /**
240
- * Returns an iterator of relationships between nested instances
241
- */
242
- internalModelRelationships() {
243
- const { outgoing, incoming } = this.relationshipsFromInstances();
244
- return intersection(incoming, outgoing);
245
- }
246
- };
247
- var DeployedInstanceModel = class extends AbstractDeploymentElementModel {
248
- id;
249
- _literalId;
250
- title;
251
- hierarchyLevel;
252
- constructor($model, $instance, element) {
253
- super();
254
- this.$model = $model;
255
- this.$instance = $instance;
256
- this.element = element;
257
- this.id = $instance.id;
258
- this._literalId = $instance.id;
259
- this.title = $instance.title ?? element.title;
260
- this.hierarchyLevel = hierarchyLevel($instance.id);
261
- }
262
- get $node() {
263
- return this.$instance;
264
- }
265
- get parent() {
266
- return nonNullable(this.$model.parent(this), `Parent of ${this.id} not found`);
267
- }
268
- get style() {
269
- return memoizeProp(this, "style", () => exact({
270
- shape: this.$model.$styles.defaults.shape,
271
- color: this.$model.$styles.defaults.color,
272
- border: this.$model.$styles.defaults.border,
273
- opacity: this.$model.$styles.defaults.opacity,
274
- size: this.$model.$styles.defaults.size,
275
- padding: this.$model.$styles.defaults.padding,
276
- textSize: this.$model.$styles.defaults.text,
277
- ...this.element.$element.style,
278
- ...this.$instance.style
279
- }));
280
- }
281
- get tags() {
282
- return memoizeProp(this, Symbol.for("tags"), () => {
283
- return n([...this.$instance.tags ?? [], ...this.element.tags]);
284
- });
285
- }
286
- get kind() {
287
- return this.element.kind;
288
- }
289
- get summary() {
290
- return RichText.memoize(this, "summary", /* @__PURE__ */ preferSummary(this.$instance) ?? /* @__PURE__ */ preferSummary(this.element.$element));
291
- }
292
- get description() {
293
- return RichText.memoize(this, "description", /* @__PURE__ */ preferDescription(this.$instance) ?? /* @__PURE__ */ preferDescription(this.element.$element));
294
- }
295
- get technology() {
296
- return this.$instance.technology ?? this.element.technology ?? null;
297
- }
298
- get links() {
299
- return this.$instance.links ?? this.element.links;
300
- }
301
- isInstance() {
302
- return true;
303
- }
304
- outgoingModelRelationships() {
305
- return this.element.outgoing();
306
- }
307
- incomingModelRelationships() {
308
- return this.element.incoming();
309
- }
310
- /**
311
- * Iterate over all views that include this instance.
312
- * (Some views may include the parent deployment node instead of the instance.)
313
- */
314
- *views() {
315
- for (const view of this.$model.views()) {
316
- if (view._type !== "deployment") continue;
317
- if (view.includesDeployment(this.id)) {
318
- yield view;
319
- continue;
320
- }
321
- if (view.includesDeployment(this.parent.id) && this.parent.onlyOneInstance()) yield view;
322
- }
323
- }
324
- };
325
- var NestedElementOfDeployedInstanceModel = class {
326
- constructor(instance, element) {
327
- this.instance = instance;
328
- this.element = element;
329
- }
330
- get id() {
331
- return this.instance.id;
332
- }
333
- get _literalId() {
334
- return this.instance.id;
335
- }
336
- get style() {
337
- return memoizeProp(this, "style ", () => ({
338
- shape: this.element.shape,
339
- color: this.element.color,
340
- ...this.element.$element.style
341
- }));
342
- }
343
- get shape() {
344
- return this.element.shape;
345
- }
346
- get color() {
347
- return this.element.color;
348
- }
349
- get title() {
350
- return this.element.title;
351
- }
352
- get summary() {
353
- return this.element.summary;
354
- }
355
- get description() {
356
- return this.element.description;
357
- }
358
- get technology() {
359
- return this.element.technology;
360
- }
361
- isDeploymentNode() {
362
- return false;
363
- }
364
- isInstance() {
365
- return false;
366
- }
367
- };
368
- var DeploymentRelationModel = class {
369
- boundary;
370
- source;
371
- target;
372
- constructor($model, $relationship) {
373
- this.$model = $model;
374
- this.$relationship = $relationship;
375
- this.source = $model.deploymentRef($relationship.source);
376
- this.target = $model.deploymentRef($relationship.target);
377
- const parent = commonAncestor(this.source.id, this.target.id);
378
- this.boundary = parent ? this.$model.node(parent) : null;
379
- }
380
- get id() {
381
- return this.$relationship.id;
382
- }
383
- get expression() {
384
- return `${this.source.id} -> ${this.target.id}`;
385
- }
386
- get title() {
387
- if (!e$1(this.$relationship.title)) return null;
388
- return this.$relationship.title;
389
- }
390
- get technology() {
391
- if (e$2(this.$relationship.technology)) return (this.kind && this.$model.specification.relationships[this.kind])?.technology ?? null;
392
- return this.$relationship.technology;
393
- }
394
- /**
395
- * Returns true if the relationship has a summary and a description
396
- * (if one is missing - it falls back to another)
397
- */
398
- get hasSummary() {
399
- return !!this.$relationship.summary && !!this.$relationship.description && !t(this.$relationship.summary, this.$relationship.description);
400
- }
401
- /**
402
- * Short description of the relationship.
403
- * Falls back to description if summary is not provided.
404
- */
405
- get summary() {
406
- return RichText.memoize(this, "summary", /* @__PURE__ */ preferSummary(this.$relationship));
407
- }
408
- /**
409
- * Long description of the relationship.
410
- * Falls back to summary if description is not provided.
411
- */
412
- get description() {
413
- return RichText.memoize(this, "description", /* @__PURE__ */ preferDescription(this.$relationship));
414
- }
415
- get tags() {
416
- return this.$relationship.tags ?? [];
417
- }
418
- get kind() {
419
- return this.$relationship.kind ?? null;
420
- }
421
- get navigateTo() {
422
- return this.$relationship.navigateTo ? this.$model.$model.view(this.$relationship.navigateTo) : null;
423
- }
424
- get links() {
425
- return this.$relationship.links ?? [];
426
- }
427
- get color() {
428
- return this.$relationship.color ?? this.$model.$styles.defaults.relationship.color;
429
- }
430
- get line() {
431
- return this.$relationship.line ?? this.$model.$styles.defaults.relationship.line;
432
- }
433
- get head() {
434
- return this.$relationship.head ?? this.$model.$styles.defaults.relationship.arrow;
435
- }
436
- get tail() {
437
- return this.$relationship.tail;
438
- }
439
- *views() {
440
- for (const view of this.$model.views()) if (view.includesRelation(this.id)) yield view;
441
- }
442
- isDeploymentRelation() {
443
- return true;
444
- }
445
- isModelRelation() {
446
- return false;
447
- }
448
- hasMetadata() {
449
- return !!this.$relationship.metadata && !e(this.$relationship.metadata);
450
- }
451
- getMetadata(field) {
452
- if (field) return this.$relationship.metadata?.[field];
453
- return this.$relationship.metadata ?? {};
454
- }
455
- /**
456
- * Checks if the relationship has the given tag.
457
- */
458
- isTagged(tag) {
459
- return this.tags.includes(tag);
460
- }
461
- };
462
- var RelationshipsAccum = class RelationshipsAccum {
463
- static empty() {
464
- return new RelationshipsAccum();
465
- }
466
- static from(model, deployment) {
467
- return new RelationshipsAccum(new Set(model), new Set(deployment));
468
- }
469
- /**
470
- * @param model relationships from logical model
471
- * @param deployment relationships from deployment model
472
- */
473
- constructor(model = /* @__PURE__ */ new Set(), deployment = /* @__PURE__ */ new Set()) {
474
- this.model = model;
475
- this.deployment = deployment;
476
- }
477
- get isEmpty() {
478
- return this.model.size === 0 && this.deployment.size === 0;
479
- }
480
- get nonEmpty() {
481
- return this.model.size > 0 || this.deployment.size > 0;
482
- }
483
- get size() {
484
- return this.model.size + this.deployment.size;
485
- }
486
- /**
487
- * Returns new Accum containing all the elements which are both in this and otherAccum
488
- */
489
- intersect(otherAccum) {
490
- return RelationshipsAccum.from(intersection(this.model, otherAccum.model), intersection(this.deployment, otherAccum.deployment));
491
- }
492
- /**
493
- * Returns new Accum containing all the elements which are both in this and otherAccum
494
- */
495
- difference(otherAccum) {
496
- return RelationshipsAccum.from(difference(this.model, otherAccum.model), difference(this.deployment, otherAccum.deployment));
497
- }
498
- /**
499
- * Returns new Accum containing all the elements from both
500
- */
501
- union(otherAccum) {
502
- return RelationshipsAccum.from(union(this.model, otherAccum.model), union(this.deployment, otherAccum.deployment));
503
- }
504
- };
505
-
506
- //#endregion
507
- //#region src/model/connection/deployment/DeploymentConnectionModel.ts
508
- /**
509
- * Connection is ephemeral entity, result of a resolving relationships between source and target.
510
- * Includes direct relationships and/or between their nested elements.
511
- */
512
- var DeploymentConnectionModel = class DeploymentConnectionModel {
513
- id;
514
- constructor(source, target, relations) {
515
- this.source = source;
516
- this.target = target;
517
- this.relations = relations;
518
- this.id = stringHash(`deployment:${source.id}:${target.id}`);
519
- }
520
- /**
521
- * Human readable expression of the connection
522
- * Mostly used for testing and debugging
523
- */
524
- get expression() {
525
- return `${this.source.id} -> ${this.target.id}`;
526
- }
527
- _boundary;
528
- /**
529
- * Common ancestor of the source and target elements.
530
- * Represents the boundary of the connection.
531
- */
532
- get boundary() {
533
- this._boundary ??= this.source.commonAncestor(this.target);
534
- return this._boundary;
535
- }
536
- nonEmpty() {
537
- return this.relations.nonEmpty;
538
- }
539
- [customInspectSymbol](_depth, _inspectOptions, _inspect) {
540
- const asString = this.toString();
541
- Object.defineProperty(asString, "constructor", {
542
- value: DeploymentConnectionModel,
543
- enumerable: false
544
- });
545
- return asString;
546
- }
547
- toString() {
548
- const model = [...this.relations.model].map((c) => " " + c.expression);
549
- if (model.length) model.unshift(" model:");
550
- else model.unshift(" model: []");
551
- const deployment = [...this.relations.deployment].map((c) => " " + c.expression);
552
- if (deployment.length) deployment.unshift(" deployment:");
553
- else deployment.unshift(" deployment: []");
554
- return [
555
- this.expression,
556
- ...model,
557
- ...deployment
558
- ].join("\n");
559
- }
560
- /**
561
- * Check if connection contains deployment relation,
562
- * that is directly connected to source or target.
563
- */
564
- hasDirectDeploymentRelation() {
565
- for (const relation of this.relations.deployment) if (relation.source.id === this.source.id || relation.target.id === this.target.id) return true;
566
- return false;
567
- }
568
- *values() {
569
- yield* this.relations.model;
570
- yield* this.relations.deployment;
571
- }
572
- mergeWith(other) {
573
- if (Array.isArray(other)) return other.reduce((acc, o) => acc.mergeWith(o), this);
574
- invariant(this.source.id === other.source.id, "Cannot merge connections with different sources");
575
- invariant(this.target.id === other.target.id, "Cannot merge connections with different targets");
576
- return new DeploymentConnectionModel(this.source, this.target, this.relations.union(other.relations));
577
- }
578
- difference(other) {
579
- return new DeploymentConnectionModel(this.source, this.target, this.relations.difference(other.relations));
580
- }
581
- intersect(other) {
582
- return new DeploymentConnectionModel(this.source, this.target, this.relations.intersect(other.relations));
583
- }
584
- equals(other) {
585
- invariant(other instanceof DeploymentConnectionModel, "Other should ne DeploymentConnectionModel");
586
- return this.id === other.id && this.source.id === other.source.id && this.target.id === other.target.id && equals(this.relations.model, other.relations.model) && equals(this.relations.deployment, other.relations.deployment);
587
- }
588
- /**
589
- * Creates a clone of the current `DeploymentConnectionModel` instance with optional overrides.
590
- * if `null` is provided in overrides, the corresponding relation set will be empty.
591
- */
592
- update(overrides) {
593
- if (overrides) overrides = {
594
- model: this.relations.model,
595
- deployment: this.relations.deployment,
596
- ...overrides
597
- };
598
- return new DeploymentConnectionModel(this.source, this.target, overrides ? new RelationshipsAccum(overrides.model ?? /* @__PURE__ */ new Set(), overrides.deployment ?? /* @__PURE__ */ new Set()) : this.relations);
599
- }
600
- };
601
-
602
- //#endregion
603
- //#region src/model/connection/deployment/find.ts
604
- var find_exports = /* @__PURE__ */ __exportAll({
605
- findConnection: () => findConnection,
606
- findConnectionsBetween: () => findConnectionsBetween,
607
- findConnectionsWithin: () => findConnectionsWithin
608
- });
609
- function findConnection(source, target, direction = "directed") {
610
- if (source === target) return [];
611
- if (isSameHierarchy(source, target)) return [];
612
- const directedIntersection = source.allOutgoing.intersect(target.allIncoming);
613
- const directed = directedIntersection.nonEmpty ? [new DeploymentConnectionModel(source, target, directedIntersection)] : [];
614
- if (direction === "directed") return directed;
615
- return [...directed, ...findConnection(target, source, "directed")];
616
- }
617
- /**
618
- * Resolve all connections between element and others
619
- * By default, look for both directions.
620
- *
621
- * @default direction both
622
- */
623
- function findConnectionsBetween(element, others, direction = "both") {
624
- if (element.allIncoming.isEmpty && element.allOutgoing.isEmpty) return [];
625
- const outgoing = [];
626
- const incoming = [];
627
- for (const _other of others) {
628
- if (element === _other) continue;
629
- for (const found of findConnection(element, _other, direction)) if (found.source === element) outgoing.push(found);
630
- else incoming.push(found);
631
- }
632
- return [...outgoing, ...incoming];
633
- }
634
- /**
635
- * Resolve all connections within a given set of elements
636
- */
637
- function findConnectionsWithin(elements) {
638
- return [...elements].reduce((acc, el, index, array) => {
639
- if (index === array.length - 1) return acc;
640
- acc.push(...findConnectionsBetween(el, array.slice(index + 1), "both"));
641
- return acc;
642
- }, []);
643
- }
644
-
645
- //#endregion
646
- export { DeploymentConnectionModel as a, DeploymentRelationModel as c, find_exports as i, NestedElementOfDeployedInstanceModel as l, findConnectionsBetween as n, DeployedInstanceModel as o, findConnectionsWithin as r, DeploymentNodeModel as s, findConnection as t, RelationshipsAccum as u };