@likec4/core 1.41.0 → 1.42.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/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
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { isNot } from 'remeda'
|
|
2
|
-
import type { AnyAux, aux, Unknown } from '../../../types'
|
|
3
|
-
import { invariant } from '../../../utils'
|
|
4
|
-
import { customInspectSymbol } from '../../../utils/const'
|
|
5
|
-
import { ifilter, isome } from '../../../utils/iterable'
|
|
6
|
-
import { difference, equals, intersection, union } from '../../../utils/set'
|
|
7
|
-
import { stringHash } from '../../../utils/string-hash'
|
|
8
|
-
import type { ElementModel } from '../../ElementModel'
|
|
9
|
-
import type { RelationshipModel } from '../../RelationModel'
|
|
10
|
-
import type { Connection } from '../Connection'
|
|
11
|
-
import { hasSameSourceTarget } from '../ops'
|
|
12
|
-
import { findConnection } from './find'
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Connection refers to any relationships between two elements,
|
|
16
|
-
* both direct and implicit ones (between their nested elements).
|
|
17
|
-
*
|
|
18
|
-
* Merges relationships together to an single edge on the diagram.
|
|
19
|
-
*/
|
|
20
|
-
export class ConnectionModel<A extends AnyAux = Unknown> implements Connection<ElementModel<A>, aux.EdgeId> {
|
|
21
|
-
public readonly id: aux.EdgeId
|
|
22
|
-
|
|
23
|
-
constructor(
|
|
24
|
-
public readonly source: ElementModel<A>,
|
|
25
|
-
public readonly target: ElementModel<A>,
|
|
26
|
-
public readonly relations: ReadonlySet<RelationshipModel<A>> = new Set(),
|
|
27
|
-
) {
|
|
28
|
-
this.id = stringHash(`model:${source.id}:${target.id}`) as aux.EdgeId
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
private _boundary: ElementModel<A> | null | undefined
|
|
32
|
-
/**
|
|
33
|
-
* Common ancestor of the source and target elements.
|
|
34
|
-
* Represents the boundary of the connection.
|
|
35
|
-
*/
|
|
36
|
-
get boundary(): ElementModel<A> | null {
|
|
37
|
-
return this._boundary ??= this.source.commonAncestor(this.target)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Human readable expression of the connection
|
|
42
|
-
* Mostly used for testing and debugging
|
|
43
|
-
*/
|
|
44
|
-
get expression(): string {
|
|
45
|
-
return `${this.source.id} -> ${this.target.id}`
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Returns true if only includes relations between the source and target elements.
|
|
50
|
-
*/
|
|
51
|
-
get isDirect(): boolean {
|
|
52
|
-
return this.nonEmpty() && !this.isImplicit
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Returns true if includes relations between nested elements of the source and target elements.
|
|
57
|
-
*/
|
|
58
|
-
get isImplicit(): boolean {
|
|
59
|
-
return this.nonEmpty() && isome(this.relations, isNot(hasSameSourceTarget(this)))
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
get directRelations(): ReadonlySet<RelationshipModel<A>> {
|
|
63
|
-
return new Set(ifilter(this.relations, hasSameSourceTarget(this)))
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
nonEmpty(): boolean {
|
|
67
|
-
return this.relations.size > 0
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
mergeWith(other: ConnectionModel<A>) {
|
|
71
|
-
invariant(this.source.id === other.source.id, 'Cannot merge connections with different sources')
|
|
72
|
-
invariant(this.target.id === other.target.id, 'Cannot merge connections with different targets')
|
|
73
|
-
return new ConnectionModel(
|
|
74
|
-
this.source,
|
|
75
|
-
this.target,
|
|
76
|
-
union(this.relations, other.relations),
|
|
77
|
-
)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
difference(other: ConnectionModel<A>) {
|
|
81
|
-
return new ConnectionModel(
|
|
82
|
-
this.source,
|
|
83
|
-
this.target,
|
|
84
|
-
difference(this.relations, other.relations),
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
intersect(other: ConnectionModel<A>) {
|
|
89
|
-
invariant(other instanceof ConnectionModel, 'Cannot intersect connection with different type')
|
|
90
|
-
return new ConnectionModel(
|
|
91
|
-
this.source,
|
|
92
|
-
this.target,
|
|
93
|
-
intersection(this.relations, other.relations),
|
|
94
|
-
)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
equals(other: Connection): boolean {
|
|
98
|
-
invariant(other instanceof ConnectionModel, 'Cannot merge connection with different type')
|
|
99
|
-
const _other = other as ConnectionModel<A>
|
|
100
|
-
return this.id === _other.id
|
|
101
|
-
&& this.source.id === _other.source.id
|
|
102
|
-
&& this.target.id === _other.target.id
|
|
103
|
-
&& equals(this.relations, _other.relations)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Returns a new instance with the updated relations.
|
|
108
|
-
*
|
|
109
|
-
* @param relations - A readonly set of `RelationshipModel` instances representing the new relations.
|
|
110
|
-
* @returns A new `ConnectionModel` instance with the updated relations.
|
|
111
|
-
*/
|
|
112
|
-
update(relations: ReadonlySet<RelationshipModel<A>>): ConnectionModel<A> {
|
|
113
|
-
return new ConnectionModel(
|
|
114
|
-
this.source,
|
|
115
|
-
this.target,
|
|
116
|
-
relations,
|
|
117
|
-
)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
[customInspectSymbol](
|
|
121
|
-
// @ts-ignore
|
|
122
|
-
depth,
|
|
123
|
-
// @ts-ignore
|
|
124
|
-
inspectOptions,
|
|
125
|
-
// @ts-ignore
|
|
126
|
-
inspect,
|
|
127
|
-
) {
|
|
128
|
-
const asString = this.toString()
|
|
129
|
-
|
|
130
|
-
// Trick so that node displays the name of the constructor
|
|
131
|
-
Object.defineProperty(asString, 'constructor', {
|
|
132
|
-
value: ConnectionModel,
|
|
133
|
-
enumerable: false,
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
return asString
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
toString() {
|
|
140
|
-
return [
|
|
141
|
-
this.expression,
|
|
142
|
-
this.relations.size ? ' relations:' : ' relations: [ ]',
|
|
143
|
-
...[...this.relations].map(c => ' ' + c.expression),
|
|
144
|
-
].join('\n')
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Creates a new connection with reversed direction (target becomes source and vice versa)
|
|
149
|
-
* @param search - When true, attempts to find an existing connection between the reversed nodes
|
|
150
|
-
*/
|
|
151
|
-
reversed(search = false): ConnectionModel<A> {
|
|
152
|
-
if (!search) {
|
|
153
|
-
return new ConnectionModel(this.target, this.source)
|
|
154
|
-
}
|
|
155
|
-
const [found] = findConnection(this.target, this.source, 'directed')
|
|
156
|
-
return found ?? new ConnectionModel(this.target, this.source, new Set())
|
|
157
|
-
}
|
|
158
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import type { AnyAux } from '../../../types'
|
|
2
|
-
import { isSameHierarchy } from '../../../utils/fqn'
|
|
3
|
-
import { intersection } from '../../../utils/set'
|
|
4
|
-
import type { ElementModel } from '../../ElementModel'
|
|
5
|
-
import { ConnectionModel } from './ConnectionModel'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Resolve connection from source to target
|
|
9
|
-
*
|
|
10
|
-
* @param direction - if 'both', also returns connection from target to source
|
|
11
|
-
* @default `directed`
|
|
12
|
-
*/
|
|
13
|
-
export function findConnection<A extends AnyAux>(
|
|
14
|
-
source: ElementModel<A>,
|
|
15
|
-
target: ElementModel<A>,
|
|
16
|
-
direction: 'directed' | 'both' = 'directed',
|
|
17
|
-
):
|
|
18
|
-
| [ConnectionModel<A>, ConnectionModel<A>]
|
|
19
|
-
| [ConnectionModel<A>]
|
|
20
|
-
| []
|
|
21
|
-
{
|
|
22
|
-
if (source === target) {
|
|
23
|
-
return []
|
|
24
|
-
}
|
|
25
|
-
if (isSameHierarchy(source, target)) {
|
|
26
|
-
return []
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const directedIntersection = intersection(source.allOutgoing, target.allIncoming)
|
|
30
|
-
|
|
31
|
-
const directed = directedIntersection.size > 0
|
|
32
|
-
? new ConnectionModel(
|
|
33
|
-
source,
|
|
34
|
-
target,
|
|
35
|
-
directedIntersection,
|
|
36
|
-
)
|
|
37
|
-
: null
|
|
38
|
-
|
|
39
|
-
if (direction === 'directed') {
|
|
40
|
-
return directed ? [directed] : []
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const reverseIntersection = intersection(source.allIncoming, target.allOutgoing)
|
|
44
|
-
const reverse = reverseIntersection.size > 0
|
|
45
|
-
? new ConnectionModel(
|
|
46
|
-
target,
|
|
47
|
-
source,
|
|
48
|
-
reverseIntersection,
|
|
49
|
-
)
|
|
50
|
-
: null
|
|
51
|
-
|
|
52
|
-
if (directed && reverse) {
|
|
53
|
-
return [directed, reverse]
|
|
54
|
-
}
|
|
55
|
-
if (directed) {
|
|
56
|
-
return [directed]
|
|
57
|
-
}
|
|
58
|
-
if (reverse) {
|
|
59
|
-
return [reverse]
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return []
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Resolve all connections between element and others
|
|
67
|
-
* @param direction - if 'directed', only look for outgoing connections from the element to others
|
|
68
|
-
* @default `both`
|
|
69
|
-
*/
|
|
70
|
-
export function findConnectionsBetween<M extends AnyAux>(
|
|
71
|
-
element: ElementModel<M>,
|
|
72
|
-
others: Iterable<ElementModel<M>>,
|
|
73
|
-
direction: 'directed' | 'both' = 'both',
|
|
74
|
-
): readonly ConnectionModel<M>[] {
|
|
75
|
-
if (element.allIncoming.size === 0 && element.allOutgoing.size === 0) {
|
|
76
|
-
return []
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// We separate resolved connection,
|
|
80
|
-
// because we want return outgoing first
|
|
81
|
-
const outgoing = [] as ConnectionModel<M>[]
|
|
82
|
-
const incoming = [] as ConnectionModel<M>[]
|
|
83
|
-
for (const _other of others) {
|
|
84
|
-
if (element === _other) {
|
|
85
|
-
continue
|
|
86
|
-
}
|
|
87
|
-
for (const found of findConnection(element, _other, direction)) {
|
|
88
|
-
if (found.source === element) {
|
|
89
|
-
outgoing.push(found)
|
|
90
|
-
} else {
|
|
91
|
-
incoming.push(found)
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return [
|
|
96
|
-
...outgoing,
|
|
97
|
-
...incoming,
|
|
98
|
-
]
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Resolve all connections within a given set of elements
|
|
103
|
-
*/
|
|
104
|
-
export function findConnectionsWithin<M extends AnyAux>(
|
|
105
|
-
elements: Iterable<ElementModel<M>>,
|
|
106
|
-
): readonly ConnectionModel<M>[] {
|
|
107
|
-
return [...elements].reduce((acc, el, index, array) => {
|
|
108
|
-
// skip for last element
|
|
109
|
-
if (index === array.length - 1) {
|
|
110
|
-
return acc
|
|
111
|
-
}
|
|
112
|
-
acc.push(
|
|
113
|
-
...findConnectionsBetween(el, array.slice(index + 1), 'both'),
|
|
114
|
-
)
|
|
115
|
-
return acc
|
|
116
|
-
}, [] as ConnectionModel<M>[])
|
|
117
|
-
}
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
import { map, pipe } from 'remeda'
|
|
2
|
-
import type { IterableContainer, ReorderedArray } from '../../types'
|
|
3
|
-
import { isString } from '../../utils'
|
|
4
|
-
import {
|
|
5
|
-
isAncestor,
|
|
6
|
-
isDescendantOf,
|
|
7
|
-
sortNaturalByFqn,
|
|
8
|
-
} from '../../utils/fqn'
|
|
9
|
-
import type { Connection } from './Connection'
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Check if connection is nested inside another connection
|
|
13
|
-
* (i.e. between descendants)
|
|
14
|
-
*/
|
|
15
|
-
export function isNestedConnection<T extends { id: string }>(
|
|
16
|
-
parent: WithSourceTarget<NoInfer<T>>,
|
|
17
|
-
): (nested: WithSourceTarget<T>) => boolean
|
|
18
|
-
export function isNestedConnection<T extends { id: string }>(
|
|
19
|
-
nested: WithSourceTarget<T>,
|
|
20
|
-
parent: WithSourceTarget<T>,
|
|
21
|
-
): boolean
|
|
22
|
-
export function isNestedConnection<T extends { id: string }>(
|
|
23
|
-
nested: WithSourceTarget<T>,
|
|
24
|
-
parent?: WithSourceTarget<T>,
|
|
25
|
-
) {
|
|
26
|
-
if (!parent) {
|
|
27
|
-
const p = nested
|
|
28
|
-
return (n: WithSourceTarget<T>) => isNestedConnection(n, p)
|
|
29
|
-
}
|
|
30
|
-
const isSameSource = nested.source === parent.source
|
|
31
|
-
const isSameTarget = nested.target === parent.target
|
|
32
|
-
if (isSameSource && isSameTarget) {
|
|
33
|
-
return false
|
|
34
|
-
}
|
|
35
|
-
const isSourceNested = isAncestor(parent.source.id, nested.source.id)
|
|
36
|
-
const isTargetNested = isAncestor(parent.target.id, nested.target.id)
|
|
37
|
-
return (
|
|
38
|
-
(isSourceNested && isTargetNested)
|
|
39
|
-
|| (isSameSource && isTargetNested)
|
|
40
|
-
|| (isSameTarget && isSourceNested)
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
type ConnectionElemId = Connection<{ readonly id: string }, any>
|
|
45
|
-
|
|
46
|
-
export function findDeepestNestedConnection<C extends ConnectionElemId>(
|
|
47
|
-
connections: ReadonlyArray<C>,
|
|
48
|
-
connection: C,
|
|
49
|
-
): C | null {
|
|
50
|
-
let deepest = connection
|
|
51
|
-
for (const c of connections) {
|
|
52
|
-
if (isNestedConnection(c, deepest)) {
|
|
53
|
-
deepest = c
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return deepest !== connection ? deepest : null
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function sortDeepestFirst<C extends ConnectionElemId>(
|
|
60
|
-
connections: ReadonlyArray<C>,
|
|
61
|
-
): C[] {
|
|
62
|
-
const sorted = [] as C[]
|
|
63
|
-
const unsorted = connections.slice()
|
|
64
|
-
let next
|
|
65
|
-
while (next = unsorted.shift()) {
|
|
66
|
-
let deepest
|
|
67
|
-
while (deepest = findDeepestNestedConnection(unsorted, next)) {
|
|
68
|
-
const index = unsorted.indexOf(deepest)
|
|
69
|
-
sorted.push(unsorted.splice(index, 1)[0]!)
|
|
70
|
-
}
|
|
71
|
-
sorted.push(next)
|
|
72
|
-
}
|
|
73
|
-
return sorted
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* To make {@link sortConnectionsByBoundaryHierarchy} work correctly we add '.' to boundary
|
|
78
|
-
* Othwerwise connection without boundary will be considered same level as connection with top-level boundary
|
|
79
|
-
*/
|
|
80
|
-
export function boundaryHierarchy<C extends WithBoundary>(conn: C): string {
|
|
81
|
-
return conn.boundary?.id ? `.${conn.boundary.id}` : ''
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
type WithBoundary = {
|
|
85
|
-
id: string
|
|
86
|
-
boundary: null | { id: string }
|
|
87
|
-
}
|
|
88
|
-
export function sortConnectionsByBoundaryHierarchy(
|
|
89
|
-
sort?: 'asc' | 'desc',
|
|
90
|
-
): <T extends WithBoundary, A extends IterableContainer<T>>(array: A) => ReorderedArray<A>
|
|
91
|
-
export function sortConnectionsByBoundaryHierarchy<T extends WithBoundary, A extends IterableContainer<T>>(
|
|
92
|
-
array: A,
|
|
93
|
-
sort?: 'asc' | 'desc',
|
|
94
|
-
): ReorderedArray<A>
|
|
95
|
-
export function sortConnectionsByBoundaryHierarchy<T extends WithBoundary, A extends IterableContainer<T>>(
|
|
96
|
-
connections?: A | 'asc' | 'desc',
|
|
97
|
-
sort?: 'asc' | 'desc',
|
|
98
|
-
) {
|
|
99
|
-
if (!connections || isString(connections)) {
|
|
100
|
-
const dir = connections ?? 'asc'
|
|
101
|
-
return (arr: A) => _sortByBoundary(arr, dir)
|
|
102
|
-
}
|
|
103
|
-
return _sortByBoundary(connections, sort ?? 'asc')
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function _sortByBoundary<C extends WithBoundary>(
|
|
107
|
-
connections: ReadonlyArray<C>,
|
|
108
|
-
order: 'asc' | 'desc',
|
|
109
|
-
): C[] {
|
|
110
|
-
return pipe(
|
|
111
|
-
connections,
|
|
112
|
-
map(conn => ({
|
|
113
|
-
id: boundaryHierarchy(conn),
|
|
114
|
-
conn: conn,
|
|
115
|
-
})),
|
|
116
|
-
sortNaturalByFqn(order),
|
|
117
|
-
map(p => p.conn),
|
|
118
|
-
)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Find connections that includes given connection (i.e between it's ancestors)
|
|
123
|
-
*/
|
|
124
|
-
export function findAscendingConnections<C extends ConnectionElemId>(
|
|
125
|
-
connections: ReadonlyArray<C>,
|
|
126
|
-
connection: C,
|
|
127
|
-
): Array<C> {
|
|
128
|
-
return connections.filter(c => isNestedConnection(connection, c))
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Find connections that given connection includes (i.e between it's descendants)
|
|
133
|
-
*/
|
|
134
|
-
export function findDescendantConnections<C extends ConnectionElemId>(
|
|
135
|
-
connections: ReadonlyArray<C>,
|
|
136
|
-
connection: C,
|
|
137
|
-
): Array<C> {
|
|
138
|
-
return connections.filter(isNestedConnection(connection))
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export function mergeConnections<C extends IterableContainer<Connection<any, any>>>(
|
|
142
|
-
connections: C,
|
|
143
|
-
): Array<C[number]> {
|
|
144
|
-
const map = new Map<C[number]['id'], C[number]>()
|
|
145
|
-
for (const conn of connections) {
|
|
146
|
-
const existing = map.get(conn.id)
|
|
147
|
-
if (existing) {
|
|
148
|
-
map.set(conn.id, conn.mergeWith(existing))
|
|
149
|
-
} else {
|
|
150
|
-
map.set(conn.id, conn)
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return [...map.values()]
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Excludes the values existing in `other` array.
|
|
158
|
-
* The output maintains the same order as the input.
|
|
159
|
-
*/
|
|
160
|
-
export function differenceConnections<C extends Connection<any, any>>(
|
|
161
|
-
source: Iterable<C>,
|
|
162
|
-
exclude: Iterable<C>,
|
|
163
|
-
): C[] {
|
|
164
|
-
const minus = new Map([...exclude].map(c => [c.id, c]))
|
|
165
|
-
return [...source].reduce((acc, c) => {
|
|
166
|
-
const other = minus.get(c.id)
|
|
167
|
-
if (!other) {
|
|
168
|
-
acc.push(c)
|
|
169
|
-
return acc
|
|
170
|
-
}
|
|
171
|
-
const updated = c.difference(other) as C
|
|
172
|
-
if (updated.nonEmpty()) {
|
|
173
|
-
acc.push(updated)
|
|
174
|
-
}
|
|
175
|
-
return acc
|
|
176
|
-
}, [] as C[])
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
type WithSourceTarget<T = unknown> = {
|
|
180
|
-
source: T
|
|
181
|
-
target: T
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export function hasSameSourceTarget<T>(a: WithSourceTarget<NoInfer<T>>): (b: WithSourceTarget<T>) => boolean
|
|
185
|
-
export function hasSameSourceTarget<T>(a: WithSourceTarget<T>, b: WithSourceTarget<T>): boolean
|
|
186
|
-
export function hasSameSourceTarget(a: WithSourceTarget, b?: WithSourceTarget) {
|
|
187
|
-
if (b) {
|
|
188
|
-
return a.source === b.source && a.target === b.target
|
|
189
|
-
}
|
|
190
|
-
return (b: WithSourceTarget) => a.source === b.source && a.target === b.target
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export function hasSameSource<T>(a: WithSourceTarget<NoInfer<T>>): (b: WithSourceTarget<T>) => boolean
|
|
194
|
-
export function hasSameSource<T>(a: WithSourceTarget<T>, b: WithSourceTarget<T>): boolean
|
|
195
|
-
export function hasSameSource(a: WithSourceTarget, b?: WithSourceTarget) {
|
|
196
|
-
if (b) {
|
|
197
|
-
return a.source === b.source
|
|
198
|
-
}
|
|
199
|
-
return (b: WithSourceTarget) => a.source === b.source
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export function hasSameTarget<T>(a: WithSourceTarget<NoInfer<T>>): (b: WithSourceTarget<T>) => boolean
|
|
203
|
-
export function hasSameTarget<T>(a: WithSourceTarget<T>, b: WithSourceTarget<T>): boolean
|
|
204
|
-
export function hasSameTarget(a: WithSourceTarget, b?: WithSourceTarget) {
|
|
205
|
-
if (b) {
|
|
206
|
-
return a.target === b.target
|
|
207
|
-
}
|
|
208
|
-
return (b: WithSourceTarget) => a.target === b.target
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
type WithId<T> = {
|
|
212
|
-
id: T
|
|
213
|
-
}
|
|
214
|
-
export function isOutgoing<T extends string>(source: WithId<NoInfer<T>>): (a: WithSourceTarget<WithId<T>>) => boolean
|
|
215
|
-
export function isOutgoing<T extends string>(a: WithSourceTarget<WithId<T>>, source: WithId<T>): boolean
|
|
216
|
-
export function isOutgoing<T extends string>(a: WithSourceTarget<WithId<T>> | WithId<T>, source?: WithId<T>) {
|
|
217
|
-
if (!source) {
|
|
218
|
-
const _source = a as WithId<T>
|
|
219
|
-
return (b: WithSourceTarget<WithId<T>>) => isOutgoing(b, _source)
|
|
220
|
-
}
|
|
221
|
-
const at = a as WithSourceTarget<WithId<T>>
|
|
222
|
-
return isDescendantOf(at.source, source) && !isDescendantOf(at.target, source)
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export function isIncoming<T extends string>(target: WithId<NoInfer<T>>): (a: WithSourceTarget<WithId<T>>) => boolean
|
|
226
|
-
export function isIncoming<T extends string>(a: WithSourceTarget<WithId<T>>, target: WithId<T>): boolean
|
|
227
|
-
export function isIncoming<T extends string>(a: WithSourceTarget<WithId<T>> | WithId<T>, target?: WithId<T>) {
|
|
228
|
-
if (!target) {
|
|
229
|
-
const _target = a as WithId<T>
|
|
230
|
-
return (b: WithSourceTarget<WithId<T>>) => isIncoming(b, _target)
|
|
231
|
-
}
|
|
232
|
-
const at = a as WithSourceTarget<WithId<T>>
|
|
233
|
-
return isDescendantOf(at.target, target) && !isDescendantOf(at.source, target)
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export function isAnyInOut<T extends string>(source: WithId<NoInfer<T>>): (a: WithSourceTarget<WithId<T>>) => boolean
|
|
237
|
-
export function isAnyInOut<T extends string>(a: WithSourceTarget<WithId<T>>, source: WithId<T>): boolean
|
|
238
|
-
export function isAnyInOut<T extends string>(a: WithSourceTarget<WithId<T>> | WithId<T>, source?: WithId<T>) {
|
|
239
|
-
if (!source) {
|
|
240
|
-
const _source = a as WithId<T>
|
|
241
|
-
return (b: WithSourceTarget<WithId<T>>) => isAnyInOut(b, _source)
|
|
242
|
-
}
|
|
243
|
-
const at = a as WithSourceTarget<WithId<T>>
|
|
244
|
-
return isDescendantOf(at.source, source) !== isDescendantOf(at.target, source)
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
export function isInside<T extends string>(source: WithId<NoInfer<T>>): (a: WithSourceTarget<WithId<T>>) => boolean
|
|
248
|
-
export function isInside<T extends string>(a: WithSourceTarget<WithId<T>>, source: WithId<T>): boolean
|
|
249
|
-
export function isInside<T extends string>(a: WithSourceTarget<WithId<T>> | WithId<T>, source?: WithId<T>) {
|
|
250
|
-
if (!source) {
|
|
251
|
-
const _source = a as WithId<T>
|
|
252
|
-
return (b: WithSourceTarget<WithId<T>>) => isInside(b, _source)
|
|
253
|
-
}
|
|
254
|
-
const at = a as WithSourceTarget<WithId<T>>
|
|
255
|
-
return isDescendantOf(at.source, source) && isDescendantOf(at.target, source)
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// export function isIncoming<T>(target: NoInfer<T>): (a: WithSourceTarget<T>) => boolean
|
|
259
|
-
// export function isIncoming<T>(a: WithSourceTarget<T>, target: T): boolean
|
|
260
|
-
// export function isIncoming<T = unknown>(a: WithSourceTarget<T> | T, target?: T) {
|
|
261
|
-
// if (target) {
|
|
262
|
-
// return (a as WithSourceTarget<T>).target === target
|
|
263
|
-
// }
|
|
264
|
-
// const _target = a as T
|
|
265
|
-
// return (b: WithSourceTarget) => b.target === _target
|
|
266
|
-
// }
|
|
267
|
-
|
|
268
|
-
// export function isAnyInOut<T>(source: NoInfer<T>): (a: WithSourceTarget<T>) => boolean
|
|
269
|
-
// export function isAnyInOut<T>(a: WithSourceTarget<T>, source: T): boolean
|
|
270
|
-
// export function isAnyInOut<T = unknown>(a: WithSourceTarget<T> | T, source?: T) {
|
|
271
|
-
// if (source) {
|
|
272
|
-
// return hasSameSource(a as WithSourceTarget<T>, source) || hasSameTarget(a as WithSourceTarget<T>, source)
|
|
273
|
-
// }
|
|
274
|
-
// const _source = a as T
|
|
275
|
-
// return (b: WithSourceTarget) => hasSameSource(b, _source) || hasSameTarget(b, _source)
|
|
276
|
-
// }
|
package/src/model/guards.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { Any, AnyAux } from '../types'
|
|
2
|
-
import {
|
|
3
|
-
type DeploymentElementModel,
|
|
4
|
-
DeployedInstanceModel,
|
|
5
|
-
DeploymentNodeModel,
|
|
6
|
-
DeploymentRelationModel,
|
|
7
|
-
NestedElementOfDeployedInstanceModel,
|
|
8
|
-
} from './DeploymentElementModel'
|
|
9
|
-
import { ElementModel } from './ElementModel'
|
|
10
|
-
import { type AnyRelationshipModel, RelationshipModel } from './RelationModel'
|
|
11
|
-
import { EdgeModel } from './view/EdgeModel'
|
|
12
|
-
import { LikeC4ViewModel } from './view/LikeC4ViewModel'
|
|
13
|
-
import { NodeModel } from './view/NodeModel'
|
|
14
|
-
|
|
15
|
-
type AnyModel<A extends AnyAux> =
|
|
16
|
-
| DeploymentNodeModel<A>
|
|
17
|
-
| DeployedInstanceModel<A>
|
|
18
|
-
| DeploymentRelationModel<A>
|
|
19
|
-
| AnyRelationshipModel<A>
|
|
20
|
-
| NestedElementOfDeployedInstanceModel<A>
|
|
21
|
-
| ElementModel<A>
|
|
22
|
-
| RelationshipModel<A>
|
|
23
|
-
| LikeC4ViewModel<A>
|
|
24
|
-
| NodeModel<A>
|
|
25
|
-
| EdgeModel<A>
|
|
26
|
-
|
|
27
|
-
export function isDeploymentNodeModel<M extends AnyAux>(
|
|
28
|
-
model: AnyModel<M>,
|
|
29
|
-
): model is DeploymentNodeModel<M> {
|
|
30
|
-
return model instanceof DeploymentNodeModel
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function isDeployedInstanceModel<M extends AnyAux>(
|
|
34
|
-
model: AnyModel<M>,
|
|
35
|
-
): model is DeployedInstanceModel<M> {
|
|
36
|
-
return model instanceof DeployedInstanceModel
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function isDeploymentElementModel<M extends AnyAux>(model: AnyModel<M>): model is DeploymentElementModel<M> {
|
|
40
|
-
return isDeploymentNodeModel(model) || isDeployedInstanceModel(model)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function isNestedElementOfDeployedInstanceModel<M extends AnyAux>(
|
|
44
|
-
model: AnyModel<M>,
|
|
45
|
-
): model is NestedElementOfDeployedInstanceModel<M> {
|
|
46
|
-
return model instanceof NestedElementOfDeployedInstanceModel
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function isDeploymentRelationModel<M extends AnyAux>(
|
|
50
|
-
x: AnyModel<M>,
|
|
51
|
-
): x is DeploymentRelationModel<M> {
|
|
52
|
-
return x instanceof DeploymentRelationModel
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function isRelationModel<M extends AnyAux>(x: AnyModel<M>): x is RelationshipModel<M> {
|
|
56
|
-
return x instanceof RelationshipModel
|
|
57
|
-
}
|
|
58
|
-
export {
|
|
59
|
-
isRelationModel as isModelRelation,
|
|
60
|
-
isRelationModel as isRelationshipModel,
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function isElementModel<M extends Any>(element: AnyModel<M>): element is ElementModel<M> {
|
|
64
|
-
return element instanceof ElementModel
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function isLikeC4ViewModel<M extends Any>(view: AnyModel<M>): view is LikeC4ViewModel<M> {
|
|
68
|
-
return view instanceof LikeC4ViewModel
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function isNodeModel<M extends Any>(node: AnyModel<M>): node is NodeModel<M> {
|
|
72
|
-
return node instanceof NodeModel
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function isEdgeModel<M extends Any>(edge: AnyModel<M>): edge is EdgeModel<M> {
|
|
76
|
-
return edge instanceof EdgeModel
|
|
77
|
-
}
|