@likec4/core 1.17.1 → 1.18.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 (112) hide show
  1. package/dist/compute-view/index.d.mts +91 -0
  2. package/dist/compute-view/index.d.ts +91 -0
  3. package/dist/compute-view/index.mjs +79 -0
  4. package/dist/index.d.mts +246 -434
  5. package/dist/index.d.ts +246 -434
  6. package/dist/index.mjs +418 -1322
  7. package/dist/model/index.d.mts +642 -0
  8. package/dist/model/index.d.ts +642 -0
  9. package/dist/model/index.mjs +2 -0
  10. package/dist/shared/core.BBgiAAv1.mjs +144 -0
  11. package/dist/shared/core.BPyJvuMU.mjs +2420 -0
  12. package/dist/shared/core.BQ4AbfvB.mjs +9228 -0
  13. package/dist/shared/{core.CoLQkcYL.d.mts → core.DMYY7C8s.d.mts} +398 -249
  14. package/dist/shared/{core.CoLQkcYL.d.ts → core.DMYY7C8s.d.ts} +398 -249
  15. package/dist/shared/core.k12s_keD.mjs +203 -0
  16. package/dist/types/index.d.mts +69 -1
  17. package/dist/types/index.d.ts +69 -1
  18. package/dist/types/index.mjs +21 -1
  19. package/package.json +38 -40
  20. package/src/builder/Builder.deployment.ts +219 -0
  21. package/src/builder/Builder.deploymentModel.ts +360 -0
  22. package/src/builder/Builder.element.ts +17 -19
  23. package/src/builder/Builder.model.ts +13 -2
  24. package/src/builder/Builder.test-d.ts +59 -4
  25. package/src/builder/Builder.ts +238 -53
  26. package/src/builder/Builder.view.ts +238 -53
  27. package/src/builder/_types.ts +87 -15
  28. package/src/compute-view/LikeC4ModelGraph.ts +330 -0
  29. package/src/compute-view/compute-view.ts +92 -0
  30. package/src/compute-view/deployment-view/Memory.ts +108 -0
  31. package/src/compute-view/deployment-view/Stage.ts +145 -0
  32. package/src/compute-view/deployment-view/__test__/fixture.ts +210 -0
  33. package/src/compute-view/deployment-view/_types.ts +29 -0
  34. package/src/compute-view/deployment-view/clean-connections.ts +229 -0
  35. package/src/compute-view/deployment-view/compute.ts +111 -0
  36. package/src/compute-view/deployment-view/predicates/deployment-ref.ts +146 -0
  37. package/src/compute-view/deployment-view/predicates/relation-direct.ts +130 -0
  38. package/src/compute-view/deployment-view/predicates/relation-in-out.ts +43 -0
  39. package/src/compute-view/deployment-view/predicates/relation-incoming.ts +46 -0
  40. package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +49 -0
  41. package/src/compute-view/deployment-view/predicates/wildcard.ts +29 -0
  42. package/src/compute-view/deployment-view/utils.ts +212 -0
  43. package/src/compute-view/dynamic-view/__test__/fixture.ts +58 -0
  44. package/src/compute-view/dynamic-view/compute.ts +310 -0
  45. package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +456 -0
  46. package/src/compute-view/element-view/__test__/fixture.ts +645 -0
  47. package/src/compute-view/element-view/compute.ts +734 -0
  48. package/src/compute-view/element-view/predicates.ts +517 -0
  49. package/src/compute-view/index.ts +5 -0
  50. package/src/compute-view/utils/__snapshots__/sortNodes.spec.ts.snap +113 -0
  51. package/src/compute-view/utils/ancestorsOfNode.ts +19 -0
  52. package/src/compute-view/utils/applyCustomElementProperties.ts +66 -0
  53. package/src/compute-view/utils/applyCustomRelationProperties.ts +41 -0
  54. package/src/compute-view/utils/applyViewRuleStyles.ts +53 -0
  55. package/src/compute-view/utils/buildComputedNodes.ts +148 -0
  56. package/src/compute-view/utils/buildElementNotations.ts +63 -0
  57. package/src/compute-view/utils/derive-edge-props-from-relationships.ts +97 -0
  58. package/src/compute-view/utils/elementExpressionToPredicate.ts +52 -0
  59. package/src/compute-view/utils/link-nodes-with-edges.ts +58 -0
  60. package/src/compute-view/utils/relationExpressionToPredicates.ts +55 -0
  61. package/src/compute-view/utils/resolve-extended-views.ts +65 -0
  62. package/src/compute-view/utils/resolve-global-rules.ts +83 -0
  63. package/src/compute-view/utils/sortNodes.ts +101 -0
  64. package/src/compute-view/utils/topological-sort.ts +160 -0
  65. package/src/compute-view/utils/uniqueTags.test.ts +42 -0
  66. package/src/compute-view/utils/uniqueTags.ts +21 -0
  67. package/src/compute-view/utils/view-hash.ts +27 -0
  68. package/src/compute-view/utils/with-readable-edges.ts +31 -0
  69. package/src/index.ts +5 -1
  70. package/src/model/DeploymentElementModel.ts +534 -0
  71. package/src/model/DeploymentModel.ts +364 -0
  72. package/src/model/ElementModel.ts +195 -0
  73. package/src/model/LikeC4Model.test-d.ts +151 -0
  74. package/src/model/LikeC4Model.ts +280 -457
  75. package/src/model/RelationModel.ts +84 -0
  76. package/src/model/__test__/fixture.ts +153 -338
  77. package/src/model/connection/ConnectionModel.ts +94 -0
  78. package/src/model/connection/DeploymentConnectionModel.ts +99 -0
  79. package/src/model/connection/deployment.ts +124 -0
  80. package/src/model/connection/model.ts +123 -0
  81. package/src/model/index.ts +4 -2
  82. package/src/model/types.ts +95 -15
  83. package/src/model/view/EdgeModel.ts +103 -0
  84. package/src/model/view/LikeC4ViewModel.ts +220 -0
  85. package/src/model/view/NodeModel.ts +228 -0
  86. package/src/types/_common.ts +2 -0
  87. package/src/types/deployments.ts +237 -0
  88. package/src/types/element.ts +7 -3
  89. package/src/types/expression.ts +8 -6
  90. package/src/types/index.ts +1 -0
  91. package/src/types/model.ts +68 -9
  92. package/src/types/overview-graph.ts +2 -2
  93. package/src/types/relation.ts +4 -4
  94. package/src/types/view-notation.ts +2 -2
  95. package/src/types/view.ts +104 -30
  96. package/src/utils/{commonHead.ts → common-head.ts} +2 -0
  97. package/src/utils/fqn.ts +83 -27
  98. package/src/utils/getOrCreate.ts +42 -0
  99. package/src/utils/graphlib.ts +10 -0
  100. package/src/utils/index.ts +4 -1
  101. package/src/utils/object-hash.ts +3 -0
  102. package/src/utils/set.ts +76 -0
  103. package/src/utils/string-hash.ts +16 -0
  104. package/dist/index.cjs +0 -5452
  105. package/dist/index.d.cts +0 -1053
  106. package/dist/shared/core.BXTs-8n7.mjs +0 -293
  107. package/dist/shared/core.CoLQkcYL.d.cts +0 -734
  108. package/dist/shared/core.DIYZvpVg.cjs +0 -353
  109. package/dist/types/index.cjs +0 -70
  110. package/dist/types/index.d.cts +0 -2
  111. package/src/model/LikeC4DiagramModel.ts +0 -338
  112. package/src/model/LikeC4ViewModel.ts +0 -320
@@ -1,4 +1,4 @@
1
- import { Tagged, LiteralUnion, TupleToUnion, NonEmptyTuple } from 'type-fest';
1
+ import { Tagged, LiteralUnion, TupleToUnion, NonEmptyTuple, Simplify, MergeExclusive, UnionToIntersection } from 'type-fest';
2
2
 
3
3
  type NonEmptyArray<T> = [T, ...T[]];
4
4
  type NonEmptyReadonlyArray<T> = readonly [T, ...T[]];
@@ -9,6 +9,7 @@ interface XYPoint {
9
9
  x: number;
10
10
  y: number;
11
11
  }
12
+ type KeysOf<T> = keyof T extends infer K extends string ? K : never;
12
13
 
13
14
  declare const ThemeColors: readonly ["amber", "blue", "gray", "slate", "green", "indigo", "muted", "primary", "red", "secondary", "sky"];
14
15
  type ThemeColor = typeof ThemeColors[number];
@@ -57,8 +58,13 @@ type ElementShape = TupleToUnion<typeof ElementShapes>;
57
58
  declare const DefaultThemeColor = "primary";
58
59
  declare const DefaultElementShape = "rectangle";
59
60
  interface ElementStyle {
60
- border?: BorderStyle;
61
- opacity?: number;
61
+ readonly border?: BorderStyle;
62
+ /**
63
+ * In percentage 0-100, 0 is fully transparent
64
+ *
65
+ * @default 100
66
+ */
67
+ readonly opacity?: number;
62
68
  }
63
69
  type Tag<Tags extends string = string> = Tagged<Tags, 'Tag'>;
64
70
  interface TagSpec {
@@ -107,30 +113,30 @@ type EqualOperator<V> = {
107
113
  eq?: never;
108
114
  neq: V;
109
115
  };
110
- type AllNever = {
116
+ type AllNever$1 = {
111
117
  not?: never;
112
118
  and?: never;
113
119
  or?: never;
114
120
  tag?: never;
115
121
  kind?: never;
116
122
  };
117
- type TagEqual<Tag> = Omit<AllNever, 'tag'> & {
123
+ type TagEqual<Tag> = Omit<AllNever$1, 'tag'> & {
118
124
  tag: EqualOperator<Tag>;
119
125
  };
120
126
  declare const isTagEqual: <Tag>(operator: WhereOperator<Tag, any>) => operator is TagEqual<Tag>;
121
- type KindEqual<Kind> = Omit<AllNever, 'kind'> & {
127
+ type KindEqual<Kind> = Omit<AllNever$1, 'kind'> & {
122
128
  kind: EqualOperator<Kind>;
123
129
  };
124
130
  declare const isKindEqual: <Kind>(operator: WhereOperator<any, Kind>) => operator is KindEqual<Kind>;
125
- type NotOperator<Tag, Kind> = Omit<AllNever, 'not'> & {
131
+ type NotOperator<Tag, Kind> = Omit<AllNever$1, 'not'> & {
126
132
  not: WhereOperator<Tag, Kind>;
127
133
  };
128
134
  declare const isNotOperator: <Tag, Kind>(operator: WhereOperator<Tag, Kind>) => operator is NotOperator<Tag, Kind>;
129
- type AndOperator<Tag, Kind> = Omit<AllNever, 'and'> & {
135
+ type AndOperator<Tag, Kind> = Omit<AllNever$1, 'and'> & {
130
136
  and: NonEmptyArray<WhereOperator<Tag, Kind>>;
131
137
  };
132
138
  declare const isAndOperator: <Tag, Kind>(operator: WhereOperator<Tag, Kind>) => operator is AndOperator<Tag, Kind>;
133
- type OrOperator<Tag, Kind> = Omit<AllNever, 'or'> & {
139
+ type OrOperator<Tag, Kind> = Omit<AllNever$1, 'or'> & {
134
140
  or: NonEmptyArray<WhereOperator<Tag, Kind>>;
135
141
  };
136
142
  declare const isOrOperator: <Tag, Kind>(operator: WhereOperator<Tag, Kind>) => operator is OrOperator<Tag, Kind>;
@@ -142,6 +148,161 @@ type Filterable<FTag extends string = string, FKind extends string = string> = {
142
148
  type OperatorPredicate<V extends Filterable> = (value: V) => boolean;
143
149
  declare function whereOperatorAsPredicate<FTag extends string = string, FKind extends string = string>(operator: WhereOperator<FTag, FKind>): OperatorPredicate<Filterable<FTag, FKind>>;
144
150
 
151
+ interface BaseExpr {
152
+ where?: never;
153
+ element?: never;
154
+ custom?: never;
155
+ expanded?: never;
156
+ elementKind?: never;
157
+ elementTag?: never;
158
+ isEqual?: never;
159
+ isChildren?: never;
160
+ isDescendants?: never;
161
+ wildcard?: never;
162
+ source?: never;
163
+ target?: never;
164
+ inout?: never;
165
+ incoming?: never;
166
+ outgoing?: never;
167
+ customRelation?: never;
168
+ }
169
+ interface ElementRefExpr extends Omit<BaseExpr, 'element' | 'isChildren' | 'isDescendants'> {
170
+ element: Fqn;
171
+ isChildren?: boolean;
172
+ isDescendants?: boolean;
173
+ }
174
+ declare function isElementRef(expr: Expression): expr is ElementRefExpr;
175
+ interface ExpandedElementExpr extends Omit<BaseExpr, 'expanded'> {
176
+ expanded: Fqn;
177
+ }
178
+ declare function isExpandedElementExpr(expr: Expression): expr is ExpandedElementExpr;
179
+ interface CustomElementExpr extends Omit<BaseExpr, 'custom'> {
180
+ custom: {
181
+ expr: ElementExpression | ElementWhereExpr;
182
+ title?: string;
183
+ description?: string;
184
+ technology?: string;
185
+ notation?: string;
186
+ shape?: ElementShape;
187
+ color?: Color;
188
+ icon?: IconUrl;
189
+ border?: BorderStyle;
190
+ opacity?: number;
191
+ navigateTo?: ViewId;
192
+ };
193
+ }
194
+ declare function isCustomElement(expr: Expression): expr is CustomElementExpr;
195
+ interface WildcardExpr extends Omit<BaseExpr, 'wildcard'> {
196
+ wildcard: true;
197
+ }
198
+ declare function isWildcard(expr: Expression): expr is WildcardExpr;
199
+ interface ElementKindExpr extends Omit<BaseExpr, 'elementKind' | 'isEqual'> {
200
+ elementKind: ElementKind;
201
+ isEqual: boolean;
202
+ }
203
+ declare function isElementKindExpr(expr: Expression): expr is ElementKindExpr;
204
+ interface ElementTagExpr extends Omit<BaseExpr, 'elementTag' | 'isEqual'> {
205
+ elementTag: Tag;
206
+ isEqual: boolean;
207
+ }
208
+ declare function isElementTagExpr(expr: Expression): expr is ElementTagExpr;
209
+ type ElementExpression = ElementRefExpr | WildcardExpr | ElementKindExpr | ElementTagExpr | ExpandedElementExpr;
210
+ declare function isElement(expr: Expression): expr is ElementExpression;
211
+ interface ElementWhereExpr extends Omit<BaseExpr, 'where'> {
212
+ where: {
213
+ expr: ElementExpression;
214
+ condition: WhereOperator<string, string>;
215
+ };
216
+ }
217
+ declare function isElementWhere(expr: Expression): expr is ElementWhereExpr;
218
+ type ElementPredicateExpression = ElementExpression | ElementWhereExpr | CustomElementExpr;
219
+ declare function isElementPredicateExpr(expr: Expression): expr is ElementPredicateExpression;
220
+ interface RelationExpr extends Omit<BaseExpr, 'source' | 'target'> {
221
+ source: ElementExpression;
222
+ target: ElementExpression;
223
+ isBidirectional?: boolean;
224
+ }
225
+ declare function isRelation(expr: Expression): expr is RelationExpr;
226
+ interface InOutExpr extends Omit<BaseExpr, 'inout'> {
227
+ inout: ElementExpression;
228
+ }
229
+ declare function isInOut(expr: Expression): expr is InOutExpr;
230
+ interface IncomingExpr extends Omit<BaseExpr, 'incoming'> {
231
+ incoming: ElementExpression;
232
+ }
233
+ declare function isIncoming(expr: Expression): expr is IncomingExpr;
234
+ interface OutgoingExpr extends Omit<BaseExpr, 'outgoing'> {
235
+ outgoing: ElementExpression;
236
+ }
237
+ declare function isOutgoing(expr: Expression): expr is OutgoingExpr;
238
+ type RelationExpression = RelationExpr | InOutExpr | IncomingExpr | OutgoingExpr;
239
+ declare function isRelationExpression(expr: Expression): expr is RelationExpression;
240
+ interface RelationWhereExpr extends Omit<BaseExpr, 'where'> {
241
+ where: {
242
+ expr: RelationExpression;
243
+ condition: WhereOperator<string, string>;
244
+ };
245
+ }
246
+ declare function isRelationWhere(expr: Expression): expr is RelationWhereExpr;
247
+ interface CustomRelationExpr extends Omit<BaseExpr, 'customRelation'> {
248
+ customRelation: {
249
+ relation: RelationExpression | RelationWhereExpr;
250
+ title?: string;
251
+ description?: string;
252
+ technology?: string;
253
+ notation?: string;
254
+ navigateTo?: ViewId;
255
+ notes?: string;
256
+ color?: Color;
257
+ line?: RelationshipLineType;
258
+ head?: RelationshipArrowType;
259
+ tail?: RelationshipArrowType;
260
+ };
261
+ }
262
+ declare function isCustomRelationExpr(expr: Expression): expr is CustomRelationExpr;
263
+ type RelationPredicateExpression = RelationExpression | RelationWhereExpr | CustomRelationExpr;
264
+ declare function isRelationPredicateExpr(expr: Expression): expr is RelationPredicateExpression;
265
+ type Expression = ElementPredicateExpression | RelationPredicateExpression;
266
+
267
+ type expression_CustomElementExpr = CustomElementExpr;
268
+ type expression_CustomRelationExpr = CustomRelationExpr;
269
+ type expression_ElementExpression = ElementExpression;
270
+ type expression_ElementKindExpr = ElementKindExpr;
271
+ type expression_ElementPredicateExpression = ElementPredicateExpression;
272
+ type expression_ElementRefExpr = ElementRefExpr;
273
+ type expression_ElementTagExpr = ElementTagExpr;
274
+ type expression_ElementWhereExpr = ElementWhereExpr;
275
+ type expression_ExpandedElementExpr = ExpandedElementExpr;
276
+ type expression_Expression = Expression;
277
+ type expression_InOutExpr = InOutExpr;
278
+ type expression_IncomingExpr = IncomingExpr;
279
+ type expression_OutgoingExpr = OutgoingExpr;
280
+ type expression_RelationExpr = RelationExpr;
281
+ type expression_RelationExpression = RelationExpression;
282
+ type expression_RelationPredicateExpression = RelationPredicateExpression;
283
+ type expression_RelationWhereExpr = RelationWhereExpr;
284
+ type expression_WildcardExpr = WildcardExpr;
285
+ declare const expression_isCustomElement: typeof isCustomElement;
286
+ declare const expression_isCustomRelationExpr: typeof isCustomRelationExpr;
287
+ declare const expression_isElement: typeof isElement;
288
+ declare const expression_isElementKindExpr: typeof isElementKindExpr;
289
+ declare const expression_isElementPredicateExpr: typeof isElementPredicateExpr;
290
+ declare const expression_isElementRef: typeof isElementRef;
291
+ declare const expression_isElementTagExpr: typeof isElementTagExpr;
292
+ declare const expression_isElementWhere: typeof isElementWhere;
293
+ declare const expression_isExpandedElementExpr: typeof isExpandedElementExpr;
294
+ declare const expression_isInOut: typeof isInOut;
295
+ declare const expression_isIncoming: typeof isIncoming;
296
+ declare const expression_isOutgoing: typeof isOutgoing;
297
+ declare const expression_isRelation: typeof isRelation;
298
+ declare const expression_isRelationExpression: typeof isRelationExpression;
299
+ declare const expression_isRelationPredicateExpr: typeof isRelationPredicateExpr;
300
+ declare const expression_isRelationWhere: typeof isRelationWhere;
301
+ declare const expression_isWildcard: typeof isWildcard;
302
+ declare namespace expression {
303
+ export { type expression_CustomElementExpr as CustomElementExpr, type expression_CustomRelationExpr as CustomRelationExpr, type expression_ElementExpression as ElementExpression, type expression_ElementKindExpr as ElementKindExpr, type expression_ElementPredicateExpression as ElementPredicateExpression, type expression_ElementRefExpr as ElementRefExpr, type expression_ElementTagExpr as ElementTagExpr, type expression_ElementWhereExpr as ElementWhereExpr, type expression_ExpandedElementExpr as ExpandedElementExpr, type expression_Expression as Expression, type expression_InOutExpr as InOutExpr, type expression_IncomingExpr as IncomingExpr, type expression_OutgoingExpr as OutgoingExpr, type expression_RelationExpr as RelationExpr, type expression_RelationExpression as RelationExpression, type expression_RelationPredicateExpression as RelationPredicateExpression, type expression_RelationWhereExpr as RelationWhereExpr, type expression_WildcardExpr as WildcardExpr, expression_isCustomElement as isCustomElement, expression_isCustomRelationExpr as isCustomRelationExpr, expression_isElement as isElement, expression_isElementKindExpr as isElementKindExpr, expression_isElementPredicateExpr as isElementPredicateExpr, expression_isElementRef as isElementRef, expression_isElementTagExpr as isElementTagExpr, expression_isElementWhere as isElementWhere, expression_isExpandedElementExpr as isExpandedElementExpr, expression_isInOut as isInOut, expression_isIncoming as isIncoming, expression_isOutgoing as isOutgoing, expression_isRelation as isRelation, expression_isRelationExpression as isRelationExpression, expression_isRelationPredicateExpr as isRelationPredicateExpr, expression_isRelationWhere as isRelationWhere, expression_isWildcard as isWildcard };
304
+ }
305
+
145
306
  type GlobalPredicateId = Tagged<string, 'GlobalPredicateId'>;
146
307
  type GlobalPredicates = NonEmptyArray<ViewRulePredicate>;
147
308
  type GlobalDynamicPredicates = NonEmptyArray<DynamicViewIncludeRule>;
@@ -154,13 +315,13 @@ interface ModelGlobals {
154
315
  }
155
316
 
156
317
  type ElementNotation = {
157
- kinds: ElementKind[];
318
+ kinds: string[];
158
319
  shape: ElementShape;
159
320
  color: Color;
160
321
  title: string;
161
322
  };
162
323
 
163
- type ViewID<Id extends string = string> = Tagged<Id, 'ViewID'>;
324
+ type ViewId<Id extends string = string> = Tagged<Id, 'ViewID'>;
164
325
  type ViewRulePredicate = {
165
326
  include: Expression[];
166
327
  exclude?: never;
@@ -168,6 +329,8 @@ type ViewRulePredicate = {
168
329
  include?: never;
169
330
  exclude: Expression[];
170
331
  };
332
+ declare function isViewRulePredicate(rule: DeploymentViewRule): rule is DeploymentViewRulePredicate;
333
+ declare function isViewRulePredicate(rule: DynamicViewRule): rule is DynamicViewIncludeRule;
171
334
  declare function isViewRulePredicate(rule: ViewRule): rule is ViewRulePredicate;
172
335
  interface ViewRuleGlobalPredicateRef {
173
336
  predicateId: GlobalPredicateId;
@@ -182,6 +345,7 @@ interface ViewRuleStyle {
182
345
  icon?: IconUrl;
183
346
  };
184
347
  }
348
+ declare function isViewRuleStyle(rule: DeploymentViewRule): rule is DeploymentViewRuleStyle;
185
349
  declare function isViewRuleStyle(rule: ViewRule): rule is ViewRuleStyle;
186
350
  interface ViewRuleGlobalStyle {
187
351
  styleId: GlobalStyleID;
@@ -195,7 +359,7 @@ interface ViewRuleAutoLayout {
195
359
  nodeSep?: number;
196
360
  rankSep?: number;
197
361
  }
198
- declare function isViewRuleAutoLayout(rule: ViewRule): rule is ViewRuleAutoLayout;
362
+ declare function isViewRuleAutoLayout(rule: DeploymentViewRule | DynamicViewRule | ViewRule): rule is ViewRuleAutoLayout;
199
363
  interface ViewRuleGroup {
200
364
  groupRules: Array<ViewRulePredicate | ViewRuleGroup>;
201
365
  title: string | null;
@@ -205,9 +369,9 @@ interface ViewRuleGroup {
205
369
  }
206
370
  declare function isViewRuleGroup(rule: ViewRule): rule is ViewRuleGroup;
207
371
  type ViewRule = ViewRulePredicate | ViewRuleGlobalPredicateRef | ViewRuleGroup | ViewRuleStyle | ViewRuleGlobalStyle | ViewRuleAutoLayout;
208
- interface BasicView<ViewType extends 'element' | 'dynamic', ViewIDs extends string, Tags extends string> {
372
+ interface BasicView<ViewType extends 'element' | 'dynamic' | 'deployment', ViewIDs extends string, Tags extends string> {
209
373
  readonly __?: ViewType;
210
- readonly id: ViewID<ViewIDs>;
374
+ readonly id: ViewId<ViewIDs>;
211
375
  readonly title: string | null;
212
376
  readonly description: string | null;
213
377
  readonly tags: NonEmptyArray<Tag<Tags>> | null;
@@ -240,7 +404,7 @@ interface ScopedElementView<ViewIDs extends string, Tags extends string> extends
240
404
  readonly viewOf: Fqn;
241
405
  }
242
406
  interface ExtendsElementView<ViewIDs extends string, Tags extends string> extends BasicElementView<ViewIDs, Tags> {
243
- readonly extends: ViewID<ViewIDs>;
407
+ readonly extends: ViewId<ViewIDs>;
244
408
  }
245
409
  type ElementView<ViewIDs extends string = string, Tags extends string = string> = ScopedElementView<ViewIDs, Tags> | ExtendsElementView<ViewIDs, Tags> | BasicElementView<ViewIDs, Tags>;
246
410
  interface DynamicViewStep {
@@ -256,7 +420,7 @@ interface DynamicViewStep {
256
420
  readonly head?: RelationshipArrowType;
257
421
  readonly tail?: RelationshipArrowType;
258
422
  readonly isBackward?: boolean;
259
- readonly navigateTo?: ViewID;
423
+ readonly navigateTo?: ViewId;
260
424
  __parallel?: never;
261
425
  }
262
426
  interface DynamicViewParallelSteps {
@@ -266,7 +430,6 @@ type DynamicViewStepOrParallel = DynamicViewStep | DynamicViewParallelSteps;
266
430
  type DynamicViewIncludeRule = {
267
431
  include: ElementPredicateExpression[];
268
432
  };
269
- declare function isDynamicViewIncludeRule(rule: DynamicViewRule): rule is DynamicViewIncludeRule;
270
433
  type DynamicViewRule = DynamicViewIncludeRule | ViewRuleGlobalPredicateRef | ViewRuleStyle | ViewRuleGlobalStyle | ViewRuleAutoLayout;
271
434
  interface DynamicView<ViewIDs extends string = string, Tags extends string = string> extends BasicView<'dynamic', ViewIDs, Tags> {
272
435
  readonly __: 'dynamic';
@@ -277,7 +440,32 @@ declare function isDynamicViewParallelSteps(step: DynamicViewStepOrParallel): st
277
440
  type CustomColorDefinitions = {
278
441
  [key: string]: ThemeColorValues;
279
442
  };
280
- type LikeC4View<ViewIDs extends string = string, Tags extends string = string> = ElementView<ViewIDs, Tags> | DynamicView<ViewIDs, Tags>;
443
+ type DeploymentViewRulePredicate = {
444
+ include: DeploymentExpression[];
445
+ exclude?: never;
446
+ } | {
447
+ include?: never;
448
+ exclude: DeploymentExpression[];
449
+ };
450
+ type DeploymentViewRuleStyle = {
451
+ targets: DeploymentExpression[];
452
+ notation?: string;
453
+ style: ElementStyle & {
454
+ color?: Color;
455
+ shape?: ElementShape;
456
+ icon?: IconUrl;
457
+ };
458
+ };
459
+ type DeploymentViewRule = DeploymentViewRulePredicate | ViewRuleAutoLayout | DeploymentViewRuleStyle;
460
+ interface DeploymentView<ViewIDs extends string = string, Tags extends string = string> extends BasicView<'deployment', ViewIDs, Tags> {
461
+ readonly __: 'deployment';
462
+ readonly rules: DeploymentViewRule[];
463
+ }
464
+ type LikeC4View<ViewIDs extends string = string, Tags extends string = string> = ElementView<ViewIDs, Tags> | DynamicView<ViewIDs, Tags> | DeploymentView<ViewIDs, Tags>;
465
+ declare function isDeploymentView(view: LikeC4View): view is DeploymentView;
466
+ declare function isDeploymentView<V extends {
467
+ __?: string;
468
+ }>(view: V): boolean;
281
469
  declare function isDynamicView(view: LikeC4View): view is DynamicView;
282
470
  declare function isElementView(view: LikeC4View): view is ElementView;
283
471
  declare function isExtendsElementView(view: LikeC4View): view is ExtendsElementView<string, string>;
@@ -286,14 +474,24 @@ type NodeId<IDs extends string = string> = Tagged<IDs, 'Fqn'>;
286
474
  type EdgeId = Tagged<string, 'EdgeId'>;
287
475
  type StepEdgeIdLiteral = `step-${number}` | `step-${number}.${number}`;
288
476
  type StepEdgeId = Tagged<StepEdgeIdLiteral, 'EdgeId'>;
289
- declare function StepEdgeId(step: number, parallelStep?: number): StepEdgeId;
477
+ declare function stepEdgeId(step: number, parallelStep?: number): StepEdgeId;
290
478
  declare function isStepEdgeId(id: string): id is StepEdgeId;
291
479
  declare function extractStep(id: EdgeId): number;
292
480
  declare function getParallelStepsPrefix(id: string): string | null;
293
481
  interface ComputedNode {
294
482
  id: NodeId;
295
- kind: ElementKind;
483
+ kind: string;
296
484
  parent: NodeId | null;
485
+ /**
486
+ * Reference to model element
487
+ * If 1 - node id is a reference
488
+ */
489
+ modelRef?: 1 | Fqn;
490
+ /**
491
+ * Reference to deployment element
492
+ * If 1 - node id is a reference
493
+ */
494
+ deploymentRef?: 1 | Fqn;
297
495
  title: string;
298
496
  description: string | null;
299
497
  technology: string | null;
@@ -304,16 +502,13 @@ interface ComputedNode {
304
502
  inEdges: EdgeId[];
305
503
  outEdges: EdgeId[];
306
504
  shape: ElementShape;
307
- /**
308
- * @deprecated Use `style` instead
309
- */
310
505
  color: Color;
311
506
  /**
312
507
  * @deprecated Use `style` instead
313
508
  */
314
509
  icon?: IconUrl;
315
510
  style: ElementStyle;
316
- navigateTo?: ViewID;
511
+ navigateTo?: ViewId;
317
512
  level: number;
318
513
  depth?: number;
319
514
  /**
@@ -322,6 +517,8 @@ interface ComputedNode {
322
517
  isCustomized?: boolean;
323
518
  }
324
519
  declare namespace ComputedNode {
520
+ function modelRef(node: ComputedNode): Fqn | null;
521
+ function deploymentRef(node: ComputedNode): Fqn | null;
325
522
  /**
326
523
  * Nodes group is a special kind of node, exisiting only in view
327
524
  */
@@ -335,7 +532,7 @@ interface ComputedEdge {
335
532
  label: string | null;
336
533
  description?: string;
337
534
  technology?: string;
338
- relations: RelationID[];
535
+ relations: RelationId[];
339
536
  kind?: RelationshipKind;
340
537
  notation?: string;
341
538
  notes?: string;
@@ -344,7 +541,7 @@ interface ComputedEdge {
344
541
  head?: RelationshipArrowType;
345
542
  tail?: RelationshipArrowType;
346
543
  tags?: NonEmptyArray<Tag>;
347
- navigateTo?: ViewID;
544
+ navigateTo?: ViewId;
348
545
  /**
349
546
  * If this edge is derived from custom relationship predicate
350
547
  */
@@ -353,7 +550,7 @@ interface ComputedEdge {
353
550
  * For layouting purposes
354
551
  * @default 'forward'
355
552
  */
356
- dir?: 'forward' | 'back';
553
+ dir?: 'forward' | 'back' | 'both';
357
554
  }
358
555
  interface ViewWithHash {
359
556
  /**
@@ -373,7 +570,7 @@ interface ViewAutoLayout {
373
570
  nodeSep?: number;
374
571
  }
375
572
  interface ComputedElementView<ViewIDs extends string = string, Tags extends string = string> extends Omit<ElementView<ViewIDs, Tags>, 'rules' | 'docUri'>, ViewWithHash, ViewWithNotation {
376
- readonly extends?: ViewID<ViewIDs>;
573
+ readonly extends?: ViewId<ViewIDs>;
377
574
  readonly autoLayout: ViewAutoLayout;
378
575
  readonly nodes: ComputedNode[];
379
576
  readonly edges: ComputedEdge[];
@@ -388,9 +585,19 @@ interface ComputedDynamicView<ViewIDs extends string = string, Tags extends stri
388
585
  rules?: never;
389
586
  docUri?: never;
390
587
  }
391
- declare function isComputedDynamicView(view: ComputedView): view is ComputedDynamicView;
392
- type ComputedView<ViewIDs extends string = string, Tags extends string = string> = ComputedElementView<ViewIDs, Tags> | ComputedDynamicView<ViewIDs, Tags>;
393
- declare function isComputedElementView(view: ComputedView): view is ComputedElementView;
588
+ interface ComputedDeploymentView<ViewIDs extends string = string, Tags extends string = string> extends Omit<DeploymentView<ViewIDs, Tags>, 'rules' | 'docUri'>, ViewWithHash, ViewWithNotation {
589
+ readonly autoLayout: ViewAutoLayout;
590
+ readonly nodes: ComputedNode[];
591
+ readonly edges: ComputedEdge[];
592
+ rules?: never;
593
+ docUri?: never;
594
+ }
595
+ type ComputedView<ViewIDs extends string = string, Tags extends string = string> = ComputedElementView<ViewIDs, Tags> | ComputedDynamicView<ViewIDs, Tags> | ComputedDeploymentView<ViewIDs, Tags>;
596
+ declare namespace ComputedView {
597
+ function isDeployment(view: ComputedView): view is ComputedDeploymentView;
598
+ function isDynamic(view: ComputedView): view is ComputedDynamicView;
599
+ function isElement(view: ComputedView): view is ComputedElementView;
600
+ }
394
601
  type BBox = {
395
602
  x: number;
396
603
  y: number;
@@ -405,6 +612,8 @@ interface DiagramNode extends ComputedNode {
405
612
  labelBBox: BBox;
406
613
  }
407
614
  declare namespace DiagramNode {
615
+ function modelRef(node: DiagramNode): Fqn | null;
616
+ function deploymentRef(node: DiagramNode): Fqn | null;
408
617
  /**
409
618
  * Nodes group is a special kind of node, exisiting only in view
410
619
  */
@@ -449,7 +658,7 @@ type ViewManualLayout = {
449
658
  }>;
450
659
  };
451
660
 
452
- type RelationID = Tagged<string, 'RelationID'>;
661
+ type RelationId = Tagged<string, 'RelationID'>;
453
662
  type RelationshipKind<Kinds extends string = string> = Tagged<Kinds, 'RelationshipKind'>;
454
663
  type RelationshipLineType = 'dashed' | 'solid' | 'dotted';
455
664
  type RelationshipArrowType = 'none' | 'normal' | 'onormal' | 'dot' | 'odot' | 'diamond' | 'odiamond' | 'crow' | 'open' | 'vee';
@@ -457,7 +666,7 @@ declare const DefaultLineStyle = "dashed";
457
666
  declare const DefaultArrowType = "normal";
458
667
  declare const DefaultRelationshipColor = "gray";
459
668
  interface Relation {
460
- readonly id: RelationID;
669
+ readonly id: RelationId;
461
670
  readonly source: Fqn;
462
671
  readonly target: Fqn;
463
672
  readonly title: string;
@@ -470,7 +679,7 @@ interface Relation {
470
679
  readonly head?: RelationshipArrowType;
471
680
  readonly tail?: RelationshipArrowType;
472
681
  readonly links?: NonEmptyArray<Link>;
473
- readonly navigateTo?: ViewID;
682
+ readonly navigateTo?: ViewId;
474
683
  readonly metadata?: {
475
684
  [key: string]: string;
476
685
  };
@@ -484,251 +693,191 @@ interface RelationshipKindSpecification {
484
693
  readonly tail?: RelationshipArrowType;
485
694
  }
486
695
 
487
- interface BaseExpr {
488
- where?: never;
489
- element?: never;
490
- custom?: never;
491
- expanded?: never;
492
- elementKind?: never;
493
- elementTag?: never;
494
- isEqual?: never;
495
- isDescedants?: never;
496
- wildcard?: never;
497
- source?: never;
498
- target?: never;
499
- inout?: never;
500
- incoming?: never;
501
- outgoing?: never;
502
- customRelation?: never;
503
- }
504
- interface ElementRefExpr extends Omit<BaseExpr, 'element' | 'isDescedants'> {
505
- element: Fqn;
506
- isDescedants?: boolean;
696
+ type DeploymentNodeKind<Kinds extends string = string> = Tagged<Kinds, 'DeploymentNodeKind'>;
697
+ type PhysicalElementStyle = ElementStyle & {
698
+ readonly icon?: IconUrl;
699
+ readonly shape?: ElementShape;
700
+ readonly color?: Color;
701
+ };
702
+ interface DeploymentNodeKindSpecification {
703
+ readonly technology?: string;
704
+ readonly notation?: string;
705
+ readonly style: PhysicalElementStyle;
507
706
  }
508
- declare function isElementRef(expr: Expression): expr is ElementRefExpr;
509
- interface ExpandedElementExpr extends Omit<BaseExpr, 'expanded'> {
510
- expanded: Fqn;
707
+ interface DeploymentNode {
708
+ readonly id: Fqn;
709
+ readonly kind: DeploymentNodeKind;
710
+ readonly title: string;
711
+ readonly description?: string | null;
712
+ readonly technology?: string | null;
713
+ readonly tags?: NonEmptyArray<Tag> | null;
714
+ readonly links?: NonEmptyArray<Link> | null;
715
+ readonly style?: PhysicalElementStyle;
716
+ readonly notation?: string;
717
+ readonly metadata?: Record<string, string>;
511
718
  }
512
- declare function isExpandedElementExpr(expr: Expression): expr is ExpandedElementExpr;
513
- interface CustomElementExpr extends Omit<BaseExpr, 'custom'> {
514
- custom: {
515
- expr: ElementExpression | ElementWhereExpr;
516
- title?: string;
517
- description?: string;
518
- technology?: string;
519
- notation?: string;
520
- shape?: ElementShape;
521
- color?: Color;
522
- icon?: IconUrl;
523
- border?: BorderStyle;
524
- opacity?: number;
525
- navigateTo?: ViewID;
526
- };
719
+ interface DeployedInstance {
720
+ /**
721
+ * Format: `<DeploymentNode Fqn>.<Instance Id>`
722
+ * i.e parent fqn is deployment target
723
+ */
724
+ readonly id: Fqn;
725
+ readonly element: Fqn;
726
+ readonly title?: string;
727
+ readonly description?: string | null;
728
+ readonly technology?: string | null;
729
+ readonly tags?: NonEmptyArray<Tag> | null;
730
+ readonly links?: NonEmptyArray<Link> | null;
731
+ readonly style?: PhysicalElementStyle;
732
+ readonly notation?: string;
733
+ readonly metadata?: Record<string, string>;
527
734
  }
528
- declare function isCustomElement(expr: Expression): expr is CustomElementExpr;
529
- interface WildcardExpr extends Omit<BaseExpr, 'wildcard'> {
530
- wildcard: true;
735
+ type DeploymentElement = Simplify<MergeExclusive<DeploymentNode, DeployedInstance>>;
736
+ declare namespace DeploymentElement {
737
+ const isDeploymentNode: (el: DeploymentElement) => el is DeploymentNode;
738
+ const isInstance: (el: DeploymentElement) => el is DeployedInstance;
531
739
  }
532
- declare function isWildcard(expr: Expression): expr is WildcardExpr;
533
- interface ElementKindExpr extends Omit<BaseExpr, 'elementKind' | 'isEqual'> {
534
- elementKind: ElementKind;
535
- isEqual: boolean;
740
+ interface DeploymentRef {
741
+ readonly id: Fqn;
742
+ readonly element?: Fqn;
536
743
  }
537
- declare function isElementKindExpr(expr: Expression): expr is ElementKindExpr;
538
- interface ElementTagExpr extends Omit<BaseExpr, 'elementTag' | 'isEqual'> {
539
- elementTag: Tag;
540
- isEqual: boolean;
541
- }
542
- declare function isElementTagExpr(expr: Expression): expr is ElementTagExpr;
543
- type ElementExpression = ElementRefExpr | WildcardExpr | ElementKindExpr | ElementTagExpr | ExpandedElementExpr;
544
- declare function isElement(expr: Expression): expr is ElementExpression;
545
- interface ElementWhereExpr extends Omit<BaseExpr, 'where'> {
546
- where: {
547
- expr: ElementExpression;
548
- condition: WhereOperator<string, string>;
744
+ /**
745
+ * NOTE:
746
+ */
747
+ interface DeploymentRelation {
748
+ readonly id: RelationId;
749
+ readonly source: DeploymentRef;
750
+ readonly target: DeploymentRef;
751
+ readonly title?: string;
752
+ readonly tags?: NonEmptyArray<Tag> | null;
753
+ readonly description?: string;
754
+ readonly technology?: string;
755
+ readonly kind?: RelationshipKind;
756
+ readonly color?: Color;
757
+ readonly line?: RelationshipLineType;
758
+ readonly head?: RelationshipArrowType;
759
+ readonly tail?: RelationshipArrowType;
760
+ readonly links?: NonEmptyArray<Link> | null;
761
+ readonly navigateTo?: ViewId;
762
+ readonly metadata?: {
763
+ [key: string]: string;
549
764
  };
550
765
  }
551
- declare function isElementWhere(expr: Expression): expr is ElementWhereExpr;
552
- type ElementPredicateExpression = ElementExpression | ElementWhereExpr | CustomElementExpr;
553
- declare function isElementPredicateExpr(expr: Expression): expr is ElementPredicateExpression;
554
- interface RelationExpr extends Omit<BaseExpr, 'source' | 'target'> {
555
- source: ElementExpression;
556
- target: ElementExpression;
557
- isBidirectional?: boolean;
558
- }
559
- declare function isRelation(expr: Expression): expr is RelationExpr;
560
- interface InOutExpr extends Omit<BaseExpr, 'inout'> {
561
- inout: ElementExpression;
562
- }
563
- declare function isInOut(expr: Expression): expr is InOutExpr;
564
- interface IncomingExpr extends Omit<BaseExpr, 'incoming'> {
565
- incoming: ElementExpression;
566
- }
567
- declare function isIncoming(expr: Expression): expr is IncomingExpr;
568
- interface OutgoingExpr extends Omit<BaseExpr, 'outgoing'> {
569
- outgoing: ElementExpression;
570
- }
571
- declare function isOutgoing(expr: Expression): expr is OutgoingExpr;
572
- type RelationExpression = RelationExpr | InOutExpr | IncomingExpr | OutgoingExpr;
573
- declare function isRelationExpression(expr: Expression): expr is RelationExpression;
574
- interface RelationWhereExpr extends Omit<BaseExpr, 'where'> {
575
- where: {
576
- expr: RelationExpression;
577
- condition: WhereOperator<string, string>;
766
+ type AllNever<Expressions> = UnionToIntersection<{
767
+ [Name in keyof Expressions]: {
768
+ -readonly [Key in keyof Expressions[Name]]?: never;
578
769
  };
579
- }
580
- declare function isRelationWhere(expr: Expression): expr is RelationWhereExpr;
581
- interface CustomRelationExpr extends Omit<BaseExpr, 'customRelation'> {
582
- customRelation: {
583
- relation: RelationExpression | RelationWhereExpr;
584
- title?: string;
585
- description?: string;
586
- technology?: string;
587
- notation?: string;
588
- navigateTo?: ViewID;
589
- notes?: string;
590
- color?: Color;
591
- line?: RelationshipLineType;
592
- head?: RelationshipArrowType;
593
- tail?: RelationshipArrowType;
770
+ }[keyof Expressions]>;
771
+ type ExclusiveUnion<Expressions> = Expressions extends object ? {
772
+ [Name in keyof Expressions]: Simplify<Omit<AllNever<Expressions>, keyof Expressions[Name]> & Expressions[Name]>;
773
+ }[keyof Expressions] : Expressions;
774
+ declare namespace DeploymentRelationExpression {
775
+ type Direct = {
776
+ source: DeploymentElementExpression;
777
+ target: DeploymentElementExpression;
778
+ isBidirectional?: boolean;
594
779
  };
595
- }
596
- declare function isCustomRelationExpr(expr: Expression): expr is CustomRelationExpr;
597
- type RelationPredicateExpression = RelationExpression | RelationWhereExpr | CustomRelationExpr;
598
- declare function isRelationPredicateExpr(expr: Expression): expr is RelationPredicateExpression;
599
- type Expression = ElementPredicateExpression | RelationPredicateExpression;
600
-
601
- type expression_CustomElementExpr = CustomElementExpr;
602
- type expression_CustomRelationExpr = CustomRelationExpr;
603
- type expression_ElementExpression = ElementExpression;
604
- type expression_ElementKindExpr = ElementKindExpr;
605
- type expression_ElementPredicateExpression = ElementPredicateExpression;
606
- type expression_ElementRefExpr = ElementRefExpr;
607
- type expression_ElementTagExpr = ElementTagExpr;
608
- type expression_ElementWhereExpr = ElementWhereExpr;
609
- type expression_ExpandedElementExpr = ExpandedElementExpr;
610
- type expression_Expression = Expression;
611
- type expression_InOutExpr = InOutExpr;
612
- type expression_IncomingExpr = IncomingExpr;
613
- type expression_OutgoingExpr = OutgoingExpr;
614
- type expression_RelationExpr = RelationExpr;
615
- type expression_RelationExpression = RelationExpression;
616
- type expression_RelationPredicateExpression = RelationPredicateExpression;
617
- type expression_RelationWhereExpr = RelationWhereExpr;
618
- type expression_WildcardExpr = WildcardExpr;
619
- declare const expression_isCustomElement: typeof isCustomElement;
620
- declare const expression_isCustomRelationExpr: typeof isCustomRelationExpr;
621
- declare const expression_isElement: typeof isElement;
622
- declare const expression_isElementKindExpr: typeof isElementKindExpr;
623
- declare const expression_isElementPredicateExpr: typeof isElementPredicateExpr;
624
- declare const expression_isElementRef: typeof isElementRef;
625
- declare const expression_isElementTagExpr: typeof isElementTagExpr;
626
- declare const expression_isElementWhere: typeof isElementWhere;
627
- declare const expression_isExpandedElementExpr: typeof isExpandedElementExpr;
628
- declare const expression_isInOut: typeof isInOut;
629
- declare const expression_isIncoming: typeof isIncoming;
630
- declare const expression_isOutgoing: typeof isOutgoing;
631
- declare const expression_isRelation: typeof isRelation;
632
- declare const expression_isRelationExpression: typeof isRelationExpression;
633
- declare const expression_isRelationPredicateExpr: typeof isRelationPredicateExpr;
634
- declare const expression_isRelationWhere: typeof isRelationWhere;
635
- declare const expression_isWildcard: typeof isWildcard;
636
- declare namespace expression {
637
- export { type expression_CustomElementExpr as CustomElementExpr, type expression_CustomRelationExpr as CustomRelationExpr, type expression_ElementExpression as ElementExpression, type expression_ElementKindExpr as ElementKindExpr, type expression_ElementPredicateExpression as ElementPredicateExpression, type expression_ElementRefExpr as ElementRefExpr, type expression_ElementTagExpr as ElementTagExpr, type expression_ElementWhereExpr as ElementWhereExpr, type expression_ExpandedElementExpr as ExpandedElementExpr, type expression_Expression as Expression, type expression_InOutExpr as InOutExpr, type expression_IncomingExpr as IncomingExpr, type expression_OutgoingExpr as OutgoingExpr, type expression_RelationExpr as RelationExpr, type expression_RelationExpression as RelationExpression, type expression_RelationPredicateExpression as RelationPredicateExpression, type expression_RelationWhereExpr as RelationWhereExpr, type expression_WildcardExpr as WildcardExpr, expression_isCustomElement as isCustomElement, expression_isCustomRelationExpr as isCustomRelationExpr, expression_isElement as isElement, expression_isElementKindExpr as isElementKindExpr, expression_isElementPredicateExpr as isElementPredicateExpr, expression_isElementRef as isElementRef, expression_isElementTagExpr as isElementTagExpr, expression_isElementWhere as isElementWhere, expression_isExpandedElementExpr as isExpandedElementExpr, expression_isInOut as isInOut, expression_isIncoming as isIncoming, expression_isOutgoing as isOutgoing, expression_isRelation as isRelation, expression_isRelationExpression as isRelationExpression, expression_isRelationPredicateExpr as isRelationPredicateExpr, expression_isRelationWhere as isRelationWhere, expression_isWildcard as isWildcard };
780
+ const isDirect: (expr: DeploymentExpression) => expr is Direct;
781
+ type Incoming = {
782
+ incoming: DeploymentElementExpression;
783
+ };
784
+ const isIncoming: (expr: DeploymentExpression) => expr is Incoming;
785
+ type Outgoing = {
786
+ outgoing: DeploymentElementExpression;
787
+ };
788
+ const isOutgoing: (expr: DeploymentExpression) => expr is Outgoing;
789
+ type InOut = {
790
+ inout: DeploymentElementExpression;
791
+ };
792
+ const isInOut: (expr: DeploymentExpression) => expr is InOut;
793
+ }
794
+ type DeploymentRelationExpression = ExclusiveUnion<{
795
+ Direct: DeploymentRelationExpression.Direct;
796
+ Incoming: DeploymentRelationExpression.Incoming;
797
+ Outgoing: DeploymentRelationExpression.Outgoing;
798
+ InOut: DeploymentRelationExpression.InOut;
799
+ }>;
800
+ declare namespace DeploymentElementExpression {
801
+ type Ref = {
802
+ ref: DeploymentRef;
803
+ selector?: 'children' | 'expanded' | 'descendants';
804
+ };
805
+ const isRef: (expr: DeploymentExpression) => expr is Ref;
806
+ type Wildcard = {
807
+ wildcard: true;
808
+ };
809
+ const isWildcard: (expr: DeploymentExpression) => expr is Wildcard;
810
+ }
811
+ type DeploymentElementExpression = ExclusiveUnion<{
812
+ DeploymentRef: DeploymentElementExpression.Ref;
813
+ Wildcard: DeploymentElementExpression.Wildcard;
814
+ }>;
815
+ type DeploymentExpression = ExclusiveUnion<{
816
+ Element: DeploymentElementExpression;
817
+ Relation: DeploymentRelationExpression;
818
+ }>;
819
+ declare namespace DeploymentExpression {
820
+ type Element = DeploymentElementExpression;
821
+ type Relation = DeploymentRelationExpression;
822
+ const isElement: (expr: DeploymentExpression) => expr is DeploymentElementExpression;
823
+ const isRelation: (expr: DeploymentExpression) => expr is DeploymentRelationExpression;
638
824
  }
639
825
 
640
826
  /**
641
827
  * Parsed elements, relations, and views.
642
828
  */
643
- interface ParsedLikeC4Model<ElementKinds extends string = string, RelationKinds extends string = string, Tags extends string = string, Fqns extends string = string, Views extends string = string> {
829
+ interface ParsedLikeC4Model<ElementKinds extends string = string, RelationKinds extends string = string, Tags extends string = string, Fqns extends string = string, Views extends string = string, DeploymentFqns extends string = string> {
644
830
  specification: {
645
831
  tags: Tag<Tags>[];
646
832
  elements: Record<ElementKinds, ElementKindSpecification>;
833
+ deployments: Record<DeploymentNodeKind, DeploymentNodeKindSpecification>;
647
834
  relationships: Record<RelationKinds, RelationshipKindSpecification>;
648
835
  };
649
836
  elements: Record<Fqns, TypedElement<Fqns, ElementKinds, Tags>>;
650
- relations: Record<RelationID, Relation>;
837
+ relations: Record<RelationId, Relation>;
651
838
  globals: ModelGlobals;
652
839
  views: Record<Views, LikeC4View<Views, Tags>>;
840
+ /**
841
+ * Deployment Model.
842
+ */
843
+ deployments: {
844
+ elements: Record<DeploymentFqns, DeploymentElement>;
845
+ relations: Record<RelationId, DeploymentRelation>;
846
+ };
653
847
  }
654
848
  /**
655
- * Same as `ParsedLikeC4Model` but with computed views.
849
+ * Hook to get types from dump
656
850
  */
657
- interface ComputedLikeC4Model extends Omit<ParsedLikeC4Model, 'views'> {
658
- __?: never;
659
- views: Record<ViewID, ComputedView>;
851
+ type ParsedLikeC4ModelDump = {
852
+ elements: {
853
+ [kind: string]: object;
854
+ };
855
+ deployments: {
856
+ elements: {
857
+ [kind: string]: object;
858
+ };
859
+ };
860
+ views: {
861
+ [kind: string]: object;
862
+ };
863
+ };
864
+ interface AnyLikeC4Model<Fqns extends string = string, DeploymentFqns extends string = string, Views extends string = string, Tags extends string = string, T = 'computed' | 'layouted'> extends Omit<ParsedLikeC4Model<string, string, Tags, Fqns, Views, DeploymentFqns>, 'views'> {
865
+ __?: T;
866
+ views: Record<Views, ComputedView | DiagramView>;
660
867
  }
661
868
  /**
662
- * Same as `ParsedLikeC4Model` but with layouted views (DiagramView)
869
+ * Same as `ParsedLikeC4Model` but with computed views.
663
870
  */
664
- interface LayoutedLikeC4Model extends Omit<ParsedLikeC4Model, 'views'> {
665
- __: 'layouted';
666
- views: Record<ViewID, DiagramView>;
871
+ interface ComputedLikeC4Model<Fqns extends string = string, DeploymentFqns extends string = string, Views extends string = string, Tags extends string = string> extends Omit<AnyLikeC4Model<Fqns, DeploymentFqns, Views, Tags, 'computed'>, 'views'> {
872
+ views: Record<Views, ComputedView>;
667
873
  }
668
-
874
+ type ComputedLikeC4ModelFromParsed<M> = M extends ParsedLikeC4Model ? ComputedLikeC4Model<KeysOf<M['elements']>, KeysOf<M['deployments']['elements']>, KeysOf<M['views']>> : ComputedLikeC4Model;
669
875
  /**
670
- * OverviewGraph is a graph representation of all views in a model
876
+ * Same as `ParsedLikeC4Model` but with layouted views (DiagramView)
671
877
  */
672
- declare namespace OverviewGraph {
673
- type Node = {
674
- id: string;
675
- type: 'folder' | 'file';
676
- path: string;
677
- label: string;
678
- parentId: string | null;
679
- position: XYPoint;
680
- width: number;
681
- height: number;
682
- } | {
683
- id: string;
684
- type: 'view';
685
- viewId: ViewID;
686
- label: string;
687
- parentId: string | null;
688
- position: XYPoint;
689
- width: number;
690
- height: number;
691
- };
692
- /**
693
- * Edge represents a navigational link from one view to another
694
- */
695
- type Edge = {
696
- id: string;
697
- source: string;
698
- target: string;
699
- points: NonEmptyArray<Point>;
700
- };
701
- }
702
- interface OverviewGraph {
703
- nodes: OverviewGraph.Node[];
704
- edges: OverviewGraph.Edge[];
705
- bounds: BBox;
706
- }
707
-
708
- declare namespace ViewChange {
709
- interface ChangeElementStyle {
710
- op: 'change-element-style';
711
- style: {
712
- border?: BorderStyle;
713
- opacity?: number;
714
- shape?: ElementShape;
715
- color?: ThemeColor;
716
- };
717
- targets: NonEmptyArray<Fqn>;
718
- }
719
- interface SaveManualLayout {
720
- op: 'save-manual-layout';
721
- layout: ViewManualLayout;
722
- }
723
- interface ChangeAutoLayout {
724
- op: 'change-autolayout';
725
- layout: {
726
- direction: AutoLayoutDirection;
727
- nodeSep?: number | null;
728
- rankSep?: number | null;
729
- };
730
- }
878
+ interface LayoutedLikeC4Model<Fqns extends string = string, DeploymentFqns extends string = string, Views extends string = string, Tags extends string = string> extends Omit<AnyLikeC4Model<Fqns, DeploymentFqns, Views, Tags, 'layouted'>, 'views'> {
879
+ __: 'layouted';
880
+ views: Record<Views, DiagramView<Views, Tags>>;
731
881
  }
732
- type ViewChange = ViewChange.ChangeElementStyle | ViewChange.SaveManualLayout | ViewChange.ChangeAutoLayout;
733
882
 
734
- export { type ExpandedElementExpr as $, type AutoLayoutDirection as A, type BorderStyle as B, type Color as C, type DiagramView as D, type ElementKindSpecification as E, type Fqn as F, AsFqn as G, type HexColorLiteral as H, type IconUrl as I, BorderStyles as J, ElementShapes as K, type LikeC4View as L, DefaultThemeColor as M, type NonEmptyArray as N, DefaultElementShape as O, type ParsedLikeC4Model as P, type ElementStyle as Q, type RelationshipKindSpecification as R, type TagSpec as S, type ThemeColorValues as T, type Link as U, type ViewRuleStyle as V, type TypedElement as W, type XYPoint as X, type ElementKindSpecificationStyle as Y, type ElementRefExpr as Z, isElementRef as _, type ElementShape as a, type ViewRuleGlobalPredicateRef as a$, isExpandedElementExpr as a0, isCustomElement as a1, type WildcardExpr as a2, isWildcard as a3, type ElementKindExpr as a4, isElementKindExpr as a5, type ElementTagExpr as a6, isElementTagExpr as a7, type ElementExpression as a8, isElement as a9, type TagEqual as aA, isTagEqual as aB, type KindEqual as aC, isKindEqual as aD, type NotOperator as aE, isNotOperator as aF, type AndOperator as aG, isAndOperator as aH, type OrOperator as aI, isOrOperator as aJ, type WhereOperator as aK, type Filterable as aL, whereOperatorAsPredicate as aM, OverviewGraph as aN, DefaultLineStyle as aO, DefaultArrowType as aP, DefaultRelationshipColor as aQ, type ThemeColor as aR, type ColorLiteral as aS, isThemeColor as aT, type ElementThemeColorValues as aU, type ElementThemeColors as aV, type RelationshipThemeColorValues as aW, type RelationshipThemeColors as aX, type LikeC4Theme as aY, type ViewRulePredicate as aZ, isViewRulePredicate as a_, type ElementWhereExpr as aa, isElementWhere as ab, type ElementPredicateExpression as ac, isElementPredicateExpr as ad, type RelationExpr as ae, isRelation as af, type InOutExpr as ag, isInOut as ah, type IncomingExpr as ai, isIncoming as aj, type OutgoingExpr as ak, isOutgoing as al, type RelationExpression as am, isRelationExpression as an, type RelationWhereExpr as ao, isRelationWhere as ap, isCustomRelationExpr as aq, type RelationPredicateExpression as ar, isRelationPredicateExpr as as, type GlobalPredicateId as at, type GlobalPredicates as au, type GlobalDynamicPredicates as av, type GlobalStyleID as aw, type GlobalStyles as ax, type ModelGlobals as ay, type EqualOperator as az, type RelationshipArrowType as b, isViewRuleGlobalPredicateRef as b0, isViewRuleStyle as b1, type ViewRuleGlobalStyle as b2, isViewRuleGlobalStyle as b3, type ViewRuleStyleOrGlobalRef as b4, isAutoLayoutDirection as b5, type ViewRuleAutoLayout as b6, isViewRuleAutoLayout as b7, type ViewRuleGroup as b8, isViewRuleGroup as b9, type ViewAutoLayout as bA, type ComputedElementView as bB, type ComputedDynamicView as bC, isComputedDynamicView as bD, isComputedElementView as bE, type BBox as bF, getBBoxCenter as bG, type ViewManualLayout as bH, ViewChange as bI, type ElementNotation as bJ, type ViewRule as ba, type BasicView as bb, type BasicElementView as bc, type ScopedElementView as bd, type ExtendsElementView as be, type ElementView as bf, type DynamicViewStep as bg, type DynamicViewParallelSteps as bh, type DynamicViewStepOrParallel as bi, type DynamicViewIncludeRule as bj, isDynamicViewIncludeRule as bk, type DynamicViewRule as bl, type DynamicView as bm, isDynamicViewParallelSteps as bn, type CustomColorDefinitions as bo, isDynamicView as bp, isElementView as bq, isExtendsElementView as br, isScopedElementView as bs, type StepEdgeIdLiteral as bt, StepEdgeId as bu, isStepEdgeId as bv, extractStep as bw, getParallelStepsPrefix as bx, type ViewWithHash as by, type ViewWithNotation as bz, type RelationshipLineType as c, type Element as d, type Relation as e, type Expression as f, type CustomElementExpr as g, type CustomRelationExpr as h, type RelationID as i, type ViewID as j, type EdgeId as k, type ComputedView as l, type Tag as m, ComputedNode as n, type NodeId as o, ElementKind as p, type ComputedEdge as q, type ComputedLikeC4Model as r, type LayoutedLikeC4Model as s, type RelationshipKind as t, DiagramNode as u, type DiagramEdge as v, expression as w, type NonEmptyReadonlyArray as x, type CustomColor as y, type Point as z };
883
+ export { type TypedElement as $, type AutoLayoutDirection as A, type BorderStyle as B, type ComputedLikeC4ModelFromParsed as C, type DeploymentNodeKindSpecification as D, type Element as E, type Fqn as F, AsFqn as G, type HexColorLiteral as H, type IconUrl as I, BorderStyles as J, type KeysOf as K, type LikeC4View as L, type ModelGlobals as M, type NonEmptyArray as N, ElementKind as O, type ParsedLikeC4Model as P, ElementShapes as Q, type Relation as R, DefaultThemeColor as S, type ThemeColorValues as T, DefaultElementShape as U, type ViewRuleStyle as V, type ElementStyle as W, type XYPoint as X, type Tag as Y, type TagSpec as Z, type Link as _, ComputedView as a, type ElementThemeColors as a$, type ElementKindSpecificationStyle as a0, type ElementRefExpr as a1, isElementRef as a2, type ExpandedElementExpr as a3, isExpandedElementExpr as a4, isCustomElement as a5, type WildcardExpr as a6, isWildcard as a7, type ElementKindExpr as a8, isElementKindExpr as a9, type GlobalStyleID as aA, type GlobalStyles as aB, type ParsedLikeC4ModelDump as aC, type AnyLikeC4Model as aD, type LayoutedLikeC4Model as aE, type EqualOperator as aF, type TagEqual as aG, isTagEqual as aH, type KindEqual as aI, isKindEqual as aJ, type NotOperator as aK, isNotOperator as aL, type AndOperator as aM, isAndOperator as aN, type OrOperator as aO, isOrOperator as aP, type WhereOperator as aQ, type Filterable as aR, whereOperatorAsPredicate as aS, type RelationshipKind as aT, DefaultLineStyle as aU, DefaultArrowType as aV, DefaultRelationshipColor as aW, type ThemeColor as aX, type ColorLiteral as aY, isThemeColor as aZ, type ElementThemeColorValues as a_, type ElementTagExpr as aa, isElementTagExpr as ab, type ElementExpression as ac, isElement as ad, type ElementWhereExpr as ae, isElementWhere as af, type ElementPredicateExpression as ag, isElementPredicateExpr as ah, type RelationExpr as ai, isRelation as aj, type InOutExpr as ak, isInOut as al, type IncomingExpr as am, isIncoming as an, type OutgoingExpr as ao, isOutgoing as ap, type RelationExpression as aq, isRelationExpression as ar, type RelationWhereExpr as as, isRelationWhere as at, isCustomRelationExpr as au, type RelationPredicateExpression as av, isRelationPredicateExpr as aw, type GlobalPredicateId as ax, type GlobalPredicates as ay, type GlobalDynamicPredicates as az, type RelationId as b, type RelationshipThemeColorValues as b0, type RelationshipThemeColors as b1, type LikeC4Theme as b2, type ViewId as b3, type ViewRulePredicate as b4, isViewRulePredicate as b5, type ViewRuleGlobalPredicateRef as b6, isViewRuleGlobalPredicateRef as b7, isViewRuleStyle as b8, type ViewRuleGlobalStyle as b9, isDynamicView as bA, isElementView as bB, isExtendsElementView as bC, isScopedElementView as bD, type NodeId as bE, type EdgeId as bF, type StepEdgeIdLiteral as bG, type StepEdgeId as bH, stepEdgeId as bI, isStepEdgeId as bJ, extractStep as bK, getParallelStepsPrefix as bL, ComputedNode as bM, type ComputedEdge as bN, type ViewWithHash as bO, type ViewWithNotation as bP, type ViewAutoLayout as bQ, type ComputedElementView as bR, type ComputedDynamicView as bS, type ComputedDeploymentView as bT, type BBox as bU, getBBoxCenter as bV, DiagramNode as bW, type DiagramEdge as bX, type DiagramView as bY, type ViewManualLayout as bZ, type ElementNotation as b_, isViewRuleGlobalStyle as ba, type ViewRuleStyleOrGlobalRef as bb, isAutoLayoutDirection as bc, type ViewRuleAutoLayout as bd, isViewRuleAutoLayout as be, type ViewRuleGroup as bf, isViewRuleGroup as bg, type ViewRule as bh, type BasicView as bi, type BasicElementView as bj, type ScopedElementView as bk, type ExtendsElementView as bl, type ElementView as bm, type DynamicViewStep as bn, type DynamicViewParallelSteps as bo, type DynamicViewStepOrParallel as bp, type DynamicViewIncludeRule as bq, type DynamicViewRule as br, type DynamicView as bs, isDynamicViewParallelSteps as bt, type CustomColorDefinitions as bu, type DeploymentViewRulePredicate as bv, type DeploymentViewRuleStyle as bw, type DeploymentViewRule as bx, type DeploymentView as by, isDeploymentView as bz, type ComputedLikeC4Model as c, type ElementKindSpecification as d, type RelationshipKindSpecification as e, type ElementShape as f, type Color as g, type RelationshipArrowType as h, type RelationshipLineType as i, DeploymentElement as j, type DeploymentRelation as k, type Expression as l, type CustomElementExpr as m, type CustomRelationExpr as n, DeploymentExpression as o, expression as p, type NonEmptyReadonlyArray as q, type CustomColor as r, type Point as s, type DeploymentNodeKind as t, type PhysicalElementStyle as u, type DeploymentNode as v, type DeployedInstance as w, type DeploymentRef as x, DeploymentRelationExpression as y, DeploymentElementExpression as z };