@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
|
@@ -1,79 +1,108 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
1
|
+
import { ct as toComputed, ht as _type, mt as _stage, n as Any, o as AnyParsed, wt as NonEmptyArray } from "../_chunks/_aux.mjs";
|
|
2
|
+
import "../_chunks/scalar.mjs";
|
|
3
|
+
import "../_chunks/expression.mjs";
|
|
4
|
+
import "../_chunks/fqnRef.mjs";
|
|
5
|
+
import { t as ModelExpression } from "../_chunks/expression-model.mjs";
|
|
6
|
+
import { $t as AnyIncludePredicate, J as ComputedEdge, Qt as AnyExcludePredicate, X as ComputedNode, c as ComputedLikeC4ModelData, d as ParsedLikeC4ModelData, h as ParsedView, on as ViewAutoLayout, p as ComputedView, rn as BaseViewProperties } from "../_chunks/index2.mjs";
|
|
7
|
+
import "../_chunks/RichText.mjs";
|
|
8
|
+
import "../_chunks/index3.mjs";
|
|
9
|
+
import { n as LikeC4Model } from "../_chunks/LikeC4Model.mjs";
|
|
10
|
+
import { B as ViewPredicate } from "../_chunks/_types.mjs";
|
|
11
|
+
import "../_chunks/const.mjs";
|
|
12
|
+
import "../_chunks/find.mjs";
|
|
13
|
+
import "../_chunks/find2.mjs";
|
|
14
|
+
import "../_chunks/index4.mjs";
|
|
15
|
+
import "../_chunks/index5.mjs";
|
|
16
|
+
import { a as LayoutedProjectNode, i as LayoutedProjectEdge, n as ComputedProjectNode, o as LayoutedProjectsView, r as ComputedProjectsView, t as ComputedProjectEdge } from "../_chunks/_types2.mjs";
|
|
17
|
+
import { n as computeRelationshipsView, r as RelationshipsViewData, t as treeFromElements } from "../_chunks/index6.mjs";
|
|
14
18
|
|
|
19
|
+
//#region src/compute-view/compute-view.d.ts
|
|
15
20
|
type ComputeViewResult<V> = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
isSuccess: true;
|
|
22
|
+
error?: undefined;
|
|
23
|
+
view: V;
|
|
19
24
|
} | {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
isSuccess: false;
|
|
26
|
+
error: Error;
|
|
27
|
+
view: undefined;
|
|
23
28
|
};
|
|
24
29
|
declare function unsafeComputeView<A extends Any>(viewsource: ParsedView<A>, likec4model: LikeC4Model<any>): ComputedView<A>;
|
|
25
30
|
declare function computeView<A extends Any>(viewsource: ParsedView<A>, likec4model: LikeC4Model<A>): ComputeViewResult<ComputedView<A>>;
|
|
26
31
|
declare function computeParsedModelData<A extends AnyParsed, B extends toComputed<A> = toComputed<A>>(parsed: ParsedLikeC4ModelData<A>): ComputedLikeC4ModelData<B>;
|
|
27
32
|
declare function computeLikeC4Model<A extends Any, B extends toComputed<A> = toComputed<A>>(parsed: ParsedLikeC4ModelData<A>): LikeC4Model<B>;
|
|
28
|
-
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/compute-view/utils/resolve-extended-views.d.ts
|
|
29
35
|
/**
|
|
30
36
|
* Resolve rules of extended views
|
|
31
37
|
* (Removes invalid views)
|
|
32
38
|
*/
|
|
33
39
|
declare function resolveRulesExtendedViews<A extends Any, V extends Record<any, ParsedView<A>>>(unresolvedViews: V): V;
|
|
34
|
-
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/compute-view/utils/with-readable-edges.d.ts
|
|
35
42
|
/**
|
|
36
43
|
* Convert hashed edge ids to human-readable
|
|
37
44
|
* Mostly for testing purposes
|
|
38
45
|
*/
|
|
39
|
-
declare function withReadableEdges<V extends ComputedView<any>>({
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
declare function withReadableEdges<V extends ComputedView<any>>({
|
|
47
|
+
edges,
|
|
48
|
+
nodes,
|
|
49
|
+
...view
|
|
50
|
+
}: V, separator?: string): V & {
|
|
51
|
+
nodeIds: string[];
|
|
52
|
+
edgeIds: string[];
|
|
42
53
|
};
|
|
43
|
-
declare function viewsWithReadableEdges<A extends Any>({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
readonly projectId: ProjectId;
|
|
50
|
-
}
|
|
51
|
-
interface LayoutedProjectNode extends DiagramNode {
|
|
52
|
-
readonly projectId: ProjectId;
|
|
53
|
-
}
|
|
54
|
-
interface LayoutedProjectEdge extends DiagramEdge {
|
|
55
|
-
readonly projectId: ProjectId;
|
|
56
|
-
}
|
|
54
|
+
declare function viewsWithReadableEdges<A extends Any>({
|
|
55
|
+
views,
|
|
56
|
+
...model
|
|
57
|
+
}: ComputedLikeC4ModelData<A>): ComputedLikeC4ModelData<A>;
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/compute-view/projects-view/compute.d.ts
|
|
57
60
|
/**
|
|
58
|
-
*
|
|
59
|
-
* Even though it has same structure as other likec4 views, it is not mixed with them, as it represents a different kind.
|
|
61
|
+
* Computes an overview of projects and their relationships
|
|
60
62
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
interface
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
declare function computeProjectsView(likec4models: NonEmptyArray<LikeC4Model>): ComputedProjectsView;
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/compute-view/adhoc-view/compute.d.ts
|
|
66
|
+
interface AdhocViewIncludePredicate<A extends Any> extends AnyIncludePredicate<ModelExpression<A>> {}
|
|
67
|
+
interface AdhocViewExcludePredicate<A extends Any> extends AnyExcludePredicate<ModelExpression<A>> {}
|
|
68
|
+
type AdhocViewPredicate<A extends Any = Any> = AdhocViewIncludePredicate<A> | AdhocViewExcludePredicate<A>;
|
|
69
|
+
interface ComputedAdhocView extends BaseViewProperties<Any> {
|
|
70
|
+
readonly [_type]: 'adhoc';
|
|
71
|
+
readonly [_stage]: 'computed';
|
|
72
|
+
readonly nodes: ReadonlyArray<ComputedNode>;
|
|
73
|
+
readonly edges: ReadonlyArray<ComputedEdge>;
|
|
74
|
+
readonly autoLayout: ViewAutoLayout;
|
|
72
75
|
}
|
|
73
|
-
|
|
74
76
|
/**
|
|
75
|
-
* Computes an
|
|
77
|
+
* Computes an adhoc view based on the given predicates.
|
|
78
|
+
* Adhoc views are not defined in the model, but computed on demand.
|
|
79
|
+
* Available for logical model only.
|
|
80
|
+
*
|
|
81
|
+
* @param predicates accepts the same predicates as element view.
|
|
82
|
+
* @param likec4model The LikeC4 model to compute view.
|
|
83
|
+
* @returns The computed adhoc view.
|
|
76
84
|
*/
|
|
77
|
-
declare function
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
declare function computeAdhocView<A extends Any>(likec4model: LikeC4Model<A>, predicates: AdhocViewPredicate<NoInfer<A>>[]): ComputedAdhocView;
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/compute-view/adhoc-view/builder.d.ts
|
|
88
|
+
/**
|
|
89
|
+
* Allows you to define type-safe adhoc views using types from the model.
|
|
90
|
+
*/
|
|
91
|
+
declare class AdhocView<A extends Any> {
|
|
92
|
+
#private;
|
|
93
|
+
private readonly model;
|
|
94
|
+
/**
|
|
95
|
+
* Creates a new adhoc view builder.
|
|
96
|
+
*/
|
|
97
|
+
static use<A extends Any>(model: LikeC4Model<A>): AdhocView<A>;
|
|
98
|
+
private constructor();
|
|
99
|
+
/**
|
|
100
|
+
* Used to cache the type of the predicates.
|
|
101
|
+
*/
|
|
102
|
+
readonly Expr: ViewPredicate.AllExpression<ViewPredicate.ElementExpr<A['ElementId']>>;
|
|
103
|
+
include(...predicates: this['Expr'][]): this;
|
|
104
|
+
exclude(...predicates: this['Expr'][]): this;
|
|
105
|
+
compute(): ComputedAdhocView;
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
export { AdhocView, type AdhocViewExcludePredicate, type AdhocViewIncludePredicate, type AdhocViewPredicate, type ComputeViewResult, type ComputedAdhocView, ComputedProjectEdge, ComputedProjectNode, ComputedProjectsView, LayoutedProjectEdge, LayoutedProjectNode, LayoutedProjectsView, type RelationshipsViewData, computeAdhocView, computeLikeC4Model, computeParsedModelData, computeProjectsView, computeRelationshipsView, computeView, resolveRulesExtendedViews, treeFromElements, unsafeComputeView, viewsWithReadableEdges, withReadableEdges };
|
|
@@ -1,229 +1,262 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { a as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { a as GlobalFqn, P as ProjectId } from '../shared/core.D0WZutNd.mjs';
|
|
18
|
-
|
|
19
|
-
function t(...t){return t$1(Object.keys,t)}
|
|
1
|
+
import { r as __toESM } from "../_chunks/rolldown-runtime.mjs";
|
|
2
|
+
import { C as t$1, E as t$4, G as t$7, I as e, S as t$3, Y as t$5, Z as t$6, i as n, m as e$1, r as t, w as t$2, x as n$1, y as t$8 } from "../_chunks/libs/remeda.mjs";
|
|
3
|
+
import { N as _stage, P as _type, _ as isExtendsElementView, g as isElementView } from "../_chunks/LikeC4Styles.mjs";
|
|
4
|
+
import "../_chunks/libs/natural-compare-lite.mjs";
|
|
5
|
+
import { N as isNonEmptyArray, r as stringHash } from "../_chunks/utils.mjs";
|
|
6
|
+
import { n as nonNullable, t as invariant } from "../_chunks/invariant.mjs";
|
|
7
|
+
import "../_chunks/libs/@mantine/colors-generator.mjs";
|
|
8
|
+
import { n as require_topological_sort, t as require_will_create_cycle } from "../_chunks/libs/graphology-dag.mjs";
|
|
9
|
+
import { n as import_default_map } from "../_chunks/libs/mnemonist.mjs";
|
|
10
|
+
import "../_chunks/libs/defu.mjs";
|
|
11
|
+
import "../_chunks/libs/extend.mjs";
|
|
12
|
+
import { n as preferSummary } from "../_chunks/_aux.mjs";
|
|
13
|
+
import { c as ProjectId, d as ViewId, i as GlobalFqn } from "../_chunks/scalar.mjs";
|
|
14
|
+
import { a as unsafeComputeView, c as linkNodesWithEdges, i as computeView, n as computeLikeC4Model, o as computeElementView, r as computeParsedModelData, s as topologicalSort$1, t as $expr } from "../_chunks/Builder.view-element.mjs";
|
|
15
|
+
import { t as Graph } from "../_chunks/libs/graphology.mjs";
|
|
16
|
+
import { n as treeFromElements, t as computeRelationshipsView } from "../_chunks/relationships-view.mjs";
|
|
20
17
|
|
|
18
|
+
//#region src/compute-view/utils/resolve-extended-views.ts
|
|
19
|
+
var import_topological_sort = require_topological_sort();
|
|
20
|
+
var import_will_create_cycle = /* @__PURE__ */ __toESM(require_will_create_cycle(), 1);
|
|
21
|
+
/**
|
|
22
|
+
* Resolve rules of extended views
|
|
23
|
+
* (Removes invalid views)
|
|
24
|
+
*/
|
|
21
25
|
function resolveRulesExtendedViews(unresolvedViews) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const links = [
|
|
62
|
-
...extendsFrom.links ?? [],
|
|
63
|
-
...view.links ?? []
|
|
64
|
-
];
|
|
65
|
-
acc[view.id] = {
|
|
66
|
-
...extendsFrom,
|
|
67
|
-
...view,
|
|
68
|
-
title: view.title ?? extendsFrom.title ?? null,
|
|
69
|
-
description: view.description ?? extendsFrom.description ?? null,
|
|
70
|
-
tags,
|
|
71
|
-
links: isNonEmptyArray(links) ? links : null,
|
|
72
|
-
rules: [...extendsFrom.rules, ...view.rules]
|
|
73
|
-
};
|
|
74
|
-
return acc;
|
|
75
|
-
}, {});
|
|
26
|
+
const g = new Graph({ type: "directed" });
|
|
27
|
+
const extendedViews = [];
|
|
28
|
+
for (const view of t(unresolvedViews)) {
|
|
29
|
+
g.addNode(view.id, { view });
|
|
30
|
+
if (isExtendsElementView(view)) extendedViews.push(view);
|
|
31
|
+
}
|
|
32
|
+
if (extendedViews.length === 0) return unresolvedViews;
|
|
33
|
+
for (const view of extendedViews) {
|
|
34
|
+
if (!g.hasNode(view.extends)) {
|
|
35
|
+
console.warn(`View "${view.id}" extends from "${view.extends}" which does not exist`);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if ((0, import_will_create_cycle.default)(g, view.id, view.extends)) {
|
|
39
|
+
console.warn(`View "${view.id}" extends from "${view.extends}" which creates a cycle`);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
g.addDirectedEdge(view.id, view.extends);
|
|
43
|
+
}
|
|
44
|
+
return (0, import_topological_sort.topologicalSort)(g).reverse().reduce((acc, id) => {
|
|
45
|
+
const view = g.getNodeAttribute(id, "view");
|
|
46
|
+
if (!isExtendsElementView(view)) {
|
|
47
|
+
acc[view.id] = view;
|
|
48
|
+
return acc;
|
|
49
|
+
}
|
|
50
|
+
const extendsFrom = acc[view.extends];
|
|
51
|
+
if (!extendsFrom || !isElementView(extendsFrom)) return acc;
|
|
52
|
+
const tags = n([...extendsFrom.tags ?? [], ...view.tags ?? []]);
|
|
53
|
+
const links = [...extendsFrom.links ?? [], ...view.links ?? []];
|
|
54
|
+
acc[view.id] = {
|
|
55
|
+
...extendsFrom,
|
|
56
|
+
...view,
|
|
57
|
+
title: view.title ?? extendsFrom.title ?? null,
|
|
58
|
+
description: view.description ?? extendsFrom.description ?? null,
|
|
59
|
+
tags,
|
|
60
|
+
links: isNonEmptyArray(links) ? links : null,
|
|
61
|
+
rules: [...extendsFrom.rules, ...view.rules]
|
|
62
|
+
};
|
|
63
|
+
return acc;
|
|
64
|
+
}, {});
|
|
76
65
|
}
|
|
77
66
|
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/compute-view/utils/with-readable-edges.ts
|
|
69
|
+
/**
|
|
70
|
+
* Convert hashed edge ids to human-readable
|
|
71
|
+
* Mostly for testing purposes
|
|
72
|
+
*/
|
|
78
73
|
function withReadableEdges({ edges, nodes, ...view }, separator = ":") {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
74
|
+
const edgeids = t$1(edges, (e) => [e.id, `${e.source}${separator}${e.target}`]);
|
|
75
|
+
return {
|
|
76
|
+
...view,
|
|
77
|
+
edges: edges.map((e) => ({
|
|
78
|
+
...e,
|
|
79
|
+
id: edgeids[e.id]
|
|
80
|
+
})),
|
|
81
|
+
nodes: nodes.map((n) => ({
|
|
82
|
+
...n,
|
|
83
|
+
inEdges: t$2(n.inEdges, (e) => edgeids[e]),
|
|
84
|
+
outEdges: t$2(n.outEdges, (e) => edgeids[e])
|
|
85
|
+
})),
|
|
86
|
+
nodeIds: nodes.map((n) => n.id),
|
|
87
|
+
edgeIds: edges.map((e) => edgeids[e.id])
|
|
88
|
+
};
|
|
94
89
|
}
|
|
95
90
|
function viewsWithReadableEdges({ views, ...model }) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
91
|
+
return {
|
|
92
|
+
...model,
|
|
93
|
+
views: t$3(views, (v) => n$1(withReadableEdges(v), ["nodeIds", "edgeIds"]))
|
|
94
|
+
};
|
|
100
95
|
}
|
|
101
96
|
|
|
102
|
-
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/compute-view/projects-view/compute.ts
|
|
99
|
+
const keysCount = (object) => t$4(object).length;
|
|
103
100
|
const nodeId = (projectId) => stringHash(projectId);
|
|
101
|
+
/**
|
|
102
|
+
* Computes an overview of projects and their relationships
|
|
103
|
+
*/
|
|
104
104
|
function computeProjectsView(likec4models) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
edge.kind = onlyOne.kind;
|
|
173
|
-
}
|
|
174
|
-
if (onlyOne.$relationship.navigateTo) {
|
|
175
|
-
edge.navigateTo = onlyOne.$relationship.navigateTo;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return edge;
|
|
179
|
-
});
|
|
180
|
-
linkNodesWithEdges(nodesMap, edges);
|
|
181
|
-
const sorted = topologicalSort({
|
|
182
|
-
nodes: nodesMap,
|
|
183
|
-
edges
|
|
184
|
-
});
|
|
185
|
-
return {
|
|
186
|
-
id: "projects-view",
|
|
187
|
-
[_stage]: "computed",
|
|
188
|
-
title: "Projects",
|
|
189
|
-
description: {
|
|
190
|
-
txt: "Overview of all projects and their relationships"
|
|
191
|
-
},
|
|
192
|
-
autoLayout: {
|
|
193
|
-
direction: "TB"
|
|
194
|
-
},
|
|
195
|
-
...sorted
|
|
196
|
-
};
|
|
105
|
+
const nodesMap = buildNodesForEachModel(likec4models);
|
|
106
|
+
const key = (from, to) => `${from}->${to}`;
|
|
107
|
+
const relationships = new import_default_map.default((key) => {
|
|
108
|
+
const [from, to] = key.split("->");
|
|
109
|
+
return {
|
|
110
|
+
from,
|
|
111
|
+
to,
|
|
112
|
+
relationships: /* @__PURE__ */ new Set()
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
const relationshipsFromTo = (from, to) => relationships.get(key(from, to)).relationships;
|
|
116
|
+
const processImportedElement = (model, importedElement) => {
|
|
117
|
+
const projectId = importedElement.projectId;
|
|
118
|
+
invariant(projectId !== model.projectId, "Imported element must have a different project id");
|
|
119
|
+
const incoming = relationshipsFromTo(model.projectId, projectId);
|
|
120
|
+
for (const rel of importedElement.incoming("direct")) if (rel.source.projectId === model.projectId) incoming.add(rel);
|
|
121
|
+
const outgoing = relationshipsFromTo(projectId, model.projectId);
|
|
122
|
+
for (const rel of importedElement.outgoing("direct")) if (rel.target.projectId === model.projectId) outgoing.add(rel);
|
|
123
|
+
};
|
|
124
|
+
for (const model of likec4models) {
|
|
125
|
+
if (e(model.$data.imports)) continue;
|
|
126
|
+
for (const [projectId, imported] of t$5(model.$data.imports)) for (const importedElement of imported) {
|
|
127
|
+
const fqn = GlobalFqn(projectId, importedElement.id);
|
|
128
|
+
processImportedElement(model, nonNullable(model.findElement(fqn), `Element ${importedElement.id} from project ${projectId} not found in model ${model.projectId}`));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const edges = Array.from(relationships.entries()).filter(([_, { relationships }]) => relationships.size > 0).map(([key, { from, to, relationships: relationshipsSet }]) => {
|
|
132
|
+
const relationships = [...relationshipsSet];
|
|
133
|
+
invariant(t$6(relationships, 1), "Relationships set must have at least one relationship");
|
|
134
|
+
const edge = {
|
|
135
|
+
id: stringHash(key),
|
|
136
|
+
source: nodeId(from),
|
|
137
|
+
target: nodeId(to),
|
|
138
|
+
projectId: from,
|
|
139
|
+
relations: t$2(relationships, e$1("id")),
|
|
140
|
+
label: null,
|
|
141
|
+
color: "gray",
|
|
142
|
+
parent: null,
|
|
143
|
+
line: "solid",
|
|
144
|
+
tags: n(t$7(relationships, e$1("tags")))
|
|
145
|
+
};
|
|
146
|
+
const onlyOne = t$8(relationships);
|
|
147
|
+
if (onlyOne) {
|
|
148
|
+
edge.label = onlyOne.title;
|
|
149
|
+
edge.description = /* @__PURE__ */ preferSummary(onlyOne.$relationship) ?? null;
|
|
150
|
+
edge.technology = onlyOne.technology;
|
|
151
|
+
edge.color = onlyOne.color;
|
|
152
|
+
edge.line = onlyOne.line;
|
|
153
|
+
if (onlyOne.kind) edge.kind = onlyOne.kind;
|
|
154
|
+
if (onlyOne.$relationship.navigateTo) edge.navigateTo = onlyOne.$relationship.navigateTo;
|
|
155
|
+
}
|
|
156
|
+
return edge;
|
|
157
|
+
});
|
|
158
|
+
linkNodesWithEdges(nodesMap, edges);
|
|
159
|
+
const sorted = topologicalSort$1({
|
|
160
|
+
nodes: nodesMap,
|
|
161
|
+
edges
|
|
162
|
+
});
|
|
163
|
+
return {
|
|
164
|
+
id: "projects-view",
|
|
165
|
+
[_type]: "projects",
|
|
166
|
+
[_stage]: "computed",
|
|
167
|
+
title: "Projects",
|
|
168
|
+
description: { txt: "Overview of all projects and their relationships" },
|
|
169
|
+
autoLayout: { direction: "TB" },
|
|
170
|
+
...sorted
|
|
171
|
+
};
|
|
197
172
|
}
|
|
198
173
|
function buildNodesForEachModel(likec4models) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
174
|
+
const nodesMap = /* @__PURE__ */ new Map();
|
|
175
|
+
for (const model of likec4models) {
|
|
176
|
+
const projectId = ProjectId(model.projectId);
|
|
177
|
+
const node = {
|
|
178
|
+
id: nodeId(projectId),
|
|
179
|
+
kind: "@project",
|
|
180
|
+
parent: null,
|
|
181
|
+
projectId,
|
|
182
|
+
title: model.project.title ?? model.project.id,
|
|
183
|
+
description: { txt: [
|
|
184
|
+
`Elements: ${keysCount(model.$data.elements)}`,
|
|
185
|
+
`Relationships: ${keysCount(model.$data.relations)}`,
|
|
186
|
+
`Views: ${keysCount(model.$data.views)}`
|
|
187
|
+
].join("\n") },
|
|
188
|
+
shape: "rectangle",
|
|
189
|
+
children: [],
|
|
190
|
+
inEdges: [],
|
|
191
|
+
outEdges: [],
|
|
192
|
+
color: "primary",
|
|
193
|
+
level: 0,
|
|
194
|
+
style: {},
|
|
195
|
+
tags: []
|
|
196
|
+
};
|
|
197
|
+
nodesMap.set(node.id, node);
|
|
198
|
+
}
|
|
199
|
+
return nodesMap;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/compute-view/adhoc-view/compute.ts
|
|
204
|
+
/**
|
|
205
|
+
* Computes an adhoc view based on the given predicates.
|
|
206
|
+
* Adhoc views are not defined in the model, but computed on demand.
|
|
207
|
+
* Available for logical model only.
|
|
208
|
+
*
|
|
209
|
+
* @param predicates accepts the same predicates as element view.
|
|
210
|
+
* @param likec4model The LikeC4 model to compute view.
|
|
211
|
+
* @returns The computed adhoc view.
|
|
212
|
+
*/
|
|
213
|
+
function computeAdhocView(likec4model, predicates) {
|
|
214
|
+
return {
|
|
215
|
+
...computeElementView(likec4model, {
|
|
216
|
+
id: ViewId("adhoc"),
|
|
217
|
+
_stage: "parsed",
|
|
218
|
+
_type: "element",
|
|
219
|
+
rules: predicates,
|
|
220
|
+
title: null,
|
|
221
|
+
description: null
|
|
222
|
+
}),
|
|
223
|
+
_type: "adhoc",
|
|
224
|
+
_stage: "computed"
|
|
225
|
+
};
|
|
227
226
|
}
|
|
228
227
|
|
|
229
|
-
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/compute-view/adhoc-view/builder.ts
|
|
230
|
+
/**
|
|
231
|
+
* Allows you to define type-safe adhoc views using types from the model.
|
|
232
|
+
*/
|
|
233
|
+
var AdhocView = class AdhocView {
|
|
234
|
+
/**
|
|
235
|
+
* Creates a new adhoc view builder.
|
|
236
|
+
*/
|
|
237
|
+
static use(model) {
|
|
238
|
+
return new AdhocView(model);
|
|
239
|
+
}
|
|
240
|
+
#predicates = [];
|
|
241
|
+
constructor(model) {
|
|
242
|
+
this.model = model;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Used to cache the type of the predicates.
|
|
246
|
+
*/
|
|
247
|
+
Expr;
|
|
248
|
+
include(...predicates) {
|
|
249
|
+
this.#predicates.push({ include: predicates.map((predicate) => $expr(predicate)) });
|
|
250
|
+
return this;
|
|
251
|
+
}
|
|
252
|
+
exclude(...predicates) {
|
|
253
|
+
this.#predicates.push({ exclude: predicates.map((predicate) => $expr(predicate)) });
|
|
254
|
+
return this;
|
|
255
|
+
}
|
|
256
|
+
compute() {
|
|
257
|
+
return computeAdhocView(this.model, this.#predicates);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
//#endregion
|
|
262
|
+
export { AdhocView, computeAdhocView, computeLikeC4Model, computeParsedModelData, computeProjectsView, computeRelationshipsView, computeView, resolveRulesExtendedViews, treeFromElements, unsafeComputeView, viewsWithReadableEdges, withReadableEdges };
|