@likec4/core 1.41.0 → 1.42.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/builder/package.json +4 -0
- package/compute-view/package.json +4 -0
- package/compute-view/relationships/package.json +4 -0
- package/dist/builder/index.d.mts +13 -11
- package/dist/builder/index.mjs +111 -91
- package/dist/compute-view/index.d.mts +8 -7
- package/dist/compute-view/index.mjs +14 -11
- package/dist/compute-view/relationships-view/index.d.mts +9 -8
- package/dist/compute-view/relationships-view/index.mjs +6 -6
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +11 -11
- package/dist/model/connection/deployment/index.d.mts +11 -10
- package/dist/model/connection/deployment/index.mjs +2 -2
- package/dist/model/connection/index.d.mts +12 -11
- package/dist/model/connection/index.mjs +3 -3
- package/dist/model/connection/model/index.d.mts +11 -10
- package/dist/model/connection/model/index.mjs +2 -2
- package/dist/model/index.d.mts +14 -14
- package/dist/model/index.mjs +4 -5
- package/dist/shared/{core.Ae86Y3tB.mjs → core.01VTr9qu.mjs} +8 -26
- package/dist/shared/core.1vX5a9AY.mjs +86 -0
- package/dist/shared/{core.BVNaR17u.mjs → core.B7KhhkRY.mjs} +1 -1
- package/dist/shared/core.B85MJLTf.mjs +5 -0
- package/dist/shared/{core.DA5vzwZ9.mjs → core.BIqHjQiH.mjs} +56 -42
- package/dist/shared/core.BKlholso.mjs +3 -0
- package/dist/shared/core.BR4zXDH-.mjs +13 -0
- package/dist/shared/{core.CXy1NLUG.mjs → core.BYNkXQ8A.mjs} +21 -12
- package/dist/shared/{core.BuoXfSMj.mjs → core.BbE4y-yl.mjs} +1 -1
- package/dist/shared/core.BoYfZOBm.mjs +3 -0
- package/dist/shared/core.BsSXS-_R.mjs +7 -0
- package/dist/shared/{core.DJp8fgok.mjs → core.BzTakU3I.mjs} +14 -10
- package/dist/shared/{core.4u1dVmfX.mjs → core.C2TiyjI6.mjs} +2 -2
- package/dist/shared/{core.DLpidoWc.mjs → core.C3JowhaZ.mjs} +3 -3
- package/dist/shared/{core.CNGyqkJh.mjs → core.C4x8aaWa.mjs} +3 -1
- package/dist/shared/{core.BB6zA-UU.mjs → core.C8YY6Uub.mjs} +38 -9
- package/dist/shared/{core.Asc11Mjy.mjs → core.C8sl5Y8Z.mjs} +122 -58
- package/dist/shared/{core.BvMRMo7Z.mjs → core.CNgZvKb8.mjs} +3 -5198
- package/dist/shared/{core.CUG6vpyL.d.mts → core.CQngdcuj.d.mts} +85 -4
- package/dist/shared/{core.Be1n9a0i.mjs → core.C_Ni6yHl.mjs} +5 -4
- package/dist/shared/core.CbT8JVYL.mjs +5 -0
- package/dist/shared/core.CqAJJpK_.mjs +3 -0
- package/dist/shared/{core.BXsxn-hf.d.mts → core.D0PjZzIS.d.mts} +27 -15
- package/dist/shared/{core.DgesAwC8.d.mts → core.D5fzJWbF.d.mts} +2 -2
- package/dist/shared/{core.hfOE3RfK.d.mts → core.DACpKp35.d.mts} +5 -5
- package/dist/shared/core.DFi2dOTl.mjs +39548 -0
- package/dist/shared/{core.xSQO0XYD.d.mts → core.DIol3syK.d.mts} +2 -2
- package/dist/shared/{core.DlG1xWt2.mjs → core.DMMOWQqc.mjs} +3 -2
- package/dist/shared/core.DNbUPnve.mjs +3990 -0
- package/dist/shared/{core.CCD1ID81.mjs → core.DRJma0Ol.mjs} +4 -3
- package/dist/shared/{core.DgttqsJc.mjs → core.DRhg-gVU.mjs} +9 -9
- package/dist/shared/core.DSO_rTC2.mjs +5322 -0
- package/dist/shared/{core.FUPplpae.d.mts → core.D_vkffV4.d.mts} +4 -2
- package/dist/shared/core.DdMJk7nx.d.mts +476 -0
- package/dist/shared/{core.BhpgpOep.d.mts → core.Dgs6-nuz.d.mts} +2 -2
- package/dist/shared/{core.Be4Jy9Qx.mjs → core.FZ305VYd.mjs} +2 -2
- package/dist/shared/core.OHD4KXm9.mjs +5 -0
- package/dist/shared/{core.GTgsmXS_.mjs → core.QJD_fcrc.mjs} +2 -2
- package/dist/shared/core.RfnaEmgA.mjs +7 -0
- package/dist/shared/core.fHR_8Tnq.d.mts +450 -0
- package/dist/shared/{core.D0EgVMQK.mjs → core.lRvxPoao.mjs} +14 -12
- package/dist/shared/{core.CaT0SUUK.mjs → core.rCeaAqgW.mjs} +1 -84
- package/dist/shared/{core.zxTBF_PD.d.mts → core.s9uwOt60.d.mts} +4 -4
- package/dist/shared/core.yna0OdV5.d.mts +98 -0
- package/dist/styles/index.d.mts +106 -0
- package/dist/styles/index.mjs +1 -0
- package/dist/types/_aux.d.mts +2 -2
- package/dist/types/expression-model.d.mts +3 -4
- package/dist/types/expression.d.mts +3 -4
- package/dist/types/fqnRef.d.mts +2 -2
- package/dist/types/fqnRef.mjs +3 -3
- package/dist/types/index.d.mts +8 -8
- package/dist/types/index.mjs +150 -5
- package/dist/types/scalar.mjs +3 -2
- package/dist/utils/graphology/index.d.mts +1864 -0
- package/dist/utils/graphology/index.mjs +1 -0
- package/dist/utils/index.d.mts +11 -6
- package/dist/utils/index.mjs +21 -37
- package/dist/utils/iterable/index.d.mts +1 -1
- package/dist/utils/iterable/index.mjs +45 -7
- package/model/package.json +4 -0
- package/package.json +42 -24
- package/styles/package.json +4 -0
- package/types/package.json +4 -0
- package/utils/graphology/package.json +4 -0
- package/utils/package.json +4 -0
- package/dist/shared/core.6_Vp2iiN.mjs +0 -172
- package/dist/shared/core.CUw_2J9j.mjs +0 -47
- package/dist/shared/core.CzdwsPmY.d.mts +0 -69
- package/dist/shared/core.D-ZGWDDt.d.mts +0 -831
- package/dist/shared/core.DoM6aM9N.mjs +0 -7
- package/dist/shared/core.ILwny7BV.mjs +0 -38
- package/dist/theme/index.d.mts +0 -11
- package/dist/theme/index.mjs +0 -232
- package/src/builder/Builder.deployment.ts +0 -224
- package/src/builder/Builder.deploymentModel.ts +0 -449
- package/src/builder/Builder.element.ts +0 -241
- package/src/builder/Builder.model.ts +0 -494
- package/src/builder/Builder.ts +0 -946
- package/src/builder/Builder.view-common.ts +0 -273
- package/src/builder/Builder.view-deployment.ts +0 -135
- package/src/builder/Builder.view-element.ts +0 -202
- package/src/builder/Builder.views.ts +0 -399
- package/src/builder/Builder.with.ts +0 -156
- package/src/builder/_types.ts +0 -324
- package/src/builder/index.ts +0 -11
- package/src/compute-view/compute-view.ts +0 -80
- package/src/compute-view/deployment-view/_types.ts +0 -38
- package/src/compute-view/deployment-view/clean-connections.ts +0 -236
- package/src/compute-view/deployment-view/compute.ts +0 -94
- package/src/compute-view/deployment-view/memory/index.ts +0 -9
- package/src/compute-view/deployment-view/memory/memory.ts +0 -96
- package/src/compute-view/deployment-view/predicates/deploymentRefs-where.ts +0 -18
- package/src/compute-view/deployment-view/predicates/deploymentRefs.ts +0 -154
- package/src/compute-view/deployment-view/predicates/index.ts +0 -8
- package/src/compute-view/deployment-view/predicates/relation-direct.ts +0 -243
- package/src/compute-view/deployment-view/predicates/relation-in-out.ts +0 -70
- package/src/compute-view/deployment-view/predicates/relation-incoming.ts +0 -101
- package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +0 -95
- package/src/compute-view/deployment-view/predicates/relation-where.ts +0 -18
- package/src/compute-view/deployment-view/predicates/utils.ts +0 -282
- package/src/compute-view/deployment-view/predicates/wildcard.ts +0 -41
- package/src/compute-view/deployment-view/stages/stage-exclude.ts +0 -5
- package/src/compute-view/deployment-view/stages/stage-final.ts +0 -245
- package/src/compute-view/deployment-view/stages/stage-include.ts +0 -95
- package/src/compute-view/deployment-view/utils.ts +0 -297
- package/src/compute-view/dynamic-view/compute.ts +0 -312
- package/src/compute-view/element-view/_types.ts +0 -47
- package/src/compute-view/element-view/clean-connections.ts +0 -117
- package/src/compute-view/element-view/compute.ts +0 -324
- package/src/compute-view/element-view/memory/NodeGroup.ts +0 -31
- package/src/compute-view/element-view/memory/index.ts +0 -10
- package/src/compute-view/element-view/memory/memory.ts +0 -178
- package/src/compute-view/element-view/memory/stage-exclude.ts +0 -59
- package/src/compute-view/element-view/memory/stage-final.ts +0 -129
- package/src/compute-view/element-view/memory/stage-include.ts +0 -130
- package/src/compute-view/element-view/predicates/_utils.ts +0 -91
- package/src/compute-view/element-view/predicates/element-expand.ts +0 -29
- package/src/compute-view/element-view/predicates/element-kind-tag.ts +0 -27
- package/src/compute-view/element-view/predicates/element-ref.ts +0 -24
- package/src/compute-view/element-view/predicates/relation-direct.ts +0 -321
- package/src/compute-view/element-view/predicates/relation-in-out.ts +0 -64
- package/src/compute-view/element-view/predicates/relation-in.ts +0 -115
- package/src/compute-view/element-view/predicates/relation-out.ts +0 -119
- package/src/compute-view/element-view/predicates/wildcard.ts +0 -88
- package/src/compute-view/element-view/utils.ts +0 -65
- package/src/compute-view/index.ts +0 -4
- package/src/compute-view/memory/AbstractMemory.ts +0 -45
- package/src/compute-view/memory/AbstractStageExclude.ts +0 -215
- package/src/compute-view/memory/AbstractStageInclude.ts +0 -200
- package/src/compute-view/memory/_types.ts +0 -148
- package/src/compute-view/memory/index.ts +0 -5
- package/src/compute-view/memory/ops.ts +0 -43
- package/src/compute-view/relationships-view/_types.ts +0 -16
- package/src/compute-view/relationships-view/compute.ts +0 -159
- package/src/compute-view/relationships-view/index.ts +0 -3
- package/src/compute-view/relationships-view/layout.ts +0 -358
- package/src/compute-view/relationships-view/utils.ts +0 -73
- package/src/compute-view/utils/ancestorsOfNode.ts +0 -19
- package/src/compute-view/utils/applyCustomElementProperties.ts +0 -107
- package/src/compute-view/utils/applyCustomRelationProperties.ts +0 -58
- package/src/compute-view/utils/applyViewRuleStyles.ts +0 -73
- package/src/compute-view/utils/buildComputedNodes.ts +0 -166
- package/src/compute-view/utils/buildElementNotations.ts +0 -64
- package/src/compute-view/utils/elementExpressionToPredicate.ts +0 -50
- package/src/compute-view/utils/link-nodes-with-edges.ts +0 -56
- package/src/compute-view/utils/merge-props-from-relationships.ts +0 -161
- package/src/compute-view/utils/relationExpressionToPredicates.ts +0 -55
- package/src/compute-view/utils/resolve-extended-views.ts +0 -85
- package/src/compute-view/utils/resolve-global-rules.ts +0 -88
- package/src/compute-view/utils/topological-sort.ts +0 -256
- package/src/compute-view/utils/view-hash.ts +0 -45
- package/src/compute-view/utils/with-readable-edges.ts +0 -40
- package/src/index.ts +0 -32
- package/src/model/DeploymentElementModel.ts +0 -712
- package/src/model/DeploymentModel.ts +0 -393
- package/src/model/ElementModel.ts +0 -316
- package/src/model/LikeC4Model.ts +0 -882
- package/src/model/RelationModel.ts +0 -152
- package/src/model/connection/Connection.ts +0 -72
- package/src/model/connection/deployment/DeploymentConnectionModel.ts +0 -185
- package/src/model/connection/deployment/find.ts +0 -120
- package/src/model/connection/deployment/index.ts +0 -8
- package/src/model/connection/index.ts +0 -22
- package/src/model/connection/model/ConnectionModel.ts +0 -158
- package/src/model/connection/model/find.ts +0 -117
- package/src/model/connection/model/index.ts +0 -8
- package/src/model/connection/ops.ts +0 -276
- package/src/model/guards.ts +0 -77
- package/src/model/index.ts +0 -72
- package/src/model/types.ts +0 -67
- package/src/model/utils.ts +0 -66
- package/src/model/view/EdgeModel.ts +0 -121
- package/src/model/view/LikeC4ViewModel.ts +0 -361
- package/src/model/view/LikeC4ViewsFolder.ts +0 -151
- package/src/model/view/NodeModel.ts +0 -247
- package/src/theme/element.ts +0 -61
- package/src/theme/index.ts +0 -127
- package/src/theme/relationships.ts +0 -54
- package/src/types/RichText.ts +0 -205
- package/src/types/_aux.ts +0 -317
- package/src/types/_common.ts +0 -102
- package/src/types/const.ts +0 -34
- package/src/types/expression-model.ts +0 -294
- package/src/types/expression.ts +0 -313
- package/src/types/fqnRef.ts +0 -91
- package/src/types/geometry.ts +0 -159
- package/src/types/global.ts +0 -21
- package/src/types/index.ts +0 -44
- package/src/types/model-data.ts +0 -77
- package/src/types/model-deployment.ts +0 -78
- package/src/types/model-dump.ts +0 -79
- package/src/types/model-logical.ts +0 -126
- package/src/types/model-spec.ts +0 -88
- package/src/types/operators.ts +0 -156
- package/src/types/project.ts +0 -14
- package/src/types/scalar.ts +0 -162
- package/src/types/styles.ts +0 -122
- package/src/types/view-changes.ts +0 -32
- package/src/types/view-common.ts +0 -157
- package/src/types/view-computed.ts +0 -126
- package/src/types/view-layouted.ts +0 -94
- package/src/types/view-parsed.deployment.ts +0 -39
- package/src/types/view-parsed.dynamic.ts +0 -89
- package/src/types/view-parsed.element.ts +0 -65
- package/src/types/view.ts +0 -113
- package/src/utils/common-head.ts +0 -22
- package/src/utils/compare-natural.ts +0 -60
- package/src/utils/const.ts +0 -1
- package/src/utils/fqn.ts +0 -302
- package/src/utils/getOrCreate.ts +0 -8
- package/src/utils/guards.ts +0 -9
- package/src/utils/index.ts +0 -68
- package/src/utils/invariant.ts +0 -29
- package/src/utils/iterable/_types.ts +0 -5
- package/src/utils/iterable/filter.ts +0 -55
- package/src/utils/iterable/find.ts +0 -38
- package/src/utils/iterable/first.ts +0 -48
- package/src/utils/iterable/flat.ts +0 -17
- package/src/utils/iterable/head.ts +0 -22
- package/src/utils/iterable/index.ts +0 -15
- package/src/utils/iterable/map.ts +0 -40
- package/src/utils/iterable/reduce.ts +0 -24
- package/src/utils/iterable/some.ts +0 -36
- package/src/utils/iterable/to.ts +0 -19
- package/src/utils/iterable/unique.ts +0 -23
- package/src/utils/markdown/index.ts +0 -2
- package/src/utils/markdown/to-html.ts +0 -32
- package/src/utils/markdown/to-text.ts +0 -14
- package/src/utils/memoize-prop.ts +0 -30
- package/src/utils/mnemonist.ts +0 -9
- package/src/utils/object-hash.ts +0 -14
- package/src/utils/promises.ts +0 -24
- package/src/utils/relations.ts +0 -36
- package/src/utils/set.ts +0 -83
- package/src/utils/string-hash.ts +0 -16
package/src/builder/_types.ts
DELETED
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
import type { IfNever, IsLiteral, IsNever, Tagged, TupleToUnion } from 'type-fest'
|
|
2
|
-
import type {
|
|
3
|
-
AnyAux,
|
|
4
|
-
Aux,
|
|
5
|
-
BorderStyle,
|
|
6
|
-
ElementShape,
|
|
7
|
-
ElementSpecification as ElementKindSpecification,
|
|
8
|
-
Expression,
|
|
9
|
-
KeysOf,
|
|
10
|
-
NonEmptyArray,
|
|
11
|
-
RelationshipArrowType,
|
|
12
|
-
RelationshipLineType,
|
|
13
|
-
RelationshipSpecification as RelationshipKindSpecification,
|
|
14
|
-
ShapeSize,
|
|
15
|
-
SpacingSize,
|
|
16
|
-
SpecAux,
|
|
17
|
-
TagSpecification,
|
|
18
|
-
TextSize,
|
|
19
|
-
ThemeColor as Color,
|
|
20
|
-
} from '../types'
|
|
21
|
-
import type { Builder } from './Builder'
|
|
22
|
-
import type { DeploymentRulesBuilderOp } from './Builder.view-deployment'
|
|
23
|
-
|
|
24
|
-
type ElementSpecification = Omit<ElementKindSpecification, 'tags'> & {
|
|
25
|
-
tags?: string[]
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type BuilderSpecification = {
|
|
29
|
-
elements: string[] | {
|
|
30
|
-
[kind: string]: Partial<ElementSpecification>
|
|
31
|
-
}
|
|
32
|
-
relationships?: string[] | {
|
|
33
|
-
[kind: string]: Partial<RelationshipKindSpecification>
|
|
34
|
-
}
|
|
35
|
-
deployments?: string[] | {
|
|
36
|
-
[kind: string]: Partial<ElementSpecification>
|
|
37
|
-
}
|
|
38
|
-
tags?: string[] | {
|
|
39
|
-
[kind: string]: Partial<TagSpecification>
|
|
40
|
-
}
|
|
41
|
-
metadataKeys?: string[]
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* We need with `id: string` to be able to derive the project id
|
|
46
|
-
*
|
|
47
|
-
* @see {@link LikeC4Project}
|
|
48
|
-
*/
|
|
49
|
-
export type BuilderProjectSpecification = {
|
|
50
|
-
id: string
|
|
51
|
-
title?: string
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export type Metadata<MetadataKey extends string> = IsNever<MetadataKey> extends true ? never :
|
|
55
|
-
IsLiteral<MetadataKey> extends true ? {
|
|
56
|
-
[key in MetadataKey]?: string
|
|
57
|
-
} :
|
|
58
|
-
Record<string, string>
|
|
59
|
-
|
|
60
|
-
export type NewElementProps<Tag, Metadata> = {
|
|
61
|
-
title?: string
|
|
62
|
-
summary?: string
|
|
63
|
-
description?: string
|
|
64
|
-
technology?: string
|
|
65
|
-
tags?: IfNever<Tag, never, [Tag, ...Tag[]]>
|
|
66
|
-
metadata?: Metadata
|
|
67
|
-
icon?: string
|
|
68
|
-
shape?: ElementShape
|
|
69
|
-
color?: Color
|
|
70
|
-
links?: Array<string | { title?: string; url: string }>
|
|
71
|
-
style?: {
|
|
72
|
-
border?: BorderStyle
|
|
73
|
-
// 0-100
|
|
74
|
-
opacity?: number
|
|
75
|
-
size?: ShapeSize
|
|
76
|
-
padding?: SpacingSize
|
|
77
|
-
textSize?: TextSize
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export type NewDeploymentNodeProps<Tag, Metadata> = {
|
|
82
|
-
title?: string
|
|
83
|
-
summary?: string
|
|
84
|
-
description?: string
|
|
85
|
-
technology?: string
|
|
86
|
-
tags?: IfNever<Tag, never, [Tag, ...Tag[]]>
|
|
87
|
-
metadata?: Metadata
|
|
88
|
-
icon?: string
|
|
89
|
-
shape?: ElementShape
|
|
90
|
-
color?: Color
|
|
91
|
-
links?: NonEmptyArray<string | { title?: string; url: string }>
|
|
92
|
-
style?: {
|
|
93
|
-
border?: BorderStyle
|
|
94
|
-
// 0-100
|
|
95
|
-
opacity?: number
|
|
96
|
-
size?: ShapeSize
|
|
97
|
-
padding?: SpacingSize
|
|
98
|
-
textSize?: TextSize
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export type NewViewProps<Tag> = {
|
|
103
|
-
title?: string
|
|
104
|
-
description?: string
|
|
105
|
-
tags?: IfNever<Tag, never, [Tag, ...Tag[]]>
|
|
106
|
-
links?: Array<string | { title?: string; url: string }>
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export type NewRelationProps<Kind, Tag, Metadata> = {
|
|
110
|
-
kind?: Kind
|
|
111
|
-
title?: string
|
|
112
|
-
description?: string
|
|
113
|
-
technology?: string
|
|
114
|
-
tags?: IfNever<Tag, never, [Tag, ...Tag[]]>
|
|
115
|
-
metadata?: Metadata
|
|
116
|
-
head?: RelationshipArrowType
|
|
117
|
-
tail?: RelationshipArrowType
|
|
118
|
-
line?: RelationshipLineType
|
|
119
|
-
color?: Color
|
|
120
|
-
links?: NonEmptyArray<string | { title?: string; url: string }>
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export type Invalid<Message extends string> = Tagged<Message, 'Error'>
|
|
124
|
-
export type Warn<Id, Existing> = IsLiteral<Existing> extends true ? Id extends Existing ? Invalid<'Already exists'> : Id
|
|
125
|
-
: Id
|
|
126
|
-
|
|
127
|
-
export type ValidId<Id> =
|
|
128
|
-
// Id extends `${string}.${string}` ? Invalid<'Id must not contain dot'>
|
|
129
|
-
Id extends `${number}${string}` ? Invalid<'Id must not start with number'>
|
|
130
|
-
: IsLiteral<Id> extends true ? Id
|
|
131
|
-
: Invalid<'Id must be a literal'>
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Auxilary type to keep track of the types in builder
|
|
135
|
-
*/
|
|
136
|
-
export interface Types<
|
|
137
|
-
ElementKind extends string,
|
|
138
|
-
Fqn extends string,
|
|
139
|
-
ViewId extends string,
|
|
140
|
-
RelationshipKind extends string,
|
|
141
|
-
Tag extends string,
|
|
142
|
-
MetadataKey extends string,
|
|
143
|
-
DeploymentKind extends string,
|
|
144
|
-
DeploymentFqn extends string,
|
|
145
|
-
> {
|
|
146
|
-
ElementKind: ElementKind
|
|
147
|
-
Fqn: Fqn
|
|
148
|
-
ViewId: ViewId
|
|
149
|
-
RelationshipKind: RelationshipKind
|
|
150
|
-
Tag: Tag
|
|
151
|
-
MetadataKey: MetadataKey
|
|
152
|
-
DeploymentKind: DeploymentKind
|
|
153
|
-
DeploymentFqn: DeploymentFqn
|
|
154
|
-
|
|
155
|
-
Tags: IfNever<Tag, never, [Tag, ...Tag[]]>
|
|
156
|
-
// Metadata: Metadata<MetadataKey>
|
|
157
|
-
|
|
158
|
-
NewElementProps: NewElementProps<Tag, Metadata<MetadataKey>>
|
|
159
|
-
NewRelationshipProps: NewRelationProps<RelationshipKind, Tag, Metadata<MetadataKey>>
|
|
160
|
-
NewViewProps: NewViewProps<Tag>
|
|
161
|
-
|
|
162
|
-
NewDeploymentNodeProps: NewDeploymentNodeProps<Tag, Metadata<MetadataKey>>
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* When building nested objects
|
|
167
|
-
*/
|
|
168
|
-
export interface TypesNested<
|
|
169
|
-
Parent extends string,
|
|
170
|
-
ElementKind extends string,
|
|
171
|
-
Fqn extends string,
|
|
172
|
-
ViewId extends string,
|
|
173
|
-
RelationshipKind extends string,
|
|
174
|
-
Tag extends string,
|
|
175
|
-
MetadataKey extends string,
|
|
176
|
-
DeploymentKind extends string,
|
|
177
|
-
DeploymentFqn extends string,
|
|
178
|
-
> extends
|
|
179
|
-
Types<
|
|
180
|
-
ElementKind,
|
|
181
|
-
Fqn,
|
|
182
|
-
ViewId,
|
|
183
|
-
RelationshipKind,
|
|
184
|
-
Tag,
|
|
185
|
-
MetadataKey,
|
|
186
|
-
DeploymentKind,
|
|
187
|
-
DeploymentFqn
|
|
188
|
-
>
|
|
189
|
-
{
|
|
190
|
-
Parent: Parent
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export type AnyTypes = Types<
|
|
194
|
-
any,
|
|
195
|
-
any,
|
|
196
|
-
any,
|
|
197
|
-
any,
|
|
198
|
-
any,
|
|
199
|
-
any,
|
|
200
|
-
any,
|
|
201
|
-
any
|
|
202
|
-
>
|
|
203
|
-
|
|
204
|
-
export type AnyTypesNested = TypesNested<
|
|
205
|
-
any,
|
|
206
|
-
any,
|
|
207
|
-
any,
|
|
208
|
-
any,
|
|
209
|
-
any,
|
|
210
|
-
any,
|
|
211
|
-
any,
|
|
212
|
-
any,
|
|
213
|
-
any
|
|
214
|
-
>
|
|
215
|
-
|
|
216
|
-
type KeysOrTuple<T> = T extends readonly string[] ? TupleToUnion<T> : KeysOf<T>
|
|
217
|
-
|
|
218
|
-
export namespace Types {
|
|
219
|
-
export type FromSpecification<Spec> = Spec extends BuilderSpecification ? Types<
|
|
220
|
-
KeysOrTuple<Spec['elements']>,
|
|
221
|
-
never,
|
|
222
|
-
never,
|
|
223
|
-
KeysOrTuple<Spec['relationships']>,
|
|
224
|
-
KeysOrTuple<Spec['tags']>,
|
|
225
|
-
TupleToUnion<Spec['metadataKeys']>,
|
|
226
|
-
KeysOrTuple<Spec['deployments']>,
|
|
227
|
-
never
|
|
228
|
-
>
|
|
229
|
-
: never
|
|
230
|
-
|
|
231
|
-
export type AddFqn<T, Id extends string> = T extends TypesNested<infer P, any, any, any, any, any, any, any, any>
|
|
232
|
-
? TypesNested<
|
|
233
|
-
P,
|
|
234
|
-
T['ElementKind'],
|
|
235
|
-
`${P}.${Id}` | T['Fqn'],
|
|
236
|
-
T['ViewId'],
|
|
237
|
-
T['RelationshipKind'],
|
|
238
|
-
T['Tag'],
|
|
239
|
-
T['MetadataKey'],
|
|
240
|
-
T['DeploymentKind'],
|
|
241
|
-
T['DeploymentFqn']
|
|
242
|
-
>
|
|
243
|
-
: T extends AnyTypes ? Types<
|
|
244
|
-
T['ElementKind'],
|
|
245
|
-
Id | T['Fqn'],
|
|
246
|
-
T['ViewId'],
|
|
247
|
-
T['RelationshipKind'],
|
|
248
|
-
T['Tag'],
|
|
249
|
-
T['MetadataKey'],
|
|
250
|
-
T['DeploymentKind'],
|
|
251
|
-
T['DeploymentFqn']
|
|
252
|
-
>
|
|
253
|
-
: never
|
|
254
|
-
|
|
255
|
-
export type AddDeploymentFqn<T, Id extends string> = T extends
|
|
256
|
-
TypesNested<infer P, any, any, any, any, any, any, any, any> ? TypesNested<
|
|
257
|
-
P,
|
|
258
|
-
T['ElementKind'],
|
|
259
|
-
T['Fqn'],
|
|
260
|
-
T['ViewId'],
|
|
261
|
-
T['RelationshipKind'],
|
|
262
|
-
T['Tag'],
|
|
263
|
-
T['MetadataKey'],
|
|
264
|
-
T['DeploymentKind'],
|
|
265
|
-
`${P}.${Id}` | T['DeploymentFqn']
|
|
266
|
-
>
|
|
267
|
-
: T extends AnyTypes ? Types<
|
|
268
|
-
T['ElementKind'],
|
|
269
|
-
T['Fqn'],
|
|
270
|
-
T['ViewId'],
|
|
271
|
-
T['RelationshipKind'],
|
|
272
|
-
T['Tag'],
|
|
273
|
-
T['MetadataKey'],
|
|
274
|
-
T['DeploymentKind'],
|
|
275
|
-
Id | T['DeploymentFqn']
|
|
276
|
-
>
|
|
277
|
-
: never
|
|
278
|
-
|
|
279
|
-
export type AddView<T, Id extends string> = T extends TypesNested<infer P, any, any, any, any, any, any, any, any>
|
|
280
|
-
? TypesNested<
|
|
281
|
-
P,
|
|
282
|
-
T['ElementKind'],
|
|
283
|
-
T['Fqn'],
|
|
284
|
-
Id | T['ViewId'],
|
|
285
|
-
T['RelationshipKind'],
|
|
286
|
-
T['Tag'],
|
|
287
|
-
T['MetadataKey'],
|
|
288
|
-
T['DeploymentKind'],
|
|
289
|
-
T['DeploymentFqn']
|
|
290
|
-
>
|
|
291
|
-
: T extends AnyTypes ? Types<
|
|
292
|
-
T['ElementKind'],
|
|
293
|
-
T['Fqn'],
|
|
294
|
-
Id | T['ViewId'],
|
|
295
|
-
T['RelationshipKind'],
|
|
296
|
-
T['Tag'],
|
|
297
|
-
T['MetadataKey'],
|
|
298
|
-
T['DeploymentKind'],
|
|
299
|
-
T['DeploymentFqn']
|
|
300
|
-
>
|
|
301
|
-
: never
|
|
302
|
-
|
|
303
|
-
export type ToAux<T> = T extends AnyTypes ? Aux<
|
|
304
|
-
'parsed',
|
|
305
|
-
T['Fqn'],
|
|
306
|
-
T['DeploymentFqn'],
|
|
307
|
-
T['ViewId'],
|
|
308
|
-
'from-builder',
|
|
309
|
-
SpecAux<
|
|
310
|
-
T['ElementKind'],
|
|
311
|
-
T['DeploymentKind'],
|
|
312
|
-
T['RelationshipKind'],
|
|
313
|
-
T['Tag'],
|
|
314
|
-
T['MetadataKey']
|
|
315
|
-
>
|
|
316
|
-
>
|
|
317
|
-
: AnyAux
|
|
318
|
-
|
|
319
|
-
export type ToExpression<T> = T extends AnyTypes ? Expression<ToAux<T>> : never
|
|
320
|
-
|
|
321
|
-
export type From<B> = B extends Builder<infer T> ? B['Types'] extends AnyTypes ? T : AnyTypes : never
|
|
322
|
-
|
|
323
|
-
export type DeploymentRules<B> = DeploymentRulesBuilderOp<From<B>>
|
|
324
|
-
}
|
package/src/builder/index.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type * from './_types'
|
|
2
|
-
export { Builder } from './Builder'
|
|
3
|
-
export type * from './Builder.deployment'
|
|
4
|
-
export type * from './Builder.deploymentModel'
|
|
5
|
-
export type * from './Builder.element'
|
|
6
|
-
export type * from './Builder.model'
|
|
7
|
-
export type * from './Builder.view-common'
|
|
8
|
-
export type * from './Builder.view-deployment'
|
|
9
|
-
export type * from './Builder.view-element'
|
|
10
|
-
export type * from './Builder.views'
|
|
11
|
-
export type * from './Builder.with'
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { indexBy, values } from 'remeda'
|
|
2
|
-
import { LikeC4Model } from '../model'
|
|
3
|
-
import {
|
|
4
|
-
type AnyAux,
|
|
5
|
-
type ComputedLikeC4ModelData,
|
|
6
|
-
type ComputedView,
|
|
7
|
-
type ParsedLikeC4ModelData,
|
|
8
|
-
type ParsedView,
|
|
9
|
-
_stage,
|
|
10
|
-
isDeploymentView,
|
|
11
|
-
isDynamicView,
|
|
12
|
-
isElementView,
|
|
13
|
-
} from '../types'
|
|
14
|
-
import { nonexhaustive } from '../utils'
|
|
15
|
-
import { computeDeploymentView } from './deployment-view/compute'
|
|
16
|
-
import { computeDynamicView } from './dynamic-view/compute'
|
|
17
|
-
import { computeElementView } from './element-view/compute'
|
|
18
|
-
|
|
19
|
-
export type ComputeViewResult<V> =
|
|
20
|
-
| {
|
|
21
|
-
isSuccess: true
|
|
22
|
-
error?: undefined
|
|
23
|
-
view: V
|
|
24
|
-
}
|
|
25
|
-
| {
|
|
26
|
-
isSuccess: false
|
|
27
|
-
error: Error
|
|
28
|
-
view: undefined
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function unsafeComputeView<A extends AnyAux>(
|
|
32
|
-
viewsource: ParsedView<A>,
|
|
33
|
-
likec4model: LikeC4Model<any>,
|
|
34
|
-
): ComputedView<A> {
|
|
35
|
-
switch (true) {
|
|
36
|
-
case isElementView(viewsource):
|
|
37
|
-
return computeElementView(likec4model, viewsource)
|
|
38
|
-
case isDeploymentView(viewsource):
|
|
39
|
-
return computeDeploymentView(likec4model, viewsource)
|
|
40
|
-
case isDynamicView(viewsource):
|
|
41
|
-
return computeDynamicView(likec4model, viewsource)
|
|
42
|
-
default:
|
|
43
|
-
nonexhaustive(viewsource)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function computeView<A extends AnyAux>(
|
|
48
|
-
viewsource: ParsedView<A>,
|
|
49
|
-
likec4model: LikeC4Model<A>,
|
|
50
|
-
): ComputeViewResult<ComputedView<A>> {
|
|
51
|
-
try {
|
|
52
|
-
return {
|
|
53
|
-
isSuccess: true,
|
|
54
|
-
view: unsafeComputeView(viewsource, likec4model),
|
|
55
|
-
}
|
|
56
|
-
} catch (e) {
|
|
57
|
-
return {
|
|
58
|
-
isSuccess: false,
|
|
59
|
-
error: e instanceof Error ? e : new Error(`Unknown error: ${e}`),
|
|
60
|
-
view: undefined,
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function computeParsedModelData<A extends AnyAux>(
|
|
66
|
-
parsed: ParsedLikeC4ModelData<A>,
|
|
67
|
-
): ComputedLikeC4ModelData<A> {
|
|
68
|
-
const likec4model = LikeC4Model.create(parsed)
|
|
69
|
-
const views = values(parsed.views as Record<string, ParsedView<A>>)
|
|
70
|
-
.map(v => unsafeComputeView(v, likec4model))
|
|
71
|
-
return {
|
|
72
|
-
...parsed,
|
|
73
|
-
[_stage]: 'computed',
|
|
74
|
-
views: indexBy(views, v => v.id),
|
|
75
|
-
} as ComputedLikeC4ModelData<A>
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function computeLikeC4Model<A extends AnyAux>(parsed: ParsedLikeC4ModelData<A>): LikeC4Model.Computed<A> {
|
|
79
|
-
return LikeC4Model.create(computeParsedModelData(parsed))
|
|
80
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { RelationshipModel } from '../../model'
|
|
2
|
-
import { LikeC4DeploymentModel } from '../../model'
|
|
3
|
-
import type { AnyAux, Expression, OperatorPredicate } from '../../types'
|
|
4
|
-
import type { Ctx, Memory, Stage, StageExclude, StageInclude } from './memory'
|
|
5
|
-
|
|
6
|
-
export { Memory, type Stage } from './memory'
|
|
7
|
-
|
|
8
|
-
export type Where<T extends {}> = (x: T) => boolean
|
|
9
|
-
|
|
10
|
-
export type Elem = Ctx['Element']
|
|
11
|
-
export type Connection = Ctx['Connection']
|
|
12
|
-
|
|
13
|
-
export type ElementWhere = Where<Elem>
|
|
14
|
-
export type ElementWhereFilter = (elements: readonly Elem[]) => Elem[]
|
|
15
|
-
export type ConnectionWhere = Where<Connection>
|
|
16
|
-
export type RelationshipWhere = Where<RelationshipModel<any>>
|
|
17
|
-
export type ConnectionWhereFilter = (connections: readonly Connection[]) => Connection[]
|
|
18
|
-
|
|
19
|
-
export type Connections = ReadonlyArray<Connection>
|
|
20
|
-
|
|
21
|
-
export interface PredicateCtx<Expr = Expression<AnyAux>> {
|
|
22
|
-
expr: Expr
|
|
23
|
-
stage: Stage
|
|
24
|
-
model: LikeC4DeploymentModel<AnyAux>
|
|
25
|
-
memory: Memory
|
|
26
|
-
where: OperatorPredicate<AnyAux> | null
|
|
27
|
-
}
|
|
28
|
-
export interface IncludePredicateCtx<Expr = Expression<AnyAux>> extends PredicateCtx<Expr> {
|
|
29
|
-
stage: StageInclude
|
|
30
|
-
}
|
|
31
|
-
export interface ExcludePredicateCtx<Expr = Expression<AnyAux>> extends PredicateCtx<Expr> {
|
|
32
|
-
stage: StageExclude
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface PredicateExecutor<Expr extends Expression<AnyAux> = Expression<AnyAux>> {
|
|
36
|
-
include(ctx: IncludePredicateCtx<Expr>): StageInclude | undefined
|
|
37
|
-
exclude(ctx: ExcludePredicateCtx<Expr>): StageExclude | undefined
|
|
38
|
-
}
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
dropWhile,
|
|
3
|
-
filter,
|
|
4
|
-
flatMap,
|
|
5
|
-
forEach,
|
|
6
|
-
groupBy,
|
|
7
|
-
hasAtLeast,
|
|
8
|
-
map,
|
|
9
|
-
pipe,
|
|
10
|
-
piped,
|
|
11
|
-
prop,
|
|
12
|
-
reduce,
|
|
13
|
-
values,
|
|
14
|
-
} from 'remeda'
|
|
15
|
-
import type { RelationshipModel } from '../../model'
|
|
16
|
-
import {
|
|
17
|
-
DeploymentConnectionModel,
|
|
18
|
-
differenceConnections,
|
|
19
|
-
isNestedConnection,
|
|
20
|
-
mergeConnections,
|
|
21
|
-
RelationshipsAccum,
|
|
22
|
-
sortConnectionsByBoundaryHierarchy,
|
|
23
|
-
} from '../../model'
|
|
24
|
-
import { invariant } from '../../utils'
|
|
25
|
-
import { imap, toArray } from '../../utils/iterable'
|
|
26
|
-
import { DefaultMap } from '../../utils/mnemonist'
|
|
27
|
-
import { intersection, union } from '../../utils/set'
|
|
28
|
-
import type { Connection, Connections } from './_types'
|
|
29
|
-
import { findConnection } from './utils'
|
|
30
|
-
|
|
31
|
-
type MapOfExcludesFromConnection = DefaultMap<DeploymentConnectionModel, Set<RelationshipModel>>
|
|
32
|
-
function findCrossBoundarySameSourceOrTarget(connections: Connections): MapOfExcludesFromConnection {
|
|
33
|
-
// Also find connections based on same relation
|
|
34
|
-
const groupedByRelation = new DefaultMap<RelationshipModel, Array<DeploymentConnectionModel>>(() => [])
|
|
35
|
-
for (const conn of connections) {
|
|
36
|
-
for (const relation of conn.relations.model) {
|
|
37
|
-
groupedByRelation.get(relation).push(conn)
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Aggreate excluded relations for each connection
|
|
42
|
-
const excludedRelations = new DefaultMap<
|
|
43
|
-
DeploymentConnectionModel,
|
|
44
|
-
Set<RelationshipModel>
|
|
45
|
-
>(() => new Set())
|
|
46
|
-
|
|
47
|
-
// In each group, find connected to same leaf
|
|
48
|
-
for (const [relation, sameRelationGroup] of groupedByRelation) {
|
|
49
|
-
if (!hasAtLeast(sameRelationGroup, 2)) {
|
|
50
|
-
continue
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Outgoing from same source
|
|
54
|
-
pipe(
|
|
55
|
-
sameRelationGroup,
|
|
56
|
-
flatMap(conn => [
|
|
57
|
-
{ group: `$source-${conn.source.id}`, conn },
|
|
58
|
-
{ group: `$target-${conn.target.id}`, conn },
|
|
59
|
-
]),
|
|
60
|
-
groupBy(prop('group')),
|
|
61
|
-
values(),
|
|
62
|
-
filter(hasAtLeast(2)),
|
|
63
|
-
forEach(
|
|
64
|
-
// In each group, sort by hierarchy, first are deepest
|
|
65
|
-
piped(
|
|
66
|
-
map(prop('conn')),
|
|
67
|
-
sortConnectionsByBoundaryHierarchy('desc'),
|
|
68
|
-
// Drop first, as it is the deepest
|
|
69
|
-
// Drop if boundary is same as previous
|
|
70
|
-
dropWhile((conn, i, all) => i === 0 || conn.boundary === all[i - 1]!.boundary),
|
|
71
|
-
// Drop relations from boundaries above
|
|
72
|
-
forEach((conn) => {
|
|
73
|
-
excludedRelations.get(conn).add(relation)
|
|
74
|
-
}),
|
|
75
|
-
),
|
|
76
|
-
),
|
|
77
|
-
)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return excludedRelations
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Identifies and processes cross-boundary connections in a deployment diagram.
|
|
85
|
-
* This function analyzes connections between nodes and removes redundant relations
|
|
86
|
-
* when multiple connections exist between the same elements across different boundaries.
|
|
87
|
-
*
|
|
88
|
-
* The function performs the following:
|
|
89
|
-
* 1. Groups connections by their relationship type
|
|
90
|
-
* 2. For each relationship group, identifies connections that:
|
|
91
|
-
* - Share the same source
|
|
92
|
-
* - Share the same target
|
|
93
|
-
* 3. When multiple connections are found in the same group, keeps only the most specific
|
|
94
|
-
* (deepest in hierarchy) connection and removes the relationship from others
|
|
95
|
-
*
|
|
96
|
-
* @param connections - The input collection of deployment connections to analyze
|
|
97
|
-
* @returns connections with redundant cross-boundary relationships
|
|
98
|
-
*/
|
|
99
|
-
export function findCrossBoundaryConnections(connections: Connections): Array<Connection> {
|
|
100
|
-
// Ensure connections are merged
|
|
101
|
-
connections = mergeConnections(connections)
|
|
102
|
-
|
|
103
|
-
const excludedRelations = findCrossBoundarySameSourceOrTarget(connections)
|
|
104
|
-
|
|
105
|
-
for (const c of connections) {
|
|
106
|
-
const { source, target } = c
|
|
107
|
-
const connectionModelRelations = c.relations.model
|
|
108
|
-
// Connections between node and instance
|
|
109
|
-
// Exclude internal relations of the node (otherwise they are cross-boundary)
|
|
110
|
-
if (source.isDeploymentNode() !== target.isDeploymentNode()) {
|
|
111
|
-
const node = source.isDeploymentNode() ? source : c.target
|
|
112
|
-
invariant(node.isDeploymentNode())
|
|
113
|
-
const nodeInternals = node.internalModelRelationships()
|
|
114
|
-
const toExclude = intersection(
|
|
115
|
-
connectionModelRelations,
|
|
116
|
-
nodeInternals,
|
|
117
|
-
)
|
|
118
|
-
for (const relation of toExclude) {
|
|
119
|
-
excludedRelations.get(c).add(relation)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
continue
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Connection between nodes
|
|
126
|
-
if (source.isDeploymentNode() && target.isDeploymentNode()) {
|
|
127
|
-
const toExclude = union(
|
|
128
|
-
// Exclude node internals (otherwise thay are cross-boundary)
|
|
129
|
-
intersection(
|
|
130
|
-
c.relations.model,
|
|
131
|
-
source.internalModelRelationships(),
|
|
132
|
-
),
|
|
133
|
-
intersection(
|
|
134
|
-
c.relations.model,
|
|
135
|
-
target.internalModelRelationships(),
|
|
136
|
-
),
|
|
137
|
-
)
|
|
138
|
-
for (const relation of toExclude) {
|
|
139
|
-
excludedRelations.get(c).add(relation)
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return pipe(
|
|
145
|
-
excludedRelations.entries(),
|
|
146
|
-
imap(([c, excluded]) =>
|
|
147
|
-
c.update({
|
|
148
|
-
model: excluded,
|
|
149
|
-
deployment: null,
|
|
150
|
-
})
|
|
151
|
-
),
|
|
152
|
-
toArray(),
|
|
153
|
-
)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Cleans connections that cross boundaries by removing overlapping parts.
|
|
158
|
-
* @example
|
|
159
|
-
* ```ts
|
|
160
|
-
* const connections = getConnections();
|
|
161
|
-
* const cleanedConnections = cleanCrossBoundary(connections);
|
|
162
|
-
* ```
|
|
163
|
-
*/
|
|
164
|
-
export function cleanCrossBoundary(connections: Connections): Array<Connection> {
|
|
165
|
-
return differenceConnections(
|
|
166
|
-
connections,
|
|
167
|
-
findCrossBoundaryConnections(connections),
|
|
168
|
-
)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Identifies and returns redundant connections in a deployment view.
|
|
173
|
-
* A connection is considered redundant if its relationships are already implied
|
|
174
|
-
* through other connections
|
|
175
|
-
*
|
|
176
|
-
* @returns Array of redundant connections that can be safely removed
|
|
177
|
-
*/
|
|
178
|
-
export function findRedundantConnections(connections: Connections): Array<Connection> {
|
|
179
|
-
return pipe(
|
|
180
|
-
connections,
|
|
181
|
-
mergeConnections,
|
|
182
|
-
reduce((redundants, connection) => {
|
|
183
|
-
const { source, target, relations } = connection
|
|
184
|
-
|
|
185
|
-
// Connection between instances is always explicit
|
|
186
|
-
if (source.isInstance() && target.isInstance()) {
|
|
187
|
-
return redundants
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
let redundantAccum = RelationshipsAccum.empty()
|
|
191
|
-
|
|
192
|
-
if (source.isDeploymentNode() && target.isDeploymentNode()) {
|
|
193
|
-
const [reversed] = findConnection(target, source, 'directed')
|
|
194
|
-
if (reversed) {
|
|
195
|
-
redundantAccum = relations.intersect(reversed.relations)
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
for (const c of connections) {
|
|
200
|
-
if (isNestedConnection(c, connection)) {
|
|
201
|
-
redundantAccum = redundantAccum.union(
|
|
202
|
-
relations.intersect(c.relations),
|
|
203
|
-
)
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if (redundantAccum.nonEmpty) {
|
|
208
|
-
redundants.push(
|
|
209
|
-
new DeploymentConnectionModel(
|
|
210
|
-
source,
|
|
211
|
-
target,
|
|
212
|
-
redundantAccum,
|
|
213
|
-
),
|
|
214
|
-
)
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
return redundants
|
|
218
|
-
}, [] as DeploymentConnectionModel[]),
|
|
219
|
-
)
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Remove relationships from connection model, that are already included in the connections between descendants.
|
|
224
|
-
* In other words - if there is same connection down the hierarchy.
|
|
225
|
-
*
|
|
226
|
-
* @returns New connection without redundant relationships
|
|
227
|
-
* Connection may be empty if all relationships are redundant, in this case it should be removed
|
|
228
|
-
*/
|
|
229
|
-
export function cleanRedundantRelationships(
|
|
230
|
-
connections: Connections,
|
|
231
|
-
): Array<Connection> {
|
|
232
|
-
return differenceConnections(
|
|
233
|
-
connections,
|
|
234
|
-
findRedundantConnections(connections),
|
|
235
|
-
)
|
|
236
|
-
}
|