@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,312 +0,0 @@
|
|
|
1
|
-
import { filter, findLast, flatMap, hasAtLeast, isTruthy, map, only, pipe, reduce, unique } from 'remeda'
|
|
2
|
-
import type { ElementModel, LikeC4Model } from '../../model'
|
|
3
|
-
import { modelConnection } from '../../model'
|
|
4
|
-
import type { AnyAux, aux, scalar } from '../../types'
|
|
5
|
-
import {
|
|
6
|
-
type Color,
|
|
7
|
-
type ComputedDynamicView,
|
|
8
|
-
type ComputedEdge,
|
|
9
|
-
type DynamicViewStep,
|
|
10
|
-
type NonEmptyArray,
|
|
11
|
-
type ParsedDynamicView as DynamicView,
|
|
12
|
-
type RelationshipArrowType,
|
|
13
|
-
type RelationshipLineType,
|
|
14
|
-
type StepEdgeId,
|
|
15
|
-
_stage,
|
|
16
|
-
_type,
|
|
17
|
-
DefaultArrowType,
|
|
18
|
-
DefaultLineStyle,
|
|
19
|
-
DefaultRelationshipColor,
|
|
20
|
-
isDynamicViewParallelSteps,
|
|
21
|
-
isViewRuleAutoLayout,
|
|
22
|
-
isViewRulePredicate,
|
|
23
|
-
stepEdgeId,
|
|
24
|
-
} from '../../types'
|
|
25
|
-
import { nonNullable } from '../../utils'
|
|
26
|
-
import { ancestorsFqn, commonAncestor, parentFqn } from '../../utils/fqn'
|
|
27
|
-
import { applyCustomElementProperties } from '../utils/applyCustomElementProperties'
|
|
28
|
-
import { applyViewRuleStyles } from '../utils/applyViewRuleStyles'
|
|
29
|
-
import { buildComputedNodes, elementModelToNodeSource } from '../utils/buildComputedNodes'
|
|
30
|
-
import { buildElementNotations } from '../utils/buildElementNotations'
|
|
31
|
-
import { elementExprToPredicate } from '../utils/elementExpressionToPredicate'
|
|
32
|
-
import { resolveGlobalRulesInDynamicView } from '../utils/resolve-global-rules'
|
|
33
|
-
import { calcViewLayoutHash } from '../utils/view-hash'
|
|
34
|
-
|
|
35
|
-
const { findConnection } = modelConnection
|
|
36
|
-
|
|
37
|
-
type Element<A extends AnyAux> = ElementModel<A>
|
|
38
|
-
|
|
39
|
-
namespace DynamicViewCompute {
|
|
40
|
-
export interface Step<A extends AnyAux> {
|
|
41
|
-
id: StepEdgeId
|
|
42
|
-
source: Element<A>
|
|
43
|
-
target: Element<A>
|
|
44
|
-
title: string | null
|
|
45
|
-
description?: string
|
|
46
|
-
technology?: string
|
|
47
|
-
// Notes for walkthrough
|
|
48
|
-
notes?: scalar.MarkdownOrString
|
|
49
|
-
color?: Color
|
|
50
|
-
line?: RelationshipLineType
|
|
51
|
-
head?: RelationshipArrowType
|
|
52
|
-
tail?: RelationshipArrowType
|
|
53
|
-
relations: scalar.RelationId[]
|
|
54
|
-
isBackward: boolean
|
|
55
|
-
navigateTo?: aux.StrictViewId<A>
|
|
56
|
-
tags?: aux.Tags<A>
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
class DynamicViewCompute<A extends AnyAux> {
|
|
61
|
-
// Intermediate state
|
|
62
|
-
private explicits = new Set<Element<A>>()
|
|
63
|
-
private steps = [] as DynamicViewCompute.Step<A>[]
|
|
64
|
-
|
|
65
|
-
constructor(
|
|
66
|
-
protected model: LikeC4Model<A>,
|
|
67
|
-
protected view: DynamicView<A>,
|
|
68
|
-
) {}
|
|
69
|
-
|
|
70
|
-
private addStep(
|
|
71
|
-
{
|
|
72
|
-
source: stepSource,
|
|
73
|
-
target: stepTarget,
|
|
74
|
-
title: stepTitle,
|
|
75
|
-
isBackward,
|
|
76
|
-
navigateTo: stepNavigateTo,
|
|
77
|
-
...step
|
|
78
|
-
}: DynamicViewStep<A>,
|
|
79
|
-
index: number,
|
|
80
|
-
parent?: number,
|
|
81
|
-
) {
|
|
82
|
-
const id = parent ? stepEdgeId(parent, index) : stepEdgeId(index)
|
|
83
|
-
const source = this.model.element(stepSource)
|
|
84
|
-
const target = this.model.element(stepTarget)
|
|
85
|
-
|
|
86
|
-
this.explicits.add(source)
|
|
87
|
-
this.explicits.add(target)
|
|
88
|
-
|
|
89
|
-
const {
|
|
90
|
-
title,
|
|
91
|
-
relations,
|
|
92
|
-
tags,
|
|
93
|
-
navigateTo: derivedNavigateTo,
|
|
94
|
-
color,
|
|
95
|
-
line,
|
|
96
|
-
} = this.findRelations(source, target)
|
|
97
|
-
|
|
98
|
-
const navigateTo = isTruthy(stepNavigateTo) && stepNavigateTo !== this.view.id ? stepNavigateTo : derivedNavigateTo
|
|
99
|
-
|
|
100
|
-
this.steps.push({
|
|
101
|
-
id,
|
|
102
|
-
...step,
|
|
103
|
-
source,
|
|
104
|
-
target,
|
|
105
|
-
title: stepTitle ?? title,
|
|
106
|
-
relations: relations ?? [],
|
|
107
|
-
isBackward: isBackward ?? false,
|
|
108
|
-
...(navigateTo ? { navigateTo } : {}),
|
|
109
|
-
...(tags ? { tags } : {}),
|
|
110
|
-
...(color ? { color } : {}),
|
|
111
|
-
...(line ? { line } : {}),
|
|
112
|
-
})
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
compute(): ComputedDynamicView<A> {
|
|
116
|
-
const {
|
|
117
|
-
docUri: _docUri, // exclude docUri
|
|
118
|
-
rules: _rules, // exclude rules
|
|
119
|
-
steps: viewSteps,
|
|
120
|
-
...view
|
|
121
|
-
} = this.view
|
|
122
|
-
|
|
123
|
-
let stepNum = 1
|
|
124
|
-
for (const step of viewSteps) {
|
|
125
|
-
if (isDynamicViewParallelSteps(step)) {
|
|
126
|
-
if (step.__parallel.length === 0) {
|
|
127
|
-
continue
|
|
128
|
-
}
|
|
129
|
-
if (step.__parallel.length === 1) {
|
|
130
|
-
this.addStep(step.__parallel[0]!, stepNum)
|
|
131
|
-
} else {
|
|
132
|
-
step.__parallel.forEach((s, i) => this.addStep(s, i + 1, stepNum))
|
|
133
|
-
}
|
|
134
|
-
} else {
|
|
135
|
-
this.addStep(step, stepNum)
|
|
136
|
-
}
|
|
137
|
-
stepNum++
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const rules = resolveGlobalRulesInDynamicView(_rules, this.model.globals)
|
|
141
|
-
|
|
142
|
-
for (const rule of rules) {
|
|
143
|
-
if (isViewRulePredicate(rule)) {
|
|
144
|
-
for (const expr of rule.include) {
|
|
145
|
-
const satisfies = elementExprToPredicate(expr)
|
|
146
|
-
for (const e of this.model.elements()) {
|
|
147
|
-
if (satisfies(e)) {
|
|
148
|
-
this.explicits.add(e)
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const nodesMap = buildComputedNodes(
|
|
156
|
-
[...this.explicits].map(elementModelToNodeSource),
|
|
157
|
-
)
|
|
158
|
-
|
|
159
|
-
const edges = this.steps.map(({ id, source, target, relations, title, description, isBackward, tags, ...step }) => {
|
|
160
|
-
const sourceNode = nonNullable(nodesMap.get(source.id as scalar.NodeId), `Source node ${source.id} not found`)
|
|
161
|
-
const targetNode = nonNullable(nodesMap.get(target.id as scalar.NodeId), `Target node ${target.id} not found`)
|
|
162
|
-
const edge: ComputedEdge<A> = {
|
|
163
|
-
id: id as unknown as aux.EdgeId,
|
|
164
|
-
parent: commonAncestor(source.id, target.id) as scalar.NodeId | null,
|
|
165
|
-
source: sourceNode.id,
|
|
166
|
-
target: targetNode.id,
|
|
167
|
-
label: title,
|
|
168
|
-
relations,
|
|
169
|
-
description: description ? { txt: description } : null,
|
|
170
|
-
color: DefaultRelationshipColor,
|
|
171
|
-
line: DefaultLineStyle,
|
|
172
|
-
head: DefaultArrowType,
|
|
173
|
-
tags: tags ?? [],
|
|
174
|
-
...step,
|
|
175
|
-
}
|
|
176
|
-
if (isBackward) {
|
|
177
|
-
edge.dir = 'back'
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
while (edge.parent && !nodesMap.has(edge.parent)) {
|
|
181
|
-
edge.parent = parentFqn(edge.parent)
|
|
182
|
-
}
|
|
183
|
-
sourceNode.outEdges.push(edge.id)
|
|
184
|
-
targetNode.inEdges.push(edge.id)
|
|
185
|
-
// Process edge source ancestors
|
|
186
|
-
for (const sourceAncestor of ancestorsFqn(edge.source)) {
|
|
187
|
-
if (sourceAncestor === edge.parent) {
|
|
188
|
-
break
|
|
189
|
-
}
|
|
190
|
-
nodesMap.get(sourceAncestor)?.outEdges.push(edge.id)
|
|
191
|
-
}
|
|
192
|
-
// Process target hierarchy
|
|
193
|
-
for (const targetAncestor of ancestorsFqn(edge.target)) {
|
|
194
|
-
if (targetAncestor === edge.parent) {
|
|
195
|
-
break
|
|
196
|
-
}
|
|
197
|
-
nodesMap.get(targetAncestor)?.inEdges.push(edge.id)
|
|
198
|
-
}
|
|
199
|
-
return edge
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
const nodes = applyCustomElementProperties(
|
|
203
|
-
rules,
|
|
204
|
-
applyViewRuleStyles(
|
|
205
|
-
rules,
|
|
206
|
-
// Keep order of elements
|
|
207
|
-
[...this.explicits].map(e => nonNullable(nodesMap.get(e.id as scalar.NodeId))),
|
|
208
|
-
),
|
|
209
|
-
)
|
|
210
|
-
|
|
211
|
-
const autoLayoutRule = findLast(rules, isViewRuleAutoLayout)
|
|
212
|
-
|
|
213
|
-
const nodeNotations = buildElementNotations(nodes)
|
|
214
|
-
|
|
215
|
-
return calcViewLayoutHash({
|
|
216
|
-
...view,
|
|
217
|
-
[_type]: 'dynamic',
|
|
218
|
-
[_stage]: 'computed',
|
|
219
|
-
variant: view.variant ?? 'diagram',
|
|
220
|
-
autoLayout: {
|
|
221
|
-
direction: autoLayoutRule?.direction ?? 'LR',
|
|
222
|
-
...(autoLayoutRule?.nodeSep && { nodeSep: autoLayoutRule.nodeSep }),
|
|
223
|
-
...(autoLayoutRule?.rankSep && { rankSep: autoLayoutRule.rankSep }),
|
|
224
|
-
},
|
|
225
|
-
nodes: map(nodes, n => {
|
|
226
|
-
if (n.icon === 'none') {
|
|
227
|
-
delete n.icon
|
|
228
|
-
}
|
|
229
|
-
return n
|
|
230
|
-
}),
|
|
231
|
-
edges,
|
|
232
|
-
...(nodeNotations.length > 0 && {
|
|
233
|
-
notation: {
|
|
234
|
-
nodes: nodeNotations,
|
|
235
|
-
},
|
|
236
|
-
}),
|
|
237
|
-
})
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
private findRelations(source: Element<A>, target: Element<A>): {
|
|
241
|
-
title: string | null
|
|
242
|
-
tags: aux.Tags<A> | null
|
|
243
|
-
relations: NonEmptyArray<aux.RelationId> | null
|
|
244
|
-
navigateTo: aux.StrictViewId<A> | null
|
|
245
|
-
color: Color | null
|
|
246
|
-
line: RelationshipLineType | null
|
|
247
|
-
} {
|
|
248
|
-
const relationships = findConnection(source, target, 'directed').flatMap(r => [...r.relations])
|
|
249
|
-
if (relationships.length === 0) {
|
|
250
|
-
return {
|
|
251
|
-
title: null,
|
|
252
|
-
tags: null,
|
|
253
|
-
relations: null,
|
|
254
|
-
navigateTo: null,
|
|
255
|
-
color: null,
|
|
256
|
-
line: null,
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
const alltags = pipe(
|
|
260
|
-
relationships,
|
|
261
|
-
flatMap(r => r.tags),
|
|
262
|
-
filter(isTruthy),
|
|
263
|
-
unique(),
|
|
264
|
-
) as aux.Tags<A>
|
|
265
|
-
const tags = hasAtLeast(alltags, 1) ? alltags : null
|
|
266
|
-
const relations = hasAtLeast(relationships, 1) ? map(relationships, r => r.id) : null
|
|
267
|
-
|
|
268
|
-
// Most closest relation
|
|
269
|
-
const relation = only(relationships) || relationships.find(r => r.source === source && r.target === target)
|
|
270
|
-
const relationNavigateTo = relation?.$relationship.navigateTo ?? null
|
|
271
|
-
|
|
272
|
-
const navigateTo = relationNavigateTo && relationNavigateTo !== this.view.id
|
|
273
|
-
? relationNavigateTo as aux.StrictViewId<A>
|
|
274
|
-
: pipe(
|
|
275
|
-
relationships,
|
|
276
|
-
map(r => r.$relationship.navigateTo as aux.StrictViewId<A>),
|
|
277
|
-
filter(isTruthy),
|
|
278
|
-
filter(v => v !== this.view.id),
|
|
279
|
-
unique(),
|
|
280
|
-
only(),
|
|
281
|
-
)
|
|
282
|
-
|
|
283
|
-
const commonProperties = pipe(
|
|
284
|
-
relationships,
|
|
285
|
-
reduce((acc, { title, $relationship: r }) => {
|
|
286
|
-
isTruthy(title) && acc.title.add(title)
|
|
287
|
-
isTruthy(r.color) && acc.color.add(r.color)
|
|
288
|
-
isTruthy(r.line) && acc.line.add(r.line)
|
|
289
|
-
return acc
|
|
290
|
-
}, {
|
|
291
|
-
color: new Set<Color>(),
|
|
292
|
-
line: new Set<RelationshipLineType>(),
|
|
293
|
-
title: new Set<string>(),
|
|
294
|
-
}),
|
|
295
|
-
)
|
|
296
|
-
|
|
297
|
-
return {
|
|
298
|
-
tags,
|
|
299
|
-
relations,
|
|
300
|
-
navigateTo: navigateTo ?? null,
|
|
301
|
-
title: only([...commonProperties.title]) ?? null,
|
|
302
|
-
color: only([...commonProperties.color]) ?? null,
|
|
303
|
-
line: only([...commonProperties.line]) ?? null,
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
export function computeDynamicView<M extends AnyAux>(
|
|
308
|
-
model: LikeC4Model<M>,
|
|
309
|
-
view: DynamicView<M>,
|
|
310
|
-
): ComputedDynamicView<M> {
|
|
311
|
-
return new DynamicViewCompute(model, view).compute()
|
|
312
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { type LikeC4Model } from '../../model'
|
|
2
|
-
import type { ConnectionModel } from '../../model'
|
|
3
|
-
import type { RelationshipModel } from '../../model'
|
|
4
|
-
import type { ModelExpression, ModelFqnExpr, ModelRelationExpr } from '../../types'
|
|
5
|
-
|
|
6
|
-
import type { Ctx, Memory, Stage, StageExclude, StageInclude } 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 { Memory } from './memory'
|
|
20
|
-
|
|
21
|
-
export type Connections = ReadonlyArray<ConnectionModel<any>>
|
|
22
|
-
|
|
23
|
-
export interface PredicateCtx<Expr = ModelExpression<any>> {
|
|
24
|
-
expr: Expr
|
|
25
|
-
stage: Stage
|
|
26
|
-
// View scope
|
|
27
|
-
scope: Elem | null
|
|
28
|
-
model: LikeC4Model<any>
|
|
29
|
-
memory: Memory
|
|
30
|
-
where: Expr extends ModelRelationExpr<any> ? RelationshipWhere
|
|
31
|
-
: Expr extends ModelFqnExpr<any> ? ElementWhere
|
|
32
|
-
: never
|
|
33
|
-
filterWhere: Expr extends ModelRelationExpr<any> ? ConnectionWhereFilter
|
|
34
|
-
: Expr extends ModelFqnExpr<any> ? ElementWhereFilter
|
|
35
|
-
: never
|
|
36
|
-
}
|
|
37
|
-
export interface IncludePredicateCtx<Expr = ModelExpression<any>> extends PredicateCtx<Expr> {
|
|
38
|
-
stage: StageInclude
|
|
39
|
-
}
|
|
40
|
-
export interface ExcludePredicateCtx<Expr = ModelExpression<any>> extends PredicateCtx<Expr> {
|
|
41
|
-
stage: StageExclude
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface PredicateExecutor<Expr = ModelExpression<any>> {
|
|
45
|
-
include(ctx: IncludePredicateCtx<Expr>): StageInclude | undefined
|
|
46
|
-
exclude(ctx: ExcludePredicateCtx<Expr>): StageExclude | undefined
|
|
47
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { allPass, anyPass, pipe, prop, reduce } from 'remeda'
|
|
2
|
-
import type { RelationshipModel } from '../../model'
|
|
3
|
-
import {
|
|
4
|
-
Connection,
|
|
5
|
-
ConnectionModel,
|
|
6
|
-
differenceConnections,
|
|
7
|
-
findDeepestNestedConnection,
|
|
8
|
-
findDescendantConnections,
|
|
9
|
-
isAnyInOut,
|
|
10
|
-
isIncoming,
|
|
11
|
-
isOutgoing,
|
|
12
|
-
mergeConnections,
|
|
13
|
-
} from '../../model'
|
|
14
|
-
import type { AnyAux } from '../../types'
|
|
15
|
-
import { intersection, union } from '../../utils'
|
|
16
|
-
import { ifilter, toSet } from '../../utils/iterable'
|
|
17
|
-
|
|
18
|
-
export function allRelationshipsFrom(connections: Iterable<ConnectionModel>): Set<RelationshipModel> {
|
|
19
|
-
const relations = new Set<RelationshipModel>()
|
|
20
|
-
for (const c of connections) {
|
|
21
|
-
for (const rel of c.relations) {
|
|
22
|
-
relations.add(rel)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return relations
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function isInOutToDescendant(id: string): (c: ConnectionModel) => boolean {
|
|
29
|
-
return anyPass([
|
|
30
|
-
allPass([
|
|
31
|
-
Connection.isOutgoing(id),
|
|
32
|
-
c => c.source.id !== id,
|
|
33
|
-
]),
|
|
34
|
-
allPass([
|
|
35
|
-
Connection.isIncoming(id),
|
|
36
|
-
c => c.target.id !== id,
|
|
37
|
-
]),
|
|
38
|
-
])
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function findRedundantConnections<A extends AnyAux>(
|
|
42
|
-
connections: Iterable<ConnectionModel<A>>,
|
|
43
|
-
): Array<ConnectionModel<A>> {
|
|
44
|
-
return pipe(
|
|
45
|
-
[...connections],
|
|
46
|
-
mergeConnections,
|
|
47
|
-
reduce((reducedConnections, connection, _, all) => {
|
|
48
|
-
const descendants = findDescendantConnections(all, connection)
|
|
49
|
-
const nestedRelations = union(
|
|
50
|
-
...descendants.map(prop('relations')),
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
let accum = intersection(connection.relations, nestedRelations)
|
|
54
|
-
|
|
55
|
-
if (descendants.length > 0) {
|
|
56
|
-
accum = union(accum, connection.directRelations)
|
|
57
|
-
}
|
|
58
|
-
// Check if there is any reversed connection to descendant
|
|
59
|
-
if (findDeepestNestedConnection(all, connection.reversed(false))) {
|
|
60
|
-
accum = union(accum, connection.directRelations)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (accum.size < connection.relations.size) {
|
|
64
|
-
const isSourceExpanded = all.some(isAnyInOut(connection.source))
|
|
65
|
-
const isTargetExpanded = all.some(isAnyInOut(connection.target))
|
|
66
|
-
|
|
67
|
-
// Check if source expandaded
|
|
68
|
-
if (isSourceExpanded) {
|
|
69
|
-
accum = union(
|
|
70
|
-
accum,
|
|
71
|
-
toSet(
|
|
72
|
-
ifilter(
|
|
73
|
-
connection.relations,
|
|
74
|
-
isOutgoing(connection.source),
|
|
75
|
-
),
|
|
76
|
-
),
|
|
77
|
-
)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Check if target expandaded
|
|
81
|
-
if (isTargetExpanded) {
|
|
82
|
-
accum = union(
|
|
83
|
-
accum,
|
|
84
|
-
toSet(
|
|
85
|
-
ifilter(
|
|
86
|
-
connection.relations,
|
|
87
|
-
isIncoming(connection.target),
|
|
88
|
-
),
|
|
89
|
-
),
|
|
90
|
-
)
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (accum.size > 0) {
|
|
95
|
-
reducedConnections.push(connection.update(accum))
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return reducedConnections
|
|
99
|
-
}, [] as ConnectionModel<A>[]),
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Remove relationships from connection model, that are already included in the connections between descendants.
|
|
105
|
-
* In other words - if there is same connection down the hierarchy.
|
|
106
|
-
*
|
|
107
|
-
* @returns New connection without redundant relationships
|
|
108
|
-
* Connection may be empty if all relationships are redundant, in this case it should be removed
|
|
109
|
-
*/
|
|
110
|
-
export function cleanRedundantRelationships<A extends AnyAux>(
|
|
111
|
-
connections: Iterable<ConnectionModel<A>>,
|
|
112
|
-
): Array<ConnectionModel<A>> {
|
|
113
|
-
return differenceConnections(
|
|
114
|
-
connections,
|
|
115
|
-
findRedundantConnections(connections),
|
|
116
|
-
)
|
|
117
|
-
}
|