@likec4/core 1.26.1 → 1.27.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 +3 -1
- package/dist/builder/index.mjs +6 -4
- package/dist/compute-view/index.d.mts +1 -2
- package/dist/compute-view/index.mjs +19 -7
- package/dist/compute-view/relationships-view/index.d.mts +42 -0
- package/dist/compute-view/relationships-view/index.mjs +181 -0
- package/dist/index.d.mts +3 -5
- package/dist/index.mjs +5 -5
- package/dist/model/index.d.mts +3 -3
- package/dist/model/index.mjs +1 -1
- package/dist/shared/{core.yND74qFI.mjs → core.BMep80lJ.mjs} +2 -1
- package/dist/shared/{core.DRxv3HIl.mjs → core.C-YXI-43.mjs} +1 -5
- package/dist/shared/core.CQXU9DF7.mjs +477 -0
- package/dist/shared/{core.Brmu7VBL.d.mts → core.CtloVwbo.d.mts} +3 -1
- package/dist/shared/{core.BqezHsjR.mjs → core.Cu-UdkSl.mjs} +16 -477
- package/dist/shared/core.DbRvwARP.mjs +5 -0
- package/dist/shared/{core.oI7caxVx.d.mts → core.Uz54YXx0.d.mts} +1 -1
- package/dist/shared/{core.CcjDE4j7.mjs → core.zj2huD5x.mjs} +17 -30
- package/dist/types/index.mjs +1 -1
- package/dist/utils/index.d.mts +3 -2
- package/dist/utils/index.mjs +5 -3
- package/package.json +19 -9
- package/src/builder/Builder.model.ts +74 -0
- package/src/builder/Builder.with.ts +20 -339
- package/src/compute-view/deployment-view/_types.ts +1 -1
- package/src/compute-view/deployment-view/predicates/relation-direct.ts +6 -7
- package/src/compute-view/deployment-view/predicates/relation-incoming.ts +2 -1
- package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +1 -1
- package/src/compute-view/dynamic-view/compute.ts +22 -43
- package/src/compute-view/index.ts +0 -1
- package/src/compute-view/relationships-view/_types.ts +7 -6
- package/src/compute-view/relationships-view/compute.ts +140 -52
- package/src/compute-view/relationships-view/index.ts +3 -0
- package/src/compute-view/relationships-view/utils.ts +44 -11
- package/src/compute-view/utils/resolve-extended-views.ts +20 -5
- package/src/compute-view/utils/view-hash.ts +1 -4
- package/src/index.ts +1 -1
- package/src/model/ElementModel.ts +2 -0
- package/src/model/view/NodeModel.ts +5 -0
- package/src/utils/object-hash.ts +13 -2
- package/dist/builder/index.d.ts +0 -509
- package/dist/compute-view/index.d.ts +0 -23
- package/dist/index.d.ts +0 -147
- package/dist/model/index.d.ts +0 -118
- package/dist/shared/core.-qjOvsEL.d.ts +0 -146
- package/dist/shared/core.30yYKXcZ.d.ts +0 -186
- package/dist/shared/core.BBJd-FqJ.mjs +0 -37
- package/dist/shared/core.BH59D8Ji.d.ts +0 -858
- package/dist/shared/core.CIbWBWW3.d.ts +0 -127
- package/dist/shared/core.Cpd5mZgF.d.ts +0 -732
- package/dist/shared/core.Dd1nCiNx.d.mts +0 -12
- package/dist/shared/core.mD0TIdz_.d.ts +0 -12
- package/dist/types/index.d.ts +0 -72
- package/dist/utils/index.d.ts +0 -458
package/dist/builder/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LastArrayElement, Split, Simplify, Writable, IfNever, TupleToUnion, Tagged, IsStringLiteral as IsStringLiteral$1, IsLiteral } from 'type-fest';
|
|
2
|
-
import { L as LikeC4Model } from '../shared/core.
|
|
2
|
+
import { L as LikeC4Model } from '../shared/core.CtloVwbo.mjs';
|
|
3
3
|
import { D as DeploymentElement, i as DeploymentRelation, ax as ModelRelation, ap as Participant, A as CustomElementExpr, B as CustomRelationExpr, bw as ViewRuleStyle, aX as AutoLayoutDirection, X as ExpressionV2, N as Expression, L as LikeC4View, b4 as DeploymentView, bh as ElementView, az as RelationshipArrowType, aC as RelationshipLineType, aB as RelationshipKindSpecification, g as DeploymentNodeKindSpecification, a9 as ParsedLikeC4ModelData } from '../shared/core.z6g06scf.mjs';
|
|
4
4
|
import { F as Fqn, m as Element, N as NonEmptyArray, p as ElementShape, x as Color, l as BorderStyle, S as ShapeSize, M as SpacingSize, O as TextSize, n as ElementKindSpecification, K as KeysOf } from '../shared/core.30yYKXcZ.mjs';
|
|
5
5
|
import { IsStringLiteral } from 'type-fest/source/is-literal';
|
|
@@ -112,6 +112,8 @@ declare function model<A extends AnyTypes, B extends AnyTypes, C extends AnyType
|
|
|
112
112
|
declare function model<A extends AnyTypes, B extends AnyTypes, C extends AnyTypes, D extends AnyTypes, E extends AnyTypes, F extends AnyTypes, G extends AnyTypes, H extends AnyTypes, I extends AnyTypes, J extends AnyTypes, K extends AnyTypes, L extends AnyTypes, M extends AnyTypes, N extends AnyTypes>(op1: (input: ModelBuilder<A>) => ModelBuilder<B>, op2: (input: ModelBuilder<B>) => ModelBuilder<C>, op3: (input: ModelBuilder<C>) => ModelBuilder<D>, op4: (input: ModelBuilder<D>) => ModelBuilder<E>, op5: (input: ModelBuilder<E>) => ModelBuilder<F>, op6: (input: ModelBuilder<F>) => ModelBuilder<G>, op7: (input: ModelBuilder<G>) => ModelBuilder<H>, op8: (input: ModelBuilder<H>) => ModelBuilder<I>, op9: (input: ModelBuilder<I>) => ModelBuilder<J>, op10: (input: ModelBuilder<J>) => ModelBuilder<K>, op11: (input: ModelBuilder<K>) => ModelBuilder<L>, op12: (input: ModelBuilder<L>) => ModelBuilder<M>, op13: (input: ModelBuilder<M>) => ModelBuilder<N>): (input: Builder<A>) => Builder<N>;
|
|
113
113
|
declare function model<A extends AnyTypes, B extends AnyTypes, C extends AnyTypes, D extends AnyTypes, E extends AnyTypes, F extends AnyTypes, G extends AnyTypes, H extends AnyTypes, I extends AnyTypes, J extends AnyTypes, K extends AnyTypes, L extends AnyTypes, M extends AnyTypes, N extends AnyTypes, O extends AnyTypes>(op1: (input: ModelBuilder<A>) => ModelBuilder<B>, op2: (input: ModelBuilder<B>) => ModelBuilder<C>, op3: (input: ModelBuilder<C>) => ModelBuilder<D>, op4: (input: ModelBuilder<D>) => ModelBuilder<E>, op5: (input: ModelBuilder<E>) => ModelBuilder<F>, op6: (input: ModelBuilder<F>) => ModelBuilder<G>, op7: (input: ModelBuilder<G>) => ModelBuilder<H>, op8: (input: ModelBuilder<H>) => ModelBuilder<I>, op9: (input: ModelBuilder<I>) => ModelBuilder<J>, op10: (input: ModelBuilder<J>) => ModelBuilder<K>, op11: (input: ModelBuilder<K>) => ModelBuilder<L>, op12: (input: ModelBuilder<L>) => ModelBuilder<M>, op13: (input: ModelBuilder<M>) => ModelBuilder<N>, op14: (input: ModelBuilder<N>) => ModelBuilder<O>): (input: Builder<A>) => Builder<O>;
|
|
114
114
|
declare function model<A extends AnyTypes, B extends AnyTypes, C extends AnyTypes, D extends AnyTypes, E extends AnyTypes, F extends AnyTypes, G extends AnyTypes, H extends AnyTypes, I extends AnyTypes, J extends AnyTypes, K extends AnyTypes, L extends AnyTypes, M extends AnyTypes, N extends AnyTypes, O extends AnyTypes, P extends AnyTypes>(op1: (input: ModelBuilder<A>) => ModelBuilder<B>, op2: (input: ModelBuilder<B>) => ModelBuilder<C>, op3: (input: ModelBuilder<C>) => ModelBuilder<D>, op4: (input: ModelBuilder<D>) => ModelBuilder<E>, op5: (input: ModelBuilder<E>) => ModelBuilder<F>, op6: (input: ModelBuilder<F>) => ModelBuilder<G>, op7: (input: ModelBuilder<G>) => ModelBuilder<H>, op8: (input: ModelBuilder<H>) => ModelBuilder<I>, op9: (input: ModelBuilder<I>) => ModelBuilder<J>, op10: (input: ModelBuilder<J>) => ModelBuilder<K>, op11: (input: ModelBuilder<K>) => ModelBuilder<L>, op12: (input: ModelBuilder<L>) => ModelBuilder<M>, op13: (input: ModelBuilder<M>) => ModelBuilder<N>, op14: (input: ModelBuilder<N>) => ModelBuilder<O>, op15: (input: ModelBuilder<O>) => ModelBuilder<P>): (input: Builder<A>) => Builder<P>;
|
|
115
|
+
declare function model<A extends AnyTypes, B extends AnyTypes, C extends AnyTypes, D extends AnyTypes, E extends AnyTypes, F extends AnyTypes, G extends AnyTypes, H extends AnyTypes, I extends AnyTypes, J extends AnyTypes, K extends AnyTypes, L extends AnyTypes, M extends AnyTypes, N extends AnyTypes, O extends AnyTypes, P extends AnyTypes, Q extends AnyTypes>(op1: (input: ModelBuilder<A>) => ModelBuilder<B>, op2: (input: ModelBuilder<B>) => ModelBuilder<C>, op3: (input: ModelBuilder<C>) => ModelBuilder<D>, op4: (input: ModelBuilder<D>) => ModelBuilder<E>, op5: (input: ModelBuilder<E>) => ModelBuilder<F>, op6: (input: ModelBuilder<F>) => ModelBuilder<G>, op7: (input: ModelBuilder<G>) => ModelBuilder<H>, op8: (input: ModelBuilder<H>) => ModelBuilder<I>, op9: (input: ModelBuilder<I>) => ModelBuilder<J>, op10: (input: ModelBuilder<J>) => ModelBuilder<K>, op11: (input: ModelBuilder<K>) => ModelBuilder<L>, op12: (input: ModelBuilder<L>) => ModelBuilder<M>, op13: (input: ModelBuilder<M>) => ModelBuilder<N>, op14: (input: ModelBuilder<N>) => ModelBuilder<O>, op15: (input: ModelBuilder<O>) => ModelBuilder<P>, op16: (input: ModelBuilder<P>) => ModelBuilder<Q>): (input: Builder<A>) => Builder<Q>;
|
|
116
|
+
declare function model<A extends AnyTypes, B extends AnyTypes, C extends AnyTypes, D extends AnyTypes, E extends AnyTypes, F extends AnyTypes, G extends AnyTypes, H extends AnyTypes, I extends AnyTypes, J extends AnyTypes, K extends AnyTypes, L extends AnyTypes, M extends AnyTypes, N extends AnyTypes, O extends AnyTypes, P extends AnyTypes, Q extends AnyTypes, R extends AnyTypes>(op1: (input: ModelBuilder<A>) => ModelBuilder<B>, op2: (input: ModelBuilder<B>) => ModelBuilder<C>, op3: (input: ModelBuilder<C>) => ModelBuilder<D>, op4: (input: ModelBuilder<D>) => ModelBuilder<E>, op5: (input: ModelBuilder<E>) => ModelBuilder<F>, op6: (input: ModelBuilder<F>) => ModelBuilder<G>, op7: (input: ModelBuilder<G>) => ModelBuilder<H>, op8: (input: ModelBuilder<H>) => ModelBuilder<I>, op9: (input: ModelBuilder<I>) => ModelBuilder<J>, op10: (input: ModelBuilder<J>) => ModelBuilder<K>, op11: (input: ModelBuilder<K>) => ModelBuilder<L>, op12: (input: ModelBuilder<L>) => ModelBuilder<M>, op13: (input: ModelBuilder<M>) => ModelBuilder<N>, op14: (input: ModelBuilder<N>) => ModelBuilder<O>, op15: (input: ModelBuilder<O>) => ModelBuilder<P>, op16: (input: ModelBuilder<P>) => ModelBuilder<Q>, op17: (input: ModelBuilder<Q>) => ModelBuilder<R>): (input: Builder<A>) => Builder<R>;
|
|
115
117
|
type RelationshipHelper<Props = unknown> = <T extends AnyTypes, From extends string & T['Fqn'], To extends string & T['Fqn']>(from: From, to: To, titleOrProps?: string | Props) => (builder: ModelBuilder<T>) => ModelBuilder<T>;
|
|
116
118
|
type NestedRelationshipHelper<Props = unknown> = <T extends AnyTypesNested, To extends string & T['Fqn']>(to: To, titleOrProps?: string | Props) => (builder: ModelBuilder<T>) => ModelBuilder<T>;
|
|
117
119
|
type AddElementHelper<T = unknown> = <const Id extends string>(id: ValidId<Id>, titleOrProps?: string | T) => AddElement<Id>;
|
package/dist/builder/index.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { i, l, d, L as LikeC4Model } from '../shared/core.
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { a as i, l, d, L as LikeC4Model } from '../shared/core.zj2huD5x.mjs';
|
|
2
|
+
import { m, l as l$1, i as i$1 } from '../shared/core.Cu-UdkSl.mjs';
|
|
3
|
+
import { f as t, n as nameFromFqn, g as isSameHierarchy, p as parentFqn, h as t$1 } from '../shared/core.CQXU9DF7.mjs';
|
|
4
|
+
import { o, b as isElementPredicateExpr, D as DefaultElementShape, c as DefaultThemeColor, n as n$1, d as DeploymentElement, e as isScopedElementView } from '../shared/core.BMep80lJ.mjs';
|
|
5
|
+
import { u } from '../shared/core.DbRvwARP.mjs';
|
|
6
|
+
import { i as invariant } from '../shared/core.C-YXI-43.mjs';
|
|
5
7
|
|
|
6
8
|
function n(...r){return u(Object.fromEntries,r)}
|
|
7
9
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export { C as ComputeViewResult, c as computeView, a as computeViews, u as unsafeComputeView } from '../shared/core.
|
|
2
|
-
export { c as computeRelationshipsView } from '../shared/core.Dd1nCiNx.mjs';
|
|
1
|
+
export { C as ComputeViewResult, c as computeView, a as computeViews, u as unsafeComputeView } from '../shared/core.CtloVwbo.mjs';
|
|
3
2
|
import { L as LikeC4View, C as ComputedLikeC4ModelData, a as ComputedView } from '../shared/core.z6g06scf.mjs';
|
|
4
3
|
import 'type-fest';
|
|
5
4
|
import '../shared/core.30yYKXcZ.mjs';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { G as Graph, r, w as willCreateCycle, t as topologicalSortExports, i as i$1, l } from '../shared/core.
|
|
2
|
-
export { c as computeView,
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { u } from '../shared/core.
|
|
1
|
+
import { G as Graph, r, w as willCreateCycle, t as topologicalSortExports, i as i$1, a as i$2, l } from '../shared/core.zj2huD5x.mjs';
|
|
2
|
+
export { c as computeView, b as computeViews, u as unsafeComputeView } from '../shared/core.zj2huD5x.mjs';
|
|
3
|
+
import { i as isExtendsElementView, a as isElementView } from '../shared/core.BMep80lJ.mjs';
|
|
4
|
+
import { e as isNonEmptyArray } from '../shared/core.CQXU9DF7.mjs';
|
|
5
|
+
import { i, m } from '../shared/core.Cu-UdkSl.mjs';
|
|
6
|
+
import { u } from '../shared/core.DbRvwARP.mjs';
|
|
7
7
|
|
|
8
8
|
function y(...t){return u(f,t)}function f(t,e){if(!i(e,1))return {...t};if(!i(e,2)){let{[e[0]]:r,...m}=t;return m}let o={...t};for(let r of e)delete o[r];return o}
|
|
9
9
|
|
|
@@ -43,9 +43,21 @@ function resolveRulesExtendedViews(unresolvedViews) {
|
|
|
43
43
|
if (!extendsFrom || !isElementView(extendsFrom)) {
|
|
44
44
|
return acc;
|
|
45
45
|
}
|
|
46
|
+
const tags = i$1([
|
|
47
|
+
...extendsFrom.tags ?? [],
|
|
48
|
+
...view.tags ?? []
|
|
49
|
+
]);
|
|
50
|
+
const links = [
|
|
51
|
+
...extendsFrom.links ?? [],
|
|
52
|
+
...view.links ?? []
|
|
53
|
+
];
|
|
46
54
|
acc[view.id] = {
|
|
47
55
|
...extendsFrom,
|
|
48
56
|
...view,
|
|
57
|
+
title: view.title ?? extendsFrom.title ?? null,
|
|
58
|
+
description: view.description ?? extendsFrom.description ?? null,
|
|
59
|
+
tags: isNonEmptyArray(tags) ? tags : null,
|
|
60
|
+
links: isNonEmptyArray(links) ? links : null,
|
|
49
61
|
rules: [...extendsFrom.rules, ...view.rules]
|
|
50
62
|
};
|
|
51
63
|
return acc;
|
|
@@ -72,7 +84,7 @@ function withReadableEdges({ edges, nodes, ...view }, separator = ":") {
|
|
|
72
84
|
function viewsWithReadableEdges({ views, ...model }) {
|
|
73
85
|
return {
|
|
74
86
|
...model,
|
|
75
|
-
views: i$
|
|
87
|
+
views: i$2(views, (v) => y(withReadableEdges(v), ["nodeIds", "edgeIds"]))
|
|
76
88
|
};
|
|
77
89
|
}
|
|
78
90
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { A as AnyAux, E as ElementModel, R as RelationshipModel, L as LikeC4Model } from '../../shared/core.CtloVwbo.mjs';
|
|
2
|
+
import 'type-fest';
|
|
3
|
+
import '../../shared/core.z6g06scf.mjs';
|
|
4
|
+
import '../../shared/core.30yYKXcZ.mjs';
|
|
5
|
+
|
|
6
|
+
type RelationshipsViewData<M extends AnyAux = AnyAux> = {
|
|
7
|
+
incomers: ReadonlySet<ElementModel<M>>;
|
|
8
|
+
incoming: ReadonlySet<RelationshipModel<M>>;
|
|
9
|
+
subjects: ReadonlySet<ElementModel<M>>;
|
|
10
|
+
outgoing: ReadonlySet<RelationshipModel<M>>;
|
|
11
|
+
outgoers: ReadonlySet<ElementModel<M>>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
declare function computeRelationshipsView<const M extends AnyAux>(subjectId: NoInfer<M['Element']>, likec4model: LikeC4Model<M>, scopeViewId: NoInfer<M['View']> | null, scope?: 'global' | 'view'): RelationshipsViewData<M>;
|
|
15
|
+
|
|
16
|
+
declare function treeFromElements<const M extends AnyAux>(elements: Iterable<ElementModel<M>>): {
|
|
17
|
+
sorted: readonly ElementModel<M>[];
|
|
18
|
+
byId: (id: M["Element"]) => ElementModel<M>;
|
|
19
|
+
root: ReadonlySet<ElementModel<M>>;
|
|
20
|
+
parent: (el: ElementModel<M>) => ElementModel<M> | null;
|
|
21
|
+
children: (el: ElementModel<M>) => ReadonlyArray<ElementModel<M>>;
|
|
22
|
+
/**
|
|
23
|
+
* Flattens the tree structure by removing redundant hierarchy levels.
|
|
24
|
+
* @example
|
|
25
|
+
* A
|
|
26
|
+
* └── B
|
|
27
|
+
* ├── C
|
|
28
|
+
* │ └── D
|
|
29
|
+
* │ └── E
|
|
30
|
+
* └── F
|
|
31
|
+
* └── G
|
|
32
|
+
* becomes
|
|
33
|
+
* A
|
|
34
|
+
* ├── C
|
|
35
|
+
* │ └── E
|
|
36
|
+
* └── F
|
|
37
|
+
* └── G
|
|
38
|
+
*/
|
|
39
|
+
flatten: () => Set<ElementModel<M>>;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { type RelationshipsViewData, computeRelationshipsView, treeFromElements };
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { s as sortParentsFirst, D as DefaultMap, i as isDescendantOf, a as isAncestor, t as toSet, b as toArray, c as ifilter, C, d as imap } from '../../shared/core.CQXU9DF7.mjs';
|
|
2
|
+
import { n as nonNullable, i as invariant } from '../../shared/core.C-YXI-43.mjs';
|
|
3
|
+
|
|
4
|
+
function treeFromElements(elements) {
|
|
5
|
+
const sorted = sortParentsFirst([...elements]);
|
|
6
|
+
const root = new Set(sorted);
|
|
7
|
+
const map = new Map(sorted.map((e) => [e._literalId, e]));
|
|
8
|
+
const parents = new DefaultMap(() => null);
|
|
9
|
+
const children = sorted.reduce((acc, parent, index, all) => {
|
|
10
|
+
acc.set(
|
|
11
|
+
parent,
|
|
12
|
+
all.slice(index + 1).filter(isDescendantOf(parent)).map((e) => {
|
|
13
|
+
root.delete(e);
|
|
14
|
+
return e;
|
|
15
|
+
}).reduce((acc2, el) => {
|
|
16
|
+
if (!acc2.some(isAncestor(el))) {
|
|
17
|
+
acc2.push(el);
|
|
18
|
+
parents.set(el, parent);
|
|
19
|
+
}
|
|
20
|
+
return acc2;
|
|
21
|
+
}, [])
|
|
22
|
+
);
|
|
23
|
+
return acc;
|
|
24
|
+
}, new DefaultMap(() => []));
|
|
25
|
+
return {
|
|
26
|
+
sorted,
|
|
27
|
+
byId: (id) => nonNullable(map.get(id), `Element not found by id: ${id}`),
|
|
28
|
+
root,
|
|
29
|
+
parent: (el) => parents.get(el),
|
|
30
|
+
children: (el) => children.get(el),
|
|
31
|
+
/**
|
|
32
|
+
* Flattens the tree structure by removing redundant hierarchy levels.
|
|
33
|
+
* @example
|
|
34
|
+
* A
|
|
35
|
+
* └── B
|
|
36
|
+
* ├── C
|
|
37
|
+
* │ └── D
|
|
38
|
+
* │ └── E
|
|
39
|
+
* └── F
|
|
40
|
+
* └── G
|
|
41
|
+
* becomes
|
|
42
|
+
* A
|
|
43
|
+
* ├── C
|
|
44
|
+
* │ └── E
|
|
45
|
+
* └── F
|
|
46
|
+
* └── G
|
|
47
|
+
*/
|
|
48
|
+
flatten: () => {
|
|
49
|
+
return /* @__PURE__ */ new Set([
|
|
50
|
+
...root,
|
|
51
|
+
...sorted.reduce((acc, el) => {
|
|
52
|
+
const _children = children.get(el);
|
|
53
|
+
if (_children.length === 0) {
|
|
54
|
+
acc.push(el);
|
|
55
|
+
return acc;
|
|
56
|
+
}
|
|
57
|
+
if (_children.length > 1) {
|
|
58
|
+
acc.push(..._children);
|
|
59
|
+
}
|
|
60
|
+
return acc;
|
|
61
|
+
}, [])
|
|
62
|
+
]);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const finalize = (elements, explicits) => {
|
|
68
|
+
if (elements.size > 2 && explicits.size !== elements.size) {
|
|
69
|
+
return new Set(sortParentsFirst([
|
|
70
|
+
...treeFromElements(elements).flatten(),
|
|
71
|
+
...explicits
|
|
72
|
+
]));
|
|
73
|
+
}
|
|
74
|
+
if (elements.size > 1) {
|
|
75
|
+
return new Set(sortParentsFirst([...elements]));
|
|
76
|
+
}
|
|
77
|
+
return elements;
|
|
78
|
+
};
|
|
79
|
+
function computeRelationships(subject, others, relationships) {
|
|
80
|
+
const isOther = (e) => others.has(e);
|
|
81
|
+
let subjects = /* @__PURE__ */ new Set([subject]);
|
|
82
|
+
const explicits = {
|
|
83
|
+
incomers: /* @__PURE__ */ new Set(),
|
|
84
|
+
subjects: /* @__PURE__ */ new Set([subject]),
|
|
85
|
+
outgoers: /* @__PURE__ */ new Set()
|
|
86
|
+
};
|
|
87
|
+
let incomers = new Set(relationships.incoming.flatMap((r) => {
|
|
88
|
+
explicits.subjects.add(r.target);
|
|
89
|
+
explicits.incomers.add(r.source);
|
|
90
|
+
subjects.add(r.target);
|
|
91
|
+
if (r.target !== subject) {
|
|
92
|
+
let target = r.target.parent;
|
|
93
|
+
while (target && target !== subject) {
|
|
94
|
+
subjects.add(target);
|
|
95
|
+
target = target.parent;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
let source = r.source;
|
|
99
|
+
const incomerBranch = [];
|
|
100
|
+
while (true) {
|
|
101
|
+
incomerBranch.push(source);
|
|
102
|
+
if (isOther(source) || !source.parent) {
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
source = source.parent;
|
|
106
|
+
}
|
|
107
|
+
return incomerBranch;
|
|
108
|
+
}));
|
|
109
|
+
let outgoers = new Set(relationships.outgoing.flatMap((r) => {
|
|
110
|
+
explicits.subjects.add(r.source);
|
|
111
|
+
explicits.outgoers.add(r.target);
|
|
112
|
+
subjects.add(r.source);
|
|
113
|
+
if (r.source !== subject) {
|
|
114
|
+
let source = r.source.parent;
|
|
115
|
+
while (source && source !== subject) {
|
|
116
|
+
subjects.add(source);
|
|
117
|
+
source = source.parent;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
let target = r.target;
|
|
121
|
+
const outgoerBranch = [];
|
|
122
|
+
while (true) {
|
|
123
|
+
outgoerBranch.push(target);
|
|
124
|
+
if (isOther(target) || !target.parent) {
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
target = target.parent;
|
|
128
|
+
}
|
|
129
|
+
return outgoerBranch;
|
|
130
|
+
}));
|
|
131
|
+
return {
|
|
132
|
+
incomers: finalize(incomers, explicits.incomers),
|
|
133
|
+
incoming: new Set(relationships.incoming),
|
|
134
|
+
subjects: finalize(subjects, explicits.subjects),
|
|
135
|
+
outgoing: new Set(relationships.outgoing),
|
|
136
|
+
outgoers: finalize(outgoers, explicits.outgoers)
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function computeRelationshipsView(subjectId, likec4model, scopeViewId, scope = "global") {
|
|
140
|
+
const view = scopeViewId ? likec4model.findView(scopeViewId) : null;
|
|
141
|
+
if (scope === "view") {
|
|
142
|
+
invariant(
|
|
143
|
+
view,
|
|
144
|
+
'Scope view id is required when scope is "view"'
|
|
145
|
+
);
|
|
146
|
+
return computeScopedRelationshipsView(subjectId, view, likec4model);
|
|
147
|
+
}
|
|
148
|
+
const subject = likec4model.element(subjectId);
|
|
149
|
+
const subjectSiblings = toSet(subject.ascendingSiblings());
|
|
150
|
+
return computeRelationships(
|
|
151
|
+
subject,
|
|
152
|
+
subjectSiblings,
|
|
153
|
+
{
|
|
154
|
+
incoming: [...subject.incoming()],
|
|
155
|
+
outgoing: [...subject.outgoing()]
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
function computeScopedRelationshipsView(subjectId, view, likec4model) {
|
|
160
|
+
const subject = likec4model.element(subjectId);
|
|
161
|
+
let relationships = {
|
|
162
|
+
incoming: toArray(ifilter(subject.incoming(), (r) => view.includesRelation(r.id))),
|
|
163
|
+
outgoing: toArray(ifilter(subject.outgoing(), (r) => view.includesRelation(r.id)))
|
|
164
|
+
};
|
|
165
|
+
const isDescendant = isDescendantOf(subject);
|
|
166
|
+
const others = /* @__PURE__ */ new Set([
|
|
167
|
+
...subject.ascendingSiblings(),
|
|
168
|
+
...C(
|
|
169
|
+
view.elements(),
|
|
170
|
+
imap((e) => e.element),
|
|
171
|
+
ifilter((e) => e !== subject && isDescendant(e))
|
|
172
|
+
)
|
|
173
|
+
]);
|
|
174
|
+
return computeRelationships(
|
|
175
|
+
subject,
|
|
176
|
+
others,
|
|
177
|
+
relationships
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export { computeRelationshipsView, treeFromElements };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { H as HexColorLiteral, T as ThemeColorValues, L as LikeC4Theme } from './shared/core.30yYKXcZ.mjs';
|
|
2
2
|
export { A as AsFqn, l as BorderStyle, B as BorderStyles, x as Color, y as ColorLiteral, C as CustomColor, D as DefaultElementShape, f as DefaultPaddingSize, g as DefaultShapeSize, h as DefaultTextSize, i as DefaultThemeColor, m as Element, j as ElementKind, n as ElementKindSpecification, o as ElementKindSpecificationStyle, p as ElementShape, k as ElementShapes, q as ElementStyle, G as ElementThemeColorValues, z as ElementThemeColors, E as ExclusiveUnion, F as Fqn, I as IconUrl, a as IteratorLike, K as KeysOf, r as Link, c as NTuple, N as NonEmptyArray, b as NonEmptyReadonlyArray, P as Point, d as Predicate, e as ProjectId, J as RelationshipThemeColorValues, R as RelationshipThemeColors, S as ShapeSize, M as SpacingSize, s as Tag, t as TagSpec, O as TextSize, Q as ThemeColor, w as ThemeColors, u as TypedElement, X as XYPoint, v as isThemeColor } from './shared/core.30yYKXcZ.mjs';
|
|
3
3
|
export { aw as AbstractRelation, ah as AllNever, ai as AndOperator, a5 as AnyParsedLikeC4ModelData, aX as AutoLayoutDirection, a_ as BBox, aY as BasicElementView, aZ as BasicView, a$ as ComputedDeploymentView, b0 as ComputedDynamicView, b1 as ComputedEdge, b2 as ComputedElementView, C as ComputedLikeC4ModelData, aD as ComputedNode, a as ComputedView, b3 as CustomColorDefinitions, A as CustomElementExpr, B as CustomRelationExpr, at as DefaultArrowType, au as DefaultLineStyle, av as DefaultRelationshipColor, b as DeployedInstance, D as DeploymentElement, c as DeploymentElementStyle, d as DeploymentNode, f as DeploymentNodeKind, g as DeploymentNodeKindSpecification, h as DeploymentRef, i as DeploymentRelation, b4 as DeploymentView, b5 as DeploymentViewRule, b6 as DeploymentViewRulePredicate, b7 as DeploymentViewRuleStyle, b8 as DiagramEdge, aE as DiagramNode, b9 as DiagramView, E as DirectRelationExpr, ba as DynamicView, bb as DynamicViewIncludeRule, bc as DynamicViewParallelSteps, bd as DynamicViewRule, be as DynamicViewStep, bf as DynamicViewStepOrParallel, bg as EdgeId, F as ElementExpression, G as ElementKindExpr, bA as ElementNotation, H as ElementPredicateExpression, I as ElementRefExpr, J as ElementTagExpr, bh as ElementView, K as ElementWhereExpr, aj as EqualOperator, M as ExpandedElementExpr, e as Expr, N as Expression, X as ExpressionV2, bi as ExtendsElementView, ak as Filterable, Y as FqnExpr, Z as FqnRef, a6 as GenericLikeC4ModelData, $ as GlobalDynamicPredicates, a0 as GlobalPredicateId, a1 as GlobalPredicates, a2 as GlobalStyleID, a3 as GlobalStyles, Q as InOutExpr, O as IncomingExpr, al as KindEqual, a7 as LayoutedLikeC4ModelData, a8 as LikeC4ModelDump, L as LikeC4View, a4 as ModelGlobals, ax as ModelRelation, bj as NodeId, R as NonWilcard, am as NotOperator, an as OperatorPredicate, ao as OrOperator, S as OutgoingExpr, a9 as ParsedLikeC4ModelData, ap as Participant, aq as ParticipantOperator, P as PredicateSelector, _ as RelationExpr, T as RelationExpression, ay as RelationId, U as RelationPredicateExpression, V as RelationWhereExpr, az as RelationshipArrowType, aA as RelationshipKind, aB as RelationshipKindSpecification, aC as RelationshipLineType, bk as ScopedElementView, bl as StepEdgeId, bm as StepEdgeIdLiteral, ar as TagEqual, bn as ViewAutoLayout, bo as ViewId, bp as ViewManualLayout, bq as ViewRule, br as ViewRuleAutoLayout, bs as ViewRuleGlobalPredicateRef, bt as ViewRuleGlobalStyle, bu as ViewRuleGroup, bv as ViewRulePredicate, bw as ViewRuleStyle, bx as ViewRuleStyleOrGlobalRef, by as ViewWithHash, bz as ViewWithNotation, as as WhereOperator, W as WildcardExpr, aF as extractStep, aG as getBBoxCenter, aH as getParallelStepsPrefix, aa as isAndOperator, aI as isAutoLayoutDirection, j as isCustomElement, k as isCustomRelationExpr, aJ as isDeploymentView, aK as isDynamicView, aL as isDynamicViewParallelSteps, l as isElement, m as isElementKindExpr, n as isElementPredicateExpr, o as isElementRef, p as isElementTagExpr, aM as isElementView, q as isElementWhere, r as isExpandedElementExpr, aN as isExtendsElementView, t as isInOut, s as isIncoming, ab as isKindEqual, ac as isNotOperator, ad as isOrOperator, u as isOutgoing, ae as isParticipantOperator, v as isRelation, w as isRelationExpression, x as isRelationPredicateExpr, y as isRelationWhere, aO as isScopedElementView, aP as isStepEdgeId, af as isTagEqual, aQ as isViewRuleAutoLayout, aR as isViewRuleGlobalPredicateRef, aS as isViewRuleGlobalStyle, aT as isViewRuleGroup, aU as isViewRulePredicate, aV as isViewRuleStyle, z as isWildcard, aW as stepEdgeId, ag as whereOperatorAsPredicate } from './shared/core.z6g06scf.mjs';
|
|
4
|
-
export { BiMap, DefaultMap, DefaultWeakMap, LinkedList, MultiMap, Queue, Stack, commonHead, compareNatural, compareRelations, delay, difference, equalsSet, getOrCreate, hasAtLeast, ifilter, ifind, iflat, imap, intersection, ireduce, isIterable, isNonEmptyArray, isString, isome, iunique, stringHash, symmetricDifference, toArray, toSet, union } from './utils/index.mjs';
|
|
5
|
-
export { A as AnyAux, b as Aux, C as ComputeViewResult, D as DeployedInstanceModel, d as DeploymentElementModel, e as DeploymentNodeModel, f as DeploymentRelationModel, g as EdgeModel, E as ElementModel, h as LikeC4DeploymentModel, L as LikeC4Model, i as LikeC4ViewModel, N as NodeModel, R as RelationshipModel, c as computeView, a as computeViews, u as unsafeComputeView } from './shared/core.
|
|
6
|
-
export { C as Connection, a as ConnectionModel, D as DeploymentConnectionModel } from './shared/core.
|
|
7
|
-
export { c as computeRelationshipsView } from './shared/core.Dd1nCiNx.mjs';
|
|
4
|
+
export { BiMap, DefaultMap, DefaultWeakMap, LinkedList, MultiMap, Queue, Stack, commonHead, compareNatural, compareRelations, delay, difference, equalsSet, getOrCreate, hasAtLeast, ifilter, ifind, iflat, imap, intersection, ireduce, isIterable, isNonEmptyArray, isString, isome, iunique, objectHash, stringHash, symmetricDifference, toArray, toSet, union } from './utils/index.mjs';
|
|
5
|
+
export { A as AnyAux, b as Aux, C as ComputeViewResult, D as DeployedInstanceModel, d as DeploymentElementModel, e as DeploymentNodeModel, f as DeploymentRelationModel, g as EdgeModel, E as ElementModel, h as LikeC4DeploymentModel, L as LikeC4Model, i as LikeC4ViewModel, N as NodeModel, R as RelationshipModel, c as computeView, a as computeViews, u as unsafeComputeView } from './shared/core.CtloVwbo.mjs';
|
|
6
|
+
export { C as Connection, a as ConnectionModel, D as DeploymentConnectionModel } from './shared/core.Uz54YXx0.mjs';
|
|
8
7
|
export { OverviewGraph, ViewChange } from './types/index.mjs';
|
|
9
8
|
export { I as IterableContainer, R as ReorderedArray, a as ancestorsFqn, c as commonAncestor, b as compareByFqnHierarchically, d as compareFqnHierarchically, h as hierarchyDistance, e as hierarchyLevel, i as isAncestor, f as isDescendantOf, g as isSameHierarchy, n as nameFromFqn, p as parentFqn, s as sortByFqnHierarchically, j as sortNaturalByFqn, k as sortParentsFirst } from './shared/core.HKn0jlo_.mjs';
|
|
10
|
-
export { default as objectHash } from '/home/runner/work/likec4/likec4/node_modules/.pnpm/@types+object-hash@3.0.6/node_modules/@types/object-hash/index.d.ts';
|
|
11
9
|
import 'type-fest';
|
|
12
10
|
|
|
13
11
|
declare const ElementColors: {
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { i as invariant,
|
|
2
|
-
export { A as AsFqn, B as BorderStyles, V as ComputedNode, W as ComputedView, S as DefaultArrowType, D as DefaultElementShape, T as DefaultLineStyle, g as DefaultPaddingSize, U as DefaultRelationshipColor, h as DefaultShapeSize, j as DefaultTextSize, c as DefaultThemeColor, d as DeploymentElement, X as DiagramNode, E as ElementKind, k as ElementShapes, f as Expr, H as ExpressionV2, I as FqnExpr, J as FqnRef, R as RelationExpr, Y as extractStep, Z as getBBoxCenter, _ as getParallelStepsPrefix, K as isAndOperator, $ as isAutoLayoutDirection, l as isCustomElement, m as isCustomRelationExpr, a0 as isDeploymentView, a1 as isDynamicView, a2 as isDynamicViewParallelSteps, p as isElement, q as isElementKindExpr, b as isElementPredicateExpr, r as isElementRef, s as isElementTagExpr, a as isElementView, t as isElementWhere, u as isExpandedElementExpr, i as isExtendsElementView, w as isInOut, v as isIncoming, L as isKindEqual, M as isNotOperator, N as isOrOperator, x as isOutgoing, O as isParticipantOperator, y as isRelation, z as isRelationExpression, C as isRelationPredicateExpr, F as isRelationWhere, e as isScopedElementView, a3 as isStepEdgeId, P as isTagEqual, a4 as isViewRuleAutoLayout, a5 as isViewRuleGlobalPredicateRef, a6 as isViewRuleGlobalStyle, a7 as isViewRuleGroup, a8 as isViewRulePredicate, a9 as isViewRuleStyle, G as isWildcard, aa as stepEdgeId, Q as whereOperatorAsPredicate } from './shared/core.
|
|
3
|
-
export { C as Connection,
|
|
4
|
-
export { c as computeRelationshipsView } from './shared/core.BBJd-FqJ.mjs';
|
|
1
|
+
export { i as invariant, n as nonNullable, a as nonexhaustive } from './shared/core.C-YXI-43.mjs';
|
|
2
|
+
export { A as AsFqn, B as BorderStyles, V as ComputedNode, W as ComputedView, S as DefaultArrowType, D as DefaultElementShape, T as DefaultLineStyle, g as DefaultPaddingSize, U as DefaultRelationshipColor, h as DefaultShapeSize, j as DefaultTextSize, c as DefaultThemeColor, d as DeploymentElement, X as DiagramNode, E as ElementKind, k as ElementShapes, f as Expr, H as ExpressionV2, I as FqnExpr, J as FqnRef, R as RelationExpr, Y as extractStep, Z as getBBoxCenter, _ as getParallelStepsPrefix, K as isAndOperator, $ as isAutoLayoutDirection, l as isCustomElement, m as isCustomRelationExpr, a0 as isDeploymentView, a1 as isDynamicView, a2 as isDynamicViewParallelSteps, p as isElement, q as isElementKindExpr, b as isElementPredicateExpr, r as isElementRef, s as isElementTagExpr, a as isElementView, t as isElementWhere, u as isExpandedElementExpr, i as isExtendsElementView, w as isInOut, v as isIncoming, L as isKindEqual, M as isNotOperator, N as isOrOperator, x as isOutgoing, O as isParticipantOperator, y as isRelation, z as isRelationExpression, C as isRelationPredicateExpr, F as isRelationWhere, e as isScopedElementView, a3 as isStepEdgeId, P as isTagEqual, a4 as isViewRuleAutoLayout, a5 as isViewRuleGlobalPredicateRef, a6 as isViewRuleGlobalStyle, a7 as isViewRuleGroup, a8 as isViewRulePredicate, a9 as isViewRuleStyle, G as isWildcard, aa as stepEdgeId, Q as whereOperatorAsPredicate } from './shared/core.BMep80lJ.mjs';
|
|
3
|
+
export { C as Connection, e as ConnectionModel, D as DeployedInstanceModel, f as DeploymentConnectionModel, g as DeploymentNodeModel, h as DeploymentRelationModel, E as EdgeModel, j as ElementModel, k as LikeC4DeploymentModel, L as LikeC4Model, m as LikeC4ViewModel, N as NodeModel, R as RelationshipModel, c as computeView, b as computeViews, u as unsafeComputeView } from './shared/core.zj2huD5x.mjs';
|
|
5
4
|
export { ThemeColors, isThemeColor } from './types/index.mjs';
|
|
6
5
|
export { BiMap, DefaultWeakMap, LinkedList, MultiMap, Queue, compareRelations, delay, ireduce } from './utils/index.mjs';
|
|
7
|
-
export { D as DefaultMap,
|
|
6
|
+
export { D as DefaultMap, l as ancestorsFqn, m as commonAncestor, o as compareByFqnHierarchically, q as compareFqnHierarchically, k as compareNatural, r as hierarchyDistance, u as hierarchyLevel, c as ifilter, d as imap, a as isAncestor, i as isDescendantOf, e as isNonEmptyArray, g as isSameHierarchy, x as isString, n as nameFromFqn, p as parentFqn, v as sortByFqnHierarchically, w as sortNaturalByFqn, s as sortParentsFirst, b as toArray, t as toSet } from './shared/core.CQXU9DF7.mjs';
|
|
7
|
+
export { S as Stack, c as commonHead, h as difference, j as equalsSet, g as getOrCreate, i as hasAtLeast, a as ifind, b as iflat, k as intersection, d as isIterable, e as isome, f as iunique, o as objectHash, n as stringHash, s as symmetricDifference, u as union } from './shared/core.Cu-UdkSl.mjs';
|
|
8
8
|
|
|
9
9
|
const { min: min$4, max: max$4 } = Math;
|
|
10
10
|
|
package/dist/model/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as AnyAux, d as DeploymentElementModel, E as ElementModel, D as DeployedInstanceModel, e as DeploymentNodeModel } from '../shared/core.
|
|
2
|
-
export { b as Aux, f as DeploymentRelationModel, g as EdgeModel, h as LikeC4DeploymentModel, L as LikeC4Model, i as LikeC4ViewModel, N as NodeModel, R as RelationshipModel } from '../shared/core.
|
|
3
|
-
import { C as Connection, D as DeploymentConnectionModel, a as ConnectionModel } from '../shared/core.
|
|
1
|
+
import { A as AnyAux, d as DeploymentElementModel, E as ElementModel, D as DeployedInstanceModel, e as DeploymentNodeModel } from '../shared/core.CtloVwbo.mjs';
|
|
2
|
+
export { b as Aux, f as DeploymentRelationModel, g as EdgeModel, h as LikeC4DeploymentModel, L as LikeC4Model, i as LikeC4ViewModel, N as NodeModel, R as RelationshipModel } from '../shared/core.CtloVwbo.mjs';
|
|
3
|
+
import { C as Connection, D as DeploymentConnectionModel, a as ConnectionModel } from '../shared/core.Uz54YXx0.mjs';
|
|
4
4
|
import { I as IterableContainer, R as ReorderedArray } from '../shared/core.HKn0jlo_.mjs';
|
|
5
5
|
import 'type-fest';
|
|
6
6
|
import '../shared/core.z6g06scf.mjs';
|
package/dist/model/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as Connection,
|
|
1
|
+
export { C as Connection, e as ConnectionModel, D as DeployedInstanceModel, f as DeploymentConnectionModel, g as DeploymentNodeModel, h as DeploymentRelationModel, E as EdgeModel, j as ElementModel, k as LikeC4DeploymentModel, L as LikeC4Model, m as LikeC4ViewModel, N as NodeModel, R as RelationshipModel, n as deploymentConnection, o as differenceConnections, p as findAscendingConnections, q as findDeepestNestedConnection, s as findDescendantConnections, v as hasSameSource, x as hasSameSourceTarget, y as hasSameTarget, z as isAnyInOut, M as isDeployedInstance, O as isDeploymentNode, A as isIncoming, B as isNestedConnection, F as isOutgoing, H as mergeConnections, I as modelConnection, J as sortConnectionsByBoundaryHierarchy, K as sortDeepestFirst } from '../shared/core.zj2huD5x.mjs';
|
|
@@ -15,8 +15,4 @@ function nonexhaustive(value) {
|
|
|
15
15
|
throw new Error(`NonExhaustive value: ${value}`);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function u(r,n,o){let a=r.length-n.length;if(a===0)return r(...n);if(a===1)return u$1(r,n,o);throw new Error("Wrong number of arguments")}
|
|
21
|
-
|
|
22
|
-
export { nonNullable as a, invariant as i, nonexhaustive as n, u };
|
|
18
|
+
export { nonexhaustive as a, invariant as i, nonNullable as n };
|