@likec4/core 1.31.0 → 1.32.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 (185) 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 +9 -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.Bq753SYD.mjs → core.CBpKAlhj.mjs} +2012 -4422
  17. package/dist/shared/core.CUYDgv2-.mjs +214 -0
  18. package/dist/shared/{core.Cu-UdkSl.mjs → core.CpXlRyE5.mjs} +7 -494
  19. package/dist/shared/{core.C-YXI-43.mjs → core.Cy9smucx.mjs} +3 -1
  20. package/dist/shared/core.CywrQs86.d.mts +31 -0
  21. package/dist/shared/core.DXzRBkuI.d.mts +1264 -0
  22. package/dist/shared/core.DoK86JEe.mjs +518 -0
  23. package/dist/shared/{core.D2830qgg.d.mts → core.Pf5I9o0e.d.mts} +1 -1
  24. package/dist/shared/core.cbA9VZ02.mjs +2681 -0
  25. package/dist/shared/{core.CQXU9DF7.mjs → core.rmvsy0n3.mjs} +23 -32
  26. package/dist/shared/core.znRaUX_A.d.mts +920 -0
  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 +16 -8
  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 +171 -144
  109. package/src/model/DeploymentModel.ts +88 -65
  110. package/src/model/ElementModel.ts +85 -74
  111. package/src/model/LikeC4Model.ts +430 -241
  112. package/src/model/RelationModel.ts +63 -29
  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/{theme.ts → styles.ts} +55 -15
  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.CQDU11hR.d.mts +0 -753
  169. package/dist/shared/core.DJvmfnEi.d.mts +0 -1153
  170. package/dist/shared/core.DgfwjBtu.mjs +0 -495
  171. package/dist/shared/core.Dx7siloV.d.mts +0 -146
  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/view-notation.ts +0 -9
  184. package/src/utils/graphlib.ts +0 -10
  185. /package/src/{errors/index.ts → utils/invariant.ts} +0 -0
@@ -1,1153 +0,0 @@
1
- import { d as IconUrl, F as Fqn, N as NonEmptyArray, T as Tag, E as ExclusiveUnion, e as ProjectId, P as Point, X as XYPoint } from './core.SjLhMA7a.mjs';
2
- import { LiteralUnion, TupleToUnion, Tagged, NonEmptyTuple, Simplify, MergeExclusive } from 'type-fest';
3
-
4
- declare const ThemeColors: readonly ["amber", "blue", "gray", "slate", "green", "indigo", "muted", "primary", "red", "secondary", "sky"];
5
- type ThemeColor = typeof ThemeColors[number];
6
- type HexColorLiteral = `#${string}`;
7
- type ColorLiteral = HexColorLiteral;
8
- type Color = LiteralUnion<ThemeColor, string>;
9
- type ShapeSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
10
- /**
11
- * For padding, margin, etc.
12
- */
13
- type SpacingSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
14
- type TextSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
15
- declare function isThemeColor(color: Color): color is ThemeColor;
16
- interface ElementThemeColorValues {
17
- fill: ColorLiteral;
18
- stroke: ColorLiteral;
19
- hiContrast: ColorLiteral;
20
- loContrast: ColorLiteral;
21
- }
22
- type ElementThemeColors = {
23
- [key in ThemeColor]: ElementThemeColorValues;
24
- };
25
- interface RelationshipThemeColorValues {
26
- lineColor: ColorLiteral;
27
- labelBgColor: ColorLiteral;
28
- labelColor: ColorLiteral;
29
- }
30
- interface ThemeColorValues {
31
- elements: ElementThemeColorValues;
32
- relationships: RelationshipThemeColorValues;
33
- }
34
- type RelationshipThemeColors = {
35
- [key in ThemeColor]: RelationshipThemeColorValues;
36
- };
37
- interface LikeC4Theme {
38
- font: 'Arial';
39
- shadow: ColorLiteral;
40
- relationships: RelationshipThemeColors;
41
- elements: ElementThemeColors;
42
- sizes: {
43
- [key in ShapeSize]: {
44
- width: number;
45
- height: number;
46
- };
47
- };
48
- spacing: {
49
- [key in SpacingSize]: number;
50
- };
51
- textSizes: {
52
- [key in TextSize]: number;
53
- };
54
- }
55
-
56
- declare const BorderStyles: readonly ["solid", "dashed", "dotted", "none"];
57
- type BorderStyle = TupleToUnion<typeof BorderStyles>;
58
- type ElementKind<Kinds extends string = string> = Tagged<Kinds, 'ElementKind'>;
59
- declare namespace ElementKind {
60
- const Group: ElementKind;
61
- }
62
- declare const ElementShapes: readonly ["rectangle", "person", "browser", "mobile", "cylinder", "storage", "queue"];
63
- type ElementShape = TupleToUnion<typeof ElementShapes>;
64
- declare const DefaultThemeColor: ThemeColor;
65
- declare const DefaultElementShape: ElementShape;
66
- declare const DefaultShapeSize: ShapeSize;
67
- declare const DefaultPaddingSize: SpacingSize;
68
- declare const DefaultTextSize: TextSize;
69
- interface ElementStyle {
70
- readonly border?: BorderStyle;
71
- /**
72
- * In percentage 0-100, 0 is fully transparent
73
- *
74
- * @default 100
75
- */
76
- readonly opacity?: number;
77
- /**
78
- * If true, the element is rendered as multiple shapes
79
- * @default false
80
- */
81
- readonly multiple?: boolean;
82
- /**
83
- * Shape size
84
- *
85
- * @default 'md'
86
- */
87
- readonly size?: ShapeSize;
88
- readonly padding?: SpacingSize;
89
- readonly textSize?: TextSize;
90
- }
91
- interface TagSpec {
92
- readonly id: Tag;
93
- readonly style: ElementStyle;
94
- }
95
- interface Link {
96
- readonly title?: string;
97
- readonly url: string;
98
- readonly relative?: string;
99
- }
100
- interface TypedElement<Ids extends string, Kinds extends string, Tags extends string, MetadataKeys extends string = never> {
101
- readonly id: Fqn<Ids>;
102
- readonly kind: ElementKind<Kinds>;
103
- readonly title: string;
104
- readonly description: string | null;
105
- readonly technology: string | null;
106
- readonly tags: NonEmptyArray<Tag<Tags>> | null;
107
- readonly links: NonEmptyArray<Link> | null;
108
- readonly icon?: IconUrl;
109
- readonly shape?: ElementShape;
110
- readonly color?: Color;
111
- readonly style?: ElementStyle;
112
- readonly notation?: string;
113
- readonly metadata?: Record<MetadataKeys, string>;
114
- }
115
- interface Element extends TypedElement<string, string, string, string> {
116
- }
117
- interface ElementKindSpecificationStyle {
118
- shape?: ElementShape;
119
- icon?: IconUrl;
120
- color?: Color;
121
- border?: BorderStyle;
122
- opacity?: number;
123
- size?: ShapeSize;
124
- padding?: SpacingSize;
125
- textSize?: TextSize;
126
- }
127
- interface ElementKindSpecification {
128
- readonly technology?: string;
129
- readonly notation?: string;
130
- readonly style: ElementKindSpecificationStyle;
131
- }
132
-
133
- type EqualOperator<V> = {
134
- eq: V;
135
- neq?: never;
136
- } | {
137
- eq?: never;
138
- neq: V;
139
- };
140
- type AllNever = {
141
- not?: never;
142
- and?: never;
143
- or?: never;
144
- tag?: never;
145
- kind?: never;
146
- participant?: never;
147
- };
148
- type TagEqual<Tag> = Omit<AllNever, 'tag'> & {
149
- tag: EqualOperator<Tag>;
150
- };
151
- declare const isTagEqual: <Tag>(operator: WhereOperator<Tag, any>) => operator is TagEqual<Tag>;
152
- type KindEqual<Kind> = Omit<AllNever, 'kind'> & {
153
- kind: EqualOperator<Kind>;
154
- };
155
- declare const isKindEqual: <Kind>(operator: WhereOperator<any, Kind>) => operator is KindEqual<Kind>;
156
- type Participant = 'source' | 'target';
157
- type ParticipantOperator<Tag, Kind> = Omit<AllNever, 'participant'> & {
158
- participant: Participant;
159
- operator: KindEqual<Kind> | TagEqual<Tag>;
160
- };
161
- declare const isParticipantOperator: <Tag, Kind>(operator: WhereOperator<Tag, any>) => operator is ParticipantOperator<Tag, Kind>;
162
- type NotOperator<Tag, Kind> = Omit<AllNever, 'not'> & {
163
- not: WhereOperator<Tag, Kind>;
164
- };
165
- declare const isNotOperator: <Tag, Kind>(operator: WhereOperator<Tag, Kind>) => operator is NotOperator<Tag, Kind>;
166
- type AndOperator<Tag, Kind> = Omit<AllNever, 'and'> & {
167
- and: NonEmptyArray<WhereOperator<Tag, Kind>>;
168
- };
169
- declare const isAndOperator: <Tag, Kind>(operator: WhereOperator<Tag, Kind>) => operator is AndOperator<Tag, Kind>;
170
- type OrOperator<Tag, Kind> = Omit<AllNever, 'or'> & {
171
- or: NonEmptyArray<WhereOperator<Tag, Kind>>;
172
- };
173
- declare const isOrOperator: <Tag, Kind>(operator: WhereOperator<Tag, Kind>) => operator is OrOperator<Tag, Kind>;
174
- type WhereOperator<Tag, Kind> = TagEqual<Tag> | KindEqual<Kind> | ParticipantOperator<Tag, Kind> | NotOperator<Tag, Kind> | AndOperator<Tag, Kind> | OrOperator<Tag, Kind>;
175
- type Filterable<FTag extends string | null = string | null, FKind extends string | null = string | null> = {
176
- tags?: readonly FTag[] | null;
177
- kind?: FKind;
178
- source?: Filterable<FTag, FKind>;
179
- target?: Filterable<FTag, FKind>;
180
- };
181
- type OperatorPredicate<V extends Filterable> = (value: V) => boolean;
182
- declare function whereOperatorAsPredicate<FTag extends string | null = string | null, FKind extends string | null = string | null>(operator: WhereOperator<FTag, FKind>): OperatorPredicate<Filterable>;
183
-
184
- declare namespace FqnRef {
185
- /**
186
- * Represents a reference to an instance within a deployment.
187
- *
188
- * @template D - The type representing the deployment fqn. Defaults to `Fqn`.
189
- * @template M - The type representing the model fqn. Defaults to `Fqn`.
190
- *
191
- * @property {D} deployment - TThe fully qualified name (FQN) of the deployed instance.
192
- * @property {M} element - The element reference within the deployment.
193
- */
194
- type InsideInstanceRef<D = Fqn, M = Fqn> = {
195
- deployment: D;
196
- element: M;
197
- };
198
- const isInsideInstanceRef: (ref: FqnRef) => ref is InsideInstanceRef;
199
- /**
200
- * Represents a reference to a deployment element.
201
- *
202
- * @template F - The type of the fully qualified name (FQN) of the deployment element. Defaults to `Fqn`.
203
- * @property {F} deployment - The fully qualified name (FQN) of the deployment element.
204
- */
205
- type DeploymentElementRef<F = Fqn> = {
206
- deployment: F;
207
- };
208
- const isDeploymentElementRef: (ref: FqnRef) => ref is DeploymentElementRef;
209
- type DeploymentRef<D = Fqn, M = Fqn> = DeploymentElementRef<D> | InsideInstanceRef<D, M>;
210
- const isDeploymentRef: (ref: FqnRef) => ref is DeploymentRef;
211
- /**
212
- * Reference to logical model element
213
- */
214
- type ModelRef<F = Fqn> = {
215
- model: F;
216
- };
217
- const isModelRef: (ref: FqnRef) => ref is ModelRef;
218
- /**
219
- * Reference to imported logical model element
220
- */
221
- type ImportRef<F = Fqn> = {
222
- project: ProjectId;
223
- model: F;
224
- };
225
- const isImportRef: (ref: FqnRef) => ref is ImportRef;
226
- const toDeploymentRef: (ref: FqnRef) => DeploymentRef;
227
- const toModelFqn: (ref: FqnRef) => Fqn;
228
- }
229
- type FqnRef<D = Fqn, M = Fqn> = ExclusiveUnion<{
230
- InsideInstanceRef: FqnRef.InsideInstanceRef<D, M>;
231
- DeploymentRef: FqnRef.DeploymentRef<D>;
232
- ModelRef: FqnRef.ModelRef<M>;
233
- ImportRef: FqnRef.ImportRef<M>;
234
- }>;
235
- declare namespace FqnExpr {
236
- type Wildcard = {
237
- wildcard: true;
238
- };
239
- const isWildcard: (expr: ExpressionV2) => expr is FqnExpr.Wildcard;
240
- type ModelRef<M = Fqn> = {
241
- ref: FqnRef.ModelRef<M> | FqnRef.ImportRef<M>;
242
- selector?: PredicateSelector;
243
- };
244
- const isModelRef: (ref: ExpressionV2) => ref is FqnExpr.ModelRef;
245
- type DeploymentRef<D = Fqn, M = Fqn> = {
246
- ref: FqnRef.DeploymentRef<D> | FqnRef.InsideInstanceRef<D, M>;
247
- selector?: PredicateSelector;
248
- };
249
- const isDeploymentRef: (ref: ExpressionV2) => ref is FqnExpr.DeploymentRef;
250
- type ElementKindExpr = {
251
- elementKind: ElementKind;
252
- isEqual: boolean;
253
- };
254
- function isElementKindExpr(expr: ExpressionV2): expr is ElementKindExpr;
255
- type ElementTagExpr = {
256
- elementTag: Tag;
257
- isEqual: boolean;
258
- };
259
- function isElementTagExpr(expr: ExpressionV2): expr is ElementTagExpr;
260
- type NonWildcard<D = Fqn, M = Fqn> = ExclusiveUnion<{
261
- ModelRef: ModelRef<M>;
262
- DeploymentRef: DeploymentRef<D, M>;
263
- ElementKind: ElementKindExpr;
264
- ElementTag: ElementTagExpr;
265
- }>;
266
- type Where<D = Fqn, M = Fqn> = {
267
- where: {
268
- expr: ExclusiveUnion<{
269
- Wildcard: Wildcard;
270
- ModelRef: ModelRef<M>;
271
- DeploymentRef: DeploymentRef<D, M>;
272
- ElementKind: ElementKindExpr;
273
- ElementTag: ElementTagExpr;
274
- }>;
275
- condition: WhereOperator<string, string>;
276
- };
277
- };
278
- const isWhere: (expr: ExpressionV2) => expr is FqnExpr.Where;
279
- type Custom<D = Fqn, M = Fqn> = {
280
- custom: {
281
- expr: OrWhere<D, M>;
282
- title?: string;
283
- description?: string;
284
- technology?: string;
285
- notation?: string;
286
- shape?: ElementShape;
287
- color?: Color;
288
- icon?: IconUrl;
289
- border?: BorderStyle;
290
- opacity?: number;
291
- navigateTo?: ViewId;
292
- multiple?: boolean;
293
- size?: ShapeSize;
294
- padding?: ShapeSize;
295
- textSize?: ShapeSize;
296
- };
297
- };
298
- const isCustom: (expr: ExpressionV2) => expr is Custom;
299
- const is: (expr: ExpressionV2) => expr is FqnExpr;
300
- type OrWhere<D = Fqn, M = Fqn> = ExclusiveUnion<{
301
- Wildcard: FqnExpr.Wildcard;
302
- ModelRef: FqnExpr.ModelRef<M>;
303
- DeploymentRef: FqnExpr.DeploymentRef<D, M>;
304
- ElementKind: ElementKindExpr;
305
- ElementTag: ElementTagExpr;
306
- Where: FqnExpr.Where<D, M>;
307
- }>;
308
- type Any<D = Fqn, M = Fqn> = ExclusiveUnion<{
309
- Wildcard: Wildcard;
310
- ModelRef: ModelRef<M>;
311
- DeploymentRef: DeploymentRef<D, M>;
312
- ElementKind: ElementKindExpr;
313
- ElementTag: ElementTagExpr;
314
- Where: Where<D, M>;
315
- Custom: Custom<D, M>;
316
- }>;
317
- const unwrap: (expr: FqnExpr) => Wildcard | ModelRef | DeploymentRef | ElementKindExpr | ElementTagExpr;
318
- }
319
- type FqnExpr<D = Fqn, M = Fqn> = ExclusiveUnion<{
320
- Wildcard: FqnExpr.Wildcard;
321
- ModelRef: FqnExpr.ModelRef<M>;
322
- DeploymentRef: FqnExpr.DeploymentRef<D, M>;
323
- ElementKind: FqnExpr.ElementKindExpr;
324
- ElementTag: FqnExpr.ElementTagExpr;
325
- }>;
326
- declare namespace RelationExpr {
327
- type Endpoint<D = Fqn, M = Fqn> = FqnExpr.Where<D, M>['where']['expr'];
328
- type Direct<D = Fqn, M = Fqn> = {
329
- source: Endpoint<D, M>;
330
- target: Endpoint<D, M>;
331
- isBidirectional?: boolean;
332
- };
333
- const isDirect: (expr: ExpressionV2) => expr is RelationExpr.Direct;
334
- type Incoming<D = Fqn, M = Fqn> = {
335
- incoming: Endpoint<D, M>;
336
- };
337
- const isIncoming: (expr: ExpressionV2) => expr is RelationExpr.Incoming;
338
- type Outgoing<D = Fqn, M = Fqn> = {
339
- outgoing: Endpoint<D, M>;
340
- };
341
- const isOutgoing: (expr: ExpressionV2) => expr is RelationExpr.Outgoing;
342
- type InOut<D = Fqn, M = Fqn> = {
343
- inout: Endpoint<D, M>;
344
- };
345
- const isInOut: (expr: ExpressionV2) => expr is RelationExpr.InOut;
346
- type Where<D = Fqn, M = Fqn> = {
347
- where: {
348
- expr: ExclusiveUnion<{
349
- Direct: RelationExpr.Direct<D, M>;
350
- Incoming: RelationExpr.Incoming<D, M>;
351
- Outgoing: RelationExpr.Outgoing<D, M>;
352
- InOut: RelationExpr.InOut<D, M>;
353
- }>;
354
- condition: WhereOperator<string, string>;
355
- };
356
- };
357
- const isWhere: (expr: ExpressionV2) => expr is RelationExpr.Where;
358
- type Custom<D = Fqn, M = Fqn> = {
359
- customRelation: {
360
- expr: OrWhere<D, M>;
361
- title?: string;
362
- description?: string;
363
- technology?: string;
364
- notation?: string;
365
- navigateTo?: ViewId;
366
- notes?: string;
367
- color?: Color;
368
- line?: RelationshipLineType;
369
- head?: RelationshipArrowType;
370
- tail?: RelationshipArrowType;
371
- };
372
- };
373
- const isCustom: (expr: ExpressionV2) => expr is Custom;
374
- const is: (expr: ExpressionV2) => expr is RelationExpr;
375
- type OrWhere<D = Fqn, M = Fqn> = ExclusiveUnion<{
376
- Direct: Direct<D, M>;
377
- Incoming: Incoming<D, M>;
378
- Outgoing: Outgoing<D, M>;
379
- InOut: InOut<D, M>;
380
- Where: Where<D, M>;
381
- }>;
382
- type Any<D = Fqn, M = Fqn> = ExclusiveUnion<{
383
- Direct: Direct<D, M>;
384
- Incoming: Incoming<D, M>;
385
- Outgoing: Outgoing<D, M>;
386
- InOut: InOut<D, M>;
387
- Where: Where<D, M>;
388
- Custom: Custom<D, M>;
389
- }>;
390
- const unwrap: (expr: RelationExpr) => Direct | Incoming | Outgoing | InOut;
391
- }
392
- type RelationExpr<D = Fqn, M = Fqn> = ExclusiveUnion<{
393
- Direct: RelationExpr.Direct<D, M>;
394
- Incoming: RelationExpr.Incoming<D, M>;
395
- Outgoing: RelationExpr.Outgoing<D, M>;
396
- InOut: RelationExpr.InOut<D, M>;
397
- }>;
398
- /**
399
- * Represents a version 2 expression which can be one of several types.
400
- *
401
- * @template D - The type for the deployment FQN, defaults to `Fqn`.
402
- * @template M - The type for the model FQN, defaults to `Fqn`.
403
- */
404
- type ExpressionV2<D = Fqn, M = Fqn> = ExclusiveUnion<{
405
- Wildcard: FqnExpr.Wildcard;
406
- ModelRef: FqnExpr.ModelRef<M>;
407
- DeploymentRef: FqnExpr.DeploymentRef<D, M>;
408
- ElementKind: FqnExpr.ElementKindExpr;
409
- ElementTag: FqnExpr.ElementTagExpr;
410
- Custom: FqnExpr.Custom<D, M>;
411
- Direct: RelationExpr.Direct<D, M>;
412
- Incoming: RelationExpr.Incoming<D, M>;
413
- Outgoing: RelationExpr.Outgoing<D, M>;
414
- InOut: RelationExpr.InOut<D, M>;
415
- Where: ExpressionV2.Where<D, M>;
416
- CustomRelation: RelationExpr.Custom<D, M>;
417
- }>;
418
- declare namespace ExpressionV2 {
419
- type Where<D = Fqn, M = Fqn> = FqnExpr.Where<D, M> | RelationExpr.Where<D, M>;
420
- const isWhere: (expr: ExpressionV2) => expr is ExpressionV2.Where;
421
- const isRelationWhere: (expr: ExpressionV2) => expr is RelationExpr.Where;
422
- const isFqnExprWhere: (expr: ExpressionV2) => expr is FqnExpr.Where;
423
- const isFqnExpr: (expr: ExpressionV2) => expr is FqnExpr.Any;
424
- const isRelation: (expr: ExpressionV2) => expr is RelationExpr.Any;
425
- }
426
-
427
- declare namespace ModelLayer {
428
- namespace FqnRef {
429
- /**
430
- * Reference to logical model element
431
- */
432
- type ModelRef<F = Fqn> = {
433
- model: F;
434
- };
435
- const isModelRef: (ref: FqnRef) => ref is ModelRef;
436
- /**
437
- * Reference to imported logical model element
438
- */
439
- type ImportRef<F = Fqn> = {
440
- project: ProjectId;
441
- model: F;
442
- };
443
- const isImportRef: (ref: FqnRef) => ref is ImportRef;
444
- const toFqn: (ref: FqnRef) => Fqn;
445
- }
446
- type FqnRef<M = Fqn> = ExclusiveUnion<{
447
- ModelRef: FqnRef.ModelRef<M>;
448
- ImportRef: FqnRef.ImportRef<M>;
449
- }>;
450
- namespace FqnExpr {
451
- type Wildcard = {
452
- wildcard: true;
453
- };
454
- const isWildcard: (expr: Expression) => expr is FqnExpr.Wildcard;
455
- type ModelRef<M = Fqn> = {
456
- ref: FqnRef.ModelRef<M> | FqnRef.ImportRef<M>;
457
- selector?: PredicateSelector;
458
- };
459
- const isModelRef: (ref: Expression) => ref is FqnExpr.ModelRef;
460
- type ElementKindExpr = {
461
- elementKind: ElementKind;
462
- isEqual: boolean;
463
- };
464
- function isElementKindExpr(expr: Expression): expr is ElementKindExpr;
465
- type ElementTagExpr = {
466
- elementTag: Tag;
467
- isEqual: boolean;
468
- };
469
- function isElementTagExpr(expr: Expression): expr is ElementTagExpr;
470
- type NonWildcard<M = Fqn> = ExclusiveUnion<{
471
- ModelRef: ModelRef<M>;
472
- ElementKind: ElementKindExpr;
473
- ElementTag: ElementTagExpr;
474
- }>;
475
- type Where<M = Fqn> = {
476
- where: {
477
- expr: ExclusiveUnion<{
478
- Wildcard: Wildcard;
479
- ModelRef: ModelRef<M>;
480
- ElementKind: ElementKindExpr;
481
- ElementTag: ElementTagExpr;
482
- }>;
483
- condition: WhereOperator<string, string>;
484
- };
485
- };
486
- const isWhere: (expr: Expression) => expr is FqnExpr.Where;
487
- type Custom<M = Fqn> = {
488
- custom: {
489
- expr: FqnExprOrWhere<M>;
490
- title?: string;
491
- description?: string;
492
- technology?: string;
493
- notation?: string;
494
- shape?: ElementShape;
495
- color?: Color;
496
- icon?: IconUrl;
497
- border?: BorderStyle;
498
- opacity?: number;
499
- navigateTo?: ViewId;
500
- multiple?: boolean;
501
- size?: ShapeSize;
502
- padding?: ShapeSize;
503
- textSize?: ShapeSize;
504
- };
505
- };
506
- const isCustom: (expr: Expression) => expr is FqnExpr.Custom;
507
- const is: (expr: Expression) => expr is FqnExpr;
508
- }
509
- type FqnExpr<M = Fqn> = ExclusiveUnion<{
510
- Wildcard: FqnExpr.Wildcard;
511
- ModelRef: FqnExpr.ModelRef<M>;
512
- ElementKind: FqnExpr.ElementKindExpr;
513
- ElementTag: FqnExpr.ElementTagExpr;
514
- }>;
515
- type FqnExprOrWhere<M = Fqn> = ExclusiveUnion<{
516
- Wildcard: FqnExpr.Wildcard;
517
- ModelRef: FqnExpr.ModelRef<M>;
518
- ElementKind: FqnExpr.ElementKindExpr;
519
- ElementTag: FqnExpr.ElementTagExpr;
520
- Where: FqnExpr.Where<M>;
521
- }>;
522
- type AnyFqnExpr<M = Fqn> = ExclusiveUnion<{
523
- Wildcard: FqnExpr.Wildcard;
524
- ModelRef: FqnExpr.ModelRef<M>;
525
- ElementKind: FqnExpr.ElementKindExpr;
526
- ElementTag: FqnExpr.ElementTagExpr;
527
- Where: FqnExpr.Where<M>;
528
- Custom: FqnExpr.Custom<M>;
529
- }>;
530
- function isAnyFqnExpr(expr: Expression): expr is AnyFqnExpr;
531
- namespace RelationExpr {
532
- type Direct<M = Fqn> = {
533
- source: FqnExpr<M>;
534
- target: FqnExpr<M>;
535
- isBidirectional?: boolean;
536
- };
537
- const isDirect: (expr: Expression) => expr is RelationExpr.Direct;
538
- type Incoming<M = Fqn> = {
539
- incoming: FqnExpr<M>;
540
- };
541
- const isIncoming: (expr: Expression) => expr is RelationExpr.Incoming;
542
- type Outgoing<M = Fqn> = {
543
- outgoing: FqnExpr<M>;
544
- };
545
- const isOutgoing: (expr: Expression) => expr is RelationExpr.Outgoing;
546
- type InOut<M = Fqn> = {
547
- inout: FqnExpr<M>;
548
- };
549
- const isInOut: (expr: Expression) => expr is RelationExpr.InOut;
550
- type Where<M = Fqn> = {
551
- where: {
552
- expr: ExclusiveUnion<{
553
- Direct: RelationExpr.Direct<M>;
554
- Incoming: RelationExpr.Incoming<M>;
555
- Outgoing: RelationExpr.Outgoing<M>;
556
- InOut: RelationExpr.InOut<M>;
557
- }>;
558
- condition: WhereOperator<string, string>;
559
- };
560
- };
561
- const isWhere: (expr: Expression) => expr is RelationExpr.Where;
562
- type Custom<M = Fqn> = {
563
- customRelation: {
564
- expr: RelationExprOrWhere<M>;
565
- title?: string;
566
- description?: string;
567
- technology?: string;
568
- notation?: string;
569
- navigateTo?: ViewId;
570
- notes?: string;
571
- color?: Color;
572
- line?: RelationshipLineType;
573
- head?: RelationshipArrowType;
574
- tail?: RelationshipArrowType;
575
- };
576
- };
577
- const isCustom: (expr: Expression) => expr is Custom;
578
- const is: (expr: Expression) => expr is RelationExpr;
579
- }
580
- type RelationExpr<M = Fqn> = ExclusiveUnion<{
581
- Direct: RelationExpr.Direct<M>;
582
- Incoming: RelationExpr.Incoming<M>;
583
- Outgoing: RelationExpr.Outgoing<M>;
584
- InOut: RelationExpr.InOut<M>;
585
- }>;
586
- type RelationExprOrWhere<M = Fqn> = ExclusiveUnion<{
587
- Direct: RelationExpr.Direct<M>;
588
- Incoming: RelationExpr.Incoming<M>;
589
- Outgoing: RelationExpr.Outgoing<M>;
590
- InOut: RelationExpr.InOut<M>;
591
- Where: RelationExpr.Where<M>;
592
- }>;
593
- type AnyRelationExpr<M = Fqn> = ExclusiveUnion<{
594
- Direct: RelationExpr.Direct<M>;
595
- Incoming: RelationExpr.Incoming<M>;
596
- Outgoing: RelationExpr.Outgoing<M>;
597
- InOut: RelationExpr.InOut<M>;
598
- Where: RelationExpr.Where<M>;
599
- CustomRelation: RelationExpr.Custom<M>;
600
- }>;
601
- function isAnyRelationExpr(expr: Expression): expr is AnyRelationExpr;
602
- /**
603
- * Represents a version 2 expression which can be one of several types.
604
- *
605
- * @template M - The type for the model FQN, defaults to `Fqn`.
606
- */
607
- type Expression<M = Fqn> = ExclusiveUnion<{
608
- Wildcard: FqnExpr.Wildcard;
609
- ModelRef: FqnExpr.ModelRef<M>;
610
- ElementKind: FqnExpr.ElementKindExpr;
611
- ElementTag: FqnExpr.ElementTagExpr;
612
- Custom: FqnExpr.Custom<M>;
613
- Direct: RelationExpr.Direct<M>;
614
- Incoming: RelationExpr.Incoming<M>;
615
- Outgoing: RelationExpr.Outgoing<M>;
616
- InOut: RelationExpr.InOut<M>;
617
- CustomRelation: RelationExpr.Custom<M>;
618
- Where: Expression.Where<M>;
619
- }>;
620
- function isExpression(expr: any): expr is Expression;
621
- namespace Expression {
622
- type Where<M = Fqn> = FqnExpr.Where<M> | RelationExpr.Where<M>;
623
- const isWhere: (expr: Expression) => expr is Expression.Where;
624
- const isCustomFqnExpr: (expr: Expression) => expr is FqnExpr.Custom;
625
- const isCustomRelationExpr: (expr: Expression) => expr is RelationExpr.Custom;
626
- const isFqnExpr: (expr: Expression) => expr is FqnExpr;
627
- const isRelation: (expr: Expression) => expr is RelationExpr;
628
- }
629
- }
630
-
631
- type GlobalPredicateId = Tagged<string, 'GlobalPredicateId'>;
632
- type GlobalPredicates = NonEmptyArray<ViewRulePredicate>;
633
- type GlobalDynamicPredicates = NonEmptyArray<DynamicViewIncludeRule>;
634
- type GlobalStyleID = Tagged<string, 'GlobalStyleID'>;
635
- type GlobalStyles = NonEmptyTuple<ViewRuleStyle>;
636
- interface ModelGlobals {
637
- readonly predicates: Record<GlobalPredicateId, GlobalPredicates>;
638
- readonly dynamicPredicates: Record<GlobalPredicateId, GlobalDynamicPredicates>;
639
- readonly styles: Record<GlobalStyleID, GlobalStyles>;
640
- }
641
-
642
- type ElementNotation = {
643
- kinds: string[];
644
- shape: ElementShape;
645
- color: Color;
646
- title: string;
647
- };
648
-
649
- type ViewId<Id extends string = string> = Tagged<Id, 'ViewID'>;
650
- type ViewRulePredicate = {
651
- include: ModelLayer.Expression[];
652
- exclude?: never;
653
- } | {
654
- include?: never;
655
- exclude: ModelLayer.Expression[];
656
- };
657
- declare function isViewRulePredicate(rule: DeploymentViewRule): rule is DeploymentViewRulePredicate;
658
- declare function isViewRulePredicate(rule: DynamicViewRule): rule is DynamicViewIncludeRule;
659
- declare function isViewRulePredicate(rule: ViewRule): rule is ViewRulePredicate;
660
- interface ViewRuleGlobalPredicateRef {
661
- predicateId: GlobalPredicateId;
662
- }
663
- declare function isViewRuleGlobalPredicateRef(rule: ViewRule): rule is ViewRuleGlobalPredicateRef;
664
- interface ViewRuleStyle {
665
- targets: ModelLayer.FqnExpr[];
666
- notation?: string;
667
- style: ElementStyle & {
668
- color?: Color;
669
- shape?: ElementShape;
670
- icon?: IconUrl;
671
- };
672
- }
673
- declare function isViewRuleStyle(rule: DeploymentViewRule): rule is DeploymentViewRuleStyle;
674
- declare function isViewRuleStyle(rule: ViewRule): rule is ViewRuleStyle;
675
- interface ViewRuleGlobalStyle {
676
- styleId: GlobalStyleID;
677
- }
678
- declare function isViewRuleGlobalStyle(rule: ViewRule): rule is ViewRuleGlobalStyle;
679
- type ViewRuleStyleOrGlobalRef = ViewRuleStyle | ViewRuleGlobalStyle;
680
- type AutoLayoutDirection = 'TB' | 'BT' | 'LR' | 'RL';
681
- declare function isAutoLayoutDirection(autoLayout: unknown): autoLayout is AutoLayoutDirection;
682
- interface ViewRuleAutoLayout {
683
- direction: AutoLayoutDirection;
684
- nodeSep?: number;
685
- rankSep?: number;
686
- }
687
- declare function isViewRuleAutoLayout(rule: DeploymentViewRule | DynamicViewRule | ViewRule): rule is ViewRuleAutoLayout;
688
- interface ViewRuleGroup {
689
- groupRules: Array<ViewRulePredicate | ViewRuleGroup>;
690
- title: string | null;
691
- color?: Color;
692
- border?: BorderStyle;
693
- opacity?: number;
694
- multiple?: boolean;
695
- size?: ShapeSize;
696
- padding?: SpacingSize;
697
- textSize?: TextSize;
698
- }
699
- declare function isViewRuleGroup(rule: ViewRule): rule is ViewRuleGroup;
700
- type ViewRule = ViewRulePredicate | ViewRuleGlobalPredicateRef | ViewRuleGroup | ViewRuleStyle | ViewRuleGlobalStyle | ViewRuleAutoLayout;
701
- interface BasicView<ViewType extends 'element' | 'dynamic' | 'deployment', ViewIDs extends string, Tags extends string> {
702
- readonly __?: ViewType;
703
- readonly id: ViewId<ViewIDs>;
704
- readonly title: string | null;
705
- readonly description: string | null;
706
- readonly tags: NonEmptyArray<Tag<Tags>> | null;
707
- readonly links: NonEmptyArray<Link> | null;
708
- /**
709
- * URI to the source file of this view.
710
- * Undefined if the view is auto-generated.
711
- */
712
- readonly docUri?: string;
713
- /**
714
- * For all views we find common ancestor path.
715
- * This is used to generate relative paths, i.e.:
716
- * - "/home/project/index.c4" becomes "index.c4"
717
- * - "/home/project/subdir/views.c4" becomes "subdir/views.c4"
718
- *
719
- * Undefined if the view is auto-generated.
720
- */
721
- readonly relativePath?: string;
722
- /**
723
- * If the view is changed manually this field contains the layout data.
724
- */
725
- readonly manualLayout?: ViewManualLayout | undefined;
726
- readonly customColorDefinitions: CustomColorDefinitions;
727
- }
728
- interface BasicElementView<ViewIDs extends string, Tags extends string> extends BasicView<'element', ViewIDs, Tags> {
729
- readonly viewOf?: Fqn;
730
- readonly rules: ViewRule[];
731
- }
732
- interface ScopedElementView<ViewIDs extends string, Tags extends string> extends BasicElementView<ViewIDs, Tags> {
733
- readonly viewOf: Fqn;
734
- }
735
- interface ExtendsElementView<ViewIDs extends string, Tags extends string> extends BasicElementView<ViewIDs, Tags> {
736
- readonly extends: ViewId<ViewIDs>;
737
- }
738
- type ElementView<ViewIDs extends string = string, Tags extends string = string> = ScopedElementView<ViewIDs, Tags> | ExtendsElementView<ViewIDs, Tags> | BasicElementView<ViewIDs, Tags>;
739
- interface DynamicViewStep {
740
- readonly source: Fqn;
741
- readonly target: Fqn;
742
- readonly title: string | null;
743
- readonly description?: string;
744
- readonly technology?: string;
745
- readonly notation?: string;
746
- readonly notes?: string;
747
- readonly color?: Color;
748
- readonly line?: RelationshipLineType;
749
- readonly head?: RelationshipArrowType;
750
- readonly tail?: RelationshipArrowType;
751
- readonly isBackward?: boolean;
752
- readonly navigateTo?: ViewId;
753
- __parallel?: never;
754
- }
755
- interface DynamicViewParallelSteps {
756
- readonly __parallel: DynamicViewStep[];
757
- }
758
- type DynamicViewStepOrParallel = DynamicViewStep | DynamicViewParallelSteps;
759
- type DynamicViewIncludeRule = {
760
- include: ModelLayer.AnyFqnExpr[];
761
- };
762
- type DynamicViewRule = DynamicViewIncludeRule | ViewRuleGlobalPredicateRef | ViewRuleStyle | ViewRuleGlobalStyle | ViewRuleAutoLayout;
763
- interface DynamicView<ViewIDs extends string = string, Tags extends string = string> extends BasicView<'dynamic', ViewIDs, Tags> {
764
- readonly __: 'dynamic';
765
- readonly steps: DynamicViewStepOrParallel[];
766
- readonly rules: DynamicViewRule[];
767
- }
768
- declare function isDynamicViewParallelSteps(step: DynamicViewStepOrParallel): step is DynamicViewParallelSteps;
769
- type CustomColorDefinitions = {
770
- [key: string]: ThemeColorValues;
771
- };
772
- type DeploymentViewRulePredicate = {
773
- include: ExpressionV2[];
774
- exclude?: never;
775
- } | {
776
- include?: never;
777
- exclude: ExpressionV2[];
778
- };
779
- type DeploymentViewRuleStyle = {
780
- targets: FqnExpr[];
781
- notation?: string;
782
- style: ElementStyle & {
783
- color?: Color;
784
- shape?: ElementShape;
785
- icon?: IconUrl;
786
- };
787
- };
788
- type DeploymentViewRule = DeploymentViewRulePredicate | ViewRuleAutoLayout | DeploymentViewRuleStyle;
789
- interface DeploymentView<ViewIDs extends string = string, Tags extends string = string> extends BasicView<'deployment', ViewIDs, Tags> {
790
- readonly __: 'deployment';
791
- readonly rules: DeploymentViewRule[];
792
- }
793
- type LikeC4View<ViewIDs extends string = string, Tags extends string = string> = ElementView<ViewIDs, Tags> | DynamicView<ViewIDs, Tags> | DeploymentView<ViewIDs, Tags>;
794
- declare function isDeploymentView(view: LikeC4View): view is DeploymentView;
795
- declare function isDeploymentView<V extends {
796
- __?: string;
797
- }>(view: V): boolean;
798
- declare function isDynamicView(view: LikeC4View): view is DynamicView;
799
- declare function isElementView(view: LikeC4View): view is ElementView;
800
- declare function isExtendsElementView(view: LikeC4View): view is ExtendsElementView<string, string>;
801
- declare function isScopedElementView(view: LikeC4View): view is ScopedElementView<string, string>;
802
- type NodeId<IDs extends string = string> = Tagged<IDs, 'Fqn'>;
803
- type EdgeId = Tagged<string, 'EdgeId'>;
804
- type StepEdgeIdLiteral = `step-${number}` | `step-${number}.${number}`;
805
- type StepEdgeId = Tagged<StepEdgeIdLiteral, 'EdgeId'>;
806
- declare function stepEdgeId(step: number, parallelStep?: number): StepEdgeId;
807
- declare function isStepEdgeId(id: string): id is StepEdgeId;
808
- declare function extractStep(id: EdgeId): number;
809
- declare function getParallelStepsPrefix(id: string): string | null;
810
- interface ComputedNode {
811
- id: NodeId;
812
- kind: string;
813
- parent: NodeId | null;
814
- /**
815
- * Reference to model element
816
- * If 1 - node id is a reference
817
- */
818
- modelRef?: 1 | Fqn;
819
- /**
820
- * Reference to deployment element
821
- * If 1 - node id is a reference
822
- */
823
- deploymentRef?: 1 | Fqn;
824
- title: string;
825
- description: string | null;
826
- technology: string | null;
827
- notation?: string;
828
- tags: NonEmptyArray<Tag> | null;
829
- links: NonEmptyArray<Link> | null;
830
- children: NodeId[];
831
- inEdges: EdgeId[];
832
- outEdges: EdgeId[];
833
- shape: ElementShape;
834
- color: Color;
835
- /**
836
- * @deprecated Use `style` instead
837
- */
838
- icon?: IconUrl;
839
- style: ElementStyle;
840
- navigateTo?: ViewId | null;
841
- level: number;
842
- depth?: number;
843
- /**
844
- * If this node was customized in the view
845
- */
846
- isCustomized?: boolean;
847
- }
848
- declare namespace ComputedNode {
849
- function modelRef(node: ComputedNode): Fqn | null;
850
- function deploymentRef(node: ComputedNode): Fqn | null;
851
- /**
852
- * Nodes group is a special kind of node, exisiting only in view
853
- */
854
- function isNodesGroup(node: ComputedNode): boolean;
855
- }
856
- interface ComputedEdge {
857
- id: EdgeId;
858
- parent: NodeId | null;
859
- source: NodeId;
860
- target: NodeId;
861
- label: string | null;
862
- description?: string;
863
- technology?: string;
864
- relations: RelationId[];
865
- kind?: RelationshipKind;
866
- notation?: string;
867
- notes?: string;
868
- color?: Color;
869
- line?: RelationshipLineType;
870
- head?: RelationshipArrowType;
871
- tail?: RelationshipArrowType;
872
- tags?: NonEmptyArray<Tag>;
873
- navigateTo?: ViewId;
874
- /**
875
- * If this edge is derived from custom relationship predicate
876
- */
877
- isCustomized?: boolean;
878
- /**
879
- * For layouting purposes
880
- * @default 'forward'
881
- */
882
- dir?: 'forward' | 'back' | 'both';
883
- }
884
- interface ViewWithHash {
885
- /**
886
- * Hash of the view object.
887
- * This is used to detect changes in layout
888
- */
889
- hash: string;
890
- }
891
- interface ViewWithNotation {
892
- notation?: {
893
- elements: ElementNotation[];
894
- };
895
- }
896
- interface ViewAutoLayout {
897
- direction: ViewRuleAutoLayout['direction'];
898
- rankSep?: number;
899
- nodeSep?: number;
900
- }
901
- interface ComputedElementView<ViewIDs extends string = string, Tags extends string = string> extends Omit<ElementView<ViewIDs, Tags>, 'rules' | 'docUri'>, ViewWithHash, ViewWithNotation {
902
- readonly extends?: ViewId<ViewIDs>;
903
- readonly autoLayout: ViewAutoLayout;
904
- readonly nodes: ComputedNode[];
905
- readonly edges: ComputedEdge[];
906
- rules?: never;
907
- docUri?: never;
908
- }
909
- interface ComputedDynamicView<ViewIDs extends string = string, Tags extends string = string> extends Omit<DynamicView<ViewIDs, Tags>, 'rules' | 'steps' | 'docUri'>, ViewWithHash, ViewWithNotation {
910
- readonly autoLayout: ViewAutoLayout;
911
- readonly nodes: ComputedNode[];
912
- readonly edges: ComputedEdge[];
913
- steps?: never;
914
- rules?: never;
915
- docUri?: never;
916
- }
917
- interface ComputedDeploymentView<ViewIDs extends string = string, Tags extends string = string> extends Omit<DeploymentView<ViewIDs, Tags>, 'rules' | 'docUri'>, ViewWithHash, ViewWithNotation {
918
- readonly autoLayout: ViewAutoLayout;
919
- readonly nodes: ComputedNode[];
920
- readonly edges: ComputedEdge[];
921
- rules?: never;
922
- docUri?: never;
923
- }
924
- type ComputedView<ViewIDs extends string = string, Tags extends string = string> = ComputedElementView<ViewIDs, Tags> | ComputedDynamicView<ViewIDs, Tags> | ComputedDeploymentView<ViewIDs, Tags>;
925
- declare namespace ComputedView {
926
- function isDeployment(view: ComputedView): view is ComputedDeploymentView;
927
- function isDynamic(view: ComputedView): view is ComputedDynamicView;
928
- function isElement(view: ComputedView): view is ComputedElementView;
929
- }
930
- type BBox = {
931
- x: number;
932
- y: number;
933
- width: number;
934
- height: number;
935
- };
936
- declare function getBBoxCenter({ x, y, width, height, }: BBox): XYPoint;
937
- interface DiagramNode extends ComputedNode {
938
- width: number;
939
- height: number;
940
- position: Point;
941
- labelBBox: BBox;
942
- }
943
- declare namespace DiagramNode {
944
- function modelRef(node: Pick<DiagramNode, 'id' | 'modelRef'>): Fqn | null;
945
- function deploymentRef(node: Pick<DiagramNode, 'id' | 'deploymentRef'>): Fqn | null;
946
- /**
947
- * Nodes group is a special kind of node, exisiting only in view
948
- */
949
- function isNodesGroup(node: Pick<DiagramNode, 'kind'>): boolean;
950
- }
951
- interface DiagramEdge extends ComputedEdge {
952
- points: NonEmptyArray<Point>;
953
- controlPoints?: NonEmptyArray<XYPoint>;
954
- labelBBox?: BBox | null;
955
- dotpos?: string;
956
- }
957
- interface DiagramView<ViewIDs extends string = string, Tags extends string = string> extends Omit<ComputedView<ViewIDs, Tags>, 'nodes' | 'edges' | 'manualLayout'> {
958
- readonly nodes: DiagramNode[];
959
- readonly edges: DiagramEdge[];
960
- readonly bounds: BBox;
961
- /**
962
- * If diagram has manual layout
963
- * But was changed and layout should be recalculated
964
- */
965
- hasLayoutDrift?: boolean;
966
- manualLayout?: never;
967
- }
968
- type ViewManualLayout = {
969
- readonly hash: string;
970
- readonly x: number;
971
- readonly y: number;
972
- readonly width: number;
973
- readonly height: number;
974
- readonly autoLayout: ViewAutoLayout;
975
- readonly nodes: Record<string, {
976
- isCompound: boolean;
977
- x: number;
978
- y: number;
979
- width: number;
980
- height: number;
981
- }>;
982
- readonly edges: Record<string, {
983
- dotpos?: string;
984
- points: NonEmptyArray<Point>;
985
- controlPoints?: NonEmptyArray<XYPoint>;
986
- labelBBox?: BBox;
987
- }>;
988
- };
989
-
990
- type RelationId = Tagged<string, 'RelationID'>;
991
- type RelationshipKind<Kinds extends string = string> = Tagged<Kinds, 'RelationshipKind'>;
992
- type RelationshipLineType = 'dashed' | 'solid' | 'dotted';
993
- type RelationshipArrowType = 'none' | 'normal' | 'onormal' | 'dot' | 'odot' | 'diamond' | 'odiamond' | 'crow' | 'open' | 'vee';
994
- declare const DefaultLineStyle: RelationshipLineType;
995
- declare const DefaultArrowType: RelationshipArrowType;
996
- declare const DefaultRelationshipColor: ThemeColor;
997
- interface AbstractRelation {
998
- readonly id: RelationId;
999
- readonly title?: string;
1000
- readonly description?: string;
1001
- readonly technology?: string;
1002
- readonly tags?: NonEmptyArray<Tag> | null;
1003
- readonly kind?: RelationshipKind;
1004
- readonly color?: Color;
1005
- readonly line?: RelationshipLineType;
1006
- readonly head?: RelationshipArrowType;
1007
- readonly tail?: RelationshipArrowType;
1008
- readonly links?: NonEmptyArray<Link> | null;
1009
- readonly navigateTo?: ViewId;
1010
- readonly metadata?: {
1011
- [key: string]: string;
1012
- };
1013
- }
1014
- interface ModelRelation extends AbstractRelation {
1015
- readonly source: Fqn;
1016
- readonly target: Fqn;
1017
- readonly title: string;
1018
- }
1019
- interface RelationshipKindSpecification {
1020
- readonly technology?: string;
1021
- readonly notation?: string;
1022
- readonly color?: Color;
1023
- readonly line?: RelationshipLineType;
1024
- readonly head?: RelationshipArrowType;
1025
- readonly tail?: RelationshipArrowType;
1026
- }
1027
-
1028
- type DeploymentNodeKind<Kinds extends string = string> = Tagged<Kinds, 'DeploymentNodeKind'>;
1029
- type DeploymentElementStyle = ElementStyle & {
1030
- readonly icon?: IconUrl;
1031
- readonly shape?: ElementShape;
1032
- readonly color?: Color;
1033
- };
1034
- interface DeploymentNodeKindSpecification {
1035
- readonly technology?: string;
1036
- readonly notation?: string;
1037
- readonly style: DeploymentElementStyle;
1038
- }
1039
- interface DeploymentNode {
1040
- readonly id: Fqn;
1041
- readonly kind: DeploymentNodeKind;
1042
- readonly title: string;
1043
- readonly description?: string | null;
1044
- readonly technology?: string | null;
1045
- readonly tags?: NonEmptyArray<Tag> | null;
1046
- readonly links?: NonEmptyArray<Link> | null;
1047
- readonly style?: DeploymentElementStyle;
1048
- readonly notation?: string;
1049
- readonly metadata?: Record<string, string>;
1050
- }
1051
- interface DeployedInstance {
1052
- /**
1053
- * Format: `<DeploymentNode Fqn>.<Instance Id>`
1054
- * i.e parent fqn is deployment target
1055
- */
1056
- readonly id: Fqn;
1057
- readonly element: Fqn;
1058
- readonly title?: string;
1059
- readonly description?: string | null;
1060
- readonly technology?: string | null;
1061
- readonly tags?: NonEmptyArray<Tag> | null;
1062
- readonly links?: NonEmptyArray<Link> | null;
1063
- readonly style?: DeploymentElementStyle;
1064
- readonly notation?: string;
1065
- readonly metadata?: Record<string, string>;
1066
- }
1067
- type DeploymentElement = Simplify<MergeExclusive<DeploymentNode, DeployedInstance>>;
1068
- declare namespace DeploymentElement {
1069
- const isDeploymentNode: (el: DeploymentElement) => el is DeploymentNode;
1070
- const isInstance: (el: DeploymentElement) => el is DeployedInstance;
1071
- }
1072
- type PredicateSelector = 'children' | 'expanded' | 'descendants';
1073
- interface DeploymentRef {
1074
- readonly id: Fqn;
1075
- readonly element?: Fqn;
1076
- }
1077
- /**
1078
- * NOTE:
1079
- */
1080
- interface DeploymentRelation extends AbstractRelation {
1081
- readonly id: RelationId;
1082
- readonly source: DeploymentRef;
1083
- readonly target: DeploymentRef;
1084
- }
1085
-
1086
- /**
1087
- * Represents a LikeC4 model with customizable type parameters,
1088
- * parsed from DSL or result from Builder
1089
- *
1090
- * !IMPORTANT: This is a low-level type, use `LikeC4Model` instead.
1091
- * !NOTE: Views are not computed yet.
1092
- *
1093
- * @typeParam ElementKinds - Types of elements in the model (defaults to string)
1094
- * @typeParam RelationKinds - Types of relationships (defaults to string)
1095
- * @typeParam Tags - Types of tags that can be applied (defaults to string)
1096
- * @typeParam Fqns - Fully Qualified Names for elements (defaults to string)
1097
- * @typeParam Views - Types of views in the model (defaults to string)
1098
- * @typeParam DeploymentFqns - Fully Qualified Names for deployment nodes (defaults to string)
1099
- */
1100
- interface ParsedLikeC4ModelData<ElementKinds extends string = string, RelationKinds extends string = string, Tags extends string = string, Fqns extends string = string, Views extends string = string, DeploymentFqns extends string = string> {
1101
- __?: never;
1102
- specification: {
1103
- tags: Tag<Tags>[];
1104
- elements: Record<ElementKinds, ElementKindSpecification>;
1105
- deployments: Record<DeploymentNodeKind, DeploymentNodeKindSpecification>;
1106
- relationships: Record<RelationKinds, RelationshipKindSpecification>;
1107
- };
1108
- elements: Record<Fqns, TypedElement<Fqns, ElementKinds, Tags>>;
1109
- relations: Record<RelationId, ModelRelation>;
1110
- globals: ModelGlobals;
1111
- views: Record<Views, LikeC4View<Views, Tags>>;
1112
- /**
1113
- * Deployment Model.
1114
- */
1115
- deployments: {
1116
- elements: Record<DeploymentFqns, DeploymentElement>;
1117
- relations: Record<RelationId, DeploymentRelation>;
1118
- };
1119
- imports: Record<ProjectId, NonEmptyArray<Element>>;
1120
- }
1121
- type AnyParsedLikeC4ModelData = ParsedLikeC4ModelData<any, any, any, any, any, any>;
1122
- /**
1123
- * Hook to get types from dump
1124
- */
1125
- type LikeC4ModelDump = {
1126
- elements: {
1127
- [kind: string]: object;
1128
- };
1129
- deployments: {
1130
- elements: {
1131
- [kind: string]: object;
1132
- };
1133
- };
1134
- views: {
1135
- [kind: string]: object;
1136
- };
1137
- };
1138
- /**
1139
- * Same as {@link ParsedLikeC4ModelData}, but with computed views or layouted views.
1140
- */
1141
- interface GenericLikeC4ModelData<Fqns extends string = string, DeploymentFqns extends string = string, Views extends string = string, Tags extends string = string, T = 'computed' | 'layouted'> extends Omit<ParsedLikeC4ModelData<string, string, Tags, Fqns, Views, DeploymentFqns>, 'views' | '__'> {
1142
- __?: T;
1143
- views: Record<Views, ComputedView<Views> | DiagramView<Views>>;
1144
- }
1145
- interface ComputedLikeC4ModelData<Fqns extends string = string, DeploymentFqns extends string = string, Views extends string = string, Tags extends string = string> extends Omit<GenericLikeC4ModelData<Fqns, DeploymentFqns, Views, Tags, 'computed'>, 'views'> {
1146
- views: Record<Views, ComputedView<Views>>;
1147
- }
1148
- interface LayoutedLikeC4ModelData<Fqns extends string = string, DeploymentFqns extends string = string, Views extends string = string, Tags extends string = string> extends Omit<GenericLikeC4ModelData<Fqns, DeploymentFqns, Views, Tags, 'layouted'>, 'views'> {
1149
- __: 'layouted';
1150
- views: Record<Views, DiagramView<Views, Tags>>;
1151
- }
1152
-
1153
- export { isTagEqual as $, type GlobalPredicateId as A, BorderStyles as B, type ComputedLikeC4ModelData as C, DeploymentElement as D, ElementKind as E, FqnExpr as F, type GlobalDynamicPredicates as G, type HexColorLiteral as H, type GlobalPredicates as I, type GlobalStyleID as J, type GlobalStyles as K, type LikeC4View as L, ModelLayer as M, type ModelGlobals as N, type AnyParsedLikeC4ModelData as O, type PredicateSelector as P, type GenericLikeC4ModelData as Q, RelationExpr as R, type LayoutedLikeC4ModelData as S, type ThemeColorValues as T, type LikeC4ModelDump as U, type ParsedLikeC4ModelData as V, isAndOperator as W, isKindEqual as X, isNotOperator as Y, isOrOperator as Z, isParticipantOperator as _, ComputedView as a, type CustomColorDefinitions as a$, whereOperatorAsPredicate as a0, type AllNever as a1, type AndOperator as a2, type EqualOperator as a3, type Filterable as a4, type KindEqual as a5, type NotOperator as a6, type OperatorPredicate as a7, type OrOperator as a8, type Participant as a9, DiagramNode as aA, extractStep as aB, getBBoxCenter as aC, getParallelStepsPrefix as aD, isAutoLayoutDirection as aE, isDeploymentView as aF, isDynamicView as aG, isDynamicViewParallelSteps as aH, isElementView as aI, isExtendsElementView as aJ, isScopedElementView as aK, isStepEdgeId as aL, isViewRuleAutoLayout as aM, isViewRuleGlobalPredicateRef as aN, isViewRuleGlobalStyle as aO, isViewRuleGroup as aP, isViewRulePredicate as aQ, isViewRuleStyle as aR, stepEdgeId as aS, type AutoLayoutDirection as aT, type BasicElementView as aU, type BasicView as aV, type BBox as aW, type ComputedDeploymentView as aX, type ComputedDynamicView as aY, type ComputedEdge as aZ, type ComputedElementView as a_, type ParticipantOperator as aa, type TagEqual as ab, type WhereOperator as ac, DefaultArrowType as ad, DefaultLineStyle as ae, DefaultRelationshipColor as af, type AbstractRelation as ag, type ModelRelation as ah, type RelationId as ai, type RelationshipArrowType as aj, type RelationshipKind as ak, type RelationshipKindSpecification as al, type RelationshipLineType as am, isThemeColor as an, ThemeColors as ao, type Color as ap, type ColorLiteral as aq, type ElementThemeColors as ar, type ElementThemeColorValues as as, type RelationshipThemeColors as at, type RelationshipThemeColorValues as au, type ShapeSize as av, type SpacingSize as aw, type TextSize as ax, type ThemeColor as ay, ComputedNode as az, type LikeC4Theme as b, type DeploymentView as b0, type DeploymentViewRule as b1, type DeploymentViewRulePredicate as b2, type DeploymentViewRuleStyle as b3, type DiagramEdge as b4, type DiagramView as b5, type DynamicView as b6, type DynamicViewIncludeRule as b7, type DynamicViewParallelSteps as b8, type DynamicViewRule as b9, type DynamicViewStep as ba, type DynamicViewStepOrParallel as bb, type EdgeId as bc, type ElementView as bd, type ExtendsElementView as be, type NodeId as bf, type ScopedElementView as bg, type StepEdgeId as bh, type StepEdgeIdLiteral as bi, type ViewAutoLayout as bj, type ViewId as bk, type ViewManualLayout as bl, type ViewRule as bm, type ViewRuleAutoLayout as bn, type ViewRuleGlobalPredicateRef as bo, type ViewRuleGlobalStyle as bp, type ViewRuleGroup as bq, type ViewRulePredicate as br, type ViewRuleStyle as bs, type ViewRuleStyleOrGlobalRef as bt, type ViewWithHash as bu, type ViewWithNotation as bv, type ElementNotation as bw, type DeployedInstance as c, type DeploymentElementStyle as d, type DeploymentNode as e, type DeploymentNodeKind as f, type DeploymentNodeKindSpecification as g, type DeploymentRef as h, type DeploymentRelation as i, DefaultElementShape as j, DefaultPaddingSize as k, DefaultShapeSize as l, DefaultTextSize as m, DefaultThemeColor as n, ElementShapes as o, type BorderStyle as p, type Element as q, type ElementKindSpecification as r, type ElementKindSpecificationStyle as s, type ElementShape as t, type ElementStyle as u, type Link as v, type TagSpec as w, type TypedElement as x, ExpressionV2 as y, FqnRef as z };