@likec4/core 1.19.1 → 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 (91) hide show
  1. package/dist/builder/index.cjs +881 -0
  2. package/dist/builder/index.d.cts +503 -0
  3. package/dist/builder/index.d.mts +5 -4
  4. package/dist/builder/index.d.ts +5 -4
  5. package/dist/builder/{index.js → index.mjs} +14 -4
  6. package/dist/compute-view/index.cjs +86 -0
  7. package/dist/compute-view/index.d.cts +23 -0
  8. package/dist/compute-view/index.d.mts +3 -2
  9. package/dist/compute-view/index.d.ts +3 -2
  10. package/dist/compute-view/{index.js → index.mjs} +6 -5
  11. package/dist/index.cjs +4320 -0
  12. package/dist/index.d.cts +270 -0
  13. package/dist/index.d.mts +130 -4
  14. package/dist/index.d.ts +130 -4
  15. package/dist/{index.js → index.mjs} +512 -7
  16. package/dist/model/index.cjs +40 -0
  17. package/dist/model/index.d.cts +259 -0
  18. package/dist/model/index.d.mts +8 -3
  19. package/dist/model/index.d.ts +8 -3
  20. package/dist/model/index.mjs +1 -0
  21. package/dist/shared/core.B2QYWlYe.cjs +435 -0
  22. package/dist/shared/core.B72vUaNB.d.cts +850 -0
  23. package/dist/shared/core.BGus30EM.cjs +8027 -0
  24. package/dist/shared/core.BRuJ3Wzf.d.mts +12 -0
  25. package/dist/shared/{core.BZ9Msq7w.d.mts → core.BdbFkE_p.d.cts} +14 -4
  26. package/dist/shared/core.BvdNMbcA.d.cts +12 -0
  27. package/dist/shared/{object_hash.CE_oF3I3.js → core.BxvDITEI.mjs} +26 -389
  28. package/dist/shared/core.ByNgh-mC.d.cts +127 -0
  29. package/dist/shared/core.C9DCnJh8.cjs +908 -0
  30. package/dist/shared/{index.DafVOuVd.js → core.CqCTxzMY.mjs} +1111 -572
  31. package/dist/shared/core.D74xkKkG.d.cts +148 -0
  32. package/dist/shared/{core.C05RDLhi.d.ts → core.D_Gc58Gt.d.ts} +23 -5
  33. package/dist/shared/core.Damrzla-.d.ts +12 -0
  34. package/dist/shared/{core.CmYMqgha.d.mts → core.Dfzrh1VA.d.mts} +23 -5
  35. package/dist/shared/core.DsoCu540.cjs +26 -0
  36. package/dist/shared/{view.CyZrG8BJ.js → core.DunIMHRf.mjs} +27 -1
  37. package/dist/shared/{core.BIfgabEw.d.ts → core.ZWiGANIJ.d.ts} +14 -4
  38. package/dist/shared/core.gv1bMwCC.cjs +39 -0
  39. package/dist/shared/core.jy6z2iRn.d.mts +729 -0
  40. package/dist/shared/core.m3rCQAv6.mjs +37 -0
  41. package/dist/types/index.cjs +107 -0
  42. package/dist/types/index.d.cts +72 -0
  43. package/dist/types/index.d.mts +2 -2
  44. package/dist/types/index.d.ts +2 -2
  45. package/dist/types/{index.js → index.mjs} +1 -1
  46. package/dist/utils/index.cjs +95 -0
  47. package/dist/utils/index.d.cts +356 -0
  48. package/dist/utils/index.d.mts +1 -64
  49. package/dist/utils/index.d.ts +1 -64
  50. package/dist/utils/index.mjs +56 -0
  51. package/package.json +52 -26
  52. package/src/builder/Builder.view-common.ts +21 -1
  53. package/src/compute-view/deployment-view/__test__/fixture.ts +31 -3
  54. package/src/compute-view/deployment-view/_types.ts +2 -1
  55. package/src/compute-view/deployment-view/compute.ts +4 -36
  56. package/src/compute-view/deployment-view/predicates/index.ts +8 -0
  57. package/src/compute-view/deployment-view/predicates/relation-direct.ts +125 -99
  58. package/src/compute-view/deployment-view/predicates/relation-in-out.ts +16 -8
  59. package/src/compute-view/deployment-view/predicates/relation-incoming.ts +18 -12
  60. package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +16 -9
  61. package/src/compute-view/deployment-view/predicates/relation-where.ts +18 -0
  62. package/src/compute-view/deployment-view/predicates/utils.ts +214 -0
  63. package/src/compute-view/element-view/__test__/fixture.ts +17 -4
  64. package/src/compute-view/element-view/compute.ts +3 -2
  65. package/src/compute-view/element-view/predicates.ts +520 -0
  66. package/src/compute-view/element-view/utils.ts +11 -7
  67. package/src/compute-view/index.ts +1 -0
  68. package/src/compute-view/relationships-view/_types.ts +16 -0
  69. package/src/compute-view/relationships-view/compute.ts +74 -0
  70. package/src/compute-view/relationships-view/layout.ts +357 -0
  71. package/src/compute-view/relationships-view/utils.ts +40 -0
  72. package/src/compute-view/utils/relationExpressionToPredicates.ts +11 -4
  73. package/src/index.ts +16 -0
  74. package/src/model/DeploymentElementModel.ts +18 -1
  75. package/src/model/ElementModel.ts +13 -0
  76. package/src/model/LikeC4Model.ts +2 -2
  77. package/src/model/RelationModel.ts +9 -0
  78. package/src/model/connection/deployment/DeploymentConnectionModel.ts +11 -1
  79. package/src/model/guards.ts +17 -1
  80. package/src/model/view/LikeC4ViewModel.ts +7 -1
  81. package/src/model/view/NodeModel.ts +5 -0
  82. package/src/types/deployments.ts +1 -0
  83. package/src/types/expression-v2.ts +12 -0
  84. package/src/types/index.ts +1 -0
  85. package/src/types/operators.ts +46 -6
  86. package/src/types/view.ts +2 -2
  87. package/src/utils/index.ts +0 -5
  88. package/src/utils/iterable/unique.ts +1 -7
  89. package/dist/model/index.js +0 -1
  90. package/dist/utils/index.js +0 -347
  91. /package/dist/shared/{chunk-RAAYCPUM.M-JWF7SS.js → core.M-JWF7SS.mjs} +0 -0
@@ -0,0 +1,729 @@
1
+ import { IsStringLiteral, LiteralUnion, Simplify, SetRequired } from 'type-fest';
2
+ import { C as ComputedView, L as LikeC4View, a9 as ParsedLikeC4Model, a as ComputedLikeC4Model, bk as ViewId, au as RelationId, bf as NodeId, bc as EdgeId, a6 as GenericLikeC4Model, a7 as LayoutedLikeC4Model, b5 as DiagramView, a8 as LikeC4ModelDump, f as DeploymentNodeKind, aY as ComputedDynamicView, bh as StepEdgeId, a_ as ComputedElementView, aX as ComputedDeploymentView, at as ModelRelation, a5 as AnyParsedLikeC4Model, a4 as ModelGlobals, h as DeploymentRef, d as DeploymentNode, b as DeployedInstance, c as DeploymentElementStyle, i as DeploymentRelation, aw as RelationshipKind } from './core.Dfzrh1VA.mjs';
3
+ import { F as Fqn, K as KeysOf, f as ElementKind, l as ElementShape, s as Color, I as IconUrl, o as Tag, n as Link, a as IteratorLike, x as ThemeColor, i as Element } from './core.D74xkKkG.mjs';
4
+
5
+ type ComputeViewResult<V extends ComputedView = ComputedView> = {
6
+ isSuccess: true;
7
+ error?: undefined;
8
+ view: V;
9
+ } | {
10
+ isSuccess: false;
11
+ error: Error;
12
+ view: undefined;
13
+ };
14
+ declare function unsafeComputeView(viewsource: LikeC4View, likec4model: LikeC4Model): ComputedView;
15
+ declare function computeView<V extends LikeC4View>(viewsource: V, likec4model: LikeC4Model): ComputeViewResult;
16
+ declare function computeViews<P extends ParsedLikeC4Model>(parsed: P): ComputedLikeC4Model;
17
+
18
+ type IncomingFilter = 'all' | 'direct' | 'to-descendants';
19
+ type OutgoingFilter = 'all' | 'direct' | 'from-descendants';
20
+ type WithId<Id> = {
21
+ id: Id;
22
+ };
23
+ type WithViews<Id extends string, ViewType> = {
24
+ views: Record<Id, ViewType>;
25
+ };
26
+ type AnyAux = Aux<string, string, string, any>;
27
+ /**
28
+ * Auxilary type to keep track
29
+ */
30
+ interface Aux<Element extends string, Deployment extends string, View extends string, ViewType> {
31
+ Element: Element;
32
+ Deployment: Deployment;
33
+ View: View;
34
+ Fqn: IsStringLiteral<Element> extends true ? Fqn<Element> : Fqn;
35
+ ElementOrFqn: Element | WithId<this['Fqn']>;
36
+ DeploymentFqn: IsStringLiteral<Deployment> extends true ? Fqn<Deployment> : Fqn;
37
+ DeploymentOrFqn: Deployment | WithId<this['DeploymentFqn']>;
38
+ ViewId: IsStringLiteral<View> extends true ? ViewId<View> : ViewId;
39
+ ViewType: ViewType;
40
+ RelationId: RelationId;
41
+ NodeId: NodeId;
42
+ NodeIdLiteral: string;
43
+ EdgeId: EdgeId;
44
+ EdgeIdLiteral: string;
45
+ NodeOrId: LiteralUnion<this['NodeIdLiteral'], string> | WithId<this['NodeId']>;
46
+ EdgeOrId: LiteralUnion<this['EdgeIdLiteral'], string> | WithId<this['EdgeId']>;
47
+ Model: Simplify<Omit<GenericLikeC4Model, 'views'> & WithViews<this['ViewId'], ViewType>>;
48
+ }
49
+ declare namespace Aux {
50
+ type FromParsed<M> = M extends ParsedLikeC4Model ? Aux<KeysOf<M['elements']>, KeysOf<M['deployments']['elements']>, KeysOf<M['views']>, ComputedView<ViewId<KeysOf<M['views']>>, string>> : never;
51
+ 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;
52
+ type FromDump<M> = M extends LikeC4ModelDump ? Aux<KeysOf<M['elements']>, KeysOf<M['deployments']['elements']>, KeysOf<M['views']>, DiagramView<ViewId<KeysOf<M['views']>>, string>> : never;
53
+ }
54
+
55
+ type NodesIterator<M extends AnyAux, V extends ComputedView | DiagramView> = IteratorLike<NodeModel<M, V>>;
56
+ declare namespace NodeModel {
57
+ interface WithParent<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
58
+ parent: NodeModel<M, V>;
59
+ }
60
+ interface WithElement<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
61
+ kind: ElementKind;
62
+ element: ElementModel<M>;
63
+ }
64
+ interface WithDeploymentElement<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
65
+ kind: DeploymentNodeKind;
66
+ deployment: DeploymentElementModel<M>;
67
+ }
68
+ interface WithDeployedInstance<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
69
+ kind: 'instance';
70
+ element: ElementModel<M>;
71
+ deployment: DeployedInstanceModel<M>;
72
+ }
73
+ interface IsGroup<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
74
+ kind: typeof ElementKind.Group;
75
+ element: null;
76
+ deployment: null;
77
+ }
78
+ }
79
+ declare class NodeModel<M extends AnyAux, V extends ComputedView | DiagramView = M['ViewType']> {
80
+ readonly $view: LikeC4ViewModel<M, V>;
81
+ readonly $node: V['nodes'][number];
82
+ constructor($view: LikeC4ViewModel<M, V>, $node: V['nodes'][number]);
83
+ get id(): NodeId;
84
+ get title(): string;
85
+ get kind(): ElementKind | DeploymentNodeKind | typeof ElementKind.Group | 'instance';
86
+ get description(): string | null;
87
+ get technology(): string | null;
88
+ get parent(): NodeModel<M, V> | null;
89
+ get element(): ElementModel<M> | null;
90
+ get deployment(): DeploymentElementModel<M> | null;
91
+ get shape(): ElementShape;
92
+ get color(): Color;
93
+ get icon(): IconUrl | null;
94
+ get tags(): ReadonlyArray<Tag>;
95
+ get links(): ReadonlyArray<Link>;
96
+ get navigateTo(): LikeC4ViewModel<M> | null;
97
+ /**
98
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
99
+ * (from closest to root)
100
+ */
101
+ ancestors(): NodesIterator<M, V>;
102
+ children(): NodesIterator<M, V>;
103
+ sublings(): NodesIterator<M, V>;
104
+ incoming(filter?: IncomingFilter): EdgesIterator<M, V>;
105
+ incomers(filter?: IncomingFilter): NodesIterator<M, V>;
106
+ outgoing(filter?: OutgoingFilter): EdgesIterator<M, V>;
107
+ outgoers(filter?: OutgoingFilter): NodesIterator<M, V>;
108
+ isDiagramNode(): this is NodeModel<M, DiagramView>;
109
+ hasChildren(): boolean;
110
+ hasParent(): this is NodeModel.WithParent<M, V>;
111
+ /**
112
+ * Check if this node references to logical model element.
113
+ */
114
+ hasElement(): this is NodeModel.WithElement<M, V>;
115
+ /**
116
+ * Check if this node references to deployment element (Node or Instance).
117
+ */
118
+ hasDeployment(): this is NodeModel.WithDeploymentElement<M, V>;
119
+ /**
120
+ * Check if this node references to deployed instance
121
+ * Deployed instance always references to element and deployment element.
122
+ */
123
+ hasDeployedInstance(): this is NodeModel.WithDeployedInstance<M, V>;
124
+ isGroup(): this is NodeModel.IsGroup<M, V>;
125
+ }
126
+
127
+ type EdgesIterator<M extends AnyAux, V extends ComputedView | DiagramView> = IteratorLike<EdgeModel<M, V>>;
128
+ declare class EdgeModel<M extends AnyAux, V extends ComputedView | DiagramView = M['ViewType']> {
129
+ readonly view: LikeC4ViewModel<M, V>;
130
+ readonly $edge: V['edges'][number];
131
+ readonly source: NodeModel<M, V>;
132
+ readonly target: NodeModel<M, V>;
133
+ constructor(view: LikeC4ViewModel<M, V>, $edge: V['edges'][number], source: NodeModel<M, V>, target: NodeModel<M, V>);
134
+ get id(): M['EdgeId'];
135
+ get parent(): NodeModel<M, V> | null;
136
+ get label(): string | null;
137
+ get description(): string | null;
138
+ get technology(): string | null;
139
+ hasParent(): this is EdgeModel.WithParent<M, V>;
140
+ get tags(): ReadonlyArray<Tag>;
141
+ get stepNumber(): number | null;
142
+ get navigateTo(): LikeC4ViewModel<M> | null;
143
+ isStep(): this is EdgeModel.StepEdge<M, ComputedDynamicView>;
144
+ relationships(type: 'model'): IteratorLike<RelationshipModel<M>>;
145
+ relationships(type: 'deployment'): IteratorLike<DeploymentRelationModel<M>>;
146
+ relationships(type?: 'model' | 'deployment'): IteratorLike<LikeC4Model.AnyRelation<M>>;
147
+ includesRelation(rel: M['RelationId']): boolean;
148
+ }
149
+ declare namespace EdgeModel {
150
+ interface StepEdge<M extends AnyAux, V extends ComputedView | DiagramView> extends EdgeModel<M, V> {
151
+ id: StepEdgeId;
152
+ stepNumber: number;
153
+ }
154
+ interface WithParent<M extends AnyAux, V extends ComputedView | DiagramView> extends EdgeModel<M, V> {
155
+ parent: NodeModel<M, V>;
156
+ }
157
+ }
158
+
159
+ type ViewsIterator<M extends AnyAux> = IteratorLike<LikeC4ViewModel<M>>;
160
+ declare class LikeC4ViewModel<M extends AnyAux, V extends ComputedView | DiagramView = M['ViewType']> {
161
+ #private;
162
+ readonly $model: LikeC4Model<M>;
163
+ readonly $view: V;
164
+ constructor($model: LikeC4Model<M>, $view: V);
165
+ get __(): NonNullable<M['ViewType']['__']>;
166
+ get id(): M['ViewId'];
167
+ get title(): string | null;
168
+ get tags(): ReadonlyArray<Tag>;
169
+ get links(): ReadonlyArray<Link>;
170
+ get viewOf(): ElementModel<M> | null;
171
+ /**
172
+ * All tags from nodes and edges.
173
+ */
174
+ get includedTags(): ReadonlyArray<Tag>;
175
+ roots(): NodesIterator<M, V>;
176
+ /**
177
+ * Iterate over all nodes that have children.
178
+ */
179
+ compounds(): NodesIterator<M, V>;
180
+ /**
181
+ * Get node by id.
182
+ * @throws Error if node is not found.
183
+ */
184
+ node(node: M['NodeOrId']): NodeModel<M, V>;
185
+ /**
186
+ * Find node by id.
187
+ */
188
+ findNode(node: M['NodeOrId']): NodeModel<M, V> | null;
189
+ findNodeWithElement(fqn: M['Element']): NodeModel.WithElement<M, V> | null;
190
+ /**
191
+ * Iterate over all nodes.
192
+ */
193
+ nodes(): NodesIterator<M, V>;
194
+ /**
195
+ * Find edge by id.
196
+ * @param edge Edge or id
197
+ * @returns EdgeModel
198
+ */
199
+ edge(edge: M['EdgeOrId']): EdgeModel<M, V>;
200
+ findEdge(edge: M['EdgeOrId']): EdgeModel<M, V> | null;
201
+ /**
202
+ * Iterate over all edges.
203
+ */
204
+ edges(): EdgesIterator<M, V>;
205
+ /**
206
+ * Iterate over all edges.
207
+ */
208
+ edgesWithRelation(relation: M['RelationId']): EdgesIterator<M, V>;
209
+ /**
210
+ * Nodes that have references to elements from logical model.
211
+ */
212
+ elements(): IteratorLike<NodeModel.WithElement<M, V>>;
213
+ includesElement(elementId: M['Element']): boolean;
214
+ includesDeployment(deploymentId: M['Deployment']): boolean;
215
+ includesRelation(relationId: M['RelationId']): boolean;
216
+ /**
217
+ * Below are type guards.
218
+ */
219
+ isComputed(): this is LikeC4ViewModel<M, ComputedView>;
220
+ isDiagram(): this is LikeC4ViewModel<M, DiagramView>;
221
+ isElementView(): this is LikeC4ViewModel<M, ComputedElementView>;
222
+ isDeploymentView(): this is LikeC4ViewModel<M, ComputedDeploymentView>;
223
+ isDynamicView(): this is LikeC4ViewModel<M, ComputedDynamicView>;
224
+ }
225
+
226
+ type RelationshipsIterator<M extends AnyAux> = IteratorLike<RelationshipModel<M>>;
227
+ declare class RelationshipModel<M extends AnyAux = AnyAux> {
228
+ readonly model: LikeC4Model<M>;
229
+ readonly $relationship: ModelRelation;
230
+ readonly source: ElementModel<M>;
231
+ readonly target: ElementModel<M>;
232
+ /**
233
+ * Common ancestor of the source and target elements.
234
+ * Represents the boundary of the Relation.
235
+ */
236
+ readonly boundary: ElementModel<M> | null;
237
+ constructor(model: LikeC4Model<M>, $relationship: ModelRelation);
238
+ get id(): M['RelationId'];
239
+ get expression(): string;
240
+ get title(): string | null;
241
+ get technology(): string | null;
242
+ get description(): string | null;
243
+ get navigateTo(): LikeC4ViewModel<M> | null;
244
+ get tags(): ReadonlyArray<Tag>;
245
+ get kind(): string | null;
246
+ get links(): ReadonlyArray<Link>;
247
+ /**
248
+ * Iterate over all views that include this relationship.
249
+ */
250
+ views(): ViewsIterator<M>;
251
+ isDeploymentRelation(): this is DeploymentRelationModel<M>;
252
+ }
253
+
254
+ declare class LikeC4Model<M extends AnyAux = LikeC4Model.Any> {
255
+ #private;
256
+ readonly $model: M['Model'];
257
+ /**
258
+ * Only available in compile tim
259
+ */
260
+ readonly Aux: M;
261
+ readonly deployment: LikeC4DeploymentModel<M>;
262
+ /**
263
+ * Computes views from the parsed model
264
+ * Creates a new LikeC4Model instance from a parsed model.
265
+ *
266
+ * May throw an error if the model is invalid.
267
+ *
268
+ * @typeParam M - The type of the parsed LikeC4 model, must extend ParsedLikeC4Model
269
+ * @param parsed - The parsed LikeC4 model to compute from
270
+ * @returns A new LikeC4Model instance with computed relationships and structure
271
+ */
272
+ static compute<const M extends AnyParsedLikeC4Model>(parsed: M): LikeC4Model<Aux.FromParsed<M>>;
273
+ /**
274
+ * Creates a function that computes a view using the data from the model.
275
+ *
276
+ * @example
277
+ * const compute = LikeC4Model.makeCompute(parsedModel);
278
+ * const result = compute(viewSource);
279
+ */
280
+ static makeCompute<M extends AnyParsedLikeC4Model>(parsed: M): (viewsource: LikeC4View) => ComputeViewResult;
281
+ /**
282
+ * Creates a new LikeC4Model instance from the provided model data.
283
+ *
284
+ * @typeParam M - Type parameter constrained to AnyLikeC4Model
285
+ * @param model - The model data to create a LikeC4Model from
286
+ * @returns A new LikeC4Model instance with the type derived from the input model
287
+ */
288
+ static create<const M extends GenericLikeC4Model>(model: M): LikeC4Model<Aux.FromModel<M>>;
289
+ /**
290
+ * Creates a new LikeC4Model instance from a model dump.
291
+ *
292
+ * @typeParam M - A constant type parameter extending LikeC4ModelDump
293
+ * @param dump - The model dump to create the instance from
294
+ * @returns A new LikeC4Model instance with types inferred from the dump
295
+ */
296
+ static fromDump<const M extends LikeC4ModelDump>(dump: M): LikeC4Model<Aux.FromDump<M>>;
297
+ private constructor();
298
+ get type(): 'computed' | 'layouted';
299
+ element(el: M['ElementOrFqn']): ElementModel<M>;
300
+ findElement(el: LiteralUnion<M['Element'], string>): ElementModel<M> | null;
301
+ /**
302
+ * Returns the root elements of the model.
303
+ */
304
+ roots(): ElementsIterator<M>;
305
+ /**
306
+ * Returns all elements in the model.
307
+ */
308
+ elements(): ElementsIterator<M>;
309
+ /**
310
+ * Returns all relationships in the model.
311
+ */
312
+ relationships(): RelationshipsIterator<M>;
313
+ /**
314
+ * Returns a specific relationship by its ID.
315
+ * If the relationship is not found in the model, it will be searched in the deployment model.
316
+ * Search can be limited to the model or deployment model only.
317
+ */
318
+ relationship(id: M['RelationId'], type: 'model'): RelationshipModel<M>;
319
+ relationship(id: M['RelationId'], type: 'deployment'): DeploymentRelationModel<M>;
320
+ relationship(id: M['RelationId'], type?: 'model' | 'deployment'): RelationshipModel<M> | DeploymentRelationModel<M>;
321
+ findRelationship(id: LiteralUnion<M['RelationId'], string>, type: 'model'): RelationshipModel<M> | null;
322
+ findRelationship(id: LiteralUnion<M['RelationId'], string>, type: 'deployment'): DeploymentRelationModel<M> | null;
323
+ findRelationship(id: LiteralUnion<M['RelationId'], string>, type?: 'model' | 'deployment'): RelationshipModel<M> | DeploymentRelationModel<M> | null;
324
+ /**
325
+ * Returns all views in the model.
326
+ */
327
+ views(): IteratorLike<LikeC4ViewModel<M>>;
328
+ /**
329
+ * Returns a specific view by its ID.
330
+ */
331
+ view(viewId: M['View']): LikeC4ViewModel<M>;
332
+ findView(viewId: M['View']): LikeC4ViewModel<M> | null;
333
+ /**
334
+ * Returns the parent element of given element.
335
+ * @see ancestors
336
+ */
337
+ parent(element: M['ElementOrFqn']): ElementModel<M> | null;
338
+ /**
339
+ * Get all children of the element (only direct children),
340
+ * @see descendants
341
+ */
342
+ children(element: M['ElementOrFqn']): ReadonlySet<ElementModel<M>>;
343
+ /**
344
+ * Get all sibling (i.e. same parent)
345
+ */
346
+ siblings(element: M['ElementOrFqn']): ElementsIterator<M>;
347
+ /**
348
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
349
+ * (from closest to root)
350
+ */
351
+ ancestors(element: M['ElementOrFqn']): ElementsIterator<M>;
352
+ /**
353
+ * Get all descendant elements (i.e. children, children’s children, etc.)
354
+ */
355
+ descendants(element: M['ElementOrFqn']): ElementsIterator<M>;
356
+ /**
357
+ * Incoming relationships to the element and its descendants
358
+ * @see incomers
359
+ */
360
+ incoming(element: M['ElementOrFqn'], filter?: IncomingFilter): RelationshipsIterator<M>;
361
+ /**
362
+ * Outgoing relationships from the element and its descendants
363
+ * @see outgoers
364
+ */
365
+ outgoing(element: M['ElementOrFqn'], filter?: OutgoingFilter): RelationshipsIterator<M>;
366
+ globals(): ModelGlobals;
367
+ private addElement;
368
+ private addRelation;
369
+ }
370
+ declare namespace LikeC4Model {
371
+ type Any = Aux<string, string, string, ComputedView | DiagramView>;
372
+ type Element<M extends AnyAux = Any> = ElementModel<M>;
373
+ type Relation<M extends AnyAux = Any> = RelationshipModel<M>;
374
+ type AnyRelation<M extends AnyAux = Any> = RelationshipModel<M> | DeploymentRelationModel<M>;
375
+ type View<M extends AnyAux = Any, V extends ComputedView | DiagramView = M['ViewType']> = LikeC4ViewModel<M, V>;
376
+ type Node<M extends AnyAux = Any, V extends ComputedView | DiagramView = M['ViewType']> = NodeModel<M, V>;
377
+ type Edge<M extends AnyAux = Any, V extends ComputedView | DiagramView = M['ViewType']> = EdgeModel<M, V>;
378
+ type DeploymentModel<M extends AnyAux = AnyAux> = LikeC4DeploymentModel<M>;
379
+ type Deployment<M extends AnyAux = AnyAux> = DeploymentElementModel<M>;
380
+ type DeploymentNode<M extends AnyAux = AnyAux> = DeploymentNodeModel<M>;
381
+ type DeployedInstance<M extends AnyAux = AnyAux> = DeployedInstanceModel<M>;
382
+ type Typed<Elements extends string = string, Deployments extends string = string, Views extends string = string, ViewType = DiagramView<Views> | ComputedView<Views>> = Aux<Elements, Deployments, Views, ViewType>;
383
+ type Computed<Elements extends string = string, Deployments extends string = string, Views extends string = string> = LikeC4Model<Typed<Elements, Deployments, Views, ComputedView<Views>>>;
384
+ type Layouted<Elements extends string = string, Deployments extends string = string, Views extends string = string> = LikeC4Model<Typed<Elements, Deployments, Views, DiagramView<Views>>>;
385
+ }
386
+
387
+ declare class LikeC4DeploymentModel<M extends AnyAux = AnyAux> {
388
+ #private;
389
+ readonly $model: LikeC4Model<M>;
390
+ readonly $deployments: GenericLikeC4Model['deployments'];
391
+ constructor($model: LikeC4Model<M>, $deployments: GenericLikeC4Model['deployments']);
392
+ element(el: M['DeploymentOrFqn']): DeploymentElementModel<M>;
393
+ findElement(el: M['Deployment']): DeploymentElementModel<M> | null;
394
+ node(el: M['DeploymentOrFqn']): DeploymentNodeModel<M>;
395
+ findNode(el: M['Deployment']): DeploymentNodeModel<M> | null;
396
+ instance(el: M['DeploymentOrFqn']): DeployedInstanceModel<M>;
397
+ findInstance(el: M['Deployment']): DeployedInstanceModel<M> | null;
398
+ /**
399
+ * Returns the root elements of the model.
400
+ */
401
+ roots(): DeploymentNodesIterator<M>;
402
+ /**
403
+ * Returns all elements in the model.
404
+ */
405
+ elements(): DeploymentElementsIterator<M>;
406
+ /**
407
+ * Returns all elements in the model.
408
+ */
409
+ nodes(): DeploymentNodesIterator<M>;
410
+ instances(): DeployedInstancesIterator<M>;
411
+ /**
412
+ * Iterate over all instances of the given logical element.
413
+ */
414
+ instancesOf(element: M['ElementOrFqn']): DeployedInstancesIterator<M>;
415
+ deploymentRef(ref: DeploymentRef): DeploymentElementModel<M> | NestedElementOfDeployedInstanceModel<M>;
416
+ /**
417
+ * Returns all relationships in the model.
418
+ */
419
+ relationships(): IteratorLike<DeploymentRelationModel<M>>;
420
+ /**
421
+ * Returns a specific relationship by its ID.
422
+ */
423
+ relationship(id: M['RelationId']): DeploymentRelationModel<M>;
424
+ findRelationship(id: LiteralUnion<M['RelationId'], string>): DeploymentRelationModel<M> | null;
425
+ /**
426
+ * Returns all deployment views in the model.
427
+ */
428
+ views(): IteratorLike<LikeC4ViewModel<M, ComputedDeploymentView>>;
429
+ /**
430
+ * Returns the parent element of given element.
431
+ * @see ancestors
432
+ */
433
+ parent(element: M['DeploymentOrFqn']): DeploymentNodeModel<M> | null;
434
+ /**
435
+ * Get all children of the element (only direct children),
436
+ * @see descendants
437
+ */
438
+ children(element: M['DeploymentOrFqn']): ReadonlySet<DeploymentElementModel<M>>;
439
+ /**
440
+ * Get all sibling (i.e. same parent)
441
+ */
442
+ siblings(element: M['DeploymentOrFqn']): DeploymentElementsIterator<M>;
443
+ /**
444
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
445
+ * (from closest to root)
446
+ */
447
+ ancestors(element: M['DeploymentOrFqn']): DeploymentNodesIterator<M>;
448
+ /**
449
+ * Get all descendant elements (i.e. children, children’s children, etc.)
450
+ */
451
+ descendants(element: M['DeploymentOrFqn'], sort?: 'asc' | 'desc'): DeploymentElementsIterator<M>;
452
+ /**
453
+ * Incoming relationships to the element and its descendants
454
+ * @see incomers
455
+ */
456
+ incoming(element: M['DeploymentOrFqn'], filter?: IncomingFilter): IteratorLike<DeploymentRelationModel<M>>;
457
+ /**
458
+ * Outgoing relationships from the element and its descendants
459
+ * @see outgoers
460
+ */
461
+ outgoing(element: M['DeploymentOrFqn'], filter?: OutgoingFilter): IteratorLike<DeploymentRelationModel<M>>;
462
+ private addElement;
463
+ private addRelation;
464
+ }
465
+
466
+ type DeploymentElementsIterator<M extends AnyAux> = IteratorLike<DeploymentNodeModel<M> | DeployedInstanceModel<M>>;
467
+ type DeployedInstancesIterator<M extends AnyAux> = IteratorLike<DeployedInstanceModel<M>>;
468
+ type DeploymentNodesIterator<M extends AnyAux> = IteratorLike<DeploymentNodeModel<M>>;
469
+ type DeploymentElementModel<M extends AnyAux = AnyAux> = DeploymentNodeModel<M> | DeployedInstanceModel<M>;
470
+ declare abstract class AbstractDeploymentElementModel<M extends AnyAux = AnyAux> {
471
+ abstract readonly id: M['DeploymentFqn'];
472
+ abstract readonly parent: DeploymentNodeModel<M> | null;
473
+ abstract readonly title: string;
474
+ abstract readonly hierarchyLevel: number;
475
+ abstract readonly $model: LikeC4DeploymentModel<M>;
476
+ abstract readonly $node: DeploymentNode | DeployedInstance;
477
+ get style(): SetRequired<DeploymentElementStyle, 'shape' | 'color'>;
478
+ get shape(): ElementShape;
479
+ get color(): ThemeColor;
480
+ get tags(): ReadonlyArray<Tag>;
481
+ get kind(): DeploymentNodeKind | string | null;
482
+ get description(): string | null;
483
+ get technology(): string | null;
484
+ get links(): ReadonlyArray<Link>;
485
+ /**
486
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
487
+ * (from closest to root)
488
+ */
489
+ ancestors(): DeploymentNodesIterator<M>;
490
+ /**
491
+ * Returns the common ancestor of this element and another element.
492
+ */
493
+ commonAncestor(another: DeploymentElementModel<M>): DeploymentNodeModel<M> | null;
494
+ /**
495
+ * Get all sibling (i.e. same parent)
496
+ */
497
+ siblings(): DeploymentElementsIterator<M>;
498
+ /**
499
+ * Check if the element is a sibling of another element
500
+ */
501
+ isSibling(other: DeploymentElementModel<M>): boolean;
502
+ /**
503
+ * Resolve siblings of the element and its ancestors
504
+ * (from closest to root)
505
+ */
506
+ ascendingSiblings(): DeploymentElementsIterator<M>;
507
+ /**
508
+ * Resolve siblings of the element and its ancestors
509
+ * (from root to closest)
510
+ */
511
+ descendingSiblings(): DeploymentElementsIterator<M>;
512
+ incoming(filter?: IncomingFilter): IteratorLike<DeploymentRelationModel<M>>;
513
+ outgoing(filter?: OutgoingFilter): IteratorLike<DeploymentRelationModel<M>>;
514
+ incomers(filter?: IncomingFilter): IteratorLike<DeploymentRelationEndpoint<M>>;
515
+ outgoers(filter?: OutgoingFilter): IteratorLike<DeploymentRelationEndpoint<M>>;
516
+ /**
517
+ * Iterate over all views that include this deployment element.
518
+ */
519
+ views(): IteratorLike<LikeC4ViewModel<M, ComputedDeploymentView>>;
520
+ isDeploymentNode(): this is DeploymentNodeModel<M>;
521
+ isInstance(): this is DeployedInstanceModel<M>;
522
+ abstract outgoingModelRelationships(): RelationshipsIterator<M>;
523
+ abstract incomingModelRelationships(): RelationshipsIterator<M>;
524
+ protected cachedOutgoing: RelationshipsAccum<M> | null;
525
+ protected cachedIncoming: RelationshipsAccum<M> | null;
526
+ get allOutgoing(): RelationshipsAccum<M>;
527
+ get allIncoming(): RelationshipsAccum<M>;
528
+ }
529
+ declare class DeploymentNodeModel<M extends AnyAux = AnyAux> extends AbstractDeploymentElementModel<M> {
530
+ readonly $model: LikeC4DeploymentModel<M>;
531
+ readonly $node: DeploymentNode;
532
+ id: M['DeploymentFqn'];
533
+ title: string;
534
+ hierarchyLevel: number;
535
+ constructor($model: LikeC4DeploymentModel<M>, $node: DeploymentNode);
536
+ get parent(): DeploymentNodeModel<M> | null;
537
+ get kind(): DeploymentNodeKind;
538
+ children(): ReadonlySet<DeploymentElementModel<M>>;
539
+ descendants(sort?: 'asc' | 'desc'): DeploymentElementsIterator<M>;
540
+ isDeploymentNode(): this is DeploymentNodeModel<M>;
541
+ /**
542
+ * Iterate over all instances nested in this deployment node.
543
+ */
544
+ instances(): DeployedInstancesIterator<M>;
545
+ /**
546
+ * Returns deployed instance inside this deployment node
547
+ * if only there are no more instances
548
+ */
549
+ onlyOneInstance(): DeployedInstanceModel<M> | null;
550
+ /**
551
+ * Cached result of relationships from instances
552
+ */
553
+ private _relationshipsFromInstances;
554
+ private relationshipsFromInstances;
555
+ /**
556
+ * We return only relationships that are not already present in nested instances
557
+ */
558
+ outgoingModelRelationships(): RelationshipsIterator<M>;
559
+ /**
560
+ * We return only relationships that are not already present in nested instances
561
+ */
562
+ incomingModelRelationships(): RelationshipsIterator<M>;
563
+ /**
564
+ * Returns an iterator of relationships between nested instances
565
+ */
566
+ internalModelRelationships(): ReadonlySet<RelationshipModel<M>>;
567
+ }
568
+ declare class DeployedInstanceModel<M extends AnyAux = AnyAux> extends AbstractDeploymentElementModel<M> {
569
+ readonly $model: LikeC4DeploymentModel<M>;
570
+ readonly $instance: DeployedInstance;
571
+ readonly element: ElementModel<M>;
572
+ readonly id: M['DeploymentFqn'];
573
+ readonly title: string;
574
+ readonly hierarchyLevel: number;
575
+ constructor($model: LikeC4DeploymentModel<M>, $instance: DeployedInstance, element: ElementModel<M>);
576
+ get $node(): DeployedInstance;
577
+ get parent(): DeploymentNodeModel<M>;
578
+ get style(): SetRequired<DeploymentElementStyle, 'shape' | 'color'>;
579
+ get shape(): ElementShape;
580
+ get color(): ThemeColor;
581
+ get tags(): ReadonlyArray<Tag>;
582
+ get kind(): string | null;
583
+ get description(): string | null;
584
+ get technology(): string | null;
585
+ get links(): ReadonlyArray<Link>;
586
+ isInstance(): this is DeployedInstanceModel<M>;
587
+ outgoingModelRelationships(): RelationshipsIterator<M>;
588
+ incomingModelRelationships(): RelationshipsIterator<M>;
589
+ /**
590
+ * Iterate over all views that include this instance.
591
+ * (Some views may include the parent deployment node instead of the instance.)
592
+ */
593
+ views(): IteratorLike<LikeC4ViewModel<M, ComputedDeploymentView>>;
594
+ }
595
+ declare class NestedElementOfDeployedInstanceModel<M extends AnyAux> {
596
+ readonly instance: DeployedInstanceModel<M>;
597
+ readonly element: ElementModel<M>;
598
+ constructor(instance: DeployedInstanceModel<M>, element: ElementModel<M>);
599
+ get id(): M['DeploymentFqn'];
600
+ get style(): SetRequired<DeploymentElementStyle, 'shape' | 'color'>;
601
+ get shape(): ElementShape;
602
+ get color(): ThemeColor;
603
+ get title(): string;
604
+ get description(): string | null;
605
+ get technology(): string | null;
606
+ isDeploymentNode(): this is DeploymentNodeModel<M>;
607
+ isInstance(): this is DeployedInstanceModel<M>;
608
+ }
609
+ type DeploymentRelationEndpoint<M extends AnyAux> = DeploymentElementModel<M> | NestedElementOfDeployedInstanceModel<M>;
610
+ declare class DeploymentRelationModel<M extends AnyAux = AnyAux> {
611
+ readonly $model: LikeC4DeploymentModel<M>;
612
+ readonly $relationship: DeploymentRelation;
613
+ boundary: DeploymentNodeModel<M> | null;
614
+ source: DeploymentRelationEndpoint<M>;
615
+ target: DeploymentRelationEndpoint<M>;
616
+ constructor($model: LikeC4DeploymentModel<M>, $relationship: DeploymentRelation);
617
+ get id(): M['RelationId'];
618
+ get expression(): string;
619
+ get title(): string | null;
620
+ get technology(): string | null;
621
+ get description(): string | null;
622
+ get tags(): ReadonlyArray<Tag>;
623
+ get kind(): RelationshipKind | null;
624
+ get navigateTo(): LikeC4ViewModel<M> | null;
625
+ get links(): ReadonlyArray<Link>;
626
+ views(): IteratorLike<LikeC4ViewModel<M, ComputedDeploymentView>>;
627
+ isDeploymentRelation(): this is DeploymentRelationModel<M>;
628
+ }
629
+ declare class RelationshipsAccum<M extends AnyAux> {
630
+ readonly model: ReadonlySet<RelationshipModel<M>>;
631
+ readonly deployment: ReadonlySet<DeploymentRelationModel<M>>;
632
+ static empty<M extends AnyAux>(): RelationshipsAccum<M>;
633
+ static from<M extends AnyAux>(model: Iterable<RelationshipModel<M>> | undefined, deployment?: Iterable<DeploymentRelationModel<M>>): RelationshipsAccum<M>;
634
+ /**
635
+ * @param model relationships from logical model
636
+ * @param deployment relationships from deployment model
637
+ */
638
+ constructor(model?: ReadonlySet<RelationshipModel<M>>, deployment?: ReadonlySet<DeploymentRelationModel<M>>);
639
+ get isEmpty(): boolean;
640
+ get nonEmpty(): boolean;
641
+ get size(): number;
642
+ /**
643
+ * Returns new Accum containing all the elements which are both in this and otherAccum
644
+ */
645
+ intersect(otherAccum: RelationshipsAccum<M>): RelationshipsAccum<M>;
646
+ /**
647
+ * Returns new Accum containing all the elements which are both in this and otherAccum
648
+ */
649
+ difference(otherAccum: RelationshipsAccum<M>): RelationshipsAccum<M>;
650
+ /**
651
+ * Returns new Accum containing all the elements from both
652
+ */
653
+ union(otherAccum: RelationshipsAccum<M>): RelationshipsAccum<M>;
654
+ }
655
+
656
+ type ElementsIterator<M extends AnyAux> = IteratorLike<ElementModel<M>>;
657
+ declare class ElementModel<M extends AnyAux = AnyAux> {
658
+ readonly $model: LikeC4Model<M>;
659
+ readonly $element: Element;
660
+ readonly id: M['Fqn'];
661
+ readonly hierarchyLevel: number;
662
+ constructor($model: LikeC4Model<M>, $element: Element);
663
+ get parent(): ElementModel<M> | null;
664
+ get kind(): ElementKind;
665
+ get shape(): ElementShape;
666
+ get color(): ThemeColor;
667
+ get icon(): IconUrl | null;
668
+ get tags(): ReadonlyArray<Tag>;
669
+ get title(): string;
670
+ get description(): string | null;
671
+ get technology(): string | null;
672
+ get links(): ReadonlyArray<Link>;
673
+ get defaultView(): LikeC4ViewModel<M> | null;
674
+ get isRoot(): boolean;
675
+ isAncestorOf(another: ElementModel<M>): boolean;
676
+ isDescendantOf(another: ElementModel<M>): boolean;
677
+ /**
678
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
679
+ * (from closest to root)
680
+ */
681
+ ancestors(): ElementsIterator<M>;
682
+ /**
683
+ * Returns the common ancestor of this element and another element.
684
+ */
685
+ commonAncestor(another: ElementModel<M>): ElementModel<M> | null;
686
+ children(): ReadonlySet<ElementModel<M>>;
687
+ /**
688
+ * Get all descendant elements (i.e. children, children’s children, etc.)
689
+ */
690
+ descendants(sort?: 'asc' | 'desc'): ElementsIterator<M>;
691
+ /**
692
+ * Get all sibling (i.e. same parent)
693
+ */
694
+ siblings(): ElementsIterator<M>;
695
+ /**
696
+ * Resolve siblings of the element and its ancestors
697
+ * (from closest to root)
698
+ */
699
+ ascendingSiblings(): ElementsIterator<M>;
700
+ /**
701
+ * Resolve siblings of the element and its ancestors
702
+ * (from root to closest)
703
+ */
704
+ descendingSiblings(): ElementsIterator<M>;
705
+ incoming(filter?: IncomingFilter): RelationshipsIterator<M>;
706
+ incomers(filter?: IncomingFilter): ElementsIterator<M>;
707
+ outgoing(filter?: OutgoingFilter): RelationshipsIterator<M>;
708
+ outgoers(filter?: OutgoingFilter): ElementsIterator<M>;
709
+ protected cachedOutgoing: Set<RelationshipModel<M>> | null;
710
+ protected cachedIncoming: Set<RelationshipModel<M>> | null;
711
+ get allOutgoing(): ReadonlySet<RelationshipModel<M>>;
712
+ get allIncoming(): ReadonlySet<RelationshipModel<M>>;
713
+ /**
714
+ * Iterate over all views that include this element.
715
+ */
716
+ views(): ViewsIterator<M>;
717
+ /**
718
+ * Iterate over all views that scope this element.
719
+ * It is possible that element is not included in the view.
720
+ */
721
+ scopedViews(): ViewsIterator<M>;
722
+ /**
723
+ * @returns true if the element is deployed
724
+ */
725
+ isDeployed(): boolean;
726
+ deployments(): DeployedInstancesIterator<M>;
727
+ }
728
+
729
+ export { type AnyAux as A, type ComputeViewResult as C, type DeploymentElementModel as D, ElementModel as E, LikeC4Model as L, NodeModel as N, RelationshipModel as R, computeViews as a, Aux as b, computeView as c, LikeC4DeploymentModel as d, LikeC4ViewModel as e, DeploymentNodeModel as f, DeployedInstanceModel as g, RelationshipsAccum as h, DeploymentRelationModel as i, EdgeModel as j, unsafeComputeView as u };