@likec4/core 1.47.0 → 1.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/_chunks/Builder.view-element.mjs +3284 -0
- package/dist/_chunks/LikeC4Model.d.mts +1287 -0
- package/dist/_chunks/LikeC4Styles.mjs +691 -0
- package/dist/_chunks/RichText.d.mts +84 -0
- package/dist/_chunks/RichText.mjs +148 -0
- package/dist/_chunks/_aux.d.mts +289 -0
- package/dist/_chunks/_aux.mjs +18 -0
- package/dist/_chunks/_types.d.mts +781 -0
- package/dist/_chunks/_types2.d.mts +38 -0
- package/dist/_chunks/assignTagColors.mjs +24 -0
- package/dist/_chunks/calcDriftsFromSnapshot.mjs +379 -0
- package/dist/_chunks/connection.mjs +0 -0
- package/dist/_chunks/const.d.mts +43 -0
- package/dist/_chunks/const.mjs +33 -0
- package/dist/_chunks/expression-model.d.mts +192 -0
- package/dist/_chunks/expression-model.mjs +103 -0
- package/dist/_chunks/expression.d.mts +347 -0
- package/dist/_chunks/expression.mjs +107 -0
- package/dist/_chunks/find.d.mts +82 -0
- package/dist/_chunks/find.mjs +646 -0
- package/dist/_chunks/find2.d.mts +78 -0
- package/dist/_chunks/find2.mjs +287 -0
- package/dist/_chunks/fqnRef.d.mts +58 -0
- package/dist/_chunks/fqnRef.mjs +41 -0
- package/dist/_chunks/geometry.mjs +335 -0
- package/dist/_chunks/index.d.mts +169 -0
- package/dist/_chunks/index2.d.mts +937 -0
- package/dist/_chunks/index3.d.mts +146 -0
- package/dist/_chunks/index4.d.mts +62 -0
- package/dist/_chunks/index5.d.mts +42 -0
- package/dist/_chunks/index6.d.mts +43 -0
- package/dist/{shared/core.OtRNdMxy.d.mts → _chunks/index7.d.mts} +113 -197
- package/dist/_chunks/index8.d.mts +144 -0
- package/dist/_chunks/invariant.mjs +18 -0
- package/dist/_chunks/iterable.mjs +146 -0
- package/dist/_chunks/libs/@mantine/colors-generator.mjs +3416 -0
- package/dist/_chunks/libs/@ungap/structured-clone.mjs +213 -0
- package/dist/_chunks/libs/bail.mjs +14 -0
- package/dist/_chunks/libs/ccount.mjs +25 -0
- package/dist/_chunks/libs/character-entities-html4.mjs +263 -0
- package/dist/_chunks/libs/character-entities-legacy.mjs +117 -0
- package/dist/_chunks/libs/character-entities.mjs +2136 -0
- package/dist/_chunks/libs/comma-separated-tokens.mjs +18 -0
- package/dist/_chunks/libs/decode-named-character-reference.mjs +21 -0
- package/dist/_chunks/libs/defu.mjs +42 -0
- package/dist/_chunks/libs/devlop.mjs +5 -0
- package/dist/_chunks/libs/escape-string-regexp.mjs +8 -0
- package/dist/_chunks/libs/extend.mjs +77 -0
- package/dist/_chunks/libs/graphology-dag.mjs +703 -0
- package/dist/_chunks/libs/graphology-types.d.mts +601 -0
- package/dist/_chunks/libs/graphology.d.mts +6 -0
- package/dist/_chunks/libs/graphology.mjs +4565 -0
- package/dist/_chunks/libs/hast-util-sanitize.mjs +863 -0
- package/dist/_chunks/libs/hast-util-to-html.mjs +2696 -0
- package/dist/_chunks/libs/is-plain-obj.mjs +9 -0
- package/dist/_chunks/libs/longest-streak.mjs +30 -0
- package/dist/_chunks/libs/markdown-table.mjs +290 -0
- package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +653 -0
- package/dist/_chunks/libs/mdast-util-from-markdown.mjs +8522 -0
- package/dist/_chunks/libs/mdast-util-gfm.mjs +2393 -0
- package/dist/_chunks/libs/mdast-util-to-hast.mjs +1803 -0
- package/dist/_chunks/libs/micromark-extension-gfm.mjs +2243 -0
- package/dist/_chunks/libs/mnemonist.d.mts +254 -0
- package/dist/_chunks/libs/mnemonist.mjs +1978 -0
- package/dist/_chunks/libs/natural-compare-lite.mjs +42 -0
- package/dist/_chunks/libs/rehype-sanitize.mjs +29 -0
- package/dist/_chunks/libs/rehype-stringify.mjs +34 -0
- package/dist/_chunks/libs/remark-gfm.mjs +36 -0
- package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +100 -0
- package/dist/_chunks/libs/remark-parse.mjs +39 -0
- package/dist/_chunks/libs/remark-rehype.mjs +171 -0
- package/dist/_chunks/libs/remeda.mjs +702 -0
- package/dist/_chunks/libs/trough.mjs +158 -0
- package/dist/_chunks/libs/unified.mjs +2212 -0
- package/dist/_chunks/mnemonist.d.mts +1 -0
- package/dist/_chunks/mnemonist.mjs +0 -0
- package/dist/_chunks/model.mjs +1898 -0
- package/dist/_chunks/model2.mjs +0 -0
- package/dist/_chunks/relationships-view.mjs +132 -0
- package/dist/_chunks/rolldown-runtime.mjs +42 -0
- package/dist/{shared/core.C_3y3eqV.d.mts → _chunks/scalar.d.mts} +13 -43
- package/dist/_chunks/scalar.mjs +84 -0
- package/dist/_chunks/utils.mjs +483 -0
- package/dist/builder/index.d.mts +11 -775
- package/dist/builder/index.mjs +631 -1022
- package/dist/compute-view/index.d.mts +85 -56
- package/dist/compute-view/index.mjs +247 -214
- package/dist/compute-view/relationships-view/index.d.mts +16 -51
- package/dist/compute-view/relationships-view/index.mjs +6 -184
- package/dist/geometry/index.d.mts +2 -109
- package/dist/geometry/index.mjs +2 -327
- package/dist/index.d.mts +18 -20
- package/dist/index.mjs +27 -18
- package/dist/model/connection/deployment/index.d.mts +12 -15
- package/dist/model/connection/deployment/index.mjs +9 -2
- package/dist/model/connection/index.d.mts +14 -75
- package/dist/model/connection/index.mjs +10 -3
- package/dist/model/connection/model/index.d.mts +12 -15
- package/dist/model/connection/model/index.mjs +8 -2
- package/dist/model/index.d.mts +15 -57
- package/dist/model/index.mjs +11 -4
- package/dist/styles/index.d.mts +9 -117
- package/dist/styles/index.mjs +26 -59
- package/dist/types/RichText.d.mts +3 -0
- package/dist/types/RichText.mjs +7 -0
- package/dist/types/_aux.d.mts +3 -4
- package/dist/types/_aux.mjs +2 -7
- package/dist/types/expression-model.d.mts +6 -190
- package/dist/types/expression-model.mjs +6 -108
- package/dist/types/expression.d.mts +5 -6
- package/dist/types/expression.mjs +6 -112
- package/dist/types/fqnRef.d.mts +4 -60
- package/dist/types/fqnRef.mjs +6 -44
- package/dist/types/index.d.mts +9 -47
- package/dist/types/index.mjs +14 -16
- package/dist/types/scalar.d.mts +2 -2
- package/dist/types/scalar.mjs +7 -4
- package/dist/utils/graphology/index.d.mts +2 -1864
- package/dist/utils/graphology/index.mjs +3 -1
- package/dist/utils/index.d.mts +11 -124
- package/dist/utils/index.mjs +16 -43
- package/dist/utils/iterable/index.d.mts +9 -132
- package/dist/utils/iterable/index.mjs +2 -61
- package/dist/utils/mnemonist.d.mts +2 -0
- package/dist/utils/mnemonist.mjs +12 -0
- package/package.json +17 -22
- package/compute-view/relationships/package.json +0 -4
- package/dist/shared/core.3ZhnKAlZ.mjs +0 -106
- package/dist/shared/core.78IWAHAE.mjs +0 -332
- package/dist/shared/core.B85MJLTf.mjs +0 -5
- package/dist/shared/core.BFd1lU9R.mjs +0 -29
- package/dist/shared/core.BKlholso.mjs +0 -3
- package/dist/shared/core.BNN-3vPH.mjs +0 -1255
- package/dist/shared/core.BPGOjone.d.mts +0 -46
- package/dist/shared/core.BP_QHEXs.mjs +0 -785
- package/dist/shared/core.BbE4y-yl.mjs +0 -177
- package/dist/shared/core.Bdy3hhTc.mjs +0 -28382
- package/dist/shared/core.BfCKSW-g.d.mts +0 -1266
- package/dist/shared/core.BhNcrwzK.mjs +0 -7
- package/dist/shared/core.BkVA6gjl.mjs +0 -5
- package/dist/shared/core.BoYfZOBm.mjs +0 -3
- package/dist/shared/core.BsSXS-_R.mjs +0 -7
- package/dist/shared/core.C3JowhaZ.mjs +0 -32
- package/dist/shared/core.C4x8aaWa.mjs +0 -27
- package/dist/shared/core.CAgYpDtM.d.mts +0 -98
- package/dist/shared/core.CHf8VEa3.mjs +0 -1206
- package/dist/shared/core.CLSZtnFh.mjs +0 -69
- package/dist/shared/core.CbT8JVYL.mjs +0 -5
- package/dist/shared/core.CdNCAwq7.mjs +0 -176
- package/dist/shared/core.CmGY9blO.mjs +0 -6717
- package/dist/shared/core.CmPXpJ8l.mjs +0 -21
- package/dist/shared/core.Coi_LOUZ.mjs +0 -7
- package/dist/shared/core.CqAJJpK_.mjs +0 -3
- package/dist/shared/core.CywrQs86.d.mts +0 -31
- package/dist/shared/core.D00YbOhQ.d.mts +0 -300
- package/dist/shared/core.D0WZutNd.mjs +0 -94
- package/dist/shared/core.D4npX2q8.mjs +0 -18
- package/dist/shared/core.DB0Ue5Wx.d.mts +0 -70
- package/dist/shared/core.DC5IAaDT.d.mts +0 -334
- package/dist/shared/core.DE9qzhn8.d.mts +0 -83
- package/dist/shared/core.DGcIbsj4.mjs +0 -3946
- package/dist/shared/core.DH7TXqXf.mjs +0 -136
- package/dist/shared/core.DKhRkHRN.d.mts +0 -41
- package/dist/shared/core.DRJma0Ol.mjs +0 -22
- package/dist/shared/core.DU5SRqNF.mjs +0 -2209
- package/dist/shared/core.DXhDWKFZ.d.mts +0 -3
- package/dist/shared/core.DbfO90vF.mjs +0 -434
- package/dist/shared/core.DcS-0zys.mjs +0 -10
- package/dist/shared/core.Dh119QSP.mjs +0 -4995
- package/dist/shared/core.DjcWextK.mjs +0 -1371
- package/dist/shared/core.Dojz4bvg.d.mts +0 -504
- package/dist/shared/core.FZ305VYd.mjs +0 -21
- package/dist/shared/core.RfnaEmgA.mjs +0 -7
- package/dist/shared/core.btEq3i3f.mjs +0 -300
- package/dist/shared/core.oSV6SRfk.mjs +0 -13
- package/dist/shared/core.om36dXXW.mjs +0 -41
- package/dist/shared/core.osFs8tU7.d.mts +0 -466
- package/dist/shared/core.q10OP9oJ.mjs +0 -5
- package/dist/shared/core.tpvDGvdC.d.mts +0 -87
- package/dist/shared/core.uFk_o9X6.mjs +0 -13
|
@@ -0,0 +1,646 @@
|
|
|
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 };
|