@likec4/core 1.30.0 → 1.32.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 (186) hide show
  1. package/README.md +407 -5
  2. package/dist/builder/index.d.mts +221 -42
  3. package/dist/builder/index.mjs +118 -65
  4. package/dist/compute-view/index.d.mts +23 -7
  5. package/dist/compute-view/index.mjs +11 -6
  6. package/dist/compute-view/relationships-view/index.d.mts +9 -7
  7. package/dist/compute-view/relationships-view/index.mjs +3 -2
  8. package/dist/index.d.mts +10 -14
  9. package/dist/index.mjs +10 -6
  10. package/dist/model/index.d.mts +173 -19
  11. package/dist/model/index.mjs +6 -1
  12. package/dist/shared/core.BaYE_r29.d.mts +258 -0
  13. package/dist/shared/core.Bk7wEZFG.mjs +276 -0
  14. package/dist/shared/core.BrCnZFTn.mjs +32 -0
  15. package/dist/shared/core.BuO4ncfY.d.mts +146 -0
  16. package/dist/shared/{core.CAcZ6_cP.mjs → core.CBpKAlhj.mjs} +1742 -4128
  17. package/dist/shared/core.CCWXGc6G.d.mts +920 -0
  18. package/dist/shared/core.CUYDgv2-.mjs +214 -0
  19. package/dist/shared/{core.Cu-UdkSl.mjs → core.CpXlRyE5.mjs} +7 -494
  20. package/dist/shared/{core.C-YXI-43.mjs → core.Cy9smucx.mjs} +3 -1
  21. package/dist/shared/core.CywrQs86.d.mts +31 -0
  22. package/dist/shared/core.DoK86JEe.mjs +518 -0
  23. package/dist/shared/core.Dpq3P3YJ.d.mts +1265 -0
  24. package/dist/shared/{core.D2830qgg.d.mts → core.Pf5I9o0e.d.mts} +1 -1
  25. package/dist/shared/core.cbA9VZ02.mjs +2681 -0
  26. package/dist/shared/{core.CQXU9DF7.mjs → core.rmvsy0n3.mjs} +23 -32
  27. package/dist/types/aux.d.mts +3 -0
  28. package/dist/types/aux.mjs +1 -0
  29. package/dist/types/index.d.mts +7 -45
  30. package/dist/types/index.mjs +130 -3
  31. package/dist/utils/index.d.mts +221 -53
  32. package/dist/utils/index.mjs +14 -10
  33. package/package.json +19 -10
  34. package/src/builder/Builder.deploymentModel.ts +82 -18
  35. package/src/builder/Builder.element.ts +40 -20
  36. package/src/builder/Builder.model.ts +66 -17
  37. package/src/builder/Builder.ts +168 -76
  38. package/src/builder/Builder.view-common.ts +35 -17
  39. package/src/builder/Builder.view-deployment.ts +25 -25
  40. package/src/builder/Builder.view-element.ts +13 -12
  41. package/src/builder/Builder.views.ts +12 -7
  42. package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +62 -34
  43. package/src/builder/__snapshots__/Builder-style2.compute-model.json5 +319 -0
  44. package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +45 -24
  45. package/src/builder/_types.ts +34 -27
  46. package/src/compute-view/compute-view.ts +31 -34
  47. package/src/compute-view/deployment-view/__test__/TestHelper.ts +27 -14
  48. package/src/compute-view/deployment-view/__test__/fixture.ts +15 -13
  49. package/src/compute-view/deployment-view/_types.ts +10 -10
  50. package/src/compute-view/deployment-view/clean-connections.ts +5 -7
  51. package/src/compute-view/deployment-view/compute.ts +16 -13
  52. package/src/compute-view/deployment-view/memory/memory.ts +5 -6
  53. package/src/compute-view/deployment-view/predicates/deploymentRefs.ts +4 -5
  54. package/src/compute-view/deployment-view/predicates/relation-direct.ts +25 -50
  55. package/src/compute-view/deployment-view/predicates/relation-in-out.ts +5 -7
  56. package/src/compute-view/deployment-view/predicates/relation-incoming.ts +7 -11
  57. package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +7 -10
  58. package/src/compute-view/deployment-view/predicates/utils.ts +37 -31
  59. package/src/compute-view/deployment-view/predicates/wildcard.ts +3 -2
  60. package/src/compute-view/deployment-view/stages/stage-final.ts +2 -2
  61. package/src/compute-view/deployment-view/stages/stage-include.ts +1 -1
  62. package/src/compute-view/deployment-view/utils.ts +79 -72
  63. package/src/compute-view/dynamic-view/__test__/fixture.ts +20 -11
  64. package/src/compute-view/dynamic-view/compute.ts +60 -53
  65. package/src/compute-view/element-view/__test__/TestHelper.ts +53 -29
  66. package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +26 -26
  67. package/src/compute-view/element-view/__test__/fixture.ts +134 -83
  68. package/src/compute-view/element-view/_types.ts +14 -19
  69. package/src/compute-view/element-view/clean-connections.ts +12 -8
  70. package/src/compute-view/element-view/compute.ts +61 -51
  71. package/src/compute-view/element-view/memory/NodeGroup.ts +8 -9
  72. package/src/compute-view/element-view/memory/memory.ts +22 -22
  73. package/src/compute-view/element-view/memory/stage-include.ts +5 -3
  74. package/src/compute-view/element-view/predicates/_utils.ts +18 -14
  75. package/src/compute-view/element-view/predicates/element-expand.ts +4 -5
  76. package/src/compute-view/element-view/predicates/element-kind-tag.ts +3 -4
  77. package/src/compute-view/element-view/predicates/element-ref.ts +3 -4
  78. package/src/compute-view/element-view/predicates/relation-direct.ts +16 -12
  79. package/src/compute-view/element-view/predicates/relation-in-out.ts +7 -8
  80. package/src/compute-view/element-view/predicates/relation-in.ts +19 -26
  81. package/src/compute-view/element-view/predicates/relation-out.ts +20 -21
  82. package/src/compute-view/element-view/predicates/wildcard.ts +3 -3
  83. package/src/compute-view/element-view/utils.ts +25 -23
  84. package/src/compute-view/index.ts +1 -1
  85. package/src/compute-view/memory/AbstractStageExclude.ts +3 -4
  86. package/src/compute-view/memory/AbstractStageInclude.ts +1 -1
  87. package/src/compute-view/memory/_types.ts +3 -2
  88. package/src/compute-view/relationships-view/_types.ts +3 -4
  89. package/src/compute-view/relationships-view/compute.ts +8 -11
  90. package/src/compute-view/relationships-view/layout.ts +6 -6
  91. package/src/compute-view/relationships-view/utils.ts +4 -4
  92. package/src/compute-view/utils/ancestorsOfNode.ts +7 -7
  93. package/src/compute-view/utils/applyCustomElementProperties.ts +16 -8
  94. package/src/compute-view/utils/applyCustomRelationProperties.ts +19 -9
  95. package/src/compute-view/utils/applyViewRuleStyles.ts +18 -10
  96. package/src/compute-view/utils/buildComputedNodes.ts +40 -40
  97. package/src/compute-view/utils/buildElementNotations.ts +14 -14
  98. package/src/compute-view/utils/elementExpressionToPredicate.ts +14 -15
  99. package/src/compute-view/utils/link-nodes-with-edges.ts +6 -4
  100. package/src/compute-view/utils/merge-props-from-relationships.ts +52 -20
  101. package/src/compute-view/utils/relationExpressionToPredicates.ts +19 -19
  102. package/src/compute-view/utils/resolve-extended-views.ts +8 -7
  103. package/src/compute-view/utils/resolve-global-rules.ts +31 -26
  104. package/src/compute-view/utils/topological-sort.ts +14 -14
  105. package/src/compute-view/utils/view-hash.ts +2 -2
  106. package/src/compute-view/utils/with-readable-edges.ts +9 -5
  107. package/src/index.ts +0 -32
  108. package/src/model/DeploymentElementModel.ts +182 -137
  109. package/src/model/DeploymentModel.ts +88 -65
  110. package/src/model/ElementModel.ts +92 -72
  111. package/src/model/LikeC4Model.ts +430 -241
  112. package/src/model/RelationModel.ts +69 -26
  113. package/src/model/__test__/fixture.ts +50 -36
  114. package/src/model/connection/Connection.ts +2 -2
  115. package/src/model/connection/deployment/DeploymentConnectionModel.ts +21 -24
  116. package/src/model/connection/deployment/find.ts +1 -1
  117. package/src/model/connection/model/ConnectionModel.ts +21 -20
  118. package/src/model/connection/model/find.ts +7 -7
  119. package/src/model/connection/ops.ts +6 -6
  120. package/src/model/guards.ts +66 -14
  121. package/src/model/index.ts +20 -7
  122. package/src/model/types.ts +41 -97
  123. package/src/model/view/EdgeModel.ts +47 -41
  124. package/src/model/view/LikeC4ViewModel.ts +130 -80
  125. package/src/model/view/NodeModel.ts +102 -96
  126. package/src/theme/element.ts +1 -1
  127. package/src/theme/index.ts +9 -9
  128. package/src/theme/relationships.ts +1 -1
  129. package/src/types/_common.ts +21 -15
  130. package/src/types/aux.ts +285 -0
  131. package/src/types/const.ts +34 -0
  132. package/src/types/expression-model.ts +292 -0
  133. package/src/types/expression.ts +311 -0
  134. package/src/types/fqnRef.ts +88 -0
  135. package/src/types/geometry.ts +131 -0
  136. package/src/types/global.ts +10 -8
  137. package/src/types/index.ts +39 -201
  138. package/src/types/model-data.ts +52 -84
  139. package/src/types/model-deployment.ts +87 -0
  140. package/src/types/model-dump.ts +72 -0
  141. package/src/types/model-logical.ts +111 -0
  142. package/src/types/model-spec.ts +81 -0
  143. package/src/types/operators.ts +51 -52
  144. package/src/types/scalar.ts +114 -0
  145. package/src/types/styles.ts +123 -0
  146. package/src/types/view-changes.ts +4 -5
  147. package/src/types/view-common.ts +157 -0
  148. package/src/types/view-computed.ts +113 -0
  149. package/src/types/view-layouted.ts +82 -0
  150. package/src/types/view-parsed.deployment.ts +40 -0
  151. package/src/types/view-parsed.dynamic.ts +78 -0
  152. package/src/types/view-parsed.element.ts +65 -0
  153. package/src/types/view.ts +122 -542
  154. package/src/utils/compare-natural.ts +43 -1
  155. package/src/utils/getOrCreate.ts +0 -34
  156. package/src/utils/index.ts +7 -12
  157. package/src/utils/iterable/filter.ts +1 -1
  158. package/src/utils/iterable/find.ts +3 -1
  159. package/src/utils/iterable/head.ts +22 -0
  160. package/src/utils/iterable/index.ts +1 -0
  161. package/src/utils/iterable/map.ts +1 -1
  162. package/src/utils/iterable/reduce.ts +1 -1
  163. package/src/utils/iterable/some.ts +1 -1
  164. package/src/utils/memoize-prop.ts +30 -0
  165. package/src/utils/object-hash.ts +1 -1
  166. package/src/utils/relations.ts +14 -11
  167. package/src/utils/string-hash.ts +1 -1
  168. package/dist/shared/core.CZR9J1Qx.d.mts +0 -146
  169. package/dist/shared/core.CiFKryGW.d.mts +0 -745
  170. package/dist/shared/core.DJvmfnEi.d.mts +0 -1153
  171. package/dist/shared/core.DgfwjBtu.mjs +0 -495
  172. package/dist/shared/core.SjLhMA7a.d.mts +0 -62
  173. package/src/builder/__snapshots__/Builder.spec.ts.snap +0 -374
  174. package/src/compute-view/element-view/predicates.ts +0 -520
  175. package/src/compute-view/utils/uniqueTags.ts +0 -21
  176. package/src/types/deployments.ts +0 -170
  177. package/src/types/element.ts +0 -109
  178. package/src/types/expression-v2-model.ts +0 -314
  179. package/src/types/expression-v2.ts +0 -392
  180. package/src/types/overview-graph.ts +0 -43
  181. package/src/types/relation.ts +0 -61
  182. package/src/types/scalars.ts +0 -39
  183. package/src/types/theme.ts +0 -82
  184. package/src/types/view-notation.ts +0 -9
  185. package/src/utils/graphlib.ts +0 -10
  186. /package/src/{errors/index.ts → utils/invariant.ts} +0 -0
@@ -0,0 +1,920 @@
1
+ import { A as Any, T as Tags, R as RelationKind, j as Metadata, k as MetadataKey, L as LooseTag, F as Fqn, g as ElementId, l as ElementKind, D as DeploymentKind, E as ExtractOnStage, m as RelationId$1, f as _type, n as StrictViewId, o as LooseElementId, p as LooseDeploymentId, q as DeploymentFqn, t as toComputed, r as toLayouted, s as Stage, u as DeploymentId, U as Unknown, V as ViewId, v as Tag, w as toParsed, P as ProjectId$1, x as LooseViewId, b as Aux, S as SpecAux, e as UnknownParsed, c as UnknownComputed, d as UnknownLayouted } from './core.BaYE_r29.mjs';
2
+ import { D as DefaultMap } from './core.CywrQs86.mjs';
3
+ import { SetRequired } from 'type-fest';
4
+ import { az as Color, av as RelationshipLineType, Y as Relationship, O as Element, ar as ElementShape, N as ElementStyle, aM as ViewWithType, aI as ComputedView, aG as LayoutedView, k as ParsedLikeC4ModelData, l as ComputedLikeC4ModelData, m as LayoutedLikeC4ModelData, b8 as ViewType, c as FqnRef, p as DeployedInstance, D as DeploymentElementStyle, u as DeploymentRelationship, q as DeploymentElement, o as DeploymentNode, x as LikeC4ModelDump, y as AuxFromDump, a2 as Specification, j as ModelGlobals, ah as WhereOperator } from './core.Dpq3P3YJ.mjs';
5
+ import { I as IteratorLike, R as RelationId, L as Link, P as ProjectId, j as IconUrl, N as NodeId, G as GroupElementKind, E as EdgeId, p as StepEdgeId, V as ViewId$1 } from './core.BuO4ncfY.mjs';
6
+
7
+ type RelationshipsIterator<A extends Any> = IteratorLike<RelationshipModel<A>>;
8
+ /**
9
+ * A relationship between two elements (in logical or deployment model)
10
+ * use {@link isDeploymentRelationModel} guard to check if the relationship is a deployment relationship
11
+ */
12
+ interface AnyRelationshipModel<A extends Any> {
13
+ get id(): RelationId;
14
+ get expression(): string;
15
+ get title(): string | null;
16
+ get technology(): string | null;
17
+ get description(): string | null;
18
+ get navigateTo(): LikeC4ViewModel<A> | null;
19
+ get tags(): Tags<A>;
20
+ get kind(): RelationKind<A> | null;
21
+ get links(): ReadonlyArray<Link>;
22
+ get color(): Color;
23
+ get line(): RelationshipLineType;
24
+ isDeploymentRelation(): this is DeploymentRelationModel<A>;
25
+ isModelRelation(): this is RelationshipModel<A>;
26
+ getMetadata(): Metadata<A>;
27
+ getMetadata(field: MetadataKey<A>): string | undefined;
28
+ views(): ViewsIterator<A>;
29
+ isTagged(tag: LooseTag<A>): boolean;
30
+ }
31
+ declare class RelationshipModel<A extends Any = Any> implements AnyRelationshipModel<A> {
32
+ readonly model: LikeC4Model<A>;
33
+ readonly $relationship: Relationship<A>;
34
+ readonly source: ElementModel<A>;
35
+ readonly target: ElementModel<A>;
36
+ /**
37
+ * Common ancestor of the source and target elements.
38
+ * Represents the boundary of the Relation.
39
+ */
40
+ readonly boundary: ElementModel<A> | null;
41
+ constructor(model: LikeC4Model<A>, $relationship: Relationship<A>);
42
+ get id(): RelationId;
43
+ get expression(): string;
44
+ get title(): string | null;
45
+ get technology(): string | null;
46
+ get description(): string | null;
47
+ get navigateTo(): LikeC4ViewModel<A> | null;
48
+ get tags(): Tags<A>;
49
+ get kind(): RelationKind<A> | null;
50
+ get links(): ReadonlyArray<Link>;
51
+ get color(): Color;
52
+ get line(): RelationshipLineType;
53
+ /**
54
+ * Iterate over all views that include this relationship.
55
+ */
56
+ views(): ViewsIterator<A>;
57
+ isDeploymentRelation(): this is DeploymentRelationModel<A>;
58
+ isModelRelation(): this is RelationshipModel<A>;
59
+ getMetadata(): Metadata<A>;
60
+ getMetadata(field: MetadataKey<A>): string | undefined;
61
+ /**
62
+ * Checks if the relationship has the given tag.
63
+ */
64
+ isTagged(tag: LooseTag<A>): boolean;
65
+ }
66
+
67
+ type ElementsIterator<M extends Any> = IteratorLike<ElementModel<M>>;
68
+ declare class ElementModel<A extends Any = Any> {
69
+ readonly $model: LikeC4Model<A>;
70
+ readonly $element: Element<A>;
71
+ readonly id: Fqn<A>;
72
+ readonly _literalId: ElementId<A>;
73
+ readonly hierarchyLevel: number;
74
+ readonly imported: null | {
75
+ from: ProjectId;
76
+ fqn: Fqn<A>;
77
+ };
78
+ constructor($model: LikeC4Model<A>, $element: Element<A>);
79
+ get parent(): ElementModel<A> | null;
80
+ get kind(): ElementKind<A>;
81
+ get shape(): ElementShape;
82
+ get color(): Color;
83
+ get icon(): IconUrl | null;
84
+ /**
85
+ * Returns all tags of the element.
86
+ * It includes tags from the element and its kind.
87
+ */
88
+ get tags(): Tags<A>;
89
+ get title(): string;
90
+ get description(): string | null;
91
+ get technology(): string | null;
92
+ get links(): ReadonlyArray<Link>;
93
+ get defaultView(): LikeC4ViewModel<A, $ViewWithType<A, 'element'> & {
94
+ viewOf: Fqn<A>;
95
+ }> | null;
96
+ get isRoot(): boolean;
97
+ get style(): SetRequired<ElementStyle, 'size'>;
98
+ isAncestorOf(another: ElementModel<A>): boolean;
99
+ isDescendantOf(another: ElementModel<A>): boolean;
100
+ /**
101
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
102
+ * (from closest to root)
103
+ */
104
+ ancestors(): ElementsIterator<A>;
105
+ /**
106
+ * Returns the common ancestor of this element and another element.
107
+ */
108
+ commonAncestor(another: ElementModel<A>): ElementModel<A> | null;
109
+ children(): ReadonlySet<ElementModel<A>>;
110
+ /**
111
+ * Get all descendant elements (i.e. children, children’s children, etc.)
112
+ */
113
+ descendants(sort?: 'asc' | 'desc'): ElementsIterator<A>;
114
+ /**
115
+ * Get all sibling (i.e. same parent)
116
+ */
117
+ siblings(): ElementsIterator<A>;
118
+ /**
119
+ * Resolve siblings of the element and its ancestors
120
+ * (from closest parent to root)
121
+ */
122
+ ascendingSiblings(): ElementsIterator<A>;
123
+ /**
124
+ * Resolve siblings of the element and its ancestors
125
+ * (from root to closest)
126
+ */
127
+ descendingSiblings(): ElementsIterator<A>;
128
+ incoming(filter?: IncomingFilter): RelationshipsIterator<A>;
129
+ incomers(filter?: IncomingFilter): ElementsIterator<A>;
130
+ outgoing(filter?: OutgoingFilter): RelationshipsIterator<A>;
131
+ outgoers(filter?: OutgoingFilter): ElementsIterator<A>;
132
+ get allOutgoing(): ReadonlySet<RelationshipModel<A>>;
133
+ get allIncoming(): ReadonlySet<RelationshipModel<A>>;
134
+ /**
135
+ * Iterate over all views that include this element.
136
+ */
137
+ views(): ReadonlySet<LikeC4ViewModel<A>>;
138
+ /**
139
+ * Iterate over all views that scope this element.
140
+ * It is possible that element is not included in the view.
141
+ */
142
+ scopedViews(): ReadonlySet<LikeC4ViewModel<A, $ViewWithType<A, 'element'> & {
143
+ viewOf: Fqn<A>;
144
+ }>>;
145
+ /**
146
+ * @returns true if the element is deployed
147
+ */
148
+ isDeployed(): boolean;
149
+ deployments(): DeployedInstancesIterator<A>;
150
+ getMetadata(): Metadata<A>;
151
+ getMetadata(field: MetadataKey<A>): string | undefined;
152
+ /**
153
+ * Checks if the element has the given tag.
154
+ */
155
+ isTagged(tag: LooseTag<A>): boolean;
156
+ }
157
+
158
+ type NodesIterator<M extends Any, V extends $View<M>> = IteratorLike<NodeModel<M, V>>;
159
+ declare class NodeModel<A extends Any = Any, V extends $View<A> = $View<A>> {
160
+ #private;
161
+ readonly $view: LikeC4ViewModel<A, V>;
162
+ readonly $node: V['nodes'][number];
163
+ constructor($view: LikeC4ViewModel<A, V>, $node: V['nodes'][number]);
164
+ get id(): NodeId;
165
+ get title(): string;
166
+ get kind(): ElementKind<A> | DeploymentKind<A> | typeof GroupElementKind | 'instance';
167
+ get description(): string | null;
168
+ get technology(): string | null;
169
+ get parent(): NodeModel<A, V> | null;
170
+ get element(): ElementModel<A> | null;
171
+ get deployment(): DeploymentElementModel<A> | null;
172
+ get shape(): ElementShape;
173
+ get color(): Color;
174
+ get icon(): IconUrl | null;
175
+ get tags(): Tags<A>;
176
+ get links(): ReadonlyArray<Link>;
177
+ get navigateTo(): LikeC4ViewModel<A> | null;
178
+ get style(): ElementStyle;
179
+ children(): ReadonlySet<NodeModel<A, V>>;
180
+ /**
181
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
182
+ * (from closest to root)
183
+ */
184
+ ancestors(): NodesIterator<A, V>;
185
+ siblings(): NodesIterator<A, V>;
186
+ incoming(filter?: IncomingFilter): EdgesIterator<A, V>;
187
+ incomers(filter?: IncomingFilter): NodesIterator<A, V>;
188
+ outgoing(filter?: OutgoingFilter): EdgesIterator<A, V>;
189
+ outgoers(filter?: OutgoingFilter): NodesIterator<A, V>;
190
+ isDiagramNode(this: NodeModel<any, any>): this is NodeModel<A, ExtractOnStage<V, 'layouted'>>;
191
+ hasChildren(): boolean;
192
+ hasParent(): this is NodeModel.WithParent<A, V>;
193
+ /**
194
+ * Check if this node references to logical model element.
195
+ */
196
+ hasElement(): this is NodeModel.WithElement<A, V>;
197
+ /**
198
+ * Check if this node references to deployment element (Node or Instance).
199
+ */
200
+ hasDeployment(): this is NodeModel.WithDeploymentElement<A, V>;
201
+ /**
202
+ * Check if this node references to deployed instance
203
+ * Deployed instance always references to element and deployment element.
204
+ */
205
+ hasDeployedInstance(): this is NodeModel.WithDeployedInstance<A, V>;
206
+ isGroup(): this is NodeModel.IsGroup<A, V>;
207
+ /**
208
+ * Checks if the node has the given tag.
209
+ */
210
+ isTagged(tag: LooseTag<A>): boolean;
211
+ }
212
+ declare namespace NodeModel {
213
+ interface WithParent<A extends Any = Any, V extends $View<A> = $View<A>> extends NodeModel<A, V> {
214
+ parent: NodeModel<A, V>;
215
+ }
216
+ interface WithElement<A extends Any = Any, V extends $View<A> = $View<A>> extends NodeModel<A, V> {
217
+ kind: ElementKind<A>;
218
+ element: ElementModel<A>;
219
+ }
220
+ interface WithDeploymentElement<A extends Any = Any, V extends $View<A> = $View<A>> extends NodeModel<A, V> {
221
+ kind: DeploymentKind<A>;
222
+ deployment: DeploymentElementModel<A>;
223
+ }
224
+ interface WithDeployedInstance<A extends Any = Any, V extends $View<A> = $View<A>> extends NodeModel<A, V> {
225
+ kind: 'instance';
226
+ element: ElementModel<A>;
227
+ deployment: DeployedInstanceModel<A>;
228
+ }
229
+ interface IsGroup<A extends Any = Any, V extends $View<A> = $View<A>> extends NodeModel<A, V> {
230
+ kind: typeof GroupElementKind;
231
+ element: null;
232
+ deployment: null;
233
+ }
234
+ }
235
+
236
+ type EdgesIterator<A extends Any, V extends $View<A>> = IteratorLike<EdgeModel<A, V>>;
237
+ declare class EdgeModel<A extends Any = Any, View extends $View<A> = $View<A>> {
238
+ #private;
239
+ readonly view: LikeC4ViewModel<A, View>;
240
+ readonly $edge: View['edges'][number];
241
+ readonly source: NodeModel<A, View>;
242
+ readonly target: NodeModel<A, View>;
243
+ constructor(view: LikeC4ViewModel<A, View>, $edge: View['edges'][number], source: NodeModel<A, View>, target: NodeModel<A, View>);
244
+ get id(): EdgeId;
245
+ get parent(): NodeModel<A, View> | null;
246
+ get label(): string | null;
247
+ get description(): string | null;
248
+ get technology(): string | null;
249
+ hasParent(): this is EdgeModel.WithParent<A, View>;
250
+ get tags(): Tags<A>;
251
+ get stepNumber(): number | null;
252
+ get navigateTo(): LikeC4ViewModel<A> | null;
253
+ get color(): Color;
254
+ get line(): RelationshipLineType;
255
+ isStep(): this is EdgeModel.StepEdge<A, View>;
256
+ relationships(type: 'model'): IteratorLike<RelationshipModel<A>>;
257
+ relationships(type: 'deployment'): IteratorLike<DeploymentRelationModel<A>>;
258
+ relationships(type?: 'model' | 'deployment'): IteratorLike<RelationshipModel<A> | DeploymentRelationModel<A>>;
259
+ includesRelation(rel: RelationId$1 | {
260
+ id: RelationId$1;
261
+ }): boolean;
262
+ isTagged(tag: LooseTag<A>): boolean;
263
+ }
264
+ declare namespace EdgeModel {
265
+ interface StepEdge<A extends Any, V extends $View<A>> extends EdgeModel<A, V> {
266
+ id: StepEdgeId;
267
+ stepNumber: number;
268
+ }
269
+ interface WithParent<A extends Any, V extends $View<A>> extends EdgeModel<A, V> {
270
+ parent: NodeModel<A, V>;
271
+ }
272
+ }
273
+
274
+ type ViewsIterator<A extends Any, V extends $View<A> = $View<A>> = IteratorLike<LikeC4ViewModel<A, V>>;
275
+ declare class LikeC4ViewModel<A extends Any = Any, V extends $View<A> = $View<A>> {
276
+ #private;
277
+ /**
278
+ * Don't use in runtime, only for type inference
279
+ */
280
+ readonly Aux: A;
281
+ readonly $view: V;
282
+ readonly $model: LikeC4Model<A>;
283
+ constructor(model: LikeC4Model<A>, view: V);
284
+ get _type(): V[_type];
285
+ get id(): StrictViewId<A>;
286
+ get title(): string | null;
287
+ get tags(): Tags<A>;
288
+ get links(): ReadonlyArray<Link>;
289
+ get viewOf(): ElementModel<A> | null;
290
+ /**
291
+ * All tags from nodes and edges.
292
+ */
293
+ get includedTags(): Tags<A>;
294
+ roots(): NodesIterator<A, V>;
295
+ /**
296
+ * Iterate over all nodes that have children.
297
+ */
298
+ compounds(): NodesIterator<A, V>;
299
+ /**
300
+ * Get node by id.
301
+ * @throws Error if node is not found.
302
+ */
303
+ node(node: NodeOrId): NodeModel<A, V>;
304
+ /**
305
+ * Find node by id.
306
+ */
307
+ findNode(node: NodeOrId): NodeModel<A, V> | null;
308
+ findNodeWithElement(element: LooseElementId<A> | {
309
+ id: Fqn<A>;
310
+ }): NodeModel.WithElement<A, V> | null;
311
+ /**
312
+ * Iterate over all nodes.
313
+ */
314
+ nodes(): NodesIterator<A, V>;
315
+ /**
316
+ * Find edge by id.
317
+ * @param edge Edge or id
318
+ * @returns EdgeModel
319
+ */
320
+ edge(edge: EdgeOrId): EdgeModel<A, V>;
321
+ findEdge(edge: EdgeOrId): EdgeModel<A, V> | null;
322
+ /**
323
+ * Iterate over all edges.
324
+ */
325
+ edges(): EdgesIterator<A, V>;
326
+ /**
327
+ * Iterate over all edges.
328
+ */
329
+ edgesWithRelation(relation: RelationId$1): EdgesIterator<A, V>;
330
+ /**
331
+ * Nodes that have references to elements from logical model.
332
+ */
333
+ elements(): IteratorLike<NodeModel.WithElement<A, V>>;
334
+ /**
335
+ * Checks if the view has the given tag.
336
+ */
337
+ isTagged(tag: LooseTag<A>): boolean;
338
+ includesElement(element: LooseElementId<A> | {
339
+ id: Fqn<A>;
340
+ }): boolean;
341
+ includesDeployment(deployment: LooseDeploymentId<A> | {
342
+ id: DeploymentFqn<A>;
343
+ }): boolean;
344
+ includesRelation(relation: RelationId | {
345
+ id: RelationId;
346
+ }): boolean;
347
+ /**
348
+ * Below are type guards.
349
+ */
350
+ isComputed(this: LikeC4ViewModel<any, any>): this is LikeC4ViewModel<toComputed<A>>;
351
+ isDiagram(this: LikeC4ViewModel<any, any>): this is LikeC4ViewModel<toLayouted<A>>;
352
+ isElementView(this: LikeC4ViewModel<any, any>): this is LikeC4ViewModel.ElementView<A, V>;
353
+ isScopedElementView(this: LikeC4ViewModel<any, any>): this is LikeC4ViewModel.ScopedElementView<A, V>;
354
+ isDeploymentView(this: LikeC4ViewModel<any, any>): this is LikeC4ViewModel.DeploymentView<A, V>;
355
+ isDynamicView(this: LikeC4ViewModel<any, any>): this is LikeC4ViewModel.DynamicView<A, V>;
356
+ }
357
+ declare namespace LikeC4ViewModel {
358
+ interface ElementView<A extends Any, V extends $View<A> = $View<A>> extends LikeC4ViewModel<A, ViewWithType<V, 'element'>> {
359
+ }
360
+ interface ScopedElementView<A extends Any, V extends $View<A> = $View<A>> extends LikeC4ViewModel<A, ViewWithType<V, 'element'> & {
361
+ viewOf: Fqn<A>;
362
+ }> {
363
+ viewOf: ElementModel<A>;
364
+ }
365
+ interface DeploymentView<A extends Any, V extends $View<A> = $View<A>> extends LikeC4ViewModel<A, ViewWithType<V, 'deployment'>> {
366
+ }
367
+ interface DynamicView<A extends Any, V extends $View<A> = $View<A>> extends LikeC4ViewModel<A, ViewWithType<V, 'dynamic'>> {
368
+ }
369
+ }
370
+
371
+ type IncomingFilter = 'all' | 'direct' | 'to-descendants';
372
+ type OutgoingFilter = 'all' | 'direct' | 'from-descendants';
373
+ type ElementOrFqn<A extends Any> = ElementId<A> | {
374
+ id: Fqn<A>;
375
+ };
376
+ type DeploymentOrFqn<A extends Any> = DeploymentId<A> | {
377
+ id: DeploymentFqn<A>;
378
+ };
379
+ type NodeOrId = string | {
380
+ id: NodeId;
381
+ };
382
+ type EdgeOrId = string | {
383
+ id: EdgeId;
384
+ };
385
+ type RelationOrId = string | {
386
+ id: RelationId;
387
+ };
388
+ type $View<A extends Any> = {
389
+ parsed: never;
390
+ computed: ComputedView<A>;
391
+ layouted: LayoutedView<A>;
392
+ }[Stage<A>];
393
+ type $ViewWithType<A extends Any, V extends ViewType> = ViewWithType<$View<A>, V>;
394
+ type $ViewModel<A extends Any> = {
395
+ parsed: never;
396
+ computed: LikeC4ViewModel<A>;
397
+ layouted: LikeC4ViewModel<A>;
398
+ }[Stage<A>];
399
+ type $ModelData<A extends Any> = {
400
+ parsed: ParsedLikeC4ModelData<A>;
401
+ computed: ComputedLikeC4ModelData<A>;
402
+ layouted: LayoutedLikeC4ModelData<A>;
403
+ }[Stage<A>];
404
+
405
+ declare class LikeC4DeploymentModel<A extends Any = Any> {
406
+ #private;
407
+ readonly $model: LikeC4Model<A>;
408
+ readonly $deployments: $ModelData<A>['deployments'];
409
+ constructor($model: LikeC4Model<A>);
410
+ element(el: DeploymentOrFqn<A>): DeploymentElementModel<A>;
411
+ findElement(el: LooseDeploymentId<A>): DeploymentElementModel<A> | null;
412
+ node(el: DeploymentOrFqn<A>): DeploymentNodeModel<A>;
413
+ findNode(el: LooseDeploymentId<A>): DeploymentNodeModel<A> | null;
414
+ instance(el: DeploymentOrFqn<A>): DeployedInstanceModel<A>;
415
+ findInstance(el: LooseDeploymentId<A>): DeployedInstanceModel<A> | null;
416
+ /**
417
+ * Returns the root elements of the model.
418
+ */
419
+ roots(): DeploymentNodesIterator<A>;
420
+ /**
421
+ * Returns all elements in the model.
422
+ */
423
+ elements(): DeploymentElementsIterator<A>;
424
+ /**
425
+ * Returns all elements in the model.
426
+ */
427
+ nodes(): DeploymentNodesIterator<A>;
428
+ nodesOfKind(kind: DeploymentKind<A>): DeploymentNodesIterator<A>;
429
+ instances(): DeployedInstancesIterator<A>;
430
+ /**
431
+ * Iterate over all instances of the given logical element.
432
+ */
433
+ instancesOf(element: ElementOrFqn<A>): DeployedInstancesIterator<A>;
434
+ deploymentRef(ref: FqnRef.DeploymentRef<A>): DeploymentElementModel<A> | NestedElementOfDeployedInstanceModel<A>;
435
+ /**
436
+ * Returns all relationships in the model.
437
+ */
438
+ relationships(): IteratorLike<DeploymentRelationModel<A>>;
439
+ /**
440
+ * Returns a specific relationship by its ID.
441
+ */
442
+ relationship(id: RelationOrId): DeploymentRelationModel<A>;
443
+ findRelationship(id: string): DeploymentRelationModel<A> | null;
444
+ /**
445
+ * Returns all deployment views in the model.
446
+ */
447
+ views(): IteratorLike<LikeC4ViewModel.DeploymentView<A>>;
448
+ /**
449
+ * Returns the parent element of given element.
450
+ * @see ancestors
451
+ */
452
+ parent(element: DeploymentOrFqn<A>): DeploymentNodeModel<A> | null;
453
+ /**
454
+ * Get all children of the element (only direct children),
455
+ * @see descendants
456
+ */
457
+ children(element: DeploymentOrFqn<A>): ReadonlySet<DeploymentElementModel<A>>;
458
+ /**
459
+ * Get all sibling (i.e. same parent)
460
+ */
461
+ siblings(element: DeploymentOrFqn<A>): DeploymentElementsIterator<A>;
462
+ /**
463
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
464
+ * (from closest to root)
465
+ */
466
+ ancestors(element: DeploymentOrFqn<A>): DeploymentNodesIterator<A>;
467
+ /**
468
+ * Get all descendant elements (i.e. children, children’s children, etc.)
469
+ */
470
+ descendants(element: DeploymentOrFqn<A>, sort?: 'asc' | 'desc'): DeploymentElementsIterator<A>;
471
+ /**
472
+ * Incoming relationships to the element and its descendants
473
+ * @see incomers
474
+ */
475
+ incoming(element: DeploymentOrFqn<A>, filter?: IncomingFilter): IteratorLike<DeploymentRelationModel<A>>;
476
+ /**
477
+ * Outgoing relationships from the element and its descendants
478
+ * @see outgoers
479
+ */
480
+ outgoing(element: DeploymentOrFqn<A>, filter?: OutgoingFilter): IteratorLike<DeploymentRelationModel<A>>;
481
+ private addElement;
482
+ private addRelation;
483
+ }
484
+
485
+ type DeploymentElementsIterator<A extends Any> = IteratorLike<DeploymentElementModel<A>>;
486
+ type DeployedInstancesIterator<A extends Any> = IteratorLike<DeployedInstanceModel<A>>;
487
+ type DeploymentNodesIterator<A extends Any> = IteratorLike<DeploymentNodeModel<A>>;
488
+ type DeploymentElementModel<A extends Any = Any> = DeploymentNodeModel<A> | DeployedInstanceModel<A>;
489
+ declare abstract class AbstractDeploymentElementModel<A extends Any> {
490
+ abstract readonly id: DeploymentFqn<A>;
491
+ abstract readonly _literalId: DeploymentId<A>;
492
+ abstract readonly parent: DeploymentNodeModel<A> | null;
493
+ abstract readonly title: string;
494
+ abstract readonly hierarchyLevel: number;
495
+ abstract readonly $model: LikeC4DeploymentModel<A>;
496
+ abstract readonly $node: DeploymentElement<A>;
497
+ abstract readonly tags: Tags<A>;
498
+ get style(): SetRequired<DeploymentElementStyle, 'shape' | 'color' | 'size'>;
499
+ get shape(): ElementShape;
500
+ get color(): Color;
501
+ get description(): string | null;
502
+ get technology(): string | null;
503
+ get links(): ReadonlyArray<Link>;
504
+ /**
505
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
506
+ * (from closest to root)
507
+ */
508
+ ancestors(): DeploymentNodesIterator<A>;
509
+ /**
510
+ * Returns the common ancestor of this element and another element.
511
+ */
512
+ commonAncestor(another: DeploymentElementModel<A>): DeploymentNodeModel<A> | null;
513
+ /**
514
+ * Get all sibling (i.e. same parent)
515
+ */
516
+ siblings(): DeploymentElementsIterator<A>;
517
+ /**
518
+ * Check if the element is a sibling of another element
519
+ */
520
+ isSibling(other: DeploymentElementModel<A>): boolean;
521
+ /**
522
+ * Resolve siblings of the element and its ancestors
523
+ * (from closest to root)
524
+ */
525
+ ascendingSiblings(): DeploymentElementsIterator<A>;
526
+ /**
527
+ * Resolve siblings of the element and its ancestors
528
+ * (from root to closest)
529
+ */
530
+ descendingSiblings(): DeploymentElementsIterator<A>;
531
+ incoming(filter?: IncomingFilter): IteratorLike<DeploymentRelationModel<A>>;
532
+ outgoing(filter?: OutgoingFilter): IteratorLike<DeploymentRelationModel<A>>;
533
+ incomers(filter?: IncomingFilter): IteratorLike<DeploymentRelationEndpoint<A>>;
534
+ outgoers(filter?: OutgoingFilter): IteratorLike<DeploymentRelationEndpoint<A>>;
535
+ /**
536
+ * Iterate over all views that include this deployment element.
537
+ */
538
+ views(): IteratorLike<LikeC4ViewModel.DeploymentView<A>>;
539
+ isDeploymentNode(): this is DeploymentNodeModel<A>;
540
+ isInstance(): this is DeployedInstanceModel<A>;
541
+ abstract outgoingModelRelationships(): RelationshipsIterator<A>;
542
+ abstract incomingModelRelationships(): RelationshipsIterator<A>;
543
+ get allOutgoing(): RelationshipsAccum<A>;
544
+ get allIncoming(): RelationshipsAccum<A>;
545
+ getMetadata(): Metadata<A>;
546
+ getMetadata(field: MetadataKey<A>): string | undefined;
547
+ /**
548
+ * Checks if the deployment element has the given tag.
549
+ */
550
+ isTagged(tag: LooseTag<A>): boolean;
551
+ }
552
+ declare class DeploymentNodeModel<A extends Any = Any> extends AbstractDeploymentElementModel<A> {
553
+ readonly $model: LikeC4DeploymentModel<A>;
554
+ readonly $node: DeploymentNode<A>;
555
+ id: DeploymentFqn<A>;
556
+ _literalId: DeploymentId<A>;
557
+ title: string;
558
+ hierarchyLevel: number;
559
+ constructor($model: LikeC4DeploymentModel<A>, $node: DeploymentNode<A>);
560
+ get parent(): DeploymentNodeModel<A> | null;
561
+ get kind(): DeploymentKind<A>;
562
+ get tags(): Tags<A>;
563
+ children(): ReadonlySet<DeploymentElementModel<A>>;
564
+ descendants(sort?: 'asc' | 'desc'): DeploymentElementsIterator<A>;
565
+ isDeploymentNode(): this is DeploymentNodeModel<A>;
566
+ /**
567
+ * Iterate over all instances nested in this deployment node.
568
+ */
569
+ instances(): DeployedInstancesIterator<A>;
570
+ /**
571
+ * Returns deployed instance inside this deployment node
572
+ * if only there are no more instances
573
+ */
574
+ onlyOneInstance(): DeployedInstanceModel<A> | null;
575
+ /**
576
+ * Cached result of relationships from instances
577
+ */
578
+ private _relationshipsFromInstances;
579
+ private relationshipsFromInstances;
580
+ /**
581
+ * We return only relationships that are not already present in nested instances
582
+ */
583
+ outgoingModelRelationships(): RelationshipsIterator<A>;
584
+ /**
585
+ * We return only relationships that are not already present in nested instances
586
+ */
587
+ incomingModelRelationships(): RelationshipsIterator<A>;
588
+ /**
589
+ * Returns an iterator of relationships between nested instances
590
+ */
591
+ internalModelRelationships(): ReadonlySet<RelationshipModel<A>>;
592
+ }
593
+ declare class DeployedInstanceModel<A extends Any = Any> extends AbstractDeploymentElementModel<A> {
594
+ readonly $model: LikeC4DeploymentModel<A>;
595
+ readonly $instance: DeployedInstance<A>;
596
+ readonly element: ElementModel<A>;
597
+ readonly id: DeploymentFqn<A>;
598
+ readonly _literalId: DeploymentId<A>;
599
+ readonly title: string;
600
+ readonly hierarchyLevel: number;
601
+ constructor($model: LikeC4DeploymentModel<A>, $instance: DeployedInstance<A>, element: ElementModel<A>);
602
+ get $node(): DeployedInstance<A>;
603
+ get parent(): DeploymentNodeModel<A>;
604
+ get style(): SetRequired<DeploymentElementStyle, 'shape' | 'color' | 'size'>;
605
+ get shape(): ElementShape;
606
+ get color(): Color;
607
+ get tags(): Tags<A>;
608
+ get kind(): ElementKind<A>;
609
+ get description(): string | null;
610
+ get technology(): string | null;
611
+ get links(): ReadonlyArray<Link>;
612
+ isInstance(): this is DeployedInstanceModel<A>;
613
+ outgoingModelRelationships(): RelationshipsIterator<A>;
614
+ incomingModelRelationships(): RelationshipsIterator<A>;
615
+ /**
616
+ * Iterate over all views that include this instance.
617
+ * (Some views may include the parent deployment node instead of the instance.)
618
+ */
619
+ views(): IteratorLike<LikeC4ViewModel.DeploymentView<A>>;
620
+ }
621
+ declare class NestedElementOfDeployedInstanceModel<A extends Any = Any> {
622
+ readonly instance: DeployedInstanceModel<A>;
623
+ readonly element: ElementModel<A>;
624
+ constructor(instance: DeployedInstanceModel<A>, element: ElementModel<A>);
625
+ get id(): DeploymentFqn<A>;
626
+ get _literalId(): DeploymentId<A>;
627
+ get style(): SetRequired<DeploymentElementStyle, 'shape' | 'color'>;
628
+ get shape(): ElementShape;
629
+ get color(): Color;
630
+ get title(): string;
631
+ get description(): string | null;
632
+ get technology(): string | null;
633
+ isDeploymentNode(): this is DeploymentNodeModel<A>;
634
+ isInstance(): this is DeployedInstanceModel<A>;
635
+ }
636
+ type DeploymentRelationEndpoint<A extends Any = Any> = DeploymentElementModel<A> | NestedElementOfDeployedInstanceModel<A>;
637
+ declare class DeploymentRelationModel<A extends Any = Any> implements AnyRelationshipModel<A> {
638
+ readonly $model: LikeC4DeploymentModel<A>;
639
+ readonly $relationship: DeploymentRelationship<A>;
640
+ boundary: DeploymentNodeModel<A> | null;
641
+ source: DeploymentRelationEndpoint<A>;
642
+ target: DeploymentRelationEndpoint<A>;
643
+ constructor($model: LikeC4DeploymentModel<A>, $relationship: DeploymentRelationship<A>);
644
+ get id(): RelationId;
645
+ get expression(): string;
646
+ get title(): string | null;
647
+ get technology(): string | null;
648
+ get description(): string | null;
649
+ get tags(): Tags<A>;
650
+ get kind(): RelationKind<A> | null;
651
+ get navigateTo(): LikeC4ViewModel<A> | null;
652
+ get links(): ReadonlyArray<Link>;
653
+ get color(): Color;
654
+ get line(): RelationshipLineType;
655
+ views(): IteratorLike<LikeC4ViewModel.DeploymentView<A>>;
656
+ isDeploymentRelation(): this is DeploymentRelationModel<A>;
657
+ isModelRelation(): this is RelationshipModel<A>;
658
+ getMetadata(): Metadata<A>;
659
+ getMetadata(field: MetadataKey<A>): string | undefined;
660
+ /**
661
+ * Checks if the relationship has the given tag.
662
+ */
663
+ isTagged(tag: LooseTag<A>): boolean;
664
+ }
665
+ declare class RelationshipsAccum<A extends Any = Any> {
666
+ readonly model: ReadonlySet<RelationshipModel<A>>;
667
+ readonly deployment: ReadonlySet<DeploymentRelationModel<A>>;
668
+ static empty<A extends Any>(): RelationshipsAccum<A>;
669
+ static from<A extends Any>(model: Iterable<RelationshipModel<A>> | undefined, deployment?: Iterable<DeploymentRelationModel<A>>): RelationshipsAccum<A>;
670
+ /**
671
+ * @param model relationships from logical model
672
+ * @param deployment relationships from deployment model
673
+ */
674
+ constructor(model?: ReadonlySet<RelationshipModel<A>>, deployment?: ReadonlySet<DeploymentRelationModel<A>>);
675
+ get isEmpty(): boolean;
676
+ get nonEmpty(): boolean;
677
+ get size(): number;
678
+ /**
679
+ * Returns new Accum containing all the elements which are both in this and otherAccum
680
+ */
681
+ intersect(otherAccum: RelationshipsAccum<A>): RelationshipsAccum<A>;
682
+ /**
683
+ * Returns new Accum containing all the elements which are both in this and otherAccum
684
+ */
685
+ difference(otherAccum: RelationshipsAccum<A>): RelationshipsAccum<A>;
686
+ /**
687
+ * Returns new Accum containing all the elements from both
688
+ */
689
+ union(otherAccum: RelationshipsAccum<A>): RelationshipsAccum<A>;
690
+ }
691
+
692
+ /**
693
+ * When you do not need types in the model
694
+ */
695
+ type AnyLikeC4Model = LikeC4Model<any>;
696
+ declare class LikeC4Model<A extends Any = Unknown> {
697
+ /**
698
+ * Don't use in runtime, only for type inference
699
+ */
700
+ readonly Aux: A;
701
+ protected readonly _elements: Map<Fqn<A>, ElementModel<A>>;
702
+ protected readonly _parents: Map<Fqn<A>, ElementModel<A>>;
703
+ protected readonly _children: DefaultMap<Fqn<A>, Set<ElementModel<A>>>;
704
+ protected readonly _rootElements: Set<ElementModel<A>>;
705
+ protected readonly _relations: Map<RelationId<string>, RelationshipModel<A>>;
706
+ protected readonly _incoming: DefaultMap<Fqn<A>, Set<RelationshipModel<A>>>;
707
+ protected readonly _outgoing: DefaultMap<Fqn<A>, Set<RelationshipModel<A>>>;
708
+ protected readonly _internal: DefaultMap<Fqn<A>, Set<RelationshipModel<A>>>;
709
+ protected readonly _views: Map<ViewId<A>, LikeC4ViewModel<A, $View<A>>>;
710
+ protected readonly _allTags: DefaultMap<Tag<A>, Set<ElementModel<A> | LikeC4ViewModel<A, $View<A>> | RelationshipModel<A>>>;
711
+ static fromParsed<T extends Any>(model: ParsedLikeC4ModelData<T>): LikeC4Model.Parsed<T>;
712
+ /**
713
+ * Creates a new LikeC4Model instance from the provided model data.
714
+ * Model with parsed data will not have views, as they must be computed
715
+ * (this model is used for computing views)
716
+ *
717
+ * @typeParam M - Type parameter constrained to AnyLikeC4Model
718
+ * @param model - The model data to create a LikeC4Model from
719
+ * @returns A new LikeC4Model instance with the type derived from the input model
720
+ */
721
+ static create<T extends Any>(model: ParsedLikeC4ModelData<T>): LikeC4Model.Parsed<T>;
722
+ static create<T extends Any>(model: LayoutedLikeC4ModelData<T>): LikeC4Model.Layouted<T>;
723
+ static create<T extends Any>(model: ComputedLikeC4ModelData<T>): LikeC4Model.Computed<T>;
724
+ /**
725
+ * Creates a new LikeC4Model instance and infers types from a model dump.\
726
+ * Model dump expected to be computed or layouted.
727
+ *
728
+ * @typeParam D - A constant type parameter extending LikeC4ModelDump
729
+ * @param dump - The model dump to create the instance from
730
+ * @returns A new LikeC4Model instance with types inferred from the dump
731
+ */
732
+ static fromDump<const D extends LikeC4ModelDump>(dump: D): LikeC4Model<AuxFromDump<D>>;
733
+ readonly deployment: LikeC4DeploymentModel<A>;
734
+ readonly $data: $ModelData<A>;
735
+ constructor($data: $ModelData<A>);
736
+ /**
737
+ * Type narrows the model to the parsed stage.
738
+ * This is useful for tests
739
+ */
740
+ get asParsed(): LikeC4Model.Parsed<A>;
741
+ /**
742
+ * Type narrows the model to the layouted stage.
743
+ * This is useful for tests
744
+ */
745
+ get asComputed(): LikeC4Model.Computed<A>;
746
+ /**
747
+ * Type narrows the model to the layouted stage.
748
+ * This is useful for tests
749
+ */
750
+ get asLayouted(): LikeC4Model.Layouted<A>;
751
+ /**
752
+ * Type guard the model to the parsed stage.
753
+ */
754
+ isParsed(this: LikeC4Model<any>): this is LikeC4Model<toParsed<A>>;
755
+ /**
756
+ * Type guard the model to the layouted stage.
757
+ */
758
+ isLayouted(this: LikeC4Model<any>): this is LikeC4Model<toLayouted<A>>;
759
+ /**
760
+ * Type guard the model to the computed stage.
761
+ */
762
+ isComputed(this: LikeC4Model<any>): this is LikeC4Model<toComputed<A>>;
763
+ /**
764
+ * Keeping here for backward compatibility
765
+ * @deprecated use {@link $data}
766
+ */
767
+ get $model(): $ModelData<A>;
768
+ get stage(): Stage<A>;
769
+ get projectId(): ProjectId$1<A>;
770
+ get specification(): Specification<A>;
771
+ get globals(): ModelGlobals;
772
+ element(el: ElementOrFqn<A>): ElementModel<A>;
773
+ findElement(el: LooseElementId<A>): ElementModel<A> | null;
774
+ /**
775
+ * Returns the root elements of the model.
776
+ */
777
+ roots(): ElementsIterator<A>;
778
+ /**
779
+ * Returns all elements in the model.
780
+ */
781
+ elements(): ElementsIterator<A>;
782
+ /**
783
+ * Returns all relationships in the model.
784
+ */
785
+ relationships(): RelationshipsIterator<A>;
786
+ /**
787
+ * Returns a specific relationship by its ID.
788
+ * If the relationship is not found in the model, it will be searched in the deployment model.
789
+ * Search can be limited to the model or deployment model only.
790
+ */
791
+ relationship(rel: RelationOrId, type: 'model'): RelationshipModel<A>;
792
+ relationship(rel: RelationOrId, type: 'deployment'): DeploymentRelationModel<A>;
793
+ relationship(rel: RelationId, type?: 'model' | 'deployment'): RelationshipModel<A> | DeploymentRelationModel<A>;
794
+ findRelationship(id: string, type: 'model'): RelationshipModel<A> | null;
795
+ findRelationship(id: string, type: 'deployment'): DeploymentRelationModel<A> | null;
796
+ findRelationship(id: string, type?: 'model' | 'deployment'): RelationshipModel<A> | DeploymentRelationModel<A> | null;
797
+ /**
798
+ * Returns all views in the model.
799
+ */
800
+ views(): IteratorLike<LikeC4ViewModel<A, $View<A>>>;
801
+ /**
802
+ * Returns a specific view by its ID.
803
+ */
804
+ view(viewId: ViewId<A> | {
805
+ id: ViewId$1<ViewId<A>>;
806
+ }): LikeC4ViewModel<A, $View<A>>;
807
+ findView(viewId: LooseViewId<A>): LikeC4ViewModel<A, $View<A>> | null;
808
+ /**
809
+ * Returns the parent element of given element.
810
+ * @see ancestors
811
+ */
812
+ parent(element: ElementOrFqn<A>): ElementModel<A> | null;
813
+ /**
814
+ * Get all children of the element (only direct children),
815
+ * @see descendants
816
+ */
817
+ children(element: ElementOrFqn<A>): ReadonlySet<ElementModel<A>>;
818
+ /**
819
+ * Get all sibling (i.e. same parent)
820
+ */
821
+ siblings(element: ElementOrFqn<A>): ElementsIterator<A>;
822
+ /**
823
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
824
+ * (from closest to root)
825
+ */
826
+ ancestors(element: ElementOrFqn<A>): ElementsIterator<A>;
827
+ /**
828
+ * Get all descendant elements (i.e. children, children’s children, etc.)
829
+ */
830
+ descendants(element: ElementOrFqn<A>): ElementsIterator<A>;
831
+ /**
832
+ * Incoming relationships to the element and its descendants
833
+ * @see incomers
834
+ */
835
+ incoming(element: ElementOrFqn<A>, filter?: IncomingFilter): RelationshipsIterator<A>;
836
+ /**
837
+ * Outgoing relationships from the element and its descendants
838
+ * @see outgoers
839
+ */
840
+ outgoing(element: ElementOrFqn<A>, filter?: OutgoingFilter): RelationshipsIterator<A>;
841
+ /**
842
+ * Returns all tags used in the model, sorted alphabetically.
843
+ */
844
+ get tags(): Tags<A>;
845
+ /**
846
+ * Returns all tags used in the model, sorted by usage count (descending).
847
+ */
848
+ get tagsSortedByUsage(): ReadonlyArray<{
849
+ tag: Tag<A>;
850
+ count: number;
851
+ tagged: ReadonlySet<ElementModel<A> | RelationshipModel<A> | LikeC4ViewModel<A>>;
852
+ }>;
853
+ /**
854
+ * Returns all elements, relationships and views marked with the given tag.
855
+ */
856
+ findByTag(tag: Tag<A>): IteratorLike<ElementModel<A> | RelationshipModel<A> | LikeC4ViewModel<A>>;
857
+ findByTag(tag: Tag<A>, type: 'elements'): IteratorLike<ElementModel<A>>;
858
+ findByTag(tag: Tag<A>, type: 'views'): IteratorLike<LikeC4ViewModel<A>>;
859
+ findByTag(tag: Tag<A>, type: 'relationships'): IteratorLike<RelationshipModel<A>>;
860
+ /**
861
+ * Returns all elements of the given kind.
862
+ */
863
+ elementsOfKind(kind: ElementKind<A>): IteratorLike<ElementModel<A>>;
864
+ /**
865
+ * Returns all elements that match the given where operator.
866
+ *
867
+ * @example
868
+ * ```ts
869
+ * model.where({
870
+ * and: [
871
+ * { kind: 'component' },
872
+ * {
873
+ * or: [
874
+ * { tag: 'old' },
875
+ * { tag: { neq: 'new' } },
876
+ * ],
877
+ * },
878
+ * ],
879
+ * })
880
+ * ```
881
+ */
882
+ elementsWhere(where: WhereOperator<A>): IteratorLike<ElementModel<A>>;
883
+ /**
884
+ * Returns all **model** relationships that match the given where operator.
885
+ *
886
+ * @example
887
+ * ```ts
888
+ * model.relationshipsWhere({
889
+ * and: [
890
+ * { kind: 'uses' },
891
+ * {
892
+ * or: [
893
+ * { tag: 'old' },
894
+ * { tag: { neq: 'new' } },
895
+ * ],
896
+ * },
897
+ * ],
898
+ * })
899
+ * ```
900
+ */
901
+ relationshipsWhere(where: WhereOperator<A>): IteratorLike<RelationshipModel<A>>;
902
+ private addElement;
903
+ private addImportedElement;
904
+ private addRelation;
905
+ }
906
+ declare namespace LikeC4Model {
907
+ const EMPTY: LikeC4Model<Aux<"computed", string, string, string, string, SpecAux<string, string, string, string, string>>>;
908
+ type Parsed<A = Unknown> = Unknown extends A ? LikeC4Model<UnknownParsed> : A extends Aux<any, infer E, infer D, infer V, infer P, infer Spec> ? LikeC4Model<Aux<'parsed', E, D, V, P, Spec>> : never;
909
+ type Computed<A = Unknown> = Unknown extends A ? LikeC4Model<UnknownComputed> : A extends Aux<any, infer E, infer D, infer V, infer P, infer Spec> ? LikeC4Model<Aux<'computed', E, D, V, P, Spec>> : never;
910
+ type Layouted<A = Unknown> = Unknown extends A ? LikeC4Model<UnknownLayouted> : A extends Aux<any, infer E, infer D, infer V, infer P, infer Spec> ? LikeC4Model<Aux<'layouted', E, D, V, P, Spec>> : never;
911
+ type Node<A = Unknown> = A extends Any ? NodeModel<A> : never;
912
+ type Element<A = Unknown> = A extends Any ? ElementModel<A> : never;
913
+ type Relationship<A = Unknown> = A extends Any ? RelationshipModel<A> : never;
914
+ type View<A = Unknown> = A extends Any ? $ViewModel<A> : never;
915
+ type DeploymentNode<A = Unknown> = A extends Any ? DeploymentNodeModel<A> : never;
916
+ type DeployedInstance<A = Unknown> = A extends Any ? DeployedInstanceModel<A> : never;
917
+ type AnyRelation<M = Unknown> = M extends Any ? RelationshipModel<M> | DeploymentRelationModel<M> : never;
918
+ }
919
+
920
+ export { type AnyRelationshipModel as A, type DeploymentElementModel as D, ElementModel as E, type IncomingFilter as I, LikeC4Model as L, NestedElementOfDeployedInstanceModel as N, type OutgoingFilter as O, RelationshipModel as R, RelationshipsAccum as a, DeploymentNodeModel as b, DeploymentRelationModel as c, DeployedInstanceModel as d, LikeC4ViewModel as e, NodeModel as f, EdgeModel as g, type AnyLikeC4Model as h, type DeploymentRelationEndpoint as i, LikeC4DeploymentModel as j, type DeploymentOrFqn as k, type EdgeOrId as l, type ElementOrFqn as m, type NodeOrId as n };