@likec4/core 1.27.3 → 1.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builder/index.d.mts +6 -6
- package/dist/builder/index.mjs +23 -13
- package/dist/compute-view/index.d.mts +3 -3
- package/dist/compute-view/index.mjs +3 -3
- package/dist/compute-view/relationships-view/index.d.mts +3 -3
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +2 -2
- package/dist/model/index.d.mts +6 -6
- package/dist/model/index.mjs +1 -1
- package/dist/shared/{core.BpuZeqlX.d.mts → core.CZR9J1Qx.d.mts} +2 -2
- package/dist/shared/{core.Djro-kuQ.d.mts → core.CiFKryGW.d.mts} +7 -2
- package/dist/shared/{core.HKn0jlo_.d.mts → core.D2830qgg.d.mts} +1 -1
- package/dist/shared/{core.CFDwncxs.d.mts → core.DJvmfnEi.d.mts} +481 -186
- package/dist/shared/{core.BMep80lJ.mjs → core.DgfwjBtu.mjs} +198 -87
- package/dist/shared/core.SjLhMA7a.d.mts +62 -0
- package/dist/shared/{core.RjpTh3vE.mjs → core.w6BcP9z5.mjs} +263 -168
- package/dist/types/index.d.mts +4 -4
- package/dist/types/index.mjs +1 -1
- package/dist/utils/index.d.mts +2 -2
- package/package.json +7 -7
- package/src/builder/Builder.ts +1 -0
- package/src/builder/Builder.view-common.ts +10 -10
- package/src/builder/Builder.view-element.ts +26 -14
- package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +23 -8
- package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +9 -4
- package/src/compute-view/deployment-view/predicates/deploymentRefs-where.ts +18 -0
- package/src/compute-view/deployment-view/predicates/relation-direct.ts +6 -0
- package/src/compute-view/deployment-view/predicates/relation-in-out.ts +3 -0
- package/src/compute-view/deployment-view/predicates/relation-incoming.ts +3 -0
- package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +3 -0
- package/src/compute-view/deployment-view/predicates/utils.ts +10 -3
- package/src/compute-view/deployment-view/utils.ts +7 -4
- package/src/compute-view/element-view/__test__/fixture.ts +72 -65
- package/src/compute-view/element-view/_types.ts +13 -9
- package/src/compute-view/element-view/compute.ts +27 -27
- package/src/compute-view/element-view/memory/NodeGroup.ts +4 -3
- package/src/compute-view/element-view/memory/memory.ts +3 -2
- package/src/compute-view/element-view/memory/stage-include.ts +2 -2
- package/src/compute-view/element-view/predicates/_utils.ts +25 -24
- package/src/compute-view/element-view/predicates/element-expand.ts +7 -10
- package/src/compute-view/element-view/predicates/element-kind-tag.ts +5 -3
- package/src/compute-view/element-view/predicates/element-ref.ts +7 -19
- package/src/compute-view/element-view/predicates/relation-direct.ts +15 -13
- package/src/compute-view/element-view/predicates/relation-in-out.ts +5 -6
- package/src/compute-view/element-view/predicates/relation-in.ts +36 -32
- package/src/compute-view/element-view/predicates/relation-out.ts +37 -33
- package/src/compute-view/element-view/predicates/wildcard.ts +2 -2
- package/src/compute-view/utils/applyCustomElementProperties.ts +9 -4
- package/src/compute-view/utils/applyCustomRelationProperties.ts +10 -7
- package/src/compute-view/utils/elementExpressionToPredicate.ts +27 -26
- package/src/compute-view/utils/link-nodes-with-edges.ts +1 -1
- package/src/compute-view/utils/relationExpressionToPredicates.ts +10 -17
- package/src/compute-view/utils/uniqueTags.ts +3 -3
- package/src/index.ts +0 -2
- package/src/model/ElementModel.ts +25 -6
- package/src/model/LikeC4Model.ts +47 -6
- package/src/model/RelationModel.ts +4 -2
- package/src/model/view/LikeC4ViewModel.ts +3 -2
- package/src/types/_common.ts +0 -4
- package/src/types/deployments.ts +3 -2
- package/src/types/element.ts +2 -10
- package/src/types/expression-v2-model.ts +314 -0
- package/src/types/expression-v2.ts +238 -30
- package/src/types/index.ts +15 -46
- package/src/types/model-data.ts +4 -1
- package/src/types/relation.ts +2 -1
- package/src/types/scalars.ts +39 -0
- package/src/types/view-changes.ts +2 -1
- package/src/types/view.ts +7 -8
- package/dist/shared/core.30yYKXcZ.d.mts +0 -186
- package/src/types/expression.ts +0 -207
package/dist/types/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { X as XYPoint, N as NonEmptyArray, P as Point,
|
|
2
|
-
export { A as AsFqn,
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
1
|
+
import { X as XYPoint, N as NonEmptyArray, P as Point, F as Fqn } from '../shared/core.SjLhMA7a.mjs';
|
|
2
|
+
export { A as AsFqn, C as CustomColor, E as ExclusiveUnion, G as GlobalFqn, d as IconUrl, I as IteratorLike, K as KeysOf, b as NTuple, a as NonEmptyReadonlyArray, c as Predicate, e as ProjectId, T as Tag, i as isGlobalFqn, s as splitGlobalFqn } from '../shared/core.SjLhMA7a.mjs';
|
|
3
|
+
import { bk as ViewId, aW as BBox, p as BorderStyle, t as ElementShape, ay as ThemeColor, bl as ViewManualLayout, aT as AutoLayoutDirection } from '../shared/core.DJvmfnEi.mjs';
|
|
4
|
+
export { ag as AbstractRelation, a1 as AllNever, a2 as AndOperator, O as AnyParsedLikeC4ModelData, aU as BasicElementView, aV as BasicView, B as BorderStyles, ap as Color, aq as ColorLiteral, aX as ComputedDeploymentView, aY as ComputedDynamicView, aZ as ComputedEdge, a_ as ComputedElementView, C as ComputedLikeC4ModelData, az as ComputedNode, a as ComputedView, a$ as CustomColorDefinitions, ad as DefaultArrowType, j as DefaultElementShape, ae as DefaultLineStyle, k as DefaultPaddingSize, af as DefaultRelationshipColor, l as DefaultShapeSize, m as DefaultTextSize, n as DefaultThemeColor, c as DeployedInstance, D as DeploymentElement, d as DeploymentElementStyle, e 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, b6 as DynamicView, b7 as DynamicViewIncludeRule, b8 as DynamicViewParallelSteps, b9 as DynamicViewRule, ba as DynamicViewStep, bb as DynamicViewStepOrParallel, bc as EdgeId, q as Element, E as ElementKind, r as ElementKindSpecification, s as ElementKindSpecificationStyle, bw as ElementNotation, o as ElementShapes, u as ElementStyle, as as ElementThemeColorValues, ar as ElementThemeColors, bd as ElementView, a3 as EqualOperator, y as ExpressionV2, be as ExtendsElementView, a4 as Filterable, F as FqnExpr, z as FqnRef, Q as GenericLikeC4ModelData, G as GlobalDynamicPredicates, A as GlobalPredicateId, I as GlobalPredicates, J as GlobalStyleID, K as GlobalStyles, H as HexColorLiteral, a5 as KindEqual, S as LayoutedLikeC4ModelData, U as LikeC4ModelDump, b as LikeC4Theme, L as LikeC4View, v as Link, N as ModelGlobals, M as ModelLayer, ah as ModelRelation, bf as NodeId, a6 as NotOperator, a7 as OperatorPredicate, a8 as OrOperator, V as ParsedLikeC4ModelData, a9 as Participant, aa as ParticipantOperator, P as PredicateSelector, R as RelationExpr, ai as RelationId, aj as RelationshipArrowType, ak as RelationshipKind, al as RelationshipKindSpecification, am as RelationshipLineType, au as RelationshipThemeColorValues, at as RelationshipThemeColors, bg as ScopedElementView, av as ShapeSize, aw as SpacingSize, bh as StepEdgeId, bi as StepEdgeIdLiteral, ab as TagEqual, w as TagSpec, ax as TextSize, T as ThemeColorValues, ao as ThemeColors, x as TypedElement, 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, ac as WhereOperator, aB as extractStep, aC as getBBoxCenter, aD as getParallelStepsPrefix, W as isAndOperator, aE as isAutoLayoutDirection, aF as isDeploymentView, aG as isDynamicView, aH as isDynamicViewParallelSteps, aI as isElementView, aJ as isExtendsElementView, X as isKindEqual, Y as isNotOperator, Z as isOrOperator, _ as isParticipantOperator, aK as isScopedElementView, aL as isStepEdgeId, $ as isTagEqual, an as isThemeColor, aM as isViewRuleAutoLayout, aN as isViewRuleGlobalPredicateRef, aO as isViewRuleGlobalStyle, aP as isViewRuleGroup, aQ as isViewRulePredicate, aR as isViewRuleStyle, aS as stepEdgeId, a0 as whereOperatorAsPredicate } from '../shared/core.DJvmfnEi.mjs';
|
|
5
5
|
import 'type-fest';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/types/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AsFqn, B as BorderStyles,
|
|
1
|
+
export { A as AsFqn, B as BorderStyles, C as ComputedNode, z as ComputedView, v as DefaultArrowType, D as DefaultElementShape, x as DefaultLineStyle, f as DefaultPaddingSize, y as DefaultRelationshipColor, g as DefaultShapeSize, h as DefaultTextSize, b as DefaultThemeColor, c as DeploymentElement, H as DiagramNode, E as ElementKind, j as ElementShapes, k as ExpressionV2, F as FqnExpr, l as FqnRef, G as GlobalFqn, M as ModelLayer, R as RelationExpr, I as extractStep, J as getBBoxCenter, K as getParallelStepsPrefix, m as isAndOperator, L as isAutoLayoutDirection, N as isDeploymentView, O as isDynamicView, P as isDynamicViewParallelSteps, a as isElementView, i as isExtendsElementView, e as isGlobalFqn, p as isKindEqual, q as isNotOperator, r as isOrOperator, t as isParticipantOperator, d as isScopedElementView, Q as isStepEdgeId, u as isTagEqual, S as isViewRuleAutoLayout, T as isViewRuleGlobalPredicateRef, U as isViewRuleGlobalStyle, V as isViewRuleGroup, W as isViewRulePredicate, X as isViewRuleStyle, s as splitGlobalFqn, Y as stepEdgeId, w as whereOperatorAsPredicate } from '../shared/core.DgfwjBtu.mjs';
|
|
2
2
|
|
|
3
3
|
const ThemeColors = [
|
|
4
4
|
"amber",
|
package/dist/utils/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { I as IterableContainer, R as ReorderedArray, a as ancestorsFqn, c as commonAncestor, b as compareByFqnHierarchically, d as compareFqnHierarchically, h as hierarchyDistance, e as hierarchyLevel, i as isAncestor, f as isDescendantOf, g as isSameHierarchy, n as nameFromFqn, p as parentFqn, s as sortByFqnHierarchically, j as sortNaturalByFqn, k as sortParentsFirst } from '../shared/core.
|
|
2
|
-
import { N as NonEmptyArray,
|
|
1
|
+
export { I as IterableContainer, R as ReorderedArray, a as ancestorsFqn, c as commonAncestor, b as compareByFqnHierarchically, d as compareFqnHierarchically, h as hierarchyDistance, e as hierarchyLevel, i as isAncestor, f as isDescendantOf, g as isSameHierarchy, n as nameFromFqn, p as parentFqn, s as sortByFqnHierarchically, j as sortNaturalByFqn, k as sortParentsFirst } from '../shared/core.D2830qgg.mjs';
|
|
2
|
+
import { N as NonEmptyArray, I as IteratorLike } from '../shared/core.SjLhMA7a.mjs';
|
|
3
3
|
import { IsNumericLiteral } from 'type-fest';
|
|
4
4
|
|
|
5
5
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://likec4.dev",
|
|
6
6
|
"author": "Denis Davydkov <denis@davydkov.com>",
|
|
@@ -84,11 +84,11 @@
|
|
|
84
84
|
"access": "public"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"type-fest": "^4.
|
|
87
|
+
"type-fest": "^4.39.1"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
90
|
"@dagrejs/dagre": "1.1.4",
|
|
91
|
-
"@mantine/colors-generator": "7.17.
|
|
91
|
+
"@mantine/colors-generator": "7.17.4",
|
|
92
92
|
"@types/natural-compare-lite": "^1.4.2",
|
|
93
93
|
"@types/object-hash": "^3.0.6",
|
|
94
94
|
"chroma-js": "^3.1.2",
|
|
@@ -102,11 +102,11 @@
|
|
|
102
102
|
"object-hash": "^3.0.0",
|
|
103
103
|
"obliterator": "^2.0.5",
|
|
104
104
|
"remeda": "^2.21.2",
|
|
105
|
-
"turbo": "^2.
|
|
106
|
-
"typescript": "^5.8.
|
|
105
|
+
"turbo": "^2.5.0",
|
|
106
|
+
"typescript": "^5.8.3",
|
|
107
107
|
"unbuild": "^3.5.0",
|
|
108
|
-
"vitest": "^3.
|
|
109
|
-
"@likec4/tsconfig": "1.
|
|
108
|
+
"vitest": "^3.1.1",
|
|
109
|
+
"@likec4/tsconfig": "1.28.1"
|
|
110
110
|
},
|
|
111
111
|
"scripts": {
|
|
112
112
|
"typecheck": "tsc --noEmit",
|
package/src/builder/Builder.ts
CHANGED
|
@@ -2,15 +2,12 @@ import { isArray, isString, map } from 'remeda'
|
|
|
2
2
|
import type { LiteralUnion, Simplify } from 'type-fest'
|
|
3
3
|
import {
|
|
4
4
|
type AutoLayoutDirection,
|
|
5
|
-
type
|
|
6
|
-
type CustomRelationExpr,
|
|
7
|
-
type ElementExpression as C4ElementExpression,
|
|
8
|
-
type Expression as C4Expression,
|
|
5
|
+
type ExpressionV2,
|
|
9
6
|
type NonEmptyArray,
|
|
10
7
|
type ViewRuleStyle,
|
|
11
8
|
type WhereOperator,
|
|
12
|
-
isElementPredicateExpr,
|
|
13
9
|
} from '../types'
|
|
10
|
+
import { ModelLayer } from '../types/expression-v2-model'
|
|
14
11
|
import type { KindEqual, Participant, TagEqual } from '../types/operators'
|
|
15
12
|
import type { AnyTypes, Types } from './_types'
|
|
16
13
|
|
|
@@ -87,7 +84,10 @@ export namespace ViewPredicate {
|
|
|
87
84
|
export type Custom<Types extends AnyTypes> = {
|
|
88
85
|
where?: ViewPredicate.WhereOperator<Types>
|
|
89
86
|
with?: Simplify<
|
|
90
|
-
Omit<
|
|
87
|
+
Omit<
|
|
88
|
+
ModelLayer.FqnExpr.Custom['custom'] & ModelLayer.RelationExpr.Custom['customRelation'],
|
|
89
|
+
'expr' | 'relation' | 'navigateTo'
|
|
90
|
+
> & {
|
|
91
91
|
navigateTo?: Types['ViewId']
|
|
92
92
|
}
|
|
93
93
|
>
|
|
@@ -181,7 +181,7 @@ function $include<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(
|
|
|
181
181
|
|
|
182
182
|
const custom = args[1].with
|
|
183
183
|
if (custom) {
|
|
184
|
-
const isElement =
|
|
184
|
+
const isElement = ModelLayer.FqnExpr.is(expr)
|
|
185
185
|
if (isElement) {
|
|
186
186
|
expr = {
|
|
187
187
|
custom: {
|
|
@@ -193,7 +193,7 @@ function $include<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(
|
|
|
193
193
|
expr = {
|
|
194
194
|
customRelation: {
|
|
195
195
|
...custom,
|
|
196
|
-
|
|
196
|
+
expr: expr as any,
|
|
197
197
|
},
|
|
198
198
|
}
|
|
199
199
|
}
|
|
@@ -212,7 +212,7 @@ function $exclude<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(
|
|
|
212
212
|
| [B['TypedExpr'], ViewPredicate.Custom<B['Types']>]
|
|
213
213
|
): (b: B) => B {
|
|
214
214
|
return (b) => {
|
|
215
|
-
let expr = b.$expr(args[0]) as
|
|
215
|
+
let expr = b.$expr(args[0]) as ExpressionV2
|
|
216
216
|
if (args.length === 2 && args[1].where) {
|
|
217
217
|
const condition = parseWhere(args[1].where)
|
|
218
218
|
expr = {
|
|
@@ -233,7 +233,7 @@ function $style<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(
|
|
|
233
233
|
): (b: B) => B {
|
|
234
234
|
return (b) =>
|
|
235
235
|
b.style({
|
|
236
|
-
targets: (isArray(element) ? element : [element]).map(e => b.$expr(e as any) as
|
|
236
|
+
targets: (isArray(element) ? element : [element]).map(e => b.$expr(e as any) as ModelLayer.FqnExpr),
|
|
237
237
|
...(notation ? { notation } : {}),
|
|
238
238
|
style: {
|
|
239
239
|
...style,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { isString } from 'remeda'
|
|
2
2
|
import type { IsStringLiteral } from 'type-fest/source/is-literal'
|
|
3
|
-
import { type
|
|
3
|
+
import { type ExpressionV2 } from '../types/expression-v2'
|
|
4
|
+
import { type Fqn } from '../types/scalars'
|
|
4
5
|
import type { AnyTypes, Invalid, Types } from './_types'
|
|
5
6
|
import type { LikeC4ViewBuilder, ViewPredicate } from './Builder.view-common'
|
|
6
7
|
import type { ViewsBuilder } from './Builder.views'
|
|
7
8
|
|
|
8
|
-
export interface ElementViewBuilder<T extends AnyTypes> extends LikeC4ViewBuilder<T, T['Fqn'],
|
|
9
|
+
export interface ElementViewBuilder<T extends AnyTypes> extends LikeC4ViewBuilder<T, T['Fqn'], Types.ToExpression<T>> {
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export type ElementViewRulesBuilder<T extends AnyTypes> = (b: ElementViewBuilder<T>) => ElementViewBuilder<T>
|
|
@@ -125,13 +126,15 @@ export interface TypedAddViewOfHelper<A extends AnyTypes> {
|
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
// To hook types
|
|
128
|
-
const asTypedExpr = (expr:
|
|
129
|
-
return expr as
|
|
129
|
+
const asTypedExpr = (expr: ExpressionV2): ExpressionV2 => {
|
|
130
|
+
return expr as ExpressionV2
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
export function $expr<Types extends AnyTypes>(
|
|
133
|
+
export function $expr<Types extends AnyTypes>(
|
|
134
|
+
expr: ViewPredicate.Expression<Types> | ExpressionV2,
|
|
135
|
+
): ExpressionV2 {
|
|
133
136
|
if (!isString(expr)) {
|
|
134
|
-
return expr as
|
|
137
|
+
return expr as ExpressionV2
|
|
135
138
|
}
|
|
136
139
|
if (expr === '*') {
|
|
137
140
|
return asTypedExpr({ wildcard: true })
|
|
@@ -168,22 +171,31 @@ export function $expr<Types extends AnyTypes>(expr: ViewPredicate.Expression<Typ
|
|
|
168
171
|
}
|
|
169
172
|
if (expr.endsWith('._')) {
|
|
170
173
|
return asTypedExpr({
|
|
171
|
-
|
|
174
|
+
ref: {
|
|
175
|
+
model: expr.replace('._', '') as Fqn,
|
|
176
|
+
},
|
|
177
|
+
selector: 'expanded',
|
|
172
178
|
})
|
|
173
179
|
}
|
|
174
|
-
if (expr.endsWith('
|
|
180
|
+
if (expr.endsWith('.**')) {
|
|
175
181
|
return asTypedExpr({
|
|
176
|
-
|
|
177
|
-
|
|
182
|
+
ref: {
|
|
183
|
+
model: expr.replace('.**', '') as Fqn,
|
|
184
|
+
},
|
|
185
|
+
selector: 'descendants',
|
|
178
186
|
})
|
|
179
187
|
}
|
|
180
|
-
if (expr.endsWith('
|
|
188
|
+
if (expr.endsWith('.*')) {
|
|
181
189
|
return asTypedExpr({
|
|
182
|
-
|
|
183
|
-
|
|
190
|
+
ref: {
|
|
191
|
+
model: expr.replace('.*', '') as Fqn,
|
|
192
|
+
},
|
|
193
|
+
selector: 'children',
|
|
184
194
|
})
|
|
185
195
|
}
|
|
186
196
|
return asTypedExpr({
|
|
187
|
-
|
|
197
|
+
ref: {
|
|
198
|
+
model: expr as any as Fqn,
|
|
199
|
+
},
|
|
188
200
|
})
|
|
189
201
|
}
|
|
@@ -99,6 +99,7 @@ exports[`Builder (style1) > should build nested elements and relTo 1`] = `
|
|
|
99
99
|
"predicates": {},
|
|
100
100
|
"styles": {},
|
|
101
101
|
},
|
|
102
|
+
"imports": {},
|
|
102
103
|
"relations": {
|
|
103
104
|
"rel1": {
|
|
104
105
|
"id": "rel1",
|
|
@@ -192,6 +193,7 @@ exports[`Builder (style1) > should build view 1`] = `
|
|
|
192
193
|
"predicates": {},
|
|
193
194
|
"styles": {},
|
|
194
195
|
},
|
|
196
|
+
"imports": {},
|
|
195
197
|
"relations": {},
|
|
196
198
|
"specification": {
|
|
197
199
|
"deployments": {},
|
|
@@ -237,8 +239,10 @@ exports[`Builder (style1) > should build view 1`] = `
|
|
|
237
239
|
{
|
|
238
240
|
"include": [
|
|
239
241
|
{
|
|
240
|
-
"
|
|
241
|
-
|
|
242
|
+
"ref": {
|
|
243
|
+
"model": "c2",
|
|
244
|
+
},
|
|
245
|
+
"selector": "children",
|
|
242
246
|
},
|
|
243
247
|
],
|
|
244
248
|
},
|
|
@@ -256,7 +260,10 @@ exports[`Builder (style1) > should build view 1`] = `
|
|
|
256
260
|
{
|
|
257
261
|
"include": [
|
|
258
262
|
{
|
|
259
|
-
"
|
|
263
|
+
"ref": {
|
|
264
|
+
"model": "c3",
|
|
265
|
+
},
|
|
266
|
+
"selector": "expanded",
|
|
260
267
|
},
|
|
261
268
|
],
|
|
262
269
|
},
|
|
@@ -329,6 +336,7 @@ exports[`Builder (style1) > should build viewOf 1`] = `
|
|
|
329
336
|
"predicates": {},
|
|
330
337
|
"styles": {},
|
|
331
338
|
},
|
|
339
|
+
"imports": {},
|
|
332
340
|
"relations": {},
|
|
333
341
|
"specification": {
|
|
334
342
|
"deployments": {},
|
|
@@ -357,8 +365,10 @@ exports[`Builder (style1) > should build viewOf 1`] = `
|
|
|
357
365
|
"include": [
|
|
358
366
|
{
|
|
359
367
|
"inout": {
|
|
360
|
-
"
|
|
361
|
-
|
|
368
|
+
"ref": {
|
|
369
|
+
"model": "c2.c3",
|
|
370
|
+
},
|
|
371
|
+
"selector": "children",
|
|
362
372
|
},
|
|
363
373
|
},
|
|
364
374
|
],
|
|
@@ -367,11 +377,16 @@ exports[`Builder (style1) > should build viewOf 1`] = `
|
|
|
367
377
|
"exclude": [
|
|
368
378
|
{
|
|
369
379
|
"source": {
|
|
370
|
-
"
|
|
380
|
+
"ref": {
|
|
381
|
+
"model": "c1",
|
|
382
|
+
},
|
|
383
|
+
"selector": "expanded",
|
|
371
384
|
},
|
|
372
385
|
"target": {
|
|
373
|
-
"
|
|
374
|
-
|
|
386
|
+
"ref": {
|
|
387
|
+
"model": "c2.c3",
|
|
388
|
+
},
|
|
389
|
+
"selector": "children",
|
|
375
390
|
},
|
|
376
391
|
},
|
|
377
392
|
],
|
|
@@ -105,6 +105,7 @@ exports[`Builder (style 2) > should build 1`] = `
|
|
|
105
105
|
"predicates": {},
|
|
106
106
|
"styles": {},
|
|
107
107
|
},
|
|
108
|
+
"imports": {},
|
|
108
109
|
"relations": {},
|
|
109
110
|
"specification": {
|
|
110
111
|
"deployments": {
|
|
@@ -143,8 +144,10 @@ exports[`Builder (style 2) > should build 1`] = `
|
|
|
143
144
|
"wildcard": true,
|
|
144
145
|
},
|
|
145
146
|
"target": {
|
|
146
|
-
"
|
|
147
|
-
|
|
147
|
+
"ref": {
|
|
148
|
+
"model": "cloud",
|
|
149
|
+
},
|
|
150
|
+
"selector": "descendants",
|
|
148
151
|
},
|
|
149
152
|
},
|
|
150
153
|
],
|
|
@@ -185,8 +188,10 @@ exports[`Builder (style 2) > should build 1`] = `
|
|
|
185
188
|
{
|
|
186
189
|
"include": [
|
|
187
190
|
{
|
|
188
|
-
"
|
|
189
|
-
|
|
191
|
+
"ref": {
|
|
192
|
+
"model": "cloud",
|
|
193
|
+
},
|
|
194
|
+
"selector": "children",
|
|
190
195
|
},
|
|
191
196
|
],
|
|
192
197
|
},
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type FqnExpr, type RelationExpr, whereOperatorAsPredicate } from '../../../types'
|
|
2
|
+
import type { PredicateExecutor } from '../_types'
|
|
3
|
+
import type { StageExclude, StageInclude } from '../memory'
|
|
4
|
+
import { predicateToPatch } from './utils'
|
|
5
|
+
|
|
6
|
+
// relation matches the condition
|
|
7
|
+
export const WhereDeploymentRefPredicate: PredicateExecutor<FqnExpr.Where> = {
|
|
8
|
+
include: ({ expr, model, memory, stage }) => {
|
|
9
|
+
const where = whereOperatorAsPredicate(expr.where.condition)
|
|
10
|
+
|
|
11
|
+
return predicateToPatch('include', { expr: expr.where.expr, model, stage, memory, where }) as StageInclude
|
|
12
|
+
},
|
|
13
|
+
exclude: ({ expr, model, memory, stage }) => {
|
|
14
|
+
const where = whereOperatorAsPredicate(expr.where.condition)
|
|
15
|
+
|
|
16
|
+
return predicateToPatch('exclude', { expr: expr.where.expr, model, stage, memory, where }) as StageExclude
|
|
17
|
+
},
|
|
18
|
+
}
|
|
@@ -40,6 +40,12 @@ const resolveWildcard = (model: LikeC4DeploymentModel, nonWildcard: FqnExpr.Depl
|
|
|
40
40
|
|
|
41
41
|
export const DirectRelationPredicate: PredicateExecutor<RelationExpr.Direct> = {
|
|
42
42
|
include: ({ expr: { source, target, isBidirectional = false }, model, stage, where }) => {
|
|
43
|
+
if (FqnExpr.isElementTagExpr(source) || FqnExpr.isElementKindExpr(source)) {
|
|
44
|
+
throw new Error('element kind and tag expressions are not supported in include')
|
|
45
|
+
}
|
|
46
|
+
if (FqnExpr.isElementTagExpr(target) || FqnExpr.isElementKindExpr(target)) {
|
|
47
|
+
throw new Error('element kind and tag expressions are not supported in include')
|
|
48
|
+
}
|
|
43
49
|
invariant(!FqnExpr.isModelRef(source), 'Invalid source model ref in direct relation')
|
|
44
50
|
invariant(!FqnExpr.isModelRef(target), 'Invalid target model ref in direct relation')
|
|
45
51
|
const sourceIsWildcard = FqnExpr.isWildcard(source)
|
|
@@ -36,6 +36,9 @@ export const InOutRelationPredicate: PredicateExecutor<RelationExpr.InOut> = {
|
|
|
36
36
|
return stage
|
|
37
37
|
},
|
|
38
38
|
exclude: ({ expr, model, memory, stage, where }) => {
|
|
39
|
+
if (FqnExpr.isElementTagExpr(expr.inout) || FqnExpr.isElementKindExpr(expr.inout)) {
|
|
40
|
+
throw new Error('element kind and tag expressions are not supported in exclude')
|
|
41
|
+
}
|
|
39
42
|
// Exclude all connections that have model relationshps with the elements
|
|
40
43
|
if (FqnExpr.isModelRef(expr.inout)) {
|
|
41
44
|
const elements = resolveModelElements(model, expr.inout)
|
|
@@ -38,6 +38,9 @@ export const IncomingRelationPredicate: PredicateExecutor<RelationExpr.Incoming>
|
|
|
38
38
|
return stage
|
|
39
39
|
},
|
|
40
40
|
exclude: ({ expr, model, memory, stage, where }) => {
|
|
41
|
+
if (FqnExpr.isElementTagExpr(expr.incoming) || FqnExpr.isElementKindExpr(expr.incoming)) {
|
|
42
|
+
throw new Error('element kind and tag expressions are not supported in exclude')
|
|
43
|
+
}
|
|
41
44
|
// Exclude all connections that have model relationshps with the elements
|
|
42
45
|
if (FqnExpr.isModelRef(expr.incoming)) {
|
|
43
46
|
const excludedRelations = resolveAllImcomingRelations(model, expr.incoming)
|
|
@@ -39,6 +39,9 @@ export const OutgoingRelationPredicate: PredicateExecutor<RelationExpr.Outgoing>
|
|
|
39
39
|
return stage
|
|
40
40
|
},
|
|
41
41
|
exclude: ({ expr, model, memory, stage, where }) => {
|
|
42
|
+
if (FqnExpr.isElementTagExpr(expr.outgoing) || FqnExpr.isElementKindExpr(expr.outgoing)) {
|
|
43
|
+
throw new Error('element kind and tag expressions are not supported in exclude')
|
|
44
|
+
}
|
|
42
45
|
// Exclude all connections that have model relationshps with the elements
|
|
43
46
|
if (FqnExpr.isModelRef(expr.outgoing)) {
|
|
44
47
|
const excludedRelations = resolveAllOutgoingRelations(model, expr.outgoing)
|
|
@@ -15,6 +15,7 @@ import { hasIntersection, intersection } from '../../../utils/set'
|
|
|
15
15
|
import type { ExcludePredicateCtx, PredicateCtx } from '../_types'
|
|
16
16
|
import type { StageExclude, StageInclude } from '../memory'
|
|
17
17
|
import { DeploymentRefPredicate } from './deploymentRefs'
|
|
18
|
+
import { WhereDeploymentRefPredicate } from './deploymentRefs-where'
|
|
18
19
|
import { DirectRelationPredicate } from './relation-direct'
|
|
19
20
|
import { InOutRelationPredicate } from './relation-in-out'
|
|
20
21
|
import { IncomingRelationPredicate } from './relation-incoming'
|
|
@@ -30,14 +31,22 @@ export function predicateToPatch(
|
|
|
30
31
|
{ expr, where, ...ctx }: PredicateCtx,
|
|
31
32
|
): StageExclude | StageInclude | undefined {
|
|
32
33
|
switch (true) {
|
|
34
|
+
case FqnExpr.isElementTagExpr(expr):
|
|
35
|
+
case FqnExpr.isElementKindExpr(expr):
|
|
36
|
+
throw new Error('element kind and tag expressions are not supported in deployment view rules')
|
|
37
|
+
case RelationExpr.isCustom(expr):
|
|
38
|
+
case FqnExpr.isCustom(expr):
|
|
33
39
|
case FqnExpr.isModelRef(expr):
|
|
34
40
|
// Ignore model refs in deployment view
|
|
35
41
|
return undefined
|
|
42
|
+
case FqnExpr.isWhere(expr):
|
|
43
|
+
return WhereDeploymentRefPredicate[op]({ ...ctx, expr, where } as any)
|
|
44
|
+
case RelationExpr.isWhere(expr):
|
|
45
|
+
return WhereRelationPredicate[op]({ ...ctx, expr, where } as any)
|
|
36
46
|
case FqnExpr.isDeploymentRef(expr):
|
|
37
47
|
return DeploymentRefPredicate[op]({ ...ctx, expr, where } as any)
|
|
38
48
|
case FqnExpr.isWildcard(expr):
|
|
39
49
|
return WildcardPredicate[op]({ ...ctx, expr, where } as any)
|
|
40
|
-
|
|
41
50
|
case RelationExpr.isDirect(expr):
|
|
42
51
|
return DirectRelationPredicate[op]({ ...ctx, expr, where } as any)
|
|
43
52
|
case RelationExpr.isInOut(expr):
|
|
@@ -46,8 +55,6 @@ export function predicateToPatch(
|
|
|
46
55
|
return OutgoingRelationPredicate[op]({ ...ctx, expr, where } as any)
|
|
47
56
|
case RelationExpr.isIncoming(expr):
|
|
48
57
|
return IncomingRelationPredicate[op]({ ...ctx, expr, where } as any)
|
|
49
|
-
case RelationExpr.isWhere(expr):
|
|
50
|
-
return WhereRelationPredicate[op]({ ...ctx, expr, where } as any)
|
|
51
58
|
default:
|
|
52
59
|
nonexhaustive(expr)
|
|
53
60
|
}
|
|
@@ -7,18 +7,18 @@ import type { AnyAux } from '../../model/types'
|
|
|
7
7
|
import {
|
|
8
8
|
type ComputedEdge,
|
|
9
9
|
type ComputedNode,
|
|
10
|
-
DefaultArrowType,
|
|
11
10
|
type DeploymentNodeKind,
|
|
12
11
|
type DeploymentViewRule,
|
|
13
12
|
type Fqn,
|
|
14
|
-
FqnExpr,
|
|
15
|
-
isViewRuleStyle,
|
|
16
13
|
type NonEmptyArray,
|
|
17
14
|
type Tag,
|
|
15
|
+
DefaultArrowType,
|
|
16
|
+
FqnExpr,
|
|
17
|
+
isViewRuleStyle,
|
|
18
18
|
} from '../../types'
|
|
19
19
|
import { nameFromFqn, parentFqn } from '../../utils'
|
|
20
20
|
import { applyViewRuleStyle } from '../utils/applyViewRuleStyles'
|
|
21
|
-
import {
|
|
21
|
+
import { type ComputedNodeSource, buildComputedNodes } from '../utils/buildComputedNodes'
|
|
22
22
|
import { mergePropsFromRelationships } from '../utils/merge-props-from-relationships'
|
|
23
23
|
import { uniqueTags } from '../utils/uniqueTags'
|
|
24
24
|
import type { Elem, Memory } from './_types'
|
|
@@ -67,6 +67,9 @@ export function deploymentExpressionToPredicate<T extends { id: string; modelRef
|
|
|
67
67
|
if (FqnExpr.isWildcard(target)) {
|
|
68
68
|
return () => true
|
|
69
69
|
}
|
|
70
|
+
if (FqnExpr.isElementTagExpr(target) || FqnExpr.isElementKindExpr(target)) {
|
|
71
|
+
throw new Error('element kind and tag expressions are not supported in deployment view rules')
|
|
72
|
+
}
|
|
70
73
|
if (FqnExpr.isDeploymentRef(target)) {
|
|
71
74
|
const fqn = target.ref.deployment
|
|
72
75
|
if (target.selector === 'expanded') {
|