@likec4/core 1.17.1 → 1.19.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/builder/index.d.mts +502 -0
- package/dist/builder/index.d.ts +502 -0
- package/dist/builder/index.js +871 -0
- package/dist/compute-view/index.d.mts +22 -0
- package/dist/compute-view/index.d.ts +22 -0
- package/dist/compute-view/index.js +78 -0
- package/dist/index.d.mts +10 -919
- package/dist/index.d.ts +10 -919
- package/dist/{index.mjs → index.js} +7 -1688
- package/dist/model/index.d.mts +254 -0
- package/dist/model/index.d.ts +254 -0
- package/dist/model/index.js +1 -0
- package/dist/shared/chunk-RAAYCPUM.M-JWF7SS.js +21 -0
- package/dist/shared/core.BIfgabEw.d.ts +719 -0
- package/dist/shared/core.BZ9Msq7w.d.mts +719 -0
- package/dist/shared/{core.CoLQkcYL.d.cts → core.C05RDLhi.d.ts} +460 -362
- package/dist/shared/{core.CoLQkcYL.d.mts → core.CmYMqgha.d.mts} +460 -362
- package/dist/shared/core.D6-fWbM3.d.ts +127 -0
- package/dist/shared/core.D74xkKkG.d.mts +148 -0
- package/dist/shared/core.D74xkKkG.d.ts +148 -0
- package/dist/shared/core.sLaWHBjR.d.mts +127 -0
- package/dist/shared/index.-BdzdI2C.js +7443 -0
- package/dist/shared/object_hash.CE_oF3I3.js +1222 -0
- package/dist/shared/{core.BXTs-8n7.mjs → view.CyZrG8BJ.js} +108 -47
- package/dist/types/index.d.mts +71 -1
- package/dist/types/index.d.ts +71 -1
- package/dist/types/index.js +20 -0
- package/dist/utils/index.d.mts +404 -0
- package/dist/utils/index.d.ts +404 -0
- package/dist/utils/index.js +330 -0
- package/package.json +59 -47
- package/src/builder/Builder-style1.test-d.ts +190 -0
- package/src/builder/Builder-style2.test-d.ts +175 -0
- package/src/builder/Builder.deployment.ts +224 -0
- package/src/builder/Builder.deploymentModel.ts +385 -0
- package/src/builder/Builder.element.ts +19 -19
- package/src/builder/Builder.model.ts +67 -42
- package/src/builder/Builder.ts +533 -367
- package/src/builder/Builder.view-common.ts +234 -0
- package/src/builder/Builder.view-deployment.ts +135 -0
- package/src/builder/Builder.view-element.ts +189 -0
- package/src/builder/Builder.views.ts +109 -33
- package/src/builder/Builder.with.ts +475 -0
- package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +374 -0
- package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +183 -0
- package/src/builder/__snapshots__/Builder.spec.ts.snap +374 -0
- package/src/builder/_types.ts +113 -18
- package/src/builder/index.ts +10 -4
- package/src/colors/index.ts +2 -2
- package/src/compute-view/compute-view.ts +83 -0
- package/src/compute-view/deployment-view/__test__/TestHelper.ts +236 -0
- package/src/compute-view/deployment-view/__test__/fixture.ts +198 -0
- package/src/compute-view/deployment-view/_types.ts +37 -0
- package/src/compute-view/deployment-view/clean-connections.ts +238 -0
- package/src/compute-view/deployment-view/compute.ts +125 -0
- package/src/compute-view/deployment-view/memory/index.ts +9 -0
- package/src/compute-view/deployment-view/memory/memory.ts +97 -0
- package/src/compute-view/deployment-view/predicates/elements.ts +144 -0
- package/src/compute-view/deployment-view/predicates/relation-direct.ts +237 -0
- package/src/compute-view/deployment-view/predicates/relation-in-out.ts +61 -0
- package/src/compute-view/deployment-view/predicates/relation-incoming.ts +95 -0
- package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +88 -0
- package/src/compute-view/deployment-view/predicates/wildcard.ts +29 -0
- package/src/compute-view/deployment-view/stages/stage-exclude.ts +5 -0
- package/src/compute-view/deployment-view/stages/stage-final.ts +245 -0
- package/src/compute-view/deployment-view/stages/stage-include.ts +95 -0
- package/src/compute-view/deployment-view/utils.ts +276 -0
- package/src/compute-view/dynamic-view/__test__/fixture.ts +58 -0
- package/src/compute-view/dynamic-view/compute.ts +324 -0
- package/src/compute-view/element-view/__test__/TestHelper.ts +258 -0
- package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +458 -0
- package/src/compute-view/element-view/__test__/fixture.ts +675 -0
- package/src/compute-view/element-view/_types.ts +48 -0
- package/src/compute-view/element-view/clean-connections.ts +113 -0
- package/src/compute-view/element-view/compute.ts +315 -0
- package/src/compute-view/element-view/memory/NodeGroup.ts +31 -0
- package/src/compute-view/element-view/memory/index.ts +10 -0
- package/src/compute-view/element-view/memory/memory.ts +177 -0
- package/src/compute-view/element-view/memory/stage-exclude.ts +59 -0
- package/src/compute-view/element-view/memory/stage-final.ts +129 -0
- package/src/compute-view/element-view/memory/stage-include.ts +128 -0
- package/src/compute-view/element-view/predicates/_utils.ts +86 -0
- package/src/compute-view/element-view/predicates/element-expand.ts +33 -0
- package/src/compute-view/element-view/predicates/element-kind-tag.ts +26 -0
- package/src/compute-view/element-view/predicates/element-ref.ts +37 -0
- package/src/compute-view/element-view/predicates/relation-direct.ts +309 -0
- package/src/compute-view/element-view/predicates/relation-in-out.ts +66 -0
- package/src/compute-view/element-view/predicates/relation-in.ts +118 -0
- package/src/compute-view/element-view/predicates/relation-out.ts +116 -0
- package/src/compute-view/element-view/predicates/wildcard.ts +88 -0
- package/src/compute-view/element-view/utils.ts +59 -0
- package/src/compute-view/index.ts +4 -0
- package/src/compute-view/memory/AbstractMemory.ts +45 -0
- package/src/compute-view/memory/AbstractStageExclude.ts +216 -0
- package/src/compute-view/memory/AbstractStageInclude.ts +200 -0
- package/src/compute-view/memory/_types.ts +147 -0
- package/src/compute-view/memory/index.ts +5 -0
- package/src/compute-view/memory/ops.ts +43 -0
- package/src/compute-view/utils/__snapshots__/sortNodes.spec.ts.snap +113 -0
- package/src/compute-view/utils/ancestorsOfNode.ts +19 -0
- package/src/compute-view/utils/applyCustomElementProperties.ts +66 -0
- package/src/compute-view/utils/applyCustomRelationProperties.ts +41 -0
- package/src/compute-view/utils/applyViewRuleStyles.ts +53 -0
- package/src/compute-view/utils/buildComputedNodes.ts +148 -0
- package/src/compute-view/utils/buildElementNotations.ts +63 -0
- package/src/compute-view/utils/elementExpressionToPredicate.ts +50 -0
- package/src/compute-view/utils/link-nodes-with-edges.ts +54 -0
- package/src/compute-view/utils/merge-props-from-relationships.ts +128 -0
- package/src/compute-view/utils/relationExpressionToPredicates.ts +55 -0
- package/src/compute-view/utils/resolve-extended-views.ts +69 -0
- package/src/compute-view/utils/resolve-global-rules.ts +83 -0
- package/src/compute-view/utils/topological-sort.ts +256 -0
- package/src/compute-view/utils/uniqueTags.test.ts +42 -0
- package/src/compute-view/utils/uniqueTags.ts +21 -0
- package/src/compute-view/utils/view-hash.ts +27 -0
- package/src/compute-view/utils/with-readable-edges.ts +36 -0
- package/src/index.ts +22 -12
- package/src/model/DeploymentElementModel.ts +599 -0
- package/src/model/DeploymentModel.ts +370 -0
- package/src/model/ElementModel.ts +221 -0
- package/src/model/LikeC4Model.test-d.ts +152 -0
- package/src/model/LikeC4Model.ts +336 -457
- package/src/model/RelationModel.ts +85 -0
- package/src/model/__test__/fixture.ts +149 -338
- package/src/model/connection/Connection.ts +72 -0
- package/src/model/connection/deployment/DeploymentConnectionModel.ts +178 -0
- package/src/model/connection/deployment/find.ts +120 -0
- package/src/model/connection/deployment/index.ts +8 -0
- package/src/model/connection/index.ts +22 -0
- package/src/model/connection/model/ConnectionModel.ts +157 -0
- package/src/model/connection/model/find.ts +117 -0
- package/src/model/connection/model/index.ts +8 -0
- package/src/model/connection/ops.ts +274 -0
- package/src/model/guards.ts +9 -0
- package/src/model/index.ts +46 -2
- package/src/model/types.ts +112 -15
- package/src/model/view/EdgeModel.ts +103 -0
- package/src/model/view/LikeC4ViewModel.ts +226 -0
- package/src/model/view/NodeModel.ts +229 -0
- package/src/types/_common.ts +55 -1
- package/src/types/deployments.ts +169 -0
- package/src/types/element.ts +9 -5
- package/src/types/expression-v2.ts +172 -0
- package/src/types/expression.ts +17 -11
- package/src/types/global.ts +3 -3
- package/src/types/index.ts +220 -12
- package/src/types/model.ts +75 -12
- package/src/types/operators.ts +1 -1
- package/src/types/overview-graph.ts +2 -2
- package/src/types/relation.ts +18 -14
- package/src/types/theme.ts +0 -1
- package/src/types/view-notation.ts +2 -2
- package/src/types/view.ts +117 -41
- package/src/utils/{commonHead.ts → common-head.ts} +2 -0
- package/src/utils/const.ts +1 -0
- package/src/utils/fqn.ts +203 -56
- package/src/utils/getOrCreate.ts +42 -0
- package/src/utils/graphlib.ts +10 -0
- package/src/utils/index.ts +74 -6
- package/src/utils/iterable/_types.ts +5 -0
- package/src/utils/iterable/filter.ts +55 -0
- package/src/utils/iterable/flat.ts +17 -0
- package/src/utils/iterable/index.ts +12 -0
- package/src/utils/iterable/map.ts +40 -0
- package/src/utils/iterable/reduce.ts +24 -0
- package/src/utils/iterable/some.ts +36 -0
- package/src/utils/iterable/to.ts +19 -0
- package/src/utils/iterable/unique.ts +29 -0
- package/src/utils/object-hash.ts +3 -0
- package/src/utils/relations.ts +3 -64
- package/src/utils/set.ts +78 -0
- package/src/utils/string-hash.ts +16 -0
- package/dist/index.cjs +0 -5452
- package/dist/index.d.cts +0 -1053
- package/dist/shared/core.CoLQkcYL.d.ts +0 -734
- package/dist/shared/core.DIYZvpVg.cjs +0 -353
- package/dist/types/index.cjs +0 -70
- package/dist/types/index.d.cts +0 -2
- package/dist/types/index.mjs +0 -1
- package/src/builder/Builder.test-d.ts +0 -69
- package/src/builder/Builder.view.ts +0 -358
- package/src/model/LikeC4DiagramModel.ts +0 -338
- package/src/model/LikeC4ViewModel.ts +0 -320
package/src/types/relation.ts
CHANGED
|
@@ -2,9 +2,9 @@ import type { Tagged } from 'type-fest'
|
|
|
2
2
|
import type { NonEmptyArray } from './_common'
|
|
3
3
|
import type { Fqn, Link, Tag } from './element'
|
|
4
4
|
import type { Color, ThemeColor } from './theme'
|
|
5
|
-
import type {
|
|
5
|
+
import type { ViewId } from './view'
|
|
6
6
|
|
|
7
|
-
export type
|
|
7
|
+
export type RelationId = Tagged<string, 'RelationID'>
|
|
8
8
|
export type RelationshipKind<Kinds extends string = string> = Tagged<Kinds, 'RelationshipKind'>
|
|
9
9
|
|
|
10
10
|
export type RelationshipLineType = 'dashed' | 'solid' | 'dotted'
|
|
@@ -22,30 +22,34 @@ export type RelationshipArrowType =
|
|
|
22
22
|
| 'open'
|
|
23
23
|
| 'vee'
|
|
24
24
|
|
|
25
|
-
export const DefaultLineStyle = 'dashed'
|
|
26
|
-
export const DefaultArrowType = 'normal'
|
|
27
|
-
export const DefaultRelationshipColor = 'gray'
|
|
25
|
+
export const DefaultLineStyle: RelationshipLineType = 'dashed'
|
|
26
|
+
export const DefaultArrowType: RelationshipArrowType = 'normal'
|
|
27
|
+
export const DefaultRelationshipColor: ThemeColor = 'gray'
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
readonly
|
|
32
|
-
readonly source: Fqn
|
|
33
|
-
readonly target: Fqn
|
|
34
|
-
readonly title: string
|
|
29
|
+
export interface AbstractRelation {
|
|
30
|
+
readonly id: RelationId
|
|
31
|
+
readonly title?: string
|
|
35
32
|
readonly description?: string
|
|
36
33
|
readonly technology?: string
|
|
37
|
-
readonly tags?: NonEmptyArray<Tag>
|
|
34
|
+
readonly tags?: NonEmptyArray<Tag> | null
|
|
38
35
|
readonly kind?: RelationshipKind
|
|
39
36
|
readonly color?: Color
|
|
40
37
|
readonly line?: RelationshipLineType
|
|
41
38
|
readonly head?: RelationshipArrowType
|
|
42
39
|
readonly tail?: RelationshipArrowType
|
|
43
|
-
readonly links?: NonEmptyArray<Link>
|
|
40
|
+
readonly links?: NonEmptyArray<Link> | null
|
|
44
41
|
// Link to dynamic view
|
|
45
|
-
readonly navigateTo?:
|
|
42
|
+
readonly navigateTo?: ViewId
|
|
46
43
|
readonly metadata?: { [key: string]: string }
|
|
47
44
|
}
|
|
48
45
|
|
|
46
|
+
// TODO: rename to Relationship
|
|
47
|
+
export interface ModelRelation extends AbstractRelation {
|
|
48
|
+
readonly source: Fqn
|
|
49
|
+
readonly target: Fqn
|
|
50
|
+
readonly title: string
|
|
51
|
+
}
|
|
52
|
+
|
|
49
53
|
export interface RelationshipKindSpecification {
|
|
50
54
|
readonly technology?: string
|
|
51
55
|
readonly notation?: string
|
package/src/types/theme.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ElementShape } from './element'
|
|
2
2
|
import type { Color } from './theme'
|
|
3
3
|
|
|
4
4
|
export type ElementNotation = {
|
|
5
|
-
kinds:
|
|
5
|
+
kinds: string[]
|
|
6
6
|
shape: ElementShape
|
|
7
7
|
color: Color
|
|
8
8
|
title: string
|
package/src/types/view.ts
CHANGED
|
@@ -8,15 +8,16 @@ import {
|
|
|
8
8
|
type ElementStyle,
|
|
9
9
|
type Fqn,
|
|
10
10
|
type Link,
|
|
11
|
-
type Tag
|
|
11
|
+
type Tag,
|
|
12
12
|
} from './element'
|
|
13
13
|
import type { ElementExpression, ElementPredicateExpression, Expression } from './expression'
|
|
14
|
+
import type { ExpressionV2, FqnExpr } from './expression-v2'
|
|
14
15
|
import type { GlobalPredicateId, GlobalStyleID } from './global'
|
|
15
|
-
import type {
|
|
16
|
+
import type { RelationId, RelationshipArrowType, RelationshipKind, RelationshipLineType } from './relation'
|
|
16
17
|
import type { Color, ThemeColorValues } from './theme'
|
|
17
18
|
import type { ElementNotation } from './view-notation'
|
|
18
19
|
|
|
19
|
-
export type
|
|
20
|
+
export type ViewId<Id extends string = string> = Tagged<Id, 'ViewID'>
|
|
20
21
|
|
|
21
22
|
export type ViewRulePredicate =
|
|
22
23
|
| {
|
|
@@ -27,7 +28,11 @@ export type ViewRulePredicate =
|
|
|
27
28
|
include?: never
|
|
28
29
|
exclude: Expression[]
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
+
|
|
32
|
+
export function isViewRulePredicate(rule: DeploymentViewRule): rule is DeploymentViewRulePredicate
|
|
33
|
+
export function isViewRulePredicate(rule: DynamicViewRule): rule is DynamicViewIncludeRule
|
|
34
|
+
export function isViewRulePredicate(rule: ViewRule): rule is ViewRulePredicate
|
|
35
|
+
export function isViewRulePredicate(rule: object) {
|
|
31
36
|
return (
|
|
32
37
|
('include' in rule && Array.isArray(rule.include))
|
|
33
38
|
|| ('exclude' in rule && Array.isArray(rule.exclude))
|
|
@@ -50,8 +55,10 @@ export interface ViewRuleStyle {
|
|
|
50
55
|
icon?: IconUrl
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
|
-
export function isViewRuleStyle(rule:
|
|
54
|
-
|
|
58
|
+
export function isViewRuleStyle(rule: DeploymentViewRule): rule is DeploymentViewRuleStyle
|
|
59
|
+
export function isViewRuleStyle(rule: ViewRule): rule is ViewRuleStyle
|
|
60
|
+
export function isViewRuleStyle(rule: object) {
|
|
61
|
+
return 'style' in rule && 'targets' in rule && Array.isArray(rule.targets)
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
export interface ViewRuleGlobalStyle {
|
|
@@ -73,7 +80,10 @@ export interface ViewRuleAutoLayout {
|
|
|
73
80
|
nodeSep?: number
|
|
74
81
|
rankSep?: number
|
|
75
82
|
}
|
|
76
|
-
|
|
83
|
+
|
|
84
|
+
export function isViewRuleAutoLayout(
|
|
85
|
+
rule: DeploymentViewRule | DynamicViewRule | ViewRule,
|
|
86
|
+
): rule is ViewRuleAutoLayout {
|
|
77
87
|
return 'direction' in rule
|
|
78
88
|
}
|
|
79
89
|
|
|
@@ -99,12 +109,12 @@ export type ViewRule =
|
|
|
99
109
|
| ViewRuleAutoLayout
|
|
100
110
|
|
|
101
111
|
export interface BasicView<
|
|
102
|
-
ViewType extends 'element' | 'dynamic',
|
|
112
|
+
ViewType extends 'element' | 'dynamic' | 'deployment',
|
|
103
113
|
ViewIDs extends string,
|
|
104
|
-
Tags extends string
|
|
114
|
+
Tags extends string,
|
|
105
115
|
> {
|
|
106
116
|
readonly __?: ViewType
|
|
107
|
-
readonly id:
|
|
117
|
+
readonly id: ViewId<ViewIDs>
|
|
108
118
|
readonly title: string | null
|
|
109
119
|
readonly description: string | null
|
|
110
120
|
readonly tags: NonEmptyArray<Tag<Tags>> | null
|
|
@@ -148,11 +158,11 @@ export interface ScopedElementView<ViewIDs extends string, Tags extends string>
|
|
|
148
158
|
export interface ExtendsElementView<ViewIDs extends string, Tags extends string>
|
|
149
159
|
extends BasicElementView<ViewIDs, Tags>
|
|
150
160
|
{
|
|
151
|
-
readonly extends:
|
|
161
|
+
readonly extends: ViewId<ViewIDs>
|
|
152
162
|
}
|
|
153
163
|
export type ElementView<
|
|
154
164
|
ViewIDs extends string = string,
|
|
155
|
-
Tags extends string = string
|
|
165
|
+
Tags extends string = string,
|
|
156
166
|
> =
|
|
157
167
|
| ScopedElementView<ViewIDs, Tags>
|
|
158
168
|
| ExtendsElementView<ViewIDs, Tags>
|
|
@@ -173,7 +183,7 @@ export interface DynamicViewStep {
|
|
|
173
183
|
readonly tail?: RelationshipArrowType
|
|
174
184
|
readonly isBackward?: boolean
|
|
175
185
|
// Link to dynamic view
|
|
176
|
-
readonly navigateTo?:
|
|
186
|
+
readonly navigateTo?: ViewId
|
|
177
187
|
__parallel?: never
|
|
178
188
|
}
|
|
179
189
|
|
|
@@ -187,10 +197,6 @@ export type DynamicViewIncludeRule = {
|
|
|
187
197
|
include: ElementPredicateExpression[]
|
|
188
198
|
}
|
|
189
199
|
|
|
190
|
-
export function isDynamicViewIncludeRule(rule: DynamicViewRule): rule is DynamicViewIncludeRule {
|
|
191
|
-
return 'include' in rule && Array.isArray(rule.include)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
200
|
export type DynamicViewRule =
|
|
195
201
|
| DynamicViewIncludeRule
|
|
196
202
|
| ViewRuleGlobalPredicateRef
|
|
@@ -199,7 +205,7 @@ export type DynamicViewRule =
|
|
|
199
205
|
| ViewRuleAutoLayout
|
|
200
206
|
export interface DynamicView<
|
|
201
207
|
ViewIDs extends string = string,
|
|
202
|
-
Tags extends string = string
|
|
208
|
+
Tags extends string = string,
|
|
203
209
|
> extends BasicView<'dynamic', ViewIDs, Tags> {
|
|
204
210
|
readonly __: 'dynamic'
|
|
205
211
|
|
|
@@ -214,14 +220,49 @@ export function isDynamicViewParallelSteps(step: DynamicViewStepOrParallel): ste
|
|
|
214
220
|
|
|
215
221
|
export type CustomColorDefinitions = { [key: string]: ThemeColorValues }
|
|
216
222
|
|
|
223
|
+
export type DeploymentViewRulePredicate =
|
|
224
|
+
| {
|
|
225
|
+
include: ExpressionV2[]
|
|
226
|
+
exclude?: never
|
|
227
|
+
}
|
|
228
|
+
| {
|
|
229
|
+
include?: never
|
|
230
|
+
exclude: ExpressionV2[]
|
|
231
|
+
}
|
|
232
|
+
export type DeploymentViewRuleStyle = {
|
|
233
|
+
targets: FqnExpr[]
|
|
234
|
+
notation?: string
|
|
235
|
+
style: ElementStyle & {
|
|
236
|
+
color?: Color
|
|
237
|
+
shape?: ElementShape
|
|
238
|
+
icon?: IconUrl
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
export type DeploymentViewRule = DeploymentViewRulePredicate | ViewRuleAutoLayout | DeploymentViewRuleStyle
|
|
242
|
+
|
|
243
|
+
export interface DeploymentView<
|
|
244
|
+
ViewIDs extends string = string,
|
|
245
|
+
Tags extends string = string,
|
|
246
|
+
> extends BasicView<'deployment', ViewIDs, Tags> {
|
|
247
|
+
readonly __: 'deployment'
|
|
248
|
+
readonly rules: DeploymentViewRule[]
|
|
249
|
+
}
|
|
250
|
+
|
|
217
251
|
export type LikeC4View<
|
|
218
252
|
ViewIDs extends string = string,
|
|
219
|
-
Tags extends string = string
|
|
220
|
-
> = ElementView<ViewIDs, Tags> | DynamicView<ViewIDs, Tags>
|
|
253
|
+
Tags extends string = string,
|
|
254
|
+
> = ElementView<ViewIDs, Tags> | DynamicView<ViewIDs, Tags> | DeploymentView<ViewIDs, Tags>
|
|
255
|
+
|
|
256
|
+
export function isDeploymentView(view: LikeC4View): view is DeploymentView
|
|
257
|
+
export function isDeploymentView<V extends { __?: string }>(view: V): boolean
|
|
258
|
+
export function isDeploymentView(view: LikeC4View): view is DeploymentView {
|
|
259
|
+
return view.__ === 'deployment'
|
|
260
|
+
}
|
|
221
261
|
|
|
222
262
|
export function isDynamicView(view: LikeC4View): view is DynamicView {
|
|
223
263
|
return view.__ === 'dynamic'
|
|
224
264
|
}
|
|
265
|
+
|
|
225
266
|
export function isElementView(view: LikeC4View): view is ElementView {
|
|
226
267
|
return isNullish(view.__) || view.__ === 'element'
|
|
227
268
|
}
|
|
@@ -239,7 +280,7 @@ export type NodeId<IDs extends string = string> = Tagged<IDs, 'Fqn'>
|
|
|
239
280
|
export type EdgeId = Tagged<string, 'EdgeId'>
|
|
240
281
|
export type StepEdgeIdLiteral = `step-${number}` | `step-${number}.${number}`
|
|
241
282
|
export type StepEdgeId = Tagged<StepEdgeIdLiteral, 'EdgeId'>
|
|
242
|
-
export function
|
|
283
|
+
export function stepEdgeId(step: number, parallelStep?: number): StepEdgeId {
|
|
243
284
|
const id = `step-${String(step).padStart(2, '0')}` as StepEdgeId
|
|
244
285
|
return parallelStep ? `${id}.${parallelStep}` as StepEdgeId : id
|
|
245
286
|
}
|
|
@@ -266,8 +307,18 @@ export function getParallelStepsPrefix(id: string): string | null {
|
|
|
266
307
|
|
|
267
308
|
export interface ComputedNode {
|
|
268
309
|
id: NodeId
|
|
269
|
-
kind: ElementKind
|
|
310
|
+
kind: string // TODO: fix ElementKind | DeploymentNodeKind
|
|
270
311
|
parent: NodeId | null
|
|
312
|
+
/**
|
|
313
|
+
* Reference to model element
|
|
314
|
+
* If 1 - node id is a reference
|
|
315
|
+
*/
|
|
316
|
+
modelRef?: 1 | Fqn
|
|
317
|
+
/**
|
|
318
|
+
* Reference to deployment element
|
|
319
|
+
* If 1 - node id is a reference
|
|
320
|
+
*/
|
|
321
|
+
deploymentRef?: 1 | Fqn
|
|
271
322
|
title: string
|
|
272
323
|
description: string | null
|
|
273
324
|
technology: string | null
|
|
@@ -278,16 +329,13 @@ export interface ComputedNode {
|
|
|
278
329
|
inEdges: EdgeId[]
|
|
279
330
|
outEdges: EdgeId[]
|
|
280
331
|
shape: ElementShape
|
|
281
|
-
/**
|
|
282
|
-
* @deprecated Use `style` instead
|
|
283
|
-
*/
|
|
284
332
|
color: Color
|
|
285
333
|
/**
|
|
286
334
|
* @deprecated Use `style` instead
|
|
287
335
|
*/
|
|
288
336
|
icon?: IconUrl
|
|
289
337
|
style: ElementStyle
|
|
290
|
-
navigateTo?:
|
|
338
|
+
navigateTo?: ViewId
|
|
291
339
|
level: number
|
|
292
340
|
// For compound nodes, the max depth of nested nodes
|
|
293
341
|
depth?: number
|
|
@@ -297,6 +345,12 @@ export interface ComputedNode {
|
|
|
297
345
|
isCustomized?: boolean
|
|
298
346
|
}
|
|
299
347
|
export namespace ComputedNode {
|
|
348
|
+
export function modelRef(node: ComputedNode): Fqn | null {
|
|
349
|
+
return node.modelRef === 1 ? node.id : (node.modelRef ?? null)
|
|
350
|
+
}
|
|
351
|
+
export function deploymentRef(node: ComputedNode): Fqn | null {
|
|
352
|
+
return node.deploymentRef === 1 ? node.id : (node.deploymentRef ?? null)
|
|
353
|
+
}
|
|
300
354
|
/**
|
|
301
355
|
* Nodes group is a special kind of node, exisiting only in view
|
|
302
356
|
*/
|
|
@@ -313,7 +367,7 @@ export interface ComputedEdge {
|
|
|
313
367
|
label: string | null
|
|
314
368
|
description?: string
|
|
315
369
|
technology?: string
|
|
316
|
-
relations:
|
|
370
|
+
relations: RelationId[]
|
|
317
371
|
kind?: RelationshipKind
|
|
318
372
|
notation?: string
|
|
319
373
|
// Notes for walkthrough
|
|
@@ -324,7 +378,7 @@ export interface ComputedEdge {
|
|
|
324
378
|
tail?: RelationshipArrowType
|
|
325
379
|
tags?: NonEmptyArray<Tag>
|
|
326
380
|
// Link to dynamic view
|
|
327
|
-
navigateTo?:
|
|
381
|
+
navigateTo?: ViewId
|
|
328
382
|
/**
|
|
329
383
|
* If this edge is derived from custom relationship predicate
|
|
330
384
|
*/
|
|
@@ -333,7 +387,7 @@ export interface ComputedEdge {
|
|
|
333
387
|
* For layouting purposes
|
|
334
388
|
* @default 'forward'
|
|
335
389
|
*/
|
|
336
|
-
dir?: 'forward' | 'back'
|
|
390
|
+
dir?: 'forward' | 'back' | 'both'
|
|
337
391
|
}
|
|
338
392
|
|
|
339
393
|
export interface ViewWithHash {
|
|
@@ -356,9 +410,9 @@ export interface ViewAutoLayout {
|
|
|
356
410
|
}
|
|
357
411
|
export interface ComputedElementView<
|
|
358
412
|
ViewIDs extends string = string,
|
|
359
|
-
Tags extends string = string
|
|
413
|
+
Tags extends string = string,
|
|
360
414
|
> extends Omit<ElementView<ViewIDs, Tags>, 'rules' | 'docUri'>, ViewWithHash, ViewWithNotation {
|
|
361
|
-
readonly extends?:
|
|
415
|
+
readonly extends?: ViewId<ViewIDs>
|
|
362
416
|
readonly autoLayout: ViewAutoLayout
|
|
363
417
|
readonly nodes: ComputedNode[]
|
|
364
418
|
readonly edges: ComputedEdge[]
|
|
@@ -367,7 +421,7 @@ export interface ComputedElementView<
|
|
|
367
421
|
}
|
|
368
422
|
export interface ComputedDynamicView<
|
|
369
423
|
ViewIDs extends string = string,
|
|
370
|
-
Tags extends string = string
|
|
424
|
+
Tags extends string = string,
|
|
371
425
|
> extends Omit<DynamicView<ViewIDs, Tags>, 'rules' | 'steps' | 'docUri'>, ViewWithHash, ViewWithNotation {
|
|
372
426
|
readonly autoLayout: ViewAutoLayout
|
|
373
427
|
readonly nodes: ComputedNode[]
|
|
@@ -376,17 +430,33 @@ export interface ComputedDynamicView<
|
|
|
376
430
|
rules?: never
|
|
377
431
|
docUri?: never
|
|
378
432
|
}
|
|
379
|
-
|
|
380
|
-
|
|
433
|
+
|
|
434
|
+
export interface ComputedDeploymentView<
|
|
435
|
+
ViewIDs extends string = string,
|
|
436
|
+
Tags extends string = string,
|
|
437
|
+
> extends Omit<DeploymentView<ViewIDs, Tags>, 'rules' | 'docUri'>, ViewWithHash, ViewWithNotation {
|
|
438
|
+
readonly autoLayout: ViewAutoLayout
|
|
439
|
+
readonly nodes: ComputedNode[]
|
|
440
|
+
readonly edges: ComputedEdge[]
|
|
441
|
+
rules?: never
|
|
442
|
+
docUri?: never
|
|
381
443
|
}
|
|
382
444
|
|
|
383
445
|
export type ComputedView<
|
|
384
446
|
ViewIDs extends string = string,
|
|
385
|
-
Tags extends string = string
|
|
386
|
-
> = ComputedElementView<ViewIDs, Tags> | ComputedDynamicView<ViewIDs, Tags>
|
|
447
|
+
Tags extends string = string,
|
|
448
|
+
> = ComputedElementView<ViewIDs, Tags> | ComputedDynamicView<ViewIDs, Tags> | ComputedDeploymentView<ViewIDs, Tags>
|
|
387
449
|
|
|
388
|
-
export
|
|
389
|
-
|
|
450
|
+
export namespace ComputedView {
|
|
451
|
+
export function isDeployment(view: ComputedView): view is ComputedDeploymentView {
|
|
452
|
+
return view.__ === 'deployment'
|
|
453
|
+
}
|
|
454
|
+
export function isDynamic(view: ComputedView): view is ComputedDynamicView {
|
|
455
|
+
return view.__ === 'dynamic'
|
|
456
|
+
}
|
|
457
|
+
export function isElement(view: ComputedView): view is ComputedElementView {
|
|
458
|
+
return isNullish(view.__) || view.__ === 'element'
|
|
459
|
+
}
|
|
390
460
|
}
|
|
391
461
|
|
|
392
462
|
// Bounding box
|
|
@@ -401,11 +471,11 @@ export function getBBoxCenter({
|
|
|
401
471
|
x,
|
|
402
472
|
y,
|
|
403
473
|
width,
|
|
404
|
-
height
|
|
474
|
+
height,
|
|
405
475
|
}: BBox): XYPoint {
|
|
406
476
|
return {
|
|
407
477
|
x: x + width / 2,
|
|
408
|
-
y: y + height / 2
|
|
478
|
+
y: y + height / 2,
|
|
409
479
|
}
|
|
410
480
|
}
|
|
411
481
|
|
|
@@ -418,6 +488,12 @@ export interface DiagramNode extends ComputedNode {
|
|
|
418
488
|
}
|
|
419
489
|
|
|
420
490
|
export namespace DiagramNode {
|
|
491
|
+
export function modelRef(node: DiagramNode): Fqn | null {
|
|
492
|
+
return node.modelRef === 1 ? node.id : (node.modelRef ?? null)
|
|
493
|
+
}
|
|
494
|
+
export function deploymentRef(node: DiagramNode): Fqn | null {
|
|
495
|
+
return node.deploymentRef === 1 ? node.id : (node.deploymentRef ?? null)
|
|
496
|
+
}
|
|
421
497
|
/**
|
|
422
498
|
* Nodes group is a special kind of node, exisiting only in view
|
|
423
499
|
*/
|
|
@@ -439,7 +515,7 @@ export interface DiagramEdge extends ComputedEdge {
|
|
|
439
515
|
|
|
440
516
|
export interface DiagramView<
|
|
441
517
|
ViewIDs extends string = string,
|
|
442
|
-
Tags extends string = string
|
|
518
|
+
Tags extends string = string,
|
|
443
519
|
> extends Omit<ComputedView<ViewIDs, Tags>, 'nodes' | 'edges' | 'manualLayout'> {
|
|
444
520
|
readonly nodes: DiagramNode[]
|
|
445
521
|
readonly edges: DiagramEdge[]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const customInspectSymbol = Symbol.for('nodejs.util.inspect.custom')
|