@likec4/core 1.47.0 → 1.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/LICENSE +1 -1
  2. package/dist/THIRD-PARTY-LICENSES.md +1012 -0
  3. package/dist/_chunks/Builder.view-element.mjs +2 -0
  4. package/dist/_chunks/LikeC4Model.d.mts +1283 -0
  5. package/dist/_chunks/RichText.mjs +1 -0
  6. package/dist/_chunks/_types.d.mts +777 -0
  7. package/dist/_chunks/_types2.d.mts +36 -0
  8. package/dist/_chunks/assignTagColors.mjs +1 -0
  9. package/dist/_chunks/calcDriftsFromSnapshot.mjs +1 -0
  10. package/dist/_chunks/guards.d.mts +2026 -0
  11. package/dist/_chunks/guards.mjs +4 -0
  12. package/dist/_chunks/index.d.mts +288 -0
  13. package/dist/_chunks/libs/@mantine/colors-generator.mjs +15 -0
  14. package/dist/_chunks/libs/@radix-ui/colors.mjs +1 -0
  15. package/dist/_chunks/libs/@ungap/structured-clone.mjs +1 -0
  16. package/dist/_chunks/libs/bail.mjs +1 -0
  17. package/dist/_chunks/libs/ccount.mjs +1 -0
  18. package/dist/_chunks/libs/character-entities-html4.mjs +1 -0
  19. package/dist/_chunks/libs/character-entities-legacy.mjs +1 -0
  20. package/dist/_chunks/libs/character-entities.mjs +2 -0
  21. package/dist/_chunks/libs/comma-separated-tokens.mjs +1 -0
  22. package/dist/_chunks/libs/decode-named-character-reference.mjs +1 -0
  23. package/dist/_chunks/libs/defu.mjs +1 -0
  24. package/dist/_chunks/libs/devlop.mjs +1 -0
  25. package/dist/_chunks/libs/escape-string-regexp.mjs +1 -0
  26. package/dist/_chunks/libs/extend.mjs +1 -0
  27. package/dist/_chunks/libs/graphology-dag.mjs +1 -0
  28. package/dist/_chunks/libs/graphology.mjs +1 -0
  29. package/dist/_chunks/libs/hast-util-sanitize.mjs +1 -0
  30. package/dist/_chunks/libs/hast-util-to-html.mjs +9 -0
  31. package/dist/_chunks/libs/is-plain-obj.mjs +1 -0
  32. package/dist/_chunks/libs/longest-streak.mjs +1 -0
  33. package/dist/_chunks/libs/markdown-table.mjs +2 -0
  34. package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +1 -0
  35. package/dist/_chunks/libs/mdast-util-from-markdown.mjs +3 -0
  36. package/dist/_chunks/libs/mdast-util-gfm.mjs +15 -0
  37. package/dist/_chunks/libs/mdast-util-to-hast.mjs +11 -0
  38. package/dist/_chunks/libs/micromark-extension-gfm.mjs +1 -0
  39. package/dist/_chunks/libs/mnemonist.d.mts +164 -0
  40. package/dist/_chunks/libs/mnemonist.mjs +1 -0
  41. package/dist/_chunks/libs/natural-compare-lite.mjs +9 -0
  42. package/dist/_chunks/libs/ohash.mjs +1 -0
  43. package/dist/_chunks/libs/rehype-sanitize.mjs +1 -0
  44. package/dist/_chunks/libs/rehype-stringify.mjs +1 -0
  45. package/dist/_chunks/libs/remark-gfm.mjs +1 -0
  46. package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +3 -0
  47. package/dist/_chunks/libs/remark-parse.mjs +1 -0
  48. package/dist/_chunks/libs/remark-rehype.mjs +1 -0
  49. package/dist/_chunks/libs/remeda.mjs +1 -0
  50. package/dist/_chunks/libs/trough.mjs +1 -0
  51. package/dist/_chunks/libs/unified.mjs +1 -0
  52. package/dist/_chunks/rolldown-runtime.mjs +1 -0
  53. package/dist/_chunks/theme.d.mts +148 -0
  54. package/dist/_chunks/to-text.d.mts +404 -0
  55. package/dist/_chunks/to-text.mjs +1 -0
  56. package/dist/_chunks/vector.d.mts +198 -0
  57. package/dist/_chunks/vector.mjs +1 -0
  58. package/dist/builder/index.d.mts +5 -775
  59. package/dist/builder/index.mjs +1 -1053
  60. package/dist/compute-view/index.d.mts +156 -56
  61. package/dist/compute-view/index.mjs +2 -229
  62. package/dist/geometry/index.d.mts +2 -109
  63. package/dist/geometry/index.mjs +1 -328
  64. package/dist/index.d.mts +14 -20
  65. package/dist/index.mjs +1 -18
  66. package/dist/model/index.d.mts +5 -57
  67. package/dist/model/index.mjs +1 -4
  68. package/dist/styles/index.d.mts +3 -117
  69. package/dist/styles/index.mjs +1 -63
  70. package/dist/types/index.d.mts +3 -47
  71. package/dist/types/index.mjs +1 -17
  72. package/dist/utils/graphology/index.d.mts +2 -1864
  73. package/dist/utils/graphology/index.mjs +1 -1
  74. package/dist/utils/index.d.mts +4 -124
  75. package/dist/utils/index.mjs +1 -44
  76. package/package.json +20 -24
  77. package/compute-view/relationships/package.json +0 -4
  78. package/dist/compute-view/relationships-view/index.d.mts +0 -51
  79. package/dist/compute-view/relationships-view/index.mjs +0 -185
  80. package/dist/model/connection/deployment/index.d.mts +0 -15
  81. package/dist/model/connection/deployment/index.mjs +0 -2
  82. package/dist/model/connection/index.d.mts +0 -75
  83. package/dist/model/connection/index.mjs +0 -3
  84. package/dist/model/connection/model/index.d.mts +0 -15
  85. package/dist/model/connection/model/index.mjs +0 -2
  86. package/dist/shared/core.3ZhnKAlZ.mjs +0 -106
  87. package/dist/shared/core.78IWAHAE.mjs +0 -332
  88. package/dist/shared/core.B85MJLTf.mjs +0 -5
  89. package/dist/shared/core.BFd1lU9R.mjs +0 -29
  90. package/dist/shared/core.BKlholso.mjs +0 -3
  91. package/dist/shared/core.BNN-3vPH.mjs +0 -1255
  92. package/dist/shared/core.BPGOjone.d.mts +0 -46
  93. package/dist/shared/core.BP_QHEXs.mjs +0 -785
  94. package/dist/shared/core.BbE4y-yl.mjs +0 -177
  95. package/dist/shared/core.Bdy3hhTc.mjs +0 -28382
  96. package/dist/shared/core.BfCKSW-g.d.mts +0 -1266
  97. package/dist/shared/core.BhNcrwzK.mjs +0 -7
  98. package/dist/shared/core.BkVA6gjl.mjs +0 -5
  99. package/dist/shared/core.BoYfZOBm.mjs +0 -3
  100. package/dist/shared/core.BsSXS-_R.mjs +0 -7
  101. package/dist/shared/core.C3JowhaZ.mjs +0 -32
  102. package/dist/shared/core.C4x8aaWa.mjs +0 -27
  103. package/dist/shared/core.CAgYpDtM.d.mts +0 -98
  104. package/dist/shared/core.CHf8VEa3.mjs +0 -1206
  105. package/dist/shared/core.CLSZtnFh.mjs +0 -69
  106. package/dist/shared/core.C_3y3eqV.d.mts +0 -139
  107. package/dist/shared/core.CbT8JVYL.mjs +0 -5
  108. package/dist/shared/core.CdNCAwq7.mjs +0 -176
  109. package/dist/shared/core.CmGY9blO.mjs +0 -6717
  110. package/dist/shared/core.CmPXpJ8l.mjs +0 -21
  111. package/dist/shared/core.Coi_LOUZ.mjs +0 -7
  112. package/dist/shared/core.CqAJJpK_.mjs +0 -3
  113. package/dist/shared/core.CywrQs86.d.mts +0 -31
  114. package/dist/shared/core.D00YbOhQ.d.mts +0 -300
  115. package/dist/shared/core.D0WZutNd.mjs +0 -94
  116. package/dist/shared/core.D4npX2q8.mjs +0 -18
  117. package/dist/shared/core.DB0Ue5Wx.d.mts +0 -70
  118. package/dist/shared/core.DC5IAaDT.d.mts +0 -334
  119. package/dist/shared/core.DE9qzhn8.d.mts +0 -83
  120. package/dist/shared/core.DGcIbsj4.mjs +0 -3946
  121. package/dist/shared/core.DH7TXqXf.mjs +0 -136
  122. package/dist/shared/core.DKhRkHRN.d.mts +0 -41
  123. package/dist/shared/core.DRJma0Ol.mjs +0 -22
  124. package/dist/shared/core.DU5SRqNF.mjs +0 -2209
  125. package/dist/shared/core.DXhDWKFZ.d.mts +0 -3
  126. package/dist/shared/core.DbfO90vF.mjs +0 -434
  127. package/dist/shared/core.DcS-0zys.mjs +0 -10
  128. package/dist/shared/core.Dh119QSP.mjs +0 -4995
  129. package/dist/shared/core.DjcWextK.mjs +0 -1371
  130. package/dist/shared/core.Dojz4bvg.d.mts +0 -504
  131. package/dist/shared/core.FZ305VYd.mjs +0 -21
  132. package/dist/shared/core.OtRNdMxy.d.mts +0 -352
  133. package/dist/shared/core.RfnaEmgA.mjs +0 -7
  134. package/dist/shared/core.btEq3i3f.mjs +0 -300
  135. package/dist/shared/core.oSV6SRfk.mjs +0 -13
  136. package/dist/shared/core.om36dXXW.mjs +0 -41
  137. package/dist/shared/core.osFs8tU7.d.mts +0 -466
  138. package/dist/shared/core.q10OP9oJ.mjs +0 -5
  139. package/dist/shared/core.tpvDGvdC.d.mts +0 -87
  140. package/dist/shared/core.uFk_o9X6.mjs +0 -13
  141. package/dist/types/_aux.d.mts +0 -4
  142. package/dist/types/_aux.mjs +0 -8
  143. package/dist/types/expression-model.d.mts +0 -190
  144. package/dist/types/expression-model.mjs +0 -109
  145. package/dist/types/expression.d.mts +0 -6
  146. package/dist/types/expression.mjs +0 -113
  147. package/dist/types/fqnRef.d.mts +0 -60
  148. package/dist/types/fqnRef.mjs +0 -45
  149. package/dist/types/scalar.d.mts +0 -2
  150. package/dist/types/scalar.mjs +0 -4
  151. package/dist/utils/iterable/index.d.mts +0 -132
  152. package/dist/utils/iterable/index.mjs +0 -62
@@ -1,785 +0,0 @@
1
- import { c as customInspectSymbol } from './core.BFd1lU9R.mjs';
2
- import { i as intersection, d as difference, u as union, e as equals } from './core.DbfO90vF.mjs';
3
- import { t as t$1 } from './core.BsSXS-_R.mjs';
4
- import { e as e$1 } from './core.BKlholso.mjs';
5
- import { n as n$1 } from './core.BhNcrwzK.mjs';
6
- import { m as hierarchyLevel, g as commonAncestor, n as nameFromFqn, d as isSameHierarchy } from './core.CdNCAwq7.mjs';
7
- import { a as nonNullable, i as invariant } from './core.D4npX2q8.mjs';
8
- import { m as memoizeProp } from './core.CLSZtnFh.mjs';
9
- import { e as exact, R as RichText } from './core.CHf8VEa3.mjs';
10
- import { preferSummary, preferDescription } from '../types/_aux.mjs';
11
- import { i as ihead } from './core.uFk_o9X6.mjs';
12
- import { s as stringHash } from './core.oSV6SRfk.mjs';
13
-
14
- function e(e){return e===``||e===void 0?true:Array.isArray(e)?e.length===0:Object.keys(e).length===0}
15
-
16
- function t(...t){return t$1(n,t)}function n(e,t){if(e===t||Object.is(e,t))return true;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return false;if(e instanceof Map&&t instanceof Map)return r(e,t);if(e instanceof Set&&t instanceof Set)return i(e,t);let n=Object.keys(e);if(n.length!==Object.keys(t).length)return false;for(let r of n){if(!Object.hasOwn(t,r))return false;let{[r]:n}=e,{[r]:i}=t;if(n!==i||!Object.is(n,i))return false}return true}function r(e,t){if(e.size!==t.size)return false;for(let[n,r]of e){let e=t.get(n);if(r!==e||!Object.is(r,e))return false}return true}function i(e,t){if(e.size!==t.size)return false;for(let n of e)if(!t.has(n))return false;return true}
17
-
18
- class AbstractDeploymentElementModel {
19
- /**
20
- * Don't use in runtime, only for type inference
21
- */
22
- Aux;
23
- get style() {
24
- return memoizeProp(this, "style", () => exact({
25
- shape: this.$model.$styles.defaults.shape,
26
- color: this.$model.$styles.defaults.color,
27
- border: this.$model.$styles.defaults.border,
28
- opacity: this.$model.$styles.defaults.opacity,
29
- size: this.$model.$styles.defaults.size,
30
- padding: this.$model.$styles.defaults.padding,
31
- textSize: this.$model.$styles.defaults.text,
32
- ...this.$node.style
33
- }));
34
- }
35
- get name() {
36
- return nameFromFqn(this.id);
37
- }
38
- get shape() {
39
- return this.style.shape;
40
- }
41
- get color() {
42
- return this.style.color;
43
- }
44
- get icon() {
45
- return this.style.icon ?? null;
46
- }
47
- /**
48
- * Short description of the element.
49
- * Falls back to description if summary is not provided.
50
- */
51
- get summary() {
52
- return RichText.memoize(this, "summary", preferSummary(this.$node));
53
- }
54
- /**
55
- * Long description of the element.
56
- * Falls back to summary if description is not provided.
57
- */
58
- get description() {
59
- return RichText.memoize(this, "description", preferDescription(this.$node));
60
- }
61
- get technology() {
62
- return this.$node.technology ?? null;
63
- }
64
- get links() {
65
- return this.$node.links ?? [];
66
- }
67
- /**
68
- * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
69
- * (from closest to root)
70
- */
71
- ancestors() {
72
- return this.$model.ancestors(this);
73
- }
74
- /**
75
- * Returns the common ancestor of this element and another element.
76
- */
77
- commonAncestor(another) {
78
- const common = commonAncestor(this.id, another.id);
79
- return common ? this.$model.node(common) : null;
80
- }
81
- /**
82
- * Get all sibling (i.e. same parent)
83
- */
84
- siblings() {
85
- return this.$model.siblings(this);
86
- }
87
- /**
88
- * Check if the element is a sibling of another element
89
- */
90
- isSibling(other) {
91
- return this.parent === other.parent;
92
- }
93
- /**
94
- * Resolve siblings of the element and its ancestors
95
- * (from closest to root)
96
- */
97
- *ascendingSiblings() {
98
- yield* this.siblings();
99
- for (const ancestor of this.ancestors()) {
100
- yield* ancestor.siblings();
101
- }
102
- return;
103
- }
104
- /**
105
- * Resolve siblings of the element and its ancestors
106
- * (from root to closest)
107
- */
108
- *descendingSiblings() {
109
- for (const ancestor of [...this.ancestors()].reverse()) {
110
- yield* ancestor.siblings();
111
- }
112
- yield* this.siblings();
113
- return;
114
- }
115
- incoming(filter = "all") {
116
- return this.$model.incoming(this, filter);
117
- }
118
- outgoing(filter = "all") {
119
- return this.$model.outgoing(this, filter);
120
- }
121
- *incomers(filter = "all") {
122
- const unique2 = /* @__PURE__ */ new Set();
123
- for (const r of this.incoming(filter)) {
124
- if (unique2.has(r.source.id)) {
125
- continue;
126
- }
127
- unique2.add(r.source.id);
128
- yield r.source;
129
- }
130
- return;
131
- }
132
- *outgoers(filter = "all") {
133
- const unique2 = /* @__PURE__ */ new Set();
134
- for (const r of this.outgoing(filter)) {
135
- if (unique2.has(r.target.id)) {
136
- continue;
137
- }
138
- unique2.add(r.target.id);
139
- yield r.target;
140
- }
141
- return;
142
- }
143
- /**
144
- * Iterate over all views that include this deployment element.
145
- */
146
- *views() {
147
- for (const view of this.$model.views()) {
148
- if (view._type !== "deployment") {
149
- continue;
150
- }
151
- if (view.includesDeployment(this.id)) {
152
- yield view;
153
- }
154
- }
155
- }
156
- // type guard
157
- isDeploymentNode() {
158
- return false;
159
- }
160
- // type guard
161
- isInstance() {
162
- return false;
163
- }
164
- get allOutgoing() {
165
- return memoizeProp(this, /* @__PURE__ */ Symbol.for("allOutgoing"), () => RelationshipsAccum.from(
166
- new Set(this.outgoingModelRelationships()),
167
- new Set(this.outgoing())
168
- ));
169
- }
170
- get allIncoming() {
171
- return memoizeProp(this, /* @__PURE__ */ Symbol.for("allIncoming"), () => RelationshipsAccum.from(
172
- new Set(this.incomingModelRelationships()),
173
- new Set(this.incoming())
174
- ));
175
- }
176
- hasMetadata() {
177
- return !!this.$node.metadata && !e(this.$node.metadata);
178
- }
179
- getMetadata(field) {
180
- if (field) {
181
- return this.$node.metadata?.[field];
182
- }
183
- return this.$node.metadata ?? {};
184
- }
185
- /**
186
- * Checks if the deployment element has the given tag.
187
- */
188
- isTagged(tag) {
189
- return this.tags.includes(tag);
190
- }
191
- }
192
- class DeploymentNodeModel extends AbstractDeploymentElementModel {
193
- constructor($model, $node) {
194
- super();
195
- this.$model = $model;
196
- this.$node = $node;
197
- this.id = $node.id;
198
- this._literalId = $node.id;
199
- this.title = $node.title;
200
- this.hierarchyLevel = hierarchyLevel($node.id);
201
- }
202
- id;
203
- _literalId;
204
- title;
205
- hierarchyLevel;
206
- get parent() {
207
- return this.$model.parent(this);
208
- }
209
- get kind() {
210
- return this.$node.kind;
211
- }
212
- get tags() {
213
- return memoizeProp(this, /* @__PURE__ */ Symbol.for("tags"), () => {
214
- return n$1([
215
- ...this.$node.tags ?? [],
216
- ...this.$model.$model.specification.deployments[this.kind]?.tags ?? []
217
- ]);
218
- });
219
- }
220
- children() {
221
- return this.$model.children(this);
222
- }
223
- descendants(sort = "desc") {
224
- return this.$model.descendants(this, sort);
225
- }
226
- isDeploymentNode() {
227
- return true;
228
- }
229
- /**
230
- * Iterate over all instances nested in this deployment node.
231
- */
232
- *instances() {
233
- for (const nested of this.descendants("desc")) {
234
- if (nested.isInstance()) {
235
- yield nested;
236
- }
237
- }
238
- return;
239
- }
240
- /**
241
- * Returns deployed instance inside this deployment node
242
- * if only there are no more instances
243
- */
244
- onlyOneInstance() {
245
- const children = this.children();
246
- if (children.size !== 1) {
247
- return null;
248
- }
249
- const child = ihead(children);
250
- if (!child) {
251
- return null;
252
- }
253
- return child.isInstance() ? child : child.onlyOneInstance();
254
- }
255
- /**
256
- * Cached result of relationships from instances
257
- */
258
- _relationshipsFromInstances = null;
259
- relationshipsFromInstances() {
260
- if (this._relationshipsFromInstances) {
261
- return this._relationshipsFromInstances;
262
- }
263
- const {
264
- outgoing,
265
- incoming
266
- } = this._relationshipsFromInstances = {
267
- outgoing: /* @__PURE__ */ new Set(),
268
- incoming: /* @__PURE__ */ new Set()
269
- };
270
- for (const instance of this.instances()) {
271
- for (const r of instance.element.outgoing()) {
272
- outgoing.add(r);
273
- }
274
- for (const r of instance.element.incoming()) {
275
- incoming.add(r);
276
- }
277
- }
278
- return this._relationshipsFromInstances;
279
- }
280
- /**
281
- * We return only relationships that are not already present in nested instances
282
- */
283
- outgoingModelRelationships() {
284
- return this.relationshipsFromInstances().outgoing.values();
285
- }
286
- /**
287
- * We return only relationships that are not already present in nested instances
288
- */
289
- incomingModelRelationships() {
290
- return this.relationshipsFromInstances().incoming.values();
291
- }
292
- /**
293
- * Returns an iterator of relationships between nested instances
294
- */
295
- internalModelRelationships() {
296
- const {
297
- outgoing,
298
- incoming
299
- } = this.relationshipsFromInstances();
300
- return intersection(incoming, outgoing);
301
- }
302
- }
303
- class DeployedInstanceModel extends AbstractDeploymentElementModel {
304
- constructor($model, $instance, element) {
305
- super();
306
- this.$model = $model;
307
- this.$instance = $instance;
308
- this.element = element;
309
- this.id = $instance.id;
310
- this._literalId = $instance.id;
311
- this.title = $instance.title ?? element.title;
312
- this.hierarchyLevel = hierarchyLevel($instance.id);
313
- }
314
- id;
315
- _literalId;
316
- title;
317
- hierarchyLevel;
318
- get $node() {
319
- return this.$instance;
320
- }
321
- get parent() {
322
- return nonNullable(this.$model.parent(this), `Parent of ${this.id} not found`);
323
- }
324
- get style() {
325
- return memoizeProp(this, "style", () => exact({
326
- shape: this.$model.$styles.defaults.shape,
327
- color: this.$model.$styles.defaults.color,
328
- border: this.$model.$styles.defaults.border,
329
- opacity: this.$model.$styles.defaults.opacity,
330
- size: this.$model.$styles.defaults.size,
331
- padding: this.$model.$styles.defaults.padding,
332
- textSize: this.$model.$styles.defaults.text,
333
- ...this.element.$element.style,
334
- ...this.$instance.style
335
- }));
336
- }
337
- get tags() {
338
- return memoizeProp(this, /* @__PURE__ */ Symbol.for("tags"), () => {
339
- return n$1([
340
- ...this.$instance.tags ?? [],
341
- ...this.element.tags
342
- ]);
343
- });
344
- }
345
- get kind() {
346
- return this.element.kind;
347
- }
348
- get summary() {
349
- return RichText.memoize(
350
- this,
351
- "summary",
352
- preferSummary(this.$instance) ?? preferSummary(this.element.$element)
353
- );
354
- }
355
- get description() {
356
- return RichText.memoize(
357
- this,
358
- "description",
359
- preferDescription(this.$instance) ?? preferDescription(this.element.$element)
360
- );
361
- }
362
- get technology() {
363
- return this.$instance.technology ?? this.element.technology ?? null;
364
- }
365
- get links() {
366
- return this.$instance.links ?? this.element.links;
367
- }
368
- isInstance() {
369
- return true;
370
- }
371
- outgoingModelRelationships() {
372
- return this.element.outgoing();
373
- }
374
- incomingModelRelationships() {
375
- return this.element.incoming();
376
- }
377
- /**
378
- * Iterate over all views that include this instance.
379
- * (Some views may include the parent deployment node instead of the instance.)
380
- */
381
- *views() {
382
- for (const view of this.$model.views()) {
383
- if (view._type !== "deployment") {
384
- continue;
385
- }
386
- if (view.includesDeployment(this.id)) {
387
- yield view;
388
- continue;
389
- }
390
- if (view.includesDeployment(this.parent.id) && this.parent.onlyOneInstance()) {
391
- yield view;
392
- }
393
- }
394
- }
395
- }
396
- class NestedElementOfDeployedInstanceModel {
397
- constructor(instance, element) {
398
- this.instance = instance;
399
- this.element = element;
400
- }
401
- get id() {
402
- return this.instance.id;
403
- }
404
- get _literalId() {
405
- return this.instance.id;
406
- }
407
- get style() {
408
- return memoizeProp(this, "style ", () => ({
409
- shape: this.element.shape,
410
- color: this.element.color,
411
- ...this.element.$element.style
412
- }));
413
- }
414
- get shape() {
415
- return this.element.shape;
416
- }
417
- get color() {
418
- return this.element.color;
419
- }
420
- get title() {
421
- return this.element.title;
422
- }
423
- get summary() {
424
- return this.element.summary;
425
- }
426
- get description() {
427
- return this.element.description;
428
- }
429
- get technology() {
430
- return this.element.technology;
431
- }
432
- isDeploymentNode() {
433
- return false;
434
- }
435
- isInstance() {
436
- return false;
437
- }
438
- }
439
- class DeploymentRelationModel {
440
- constructor($model, $relationship) {
441
- this.$model = $model;
442
- this.$relationship = $relationship;
443
- this.source = $model.deploymentRef($relationship.source);
444
- this.target = $model.deploymentRef($relationship.target);
445
- const parent = commonAncestor(this.source.id, this.target.id);
446
- this.boundary = parent ? this.$model.node(parent) : null;
447
- }
448
- boundary;
449
- source;
450
- target;
451
- get id() {
452
- return this.$relationship.id;
453
- }
454
- get expression() {
455
- return `${this.source.id} -> ${this.target.id}`;
456
- }
457
- get title() {
458
- if (!e$1(this.$relationship.title)) {
459
- return null;
460
- }
461
- return this.$relationship.title;
462
- }
463
- get technology() {
464
- return this.$relationship.technology ?? null;
465
- }
466
- /**
467
- * Returns true if the relationship has a summary and a description
468
- * (if one is missing - it falls back to another)
469
- */
470
- get hasSummary() {
471
- return !!this.$relationship.summary && !!this.$relationship.description && !t(this.$relationship.summary, this.$relationship.description);
472
- }
473
- /**
474
- * Short description of the relationship.
475
- * Falls back to description if summary is not provided.
476
- */
477
- get summary() {
478
- return RichText.memoize(this, "summary", preferSummary(this.$relationship));
479
- }
480
- /**
481
- * Long description of the relationship.
482
- * Falls back to summary if description is not provided.
483
- */
484
- get description() {
485
- return RichText.memoize(this, "description", preferDescription(this.$relationship));
486
- }
487
- get tags() {
488
- return this.$relationship.tags ?? [];
489
- }
490
- get kind() {
491
- return this.$relationship.kind ?? null;
492
- }
493
- get navigateTo() {
494
- return this.$relationship.navigateTo ? this.$model.$model.view(this.$relationship.navigateTo) : null;
495
- }
496
- get links() {
497
- return this.$relationship.links ?? [];
498
- }
499
- get color() {
500
- return this.$relationship.color ?? this.$model.$styles.defaults.relationship.color;
501
- }
502
- get line() {
503
- return this.$relationship.line ?? this.$model.$styles.defaults.relationship.line;
504
- }
505
- get head() {
506
- return this.$relationship.head ?? this.$model.$styles.defaults.relationship.arrow;
507
- }
508
- get tail() {
509
- return this.$relationship.tail;
510
- }
511
- *views() {
512
- for (const view of this.$model.views()) {
513
- if (view.includesRelation(this.id)) {
514
- yield view;
515
- }
516
- }
517
- return;
518
- }
519
- isDeploymentRelation() {
520
- return true;
521
- }
522
- isModelRelation() {
523
- return false;
524
- }
525
- hasMetadata() {
526
- return !!this.$relationship.metadata && !e(this.$relationship.metadata);
527
- }
528
- getMetadata(field) {
529
- if (field) {
530
- return this.$relationship.metadata?.[field];
531
- }
532
- return this.$relationship.metadata ?? {};
533
- }
534
- /**
535
- * Checks if the relationship has the given tag.
536
- */
537
- isTagged(tag) {
538
- return this.tags.includes(tag);
539
- }
540
- }
541
- class RelationshipsAccum {
542
- /**
543
- * @param model relationships from logical model
544
- * @param deployment relationships from deployment model
545
- */
546
- constructor(model = /* @__PURE__ */ new Set(), deployment = /* @__PURE__ */ new Set()) {
547
- this.model = model;
548
- this.deployment = deployment;
549
- }
550
- static empty() {
551
- return new RelationshipsAccum();
552
- }
553
- static from(model, deployment) {
554
- return new RelationshipsAccum(
555
- new Set(model),
556
- new Set(deployment)
557
- );
558
- }
559
- get isEmpty() {
560
- return this.model.size === 0 && this.deployment.size === 0;
561
- }
562
- get nonEmpty() {
563
- return this.model.size > 0 || this.deployment.size > 0;
564
- }
565
- get size() {
566
- return this.model.size + this.deployment.size;
567
- }
568
- /**
569
- * Returns new Accum containing all the elements which are both in this and otherAccum
570
- */
571
- intersect(otherAccum) {
572
- return RelationshipsAccum.from(
573
- intersection(this.model, otherAccum.model),
574
- intersection(this.deployment, otherAccum.deployment)
575
- );
576
- }
577
- /**
578
- * Returns new Accum containing all the elements which are both in this and otherAccum
579
- */
580
- difference(otherAccum) {
581
- return RelationshipsAccum.from(
582
- difference(this.model, otherAccum.model),
583
- difference(this.deployment, otherAccum.deployment)
584
- );
585
- }
586
- /**
587
- * Returns new Accum containing all the elements from both
588
- */
589
- union(otherAccum) {
590
- return RelationshipsAccum.from(
591
- union(this.model, otherAccum.model),
592
- union(this.deployment, otherAccum.deployment)
593
- );
594
- }
595
- }
596
-
597
- class DeploymentConnectionModel {
598
- constructor(source, target, relations) {
599
- this.source = source;
600
- this.target = target;
601
- this.relations = relations;
602
- this.id = stringHash(`deployment:${source.id}:${target.id}`);
603
- }
604
- id;
605
- /**
606
- * Human readable expression of the connection
607
- * Mostly used for testing and debugging
608
- */
609
- get expression() {
610
- return `${this.source.id} -> ${this.target.id}`;
611
- }
612
- _boundary;
613
- /**
614
- * Common ancestor of the source and target elements.
615
- * Represents the boundary of the connection.
616
- */
617
- get boundary() {
618
- this._boundary ??= this.source.commonAncestor(this.target);
619
- return this._boundary;
620
- }
621
- nonEmpty() {
622
- return this.relations.nonEmpty;
623
- }
624
- [customInspectSymbol](_depth, _inspectOptions, _inspect) {
625
- const asString = this.toString();
626
- Object.defineProperty(asString, "constructor", {
627
- value: DeploymentConnectionModel,
628
- enumerable: false
629
- });
630
- return asString;
631
- }
632
- toString() {
633
- const model = [...this.relations.model].map((c) => " " + c.expression);
634
- if (model.length) {
635
- model.unshift(" model:");
636
- } else {
637
- model.unshift(" model: []");
638
- }
639
- const deployment = [...this.relations.deployment].map((c) => " " + c.expression);
640
- if (deployment.length) {
641
- deployment.unshift(" deployment:");
642
- } else {
643
- deployment.unshift(" deployment: []");
644
- }
645
- return [
646
- this.expression,
647
- ...model,
648
- ...deployment
649
- ].join("\n");
650
- }
651
- /**
652
- * Check if connection contains deployment relation,
653
- * that is directly connected to source or target.
654
- */
655
- hasDirectDeploymentRelation() {
656
- for (const relation of this.relations.deployment) {
657
- if (relation.source.id === this.source.id || relation.target.id === this.target.id) {
658
- return true;
659
- }
660
- }
661
- return false;
662
- }
663
- *values() {
664
- yield* this.relations.model;
665
- yield* this.relations.deployment;
666
- }
667
- mergeWith(other) {
668
- if (Array.isArray(other)) {
669
- return other.reduce((acc, o) => acc.mergeWith(o), this);
670
- }
671
- invariant(this.source.id === other.source.id, "Cannot merge connections with different sources");
672
- invariant(this.target.id === other.target.id, "Cannot merge connections with different targets");
673
- return new DeploymentConnectionModel(
674
- this.source,
675
- this.target,
676
- this.relations.union(other.relations)
677
- );
678
- }
679
- difference(other) {
680
- return new DeploymentConnectionModel(
681
- this.source,
682
- this.target,
683
- this.relations.difference(other.relations)
684
- );
685
- }
686
- intersect(other) {
687
- return new DeploymentConnectionModel(
688
- this.source,
689
- this.target,
690
- this.relations.intersect(other.relations)
691
- );
692
- }
693
- equals(other) {
694
- invariant(other instanceof DeploymentConnectionModel, "Other should ne DeploymentConnectionModel");
695
- 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);
696
- }
697
- /**
698
- * Creates a clone of the current `DeploymentConnectionModel` instance with optional overrides.
699
- * if `null` is provided in overrides, the corresponding relation set will be empty.
700
- */
701
- update(overrides) {
702
- if (overrides) {
703
- overrides = {
704
- model: this.relations.model,
705
- deployment: this.relations.deployment,
706
- ...overrides
707
- };
708
- }
709
- return new DeploymentConnectionModel(
710
- this.source,
711
- this.target,
712
- overrides ? new RelationshipsAccum(
713
- overrides.model ?? /* @__PURE__ */ new Set(),
714
- overrides.deployment ?? /* @__PURE__ */ new Set()
715
- ) : this.relations
716
- );
717
- }
718
- }
719
-
720
- function findConnection(source, target, direction = "directed") {
721
- if (source === target) {
722
- return [];
723
- }
724
- if (isSameHierarchy(source, target)) {
725
- return [];
726
- }
727
- const directedIntersection = source.allOutgoing.intersect(target.allIncoming);
728
- const directed = directedIntersection.nonEmpty ? [
729
- new DeploymentConnectionModel(
730
- source,
731
- target,
732
- directedIntersection
733
- )
734
- ] : [];
735
- if (direction === "directed") {
736
- return directed;
737
- }
738
- return [
739
- ...directed,
740
- ...findConnection(target, source, "directed")
741
- ];
742
- }
743
- function findConnectionsBetween(element, others, direction = "both") {
744
- if (element.allIncoming.isEmpty && element.allOutgoing.isEmpty) {
745
- return [];
746
- }
747
- const outgoing = [];
748
- const incoming = [];
749
- for (const _other of others) {
750
- if (element === _other) {
751
- continue;
752
- }
753
- for (const found of findConnection(element, _other, direction)) {
754
- if (found.source === element) {
755
- outgoing.push(found);
756
- } else {
757
- incoming.push(found);
758
- }
759
- }
760
- }
761
- return [
762
- ...outgoing,
763
- ...incoming
764
- ];
765
- }
766
- function findConnectionsWithin(elements) {
767
- return [...elements].reduce((acc, el, index, array) => {
768
- if (index === array.length - 1) {
769
- return acc;
770
- }
771
- acc.push(
772
- ...findConnectionsBetween(el, array.slice(index + 1), "both")
773
- );
774
- return acc;
775
- }, []);
776
- }
777
-
778
- const deploymentConnection = {
779
- __proto__: null,
780
- findConnection: findConnection,
781
- findConnectionsBetween: findConnectionsBetween,
782
- findConnectionsWithin: findConnectionsWithin
783
- };
784
-
785
- export { DeploymentConnectionModel as D, NestedElementOfDeployedInstanceModel as N, RelationshipsAccum as R, DeploymentNodeModel as a, DeployedInstanceModel as b, DeploymentRelationModel as c, deploymentConnection as d, e, findConnection as f, findConnectionsBetween as g, findConnectionsWithin as h, t };