@likec4/core 1.30.0 → 1.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/README.md +407 -5
  2. package/dist/builder/index.d.mts +221 -42
  3. package/dist/builder/index.mjs +118 -65
  4. package/dist/compute-view/index.d.mts +23 -7
  5. package/dist/compute-view/index.mjs +11 -6
  6. package/dist/compute-view/relationships-view/index.d.mts +9 -7
  7. package/dist/compute-view/relationships-view/index.mjs +3 -2
  8. package/dist/index.d.mts +10 -14
  9. package/dist/index.mjs +10 -6
  10. package/dist/model/index.d.mts +173 -19
  11. package/dist/model/index.mjs +6 -1
  12. package/dist/shared/core.BaYE_r29.d.mts +258 -0
  13. package/dist/shared/core.Bk7wEZFG.mjs +276 -0
  14. package/dist/shared/core.BrCnZFTn.mjs +32 -0
  15. package/dist/shared/core.BuO4ncfY.d.mts +146 -0
  16. package/dist/shared/{core.CAcZ6_cP.mjs → core.CBpKAlhj.mjs} +1742 -4128
  17. package/dist/shared/core.CCWXGc6G.d.mts +920 -0
  18. package/dist/shared/core.CUYDgv2-.mjs +214 -0
  19. package/dist/shared/{core.Cu-UdkSl.mjs → core.CpXlRyE5.mjs} +7 -494
  20. package/dist/shared/{core.C-YXI-43.mjs → core.Cy9smucx.mjs} +3 -1
  21. package/dist/shared/core.CywrQs86.d.mts +31 -0
  22. package/dist/shared/core.DoK86JEe.mjs +518 -0
  23. package/dist/shared/core.Dpq3P3YJ.d.mts +1265 -0
  24. package/dist/shared/{core.D2830qgg.d.mts → core.Pf5I9o0e.d.mts} +1 -1
  25. package/dist/shared/core.cbA9VZ02.mjs +2681 -0
  26. package/dist/shared/{core.CQXU9DF7.mjs → core.rmvsy0n3.mjs} +23 -32
  27. package/dist/types/aux.d.mts +3 -0
  28. package/dist/types/aux.mjs +1 -0
  29. package/dist/types/index.d.mts +7 -45
  30. package/dist/types/index.mjs +130 -3
  31. package/dist/utils/index.d.mts +221 -53
  32. package/dist/utils/index.mjs +14 -10
  33. package/package.json +19 -10
  34. package/src/builder/Builder.deploymentModel.ts +82 -18
  35. package/src/builder/Builder.element.ts +40 -20
  36. package/src/builder/Builder.model.ts +66 -17
  37. package/src/builder/Builder.ts +168 -76
  38. package/src/builder/Builder.view-common.ts +35 -17
  39. package/src/builder/Builder.view-deployment.ts +25 -25
  40. package/src/builder/Builder.view-element.ts +13 -12
  41. package/src/builder/Builder.views.ts +12 -7
  42. package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +62 -34
  43. package/src/builder/__snapshots__/Builder-style2.compute-model.json5 +319 -0
  44. package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +45 -24
  45. package/src/builder/_types.ts +34 -27
  46. package/src/compute-view/compute-view.ts +31 -34
  47. package/src/compute-view/deployment-view/__test__/TestHelper.ts +27 -14
  48. package/src/compute-view/deployment-view/__test__/fixture.ts +15 -13
  49. package/src/compute-view/deployment-view/_types.ts +10 -10
  50. package/src/compute-view/deployment-view/clean-connections.ts +5 -7
  51. package/src/compute-view/deployment-view/compute.ts +16 -13
  52. package/src/compute-view/deployment-view/memory/memory.ts +5 -6
  53. package/src/compute-view/deployment-view/predicates/deploymentRefs.ts +4 -5
  54. package/src/compute-view/deployment-view/predicates/relation-direct.ts +25 -50
  55. package/src/compute-view/deployment-view/predicates/relation-in-out.ts +5 -7
  56. package/src/compute-view/deployment-view/predicates/relation-incoming.ts +7 -11
  57. package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +7 -10
  58. package/src/compute-view/deployment-view/predicates/utils.ts +37 -31
  59. package/src/compute-view/deployment-view/predicates/wildcard.ts +3 -2
  60. package/src/compute-view/deployment-view/stages/stage-final.ts +2 -2
  61. package/src/compute-view/deployment-view/stages/stage-include.ts +1 -1
  62. package/src/compute-view/deployment-view/utils.ts +79 -72
  63. package/src/compute-view/dynamic-view/__test__/fixture.ts +20 -11
  64. package/src/compute-view/dynamic-view/compute.ts +60 -53
  65. package/src/compute-view/element-view/__test__/TestHelper.ts +53 -29
  66. package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +26 -26
  67. package/src/compute-view/element-view/__test__/fixture.ts +134 -83
  68. package/src/compute-view/element-view/_types.ts +14 -19
  69. package/src/compute-view/element-view/clean-connections.ts +12 -8
  70. package/src/compute-view/element-view/compute.ts +61 -51
  71. package/src/compute-view/element-view/memory/NodeGroup.ts +8 -9
  72. package/src/compute-view/element-view/memory/memory.ts +22 -22
  73. package/src/compute-view/element-view/memory/stage-include.ts +5 -3
  74. package/src/compute-view/element-view/predicates/_utils.ts +18 -14
  75. package/src/compute-view/element-view/predicates/element-expand.ts +4 -5
  76. package/src/compute-view/element-view/predicates/element-kind-tag.ts +3 -4
  77. package/src/compute-view/element-view/predicates/element-ref.ts +3 -4
  78. package/src/compute-view/element-view/predicates/relation-direct.ts +16 -12
  79. package/src/compute-view/element-view/predicates/relation-in-out.ts +7 -8
  80. package/src/compute-view/element-view/predicates/relation-in.ts +19 -26
  81. package/src/compute-view/element-view/predicates/relation-out.ts +20 -21
  82. package/src/compute-view/element-view/predicates/wildcard.ts +3 -3
  83. package/src/compute-view/element-view/utils.ts +25 -23
  84. package/src/compute-view/index.ts +1 -1
  85. package/src/compute-view/memory/AbstractStageExclude.ts +3 -4
  86. package/src/compute-view/memory/AbstractStageInclude.ts +1 -1
  87. package/src/compute-view/memory/_types.ts +3 -2
  88. package/src/compute-view/relationships-view/_types.ts +3 -4
  89. package/src/compute-view/relationships-view/compute.ts +8 -11
  90. package/src/compute-view/relationships-view/layout.ts +6 -6
  91. package/src/compute-view/relationships-view/utils.ts +4 -4
  92. package/src/compute-view/utils/ancestorsOfNode.ts +7 -7
  93. package/src/compute-view/utils/applyCustomElementProperties.ts +16 -8
  94. package/src/compute-view/utils/applyCustomRelationProperties.ts +19 -9
  95. package/src/compute-view/utils/applyViewRuleStyles.ts +18 -10
  96. package/src/compute-view/utils/buildComputedNodes.ts +40 -40
  97. package/src/compute-view/utils/buildElementNotations.ts +14 -14
  98. package/src/compute-view/utils/elementExpressionToPredicate.ts +14 -15
  99. package/src/compute-view/utils/link-nodes-with-edges.ts +6 -4
  100. package/src/compute-view/utils/merge-props-from-relationships.ts +52 -20
  101. package/src/compute-view/utils/relationExpressionToPredicates.ts +19 -19
  102. package/src/compute-view/utils/resolve-extended-views.ts +8 -7
  103. package/src/compute-view/utils/resolve-global-rules.ts +31 -26
  104. package/src/compute-view/utils/topological-sort.ts +14 -14
  105. package/src/compute-view/utils/view-hash.ts +2 -2
  106. package/src/compute-view/utils/with-readable-edges.ts +9 -5
  107. package/src/index.ts +0 -32
  108. package/src/model/DeploymentElementModel.ts +182 -137
  109. package/src/model/DeploymentModel.ts +88 -65
  110. package/src/model/ElementModel.ts +92 -72
  111. package/src/model/LikeC4Model.ts +430 -241
  112. package/src/model/RelationModel.ts +69 -26
  113. package/src/model/__test__/fixture.ts +50 -36
  114. package/src/model/connection/Connection.ts +2 -2
  115. package/src/model/connection/deployment/DeploymentConnectionModel.ts +21 -24
  116. package/src/model/connection/deployment/find.ts +1 -1
  117. package/src/model/connection/model/ConnectionModel.ts +21 -20
  118. package/src/model/connection/model/find.ts +7 -7
  119. package/src/model/connection/ops.ts +6 -6
  120. package/src/model/guards.ts +66 -14
  121. package/src/model/index.ts +20 -7
  122. package/src/model/types.ts +41 -97
  123. package/src/model/view/EdgeModel.ts +47 -41
  124. package/src/model/view/LikeC4ViewModel.ts +130 -80
  125. package/src/model/view/NodeModel.ts +102 -96
  126. package/src/theme/element.ts +1 -1
  127. package/src/theme/index.ts +9 -9
  128. package/src/theme/relationships.ts +1 -1
  129. package/src/types/_common.ts +21 -15
  130. package/src/types/aux.ts +285 -0
  131. package/src/types/const.ts +34 -0
  132. package/src/types/expression-model.ts +292 -0
  133. package/src/types/expression.ts +311 -0
  134. package/src/types/fqnRef.ts +88 -0
  135. package/src/types/geometry.ts +131 -0
  136. package/src/types/global.ts +10 -8
  137. package/src/types/index.ts +39 -201
  138. package/src/types/model-data.ts +52 -84
  139. package/src/types/model-deployment.ts +87 -0
  140. package/src/types/model-dump.ts +72 -0
  141. package/src/types/model-logical.ts +111 -0
  142. package/src/types/model-spec.ts +81 -0
  143. package/src/types/operators.ts +51 -52
  144. package/src/types/scalar.ts +114 -0
  145. package/src/types/styles.ts +123 -0
  146. package/src/types/view-changes.ts +4 -5
  147. package/src/types/view-common.ts +157 -0
  148. package/src/types/view-computed.ts +113 -0
  149. package/src/types/view-layouted.ts +82 -0
  150. package/src/types/view-parsed.deployment.ts +40 -0
  151. package/src/types/view-parsed.dynamic.ts +78 -0
  152. package/src/types/view-parsed.element.ts +65 -0
  153. package/src/types/view.ts +122 -542
  154. package/src/utils/compare-natural.ts +43 -1
  155. package/src/utils/getOrCreate.ts +0 -34
  156. package/src/utils/index.ts +7 -12
  157. package/src/utils/iterable/filter.ts +1 -1
  158. package/src/utils/iterable/find.ts +3 -1
  159. package/src/utils/iterable/head.ts +22 -0
  160. package/src/utils/iterable/index.ts +1 -0
  161. package/src/utils/iterable/map.ts +1 -1
  162. package/src/utils/iterable/reduce.ts +1 -1
  163. package/src/utils/iterable/some.ts +1 -1
  164. package/src/utils/memoize-prop.ts +30 -0
  165. package/src/utils/object-hash.ts +1 -1
  166. package/src/utils/relations.ts +14 -11
  167. package/src/utils/string-hash.ts +1 -1
  168. package/dist/shared/core.CZR9J1Qx.d.mts +0 -146
  169. package/dist/shared/core.CiFKryGW.d.mts +0 -745
  170. package/dist/shared/core.DJvmfnEi.d.mts +0 -1153
  171. package/dist/shared/core.DgfwjBtu.mjs +0 -495
  172. package/dist/shared/core.SjLhMA7a.d.mts +0 -62
  173. package/src/builder/__snapshots__/Builder.spec.ts.snap +0 -374
  174. package/src/compute-view/element-view/predicates.ts +0 -520
  175. package/src/compute-view/utils/uniqueTags.ts +0 -21
  176. package/src/types/deployments.ts +0 -170
  177. package/src/types/element.ts +0 -109
  178. package/src/types/expression-v2-model.ts +0 -314
  179. package/src/types/expression-v2.ts +0 -392
  180. package/src/types/overview-graph.ts +0 -43
  181. package/src/types/relation.ts +0 -61
  182. package/src/types/scalars.ts +0 -39
  183. package/src/types/theme.ts +0 -82
  184. package/src/types/view-notation.ts +0 -9
  185. package/src/utils/graphlib.ts +0 -10
  186. /package/src/{errors/index.ts → utils/invariant.ts} +0 -0
@@ -1,8 +1,7 @@
1
1
  import type { NonEmptyArray } from './_common'
2
- import type { BorderStyle, ElementShape } from './element'
3
- import type { Fqn } from './scalars'
4
- import type { ThemeColor } from './theme'
5
- import type { AutoLayoutDirection, ViewManualLayout } from './view'
2
+ import type * as scalar from './scalar'
3
+ import type { BorderStyle, ElementShape, ThemeColor } from './styles'
4
+ import type { AutoLayoutDirection, ViewManualLayout } from './view-common'
6
5
 
7
6
  export namespace ViewChange {
8
7
  export interface ChangeElementStyle {
@@ -13,7 +12,7 @@ export namespace ViewChange {
13
12
  shape?: ElementShape
14
13
  color?: ThemeColor
15
14
  }
16
- targets: NonEmptyArray<Fqn>
15
+ targets: NonEmptyArray<scalar.Fqn | scalar.DeploymentFqn>
17
16
  }
18
17
 
19
18
  export interface SaveManualLayout {
@@ -0,0 +1,157 @@
1
+ import type { NonEmptyArray } from './_common'
2
+ import type * as aux from './aux'
3
+ import type { AnyAux } from './aux'
4
+ import type { _stage } from './const'
5
+
6
+ import type { BBox, Point, XYPoint } from './geometry'
7
+ import type { GlobalPredicateId, GlobalStyleID } from './global'
8
+ import * as scalar from './scalar'
9
+ import type {
10
+ BorderStyle,
11
+ Color,
12
+ ElementShape,
13
+ ShapeSize,
14
+ SpacingSize,
15
+ TextSize,
16
+ } from './styles'
17
+
18
+ export interface AnyIncludePredicate<Expr> {
19
+ include: Expr[]
20
+ exclude?: never
21
+ }
22
+ export interface AnyExcludePredicate<Expr> {
23
+ include?: never
24
+ exclude: Expr[]
25
+ }
26
+
27
+ export interface AnyViewRuleStyle<Expr> {
28
+ targets: Expr[]
29
+ notation?: string
30
+ style: {
31
+ border?: BorderStyle
32
+ opacity?: number
33
+ multiple?: boolean
34
+ size?: ShapeSize
35
+ padding?: SpacingSize
36
+ textSize?: TextSize
37
+ color?: Color
38
+ shape?: ElementShape
39
+ icon?: scalar.Icon
40
+ }
41
+ }
42
+
43
+ export interface ViewRuleGlobalStyle {
44
+ styleId: GlobalStyleID
45
+ }
46
+ export function isViewRuleGlobalStyle(rule: object): rule is ViewRuleGlobalStyle {
47
+ return 'styleId' in rule
48
+ }
49
+
50
+ export interface ViewRuleGlobalPredicateRef {
51
+ predicateId: GlobalPredicateId
52
+ }
53
+ export function isViewRuleGlobalPredicateRef(rule: object): rule is ViewRuleGlobalPredicateRef {
54
+ return 'predicateId' in rule
55
+ }
56
+
57
+ export type AutoLayoutDirection = 'TB' | 'BT' | 'LR' | 'RL'
58
+ export function isAutoLayoutDirection(autoLayout: unknown): autoLayout is AutoLayoutDirection {
59
+ return autoLayout === 'TB' || autoLayout === 'BT' || autoLayout === 'LR' || autoLayout === 'RL'
60
+ }
61
+
62
+ export interface ViewRuleAutoLayout {
63
+ direction: AutoLayoutDirection
64
+ nodeSep?: number
65
+ rankSep?: number
66
+ }
67
+
68
+ export function isViewRuleAutoLayout(rule: object): rule is ViewRuleAutoLayout {
69
+ return 'direction' in rule
70
+ }
71
+
72
+ export interface ViewAutoLayout {
73
+ direction: ViewRuleAutoLayout['direction']
74
+ rankSep?: number
75
+ nodeSep?: number
76
+ }
77
+
78
+ export type ViewManualLayout = {
79
+ // Object hash of previous layout
80
+ readonly hash: string
81
+ readonly x: number
82
+ readonly y: number
83
+ readonly width: number
84
+ readonly height: number
85
+ readonly autoLayout: ViewAutoLayout
86
+ readonly nodes: Record<string, {
87
+ isCompound: boolean
88
+ x: number
89
+ y: number
90
+ width: number
91
+ height: number
92
+ }>
93
+ readonly edges: Record<string, {
94
+ // Graphviz edge POS
95
+ dotpos?: string
96
+ // Bezier points
97
+ points: NonEmptyArray<Point>
98
+ // Control points to adjust the edge
99
+ controlPoints?: NonEmptyArray<XYPoint>
100
+ labelBBox?: BBox
101
+ }>
102
+ }
103
+
104
+ export type ViewType = 'element' | 'dynamic' | 'deployment'
105
+
106
+ export interface BaseViewProperties<A extends AnyAux> extends aux.WithOptionalTags<A>, aux.WithOptionalLinks {
107
+ readonly id: aux.StrictViewId<A>
108
+ readonly title: string | null
109
+ readonly description: string | null
110
+ /**
111
+ * For all views we find common ancestor path.
112
+ * This is used to generate relative paths, i.e.:
113
+ * - "/home/project/index.c4" becomes "index.c4"
114
+ * - "/home/project/subdir/views.c4" becomes "subdir/views.c4"
115
+ *
116
+ * Undefined if the view is auto-generated.
117
+ */
118
+ readonly relativePath?: string | undefined
119
+ }
120
+
121
+ export interface BaseParsedViewProperties<A extends AnyAux> extends BaseViewProperties<A> {
122
+ /**
123
+ * Internal field to identify the stage of the view.
124
+ * This is used to create the correct type of the view.
125
+ */
126
+ readonly [_stage]: 'parsed'
127
+ /**
128
+ * URI to the source file of this view.
129
+ * Undefined if the view is auto-generated.
130
+ */
131
+ readonly docUri?: string | undefined
132
+
133
+ /**
134
+ * If the view is changed manually this field contains the layout data.
135
+ */
136
+ readonly manualLayout?: ViewManualLayout | undefined
137
+ }
138
+
139
+ export type NodeNotation = {
140
+ kinds: string[]
141
+ shape: ElementShape
142
+ color: Color
143
+ title: string
144
+ }
145
+
146
+ export interface ViewWithNotation {
147
+ notation?: {
148
+ nodes: NodeNotation[]
149
+ }
150
+ }
151
+ export interface ViewWithHash {
152
+ /**
153
+ * Hash of the view object.
154
+ * This is used to detect changes in layout
155
+ */
156
+ hash: string
157
+ }
@@ -0,0 +1,113 @@
1
+ import type * as aux from './aux'
2
+ import type { Any } from './aux'
3
+ import type { _stage, _type } from './const'
4
+ import type { ElementStyle } from './model-logical'
5
+ import type * as scalar from './scalar'
6
+ import {
7
+ type Icon,
8
+ } from './scalar'
9
+ import type {
10
+ Color,
11
+ ElementShape,
12
+ RelationshipArrowType,
13
+ RelationshipLineType,
14
+ } from './styles'
15
+ import type {
16
+ BaseViewProperties,
17
+ ViewAutoLayout,
18
+ ViewManualLayout,
19
+ ViewWithHash,
20
+ ViewWithNotation,
21
+ } from './view-common'
22
+
23
+ export interface ComputedNode<A extends Any = Any> extends aux.WithOptionalLinks {
24
+ id: scalar.NodeId
25
+ kind: aux.ElementKind<A> | aux.DeploymentKind<A> | '@group'
26
+ parent: scalar.NodeId | null
27
+ /**
28
+ * Reference to model element
29
+ * If 1 - node id is a reference
30
+ */
31
+ modelRef?: aux.Fqn<A> | undefined
32
+ /**
33
+ * Reference to deployment element
34
+ * If 1 - node id is a reference
35
+ */
36
+ deploymentRef?: aux.DeploymentFqn<A> | undefined
37
+ title: string
38
+ description?: string | null
39
+ technology?: string | null
40
+ notation?: string
41
+ children: scalar.NodeId[]
42
+ inEdges: scalar.EdgeId[]
43
+ outEdges: scalar.EdgeId[]
44
+ tags: aux.Tags<A>
45
+ shape: ElementShape
46
+ color: Color
47
+ icon?: Icon
48
+ style: ElementStyle
49
+ navigateTo?: aux.StrictViewId<A> | null
50
+ level: number
51
+ // For compound nodes, the max depth of nested nodes
52
+ depth?: number
53
+ /**
54
+ * If this node was customized in the view
55
+ */
56
+ isCustomized?: boolean
57
+ }
58
+
59
+ export interface ComputedEdge<A extends Any = Any> extends aux.WithOptionalTags<A> {
60
+ id: scalar.EdgeId
61
+ parent: scalar.NodeId | null
62
+ source: scalar.NodeId
63
+ target: scalar.NodeId
64
+ label: string | null
65
+ description?: string
66
+ technology?: string
67
+ relations: scalar.RelationId[]
68
+ kind?: aux.RelationKind<A> | typeof scalar.StepEdgeKind
69
+ notation?: string
70
+ // Notes for walkthrough
71
+ notes?: string
72
+ color?: Color
73
+ line?: RelationshipLineType
74
+ head?: RelationshipArrowType
75
+ tail?: RelationshipArrowType
76
+ // Link to dynamic view
77
+ navigateTo?: aux.StrictViewId<A> | null
78
+ /**
79
+ * If this edge is derived from custom relationship predicate
80
+ */
81
+ isCustomized?: boolean
82
+ /**
83
+ * For layouting purposes
84
+ * @default 'forward'
85
+ */
86
+ dir?: 'forward' | 'back' | 'both'
87
+ }
88
+
89
+ interface BaseComputedViewProperties<A extends Any> extends BaseViewProperties<A>, ViewWithHash, ViewWithNotation {
90
+ readonly [_stage]: 'computed'
91
+ readonly autoLayout: ViewAutoLayout
92
+ readonly nodes: ComputedNode<A>[]
93
+ readonly edges: ComputedEdge<A>[]
94
+
95
+ /**
96
+ * If the view is changed manually this field contains the layout data.
97
+ */
98
+ readonly manualLayout?: ViewManualLayout | undefined
99
+ }
100
+
101
+ export interface ComputedElementView<A extends Any = Any> extends BaseComputedViewProperties<A> {
102
+ readonly [_type]: 'element'
103
+ readonly viewOf?: aux.StrictFqn<A>
104
+ readonly extends?: aux.StrictViewId<A>
105
+ }
106
+
107
+ export interface ComputedDeploymentView<A extends Any = Any> extends BaseComputedViewProperties<A> {
108
+ readonly [_type]: 'deployment'
109
+ }
110
+
111
+ export interface ComputedDynamicView<A extends Any = Any> extends BaseComputedViewProperties<A> {
112
+ readonly [_type]: 'dynamic'
113
+ }
@@ -0,0 +1,82 @@
1
+ import type { NonEmptyArray } from './_common'
2
+ import type * as aux from './aux'
3
+ import type { AnyAux } from './aux'
4
+ import type { _stage, _type } from './const'
5
+ import type { BBox, Point, XYPoint } from './geometry'
6
+ import type {
7
+ BaseViewProperties,
8
+ ViewAutoLayout,
9
+ ViewWithHash,
10
+ ViewWithNotation,
11
+ } from './view-common'
12
+ import type { ComputedEdge, ComputedNode } from './view-computed'
13
+
14
+ export interface DiagramNode<A extends AnyAux = AnyAux> extends ComputedNode<A>, BBox {
15
+ x: number
16
+ y: number
17
+ width: number
18
+ height: number
19
+ /**
20
+ * Absolute position, top left
21
+ * @deprecated Use `x` and `y` instead
22
+ */
23
+ position: Point
24
+ /**
25
+ * Bounding box of label
26
+ * (Absolute coordinates)
27
+ */
28
+ labelBBox: BBox
29
+ }
30
+
31
+ export interface DiagramEdge<A extends AnyAux = AnyAux> extends ComputedEdge<A> {
32
+ /**
33
+ * Bezier points
34
+ * (Absolute coordinates)
35
+ */
36
+ points: NonEmptyArray<Point>
37
+ /**
38
+ * Control points to adjust the edge
39
+ * (Absolute coordinates)
40
+ */
41
+ controlPoints?: NonEmptyArray<XYPoint>
42
+ /**
43
+ * Bounding box of label
44
+ * (Absolute coordinates)
45
+ */
46
+ labelBBox?: BBox | null
47
+ /**
48
+ * Graphviz edge POS
49
+ *
50
+ * TODO: temporary solution, should be moved out
51
+ * @deprecated
52
+ */
53
+ dotpos?: string
54
+ }
55
+
56
+ interface BaseLayoutedViewProperties<A extends AnyAux> extends BaseViewProperties<A>, ViewWithHash, ViewWithNotation {
57
+ readonly [_stage]: 'layouted'
58
+ readonly autoLayout: ViewAutoLayout
59
+ readonly nodes: DiagramNode<A>[]
60
+ readonly edges: DiagramEdge<A>[]
61
+ readonly bounds: BBox
62
+
63
+ /**
64
+ * If diagram has manual layout
65
+ * But was changed and layout should be recalculated
66
+ */
67
+ hasLayoutDrift?: boolean
68
+ }
69
+
70
+ export interface LayoutedElementView<A extends AnyAux = AnyAux> extends BaseLayoutedViewProperties<A> {
71
+ readonly [_type]: 'element'
72
+ readonly viewOf?: aux.Fqn<A>
73
+ readonly extends?: aux.StrictViewId<A>
74
+ }
75
+
76
+ export interface LayoutedDeploymentView<A extends AnyAux = AnyAux> extends BaseLayoutedViewProperties<A> {
77
+ readonly [_type]: 'deployment'
78
+ }
79
+
80
+ export interface LayoutedDynamicView<A extends AnyAux = AnyAux> extends BaseLayoutedViewProperties<A> {
81
+ readonly [_type]: 'dynamic'
82
+ }
@@ -0,0 +1,40 @@
1
+ import type { MergeExclusive, Simplify } from 'type-fest'
2
+ import type { ExclusiveUnion } from './_common'
3
+ import type { AnyAux, Unknown } from './aux'
4
+ import type { _type } from './const'
5
+ import type { Expression, FqnExpr } from './expression'
6
+ import type {
7
+ AnyExcludePredicate,
8
+ AnyIncludePredicate,
9
+ AnyViewRuleStyle,
10
+ BaseParsedViewProperties,
11
+ ViewRuleAutoLayout,
12
+ } from './view-common'
13
+
14
+ /**
15
+ * Predicates scoped to deployment model
16
+ */
17
+ export interface DeploymentViewIncludePredicate<A extends AnyAux = Unknown>
18
+ extends AnyIncludePredicate<Expression<A>>
19
+ {}
20
+ export interface DeploymentViewExcludePredicate<A extends AnyAux = Unknown>
21
+ extends AnyExcludePredicate<Expression<A>>
22
+ {}
23
+
24
+ export type DeploymentViewPredicate<A extends AnyAux = Unknown> =
25
+ | DeploymentViewIncludePredicate<A>
26
+ | DeploymentViewExcludePredicate<A>
27
+
28
+ export interface DeploymentViewRuleStyle<A extends AnyAux = Unknown> extends AnyViewRuleStyle<FqnExpr<A>> {}
29
+
30
+ export type DeploymentViewRule<A extends AnyAux = Unknown> = ExclusiveUnion<{
31
+ Include: DeploymentViewIncludePredicate<A>
32
+ Exclude: DeploymentViewExcludePredicate<A>
33
+ Style: DeploymentViewRuleStyle<A>
34
+ AutoLayout: ViewRuleAutoLayout
35
+ }>
36
+
37
+ export interface ParsedDeploymentView<A extends AnyAux = Unknown> extends BaseParsedViewProperties<A> {
38
+ [_type]: 'deployment'
39
+ readonly rules: DeploymentViewRule<A>[]
40
+ }
@@ -0,0 +1,78 @@
1
+ import { isArray } from 'remeda'
2
+ import type { MergeExclusive, Simplify } from 'type-fest'
3
+ import type { ExclusiveUnion } from './_common'
4
+ import type * as aux from './aux'
5
+ import type { AnyAux } from './aux'
6
+ import type { _type } from './const'
7
+ import type { ModelFqnExpr } from './expression-model'
8
+ import { isStepEdgeId } from './scalar'
9
+ import type { Color, RelationshipArrowType, RelationshipLineType } from './styles'
10
+ import type {
11
+ BaseParsedViewProperties,
12
+ ViewRuleAutoLayout,
13
+ ViewRuleGlobalPredicateRef,
14
+ ViewRuleGlobalStyle,
15
+ } from './view-common'
16
+ import type { ElementViewRuleStyle } from './view-parsed.element'
17
+
18
+ export interface DynamicViewStep<A extends AnyAux = AnyAux> {
19
+ readonly source: aux.StrictFqn<A>
20
+ readonly target: aux.StrictFqn<A>
21
+ readonly title: string | null
22
+ readonly description?: string
23
+ readonly technology?: string
24
+ readonly notation?: string
25
+ // Notes for walkthrough
26
+ readonly notes?: string
27
+ readonly color?: Color
28
+ readonly line?: RelationshipLineType
29
+ readonly head?: RelationshipArrowType
30
+ readonly tail?: RelationshipArrowType
31
+ readonly isBackward?: boolean
32
+ // Link to dynamic view
33
+ readonly navigateTo?: aux.StrictViewId<A>
34
+ }
35
+
36
+ export interface DynamicViewParallelSteps<A extends AnyAux = AnyAux> {
37
+ readonly __parallel: DynamicViewStep<A>[]
38
+ }
39
+
40
+ // Get the prefix of the parallel steps
41
+ // i.e. step-01.1 -> step-01.
42
+ export function getParallelStepsPrefix(id: string): string | null {
43
+ if (isStepEdgeId(id) && id.includes('.')) {
44
+ return id.slice(0, id.indexOf('.') + 1)
45
+ }
46
+ return null
47
+ }
48
+
49
+ export type DynamicViewStepOrParallel<A extends AnyAux = AnyAux> = Simplify<
50
+ MergeExclusive<
51
+ DynamicViewStep<A>,
52
+ DynamicViewParallelSteps<A>
53
+ >
54
+ >
55
+
56
+ export interface DynamicViewIncludeRule<A extends AnyAux = AnyAux> {
57
+ include: ModelFqnExpr.Any<A>[]
58
+ }
59
+
60
+ export type DynamicViewRule<A extends AnyAux = AnyAux> = ExclusiveUnion<{
61
+ Include: DynamicViewIncludeRule<A>
62
+ GlobalPredicateRef: ViewRuleGlobalPredicateRef
63
+ ElementViewRuleStyle: ElementViewRuleStyle<A>
64
+ GlobalStyle: ViewRuleGlobalStyle
65
+ AutoLayout: ViewRuleAutoLayout
66
+ }>
67
+
68
+ export interface ParsedDynamicView<A extends AnyAux = AnyAux> extends BaseParsedViewProperties<A> {
69
+ [_type]: 'dynamic'
70
+ readonly steps: DynamicViewStepOrParallel<A>[]
71
+ readonly rules: DynamicViewRule<A>[]
72
+ }
73
+
74
+ export function isDynamicViewParallelSteps<A extends AnyAux>(
75
+ step: DynamicViewStepOrParallel<A>,
76
+ ): step is DynamicViewParallelSteps<A> {
77
+ return '__parallel' in step && isArray(step.__parallel)
78
+ }
@@ -0,0 +1,65 @@
1
+ import type { ExclusiveUnion } from './_common'
2
+ import type * as aux from './aux'
3
+ import type { AnyAux } from './aux'
4
+ import type { _type } from './const'
5
+ import type { ModelExpression, ModelFqnExpr } from './expression-model'
6
+ import type { BorderStyle, Color, ShapeSize, SpacingSize, TextSize } from './styles'
7
+ import type {
8
+ AnyExcludePredicate,
9
+ AnyIncludePredicate,
10
+ AnyViewRuleStyle,
11
+ BaseParsedViewProperties,
12
+ ViewRuleAutoLayout,
13
+ ViewRuleGlobalPredicateRef,
14
+ ViewRuleGlobalStyle,
15
+ } from './view-common'
16
+
17
+ /**
18
+ * Predicates scoped to logical model
19
+ */
20
+ export interface ElementViewIncludePredicate<A extends AnyAux = AnyAux>
21
+ extends AnyIncludePredicate<ModelExpression<A>>
22
+ {}
23
+ export interface ElementViewExcludePredicate<A extends AnyAux = AnyAux>
24
+ extends AnyExcludePredicate<ModelExpression<A>>
25
+ {}
26
+
27
+ export type ElementViewPredicate<A extends AnyAux = AnyAux> =
28
+ | ElementViewIncludePredicate<A>
29
+ | ElementViewExcludePredicate<A>
30
+
31
+ export interface ElementViewRuleGroup<A extends AnyAux = AnyAux> {
32
+ groupRules: Array<ElementViewPredicate<A> | ElementViewRuleGroup<A>>
33
+ title: string | null
34
+ color?: Color
35
+ border?: BorderStyle
36
+ // 0-100
37
+ opacity?: number
38
+ multiple?: boolean
39
+ size?: ShapeSize
40
+ padding?: SpacingSize
41
+ textSize?: TextSize
42
+ }
43
+
44
+ export function isViewRuleGroup<A extends AnyAux>(rule: ElementViewRule<A>): rule is ElementViewRuleGroup<A> {
45
+ return 'title' in rule && 'groupRules' in rule && Array.isArray(rule.groupRules)
46
+ }
47
+
48
+ export interface ElementViewRuleStyle<A extends AnyAux = AnyAux> extends AnyViewRuleStyle<ModelFqnExpr<A>> {}
49
+
50
+ export type ElementViewRule<A extends AnyAux = AnyAux> = ExclusiveUnion<{
51
+ IncludePredicate: ElementViewIncludePredicate<A>
52
+ ExcludePredicate: ElementViewExcludePredicate<A>
53
+ Group: ElementViewRuleGroup<A>
54
+ Style: ElementViewRuleStyle<A>
55
+ GlobalStyle: ViewRuleGlobalStyle
56
+ GlobalPredicateRef: ViewRuleGlobalPredicateRef
57
+ AutoLayout: ViewRuleAutoLayout
58
+ }>
59
+
60
+ export interface ParsedElementView<A extends AnyAux = AnyAux> extends BaseParsedViewProperties<A> {
61
+ [_type]: 'element'
62
+ readonly rules: ElementViewRule<A>[]
63
+ readonly viewOf?: aux.StrictFqn<A>
64
+ readonly extends?: aux.StrictViewId<A>
65
+ }