likec4 1.19.2 → 1.20.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 (38) hide show
  1. package/__app__/react/likec4.tsx +16 -114
  2. package/__app__/src/chunks/{-index-overview-COSF42be.js → -index-overview-r2wnjkuP.js} +20 -19
  3. package/__app__/src/chunks/{likec4-CusAw_j6.js → likec4-CK8zVxjc.js} +1172 -1209
  4. package/__app__/src/chunks/main-DnSU4JID.js +23887 -0
  5. package/__app__/src/chunks/{mantine-B_6mKFFA.js → mantine-B9NZkjVg.js} +993 -981
  6. package/__app__/src/chunks/tanstack-router-B9I-d36d.js +3032 -0
  7. package/__app__/src/main.js +1 -2
  8. package/__app__/src/style.css +1 -1
  9. package/__app__/webcomponent/webcomponent.js +31797 -32401
  10. package/dist/chunks/prompt.cjs +1 -1
  11. package/dist/chunks/prompt.mjs +1 -1
  12. package/dist/cli/index.cjs +47 -58
  13. package/dist/cli/index.mjs +29 -40
  14. package/dist/index.cjs +1 -1
  15. package/dist/index.d.cts +106 -81
  16. package/dist/index.d.mts +106 -81
  17. package/dist/index.d.ts +106 -81
  18. package/dist/index.mjs +1 -1
  19. package/dist/model/index.cjs +1 -1
  20. package/dist/model/index.d.cts +4 -257
  21. package/dist/model/index.d.mts +4 -257
  22. package/dist/model/index.d.ts +4 -257
  23. package/dist/model/index.mjs +1 -1
  24. package/dist/shared/likec4.DBfW7tKq.cjs +1857 -0
  25. package/dist/shared/likec4.DCOeDSBO.mjs +1857 -0
  26. package/package.json +39 -39
  27. package/react/index.d.ts +771 -1546
  28. package/react/index.js +36748 -37458
  29. package/react/style.css +1 -1
  30. package/__app__/src/chunks/main-CtzxB_vG.js +0 -24136
  31. package/__app__/src/chunks/tanstack-router-BBWuTKWO.js +0 -2373
  32. package/dist/shared/likec4.-U9_Dinu.cjs +0 -1856
  33. package/dist/shared/likec4.CVn8U3Og.cjs +0 -9
  34. package/dist/shared/likec4.Cgd5VecV.mjs +0 -9
  35. package/dist/shared/likec4.D7BM0ZAO.mjs +0 -1856
  36. package/dist/shared/likec4.DJeGiAvE.d.cts +0 -1639
  37. package/dist/shared/likec4.DJeGiAvE.d.mts +0 -1639
  38. package/dist/shared/likec4.DJeGiAvE.d.ts +0 -1639
@@ -1,1639 +0,0 @@
1
- import { LiteralUnion, Tagged, Simplify, TupleToUnion, UnionToIntersection, MergeExclusive, NonEmptyTuple, IsStringLiteral, SetRequired } from 'type-fest';
2
-
3
- declare const ThemeColors: readonly ["amber", "blue", "gray", "slate", "green", "indigo", "muted", "primary", "red", "secondary", "sky"];
4
- type ThemeColor = typeof ThemeColors[number];
5
- type HexColorLiteral = `#${string}`;
6
- type ColorLiteral = HexColorLiteral;
7
- type Color = LiteralUnion<ThemeColor, string>;
8
- interface ElementThemeColorValues {
9
- fill: ColorLiteral;
10
- stroke: ColorLiteral;
11
- hiContrast: ColorLiteral;
12
- loContrast: ColorLiteral;
13
- }
14
- interface RelationshipThemeColorValues {
15
- lineColor: ColorLiteral;
16
- labelBgColor: ColorLiteral;
17
- labelColor: ColorLiteral;
18
- }
19
- interface ThemeColorValues {
20
- elements: ElementThemeColorValues;
21
- relationships: RelationshipThemeColorValues;
22
- }
23
-
24
- type NonEmptyArray<T> = [T, ...T[]];
25
- type IconUrl = Tagged<string, 'IconUrl'> | 'none';
26
- type CustomColor = string;
27
- type Point = readonly [x: number, y: number];
28
- interface XYPoint {
29
- x: number;
30
- y: number;
31
- }
32
- type KeysOf<T> = keyof T extends infer K extends string ? K : never;
33
- type AllNever$1<Expressions> = UnionToIntersection<{
34
- [Name in keyof Expressions]: {
35
- -readonly [Key in keyof Expressions[Name]]?: never;
36
- };
37
- }[keyof Expressions]>;
38
- /**
39
- * @example
40
- * type Variant1 = {
41
- * a: string
42
- * }
43
- * type Variant2 = {
44
- * b: number
45
- * }
46
- *
47
- * type Variants = ExclusiveUnion<{
48
- * Variant1: Variant1,
49
- * Variant2: Variant2
50
- * }>
51
- *
52
- * Fail here
53
- * const variant1: Variants = {
54
- * a: 'one',
55
- * b: 1
56
- * }
57
- */
58
- type ExclusiveUnion<Expressions> = Expressions extends object ? {
59
- [Name in keyof Expressions]: Simplify<Omit<AllNever$1<Expressions>, keyof Expressions[Name]> & Expressions[Name]>;
60
- }[keyof Expressions] : Expressions;
61
- type IteratorLike<T> = IteratorObject<T, BuiltinIteratorReturn>;
62
-
63
- type Fqn<Id extends string = string> = Tagged<Id, 'Fqn'>;
64
- declare const BorderStyles: readonly ["solid", "dashed", "dotted", "none"];
65
- type BorderStyle = TupleToUnion<typeof BorderStyles>;
66
- type ElementKind<Kinds extends string = string> = Tagged<Kinds, 'ElementKind'>;
67
- declare namespace ElementKind {
68
- const Group: ElementKind;
69
- }
70
- declare const ElementShapes: readonly ["rectangle", "person", "browser", "mobile", "cylinder", "storage", "queue"];
71
- type ElementShape = TupleToUnion<typeof ElementShapes>;
72
- interface ElementStyle {
73
- readonly border?: BorderStyle;
74
- /**
75
- * In percentage 0-100, 0 is fully transparent
76
- *
77
- * @default 100
78
- */
79
- readonly opacity?: number;
80
- }
81
- type Tag<Tags extends string = string> = Tagged<Tags, 'Tag'>;
82
- interface Link {
83
- readonly title?: string;
84
- readonly url: string;
85
- readonly relative?: string;
86
- }
87
- interface TypedElement<Ids extends string, Kinds extends string, Tags extends string, MetadataKeys extends string = never> {
88
- readonly id: Fqn<Ids>;
89
- readonly kind: ElementKind<Kinds>;
90
- readonly title: string;
91
- readonly description: string | null;
92
- readonly technology: string | null;
93
- readonly tags: NonEmptyArray<Tag<Tags>> | null;
94
- readonly links: NonEmptyArray<Link> | null;
95
- readonly icon?: IconUrl;
96
- readonly shape?: ElementShape;
97
- readonly color?: Color;
98
- readonly style?: ElementStyle;
99
- readonly notation?: string;
100
- readonly metadata?: Record<MetadataKeys, string>;
101
- }
102
- interface Element extends TypedElement<string, string, string, string> {
103
- }
104
- interface ElementKindSpecificationStyle {
105
- shape?: ElementShape;
106
- icon?: IconUrl;
107
- color?: Color;
108
- border?: BorderStyle;
109
- opacity?: number;
110
- }
111
- interface ElementKindSpecification {
112
- readonly technology?: string;
113
- readonly notation?: string;
114
- readonly style: ElementKindSpecificationStyle;
115
- }
116
-
117
- type EqualOperator<V> = {
118
- eq: V;
119
- neq?: never;
120
- } | {
121
- eq?: never;
122
- neq: V;
123
- };
124
- type AllNever = {
125
- not?: never;
126
- and?: never;
127
- or?: never;
128
- tag?: never;
129
- kind?: never;
130
- };
131
- type TagEqual<Tag> = Omit<AllNever, 'tag'> & {
132
- tag: EqualOperator<Tag>;
133
- };
134
- type KindEqual<Kind> = Omit<AllNever, 'kind'> & {
135
- kind: EqualOperator<Kind>;
136
- };
137
- type NotOperator<Tag, Kind> = Omit<AllNever, 'not'> & {
138
- not: WhereOperator<Tag, Kind>;
139
- };
140
- type AndOperator<Tag, Kind> = Omit<AllNever, 'and'> & {
141
- and: NonEmptyArray<WhereOperator<Tag, Kind>>;
142
- };
143
- type OrOperator<Tag, Kind> = Omit<AllNever, 'or'> & {
144
- or: NonEmptyArray<WhereOperator<Tag, Kind>>;
145
- };
146
- type WhereOperator<Tag, Kind> = TagEqual<Tag> | KindEqual<Kind> | NotOperator<Tag, Kind> | AndOperator<Tag, Kind> | OrOperator<Tag, Kind>;
147
-
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 NonWilcard = ElementRefExpr | ElementKindExpr | ElementTagExpr | ExpandedElementExpr;
201
- type ElementExpression = NonWilcard | WildcardExpr;
202
- interface ElementWhereExpr extends Omit<BaseExpr, 'where'> {
203
- where: {
204
- expr: ElementExpression;
205
- condition: WhereOperator<string, string>;
206
- };
207
- }
208
- type ElementPredicateExpression = ElementExpression | ElementWhereExpr | CustomElementExpr;
209
- interface DirectRelationExpr extends Omit<BaseExpr, 'source' | 'target'> {
210
- source: ElementExpression;
211
- target: ElementExpression;
212
- isBidirectional?: boolean;
213
- }
214
- interface InOutExpr extends Omit<BaseExpr, 'inout'> {
215
- inout: ElementExpression;
216
- }
217
- interface IncomingExpr extends Omit<BaseExpr, 'incoming'> {
218
- incoming: ElementExpression;
219
- }
220
- interface OutgoingExpr extends Omit<BaseExpr, 'outgoing'> {
221
- outgoing: ElementExpression;
222
- }
223
- type RelationExpression = DirectRelationExpr | InOutExpr | IncomingExpr | OutgoingExpr;
224
- interface RelationWhereExpr extends Omit<BaseExpr, 'where'> {
225
- where: {
226
- expr: RelationExpression;
227
- condition: WhereOperator<string, string>;
228
- };
229
- }
230
- interface CustomRelationExpr extends Omit<BaseExpr, 'customRelation'> {
231
- customRelation: {
232
- relation: RelationExpression | RelationWhereExpr;
233
- title?: string;
234
- description?: string;
235
- technology?: string;
236
- notation?: string;
237
- navigateTo?: ViewId;
238
- notes?: string;
239
- color?: Color;
240
- line?: RelationshipLineType;
241
- head?: RelationshipArrowType;
242
- tail?: RelationshipArrowType;
243
- };
244
- }
245
- type RelationPredicateExpression = RelationExpression | RelationWhereExpr | CustomRelationExpr;
246
- type Expression = ElementPredicateExpression | RelationPredicateExpression;
247
-
248
- declare namespace FqnRef {
249
- /**
250
- * Represents a reference to an instance within a deployment.
251
- *
252
- * @template D - The type representing the deployment fqn. Defaults to `Fqn`.
253
- * @template M - The type representing the model fqn. Defaults to `Fqn`.
254
- *
255
- * @property {D} deployment - TThe fully qualified name (FQN) of the deployed instance.
256
- * @property {M} element - The element reference within the deployment.
257
- */
258
- type InsideInstanceRef<D = Fqn, M = Fqn> = {
259
- deployment: D;
260
- element: M;
261
- };
262
- const isInsideInstanceRef: (ref: FqnRef) => ref is InsideInstanceRef;
263
- /**
264
- * Represents a reference to a deployment element.
265
- *
266
- * @template F - The type of the fully qualified name (FQN) of the deployment element. Defaults to `Fqn`.
267
- * @property {F} deployment - The fully qualified name (FQN) of the deployment element.
268
- */
269
- type DeploymentElementRef<F = Fqn> = {
270
- deployment: F;
271
- };
272
- const isDeploymentElementRef: (ref: FqnRef) => ref is DeploymentElementRef;
273
- type DeploymentRef<D = Fqn, M = Fqn> = DeploymentElementRef<D> | InsideInstanceRef<D, M>;
274
- const isDeploymentRef: (ref: FqnRef) => ref is DeploymentRef;
275
- /**
276
- * Reference to logical model element
277
- */
278
- type ModelRef<F = Fqn> = {
279
- model: F;
280
- };
281
- const isModelRef: (ref: FqnRef) => ref is ModelRef;
282
- const toDeploymentRef: (ref: FqnRef) => DeploymentRef;
283
- }
284
- type FqnRef<D = Fqn, M = Fqn> = ExclusiveUnion<{
285
- InsideInstanceRef: FqnRef.InsideInstanceRef<D, M>;
286
- DeploymentRef: FqnRef.DeploymentRef<D>;
287
- ModelRef: FqnRef.ModelRef<M>;
288
- }>;
289
- declare namespace FqnExpr {
290
- type Wildcard = {
291
- wildcard: true;
292
- };
293
- const isWildcard: (expr: ExpressionV2) => expr is Wildcard;
294
- type ModelRef<M = Fqn> = {
295
- ref: FqnRef.ModelRef<M>;
296
- selector?: PredicateSelector;
297
- };
298
- const isModelRef: (ref: ExpressionV2) => ref is ModelRef;
299
- type DeploymentRef<D = Fqn, M = Fqn> = {
300
- ref: FqnRef.DeploymentRef<D> | FqnRef.InsideInstanceRef<D, M>;
301
- selector?: PredicateSelector;
302
- };
303
- const isDeploymentRef: (ref: ExpressionV2) => ref is FqnExpr.DeploymentRef;
304
- type NonWildcard<D = Fqn, M = Fqn> = ExclusiveUnion<{
305
- ModelRef: ModelRef<M>;
306
- DeploymentRef: DeploymentRef<D, M>;
307
- }>;
308
- }
309
- type FqnExpr<D = Fqn, M = Fqn> = ExclusiveUnion<{
310
- Wildcard: FqnExpr.Wildcard;
311
- ModelRef: FqnExpr.ModelRef<M>;
312
- DeploymentRef: FqnExpr.DeploymentRef<D, M>;
313
- }>;
314
- declare namespace RelationExpr {
315
- type Direct<D = Fqn, M = Fqn> = {
316
- source: FqnExpr<D, M>;
317
- target: FqnExpr<D, M>;
318
- isBidirectional?: boolean;
319
- };
320
- const isDirect: (expr: ExpressionV2) => expr is Direct;
321
- type Incoming<D = Fqn, M = Fqn> = {
322
- incoming: FqnExpr<D, M>;
323
- };
324
- const isIncoming: (expr: ExpressionV2) => expr is Incoming;
325
- type Outgoing<D = Fqn, M = Fqn> = {
326
- outgoing: FqnExpr<D, M>;
327
- };
328
- const isOutgoing: (expr: ExpressionV2) => expr is Outgoing;
329
- type InOut<D = Fqn, M = Fqn> = {
330
- inout: FqnExpr<D, M>;
331
- };
332
- const isInOut: (expr: ExpressionV2) => expr is InOut;
333
- type Where<D = Fqn, M = Fqn> = {
334
- where: {
335
- expr: ExpressionV2<D, M>;
336
- condition: WhereOperator<string, string>;
337
- };
338
- };
339
- const isWhere: (expr: ExpressionV2) => expr is Where;
340
- }
341
- type RelationExpr<D = Fqn, M = Fqn> = ExclusiveUnion<{
342
- Direct: RelationExpr.Direct<D, M>;
343
- Incoming: RelationExpr.Incoming<D, M>;
344
- Outgoing: RelationExpr.Outgoing<D, M>;
345
- InOut: RelationExpr.InOut<D, M>;
346
- Where: RelationExpr.Where<D, M>;
347
- }>;
348
- /**
349
- * Represents a version 2 expression which can be one of several types.
350
- *
351
- * @template D - The type for the deployment FQN, defaults to `Fqn`.
352
- * @template M - The type for the model FQN, defaults to `Fqn`.
353
- */
354
- type ExpressionV2<D = Fqn, M = Fqn> = ExclusiveUnion<{
355
- Wildcard: FqnExpr.Wildcard;
356
- ModelRef: FqnExpr.ModelRef<M>;
357
- DeploymentRef: FqnExpr.DeploymentRef<D, M>;
358
- Direct: RelationExpr.Direct<D, M>;
359
- Incoming: RelationExpr.Incoming<D, M>;
360
- Outgoing: RelationExpr.Outgoing<D, M>;
361
- InOut: RelationExpr.InOut<D, M>;
362
- RelationPredicateOrWhere: RelationExpr.Where<D, M>;
363
- }>;
364
- declare namespace ExpressionV2 {
365
- const isFqnExpr: (expr: ExpressionV2) => expr is FqnExpr;
366
- const isRelation: (expr: ExpressionV2) => expr is RelationExpr;
367
- }
368
-
369
- type GlobalPredicateId = Tagged<string, 'GlobalPredicateId'>;
370
- type GlobalPredicates = NonEmptyArray<ViewRulePredicate>;
371
- type GlobalDynamicPredicates = NonEmptyArray<DynamicViewIncludeRule>;
372
- type GlobalStyleID = Tagged<string, 'GlobalStyleID'>;
373
- type GlobalStyles = NonEmptyTuple<ViewRuleStyle>;
374
- interface ModelGlobals {
375
- readonly predicates: Record<GlobalPredicateId, GlobalPredicates>;
376
- readonly dynamicPredicates: Record<GlobalPredicateId, GlobalDynamicPredicates>;
377
- readonly styles: Record<GlobalStyleID, GlobalStyles>;
378
- }
379
-
380
- type ElementNotation = {
381
- kinds: string[];
382
- shape: ElementShape;
383
- color: Color;
384
- title: string;
385
- };
386
-
387
- type ViewId<Id extends string = string> = Tagged<Id, 'ViewID'>;
388
- type ViewRulePredicate = {
389
- include: Expression[];
390
- exclude?: never;
391
- } | {
392
- include?: never;
393
- exclude: Expression[];
394
- };
395
- interface ViewRuleGlobalPredicateRef {
396
- predicateId: GlobalPredicateId;
397
- }
398
- interface ViewRuleStyle {
399
- targets: ElementExpression[];
400
- notation?: string;
401
- style: ElementStyle & {
402
- color?: Color;
403
- shape?: ElementShape;
404
- icon?: IconUrl;
405
- };
406
- }
407
- interface ViewRuleGlobalStyle {
408
- styleId: GlobalStyleID;
409
- }
410
- type AutoLayoutDirection = 'TB' | 'BT' | 'LR' | 'RL';
411
- interface ViewRuleAutoLayout {
412
- direction: AutoLayoutDirection;
413
- nodeSep?: number;
414
- rankSep?: number;
415
- }
416
- interface ViewRuleGroup {
417
- groupRules: Array<ViewRulePredicate | ViewRuleGroup>;
418
- title: string | null;
419
- color?: Color;
420
- border?: BorderStyle;
421
- opacity?: number;
422
- }
423
- type ViewRule = ViewRulePredicate | ViewRuleGlobalPredicateRef | ViewRuleGroup | ViewRuleStyle | ViewRuleGlobalStyle | ViewRuleAutoLayout;
424
- interface BasicView<ViewType extends 'element' | 'dynamic' | 'deployment', ViewIDs extends string, Tags extends string> {
425
- readonly __?: ViewType;
426
- readonly id: ViewId<ViewIDs>;
427
- readonly title: string | null;
428
- readonly description: string | null;
429
- readonly tags: NonEmptyArray<Tag<Tags>> | null;
430
- readonly links: NonEmptyArray<Link> | null;
431
- /**
432
- * URI to the source file of this view.
433
- * Undefined if the view is auto-generated.
434
- */
435
- readonly docUri?: string;
436
- /**
437
- * For all views we find common ancestor path.
438
- * This is used to generate relative paths, i.e.:
439
- * - "/home/project/index.c4" becomes "index.c4"
440
- * - "/home/project/subdir/views.c4" becomes "subdir/views.c4"
441
- *
442
- * Undefined if the view is auto-generated.
443
- */
444
- readonly relativePath?: string;
445
- /**
446
- * If the view is changed manually this field contains the layout data.
447
- */
448
- readonly manualLayout?: ViewManualLayout | undefined;
449
- readonly customColorDefinitions: CustomColorDefinitions;
450
- }
451
- interface BasicElementView<ViewIDs extends string, Tags extends string> extends BasicView<'element', ViewIDs, Tags> {
452
- readonly viewOf?: Fqn;
453
- readonly rules: ViewRule[];
454
- }
455
- interface ScopedElementView<ViewIDs extends string, Tags extends string> extends BasicElementView<ViewIDs, Tags> {
456
- readonly viewOf: Fqn;
457
- }
458
- interface ExtendsElementView<ViewIDs extends string, Tags extends string> extends BasicElementView<ViewIDs, Tags> {
459
- readonly extends: ViewId<ViewIDs>;
460
- }
461
- type ElementView<ViewIDs extends string = string, Tags extends string = string> = ScopedElementView<ViewIDs, Tags> | ExtendsElementView<ViewIDs, Tags> | BasicElementView<ViewIDs, Tags>;
462
- interface DynamicViewStep {
463
- readonly source: Fqn;
464
- readonly target: Fqn;
465
- readonly title: string | null;
466
- readonly description?: string;
467
- readonly technology?: string;
468
- readonly notation?: string;
469
- readonly notes?: string;
470
- readonly color?: Color;
471
- readonly line?: RelationshipLineType;
472
- readonly head?: RelationshipArrowType;
473
- readonly tail?: RelationshipArrowType;
474
- readonly isBackward?: boolean;
475
- readonly navigateTo?: ViewId;
476
- __parallel?: never;
477
- }
478
- interface DynamicViewParallelSteps {
479
- readonly __parallel: DynamicViewStep[];
480
- }
481
- type DynamicViewStepOrParallel = DynamicViewStep | DynamicViewParallelSteps;
482
- type DynamicViewIncludeRule = {
483
- include: ElementPredicateExpression[];
484
- };
485
- type DynamicViewRule = DynamicViewIncludeRule | ViewRuleGlobalPredicateRef | ViewRuleStyle | ViewRuleGlobalStyle | ViewRuleAutoLayout;
486
- interface DynamicView<ViewIDs extends string = string, Tags extends string = string> extends BasicView<'dynamic', ViewIDs, Tags> {
487
- readonly __: 'dynamic';
488
- readonly steps: DynamicViewStepOrParallel[];
489
- readonly rules: DynamicViewRule[];
490
- }
491
- type CustomColorDefinitions = {
492
- [key: string]: ThemeColorValues;
493
- };
494
- type DeploymentViewRulePredicate = {
495
- include: ExpressionV2[];
496
- exclude?: never;
497
- } | {
498
- include?: never;
499
- exclude: ExpressionV2[];
500
- };
501
- type DeploymentViewRuleStyle = {
502
- targets: FqnExpr[];
503
- notation?: string;
504
- style: ElementStyle & {
505
- color?: Color;
506
- shape?: ElementShape;
507
- icon?: IconUrl;
508
- };
509
- };
510
- type DeploymentViewRule = DeploymentViewRulePredicate | ViewRuleAutoLayout | DeploymentViewRuleStyle;
511
- interface DeploymentView<ViewIDs extends string = string, Tags extends string = string> extends BasicView<'deployment', ViewIDs, Tags> {
512
- readonly __: 'deployment';
513
- readonly rules: DeploymentViewRule[];
514
- }
515
- type LikeC4View<ViewIDs extends string = string, Tags extends string = string> = ElementView<ViewIDs, Tags> | DynamicView<ViewIDs, Tags> | DeploymentView<ViewIDs, Tags>;
516
- type NodeId<IDs extends string = string> = Tagged<IDs, 'Fqn'>;
517
- type EdgeId = Tagged<string, 'EdgeId'>;
518
- type StepEdgeIdLiteral = `step-${number}` | `step-${number}.${number}`;
519
- type StepEdgeId = Tagged<StepEdgeIdLiteral, 'EdgeId'>;
520
- interface ComputedNode {
521
- id: NodeId;
522
- kind: string;
523
- parent: NodeId | null;
524
- /**
525
- * Reference to model element
526
- * If 1 - node id is a reference
527
- */
528
- modelRef?: 1 | Fqn;
529
- /**
530
- * Reference to deployment element
531
- * If 1 - node id is a reference
532
- */
533
- deploymentRef?: 1 | Fqn;
534
- title: string;
535
- description: string | null;
536
- technology: string | null;
537
- notation?: string;
538
- tags: NonEmptyArray<Tag> | null;
539
- links: NonEmptyArray<Link> | null;
540
- children: NodeId[];
541
- inEdges: EdgeId[];
542
- outEdges: EdgeId[];
543
- shape: ElementShape;
544
- color: Color;
545
- /**
546
- * @deprecated Use `style` instead
547
- */
548
- icon?: IconUrl;
549
- style: ElementStyle;
550
- navigateTo?: ViewId;
551
- level: number;
552
- depth?: number;
553
- /**
554
- * If this node was customized in the view
555
- */
556
- isCustomized?: boolean;
557
- }
558
- declare namespace ComputedNode {
559
- function modelRef(node: ComputedNode): Fqn | null;
560
- function deploymentRef(node: ComputedNode): Fqn | null;
561
- /**
562
- * Nodes group is a special kind of node, exisiting only in view
563
- */
564
- function isNodesGroup(node: ComputedNode): boolean;
565
- }
566
- interface ComputedEdge {
567
- id: EdgeId;
568
- parent: NodeId | null;
569
- source: NodeId;
570
- target: NodeId;
571
- label: string | null;
572
- description?: string;
573
- technology?: string;
574
- relations: RelationId[];
575
- kind?: RelationshipKind;
576
- notation?: string;
577
- notes?: string;
578
- color?: Color;
579
- line?: RelationshipLineType;
580
- head?: RelationshipArrowType;
581
- tail?: RelationshipArrowType;
582
- tags?: NonEmptyArray<Tag>;
583
- navigateTo?: ViewId;
584
- /**
585
- * If this edge is derived from custom relationship predicate
586
- */
587
- isCustomized?: boolean;
588
- /**
589
- * For layouting purposes
590
- * @default 'forward'
591
- */
592
- dir?: 'forward' | 'back' | 'both';
593
- }
594
- interface ViewWithHash {
595
- /**
596
- * Hash of the view object.
597
- * This is used to detect changes in layout
598
- */
599
- hash: string;
600
- }
601
- interface ViewWithNotation {
602
- notation?: {
603
- elements: ElementNotation[];
604
- };
605
- }
606
- interface ViewAutoLayout {
607
- direction: ViewRuleAutoLayout['direction'];
608
- rankSep?: number;
609
- nodeSep?: number;
610
- }
611
- interface ComputedElementView<ViewIDs extends string = string, Tags extends string = string> extends Omit<ElementView<ViewIDs, Tags>, 'rules' | 'docUri'>, ViewWithHash, ViewWithNotation {
612
- readonly extends?: ViewId<ViewIDs>;
613
- readonly autoLayout: ViewAutoLayout;
614
- readonly nodes: ComputedNode[];
615
- readonly edges: ComputedEdge[];
616
- rules?: never;
617
- docUri?: never;
618
- }
619
- interface ComputedDynamicView<ViewIDs extends string = string, Tags extends string = string> extends Omit<DynamicView<ViewIDs, Tags>, 'rules' | 'steps' | 'docUri'>, ViewWithHash, ViewWithNotation {
620
- readonly autoLayout: ViewAutoLayout;
621
- readonly nodes: ComputedNode[];
622
- readonly edges: ComputedEdge[];
623
- steps?: never;
624
- rules?: never;
625
- docUri?: never;
626
- }
627
- interface ComputedDeploymentView<ViewIDs extends string = string, Tags extends string = string> extends Omit<DeploymentView<ViewIDs, Tags>, 'rules' | 'docUri'>, ViewWithHash, ViewWithNotation {
628
- readonly autoLayout: ViewAutoLayout;
629
- readonly nodes: ComputedNode[];
630
- readonly edges: ComputedEdge[];
631
- rules?: never;
632
- docUri?: never;
633
- }
634
- type ComputedView<ViewIDs extends string = string, Tags extends string = string> = ComputedElementView<ViewIDs, Tags> | ComputedDynamicView<ViewIDs, Tags> | ComputedDeploymentView<ViewIDs, Tags>;
635
- declare namespace ComputedView {
636
- function isDeployment(view: ComputedView): view is ComputedDeploymentView;
637
- function isDynamic(view: ComputedView): view is ComputedDynamicView;
638
- function isElement(view: ComputedView): view is ComputedElementView;
639
- }
640
- type BBox = {
641
- x: number;
642
- y: number;
643
- width: number;
644
- height: number;
645
- };
646
- interface DiagramNode extends ComputedNode {
647
- width: number;
648
- height: number;
649
- position: Point;
650
- labelBBox: BBox;
651
- }
652
- declare namespace DiagramNode {
653
- function modelRef(node: DiagramNode): Fqn | null;
654
- function deploymentRef(node: DiagramNode): Fqn | null;
655
- /**
656
- * Nodes group is a special kind of node, exisiting only in view
657
- */
658
- function isNodesGroup(node: DiagramNode): boolean;
659
- }
660
- interface DiagramEdge extends ComputedEdge {
661
- points: NonEmptyArray<Point>;
662
- controlPoints?: NonEmptyArray<XYPoint>;
663
- labelBBox?: BBox | null;
664
- dotpos?: string;
665
- }
666
- interface DiagramView<ViewIDs extends string = string, Tags extends string = string> extends Omit<ComputedView<ViewIDs, Tags>, 'nodes' | 'edges' | 'manualLayout'> {
667
- readonly nodes: DiagramNode[];
668
- readonly edges: DiagramEdge[];
669
- readonly bounds: BBox;
670
- /**
671
- * If diagram has manual layout
672
- * But was changed and layout should be recalculated
673
- */
674
- hasLayoutDrift?: boolean;
675
- manualLayout?: never;
676
- }
677
- type ViewManualLayout = {
678
- readonly hash: string;
679
- readonly x: number;
680
- readonly y: number;
681
- readonly width: number;
682
- readonly height: number;
683
- readonly autoLayout: ViewAutoLayout;
684
- readonly nodes: Record<string, {
685
- isCompound: boolean;
686
- x: number;
687
- y: number;
688
- width: number;
689
- height: number;
690
- }>;
691
- readonly edges: Record<string, {
692
- dotpos?: string;
693
- points: NonEmptyArray<Point>;
694
- controlPoints?: NonEmptyArray<XYPoint>;
695
- labelBBox?: BBox;
696
- }>;
697
- };
698
-
699
- type RelationId = Tagged<string, 'RelationID'>;
700
- type RelationshipKind<Kinds extends string = string> = Tagged<Kinds, 'RelationshipKind'>;
701
- type RelationshipLineType = 'dashed' | 'solid' | 'dotted';
702
- type RelationshipArrowType = 'none' | 'normal' | 'onormal' | 'dot' | 'odot' | 'diamond' | 'odiamond' | 'crow' | 'open' | 'vee';
703
- interface AbstractRelation {
704
- readonly id: RelationId;
705
- readonly title?: string;
706
- readonly description?: string;
707
- readonly technology?: string;
708
- readonly tags?: NonEmptyArray<Tag> | null;
709
- readonly kind?: RelationshipKind;
710
- readonly color?: Color;
711
- readonly line?: RelationshipLineType;
712
- readonly head?: RelationshipArrowType;
713
- readonly tail?: RelationshipArrowType;
714
- readonly links?: NonEmptyArray<Link> | null;
715
- readonly navigateTo?: ViewId;
716
- readonly metadata?: {
717
- [key: string]: string;
718
- };
719
- }
720
- interface ModelRelation extends AbstractRelation {
721
- readonly source: Fqn;
722
- readonly target: Fqn;
723
- readonly title: string;
724
- }
725
- interface RelationshipKindSpecification {
726
- readonly technology?: string;
727
- readonly notation?: string;
728
- readonly color?: Color;
729
- readonly line?: RelationshipLineType;
730
- readonly head?: RelationshipArrowType;
731
- readonly tail?: RelationshipArrowType;
732
- }
733
-
734
- type DeploymentNodeKind<Kinds extends string = string> = Tagged<Kinds, 'DeploymentNodeKind'>;
735
- type DeploymentElementStyle = ElementStyle & {
736
- readonly icon?: IconUrl;
737
- readonly shape?: ElementShape;
738
- readonly color?: Color;
739
- };
740
- interface DeploymentNodeKindSpecification {
741
- readonly technology?: string;
742
- readonly notation?: string;
743
- readonly style: DeploymentElementStyle;
744
- }
745
- interface DeploymentNode {
746
- readonly id: Fqn;
747
- readonly kind: DeploymentNodeKind;
748
- readonly title: string;
749
- readonly description?: string | null;
750
- readonly technology?: string | null;
751
- readonly tags?: NonEmptyArray<Tag> | null;
752
- readonly links?: NonEmptyArray<Link> | null;
753
- readonly style?: DeploymentElementStyle;
754
- readonly notation?: string;
755
- readonly metadata?: Record<string, string>;
756
- }
757
- interface DeployedInstance {
758
- /**
759
- * Format: `<DeploymentNode Fqn>.<Instance Id>`
760
- * i.e parent fqn is deployment target
761
- */
762
- readonly id: Fqn;
763
- readonly element: Fqn;
764
- readonly title?: string;
765
- readonly description?: string | null;
766
- readonly technology?: string | null;
767
- readonly kind?: string | null;
768
- readonly tags?: NonEmptyArray<Tag> | null;
769
- readonly links?: NonEmptyArray<Link> | null;
770
- readonly style?: DeploymentElementStyle;
771
- readonly notation?: string;
772
- readonly metadata?: Record<string, string>;
773
- }
774
- type DeploymentElement = Simplify<MergeExclusive<DeploymentNode, DeployedInstance>>;
775
- declare namespace DeploymentElement {
776
- const isDeploymentNode: (el: DeploymentElement) => el is DeploymentNode;
777
- const isInstance: (el: DeploymentElement) => el is DeployedInstance;
778
- }
779
- type PredicateSelector = 'children' | 'expanded' | 'descendants';
780
- interface DeploymentRef {
781
- readonly id: Fqn;
782
- readonly element?: Fqn;
783
- }
784
- /**
785
- * NOTE:
786
- */
787
- interface DeploymentRelation extends AbstractRelation {
788
- readonly id: RelationId;
789
- readonly source: DeploymentRef;
790
- readonly target: DeploymentRef;
791
- }
792
-
793
- /**
794
- * Represents a LikeC4 model with customizable type parameters,
795
- * parsed from DSL or result from Builder
796
- *
797
- * !IMPORTANT: This is a low-level type, use `LikeC4Model` instead.
798
- * !NOTE: Views are not computed yet.
799
- *
800
- * @typeParam ElementKinds - Types of elements in the model (defaults to string)
801
- * @typeParam RelationKinds - Types of relationships (defaults to string)
802
- * @typeParam Tags - Types of tags that can be applied (defaults to string)
803
- * @typeParam Fqns - Fully Qualified Names for elements (defaults to string)
804
- * @typeParam Views - Types of views in the model (defaults to string)
805
- * @typeParam DeploymentFqns - Fully Qualified Names for deployment nodes (defaults to string)
806
- */
807
- 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> {
808
- __?: never;
809
- specification: {
810
- tags: Tag<Tags>[];
811
- elements: Record<ElementKinds, ElementKindSpecification>;
812
- deployments: Record<DeploymentNodeKind, DeploymentNodeKindSpecification>;
813
- relationships: Record<RelationKinds, RelationshipKindSpecification>;
814
- };
815
- elements: Record<Fqns, TypedElement<Fqns, ElementKinds, Tags>>;
816
- relations: Record<RelationId, ModelRelation>;
817
- globals: ModelGlobals;
818
- views: Record<Views, LikeC4View<Views, Tags>>;
819
- /**
820
- * Deployment Model.
821
- */
822
- deployments: {
823
- elements: Record<DeploymentFqns, DeploymentElement>;
824
- relations: Record<RelationId, DeploymentRelation>;
825
- };
826
- }
827
- type AnyParsedLikeC4Model = ParsedLikeC4Model<any, any, any, any, any, any>;
828
- /**
829
- * Hook to get types from dump
830
- */
831
- type LikeC4ModelDump = {
832
- elements: {
833
- [kind: string]: object;
834
- };
835
- deployments: {
836
- elements: {
837
- [kind: string]: object;
838
- };
839
- };
840
- views: {
841
- [kind: string]: object;
842
- };
843
- };
844
- /**
845
- * Same as {@link ParsedLikeC4Model}, but with computed views or layouted views.
846
- */
847
- interface GenericLikeC4Model<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' | '__'> {
848
- __?: T;
849
- views: Record<Views, ComputedView<Views> | DiagramView<Views>>;
850
- }
851
- interface ComputedLikeC4Model<Fqns extends string = string, DeploymentFqns extends string = string, Views extends string = string, Tags extends string = string> extends Omit<GenericLikeC4Model<Fqns, DeploymentFqns, Views, Tags, 'computed'>, 'views'> {
852
- views: Record<Views, ComputedView<Views>>;
853
- }
854
- interface LayoutedLikeC4Model<Fqns extends string = string, DeploymentFqns extends string = string, Views extends string = string, Tags extends string = string> extends Omit<GenericLikeC4Model<Fqns, DeploymentFqns, Views, Tags, 'layouted'>, 'views'> {
855
- __: 'layouted';
856
- views: Record<Views, DiagramView<Views, Tags>>;
857
- }
858
-
859
- type ComputeViewResult<V extends ComputedView = ComputedView> = {
860
- isSuccess: true;
861
- error?: undefined;
862
- view: V;
863
- } | {
864
- isSuccess: false;
865
- error: Error;
866
- view: undefined;
867
- };
868
-
869
- type IncomingFilter = 'all' | 'direct' | 'to-descendants';
870
- type OutgoingFilter = 'all' | 'direct' | 'from-descendants';
871
- type WithId<Id> = {
872
- id: Id;
873
- };
874
- type WithViews<Id extends string, ViewType> = {
875
- views: Record<Id, ViewType>;
876
- };
877
- type AnyAux = Aux<string, string, string, any>;
878
- /**
879
- * Auxilary type to keep track
880
- */
881
- interface Aux<Element extends string, Deployment extends string, View extends string, ViewType> {
882
- Element: Element;
883
- Deployment: Deployment;
884
- View: View;
885
- Fqn: IsStringLiteral<Element> extends true ? Fqn<Element> : Fqn;
886
- ElementOrFqn: Element | WithId<this['Fqn']>;
887
- DeploymentFqn: IsStringLiteral<Deployment> extends true ? Fqn<Deployment> : Fqn;
888
- DeploymentOrFqn: Deployment | WithId<this['DeploymentFqn']>;
889
- ViewId: IsStringLiteral<View> extends true ? ViewId<View> : ViewId;
890
- ViewType: ViewType;
891
- RelationId: RelationId;
892
- NodeId: NodeId;
893
- NodeIdLiteral: string;
894
- EdgeId: EdgeId;
895
- EdgeIdLiteral: string;
896
- NodeOrId: LiteralUnion<this['NodeIdLiteral'], string> | WithId<this['NodeId']>;
897
- EdgeOrId: LiteralUnion<this['EdgeIdLiteral'], string> | WithId<this['EdgeId']>;
898
- Model: Simplify<Omit<GenericLikeC4Model, 'views'> & WithViews<this['ViewId'], ViewType>>;
899
- }
900
- declare namespace Aux {
901
- type FromParsed<M> = M extends ParsedLikeC4Model ? Aux<KeysOf<M['elements']>, KeysOf<M['deployments']['elements']>, KeysOf<M['views']>, ComputedView<ViewId<KeysOf<M['views']>>, string>> : never;
902
- type FromModel<M> = M extends GenericLikeC4Model ? 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;
903
- type FromDump<M> = M extends LikeC4ModelDump ? Aux<KeysOf<M['elements']>, KeysOf<M['deployments']['elements']>, KeysOf<M['views']>, DiagramView<ViewId<KeysOf<M['views']>>, string>> : never;
904
- }
905
-
906
- type NodesIterator<M extends AnyAux, V extends ComputedView | DiagramView> = IteratorLike<NodeModel<M, V>>;
907
- declare namespace NodeModel {
908
- interface WithParent<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
909
- parent: NodeModel<M, V>;
910
- }
911
- interface WithElement<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
912
- kind: ElementKind;
913
- element: ElementModel<M>;
914
- }
915
- interface WithDeploymentElement<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
916
- kind: DeploymentNodeKind;
917
- deployment: DeploymentElementModel<M>;
918
- }
919
- interface WithDeployedInstance<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
920
- kind: 'instance';
921
- element: ElementModel<M>;
922
- deployment: DeployedInstanceModel<M>;
923
- }
924
- interface IsGroup<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
925
- kind: typeof ElementKind.Group;
926
- element: null;
927
- deployment: null;
928
- }
929
- }
930
- declare class NodeModel<M extends AnyAux, V extends ComputedView | DiagramView = M['ViewType']> {
931
- readonly $view: LikeC4ViewModel<M, V>;
932
- readonly $node: V['nodes'][number];
933
- constructor($view: LikeC4ViewModel<M, V>, $node: V['nodes'][number]);
934
- get id(): NodeId;
935
- get title(): string;
936
- get kind(): ElementKind | DeploymentNodeKind | typeof ElementKind.Group | 'instance';
937
- get description(): string | null;
938
- get technology(): string | null;
939
- get parent(): NodeModel<M, V> | null;
940
- get element(): ElementModel<M> | null;
941
- get deployment(): DeploymentElementModel<M> | null;
942
- get shape(): ElementShape;
943
- get color(): Color;
944
- get tags(): ReadonlyArray<Tag>;
945
- get links(): ReadonlyArray<Link>;
946
- get navigateTo(): LikeC4ViewModel<M> | null;
947
- /**
948
- * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
949
- * (from closest to root)
950
- */
951
- ancestors(): NodesIterator<M, V>;
952
- children(): NodesIterator<M, V>;
953
- sublings(): NodesIterator<M, V>;
954
- incoming(filter?: IncomingFilter): EdgesIterator<M, V>;
955
- incomers(filter?: IncomingFilter): NodesIterator<M, V>;
956
- outgoing(filter?: OutgoingFilter): EdgesIterator<M, V>;
957
- outgoers(filter?: OutgoingFilter): NodesIterator<M, V>;
958
- isDiagramNode(): this is NodeModel<M, DiagramView>;
959
- hasChildren(): boolean;
960
- hasParent(): this is NodeModel.WithParent<M, V>;
961
- /**
962
- * Check if this node references to logical model element.
963
- */
964
- hasElement(): this is NodeModel.WithElement<M, V>;
965
- /**
966
- * Check if this node references to deployment element (Node or Instance).
967
- */
968
- hasDeployment(): this is NodeModel.WithDeploymentElement<M, V>;
969
- /**
970
- * Check if this node references to deployed instance
971
- * Deployed instance always references to element and deployment element.
972
- */
973
- hasDeployedInstance(): this is NodeModel.WithDeployedInstance<M, V>;
974
- isGroup(): this is NodeModel.IsGroup<M, V>;
975
- }
976
-
977
- type EdgesIterator<M extends AnyAux, V extends ComputedView | DiagramView> = IteratorLike<EdgeModel<M, V>>;
978
- declare class EdgeModel<M extends AnyAux, V extends ComputedView | DiagramView = M['ViewType']> {
979
- readonly view: LikeC4ViewModel<M, V>;
980
- readonly $edge: V['edges'][number];
981
- readonly source: NodeModel<M, V>;
982
- readonly target: NodeModel<M, V>;
983
- constructor(view: LikeC4ViewModel<M, V>, $edge: V['edges'][number], source: NodeModel<M, V>, target: NodeModel<M, V>);
984
- get id(): M['EdgeId'];
985
- get parent(): NodeModel<M, V> | null;
986
- get label(): string | null;
987
- get description(): string | null;
988
- get technology(): string | null;
989
- hasParent(): this is EdgeModel.WithParent<M, V>;
990
- get tags(): ReadonlyArray<Tag>;
991
- get stepNumber(): number | null;
992
- get navigateTo(): LikeC4ViewModel<M> | null;
993
- isStep(): this is EdgeModel.StepEdge<M, ComputedDynamicView>;
994
- relationships(type: 'model'): IteratorLike<RelationshipModel<M>>;
995
- relationships(type: 'deployment'): IteratorLike<DeploymentRelationModel<M>>;
996
- relationships(type?: 'model' | 'deployment'): IteratorLike<LikeC4Model.AnyRelation<M>>;
997
- includesRelation(rel: M['RelationId']): boolean;
998
- }
999
- declare namespace EdgeModel {
1000
- interface StepEdge<M extends AnyAux, V extends ComputedView | DiagramView> extends EdgeModel<M, V> {
1001
- id: StepEdgeId;
1002
- stepNumber: number;
1003
- }
1004
- interface WithParent<M extends AnyAux, V extends ComputedView | DiagramView> extends EdgeModel<M, V> {
1005
- parent: NodeModel<M, V>;
1006
- }
1007
- }
1008
-
1009
- type ViewsIterator<M extends AnyAux> = IteratorLike<LikeC4ViewModel<M>>;
1010
- declare class LikeC4ViewModel<M extends AnyAux, V extends ComputedView | DiagramView = M['ViewType']> {
1011
- #private;
1012
- readonly $model: LikeC4Model<M>;
1013
- readonly $view: V;
1014
- constructor($model: LikeC4Model<M>, $view: V);
1015
- get __(): NonNullable<M['ViewType']['__']>;
1016
- get id(): M['ViewId'];
1017
- get title(): string | null;
1018
- get tags(): ReadonlyArray<Tag>;
1019
- get links(): ReadonlyArray<Link>;
1020
- get viewOf(): ElementModel<M> | null;
1021
- /**
1022
- * All tags from nodes and edges.
1023
- */
1024
- get includedTags(): ReadonlyArray<Tag>;
1025
- roots(): NodesIterator<M, V>;
1026
- /**
1027
- * Iterate over all nodes that have children.
1028
- */
1029
- compounds(): NodesIterator<M, V>;
1030
- /**
1031
- * Get node by id.
1032
- * @throws Error if node is not found.
1033
- */
1034
- node(node: M['NodeOrId']): NodeModel<M, V>;
1035
- /**
1036
- * Find node by id.
1037
- */
1038
- findNode(node: M['NodeOrId']): NodeModel<M, V> | null;
1039
- /**
1040
- * Iterate over all nodes.
1041
- */
1042
- nodes(): NodesIterator<M, V>;
1043
- /**
1044
- * Find edge by id.
1045
- * @param edge Edge or id
1046
- * @returns EdgeModel
1047
- */
1048
- edge(edge: M['EdgeOrId']): EdgeModel<M, V>;
1049
- findEdge(edge: M['EdgeOrId']): EdgeModel<M, V> | null;
1050
- /**
1051
- * Iterate over all edges.
1052
- */
1053
- edges(): EdgesIterator<M, V>;
1054
- /**
1055
- * Iterate over all edges.
1056
- */
1057
- edgesWithRelation(relation: M['RelationId']): EdgesIterator<M, V>;
1058
- /**
1059
- * Nodes that have references to elements from logical model.
1060
- */
1061
- elements(): IteratorLike<NodeModel.WithElement<M, V>>;
1062
- includesElement(elementId: M['Element']): boolean;
1063
- includesDeployment(deploymentId: M['Deployment']): boolean;
1064
- includesRelation(relationId: M['RelationId']): boolean;
1065
- /**
1066
- * Below are type guards.
1067
- */
1068
- isComputed(): this is LikeC4ViewModel<M, ComputedView>;
1069
- isDiagram(): this is LikeC4ViewModel<M, DiagramView>;
1070
- isElementView(): this is LikeC4ViewModel<M, ComputedElementView>;
1071
- isDeploymentView(): this is LikeC4ViewModel<M, ComputedDeploymentView>;
1072
- isDynamicView(): this is LikeC4ViewModel<M, ComputedDynamicView>;
1073
- }
1074
-
1075
- type RelationshipsIterator<M extends AnyAux> = IteratorLike<RelationshipModel<M>>;
1076
- declare class RelationshipModel<M extends AnyAux = AnyAux> {
1077
- readonly model: LikeC4Model<M>;
1078
- readonly $relationship: ModelRelation;
1079
- readonly source: ElementModel<M>;
1080
- readonly target: ElementModel<M>;
1081
- /**
1082
- * Common ancestor of the source and target elements.
1083
- * Represents the boundary of the Relation.
1084
- */
1085
- readonly boundary: ElementModel<M> | null;
1086
- constructor(model: LikeC4Model<M>, $relationship: ModelRelation);
1087
- get id(): M['RelationId'];
1088
- get expression(): string;
1089
- get title(): string | null;
1090
- get technology(): string | null;
1091
- get description(): string | null;
1092
- get navigateTo(): LikeC4ViewModel<M> | null;
1093
- get tags(): ReadonlyArray<Tag>;
1094
- get kind(): string | null;
1095
- get links(): ReadonlyArray<Link>;
1096
- /**
1097
- * Iterate over all views that include this relationship.
1098
- */
1099
- views(): ViewsIterator<M>;
1100
- }
1101
-
1102
- declare class LikeC4Model<M extends AnyAux = LikeC4Model.Any> {
1103
- #private;
1104
- readonly $model: M['Model'];
1105
- /**
1106
- * Only available in compile tim
1107
- */
1108
- readonly Aux: M;
1109
- readonly deployment: LikeC4DeploymentModel<M>;
1110
- /**
1111
- * Computes views from the parsed model
1112
- * Creates a new LikeC4Model instance from a parsed model.
1113
- *
1114
- * May throw an error if the model is invalid.
1115
- *
1116
- * @typeParam M - The type of the parsed LikeC4 model, must extend ParsedLikeC4Model
1117
- * @param parsed - The parsed LikeC4 model to compute from
1118
- * @returns A new LikeC4Model instance with computed relationships and structure
1119
- */
1120
- static compute<const M extends AnyParsedLikeC4Model>(parsed: M): LikeC4Model<Aux.FromParsed<M>>;
1121
- /**
1122
- * Creates a function that computes a view using the data from the model.
1123
- *
1124
- * @example
1125
- * const compute = LikeC4Model.makeCompute(parsedModel);
1126
- * const result = compute(viewSource);
1127
- */
1128
- static makeCompute<M extends AnyParsedLikeC4Model>(parsed: M): (viewsource: LikeC4View) => ComputeViewResult;
1129
- /**
1130
- * Creates a new LikeC4Model instance from the provided model data.
1131
- *
1132
- * @typeParam M - Type parameter constrained to AnyLikeC4Model
1133
- * @param model - The model data to create a LikeC4Model from
1134
- * @returns A new LikeC4Model instance with the type derived from the input model
1135
- */
1136
- static create<const M extends GenericLikeC4Model>(model: M): LikeC4Model<Aux.FromModel<M>>;
1137
- /**
1138
- * Creates a new LikeC4Model instance from a model dump.
1139
- *
1140
- * @typeParam M - A constant type parameter extending LikeC4ModelDump
1141
- * @param dump - The model dump to create the instance from
1142
- * @returns A new LikeC4Model instance with types inferred from the dump
1143
- */
1144
- static fromDump<const M extends LikeC4ModelDump>(dump: M): LikeC4Model<Aux.FromDump<M>>;
1145
- private constructor();
1146
- get type(): 'computed' | 'layouted';
1147
- element(el: M['ElementOrFqn']): ElementModel<M>;
1148
- findElement(el: LiteralUnion<M['Element'], string>): ElementModel<M> | null;
1149
- /**
1150
- * Returns the root elements of the model.
1151
- */
1152
- roots(): ElementsIterator<M>;
1153
- /**
1154
- * Returns all elements in the model.
1155
- */
1156
- elements(): ElementsIterator<M>;
1157
- /**
1158
- * Returns all relationships in the model.
1159
- */
1160
- relationships(): RelationshipsIterator<M>;
1161
- /**
1162
- * Returns a specific relationship by its ID.
1163
- * If the relationship is not found in the model, it will be searched in the deployment model.
1164
- * Search can be limited to the model or deployment model only.
1165
- */
1166
- relationship(id: M['RelationId'], type: 'model'): RelationshipModel<M>;
1167
- relationship(id: M['RelationId'], type: 'deployment'): DeploymentRelationModel<M>;
1168
- relationship(id: M['RelationId'], type?: 'model' | 'deployment'): RelationshipModel<M> | DeploymentRelationModel<M>;
1169
- findRelationship(id: LiteralUnion<M['RelationId'], string>, type: 'model'): RelationshipModel<M> | null;
1170
- findRelationship(id: LiteralUnion<M['RelationId'], string>, type: 'deployment'): DeploymentRelationModel<M> | null;
1171
- findRelationship(id: LiteralUnion<M['RelationId'], string>, type?: 'model' | 'deployment'): RelationshipModel<M> | DeploymentRelationModel<M> | null;
1172
- /**
1173
- * Returns all views in the model.
1174
- */
1175
- views(): IteratorLike<LikeC4ViewModel<M>>;
1176
- /**
1177
- * Returns a specific view by its ID.
1178
- */
1179
- view(viewId: M['View']): LikeC4ViewModel<M>;
1180
- findView(viewId: M['View']): LikeC4ViewModel<M>;
1181
- /**
1182
- * Returns the parent element of given element.
1183
- * @see ancestors
1184
- */
1185
- parent(element: M['ElementOrFqn']): ElementModel<M> | null;
1186
- /**
1187
- * Get all children of the element (only direct children),
1188
- * @see descendants
1189
- */
1190
- children(element: M['ElementOrFqn']): ReadonlySet<ElementModel<M>>;
1191
- /**
1192
- * Get all sibling (i.e. same parent)
1193
- */
1194
- siblings(element: M['ElementOrFqn']): ElementsIterator<M>;
1195
- /**
1196
- * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
1197
- * (from closest to root)
1198
- */
1199
- ancestors(element: M['ElementOrFqn']): ElementsIterator<M>;
1200
- /**
1201
- * Get all descendant elements (i.e. children, children’s children, etc.)
1202
- */
1203
- descendants(element: M['ElementOrFqn']): ElementsIterator<M>;
1204
- /**
1205
- * Incoming relationships to the element and its descendants
1206
- * @see incomers
1207
- */
1208
- incoming(element: M['ElementOrFqn'], filter?: IncomingFilter): RelationshipsIterator<M>;
1209
- /**
1210
- * Outgoing relationships from the element and its descendants
1211
- * @see outgoers
1212
- */
1213
- outgoing(element: M['ElementOrFqn'], filter?: OutgoingFilter): RelationshipsIterator<M>;
1214
- globals(): ModelGlobals;
1215
- private addElement;
1216
- private addRelation;
1217
- }
1218
- declare namespace LikeC4Model {
1219
- type Any = Aux<string, string, string, ComputedView | DiagramView>;
1220
- type Element<M extends AnyAux = Any> = ElementModel<M>;
1221
- type Relation<M extends AnyAux = Any> = RelationshipModel<M>;
1222
- type AnyRelation<M extends AnyAux = Any> = RelationshipModel<M> | DeploymentRelationModel<M>;
1223
- type View<M extends AnyAux = Any, V extends ComputedView | DiagramView = M['ViewType']> = LikeC4ViewModel<M, V>;
1224
- type Node<M extends AnyAux = Any, V extends ComputedView | DiagramView = M['ViewType']> = NodeModel<M, V>;
1225
- type Edge<M extends AnyAux = Any, V extends ComputedView | DiagramView = M['ViewType']> = EdgeModel<M, V>;
1226
- type DeploymentModel<M extends AnyAux = AnyAux> = LikeC4DeploymentModel<M>;
1227
- type Deployment<M extends AnyAux = AnyAux> = DeploymentElementModel<M>;
1228
- type DeploymentNode<M extends AnyAux = AnyAux> = DeploymentNodeModel<M>;
1229
- type DeployedInstance<M extends AnyAux = AnyAux> = DeployedInstanceModel<M>;
1230
- type Typed<Elements extends string = string, Deployments extends string = string, Views extends string = string, ViewType = DiagramView<Views> | ComputedView<Views>> = Aux<Elements, Deployments, Views, ViewType>;
1231
- type Computed<Elements extends string = string, Deployments extends string = string, Views extends string = string> = LikeC4Model<Typed<Elements, Deployments, Views, ComputedView<Views>>>;
1232
- type Layouted<Elements extends string = string, Deployments extends string = string, Views extends string = string> = LikeC4Model<Typed<Elements, Deployments, Views, DiagramView<Views>>>;
1233
- }
1234
-
1235
- declare class LikeC4DeploymentModel<M extends AnyAux = AnyAux> {
1236
- #private;
1237
- readonly $model: LikeC4Model<M>;
1238
- readonly $deployments: GenericLikeC4Model['deployments'];
1239
- constructor($model: LikeC4Model<M>, $deployments: GenericLikeC4Model['deployments']);
1240
- element(el: M['DeploymentOrFqn']): DeploymentElementModel<M>;
1241
- findElement(el: M['Deployment']): DeploymentElementModel<M> | null;
1242
- node(el: M['DeploymentOrFqn']): DeploymentNodeModel<M>;
1243
- findNode(el: M['Deployment']): DeploymentNodeModel<M> | null;
1244
- instance(el: M['DeploymentOrFqn']): DeployedInstanceModel<M>;
1245
- findInstance(el: M['Deployment']): DeployedInstanceModel<M> | null;
1246
- /**
1247
- * Returns the root elements of the model.
1248
- */
1249
- roots(): DeploymentNodesIterator<M>;
1250
- /**
1251
- * Returns all elements in the model.
1252
- */
1253
- elements(): DeploymentElementsIterator<M>;
1254
- /**
1255
- * Returns all elements in the model.
1256
- */
1257
- nodes(): DeploymentNodesIterator<M>;
1258
- instances(): DeployedInstancesIterator<M>;
1259
- /**
1260
- * Iterate over all instances of the given logical element.
1261
- */
1262
- instancesOf(element: M['ElementOrFqn']): DeployedInstancesIterator<M>;
1263
- deploymentRef(ref: DeploymentRef): DeploymentElementModel<M> | NestedElementOfDeployedInstanceModel<M>;
1264
- /**
1265
- * Returns all relationships in the model.
1266
- */
1267
- relationships(): IteratorLike<DeploymentRelationModel<M>>;
1268
- /**
1269
- * Returns a specific relationship by its ID.
1270
- */
1271
- relationship(id: M['RelationId']): DeploymentRelationModel<M>;
1272
- findRelationship(id: LiteralUnion<M['RelationId'], string>): DeploymentRelationModel<M> | null;
1273
- /**
1274
- * Returns all deployment views in the model.
1275
- */
1276
- views(): IteratorLike<LikeC4ViewModel<M, ComputedDeploymentView>>;
1277
- /**
1278
- * Returns the parent element of given element.
1279
- * @see ancestors
1280
- */
1281
- parent(element: M['DeploymentOrFqn']): DeploymentNodeModel<M> | null;
1282
- /**
1283
- * Get all children of the element (only direct children),
1284
- * @see descendants
1285
- */
1286
- children(element: M['DeploymentOrFqn']): ReadonlySet<DeploymentElementModel<M>>;
1287
- /**
1288
- * Get all sibling (i.e. same parent)
1289
- */
1290
- siblings(element: M['DeploymentOrFqn']): DeploymentElementsIterator<M>;
1291
- /**
1292
- * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
1293
- * (from closest to root)
1294
- */
1295
- ancestors(element: M['DeploymentOrFqn']): DeploymentNodesIterator<M>;
1296
- /**
1297
- * Get all descendant elements (i.e. children, children’s children, etc.)
1298
- */
1299
- descendants(element: M['DeploymentOrFqn'], sort?: 'asc' | 'desc'): DeploymentElementsIterator<M>;
1300
- /**
1301
- * Incoming relationships to the element and its descendants
1302
- * @see incomers
1303
- */
1304
- incoming(element: M['DeploymentOrFqn'], filter?: IncomingFilter): IteratorLike<DeploymentRelationModel<M>>;
1305
- /**
1306
- * Outgoing relationships from the element and its descendants
1307
- * @see outgoers
1308
- */
1309
- outgoing(element: M['DeploymentOrFqn'], filter?: OutgoingFilter): IteratorLike<DeploymentRelationModel<M>>;
1310
- private addElement;
1311
- private addRelation;
1312
- }
1313
-
1314
- type DeploymentElementsIterator<M extends AnyAux> = IteratorLike<DeploymentNodeModel<M> | DeployedInstanceModel<M>>;
1315
- type DeployedInstancesIterator<M extends AnyAux> = IteratorLike<DeployedInstanceModel<M>>;
1316
- type DeploymentNodesIterator<M extends AnyAux> = IteratorLike<DeploymentNodeModel<M>>;
1317
- type DeploymentElementModel<M extends AnyAux = AnyAux> = DeploymentNodeModel<M> | DeployedInstanceModel<M>;
1318
- declare abstract class AbstractDeploymentElementModel<M extends AnyAux = AnyAux> {
1319
- abstract readonly id: M['DeploymentFqn'];
1320
- abstract readonly parent: DeploymentNodeModel<M> | null;
1321
- abstract readonly title: string;
1322
- abstract readonly hierarchyLevel: number;
1323
- abstract readonly $model: LikeC4DeploymentModel<M>;
1324
- abstract readonly $node: DeploymentNode | DeployedInstance;
1325
- get style(): SetRequired<DeploymentElementStyle, 'shape' | 'color'>;
1326
- get shape(): ElementShape;
1327
- get color(): ThemeColor;
1328
- get tags(): ReadonlyArray<Tag>;
1329
- get kind(): DeploymentNodeKind | string | null;
1330
- get description(): string | null;
1331
- get technology(): string | null;
1332
- get links(): ReadonlyArray<Link>;
1333
- /**
1334
- * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
1335
- * (from closest to root)
1336
- */
1337
- ancestors(): DeploymentNodesIterator<M>;
1338
- /**
1339
- * Returns the common ancestor of this element and another element.
1340
- */
1341
- commonAncestor(another: DeploymentElementModel<M>): DeploymentNodeModel<M> | null;
1342
- /**
1343
- * Get all sibling (i.e. same parent)
1344
- */
1345
- siblings(): DeploymentElementsIterator<M>;
1346
- /**
1347
- * Check if the element is a sibling of another element
1348
- */
1349
- isSibling(other: DeploymentElementModel<M>): boolean;
1350
- /**
1351
- * Resolve siblings of the element and its ancestors
1352
- * (from closest to root)
1353
- */
1354
- ascendingSiblings(): DeploymentElementsIterator<M>;
1355
- /**
1356
- * Resolve siblings of the element and its ancestors
1357
- * (from root to closest)
1358
- */
1359
- descendingSiblings(): DeploymentElementsIterator<M>;
1360
- incoming(filter?: IncomingFilter): IteratorLike<DeploymentRelationModel<M>>;
1361
- outgoing(filter?: OutgoingFilter): IteratorLike<DeploymentRelationModel<M>>;
1362
- incomers(filter?: IncomingFilter): IteratorLike<DeploymentRelationEndpoint<M>>;
1363
- outgoers(filter?: OutgoingFilter): IteratorLike<DeploymentRelationEndpoint<M>>;
1364
- /**
1365
- * Iterate over all views that include this deployment element.
1366
- */
1367
- views(): IteratorLike<LikeC4ViewModel<M, ComputedDeploymentView>>;
1368
- isDeploymentNode(): this is DeploymentNodeModel<M>;
1369
- isInstance(): this is DeployedInstanceModel<M>;
1370
- abstract outgoingModelRelationships(): RelationshipsIterator<M>;
1371
- abstract incomingModelRelationships(): RelationshipsIterator<M>;
1372
- protected cachedOutgoing: RelationshipsAccum<M> | null;
1373
- protected cachedIncoming: RelationshipsAccum<M> | null;
1374
- get allOutgoing(): RelationshipsAccum<M>;
1375
- get allIncoming(): RelationshipsAccum<M>;
1376
- }
1377
- declare class DeploymentNodeModel<M extends AnyAux = AnyAux> extends AbstractDeploymentElementModel<M> {
1378
- readonly $model: LikeC4DeploymentModel<M>;
1379
- readonly $node: DeploymentNode;
1380
- id: M['DeploymentFqn'];
1381
- title: string;
1382
- hierarchyLevel: number;
1383
- constructor($model: LikeC4DeploymentModel<M>, $node: DeploymentNode);
1384
- get parent(): DeploymentNodeModel<M> | null;
1385
- get kind(): DeploymentNodeKind;
1386
- children(): ReadonlySet<DeploymentElementModel<M>>;
1387
- descendants(sort?: 'asc' | 'desc'): DeploymentElementsIterator<M>;
1388
- isDeploymentNode(): this is DeploymentNodeModel<M>;
1389
- /**
1390
- * Iterate over all instances nested in this deployment node.
1391
- */
1392
- instances(): DeployedInstancesIterator<M>;
1393
- /**
1394
- * Returns deployed instance inside this deployment node
1395
- * if only there are no more instances
1396
- */
1397
- onlyOneInstance(): DeployedInstanceModel<M> | null;
1398
- /**
1399
- * Cached result of relationships from instances
1400
- */
1401
- private _relationshipsFromInstances;
1402
- private relationshipsFromInstances;
1403
- /**
1404
- * We return only relationships that are not already present in nested instances
1405
- */
1406
- outgoingModelRelationships(): RelationshipsIterator<M>;
1407
- /**
1408
- * We return only relationships that are not already present in nested instances
1409
- */
1410
- incomingModelRelationships(): RelationshipsIterator<M>;
1411
- /**
1412
- * Returns an iterator of relationships between nested instances
1413
- */
1414
- internalModelRelationships(): ReadonlySet<RelationshipModel<M>>;
1415
- }
1416
- declare class DeployedInstanceModel<M extends AnyAux = AnyAux> extends AbstractDeploymentElementModel<M> {
1417
- readonly $model: LikeC4DeploymentModel<M>;
1418
- readonly $instance: DeployedInstance;
1419
- readonly element: ElementModel<M>;
1420
- readonly id: M['DeploymentFqn'];
1421
- readonly title: string;
1422
- readonly hierarchyLevel: number;
1423
- constructor($model: LikeC4DeploymentModel<M>, $instance: DeployedInstance, element: ElementModel<M>);
1424
- get $node(): DeployedInstance;
1425
- get parent(): DeploymentNodeModel<M>;
1426
- get style(): SetRequired<DeploymentElementStyle, 'shape' | 'color'>;
1427
- get shape(): ElementShape;
1428
- get color(): ThemeColor;
1429
- get tags(): ReadonlyArray<Tag>;
1430
- get kind(): string | null;
1431
- get description(): string | null;
1432
- get technology(): string | null;
1433
- get links(): ReadonlyArray<Link>;
1434
- isInstance(): this is DeployedInstanceModel<M>;
1435
- outgoingModelRelationships(): RelationshipsIterator<M>;
1436
- incomingModelRelationships(): RelationshipsIterator<M>;
1437
- /**
1438
- * Iterate over all views that include this instance.
1439
- * (Some views may include the parent deployment node instead of the instance.)
1440
- */
1441
- views(): IteratorLike<LikeC4ViewModel<M, ComputedDeploymentView>>;
1442
- }
1443
- declare class NestedElementOfDeployedInstanceModel<M extends AnyAux> {
1444
- readonly instance: DeployedInstanceModel<M>;
1445
- readonly element: ElementModel<M>;
1446
- constructor(instance: DeployedInstanceModel<M>, element: ElementModel<M>);
1447
- get id(): M['DeploymentFqn'];
1448
- get style(): SetRequired<DeploymentElementStyle, 'shape' | 'color'>;
1449
- get shape(): ElementShape;
1450
- get color(): ThemeColor;
1451
- get title(): string;
1452
- get description(): string | null;
1453
- get technology(): string | null;
1454
- isDeploymentNode(): this is DeploymentNodeModel<M>;
1455
- isInstance(): this is DeployedInstanceModel<M>;
1456
- }
1457
- type DeploymentRelationEndpoint<M extends AnyAux> = DeploymentElementModel<M> | NestedElementOfDeployedInstanceModel<M>;
1458
- declare class DeploymentRelationModel<M extends AnyAux = AnyAux> {
1459
- readonly $model: LikeC4DeploymentModel<M>;
1460
- readonly $relationship: DeploymentRelation;
1461
- boundary: DeploymentNodeModel<M> | null;
1462
- source: DeploymentRelationEndpoint<M>;
1463
- target: DeploymentRelationEndpoint<M>;
1464
- constructor($model: LikeC4DeploymentModel<M>, $relationship: DeploymentRelation);
1465
- get id(): M['RelationId'];
1466
- get expression(): string;
1467
- get title(): string | null;
1468
- get technology(): string | null;
1469
- get description(): string | null;
1470
- get tags(): ReadonlyArray<Tag>;
1471
- get kind(): RelationshipKind | null;
1472
- get navigateTo(): LikeC4ViewModel<M> | null;
1473
- get links(): ReadonlyArray<Link>;
1474
- views(): IteratorLike<LikeC4ViewModel<M, ComputedDeploymentView>>;
1475
- }
1476
- declare class RelationshipsAccum<M extends AnyAux> {
1477
- readonly model: ReadonlySet<RelationshipModel<M>>;
1478
- readonly deployment: ReadonlySet<DeploymentRelationModel<M>>;
1479
- static empty<M extends AnyAux>(): RelationshipsAccum<M>;
1480
- static from<M extends AnyAux>(model: Iterable<RelationshipModel<M>> | undefined, deployment?: Iterable<DeploymentRelationModel<M>>): RelationshipsAccum<M>;
1481
- /**
1482
- * @param model relationships from logical model
1483
- * @param deployment relationships from deployment model
1484
- */
1485
- constructor(model?: ReadonlySet<RelationshipModel<M>>, deployment?: ReadonlySet<DeploymentRelationModel<M>>);
1486
- get isEmpty(): boolean;
1487
- get nonEmpty(): boolean;
1488
- get size(): number;
1489
- /**
1490
- * Returns new Accum containing all the elements which are both in this and otherAccum
1491
- */
1492
- intersect(otherAccum: RelationshipsAccum<M>): RelationshipsAccum<M>;
1493
- /**
1494
- * Returns new Accum containing all the elements which are both in this and otherAccum
1495
- */
1496
- difference(otherAccum: RelationshipsAccum<M>): RelationshipsAccum<M>;
1497
- /**
1498
- * Returns new Accum containing all the elements from both
1499
- */
1500
- union(otherAccum: RelationshipsAccum<M>): RelationshipsAccum<M>;
1501
- }
1502
-
1503
- type ElementsIterator<M extends AnyAux> = IteratorLike<ElementModel<M>>;
1504
- declare class ElementModel<M extends AnyAux = AnyAux> {
1505
- readonly $model: LikeC4Model<M>;
1506
- readonly $element: Element;
1507
- readonly id: M['Fqn'];
1508
- readonly hierarchyLevel: number;
1509
- constructor($model: LikeC4Model<M>, $element: Element);
1510
- get parent(): ElementModel<M> | null;
1511
- get kind(): ElementKind;
1512
- get shape(): ElementShape;
1513
- get color(): ThemeColor;
1514
- get tags(): ReadonlyArray<Tag>;
1515
- get title(): string;
1516
- get description(): string | null;
1517
- get technology(): string | null;
1518
- get links(): ReadonlyArray<Link>;
1519
- get defaultView(): LikeC4ViewModel<M> | null;
1520
- isAncestorOf(another: ElementModel<M>): boolean;
1521
- isDescendantOf(another: ElementModel<M>): boolean;
1522
- /**
1523
- * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
1524
- * (from closest to root)
1525
- */
1526
- ancestors(): ElementsIterator<M>;
1527
- /**
1528
- * Returns the common ancestor of this element and another element.
1529
- */
1530
- commonAncestor(another: ElementModel<M>): ElementModel<M> | null;
1531
- children(): ReadonlySet<ElementModel<M>>;
1532
- /**
1533
- * Get all descendant elements (i.e. children, children’s children, etc.)
1534
- */
1535
- descendants(sort?: 'asc' | 'desc'): ElementsIterator<M>;
1536
- /**
1537
- * Get all sibling (i.e. same parent)
1538
- */
1539
- siblings(): ElementsIterator<M>;
1540
- /**
1541
- * Resolve siblings of the element and its ancestors
1542
- * (from closest to root)
1543
- */
1544
- ascendingSiblings(): ElementsIterator<M>;
1545
- /**
1546
- * Resolve siblings of the element and its ancestors
1547
- * (from root to closest)
1548
- */
1549
- descendingSiblings(): ElementsIterator<M>;
1550
- incoming(filter?: IncomingFilter): RelationshipsIterator<M>;
1551
- incomers(filter?: IncomingFilter): ElementsIterator<M>;
1552
- outgoing(filter?: OutgoingFilter): RelationshipsIterator<M>;
1553
- outgoers(filter?: OutgoingFilter): ElementsIterator<M>;
1554
- protected cachedOutgoing: Set<RelationshipModel<M>> | null;
1555
- protected cachedIncoming: Set<RelationshipModel<M>> | null;
1556
- get allOutgoing(): ReadonlySet<RelationshipModel<M>>;
1557
- get allIncoming(): ReadonlySet<RelationshipModel<M>>;
1558
- /**
1559
- * Iterate over all views that include this element.
1560
- */
1561
- views(): ViewsIterator<M>;
1562
- /**
1563
- * Iterate over all views that scope this element.
1564
- * It is possible that element is not included in the view.
1565
- */
1566
- scopedViews(): ViewsIterator<M>;
1567
- /**
1568
- * @returns true if the element is deployed
1569
- */
1570
- isDeployed(): boolean;
1571
- deployments(): DeployedInstancesIterator<M>;
1572
- }
1573
-
1574
- /**
1575
- * OverviewGraph is a graph representation of all views in a model
1576
- */
1577
- declare namespace OverviewGraph {
1578
- type Node = {
1579
- id: string;
1580
- type: 'folder' | 'file';
1581
- path: string;
1582
- label: string;
1583
- parentId: string | null;
1584
- position: XYPoint;
1585
- width: number;
1586
- height: number;
1587
- } | {
1588
- id: string;
1589
- type: 'view';
1590
- viewId: ViewId;
1591
- label: string;
1592
- parentId: string | null;
1593
- position: XYPoint;
1594
- width: number;
1595
- height: number;
1596
- };
1597
- /**
1598
- * Edge represents a navigational link from one view to another
1599
- */
1600
- type Edge = {
1601
- id: string;
1602
- source: string;
1603
- target: string;
1604
- points: NonEmptyArray<Point>;
1605
- };
1606
- }
1607
- interface OverviewGraph {
1608
- nodes: OverviewGraph.Node[];
1609
- edges: OverviewGraph.Edge[];
1610
- bounds: BBox;
1611
- }
1612
-
1613
- declare namespace ViewChange {
1614
- interface ChangeElementStyle {
1615
- op: 'change-element-style';
1616
- style: {
1617
- border?: BorderStyle;
1618
- opacity?: number;
1619
- shape?: ElementShape;
1620
- color?: ThemeColor;
1621
- };
1622
- targets: NonEmptyArray<Fqn>;
1623
- }
1624
- interface SaveManualLayout {
1625
- op: 'save-manual-layout';
1626
- layout: ViewManualLayout;
1627
- }
1628
- interface ChangeAutoLayout {
1629
- op: 'change-autolayout';
1630
- layout: {
1631
- direction: AutoLayoutDirection;
1632
- nodeSep?: number | null;
1633
- rankSep?: number | null;
1634
- };
1635
- }
1636
- }
1637
- type ViewChange = ViewChange.ChangeElementStyle | ViewChange.SaveManualLayout | ViewChange.ChangeAutoLayout;
1638
-
1639
- export { type ViewId as $, type AnyAux as A, type BBox as B, ComputedNode as C, type DeploymentElementModel as D, ElementModel as E, type Fqn as F, type DynamicView as G, type EdgeId as H, type IteratorLike as I, type Element as J, ElementKind as K, LikeC4Model as L, type ElementView as M, NodeModel as N, type HexColorLiteral as O, type LayoutedLikeC4Model as P, type LikeC4View as Q, RelationshipsAccum as R, type NodeId as S, OverviewGraph as T, type ParsedLikeC4Model as U, type Point as V, RelationExpr as W, type RelationId as X, type StepEdgeId as Y, type Tag as Z, type ThemeColor as _, DeploymentNodeModel as a, type WhereOperator as a0, type XYPoint as a1, type NonEmptyArray as a2, type ElementShape as a3, type IconUrl as a4, type BorderStyle as a5, type RelationshipKind as a6, type RelationshipLineType as a7, type RelationshipArrowType as a8, type CustomColor as a9, type DeploymentNodeKindSpecification as aa, type ModelGlobals as ab, type ViewRule as ac, type ViewManualLayout as ad, type DynamicViewStepOrParallel as ae, type DynamicViewRule as af, type DeploymentViewRule as ag, ViewChange as ah, DeployedInstanceModel as b, RelationshipModel as c, DeploymentRelationModel as d, Aux as e, EdgeModel as f, LikeC4DeploymentModel as g, LikeC4ViewModel as h, ComputedView as i, DiagramNode as j, type AbstractRelation as k, type AutoLayoutDirection as l, type Color as m, type ComputedDeploymentView as n, type ComputedDynamicView as o, type ComputedEdge as p, type ComputedElementView as q, type ComputedLikeC4Model as r, type DeployedInstance as s, DeploymentElement as t, type DeploymentNode as u, type DeploymentNodeKind as v, type DeploymentRelation as w, type DeploymentView as x, type DiagramEdge as y, type DiagramView as z };