@likec4/core 1.17.1 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/compute-view/index.d.mts +91 -0
  2. package/dist/compute-view/index.d.ts +91 -0
  3. package/dist/compute-view/index.mjs +79 -0
  4. package/dist/index.d.mts +246 -434
  5. package/dist/index.d.ts +246 -434
  6. package/dist/index.mjs +418 -1322
  7. package/dist/model/index.d.mts +642 -0
  8. package/dist/model/index.d.ts +642 -0
  9. package/dist/model/index.mjs +2 -0
  10. package/dist/shared/core.BBgiAAv1.mjs +144 -0
  11. package/dist/shared/core.BPyJvuMU.mjs +2420 -0
  12. package/dist/shared/core.BQ4AbfvB.mjs +9228 -0
  13. package/dist/shared/{core.CoLQkcYL.d.mts → core.DMYY7C8s.d.mts} +398 -249
  14. package/dist/shared/{core.CoLQkcYL.d.ts → core.DMYY7C8s.d.ts} +398 -249
  15. package/dist/shared/core.k12s_keD.mjs +203 -0
  16. package/dist/types/index.d.mts +69 -1
  17. package/dist/types/index.d.ts +69 -1
  18. package/dist/types/index.mjs +21 -1
  19. package/package.json +38 -40
  20. package/src/builder/Builder.deployment.ts +219 -0
  21. package/src/builder/Builder.deploymentModel.ts +360 -0
  22. package/src/builder/Builder.element.ts +17 -19
  23. package/src/builder/Builder.model.ts +13 -2
  24. package/src/builder/Builder.test-d.ts +59 -4
  25. package/src/builder/Builder.ts +238 -53
  26. package/src/builder/Builder.view.ts +238 -53
  27. package/src/builder/_types.ts +87 -15
  28. package/src/compute-view/LikeC4ModelGraph.ts +330 -0
  29. package/src/compute-view/compute-view.ts +92 -0
  30. package/src/compute-view/deployment-view/Memory.ts +108 -0
  31. package/src/compute-view/deployment-view/Stage.ts +145 -0
  32. package/src/compute-view/deployment-view/__test__/fixture.ts +210 -0
  33. package/src/compute-view/deployment-view/_types.ts +29 -0
  34. package/src/compute-view/deployment-view/clean-connections.ts +229 -0
  35. package/src/compute-view/deployment-view/compute.ts +111 -0
  36. package/src/compute-view/deployment-view/predicates/deployment-ref.ts +146 -0
  37. package/src/compute-view/deployment-view/predicates/relation-direct.ts +130 -0
  38. package/src/compute-view/deployment-view/predicates/relation-in-out.ts +43 -0
  39. package/src/compute-view/deployment-view/predicates/relation-incoming.ts +46 -0
  40. package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +49 -0
  41. package/src/compute-view/deployment-view/predicates/wildcard.ts +29 -0
  42. package/src/compute-view/deployment-view/utils.ts +212 -0
  43. package/src/compute-view/dynamic-view/__test__/fixture.ts +58 -0
  44. package/src/compute-view/dynamic-view/compute.ts +310 -0
  45. package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +456 -0
  46. package/src/compute-view/element-view/__test__/fixture.ts +645 -0
  47. package/src/compute-view/element-view/compute.ts +734 -0
  48. package/src/compute-view/element-view/predicates.ts +517 -0
  49. package/src/compute-view/index.ts +5 -0
  50. package/src/compute-view/utils/__snapshots__/sortNodes.spec.ts.snap +113 -0
  51. package/src/compute-view/utils/ancestorsOfNode.ts +19 -0
  52. package/src/compute-view/utils/applyCustomElementProperties.ts +66 -0
  53. package/src/compute-view/utils/applyCustomRelationProperties.ts +41 -0
  54. package/src/compute-view/utils/applyViewRuleStyles.ts +53 -0
  55. package/src/compute-view/utils/buildComputedNodes.ts +148 -0
  56. package/src/compute-view/utils/buildElementNotations.ts +63 -0
  57. package/src/compute-view/utils/derive-edge-props-from-relationships.ts +97 -0
  58. package/src/compute-view/utils/elementExpressionToPredicate.ts +52 -0
  59. package/src/compute-view/utils/link-nodes-with-edges.ts +58 -0
  60. package/src/compute-view/utils/relationExpressionToPredicates.ts +55 -0
  61. package/src/compute-view/utils/resolve-extended-views.ts +65 -0
  62. package/src/compute-view/utils/resolve-global-rules.ts +83 -0
  63. package/src/compute-view/utils/sortNodes.ts +101 -0
  64. package/src/compute-view/utils/topological-sort.ts +160 -0
  65. package/src/compute-view/utils/uniqueTags.test.ts +42 -0
  66. package/src/compute-view/utils/uniqueTags.ts +21 -0
  67. package/src/compute-view/utils/view-hash.ts +27 -0
  68. package/src/compute-view/utils/with-readable-edges.ts +31 -0
  69. package/src/index.ts +5 -1
  70. package/src/model/DeploymentElementModel.ts +534 -0
  71. package/src/model/DeploymentModel.ts +364 -0
  72. package/src/model/ElementModel.ts +195 -0
  73. package/src/model/LikeC4Model.test-d.ts +151 -0
  74. package/src/model/LikeC4Model.ts +280 -457
  75. package/src/model/RelationModel.ts +84 -0
  76. package/src/model/__test__/fixture.ts +153 -338
  77. package/src/model/connection/ConnectionModel.ts +94 -0
  78. package/src/model/connection/DeploymentConnectionModel.ts +99 -0
  79. package/src/model/connection/deployment.ts +124 -0
  80. package/src/model/connection/model.ts +123 -0
  81. package/src/model/index.ts +4 -2
  82. package/src/model/types.ts +95 -15
  83. package/src/model/view/EdgeModel.ts +103 -0
  84. package/src/model/view/LikeC4ViewModel.ts +220 -0
  85. package/src/model/view/NodeModel.ts +228 -0
  86. package/src/types/_common.ts +2 -0
  87. package/src/types/deployments.ts +237 -0
  88. package/src/types/element.ts +7 -3
  89. package/src/types/expression.ts +8 -6
  90. package/src/types/index.ts +1 -0
  91. package/src/types/model.ts +68 -9
  92. package/src/types/overview-graph.ts +2 -2
  93. package/src/types/relation.ts +4 -4
  94. package/src/types/view-notation.ts +2 -2
  95. package/src/types/view.ts +104 -30
  96. package/src/utils/{commonHead.ts → common-head.ts} +2 -0
  97. package/src/utils/fqn.ts +83 -27
  98. package/src/utils/getOrCreate.ts +42 -0
  99. package/src/utils/graphlib.ts +10 -0
  100. package/src/utils/index.ts +4 -1
  101. package/src/utils/object-hash.ts +3 -0
  102. package/src/utils/set.ts +76 -0
  103. package/src/utils/string-hash.ts +16 -0
  104. package/dist/index.cjs +0 -5452
  105. package/dist/index.d.cts +0 -1053
  106. package/dist/shared/core.BXTs-8n7.mjs +0 -293
  107. package/dist/shared/core.CoLQkcYL.d.cts +0 -734
  108. package/dist/shared/core.DIYZvpVg.cjs +0 -353
  109. package/dist/types/index.cjs +0 -70
  110. package/dist/types/index.d.cts +0 -2
  111. package/src/model/LikeC4DiagramModel.ts +0 -338
  112. package/src/model/LikeC4ViewModel.ts +0 -320
@@ -0,0 +1,642 @@
1
+ import { IsLiteral, LiteralUnion, Simplify, SetRequired } from 'type-fest';
2
+ import { F as Fqn, b3 as ViewId, b as RelationId, bE as NodeId, bF as EdgeId, aD as AnyLikeC4Model, K as KeysOf, aE as LayoutedLikeC4Model, bY as DiagramView, a as ComputedView, aC as ParsedLikeC4ModelDump, R as Relation, Y as Tag, _ as Link, E as Element, O as ElementKind, f as ElementShape, aX as ThemeColor, t as DeploymentNodeKind, g as Color, bS as ComputedDynamicView, bH as StepEdgeId, bR as ComputedElementView, bT as ComputedDeploymentView, x as DeploymentRef, v as DeploymentNode, w as DeployedInstance, u as PhysicalElementStyle, k as DeploymentRelation } from '../shared/core.DMYY7C8s.js';
3
+
4
+ type IncomingFilter = 'all' | 'direct' | 'to-descendants';
5
+ type OutgoingFilter = 'all' | 'direct' | 'from-descendants';
6
+ type IteratorLike<T> = IteratorObject<T, BuiltinIteratorReturn>;
7
+ type WithId<Id> = {
8
+ id: Id;
9
+ };
10
+ type WithViews<Id extends string, ViewType> = {
11
+ views: Record<Id, ViewType>;
12
+ };
13
+ type AnyAux = Aux<string, string, string, any>;
14
+ /**
15
+ * Auxilary type to keep track
16
+ */
17
+ interface Aux<Element extends string, Deployment extends string, Views extends string, ViewType> {
18
+ Fqn: IsLiteral<Element> extends true ? Fqn<Element> : Fqn;
19
+ Element: Element;
20
+ ElementOrFqn: Element | WithId<this['Fqn']>;
21
+ DeploymentFqn: IsLiteral<Deployment> extends true ? Fqn<Deployment> : Fqn;
22
+ Deployment: Deployment;
23
+ DeploymentOrFqn: Deployment | WithId<this['DeploymentFqn']>;
24
+ ViewId: IsLiteral<Views> extends true ? ViewId<Views> : ViewId;
25
+ ViewIdLiteral: Views;
26
+ ViewType: ViewType;
27
+ RelationId: RelationId;
28
+ NodeId: NodeId;
29
+ NodeIdLiteral: string;
30
+ EdgeId: EdgeId;
31
+ EdgeIdLiteral: string;
32
+ NodeOrId: LiteralUnion<this['NodeIdLiteral'], string> | WithId<this['NodeId']>;
33
+ EdgeOrId: LiteralUnion<this['EdgeIdLiteral'], string> | WithId<this['EdgeId']>;
34
+ Model: Simplify<Omit<AnyLikeC4Model, 'views'> & WithViews<this['ViewId'], ViewType>>;
35
+ }
36
+ declare namespace Aux {
37
+ type FromModel<M> = M extends AnyLikeC4Model ? Aux<KeysOf<M['elements']>, KeysOf<M['deployments']['elements']>, KeysOf<M['views']>, M extends LayoutedLikeC4Model ? DiagramView<ViewId<KeysOf<M['views']>>, string> : ComputedView<ViewId<KeysOf<M['views']>>, string>> : never;
38
+ type FromDump<M> = M extends ParsedLikeC4ModelDump ? Aux<KeysOf<M['elements']>, KeysOf<M['deployments']['elements']>, KeysOf<M['views']>, DiagramView<ViewId<KeysOf<M['views']>>, string>> : never;
39
+ }
40
+
41
+ type RelationshipsIterator<M extends AnyAux> = IteratorLike<RelationshipModel<M>>;
42
+ declare class RelationshipModel<M extends AnyAux> {
43
+ readonly model: LikeC4Model<M>;
44
+ readonly $relationship: Relation;
45
+ readonly source: ElementModel<M>;
46
+ readonly target: ElementModel<M>;
47
+ /**
48
+ * Common ancestor of the source and target elements.
49
+ * Represents the boundary of the Relation.
50
+ */
51
+ readonly boundary: ElementModel<M> | null;
52
+ constructor(model: LikeC4Model<M>, $relationship: Relation);
53
+ get id(): M['RelationId'];
54
+ get expression(): string;
55
+ get title(): string | null;
56
+ get technology(): string | null;
57
+ get description(): string | null;
58
+ get navigateTo(): LikeC4ViewModel<M> | null;
59
+ get tags(): ReadonlyArray<Tag>;
60
+ get links(): ReadonlyArray<Link>;
61
+ /**
62
+ * Iterate over all views that include this relationship.
63
+ */
64
+ views(): ViewsIterator<M>;
65
+ }
66
+
67
+ type ElementsIterator<M extends AnyAux> = IteratorLike<ElementModel<M>>;
68
+ declare class ElementModel<M extends AnyAux> {
69
+ readonly model: LikeC4Model<M>;
70
+ readonly $element: Element;
71
+ constructor(model: LikeC4Model<M>, $element: Element);
72
+ get id(): M['Fqn'];
73
+ get kind(): ElementKind;
74
+ get shape(): ElementShape;
75
+ get color(): ThemeColor;
76
+ get tags(): ReadonlyArray<Tag>;
77
+ get title(): string;
78
+ get description(): string | null;
79
+ get technology(): string | null;
80
+ get links(): ReadonlyArray<Link>;
81
+ get parent(): ElementModel<M> | null;
82
+ get defaultView(): LikeC4ViewModel<M> | null;
83
+ /**
84
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
85
+ * (from closest to root)
86
+ */
87
+ ancestors(): ElementsIterator<M>;
88
+ /**
89
+ * Returns the common ancestor of this element and another element.
90
+ */
91
+ commonAncestor(another: ElementModel<M>): ElementModel<M> | null;
92
+ children(): ReadonlySet<ElementModel<M>>;
93
+ /**
94
+ * Get all descendant elements (i.e. children, children’s children, etc.)
95
+ */
96
+ descendants(): ElementsIterator<M>;
97
+ /**
98
+ * Get all sibling (i.e. same parent)
99
+ */
100
+ siblings(): ElementsIterator<M>;
101
+ /**
102
+ * Resolve siblings of the element and its ancestors
103
+ * (from closest to root)
104
+ */
105
+ ascendingSiblings(): ElementsIterator<M>;
106
+ incoming(filter?: IncomingFilter): RelationshipsIterator<M>;
107
+ incomers(filter?: IncomingFilter): ElementsIterator<M>;
108
+ outgoing(filter?: OutgoingFilter): RelationshipsIterator<M>;
109
+ outgoers(filter?: OutgoingFilter): ElementsIterator<M>;
110
+ protected cachedOutgoing: Set<RelationshipModel<M>> | null;
111
+ protected cachedIncoming: Set<RelationshipModel<M>> | null;
112
+ get allOutgoing(): ReadonlySet<RelationshipModel<M>>;
113
+ get allIncoming(): ReadonlySet<RelationshipModel<M>>;
114
+ /**
115
+ * Iterate over all views that include this element.
116
+ */
117
+ views(): ViewsIterator<M>;
118
+ /**
119
+ * Iterate over all views that scope this element.
120
+ * It is possible that element is not included in the view.
121
+ */
122
+ scopedViews(): ViewsIterator<M>;
123
+ /**
124
+ * @returns true if the element is deployed
125
+ */
126
+ isDeployed(): boolean;
127
+ deployments(): DeployedInstancesIterator<M>;
128
+ }
129
+
130
+ type NodesIterator<M extends AnyAux, V extends ComputedView | DiagramView> = IteratorLike<NodeModel<M, V>>;
131
+ declare namespace NodeModel {
132
+ interface WithParent<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
133
+ parent: NodeModel<M, V>;
134
+ }
135
+ interface WithElement<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
136
+ kind: ElementKind;
137
+ element: ElementModel<M>;
138
+ }
139
+ interface WithDeploymentElement<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
140
+ kind: DeploymentNodeKind;
141
+ deployment: DeploymentElementModel<M>;
142
+ }
143
+ interface WithDeployedInstance<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
144
+ kind: 'instance';
145
+ element: ElementModel<M>;
146
+ deployment: DeployedInstanceModel<M>;
147
+ }
148
+ interface IsGroup<M extends AnyAux, V extends ComputedView | DiagramView> extends NodeModel<M, V> {
149
+ kind: typeof ElementKind.Group;
150
+ element: null;
151
+ deployment: null;
152
+ }
153
+ }
154
+ declare class NodeModel<M extends AnyAux, V extends ComputedView | DiagramView = M['ViewType']> {
155
+ readonly $view: LikeC4ViewModel<M, V>;
156
+ readonly $node: V['nodes'][number];
157
+ constructor($view: LikeC4ViewModel<M, V>, $node: V['nodes'][number]);
158
+ get id(): NodeId;
159
+ get title(): string;
160
+ get kind(): ElementKind | DeploymentNodeKind | typeof ElementKind.Group | 'instance';
161
+ get description(): string | null;
162
+ get technology(): string | null;
163
+ get parent(): NodeModel<M, V> | null;
164
+ get element(): ElementModel<M> | null;
165
+ get deployment(): DeploymentElementModel<M> | null;
166
+ get shape(): ElementShape;
167
+ get color(): Color;
168
+ get tags(): ReadonlyArray<Tag>;
169
+ get links(): ReadonlyArray<Link>;
170
+ get navigateTo(): LikeC4ViewModel<M> | null;
171
+ /**
172
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
173
+ * (from closest to root)
174
+ */
175
+ ancestors(): NodesIterator<M, V>;
176
+ children(): NodesIterator<M, V>;
177
+ sublings(): NodesIterator<M, V>;
178
+ incoming(filter?: IncomingFilter): EdgesIterator<M, V>;
179
+ incomers(filter?: IncomingFilter): NodesIterator<M, V>;
180
+ outgoing(filter?: OutgoingFilter): EdgesIterator<M, V>;
181
+ outgoers(filter?: OutgoingFilter): NodesIterator<M, V>;
182
+ isDiagramNode(): this is NodeModel<M, DiagramView>;
183
+ hasChildren(): boolean;
184
+ hasParent(): this is NodeModel.WithParent<M, V>;
185
+ /**
186
+ * Check if this node references to logical model element.
187
+ */
188
+ hasElement(): this is NodeModel.WithElement<M, V>;
189
+ /**
190
+ * Check if this node references to deployment element (Node or Instance).
191
+ */
192
+ hasDeployment(): this is NodeModel.WithDeploymentElement<M, V>;
193
+ /**
194
+ * Check if this node references to deployed instance
195
+ * Deployed instance always references to element and deployment element.
196
+ */
197
+ hasDeployedInstance(): this is NodeModel.WithDeployedInstance<M, V>;
198
+ isGroup(): this is NodeModel.IsGroup<M, V>;
199
+ }
200
+
201
+ type EdgesIterator<M extends AnyAux, V extends ComputedView | DiagramView> = IteratorLike<EdgeModel<M, V>>;
202
+ declare class EdgeModel<M extends AnyAux, V extends ComputedView | DiagramView = M['ViewType']> {
203
+ readonly view: LikeC4ViewModel<M, V>;
204
+ readonly $edge: V['edges'][number];
205
+ readonly source: NodeModel<M, V>;
206
+ readonly target: NodeModel<M, V>;
207
+ constructor(view: LikeC4ViewModel<M, V>, $edge: V['edges'][number], source: NodeModel<M, V>, target: NodeModel<M, V>);
208
+ get id(): M['EdgeId'];
209
+ get parent(): NodeModel<M, V> | null;
210
+ get label(): string | null;
211
+ get description(): string | null;
212
+ get technology(): string | null;
213
+ hasParent(): this is EdgeModel.WithParent<M, V>;
214
+ get tags(): ReadonlyArray<Tag>;
215
+ get stepNumber(): number | null;
216
+ get navigateTo(): LikeC4ViewModel<M> | null;
217
+ isStep(): this is EdgeModel.StepEdge<M, ComputedDynamicView>;
218
+ relationships(type: 'model'): IteratorLike<RelationshipModel<M>>;
219
+ relationships(type: 'deployment'): IteratorLike<DeploymentRelationModel<M>>;
220
+ relationships(type?: 'model' | 'deployment'): IteratorLike<LikeC4Model.AnyRelation<M>>;
221
+ includesRelation(rel: M['RelationId']): boolean;
222
+ }
223
+ declare namespace EdgeModel {
224
+ interface StepEdge<M extends AnyAux, V extends ComputedView | DiagramView> extends EdgeModel<M, V> {
225
+ id: StepEdgeId;
226
+ stepNumber: number;
227
+ }
228
+ interface WithParent<M extends AnyAux, V extends ComputedView | DiagramView> extends EdgeModel<M, V> {
229
+ parent: NodeModel<M, V>;
230
+ }
231
+ }
232
+
233
+ type ViewsIterator<M extends AnyAux> = IteratorLike<LikeC4ViewModel<M>>;
234
+ declare class LikeC4ViewModel<M extends AnyAux, V extends ComputedView | DiagramView = M['ViewType']> {
235
+ #private;
236
+ readonly $model: LikeC4Model<M>;
237
+ readonly $view: V;
238
+ constructor($model: LikeC4Model<M>, $view: V);
239
+ get __(): NonNullable<M['ViewType']['__']>;
240
+ get id(): M['ViewId'];
241
+ get title(): string | null;
242
+ get tags(): ReadonlyArray<Tag>;
243
+ get links(): ReadonlyArray<Link>;
244
+ get viewOf(): ElementModel<M> | null;
245
+ /**
246
+ * All tags from nodes and edges.
247
+ */
248
+ get includedTags(): ReadonlyArray<Tag>;
249
+ roots(): NodesIterator<M, V>;
250
+ /**
251
+ * Iterate over all nodes that have children.
252
+ */
253
+ compounds(): NodesIterator<M, V>;
254
+ /**
255
+ * Get node by id.
256
+ * @throws Error if node is not found.
257
+ */
258
+ node(node: M['NodeOrId']): NodeModel<M, V>;
259
+ /**
260
+ * Find node by id.
261
+ */
262
+ findNode(node: M['NodeOrId']): NodeModel<M, V> | null;
263
+ /**
264
+ * Iterate over all nodes.
265
+ */
266
+ nodes(): NodesIterator<M, V>;
267
+ /**
268
+ * Find edge by id.
269
+ * @param edge Edge or id
270
+ * @returns EdgeModel
271
+ */
272
+ edge(edge: M['EdgeOrId']): EdgeModel<M, V>;
273
+ findEdge(edge: M['EdgeOrId']): EdgeModel<M, V> | null;
274
+ /**
275
+ * Iterate over all edges.
276
+ */
277
+ edges(): EdgesIterator<M, V>;
278
+ /**
279
+ * Iterate over all edges.
280
+ */
281
+ edgesWithRelation(relation: M['RelationId']): EdgesIterator<M, V>;
282
+ /**
283
+ * Nodes that have references to elements from logical model.
284
+ */
285
+ elements(): IteratorLike<NodeModel.WithElement<M, V>>;
286
+ includesElement(elementId: M['Element']): boolean;
287
+ includesDeployment(deploymentId: M['Deployment']): boolean;
288
+ includesRelation(relationId: M['RelationId']): boolean;
289
+ /**
290
+ * Below are type guards.
291
+ */
292
+ isComputed(): this is LikeC4ViewModel<M, ComputedView>;
293
+ isDiagram(): this is LikeC4ViewModel<M, DiagramView>;
294
+ isElementView(): this is LikeC4ViewModel<M, ComputedElementView>;
295
+ isDeploymentView(): this is LikeC4ViewModel<M, ComputedDeploymentView>;
296
+ isDynamicView(): this is LikeC4ViewModel<M, ComputedDynamicView>;
297
+ }
298
+
299
+ declare class LikeC4DeploymentModel<M extends AnyAux = AnyAux> {
300
+ #private;
301
+ readonly $model: LikeC4Model<M>;
302
+ readonly $deployments: AnyLikeC4Model['deployments'];
303
+ constructor($model: LikeC4Model<M>, $deployments: AnyLikeC4Model['deployments']);
304
+ element(el: M['DeploymentOrFqn']): DeploymentElementModel<M>;
305
+ findElement(el: M['Deployment']): DeploymentElementModel<M> | null;
306
+ node(el: M['DeploymentOrFqn']): DeploymentNodeModel<M>;
307
+ findNode(el: M['Deployment']): DeploymentNodeModel<M> | null;
308
+ instance(el: M['DeploymentOrFqn']): DeployedInstanceModel<M>;
309
+ findInstance(el: M['Deployment']): DeployedInstanceModel<M> | null;
310
+ /**
311
+ * Returns the root elements of the model.
312
+ */
313
+ roots(): DeploymentNodesIterator<M>;
314
+ /**
315
+ * Returns all elements in the model.
316
+ */
317
+ elements(): DeploymentElementsIterator<M>;
318
+ /**
319
+ * Returns all elements in the model.
320
+ */
321
+ nodes(): DeploymentNodesIterator<M>;
322
+ instances(): DeployedInstancesIterator<M>;
323
+ /**
324
+ * Iterate over all instances of the given logical element.
325
+ */
326
+ instancesOf(element: M['ElementOrFqn']): DeployedInstancesIterator<M>;
327
+ deploymentRef(ref: DeploymentRef): DeploymentElementModel<M> | NestedElementOfDeployedInstanceModel<M>;
328
+ /**
329
+ * Returns all relationships in the model.
330
+ */
331
+ relationships(): IteratorLike<DeploymentRelationModel<M>>;
332
+ /**
333
+ * Returns a specific relationship by its ID.
334
+ */
335
+ relationship(id: M['RelationId']): DeploymentRelationModel<M>;
336
+ findRelationship(id: LiteralUnion<M['RelationId'], string>): DeploymentRelationModel<M> | null;
337
+ /**
338
+ * Returns all deployment views in the model.
339
+ */
340
+ views(): IteratorLike<LikeC4ViewModel<M, ComputedDeploymentView>>;
341
+ /**
342
+ * Returns the parent element of given element.
343
+ * @see ancestors
344
+ */
345
+ parent(element: M['DeploymentOrFqn']): DeploymentNodeModel<M> | null;
346
+ /**
347
+ * Get all children of the element (only direct children),
348
+ * @see descendants
349
+ */
350
+ children(element: M['DeploymentOrFqn']): ReadonlySet<DeploymentElementModel<M>>;
351
+ /**
352
+ * Get all sibling (i.e. same parent)
353
+ */
354
+ siblings(element: M['DeploymentOrFqn']): DeploymentElementsIterator<M>;
355
+ /**
356
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
357
+ * (from closest to root)
358
+ */
359
+ ancestors(element: M['DeploymentOrFqn']): DeploymentNodesIterator<M>;
360
+ /**
361
+ * Get all descendant elements (i.e. children, children’s children, etc.)
362
+ */
363
+ descendants(element: M['DeploymentOrFqn']): DeploymentElementsIterator<M>;
364
+ /**
365
+ * Incoming relationships to the element and its descendants
366
+ * @see incomers
367
+ */
368
+ incoming(element: M['DeploymentOrFqn'], filter?: IncomingFilter): IteratorLike<DeploymentRelationModel<M>>;
369
+ /**
370
+ * Outgoing relationships from the element and its descendants
371
+ * @see outgoers
372
+ */
373
+ outgoing(element: M['DeploymentOrFqn'], filter?: OutgoingFilter): IteratorLike<DeploymentRelationModel<M>>;
374
+ private addElement;
375
+ private addRelation;
376
+ }
377
+
378
+ type DeploymentElementsIterator<M extends AnyAux> = IteratorLike<DeploymentElementModel<M>>;
379
+ type DeployedInstancesIterator<M extends AnyAux> = IteratorLike<DeployedInstanceModel<M>>;
380
+ type DeploymentNodesIterator<M extends AnyAux> = IteratorLike<DeploymentNodeModel<M>>;
381
+ declare abstract class DeploymentElementModel<M extends AnyAux = AnyAux> {
382
+ abstract readonly $model: LikeC4DeploymentModel<M>;
383
+ abstract readonly $node: DeploymentNode | DeployedInstance;
384
+ get id(): M['DeploymentFqn'];
385
+ get style(): SetRequired<PhysicalElementStyle, 'shape' | 'color'>;
386
+ get shape(): ElementShape;
387
+ get color(): ThemeColor;
388
+ get tags(): ReadonlyArray<Tag>;
389
+ get title(): string;
390
+ get description(): string | null;
391
+ get technology(): string | null;
392
+ get parent(): DeploymentNodeModel<M> | null;
393
+ get links(): ReadonlyArray<Link>;
394
+ /**
395
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
396
+ * (from closest to root)
397
+ */
398
+ ancestors(): DeploymentNodesIterator<M>;
399
+ /**
400
+ * Returns the common ancestor of this element and another element.
401
+ */
402
+ commonAncestor(another: DeploymentElementModel<M>): DeploymentNodeModel<M> | null;
403
+ /**
404
+ * Get all sibling (i.e. same parent)
405
+ */
406
+ siblings(): DeploymentElementsIterator<M>;
407
+ /**
408
+ * Check if the element is a sibling of another element
409
+ */
410
+ isSibling(other: DeploymentElementModel<M>): boolean;
411
+ /**
412
+ * Resolve siblings of the element and its ancestors
413
+ * (from closest to root)
414
+ */
415
+ ascendingSiblings(): DeploymentElementsIterator<M>;
416
+ incoming(filter?: IncomingFilter): IteratorLike<DeploymentRelationModel<M>>;
417
+ outgoing(filter?: OutgoingFilter): IteratorLike<DeploymentRelationModel<M>>;
418
+ incomers(filter?: IncomingFilter): IteratorLike<DeploymentRelationEndpoint<M>>;
419
+ outgoers(filter?: OutgoingFilter): IteratorLike<DeploymentRelationEndpoint<M>>;
420
+ /**
421
+ * Iterate over all views that include this deployment element.
422
+ */
423
+ views(): IteratorLike<LikeC4ViewModel<M, ComputedDeploymentView>>;
424
+ isDeploymentNode(): this is DeploymentNodeModel<M>;
425
+ isInstance(): this is DeployedInstanceModel<M>;
426
+ abstract outgoingFromModel(): RelationshipsIterator<M>;
427
+ abstract incomingFromModel(): RelationshipsIterator<M>;
428
+ protected cachedOutgoing: RelationshipsAccum<M> | null;
429
+ protected cachedIncoming: RelationshipsAccum<M> | null;
430
+ get allOutgoing(): RelationshipsAccum<M>;
431
+ get allIncoming(): RelationshipsAccum<M>;
432
+ }
433
+ declare class DeploymentNodeModel<M extends AnyAux = AnyAux> extends DeploymentElementModel<M> {
434
+ readonly $model: LikeC4DeploymentModel<M>;
435
+ readonly $node: DeploymentNode;
436
+ constructor($model: LikeC4DeploymentModel<M>, $node: DeploymentNode);
437
+ get kind(): DeploymentNodeKind;
438
+ children(): ReadonlySet<DeploymentElementModel<M>>;
439
+ descendants(): DeploymentElementsIterator<M>;
440
+ isDeploymentNode(): this is DeploymentNodeModel<M>;
441
+ /**
442
+ * Iterate over all instances nested in this deployment node.
443
+ */
444
+ instances(): DeployedInstancesIterator<M>;
445
+ /**
446
+ * Returns deployed instance inside this deployment node
447
+ * if only there are no more instances
448
+ */
449
+ onlyOneInstance(): DeployedInstanceModel<M> | null;
450
+ /**
451
+ * Cached result of relationships from instances
452
+ */
453
+ private _relationshipsFromInstances;
454
+ private relationshipsFromInstances;
455
+ /**
456
+ * We return only relationships that are not already present in nested instances
457
+ */
458
+ outgoingFromModel(): RelationshipsIterator<M>;
459
+ /**
460
+ * We return only relationships that are not already present in nested instances
461
+ */
462
+ incomingFromModel(): RelationshipsIterator<M>;
463
+ }
464
+ declare class DeployedInstanceModel<M extends AnyAux = AnyAux> extends DeploymentElementModel<M> {
465
+ readonly $model: LikeC4DeploymentModel<M>;
466
+ readonly $instance: DeployedInstance;
467
+ readonly $element: ElementModel<M>;
468
+ constructor($model: LikeC4DeploymentModel<M>, $instance: DeployedInstance, $element: ElementModel<M>);
469
+ get parent(): DeploymentNodeModel<M>;
470
+ get $node(): DeployedInstance;
471
+ get style(): SetRequired<PhysicalElementStyle, 'shape' | 'color'>;
472
+ get shape(): ElementShape;
473
+ get color(): ThemeColor;
474
+ get tags(): ReadonlyArray<Tag>;
475
+ get title(): string;
476
+ get description(): string | null;
477
+ get technology(): string | null;
478
+ get links(): ReadonlyArray<Link>;
479
+ isInstance(): this is DeployedInstanceModel<M>;
480
+ outgoingFromModel(): RelationshipsIterator<M>;
481
+ incomingFromModel(): RelationshipsIterator<M>;
482
+ }
483
+ declare class NestedElementOfDeployedInstanceModel<M extends AnyAux> {
484
+ readonly instance: DeployedInstanceModel<M>;
485
+ readonly element: ElementModel<M>;
486
+ constructor(instance: DeployedInstanceModel<M>, element: ElementModel<M>);
487
+ get id(): M['DeploymentFqn'];
488
+ get style(): SetRequired<PhysicalElementStyle, 'shape' | 'color'>;
489
+ get shape(): ElementShape;
490
+ get color(): ThemeColor;
491
+ get title(): string;
492
+ get description(): string | null;
493
+ get technology(): string | null;
494
+ isDeploymentNode(): this is DeploymentNodeModel<M>;
495
+ isInstance(): this is DeployedInstanceModel<M>;
496
+ }
497
+ type DeploymentRelationEndpoint<M extends AnyAux> = DeploymentElementModel<M> | NestedElementOfDeployedInstanceModel<M>;
498
+ declare class DeploymentRelationModel<M extends AnyAux> {
499
+ readonly $model: LikeC4DeploymentModel<M>;
500
+ readonly $relationship: DeploymentRelation;
501
+ boundary: DeploymentNodeModel<M> | null;
502
+ source: DeploymentRelationEndpoint<M>;
503
+ target: DeploymentRelationEndpoint<M>;
504
+ constructor($model: LikeC4DeploymentModel<M>, $relationship: DeploymentRelation);
505
+ get id(): M['RelationId'];
506
+ get expression(): string;
507
+ get title(): string | null;
508
+ get technology(): string | null;
509
+ get description(): string | null;
510
+ get tags(): ReadonlyArray<Tag>;
511
+ get navigateTo(): LikeC4ViewModel<M> | null;
512
+ get links(): ReadonlyArray<Link>;
513
+ views(): IteratorLike<LikeC4ViewModel<M, ComputedDeploymentView>>;
514
+ }
515
+ declare class RelationshipsAccum<M extends AnyAux> {
516
+ readonly model: ReadonlySet<RelationshipModel<M>>;
517
+ readonly deployment: ReadonlySet<DeploymentRelationModel<M>>;
518
+ /**
519
+ * @param model relationships from logical model
520
+ * @param deployment relationships from deployment model
521
+ */
522
+ constructor(model: ReadonlySet<RelationshipModel<M>>, deployment: ReadonlySet<DeploymentRelationModel<M>>);
523
+ get isEmpty(): boolean;
524
+ get nonEmpty(): boolean;
525
+ get size(): number;
526
+ /**
527
+ * Returns new Accum containing all the elements which are both in this and otherAccum
528
+ */
529
+ intersect(otherAccum: RelationshipsAccum<M>): RelationshipsAccum<M>;
530
+ /**
531
+ * Returns new Accum containing all the elements which are both in this and otherAccum
532
+ */
533
+ difference(otherAccum: RelationshipsAccum<M>): RelationshipsAccum<M>;
534
+ /**
535
+ * Returns new Accum containing all the elements from both
536
+ */
537
+ union(otherAccum: RelationshipsAccum<M>): RelationshipsAccum<M>;
538
+ }
539
+
540
+ declare class LikeC4Model<M extends AnyAux = LikeC4Model.Any> {
541
+ #private;
542
+ readonly $model: M['Model'];
543
+ /**
544
+ * Only available in compile time
545
+ */
546
+ readonly Aux: M;
547
+ readonly deployment: LikeC4DeploymentModel<M>;
548
+ static create<const M extends AnyLikeC4Model>(model: M): LikeC4Model<Aux.FromModel<M>>;
549
+ /**
550
+ * This method is supposed to be used only in dumps
551
+ */
552
+ static fromDump<const M extends ParsedLikeC4ModelDump>(dump: M): LikeC4Model<Aux.FromDump<M>>;
553
+ private constructor();
554
+ get type(): 'computed' | 'layouted';
555
+ element(el: M['ElementOrFqn']): ElementModel<M>;
556
+ findElement(el: LiteralUnion<M['Element'], string>): ElementModel<M> | null;
557
+ /**
558
+ * Returns the root elements of the model.
559
+ */
560
+ roots(): ElementsIterator<M>;
561
+ /**
562
+ * Returns all elements in the model.
563
+ */
564
+ elements(): ElementsIterator<M>;
565
+ /**
566
+ * Returns all relationships in the model.
567
+ */
568
+ relationships(): RelationshipsIterator<M>;
569
+ /**
570
+ * Returns a specific relationship by its ID.
571
+ * If the relationship is not found in the model, it will be searched in the deployment model.
572
+ * Search can be limited to the model or deployment model only.
573
+ */
574
+ relationship(id: M['RelationId'], type: 'model'): RelationshipModel<M>;
575
+ relationship(id: M['RelationId'], type: 'deployment'): DeploymentRelationModel<M>;
576
+ relationship(id: M['RelationId'], type?: 'model' | 'deployment'): RelationshipModel<M> | DeploymentRelationModel<M>;
577
+ findRelationship(id: LiteralUnion<M['RelationId'], string>, type: 'model'): RelationshipModel<M> | null;
578
+ findRelationship(id: LiteralUnion<M['RelationId'], string>, type: 'deployment'): DeploymentRelationModel<M> | null;
579
+ findRelationship(id: LiteralUnion<M['RelationId'], string>, type?: 'model' | 'deployment'): RelationshipModel<M> | DeploymentRelationModel<M> | null;
580
+ /**
581
+ * Returns all views in the model.
582
+ */
583
+ views(): MapIterator<LikeC4ViewModel<M, M["ViewType"]>>;
584
+ /**
585
+ * Returns a specific view by its ID.
586
+ */
587
+ view(viewId: M['ViewIdLiteral']): LikeC4ViewModel<M>;
588
+ findView(viewId: LiteralUnion<M['ViewId'], string>): LikeC4ViewModel<M>;
589
+ /**
590
+ * Returns the parent element of given element.
591
+ * @see ancestors
592
+ */
593
+ parent(element: M['ElementOrFqn']): ElementModel<M> | null;
594
+ /**
595
+ * Get all children of the element (only direct children),
596
+ * @see descendants
597
+ */
598
+ children(element: M['ElementOrFqn']): ReadonlySet<ElementModel<M>>;
599
+ /**
600
+ * Get all sibling (i.e. same parent)
601
+ */
602
+ siblings(element: M['ElementOrFqn']): ElementsIterator<M>;
603
+ /**
604
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
605
+ * (from closest to root)
606
+ */
607
+ ancestors(element: M['ElementOrFqn']): ElementsIterator<M>;
608
+ /**
609
+ * Get all descendant elements (i.e. children, children’s children, etc.)
610
+ */
611
+ descendants(element: M['ElementOrFqn']): ElementsIterator<M>;
612
+ /**
613
+ * Incoming relationships to the element and its descendants
614
+ * @see incomers
615
+ */
616
+ incoming(element: M['ElementOrFqn'], filter?: IncomingFilter): RelationshipsIterator<M>;
617
+ /**
618
+ * Outgoing relationships from the element and its descendants
619
+ * @see outgoers
620
+ */
621
+ outgoing(element: M['ElementOrFqn'], filter?: OutgoingFilter): RelationshipsIterator<M>;
622
+ private addElement;
623
+ private addRelation;
624
+ }
625
+ declare namespace LikeC4Model {
626
+ type Any = Aux<string, string, string, ComputedView | DiagramView>;
627
+ type Element<M extends AnyAux = Any> = ElementModel<M>;
628
+ type Relation<M extends AnyAux = Any> = RelationshipModel<M>;
629
+ type AnyRelation<M extends AnyAux = Any> = RelationshipModel<M> | DeploymentRelationModel<M>;
630
+ type View<M extends AnyAux = Any, V extends ComputedView | DiagramView = M['ViewType']> = LikeC4ViewModel<M, V>;
631
+ type Node<M extends AnyAux = Any, V extends ComputedView | DiagramView = M['ViewType']> = NodeModel<M, V>;
632
+ type Edge<M extends AnyAux = Any, V extends ComputedView | DiagramView = M['ViewType']> = EdgeModel<M, V>;
633
+ type DeploymentModel<M extends AnyAux = AnyAux> = LikeC4DeploymentModel<M>;
634
+ type Deployment<M extends AnyAux = AnyAux> = DeploymentElementModel<M>;
635
+ type DeploymentNode<M extends AnyAux = AnyAux> = DeploymentNodeModel<M>;
636
+ type DeployedInstance<M extends AnyAux = AnyAux> = DeployedInstanceModel<M>;
637
+ type Typed<Elements extends string = string, Deployments extends string = string, Views extends string = string, ViewType = DiagramView<Views> | ComputedView<Views>> = Aux<Elements, Deployments, Views, ViewType>;
638
+ type Computed<Elements extends string = string, Deployments extends string = string, Views extends string = string> = LikeC4Model<Typed<Elements, Deployments, Views, ComputedView<Views>>>;
639
+ type Layouted<Elements extends string = string, Deployments extends string = string, Views extends string = string> = LikeC4Model<Typed<Elements, Deployments, Views, DiagramView<Views>>>;
640
+ }
641
+
642
+ export { LikeC4DeploymentModel, LikeC4Model, Aux as LikeC4ModelAux, LikeC4ViewModel };
@@ -0,0 +1,2 @@
1
+ export { a as LikeC4DeploymentModel, L as LikeC4Model, b as LikeC4ViewModel } from '../shared/core.BPyJvuMU.mjs';
2
+ import '../shared/core.k12s_keD.mjs';