likec4 1.17.0 → 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 (28) hide show
  1. package/{dist/__app__ → __app__}/react/likec4.tsx +9 -26
  2. package/{dist/__app__/src/chunks/-index-overview-DNT3FQkn.js → __app__/src/chunks/-index-overview-CBnvpD1d.js} +12 -12
  3. package/{dist/__app__/src/chunks/likec4-CLNXvKhh.js → __app__/src/chunks/likec4-DslTxitT.js} +50 -41
  4. package/{dist/__app__/src/chunks/main-Beyl8kQ7.js → __app__/src/chunks/main-ByUdz_Be.js} +14236 -13301
  5. package/{dist/__app__/src/chunks/mantine-CdYQpHSU.js → __app__/src/chunks/mantine-oFa3ZrEq.js} +1731 -713
  6. package/{dist/__app__/src/chunks/tanstack-router-DJI32bwX.js → __app__/src/chunks/tanstack-router-BWjXKr0n.js} +1 -1
  7. package/{dist/__app__ → __app__}/src/main.js +1 -1
  8. package/{dist/__app__ → __app__}/src/style.css +1 -1
  9. package/{dist/__app__ → __app__}/webcomponent/webcomponent.js +30987 -28447
  10. package/dist/chunks/prompt.mjs +3 -3
  11. package/dist/cli/index.mjs +210 -179
  12. package/dist/index.d.mts +1785 -722
  13. package/dist/index.d.ts +1785 -722
  14. package/dist/index.mjs +1 -1
  15. package/dist/shared/likec4.lgHXhASw.mjs +1832 -0
  16. package/package.json +37 -37
  17. package/react/index.d.ts +896 -423
  18. package/react/index.mjs +32935 -29389
  19. package/react/style.css +1 -1
  20. package/dist/shared/likec4.D5WUQlNc.mjs +0 -1824
  21. /package/{dist/__app__ → __app__}/favicon.ico +0 -0
  22. /package/{dist/__app__ → __app__}/favicon.svg +0 -0
  23. /package/{dist/__app__ → __app__}/index.html +0 -0
  24. /package/{dist/__app__ → __app__}/robots.txt +0 -0
  25. /package/{dist/__app__ → __app__}/src/chunks/-view-lazy-data-WZmbIsHq.js +0 -0
  26. /package/{dist/__app__ → __app__}/src/chunks/index-CIsxIzOH.js +0 -0
  27. /package/{dist/__app__ → __app__}/src/const.js +0 -0
  28. /package/{dist/__app__ → __app__}/src/icons.js +0 -0
package/react/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // Generated by dts-bundle-generator v9.5.1
2
2
 
3
3
  import { CSSProperties, DependencyList, HTMLAttributes, MouseEvent as ReactMouseEvent, PropsWithChildren, ReactNode } from 'react';
4
- import { Class, LiteralUnion, NonEmptyTuple, OverrideProperties, PartialDeep, Tagged, TupleToUnion } from 'type-fest';
4
+ import { IsLiteral, LiteralUnion, MergeExclusive, NonEmptyTuple, OverrideProperties, PartialDeep, SetRequired, Simplify, Tagged, TupleToUnion, UnionToIntersection } from 'type-fest';
5
5
 
6
6
  type NonEmptyArray<T> = [
7
7
  T,
@@ -16,6 +16,7 @@ interface XYPoint {
16
16
  x: number;
17
17
  y: number;
18
18
  }
19
+ type KeysOf<T> = keyof T extends infer K extends string ? K : never;
19
20
  declare const ThemeColors: readonly [
20
21
  "amber",
21
22
  "blue",
@@ -71,8 +72,13 @@ declare const ElementShapes: readonly [
71
72
  ];
72
73
  type ElementShape = TupleToUnion<typeof ElementShapes>;
73
74
  interface ElementStyle {
74
- border?: BorderStyle;
75
- opacity?: number;
75
+ readonly border?: BorderStyle;
76
+ /**
77
+ * In percentage 0-100, 0 is fully transparent
78
+ *
79
+ * @default 100
80
+ */
81
+ readonly opacity?: number;
76
82
  }
77
83
  type Tag<Tags extends string = string> = Tagged<Tags, "Tag">;
78
84
  interface Link {
@@ -139,6 +145,104 @@ type OrOperator<Tag, Kind> = Omit<AllNever, "or"> & {
139
145
  or: NonEmptyArray<WhereOperator<Tag, Kind>>;
140
146
  };
141
147
  type WhereOperator<Tag, Kind> = TagEqual<Tag> | KindEqual<Kind> | NotOperator<Tag, Kind> | AndOperator<Tag, Kind> | OrOperator<Tag, Kind>;
148
+ interface BaseExpr {
149
+ where?: never;
150
+ element?: never;
151
+ custom?: never;
152
+ expanded?: never;
153
+ elementKind?: never;
154
+ elementTag?: never;
155
+ isEqual?: never;
156
+ isChildren?: never;
157
+ isDescendants?: never;
158
+ wildcard?: never;
159
+ source?: never;
160
+ target?: never;
161
+ inout?: never;
162
+ incoming?: never;
163
+ outgoing?: never;
164
+ customRelation?: never;
165
+ }
166
+ interface ElementRefExpr extends Omit<BaseExpr, "element" | "isChildren" | "isDescendants"> {
167
+ element: Fqn;
168
+ isChildren?: boolean;
169
+ isDescendants?: boolean;
170
+ }
171
+ interface ExpandedElementExpr extends Omit<BaseExpr, "expanded"> {
172
+ expanded: Fqn;
173
+ }
174
+ interface CustomElementExpr extends Omit<BaseExpr, "custom"> {
175
+ custom: {
176
+ expr: ElementExpression | ElementWhereExpr;
177
+ title?: string;
178
+ description?: string;
179
+ technology?: string;
180
+ notation?: string;
181
+ shape?: ElementShape;
182
+ color?: Color;
183
+ icon?: IconUrl;
184
+ border?: BorderStyle;
185
+ opacity?: number;
186
+ navigateTo?: ViewId;
187
+ };
188
+ }
189
+ interface WildcardExpr extends Omit<BaseExpr, "wildcard"> {
190
+ wildcard: true;
191
+ }
192
+ interface ElementKindExpr extends Omit<BaseExpr, "elementKind" | "isEqual"> {
193
+ elementKind: ElementKind;
194
+ isEqual: boolean;
195
+ }
196
+ interface ElementTagExpr extends Omit<BaseExpr, "elementTag" | "isEqual"> {
197
+ elementTag: Tag;
198
+ isEqual: boolean;
199
+ }
200
+ type ElementExpression = ElementRefExpr | WildcardExpr | ElementKindExpr | ElementTagExpr | ExpandedElementExpr;
201
+ interface ElementWhereExpr extends Omit<BaseExpr, "where"> {
202
+ where: {
203
+ expr: ElementExpression;
204
+ condition: WhereOperator<string, string>;
205
+ };
206
+ }
207
+ type ElementPredicateExpression = ElementExpression | ElementWhereExpr | CustomElementExpr;
208
+ interface RelationExpr extends Omit<BaseExpr, "source" | "target"> {
209
+ source: ElementExpression;
210
+ target: ElementExpression;
211
+ isBidirectional?: boolean;
212
+ }
213
+ interface InOutExpr extends Omit<BaseExpr, "inout"> {
214
+ inout: ElementExpression;
215
+ }
216
+ interface IncomingExpr extends Omit<BaseExpr, "incoming"> {
217
+ incoming: ElementExpression;
218
+ }
219
+ interface OutgoingExpr extends Omit<BaseExpr, "outgoing"> {
220
+ outgoing: ElementExpression;
221
+ }
222
+ type RelationExpression = RelationExpr | InOutExpr | IncomingExpr | OutgoingExpr;
223
+ interface RelationWhereExpr extends Omit<BaseExpr, "where"> {
224
+ where: {
225
+ expr: RelationExpression;
226
+ condition: WhereOperator<string, string>;
227
+ };
228
+ }
229
+ interface CustomRelationExpr extends Omit<BaseExpr, "customRelation"> {
230
+ customRelation: {
231
+ relation: RelationExpression | RelationWhereExpr;
232
+ title?: string;
233
+ description?: string;
234
+ technology?: string;
235
+ notation?: string;
236
+ navigateTo?: ViewId;
237
+ notes?: string;
238
+ color?: Color;
239
+ line?: RelationshipLineType;
240
+ head?: RelationshipArrowType;
241
+ tail?: RelationshipArrowType;
242
+ };
243
+ }
244
+ type RelationPredicateExpression = RelationExpression | RelationWhereExpr | CustomRelationExpr;
245
+ type Expression = ElementPredicateExpression | RelationPredicateExpression;
142
246
  type GlobalPredicateId = Tagged<string, "GlobalPredicateId">;
143
247
  type GlobalPredicates = NonEmptyArray<ViewRulePredicate>;
144
248
  type GlobalDynamicPredicates = NonEmptyArray<DynamicViewIncludeRule>;
@@ -150,12 +254,12 @@ interface ModelGlobals {
150
254
  styles: Record<GlobalStyleID, GlobalStyles>;
151
255
  }
152
256
  type ElementNotation = {
153
- kinds: ElementKind[];
257
+ kinds: string[];
154
258
  shape: ElementShape;
155
259
  color: Color;
156
260
  title: string;
157
261
  };
158
- type ViewID<Id extends string = string> = Tagged<Id, "ViewID">;
262
+ type ViewId<Id extends string = string> = Tagged<Id, "ViewID">;
159
263
  type ViewRulePredicate = {
160
264
  include: Expression[];
161
265
  exclude?: never;
@@ -192,9 +296,9 @@ interface ViewRuleGroup {
192
296
  opacity?: number;
193
297
  }
194
298
  type ViewRule = ViewRulePredicate | ViewRuleGlobalPredicateRef | ViewRuleGroup | ViewRuleStyle | ViewRuleGlobalStyle | ViewRuleAutoLayout;
195
- interface BasicView<ViewType extends "element" | "dynamic", ViewIDs extends string, Tags extends string> {
299
+ interface BasicView<ViewType extends "element" | "dynamic" | "deployment", ViewIDs extends string, Tags extends string> {
196
300
  readonly __?: ViewType;
197
- readonly id: ViewID<ViewIDs>;
301
+ readonly id: ViewId<ViewIDs>;
198
302
  readonly title: string | null;
199
303
  readonly description: string | null;
200
304
  readonly tags: NonEmptyArray<Tag<Tags>> | null;
@@ -227,7 +331,7 @@ interface ScopedElementView<ViewIDs extends string, Tags extends string> extends
227
331
  readonly viewOf: Fqn;
228
332
  }
229
333
  interface ExtendsElementView<ViewIDs extends string, Tags extends string> extends BasicElementView<ViewIDs, Tags> {
230
- readonly extends: ViewID<ViewIDs>;
334
+ readonly extends: ViewId<ViewIDs>;
231
335
  }
232
336
  type ElementView<ViewIDs extends string = string, Tags extends string = string> = ScopedElementView<ViewIDs, Tags> | ExtendsElementView<ViewIDs, Tags> | BasicElementView<ViewIDs, Tags>;
233
337
  interface DynamicViewStep {
@@ -243,7 +347,7 @@ interface DynamicViewStep {
243
347
  readonly head?: RelationshipArrowType;
244
348
  readonly tail?: RelationshipArrowType;
245
349
  readonly isBackward?: boolean;
246
- readonly navigateTo?: ViewID;
350
+ readonly navigateTo?: ViewId;
247
351
  __parallel?: never;
248
352
  }
249
353
  interface DynamicViewParallelSteps {
@@ -262,13 +366,46 @@ interface DynamicView<ViewIDs extends string = string, Tags extends string = str
262
366
  type CustomColorDefinitions = {
263
367
  [key: string]: ThemeColorValues;
264
368
  };
265
- type LikeC4View<ViewIDs extends string = string, Tags extends string = string> = ElementView<ViewIDs, Tags> | DynamicView<ViewIDs, Tags>;
369
+ type DeploymentViewRulePredicate = {
370
+ include: DeploymentExpression[];
371
+ exclude?: never;
372
+ } | {
373
+ include?: never;
374
+ exclude: DeploymentExpression[];
375
+ };
376
+ type DeploymentViewRuleStyle = {
377
+ targets: DeploymentExpression[];
378
+ notation?: string;
379
+ style: ElementStyle & {
380
+ color?: Color;
381
+ shape?: ElementShape;
382
+ icon?: IconUrl;
383
+ };
384
+ };
385
+ type DeploymentViewRule = DeploymentViewRulePredicate | ViewRuleAutoLayout | DeploymentViewRuleStyle;
386
+ interface DeploymentView<ViewIDs extends string = string, Tags extends string = string> extends BasicView<"deployment", ViewIDs, Tags> {
387
+ readonly __: "deployment";
388
+ readonly rules: DeploymentViewRule[];
389
+ }
390
+ type LikeC4View<ViewIDs extends string = string, Tags extends string = string> = ElementView<ViewIDs, Tags> | DynamicView<ViewIDs, Tags> | DeploymentView<ViewIDs, Tags>;
266
391
  type NodeId<IDs extends string = string> = Tagged<IDs, "Fqn">;
267
392
  type EdgeId = Tagged<string, "EdgeId">;
393
+ type StepEdgeIdLiteral = `step-${number}` | `step-${number}.${number}`;
394
+ type StepEdgeId = Tagged<StepEdgeIdLiteral, "EdgeId">;
268
395
  interface ComputedNode {
269
396
  id: NodeId;
270
- kind: ElementKind;
397
+ kind: string;
271
398
  parent: NodeId | null;
399
+ /**
400
+ * Reference to model element
401
+ * If 1 - node id is a reference
402
+ */
403
+ modelRef?: 1 | Fqn;
404
+ /**
405
+ * Reference to deployment element
406
+ * If 1 - node id is a reference
407
+ */
408
+ deploymentRef?: 1 | Fqn;
272
409
  title: string;
273
410
  description: string | null;
274
411
  technology: string | null;
@@ -279,16 +416,13 @@ interface ComputedNode {
279
416
  inEdges: EdgeId[];
280
417
  outEdges: EdgeId[];
281
418
  shape: ElementShape;
282
- /**
283
- * @deprecated Use `style` instead
284
- */
285
419
  color: Color;
286
420
  /**
287
421
  * @deprecated Use `style` instead
288
422
  */
289
423
  icon?: IconUrl;
290
424
  style: ElementStyle;
291
- navigateTo?: ViewID;
425
+ navigateTo?: ViewId;
292
426
  level: number;
293
427
  depth?: number;
294
428
  /**
@@ -297,6 +431,8 @@ interface ComputedNode {
297
431
  isCustomized?: boolean;
298
432
  }
299
433
  declare namespace ComputedNode {
434
+ function modelRef(node: ComputedNode): Fqn | null;
435
+ function deploymentRef(node: ComputedNode): Fqn | null;
300
436
  /**
301
437
  * Nodes group is a special kind of node, exisiting only in view
302
438
  */
@@ -310,7 +446,7 @@ interface ComputedEdge {
310
446
  label: string | null;
311
447
  description?: string;
312
448
  technology?: string;
313
- relations: RelationID[];
449
+ relations: RelationId[];
314
450
  kind?: RelationshipKind;
315
451
  notation?: string;
316
452
  notes?: string;
@@ -319,7 +455,7 @@ interface ComputedEdge {
319
455
  head?: RelationshipArrowType;
320
456
  tail?: RelationshipArrowType;
321
457
  tags?: NonEmptyArray<Tag>;
322
- navigateTo?: ViewID;
458
+ navigateTo?: ViewId;
323
459
  /**
324
460
  * If this edge is derived from custom relationship predicate
325
461
  */
@@ -328,7 +464,7 @@ interface ComputedEdge {
328
464
  * For layouting purposes
329
465
  * @default 'forward'
330
466
  */
331
- dir?: "forward" | "back";
467
+ dir?: "forward" | "back" | "both";
332
468
  }
333
469
  interface ViewWithHash {
334
470
  /**
@@ -348,7 +484,7 @@ interface ViewAutoLayout {
348
484
  nodeSep?: number;
349
485
  }
350
486
  interface ComputedElementView<ViewIDs extends string = string, Tags extends string = string> extends Omit<ElementView<ViewIDs, Tags>, "rules" | "docUri">, ViewWithHash, ViewWithNotation {
351
- readonly extends?: ViewID<ViewIDs>;
487
+ readonly extends?: ViewId<ViewIDs>;
352
488
  readonly autoLayout: ViewAutoLayout;
353
489
  readonly nodes: ComputedNode[];
354
490
  readonly edges: ComputedEdge[];
@@ -363,7 +499,19 @@ interface ComputedDynamicView<ViewIDs extends string = string, Tags extends stri
363
499
  rules?: never;
364
500
  docUri?: never;
365
501
  }
366
- type ComputedView<ViewIDs extends string = string, Tags extends string = string> = ComputedElementView<ViewIDs, Tags> | ComputedDynamicView<ViewIDs, Tags>;
502
+ interface ComputedDeploymentView<ViewIDs extends string = string, Tags extends string = string> extends Omit<DeploymentView<ViewIDs, Tags>, "rules" | "docUri">, ViewWithHash, ViewWithNotation {
503
+ readonly autoLayout: ViewAutoLayout;
504
+ readonly nodes: ComputedNode[];
505
+ readonly edges: ComputedEdge[];
506
+ rules?: never;
507
+ docUri?: never;
508
+ }
509
+ type ComputedView<ViewIDs extends string = string, Tags extends string = string> = ComputedElementView<ViewIDs, Tags> | ComputedDynamicView<ViewIDs, Tags> | ComputedDeploymentView<ViewIDs, Tags>;
510
+ declare namespace ComputedView {
511
+ function isDeployment(view: ComputedView): view is ComputedDeploymentView;
512
+ function isDynamic(view: ComputedView): view is ComputedDynamicView;
513
+ function isElement(view: ComputedView): view is ComputedElementView;
514
+ }
367
515
  type BBox = {
368
516
  x: number;
369
517
  y: number;
@@ -377,6 +525,8 @@ interface DiagramNode extends ComputedNode {
377
525
  labelBBox: BBox;
378
526
  }
379
527
  declare namespace DiagramNode {
528
+ function modelRef(node: DiagramNode): Fqn | null;
529
+ function deploymentRef(node: DiagramNode): Fqn | null;
380
530
  /**
381
531
  * Nodes group is a special kind of node, exisiting only in view
382
532
  */
@@ -388,7 +538,7 @@ interface DiagramEdge extends ComputedEdge {
388
538
  labelBBox?: BBox | null;
389
539
  dotpos?: string;
390
540
  }
391
- interface DiagramView<ViewIDs extends string = string, Tags extends string = string> extends Omit<ComputedView<ViewIDs, Tags>, "nodes" | "edges" | "manualLayout"> {
541
+ export interface DiagramView<ViewIDs extends string = string, Tags extends string = string> extends Omit<ComputedView<ViewIDs, Tags>, "nodes" | "edges" | "manualLayout"> {
392
542
  readonly nodes: DiagramNode[];
393
543
  readonly edges: DiagramEdge[];
394
544
  readonly bounds: BBox;
@@ -420,12 +570,12 @@ type ViewManualLayout = {
420
570
  labelBBox?: BBox;
421
571
  }>;
422
572
  };
423
- type RelationID = Tagged<string, "RelationID">;
573
+ type RelationId = Tagged<string, "RelationID">;
424
574
  type RelationshipKind<Kinds extends string = string> = Tagged<Kinds, "RelationshipKind">;
425
575
  type RelationshipLineType = "dashed" | "solid" | "dotted";
426
576
  type RelationshipArrowType = "none" | "normal" | "onormal" | "dot" | "odot" | "diamond" | "odiamond" | "crow" | "open" | "vee";
427
577
  interface Relation {
428
- readonly id: RelationID;
578
+ readonly id: RelationId;
429
579
  readonly source: Fqn;
430
580
  readonly target: Fqn;
431
581
  readonly title: string;
@@ -438,7 +588,7 @@ interface Relation {
438
588
  readonly head?: RelationshipArrowType;
439
589
  readonly tail?: RelationshipArrowType;
440
590
  readonly links?: NonEmptyArray<Link>;
441
- readonly navigateTo?: ViewID;
591
+ readonly navigateTo?: ViewId;
442
592
  readonly metadata?: {
443
593
  [key: string]: string;
444
594
  };
@@ -451,120 +601,171 @@ interface RelationshipKindSpecification {
451
601
  readonly head?: RelationshipArrowType;
452
602
  readonly tail?: RelationshipArrowType;
453
603
  }
454
- interface BaseExpr {
455
- where?: never;
456
- element?: never;
457
- custom?: never;
458
- expanded?: never;
459
- elementKind?: never;
460
- elementTag?: never;
461
- isEqual?: never;
462
- isDescedants?: never;
463
- wildcard?: never;
464
- source?: never;
465
- target?: never;
466
- inout?: never;
467
- incoming?: never;
468
- outgoing?: never;
469
- customRelation?: never;
470
- }
471
- interface ElementRefExpr extends Omit<BaseExpr, "element" | "isDescedants"> {
472
- element: Fqn;
473
- isDescedants?: boolean;
474
- }
475
- interface ExpandedElementExpr extends Omit<BaseExpr, "expanded"> {
476
- expanded: Fqn;
604
+ type DeploymentNodeKind<Kinds extends string = string> = Tagged<Kinds, "DeploymentNodeKind">;
605
+ type PhysicalElementStyle = ElementStyle & {
606
+ readonly icon?: IconUrl;
607
+ readonly shape?: ElementShape;
608
+ readonly color?: Color;
609
+ };
610
+ interface DeploymentNodeKindSpecification {
611
+ readonly technology?: string;
612
+ readonly notation?: string;
613
+ readonly style: PhysicalElementStyle;
477
614
  }
478
- interface CustomElementExpr extends Omit<BaseExpr, "custom"> {
479
- custom: {
480
- expr: ElementExpression | ElementWhereExpr;
481
- title?: string;
482
- description?: string;
483
- technology?: string;
484
- notation?: string;
485
- shape?: ElementShape;
486
- color?: Color;
487
- icon?: IconUrl;
488
- border?: BorderStyle;
489
- opacity?: number;
490
- navigateTo?: ViewID;
491
- };
615
+ interface DeploymentNode {
616
+ readonly id: Fqn;
617
+ readonly kind: DeploymentNodeKind;
618
+ readonly title: string;
619
+ readonly description?: string | null;
620
+ readonly technology?: string | null;
621
+ readonly tags?: NonEmptyArray<Tag> | null;
622
+ readonly links?: NonEmptyArray<Link> | null;
623
+ readonly style?: PhysicalElementStyle;
624
+ readonly notation?: string;
625
+ readonly metadata?: Record<string, string>;
492
626
  }
493
- interface WildcardExpr extends Omit<BaseExpr, "wildcard"> {
494
- wildcard: true;
627
+ interface DeployedInstance {
628
+ /**
629
+ * Format: `<DeploymentNode Fqn>.<Instance Id>`
630
+ * i.e parent fqn is deployment target
631
+ */
632
+ readonly id: Fqn;
633
+ readonly element: Fqn;
634
+ readonly title?: string;
635
+ readonly description?: string | null;
636
+ readonly technology?: string | null;
637
+ readonly tags?: NonEmptyArray<Tag> | null;
638
+ readonly links?: NonEmptyArray<Link> | null;
639
+ readonly style?: PhysicalElementStyle;
640
+ readonly notation?: string;
641
+ readonly metadata?: Record<string, string>;
495
642
  }
496
- interface ElementKindExpr extends Omit<BaseExpr, "elementKind" | "isEqual"> {
497
- elementKind: ElementKind;
498
- isEqual: boolean;
643
+ type DeploymentElement = Simplify<MergeExclusive<DeploymentNode, DeployedInstance>>;
644
+ declare namespace DeploymentElement {
645
+ const isDeploymentNode: (el: DeploymentElement) => el is DeploymentNode;
646
+ const isInstance: (el: DeploymentElement) => el is DeployedInstance;
499
647
  }
500
- interface ElementTagExpr extends Omit<BaseExpr, "elementTag" | "isEqual"> {
501
- elementTag: Tag;
502
- isEqual: boolean;
648
+ interface DeploymentRef {
649
+ readonly id: Fqn;
650
+ readonly element?: Fqn;
503
651
  }
504
- type ElementExpression = ElementRefExpr | WildcardExpr | ElementKindExpr | ElementTagExpr | ExpandedElementExpr;
505
- interface ElementWhereExpr extends Omit<BaseExpr, "where"> {
506
- where: {
507
- expr: ElementExpression;
508
- condition: WhereOperator<string, string>;
652
+ interface DeploymentRelation {
653
+ readonly id: RelationId;
654
+ readonly source: DeploymentRef;
655
+ readonly target: DeploymentRef;
656
+ readonly title?: string;
657
+ readonly tags?: NonEmptyArray<Tag> | null;
658
+ readonly description?: string;
659
+ readonly technology?: string;
660
+ readonly kind?: RelationshipKind;
661
+ readonly color?: Color;
662
+ readonly line?: RelationshipLineType;
663
+ readonly head?: RelationshipArrowType;
664
+ readonly tail?: RelationshipArrowType;
665
+ readonly links?: NonEmptyArray<Link> | null;
666
+ readonly navigateTo?: ViewId;
667
+ readonly metadata?: {
668
+ [key: string]: string;
509
669
  };
510
670
  }
511
- type ElementPredicateExpression = ElementExpression | ElementWhereExpr | CustomElementExpr;
512
- interface RelationExpr extends Omit<BaseExpr, "source" | "target"> {
513
- source: ElementExpression;
514
- target: ElementExpression;
515
- isBidirectional?: boolean;
516
- }
517
- interface InOutExpr extends Omit<BaseExpr, "inout"> {
518
- inout: ElementExpression;
519
- }
520
- interface IncomingExpr extends Omit<BaseExpr, "incoming"> {
521
- incoming: ElementExpression;
522
- }
523
- interface OutgoingExpr extends Omit<BaseExpr, "outgoing"> {
524
- outgoing: ElementExpression;
525
- }
526
- type RelationExpression = RelationExpr | InOutExpr | IncomingExpr | OutgoingExpr;
527
- interface RelationWhereExpr extends Omit<BaseExpr, "where"> {
528
- where: {
529
- expr: RelationExpression;
530
- condition: WhereOperator<string, string>;
671
+ type AllNever$1<Expressions> = UnionToIntersection<{
672
+ [Name in keyof Expressions]: {
673
+ -readonly [Key in keyof Expressions[Name]]?: never;
674
+ };
675
+ }[keyof Expressions]>;
676
+ type ExclusiveUnion<Expressions> = Expressions extends object ? {
677
+ [Name in keyof Expressions]: Simplify<Omit<AllNever$1<Expressions>, keyof Expressions[Name]> & Expressions[Name]>;
678
+ }[keyof Expressions] : Expressions;
679
+ declare namespace DeploymentRelationExpression {
680
+ type Direct = {
681
+ source: DeploymentElementExpression;
682
+ target: DeploymentElementExpression;
683
+ isBidirectional?: boolean;
684
+ };
685
+ const isDirect: (expr: DeploymentExpression) => expr is Direct;
686
+ type Incoming = {
687
+ incoming: DeploymentElementExpression;
531
688
  };
689
+ const isIncoming: (expr: DeploymentExpression) => expr is Incoming;
690
+ type Outgoing = {
691
+ outgoing: DeploymentElementExpression;
692
+ };
693
+ const isOutgoing: (expr: DeploymentExpression) => expr is Outgoing;
694
+ type InOut = {
695
+ inout: DeploymentElementExpression;
696
+ };
697
+ const isInOut: (expr: DeploymentExpression) => expr is InOut;
532
698
  }
533
- interface CustomRelationExpr extends Omit<BaseExpr, "customRelation"> {
534
- customRelation: {
535
- relation: RelationExpression | RelationWhereExpr;
536
- title?: string;
537
- description?: string;
538
- technology?: string;
539
- notation?: string;
540
- navigateTo?: ViewID;
541
- notes?: string;
542
- color?: Color;
543
- line?: RelationshipLineType;
544
- head?: RelationshipArrowType;
545
- tail?: RelationshipArrowType;
699
+ type DeploymentRelationExpression = ExclusiveUnion<{
700
+ Direct: DeploymentRelationExpression.Direct;
701
+ Incoming: DeploymentRelationExpression.Incoming;
702
+ Outgoing: DeploymentRelationExpression.Outgoing;
703
+ InOut: DeploymentRelationExpression.InOut;
704
+ }>;
705
+ declare namespace DeploymentElementExpression {
706
+ type Ref = {
707
+ ref: DeploymentRef;
708
+ selector?: "children" | "expanded" | "descendants";
709
+ };
710
+ const isRef: (expr: DeploymentExpression) => expr is Ref;
711
+ type Wildcard = {
712
+ wildcard: true;
546
713
  };
714
+ const isWildcard: (expr: DeploymentExpression) => expr is Wildcard;
547
715
  }
548
- type RelationPredicateExpression = RelationExpression | RelationWhereExpr | CustomRelationExpr;
549
- type Expression = ElementPredicateExpression | RelationPredicateExpression;
550
- interface ParsedLikeC4Model<ElementKinds extends string = string, RelationKinds extends string = string, Tags extends string = string, Fqns extends string = string, Views extends string = string> {
716
+ type DeploymentElementExpression = ExclusiveUnion<{
717
+ DeploymentRef: DeploymentElementExpression.Ref;
718
+ Wildcard: DeploymentElementExpression.Wildcard;
719
+ }>;
720
+ type DeploymentExpression = ExclusiveUnion<{
721
+ Element: DeploymentElementExpression;
722
+ Relation: DeploymentRelationExpression;
723
+ }>;
724
+ declare namespace DeploymentExpression {
725
+ type Element = DeploymentElementExpression;
726
+ type Relation = DeploymentRelationExpression;
727
+ const isElement: (expr: DeploymentExpression) => expr is DeploymentElementExpression;
728
+ const isRelation: (expr: DeploymentExpression) => expr is DeploymentRelationExpression;
729
+ }
730
+ 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> {
551
731
  specification: {
552
732
  tags: Tag<Tags>[];
553
733
  elements: Record<ElementKinds, ElementKindSpecification>;
734
+ deployments: Record<DeploymentNodeKind, DeploymentNodeKindSpecification>;
554
735
  relationships: Record<RelationKinds, RelationshipKindSpecification>;
555
736
  };
556
737
  elements: Record<Fqns, TypedElement<Fqns, ElementKinds, Tags>>;
557
- relations: Record<RelationID, Relation>;
738
+ relations: Record<RelationId, Relation>;
558
739
  globals: ModelGlobals;
559
740
  views: Record<Views, LikeC4View<Views, Tags>>;
741
+ /**
742
+ * Deployment Model.
743
+ */
744
+ deployments: {
745
+ elements: Record<DeploymentFqns, DeploymentElement>;
746
+ relations: Record<RelationId, DeploymentRelation>;
747
+ };
560
748
  }
561
- interface ComputedLikeC4Model extends Omit<ParsedLikeC4Model, "views"> {
562
- __?: never;
563
- views: Record<ViewID, ComputedView>;
749
+ type ParsedLikeC4ModelDump = {
750
+ elements: {
751
+ [kind: string]: object;
752
+ };
753
+ deployments: {
754
+ elements: {
755
+ [kind: string]: object;
756
+ };
757
+ };
758
+ views: {
759
+ [kind: string]: object;
760
+ };
761
+ };
762
+ 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"> {
763
+ __?: T;
764
+ views: Record<Views, ComputedView | DiagramView>;
564
765
  }
565
- interface LayoutedLikeC4Model extends Omit<ParsedLikeC4Model, "views"> {
766
+ 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"> {
566
767
  __: "layouted";
567
- views: Record<ViewID, DiagramView>;
768
+ views: Record<Views, DiagramView<Views, Tags>>;
568
769
  }
569
770
  declare namespace ViewChange {
570
771
  interface ChangeElementStyle {
@@ -591,374 +792,631 @@ declare namespace ViewChange {
591
792
  }
592
793
  }
593
794
  type ViewChange = ViewChange.ChangeElementStyle | ViewChange.SaveManualLayout | ViewChange.ChangeAutoLayout;
594
- type Fqn$1 = LiteralUnion<Fqn, string>;
595
- type RelationID$1 = LiteralUnion<RelationID, string>;
596
- type ViewID$1 = LiteralUnion<ViewID, string>;
597
- type EdgeId$1 = LiteralUnion<EdgeId, string>;
598
795
  type IncomingFilter = "all" | "direct" | "to-descendants";
599
796
  type OutgoingFilter = "all" | "direct" | "from-descendants";
600
- type ElementOrFqn = Fqn$1 | {
601
- id: Fqn$1;
797
+ type IteratorLike<T> = IteratorObject<T, BuiltinIteratorReturn>;
798
+ type WithId<Id> = {
799
+ id: Id;
800
+ };
801
+ type WithViews<Id extends string, ViewType> = {
802
+ views: Record<Id, ViewType>;
602
803
  };
603
- declare class LikeC4ViewModel {
604
- readonly view: ComputedView;
605
- readonly model: LikeC4Model<LikeC4ViewModel>;
606
- private readonly _rootElements;
607
- private readonly _elements;
608
- private readonly _connections;
609
- constructor(view: ComputedView, model: LikeC4Model<LikeC4ViewModel>);
610
- get id(): ViewID<string>;
804
+ interface Aux<Element extends string, Deployment extends string, Views extends string, ViewType> {
805
+ Fqn: IsLiteral<Element> extends true ? Fqn<Element> : Fqn;
806
+ Element: Element;
807
+ ElementOrFqn: Element | WithId<this["Fqn"]>;
808
+ DeploymentFqn: IsLiteral<Deployment> extends true ? Fqn<Deployment> : Fqn;
809
+ Deployment: Deployment;
810
+ DeploymentOrFqn: Deployment | WithId<this["DeploymentFqn"]>;
811
+ ViewId: IsLiteral<Views> extends true ? ViewId<Views> : ViewId;
812
+ ViewIdLiteral: Views;
813
+ ViewType: ViewType;
814
+ RelationId: RelationId;
815
+ NodeId: NodeId;
816
+ NodeIdLiteral: string;
817
+ EdgeId: EdgeId;
818
+ EdgeIdLiteral: string;
819
+ NodeOrId: LiteralUnion<this["NodeIdLiteral"], string> | WithId<this["NodeId"]>;
820
+ EdgeOrId: LiteralUnion<this["EdgeIdLiteral"], string> | WithId<this["EdgeId"]>;
821
+ Model: Simplify<Omit<AnyLikeC4Model, "views"> & WithViews<this["ViewId"], ViewType>>;
822
+ }
823
+ type AnyAux = Aux<string, string, string, any>;
824
+ declare namespace Aux {
825
+ type FromModel<M> = M extends AnyLikeC4Model ? Aux<KeysOf<M["elements"]>, KeysOf<M["deployments"]["elements"]>, KeysOf<M["views"]>, M extends LayoutedLikeC4Model ? DiagramView<ViewId<KeysOf<M["views"]>>, string> : ComputedView<ViewId<KeysOf<M["views"]>>, string>> : never;
826
+ type FromDump<M> = M extends ParsedLikeC4ModelDump ? Aux<KeysOf<M["elements"]>, KeysOf<M["deployments"]["elements"]>, KeysOf<M["views"]>, DiagramView<ViewId<KeysOf<M["views"]>>, string>> : never;
827
+ }
828
+ type RelationshipsIterator<M extends AnyAux> = IteratorLike<RelationshipModel<M>>;
829
+ declare class RelationshipModel<M extends AnyAux> {
830
+ readonly model: LikeC4Model<M>;
831
+ readonly $relationship: Relation;
832
+ readonly source: ElementModel<M>;
833
+ readonly target: ElementModel<M>;
834
+ /**
835
+ * Common ancestor of the source and target elements.
836
+ * Represents the boundary of the Relation.
837
+ */
838
+ readonly boundary: ElementModel<M> | null;
839
+ constructor(model: LikeC4Model<M>, $relationship: Relation);
840
+ get id(): M["RelationId"];
841
+ get expression(): string;
842
+ get title(): string | null;
843
+ get technology(): string | null;
844
+ get description(): string | null;
845
+ get navigateTo(): LikeC4ViewModel<M> | null;
846
+ get tags(): ReadonlyArray<Tag>;
847
+ get links(): ReadonlyArray<Link>;
848
+ /**
849
+ * Iterate over all views that include this relationship.
850
+ */
851
+ views(): ViewsIterator<M>;
852
+ }
853
+ type ElementsIterator<M extends AnyAux> = IteratorLike<ElementModel<M>>;
854
+ declare class ElementModel<M extends AnyAux> {
855
+ readonly model: LikeC4Model<M>;
856
+ readonly $element: Element$1;
857
+ constructor(model: LikeC4Model<M>, $element: Element$1);
858
+ get id(): M["Fqn"];
859
+ get kind(): ElementKind;
860
+ get shape(): ElementShape;
861
+ get color(): ThemeColor;
862
+ get tags(): ReadonlyArray<Tag>;
611
863
  get title(): string;
612
- get viewOf(): LikeC4Model.ElementModel<LikeC4ViewModel>;
613
- get tags(): Tag[];
614
- roots(): ReadonlyArray<LikeC4ViewModel.Element>;
615
- elements(): ReadonlyArray<LikeC4ViewModel.Element>;
616
- element(id: Fqn$1): LikeC4ViewModel.Element;
617
- hasElement(id: Fqn$1): boolean;
618
- connections(): ReadonlyArray<LikeC4ViewModel.Connection>;
619
- connection(id: EdgeId$1): LikeC4ViewModel.Connection;
620
- findConnections(source: ElementOrFqn, target: ElementOrFqn, direction?: "both" | "direct"): ReadonlyArray<LikeC4ViewModel.Connection>;
621
- parent(element: ElementOrFqn): LikeC4ViewModel.Element | null;
622
- children(element: ElementOrFqn): ReadonlyArray<LikeC4ViewModel.Element>;
623
- siblings(element: ElementOrFqn): ReadonlyArray<LikeC4ViewModel.Element>;
864
+ get description(): string | null;
865
+ get technology(): string | null;
866
+ get links(): ReadonlyArray<Link>;
867
+ get parent(): ElementModel<M> | null;
868
+ get defaultView(): LikeC4ViewModel<M> | null;
624
869
  /**
625
870
  * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
626
871
  * (from closest to root)
627
872
  */
628
- ancestors(element: ElementOrFqn): ReadonlyArray<LikeC4ViewModel.Element>;
629
- descendants(element: ElementOrFqn): ReadonlyArray<LikeC4ViewModel.Element>;
630
- incoming(element: ElementOrFqn, filter?: IncomingFilter): ReadonlyArray<LikeC4ViewModel.Connection>;
631
- incomers(element: ElementOrFqn, filter?: IncomingFilter): ReadonlyArray<LikeC4ViewModel.Element>;
873
+ ancestors(): ElementsIterator<M>;
632
874
  /**
633
- * Outgoing relationships from the element and its descendants
875
+ * Returns the common ancestor of this element and another element.
876
+ */
877
+ commonAncestor(another: ElementModel<M>): ElementModel<M> | null;
878
+ children(): ReadonlySet<ElementModel<M>>;
879
+ /**
880
+ * Get all descendant elements (i.e. children, children’s children, etc.)
881
+ */
882
+ descendants(): ElementsIterator<M>;
883
+ /**
884
+ * Get all sibling (i.e. same parent)
634
885
  */
635
- outgoing(element: ElementOrFqn, filter?: OutgoingFilter): ReadonlyArray<LikeC4ViewModel.Connection>;
636
- outgoers(element: ElementOrFqn, filter?: OutgoingFilter): ReadonlyArray<LikeC4ViewModel.Element>;
637
- }
638
- declare namespace LikeC4ViewModel {
639
- /**
640
- * Represents an element in the view. (Diagram node)
641
- * All methods are view-scoped, i.e. `children` returns only children of the element in the view.
642
- */
643
- class Element {
644
- readonly node: ComputedNode;
645
- private readonly viewmodel;
646
- constructor(node: ComputedNode, viewmodel: LikeC4ViewModel);
647
- get id(): NodeId<string>;
648
- get title(): string;
649
- get kind(): ElementKind;
650
- get isRoot(): boolean;
651
- get hasNested(): boolean;
652
- get shape(): ElementShape;
653
- get color(): Color;
654
- get tags(): Tag[];
655
- model(): LikeC4Model.ElementModel<LikeC4ViewModel>;
656
- parent(): LikeC4ViewModel.Element | null;
657
- metadata(key: string): string | undefined;
658
- metadata(key: string, defaultValue: string): string;
659
- hasMetadata(key: string): boolean;
660
- ancestors(): ReadonlyArray<LikeC4ViewModel.Element>;
661
- siblings(): ReadonlyArray<LikeC4ViewModel.Element>;
662
- descendants(): ReadonlyArray<LikeC4ViewModel.Element>;
663
- children(): ReadonlyArray<LikeC4ViewModel.Element>;
664
- incoming(filter?: "all" | "direct" | "to-descendants"): ReadonlyArray<LikeC4ViewModel.Connection>;
665
- incomers(filter?: "all" | "direct" | "to-descendants"): ReadonlyArray<LikeC4ViewModel.Element>;
666
- outgoing(filter?: OutgoingFilter): ReadonlyArray<LikeC4ViewModel.Connection>;
667
- outgoers(filter?: OutgoingFilter): ReadonlyArray<LikeC4ViewModel.Element>;
668
- connectionsTo(target: Fqn$1 | LikeC4ViewModel.Element): ReadonlyArray<LikeC4ViewModel.Connection>;
886
+ siblings(): ElementsIterator<M>;
887
+ /**
888
+ * Resolve siblings of the element and its ancestors
889
+ * (from closest to root)
890
+ */
891
+ ascendingSiblings(): ElementsIterator<M>;
892
+ incoming(filter?: IncomingFilter): RelationshipsIterator<M>;
893
+ incomers(filter?: IncomingFilter): ElementsIterator<M>;
894
+ outgoing(filter?: OutgoingFilter): RelationshipsIterator<M>;
895
+ outgoers(filter?: OutgoingFilter): ElementsIterator<M>;
896
+ protected cachedOutgoing: Set<RelationshipModel<M>> | null;
897
+ protected cachedIncoming: Set<RelationshipModel<M>> | null;
898
+ get allOutgoing(): ReadonlySet<RelationshipModel<M>>;
899
+ get allIncoming(): ReadonlySet<RelationshipModel<M>>;
900
+ /**
901
+ * Iterate over all views that include this element.
902
+ */
903
+ views(): ViewsIterator<M>;
904
+ /**
905
+ * Iterate over all views that scope this element.
906
+ * It is possible that element is not included in the view.
907
+ */
908
+ scopedViews(): ViewsIterator<M>;
909
+ /**
910
+ * @returns true if the element is deployed
911
+ */
912
+ isDeployed(): boolean;
913
+ deployments(): DeployedInstancesIterator<M>;
914
+ }
915
+ type NodesIterator<M extends AnyAux, V extends ComputedView | DiagramView> = IteratorLike<NodeModel<M, V>>;
916
+ declare namespace NodeModel {
917
+ interface WithParent<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
918
+ parent: NodeModel<M, V>;
919
+ }
920
+ interface WithElement<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
921
+ kind: ElementKind;
922
+ element: ElementModel<M>;
923
+ }
924
+ interface WithDeploymentElement<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
925
+ kind: DeploymentNodeKind;
926
+ deployment: DeploymentElementModel<M>;
927
+ }
928
+ interface WithDeployedInstance<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
929
+ kind: "instance";
930
+ element: ElementModel<M>;
931
+ deployment: DeployedInstanceModel<M>;
669
932
  }
933
+ interface IsGroup<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
934
+ kind: typeof ElementKind.Group;
935
+ element: null;
936
+ deployment: null;
937
+ }
938
+ }
939
+ declare class NodeModel<M extends AnyAux, V extends ComputedView | DiagramView = M["ViewType"]> {
940
+ readonly $view: LikeC4ViewModel<M, V>;
941
+ readonly $node: V["nodes"][number];
942
+ constructor($view: LikeC4ViewModel<M, V>, $node: V["nodes"][number]);
943
+ get id(): NodeId;
944
+ get title(): string;
945
+ get kind(): ElementKind | DeploymentNodeKind | typeof ElementKind.Group | "instance";
946
+ get description(): string | null;
947
+ get technology(): string | null;
948
+ get parent(): NodeModel<M, V> | null;
949
+ get element(): ElementModel<M> | null;
950
+ get deployment(): DeploymentElementModel<M> | null;
951
+ get shape(): ElementShape;
952
+ get color(): Color;
953
+ get tags(): ReadonlyArray<Tag>;
954
+ get links(): ReadonlyArray<Link>;
955
+ get navigateTo(): LikeC4ViewModel<M> | null;
670
956
  /**
671
- * Represents a connection between two elements.
672
- * May be source from multiple model relationships.
673
- */
674
- class Connection {
675
- readonly edge: ComputedEdge;
676
- private readonly viewmodel;
677
- constructor(edge: ComputedEdge, viewmodel: LikeC4ViewModel);
678
- get id(): EdgeId;
679
- get source(): LikeC4ViewModel.Element;
680
- get target(): LikeC4ViewModel.Element;
681
- get tags(): Tag[];
682
- /**
683
- * Model relationships
684
- */
685
- relationships(): ReadonlyArray<LikeC4Model.Relationship<LikeC4ViewModel>>;
957
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
958
+ * (from closest to root)
959
+ */
960
+ ancestors(): NodesIterator<M, V>;
961
+ children(): NodesIterator<M, V>;
962
+ sublings(): NodesIterator<M, V>;
963
+ incoming(filter?: IncomingFilter): EdgesIterator<M, V>;
964
+ incomers(filter?: IncomingFilter): NodesIterator<M, V>;
965
+ outgoing(filter?: OutgoingFilter): EdgesIterator<M, V>;
966
+ outgoers(filter?: OutgoingFilter): NodesIterator<M, V>;
967
+ isDiagramNode(): this is NodeModel<M, DiagramView>;
968
+ hasChildren(): boolean;
969
+ hasParent(): this is NodeModel.WithParent<M, V>;
970
+ /**
971
+ * Check if this node references to logical model element.
972
+ */
973
+ hasElement(): this is NodeModel.WithElement<M, V>;
974
+ /**
975
+ * Check if this node references to deployment element (Node or Instance).
976
+ */
977
+ hasDeployment(): this is NodeModel.WithDeploymentElement<M, V>;
978
+ /**
979
+ * Check if this node references to deployed instance
980
+ * Deployed instance always references to element and deployment element.
981
+ */
982
+ hasDeployedInstance(): this is NodeModel.WithDeployedInstance<M, V>;
983
+ isGroup(): this is NodeModel.IsGroup<M, V>;
984
+ }
985
+ type EdgesIterator<M extends AnyAux, V extends ComputedView | DiagramView> = IteratorLike<EdgeModel<M, V>>;
986
+ declare class EdgeModel<M extends AnyAux, V extends ComputedView | DiagramView = M["ViewType"]> {
987
+ readonly view: LikeC4ViewModel<M, V>;
988
+ readonly $edge: V["edges"][number];
989
+ readonly source: NodeModel<M, V>;
990
+ readonly target: NodeModel<M, V>;
991
+ constructor(view: LikeC4ViewModel<M, V>, $edge: V["edges"][number], source: NodeModel<M, V>, target: NodeModel<M, V>);
992
+ get id(): M["EdgeId"];
993
+ get parent(): NodeModel<M, V> | null;
994
+ get label(): string | null;
995
+ get description(): string | null;
996
+ get technology(): string | null;
997
+ hasParent(): this is EdgeModel$1.WithParent<M, V>;
998
+ get tags(): ReadonlyArray<Tag>;
999
+ get stepNumber(): number | null;
1000
+ get navigateTo(): LikeC4ViewModel<M> | null;
1001
+ isStep(): this is EdgeModel$1.StepEdge<M, ComputedDynamicView>;
1002
+ relationships(type: "model"): IteratorLike<RelationshipModel<M>>;
1003
+ relationships(type: "deployment"): IteratorLike<DeploymentRelationModel<M>>;
1004
+ relationships(type?: "model" | "deployment"): IteratorLike<LikeC4Model.AnyRelation<M>>;
1005
+ includesRelation(rel: M["RelationId"]): boolean;
1006
+ }
1007
+ declare namespace EdgeModel$1 {
1008
+ interface StepEdge<M extends AnyAux, V extends ComputedView | DiagramView> extends EdgeModel<M, V> {
1009
+ id: StepEdgeId;
1010
+ stepNumber: number;
1011
+ }
1012
+ interface WithParent<M extends AnyAux, V extends ComputedView | DiagramView> extends EdgeModel<M, V> {
1013
+ parent: NodeModel<M, V>;
686
1014
  }
687
1015
  }
688
- type PickBySource<Source> = Source extends LikeC4Model.Layouted.SourceModel ? LikeC4Model.Layouted : Source extends LikeC4Model.Computed.SourceModel ? LikeC4Model.Computed : never;
689
- export declare class LikeC4Model<M extends LikeC4Model.ViewModel = LikeC4Model.ViewModel> {
690
- readonly type: LikeC4Model.ModelType<M>;
691
- readonly sourcemodel: LikeC4Model.SourceModel<M>;
692
- private _elements;
693
- private _parents;
694
- private _children;
695
- private _rootElements;
696
- private _relations;
697
- private _incoming;
698
- private _outgoing;
699
- private _internal;
700
- private _cacheAscendingSiblings;
701
- private _views;
702
- constructor(type: LikeC4Model.ModelType<M>, sourcemodel: LikeC4Model.SourceModel<M>, elements: Element$1[], relations: Relation[], views: LikeC4Model.SourceModel<M>["views"], ViewModelClass: Class<M>);
1016
+ type ViewsIterator<M extends AnyAux> = IteratorLike<LikeC4ViewModel<M>>;
1017
+ declare class LikeC4ViewModel<M extends AnyAux, V extends ComputedView | DiagramView = M["ViewType"]> {
1018
+ #private;
1019
+ readonly $model: LikeC4Model<M>;
1020
+ readonly $view: V;
1021
+ constructor($model: LikeC4Model<M>, $view: V);
1022
+ get __(): NonNullable<M["ViewType"]["__"]>;
1023
+ get id(): M["ViewId"];
1024
+ get title(): string | null;
1025
+ get tags(): ReadonlyArray<Tag>;
1026
+ get links(): ReadonlyArray<Link>;
1027
+ get viewOf(): ElementModel<M> | null;
1028
+ /**
1029
+ * All tags from nodes and edges.
1030
+ */
1031
+ get includedTags(): ReadonlyArray<Tag>;
1032
+ roots(): NodesIterator<M, V>;
1033
+ /**
1034
+ * Iterate over all nodes that have children.
1035
+ */
1036
+ compounds(): NodesIterator<M, V>;
1037
+ /**
1038
+ * Get node by id.
1039
+ * @throws Error if node is not found.
1040
+ */
1041
+ node(node: M["NodeOrId"]): NodeModel<M, V>;
1042
+ /**
1043
+ * Find node by id.
1044
+ */
1045
+ findNode(node: M["NodeOrId"]): NodeModel<M, V> | null;
1046
+ /**
1047
+ * Iterate over all nodes.
1048
+ */
1049
+ nodes(): NodesIterator<M, V>;
1050
+ /**
1051
+ * Find edge by id.
1052
+ * @param edge Edge or id
1053
+ * @returns EdgeModel
1054
+ */
1055
+ edge(edge: M["EdgeOrId"]): EdgeModel<M, V>;
1056
+ findEdge(edge: M["EdgeOrId"]): EdgeModel<M, V> | null;
1057
+ /**
1058
+ * Iterate over all edges.
1059
+ */
1060
+ edges(): EdgesIterator<M, V>;
1061
+ /**
1062
+ * Iterate over all edges.
1063
+ */
1064
+ edgesWithRelation(relation: M["RelationId"]): EdgesIterator<M, V>;
1065
+ /**
1066
+ * Nodes that have references to elements from logical model.
1067
+ */
1068
+ elements(): IteratorLike<NodeModel.WithElement<M, V>>;
1069
+ includesElement(elementId: M["Element"]): boolean;
1070
+ includesDeployment(deploymentId: M["Deployment"]): boolean;
1071
+ includesRelation(relationId: M["RelationId"]): boolean;
1072
+ /**
1073
+ * Below are type guards.
1074
+ */
1075
+ isComputed(): this is LikeC4ViewModel<M, ComputedView>;
1076
+ isDiagram(): this is LikeC4ViewModel<M, DiagramView>;
1077
+ isElementView(): this is LikeC4ViewModel<M, ComputedElementView>;
1078
+ isDeploymentView(): this is LikeC4ViewModel<M, ComputedDeploymentView>;
1079
+ isDynamicView(): this is LikeC4ViewModel<M, ComputedDynamicView>;
1080
+ }
1081
+ declare class LikeC4DeploymentModel<M extends AnyAux = AnyAux> {
1082
+ #private;
1083
+ readonly $model: LikeC4Model<M>;
1084
+ readonly $deployments: AnyLikeC4Model["deployments"];
1085
+ constructor($model: LikeC4Model<M>, $deployments: AnyLikeC4Model["deployments"]);
1086
+ element(el: M["DeploymentOrFqn"]): DeploymentElementModel<M>;
1087
+ findElement(el: M["Deployment"]): DeploymentElementModel<M> | null;
1088
+ node(el: M["DeploymentOrFqn"]): DeploymentNodeModel<M>;
1089
+ findNode(el: M["Deployment"]): DeploymentNodeModel<M> | null;
1090
+ instance(el: M["DeploymentOrFqn"]): DeployedInstanceModel<M>;
1091
+ findInstance(el: M["Deployment"]): DeployedInstanceModel<M> | null;
703
1092
  /**
704
1093
  * Returns the root elements of the model.
705
1094
  */
706
- roots(): ReadonlyArray<LikeC4Model.ElementModel<M>>;
1095
+ roots(): DeploymentNodesIterator<M>;
707
1096
  /**
708
1097
  * Returns all elements in the model.
709
1098
  */
710
- elements(): ReadonlyArray<LikeC4Model.ElementModel<M>>;
1099
+ elements(): DeploymentElementsIterator<M>;
711
1100
  /**
712
- * Returns a specific element by its FQN.
1101
+ * Returns all elements in the model.
713
1102
  */
714
- element(id: Fqn$1): LikeC4Model.ElementModel<M>;
1103
+ nodes(): DeploymentNodesIterator<M>;
1104
+ instances(): DeployedInstancesIterator<M>;
715
1105
  /**
716
- * Returns all relationships in the model.
1106
+ * Iterate over all instances of the given logical element.
717
1107
  */
718
- relationships(): ReadonlyArray<LikeC4Model.Relationship<M>>;
1108
+ instancesOf(element: M["ElementOrFqn"]): DeployedInstancesIterator<M>;
1109
+ deploymentRef(ref: DeploymentRef): DeploymentElementModel<M> | NestedElementOfDeployedInstanceModel<M>;
719
1110
  /**
720
- * Returns a specific relationship by its ID.
1111
+ * Returns all relationships in the model.
721
1112
  */
722
- relationship(id: RelationID$1): LikeC4Model.Relationship<M>;
1113
+ relationships(): IteratorLike<DeploymentRelationModel<M>>;
723
1114
  /**
724
- * Returns all views in the model.
1115
+ * Returns a specific relationship by its ID.
725
1116
  */
726
- views(): ReadonlyArray<M>;
1117
+ relationship(id: M["RelationId"]): DeploymentRelationModel<M>;
1118
+ findRelationship(id: LiteralUnion<M["RelationId"], string>): DeploymentRelationModel<M> | null;
727
1119
  /**
728
- * Returns a specific view by its ID.
1120
+ * Returns all deployment views in the model.
729
1121
  */
730
- view(viewId: ViewID$1): M;
1122
+ views(): IteratorLike<LikeC4ViewModel<M, ComputedDeploymentView>>;
731
1123
  /**
732
1124
  * Returns the parent element of given element.
733
1125
  * @see ancestors
734
1126
  */
735
- parent(element: ElementOrFqn): LikeC4Model.ElementModel<M> | null;
1127
+ parent(element: M["DeploymentOrFqn"]): DeploymentNodeModel<M> | null;
736
1128
  /**
737
1129
  * Get all children of the element (only direct children),
738
1130
  * @see descendants
739
1131
  */
740
- children(element: ElementOrFqn): ReadonlyArray<LikeC4Model.ElementModel<M>>;
1132
+ children(element: M["DeploymentOrFqn"]): ReadonlySet<DeploymentElementModel<M>>;
741
1133
  /**
742
1134
  * Get all sibling (i.e. same parent)
743
1135
  */
744
- siblings(element: ElementOrFqn): ReadonlyArray<LikeC4Model.ElementModel<M>>;
1136
+ siblings(element: M["DeploymentOrFqn"]): DeploymentElementsIterator<M>;
745
1137
  /**
746
1138
  * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
747
1139
  * (from closest to root)
748
1140
  */
749
- ancestors(element: ElementOrFqn): ReadonlyArray<LikeC4Model.ElementModel<M>>;
1141
+ ancestors(element: M["DeploymentOrFqn"]): DeploymentNodesIterator<M>;
750
1142
  /**
751
1143
  * Get all descendant elements (i.e. children, children’s children, etc.)
752
1144
  */
753
- descendants(element: ElementOrFqn): ReadonlyArray<LikeC4Model.ElementModel<M>>;
1145
+ descendants(element: M["DeploymentOrFqn"]): DeploymentElementsIterator<M>;
754
1146
  /**
755
1147
  * Incoming relationships to the element and its descendants
756
1148
  * @see incomers
757
1149
  */
758
- incoming(element: ElementOrFqn, filter?: IncomingFilter): ReadonlyArray<LikeC4Model.Relationship<M>>;
759
- /**
760
- * Source elements of incoming relationships
761
- */
762
- incomers(element: ElementOrFqn, filter?: IncomingFilter): ReadonlyArray<LikeC4Model.ElementModel<M>>;
1150
+ incoming(element: M["DeploymentOrFqn"], filter?: IncomingFilter): IteratorLike<DeploymentRelationModel<M>>;
763
1151
  /**
764
1152
  * Outgoing relationships from the element and its descendants
765
1153
  * @see outgoers
766
1154
  */
767
- outgoing(element: ElementOrFqn, filter?: OutgoingFilter): ReadonlyArray<LikeC4Model.Relationship<M>>;
1155
+ outgoing(element: M["DeploymentOrFqn"], filter?: OutgoingFilter): IteratorLike<DeploymentRelationModel<M>>;
1156
+ private addElement;
1157
+ private addRelation;
1158
+ }
1159
+ type DeploymentElementsIterator<M extends AnyAux> = IteratorLike<DeploymentElementModel<M>>;
1160
+ type DeployedInstancesIterator<M extends AnyAux> = IteratorLike<DeployedInstanceModel<M>>;
1161
+ type DeploymentNodesIterator<M extends AnyAux> = IteratorLike<DeploymentNodeModel<M>>;
1162
+ declare abstract class DeploymentElementModel<M extends AnyAux = AnyAux> {
1163
+ abstract readonly $model: LikeC4DeploymentModel<M>;
1164
+ abstract readonly $node: DeploymentNode | DeployedInstance;
1165
+ get id(): M["DeploymentFqn"];
1166
+ get style(): SetRequired<PhysicalElementStyle, "shape" | "color">;
1167
+ get shape(): ElementShape;
1168
+ get color(): ThemeColor;
1169
+ get tags(): ReadonlyArray<Tag>;
1170
+ get title(): string;
1171
+ get description(): string | null;
1172
+ get technology(): string | null;
1173
+ get parent(): DeploymentNodeModel<M> | null;
1174
+ get links(): ReadonlyArray<Link>;
768
1175
  /**
769
- * Target elements of outgoing relationships
1176
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
1177
+ * (from closest to root)
770
1178
  */
771
- outgoers(element: ElementOrFqn, filter?: OutgoingFilter): ReadonlyArray<LikeC4Model.ElementModel<M>>;
1179
+ ancestors(): DeploymentNodesIterator<M>;
772
1180
  /**
773
- * Relationships inside the element, among descendants
1181
+ * Returns the common ancestor of this element and another element.
774
1182
  */
775
- internal(element: ElementOrFqn): ReadonlyArray<LikeC4Model.Relationship<M>>;
1183
+ commonAncestor(another: DeploymentElementModel<M>): DeploymentNodeModel<M> | null;
776
1184
  /**
777
- * Resolve siblings of the element and siblings of ancestors
1185
+ * Get all sibling (i.e. same parent)
1186
+ */
1187
+ siblings(): DeploymentElementsIterator<M>;
1188
+ /**
1189
+ * Check if the element is a sibling of another element
1190
+ */
1191
+ isSibling(other: DeploymentElementModel<M>): boolean;
1192
+ /**
1193
+ * Resolve siblings of the element and its ancestors
778
1194
  * (from closest to root)
779
1195
  */
780
- ascendingSiblings(element: ElementOrFqn): ReadonlyArray<LikeC4Model.ElementModel<M>>;
1196
+ ascendingSiblings(): DeploymentElementsIterator<M>;
1197
+ incoming(filter?: IncomingFilter): IteratorLike<DeploymentRelationModel<M>>;
1198
+ outgoing(filter?: OutgoingFilter): IteratorLike<DeploymentRelationModel<M>>;
1199
+ incomers(filter?: IncomingFilter): IteratorLike<DeploymentRelationEndpoint<M>>;
1200
+ outgoers(filter?: OutgoingFilter): IteratorLike<DeploymentRelationEndpoint<M>>;
781
1201
  /**
782
- * Resolve all views that contain the element
1202
+ * Iterate over all views that include this deployment element.
783
1203
  */
784
- viewsWithElement(element: ElementOrFqn): ReadonlyArray<M>;
785
- private addElement;
786
- private addRelation;
787
- private _childrenOf;
788
- private _incomingTo;
789
- private _outgoingFrom;
790
- private _internalOf;
1204
+ views(): IteratorLike<LikeC4ViewModel<M, ComputedDeploymentView>>;
1205
+ isDeploymentNode(): this is DeploymentNodeModel<M>;
1206
+ isInstance(): this is DeployedInstanceModel<M>;
1207
+ abstract outgoingFromModel(): RelationshipsIterator<M>;
1208
+ abstract incomingFromModel(): RelationshipsIterator<M>;
1209
+ protected cachedOutgoing: RelationshipsAccum<M> | null;
1210
+ protected cachedIncoming: RelationshipsAccum<M> | null;
1211
+ get allOutgoing(): RelationshipsAccum<M>;
1212
+ get allIncoming(): RelationshipsAccum<M>;
791
1213
  }
792
- export declare namespace LikeC4Model {
793
- function create(source: LikeC4Model.SourceModel): PickBySource<typeof source>;
794
- function computed(source: ComputedLikeC4Model): LikeC4Model<LikeC4ViewModel>;
795
- function layouted(source: LayoutedLikeC4Model): LikeC4Model<LikeC4DiagramModel>;
796
- function isModel(model: any): model is LikeC4Model;
797
- type SourceModel<M extends ViewModel = ViewModel> = M extends LikeC4DiagramModel ? LayoutedLikeC4Model : ComputedLikeC4Model;
798
- type ViewModel = LikeC4ViewModel | LikeC4DiagramModel;
799
- namespace ViewModel {
800
- type ElementModel = LikeC4ViewModel.Element | LikeC4DiagramModel.Element;
801
- type Relationship = LikeC4Model.Relationship<ViewModel>;
802
- function isLayouted(model: ViewModel): model is LikeC4DiagramModel;
803
- }
804
- type Computed = LikeC4Model<LikeC4ViewModel>;
805
- namespace Computed {
806
- type ViewModel = LikeC4ViewModel;
807
- type SourceModel = LikeC4Model.SourceModel<ViewModel>;
808
- }
809
- type Layouted = LikeC4Model<LikeC4DiagramModel>;
810
- namespace Layouted {
811
- type ViewModel = LikeC4DiagramModel;
812
- type SourceModel = LikeC4Model.SourceModel<ViewModel>;
813
- }
814
- type ModelType<M extends ViewModel = ViewModel> = M extends LikeC4DiagramModel ? "layouted" : M extends LikeC4ViewModel ? "computed" : never;
815
- function isLayouted(model: LikeC4Model): model is Layouted;
816
- class Relationship<M extends ViewModel = ViewModel> {
817
- readonly relationship: Relation;
818
- private readonly model;
819
- constructor(relationship: Relation, model: LikeC4Model<M>);
820
- get id(): RelationID;
821
- get title(): string;
822
- get kind(): RelationshipKind<string>;
823
- get tags(): Tag[];
824
- get source(): ElementModel<M>;
825
- get target(): ElementModel<M>;
826
- metadata(key: string): string | undefined;
827
- metadata(key: string, defaultValue: string): string;
828
- hasMetadata(key: string): boolean;
829
- }
830
- class ElementModel<M extends ViewModel = ViewModel> {
831
- readonly element: Element$1;
832
- private readonly model;
833
- constructor(element: Element$1, model: LikeC4Model<M>);
834
- get id(): Fqn<string>;
835
- get title(): string;
836
- get kind(): ElementKind;
837
- get isRoot(): boolean;
838
- get hasNested(): boolean;
839
- get shape(): ElementShape;
840
- get color(): Color;
841
- get tags(): Tag[];
842
- parent(): ElementModel<M> | null;
843
- metadata(key: string): string | undefined;
844
- metadata(key: string, defaultValue: string): string;
845
- hasMetadata(key: string): boolean;
846
- ancestors(): readonly ElementModel<M>[];
847
- siblings(): readonly ElementModel<M>[];
848
- descendants(): readonly ElementModel<M>[];
849
- children(): readonly ElementModel<M>[];
850
- /**
851
- * First 'view of' current element
852
- */
853
- viewOf(): M;
854
- /**
855
- * All views 'view of' current element
856
- */
857
- viewsOf(): M[];
858
- /**
859
- * Views that contain this element
860
- */
861
- views(): readonly M[];
862
- incoming(filter?: IncomingFilter): readonly Relationship<M>[];
863
- incomers(filter?: IncomingFilter): readonly ElementModel<M>[];
864
- outgoing(filter?: OutgoingFilter): readonly Relationship<M>[];
865
- outgoers(filter?: OutgoingFilter): readonly ElementModel<M>[];
866
- internal(): readonly Relationship<M>[];
867
- /**
868
- * Resolve siblings of the element and siblings of ancestors
869
- * (from closest to root)
870
- */
871
- ascendingSiblings(): readonly ElementModel<M>[];
872
- }
1214
+ declare class DeploymentNodeModel<M extends AnyAux = AnyAux> extends DeploymentElementModel<M> {
1215
+ readonly $model: LikeC4DeploymentModel<M>;
1216
+ readonly $node: DeploymentNode;
1217
+ constructor($model: LikeC4DeploymentModel<M>, $node: DeploymentNode);
1218
+ get kind(): DeploymentNodeKind;
1219
+ children(): ReadonlySet<DeploymentElementModel<M>>;
1220
+ descendants(): DeploymentElementsIterator<M>;
1221
+ isDeploymentNode(): this is DeploymentNodeModel<M>;
1222
+ /**
1223
+ * Iterate over all instances nested in this deployment node.
1224
+ */
1225
+ instances(): DeployedInstancesIterator<M>;
1226
+ /**
1227
+ * Returns deployed instance inside this deployment node
1228
+ * if only there are no more instances
1229
+ */
1230
+ onlyOneInstance(): DeployedInstanceModel<M> | null;
1231
+ /**
1232
+ * Cached result of relationships from instances
1233
+ */
1234
+ private _relationshipsFromInstances;
1235
+ private relationshipsFromInstances;
1236
+ /**
1237
+ * We return only relationships that are not already present in nested instances
1238
+ */
1239
+ outgoingFromModel(): RelationshipsIterator<M>;
1240
+ /**
1241
+ * We return only relationships that are not already present in nested instances
1242
+ */
1243
+ incomingFromModel(): RelationshipsIterator<M>;
873
1244
  }
874
- declare class LikeC4DiagramModel {
875
- readonly view: DiagramView;
876
- readonly model: LikeC4Model.Layouted;
877
- private readonly _rootElements;
878
- private readonly _elements;
879
- private readonly _connections;
880
- constructor(view: DiagramView, model: LikeC4Model.Layouted);
881
- get isDynamic(): boolean;
882
- get id(): ViewID<string>;
1245
+ declare class DeployedInstanceModel<M extends AnyAux = AnyAux> extends DeploymentElementModel<M> {
1246
+ readonly $model: LikeC4DeploymentModel<M>;
1247
+ readonly $instance: DeployedInstance;
1248
+ readonly $element: ElementModel<M>;
1249
+ constructor($model: LikeC4DeploymentModel<M>, $instance: DeployedInstance, $element: ElementModel<M>);
1250
+ get parent(): DeploymentNodeModel<M>;
1251
+ get $node(): DeployedInstance;
1252
+ get style(): SetRequired<PhysicalElementStyle, "shape" | "color">;
1253
+ get shape(): ElementShape;
1254
+ get color(): ThemeColor;
1255
+ get tags(): ReadonlyArray<Tag>;
1256
+ get title(): string;
1257
+ get description(): string | null;
1258
+ get technology(): string | null;
1259
+ get links(): ReadonlyArray<Link>;
1260
+ isInstance(): this is DeployedInstanceModel<M>;
1261
+ outgoingFromModel(): RelationshipsIterator<M>;
1262
+ incomingFromModel(): RelationshipsIterator<M>;
1263
+ }
1264
+ declare class NestedElementOfDeployedInstanceModel<M extends AnyAux> {
1265
+ readonly instance: DeployedInstanceModel<M>;
1266
+ readonly element: ElementModel<M>;
1267
+ constructor(instance: DeployedInstanceModel<M>, element: ElementModel<M>);
1268
+ get id(): M["DeploymentFqn"];
1269
+ get style(): SetRequired<PhysicalElementStyle, "shape" | "color">;
1270
+ get shape(): ElementShape;
1271
+ get color(): ThemeColor;
883
1272
  get title(): string;
884
- get viewOf(): LikeC4Model.ElementModel<LikeC4DiagramModel>;
885
- get tags(): Tag[];
886
- roots(): ReadonlyArray<LikeC4DiagramModel.Element>;
887
- elements(): ReadonlyArray<LikeC4DiagramModel.Element>;
888
- element(id: Fqn$1): LikeC4DiagramModel.Element;
889
- hasElement(id: Fqn$1): boolean;
890
- connections(): ReadonlyArray<LikeC4DiagramModel.Connection>;
891
- connection(id: EdgeId$1): LikeC4DiagramModel.Connection;
892
- findConnections(source: ElementOrFqn, target: ElementOrFqn, direction?: "both" | "direct"): ReadonlyArray<LikeC4DiagramModel.Connection>;
893
- parent(element: ElementOrFqn): LikeC4DiagramModel.Element | null;
894
- children(element: ElementOrFqn): ReadonlyArray<LikeC4DiagramModel.Element>;
895
- siblings(element: ElementOrFqn): ReadonlyArray<LikeC4DiagramModel.Element>;
1273
+ get description(): string | null;
1274
+ get technology(): string | null;
1275
+ isDeploymentNode(): this is DeploymentNodeModel<M>;
1276
+ isInstance(): this is DeployedInstanceModel<M>;
1277
+ }
1278
+ type DeploymentRelationEndpoint<M extends AnyAux> = DeploymentElementModel<M> | NestedElementOfDeployedInstanceModel<M>;
1279
+ declare class DeploymentRelationModel<M extends AnyAux> {
1280
+ readonly $model: LikeC4DeploymentModel<M>;
1281
+ readonly $relationship: DeploymentRelation;
1282
+ boundary: DeploymentNodeModel<M> | null;
1283
+ source: DeploymentRelationEndpoint<M>;
1284
+ target: DeploymentRelationEndpoint<M>;
1285
+ constructor($model: LikeC4DeploymentModel<M>, $relationship: DeploymentRelation);
1286
+ get id(): M["RelationId"];
1287
+ get expression(): string;
1288
+ get title(): string | null;
1289
+ get technology(): string | null;
1290
+ get description(): string | null;
1291
+ get tags(): ReadonlyArray<Tag>;
1292
+ get navigateTo(): LikeC4ViewModel<M> | null;
1293
+ get links(): ReadonlyArray<Link>;
1294
+ views(): IteratorLike<LikeC4ViewModel<M, ComputedDeploymentView>>;
1295
+ }
1296
+ declare class RelationshipsAccum<M extends AnyAux> {
1297
+ readonly model: ReadonlySet<RelationshipModel<M>>;
1298
+ readonly deployment: ReadonlySet<DeploymentRelationModel<M>>;
1299
+ /**
1300
+ * @param model relationships from logical model
1301
+ * @param deployment relationships from deployment model
1302
+ */
1303
+ constructor(model: ReadonlySet<RelationshipModel<M>>, deployment: ReadonlySet<DeploymentRelationModel<M>>);
1304
+ get isEmpty(): boolean;
1305
+ get nonEmpty(): boolean;
1306
+ get size(): number;
1307
+ /**
1308
+ * Returns new Accum containing all the elements which are both in this and otherAccum
1309
+ */
1310
+ intersect(otherAccum: RelationshipsAccum<M>): RelationshipsAccum<M>;
1311
+ /**
1312
+ * Returns new Accum containing all the elements which are both in this and otherAccum
1313
+ */
1314
+ difference(otherAccum: RelationshipsAccum<M>): RelationshipsAccum<M>;
1315
+ /**
1316
+ * Returns new Accum containing all the elements from both
1317
+ */
1318
+ union(otherAccum: RelationshipsAccum<M>): RelationshipsAccum<M>;
1319
+ }
1320
+ export declare class LikeC4Model<M extends AnyAux = LikeC4Model.Any> {
1321
+ #private;
1322
+ readonly $model: M["Model"];
1323
+ /**
1324
+ * Only available in compile time
1325
+ */
1326
+ readonly Aux: M;
1327
+ readonly deployment: LikeC4DeploymentModel<M>;
1328
+ static create<const M extends AnyLikeC4Model>(model: M): LikeC4Model<Aux.FromModel<M>>;
1329
+ /**
1330
+ * This method is supposed to be used only in dumps
1331
+ */
1332
+ static fromDump<const M extends ParsedLikeC4ModelDump>(dump: M): LikeC4Model<Aux.FromDump<M>>;
1333
+ private constructor();
1334
+ get type(): "computed" | "layouted";
1335
+ element(el: M["ElementOrFqn"]): ElementModel<M>;
1336
+ findElement(el: LiteralUnion<M["Element"], string>): ElementModel<M> | null;
1337
+ /**
1338
+ * Returns the root elements of the model.
1339
+ */
1340
+ roots(): ElementsIterator<M>;
1341
+ /**
1342
+ * Returns all elements in the model.
1343
+ */
1344
+ elements(): ElementsIterator<M>;
1345
+ /**
1346
+ * Returns all relationships in the model.
1347
+ */
1348
+ relationships(): RelationshipsIterator<M>;
1349
+ /**
1350
+ * Returns a specific relationship by its ID.
1351
+ * If the relationship is not found in the model, it will be searched in the deployment model.
1352
+ * Search can be limited to the model or deployment model only.
1353
+ */
1354
+ relationship(id: M["RelationId"], type: "model"): RelationshipModel<M>;
1355
+ relationship(id: M["RelationId"], type: "deployment"): DeploymentRelationModel<M>;
1356
+ relationship(id: M["RelationId"], type?: "model" | "deployment"): RelationshipModel<M> | DeploymentRelationModel<M>;
1357
+ findRelationship(id: LiteralUnion<M["RelationId"], string>, type: "model"): RelationshipModel<M> | null;
1358
+ findRelationship(id: LiteralUnion<M["RelationId"], string>, type: "deployment"): DeploymentRelationModel<M> | null;
1359
+ findRelationship(id: LiteralUnion<M["RelationId"], string>, type?: "model" | "deployment"): RelationshipModel<M> | DeploymentRelationModel<M> | null;
1360
+ /**
1361
+ * Returns all views in the model.
1362
+ */
1363
+ views(): MapIterator<LikeC4ViewModel<M, M["ViewType"]>>;
1364
+ /**
1365
+ * Returns a specific view by its ID.
1366
+ */
1367
+ view(viewId: M["ViewIdLiteral"]): LikeC4ViewModel<M>;
1368
+ findView(viewId: LiteralUnion<M["ViewId"], string>): LikeC4ViewModel<M>;
1369
+ /**
1370
+ * Returns the parent element of given element.
1371
+ * @see ancestors
1372
+ */
1373
+ parent(element: M["ElementOrFqn"]): ElementModel<M> | null;
1374
+ /**
1375
+ * Get all children of the element (only direct children),
1376
+ * @see descendants
1377
+ */
1378
+ children(element: M["ElementOrFqn"]): ReadonlySet<ElementModel<M>>;
1379
+ /**
1380
+ * Get all sibling (i.e. same parent)
1381
+ */
1382
+ siblings(element: M["ElementOrFqn"]): ElementsIterator<M>;
896
1383
  /**
897
1384
  * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
898
1385
  * (from closest to root)
899
1386
  */
900
- ancestors(element: ElementOrFqn): ReadonlyArray<LikeC4DiagramModel.Element>;
901
- descendants(element: ElementOrFqn): ReadonlyArray<LikeC4DiagramModel.Element>;
902
- incoming(element: ElementOrFqn, filter?: IncomingFilter): ReadonlyArray<LikeC4DiagramModel.Connection>;
903
- incomers(element: ElementOrFqn, filter?: IncomingFilter): ReadonlyArray<LikeC4DiagramModel.Element>;
1387
+ ancestors(element: M["ElementOrFqn"]): ElementsIterator<M>;
904
1388
  /**
905
- * Outgoing relationships from the element and its descendants
1389
+ * Get all descendant elements (i.e. children, children’s children, etc.)
906
1390
  */
907
- outgoing(element: ElementOrFqn, filter?: OutgoingFilter): ReadonlyArray<LikeC4DiagramModel.Connection>;
908
- outgoers(element: ElementOrFqn, filter?: OutgoingFilter): ReadonlyArray<LikeC4DiagramModel.Element>;
909
- }
910
- declare namespace LikeC4DiagramModel {
911
- /**
912
- * Represents an element in the view. (Diagram node)
913
- * All methods are view-scoped, i.e. `children` returns only children of the element in the view.
914
- */
915
- class Element {
916
- readonly node: DiagramNode;
917
- private readonly view;
918
- constructor(node: DiagramNode, view: LikeC4DiagramModel);
919
- get id(): NodeId<string>;
920
- get title(): string;
921
- get kind(): ElementKind;
922
- get isRoot(): boolean;
923
- get hasNested(): boolean;
924
- get shape(): ElementShape;
925
- get color(): Color;
926
- get tags(): Tag[];
927
- get level(): number;
928
- get depth(): number;
929
- model(): LikeC4Model.ElementModel<LikeC4DiagramModel>;
930
- parent(): LikeC4DiagramModel.Element | null;
931
- metadata(key: string): string | undefined;
932
- metadata(key: string, defaultValue: string): string;
933
- hasMetadata(key: string): boolean;
934
- ancestors(): ReadonlyArray<LikeC4DiagramModel.Element>;
935
- siblings(): ReadonlyArray<LikeC4DiagramModel.Element>;
936
- descendants(): ReadonlyArray<LikeC4DiagramModel.Element>;
937
- children(): ReadonlyArray<LikeC4DiagramModel.Element>;
938
- incoming(filter?: IncomingFilter): ReadonlyArray<LikeC4DiagramModel.Connection>;
939
- incomers(filter?: IncomingFilter): ReadonlyArray<LikeC4DiagramModel.Element>;
940
- outgoing(filter?: OutgoingFilter): ReadonlyArray<LikeC4DiagramModel.Connection>;
941
- outgoers(filter?: OutgoingFilter): ReadonlyArray<LikeC4DiagramModel.Element>;
942
- connectionsTo(target: Fqn$1 | LikeC4DiagramModel.Element): ReadonlyArray<LikeC4DiagramModel.Connection>;
943
- }
1391
+ descendants(element: M["ElementOrFqn"]): ElementsIterator<M>;
944
1392
  /**
945
- * Represents a connection between two elements.
946
- * May be source from multiple model relationships.
947
- */
948
- class Connection {
949
- readonly edge: DiagramEdge;
950
- private readonly view;
951
- constructor(edge: DiagramEdge, view: LikeC4DiagramModel);
952
- get id(): EdgeId;
953
- get source(): LikeC4DiagramModel.Element;
954
- get target(): LikeC4DiagramModel.Element;
955
- get tags(): Tag[];
956
- get color(): Color;
957
- /**
958
- * Model relationships
959
- */
960
- relationships(): ReadonlyArray<LikeC4Model.Relationship<LikeC4DiagramModel>>;
961
- }
1393
+ * Incoming relationships to the element and its descendants
1394
+ * @see incomers
1395
+ */
1396
+ incoming(element: M["ElementOrFqn"], filter?: IncomingFilter): RelationshipsIterator<M>;
1397
+ /**
1398
+ * Outgoing relationships from the element and its descendants
1399
+ * @see outgoers
1400
+ */
1401
+ outgoing(element: M["ElementOrFqn"], filter?: OutgoingFilter): RelationshipsIterator<M>;
1402
+ private addElement;
1403
+ private addRelation;
1404
+ }
1405
+ export declare namespace LikeC4Model {
1406
+ type Any = Aux<string, string, string, ComputedView | DiagramView>;
1407
+ type Element<M extends AnyAux = Any> = ElementModel<M>;
1408
+ type Relation<M extends AnyAux = Any> = RelationshipModel<M>;
1409
+ type AnyRelation<M extends AnyAux = Any> = RelationshipModel<M> | DeploymentRelationModel<M>;
1410
+ type View<M extends AnyAux = Any, V extends ComputedView | DiagramView = M["ViewType"]> = LikeC4ViewModel<M, V>;
1411
+ type Node<M extends AnyAux = Any, V extends ComputedView | DiagramView = M["ViewType"]> = NodeModel<M, V>;
1412
+ type Edge<M extends AnyAux = Any, V extends ComputedView | DiagramView = M["ViewType"]> = EdgeModel<M, V>;
1413
+ type DeploymentModel<M extends AnyAux = AnyAux> = LikeC4DeploymentModel<M>;
1414
+ type Deployment<M extends AnyAux = AnyAux> = DeploymentElementModel<M>;
1415
+ type DeploymentNode<M extends AnyAux = AnyAux> = DeploymentNodeModel<M>;
1416
+ type DeployedInstance<M extends AnyAux = AnyAux> = DeployedInstanceModel<M>;
1417
+ type Typed<Elements extends string = string, Deployments extends string = string, Views extends string = string, ViewType = DiagramView<Views> | ComputedView<Views>> = Aux<Elements, Deployments, Views, ViewType>;
1418
+ type Computed<Elements extends string = string, Deployments extends string = string, Views extends string = string> = LikeC4Model<Typed<Elements, Deployments, Views, ComputedView<Views>>>;
1419
+ type Layouted<Elements extends string = string, Deployments extends string = string, Views extends string = string> = LikeC4Model<Typed<Elements, Deployments, Views, DiagramView<Views>>>;
962
1420
  }
963
1421
  interface VariantColorsResolverInput {
964
1422
  color: MantineColor | undefined;
@@ -1132,9 +1590,7 @@ type MantineThemeColors = MantineThemeColorsOverride extends {
1132
1590
  colors: Record<infer CustomColors, MantineColorsTuple>;
1133
1591
  } ? Record<CustomColors, MantineColorsTuple> : Record<DefaultMantineColor, MantineColorsTuple>;
1134
1592
  type MantineColor = keyof MantineThemeColors;
1135
- export type ViewData<ViewId extends string> = Omit<DiagramView, "id"> & {
1136
- id: ViewId;
1137
- };
1593
+ export type ViewData<Views extends string> = DiagramView<Views, string>;
1138
1594
  type ElementIconRendererProps = {
1139
1595
  node: {
1140
1596
  id: string;
@@ -1379,7 +1835,7 @@ type XYBackgroundVariant = "dots" | "lines" | "cross";
1379
1835
  type XYBackground = XYBackgroundVariant | OverrideProperties<BackgroundProps, {
1380
1836
  variant: XYBackgroundVariant;
1381
1837
  }>;
1382
- type DiagramNodeWithNavigate<ID extends string = ViewID> = Omit<DiagramNode, "navigateTo"> & {
1838
+ type DiagramNodeWithNavigate<ID extends string = ViewId> = Omit<DiagramNode, "navigateTo"> & {
1383
1839
  navigateTo: ID;
1384
1840
  };
1385
1841
  type ElementIconNodeProps = {
@@ -1390,7 +1846,7 @@ type ElementIconNodeProps = {
1390
1846
  type ElementIconRenderer$1 = (props: {
1391
1847
  node: ElementIconNodeProps;
1392
1848
  }) => ReactNode;
1393
- type OnNavigateTo<ID extends string = ViewID> = (to: ID, event?: ReactMouseEvent, element?: DiagramNodeWithNavigate<ID>) => void;
1849
+ type OnNavigateTo<ID extends string = ViewId> = (to: ID, event?: ReactMouseEvent, element?: DiagramNodeWithNavigate<ID>) => void;
1394
1850
  type OnNodeClick = (node: DiagramNode, event: ReactMouseEvent) => void;
1395
1851
  type OnEdgeClick = (edge: DiagramEdge, event: ReactMouseEvent) => void;
1396
1852
  type OnCanvasClick = (event: ReactMouseEvent) => void;
@@ -1477,6 +1933,11 @@ interface LikeC4DiagramProperties {
1477
1933
  * @default false
1478
1934
  */
1479
1935
  enableFocusMode?: boolean | undefined;
1936
+ /**
1937
+ * Enable search popup for elements and views
1938
+ * @default true
1939
+ */
1940
+ enableSearch?: boolean | undefined;
1480
1941
  /**
1481
1942
  * Enable modal with element details
1482
1943
  * @default false
@@ -1508,6 +1969,17 @@ interface LikeC4DiagramProperties {
1508
1969
  */
1509
1970
  where?: WhereOperator<string, string> | undefined;
1510
1971
  }
1972
+ type OpenSourceParams = {
1973
+ element: Fqn;
1974
+ property?: string;
1975
+ } | {
1976
+ relation: RelationId;
1977
+ } | {
1978
+ deployment: Fqn;
1979
+ property?: string;
1980
+ } | {
1981
+ view: ViewId;
1982
+ };
1511
1983
  interface LikeC4DiagramEventHandlers {
1512
1984
  onChange?: OnChange | null | undefined;
1513
1985
  onNavigateTo?: OnNavigateTo | null | undefined;
@@ -1519,9 +1991,7 @@ interface LikeC4DiagramEventHandlers {
1519
1991
  onCanvasClick?: OnCanvasClick | null | undefined;
1520
1992
  onCanvasDblClick?: OnCanvasClick | null | undefined;
1521
1993
  onBurgerMenuClick?: null | undefined | (() => void);
1522
- onOpenSourceView?: null | undefined | (() => void);
1523
- onOpenSourceElement?: null | undefined | ((fqn: Fqn) => void);
1524
- onOpenSourceRelation?: null | undefined | ((id: RelationID) => void);
1994
+ onOpenSource?: null | undefined | ((params: OpenSourceParams) => void);
1525
1995
  }
1526
1996
  type LikeC4DiagramProps = LikeC4DiagramProperties & LikeC4DiagramEventHandlers;
1527
1997
  export declare function useLikeC4Model(): LikeC4Model | null;
@@ -1529,17 +1999,17 @@ export declare function useLikeC4Model(strict: true): LikeC4Model;
1529
1999
  export declare function useLikeC4Model(strict: boolean): LikeC4Model | null;
1530
2000
  export declare function useLikeC4Model(strict: true, type: "layouted"): LikeC4Model.Layouted;
1531
2001
  export declare function useLikeC4Model(strict: true, type: "computed"): LikeC4Model.Computed;
1532
- export declare function useLikeC4Model(strict: true, type: LikeC4Model["type"] | undefined): LikeC4Model;
2002
+ export declare function useLikeC4Model(strict: true, type: "layouted" | "computed" | undefined): LikeC4Model;
1533
2003
  export declare function useLikeC4Model(strict: boolean, type: "layouted"): LikeC4Model.Layouted | null;
1534
2004
  export declare function useLikeC4Model(strict: boolean, type: "computed"): LikeC4Model.Computed | null;
1535
- export declare function useLikeC4Model(strict: boolean, type: LikeC4Model["type"] | undefined): LikeC4Model | null;
1536
- export declare function useLikeC4Views(): LikeC4Model.SourceModel["views"];
1537
- export declare function useLikeC4ViewModel(viewId: LiteralUnion<ViewID, string>): LikeC4Model.ViewModel;
2005
+ export declare function useLikeC4Model(strict: boolean, type: "layouted" | "computed" | undefined): LikeC4Model | null;
2006
+ export declare function useLikeC4Views(): Record<ViewId, ComputedView | DiagramView>;
2007
+ export declare function useLikeC4ViewModel(viewId: LiteralUnion<ViewId, string>): LikeC4Model.View;
1538
2008
  /**
1539
2009
  * Parsed view, computed or layouted
1540
2010
  */
1541
- export declare function useLikeC4View(viewId: LiteralUnion<ViewID, string>): ComputedView | DiagramView | null;
1542
- export declare function useLikeC4DiagramView(viewId: LiteralUnion<ViewID, string>): DiagramView | null;
2011
+ export declare function useLikeC4View(viewId: LiteralUnion<ViewId, string>): ComputedView | DiagramView | null;
2012
+ export declare function useLikeC4DiagramView(viewId: LiteralUnion<ViewId, string>): DiagramView | null;
1543
2013
  type LikeC4ModelProviderProps = PropsWithChildren<{
1544
2014
  likec4model: LikeC4Model;
1545
2015
  }>;
@@ -1815,6 +2285,9 @@ export declare const BundledStyles: () => any;
1815
2285
  export declare function useBundledStyleSheet(injectFontCss: boolean, styleNonce?: string | (() => string) | undefined): CSSStyleSheet[];
1816
2286
  type ColorScheme = "light" | "dark";
1817
2287
  export declare function useColorScheme(explicit?: ColorScheme): ColorScheme;
2288
+ export declare const ViewNotFound: ({ viewId }: {
2289
+ viewId: string;
2290
+ }) => import("react/jsx-runtime").JSX.Element;
1818
2291
  /**
1819
2292
  * We need this function to bundle LikeC4Model with `likec4/react'
1820
2293
  * Used by vite plugin to generate `virtual:likec4/model`