@likec4/core 1.19.2 → 1.20.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/dist/builder/index.cjs +881 -0
- package/dist/builder/index.d.cts +503 -0
- package/dist/builder/index.d.mts +4 -3
- package/dist/builder/index.d.ts +4 -3
- package/dist/builder/{index.js → index.mjs} +14 -4
- package/dist/compute-view/index.cjs +86 -0
- package/dist/compute-view/index.d.cts +23 -0
- package/dist/compute-view/index.d.mts +3 -2
- package/dist/compute-view/index.d.ts +3 -2
- package/dist/compute-view/{index.js → index.mjs} +6 -5
- package/dist/index.cjs +4320 -0
- package/dist/index.d.cts +270 -0
- package/dist/index.d.mts +130 -4
- package/dist/index.d.ts +130 -4
- package/dist/{index.js → index.mjs} +512 -7
- package/dist/model/index.cjs +40 -0
- package/dist/model/index.d.cts +259 -0
- package/dist/model/index.d.mts +3 -3
- package/dist/model/index.d.ts +3 -3
- package/dist/model/index.mjs +1 -0
- package/dist/shared/core.B2QYWlYe.cjs +435 -0
- package/dist/shared/core.B72vUaNB.d.cts +850 -0
- package/dist/shared/core.BGus30EM.cjs +8027 -0
- package/dist/shared/core.BRuJ3Wzf.d.mts +12 -0
- package/dist/shared/{core.CqXs9Frh.d.ts → core.BdbFkE_p.d.cts} +10 -4
- package/dist/shared/core.BvdNMbcA.d.cts +12 -0
- package/dist/shared/{object_hash.CE_oF3I3.js → core.BxvDITEI.mjs} +26 -389
- package/dist/shared/core.ByNgh-mC.d.cts +127 -0
- package/dist/shared/core.C9DCnJh8.cjs +908 -0
- package/dist/shared/{index.KOeaSlL8.js → core.CqCTxzMY.mjs} +787 -372
- package/dist/shared/core.D74xkKkG.d.cts +148 -0
- package/dist/shared/{core.DyJ41fBO.d.ts → core.D_Gc58Gt.d.ts} +12 -4
- package/dist/shared/core.Damrzla-.d.ts +12 -0
- package/dist/shared/{core.BL1oTk7-.d.mts → core.Dfzrh1VA.d.mts} +12 -4
- package/dist/shared/core.DsoCu540.cjs +26 -0
- package/dist/shared/{view.DrmaOfjr.js → core.DunIMHRf.mjs} +24 -1
- package/dist/shared/{core.2I-l5UtM.d.mts → core.ZWiGANIJ.d.ts} +10 -4
- package/dist/shared/core.gv1bMwCC.cjs +39 -0
- package/dist/shared/core.jy6z2iRn.d.mts +729 -0
- package/dist/shared/core.m3rCQAv6.mjs +37 -0
- package/dist/types/index.cjs +107 -0
- package/dist/types/index.d.cts +72 -0
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/{index.js → index.mjs} +1 -1
- package/dist/utils/index.cjs +95 -0
- package/dist/utils/index.d.cts +356 -0
- package/dist/utils/index.d.mts +1 -64
- package/dist/utils/index.d.ts +1 -64
- package/dist/utils/index.mjs +56 -0
- package/package.json +51 -25
- package/src/builder/Builder.view-common.ts +20 -1
- package/src/compute-view/deployment-view/predicates/relation-direct.ts +26 -29
- package/src/compute-view/deployment-view/predicates/relation-incoming.ts +1 -1
- package/src/compute-view/deployment-view/predicates/utils.ts +47 -16
- package/src/compute-view/element-view/__test__/fixture.ts +17 -4
- package/src/compute-view/element-view/compute.ts +3 -2
- package/src/compute-view/element-view/predicates.ts +520 -0
- package/src/compute-view/element-view/utils.ts +11 -7
- package/src/compute-view/index.ts +1 -0
- package/src/compute-view/relationships-view/_types.ts +16 -0
- package/src/compute-view/relationships-view/compute.ts +74 -0
- package/src/compute-view/relationships-view/layout.ts +357 -0
- package/src/compute-view/relationships-view/utils.ts +40 -0
- package/src/compute-view/utils/relationExpressionToPredicates.ts +11 -4
- package/src/index.ts +16 -0
- package/src/model/DeploymentElementModel.ts +4 -0
- package/src/model/ElementModel.ts +13 -0
- package/src/model/LikeC4Model.ts +2 -2
- package/src/model/RelationModel.ts +5 -0
- package/src/model/guards.ts +17 -1
- package/src/model/view/LikeC4ViewModel.ts +7 -1
- package/src/model/view/NodeModel.ts +5 -0
- package/src/types/operators.ts +42 -2
- package/src/types/view.ts +2 -2
- package/src/utils/index.ts +0 -5
- package/src/utils/iterable/unique.ts +1 -7
- package/dist/model/index.js +0 -1
- package/dist/utils/index.js +0 -347
- /package/dist/shared/{chunk-RAAYCPUM.M-JWF7SS.js → core.M-JWF7SS.mjs} +0 -0
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://likec4.dev",
|
|
6
6
|
"author": "Denis Davydkov <denis@davydkov.com>",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/likec4/likec4.git",
|
|
9
|
+
"url": "git+https://github.com/likec4/likec4.git",
|
|
10
10
|
"directory": "packages/core"
|
|
11
11
|
},
|
|
12
12
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"lint": "run -T eslint src/ --fix",
|
|
17
17
|
"test": "vitest run --no-isolate",
|
|
18
18
|
"test:watch": "vitest",
|
|
19
|
-
"clean": "rm -r -f dist"
|
|
19
|
+
"clean": "rm -r -f dist",
|
|
20
|
+
"package": "yarn pack"
|
|
20
21
|
},
|
|
21
22
|
"files": [
|
|
22
23
|
"dist",
|
|
@@ -30,50 +31,74 @@
|
|
|
30
31
|
"exports": {
|
|
31
32
|
".": {
|
|
32
33
|
"sources": "./src/index.ts",
|
|
34
|
+
"require": {
|
|
35
|
+
"types": "./dist/index.d.cts",
|
|
36
|
+
"default": "./dist/index.cjs"
|
|
37
|
+
},
|
|
33
38
|
"default": {
|
|
34
|
-
"types": "./dist/index.d.
|
|
35
|
-
"import": "./dist/index.
|
|
36
|
-
"default": "./dist/index.
|
|
39
|
+
"types": "./dist/index.d.mts",
|
|
40
|
+
"import": "./dist/index.mjs",
|
|
41
|
+
"default": "./dist/index.mjs"
|
|
37
42
|
}
|
|
38
43
|
},
|
|
39
44
|
"./builder": {
|
|
40
45
|
"sources": "./src/builder/index.ts",
|
|
46
|
+
"require": {
|
|
47
|
+
"types": "./dist/builder/index.d.cts",
|
|
48
|
+
"default": "./dist/builder/index.cjs"
|
|
49
|
+
},
|
|
41
50
|
"default": {
|
|
42
|
-
"types": "./dist/builder/index.d.
|
|
43
|
-
"import": "./dist/builder/index.
|
|
44
|
-
"default": "./dist/builder/index.
|
|
51
|
+
"types": "./dist/builder/index.d.mts",
|
|
52
|
+
"import": "./dist/builder/index.mjs",
|
|
53
|
+
"default": "./dist/builder/index.mjs"
|
|
45
54
|
}
|
|
46
55
|
},
|
|
47
56
|
"./compute-view": {
|
|
48
57
|
"sources": "./src/compute-view/index.ts",
|
|
58
|
+
"require": {
|
|
59
|
+
"types": "./dist/compute-view/index.d.cts",
|
|
60
|
+
"default": "./dist/compute-view/index.cjs"
|
|
61
|
+
},
|
|
49
62
|
"default": {
|
|
50
|
-
"types": "./dist/compute-view/index.d.
|
|
51
|
-
"import": "./dist/compute-view/index.
|
|
52
|
-
"default": "./dist/compute-view/index.
|
|
63
|
+
"types": "./dist/compute-view/index.d.mts",
|
|
64
|
+
"import": "./dist/compute-view/index.mjs",
|
|
65
|
+
"default": "./dist/compute-view/index.mjs"
|
|
53
66
|
}
|
|
54
67
|
},
|
|
55
68
|
"./model": {
|
|
56
69
|
"sources": "./src/model/index.ts",
|
|
70
|
+
"require": {
|
|
71
|
+
"types": "./dist/model/index.d.cts",
|
|
72
|
+
"default": "./dist/model/index.cjs"
|
|
73
|
+
},
|
|
57
74
|
"default": {
|
|
58
|
-
"types": "./dist/model/index.d.
|
|
59
|
-
"import": "./dist/model/index.
|
|
60
|
-
"default": "./dist/model/index.
|
|
75
|
+
"types": "./dist/model/index.d.mts",
|
|
76
|
+
"import": "./dist/model/index.mjs",
|
|
77
|
+
"default": "./dist/model/index.mjs"
|
|
61
78
|
}
|
|
62
79
|
},
|
|
63
80
|
"./utils": {
|
|
64
81
|
"sources": "./src/utils/index.ts",
|
|
82
|
+
"require": {
|
|
83
|
+
"types": "./dist/utils/index.d.cts",
|
|
84
|
+
"default": "./dist/utils/index.cjs"
|
|
85
|
+
},
|
|
65
86
|
"default": {
|
|
66
|
-
"types": "./dist/utils/index.d.
|
|
67
|
-
"import": "./dist/utils/index.
|
|
68
|
-
"default": "./dist/utils/index.
|
|
87
|
+
"types": "./dist/utils/index.d.mts",
|
|
88
|
+
"import": "./dist/utils/index.mjs",
|
|
89
|
+
"default": "./dist/utils/index.mjs"
|
|
69
90
|
}
|
|
70
91
|
},
|
|
71
92
|
"./types": {
|
|
72
93
|
"sources": "./src/types/index.ts",
|
|
94
|
+
"require": {
|
|
95
|
+
"types": "./dist/types/index.d.cts",
|
|
96
|
+
"default": "./dist/types/index.cjs"
|
|
97
|
+
},
|
|
73
98
|
"default": {
|
|
74
|
-
"types": "./dist/types/index.d.
|
|
75
|
-
"import": "./dist/types/index.
|
|
76
|
-
"default": "./dist/types/index.
|
|
99
|
+
"types": "./dist/types/index.d.mts",
|
|
100
|
+
"import": "./dist/types/index.mjs",
|
|
101
|
+
"default": "./dist/types/index.mjs"
|
|
77
102
|
}
|
|
78
103
|
}
|
|
79
104
|
},
|
|
@@ -85,7 +110,8 @@
|
|
|
85
110
|
"type-fest": "4.28.1"
|
|
86
111
|
},
|
|
87
112
|
"devDependencies": {
|
|
88
|
-
"@
|
|
113
|
+
"@dagrejs/dagre": "1.1.4",
|
|
114
|
+
"@likec4/tsconfig": "1.20.0",
|
|
89
115
|
"@mantine/colors-generator": "7.15.2",
|
|
90
116
|
"@types/natural-compare-lite": "^1.4.2",
|
|
91
117
|
"@types/object-hash": "^3.0.6",
|
|
@@ -98,10 +124,10 @@
|
|
|
98
124
|
"natural-compare-lite": "^1.4.0",
|
|
99
125
|
"object-hash": "^3.0.0",
|
|
100
126
|
"obliterator": "^2.0.4",
|
|
101
|
-
"remeda": "^2.
|
|
127
|
+
"remeda": "^2.19.0",
|
|
102
128
|
"turbo": "^2.3.3",
|
|
103
|
-
"typescript": "^5.7.
|
|
104
|
-
"unbuild": "^3.
|
|
129
|
+
"typescript": "^5.7.3",
|
|
130
|
+
"unbuild": "^3.2.0",
|
|
105
131
|
"vitest": "^2.1.8"
|
|
106
132
|
},
|
|
107
133
|
"packageManager": "yarn@4.6.0"
|
|
@@ -6,11 +6,12 @@ import {
|
|
|
6
6
|
type CustomRelationExpr,
|
|
7
7
|
type ElementExpression as C4ElementExpression,
|
|
8
8
|
type Expression as C4Expression,
|
|
9
|
-
isElementPredicateExpr,
|
|
10
9
|
type NonEmptyArray,
|
|
11
10
|
type ViewRuleStyle,
|
|
12
11
|
type WhereOperator,
|
|
12
|
+
isElementPredicateExpr,
|
|
13
13
|
} from '../types'
|
|
14
|
+
import type { KindEqual, Participant, TagEqual } from '../types/operators'
|
|
14
15
|
import type { AnyTypes, Types } from './_types'
|
|
15
16
|
|
|
16
17
|
export interface LikeC4ViewBuilder<
|
|
@@ -59,10 +60,14 @@ export namespace ViewPredicate {
|
|
|
59
60
|
|
|
60
61
|
export type WhereTag<Tag extends string> = `tag ${'is' | 'is not'} #${Tag}`
|
|
61
62
|
export type WhereKind<Kind extends string> = `kind ${'is' | 'is not'} ${Kind}`
|
|
63
|
+
export type WhereParticipant<Types extends AnyTypes> = `${Participant}.${
|
|
64
|
+
| WhereTag<Types['Tag']>
|
|
65
|
+
| WhereKind<Types['ElementKind']>}`
|
|
62
66
|
|
|
63
67
|
export type WhereEq<Types extends AnyTypes> =
|
|
64
68
|
| ViewPredicate.WhereTag<Types['Tag']>
|
|
65
69
|
| ViewPredicate.WhereKind<Types['ElementKind']>
|
|
70
|
+
| ViewPredicate.WhereParticipant<Types>
|
|
66
71
|
|
|
67
72
|
export type WhereOperator<Types extends AnyTypes> = ViewPredicate.WhereEq<Types> | {
|
|
68
73
|
and: NonEmptyArray<ViewPredicate.WhereOperator<Types>>
|
|
@@ -116,6 +121,20 @@ function parseWhere(where: ViewPredicate.WhereOperator<AnyTypes>): WhereOperator
|
|
|
116
121
|
eq: op.replace('kind is ', ''),
|
|
117
122
|
},
|
|
118
123
|
}
|
|
124
|
+
case op.startsWith('source.'):
|
|
125
|
+
return {
|
|
126
|
+
operator: parseWhere(op.replace('source.', '') as ViewPredicate.WhereOperator<AnyTypes>) as
|
|
127
|
+
| KindEqual<string>
|
|
128
|
+
| TagEqual<string>,
|
|
129
|
+
participant: 'source',
|
|
130
|
+
}
|
|
131
|
+
case op.startsWith('target.'):
|
|
132
|
+
return {
|
|
133
|
+
operator: parseWhere(op.replace('target.', '') as ViewPredicate.WhereOperator<AnyTypes>) as
|
|
134
|
+
| KindEqual<string>
|
|
135
|
+
| TagEqual<string>,
|
|
136
|
+
participant: 'target',
|
|
137
|
+
}
|
|
119
138
|
default:
|
|
120
139
|
throw new Error(`Unknown where operator: ${where}`)
|
|
121
140
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { filter, flatMap, isNonNullish, pick, pipe } from 'remeda'
|
|
1
|
+
import { filter, flatMap, isNonNullish, map, pick, pipe } from 'remeda'
|
|
2
2
|
import { invariant } from '../../../errors'
|
|
3
3
|
import type {
|
|
4
4
|
ConnectionModel,
|
|
@@ -53,10 +53,14 @@ export const DirectRelationPredicate: PredicateExecutor<RelationExpr.Direct> = {
|
|
|
53
53
|
switch (true) {
|
|
54
54
|
// * -> *
|
|
55
55
|
case sourceIsWildcard && targetIsWildcard: {
|
|
56
|
-
connections =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
connections = pipe(
|
|
57
|
+
findConnectionsWithin(model.instances()),
|
|
58
|
+
applyPredicate(where),
|
|
59
|
+
map(c => {
|
|
60
|
+
stage.addImplicit(c.boundary)
|
|
61
|
+
return c
|
|
62
|
+
}),
|
|
63
|
+
)
|
|
60
64
|
break
|
|
61
65
|
}
|
|
62
66
|
|
|
@@ -71,12 +75,15 @@ export const DirectRelationPredicate: PredicateExecutor<RelationExpr.Direct> = {
|
|
|
71
75
|
postFilter = c => isSource(c) !== isTarget(c)
|
|
72
76
|
}
|
|
73
77
|
|
|
74
|
-
connections =
|
|
75
|
-
|
|
78
|
+
connections = pipe(
|
|
79
|
+
sources,
|
|
80
|
+
flatMap(source => {
|
|
76
81
|
const targets = resolveAscendingSiblings(source)
|
|
77
82
|
return findConnectionsBetween(source, targets, dir)
|
|
78
|
-
})
|
|
79
|
-
|
|
83
|
+
}),
|
|
84
|
+
filter(postFilter),
|
|
85
|
+
applyPredicate(where),
|
|
86
|
+
)
|
|
80
87
|
break
|
|
81
88
|
}
|
|
82
89
|
// * -> target; * <-> target
|
|
@@ -90,12 +97,15 @@ export const DirectRelationPredicate: PredicateExecutor<RelationExpr.Direct> = {
|
|
|
90
97
|
postFilter = c => isSource(c) !== isTarget(c)
|
|
91
98
|
}
|
|
92
99
|
|
|
93
|
-
connections =
|
|
94
|
-
|
|
100
|
+
connections = pipe(
|
|
101
|
+
targets,
|
|
102
|
+
flatMap(target => {
|
|
95
103
|
const sources = resolveAscendingSiblings(target)
|
|
96
104
|
return [...sources].flatMap(source => findConnection(source, target, dir))
|
|
97
|
-
})
|
|
98
|
-
|
|
105
|
+
}),
|
|
106
|
+
filter(postFilter),
|
|
107
|
+
applyPredicate(where),
|
|
108
|
+
)
|
|
99
109
|
break
|
|
100
110
|
}
|
|
101
111
|
default: {
|
|
@@ -109,8 +119,9 @@ export const DirectRelationPredicate: PredicateExecutor<RelationExpr.Direct> = {
|
|
|
109
119
|
|
|
110
120
|
connections = pipe(
|
|
111
121
|
sources,
|
|
112
|
-
flatMap(s =>
|
|
122
|
+
flatMap(s => findConnectionsBetween(s, targets, dir)),
|
|
113
123
|
filter(c => isSource(c) && isTarget(c)),
|
|
124
|
+
applyPredicate(where),
|
|
114
125
|
)
|
|
115
126
|
}
|
|
116
127
|
}
|
|
@@ -134,7 +145,7 @@ export const DirectRelationPredicate: PredicateExecutor<RelationExpr.Direct> = {
|
|
|
134
145
|
switch (true) {
|
|
135
146
|
// * -> *
|
|
136
147
|
case FqnExpr.isWildcard(expr.source) && FqnExpr.isWildcard(expr.target):
|
|
137
|
-
stage.excludeConnections(
|
|
148
|
+
stage.excludeConnections(applyPredicate(memory.connections, where))
|
|
138
149
|
return stage
|
|
139
150
|
|
|
140
151
|
// model -> model
|
|
@@ -250,17 +261,3 @@ function matchConnection<M extends AnyAux>(
|
|
|
250
261
|
]
|
|
251
262
|
.filter(where).length > 0
|
|
252
263
|
}
|
|
253
|
-
|
|
254
|
-
function matchConnections<M extends AnyAux>(
|
|
255
|
-
connections: readonly DeploymentConnectionModel<M>[],
|
|
256
|
-
where: OperatorPredicate<Filterable> | null,
|
|
257
|
-
): readonly DeploymentConnectionModel[] {
|
|
258
|
-
if (!where) {
|
|
259
|
-
return connections
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
return pipe(
|
|
263
|
-
connections,
|
|
264
|
-
filter(c => matchConnection(c, where)),
|
|
265
|
-
)
|
|
266
|
-
}
|
|
@@ -8,7 +8,7 @@ import { isAncestor } from '../../../utils'
|
|
|
8
8
|
import type { Connection, Elem, PredicateExecutor } from '../_types'
|
|
9
9
|
import { resolveElements, resolveModelElements } from '../utils'
|
|
10
10
|
import { resolveAscendingSiblings } from './relation-direct'
|
|
11
|
-
import { applyPredicate, excludeModelRelations
|
|
11
|
+
import { applyPredicate, excludeModelRelations } from './utils'
|
|
12
12
|
|
|
13
13
|
// from visible element incoming to this
|
|
14
14
|
export const IncomingRelationPredicate: PredicateExecutor<RelationExpr.Incoming> = {
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { filter, isArray, map, pick, pipe } from 'remeda'
|
|
2
2
|
import { nonexhaustive } from '../../../errors'
|
|
3
|
-
import type
|
|
4
|
-
import type {
|
|
3
|
+
import { type DeploymentConnectionModel, ElementModel, isDeployedInstance, isDeploymentNode } from '../../../model'
|
|
4
|
+
import type {
|
|
5
|
+
DeploymentElementModel,
|
|
6
|
+
DeploymentRelationEndpoint,
|
|
7
|
+
DeploymentRelationModel,
|
|
8
|
+
} from '../../../model/DeploymentElementModel'
|
|
9
|
+
import { isElementModel } from '../../../model/ElementModel'
|
|
10
|
+
import { isDeploymentElementModel, isNestedElementOfDeployedInstanceModel } from '../../../model/guards'
|
|
5
11
|
import type { RelationshipModel } from '../../../model/RelationModel'
|
|
6
12
|
import type { AnyAux } from '../../../model/types'
|
|
7
13
|
import { type Filterable, type OperatorPredicate, FqnExpr, RelationExpr } from '../../../types'
|
|
@@ -143,10 +149,9 @@ export function applyPredicate<M extends AnyAux>(
|
|
|
143
149
|
.filter(x => x.nonEmpty())
|
|
144
150
|
}
|
|
145
151
|
|
|
146
|
-
const map = toFilterableRelation(c.source, c.target)
|
|
147
152
|
return c.update({
|
|
148
|
-
model: new Set([...c.relations.model.values()].filter(r => where(
|
|
149
|
-
deployment: new Set([...c.relations.deployment.values()].filter(r => where(
|
|
153
|
+
model: new Set([...c.relations.model.values()].filter(r => where(toFilterableRelation(c)(r)))),
|
|
154
|
+
deployment: new Set([...c.relations.deployment.values()].filter(r => where(toFilterableRelation(c)(r)))),
|
|
150
155
|
})
|
|
151
156
|
}
|
|
152
157
|
|
|
@@ -164,20 +169,46 @@ export function matchConnections<M extends AnyAux>(
|
|
|
164
169
|
)
|
|
165
170
|
}
|
|
166
171
|
|
|
167
|
-
|
|
168
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Builds filterable presentation for relation endpoint. Enriches model properties with deployment properties when needed.
|
|
174
|
+
* @param relationEndpoint Endpoint for which to build presentation
|
|
175
|
+
* @param connectionEndpoint Endpoint of connection which was build from the relation.
|
|
176
|
+
* @returns Presentation of the endpoint for usage in predicates
|
|
177
|
+
*/
|
|
178
|
+
function toFilterable<M extends AnyAux>(
|
|
179
|
+
relationEndpoint: ElementModel<M> | DeploymentRelationEndpoint<M>,
|
|
180
|
+
connectionEndpoint: DeploymentRelationEndpoint<M>,
|
|
181
|
+
): Filterable {
|
|
182
|
+
if (isElementModel(relationEndpoint)) { // Element itself. Extend with tags of the deployed instance (TODO)
|
|
183
|
+
const deployedInstance = isDeploymentElementModel(connectionEndpoint) && isDeployedInstance(connectionEndpoint)
|
|
184
|
+
? connectionEndpoint
|
|
185
|
+
: null
|
|
186
|
+
return {
|
|
187
|
+
kind: relationEndpoint.kind,
|
|
188
|
+
tags: [...relationEndpoint.tags, ...(deployedInstance?.tags ?? [])],
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (isNestedElementOfDeployedInstanceModel(relationEndpoint)) { // Nested element. Has no own instance. No need to extend
|
|
192
|
+
return pick(relationEndpoint.element, ['tags', 'kind'])
|
|
193
|
+
}
|
|
194
|
+
if (isDeployedInstance(relationEndpoint)) { // Deployed instance. Extend with tags of the model element
|
|
195
|
+
return {
|
|
196
|
+
kind: relationEndpoint.element.kind,
|
|
197
|
+
tags: [...relationEndpoint.tags, ...relationEndpoint.element.tags],
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (isDeploymentNode(relationEndpoint)) { // Deployment node. Has no representation in model. No need to extend
|
|
201
|
+
return pick(relationEndpoint, ['tags', 'kind'])
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
nonexhaustive(relationEndpoint)
|
|
169
205
|
}
|
|
170
206
|
|
|
171
|
-
function toFilterableRelation<M extends AnyAux>(
|
|
172
|
-
|
|
173
|
-
target: DeploymentElementModel<M>,
|
|
174
|
-
) {
|
|
175
|
-
return (
|
|
176
|
-
relation: RelationshipModel<M> | DeploymentRelationModel<M>,
|
|
177
|
-
) => ({
|
|
207
|
+
function toFilterableRelation<M extends AnyAux>(c: DeploymentConnectionModel<M>) {
|
|
208
|
+
return (relation: RelationshipModel<M> | DeploymentRelationModel<M>) => ({
|
|
178
209
|
tags: relation.tags,
|
|
179
210
|
kind: relation.kind,
|
|
180
|
-
source:
|
|
181
|
-
target:
|
|
211
|
+
source: toFilterable(relation.source, c.source),
|
|
212
|
+
target: toFilterable(relation.target, c.target),
|
|
182
213
|
})
|
|
183
214
|
}
|
|
@@ -18,10 +18,7 @@ import {
|
|
|
18
18
|
type IconUrl,
|
|
19
19
|
type IncomingExpr as C4IncomingExpr,
|
|
20
20
|
type InOutExpr as C4InOutExpr,
|
|
21
|
-
|
|
22
|
-
isElementWhere,
|
|
23
|
-
isRelationExpression,
|
|
24
|
-
isRelationWhere,
|
|
21
|
+
type KindEqual,
|
|
25
22
|
type ModelRelation,
|
|
26
23
|
type NonEmptyArray,
|
|
27
24
|
type OutgoingExpr as C4OutgoingExpr,
|
|
@@ -30,6 +27,7 @@ import {
|
|
|
30
27
|
type RelationshipLineType,
|
|
31
28
|
type RelationWhereExpr,
|
|
32
29
|
type Tag,
|
|
30
|
+
type TagEqual,
|
|
33
31
|
type ViewId,
|
|
34
32
|
type ViewRule,
|
|
35
33
|
type ViewRuleGlobalPredicateRef,
|
|
@@ -38,8 +36,13 @@ import {
|
|
|
38
36
|
type ViewRulePredicate,
|
|
39
37
|
type ViewRuleStyle,
|
|
40
38
|
type WhereOperator,
|
|
39
|
+
isElementRef,
|
|
40
|
+
isElementWhere,
|
|
41
|
+
isRelationExpression,
|
|
42
|
+
isRelationWhere,
|
|
41
43
|
} from '../../../types'
|
|
42
44
|
import { type DirectRelationExpr as C4RelationExpr } from '../../../types/expression'
|
|
45
|
+
import type { Participant } from '../../../types/operators'
|
|
43
46
|
import { withReadableEdges } from '../../utils/with-readable-edges'
|
|
44
47
|
import { computeElementView } from '../compute'
|
|
45
48
|
|
|
@@ -482,6 +485,16 @@ export function $where(
|
|
|
482
485
|
}
|
|
483
486
|
}
|
|
484
487
|
|
|
488
|
+
export function $participant(
|
|
489
|
+
participant: Participant,
|
|
490
|
+
operator: TagEqual<TestTag> | KindEqual<TestTag>,
|
|
491
|
+
): WhereOperator<TestTag, string> {
|
|
492
|
+
return {
|
|
493
|
+
participant,
|
|
494
|
+
operator,
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
485
498
|
export function $inout(
|
|
486
499
|
expr: InOutExpr | C4ElementExpression,
|
|
487
500
|
): C4InOutExpr {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import DefaultMap from 'mnemonist/default-map'
|
|
2
2
|
import { filter, findLast, forEach, map, pipe } from 'remeda'
|
|
3
3
|
import { invariant, nonexhaustive, nonNullable } from '../../errors'
|
|
4
|
-
import { type ElementModel, LikeC4Model } from '../../model'
|
|
5
4
|
import { ConnectionModel } from '../../model/connection/model/ConnectionModel'
|
|
5
|
+
import { type ElementModel } from '../../model/ElementModel'
|
|
6
|
+
import { LikeC4Model } from '../../model/LikeC4Model'
|
|
6
7
|
import type { RelationshipModel } from '../../model/RelationModel'
|
|
7
8
|
import type { AnyAux } from '../../model/types'
|
|
8
9
|
import type {
|
|
@@ -15,7 +16,7 @@ import type {
|
|
|
15
16
|
} from '../../types'
|
|
16
17
|
import { isViewRuleAutoLayout, isViewRuleGroup, isViewRulePredicate, whereOperatorAsPredicate } from '../../types'
|
|
17
18
|
import * as Expr from '../../types/expression'
|
|
18
|
-
import {
|
|
19
|
+
import { sortParentsFirst } from '../../utils'
|
|
19
20
|
import { applyCustomElementProperties } from '../utils/applyCustomElementProperties'
|
|
20
21
|
import { applyCustomRelationProperties } from '../utils/applyCustomRelationProperties'
|
|
21
22
|
import { applyViewRuleStyles } from '../utils/applyViewRuleStyles'
|