@likec4/core 1.20.3 → 1.21.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 +24 -18
- package/dist/builder/index.d.cts +11 -5
- package/dist/builder/index.d.mts +11 -5
- package/dist/builder/index.d.ts +11 -5
- package/dist/builder/index.mjs +10 -4
- package/dist/compute-view/index.cjs +6 -6
- package/dist/compute-view/index.d.cts +4 -4
- package/dist/compute-view/index.d.mts +4 -4
- package/dist/compute-view/index.d.ts +4 -4
- package/dist/compute-view/index.mjs +6 -6
- package/dist/index.cjs +52 -14
- package/dist/index.d.cts +6 -6
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.mjs +46 -11
- package/dist/model/index.cjs +1 -1
- package/dist/model/index.d.cts +5 -5
- package/dist/model/index.d.mts +5 -5
- package/dist/model/index.d.ts +5 -5
- package/dist/model/index.mjs +1 -1
- package/dist/shared/{core.Cmfo_N4F.d.mts → core.5Z5cpENq.d.mts} +5 -4
- package/dist/shared/{core.D4wZW7zR.d.ts → core.BJfq046m.d.ts} +5 -4
- package/dist/shared/{core.C0ygs98j.d.cts → core.BS_nXBsP.d.cts} +9 -2
- package/dist/shared/{core.CajOK_t3.d.mts → core.BYs5deiY.d.cts} +1 -1
- package/dist/shared/{core.Bezy7K65.mjs → core.BfZZXtur.mjs} +2 -2
- package/dist/shared/{core.CwZmAghJ.d.cts → core.BgPZ8Tl8.d.cts} +5 -4
- package/dist/shared/{core.FACQZmma.cjs → core.BjR0D3IO.cjs} +15 -15
- package/dist/shared/{core.uxHtIZaH.cjs → core.CAkSSvJ6.cjs} +11 -5
- package/dist/shared/{core.El-gigOM.mjs → core.CE-kCVHA.mjs} +1 -1
- package/dist/shared/{core.DjMYkPMQ.d.mts → core.CJaCUZQ9.d.mts} +9 -2
- package/dist/shared/{core.88YY6vtF.d.mts → core.CT1nzYjO.d.cts} +2 -2
- package/dist/shared/{core.0PxLtLpP.mjs → core.CYNYaH2U.mjs} +5 -2
- package/dist/shared/{core.CCyhaU-4.mjs → core.CeefT_JU.mjs} +6 -6
- package/dist/shared/{core.BG1hfxpq.mjs → core.Cz9Oy_FA.mjs} +475 -409
- package/dist/shared/{core.BIZD3l1g.d.cts → core.D0KD4FiT.d.mts} +1 -1
- package/dist/shared/{core.DRfrKNT6.cjs → core.D91uYrqI.cjs} +551 -485
- package/dist/shared/{core.BtISRjMA.d.ts → core.DQCc-Jxk.d.ts} +1 -1
- package/dist/shared/{core.Db_OTRdC.cjs → core.DnPc_NDM.cjs} +1 -1
- package/dist/shared/{core.CNUzoKM7.d.ts → core.Dp3HTiRV.d.ts} +2 -2
- package/dist/shared/{core.CKYxnFEl.cjs → core.DqQrj2oQ.cjs} +2 -2
- package/dist/shared/{core.Bs71hdR4.d.ts → core.DsDq-blc.d.ts} +9 -2
- package/dist/shared/{core.Lh2RFJf1.d.cts → core.DuuS_BrY.d.mts} +2 -2
- package/dist/shared/{core.BJfn72tj.d.ts → core.QP35c488.d.cts} +33 -1
- package/dist/shared/{core.BJfn72tj.d.cts → core.QP35c488.d.mts} +33 -1
- package/dist/shared/{core.BJfn72tj.d.mts → core.QP35c488.d.ts} +33 -1
- package/dist/types/index.cjs +4 -1
- package/dist/types/index.d.cts +4 -4
- package/dist/types/index.d.mts +4 -4
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.mjs +1 -1
- package/dist/utils/index.cjs +3 -3
- package/dist/utils/index.d.cts +2 -2
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.mjs +3 -3
- package/package.json +6 -6
- package/src/builder/Builder.ts +11 -5
- package/src/builder/Builder.view-common.ts +1 -0
- package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +16 -4
- package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +21 -5
- package/src/builder/_types.ts +9 -0
- package/src/colors/index.ts +41 -5
- package/src/compute-view/deployment-view/predicates/{elements.ts → deploymentRefs.ts} +32 -21
- package/src/compute-view/deployment-view/predicates/index.ts +1 -1
- package/src/compute-view/deployment-view/predicates/utils.ts +56 -1
- package/src/compute-view/deployment-view/predicates/wildcard.ts +20 -9
- package/src/compute-view/memory/AbstractStageExclude.ts +1 -1
- package/src/compute-view/utils/applyCustomElementProperties.ts +18 -1
- package/src/compute-view/utils/applyViewRuleStyles.ts +9 -0
- package/src/compute-view/utils/buildComputedNodes.ts +13 -9
- package/src/model/DeploymentElementModel.ts +5 -2
- package/src/model/ElementModel.ts +10 -0
- package/src/types/element.ts +19 -1
- package/src/types/expression.ts +4 -1
- package/src/types/index.ts +6 -0
- package/src/types/theme.ts +22 -1
- package/src/types/view.ts +5 -1
|
@@ -16,6 +16,7 @@ exports[`Builder (style1) > should build nested elements and relTo 1`] = `
|
|
|
16
16
|
"shape": "rectangle",
|
|
17
17
|
"style": {
|
|
18
18
|
"opacity": 10,
|
|
19
|
+
"size": "lg",
|
|
19
20
|
},
|
|
20
21
|
"tags": null,
|
|
21
22
|
"technology": null,
|
|
@@ -28,7 +29,9 @@ exports[`Builder (style1) > should build nested elements and relTo 1`] = `
|
|
|
28
29
|
"kind": "component",
|
|
29
30
|
"links": null,
|
|
30
31
|
"shape": "browser",
|
|
31
|
-
"style": {
|
|
32
|
+
"style": {
|
|
33
|
+
"textSize": "sm",
|
|
34
|
+
},
|
|
32
35
|
"tags": null,
|
|
33
36
|
"technology": null,
|
|
34
37
|
"title": "c1",
|
|
@@ -42,6 +45,7 @@ exports[`Builder (style1) > should build nested elements and relTo 1`] = `
|
|
|
42
45
|
"shape": "rectangle",
|
|
43
46
|
"style": {
|
|
44
47
|
"opacity": 10,
|
|
48
|
+
"size": "lg",
|
|
45
49
|
},
|
|
46
50
|
"tags": null,
|
|
47
51
|
"technology": null,
|
|
@@ -54,7 +58,9 @@ exports[`Builder (style1) > should build nested elements and relTo 1`] = `
|
|
|
54
58
|
"kind": "component",
|
|
55
59
|
"links": null,
|
|
56
60
|
"shape": "browser",
|
|
57
|
-
"style": {
|
|
61
|
+
"style": {
|
|
62
|
+
"textSize": "sm",
|
|
63
|
+
},
|
|
58
64
|
"tags": null,
|
|
59
65
|
"technology": null,
|
|
60
66
|
"title": "Component s2.1",
|
|
@@ -66,7 +72,9 @@ exports[`Builder (style1) > should build nested elements and relTo 1`] = `
|
|
|
66
72
|
"kind": "component",
|
|
67
73
|
"links": null,
|
|
68
74
|
"shape": "browser",
|
|
69
|
-
"style": {
|
|
75
|
+
"style": {
|
|
76
|
+
"textSize": "sm",
|
|
77
|
+
},
|
|
70
78
|
"tags": null,
|
|
71
79
|
"technology": null,
|
|
72
80
|
"title": "Component s2.1.2",
|
|
@@ -78,7 +86,9 @@ exports[`Builder (style1) > should build nested elements and relTo 1`] = `
|
|
|
78
86
|
"kind": "component",
|
|
79
87
|
"links": null,
|
|
80
88
|
"shape": "browser",
|
|
81
|
-
"style": {
|
|
89
|
+
"style": {
|
|
90
|
+
"textSize": "sm",
|
|
91
|
+
},
|
|
82
92
|
"tags": null,
|
|
83
93
|
"technology": null,
|
|
84
94
|
"title": "c3",
|
|
@@ -115,12 +125,14 @@ exports[`Builder (style1) > should build nested elements and relTo 1`] = `
|
|
|
115
125
|
"component": {
|
|
116
126
|
"style": {
|
|
117
127
|
"shape": "browser",
|
|
128
|
+
"textSize": "sm",
|
|
118
129
|
},
|
|
119
130
|
},
|
|
120
131
|
"system": {
|
|
121
132
|
"style": {
|
|
122
133
|
"color": "green",
|
|
123
134
|
"opacity": 10,
|
|
135
|
+
"size": "lg",
|
|
124
136
|
},
|
|
125
137
|
},
|
|
126
138
|
},
|
|
@@ -10,7 +10,9 @@ exports[`Builder (style 2) > should build 1`] = `
|
|
|
10
10
|
"id": "dev",
|
|
11
11
|
"kind": "env",
|
|
12
12
|
"shape": "rectangle",
|
|
13
|
-
"style": {
|
|
13
|
+
"style": {
|
|
14
|
+
"size": "lg",
|
|
15
|
+
},
|
|
14
16
|
"tags": null,
|
|
15
17
|
"technology": null,
|
|
16
18
|
"title": "dev",
|
|
@@ -32,7 +34,9 @@ exports[`Builder (style 2) > should build 1`] = `
|
|
|
32
34
|
"id": "prod",
|
|
33
35
|
"kind": "env",
|
|
34
36
|
"shape": "rectangle",
|
|
35
|
-
"style": {
|
|
37
|
+
"style": {
|
|
38
|
+
"size": "lg",
|
|
39
|
+
},
|
|
36
40
|
"tags": null,
|
|
37
41
|
"technology": null,
|
|
38
42
|
"title": "prod",
|
|
@@ -63,7 +67,10 @@ exports[`Builder (style 2) > should build 1`] = `
|
|
|
63
67
|
"kind": "system",
|
|
64
68
|
"links": null,
|
|
65
69
|
"shape": "rectangle",
|
|
66
|
-
"style": {
|
|
70
|
+
"style": {
|
|
71
|
+
"size": "lg",
|
|
72
|
+
"textSize": "sm",
|
|
73
|
+
},
|
|
67
74
|
"tags": null,
|
|
68
75
|
"technology": null,
|
|
69
76
|
"title": "cloud",
|
|
@@ -101,13 +108,22 @@ exports[`Builder (style 2) > should build 1`] = `
|
|
|
101
108
|
"relations": {},
|
|
102
109
|
"specification": {
|
|
103
110
|
"deployments": {
|
|
104
|
-
"env": {
|
|
111
|
+
"env": {
|
|
112
|
+
"style": {
|
|
113
|
+
"size": "lg",
|
|
114
|
+
},
|
|
115
|
+
},
|
|
105
116
|
"node": {},
|
|
106
117
|
},
|
|
107
118
|
"elements": {
|
|
108
119
|
"actor": {},
|
|
109
120
|
"component": {},
|
|
110
|
-
"system": {
|
|
121
|
+
"system": {
|
|
122
|
+
"style": {
|
|
123
|
+
"size": "lg",
|
|
124
|
+
"textSize": "sm",
|
|
125
|
+
},
|
|
126
|
+
},
|
|
111
127
|
},
|
|
112
128
|
"relationships": {},
|
|
113
129
|
"tags": [],
|
package/src/builder/_types.ts
CHANGED
|
@@ -12,6 +12,9 @@ import type {
|
|
|
12
12
|
RelationshipArrowType,
|
|
13
13
|
RelationshipKindSpecification,
|
|
14
14
|
RelationshipLineType,
|
|
15
|
+
ShapeSize,
|
|
16
|
+
SpacingSize,
|
|
17
|
+
TextSize,
|
|
15
18
|
} from '../types'
|
|
16
19
|
import type { ExpressionV2 } from '../types/expression-v2'
|
|
17
20
|
import type { Builder } from './Builder'
|
|
@@ -47,6 +50,9 @@ export type NewElementProps<Tag, Metadata> = {
|
|
|
47
50
|
border?: BorderStyle
|
|
48
51
|
// 0-100
|
|
49
52
|
opacity?: number
|
|
53
|
+
size?: ShapeSize
|
|
54
|
+
padding?: SpacingSize
|
|
55
|
+
textSize?: TextSize
|
|
50
56
|
}
|
|
51
57
|
}
|
|
52
58
|
|
|
@@ -64,6 +70,9 @@ export type NewDeploymentNodeProps<Tag, Metadata> = {
|
|
|
64
70
|
border?: BorderStyle
|
|
65
71
|
// 0-100
|
|
66
72
|
opacity?: number
|
|
73
|
+
size?: ShapeSize
|
|
74
|
+
padding?: SpacingSize
|
|
75
|
+
textSize?: TextSize
|
|
67
76
|
}
|
|
68
77
|
}
|
|
69
78
|
|
package/src/colors/index.ts
CHANGED
|
@@ -7,7 +7,43 @@ export const defaultTheme: LikeC4Theme = {
|
|
|
7
7
|
elements: ElementColors,
|
|
8
8
|
relationships: RelationshipColors,
|
|
9
9
|
font: 'Arial',
|
|
10
|
-
shadow: '#0a0a0a'
|
|
10
|
+
shadow: '#0a0a0a',
|
|
11
|
+
sizes: {
|
|
12
|
+
xs: {
|
|
13
|
+
width: 120,
|
|
14
|
+
height: 80,
|
|
15
|
+
},
|
|
16
|
+
sm: {
|
|
17
|
+
width: 180,
|
|
18
|
+
height: 110,
|
|
19
|
+
},
|
|
20
|
+
md: {
|
|
21
|
+
width: 320,
|
|
22
|
+
height: 180,
|
|
23
|
+
},
|
|
24
|
+
lg: {
|
|
25
|
+
width: 420,
|
|
26
|
+
height: 234,
|
|
27
|
+
},
|
|
28
|
+
xl: {
|
|
29
|
+
width: 520,
|
|
30
|
+
height: 290,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
spacing: {
|
|
34
|
+
xs: 8, // 0.5rem
|
|
35
|
+
sm: 10, // 0.625rem
|
|
36
|
+
md: 24, // 1.5rem = 16px + 8px
|
|
37
|
+
lg: 32, // 2rem
|
|
38
|
+
xl: 48,
|
|
39
|
+
},
|
|
40
|
+
textSizes: {
|
|
41
|
+
xs: 12,
|
|
42
|
+
sm: 14,
|
|
43
|
+
md: 19,
|
|
44
|
+
lg: 24,
|
|
45
|
+
xl: 32,
|
|
46
|
+
},
|
|
11
47
|
}
|
|
12
48
|
|
|
13
49
|
export function computeColorValues(color: HexColorLiteral): ThemeColorValues {
|
|
@@ -19,18 +55,18 @@ export function computeColorValues(color: HexColorLiteral): ThemeColorValues {
|
|
|
19
55
|
fill: colors[6] as HexColorLiteral,
|
|
20
56
|
stroke: colors[7] as HexColorLiteral,
|
|
21
57
|
hiContrast: colors[0] as HexColorLiteral,
|
|
22
|
-
loContrast: colors[1] as HexColorLiteral
|
|
58
|
+
loContrast: colors[1] as HexColorLiteral,
|
|
23
59
|
},
|
|
24
60
|
relationships: {
|
|
25
61
|
lineColor: colors[4] as HexColorLiteral,
|
|
26
62
|
labelColor: colors[3] as HexColorLiteral,
|
|
27
|
-
labelBgColor: colors[9] as HexColorLiteral
|
|
28
|
-
}
|
|
63
|
+
labelBgColor: colors[9] as HexColorLiteral,
|
|
64
|
+
},
|
|
29
65
|
}
|
|
30
66
|
} else {
|
|
31
67
|
return {
|
|
32
68
|
elements: defaultTheme.elements['primary'],
|
|
33
|
-
relationships: defaultTheme.relationships['primary']
|
|
69
|
+
relationships: defaultTheme.relationships['primary'],
|
|
34
70
|
}
|
|
35
71
|
}
|
|
36
72
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pipe, reduce } from 'remeda'
|
|
1
|
+
import { filter, forEach, pipe, reduce } from 'remeda'
|
|
2
2
|
import { isDeployedInstance } from '../../../model'
|
|
3
3
|
import { findConnectionsBetween, findConnectionsWithin } from '../../../model/connection/deployment'
|
|
4
4
|
import type { DeploymentElementModel, DeploymentNodeModel } from '../../../model/DeploymentElementModel'
|
|
@@ -7,15 +7,18 @@ import type { Elem, IncludePredicateCtx, PredicateExecutor } from '../_types'
|
|
|
7
7
|
import { cleanCrossBoundary, cleanRedundantRelationships } from '../clean-connections'
|
|
8
8
|
import type { StageInclude } from '../memory'
|
|
9
9
|
import { deploymentExpressionToPredicate } from '../utils'
|
|
10
|
+
import { applyElementPredicate } from './utils'
|
|
10
11
|
|
|
11
12
|
export const DeploymentRefPredicate: PredicateExecutor<FqnExpr.DeploymentRef> = {
|
|
12
13
|
include: (ctx) => {
|
|
13
|
-
const { expr } = ctx
|
|
14
|
+
const { expr, where } = ctx
|
|
14
15
|
const el = ctx.model.element(expr.ref.deployment)
|
|
15
16
|
|
|
16
17
|
if (isDeployedInstance(el)) {
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
if (applyElementPredicate(el, where)) {
|
|
19
|
+
ctx.stage.addExplicit(el)
|
|
20
|
+
ctx.stage.connectWithExisting(el)
|
|
21
|
+
}
|
|
19
22
|
return ctx.stage
|
|
20
23
|
}
|
|
21
24
|
|
|
@@ -30,16 +33,23 @@ export const DeploymentRefPredicate: PredicateExecutor<FqnExpr.DeploymentRef> =
|
|
|
30
33
|
includeDeployedNodeDescendants(el, ctx)
|
|
31
34
|
break
|
|
32
35
|
default: {
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
if (applyElementPredicate(el, where)) {
|
|
37
|
+
ctx.stage.addExplicit(el)
|
|
38
|
+
ctx.stage.connectWithExisting(el)
|
|
39
|
+
}
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
return ctx.stage
|
|
38
43
|
},
|
|
39
44
|
|
|
40
|
-
exclude: ({ expr, stage, memory }) => {
|
|
45
|
+
exclude: ({ expr, stage, memory, where }) => {
|
|
41
46
|
const exprPredicate = deploymentExpressionToPredicate(expr)
|
|
42
|
-
|
|
47
|
+
const toExclude = pipe(
|
|
48
|
+
[...memory.elements],
|
|
49
|
+
filter<DeploymentElementModel>(exprPredicate),
|
|
50
|
+
applyElementPredicate(where),
|
|
51
|
+
)
|
|
52
|
+
stage.exclude(toExclude)
|
|
43
53
|
return stage
|
|
44
54
|
},
|
|
45
55
|
}
|
|
@@ -49,9 +59,9 @@ export const DeploymentRefPredicate: PredicateExecutor<FqnExpr.DeploymentRef> =
|
|
|
49
59
|
*/
|
|
50
60
|
function includeDeployedNodeChildren(
|
|
51
61
|
node: DeploymentNodeModel,
|
|
52
|
-
{ stage }: IncludePredicateCtx,
|
|
62
|
+
{ stage, where }: IncludePredicateCtx,
|
|
53
63
|
) {
|
|
54
|
-
const children = [...node.children()]
|
|
64
|
+
const children = applyElementPredicate([...node.children()], where)
|
|
55
65
|
if (children.length === 0) {
|
|
56
66
|
return
|
|
57
67
|
}
|
|
@@ -68,12 +78,12 @@ function includeDeployedNodeChildren(
|
|
|
68
78
|
*/
|
|
69
79
|
function includeDeployedNodeWithExpanded(
|
|
70
80
|
node: DeploymentNodeModel,
|
|
71
|
-
{ memory, stage }: IncludePredicateCtx,
|
|
81
|
+
{ memory, stage, where }: IncludePredicateCtx,
|
|
72
82
|
) {
|
|
73
|
-
const children = [...node.children()]
|
|
74
83
|
stage.addImplicit(node)
|
|
75
84
|
stage.connectWithExisting(node)
|
|
76
85
|
|
|
86
|
+
const children = applyElementPredicate([...node.children()], where)
|
|
77
87
|
let hasConnectionsWithVisible = false
|
|
78
88
|
for (const child of children) {
|
|
79
89
|
if (findConnectionsBetween(child, memory.elements).length > 0) {
|
|
@@ -99,7 +109,7 @@ function includeDeployedNodeWithExpanded(
|
|
|
99
109
|
*/
|
|
100
110
|
function includeDeployedNodeDescendants(
|
|
101
111
|
node: DeploymentNodeModel,
|
|
102
|
-
{ stage }: IncludePredicateCtx,
|
|
112
|
+
{ stage, where }: IncludePredicateCtx,
|
|
103
113
|
) {
|
|
104
114
|
const dfs = (node: DeploymentNodeModel): DeploymentElementModel[] => {
|
|
105
115
|
const children = [] as DeploymentElementModel[]
|
|
@@ -107,7 +117,9 @@ function includeDeployedNodeDescendants(
|
|
|
107
117
|
if (child.isDeploymentNode()) {
|
|
108
118
|
children.push(...dfs(child))
|
|
109
119
|
}
|
|
110
|
-
|
|
120
|
+
if (applyElementPredicate(child, where)) {
|
|
121
|
+
children.push(child)
|
|
122
|
+
}
|
|
111
123
|
}
|
|
112
124
|
stage.connectWithExisting(children, 'in')
|
|
113
125
|
stage.addConnections(findConnectionsWithin(children))
|
|
@@ -120,14 +132,13 @@ function includeDeployedNodeDescendants(
|
|
|
120
132
|
return
|
|
121
133
|
}
|
|
122
134
|
stage.connectWithExisting(descendants, 'out')
|
|
123
|
-
// stage.addImplicit(descendants)
|
|
124
135
|
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
136
|
+
const allConnected = findConnectedElements(stage)
|
|
137
|
+
pipe(
|
|
138
|
+
descendants,
|
|
139
|
+
filter(desc => allConnected.has(desc)),
|
|
140
|
+
forEach(desc => stage.addExplicit(desc)),
|
|
141
|
+
)
|
|
131
142
|
}
|
|
132
143
|
|
|
133
144
|
function findConnectedElements(stage: StageInclude) {
|
|
@@ -14,7 +14,7 @@ import { type Filterable, type OperatorPredicate, FqnExpr, RelationExpr } from '
|
|
|
14
14
|
import { hasIntersection, intersection } from '../../../utils/set'
|
|
15
15
|
import type { ExcludePredicateCtx, PredicateCtx } from '../_types'
|
|
16
16
|
import type { StageExclude, StageInclude } from '../memory'
|
|
17
|
-
import { DeploymentRefPredicate } from './
|
|
17
|
+
import { DeploymentRefPredicate } from './deploymentRefs'
|
|
18
18
|
import { DirectRelationPredicate } from './relation-direct'
|
|
19
19
|
import { InOutRelationPredicate } from './relation-in-out'
|
|
20
20
|
import { IncomingRelationPredicate } from './relation-incoming'
|
|
@@ -37,6 +37,7 @@ export function predicateToPatch(
|
|
|
37
37
|
return DeploymentRefPredicate[op]({ ...ctx, expr, where } as any)
|
|
38
38
|
case FqnExpr.isWildcard(expr):
|
|
39
39
|
return WildcardPredicate[op]({ ...ctx, expr, where } as any)
|
|
40
|
+
|
|
40
41
|
case RelationExpr.isDirect(expr):
|
|
41
42
|
return DirectRelationPredicate[op]({ ...ctx, expr, where } as any)
|
|
42
43
|
case RelationExpr.isInOut(expr):
|
|
@@ -155,6 +156,60 @@ export function applyPredicate<M extends AnyAux>(
|
|
|
155
156
|
})
|
|
156
157
|
}
|
|
157
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Checks elements using the provided predicate.
|
|
161
|
+
*
|
|
162
|
+
* @param c The collection of element to apply the predicate to
|
|
163
|
+
* @param where The predicate
|
|
164
|
+
* @returns Returns array of elements those match the predicate
|
|
165
|
+
*/
|
|
166
|
+
export function applyElementPredicate<M extends AnyAux>(
|
|
167
|
+
c: readonly DeploymentElementModel<M>[],
|
|
168
|
+
where: OperatorPredicate<Filterable> | null,
|
|
169
|
+
): readonly DeploymentElementModel<M>[]
|
|
170
|
+
/**
|
|
171
|
+
* Checks element using the provided predicate.
|
|
172
|
+
*
|
|
173
|
+
* @param c The element to apply the predicate to
|
|
174
|
+
* @param where The predicate
|
|
175
|
+
* @returns The result of the check
|
|
176
|
+
*/
|
|
177
|
+
export function applyElementPredicate<M extends AnyAux, E extends DeploymentElementModel<M>>(
|
|
178
|
+
c: E,
|
|
179
|
+
where: OperatorPredicate<Filterable> | null,
|
|
180
|
+
): boolean
|
|
181
|
+
/**
|
|
182
|
+
* Creates a function that filters elemetns using the provided predicate.
|
|
183
|
+
*
|
|
184
|
+
* @param where The predicate
|
|
185
|
+
* @returns A function to filter elements
|
|
186
|
+
*/
|
|
187
|
+
export function applyElementPredicate<M extends AnyAux, E extends DeploymentElementModel<M>>(
|
|
188
|
+
where: OperatorPredicate<Filterable> | null,
|
|
189
|
+
): (data: readonly E[]) => readonly E[]
|
|
190
|
+
export function applyElementPredicate<M extends AnyAux, E extends DeploymentElementModel<M>>(
|
|
191
|
+
...args:
|
|
192
|
+
| [readonly E[], OperatorPredicate<Filterable> | null]
|
|
193
|
+
| [OperatorPredicate<Filterable> | null]
|
|
194
|
+
| [c: E, OperatorPredicate<Filterable> | null]
|
|
195
|
+
):
|
|
196
|
+
| boolean
|
|
197
|
+
| readonly E[]
|
|
198
|
+
| ((data: readonly E[]) => readonly E[])
|
|
199
|
+
{
|
|
200
|
+
if (args.length === 1) {
|
|
201
|
+
return x => applyElementPredicate(x, args[0]) as readonly E[]
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const [c, where] = args
|
|
205
|
+
|
|
206
|
+
if (isArray(c)) {
|
|
207
|
+
return c.filter(x => applyElementPredicate(x, where))
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return where?.(toFilterable(c, c)) ?? true
|
|
211
|
+
}
|
|
212
|
+
|
|
158
213
|
export function matchConnections<M extends AnyAux>(
|
|
159
214
|
connections: readonly DeploymentConnectionModel<M>[],
|
|
160
215
|
where: OperatorPredicate<Filterable> | null,
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
+
import { map, pipe } from 'remeda'
|
|
1
2
|
import { findConnectionsWithin } from '../../../model/connection/deployment'
|
|
2
3
|
import type { FqnExpr } from '../../../types'
|
|
3
4
|
import { type Elem, type PredicateExecutor } from '../_types'
|
|
5
|
+
import { applyElementPredicate } from './utils'
|
|
4
6
|
|
|
5
7
|
export const WildcardPredicate: PredicateExecutor<FqnExpr.Wildcard> = {
|
|
6
|
-
include: ({ model, stage }) => {
|
|
8
|
+
include: ({ model, stage, where }) => {
|
|
7
9
|
const children = [] as Elem[]
|
|
8
10
|
|
|
9
|
-
const rootElements =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
}))
|
|
15
20
|
|
|
16
21
|
stage.addExplicit(rootElements)
|
|
17
22
|
if (children.length > 1) {
|
|
@@ -22,8 +27,14 @@ export const WildcardPredicate: PredicateExecutor<FqnExpr.Wildcard> = {
|
|
|
22
27
|
}
|
|
23
28
|
return stage
|
|
24
29
|
},
|
|
25
|
-
exclude: ({ stage, memory }) => {
|
|
26
|
-
|
|
30
|
+
exclude: ({ stage, memory, where }) => {
|
|
31
|
+
const elementsToExclude = pipe(
|
|
32
|
+
[...memory.elements],
|
|
33
|
+
applyElementPredicate(where),
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
stage.exclude(elementsToExclude)
|
|
37
|
+
|
|
27
38
|
return stage
|
|
28
39
|
},
|
|
29
40
|
}
|
|
@@ -209,7 +209,7 @@ export abstract class AbstractStageExclude<T extends AnyCtx> implements StageExc
|
|
|
209
209
|
state = this.removeElements(state)
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
state = this.moveDisconnectedExplicitsToImplicits(state)
|
|
212
|
+
//state = this.moveDisconnectedExplicitsToImplicits(state)
|
|
213
213
|
|
|
214
214
|
return this.memory.update(this.postcommit(state))
|
|
215
215
|
}
|
|
@@ -27,7 +27,15 @@ export function applyCustomElementProperties(_rules: ViewRule[], _nodes: Compute
|
|
|
27
27
|
custom: { expr, ...props },
|
|
28
28
|
} of rules
|
|
29
29
|
) {
|
|
30
|
-
const {
|
|
30
|
+
const {
|
|
31
|
+
border,
|
|
32
|
+
opacity,
|
|
33
|
+
multiple,
|
|
34
|
+
padding,
|
|
35
|
+
size,
|
|
36
|
+
textSize,
|
|
37
|
+
...rest
|
|
38
|
+
} = omitBy(props, isNullish)
|
|
31
39
|
const notEmpty = !isEmpty(rest)
|
|
32
40
|
const satisfies = elementExprToPredicate(expr)
|
|
33
41
|
nodes.forEach((node, i) => {
|
|
@@ -52,6 +60,15 @@ export function applyCustomElementProperties(_rules: ViewRule[], _nodes: Compute
|
|
|
52
60
|
if (multiple !== undefined) {
|
|
53
61
|
styleOverride = { ...styleOverride, multiple }
|
|
54
62
|
}
|
|
63
|
+
if (padding !== undefined) {
|
|
64
|
+
styleOverride = { ...styleOverride, padding }
|
|
65
|
+
}
|
|
66
|
+
if (size !== undefined) {
|
|
67
|
+
styleOverride = { ...styleOverride, size }
|
|
68
|
+
}
|
|
69
|
+
if (textSize !== undefined) {
|
|
70
|
+
styleOverride = { ...styleOverride, textSize }
|
|
71
|
+
}
|
|
55
72
|
if (styleOverride) {
|
|
56
73
|
node = {
|
|
57
74
|
...node,
|
|
@@ -34,6 +34,15 @@ export function applyViewRuleStyle<Rule extends CommonViewRuleStyle>(
|
|
|
34
34
|
if (isDefined(rule.style.multiple)) {
|
|
35
35
|
styleOverride = { ...styleOverride, multiple: rule.style.multiple }
|
|
36
36
|
}
|
|
37
|
+
if (isDefined(rule.style.padding)) {
|
|
38
|
+
styleOverride = { ...styleOverride, padding: rule.style.padding }
|
|
39
|
+
}
|
|
40
|
+
if (isDefined(rule.style.size)) {
|
|
41
|
+
styleOverride = { ...styleOverride, size: rule.style.size }
|
|
42
|
+
}
|
|
43
|
+
if (isDefined(rule.style.textSize)) {
|
|
44
|
+
styleOverride = { ...styleOverride, textSize: rule.style.textSize }
|
|
45
|
+
}
|
|
37
46
|
if (styleOverride) {
|
|
38
47
|
n.style = {
|
|
39
48
|
...n.style,
|
|
@@ -2,12 +2,12 @@ import type { Simplify } from 'type-fest'
|
|
|
2
2
|
import { nonNullable } from '../../errors'
|
|
3
3
|
import {
|
|
4
4
|
type ComputedNode,
|
|
5
|
+
type Element,
|
|
6
|
+
type Fqn,
|
|
7
|
+
type NodeId,
|
|
5
8
|
DefaultElementShape,
|
|
6
9
|
DefaultThemeColor,
|
|
7
|
-
type Element,
|
|
8
10
|
ElementKind,
|
|
9
|
-
type Fqn,
|
|
10
|
-
type NodeId
|
|
11
11
|
} from '../../types'
|
|
12
12
|
import { compareByFqnHierarchically, parentFqn } from '../../utils/fqn'
|
|
13
13
|
import { NodesGroup } from '../element-view/memory'
|
|
@@ -28,7 +28,7 @@ function updateDepthOfAncestors(node: ComputedNode, nodes: ReadonlyMap<Fqn, Comp
|
|
|
28
28
|
const modelElementAsNodeSource = (element: Element): ComputedNodeSource => {
|
|
29
29
|
return {
|
|
30
30
|
...element,
|
|
31
|
-
modelRef: 1
|
|
31
|
+
modelRef: 1,
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -44,7 +44,7 @@ export function buildComputedNodesFromElements(elements: ReadonlyArray<Element>,
|
|
|
44
44
|
|
|
45
45
|
export function buildComputedNodes(
|
|
46
46
|
elements: ReadonlyArray<ComputedNodeSource>,
|
|
47
|
-
groups?: ReadonlyArray<NodesGroup
|
|
47
|
+
groups?: ReadonlyArray<NodesGroup>,
|
|
48
48
|
): ReadonlyMap<Fqn, ComputedNode> {
|
|
49
49
|
const nodesMap = new Map<Fqn, ComputedNode>()
|
|
50
50
|
|
|
@@ -72,8 +72,12 @@ export function buildComputedNodes(
|
|
|
72
72
|
links: null,
|
|
73
73
|
style: {
|
|
74
74
|
border: viewRule.border ?? 'dashed',
|
|
75
|
-
opacity: viewRule.opacity ?? 0
|
|
76
|
-
|
|
75
|
+
opacity: viewRule.opacity ?? 0,
|
|
76
|
+
size: viewRule.size ?? 'md',
|
|
77
|
+
multiple: viewRule.multiple ?? false,
|
|
78
|
+
padding: viewRule.padding ?? 'md',
|
|
79
|
+
textSize: viewRule.textSize ?? 'md',
|
|
80
|
+
},
|
|
77
81
|
})
|
|
78
82
|
for (const e of elements) {
|
|
79
83
|
elementToGroup.set(e.id, id)
|
|
@@ -128,8 +132,8 @@ export function buildComputedNodes(
|
|
|
128
132
|
outEdges: [],
|
|
129
133
|
...el,
|
|
130
134
|
style: {
|
|
131
|
-
...style
|
|
132
|
-
}
|
|
135
|
+
...style,
|
|
136
|
+
},
|
|
133
137
|
}
|
|
134
138
|
nodesMap.set(id, node)
|
|
135
139
|
})
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
DefaultElementShape,
|
|
19
19
|
DefaultThemeColor,
|
|
20
20
|
} from '../types'
|
|
21
|
+
import { DefaultShapeSize } from '../types/element'
|
|
21
22
|
import { commonAncestor, hierarchyLevel } from '../utils'
|
|
22
23
|
import { difference, intersection, union } from '../utils/set'
|
|
23
24
|
import type { LikeC4DeploymentModel } from './DeploymentModel'
|
|
@@ -43,10 +44,11 @@ abstract class AbstractDeploymentElementModel<M extends AnyAux = AnyAux> {
|
|
|
43
44
|
abstract readonly $model: LikeC4DeploymentModel<M>
|
|
44
45
|
abstract readonly $node: DeploymentNode | DeployedInstance
|
|
45
46
|
|
|
46
|
-
get style(): SetRequired<DeploymentElementStyle, 'shape' | 'color'> {
|
|
47
|
+
get style(): SetRequired<DeploymentElementStyle, 'shape' | 'color' | 'size'> {
|
|
47
48
|
return {
|
|
48
49
|
shape: DefaultElementShape,
|
|
49
50
|
color: DefaultThemeColor,
|
|
51
|
+
size: DefaultShapeSize,
|
|
50
52
|
...this.$node.style,
|
|
51
53
|
}
|
|
52
54
|
}
|
|
@@ -349,11 +351,12 @@ export class DeployedInstanceModel<M extends AnyAux = AnyAux> extends AbstractDe
|
|
|
349
351
|
return nonNullable(this.$model.parent(this), `Parent of ${this.id} not found`)
|
|
350
352
|
}
|
|
351
353
|
|
|
352
|
-
override get style(): SetRequired<DeploymentElementStyle, 'shape' | 'color'> {
|
|
354
|
+
override get style(): SetRequired<DeploymentElementStyle, 'shape' | 'color' | 'size'> {
|
|
353
355
|
const { icon, style } = this.element.$element
|
|
354
356
|
return {
|
|
355
357
|
shape: this.element.shape,
|
|
356
358
|
color: this.element.color,
|
|
359
|
+
size: DefaultShapeSize,
|
|
357
360
|
...icon && { icon },
|
|
358
361
|
...style,
|
|
359
362
|
...this.$instance.style,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { isTruthy } from 'remeda'
|
|
2
|
+
import type { SetRequired } from 'type-fest'
|
|
2
3
|
import {
|
|
3
4
|
type Element as C4Element,
|
|
4
5
|
type ElementKind as C4ElementKind,
|
|
5
6
|
type ElementShape as C4ElementShape,
|
|
7
|
+
type ElementStyle,
|
|
6
8
|
type IconUrl,
|
|
7
9
|
type IteratorLike,
|
|
8
10
|
type Link,
|
|
@@ -11,6 +13,7 @@ import {
|
|
|
11
13
|
DefaultElementShape,
|
|
12
14
|
DefaultThemeColor,
|
|
13
15
|
} from '../types'
|
|
16
|
+
import { DefaultShapeSize } from '../types/element'
|
|
14
17
|
import { commonAncestor, hierarchyLevel, isAncestor, sortNaturalByFqn } from '../utils'
|
|
15
18
|
import { type DeployedInstancesIterator } from './DeploymentElementModel'
|
|
16
19
|
import type { LikeC4Model } from './LikeC4Model'
|
|
@@ -80,6 +83,13 @@ export class ElementModel<M extends AnyAux = AnyAux> {
|
|
|
80
83
|
return this.parent === null
|
|
81
84
|
}
|
|
82
85
|
|
|
86
|
+
get style(): SetRequired<ElementStyle, 'size'> {
|
|
87
|
+
return {
|
|
88
|
+
size: DefaultShapeSize,
|
|
89
|
+
...this.$element.style,
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
83
93
|
public isAncestorOf(another: ElementModel<M>): boolean {
|
|
84
94
|
return isAncestor(this, another)
|
|
85
95
|
}
|