@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
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { anyPass, filter, pipe } from 'remeda'
|
|
2
|
-
import type { AnyAux, LikeC4DeploymentModel, RelationshipModel } from '../../../model'
|
|
3
|
-
import { type RelationExpr, FqnExpr } from '../../../types'
|
|
4
|
-
import { invariant, isAncestor } from '../../../utils'
|
|
5
|
-
import type { Connection, Elem, PredicateExecutor } from '../_types'
|
|
6
|
-
import { findConnectionsBetween, resolveElements, resolveModelElements } from '../utils'
|
|
7
|
-
import { resolveAscendingSiblings } from './relation-direct'
|
|
8
|
-
import { applyPredicate, excludeModelRelations } from './utils'
|
|
9
|
-
|
|
10
|
-
// from visible element incoming to this
|
|
11
|
-
export const IncomingRelationPredicate: PredicateExecutor<RelationExpr.Incoming> = {
|
|
12
|
-
include: ({ expr, model, memory, stage, where }) => {
|
|
13
|
-
const sources = [...memory.elements]
|
|
14
|
-
|
|
15
|
-
if (FqnExpr.isWildcard(expr.incoming)) {
|
|
16
|
-
for (const source of sources) {
|
|
17
|
-
if (source.allOutgoing.isEmpty) {
|
|
18
|
-
continue
|
|
19
|
-
}
|
|
20
|
-
const targets = [...resolveAscendingSiblings(source)]
|
|
21
|
-
const toInclude = applyPredicate(findConnectionsBetween(source, targets, 'directed'), where)
|
|
22
|
-
stage.addConnections(toInclude)
|
|
23
|
-
}
|
|
24
|
-
return stage
|
|
25
|
-
}
|
|
26
|
-
invariant(FqnExpr.isDeploymentRef(expr.incoming), 'Only deployment refs are supported in include')
|
|
27
|
-
|
|
28
|
-
const targets = resolveElements(model, expr.incoming)
|
|
29
|
-
for (const source of sources) {
|
|
30
|
-
const toInclude = applyPredicate(findConnectionsBetween(source, targets, 'directed'), where)
|
|
31
|
-
stage.addConnections(toInclude)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return stage
|
|
35
|
-
},
|
|
36
|
-
exclude: ({ expr, model, memory, stage, where }) => {
|
|
37
|
-
if (FqnExpr.isElementTagExpr(expr.incoming) || FqnExpr.isElementKindExpr(expr.incoming)) {
|
|
38
|
-
throw new Error('element kind and tag expressions are not supported in exclude')
|
|
39
|
-
}
|
|
40
|
-
// Exclude all connections that have model relationshps with the elements
|
|
41
|
-
if (FqnExpr.isModelRef(expr.incoming)) {
|
|
42
|
-
const excludedRelations = resolveAllImcomingRelations(model, expr.incoming)
|
|
43
|
-
return excludeModelRelations(excludedRelations, { stage, memory }, where)
|
|
44
|
-
}
|
|
45
|
-
if (FqnExpr.isWildcard(expr.incoming)) {
|
|
46
|
-
// non-sense
|
|
47
|
-
return stage
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const isIncoming = filterIncomingConnections(resolveElements(model, expr.incoming))
|
|
51
|
-
const toExclude = pipe(
|
|
52
|
-
memory.connections,
|
|
53
|
-
filter(isIncoming),
|
|
54
|
-
applyPredicate(where),
|
|
55
|
-
)
|
|
56
|
-
stage.excludeConnections(toExclude)
|
|
57
|
-
return stage
|
|
58
|
-
},
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function filterIncomingConnections(
|
|
62
|
-
targets: Elem[],
|
|
63
|
-
): (connection: Connection) => boolean {
|
|
64
|
-
return anyPass(
|
|
65
|
-
targets.map(target => {
|
|
66
|
-
const satisfies = (el: Elem) => el === target || isAncestor(target, el)
|
|
67
|
-
return (connection: Connection) => {
|
|
68
|
-
return !satisfies(connection.source) && satisfies(connection.target)
|
|
69
|
-
}
|
|
70
|
-
}),
|
|
71
|
-
)
|
|
72
|
-
}
|
|
73
|
-
// model: LikeC4DeploymentModel,
|
|
74
|
-
// model: LikeC4DeploymentModel,
|
|
75
|
-
// expr: FqnExpr.DeploymentRef
|
|
76
|
-
// ): (connection: Connection) => boolean {
|
|
77
|
-
// if (FqnExpr.isWildcard(expr)) {
|
|
78
|
-
// return () => true
|
|
79
|
-
// }
|
|
80
|
-
// if (isNullish(expr.selector)) {
|
|
81
|
-
// // -> element
|
|
82
|
-
// const target = model.element(expr.ref.deployment)
|
|
83
|
-
// const isInside = (el: Elem) => el === target || isAncestor(target, el)
|
|
84
|
-
// return (connection) => {
|
|
85
|
-
// return !isInside(connection.source) && isInside(connection.target)
|
|
86
|
-
// }
|
|
87
|
-
// }
|
|
88
|
-
|
|
89
|
-
// const isTarget = deploymentExpressionToPredicate(expr)
|
|
90
|
-
// return (connection) => {
|
|
91
|
-
// return isTarget(connection.target)
|
|
92
|
-
// }
|
|
93
|
-
// }
|
|
94
|
-
|
|
95
|
-
export function resolveAllImcomingRelations<A extends AnyAux>(
|
|
96
|
-
model: LikeC4DeploymentModel<A>,
|
|
97
|
-
moodelRef: FqnExpr.ModelRef<A>,
|
|
98
|
-
): Set<RelationshipModel<A>> {
|
|
99
|
-
const targets = resolveModelElements(model, moodelRef)
|
|
100
|
-
return new Set(targets.flatMap(e => [...e.allIncoming]))
|
|
101
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { anyPass, filter, pipe } from 'remeda'
|
|
2
|
-
import type { AnyAux, LikeC4DeploymentModel, RelationshipModel } from '../../../model'
|
|
3
|
-
import { type RelationExpr, FqnExpr } from '../../../types'
|
|
4
|
-
import { invariant, isAncestor } from '../../../utils'
|
|
5
|
-
import type { Connection, Elem, PredicateExecutor } from '../_types'
|
|
6
|
-
import { findConnection, findConnectionsBetween, resolveElements, resolveModelElements } from '../utils'
|
|
7
|
-
import { resolveAscendingSiblings } from './relation-direct'
|
|
8
|
-
import { applyPredicate, excludeModelRelations } from './utils'
|
|
9
|
-
|
|
10
|
-
export const OutgoingRelationPredicate: PredicateExecutor<RelationExpr.Outgoing> = {
|
|
11
|
-
include: ({ expr, model, memory, stage, where }) => {
|
|
12
|
-
const targets = [...memory.elements]
|
|
13
|
-
|
|
14
|
-
// * -> (to visible elements)
|
|
15
|
-
// outgoing from wildcard to visible element
|
|
16
|
-
if (FqnExpr.isWildcard(expr.outgoing)) {
|
|
17
|
-
for (const target of targets) {
|
|
18
|
-
if (target.allIncoming.isEmpty) {
|
|
19
|
-
continue
|
|
20
|
-
}
|
|
21
|
-
for (const source of resolveAscendingSiblings(target)) {
|
|
22
|
-
const toInclude = applyPredicate(findConnection(source, target, 'directed'), where)
|
|
23
|
-
stage.addConnections(toInclude)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return stage
|
|
27
|
-
}
|
|
28
|
-
invariant(FqnExpr.isDeploymentRef(expr.outgoing), 'Only deployment refs are supported in include')
|
|
29
|
-
|
|
30
|
-
const sources = resolveElements(model, expr.outgoing)
|
|
31
|
-
for (const source of sources) {
|
|
32
|
-
const toInclude = applyPredicate(findConnectionsBetween(source, targets, 'directed'), where)
|
|
33
|
-
stage.addConnections(toInclude)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return stage
|
|
37
|
-
},
|
|
38
|
-
exclude: ({ expr, model, memory, stage, where }) => {
|
|
39
|
-
if (FqnExpr.isElementTagExpr(expr.outgoing) || FqnExpr.isElementKindExpr(expr.outgoing)) {
|
|
40
|
-
throw new Error('element kind and tag expressions are not supported in exclude')
|
|
41
|
-
}
|
|
42
|
-
// Exclude all connections that have model relationshps with the elements
|
|
43
|
-
if (FqnExpr.isModelRef(expr.outgoing)) {
|
|
44
|
-
const excludedRelations = resolveAllOutgoingRelations(model, expr.outgoing)
|
|
45
|
-
return excludeModelRelations(excludedRelations, { stage, memory }, where)
|
|
46
|
-
}
|
|
47
|
-
if (FqnExpr.isWildcard(expr.outgoing)) {
|
|
48
|
-
// non-sense
|
|
49
|
-
return stage
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const isOutgoing = filterOutgoingConnections(resolveElements(model, expr.outgoing))
|
|
53
|
-
const toExclude = pipe(
|
|
54
|
-
memory.connections,
|
|
55
|
-
filter(isOutgoing),
|
|
56
|
-
applyPredicate(where),
|
|
57
|
-
)
|
|
58
|
-
stage.excludeConnections(toExclude)
|
|
59
|
-
return stage
|
|
60
|
-
},
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function filterOutgoingConnections(
|
|
64
|
-
sources: Elem[],
|
|
65
|
-
): (connection: Connection) => boolean {
|
|
66
|
-
return anyPass(
|
|
67
|
-
sources.map(source => {
|
|
68
|
-
const satisfies = (el: Elem) => el === source || isAncestor(source, el)
|
|
69
|
-
return (connection: Connection) => {
|
|
70
|
-
return satisfies(connection.source) && !satisfies(connection.target)
|
|
71
|
-
}
|
|
72
|
-
}),
|
|
73
|
-
)
|
|
74
|
-
// if (FqnExpr.isDeploymentRef(expr) && isNullish(expr.selector)) {
|
|
75
|
-
// // element ->
|
|
76
|
-
// const source = model.element(expr.ref.deployment)
|
|
77
|
-
// const isInside = (el: Elem) => el === source || isAncestor(source, el)
|
|
78
|
-
// return (connection: Connection) => {
|
|
79
|
-
// return isInside(connection.source) && !isInside(connection.target)
|
|
80
|
-
// }
|
|
81
|
-
// } else {
|
|
82
|
-
// const isSource = deploymentExpressionToPredicate(expr)
|
|
83
|
-
// return (connection: Connection) => {
|
|
84
|
-
// return isSource(connection.source)
|
|
85
|
-
// }
|
|
86
|
-
// }
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function resolveAllOutgoingRelations<A extends AnyAux>(
|
|
90
|
-
model: LikeC4DeploymentModel<A>,
|
|
91
|
-
moodelRef: FqnExpr.ModelRef<A>,
|
|
92
|
-
): Set<RelationshipModel<A>> {
|
|
93
|
-
const targets = resolveModelElements(model, moodelRef)
|
|
94
|
-
return new Set(targets.flatMap(e => [...e.allOutgoing]))
|
|
95
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { whereOperatorAsPredicate, type RelationExpr } from '../../../types'
|
|
2
|
-
import type { PredicateExecutor } from '../_types'
|
|
3
|
-
import type { StageExclude, StageInclude } from '../memory'
|
|
4
|
-
import { predicateToPatch } from './utils'
|
|
5
|
-
|
|
6
|
-
// relation matches the condition
|
|
7
|
-
export const WhereRelationPredicate: PredicateExecutor<RelationExpr.Where> = {
|
|
8
|
-
include: ({ expr, model, memory, stage }) => {
|
|
9
|
-
const where = whereOperatorAsPredicate(expr.where.condition)
|
|
10
|
-
|
|
11
|
-
return predicateToPatch('include', { expr: expr.where.expr, model, stage, memory, where }) as StageInclude
|
|
12
|
-
},
|
|
13
|
-
exclude: ({ expr, model, memory, stage }) => {
|
|
14
|
-
const where = whereOperatorAsPredicate(expr.where.condition)
|
|
15
|
-
|
|
16
|
-
return predicateToPatch('exclude', { expr: expr.where.expr, model, stage, memory, where }) as StageExclude
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
import { filter, isArray, map, pick, pipe } from 'remeda'
|
|
2
|
-
import type {
|
|
3
|
-
DeploymentElementModel,
|
|
4
|
-
DeploymentRelationEndpoint,
|
|
5
|
-
DeploymentRelationModel,
|
|
6
|
-
RelationshipModel,
|
|
7
|
-
} from '../../../model'
|
|
8
|
-
import {
|
|
9
|
-
type DeploymentConnectionModel,
|
|
10
|
-
ElementModel,
|
|
11
|
-
isDeployedInstanceModel as isDeployedInstance,
|
|
12
|
-
isDeploymentElementModel,
|
|
13
|
-
isDeploymentNodeModel as isDeploymentNode,
|
|
14
|
-
isElementModel,
|
|
15
|
-
isNestedElementOfDeployedInstanceModel,
|
|
16
|
-
} from '../../../model'
|
|
17
|
-
import type { AnyAux } from '../../../types'
|
|
18
|
-
import { type Filterable, type OperatorPredicate, FqnExpr, RelationExpr } from '../../../types'
|
|
19
|
-
import { nonexhaustive } from '../../../utils'
|
|
20
|
-
import { hasIntersection, intersection } from '../../../utils/set'
|
|
21
|
-
import type { ExcludePredicateCtx, PredicateCtx } from '../_types'
|
|
22
|
-
import type { StageExclude, StageInclude } from '../memory'
|
|
23
|
-
import { DeploymentRefPredicate } from './deploymentRefs'
|
|
24
|
-
import { WhereDeploymentRefPredicate } from './deploymentRefs-where'
|
|
25
|
-
import { DirectRelationPredicate } from './relation-direct'
|
|
26
|
-
import { InOutRelationPredicate } from './relation-in-out'
|
|
27
|
-
import { IncomingRelationPredicate } from './relation-incoming'
|
|
28
|
-
import { OutgoingRelationPredicate } from './relation-outgoing'
|
|
29
|
-
import { WhereRelationPredicate } from './relation-where'
|
|
30
|
-
import { WildcardPredicate } from './wildcard'
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Builds a patch object from an expression
|
|
34
|
-
*/
|
|
35
|
-
export function predicateToPatch(
|
|
36
|
-
op: 'include' | 'exclude',
|
|
37
|
-
{ expr, where, ...ctx }: PredicateCtx,
|
|
38
|
-
): StageExclude | StageInclude | undefined {
|
|
39
|
-
switch (true) {
|
|
40
|
-
case FqnExpr.isElementTagExpr(expr):
|
|
41
|
-
case FqnExpr.isElementKindExpr(expr):
|
|
42
|
-
throw new Error('element kind and tag expressions are not supported in deployment view rules')
|
|
43
|
-
case RelationExpr.isCustom(expr):
|
|
44
|
-
case FqnExpr.isCustom(expr):
|
|
45
|
-
case FqnExpr.isModelRef(expr):
|
|
46
|
-
// Ignore model refs in deployment view
|
|
47
|
-
return undefined
|
|
48
|
-
case FqnExpr.isWhere(expr):
|
|
49
|
-
return WhereDeploymentRefPredicate[op]({ ...ctx, expr, where } as any)
|
|
50
|
-
case RelationExpr.isWhere(expr):
|
|
51
|
-
return WhereRelationPredicate[op]({ ...ctx, expr, where } as any)
|
|
52
|
-
case FqnExpr.isDeploymentRef(expr):
|
|
53
|
-
return DeploymentRefPredicate[op]({ ...ctx, expr, where } as any)
|
|
54
|
-
case FqnExpr.isWildcard(expr):
|
|
55
|
-
return WildcardPredicate[op]({ ...ctx, expr, where } as any)
|
|
56
|
-
case RelationExpr.isDirect(expr):
|
|
57
|
-
return DirectRelationPredicate[op]({ ...ctx, expr, where } as any)
|
|
58
|
-
case RelationExpr.isInOut(expr):
|
|
59
|
-
return InOutRelationPredicate[op]({ ...ctx, expr, where } as any)
|
|
60
|
-
case RelationExpr.isOutgoing(expr):
|
|
61
|
-
return OutgoingRelationPredicate[op]({ ...ctx, expr, where } as any)
|
|
62
|
-
case RelationExpr.isIncoming(expr):
|
|
63
|
-
return IncomingRelationPredicate[op]({ ...ctx, expr, where } as any)
|
|
64
|
-
default:
|
|
65
|
-
nonexhaustive(expr)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function excludeModelRelations<M extends AnyAux>(
|
|
70
|
-
relationsToExclude: ReadonlySet<RelationshipModel<M>>,
|
|
71
|
-
{ stage, memory }: Pick<ExcludePredicateCtx, 'stage' | 'memory'>,
|
|
72
|
-
where: OperatorPredicate<M> | null,
|
|
73
|
-
// Optional filter to scope the connections to exclude
|
|
74
|
-
filterConnections: (c: DeploymentConnectionModel<M>) => boolean = () => true,
|
|
75
|
-
): StageExclude {
|
|
76
|
-
if (relationsToExclude.size === 0) {
|
|
77
|
-
return stage
|
|
78
|
-
}
|
|
79
|
-
const toExclude = pipe(
|
|
80
|
-
memory.connections as unknown as readonly DeploymentConnectionModel<M>[],
|
|
81
|
-
filter(c => filterConnections(c)),
|
|
82
|
-
// Find connections that have at least one relation in common with the excluded relations
|
|
83
|
-
filter(c => hasIntersection(c.relations.model, relationsToExclude)),
|
|
84
|
-
map(c =>
|
|
85
|
-
c.update({
|
|
86
|
-
deployment: null,
|
|
87
|
-
model: intersection(c.relations.model, relationsToExclude),
|
|
88
|
-
})
|
|
89
|
-
),
|
|
90
|
-
applyPredicate(where),
|
|
91
|
-
filter(c => c.nonEmpty()),
|
|
92
|
-
)
|
|
93
|
-
if (toExclude.length === 0) {
|
|
94
|
-
return stage
|
|
95
|
-
}
|
|
96
|
-
return stage.excludeConnections(toExclude as unknown as DeploymentConnectionModel[])
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function matchConnection<M extends AnyAux>(
|
|
100
|
-
c: DeploymentConnectionModel<M>,
|
|
101
|
-
where: OperatorPredicate<M> | null,
|
|
102
|
-
): boolean {
|
|
103
|
-
return applyPredicate(c, where).nonEmpty()
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Filters relations of the provided connections using the provided predicate.
|
|
108
|
-
* And copy of the connection with the filtered relations will be created.
|
|
109
|
-
* Connections left without relations are removed from resulting collection.
|
|
110
|
-
*
|
|
111
|
-
* @param c The connection to apply the predicate to
|
|
112
|
-
* @param where The predicate
|
|
113
|
-
* @returns A copy of the connection with the filtered relations
|
|
114
|
-
*/
|
|
115
|
-
export function applyPredicate<M extends AnyAux>(
|
|
116
|
-
c: readonly DeploymentConnectionModel<M>[],
|
|
117
|
-
where: OperatorPredicate<M> | null,
|
|
118
|
-
): readonly DeploymentConnectionModel<M>[]
|
|
119
|
-
/**
|
|
120
|
-
* Filters relations of the connection using the provided predicate.
|
|
121
|
-
*
|
|
122
|
-
* @param c The connection to apply the predicate to
|
|
123
|
-
* @param where The predicate
|
|
124
|
-
* @returns A deep copy of the original collection with the filtered relations
|
|
125
|
-
*/
|
|
126
|
-
export function applyPredicate<M extends AnyAux>(
|
|
127
|
-
c: DeploymentConnectionModel<M>,
|
|
128
|
-
where: OperatorPredicate<M> | null,
|
|
129
|
-
): DeploymentConnectionModel<M>
|
|
130
|
-
/**
|
|
131
|
-
* Creates a function that filters relations of the provided connections using the provided predicate.
|
|
132
|
-
* Connections left without relations are removed from resulting collection.
|
|
133
|
-
*
|
|
134
|
-
* @param c The connection to apply the predicate to
|
|
135
|
-
* @param where The predicate
|
|
136
|
-
* @returns A function to create a filtered copy of connections
|
|
137
|
-
*/
|
|
138
|
-
export function applyPredicate<M extends AnyAux>(
|
|
139
|
-
where: OperatorPredicate<M> | null,
|
|
140
|
-
): (data: readonly DeploymentConnectionModel<M>[]) => readonly DeploymentConnectionModel<M>[]
|
|
141
|
-
export function applyPredicate<M extends AnyAux>(
|
|
142
|
-
...args:
|
|
143
|
-
| [readonly DeploymentConnectionModel<M>[], OperatorPredicate<M> | null]
|
|
144
|
-
| [OperatorPredicate<M> | null]
|
|
145
|
-
| [c: DeploymentConnectionModel<M>, OperatorPredicate<M> | null]
|
|
146
|
-
):
|
|
147
|
-
| DeploymentConnectionModel<M>
|
|
148
|
-
| readonly DeploymentConnectionModel<M>[]
|
|
149
|
-
| ((data: readonly DeploymentConnectionModel<M>[]) => readonly DeploymentConnectionModel<M>[])
|
|
150
|
-
{
|
|
151
|
-
if (args.length === 1) {
|
|
152
|
-
return x => applyPredicate(x, args[0])
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const [c, where] = args
|
|
156
|
-
if (where === null) {
|
|
157
|
-
return c
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (isArray(c)) {
|
|
161
|
-
return c
|
|
162
|
-
.map(x => applyPredicate(x, where))
|
|
163
|
-
.filter(x => x.nonEmpty())
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return c.update({
|
|
167
|
-
model: new Set([...c.relations.model.values()].filter(r => where(toFilterableRelation(c)(r)))),
|
|
168
|
-
deployment: new Set([...c.relations.deployment.values()].filter(r => where(toFilterableRelation(c)(r)))),
|
|
169
|
-
})
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Checks elements using the provided predicate.
|
|
174
|
-
*
|
|
175
|
-
* @param c The collection of element to apply the predicate to
|
|
176
|
-
* @param where The predicate
|
|
177
|
-
* @returns Returns array of elements those match the predicate
|
|
178
|
-
*/
|
|
179
|
-
export function applyElementPredicate<M extends AnyAux>(
|
|
180
|
-
c: readonly DeploymentElementModel<M>[],
|
|
181
|
-
where: OperatorPredicate<M> | null,
|
|
182
|
-
): readonly DeploymentElementModel<M>[]
|
|
183
|
-
/**
|
|
184
|
-
* Checks element using the provided predicate.
|
|
185
|
-
*
|
|
186
|
-
* @param c The element to apply the predicate to
|
|
187
|
-
* @param where The predicate
|
|
188
|
-
* @returns The result of the check
|
|
189
|
-
*/
|
|
190
|
-
export function applyElementPredicate<M extends AnyAux, E extends DeploymentElementModel<M>>(
|
|
191
|
-
c: E,
|
|
192
|
-
where: OperatorPredicate<M> | null,
|
|
193
|
-
): boolean
|
|
194
|
-
/**
|
|
195
|
-
* Creates a function that filters elemetns using the provided predicate.
|
|
196
|
-
*
|
|
197
|
-
* @param where The predicate
|
|
198
|
-
* @returns A function to filter elements
|
|
199
|
-
*/
|
|
200
|
-
export function applyElementPredicate<M extends AnyAux, E extends DeploymentElementModel<M>>(
|
|
201
|
-
where: OperatorPredicate<M> | null,
|
|
202
|
-
): (data: readonly E[]) => readonly E[]
|
|
203
|
-
export function applyElementPredicate<M extends AnyAux, E extends DeploymentElementModel<M>>(
|
|
204
|
-
...args:
|
|
205
|
-
| [readonly E[], OperatorPredicate<M> | null]
|
|
206
|
-
| [OperatorPredicate<M> | null]
|
|
207
|
-
| [c: E, OperatorPredicate<M> | null]
|
|
208
|
-
):
|
|
209
|
-
| boolean
|
|
210
|
-
| readonly E[]
|
|
211
|
-
| ((data: readonly E[]) => readonly E[])
|
|
212
|
-
{
|
|
213
|
-
if (args.length === 1) {
|
|
214
|
-
return x => applyElementPredicate(x, args[0]) as readonly E[]
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
const [c, where] = args
|
|
218
|
-
|
|
219
|
-
if (isArray(c)) {
|
|
220
|
-
return c.filter(x => applyElementPredicate(x, where))
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
return where?.(toFilterable(c, c)) ?? true
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export function matchConnections<M extends AnyAux>(
|
|
227
|
-
connections: readonly DeploymentConnectionModel<M>[],
|
|
228
|
-
where: OperatorPredicate<M> | null,
|
|
229
|
-
): readonly DeploymentConnectionModel<M>[] {
|
|
230
|
-
if (!where) {
|
|
231
|
-
return connections
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return pipe(
|
|
235
|
-
connections,
|
|
236
|
-
filter(c => matchConnection(c, where)),
|
|
237
|
-
)
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Builds filterable presentation for relation endpoint. Enriches model properties with deployment properties when needed.
|
|
242
|
-
* @param relationEndpoint Endpoint for which to build presentation
|
|
243
|
-
* @param connectionEndpoint Endpoint of connection which was build from the relation.
|
|
244
|
-
* @returns Presentation of the endpoint for usage in predicates
|
|
245
|
-
*/
|
|
246
|
-
function toFilterable<M extends AnyAux>(
|
|
247
|
-
relationEndpoint: ElementModel<M> | DeploymentRelationEndpoint<M>,
|
|
248
|
-
connectionEndpoint: DeploymentRelationEndpoint<M>,
|
|
249
|
-
): Filterable<M> {
|
|
250
|
-
if (isElementModel<M>(relationEndpoint)) { // Element itself. Extend with tags of the deployed instance (TODO)
|
|
251
|
-
const deployedInstance = isDeploymentElementModel<M>(connectionEndpoint) && isDeployedInstance(connectionEndpoint)
|
|
252
|
-
? connectionEndpoint
|
|
253
|
-
: null
|
|
254
|
-
return {
|
|
255
|
-
kind: relationEndpoint.kind,
|
|
256
|
-
tags: [...relationEndpoint.tags, ...(deployedInstance?.tags ?? [])],
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
if (isNestedElementOfDeployedInstanceModel(relationEndpoint)) { // Nested element. Has no own instance. No need to extend
|
|
260
|
-
return pick(relationEndpoint.element, ['tags', 'kind'])
|
|
261
|
-
}
|
|
262
|
-
if (isDeployedInstance(relationEndpoint)) { // Deployed instance. Extend with tags of the model element
|
|
263
|
-
return {
|
|
264
|
-
kind: relationEndpoint.element.kind,
|
|
265
|
-
tags: [...relationEndpoint.tags, ...relationEndpoint.element.tags],
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
if (isDeploymentNode(relationEndpoint)) { // Deployment node. Has no representation in model. No need to extend
|
|
269
|
-
return pick(relationEndpoint, ['tags', 'kind'])
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
nonexhaustive(relationEndpoint)
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
function toFilterableRelation<M extends AnyAux>(c: DeploymentConnectionModel<M>) {
|
|
276
|
-
return (relation: RelationshipModel<M> | DeploymentRelationModel<M>) => ({
|
|
277
|
-
tags: relation.tags,
|
|
278
|
-
kind: relation.kind,
|
|
279
|
-
source: toFilterable(relation.source, c.source),
|
|
280
|
-
target: toFilterable(relation.target, c.target),
|
|
281
|
-
})
|
|
282
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { map, pipe } from 'remeda'
|
|
2
|
-
import type { FqnExpr } from '../../../types'
|
|
3
|
-
import { type Elem, type PredicateExecutor } from '../_types'
|
|
4
|
-
import { findConnectionsWithin } from '../utils'
|
|
5
|
-
import { applyElementPredicate } from './utils'
|
|
6
|
-
|
|
7
|
-
export const WildcardPredicate: PredicateExecutor<FqnExpr.Wildcard> = {
|
|
8
|
-
include: ({ model, stage, where }) => {
|
|
9
|
-
const children = [] as Elem[]
|
|
10
|
-
|
|
11
|
-
const rootElements = pipe(
|
|
12
|
-
[...model.roots()],
|
|
13
|
-
applyElementPredicate(where),
|
|
14
|
-
map(root => {
|
|
15
|
-
if (!root.onlyOneInstance()) {
|
|
16
|
-
children.push(...root.children())
|
|
17
|
-
}
|
|
18
|
-
return root
|
|
19
|
-
}),
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
stage.addExplicit(rootElements)
|
|
23
|
-
if (children.length > 1) {
|
|
24
|
-
stage.addConnections(findConnectionsWithin([
|
|
25
|
-
...rootElements,
|
|
26
|
-
...children,
|
|
27
|
-
]))
|
|
28
|
-
}
|
|
29
|
-
return stage
|
|
30
|
-
},
|
|
31
|
-
exclude: ({ stage, memory, where }) => {
|
|
32
|
-
const elementsToExclude = pipe(
|
|
33
|
-
[...memory.elements],
|
|
34
|
-
applyElementPredicate(where),
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
stage.exclude(elementsToExclude)
|
|
38
|
-
|
|
39
|
-
return stage
|
|
40
|
-
},
|
|
41
|
-
}
|