@likec4/core 1.31.0 → 1.32.1
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/README.md +407 -5
- package/dist/builder/index.d.mts +221 -42
- package/dist/builder/index.mjs +118 -65
- package/dist/compute-view/index.d.mts +23 -7
- package/dist/compute-view/index.mjs +11 -6
- package/dist/compute-view/relationships-view/index.d.mts +9 -7
- package/dist/compute-view/relationships-view/index.mjs +3 -2
- package/dist/index.d.mts +10 -14
- package/dist/index.mjs +9 -6
- package/dist/model/index.d.mts +173 -19
- package/dist/model/index.mjs +6 -1
- package/dist/shared/core.BaYE_r29.d.mts +258 -0
- package/dist/shared/core.Bk7wEZFG.mjs +276 -0
- package/dist/shared/core.BrCnZFTn.mjs +32 -0
- package/dist/shared/core.BuO4ncfY.d.mts +146 -0
- package/dist/shared/{core.Bq753SYD.mjs → core.CBpKAlhj.mjs} +2012 -4422
- package/dist/shared/core.CUYDgv2-.mjs +214 -0
- package/dist/shared/{core.Cu-UdkSl.mjs → core.CpXlRyE5.mjs} +7 -494
- package/dist/shared/{core.C-YXI-43.mjs → core.Cy9smucx.mjs} +3 -1
- package/dist/shared/core.CywrQs86.d.mts +31 -0
- package/dist/shared/core.DXzRBkuI.d.mts +1264 -0
- package/dist/shared/core.DoK86JEe.mjs +518 -0
- package/dist/shared/{core.D2830qgg.d.mts → core.Pf5I9o0e.d.mts} +1 -1
- package/dist/shared/core.cbA9VZ02.mjs +2681 -0
- package/dist/shared/{core.CQXU9DF7.mjs → core.rmvsy0n3.mjs} +23 -32
- package/dist/shared/core.znRaUX_A.d.mts +920 -0
- package/dist/types/aux.d.mts +3 -0
- package/dist/types/aux.mjs +1 -0
- package/dist/types/index.d.mts +7 -45
- package/dist/types/index.mjs +130 -3
- package/dist/utils/index.d.mts +221 -53
- package/dist/utils/index.mjs +14 -10
- package/package.json +16 -8
- package/src/builder/Builder.deploymentModel.ts +82 -18
- package/src/builder/Builder.element.ts +40 -20
- package/src/builder/Builder.model.ts +66 -17
- package/src/builder/Builder.ts +168 -76
- package/src/builder/Builder.view-common.ts +35 -17
- package/src/builder/Builder.view-deployment.ts +25 -25
- package/src/builder/Builder.view-element.ts +13 -12
- package/src/builder/Builder.views.ts +12 -7
- package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +62 -34
- package/src/builder/__snapshots__/Builder-style2.compute-model.json5 +319 -0
- package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +45 -24
- package/src/builder/_types.ts +34 -27
- package/src/compute-view/compute-view.ts +31 -34
- package/src/compute-view/deployment-view/__test__/TestHelper.ts +27 -14
- package/src/compute-view/deployment-view/__test__/fixture.ts +15 -13
- package/src/compute-view/deployment-view/_types.ts +10 -10
- package/src/compute-view/deployment-view/clean-connections.ts +5 -7
- package/src/compute-view/deployment-view/compute.ts +16 -13
- package/src/compute-view/deployment-view/memory/memory.ts +5 -6
- package/src/compute-view/deployment-view/predicates/deploymentRefs.ts +4 -5
- package/src/compute-view/deployment-view/predicates/relation-direct.ts +25 -50
- package/src/compute-view/deployment-view/predicates/relation-in-out.ts +5 -7
- package/src/compute-view/deployment-view/predicates/relation-incoming.ts +7 -11
- package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +7 -10
- package/src/compute-view/deployment-view/predicates/utils.ts +37 -31
- package/src/compute-view/deployment-view/predicates/wildcard.ts +3 -2
- package/src/compute-view/deployment-view/stages/stage-final.ts +2 -2
- package/src/compute-view/deployment-view/stages/stage-include.ts +1 -1
- package/src/compute-view/deployment-view/utils.ts +79 -72
- package/src/compute-view/dynamic-view/__test__/fixture.ts +20 -11
- package/src/compute-view/dynamic-view/compute.ts +60 -53
- package/src/compute-view/element-view/__test__/TestHelper.ts +53 -29
- package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +26 -26
- package/src/compute-view/element-view/__test__/fixture.ts +134 -83
- package/src/compute-view/element-view/_types.ts +14 -19
- package/src/compute-view/element-view/clean-connections.ts +12 -8
- package/src/compute-view/element-view/compute.ts +61 -51
- package/src/compute-view/element-view/memory/NodeGroup.ts +8 -9
- package/src/compute-view/element-view/memory/memory.ts +22 -22
- package/src/compute-view/element-view/memory/stage-include.ts +5 -3
- package/src/compute-view/element-view/predicates/_utils.ts +18 -14
- package/src/compute-view/element-view/predicates/element-expand.ts +4 -5
- package/src/compute-view/element-view/predicates/element-kind-tag.ts +3 -4
- package/src/compute-view/element-view/predicates/element-ref.ts +3 -4
- package/src/compute-view/element-view/predicates/relation-direct.ts +16 -12
- package/src/compute-view/element-view/predicates/relation-in-out.ts +7 -8
- package/src/compute-view/element-view/predicates/relation-in.ts +19 -26
- package/src/compute-view/element-view/predicates/relation-out.ts +20 -21
- package/src/compute-view/element-view/predicates/wildcard.ts +3 -3
- package/src/compute-view/element-view/utils.ts +25 -23
- package/src/compute-view/index.ts +1 -1
- package/src/compute-view/memory/AbstractStageExclude.ts +3 -4
- package/src/compute-view/memory/AbstractStageInclude.ts +1 -1
- package/src/compute-view/memory/_types.ts +3 -2
- package/src/compute-view/relationships-view/_types.ts +3 -4
- package/src/compute-view/relationships-view/compute.ts +8 -11
- package/src/compute-view/relationships-view/layout.ts +6 -6
- package/src/compute-view/relationships-view/utils.ts +4 -4
- package/src/compute-view/utils/ancestorsOfNode.ts +7 -7
- package/src/compute-view/utils/applyCustomElementProperties.ts +16 -8
- package/src/compute-view/utils/applyCustomRelationProperties.ts +19 -9
- package/src/compute-view/utils/applyViewRuleStyles.ts +18 -10
- package/src/compute-view/utils/buildComputedNodes.ts +40 -40
- package/src/compute-view/utils/buildElementNotations.ts +14 -14
- package/src/compute-view/utils/elementExpressionToPredicate.ts +14 -15
- package/src/compute-view/utils/link-nodes-with-edges.ts +6 -4
- package/src/compute-view/utils/merge-props-from-relationships.ts +52 -20
- package/src/compute-view/utils/relationExpressionToPredicates.ts +19 -19
- package/src/compute-view/utils/resolve-extended-views.ts +8 -7
- package/src/compute-view/utils/resolve-global-rules.ts +31 -26
- package/src/compute-view/utils/topological-sort.ts +14 -14
- package/src/compute-view/utils/view-hash.ts +2 -2
- package/src/compute-view/utils/with-readable-edges.ts +9 -5
- package/src/index.ts +0 -32
- package/src/model/DeploymentElementModel.ts +171 -144
- package/src/model/DeploymentModel.ts +88 -65
- package/src/model/ElementModel.ts +85 -74
- package/src/model/LikeC4Model.ts +430 -241
- package/src/model/RelationModel.ts +63 -29
- package/src/model/__test__/fixture.ts +50 -36
- package/src/model/connection/Connection.ts +2 -2
- package/src/model/connection/deployment/DeploymentConnectionModel.ts +21 -24
- package/src/model/connection/deployment/find.ts +1 -1
- package/src/model/connection/model/ConnectionModel.ts +21 -20
- package/src/model/connection/model/find.ts +7 -7
- package/src/model/connection/ops.ts +6 -6
- package/src/model/guards.ts +66 -14
- package/src/model/index.ts +20 -7
- package/src/model/types.ts +41 -97
- package/src/model/view/EdgeModel.ts +47 -41
- package/src/model/view/LikeC4ViewModel.ts +130 -80
- package/src/model/view/NodeModel.ts +102 -96
- package/src/theme/element.ts +1 -1
- package/src/theme/index.ts +9 -9
- package/src/theme/relationships.ts +1 -1
- package/src/types/_common.ts +21 -15
- package/src/types/aux.ts +285 -0
- package/src/types/const.ts +34 -0
- package/src/types/expression-model.ts +292 -0
- package/src/types/expression.ts +311 -0
- package/src/types/fqnRef.ts +88 -0
- package/src/types/geometry.ts +131 -0
- package/src/types/global.ts +10 -8
- package/src/types/index.ts +39 -201
- package/src/types/model-data.ts +52 -84
- package/src/types/model-deployment.ts +87 -0
- package/src/types/model-dump.ts +72 -0
- package/src/types/model-logical.ts +111 -0
- package/src/types/model-spec.ts +81 -0
- package/src/types/operators.ts +51 -52
- package/src/types/scalar.ts +114 -0
- package/src/types/{theme.ts → styles.ts} +55 -15
- package/src/types/view-changes.ts +4 -5
- package/src/types/view-common.ts +157 -0
- package/src/types/view-computed.ts +113 -0
- package/src/types/view-layouted.ts +82 -0
- package/src/types/view-parsed.deployment.ts +40 -0
- package/src/types/view-parsed.dynamic.ts +78 -0
- package/src/types/view-parsed.element.ts +65 -0
- package/src/types/view.ts +122 -542
- package/src/utils/compare-natural.ts +43 -1
- package/src/utils/getOrCreate.ts +0 -34
- package/src/utils/index.ts +7 -12
- package/src/utils/iterable/filter.ts +1 -1
- package/src/utils/iterable/find.ts +3 -1
- package/src/utils/iterable/head.ts +22 -0
- package/src/utils/iterable/index.ts +1 -0
- package/src/utils/iterable/map.ts +1 -1
- package/src/utils/iterable/reduce.ts +1 -1
- package/src/utils/iterable/some.ts +1 -1
- package/src/utils/memoize-prop.ts +30 -0
- package/src/utils/object-hash.ts +1 -1
- package/src/utils/relations.ts +14 -11
- package/src/utils/string-hash.ts +1 -1
- package/dist/shared/core.CQDU11hR.d.mts +0 -753
- package/dist/shared/core.DJvmfnEi.d.mts +0 -1153
- package/dist/shared/core.DgfwjBtu.mjs +0 -495
- package/dist/shared/core.Dx7siloV.d.mts +0 -146
- package/dist/shared/core.SjLhMA7a.d.mts +0 -62
- package/src/builder/__snapshots__/Builder.spec.ts.snap +0 -374
- package/src/compute-view/element-view/predicates.ts +0 -520
- package/src/compute-view/utils/uniqueTags.ts +0 -21
- package/src/types/deployments.ts +0 -170
- package/src/types/element.ts +0 -109
- package/src/types/expression-v2-model.ts +0 -314
- package/src/types/expression-v2.ts +0 -392
- package/src/types/overview-graph.ts +0 -43
- package/src/types/relation.ts +0 -61
- package/src/types/scalars.ts +0 -39
- package/src/types/view-notation.ts +0 -9
- package/src/utils/graphlib.ts +0 -10
- /package/src/{errors/index.ts → utils/invariant.ts} +0 -0
package/src/types/view.ts
CHANGED
|
@@ -1,560 +1,140 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from './
|
|
11
|
-
import type {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import type {
|
|
17
|
-
import type {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
export
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
textSize?: TextSize
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function isViewRuleGroup(rule: ViewRule): rule is ViewRuleGroup {
|
|
103
|
-
return 'title' in rule && 'groupRules' in rule && Array.isArray(rule.groupRules)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export type ViewRule =
|
|
107
|
-
| ViewRulePredicate
|
|
108
|
-
| ViewRuleGlobalPredicateRef
|
|
109
|
-
| ViewRuleGroup
|
|
110
|
-
| ViewRuleStyle
|
|
111
|
-
| ViewRuleGlobalStyle
|
|
112
|
-
| ViewRuleAutoLayout
|
|
113
|
-
|
|
114
|
-
export interface BasicView<
|
|
115
|
-
ViewType extends 'element' | 'dynamic' | 'deployment',
|
|
116
|
-
ViewIDs extends string,
|
|
117
|
-
Tags extends string,
|
|
1
|
+
import { isTruthy } from 'remeda'
|
|
2
|
+
import type { Any } from './aux'
|
|
3
|
+
import * as aux from './aux'
|
|
4
|
+
import type { _stage, _type, ExtractOnStage, ModelStage } from './const'
|
|
5
|
+
import type { ViewType } from './view-common'
|
|
6
|
+
import type {
|
|
7
|
+
ComputedDeploymentView,
|
|
8
|
+
ComputedDynamicView,
|
|
9
|
+
ComputedElementView,
|
|
10
|
+
} from './view-computed'
|
|
11
|
+
import type {
|
|
12
|
+
LayoutedDeploymentView,
|
|
13
|
+
LayoutedDynamicView,
|
|
14
|
+
LayoutedElementView,
|
|
15
|
+
} from './view-layouted'
|
|
16
|
+
import type { ParsedDeploymentView } from './view-parsed.deployment'
|
|
17
|
+
import type { ParsedDynamicView } from './view-parsed.dynamic'
|
|
18
|
+
import type { ParsedElementView } from './view-parsed.element'
|
|
19
|
+
|
|
20
|
+
export type ParsedView<A extends Any = Any> =
|
|
21
|
+
| ParsedElementView<A>
|
|
22
|
+
| ParsedDeploymentView<A>
|
|
23
|
+
| ParsedDynamicView<A>
|
|
24
|
+
|
|
25
|
+
// export type ParsedView<A extends Any = Any> = ExclusiveUnion<{
|
|
26
|
+
// Element: ParsedElementView<A>
|
|
27
|
+
// Deployment: ParsedDeploymentView<A>
|
|
28
|
+
// Dynamic: ParsedDynamicView<A>
|
|
29
|
+
// }>
|
|
30
|
+
/**
|
|
31
|
+
* Should be `ParsedView` but keep it for backward compatibility
|
|
32
|
+
* @deprecated use `ParsedView`
|
|
33
|
+
*/
|
|
34
|
+
export type { ParsedView as LikeC4View }
|
|
35
|
+
|
|
36
|
+
export type ComputedView<A extends Any = Any> =
|
|
37
|
+
| ComputedElementView<A>
|
|
38
|
+
| ComputedDeploymentView<A>
|
|
39
|
+
| ComputedDynamicView<A>
|
|
40
|
+
// export type ComputedView<A extends Any = Any> = ExclusiveUnion<{
|
|
41
|
+
// Element: ComputedElementView<A>
|
|
42
|
+
// Deployment: ComputedDeploymentView<A>
|
|
43
|
+
// Dynamic: ComputedDynamicView<A>
|
|
44
|
+
// }>
|
|
45
|
+
|
|
46
|
+
// export type LayoutedView<A extends Any = Any> = ExclusiveUnion<{
|
|
47
|
+
// Element: LayoutedElementView<A>
|
|
48
|
+
// Deployment: LayoutedDeploymentView<A>
|
|
49
|
+
// Dynamic: LayoutedDynamicView<A>
|
|
50
|
+
// }>
|
|
51
|
+
|
|
52
|
+
export type LayoutedView<A extends Any = Any> =
|
|
53
|
+
| LayoutedElementView<A>
|
|
54
|
+
| LayoutedDeploymentView<A>
|
|
55
|
+
| LayoutedDynamicView<A>
|
|
56
|
+
|
|
57
|
+
export type ProcessedView<A extends Any = Any> =
|
|
58
|
+
| ComputedView<A>
|
|
59
|
+
| LayoutedView<A>
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @alias DiagramView
|
|
63
|
+
*/
|
|
64
|
+
export type { LayoutedView as DiagramView }
|
|
65
|
+
export type AnyView<A extends Any = Any> =
|
|
66
|
+
| ParsedElementView<A>
|
|
67
|
+
| ParsedDeploymentView<A>
|
|
68
|
+
| ParsedDynamicView<A>
|
|
69
|
+
| ComputedElementView<A>
|
|
70
|
+
| ComputedDeploymentView<A>
|
|
71
|
+
| ComputedDynamicView<A>
|
|
72
|
+
| LayoutedElementView<A>
|
|
73
|
+
| LayoutedDeploymentView<A>
|
|
74
|
+
| LayoutedDynamicView<A>
|
|
75
|
+
// export type AnyView<A extends Any = Any> = ExclusiveUnion<{
|
|
76
|
+
// ParsedElement: ParsedElementView<A>
|
|
77
|
+
// ParsedDeployment: ParsedDeploymentView<A>
|
|
78
|
+
// ParsedDynamic: ParsedDynamicView<A>
|
|
79
|
+
// ComputedElement: ComputedElementView<A>
|
|
80
|
+
// ComputedDeployment: ComputedDeploymentView<A>
|
|
81
|
+
// ComputedDynamic: ComputedDynamicView<A>
|
|
82
|
+
// LayoutedElement: LayoutedElementView<A>
|
|
83
|
+
// LayoutedDeployment: LayoutedDeploymentView<A>
|
|
84
|
+
// LayoutedDynamic: LayoutedDynamicView<A>
|
|
85
|
+
// }>
|
|
86
|
+
|
|
87
|
+
export type ViewOnStage<V extends AnyView<Any>, T extends ModelStage> = Extract<V, { [_stage]: T }>
|
|
88
|
+
export type ViewWithType<V extends AnyView<Any>, T extends ViewType> = Extract<V, { [_type]: T }>
|
|
89
|
+
|
|
90
|
+
export type ViewRule<A extends Any = Any> = ParsedView<A>['rules'][number]
|
|
91
|
+
export type ViewRulePredicate<A extends Any = Any> = Extract<
|
|
92
|
+
ViewRule<A>,
|
|
93
|
+
{ include: any[] } | { exclude: any[] }
|
|
94
|
+
>
|
|
95
|
+
|
|
96
|
+
export function isViewRulePredicate<V extends ViewRule<any>>(rule: V): rule is Extract<
|
|
97
|
+
V,
|
|
98
|
+
{ include: any[] } | { exclude: any[] }
|
|
118
99
|
> {
|
|
119
|
-
|
|
120
|
-
readonly id: ViewId<ViewIDs>
|
|
121
|
-
readonly title: string | null
|
|
122
|
-
readonly description: string | null
|
|
123
|
-
readonly tags: NonEmptyArray<Tag<Tags>> | null
|
|
124
|
-
readonly links: NonEmptyArray<Link> | null
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* URI to the source file of this view.
|
|
128
|
-
* Undefined if the view is auto-generated.
|
|
129
|
-
*/
|
|
130
|
-
readonly docUri?: string
|
|
131
|
-
/**
|
|
132
|
-
* For all views we find common ancestor path.
|
|
133
|
-
* This is used to generate relative paths, i.e.:
|
|
134
|
-
* - "/home/project/index.c4" becomes "index.c4"
|
|
135
|
-
* - "/home/project/subdir/views.c4" becomes "subdir/views.c4"
|
|
136
|
-
*
|
|
137
|
-
* Undefined if the view is auto-generated.
|
|
138
|
-
*/
|
|
139
|
-
readonly relativePath?: string
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* If the view is changed manually this field contains the layout data.
|
|
143
|
-
*/
|
|
144
|
-
readonly manualLayout?: ViewManualLayout | undefined
|
|
145
|
-
|
|
146
|
-
readonly customColorDefinitions: CustomColorDefinitions
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export interface BasicElementView<ViewIDs extends string, Tags extends string>
|
|
150
|
-
extends BasicView<'element', ViewIDs, Tags>
|
|
151
|
-
{
|
|
152
|
-
readonly viewOf?: Fqn
|
|
153
|
-
readonly rules: ViewRule[]
|
|
154
|
-
}
|
|
155
|
-
export interface ScopedElementView<ViewIDs extends string, Tags extends string>
|
|
156
|
-
extends BasicElementView<ViewIDs, Tags>
|
|
157
|
-
{
|
|
158
|
-
readonly viewOf: Fqn
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export interface ExtendsElementView<ViewIDs extends string, Tags extends string>
|
|
162
|
-
extends BasicElementView<ViewIDs, Tags>
|
|
163
|
-
{
|
|
164
|
-
readonly extends: ViewId<ViewIDs>
|
|
165
|
-
}
|
|
166
|
-
export type ElementView<
|
|
167
|
-
ViewIDs extends string = string,
|
|
168
|
-
Tags extends string = string,
|
|
169
|
-
> =
|
|
170
|
-
| ScopedElementView<ViewIDs, Tags>
|
|
171
|
-
| ExtendsElementView<ViewIDs, Tags>
|
|
172
|
-
| BasicElementView<ViewIDs, Tags>
|
|
173
|
-
|
|
174
|
-
export interface DynamicViewStep {
|
|
175
|
-
readonly source: Fqn
|
|
176
|
-
readonly target: Fqn
|
|
177
|
-
readonly title: string | null
|
|
178
|
-
readonly description?: string
|
|
179
|
-
readonly technology?: string
|
|
180
|
-
readonly notation?: string
|
|
181
|
-
// Notes for walkthrough
|
|
182
|
-
readonly notes?: string
|
|
183
|
-
readonly color?: Color
|
|
184
|
-
readonly line?: RelationshipLineType
|
|
185
|
-
readonly head?: RelationshipArrowType
|
|
186
|
-
readonly tail?: RelationshipArrowType
|
|
187
|
-
readonly isBackward?: boolean
|
|
188
|
-
// Link to dynamic view
|
|
189
|
-
readonly navigateTo?: ViewId
|
|
190
|
-
__parallel?: never
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export interface DynamicViewParallelSteps {
|
|
194
|
-
readonly __parallel: DynamicViewStep[]
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export type DynamicViewStepOrParallel = DynamicViewStep | DynamicViewParallelSteps
|
|
198
|
-
|
|
199
|
-
export type DynamicViewIncludeRule = {
|
|
200
|
-
include: ModelLayer.AnyFqnExpr[]
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export type DynamicViewRule =
|
|
204
|
-
| DynamicViewIncludeRule
|
|
205
|
-
| ViewRuleGlobalPredicateRef
|
|
206
|
-
| ViewRuleStyle
|
|
207
|
-
| ViewRuleGlobalStyle
|
|
208
|
-
| ViewRuleAutoLayout
|
|
209
|
-
export interface DynamicView<
|
|
210
|
-
ViewIDs extends string = string,
|
|
211
|
-
Tags extends string = string,
|
|
212
|
-
> extends BasicView<'dynamic', ViewIDs, Tags> {
|
|
213
|
-
readonly __: 'dynamic'
|
|
214
|
-
|
|
215
|
-
readonly steps: DynamicViewStepOrParallel[]
|
|
216
|
-
|
|
217
|
-
readonly rules: DynamicViewRule[]
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export function isDynamicViewParallelSteps(step: DynamicViewStepOrParallel): step is DynamicViewParallelSteps {
|
|
221
|
-
return '__parallel' in step && isArray(step.__parallel)
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
export type CustomColorDefinitions = { [key: string]: ThemeColorValues }
|
|
225
|
-
|
|
226
|
-
export type DeploymentViewRulePredicate =
|
|
227
|
-
| {
|
|
228
|
-
include: ExpressionV2[]
|
|
229
|
-
exclude?: never
|
|
230
|
-
}
|
|
231
|
-
| {
|
|
232
|
-
include?: never
|
|
233
|
-
exclude: ExpressionV2[]
|
|
234
|
-
}
|
|
235
|
-
export type DeploymentViewRuleStyle = {
|
|
236
|
-
targets: FqnExpr[]
|
|
237
|
-
notation?: string
|
|
238
|
-
style: ElementStyle & {
|
|
239
|
-
color?: Color
|
|
240
|
-
shape?: ElementShape
|
|
241
|
-
icon?: IconUrl
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
export type DeploymentViewRule = DeploymentViewRulePredicate | ViewRuleAutoLayout | DeploymentViewRuleStyle
|
|
245
|
-
|
|
246
|
-
export interface DeploymentView<
|
|
247
|
-
ViewIDs extends string = string,
|
|
248
|
-
Tags extends string = string,
|
|
249
|
-
> extends BasicView<'deployment', ViewIDs, Tags> {
|
|
250
|
-
readonly __: 'deployment'
|
|
251
|
-
readonly rules: DeploymentViewRule[]
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
export type LikeC4View<
|
|
255
|
-
ViewIDs extends string = string,
|
|
256
|
-
Tags extends string = string,
|
|
257
|
-
> = ElementView<ViewIDs, Tags> | DynamicView<ViewIDs, Tags> | DeploymentView<ViewIDs, Tags>
|
|
258
|
-
|
|
259
|
-
export function isDeploymentView(view: LikeC4View): view is DeploymentView
|
|
260
|
-
export function isDeploymentView<V extends { __?: string }>(view: V): boolean
|
|
261
|
-
export function isDeploymentView(view: LikeC4View): view is DeploymentView {
|
|
262
|
-
return view.__ === 'deployment'
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
export function isDynamicView(view: LikeC4View): view is DynamicView {
|
|
266
|
-
return view.__ === 'dynamic'
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
export function isElementView(view: LikeC4View): view is ElementView {
|
|
270
|
-
return isNullish(view.__) || view.__ === 'element'
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
export function isExtendsElementView(view: LikeC4View): view is ExtendsElementView<string, string> {
|
|
274
|
-
return isElementView(view) && 'extends' in view
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
export function isScopedElementView(view: LikeC4View): view is ScopedElementView<string, string> {
|
|
278
|
-
return isElementView(view) && 'viewOf' in view
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
export type NodeId<IDs extends string = string> = Tagged<IDs, 'Fqn'>
|
|
282
|
-
|
|
283
|
-
export type EdgeId = Tagged<string, 'EdgeId'>
|
|
284
|
-
export type StepEdgeIdLiteral = `step-${number}` | `step-${number}.${number}`
|
|
285
|
-
export type StepEdgeId = Tagged<StepEdgeIdLiteral, 'EdgeId'>
|
|
286
|
-
export function stepEdgeId(step: number, parallelStep?: number): StepEdgeId {
|
|
287
|
-
const id = `step-${String(step).padStart(2, '0')}` as StepEdgeId
|
|
288
|
-
return parallelStep ? `${id}.${parallelStep}` as StepEdgeId : id
|
|
100
|
+
return 'include' in rule || 'exclude' in rule
|
|
289
101
|
}
|
|
290
102
|
|
|
291
|
-
export function
|
|
292
|
-
|
|
103
|
+
export function isViewRuleStyle<V extends ViewRule<any>>(
|
|
104
|
+
rule: V,
|
|
105
|
+
): rule is Extract<V, { targets: any[]; style: {} }> {
|
|
106
|
+
return 'targets' in rule && 'style' in rule
|
|
293
107
|
}
|
|
294
108
|
|
|
295
|
-
export function
|
|
296
|
-
|
|
297
|
-
throw new Error(`Invalid step edge id: ${id}`)
|
|
298
|
-
}
|
|
299
|
-
return parseFloat(id.slice('step-'.length))
|
|
109
|
+
export function isComputedView<V extends AnyView<any>>(view: V): view is ExtractOnStage<V, 'computed'> {
|
|
110
|
+
return view._stage === 'computed'
|
|
300
111
|
}
|
|
301
112
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
export function getParallelStepsPrefix(id: string): string | null {
|
|
305
|
-
if (isStepEdgeId(id) && id.includes('.')) {
|
|
306
|
-
return id.slice(0, id.indexOf('.') + 1)
|
|
307
|
-
}
|
|
308
|
-
return null
|
|
113
|
+
export function isDiagramView<V extends AnyView<any>>(view: V): view is ExtractOnStage<V, 'layouted'> {
|
|
114
|
+
return view._stage === 'layouted'
|
|
309
115
|
}
|
|
116
|
+
export { isDiagramView as isLayoutedView }
|
|
310
117
|
|
|
311
|
-
export
|
|
312
|
-
|
|
313
|
-
kind: string // TODO: fix ElementKind | DeploymentNodeKind
|
|
314
|
-
parent: NodeId | null
|
|
315
|
-
/**
|
|
316
|
-
* Reference to model element
|
|
317
|
-
* If 1 - node id is a reference
|
|
318
|
-
*/
|
|
319
|
-
modelRef?: 1 | Fqn
|
|
320
|
-
/**
|
|
321
|
-
* Reference to deployment element
|
|
322
|
-
* If 1 - node id is a reference
|
|
323
|
-
*/
|
|
324
|
-
deploymentRef?: 1 | Fqn
|
|
325
|
-
title: string
|
|
326
|
-
description: string | null
|
|
327
|
-
technology: string | null
|
|
328
|
-
notation?: string
|
|
329
|
-
tags: NonEmptyArray<Tag> | null
|
|
330
|
-
links: NonEmptyArray<Link> | null
|
|
331
|
-
children: NodeId[]
|
|
332
|
-
inEdges: EdgeId[]
|
|
333
|
-
outEdges: EdgeId[]
|
|
334
|
-
shape: ElementShape
|
|
335
|
-
color: Color
|
|
336
|
-
/**
|
|
337
|
-
* @deprecated Use `style` instead
|
|
338
|
-
*/
|
|
339
|
-
icon?: IconUrl
|
|
340
|
-
style: ElementStyle
|
|
341
|
-
navigateTo?: ViewId | null
|
|
342
|
-
level: number
|
|
343
|
-
// For compound nodes, the max depth of nested nodes
|
|
344
|
-
depth?: number
|
|
345
|
-
/**
|
|
346
|
-
* If this node was customized in the view
|
|
347
|
-
*/
|
|
348
|
-
isCustomized?: boolean
|
|
349
|
-
}
|
|
350
|
-
export namespace ComputedNode {
|
|
351
|
-
export function modelRef(node: ComputedNode): Fqn | null {
|
|
352
|
-
return node.modelRef === 1 ? node.id : (node.modelRef ?? null)
|
|
353
|
-
}
|
|
354
|
-
export function deploymentRef(node: ComputedNode): Fqn | null {
|
|
355
|
-
return node.deploymentRef === 1 ? node.id : (node.deploymentRef ?? null)
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Nodes group is a special kind of node, exisiting only in view
|
|
359
|
-
*/
|
|
360
|
-
export function isNodesGroup(node: ComputedNode): boolean {
|
|
361
|
-
return node.kind === ElementKind.Group
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
export interface ComputedEdge {
|
|
366
|
-
id: EdgeId
|
|
367
|
-
parent: NodeId | null
|
|
368
|
-
source: NodeId
|
|
369
|
-
target: NodeId
|
|
370
|
-
label: string | null
|
|
371
|
-
description?: string
|
|
372
|
-
technology?: string
|
|
373
|
-
relations: RelationId[]
|
|
374
|
-
kind?: RelationshipKind
|
|
375
|
-
notation?: string
|
|
376
|
-
// Notes for walkthrough
|
|
377
|
-
notes?: string
|
|
378
|
-
color?: Color
|
|
379
|
-
line?: RelationshipLineType
|
|
380
|
-
head?: RelationshipArrowType
|
|
381
|
-
tail?: RelationshipArrowType
|
|
382
|
-
tags?: NonEmptyArray<Tag>
|
|
383
|
-
// Link to dynamic view
|
|
384
|
-
navigateTo?: ViewId
|
|
385
|
-
/**
|
|
386
|
-
* If this edge is derived from custom relationship predicate
|
|
387
|
-
*/
|
|
388
|
-
isCustomized?: boolean
|
|
389
|
-
/**
|
|
390
|
-
* For layouting purposes
|
|
391
|
-
* @default 'forward'
|
|
392
|
-
*/
|
|
393
|
-
dir?: 'forward' | 'back' | 'both'
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
export interface ViewWithHash {
|
|
397
|
-
/**
|
|
398
|
-
* Hash of the view object.
|
|
399
|
-
* This is used to detect changes in layout
|
|
400
|
-
*/
|
|
401
|
-
hash: string
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
export interface ViewWithNotation {
|
|
405
|
-
notation?: {
|
|
406
|
-
elements: ElementNotation[]
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
export interface ViewAutoLayout {
|
|
410
|
-
direction: ViewRuleAutoLayout['direction']
|
|
411
|
-
rankSep?: number
|
|
412
|
-
nodeSep?: number
|
|
413
|
-
}
|
|
414
|
-
export interface ComputedElementView<
|
|
415
|
-
ViewIDs extends string = string,
|
|
416
|
-
Tags extends string = string,
|
|
417
|
-
> extends Omit<ElementView<ViewIDs, Tags>, 'rules' | 'docUri'>, ViewWithHash, ViewWithNotation {
|
|
418
|
-
readonly extends?: ViewId<ViewIDs>
|
|
419
|
-
readonly autoLayout: ViewAutoLayout
|
|
420
|
-
readonly nodes: ComputedNode[]
|
|
421
|
-
readonly edges: ComputedEdge[]
|
|
422
|
-
rules?: never
|
|
423
|
-
docUri?: never
|
|
424
|
-
}
|
|
425
|
-
export interface ComputedDynamicView<
|
|
426
|
-
ViewIDs extends string = string,
|
|
427
|
-
Tags extends string = string,
|
|
428
|
-
> extends Omit<DynamicView<ViewIDs, Tags>, 'rules' | 'steps' | 'docUri'>, ViewWithHash, ViewWithNotation {
|
|
429
|
-
readonly autoLayout: ViewAutoLayout
|
|
430
|
-
readonly nodes: ComputedNode[]
|
|
431
|
-
readonly edges: ComputedEdge[]
|
|
432
|
-
steps?: never
|
|
433
|
-
rules?: never
|
|
434
|
-
docUri?: never
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
export interface ComputedDeploymentView<
|
|
438
|
-
ViewIDs extends string = string,
|
|
439
|
-
Tags extends string = string,
|
|
440
|
-
> extends Omit<DeploymentView<ViewIDs, Tags>, 'rules' | 'docUri'>, ViewWithHash, ViewWithNotation {
|
|
441
|
-
readonly autoLayout: ViewAutoLayout
|
|
442
|
-
readonly nodes: ComputedNode[]
|
|
443
|
-
readonly edges: ComputedEdge[]
|
|
444
|
-
rules?: never
|
|
445
|
-
docUri?: never
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
export type ComputedView<
|
|
449
|
-
ViewIDs extends string = string,
|
|
450
|
-
Tags extends string = string,
|
|
451
|
-
> = ComputedElementView<ViewIDs, Tags> | ComputedDynamicView<ViewIDs, Tags> | ComputedDeploymentView<ViewIDs, Tags>
|
|
452
|
-
|
|
453
|
-
export namespace ComputedView {
|
|
454
|
-
export function isDeployment(view: ComputedView): view is ComputedDeploymentView {
|
|
455
|
-
return view.__ === 'deployment'
|
|
456
|
-
}
|
|
457
|
-
export function isDynamic(view: ComputedView): view is ComputedDynamicView {
|
|
458
|
-
return view.__ === 'dynamic'
|
|
459
|
-
}
|
|
460
|
-
export function isElement(view: ComputedView): view is ComputedElementView {
|
|
461
|
-
return isNullish(view.__) || view.__ === 'element'
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
// Bounding box
|
|
466
|
-
export type BBox = {
|
|
467
|
-
x: number
|
|
468
|
-
y: number
|
|
469
|
-
width: number
|
|
470
|
-
height: number
|
|
118
|
+
export function isElementView<V extends AnyView<any>>(view: V): view is ViewWithType<V, 'element'> {
|
|
119
|
+
return view._type === 'element'
|
|
471
120
|
}
|
|
472
121
|
|
|
473
|
-
export function
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
height,
|
|
478
|
-
}: BBox): XYPoint {
|
|
479
|
-
return {
|
|
480
|
-
x: x + width / 2,
|
|
481
|
-
y: y + height / 2,
|
|
482
|
-
}
|
|
122
|
+
export function isScopedElementView<V extends AnyView<any>>(
|
|
123
|
+
view: V,
|
|
124
|
+
): view is ViewWithType<V, 'element'> & { viewOf: aux.StrictFqn<Any> } {
|
|
125
|
+
return isElementView(view) && isTruthy(view.viewOf)
|
|
483
126
|
}
|
|
484
127
|
|
|
485
|
-
export
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
position: Point
|
|
490
|
-
labelBBox: BBox
|
|
128
|
+
export function isExtendsElementView<V extends AnyView<any>>(
|
|
129
|
+
view: V,
|
|
130
|
+
): view is ViewWithType<V, 'element'> & { extends: aux.StrictViewId<Any> } {
|
|
131
|
+
return isElementView(view) && isTruthy(view.extends)
|
|
491
132
|
}
|
|
492
133
|
|
|
493
|
-
export
|
|
494
|
-
|
|
495
|
-
return node.modelRef === 1 ? node.id : (node.modelRef ?? null)
|
|
496
|
-
}
|
|
497
|
-
export function deploymentRef(node: Pick<DiagramNode, 'id' | 'deploymentRef'>): Fqn | null {
|
|
498
|
-
return node.deploymentRef === 1 ? node.id : (node.deploymentRef ?? null)
|
|
499
|
-
}
|
|
500
|
-
/**
|
|
501
|
-
* Nodes group is a special kind of node, exisiting only in view
|
|
502
|
-
*/
|
|
503
|
-
export function isNodesGroup(node: Pick<DiagramNode, 'kind'>): boolean {
|
|
504
|
-
return node.kind === ElementKind.Group
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
export interface DiagramEdge extends ComputedEdge {
|
|
509
|
-
// Bezier points
|
|
510
|
-
points: NonEmptyArray<Point>
|
|
511
|
-
// Control points to adjust the edge
|
|
512
|
-
controlPoints?: NonEmptyArray<XYPoint>
|
|
513
|
-
labelBBox?: BBox | null
|
|
514
|
-
// Graphviz edge POS
|
|
515
|
-
// TODO: temporary solution, should be moved out
|
|
516
|
-
dotpos?: string
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
export interface DiagramView<
|
|
520
|
-
ViewIDs extends string = string,
|
|
521
|
-
Tags extends string = string,
|
|
522
|
-
> extends Omit<ComputedView<ViewIDs, Tags>, 'nodes' | 'edges' | 'manualLayout'> {
|
|
523
|
-
readonly nodes: DiagramNode[]
|
|
524
|
-
readonly edges: DiagramEdge[]
|
|
525
|
-
readonly bounds: BBox
|
|
526
|
-
|
|
527
|
-
/**
|
|
528
|
-
* If diagram has manual layout
|
|
529
|
-
* But was changed and layout should be recalculated
|
|
530
|
-
*/
|
|
531
|
-
hasLayoutDrift?: boolean
|
|
532
|
-
// Should not exist in DiagramView
|
|
533
|
-
manualLayout?: never
|
|
134
|
+
export function isDeploymentView<V extends AnyView<any>>(view: V): view is ViewWithType<V, 'deployment'> {
|
|
135
|
+
return view._type === 'deployment'
|
|
534
136
|
}
|
|
535
137
|
|
|
536
|
-
export
|
|
537
|
-
|
|
538
|
-
readonly hash: string
|
|
539
|
-
readonly x: number
|
|
540
|
-
readonly y: number
|
|
541
|
-
readonly width: number
|
|
542
|
-
readonly height: number
|
|
543
|
-
readonly autoLayout: ViewAutoLayout
|
|
544
|
-
readonly nodes: Record<string, {
|
|
545
|
-
isCompound: boolean
|
|
546
|
-
x: number
|
|
547
|
-
y: number
|
|
548
|
-
width: number
|
|
549
|
-
height: number
|
|
550
|
-
}>
|
|
551
|
-
readonly edges: Record<string, {
|
|
552
|
-
// Graphviz edge POS
|
|
553
|
-
dotpos?: string
|
|
554
|
-
// Bezier points
|
|
555
|
-
points: NonEmptyArray<Point>
|
|
556
|
-
// Control points to adjust the edge
|
|
557
|
-
controlPoints?: NonEmptyArray<XYPoint>
|
|
558
|
-
labelBBox?: BBox
|
|
559
|
-
}>
|
|
138
|
+
export function isDynamicView<V extends AnyView<any>>(view: V): view is ViewWithType<V, 'dynamic'> {
|
|
139
|
+
return view._type === 'dynamic'
|
|
560
140
|
}
|