@likec4/core 1.19.1 → 1.19.2
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.d.mts +3 -3
- package/dist/builder/index.d.ts +3 -3
- package/dist/builder/index.js +2 -2
- package/dist/compute-view/index.d.mts +2 -2
- package/dist/compute-view/index.d.ts +2 -2
- package/dist/compute-view/index.js +3 -3
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/model/index.d.mts +8 -3
- package/dist/model/index.d.ts +8 -3
- package/dist/model/index.js +1 -1
- package/dist/shared/{core.BZ9Msq7w.d.mts → core.2I-l5UtM.d.mts} +5 -1
- package/dist/shared/{core.CmYMqgha.d.mts → core.BL1oTk7-.d.mts} +13 -3
- package/dist/shared/{core.BIfgabEw.d.ts → core.CqXs9Frh.d.ts} +5 -1
- package/dist/shared/{core.C05RDLhi.d.ts → core.DyJ41fBO.d.ts} +13 -3
- package/dist/shared/{index.DafVOuVd.js → index.KOeaSlL8.js} +332 -208
- package/dist/shared/{view.CyZrG8BJ.js → view.DrmaOfjr.js} +3 -0
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +1 -1
- package/package.json +3 -3
- package/src/builder/Builder.view-common.ts +1 -0
- package/src/compute-view/deployment-view/__test__/fixture.ts +31 -3
- package/src/compute-view/deployment-view/_types.ts +2 -1
- package/src/compute-view/deployment-view/compute.ts +4 -36
- package/src/compute-view/deployment-view/predicates/index.ts +8 -0
- package/src/compute-view/deployment-view/predicates/relation-direct.ts +117 -88
- package/src/compute-view/deployment-view/predicates/relation-in-out.ts +16 -8
- package/src/compute-view/deployment-view/predicates/relation-incoming.ts +18 -12
- package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +16 -9
- package/src/compute-view/deployment-view/predicates/relation-where.ts +18 -0
- package/src/compute-view/deployment-view/predicates/utils.ts +183 -0
- package/src/model/DeploymentElementModel.ts +14 -1
- package/src/model/RelationModel.ts +4 -0
- package/src/model/connection/deployment/DeploymentConnectionModel.ts +11 -1
- package/src/types/deployments.ts +1 -0
- package/src/types/expression-v2.ts +12 -0
- package/src/types/index.ts +1 -0
- package/src/types/operators.ts +5 -5
|
@@ -163,6 +163,9 @@ var RelationExpr;
|
|
|
163
163
|
RelationExpr2.isInOut = (expr) => {
|
|
164
164
|
return "inout" in expr;
|
|
165
165
|
};
|
|
166
|
+
RelationExpr2.isWhere = (expr) => {
|
|
167
|
+
return "where" in expr;
|
|
168
|
+
};
|
|
166
169
|
})(RelationExpr || (RelationExpr = {}));
|
|
167
170
|
var ExpressionV2;
|
|
168
171
|
((ExpressionV22) => {
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { X as XYPoint, N as NonEmptyArray, P as Point, h as BorderStyle, l as ElementShape, x as ThemeColor, F as Fqn } from '../shared/core.D74xkKkG.mjs';
|
|
2
2
|
export { A as AsFqn, B as BorderStyles, s as Color, t as ColorLiteral, C as CustomColor, D as DefaultElementShape, e as DefaultThemeColor, i as Element, f as ElementKind, j as ElementKindSpecification, k as ElementKindSpecificationStyle, g as ElementShapes, m as ElementStyle, v as ElementThemeColorValues, u as ElementThemeColors, E as ExclusiveUnion, H as HexColorLiteral, I as IconUrl, a as IteratorLike, K as KeysOf, L as LikeC4Theme, n as Link, c as NTuple, b as NonEmptyReadonlyArray, d as Predicate, w as RelationshipThemeColorValues, R as RelationshipThemeColors, o as Tag, p as TagSpec, T as ThemeColorValues, q as TypedElement, r as isThemeColor } from '../shared/core.D74xkKkG.mjs';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { bk as ViewId, aW as BBox, bl as ViewManualLayout, aT as AutoLayoutDirection } from '../shared/core.BL1oTk7-.mjs';
|
|
4
|
+
export { as as AbstractRelation, ag as AndOperator, a5 as AnyParsedLikeC4Model, aU as BasicElementView, aV as BasicView, aX as ComputedDeploymentView, aY as ComputedDynamicView, aZ as ComputedEdge, a_ as ComputedElementView, a as ComputedLikeC4Model, az as ComputedNode, C as ComputedView, a$ as CustomColorDefinitions, A as CustomElementExpr, B as CustomRelationExpr, ap as DefaultArrowType, aq as DefaultLineStyle, ar as DefaultRelationshipColor, b as DeployedInstance, D as DeploymentElement, c as DeploymentElementStyle, d as DeploymentNode, f as DeploymentNodeKind, g as DeploymentNodeKindSpecification, h as DeploymentRef, i as DeploymentRelation, b0 as DeploymentView, b1 as DeploymentViewRule, b2 as DeploymentViewRulePredicate, b3 as DeploymentViewRuleStyle, b4 as DiagramEdge, aA as DiagramNode, b5 as DiagramView, E as DirectRelationExpr, b6 as DynamicView, b7 as DynamicViewIncludeRule, b8 as DynamicViewParallelSteps, b9 as DynamicViewRule, ba as DynamicViewStep, bb as DynamicViewStepOrParallel, bc as EdgeId, F as ElementExpression, G as ElementKindExpr, bw as ElementNotation, H as ElementPredicateExpression, I as ElementRefExpr, J as ElementTagExpr, bd as ElementView, K as ElementWhereExpr, ah as EqualOperator, M as ExpandedElementExpr, N as Expression, X as ExpressionV2, be as ExtendsElementView, ai as Filterable, Y as FqnExpr, Z as FqnRef, a6 as GenericLikeC4Model, $ as GlobalDynamicPredicates, a0 as GlobalPredicateId, a1 as GlobalPredicates, a2 as GlobalStyleID, a3 as GlobalStyles, Q as InOutExpr, O as IncomingExpr, aj as KindEqual, a7 as LayoutedLikeC4Model, a8 as LikeC4ModelDump, L as LikeC4View, a4 as ModelGlobals, at as ModelRelation, bf as NodeId, R as NonWilcard, ak as NotOperator, al as OperatorPredicate, am as OrOperator, S as OutgoingExpr, a9 as ParsedLikeC4Model, P as PredicateSelector, _ as RelationExpr, T as RelationExpression, au as RelationId, U as RelationPredicateExpression, V as RelationWhereExpr, av as RelationshipArrowType, aw as RelationshipKind, ax as RelationshipKindSpecification, ay as RelationshipLineType, bg as ScopedElementView, bh as StepEdgeId, bi as StepEdgeIdLiteral, an as TagEqual, bj as ViewAutoLayout, bm as ViewRule, bn as ViewRuleAutoLayout, bo as ViewRuleGlobalPredicateRef, bp as ViewRuleGlobalStyle, bq as ViewRuleGroup, br as ViewRulePredicate, bs as ViewRuleStyle, bt as ViewRuleStyleOrGlobalRef, bu as ViewWithHash, bv as ViewWithNotation, ao as WhereOperator, W as WildcardExpr, aB as extractStep, aC as getBBoxCenter, aD as getParallelStepsPrefix, aa as isAndOperator, aE as isAutoLayoutDirection, j as isCustomElement, k as isCustomRelationExpr, aF as isDeploymentView, aG as isDynamicView, aH as isDynamicViewParallelSteps, l as isElement, m as isElementKindExpr, n as isElementPredicateExpr, o as isElementRef, p as isElementTagExpr, aI as isElementView, q as isElementWhere, r as isExpandedElementExpr, aJ as isExtendsElementView, t as isInOut, s as isIncoming, ab as isKindEqual, ac as isNotOperator, ad as isOrOperator, u as isOutgoing, v as isRelation, w as isRelationExpression, x as isRelationPredicateExpr, y as isRelationWhere, aK as isScopedElementView, aL as isStepEdgeId, ae as isTagEqual, aM as isViewRuleAutoLayout, aN as isViewRuleGlobalPredicateRef, aO as isViewRuleGlobalStyle, aP as isViewRuleGroup, aQ as isViewRulePredicate, aR as isViewRuleStyle, z as isWildcard, aS as stepEdgeId, af as whereOperatorAsPredicate } from '../shared/core.BL1oTk7-.mjs';
|
|
5
5
|
import 'type-fest';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { X as XYPoint, N as NonEmptyArray, P as Point, h as BorderStyle, l as ElementShape, x as ThemeColor, F as Fqn } from '../shared/core.D74xkKkG.js';
|
|
2
2
|
export { A as AsFqn, B as BorderStyles, s as Color, t as ColorLiteral, C as CustomColor, D as DefaultElementShape, e as DefaultThemeColor, i as Element, f as ElementKind, j as ElementKindSpecification, k as ElementKindSpecificationStyle, g as ElementShapes, m as ElementStyle, v as ElementThemeColorValues, u as ElementThemeColors, E as ExclusiveUnion, H as HexColorLiteral, I as IconUrl, a as IteratorLike, K as KeysOf, L as LikeC4Theme, n as Link, c as NTuple, b as NonEmptyReadonlyArray, d as Predicate, w as RelationshipThemeColorValues, R as RelationshipThemeColors, o as Tag, p as TagSpec, T as ThemeColorValues, q as TypedElement, r as isThemeColor } from '../shared/core.D74xkKkG.js';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { bk as ViewId, aW as BBox, bl as ViewManualLayout, aT as AutoLayoutDirection } from '../shared/core.DyJ41fBO.js';
|
|
4
|
+
export { as as AbstractRelation, ag as AndOperator, a5 as AnyParsedLikeC4Model, aU as BasicElementView, aV as BasicView, aX as ComputedDeploymentView, aY as ComputedDynamicView, aZ as ComputedEdge, a_ as ComputedElementView, a as ComputedLikeC4Model, az as ComputedNode, C as ComputedView, a$ as CustomColorDefinitions, A as CustomElementExpr, B as CustomRelationExpr, ap as DefaultArrowType, aq as DefaultLineStyle, ar as DefaultRelationshipColor, b as DeployedInstance, D as DeploymentElement, c as DeploymentElementStyle, d as DeploymentNode, f as DeploymentNodeKind, g as DeploymentNodeKindSpecification, h as DeploymentRef, i as DeploymentRelation, b0 as DeploymentView, b1 as DeploymentViewRule, b2 as DeploymentViewRulePredicate, b3 as DeploymentViewRuleStyle, b4 as DiagramEdge, aA as DiagramNode, b5 as DiagramView, E as DirectRelationExpr, b6 as DynamicView, b7 as DynamicViewIncludeRule, b8 as DynamicViewParallelSteps, b9 as DynamicViewRule, ba as DynamicViewStep, bb as DynamicViewStepOrParallel, bc as EdgeId, F as ElementExpression, G as ElementKindExpr, bw as ElementNotation, H as ElementPredicateExpression, I as ElementRefExpr, J as ElementTagExpr, bd as ElementView, K as ElementWhereExpr, ah as EqualOperator, M as ExpandedElementExpr, N as Expression, X as ExpressionV2, be as ExtendsElementView, ai as Filterable, Y as FqnExpr, Z as FqnRef, a6 as GenericLikeC4Model, $ as GlobalDynamicPredicates, a0 as GlobalPredicateId, a1 as GlobalPredicates, a2 as GlobalStyleID, a3 as GlobalStyles, Q as InOutExpr, O as IncomingExpr, aj as KindEqual, a7 as LayoutedLikeC4Model, a8 as LikeC4ModelDump, L as LikeC4View, a4 as ModelGlobals, at as ModelRelation, bf as NodeId, R as NonWilcard, ak as NotOperator, al as OperatorPredicate, am as OrOperator, S as OutgoingExpr, a9 as ParsedLikeC4Model, P as PredicateSelector, _ as RelationExpr, T as RelationExpression, au as RelationId, U as RelationPredicateExpression, V as RelationWhereExpr, av as RelationshipArrowType, aw as RelationshipKind, ax as RelationshipKindSpecification, ay as RelationshipLineType, bg as ScopedElementView, bh as StepEdgeId, bi as StepEdgeIdLiteral, an as TagEqual, bj as ViewAutoLayout, bm as ViewRule, bn as ViewRuleAutoLayout, bo as ViewRuleGlobalPredicateRef, bp as ViewRuleGlobalStyle, bq as ViewRuleGroup, br as ViewRulePredicate, bs as ViewRuleStyle, bt as ViewRuleStyleOrGlobalRef, bu as ViewWithHash, bv as ViewWithNotation, ao as WhereOperator, W as WildcardExpr, aB as extractStep, aC as getBBoxCenter, aD as getParallelStepsPrefix, aa as isAndOperator, aE as isAutoLayoutDirection, j as isCustomElement, k as isCustomRelationExpr, aF as isDeploymentView, aG as isDynamicView, aH as isDynamicViewParallelSteps, l as isElement, m as isElementKindExpr, n as isElementPredicateExpr, o as isElementRef, p as isElementTagExpr, aI as isElementView, q as isElementWhere, r as isExpandedElementExpr, aJ as isExtendsElementView, t as isInOut, s as isIncoming, ab as isKindEqual, ac as isNotOperator, ad as isOrOperator, u as isOutgoing, v as isRelation, w as isRelationExpression, x as isRelationPredicateExpr, y as isRelationWhere, aK as isScopedElementView, aL as isStepEdgeId, ae as isTagEqual, aM as isViewRuleAutoLayout, aN as isViewRuleGlobalPredicateRef, aO as isViewRuleGlobalStyle, aP as isViewRuleGroup, aQ as isViewRulePredicate, aR as isViewRuleStyle, z as isWildcard, aS as stepEdgeId, af as whereOperatorAsPredicate } from '../shared/core.DyJ41fBO.js';
|
|
5
5
|
import 'type-fest';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/types/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AsFqn, B as BorderStyles, Q as ComputedNode, S as ComputedView, N as DefaultArrowType, e as DefaultElementShape, O as DefaultLineStyle, P as DefaultRelationshipColor, d as DefaultThemeColor, D as DeploymentElement, T as DiagramNode, E as ElementKind, g as ElementShapes, C as ExpressionV2, F as FqnExpr, G as FqnRef, R as RelationExpr, U as extractStep, V as getBBoxCenter, W as getParallelStepsPrefix, H as isAndOperator, X as isAutoLayoutDirection, h as isCustomElement, j as isCustomRelationExpr, Y as isDeploymentView, Z as isDynamicView, _ as isDynamicViewParallelSteps, k as isElement, l as isElementKindExpr, b as isElementPredicateExpr, m as isElementRef, p as isElementTagExpr, a as isElementView, q as isElementWhere, r as isExpandedElementExpr, i as isExtendsElementView, t as isInOut, s as isIncoming, I as isKindEqual, J as isNotOperator, K as isOrOperator, u as isOutgoing, v as isRelation, w as isRelationExpression, x as isRelationPredicateExpr, y as isRelationWhere, c as isScopedElementView, $ as isStepEdgeId, L as isTagEqual, a0 as isViewRuleAutoLayout, a1 as isViewRuleGlobalPredicateRef, a2 as isViewRuleGlobalStyle, a3 as isViewRuleGroup, a4 as isViewRulePredicate, a5 as isViewRuleStyle, z as isWildcard, a6 as stepEdgeId, M as whereOperatorAsPredicate } from '../shared/view.
|
|
1
|
+
export { A as AsFqn, B as BorderStyles, Q as ComputedNode, S as ComputedView, N as DefaultArrowType, e as DefaultElementShape, O as DefaultLineStyle, P as DefaultRelationshipColor, d as DefaultThemeColor, D as DeploymentElement, T as DiagramNode, E as ElementKind, g as ElementShapes, C as ExpressionV2, F as FqnExpr, G as FqnRef, R as RelationExpr, U as extractStep, V as getBBoxCenter, W as getParallelStepsPrefix, H as isAndOperator, X as isAutoLayoutDirection, h as isCustomElement, j as isCustomRelationExpr, Y as isDeploymentView, Z as isDynamicView, _ as isDynamicViewParallelSteps, k as isElement, l as isElementKindExpr, b as isElementPredicateExpr, m as isElementRef, p as isElementTagExpr, a as isElementView, q as isElementWhere, r as isExpandedElementExpr, i as isExtendsElementView, t as isInOut, s as isIncoming, I as isKindEqual, J as isNotOperator, K as isOrOperator, u as isOutgoing, v as isRelation, w as isRelationExpression, x as isRelationPredicateExpr, y as isRelationWhere, c as isScopedElementView, $ as isStepEdgeId, L as isTagEqual, a0 as isViewRuleAutoLayout, a1 as isViewRuleGlobalPredicateRef, a2 as isViewRuleGlobalStyle, a3 as isViewRuleGroup, a4 as isViewRulePredicate, a5 as isViewRuleStyle, z as isWildcard, a6 as stepEdgeId, M as whereOperatorAsPredicate } from '../shared/view.DrmaOfjr.js';
|
|
2
2
|
|
|
3
3
|
const ThemeColors = [
|
|
4
4
|
"amber",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/core",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://likec4.dev",
|
|
6
6
|
"author": "Denis Davydkov <denis@davydkov.com>",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"type-fest": "4.28.1"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
|
-
"@likec4/tsconfig": "1.19.
|
|
88
|
+
"@likec4/tsconfig": "1.19.2",
|
|
89
89
|
"@mantine/colors-generator": "7.15.2",
|
|
90
90
|
"@types/natural-compare-lite": "^1.4.2",
|
|
91
91
|
"@types/object-hash": "^3.0.6",
|
|
@@ -104,5 +104,5 @@
|
|
|
104
104
|
"unbuild": "^3.1.0",
|
|
105
105
|
"vitest": "^2.1.8"
|
|
106
106
|
},
|
|
107
|
-
"packageManager": "yarn@4.
|
|
107
|
+
"packageManager": "yarn@4.6.0"
|
|
108
108
|
}
|
|
@@ -189,6 +189,7 @@ function $exclude<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(
|
|
|
189
189
|
| [B['Expr']]
|
|
190
190
|
| [B['TypedExpr']]
|
|
191
191
|
| [B['Expr'], ViewPredicate.Custom<B['Types']>]
|
|
192
|
+
| [B['TypedExpr'], ViewPredicate.Custom<B['Types']>]
|
|
192
193
|
): (b: B) => B {
|
|
193
194
|
return (b) => {
|
|
194
195
|
let expr = b.$expr(args[0]) as C4Expression
|
|
@@ -57,6 +57,8 @@ const {
|
|
|
57
57
|
zone: {},
|
|
58
58
|
node: {},
|
|
59
59
|
},
|
|
60
|
+
tags: ['old', 'next', 'temp'],
|
|
61
|
+
relationships: { 'https': {} },
|
|
60
62
|
})
|
|
61
63
|
|
|
62
64
|
export const builder = b
|
|
@@ -91,13 +93,22 @@ export const builder = b
|
|
|
91
93
|
model(
|
|
92
94
|
$m.rel('customer', 'cloud', 'uses services'),
|
|
93
95
|
$m.rel('customer', 'cloud.frontend.mobile', 'opens mobile app'),
|
|
94
|
-
$m.rel('customer', 'cloud.frontend.dashboard',
|
|
96
|
+
$m.rel('customer', 'cloud.frontend.dashboard', {
|
|
97
|
+
title: 'opens in browser',
|
|
98
|
+
tags: ['old'],
|
|
99
|
+
}),
|
|
95
100
|
$m.rel('cloud.frontend.dashboard', 'cloud.auth', {
|
|
96
101
|
title: 'authenticates',
|
|
97
102
|
color: 'green',
|
|
98
103
|
}),
|
|
99
|
-
$m.rel('cloud.frontend.dashboard', 'cloud.backend.api',
|
|
100
|
-
|
|
104
|
+
$m.rel('cloud.frontend.dashboard', 'cloud.backend.api', {
|
|
105
|
+
title: 'fetches data',
|
|
106
|
+
tags: ['old'],
|
|
107
|
+
}),
|
|
108
|
+
$m.rel('cloud.frontend.dashboard', 'cloud.media', {
|
|
109
|
+
title: 'fetches media',
|
|
110
|
+
tags: ['temp'],
|
|
111
|
+
}),
|
|
101
112
|
$m.rel('cloud.frontend.mobile', 'cloud.auth', {
|
|
102
113
|
title: 'authenticates',
|
|
103
114
|
color: 'amber',
|
|
@@ -137,6 +148,14 @@ export const builder = b
|
|
|
137
148
|
instanceOf('db', 'aws.rds'),
|
|
138
149
|
),
|
|
139
150
|
),
|
|
151
|
+
env('dev').with(
|
|
152
|
+
node('devCustomer').with(
|
|
153
|
+
instanceOf('instance', 'customer'),
|
|
154
|
+
),
|
|
155
|
+
node('devCloud').with(
|
|
156
|
+
instanceOf('instance', 'cloud'),
|
|
157
|
+
),
|
|
158
|
+
),
|
|
140
159
|
env('acc').with(
|
|
141
160
|
node('testCustomer').with(
|
|
142
161
|
instanceOf('instance', 'customer'),
|
|
@@ -196,3 +215,12 @@ export function computeNodesAndEdges(...rules: DeploymentRulesBuilderOp<Types>[]
|
|
|
196
215
|
edges: edgeIds,
|
|
197
216
|
}
|
|
198
217
|
}
|
|
218
|
+
|
|
219
|
+
export function createModel() {
|
|
220
|
+
const modelsource = builder.build()
|
|
221
|
+
|
|
222
|
+
return LikeC4Model.create({
|
|
223
|
+
...modelsource,
|
|
224
|
+
views: {},
|
|
225
|
+
})
|
|
226
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LikeC4DeploymentModel } from '../../model'
|
|
2
2
|
import type { RelationshipModel } from '../../model/RelationModel'
|
|
3
|
-
import type { ExpressionV2 } from '../../types'
|
|
3
|
+
import type { ExpressionV2, Filterable, OperatorPredicate } from '../../types'
|
|
4
4
|
import type { Ctx, Memory, Stage, StageExclude, StageInclude } from './memory'
|
|
5
5
|
|
|
6
6
|
export { Memory, type Stage } from './memory'
|
|
@@ -23,6 +23,7 @@ export interface PredicateCtx<Expr extends ExpressionV2 = ExpressionV2> {
|
|
|
23
23
|
stage: Stage
|
|
24
24
|
model: LikeC4DeploymentModel
|
|
25
25
|
memory: Memory
|
|
26
|
+
where: OperatorPredicate<Filterable> | null
|
|
26
27
|
}
|
|
27
28
|
export interface IncludePredicateCtx<Expr extends ExpressionV2 = ExpressionV2> extends PredicateCtx<Expr> {
|
|
28
29
|
stage: StageInclude
|
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
import { findLast, map } from 'remeda'
|
|
2
|
-
import { nonexhaustive } from '../../errors'
|
|
3
2
|
import { type LikeC4DeploymentModel, LikeC4Model } from '../../model'
|
|
4
3
|
import type { AnyAux } from '../../model/types'
|
|
5
4
|
import type { DeploymentViewRule } from '../../types'
|
|
6
5
|
import {
|
|
7
6
|
type ComputedDeploymentView,
|
|
8
7
|
type DeploymentView,
|
|
9
|
-
FqnExpr,
|
|
10
8
|
isViewRuleAutoLayout,
|
|
11
9
|
isViewRulePredicate,
|
|
12
10
|
} from '../../types'
|
|
13
|
-
import { RelationExpr } from '../../types/expression-v2'
|
|
14
11
|
import { buildElementNotations } from '../utils/buildElementNotations'
|
|
15
12
|
import { linkNodesWithEdges } from '../utils/link-nodes-with-edges'
|
|
16
13
|
import { topologicalSort } from '../utils/topological-sort'
|
|
17
14
|
import { calcViewLayoutHash } from '../utils/view-hash'
|
|
18
15
|
import { Memory } from './memory'
|
|
19
|
-
import {
|
|
20
|
-
import { DirectRelationPredicate } from './predicates/relation-direct'
|
|
21
|
-
import { InOutRelationPredicate } from './predicates/relation-in-out'
|
|
22
|
-
import { IncomingRelationPredicate } from './predicates/relation-incoming'
|
|
23
|
-
import { OutgoingRelationPredicate } from './predicates/relation-outgoing'
|
|
24
|
-
import { WildcardPredicate } from './predicates/wildcard'
|
|
16
|
+
import { predicateToPatch } from './predicates'
|
|
25
17
|
import { StageFinal } from './stages/stage-final'
|
|
26
18
|
import { applyDeploymentViewRuleStyles, buildNodes, toComputedEdges } from './utils'
|
|
27
19
|
|
|
@@ -37,32 +29,8 @@ export function processPredicates<M extends AnyAux>(
|
|
|
37
29
|
const exprs = rule.include ?? rule.exclude
|
|
38
30
|
for (const expr of exprs) {
|
|
39
31
|
let stage = op === 'include' ? memory.stageInclude(expr) : memory.stageExclude(expr)
|
|
40
|
-
const ctx = { model, stage, memory }
|
|
41
|
-
|
|
42
|
-
case FqnExpr.isModelRef(expr):
|
|
43
|
-
// Ignore model refs in deployment view
|
|
44
|
-
break
|
|
45
|
-
case FqnExpr.isDeploymentRef(expr):
|
|
46
|
-
stage = DeploymentRefPredicate[op]({ ...ctx, expr } as any) ?? stage
|
|
47
|
-
break
|
|
48
|
-
case FqnExpr.isWildcard(expr):
|
|
49
|
-
stage = WildcardPredicate[op]({ ...ctx, expr } as any) ?? stage
|
|
50
|
-
break
|
|
51
|
-
case RelationExpr.isDirect(expr):
|
|
52
|
-
stage = DirectRelationPredicate[op]({ ...ctx, expr } as any) ?? stage
|
|
53
|
-
break
|
|
54
|
-
case RelationExpr.isInOut(expr):
|
|
55
|
-
stage = InOutRelationPredicate[op]({ ...ctx, expr } as any) ?? stage
|
|
56
|
-
break
|
|
57
|
-
case RelationExpr.isOutgoing(expr):
|
|
58
|
-
stage = OutgoingRelationPredicate[op]({ ...ctx, expr } as any) ?? stage
|
|
59
|
-
break
|
|
60
|
-
case RelationExpr.isIncoming(expr):
|
|
61
|
-
stage = IncomingRelationPredicate[op]({ ...ctx, expr } as any) ?? stage
|
|
62
|
-
break
|
|
63
|
-
default:
|
|
64
|
-
nonexhaustive(expr)
|
|
65
|
-
}
|
|
32
|
+
const ctx = { expr, model, stage, memory, where: null }
|
|
33
|
+
stage = predicateToPatch(op, ctx) ?? stage
|
|
66
34
|
memory = stage.commit()
|
|
67
35
|
}
|
|
68
36
|
}
|
|
@@ -78,7 +46,7 @@ export function computeDeploymentView<M extends AnyAux>(
|
|
|
78
46
|
...view
|
|
79
47
|
}: DeploymentView,
|
|
80
48
|
): ComputedDeploymentView<M['ViewId']> {
|
|
81
|
-
|
|
49
|
+
const memory = processPredicates<M>(likec4model.deployment, rules)
|
|
82
50
|
|
|
83
51
|
const nodesMap = buildNodes(memory)
|
|
84
52
|
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { filter, flatMap, isNonNullish,
|
|
1
|
+
import { filter, flatMap, isNonNullish, pick, pipe } from 'remeda'
|
|
2
2
|
import { invariant } from '../../../errors'
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
ConnectionModel,
|
|
5
|
+
DeploymentElementModel,
|
|
6
|
+
DeploymentRelationModel,
|
|
7
|
+
LikeC4DeploymentModel,
|
|
8
|
+
} from '../../../model'
|
|
4
9
|
import type { DeploymentConnectionModel } from '../../../model/connection/deployment'
|
|
5
10
|
import { findConnection, findConnectionsBetween, findConnectionsWithin } from '../../../model/connection/deployment'
|
|
6
11
|
import { findConnectionsBetween as findModelConnectionsBetween } from '../../../model/connection/model'
|
|
7
|
-
import type { ConnectionModel } from '../../../model/connection/model/ConnectionModel'
|
|
8
|
-
import type { DeploymentElementModel } from '../../../model/DeploymentElementModel'
|
|
9
12
|
import type { RelationshipModel } from '../../../model/RelationModel'
|
|
10
13
|
import type { AnyAux } from '../../../model/types'
|
|
11
|
-
import { type RelationExpr, FqnExpr } from '../../../types'
|
|
12
|
-
import {
|
|
13
|
-
import type { ExcludePredicateCtx, PredicateExecutor } from '../_types'
|
|
14
|
-
import type { StageExclude } from '../memory'
|
|
14
|
+
import { type Filterable, type OperatorPredicate, type RelationExpr, FqnExpr } from '../../../types'
|
|
15
|
+
import type { PredicateExecutor } from '../_types'
|
|
15
16
|
import { deploymentExpressionToPredicate, resolveElements, resolveModelElements } from '../utils'
|
|
16
17
|
import { filterIncomingConnections, resolveAllImcomingRelations } from './relation-incoming'
|
|
17
18
|
import { filterOutgoingConnections, resolveAllOutgoingRelations } from './relation-outgoing'
|
|
18
|
-
|
|
19
|
-
// const isRef = DeploymentElementExpression.isRef
|
|
19
|
+
import { applyPredicate, excludeModelRelations } from './utils'
|
|
20
20
|
|
|
21
21
|
export const resolveAscendingSiblings = (element: DeploymentElementModel) => {
|
|
22
22
|
const siblings = new Set<DeploymentElementModel>()
|
|
@@ -40,7 +40,7 @@ const resolveWildcard = (model: LikeC4DeploymentModel, nonWildcard: FqnExpr.Depl
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export const DirectRelationPredicate: PredicateExecutor<RelationExpr.Direct> = {
|
|
43
|
-
include: ({ expr: { source, target, isBidirectional = false }, model, stage }) => {
|
|
43
|
+
include: ({ expr: { source, target, isBidirectional = false }, model, stage, where }) => {
|
|
44
44
|
invariant(!FqnExpr.isModelRef(source), 'Invalid source model ref in direct relation')
|
|
45
45
|
invariant(!FqnExpr.isModelRef(target), 'Invalid target model ref in direct relation')
|
|
46
46
|
const sourceIsWildcard = FqnExpr.isWildcard(source)
|
|
@@ -109,7 +109,7 @@ export const DirectRelationPredicate: PredicateExecutor<RelationExpr.Direct> = {
|
|
|
109
109
|
|
|
110
110
|
connections = pipe(
|
|
111
111
|
sources,
|
|
112
|
-
flatMap(s => findConnectionsBetween(s, targets, dir)),
|
|
112
|
+
flatMap(s => matchConnections(findConnectionsBetween(s, targets, dir), where)),
|
|
113
113
|
filter(c => isSource(c) && isTarget(c)),
|
|
114
114
|
)
|
|
115
115
|
}
|
|
@@ -126,90 +126,72 @@ export const DirectRelationPredicate: PredicateExecutor<RelationExpr.Direct> = {
|
|
|
126
126
|
|
|
127
127
|
return stage
|
|
128
128
|
},
|
|
129
|
-
exclude: ({ expr, model, memory, stage }) => {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (
|
|
133
|
-
FqnExpr.isWildcard(expr.source)
|
|
134
|
-
&& FqnExpr.isWildcard(expr.target)
|
|
135
|
-
) {
|
|
136
|
-
stage.excludeConnections(memory.connections)
|
|
137
|
-
return stage
|
|
138
|
-
}
|
|
129
|
+
exclude: ({ expr, model, memory, stage, where }) => {
|
|
130
|
+
const isTarget = deploymentExpressionToPredicate(expr.target)
|
|
131
|
+
const isSource = deploymentExpressionToPredicate(expr.source)
|
|
139
132
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
})
|
|
147
|
-
return excludeModelRelations(toExclude, { stage, memory })
|
|
148
|
-
}
|
|
133
|
+
let modelRelationsToExclude: ReadonlySet<RelationshipModel<AnyAux>>
|
|
134
|
+
switch (true) {
|
|
135
|
+
// * -> *
|
|
136
|
+
case FqnExpr.isWildcard(expr.source) && FqnExpr.isWildcard(expr.target):
|
|
137
|
+
stage.excludeConnections(matchConnections(memory.connections, where))
|
|
138
|
+
return stage
|
|
149
139
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
{ stage, memory },
|
|
160
|
-
c => isTarget(c.target),
|
|
161
|
-
)
|
|
162
|
-
}
|
|
140
|
+
// model -> model
|
|
141
|
+
case FqnExpr.isModelRef(expr.source) && FqnExpr.isModelRef(expr.target):
|
|
142
|
+
modelRelationsToExclude = resolveRelationsBetweenModelElements({
|
|
143
|
+
source: expr.source,
|
|
144
|
+
target: expr.target,
|
|
145
|
+
expr,
|
|
146
|
+
model,
|
|
147
|
+
})
|
|
148
|
+
return excludeModelRelations(modelRelationsToExclude, { stage, memory }, where)
|
|
163
149
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
toExclude,
|
|
169
|
-
{ stage, memory },
|
|
170
|
-
c => isSource(c.source),
|
|
171
|
-
)
|
|
172
|
-
}
|
|
150
|
+
// model -> *
|
|
151
|
+
case FqnExpr.isModelRef(expr.source) && FqnExpr.isWildcard(expr.target):
|
|
152
|
+
modelRelationsToExclude = resolveAllOutgoingRelations(model, expr.source)
|
|
153
|
+
return excludeModelRelations(modelRelationsToExclude, { stage, memory }, where)
|
|
173
154
|
|
|
174
|
-
|
|
175
|
-
|
|
155
|
+
// model -> deployment
|
|
156
|
+
case FqnExpr.isModelRef(expr.source):
|
|
157
|
+
modelRelationsToExclude = resolveAllOutgoingRelations(model, expr.source)
|
|
158
|
+
return excludeModelRelations(
|
|
159
|
+
modelRelationsToExclude,
|
|
160
|
+
{ stage, memory },
|
|
161
|
+
where,
|
|
162
|
+
c => isTarget(c.target),
|
|
163
|
+
)
|
|
176
164
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
165
|
+
// deployment -> model
|
|
166
|
+
case FqnExpr.isModelRef(expr.target):
|
|
167
|
+
modelRelationsToExclude = resolveAllImcomingRelations(model, expr.target)
|
|
168
|
+
return excludeModelRelations(
|
|
169
|
+
modelRelationsToExclude,
|
|
170
|
+
{ stage, memory },
|
|
171
|
+
where,
|
|
172
|
+
c => isSource(c.source),
|
|
173
|
+
)
|
|
181
174
|
|
|
182
|
-
|
|
175
|
+
// deployment -> deployment
|
|
176
|
+
default:
|
|
177
|
+
const satisfies = (connection: DeploymentConnectionModel) => {
|
|
178
|
+
return (isSource(connection.source) && isTarget(connection.target))
|
|
179
|
+
|| (expr.isBidirectional === true && isSource(connection.target) && isTarget(connection.source))
|
|
180
|
+
}
|
|
183
181
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
182
|
+
const deploymentRelationsToExclude = pipe(
|
|
183
|
+
memory.connections,
|
|
184
|
+
filter(satisfies),
|
|
185
|
+
applyPredicate(where),
|
|
186
|
+
)
|
|
187
|
+
if (deploymentRelationsToExclude.length === 0) {
|
|
188
|
+
return stage
|
|
189
|
+
}
|
|
188
190
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
filterConnections: (c: DeploymentConnectionModel) => boolean = () => true,
|
|
194
|
-
): StageExclude {
|
|
195
|
-
if (relationsToExclude.size === 0) {
|
|
196
|
-
return stage
|
|
197
|
-
}
|
|
198
|
-
const toExclude = pipe(
|
|
199
|
-
memory.connections,
|
|
200
|
-
// Find connections that have at least one relation in common with the excluded relations
|
|
201
|
-
filter(c => filterConnections(c) && hasIntersection(c.relations.model, relationsToExclude)),
|
|
202
|
-
map(c =>
|
|
203
|
-
c.update({
|
|
204
|
-
deployment: null,
|
|
205
|
-
model: intersection(c.relations.model, relationsToExclude),
|
|
206
|
-
})
|
|
207
|
-
),
|
|
208
|
-
)
|
|
209
|
-
if (toExclude.length === 0) {
|
|
210
|
-
return stage
|
|
211
|
-
}
|
|
212
|
-
return stage.excludeConnections(toExclude)
|
|
191
|
+
stage.excludeConnections(deploymentRelationsToExclude)
|
|
192
|
+
return stage
|
|
193
|
+
}
|
|
194
|
+
},
|
|
213
195
|
}
|
|
214
196
|
|
|
215
197
|
function resolveRelationsBetweenModelElements({
|
|
@@ -235,3 +217,50 @@ function resolveRelationsBetweenModelElements({
|
|
|
235
217
|
|
|
236
218
|
return new Set(modelConnections.flatMap(c => [...c.relations]))
|
|
237
219
|
}
|
|
220
|
+
|
|
221
|
+
function elementToFilterable<M extends AnyAux>(element: DeploymentElementModel<M>) {
|
|
222
|
+
return pick(element, ['tags', 'kind'])
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function toFilterableRelation<M extends AnyAux>(
|
|
226
|
+
source: DeploymentElementModel<M>,
|
|
227
|
+
target: DeploymentElementModel<M>,
|
|
228
|
+
) {
|
|
229
|
+
return (
|
|
230
|
+
relation: RelationshipModel<M> | DeploymentRelationModel<M>,
|
|
231
|
+
) => ({
|
|
232
|
+
tags: relation.tags,
|
|
233
|
+
kind: relation.kind,
|
|
234
|
+
source: elementToFilterable(source),
|
|
235
|
+
target: elementToFilterable(target),
|
|
236
|
+
})
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function matchConnection<M extends AnyAux>(
|
|
240
|
+
c: DeploymentConnectionModel<M>,
|
|
241
|
+
where: OperatorPredicate<Filterable> | null,
|
|
242
|
+
): boolean {
|
|
243
|
+
if (!where) {
|
|
244
|
+
return true
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return [
|
|
248
|
+
...Array.from(c.relations.deployment.values()).map(toFilterableRelation(c.source, c.target)),
|
|
249
|
+
...Array.from(c.relations.model.values()).map(toFilterableRelation(c.source, c.target)),
|
|
250
|
+
]
|
|
251
|
+
.filter(where).length > 0
|
|
252
|
+
}
|
|
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
|
+
}
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
+
import { filter, pipe } from 'remeda'
|
|
1
2
|
import { invariant } from '../../../errors'
|
|
2
3
|
import { findConnectionsBetween } from '../../../model/connection/deployment'
|
|
3
4
|
import type { RelationshipModel } from '../../../model/RelationModel'
|
|
4
5
|
import type { AnyAux } from '../../../model/types'
|
|
5
|
-
import {
|
|
6
|
+
import { type RelationExpr, FqnExpr } from '../../../types/expression-v2'
|
|
6
7
|
import { union } from '../../../utils/set'
|
|
7
8
|
import type { PredicateExecutor } from '../_types'
|
|
8
9
|
import { resolveElements, resolveModelElements } from '../utils'
|
|
9
|
-
import {
|
|
10
|
+
import { resolveAscendingSiblings } from './relation-direct'
|
|
10
11
|
import { filterIncomingConnections } from './relation-incoming'
|
|
11
12
|
import { filterOutgoingConnections } from './relation-outgoing'
|
|
13
|
+
import { applyPredicate, excludeModelRelations, matchConnections } from './utils'
|
|
12
14
|
|
|
13
15
|
//
|
|
14
16
|
export const InOutRelationPredicate: PredicateExecutor<RelationExpr.InOut> = {
|
|
15
|
-
include: ({ expr, model, memory, stage }) => {
|
|
17
|
+
include: ({ expr, model, memory, stage, where }) => {
|
|
16
18
|
const sources = [...memory.elements]
|
|
17
19
|
|
|
18
20
|
if (FqnExpr.isWildcard(expr.inout)) {
|
|
19
21
|
for (const source of sources) {
|
|
20
22
|
const targets = [...resolveAscendingSiblings(source)]
|
|
21
|
-
|
|
23
|
+
const toInclude = matchConnections(findConnectionsBetween(source, targets, 'both'), where)
|
|
24
|
+
stage.addConnections(toInclude)
|
|
22
25
|
}
|
|
23
26
|
return stage
|
|
24
27
|
}
|
|
@@ -26,12 +29,13 @@ export const InOutRelationPredicate: PredicateExecutor<RelationExpr.InOut> = {
|
|
|
26
29
|
|
|
27
30
|
const targets = resolveElements(model, expr.inout)
|
|
28
31
|
for (const source of sources) {
|
|
29
|
-
|
|
32
|
+
const toInclude = matchConnections(findConnectionsBetween(source, targets, 'both'), where)
|
|
33
|
+
stage.addConnections(toInclude)
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
return stage
|
|
33
37
|
},
|
|
34
|
-
exclude: ({ expr, model, memory, stage }) => {
|
|
38
|
+
exclude: ({ expr, model, memory, stage, where }) => {
|
|
35
39
|
// Exclude all connections that have model relationshps with the elements
|
|
36
40
|
if (FqnExpr.isModelRef(expr.inout)) {
|
|
37
41
|
const elements = resolveModelElements(model, expr.inout)
|
|
@@ -42,7 +46,7 @@ export const InOutRelationPredicate: PredicateExecutor<RelationExpr.InOut> = {
|
|
|
42
46
|
new Set<RelationshipModel<AnyAux>>(),
|
|
43
47
|
...elements.flatMap(e => [e.allIncoming, e.allOutgoing]),
|
|
44
48
|
)
|
|
45
|
-
return excludeModelRelations(excludedRelations, { stage, memory })
|
|
49
|
+
return excludeModelRelations(excludedRelations, { stage, memory }, where)
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
if (FqnExpr.isWildcard(expr.inout)) {
|
|
@@ -54,7 +58,11 @@ export const InOutRelationPredicate: PredicateExecutor<RelationExpr.InOut> = {
|
|
|
54
58
|
const isIncoming = filterIncomingConnections(elements)
|
|
55
59
|
const isOutgoing = filterOutgoingConnections(elements)
|
|
56
60
|
|
|
57
|
-
const toExclude =
|
|
61
|
+
const toExclude = pipe(
|
|
62
|
+
memory.connections,
|
|
63
|
+
filter(c => isIncoming(c) !== isOutgoing(c)),
|
|
64
|
+
applyPredicate(where),
|
|
65
|
+
)
|
|
58
66
|
stage.excludeConnections(toExclude)
|
|
59
67
|
return stage
|
|
60
68
|
},
|