@likec4/core 1.18.0 → 1.19.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 (177) hide show
  1. package/LICENSE +1 -1
  2. package/dist/builder/index.d.mts +502 -0
  3. package/dist/builder/index.d.ts +502 -0
  4. package/dist/builder/index.js +871 -0
  5. package/dist/compute-view/index.d.mts +9 -78
  6. package/dist/compute-view/index.d.ts +9 -78
  7. package/dist/compute-view/index.js +78 -0
  8. package/dist/index.d.mts +9 -730
  9. package/dist/index.d.ts +9 -730
  10. package/dist/{index.mjs → index.js} +7 -784
  11. package/dist/model/index.d.mts +218 -606
  12. package/dist/model/index.d.ts +218 -606
  13. package/dist/model/index.js +1 -0
  14. package/dist/shared/chunk-RAAYCPUM.M-JWF7SS.js +21 -0
  15. package/dist/shared/core.BIfgabEw.d.ts +719 -0
  16. package/dist/shared/core.BZ9Msq7w.d.mts +719 -0
  17. package/dist/shared/{core.DMYY7C8s.d.mts → core.C05RDLhi.d.ts} +179 -230
  18. package/dist/shared/{core.DMYY7C8s.d.ts → core.CmYMqgha.d.mts} +179 -230
  19. package/dist/shared/core.D6-fWbM3.d.ts +127 -0
  20. package/dist/shared/core.D74xkKkG.d.mts +148 -0
  21. package/dist/shared/core.D74xkKkG.d.ts +148 -0
  22. package/dist/shared/core.sLaWHBjR.d.mts +127 -0
  23. package/dist/shared/index.DafVOuVd.js +7443 -0
  24. package/dist/shared/object_hash.CE_oF3I3.js +1222 -0
  25. package/dist/shared/view.CyZrG8BJ.js +354 -0
  26. package/dist/types/index.d.mts +4 -2
  27. package/dist/types/index.d.ts +4 -2
  28. package/dist/types/index.js +20 -0
  29. package/dist/utils/index.d.mts +419 -0
  30. package/dist/utils/index.d.ts +419 -0
  31. package/dist/utils/index.js +347 -0
  32. package/package.json +47 -33
  33. package/src/builder/Builder-style1.test-d.ts +190 -0
  34. package/src/builder/Builder-style2.test-d.ts +175 -0
  35. package/src/builder/Builder.deployment.ts +25 -20
  36. package/src/builder/Builder.deploymentModel.ts +80 -55
  37. package/src/builder/Builder.element.ts +2 -0
  38. package/src/builder/Builder.model.ts +57 -43
  39. package/src/builder/Builder.ts +412 -431
  40. package/src/builder/Builder.view-common.ts +234 -0
  41. package/src/builder/Builder.view-deployment.ts +135 -0
  42. package/src/builder/Builder.view-element.ts +189 -0
  43. package/src/builder/Builder.views.ts +109 -33
  44. package/src/builder/Builder.with.ts +475 -0
  45. package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +374 -0
  46. package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +183 -0
  47. package/src/builder/__snapshots__/Builder.spec.ts.snap +374 -0
  48. package/src/builder/_types.ts +28 -5
  49. package/src/builder/index.ts +10 -4
  50. package/src/colors/index.ts +2 -2
  51. package/src/compute-view/compute-view.ts +45 -54
  52. package/src/compute-view/deployment-view/__test__/TestHelper.ts +236 -0
  53. package/src/compute-view/deployment-view/__test__/fixture.ts +50 -62
  54. package/src/compute-view/deployment-view/_types.ts +26 -18
  55. package/src/compute-view/deployment-view/clean-connections.ts +173 -164
  56. package/src/compute-view/deployment-view/compute.ts +51 -37
  57. package/src/compute-view/deployment-view/memory/index.ts +9 -0
  58. package/src/compute-view/deployment-view/memory/memory.ts +97 -0
  59. package/src/compute-view/deployment-view/predicates/elements.ts +144 -0
  60. package/src/compute-view/deployment-view/predicates/relation-direct.ts +183 -76
  61. package/src/compute-view/deployment-view/predicates/relation-in-out.ts +38 -20
  62. package/src/compute-view/deployment-view/predicates/relation-incoming.ts +72 -23
  63. package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +61 -22
  64. package/src/compute-view/deployment-view/predicates/wildcard.ts +15 -15
  65. package/src/compute-view/deployment-view/stages/stage-exclude.ts +5 -0
  66. package/src/compute-view/deployment-view/stages/stage-final.ts +245 -0
  67. package/src/compute-view/deployment-view/stages/stage-include.ts +95 -0
  68. package/src/compute-view/deployment-view/utils.ts +95 -31
  69. package/src/compute-view/dynamic-view/__test__/fixture.ts +4 -4
  70. package/src/compute-view/dynamic-view/compute.ts +59 -45
  71. package/src/compute-view/element-view/__test__/TestHelper.ts +258 -0
  72. package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +64 -62
  73. package/src/compute-view/element-view/__test__/fixture.ts +147 -117
  74. package/src/compute-view/element-view/_types.ts +48 -0
  75. package/src/compute-view/element-view/clean-connections.ts +113 -0
  76. package/src/compute-view/element-view/compute.ts +264 -683
  77. package/src/compute-view/element-view/memory/NodeGroup.ts +31 -0
  78. package/src/compute-view/element-view/memory/index.ts +10 -0
  79. package/src/compute-view/element-view/memory/memory.ts +177 -0
  80. package/src/compute-view/element-view/memory/stage-exclude.ts +59 -0
  81. package/src/compute-view/element-view/memory/stage-final.ts +129 -0
  82. package/src/compute-view/element-view/memory/stage-include.ts +128 -0
  83. package/src/compute-view/element-view/predicates/_utils.ts +86 -0
  84. package/src/compute-view/element-view/predicates/element-expand.ts +33 -0
  85. package/src/compute-view/element-view/predicates/element-kind-tag.ts +26 -0
  86. package/src/compute-view/element-view/predicates/element-ref.ts +37 -0
  87. package/src/compute-view/element-view/predicates/relation-direct.ts +309 -0
  88. package/src/compute-view/element-view/predicates/relation-in-out.ts +66 -0
  89. package/src/compute-view/element-view/predicates/relation-in.ts +118 -0
  90. package/src/compute-view/element-view/predicates/relation-out.ts +116 -0
  91. package/src/compute-view/element-view/predicates/wildcard.ts +88 -0
  92. package/src/compute-view/element-view/utils.ts +59 -0
  93. package/src/compute-view/index.ts +3 -4
  94. package/src/compute-view/memory/AbstractMemory.ts +45 -0
  95. package/src/compute-view/memory/AbstractStageExclude.ts +216 -0
  96. package/src/compute-view/memory/AbstractStageInclude.ts +200 -0
  97. package/src/compute-view/memory/_types.ts +147 -0
  98. package/src/compute-view/memory/index.ts +5 -0
  99. package/src/compute-view/memory/ops.ts +43 -0
  100. package/src/compute-view/utils/buildComputedNodes.ts +4 -4
  101. package/src/compute-view/utils/elementExpressionToPredicate.ts +1 -3
  102. package/src/compute-view/utils/link-nodes-with-edges.ts +3 -7
  103. package/src/compute-view/utils/{derive-edge-props-from-relationships.ts → merge-props-from-relationships.ts} +54 -23
  104. package/src/compute-view/utils/relationExpressionToPredicates.ts +2 -2
  105. package/src/compute-view/utils/resolve-extended-views.ts +44 -40
  106. package/src/compute-view/utils/resolve-global-rules.ts +6 -6
  107. package/src/compute-view/utils/topological-sort.ts +167 -71
  108. package/src/compute-view/utils/with-readable-edges.ts +14 -9
  109. package/src/index.ts +22 -16
  110. package/src/model/DeploymentElementModel.ts +150 -85
  111. package/src/model/DeploymentModel.ts +27 -21
  112. package/src/model/ElementModel.ts +51 -25
  113. package/src/model/LikeC4Model.test-d.ts +4 -3
  114. package/src/model/LikeC4Model.ts +98 -42
  115. package/src/model/RelationModel.ts +5 -4
  116. package/src/model/__test__/fixture.ts +5 -9
  117. package/src/model/connection/Connection.ts +72 -0
  118. package/src/model/connection/deployment/DeploymentConnectionModel.ts +178 -0
  119. package/src/model/connection/{deployment.ts → deployment/find.ts} +14 -18
  120. package/src/model/connection/deployment/index.ts +8 -0
  121. package/src/model/connection/index.ts +22 -0
  122. package/src/model/connection/model/ConnectionModel.ts +157 -0
  123. package/src/model/connection/{model.ts → model/find.ts} +43 -49
  124. package/src/model/connection/model/index.ts +8 -0
  125. package/src/model/connection/ops.ts +274 -0
  126. package/src/model/guards.ts +9 -0
  127. package/src/model/index.ts +45 -3
  128. package/src/model/types.ts +35 -18
  129. package/src/model/view/EdgeModel.ts +6 -6
  130. package/src/model/view/LikeC4ViewModel.ts +14 -8
  131. package/src/model/view/NodeModel.ts +6 -5
  132. package/src/types/_common.ts +53 -1
  133. package/src/types/deployments.ts +88 -156
  134. package/src/types/element.ts +2 -2
  135. package/src/types/expression-v2.ts +172 -0
  136. package/src/types/expression.ts +9 -5
  137. package/src/types/global.ts +3 -3
  138. package/src/types/index.ts +220 -13
  139. package/src/types/model.ts +28 -24
  140. package/src/types/operators.ts +1 -1
  141. package/src/types/relation.ts +14 -10
  142. package/src/types/theme.ts +0 -1
  143. package/src/types/view.ts +20 -18
  144. package/src/utils/const.ts +1 -0
  145. package/src/utils/fqn.ts +140 -49
  146. package/src/utils/getOrCreate.ts +1 -1
  147. package/src/utils/index.ts +75 -9
  148. package/src/utils/iterable/_types.ts +5 -0
  149. package/src/utils/iterable/filter.ts +55 -0
  150. package/src/utils/iterable/find.ts +36 -0
  151. package/src/utils/iterable/flat.ts +17 -0
  152. package/src/utils/iterable/index.ts +13 -0
  153. package/src/utils/iterable/map.ts +40 -0
  154. package/src/utils/iterable/reduce.ts +24 -0
  155. package/src/utils/iterable/some.ts +36 -0
  156. package/src/utils/iterable/to.ts +19 -0
  157. package/src/utils/iterable/unique.ts +29 -0
  158. package/src/utils/relations.ts +3 -64
  159. package/src/utils/set.ts +11 -9
  160. package/src/utils/string-hash.ts +1 -1
  161. package/dist/compute-view/index.mjs +0 -79
  162. package/dist/model/index.mjs +0 -2
  163. package/dist/shared/core.BBgiAAv1.mjs +0 -144
  164. package/dist/shared/core.BPyJvuMU.mjs +0 -2420
  165. package/dist/shared/core.BQ4AbfvB.mjs +0 -9228
  166. package/dist/shared/core.k12s_keD.mjs +0 -203
  167. package/dist/types/index.mjs +0 -21
  168. package/src/builder/Builder.test-d.ts +0 -124
  169. package/src/builder/Builder.view.ts +0 -543
  170. package/src/compute-view/LikeC4ModelGraph.ts +0 -330
  171. package/src/compute-view/deployment-view/Memory.ts +0 -108
  172. package/src/compute-view/deployment-view/Stage.ts +0 -145
  173. package/src/compute-view/deployment-view/predicates/deployment-ref.ts +0 -146
  174. package/src/compute-view/element-view/predicates.ts +0 -517
  175. package/src/compute-view/utils/sortNodes.ts +0 -101
  176. package/src/model/connection/ConnectionModel.ts +0 -94
  177. package/src/model/connection/DeploymentConnectionModel.ts +0 -99
@@ -1,13 +1,220 @@
1
- export * from './_common'
2
- export * from './deployments'
3
- export * from './element'
4
- export * from './expression'
5
- export * from './global'
6
- export * from './model'
7
- export * from './operators'
8
- export * from './overview-graph'
9
- export * from './relation'
10
- export * from './theme'
11
- export * from './view'
12
- export * from './view-changes'
13
- export * from './view-notation'
1
+ export type {
2
+ CustomColor,
3
+ ExclusiveUnion,
4
+ IconUrl,
5
+ IteratorLike,
6
+ KeysOf,
7
+ NonEmptyArray,
8
+ NonEmptyReadonlyArray,
9
+ NTuple,
10
+ Point,
11
+ Predicate,
12
+ XYPoint,
13
+ } from './_common'
14
+
15
+ export { DeploymentElement } from './deployments'
16
+ export type {
17
+ DeployedInstance,
18
+ DeploymentElementStyle,
19
+ DeploymentNode,
20
+ DeploymentNodeKind,
21
+ DeploymentNodeKindSpecification,
22
+ DeploymentRef,
23
+ DeploymentRelation,
24
+ PredicateSelector,
25
+ } from './deployments'
26
+
27
+ export {
28
+ AsFqn,
29
+ BorderStyles,
30
+ DefaultElementShape,
31
+ DefaultThemeColor,
32
+ ElementKind,
33
+ ElementShapes,
34
+ } from './element'
35
+ export type {
36
+ BorderStyle,
37
+ Element,
38
+ ElementKindSpecification,
39
+ ElementKindSpecificationStyle,
40
+ ElementShape,
41
+ ElementStyle,
42
+ Fqn,
43
+ Link,
44
+ Tag,
45
+ TagSpec,
46
+ TypedElement,
47
+ } from './element'
48
+
49
+ export {
50
+ isCustomElement,
51
+ isCustomRelationExpr,
52
+ isElement,
53
+ isElementKindExpr,
54
+ isElementPredicateExpr,
55
+ isElementRef,
56
+ isElementTagExpr,
57
+ isElementWhere,
58
+ isExpandedElementExpr,
59
+ isIncoming,
60
+ isInOut,
61
+ isOutgoing,
62
+ isRelation,
63
+ isRelationExpression,
64
+ isRelationPredicateExpr,
65
+ isRelationWhere,
66
+ isWildcard,
67
+ } from './expression'
68
+ export type {
69
+ CustomElementExpr,
70
+ CustomRelationExpr,
71
+ DirectRelationExpr,
72
+ ElementExpression,
73
+ ElementKindExpr,
74
+ ElementPredicateExpression,
75
+ ElementRefExpr,
76
+ ElementTagExpr,
77
+ ElementWhereExpr,
78
+ ExpandedElementExpr,
79
+ Expression,
80
+ IncomingExpr,
81
+ InOutExpr,
82
+ NonWilcard,
83
+ OutgoingExpr,
84
+ RelationExpression,
85
+ RelationPredicateExpression,
86
+ RelationWhereExpr,
87
+ WildcardExpr,
88
+ } from './expression'
89
+
90
+ export { ExpressionV2, FqnExpr, FqnRef, RelationExpr } from './expression-v2'
91
+
92
+ export type {
93
+ GlobalDynamicPredicates,
94
+ GlobalPredicateId,
95
+ GlobalPredicates,
96
+ GlobalStyleID,
97
+ GlobalStyles,
98
+ ModelGlobals,
99
+ } from './global'
100
+
101
+ export type {
102
+ AnyParsedLikeC4Model,
103
+ ComputedLikeC4Model,
104
+ GenericLikeC4Model,
105
+ LayoutedLikeC4Model,
106
+ LikeC4ModelDump,
107
+ ParsedLikeC4Model,
108
+ } from './model'
109
+
110
+ export {
111
+ isAndOperator,
112
+ isKindEqual,
113
+ isNotOperator,
114
+ isOrOperator,
115
+ isTagEqual,
116
+ whereOperatorAsPredicate,
117
+ } from './operators'
118
+ export type {
119
+ AndOperator,
120
+ EqualOperator,
121
+ Filterable,
122
+ KindEqual,
123
+ NotOperator,
124
+ OrOperator,
125
+ TagEqual,
126
+ WhereOperator,
127
+ } from './operators'
128
+ export type { OverviewGraph } from './overview-graph'
129
+ export { DefaultArrowType, DefaultLineStyle, DefaultRelationshipColor } from './relation'
130
+ export type {
131
+ AbstractRelation,
132
+ ModelRelation,
133
+ RelationId,
134
+ RelationshipArrowType,
135
+ RelationshipKind,
136
+ RelationshipKindSpecification,
137
+ RelationshipLineType,
138
+ } from './relation'
139
+ export { isThemeColor } from './theme'
140
+ export type {
141
+ Color,
142
+ ColorLiteral,
143
+ ElementThemeColors,
144
+ ElementThemeColorValues,
145
+ HexColorLiteral,
146
+ LikeC4Theme,
147
+ RelationshipThemeColors,
148
+ RelationshipThemeColorValues,
149
+ ThemeColor,
150
+ ThemeColorValues,
151
+ } from './theme'
152
+ export {
153
+ ComputedNode, // namespace
154
+ ComputedView, // namespace
155
+ DiagramNode, // namespace
156
+ extractStep,
157
+ getBBoxCenter,
158
+ getParallelStepsPrefix,
159
+ isAutoLayoutDirection,
160
+ isDeploymentView,
161
+ isDynamicView,
162
+ isDynamicViewParallelSteps,
163
+ isElementView,
164
+ isExtendsElementView,
165
+ isScopedElementView,
166
+ isStepEdgeId,
167
+ isViewRuleAutoLayout,
168
+ isViewRuleGlobalPredicateRef,
169
+ isViewRuleGlobalStyle,
170
+ isViewRuleGroup,
171
+ isViewRulePredicate,
172
+ isViewRuleStyle,
173
+ stepEdgeId,
174
+ } from './view'
175
+ export type {
176
+ AutoLayoutDirection,
177
+ BasicElementView,
178
+ BasicView,
179
+ BBox,
180
+ ComputedDeploymentView,
181
+ ComputedDynamicView,
182
+ ComputedEdge,
183
+ ComputedElementView,
184
+ CustomColorDefinitions,
185
+ DeploymentView,
186
+ DeploymentViewRule,
187
+ DeploymentViewRulePredicate,
188
+ DeploymentViewRuleStyle,
189
+ DiagramEdge,
190
+ DiagramView,
191
+ DynamicView,
192
+ DynamicViewIncludeRule,
193
+ DynamicViewParallelSteps,
194
+ DynamicViewRule,
195
+ DynamicViewStep,
196
+ DynamicViewStepOrParallel,
197
+ EdgeId,
198
+ ElementView,
199
+ ExtendsElementView,
200
+ LikeC4View,
201
+ NodeId,
202
+ ScopedElementView,
203
+ StepEdgeId,
204
+ StepEdgeIdLiteral,
205
+ ViewAutoLayout,
206
+ ViewId,
207
+ ViewManualLayout,
208
+ ViewRule,
209
+ ViewRuleAutoLayout,
210
+ ViewRuleGlobalPredicateRef,
211
+ ViewRuleGlobalStyle,
212
+ ViewRuleGroup,
213
+ ViewRulePredicate,
214
+ ViewRuleStyle,
215
+ ViewRuleStyleOrGlobalRef,
216
+ ViewWithHash,
217
+ ViewWithNotation,
218
+ } from './view'
219
+ export type { ViewChange } from './view-changes'
220
+ export type { ElementNotation } from './view-notation'
@@ -1,4 +1,3 @@
1
- import type { KeysOf } from './_common'
2
1
  import type {
3
2
  DeploymentElement,
4
3
  DeploymentNodeKind,
@@ -7,11 +6,22 @@ import type {
7
6
  } from './deployments'
8
7
  import type { ElementKindSpecification, Tag, TypedElement } from './element'
9
8
  import type { ModelGlobals } from './global'
10
- import type { Relation, RelationId, RelationshipKindSpecification } from './relation'
9
+ import type { ModelRelation, RelationId, RelationshipKindSpecification } from './relation'
11
10
  import type { ComputedView, DiagramView, LikeC4View } from './view'
12
11
 
13
12
  /**
14
- * Parsed elements, relations, and views.
13
+ * Represents a LikeC4 model with customizable type parameters,
14
+ * parsed from DSL or result from Builder
15
+ *
16
+ * !IMPORTANT: This is a low-level type, use `LikeC4Model` instead.
17
+ * !NOTE: Views are not computed yet.
18
+ *
19
+ * @typeParam ElementKinds - Types of elements in the model (defaults to string)
20
+ * @typeParam RelationKinds - Types of relationships (defaults to string)
21
+ * @typeParam Tags - Types of tags that can be applied (defaults to string)
22
+ * @typeParam Fqns - Fully Qualified Names for elements (defaults to string)
23
+ * @typeParam Views - Types of views in the model (defaults to string)
24
+ * @typeParam DeploymentFqns - Fully Qualified Names for deployment nodes (defaults to string)
15
25
  */
16
26
  export interface ParsedLikeC4Model<
17
27
  ElementKinds extends string = string,
@@ -21,6 +31,8 @@ export interface ParsedLikeC4Model<
21
31
  Views extends string = string,
22
32
  DeploymentFqns extends string = string
23
33
  > {
34
+ // To prevent accidental use of this type
35
+ __?: never
24
36
  specification: {
25
37
  tags: Tag<Tags>[]
26
38
  elements: Record<ElementKinds, ElementKindSpecification>
@@ -28,7 +40,7 @@ export interface ParsedLikeC4Model<
28
40
  relationships: Record<RelationKinds, RelationshipKindSpecification>
29
41
  }
30
42
  elements: Record<Fqns, TypedElement<Fqns, ElementKinds, Tags>>
31
- relations: Record<RelationId, Relation>
43
+ relations: Record<RelationId, ModelRelation>
32
44
  globals: ModelGlobals
33
45
  views: Record<Views, LikeC4View<Views, Tags>>
34
46
  /**
@@ -39,10 +51,12 @@ export interface ParsedLikeC4Model<
39
51
  relations: Record<RelationId, DeploymentRelation>
40
52
  }
41
53
  }
54
+
55
+ export type AnyParsedLikeC4Model = ParsedLikeC4Model<any, any, any, any, any, any>
42
56
  /**
43
57
  * Hook to get types from dump
44
58
  */
45
- export type ParsedLikeC4ModelDump = {
59
+ export type LikeC4ModelDump = {
46
60
  elements: {
47
61
  [kind: string]: object
48
62
  }
@@ -56,45 +70,35 @@ export type ParsedLikeC4ModelDump = {
56
70
  }
57
71
  }
58
72
 
59
- export interface AnyLikeC4Model<
73
+ /**
74
+ * Same as {@link ParsedLikeC4Model}, but with computed views or layouted views.
75
+ */
76
+ export interface GenericLikeC4Model<
60
77
  Fqns extends string = string,
61
78
  DeploymentFqns extends string = string,
62
79
  Views extends string = string,
63
80
  Tags extends string = string,
64
81
  T = 'computed' | 'layouted'
65
- > extends Omit<ParsedLikeC4Model<string, string, Tags, Fqns, Views, DeploymentFqns>, 'views'> {
82
+ > extends Omit<ParsedLikeC4Model<string, string, Tags, Fqns, Views, DeploymentFqns>, 'views' | '__'> {
66
83
  __?: T
67
- views: Record<Views, ComputedView | DiagramView>
84
+ views: Record<Views, ComputedView<Views> | DiagramView<Views>>
68
85
  }
69
86
 
70
- /**
71
- * Same as `ParsedLikeC4Model` but with computed views.
72
- */
73
87
  export interface ComputedLikeC4Model<
74
88
  Fqns extends string = string,
75
89
  DeploymentFqns extends string = string,
76
90
  Views extends string = string,
77
91
  Tags extends string = string
78
- > extends Omit<AnyLikeC4Model<Fqns, DeploymentFqns, Views, Tags, 'computed'>, 'views'> {
79
- views: Record<Views, ComputedView>
92
+ > extends Omit<GenericLikeC4Model<Fqns, DeploymentFqns, Views, Tags, 'computed'>, 'views'> {
93
+ views: Record<Views, ComputedView<Views>>
80
94
  }
81
95
 
82
- export type ComputedLikeC4ModelFromParsed<M> = M extends ParsedLikeC4Model ? ComputedLikeC4Model<
83
- KeysOf<M['elements']>,
84
- KeysOf<M['deployments']['elements']>,
85
- KeysOf<M['views']>
86
- >
87
- : ComputedLikeC4Model
88
-
89
- /**
90
- * Same as `ParsedLikeC4Model` but with layouted views (DiagramView)
91
- */
92
96
  export interface LayoutedLikeC4Model<
93
97
  Fqns extends string = string,
94
98
  DeploymentFqns extends string = string,
95
99
  Views extends string = string,
96
100
  Tags extends string = string
97
- > extends Omit<AnyLikeC4Model<Fqns, DeploymentFqns, Views, Tags, 'layouted'>, 'views'> {
101
+ > extends Omit<GenericLikeC4Model<Fqns, DeploymentFqns, Views, Tags, 'layouted'>, 'views'> {
98
102
  __: 'layouted'
99
103
  views: Record<Views, DiagramView<Views, Tags>>
100
104
  }
@@ -64,7 +64,7 @@ export type Filterable<
64
64
  FTag extends string = string,
65
65
  FKind extends string = string
66
66
  > = {
67
- tags?: FTag[] | null
67
+ tags?: readonly FTag[] | null
68
68
  kind?: FKind
69
69
  }
70
70
 
@@ -22,30 +22,34 @@ export type RelationshipArrowType =
22
22
  | 'open'
23
23
  | 'vee'
24
24
 
25
- export const DefaultLineStyle = 'dashed' satisfies RelationshipLineType
26
- export const DefaultArrowType = 'normal' satisfies RelationshipArrowType
27
- export const DefaultRelationshipColor = 'gray' satisfies ThemeColor
25
+ export const DefaultLineStyle: RelationshipLineType = 'dashed'
26
+ export const DefaultArrowType: RelationshipArrowType = 'normal'
27
+ export const DefaultRelationshipColor: ThemeColor = 'gray'
28
28
 
29
- // TODO: rename to Relationship
30
- export interface Relation {
29
+ export interface AbstractRelation {
31
30
  readonly id: RelationId
32
- readonly source: Fqn
33
- readonly target: Fqn
34
- readonly title: string
31
+ readonly title?: string
35
32
  readonly description?: string
36
33
  readonly technology?: string
37
- readonly tags?: NonEmptyArray<Tag>
34
+ readonly tags?: NonEmptyArray<Tag> | null
38
35
  readonly kind?: RelationshipKind
39
36
  readonly color?: Color
40
37
  readonly line?: RelationshipLineType
41
38
  readonly head?: RelationshipArrowType
42
39
  readonly tail?: RelationshipArrowType
43
- readonly links?: NonEmptyArray<Link>
40
+ readonly links?: NonEmptyArray<Link> | null
44
41
  // Link to dynamic view
45
42
  readonly navigateTo?: ViewId
46
43
  readonly metadata?: { [key: string]: string }
47
44
  }
48
45
 
46
+ // TODO: rename to Relationship
47
+ export interface ModelRelation extends AbstractRelation {
48
+ readonly source: Fqn
49
+ readonly target: Fqn
50
+ readonly title: string
51
+ }
52
+
49
53
  export interface RelationshipKindSpecification {
50
54
  readonly technology?: string
51
55
  readonly notation?: string
@@ -1,5 +1,4 @@
1
1
  import type { LiteralUnion } from 'type-fest'
2
- import type { CustomColor } from './_common'
3
2
 
4
3
  const ThemeColors = [
5
4
  'amber',
package/src/types/view.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { isArray, isNullish } from 'remeda'
2
2
  import type { Tagged } from 'type-fest'
3
3
  import type { IconUrl, NonEmptyArray, Point, XYPoint } from './_common'
4
- import type { DeploymentExpression } from './deployments'
5
4
  import {
6
5
  type BorderStyle,
7
6
  ElementKind,
@@ -9,9 +8,10 @@ import {
9
8
  type ElementStyle,
10
9
  type Fqn,
11
10
  type Link,
12
- type Tag
11
+ type Tag,
13
12
  } from './element'
14
13
  import type { ElementExpression, ElementPredicateExpression, Expression } from './expression'
14
+ import type { ExpressionV2, FqnExpr } from './expression-v2'
15
15
  import type { GlobalPredicateId, GlobalStyleID } from './global'
16
16
  import type { RelationId, RelationshipArrowType, RelationshipKind, RelationshipLineType } from './relation'
17
17
  import type { Color, ThemeColorValues } from './theme'
@@ -82,7 +82,7 @@ export interface ViewRuleAutoLayout {
82
82
  }
83
83
 
84
84
  export function isViewRuleAutoLayout(
85
- rule: DeploymentViewRule | DynamicViewRule | ViewRule
85
+ rule: DeploymentViewRule | DynamicViewRule | ViewRule,
86
86
  ): rule is ViewRuleAutoLayout {
87
87
  return 'direction' in rule
88
88
  }
@@ -111,7 +111,7 @@ export type ViewRule =
111
111
  export interface BasicView<
112
112
  ViewType extends 'element' | 'dynamic' | 'deployment',
113
113
  ViewIDs extends string,
114
- Tags extends string
114
+ Tags extends string,
115
115
  > {
116
116
  readonly __?: ViewType
117
117
  readonly id: ViewId<ViewIDs>
@@ -162,7 +162,7 @@ export interface ExtendsElementView<ViewIDs extends string, Tags extends string>
162
162
  }
163
163
  export type ElementView<
164
164
  ViewIDs extends string = string,
165
- Tags extends string = string
165
+ Tags extends string = string,
166
166
  > =
167
167
  | ScopedElementView<ViewIDs, Tags>
168
168
  | ExtendsElementView<ViewIDs, Tags>
@@ -205,7 +205,7 @@ export type DynamicViewRule =
205
205
  | ViewRuleAutoLayout
206
206
  export interface DynamicView<
207
207
  ViewIDs extends string = string,
208
- Tags extends string = string
208
+ Tags extends string = string,
209
209
  > extends BasicView<'dynamic', ViewIDs, Tags> {
210
210
  readonly __: 'dynamic'
211
211
 
@@ -222,15 +222,15 @@ export type CustomColorDefinitions = { [key: string]: ThemeColorValues }
222
222
 
223
223
  export type DeploymentViewRulePredicate =
224
224
  | {
225
- include: DeploymentExpression[]
225
+ include: ExpressionV2[]
226
226
  exclude?: never
227
227
  }
228
228
  | {
229
229
  include?: never
230
- exclude: DeploymentExpression[]
230
+ exclude: ExpressionV2[]
231
231
  }
232
232
  export type DeploymentViewRuleStyle = {
233
- targets: DeploymentExpression[]
233
+ targets: FqnExpr[]
234
234
  notation?: string
235
235
  style: ElementStyle & {
236
236
  color?: Color
@@ -242,7 +242,7 @@ export type DeploymentViewRule = DeploymentViewRulePredicate | ViewRuleAutoLayou
242
242
 
243
243
  export interface DeploymentView<
244
244
  ViewIDs extends string = string,
245
- Tags extends string = string
245
+ Tags extends string = string,
246
246
  > extends BasicView<'deployment', ViewIDs, Tags> {
247
247
  readonly __: 'deployment'
248
248
  readonly rules: DeploymentViewRule[]
@@ -250,7 +250,7 @@ export interface DeploymentView<
250
250
 
251
251
  export type LikeC4View<
252
252
  ViewIDs extends string = string,
253
- Tags extends string = string
253
+ Tags extends string = string,
254
254
  > = ElementView<ViewIDs, Tags> | DynamicView<ViewIDs, Tags> | DeploymentView<ViewIDs, Tags>
255
255
 
256
256
  export function isDeploymentView(view: LikeC4View): view is DeploymentView
@@ -258,9 +258,11 @@ export function isDeploymentView<V extends { __?: string }>(view: V): boolean
258
258
  export function isDeploymentView(view: LikeC4View): view is DeploymentView {
259
259
  return view.__ === 'deployment'
260
260
  }
261
+
261
262
  export function isDynamicView(view: LikeC4View): view is DynamicView {
262
263
  return view.__ === 'dynamic'
263
264
  }
265
+
264
266
  export function isElementView(view: LikeC4View): view is ElementView {
265
267
  return isNullish(view.__) || view.__ === 'element'
266
268
  }
@@ -408,7 +410,7 @@ export interface ViewAutoLayout {
408
410
  }
409
411
  export interface ComputedElementView<
410
412
  ViewIDs extends string = string,
411
- Tags extends string = string
413
+ Tags extends string = string,
412
414
  > extends Omit<ElementView<ViewIDs, Tags>, 'rules' | 'docUri'>, ViewWithHash, ViewWithNotation {
413
415
  readonly extends?: ViewId<ViewIDs>
414
416
  readonly autoLayout: ViewAutoLayout
@@ -419,7 +421,7 @@ export interface ComputedElementView<
419
421
  }
420
422
  export interface ComputedDynamicView<
421
423
  ViewIDs extends string = string,
422
- Tags extends string = string
424
+ Tags extends string = string,
423
425
  > extends Omit<DynamicView<ViewIDs, Tags>, 'rules' | 'steps' | 'docUri'>, ViewWithHash, ViewWithNotation {
424
426
  readonly autoLayout: ViewAutoLayout
425
427
  readonly nodes: ComputedNode[]
@@ -431,7 +433,7 @@ export interface ComputedDynamicView<
431
433
 
432
434
  export interface ComputedDeploymentView<
433
435
  ViewIDs extends string = string,
434
- Tags extends string = string
436
+ Tags extends string = string,
435
437
  > extends Omit<DeploymentView<ViewIDs, Tags>, 'rules' | 'docUri'>, ViewWithHash, ViewWithNotation {
436
438
  readonly autoLayout: ViewAutoLayout
437
439
  readonly nodes: ComputedNode[]
@@ -442,7 +444,7 @@ export interface ComputedDeploymentView<
442
444
 
443
445
  export type ComputedView<
444
446
  ViewIDs extends string = string,
445
- Tags extends string = string
447
+ Tags extends string = string,
446
448
  > = ComputedElementView<ViewIDs, Tags> | ComputedDynamicView<ViewIDs, Tags> | ComputedDeploymentView<ViewIDs, Tags>
447
449
 
448
450
  export namespace ComputedView {
@@ -469,11 +471,11 @@ export function getBBoxCenter({
469
471
  x,
470
472
  y,
471
473
  width,
472
- height
474
+ height,
473
475
  }: BBox): XYPoint {
474
476
  return {
475
477
  x: x + width / 2,
476
- y: y + height / 2
478
+ y: y + height / 2,
477
479
  }
478
480
  }
479
481
 
@@ -513,7 +515,7 @@ export interface DiagramEdge extends ComputedEdge {
513
515
 
514
516
  export interface DiagramView<
515
517
  ViewIDs extends string = string,
516
- Tags extends string = string
518
+ Tags extends string = string,
517
519
  > extends Omit<ComputedView<ViewIDs, Tags>, 'nodes' | 'edges' | 'manualLayout'> {
518
520
  readonly nodes: DiagramNode[]
519
521
  readonly edges: DiagramEdge[]
@@ -0,0 +1 @@
1
+ export const customInspectSymbol = Symbol.for('nodejs.util.inspect.custom')