@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.
Files changed (71) hide show
  1. package/dist/builder/index.d.mts +6 -6
  2. package/dist/builder/index.mjs +23 -13
  3. package/dist/compute-view/index.d.mts +3 -3
  4. package/dist/compute-view/index.mjs +3 -3
  5. package/dist/compute-view/relationships-view/index.d.mts +3 -3
  6. package/dist/index.d.mts +6 -6
  7. package/dist/index.mjs +2 -2
  8. package/dist/model/index.d.mts +6 -6
  9. package/dist/model/index.mjs +1 -1
  10. package/dist/shared/{core.BpuZeqlX.d.mts → core.CZR9J1Qx.d.mts} +2 -2
  11. package/dist/shared/{core.Djro-kuQ.d.mts → core.CiFKryGW.d.mts} +7 -2
  12. package/dist/shared/{core.HKn0jlo_.d.mts → core.D2830qgg.d.mts} +1 -1
  13. package/dist/shared/{core.CFDwncxs.d.mts → core.DJvmfnEi.d.mts} +481 -186
  14. package/dist/shared/{core.BMep80lJ.mjs → core.DgfwjBtu.mjs} +198 -87
  15. package/dist/shared/core.SjLhMA7a.d.mts +62 -0
  16. package/dist/shared/{core.RjpTh3vE.mjs → core.w6BcP9z5.mjs} +263 -168
  17. package/dist/types/index.d.mts +4 -4
  18. package/dist/types/index.mjs +1 -1
  19. package/dist/utils/index.d.mts +2 -2
  20. package/package.json +7 -7
  21. package/src/builder/Builder.ts +1 -0
  22. package/src/builder/Builder.view-common.ts +10 -10
  23. package/src/builder/Builder.view-element.ts +26 -14
  24. package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +23 -8
  25. package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +9 -4
  26. package/src/compute-view/deployment-view/predicates/deploymentRefs-where.ts +18 -0
  27. package/src/compute-view/deployment-view/predicates/relation-direct.ts +6 -0
  28. package/src/compute-view/deployment-view/predicates/relation-in-out.ts +3 -0
  29. package/src/compute-view/deployment-view/predicates/relation-incoming.ts +3 -0
  30. package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +3 -0
  31. package/src/compute-view/deployment-view/predicates/utils.ts +10 -3
  32. package/src/compute-view/deployment-view/utils.ts +7 -4
  33. package/src/compute-view/element-view/__test__/fixture.ts +72 -65
  34. package/src/compute-view/element-view/_types.ts +13 -9
  35. package/src/compute-view/element-view/compute.ts +27 -27
  36. package/src/compute-view/element-view/memory/NodeGroup.ts +4 -3
  37. package/src/compute-view/element-view/memory/memory.ts +3 -2
  38. package/src/compute-view/element-view/memory/stage-include.ts +2 -2
  39. package/src/compute-view/element-view/predicates/_utils.ts +25 -24
  40. package/src/compute-view/element-view/predicates/element-expand.ts +7 -10
  41. package/src/compute-view/element-view/predicates/element-kind-tag.ts +5 -3
  42. package/src/compute-view/element-view/predicates/element-ref.ts +7 -19
  43. package/src/compute-view/element-view/predicates/relation-direct.ts +15 -13
  44. package/src/compute-view/element-view/predicates/relation-in-out.ts +5 -6
  45. package/src/compute-view/element-view/predicates/relation-in.ts +36 -32
  46. package/src/compute-view/element-view/predicates/relation-out.ts +37 -33
  47. package/src/compute-view/element-view/predicates/wildcard.ts +2 -2
  48. package/src/compute-view/utils/applyCustomElementProperties.ts +9 -4
  49. package/src/compute-view/utils/applyCustomRelationProperties.ts +10 -7
  50. package/src/compute-view/utils/elementExpressionToPredicate.ts +27 -26
  51. package/src/compute-view/utils/link-nodes-with-edges.ts +1 -1
  52. package/src/compute-view/utils/relationExpressionToPredicates.ts +10 -17
  53. package/src/compute-view/utils/uniqueTags.ts +3 -3
  54. package/src/index.ts +0 -2
  55. package/src/model/ElementModel.ts +25 -6
  56. package/src/model/LikeC4Model.ts +47 -6
  57. package/src/model/RelationModel.ts +4 -2
  58. package/src/model/view/LikeC4ViewModel.ts +3 -2
  59. package/src/types/_common.ts +0 -4
  60. package/src/types/deployments.ts +3 -2
  61. package/src/types/element.ts +2 -10
  62. package/src/types/expression-v2-model.ts +314 -0
  63. package/src/types/expression-v2.ts +238 -30
  64. package/src/types/index.ts +15 -46
  65. package/src/types/model-data.ts +4 -1
  66. package/src/types/relation.ts +2 -1
  67. package/src/types/scalars.ts +39 -0
  68. package/src/types/view-changes.ts +2 -1
  69. package/src/types/view.ts +7 -8
  70. package/dist/shared/core.30yYKXcZ.d.mts +0 -186
  71. package/src/types/expression.ts +0 -207
@@ -1,7 +1,7 @@
1
- import { X as XYPoint, N as NonEmptyArray, P as Point, l as BorderStyle, p as ElementShape, Q as ThemeColor, F as Fqn } from '../shared/core.30yYKXcZ.mjs';
2
- export { A as AsFqn, B as BorderStyles, x as Color, y as ColorLiteral, C as CustomColor, D as DefaultElementShape, f as DefaultPaddingSize, g as DefaultShapeSize, h as DefaultTextSize, i as DefaultThemeColor, m as Element, j as ElementKind, n as ElementKindSpecification, o as ElementKindSpecificationStyle, k as ElementShapes, q as ElementStyle, G as ElementThemeColorValues, z as ElementThemeColors, E as ExclusiveUnion, H as HexColorLiteral, I as IconUrl, a as IteratorLike, K as KeysOf, L as LikeC4Theme, r as Link, c as NTuple, b as NonEmptyReadonlyArray, d as Predicate, e as ProjectId, J as RelationshipThemeColorValues, R as RelationshipThemeColors, S as ShapeSize, M as SpacingSize, s as Tag, t as TagSpec, O as TextSize, T as ThemeColorValues, w as ThemeColors, u as TypedElement, v as isThemeColor } from '../shared/core.30yYKXcZ.mjs';
3
- import { bo as ViewId, a_ as BBox, bp as ViewManualLayout, aX as AutoLayoutDirection } from '../shared/core.CFDwncxs.mjs';
4
- export { aw as AbstractRelation, ah as AllNever, ai as AndOperator, a5 as AnyParsedLikeC4ModelData, aY as BasicElementView, aZ as BasicView, a$ as ComputedDeploymentView, b0 as ComputedDynamicView, b1 as ComputedEdge, b2 as ComputedElementView, C as ComputedLikeC4ModelData, aD as ComputedNode, a as ComputedView, b3 as CustomColorDefinitions, A as CustomElementExpr, B as CustomRelationExpr, at as DefaultArrowType, au as DefaultLineStyle, av 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, b4 as DeploymentView, b5 as DeploymentViewRule, b6 as DeploymentViewRulePredicate, b7 as DeploymentViewRuleStyle, b8 as DiagramEdge, aE as DiagramNode, b9 as DiagramView, E as DirectRelationExpr, ba as DynamicView, bb as DynamicViewIncludeRule, bc as DynamicViewParallelSteps, bd as DynamicViewRule, be as DynamicViewStep, bf as DynamicViewStepOrParallel, bg as EdgeId, F as ElementExpression, G as ElementKindExpr, bA as ElementNotation, H as ElementPredicateExpression, I as ElementRefExpr, J as ElementTagExpr, bh as ElementView, K as ElementWhereExpr, aj as EqualOperator, M as ExpandedElementExpr, N as Expression, X as ExpressionV2, bi as ExtendsElementView, ak as Filterable, Y as FqnExpr, Z as FqnRef, a6 as GenericLikeC4ModelData, $ as GlobalDynamicPredicates, a0 as GlobalPredicateId, a1 as GlobalPredicates, a2 as GlobalStyleID, a3 as GlobalStyles, Q as InOutExpr, O as IncomingExpr, al as KindEqual, a7 as LayoutedLikeC4ModelData, a8 as LikeC4ModelDump, L as LikeC4View, a4 as ModelGlobals, ax as ModelRelation, bj as NodeId, R as NonWilcard, am as NotOperator, an as OperatorPredicate, ao as OrOperator, S as OutgoingExpr, a9 as ParsedLikeC4ModelData, ap as Participant, aq as ParticipantOperator, P as PredicateSelector, _ as RelationExpr, T as RelationExpression, ay as RelationId, U as RelationPredicateExpression, V as RelationWhereExpr, az as RelationshipArrowType, aA as RelationshipKind, aB as RelationshipKindSpecification, aC as RelationshipLineType, bk as ScopedElementView, bl as StepEdgeId, bm as StepEdgeIdLiteral, ar as TagEqual, bn as ViewAutoLayout, bq as ViewRule, br as ViewRuleAutoLayout, bs as ViewRuleGlobalPredicateRef, bt as ViewRuleGlobalStyle, bu as ViewRuleGroup, bv as ViewRulePredicate, bw as ViewRuleStyle, bx as ViewRuleStyleOrGlobalRef, by as ViewWithHash, bz as ViewWithNotation, as as WhereOperator, W as WildcardExpr, aF as extractStep, aG as getBBoxCenter, aH as getParallelStepsPrefix, aa as isAndOperator, aI as isAutoLayoutDirection, j as isCustomElement, k as isCustomRelationExpr, aJ as isDeploymentView, aK as isDynamicView, aL as isDynamicViewParallelSteps, l as isElement, m as isElementKindExpr, n as isElementPredicateExpr, o as isElementRef, p as isElementTagExpr, aM as isElementView, q as isElementWhere, r as isExpandedElementExpr, aN as isExtendsElementView, t as isInOut, s as isIncoming, ab as isKindEqual, ac as isNotOperator, ad as isOrOperator, u as isOutgoing, ae as isParticipantOperator, v as isRelation, w as isRelationExpression, x as isRelationPredicateExpr, y as isRelationWhere, aO as isScopedElementView, aP as isStepEdgeId, af as isTagEqual, aQ as isViewRuleAutoLayout, aR as isViewRuleGlobalPredicateRef, aS as isViewRuleGlobalStyle, aT as isViewRuleGroup, aU as isViewRulePredicate, aV as isViewRuleStyle, z as isWildcard, aW as stepEdgeId, ag as whereOperatorAsPredicate } from '../shared/core.CFDwncxs.mjs';
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
  /**
@@ -1,4 +1,4 @@
1
- export { A as AsFqn, B as BorderStyles, V as ComputedNode, W as ComputedView, S as DefaultArrowType, D as DefaultElementShape, T as DefaultLineStyle, g as DefaultPaddingSize, U as DefaultRelationshipColor, h as DefaultShapeSize, j as DefaultTextSize, c as DefaultThemeColor, d as DeploymentElement, X as DiagramNode, E as ElementKind, k as ElementShapes, H as ExpressionV2, I as FqnExpr, J as FqnRef, R as RelationExpr, Y as extractStep, Z as getBBoxCenter, _ as getParallelStepsPrefix, K as isAndOperator, $ as isAutoLayoutDirection, l as isCustomElement, m as isCustomRelationExpr, a0 as isDeploymentView, a1 as isDynamicView, a2 as isDynamicViewParallelSteps, p as isElement, q as isElementKindExpr, b as isElementPredicateExpr, r as isElementRef, s as isElementTagExpr, a as isElementView, t as isElementWhere, u as isExpandedElementExpr, i as isExtendsElementView, w as isInOut, v as isIncoming, L as isKindEqual, M as isNotOperator, N as isOrOperator, x as isOutgoing, O as isParticipantOperator, y as isRelation, z as isRelationExpression, C as isRelationPredicateExpr, F as isRelationWhere, e as isScopedElementView, a3 as isStepEdgeId, P as isTagEqual, a4 as isViewRuleAutoLayout, a5 as isViewRuleGlobalPredicateRef, a6 as isViewRuleGlobalStyle, a7 as isViewRuleGroup, a8 as isViewRulePredicate, a9 as isViewRuleStyle, G as isWildcard, aa as stepEdgeId, Q as whereOperatorAsPredicate } from '../shared/core.BMep80lJ.mjs';
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",
@@ -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.HKn0jlo_.mjs';
2
- import { N as NonEmptyArray, a as IteratorLike } from '../shared/core.30yYKXcZ.mjs';
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.27.3",
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.38.0"
87
+ "type-fest": "^4.39.1"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@dagrejs/dagre": "1.1.4",
91
- "@mantine/colors-generator": "7.17.3",
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.4.4",
106
- "typescript": "^5.8.2",
105
+ "turbo": "^2.5.0",
106
+ "typescript": "^5.8.3",
107
107
  "unbuild": "^3.5.0",
108
- "vitest": "^3.0.9",
109
- "@likec4/tsconfig": "1.27.3"
108
+ "vitest": "^3.1.1",
109
+ "@likec4/tsconfig": "1.28.1"
110
110
  },
111
111
  "scripts": {
112
112
  "typecheck": "tsc --noEmit",
@@ -340,6 +340,7 @@ function builder<Spec extends BuilderSpecification, T extends AnyTypes>(
340
340
  Array.from(_views.entries()),
341
341
  ),
342
342
  ),
343
+ imports: {},
343
344
  } as any),
344
345
  toLikeC4Model: () => {
345
346
  const parsed = self.build()
@@ -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 CustomElementExpr,
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<CustomElementExpr['custom'] & CustomRelationExpr['customRelation'], 'expr' | 'relation' | 'navigateTo'> & {
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 = isElementPredicateExpr(expr)
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
- relation: expr as any,
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 C4Expression
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 C4ElementExpression),
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 Expression as C4Expression, type Fqn } from '../types'
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'], C4Expression> {
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: C4Expression): C4Expression => {
129
- return expr as C4Expression
129
+ const asTypedExpr = (expr: ExpressionV2): ExpressionV2 => {
130
+ return expr as ExpressionV2
130
131
  }
131
132
 
132
- export function $expr<Types extends AnyTypes>(expr: ViewPredicate.Expression<Types> | C4Expression): C4Expression {
133
+ export function $expr<Types extends AnyTypes>(
134
+ expr: ViewPredicate.Expression<Types> | ExpressionV2,
135
+ ): ExpressionV2 {
133
136
  if (!isString(expr)) {
134
- return expr as C4Expression
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
- expanded: expr.replace('._', '') as Fqn,
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
- element: expr.replace('.*', '') as Fqn,
177
- isChildren: true,
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
- element: expr.replace('.**', '') as Fqn,
183
- isDescendants: true,
190
+ ref: {
191
+ model: expr.replace('.*', '') as Fqn,
192
+ },
193
+ selector: 'children',
184
194
  })
185
195
  }
186
196
  return asTypedExpr({
187
- element: expr as any as Fqn,
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
- "element": "c2",
241
- "isChildren": true,
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
- "expanded": "c3",
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
- "element": "c2.c3",
361
- "isChildren": true,
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
- "expanded": "c1",
380
+ "ref": {
381
+ "model": "c1",
382
+ },
383
+ "selector": "expanded",
371
384
  },
372
385
  "target": {
373
- "element": "c2.c3",
374
- "isChildren": true,
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
- "element": "cloud",
147
- "isDescendants": true,
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
- "element": "cloud",
189
- "isChildren": true,
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 { buildComputedNodes, type ComputedNodeSource } from '../utils/buildComputedNodes'
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') {