@likec4/core 1.32.2 → 1.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builder/index.d.mts +6 -4
- package/dist/builder/index.mjs +45 -13
- package/dist/compute-view/index.d.mts +6 -4
- package/dist/compute-view/index.mjs +33 -10
- package/dist/compute-view/relationships-view/index.d.mts +6 -4
- package/dist/compute-view/relationships-view/index.mjs +6 -3
- package/dist/index.d.mts +9 -138
- package/dist/index.mjs +31 -3712
- package/dist/model/connection/deployment/index.d.mts +10 -0
- package/dist/model/connection/deployment/index.mjs +18 -0
- package/dist/model/connection/index.d.mts +70 -0
- package/dist/model/connection/index.mjs +23 -0
- package/dist/model/connection/model/index.d.mts +10 -0
- package/dist/model/connection/model/index.mjs +11 -0
- package/dist/model/index.d.mts +14 -256
- package/dist/model/index.mjs +27 -5
- package/dist/shared/{core.Bdz6fBF1.d.mts → core.1pNeDdRk.d.mts} +92 -81
- package/dist/shared/{core.BuO4ncfY.d.mts → core.668kXpZq.d.mts} +42 -52
- package/dist/shared/core.8KM0D6va.mjs +33 -0
- package/dist/shared/core.B0oEIXqd.mjs +47 -0
- package/dist/shared/core.BH9nN-_I.mjs +22 -0
- package/dist/shared/core.BMCb0wJI.mjs +177 -0
- package/dist/shared/core.BTnf14gD.mjs +331 -0
- package/dist/shared/core.BgvIuGGU.mjs +3 -0
- package/dist/shared/core.BoyJPEen.mjs +21 -0
- package/dist/shared/{core.CUYDgv2-.mjs → core.Br7Fab9l.mjs} +12 -15
- package/dist/shared/{core.BrCnZFTn.mjs → core.Btl47GOn.mjs} +3 -3
- package/dist/shared/core.ByrmCl9I.mjs +5 -0
- package/dist/shared/core.C80Z37Eu.mjs +29 -0
- package/dist/shared/{core.Pf5I9o0e.d.mts → core.CF82MWyh.d.mts} +1 -1
- package/dist/shared/{core.rmvsy0n3.mjs → core.C_C-3c1S.mjs} +5 -198
- package/dist/shared/core.CeQbbp7K.d.mts +41 -0
- package/dist/shared/{core.DoK86JEe.mjs → core.CpwrZi3D.mjs} +2 -73
- package/dist/shared/{core.CpXlRyE5.mjs → core.CtKXPqN_.mjs} +5 -36
- package/dist/shared/core.CxGKeL-L.mjs +144 -0
- package/dist/shared/core.CzdwsPmY.d.mts +69 -0
- package/dist/shared/{core.Cy9smucx.mjs → core.D4npX2q8.mjs} +1 -3
- package/dist/shared/core.D56nCp7e.mjs +168 -0
- package/dist/shared/core.D5qVzkws.mjs +724 -0
- package/dist/shared/core.DDAPzd3T.d.mts +87 -0
- package/dist/shared/{core.CBpKAlhj.mjs → core.DDynPqbh.mjs} +96 -56
- package/dist/shared/{core.Bk7wEZFG.mjs → core.DXRAwwDB.mjs} +3 -2
- package/dist/shared/core.DcS-0zys.mjs +10 -0
- package/dist/shared/{core.CBxTtXMi.d.mts → core.De___iBS.d.mts} +3 -2
- package/dist/shared/core.DsMrjY2q.mjs +34 -0
- package/dist/shared/core.DuSLYTG6.d.mts +57 -0
- package/dist/shared/core.Dy-F3xRP.d.mts +83 -0
- package/dist/shared/{core.DaAyklhe.d.mts → core.OLInHaJx.d.mts} +30 -22
- package/dist/shared/core.XptQjhMA.mjs +1295 -0
- package/dist/shared/{core.cbA9VZ02.mjs → core.hoq9W4rW.mjs} +28 -1073
- package/dist/shared/core.zLlww-07.mjs +3 -0
- package/dist/theme/index.d.mts +134 -0
- package/dist/theme/index.mjs +3709 -0
- package/dist/types/aux.d.mts +3 -2
- package/dist/types/index.d.mts +9 -5
- package/dist/types/index.mjs +17 -146
- package/dist/utils/index.d.mts +15 -100
- package/dist/utils/index.mjs +25 -1315
- package/dist/utils/iterable/index.d.mts +100 -0
- package/dist/utils/iterable/index.mjs +24 -0
- package/package.json +23 -7
- package/src/builder/Builder.ts +13 -4
- package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +0 -13
- package/src/builder/__snapshots__/Builder-style2.compute-model.json5 +2 -6
- package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +0 -7
- package/src/compute-view/deployment-view/__test__/fixture.ts +15 -5
- package/src/compute-view/deployment-view/utils.ts +13 -13
- package/src/compute-view/dynamic-view/compute.ts +2 -1
- package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +2 -2
- package/src/compute-view/relationships-view/layout.ts +1 -1
- package/src/compute-view/utils/applyCustomElementProperties.ts +8 -0
- package/src/compute-view/utils/applyCustomRelationProperties.ts +2 -0
- package/src/compute-view/utils/buildComputedNodes.ts +4 -3
- package/src/compute-view/utils/merge-props-from-relationships.ts +6 -5
- package/src/compute-view/utils/view-hash.ts +24 -3
- package/src/model/DeploymentElementModel.ts +20 -16
- package/src/model/ElementModel.ts +9 -3
- package/src/model/RelationModel.ts +19 -16
- package/src/model/index.ts +2 -0
- package/src/model/types.ts +1 -0
- package/src/model/view/EdgeModel.ts +4 -3
- package/src/model/view/LikeC4ViewModel.ts +5 -0
- package/src/model/view/NodeModel.ts +4 -2
- package/src/theme/index.ts +12 -5
- package/src/types/RichText.ts +200 -0
- package/src/types/index.ts +2 -0
- package/src/types/model-deployment.ts +4 -3
- package/src/types/model-logical.ts +3 -3
- package/src/types/scalar.ts +47 -2
- package/src/types/view-common.ts +1 -1
- package/src/types/view-computed.ts +2 -4
- package/src/types/view-layouted.ts +9 -0
- package/src/utils/index.ts +4 -9
- package/src/utils/markdown/index.ts +2 -0
- package/src/utils/markdown/to-html.ts +32 -0
- package/src/utils/markdown/to-text.ts +14 -0
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { C, f as s$1, u as hierarchyLevel, a as isAncestor, k as commonAncestor, v as sortNaturalByFqn, s as sortParentsFirst, D as DefaultMap, p as parentFqn, l as ancestorsFqn, b as ifilter, m as compareNatural, i as isDescendantOf, w as isString, d as isSameHierarchy } from './core.rmvsy0n3.mjs';
|
|
2
|
-
import { E as splitGlobalFqn, D as DefaultElementShape, a as DefaultThemeColor, l as DefaultShapeSize, c as n$1, g as DefaultLineStyle, F as FqnRef, k as isDeploymentNode, h as DefaultRelationshipColor, I as extractStep, d as isStepEdgeId, e as isGroupElementKind, _ as _type, b as _stage, j as isOnStage, w as whereOperatorAsPredicate, C as isGlobalFqn, B as GlobalFqn, o as o$2 } from './core.CUYDgv2-.mjs';
|
|
3
|
-
import { f as memoizeProp, e as ihead, a as intersection, d as difference, u as union, g as getOrCreate, c as ifind, m as m$2, k as stringHash, j as equals, b as isome } from './core.DoK86JEe.mjs';
|
|
4
1
|
import { u as u$1 } from './core.DbRvwARP.mjs';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { p } from './core.BTnf14gD.mjs';
|
|
3
|
+
import { m as m$2 } from './core.ByrmCl9I.mjs';
|
|
4
|
+
import { g as hierarchyLevel, i as isAncestor, d as commonAncestor, l as sortNaturalByFqn, m as sortParentsFirst, p as parentFqn, b as ancestorsFqn, C, c as compareNatural } from './core.C_C-3c1S.mjs';
|
|
5
|
+
import { g as getOrCreate } from './core.DcS-0zys.mjs';
|
|
6
|
+
import { i, n as n$2, e as DeploymentNodeModel, c as DeployedInstanceModel, N as NestedElementOfDeployedInstanceModel, g as DeploymentRelationModel } from './core.D5qVzkws.mjs';
|
|
7
|
+
import { D as DefaultMap } from './core.BMCb0wJI.mjs';
|
|
8
|
+
import { a as nonNullable, i as invariant } from './core.D4npX2q8.mjs';
|
|
9
|
+
import { s as splitGlobalFqn, F as FqnRef, b as isDeploymentNode, r as extractStep, q as isStepEdgeId, m as isGroupElementKind, a as _type, _ as _stage, i as isOnStage, w as whereOperatorAsPredicate, o as isGlobalFqn, n as GlobalFqn } from './core.Br7Fab9l.mjs';
|
|
10
|
+
import { m as memoizeProp } from './core.B0oEIXqd.mjs';
|
|
11
|
+
import { i as ifilter } from './core.BH9nN-_I.mjs';
|
|
12
|
+
import { a as DefaultElementShape, D as DefaultThemeColor, R as RichText, b as DefaultShapeSize, n as n$1, g as DefaultRelationshipColor, e as DefaultLineStyle } from './core.D56nCp7e.mjs';
|
|
13
|
+
import { a as ihead, i as ifind } from './core.DsMrjY2q.mjs';
|
|
10
14
|
|
|
11
15
|
function r(...t){return u$1(Object.values,t)}
|
|
12
16
|
|
|
13
17
|
var T={asc:(r,n)=>r>n,desc:(r,n)=>r<n};function s(r,n){let[e,...o]=n;if(!m$1(e)){let t=u(...o);return r(e,t)}let a=u(e,...o);return t=>r(t,a)}function u(r,n,...e){let o=typeof r=="function"?r:r[0],a=typeof r=="function"?"asc":r[1],{[a]:t}=T,i=n===void 0?void 0:u(n,...e);return (y,c)=>{let p=o(y),l=o(c);return t(p,l)?1:t(l,p)?-1:i?.(y,c)??0}}function m$1(r){if(d(r))return true;if(typeof r!="object"||!Array.isArray(r))return false;let[n,e,...o]=r;return d(n)&&typeof e=="string"&&e in T&&o.length===0}var d=r=>typeof r=="function"&&r.length===1;
|
|
14
18
|
|
|
15
|
-
function m(...r){return u$1(o
|
|
19
|
+
function m(...r){return u$1(o,r)}function o(r,t){let e=[...r];return e.sort(t),e}
|
|
16
20
|
|
|
17
21
|
function a(...r){return s(n,r)}var n=(r,t)=>[...r].sort(t);
|
|
18
22
|
|
|
19
|
-
function p(...e){return u$1(t$2,e)}var t$2=(e,o)=>e[o];
|
|
20
|
-
|
|
21
|
-
function t$1(...n){return u$1(o,n)}var o=n=>n.length===1?n[0]:void 0;
|
|
22
|
-
|
|
23
23
|
function t(...r){return u$1(Object.entries,r)}
|
|
24
24
|
|
|
25
25
|
class ElementModel {
|
|
@@ -75,7 +75,7 @@ class ElementModel {
|
|
|
75
75
|
return this.$element.title;
|
|
76
76
|
}
|
|
77
77
|
get description() {
|
|
78
|
-
return this.$element.description
|
|
78
|
+
return RichText.memoize(this, this.$element.description);
|
|
79
79
|
}
|
|
80
80
|
get technology() {
|
|
81
81
|
return this.$element.technology ?? null;
|
|
@@ -228,6 +228,9 @@ class ElementModel {
|
|
|
228
228
|
deployments() {
|
|
229
229
|
return this.$model.deployment.instancesOf(this);
|
|
230
230
|
}
|
|
231
|
+
hasMetadata() {
|
|
232
|
+
return !!this.$element.metadata && !n$2(this.$element.metadata);
|
|
233
|
+
}
|
|
231
234
|
getMetadata(field) {
|
|
232
235
|
if (field) {
|
|
233
236
|
return this.$element.metadata?.[field];
|
|
@@ -242,525 +245,6 @@ class ElementModel {
|
|
|
242
245
|
}
|
|
243
246
|
}
|
|
244
247
|
|
|
245
|
-
class AbstractDeploymentElementModel {
|
|
246
|
-
get style() {
|
|
247
|
-
return {
|
|
248
|
-
shape: DefaultElementShape,
|
|
249
|
-
color: DefaultThemeColor,
|
|
250
|
-
size: DefaultShapeSize,
|
|
251
|
-
...this.$node.style
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
get shape() {
|
|
255
|
-
return this.$node.style?.shape ?? DefaultElementShape;
|
|
256
|
-
}
|
|
257
|
-
get color() {
|
|
258
|
-
return this.$node.style?.color ?? DefaultThemeColor;
|
|
259
|
-
}
|
|
260
|
-
get description() {
|
|
261
|
-
return this.$node.description ?? null;
|
|
262
|
-
}
|
|
263
|
-
get technology() {
|
|
264
|
-
return this.$node.technology ?? null;
|
|
265
|
-
}
|
|
266
|
-
get links() {
|
|
267
|
-
return this.$node.links ?? [];
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Get all ancestor elements (i.e. parent, parent’s parent, etc.)
|
|
271
|
-
* (from closest to root)
|
|
272
|
-
*/
|
|
273
|
-
ancestors() {
|
|
274
|
-
return this.$model.ancestors(this);
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Returns the common ancestor of this element and another element.
|
|
278
|
-
*/
|
|
279
|
-
commonAncestor(another) {
|
|
280
|
-
const common = commonAncestor(this.id, another.id);
|
|
281
|
-
return common ? this.$model.node(common) : null;
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Get all sibling (i.e. same parent)
|
|
285
|
-
*/
|
|
286
|
-
siblings() {
|
|
287
|
-
return this.$model.siblings(this);
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Check if the element is a sibling of another element
|
|
291
|
-
*/
|
|
292
|
-
isSibling(other) {
|
|
293
|
-
return this.parent === other.parent;
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Resolve siblings of the element and its ancestors
|
|
297
|
-
* (from closest to root)
|
|
298
|
-
*/
|
|
299
|
-
*ascendingSiblings() {
|
|
300
|
-
yield* this.siblings();
|
|
301
|
-
for (const ancestor of this.ancestors()) {
|
|
302
|
-
yield* ancestor.siblings();
|
|
303
|
-
}
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Resolve siblings of the element and its ancestors
|
|
308
|
-
* (from root to closest)
|
|
309
|
-
*/
|
|
310
|
-
*descendingSiblings() {
|
|
311
|
-
for (const ancestor of [...this.ancestors()].reverse()) {
|
|
312
|
-
yield* ancestor.siblings();
|
|
313
|
-
}
|
|
314
|
-
yield* this.siblings();
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
incoming(filter = "all") {
|
|
318
|
-
return this.$model.incoming(this, filter);
|
|
319
|
-
}
|
|
320
|
-
outgoing(filter = "all") {
|
|
321
|
-
return this.$model.outgoing(this, filter);
|
|
322
|
-
}
|
|
323
|
-
*incomers(filter = "all") {
|
|
324
|
-
const unique2 = /* @__PURE__ */ new Set();
|
|
325
|
-
for (const r of this.incoming(filter)) {
|
|
326
|
-
if (unique2.has(r.source.id)) {
|
|
327
|
-
continue;
|
|
328
|
-
}
|
|
329
|
-
unique2.add(r.source.id);
|
|
330
|
-
yield r.source;
|
|
331
|
-
}
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
*outgoers(filter = "all") {
|
|
335
|
-
const unique2 = /* @__PURE__ */ new Set();
|
|
336
|
-
for (const r of this.outgoing(filter)) {
|
|
337
|
-
if (unique2.has(r.target.id)) {
|
|
338
|
-
continue;
|
|
339
|
-
}
|
|
340
|
-
unique2.add(r.target.id);
|
|
341
|
-
yield r.target;
|
|
342
|
-
}
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Iterate over all views that include this deployment element.
|
|
347
|
-
*/
|
|
348
|
-
*views() {
|
|
349
|
-
for (const view of this.$model.views()) {
|
|
350
|
-
if (view._type !== "deployment") {
|
|
351
|
-
continue;
|
|
352
|
-
}
|
|
353
|
-
if (view.includesDeployment(this.id)) {
|
|
354
|
-
yield view;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
// type guard
|
|
359
|
-
isDeploymentNode() {
|
|
360
|
-
return false;
|
|
361
|
-
}
|
|
362
|
-
// type guard
|
|
363
|
-
isInstance() {
|
|
364
|
-
return false;
|
|
365
|
-
}
|
|
366
|
-
get allOutgoing() {
|
|
367
|
-
return memoizeProp(this, Symbol.for("allOutgoing"), () => RelationshipsAccum.from(
|
|
368
|
-
new Set(this.outgoingModelRelationships()),
|
|
369
|
-
new Set(this.outgoing())
|
|
370
|
-
));
|
|
371
|
-
}
|
|
372
|
-
get allIncoming() {
|
|
373
|
-
return memoizeProp(this, Symbol.for("allIncoming"), () => RelationshipsAccum.from(
|
|
374
|
-
new Set(this.incomingModelRelationships()),
|
|
375
|
-
new Set(this.incoming())
|
|
376
|
-
));
|
|
377
|
-
}
|
|
378
|
-
getMetadata(field) {
|
|
379
|
-
if (field) {
|
|
380
|
-
return this.$node.metadata?.[field];
|
|
381
|
-
}
|
|
382
|
-
return this.$node.metadata ?? {};
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* Checks if the deployment element has the given tag.
|
|
386
|
-
*/
|
|
387
|
-
isTagged(tag) {
|
|
388
|
-
return this.tags.includes(tag);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
class DeploymentNodeModel extends AbstractDeploymentElementModel {
|
|
392
|
-
constructor($model, $node) {
|
|
393
|
-
super();
|
|
394
|
-
this.$model = $model;
|
|
395
|
-
this.$node = $node;
|
|
396
|
-
this.id = $node.id;
|
|
397
|
-
this._literalId = $node.id;
|
|
398
|
-
this.title = $node.title;
|
|
399
|
-
this.hierarchyLevel = hierarchyLevel($node.id);
|
|
400
|
-
}
|
|
401
|
-
id;
|
|
402
|
-
_literalId;
|
|
403
|
-
title;
|
|
404
|
-
hierarchyLevel;
|
|
405
|
-
get parent() {
|
|
406
|
-
return this.$model.parent(this);
|
|
407
|
-
}
|
|
408
|
-
get kind() {
|
|
409
|
-
return this.$node.kind;
|
|
410
|
-
}
|
|
411
|
-
get tags() {
|
|
412
|
-
return memoizeProp(this, Symbol.for("tags"), () => {
|
|
413
|
-
return i([
|
|
414
|
-
...this.$node.tags ?? [],
|
|
415
|
-
...this.$model.$model.specification.deployments[this.kind]?.tags ?? []
|
|
416
|
-
]);
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
children() {
|
|
420
|
-
return this.$model.children(this);
|
|
421
|
-
}
|
|
422
|
-
descendants(sort = "desc") {
|
|
423
|
-
return this.$model.descendants(this, sort);
|
|
424
|
-
}
|
|
425
|
-
isDeploymentNode() {
|
|
426
|
-
return true;
|
|
427
|
-
}
|
|
428
|
-
/**
|
|
429
|
-
* Iterate over all instances nested in this deployment node.
|
|
430
|
-
*/
|
|
431
|
-
*instances() {
|
|
432
|
-
for (const nested of this.descendants("desc")) {
|
|
433
|
-
if (nested.isInstance()) {
|
|
434
|
-
yield nested;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
/**
|
|
440
|
-
* Returns deployed instance inside this deployment node
|
|
441
|
-
* if only there are no more instances
|
|
442
|
-
*/
|
|
443
|
-
onlyOneInstance() {
|
|
444
|
-
const children = this.children();
|
|
445
|
-
if (children.size !== 1) {
|
|
446
|
-
return null;
|
|
447
|
-
}
|
|
448
|
-
const child = t$1([...children]);
|
|
449
|
-
return child?.isInstance() ? child : null;
|
|
450
|
-
}
|
|
451
|
-
/**
|
|
452
|
-
* Cached result of relationships from instances
|
|
453
|
-
*/
|
|
454
|
-
_relationshipsFromInstances = null;
|
|
455
|
-
relationshipsFromInstances() {
|
|
456
|
-
if (this._relationshipsFromInstances) {
|
|
457
|
-
return this._relationshipsFromInstances;
|
|
458
|
-
}
|
|
459
|
-
const {
|
|
460
|
-
outgoing,
|
|
461
|
-
incoming
|
|
462
|
-
} = this._relationshipsFromInstances = {
|
|
463
|
-
outgoing: /* @__PURE__ */ new Set(),
|
|
464
|
-
incoming: /* @__PURE__ */ new Set()
|
|
465
|
-
};
|
|
466
|
-
for (const instance of this.instances()) {
|
|
467
|
-
for (const r of instance.element.outgoing()) {
|
|
468
|
-
outgoing.add(r);
|
|
469
|
-
}
|
|
470
|
-
for (const r of instance.element.incoming()) {
|
|
471
|
-
incoming.add(r);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
return this._relationshipsFromInstances;
|
|
475
|
-
}
|
|
476
|
-
/**
|
|
477
|
-
* We return only relationships that are not already present in nested instances
|
|
478
|
-
*/
|
|
479
|
-
outgoingModelRelationships() {
|
|
480
|
-
return this.relationshipsFromInstances().outgoing.values();
|
|
481
|
-
}
|
|
482
|
-
/**
|
|
483
|
-
* We return only relationships that are not already present in nested instances
|
|
484
|
-
*/
|
|
485
|
-
incomingModelRelationships() {
|
|
486
|
-
return this.relationshipsFromInstances().incoming.values();
|
|
487
|
-
}
|
|
488
|
-
/**
|
|
489
|
-
* Returns an iterator of relationships between nested instances
|
|
490
|
-
*/
|
|
491
|
-
internalModelRelationships() {
|
|
492
|
-
const {
|
|
493
|
-
outgoing,
|
|
494
|
-
incoming
|
|
495
|
-
} = this.relationshipsFromInstances();
|
|
496
|
-
return intersection(incoming, outgoing);
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
class DeployedInstanceModel extends AbstractDeploymentElementModel {
|
|
500
|
-
constructor($model, $instance, element) {
|
|
501
|
-
super();
|
|
502
|
-
this.$model = $model;
|
|
503
|
-
this.$instance = $instance;
|
|
504
|
-
this.element = element;
|
|
505
|
-
this.id = $instance.id;
|
|
506
|
-
this._literalId = $instance.id;
|
|
507
|
-
this.title = $instance.title ?? element.title;
|
|
508
|
-
this.hierarchyLevel = hierarchyLevel($instance.id);
|
|
509
|
-
}
|
|
510
|
-
id;
|
|
511
|
-
_literalId;
|
|
512
|
-
title;
|
|
513
|
-
hierarchyLevel;
|
|
514
|
-
get $node() {
|
|
515
|
-
return this.$instance;
|
|
516
|
-
}
|
|
517
|
-
get parent() {
|
|
518
|
-
return nonNullable(this.$model.parent(this), `Parent of ${this.id} not found`);
|
|
519
|
-
}
|
|
520
|
-
get style() {
|
|
521
|
-
const { icon, style } = this.element.$element;
|
|
522
|
-
return {
|
|
523
|
-
shape: this.element.shape,
|
|
524
|
-
color: this.element.color,
|
|
525
|
-
size: DefaultShapeSize,
|
|
526
|
-
...icon && { icon },
|
|
527
|
-
...style,
|
|
528
|
-
...this.$instance.style
|
|
529
|
-
};
|
|
530
|
-
}
|
|
531
|
-
get shape() {
|
|
532
|
-
return this.$instance.style?.shape ?? this.element.shape;
|
|
533
|
-
}
|
|
534
|
-
get color() {
|
|
535
|
-
return this.$instance.style?.color ?? this.element.color;
|
|
536
|
-
}
|
|
537
|
-
get tags() {
|
|
538
|
-
return memoizeProp(this, Symbol.for("tags"), () => {
|
|
539
|
-
return i([
|
|
540
|
-
...this.$instance.tags ?? [],
|
|
541
|
-
...this.element.tags
|
|
542
|
-
]);
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
get kind() {
|
|
546
|
-
return this.element.kind;
|
|
547
|
-
}
|
|
548
|
-
get description() {
|
|
549
|
-
return this.$instance.description ?? this.element.description;
|
|
550
|
-
}
|
|
551
|
-
get technology() {
|
|
552
|
-
return this.$instance.technology ?? this.element.technology;
|
|
553
|
-
}
|
|
554
|
-
get links() {
|
|
555
|
-
return this.$instance.links ?? this.element.links;
|
|
556
|
-
}
|
|
557
|
-
isInstance() {
|
|
558
|
-
return true;
|
|
559
|
-
}
|
|
560
|
-
outgoingModelRelationships() {
|
|
561
|
-
return this.element.outgoing();
|
|
562
|
-
}
|
|
563
|
-
incomingModelRelationships() {
|
|
564
|
-
return this.element.incoming();
|
|
565
|
-
}
|
|
566
|
-
/**
|
|
567
|
-
* Iterate over all views that include this instance.
|
|
568
|
-
* (Some views may include the parent deployment node instead of the instance.)
|
|
569
|
-
*/
|
|
570
|
-
*views() {
|
|
571
|
-
for (const view of this.$model.views()) {
|
|
572
|
-
if (view._type !== "deployment") {
|
|
573
|
-
continue;
|
|
574
|
-
}
|
|
575
|
-
if (view.includesDeployment(this.id)) {
|
|
576
|
-
yield view;
|
|
577
|
-
continue;
|
|
578
|
-
}
|
|
579
|
-
if (view.includesDeployment(this.parent.id) && this.parent.onlyOneInstance()) {
|
|
580
|
-
yield view;
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
class NestedElementOfDeployedInstanceModel {
|
|
586
|
-
constructor(instance, element) {
|
|
587
|
-
this.instance = instance;
|
|
588
|
-
this.element = element;
|
|
589
|
-
}
|
|
590
|
-
get id() {
|
|
591
|
-
return this.instance.id;
|
|
592
|
-
}
|
|
593
|
-
get _literalId() {
|
|
594
|
-
return this.instance.id;
|
|
595
|
-
}
|
|
596
|
-
get style() {
|
|
597
|
-
const { icon, style } = this.element.$element;
|
|
598
|
-
return {
|
|
599
|
-
shape: this.element.shape,
|
|
600
|
-
color: this.element.color,
|
|
601
|
-
...icon && { icon },
|
|
602
|
-
...style
|
|
603
|
-
};
|
|
604
|
-
}
|
|
605
|
-
get shape() {
|
|
606
|
-
return this.element.shape;
|
|
607
|
-
}
|
|
608
|
-
get color() {
|
|
609
|
-
return this.element.color;
|
|
610
|
-
}
|
|
611
|
-
get title() {
|
|
612
|
-
return this.element.title;
|
|
613
|
-
}
|
|
614
|
-
get description() {
|
|
615
|
-
return this.element.description;
|
|
616
|
-
}
|
|
617
|
-
get technology() {
|
|
618
|
-
return this.element.technology;
|
|
619
|
-
}
|
|
620
|
-
isDeploymentNode() {
|
|
621
|
-
return false;
|
|
622
|
-
}
|
|
623
|
-
isInstance() {
|
|
624
|
-
return false;
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
class DeploymentRelationModel {
|
|
628
|
-
constructor($model, $relationship) {
|
|
629
|
-
this.$model = $model;
|
|
630
|
-
this.$relationship = $relationship;
|
|
631
|
-
this.source = $model.deploymentRef($relationship.source);
|
|
632
|
-
this.target = $model.deploymentRef($relationship.target);
|
|
633
|
-
const parent = commonAncestor(this.source.id, this.target.id);
|
|
634
|
-
this.boundary = parent ? this.$model.node(parent) : null;
|
|
635
|
-
}
|
|
636
|
-
boundary;
|
|
637
|
-
source;
|
|
638
|
-
target;
|
|
639
|
-
get id() {
|
|
640
|
-
return this.$relationship.id;
|
|
641
|
-
}
|
|
642
|
-
get expression() {
|
|
643
|
-
return `${this.source.id} -> ${this.target.id}`;
|
|
644
|
-
}
|
|
645
|
-
get title() {
|
|
646
|
-
if (!n$1(this.$relationship.title)) {
|
|
647
|
-
return null;
|
|
648
|
-
}
|
|
649
|
-
return this.$relationship.title;
|
|
650
|
-
}
|
|
651
|
-
get technology() {
|
|
652
|
-
if (!n$1(this.$relationship.technology)) {
|
|
653
|
-
return null;
|
|
654
|
-
}
|
|
655
|
-
return this.$relationship.technology;
|
|
656
|
-
}
|
|
657
|
-
get description() {
|
|
658
|
-
if (!n$1(this.$relationship.description)) {
|
|
659
|
-
return null;
|
|
660
|
-
}
|
|
661
|
-
return this.$relationship.description;
|
|
662
|
-
}
|
|
663
|
-
get tags() {
|
|
664
|
-
return this.$relationship.tags ?? [];
|
|
665
|
-
}
|
|
666
|
-
get kind() {
|
|
667
|
-
return this.$relationship.kind ?? null;
|
|
668
|
-
}
|
|
669
|
-
get navigateTo() {
|
|
670
|
-
return this.$relationship.navigateTo ? this.$model.$model.view(this.$relationship.navigateTo) : null;
|
|
671
|
-
}
|
|
672
|
-
get links() {
|
|
673
|
-
return this.$relationship.links ?? [];
|
|
674
|
-
}
|
|
675
|
-
get color() {
|
|
676
|
-
return this.$relationship.color ?? DefaultThemeColor;
|
|
677
|
-
}
|
|
678
|
-
get line() {
|
|
679
|
-
return this.$relationship.line ?? DefaultLineStyle;
|
|
680
|
-
}
|
|
681
|
-
*views() {
|
|
682
|
-
for (const view of this.$model.views()) {
|
|
683
|
-
if (view.includesRelation(this.id)) {
|
|
684
|
-
yield view;
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
return;
|
|
688
|
-
}
|
|
689
|
-
isDeploymentRelation() {
|
|
690
|
-
return true;
|
|
691
|
-
}
|
|
692
|
-
isModelRelation() {
|
|
693
|
-
return false;
|
|
694
|
-
}
|
|
695
|
-
getMetadata(field) {
|
|
696
|
-
if (field) {
|
|
697
|
-
return this.$relationship.metadata?.[field];
|
|
698
|
-
}
|
|
699
|
-
return this.$relationship.metadata ?? {};
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* Checks if the relationship has the given tag.
|
|
703
|
-
*/
|
|
704
|
-
isTagged(tag) {
|
|
705
|
-
return this.tags.includes(tag);
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
class RelationshipsAccum {
|
|
709
|
-
/**
|
|
710
|
-
* @param model relationships from logical model
|
|
711
|
-
* @param deployment relationships from deployment model
|
|
712
|
-
*/
|
|
713
|
-
constructor(model = /* @__PURE__ */ new Set(), deployment = /* @__PURE__ */ new Set()) {
|
|
714
|
-
this.model = model;
|
|
715
|
-
this.deployment = deployment;
|
|
716
|
-
}
|
|
717
|
-
static empty() {
|
|
718
|
-
return new RelationshipsAccum();
|
|
719
|
-
}
|
|
720
|
-
static from(model, deployment) {
|
|
721
|
-
return new RelationshipsAccum(
|
|
722
|
-
new Set(model),
|
|
723
|
-
new Set(deployment)
|
|
724
|
-
);
|
|
725
|
-
}
|
|
726
|
-
get isEmpty() {
|
|
727
|
-
return this.model.size === 0 && this.deployment.size === 0;
|
|
728
|
-
}
|
|
729
|
-
get nonEmpty() {
|
|
730
|
-
return this.model.size > 0 || this.deployment.size > 0;
|
|
731
|
-
}
|
|
732
|
-
get size() {
|
|
733
|
-
return this.model.size + this.deployment.size;
|
|
734
|
-
}
|
|
735
|
-
/**
|
|
736
|
-
* Returns new Accum containing all the elements which are both in this and otherAccum
|
|
737
|
-
*/
|
|
738
|
-
intersect(otherAccum) {
|
|
739
|
-
return RelationshipsAccum.from(
|
|
740
|
-
intersection(this.model, otherAccum.model),
|
|
741
|
-
intersection(this.deployment, otherAccum.deployment)
|
|
742
|
-
);
|
|
743
|
-
}
|
|
744
|
-
/**
|
|
745
|
-
* Returns new Accum containing all the elements which are both in this and otherAccum
|
|
746
|
-
*/
|
|
747
|
-
difference(otherAccum) {
|
|
748
|
-
return RelationshipsAccum.from(
|
|
749
|
-
difference(this.model, otherAccum.model),
|
|
750
|
-
difference(this.deployment, otherAccum.deployment)
|
|
751
|
-
);
|
|
752
|
-
}
|
|
753
|
-
/**
|
|
754
|
-
* Returns new Accum containing all the elements from both
|
|
755
|
-
*/
|
|
756
|
-
union(otherAccum) {
|
|
757
|
-
return RelationshipsAccum.from(
|
|
758
|
-
union(this.model, otherAccum.model),
|
|
759
|
-
union(this.deployment, otherAccum.deployment)
|
|
760
|
-
);
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
|
|
764
248
|
function getId(element) {
|
|
765
249
|
return typeof element === "string" ? element : element.id;
|
|
766
250
|
}
|
|
@@ -1104,10 +588,7 @@ class RelationshipModel {
|
|
|
1104
588
|
return this.$relationship.technology;
|
|
1105
589
|
}
|
|
1106
590
|
get description() {
|
|
1107
|
-
|
|
1108
|
-
return null;
|
|
1109
|
-
}
|
|
1110
|
-
return this.$relationship.description;
|
|
591
|
+
return RichText.memoize(this, this.$relationship.description);
|
|
1111
592
|
}
|
|
1112
593
|
get navigateTo() {
|
|
1113
594
|
return this.$relationship.navigateTo ? this.model.view(this.$relationship.navigateTo) : null;
|
|
@@ -1144,6 +625,9 @@ class RelationshipModel {
|
|
|
1144
625
|
isModelRelation() {
|
|
1145
626
|
return true;
|
|
1146
627
|
}
|
|
628
|
+
hasMetadata() {
|
|
629
|
+
return !!this.$relationship.metadata && !n$2(this.$relationship.metadata);
|
|
630
|
+
}
|
|
1147
631
|
getMetadata(field) {
|
|
1148
632
|
if (field) {
|
|
1149
633
|
return this.$relationship.metadata?.[field];
|
|
@@ -1174,10 +658,10 @@ class EdgeModel {
|
|
|
1174
658
|
return this.#edge.parent ? this.view.node(this.#edge.parent) : null;
|
|
1175
659
|
}
|
|
1176
660
|
get label() {
|
|
1177
|
-
return this.#edge.label;
|
|
661
|
+
return this.#edge.label ?? null;
|
|
1178
662
|
}
|
|
1179
663
|
get description() {
|
|
1180
|
-
return this.#edge.description
|
|
664
|
+
return RichText.memoize(this, this.#edge.description);
|
|
1181
665
|
}
|
|
1182
666
|
get technology() {
|
|
1183
667
|
return this.#edge.technology ?? null;
|
|
@@ -1242,7 +726,7 @@ class NodeModel {
|
|
|
1242
726
|
return this.#node.kind;
|
|
1243
727
|
}
|
|
1244
728
|
get description() {
|
|
1245
|
-
return this.#node.description
|
|
729
|
+
return RichText.memoize(this, this.#node.description);
|
|
1246
730
|
}
|
|
1247
731
|
get technology() {
|
|
1248
732
|
return this.#node.technology ?? null;
|
|
@@ -1448,6 +932,9 @@ class LikeC4ViewModel {
|
|
|
1448
932
|
get title() {
|
|
1449
933
|
return this.$view.title;
|
|
1450
934
|
}
|
|
935
|
+
get description() {
|
|
936
|
+
return RichText.memoize(this, this.$view.description);
|
|
937
|
+
}
|
|
1451
938
|
get tags() {
|
|
1452
939
|
return this.$view.tags ?? [];
|
|
1453
940
|
}
|
|
@@ -2115,538 +1602,6 @@ class LikeC4Model {
|
|
|
2115
1602
|
});
|
|
2116
1603
|
})(LikeC4Model || (LikeC4Model = {}));
|
|
2117
1604
|
|
|
2118
|
-
var Connection;
|
|
2119
|
-
((Connection2) => {
|
|
2120
|
-
Connection2.isInside = (fqn) => {
|
|
2121
|
-
return (connection) => isAncestor(fqn, connection.source.id) && isAncestor(fqn, connection.target.id);
|
|
2122
|
-
};
|
|
2123
|
-
Connection2.isDirectedBetween = (source, target) => {
|
|
2124
|
-
return (connection) => (connection.source.id === source || isAncestor(source, connection.source.id)) && (connection.target.id === target || isAncestor(target, connection.target.id));
|
|
2125
|
-
};
|
|
2126
|
-
Connection2.isAnyBetween = (source, target) => {
|
|
2127
|
-
const forward = (0, Connection2.isDirectedBetween)(source, target), backward = (0, Connection2.isDirectedBetween)(target, source);
|
|
2128
|
-
return (connection) => forward(connection) || backward(connection);
|
|
2129
|
-
};
|
|
2130
|
-
Connection2.isIncoming = (target) => {
|
|
2131
|
-
return (connection) => (connection.target.id === target || isAncestor(target, connection.target.id)) && !isAncestor(target, connection.source.id);
|
|
2132
|
-
};
|
|
2133
|
-
Connection2.isOutgoing = (source) => {
|
|
2134
|
-
return (connection) => (connection.source.id === source || isAncestor(source, connection.source.id)) && !isAncestor(source, connection.target.id);
|
|
2135
|
-
};
|
|
2136
|
-
Connection2.isAnyInOut = (source) => {
|
|
2137
|
-
const isIn = (0, Connection2.isIncoming)(source), isOut = (0, Connection2.isOutgoing)(source);
|
|
2138
|
-
return (connection) => isIn(connection) || isOut(connection);
|
|
2139
|
-
};
|
|
2140
|
-
})(Connection || (Connection = {}));
|
|
2141
|
-
|
|
2142
|
-
const customInspectSymbol = Symbol.for("nodejs.util.inspect.custom");
|
|
2143
|
-
|
|
2144
|
-
class DeploymentConnectionModel {
|
|
2145
|
-
constructor(source, target, relations) {
|
|
2146
|
-
this.source = source;
|
|
2147
|
-
this.target = target;
|
|
2148
|
-
this.relations = relations;
|
|
2149
|
-
this.id = stringHash(`deployment:${source.id}:${target.id}`);
|
|
2150
|
-
}
|
|
2151
|
-
id;
|
|
2152
|
-
/**
|
|
2153
|
-
* Human readable expression of the connection
|
|
2154
|
-
* Mostly used for testing and debugging
|
|
2155
|
-
*/
|
|
2156
|
-
get expression() {
|
|
2157
|
-
return `${this.source.id} -> ${this.target.id}`;
|
|
2158
|
-
}
|
|
2159
|
-
_boundary;
|
|
2160
|
-
/**
|
|
2161
|
-
* Common ancestor of the source and target elements.
|
|
2162
|
-
* Represents the boundary of the connection.
|
|
2163
|
-
*/
|
|
2164
|
-
get boundary() {
|
|
2165
|
-
this._boundary ??= this.source.commonAncestor(this.target);
|
|
2166
|
-
return this._boundary;
|
|
2167
|
-
}
|
|
2168
|
-
nonEmpty() {
|
|
2169
|
-
return this.relations.nonEmpty;
|
|
2170
|
-
}
|
|
2171
|
-
[customInspectSymbol](depth, inspectOptions, inspect) {
|
|
2172
|
-
const asString = this.toString();
|
|
2173
|
-
Object.defineProperty(asString, "constructor", {
|
|
2174
|
-
value: DeploymentConnectionModel,
|
|
2175
|
-
enumerable: false
|
|
2176
|
-
});
|
|
2177
|
-
return asString;
|
|
2178
|
-
}
|
|
2179
|
-
toString() {
|
|
2180
|
-
const model = [...this.relations.model].map((c) => " " + c.expression);
|
|
2181
|
-
if (model.length) {
|
|
2182
|
-
model.unshift(" model:");
|
|
2183
|
-
} else {
|
|
2184
|
-
model.unshift(" model: []");
|
|
2185
|
-
}
|
|
2186
|
-
const deployment = [...this.relations.deployment].map((c) => " " + c.expression);
|
|
2187
|
-
if (deployment.length) {
|
|
2188
|
-
deployment.unshift(" deployment:");
|
|
2189
|
-
} else {
|
|
2190
|
-
deployment.unshift(" deployment: []");
|
|
2191
|
-
}
|
|
2192
|
-
return [
|
|
2193
|
-
this.expression,
|
|
2194
|
-
...model,
|
|
2195
|
-
...deployment
|
|
2196
|
-
].join("\n");
|
|
2197
|
-
}
|
|
2198
|
-
/**
|
|
2199
|
-
* Check if connection contains deployment relation,
|
|
2200
|
-
* that is directly connected to source or target.
|
|
2201
|
-
*/
|
|
2202
|
-
hasDirectDeploymentRelation() {
|
|
2203
|
-
for (const relation of this.relations.deployment) {
|
|
2204
|
-
if (relation.source.id === this.source.id || relation.target.id === this.target.id) {
|
|
2205
|
-
return true;
|
|
2206
|
-
}
|
|
2207
|
-
}
|
|
2208
|
-
return false;
|
|
2209
|
-
}
|
|
2210
|
-
*values() {
|
|
2211
|
-
yield* this.relations.model;
|
|
2212
|
-
yield* this.relations.deployment;
|
|
2213
|
-
}
|
|
2214
|
-
mergeWith(other) {
|
|
2215
|
-
if (Array.isArray(other)) {
|
|
2216
|
-
return other.reduce((acc, o) => acc.mergeWith(o), this);
|
|
2217
|
-
}
|
|
2218
|
-
invariant(this.source.id === other.source.id, "Cannot merge connections with different sources");
|
|
2219
|
-
invariant(this.target.id === other.target.id, "Cannot merge connections with different targets");
|
|
2220
|
-
return new DeploymentConnectionModel(
|
|
2221
|
-
this.source,
|
|
2222
|
-
this.target,
|
|
2223
|
-
this.relations.union(other.relations)
|
|
2224
|
-
);
|
|
2225
|
-
}
|
|
2226
|
-
difference(other) {
|
|
2227
|
-
return new DeploymentConnectionModel(
|
|
2228
|
-
this.source,
|
|
2229
|
-
this.target,
|
|
2230
|
-
this.relations.difference(other.relations)
|
|
2231
|
-
);
|
|
2232
|
-
}
|
|
2233
|
-
intersect(other) {
|
|
2234
|
-
return new DeploymentConnectionModel(
|
|
2235
|
-
this.source,
|
|
2236
|
-
this.target,
|
|
2237
|
-
this.relations.intersect(other.relations)
|
|
2238
|
-
);
|
|
2239
|
-
}
|
|
2240
|
-
equals(other) {
|
|
2241
|
-
invariant(other instanceof DeploymentConnectionModel, "Other should ne DeploymentConnectionModel");
|
|
2242
|
-
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);
|
|
2243
|
-
}
|
|
2244
|
-
/**
|
|
2245
|
-
* Creates a clone of the current `DeploymentConnectionModel` instance with optional overrides.
|
|
2246
|
-
* if `null` is provided in overrides, the corresponding relation set will be empty.
|
|
2247
|
-
*/
|
|
2248
|
-
update(overrides) {
|
|
2249
|
-
if (overrides) {
|
|
2250
|
-
overrides = {
|
|
2251
|
-
model: this.relations.model,
|
|
2252
|
-
deployment: this.relations.deployment,
|
|
2253
|
-
...overrides
|
|
2254
|
-
};
|
|
2255
|
-
}
|
|
2256
|
-
return new DeploymentConnectionModel(
|
|
2257
|
-
this.source,
|
|
2258
|
-
this.target,
|
|
2259
|
-
overrides ? new RelationshipsAccum(
|
|
2260
|
-
overrides.model ?? /* @__PURE__ */ new Set(),
|
|
2261
|
-
overrides.deployment ?? /* @__PURE__ */ new Set()
|
|
2262
|
-
) : this.relations
|
|
2263
|
-
);
|
|
2264
|
-
}
|
|
2265
|
-
}
|
|
2266
|
-
|
|
2267
|
-
function isNestedConnection(nested, parent) {
|
|
2268
|
-
if (!parent) {
|
|
2269
|
-
const p = nested;
|
|
2270
|
-
return (n) => isNestedConnection(n, p);
|
|
2271
|
-
}
|
|
2272
|
-
const isSameSource = nested.source === parent.source;
|
|
2273
|
-
const isSameTarget = nested.target === parent.target;
|
|
2274
|
-
if (isSameSource && isSameTarget) {
|
|
2275
|
-
return false;
|
|
2276
|
-
}
|
|
2277
|
-
const isSourceNested = isAncestor(parent.source.id, nested.source.id);
|
|
2278
|
-
const isTargetNested = isAncestor(parent.target.id, nested.target.id);
|
|
2279
|
-
return isSourceNested && isTargetNested || isSameSource && isTargetNested || isSameTarget && isSourceNested;
|
|
2280
|
-
}
|
|
2281
|
-
function findDeepestNestedConnection(connections, connection) {
|
|
2282
|
-
let deepest = connection;
|
|
2283
|
-
for (const c of connections) {
|
|
2284
|
-
if (isNestedConnection(c, deepest)) {
|
|
2285
|
-
deepest = c;
|
|
2286
|
-
}
|
|
2287
|
-
}
|
|
2288
|
-
return deepest !== connection ? deepest : null;
|
|
2289
|
-
}
|
|
2290
|
-
function sortDeepestFirst(connections) {
|
|
2291
|
-
const sorted = [];
|
|
2292
|
-
const unsorted = connections.slice();
|
|
2293
|
-
let next;
|
|
2294
|
-
while (next = unsorted.shift()) {
|
|
2295
|
-
let deepest;
|
|
2296
|
-
while (deepest = findDeepestNestedConnection(unsorted, next)) {
|
|
2297
|
-
const index = unsorted.indexOf(deepest);
|
|
2298
|
-
sorted.push(unsorted.splice(index, 1)[0]);
|
|
2299
|
-
}
|
|
2300
|
-
sorted.push(next);
|
|
2301
|
-
}
|
|
2302
|
-
return sorted;
|
|
2303
|
-
}
|
|
2304
|
-
const boundaryHierarchy = (conn) => conn.boundary?.id ? `.${conn.boundary.id}` : "";
|
|
2305
|
-
function sortConnectionsByBoundaryHierarchy(connections, sort) {
|
|
2306
|
-
if (!connections || isString(connections)) {
|
|
2307
|
-
const dir = connections ?? "asc";
|
|
2308
|
-
return (arr) => _sortByBoundary(arr, dir);
|
|
2309
|
-
}
|
|
2310
|
-
return _sortByBoundary(connections, sort ?? "asc");
|
|
2311
|
-
}
|
|
2312
|
-
function _sortByBoundary(connections, order) {
|
|
2313
|
-
return C(
|
|
2314
|
-
connections,
|
|
2315
|
-
m$2((conn) => ({
|
|
2316
|
-
id: boundaryHierarchy(conn),
|
|
2317
|
-
conn
|
|
2318
|
-
})),
|
|
2319
|
-
sortNaturalByFqn(order),
|
|
2320
|
-
m$2(p("conn"))
|
|
2321
|
-
);
|
|
2322
|
-
}
|
|
2323
|
-
function findAscendingConnections(connections, connection) {
|
|
2324
|
-
return connections.filter((c) => isNestedConnection(connection, c));
|
|
2325
|
-
}
|
|
2326
|
-
function findDescendantConnections(connections, connection) {
|
|
2327
|
-
return connections.filter(isNestedConnection(connection));
|
|
2328
|
-
}
|
|
2329
|
-
function mergeConnections(connections) {
|
|
2330
|
-
const map2 = /* @__PURE__ */ new Map();
|
|
2331
|
-
for (const conn of connections) {
|
|
2332
|
-
const existing = map2.get(conn.id);
|
|
2333
|
-
if (existing) {
|
|
2334
|
-
map2.set(conn.id, conn.mergeWith(existing));
|
|
2335
|
-
} else {
|
|
2336
|
-
map2.set(conn.id, conn);
|
|
2337
|
-
}
|
|
2338
|
-
}
|
|
2339
|
-
return [...map2.values()];
|
|
2340
|
-
}
|
|
2341
|
-
function differenceConnections(source, exclude) {
|
|
2342
|
-
const minus = new Map([...exclude].map((c) => [c.id, c]));
|
|
2343
|
-
return [...source].reduce((acc, c) => {
|
|
2344
|
-
const other = minus.get(c.id);
|
|
2345
|
-
if (!other) {
|
|
2346
|
-
acc.push(c);
|
|
2347
|
-
return acc;
|
|
2348
|
-
}
|
|
2349
|
-
const updated = c.difference(other);
|
|
2350
|
-
if (updated.nonEmpty()) {
|
|
2351
|
-
acc.push(updated);
|
|
2352
|
-
}
|
|
2353
|
-
return acc;
|
|
2354
|
-
}, []);
|
|
2355
|
-
}
|
|
2356
|
-
function hasSameSourceTarget(a, b) {
|
|
2357
|
-
if (b) {
|
|
2358
|
-
return a.source === b.source && a.target === b.target;
|
|
2359
|
-
}
|
|
2360
|
-
return (b2) => a.source === b2.source && a.target === b2.target;
|
|
2361
|
-
}
|
|
2362
|
-
function hasSameSource(a, b) {
|
|
2363
|
-
if (b) {
|
|
2364
|
-
return a.source === b.source;
|
|
2365
|
-
}
|
|
2366
|
-
return (b2) => a.source === b2.source;
|
|
2367
|
-
}
|
|
2368
|
-
function hasSameTarget(a, b) {
|
|
2369
|
-
if (b) {
|
|
2370
|
-
return a.target === b.target;
|
|
2371
|
-
}
|
|
2372
|
-
return (b2) => a.target === b2.target;
|
|
2373
|
-
}
|
|
2374
|
-
function isOutgoing(a, source) {
|
|
2375
|
-
if (!source) {
|
|
2376
|
-
const _source = a;
|
|
2377
|
-
return (b) => isOutgoing(b, _source);
|
|
2378
|
-
}
|
|
2379
|
-
const at = a;
|
|
2380
|
-
return isDescendantOf(at.source, source) && !isDescendantOf(at.target, source);
|
|
2381
|
-
}
|
|
2382
|
-
function isIncoming(a, target) {
|
|
2383
|
-
if (!target) {
|
|
2384
|
-
const _target = a;
|
|
2385
|
-
return (b) => isIncoming(b, _target);
|
|
2386
|
-
}
|
|
2387
|
-
const at = a;
|
|
2388
|
-
return isDescendantOf(at.target, target) && !isDescendantOf(at.source, target);
|
|
2389
|
-
}
|
|
2390
|
-
function isAnyInOut(a, source) {
|
|
2391
|
-
if (!source) {
|
|
2392
|
-
const _source = a;
|
|
2393
|
-
return (b) => isAnyInOut(b, _source);
|
|
2394
|
-
}
|
|
2395
|
-
const at = a;
|
|
2396
|
-
return isDescendantOf(at.source, source) !== isDescendantOf(at.target, source);
|
|
2397
|
-
}
|
|
2398
|
-
|
|
2399
|
-
function findConnection$1(source, target, direction = "directed") {
|
|
2400
|
-
if (source === target) {
|
|
2401
|
-
return [];
|
|
2402
|
-
}
|
|
2403
|
-
if (isSameHierarchy(source, target)) {
|
|
2404
|
-
return [];
|
|
2405
|
-
}
|
|
2406
|
-
const directedIntersection = intersection(source.allOutgoing, target.allIncoming);
|
|
2407
|
-
const directed = directedIntersection.size > 0 ? new ConnectionModel(
|
|
2408
|
-
source,
|
|
2409
|
-
target,
|
|
2410
|
-
directedIntersection
|
|
2411
|
-
) : null;
|
|
2412
|
-
if (direction === "directed") {
|
|
2413
|
-
return directed ? [directed] : [];
|
|
2414
|
-
}
|
|
2415
|
-
const reverseIntersection = intersection(source.allIncoming, target.allOutgoing);
|
|
2416
|
-
const reverse = reverseIntersection.size > 0 ? new ConnectionModel(
|
|
2417
|
-
target,
|
|
2418
|
-
source,
|
|
2419
|
-
reverseIntersection
|
|
2420
|
-
) : null;
|
|
2421
|
-
if (directed && reverse) {
|
|
2422
|
-
return [directed, reverse];
|
|
2423
|
-
}
|
|
2424
|
-
if (directed) {
|
|
2425
|
-
return [directed];
|
|
2426
|
-
}
|
|
2427
|
-
if (reverse) {
|
|
2428
|
-
return [reverse];
|
|
2429
|
-
}
|
|
2430
|
-
return [];
|
|
2431
|
-
}
|
|
2432
|
-
function findConnectionsBetween$1(element, others, direction = "both") {
|
|
2433
|
-
if (element.allIncoming.size === 0 && element.allOutgoing.size === 0) {
|
|
2434
|
-
return [];
|
|
2435
|
-
}
|
|
2436
|
-
const outgoing = [];
|
|
2437
|
-
const incoming = [];
|
|
2438
|
-
for (const _other of others) {
|
|
2439
|
-
if (element === _other) {
|
|
2440
|
-
continue;
|
|
2441
|
-
}
|
|
2442
|
-
for (const found of findConnection$1(element, _other, direction)) {
|
|
2443
|
-
if (found.source === element) {
|
|
2444
|
-
outgoing.push(found);
|
|
2445
|
-
} else {
|
|
2446
|
-
incoming.push(found);
|
|
2447
|
-
}
|
|
2448
|
-
}
|
|
2449
|
-
}
|
|
2450
|
-
return [
|
|
2451
|
-
...outgoing,
|
|
2452
|
-
...incoming
|
|
2453
|
-
];
|
|
2454
|
-
}
|
|
2455
|
-
function findConnectionsWithin$1(elements) {
|
|
2456
|
-
return [...elements].reduce((acc, el, index, array) => {
|
|
2457
|
-
if (index === array.length - 1) {
|
|
2458
|
-
return acc;
|
|
2459
|
-
}
|
|
2460
|
-
acc.push(
|
|
2461
|
-
...findConnectionsBetween$1(el, array.slice(index + 1), "both")
|
|
2462
|
-
);
|
|
2463
|
-
return acc;
|
|
2464
|
-
}, []);
|
|
2465
|
-
}
|
|
2466
|
-
|
|
2467
|
-
const modelConnection = {
|
|
2468
|
-
__proto__: null,
|
|
2469
|
-
findConnection: findConnection$1,
|
|
2470
|
-
findConnectionsBetween: findConnectionsBetween$1,
|
|
2471
|
-
findConnectionsWithin: findConnectionsWithin$1
|
|
2472
|
-
};
|
|
2473
|
-
|
|
2474
|
-
class ConnectionModel {
|
|
2475
|
-
constructor(source, target, relations = /* @__PURE__ */ new Set()) {
|
|
2476
|
-
this.source = source;
|
|
2477
|
-
this.target = target;
|
|
2478
|
-
this.relations = relations;
|
|
2479
|
-
this.id = stringHash(`model:${source.id}:${target.id}`);
|
|
2480
|
-
}
|
|
2481
|
-
id;
|
|
2482
|
-
_boundary;
|
|
2483
|
-
/**
|
|
2484
|
-
* Common ancestor of the source and target elements.
|
|
2485
|
-
* Represents the boundary of the connection.
|
|
2486
|
-
*/
|
|
2487
|
-
get boundary() {
|
|
2488
|
-
return this._boundary ??= this.source.commonAncestor(this.target);
|
|
2489
|
-
}
|
|
2490
|
-
/**
|
|
2491
|
-
* Human readable expression of the connection
|
|
2492
|
-
* Mostly used for testing and debugging
|
|
2493
|
-
*/
|
|
2494
|
-
get expression() {
|
|
2495
|
-
return `${this.source.id} -> ${this.target.id}`;
|
|
2496
|
-
}
|
|
2497
|
-
/**
|
|
2498
|
-
* Returns true if only includes relations between the source and target elements.
|
|
2499
|
-
*/
|
|
2500
|
-
get isDirect() {
|
|
2501
|
-
return this.nonEmpty() && !this.isImplicit;
|
|
2502
|
-
}
|
|
2503
|
-
/**
|
|
2504
|
-
* Returns true if includes relations between nested elements of the source and target elements.
|
|
2505
|
-
*/
|
|
2506
|
-
get isImplicit() {
|
|
2507
|
-
return this.nonEmpty() && isome(this.relations, o$2(hasSameSourceTarget(this)));
|
|
2508
|
-
}
|
|
2509
|
-
get directRelations() {
|
|
2510
|
-
return new Set(ifilter(this.relations, hasSameSourceTarget(this)));
|
|
2511
|
-
}
|
|
2512
|
-
nonEmpty() {
|
|
2513
|
-
return this.relations.size > 0;
|
|
2514
|
-
}
|
|
2515
|
-
mergeWith(other) {
|
|
2516
|
-
invariant(this.source.id === other.source.id, "Cannot merge connections with different sources");
|
|
2517
|
-
invariant(this.target.id === other.target.id, "Cannot merge connections with different targets");
|
|
2518
|
-
return new ConnectionModel(
|
|
2519
|
-
this.source,
|
|
2520
|
-
this.target,
|
|
2521
|
-
union(this.relations, other.relations)
|
|
2522
|
-
);
|
|
2523
|
-
}
|
|
2524
|
-
difference(other) {
|
|
2525
|
-
return new ConnectionModel(
|
|
2526
|
-
this.source,
|
|
2527
|
-
this.target,
|
|
2528
|
-
difference(this.relations, other.relations)
|
|
2529
|
-
);
|
|
2530
|
-
}
|
|
2531
|
-
intersect(other) {
|
|
2532
|
-
invariant(other instanceof ConnectionModel, "Cannot intersect connection with different type");
|
|
2533
|
-
return new ConnectionModel(
|
|
2534
|
-
this.source,
|
|
2535
|
-
this.target,
|
|
2536
|
-
intersection(this.relations, other.relations)
|
|
2537
|
-
);
|
|
2538
|
-
}
|
|
2539
|
-
equals(other) {
|
|
2540
|
-
invariant(other instanceof ConnectionModel, "Cannot merge connection with different type");
|
|
2541
|
-
const _other = other;
|
|
2542
|
-
return this.id === _other.id && this.source.id === _other.source.id && this.target.id === _other.target.id && equals(this.relations, _other.relations);
|
|
2543
|
-
}
|
|
2544
|
-
/**
|
|
2545
|
-
* Returns a new instance with the updated relations.
|
|
2546
|
-
*
|
|
2547
|
-
* @param relations - A readonly set of `RelationshipModel` instances representing the new relations.
|
|
2548
|
-
* @returns A new `ConnectionModel` instance with the updated relations.
|
|
2549
|
-
*/
|
|
2550
|
-
update(relations) {
|
|
2551
|
-
return new ConnectionModel(
|
|
2552
|
-
this.source,
|
|
2553
|
-
this.target,
|
|
2554
|
-
relations
|
|
2555
|
-
);
|
|
2556
|
-
}
|
|
2557
|
-
[customInspectSymbol](depth, inspectOptions, inspect) {
|
|
2558
|
-
const asString = this.toString();
|
|
2559
|
-
Object.defineProperty(asString, "constructor", {
|
|
2560
|
-
value: ConnectionModel,
|
|
2561
|
-
enumerable: false
|
|
2562
|
-
});
|
|
2563
|
-
return asString;
|
|
2564
|
-
}
|
|
2565
|
-
toString() {
|
|
2566
|
-
return [
|
|
2567
|
-
this.expression,
|
|
2568
|
-
this.relations.size ? " relations:" : " relations: [ ]",
|
|
2569
|
-
...[...this.relations].map((c) => " " + c.expression)
|
|
2570
|
-
].join("\n");
|
|
2571
|
-
}
|
|
2572
|
-
/**
|
|
2573
|
-
* Creates a new connection with reversed direction (target becomes source and vice versa)
|
|
2574
|
-
* @param search - When true, attempts to find an existing connection between the reversed nodes
|
|
2575
|
-
*/
|
|
2576
|
-
reversed(search = false) {
|
|
2577
|
-
if (!search) {
|
|
2578
|
-
return new ConnectionModel(this.target, this.source);
|
|
2579
|
-
}
|
|
2580
|
-
const [found] = findConnection$1(this.target, this.source, "directed");
|
|
2581
|
-
return found ?? new ConnectionModel(this.target, this.source, /* @__PURE__ */ new Set());
|
|
2582
|
-
}
|
|
2583
|
-
}
|
|
2584
|
-
|
|
2585
|
-
function findConnection(source, target, direction = "directed") {
|
|
2586
|
-
if (source === target) {
|
|
2587
|
-
return [];
|
|
2588
|
-
}
|
|
2589
|
-
if (isSameHierarchy(source, target)) {
|
|
2590
|
-
return [];
|
|
2591
|
-
}
|
|
2592
|
-
const directedIntersection = source.allOutgoing.intersect(target.allIncoming);
|
|
2593
|
-
const directed = directedIntersection.nonEmpty ? [
|
|
2594
|
-
new DeploymentConnectionModel(
|
|
2595
|
-
source,
|
|
2596
|
-
target,
|
|
2597
|
-
directedIntersection
|
|
2598
|
-
)
|
|
2599
|
-
] : [];
|
|
2600
|
-
if (direction === "directed") {
|
|
2601
|
-
return directed;
|
|
2602
|
-
}
|
|
2603
|
-
return [
|
|
2604
|
-
...directed,
|
|
2605
|
-
...findConnection(target, source, "directed")
|
|
2606
|
-
];
|
|
2607
|
-
}
|
|
2608
|
-
function findConnectionsBetween(element, others, direction = "both") {
|
|
2609
|
-
if (element.allIncoming.isEmpty && element.allOutgoing.isEmpty) {
|
|
2610
|
-
return [];
|
|
2611
|
-
}
|
|
2612
|
-
const outgoing = [];
|
|
2613
|
-
const incoming = [];
|
|
2614
|
-
for (const _other of others) {
|
|
2615
|
-
if (element === _other) {
|
|
2616
|
-
continue;
|
|
2617
|
-
}
|
|
2618
|
-
for (const found of findConnection(element, _other, direction)) {
|
|
2619
|
-
if (found.source === element) {
|
|
2620
|
-
outgoing.push(found);
|
|
2621
|
-
} else {
|
|
2622
|
-
incoming.push(found);
|
|
2623
|
-
}
|
|
2624
|
-
}
|
|
2625
|
-
}
|
|
2626
|
-
return [
|
|
2627
|
-
...outgoing,
|
|
2628
|
-
...incoming
|
|
2629
|
-
];
|
|
2630
|
-
}
|
|
2631
|
-
function findConnectionsWithin(elements) {
|
|
2632
|
-
return [...elements].reduce((acc, el, index, array) => {
|
|
2633
|
-
if (index === array.length - 1) {
|
|
2634
|
-
return acc;
|
|
2635
|
-
}
|
|
2636
|
-
acc.push(
|
|
2637
|
-
...findConnectionsBetween(el, array.slice(index + 1), "both")
|
|
2638
|
-
);
|
|
2639
|
-
return acc;
|
|
2640
|
-
}, []);
|
|
2641
|
-
}
|
|
2642
|
-
|
|
2643
|
-
const deploymentConnection = {
|
|
2644
|
-
__proto__: null,
|
|
2645
|
-
findConnection: findConnection,
|
|
2646
|
-
findConnectionsBetween: findConnectionsBetween,
|
|
2647
|
-
findConnectionsWithin: findConnectionsWithin
|
|
2648
|
-
};
|
|
2649
|
-
|
|
2650
1605
|
function isDeploymentNodeModel(model) {
|
|
2651
1606
|
return model instanceof DeploymentNodeModel;
|
|
2652
1607
|
}
|
|
@@ -2678,4 +1633,4 @@ function isEdgeModel(edge) {
|
|
|
2678
1633
|
return edge instanceof EdgeModel;
|
|
2679
1634
|
}
|
|
2680
1635
|
|
|
2681
|
-
export {
|
|
1636
|
+
export { ElementModel as E, LikeC4Model as L, NodeModel as N, RelationshipModel as R, LikeC4DeploymentModel as a, EdgeModel as b, LikeC4ViewModel as c, isDeployedInstanceModel as d, isDeploymentElementModel as e, isNestedElementOfDeployedInstanceModel as f, isDeploymentRelationModel as g, isRelationModel as h, isDeploymentNodeModel as i, isElementModel as j, isLikeC4ViewModel as k, isNodeModel as l, isEdgeModel as m, a as n, r, t };
|