@likec4/core 1.17.1 → 1.19.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 (184) hide show
  1. package/LICENSE +1 -1
  2. package/dist/builder/index.d.mts +502 -0
  3. package/dist/builder/index.d.ts +502 -0
  4. package/dist/builder/index.js +871 -0
  5. package/dist/compute-view/index.d.mts +22 -0
  6. package/dist/compute-view/index.d.ts +22 -0
  7. package/dist/compute-view/index.js +78 -0
  8. package/dist/index.d.mts +10 -919
  9. package/dist/index.d.ts +10 -919
  10. package/dist/{index.mjs → index.js} +7 -1688
  11. package/dist/model/index.d.mts +254 -0
  12. package/dist/model/index.d.ts +254 -0
  13. package/dist/model/index.js +1 -0
  14. package/dist/shared/chunk-RAAYCPUM.M-JWF7SS.js +21 -0
  15. package/dist/shared/core.BIfgabEw.d.ts +719 -0
  16. package/dist/shared/core.BZ9Msq7w.d.mts +719 -0
  17. package/dist/shared/{core.CoLQkcYL.d.cts → core.C05RDLhi.d.ts} +460 -362
  18. package/dist/shared/{core.CoLQkcYL.d.mts → core.CmYMqgha.d.mts} +460 -362
  19. package/dist/shared/core.D6-fWbM3.d.ts +127 -0
  20. package/dist/shared/core.D74xkKkG.d.mts +148 -0
  21. package/dist/shared/core.D74xkKkG.d.ts +148 -0
  22. package/dist/shared/core.sLaWHBjR.d.mts +127 -0
  23. package/dist/shared/index.-BdzdI2C.js +7443 -0
  24. package/dist/shared/object_hash.CE_oF3I3.js +1222 -0
  25. package/dist/shared/{core.BXTs-8n7.mjs → view.CyZrG8BJ.js} +108 -47
  26. package/dist/types/index.d.mts +71 -1
  27. package/dist/types/index.d.ts +71 -1
  28. package/dist/types/index.js +20 -0
  29. package/dist/utils/index.d.mts +404 -0
  30. package/dist/utils/index.d.ts +404 -0
  31. package/dist/utils/index.js +330 -0
  32. package/package.json +59 -47
  33. package/src/builder/Builder-style1.test-d.ts +190 -0
  34. package/src/builder/Builder-style2.test-d.ts +175 -0
  35. package/src/builder/Builder.deployment.ts +224 -0
  36. package/src/builder/Builder.deploymentModel.ts +385 -0
  37. package/src/builder/Builder.element.ts +19 -19
  38. package/src/builder/Builder.model.ts +67 -42
  39. package/src/builder/Builder.ts +533 -367
  40. package/src/builder/Builder.view-common.ts +234 -0
  41. package/src/builder/Builder.view-deployment.ts +135 -0
  42. package/src/builder/Builder.view-element.ts +189 -0
  43. package/src/builder/Builder.views.ts +109 -33
  44. package/src/builder/Builder.with.ts +475 -0
  45. package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +374 -0
  46. package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +183 -0
  47. package/src/builder/__snapshots__/Builder.spec.ts.snap +374 -0
  48. package/src/builder/_types.ts +113 -18
  49. package/src/builder/index.ts +10 -4
  50. package/src/colors/index.ts +2 -2
  51. package/src/compute-view/compute-view.ts +83 -0
  52. package/src/compute-view/deployment-view/__test__/TestHelper.ts +236 -0
  53. package/src/compute-view/deployment-view/__test__/fixture.ts +198 -0
  54. package/src/compute-view/deployment-view/_types.ts +37 -0
  55. package/src/compute-view/deployment-view/clean-connections.ts +238 -0
  56. package/src/compute-view/deployment-view/compute.ts +125 -0
  57. package/src/compute-view/deployment-view/memory/index.ts +9 -0
  58. package/src/compute-view/deployment-view/memory/memory.ts +97 -0
  59. package/src/compute-view/deployment-view/predicates/elements.ts +144 -0
  60. package/src/compute-view/deployment-view/predicates/relation-direct.ts +237 -0
  61. package/src/compute-view/deployment-view/predicates/relation-in-out.ts +61 -0
  62. package/src/compute-view/deployment-view/predicates/relation-incoming.ts +95 -0
  63. package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +88 -0
  64. package/src/compute-view/deployment-view/predicates/wildcard.ts +29 -0
  65. package/src/compute-view/deployment-view/stages/stage-exclude.ts +5 -0
  66. package/src/compute-view/deployment-view/stages/stage-final.ts +245 -0
  67. package/src/compute-view/deployment-view/stages/stage-include.ts +95 -0
  68. package/src/compute-view/deployment-view/utils.ts +276 -0
  69. package/src/compute-view/dynamic-view/__test__/fixture.ts +58 -0
  70. package/src/compute-view/dynamic-view/compute.ts +324 -0
  71. package/src/compute-view/element-view/__test__/TestHelper.ts +258 -0
  72. package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +458 -0
  73. package/src/compute-view/element-view/__test__/fixture.ts +675 -0
  74. package/src/compute-view/element-view/_types.ts +48 -0
  75. package/src/compute-view/element-view/clean-connections.ts +113 -0
  76. package/src/compute-view/element-view/compute.ts +315 -0
  77. package/src/compute-view/element-view/memory/NodeGroup.ts +31 -0
  78. package/src/compute-view/element-view/memory/index.ts +10 -0
  79. package/src/compute-view/element-view/memory/memory.ts +177 -0
  80. package/src/compute-view/element-view/memory/stage-exclude.ts +59 -0
  81. package/src/compute-view/element-view/memory/stage-final.ts +129 -0
  82. package/src/compute-view/element-view/memory/stage-include.ts +128 -0
  83. package/src/compute-view/element-view/predicates/_utils.ts +86 -0
  84. package/src/compute-view/element-view/predicates/element-expand.ts +33 -0
  85. package/src/compute-view/element-view/predicates/element-kind-tag.ts +26 -0
  86. package/src/compute-view/element-view/predicates/element-ref.ts +37 -0
  87. package/src/compute-view/element-view/predicates/relation-direct.ts +309 -0
  88. package/src/compute-view/element-view/predicates/relation-in-out.ts +66 -0
  89. package/src/compute-view/element-view/predicates/relation-in.ts +118 -0
  90. package/src/compute-view/element-view/predicates/relation-out.ts +116 -0
  91. package/src/compute-view/element-view/predicates/wildcard.ts +88 -0
  92. package/src/compute-view/element-view/utils.ts +59 -0
  93. package/src/compute-view/index.ts +4 -0
  94. package/src/compute-view/memory/AbstractMemory.ts +45 -0
  95. package/src/compute-view/memory/AbstractStageExclude.ts +216 -0
  96. package/src/compute-view/memory/AbstractStageInclude.ts +200 -0
  97. package/src/compute-view/memory/_types.ts +147 -0
  98. package/src/compute-view/memory/index.ts +5 -0
  99. package/src/compute-view/memory/ops.ts +43 -0
  100. package/src/compute-view/utils/__snapshots__/sortNodes.spec.ts.snap +113 -0
  101. package/src/compute-view/utils/ancestorsOfNode.ts +19 -0
  102. package/src/compute-view/utils/applyCustomElementProperties.ts +66 -0
  103. package/src/compute-view/utils/applyCustomRelationProperties.ts +41 -0
  104. package/src/compute-view/utils/applyViewRuleStyles.ts +53 -0
  105. package/src/compute-view/utils/buildComputedNodes.ts +148 -0
  106. package/src/compute-view/utils/buildElementNotations.ts +63 -0
  107. package/src/compute-view/utils/elementExpressionToPredicate.ts +50 -0
  108. package/src/compute-view/utils/link-nodes-with-edges.ts +54 -0
  109. package/src/compute-view/utils/merge-props-from-relationships.ts +128 -0
  110. package/src/compute-view/utils/relationExpressionToPredicates.ts +55 -0
  111. package/src/compute-view/utils/resolve-extended-views.ts +69 -0
  112. package/src/compute-view/utils/resolve-global-rules.ts +83 -0
  113. package/src/compute-view/utils/topological-sort.ts +256 -0
  114. package/src/compute-view/utils/uniqueTags.test.ts +42 -0
  115. package/src/compute-view/utils/uniqueTags.ts +21 -0
  116. package/src/compute-view/utils/view-hash.ts +27 -0
  117. package/src/compute-view/utils/with-readable-edges.ts +36 -0
  118. package/src/index.ts +22 -12
  119. package/src/model/DeploymentElementModel.ts +599 -0
  120. package/src/model/DeploymentModel.ts +370 -0
  121. package/src/model/ElementModel.ts +221 -0
  122. package/src/model/LikeC4Model.test-d.ts +152 -0
  123. package/src/model/LikeC4Model.ts +336 -457
  124. package/src/model/RelationModel.ts +85 -0
  125. package/src/model/__test__/fixture.ts +149 -338
  126. package/src/model/connection/Connection.ts +72 -0
  127. package/src/model/connection/deployment/DeploymentConnectionModel.ts +178 -0
  128. package/src/model/connection/deployment/find.ts +120 -0
  129. package/src/model/connection/deployment/index.ts +8 -0
  130. package/src/model/connection/index.ts +22 -0
  131. package/src/model/connection/model/ConnectionModel.ts +157 -0
  132. package/src/model/connection/model/find.ts +117 -0
  133. package/src/model/connection/model/index.ts +8 -0
  134. package/src/model/connection/ops.ts +274 -0
  135. package/src/model/guards.ts +9 -0
  136. package/src/model/index.ts +46 -2
  137. package/src/model/types.ts +112 -15
  138. package/src/model/view/EdgeModel.ts +103 -0
  139. package/src/model/view/LikeC4ViewModel.ts +226 -0
  140. package/src/model/view/NodeModel.ts +229 -0
  141. package/src/types/_common.ts +55 -1
  142. package/src/types/deployments.ts +169 -0
  143. package/src/types/element.ts +9 -5
  144. package/src/types/expression-v2.ts +172 -0
  145. package/src/types/expression.ts +17 -11
  146. package/src/types/global.ts +3 -3
  147. package/src/types/index.ts +220 -12
  148. package/src/types/model.ts +75 -12
  149. package/src/types/operators.ts +1 -1
  150. package/src/types/overview-graph.ts +2 -2
  151. package/src/types/relation.ts +18 -14
  152. package/src/types/theme.ts +0 -1
  153. package/src/types/view-notation.ts +2 -2
  154. package/src/types/view.ts +117 -41
  155. package/src/utils/{commonHead.ts → common-head.ts} +2 -0
  156. package/src/utils/const.ts +1 -0
  157. package/src/utils/fqn.ts +203 -56
  158. package/src/utils/getOrCreate.ts +42 -0
  159. package/src/utils/graphlib.ts +10 -0
  160. package/src/utils/index.ts +74 -6
  161. package/src/utils/iterable/_types.ts +5 -0
  162. package/src/utils/iterable/filter.ts +55 -0
  163. package/src/utils/iterable/flat.ts +17 -0
  164. package/src/utils/iterable/index.ts +12 -0
  165. package/src/utils/iterable/map.ts +40 -0
  166. package/src/utils/iterable/reduce.ts +24 -0
  167. package/src/utils/iterable/some.ts +36 -0
  168. package/src/utils/iterable/to.ts +19 -0
  169. package/src/utils/iterable/unique.ts +29 -0
  170. package/src/utils/object-hash.ts +3 -0
  171. package/src/utils/relations.ts +3 -64
  172. package/src/utils/set.ts +78 -0
  173. package/src/utils/string-hash.ts +16 -0
  174. package/dist/index.cjs +0 -5452
  175. package/dist/index.d.cts +0 -1053
  176. package/dist/shared/core.CoLQkcYL.d.ts +0 -734
  177. package/dist/shared/core.DIYZvpVg.cjs +0 -353
  178. package/dist/types/index.cjs +0 -70
  179. package/dist/types/index.d.cts +0 -2
  180. package/dist/types/index.mjs +0 -1
  181. package/src/builder/Builder.test-d.ts +0 -69
  182. package/src/builder/Builder.view.ts +0 -358
  183. package/src/model/LikeC4DiagramModel.ts +0 -338
  184. package/src/model/LikeC4ViewModel.ts +0 -320
@@ -0,0 +1,254 @@
1
+ import { E as ElementModel, D as DeploymentElementModel, A as AnyAux, f as DeploymentNodeModel, g as DeployedInstanceModel, R as RelationshipsAccum, h as RelationshipModel, i as DeploymentRelationModel } from '../shared/core.BZ9Msq7w.mjs';
2
+ export { b as Aux, j as EdgeModel, L as LikeC4DeploymentModel, d as LikeC4Model, e as LikeC4ViewModel, N as NodeModel } from '../shared/core.BZ9Msq7w.mjs';
3
+ import { F as Fqn, a as IteratorLike } from '../shared/core.D74xkKkG.mjs';
4
+ import { I as IterableContainer, R as ReorderedArray } from '../shared/core.sLaWHBjR.mjs';
5
+ import 'type-fest';
6
+ import '../shared/core.CmYMqgha.mjs';
7
+
8
+ interface Connection<Elem = ElementModel | DeploymentElementModel, Id = string> {
9
+ readonly id: Id;
10
+ readonly source: Elem;
11
+ readonly target: Elem;
12
+ /**
13
+ * Common ancestor of the source and target elements.
14
+ * Represents the boundary of the connection.
15
+ */
16
+ readonly boundary: Elem | null;
17
+ /**
18
+ * Human readable expression of the connection
19
+ * Mostly used for testing and debugging
20
+ */
21
+ readonly expression: string;
22
+ mergeWith(this: Connection<Elem, Id>, other: typeof this): typeof this;
23
+ nonEmpty(): boolean;
24
+ difference(this: Connection<Elem, Id>, other: typeof this): typeof this;
25
+ intersect(this: Connection<Elem, Id>, other: typeof this): typeof this;
26
+ equals(other: Connection): boolean;
27
+ }
28
+ declare namespace Connection {
29
+ type ConnectionPredicate = <C extends Connection<{
30
+ id: string;
31
+ }, any>>(connection: C) => boolean;
32
+ type ElementId = Fqn | string;
33
+ export const isInside: (fqn: ElementId) => ConnectionPredicate;
34
+ export const isDirectedBetween: (source: ElementId, target: ElementId) => ConnectionPredicate;
35
+ export const isAnyBetween: (source: ElementId, target: ElementId) => ConnectionPredicate;
36
+ export const isIncoming: (target: ElementId) => ConnectionPredicate;
37
+ export const isOutgoing: (source: ElementId) => ConnectionPredicate;
38
+ export const isAnyInOut: (source: ElementId) => ConnectionPredicate;
39
+ export { };
40
+ }
41
+
42
+ declare const customInspectSymbol: unique symbol;
43
+
44
+ /**
45
+ * Connection is ephemeral entity, result of a resolving relationships between source and target.
46
+ * Includes direct relationships and/or between their nested elements.
47
+ */
48
+ declare class DeploymentConnectionModel<M extends AnyAux = AnyAux> implements Connection<DeploymentElementModel<M>, M['EdgeId']> {
49
+ readonly source: DeploymentNodeModel<M> | DeployedInstanceModel<M>;
50
+ readonly target: DeploymentNodeModel<M> | DeployedInstanceModel<M>;
51
+ readonly relations: RelationshipsAccum<M>;
52
+ constructor(source: DeploymentNodeModel<M> | DeployedInstanceModel<M>, target: DeploymentNodeModel<M> | DeployedInstanceModel<M>, relations: RelationshipsAccum<M>);
53
+ readonly id: M['EdgeId'];
54
+ /**
55
+ * Human readable expression of the connection
56
+ * Mostly used for testing and debugging
57
+ */
58
+ get expression(): string;
59
+ private _boundary;
60
+ /**
61
+ * Common ancestor of the source and target elements.
62
+ * Represents the boundary of the connection.
63
+ */
64
+ get boundary(): DeploymentNodeModel<M> | null;
65
+ nonEmpty(): boolean;
66
+ [customInspectSymbol](depth: any, inspectOptions: any, inspect: any): string;
67
+ toString(): string;
68
+ /**
69
+ * Check if connection contains deployment relation,
70
+ * that is directly connected to source or target.
71
+ */
72
+ hasDirectDeploymentRelation(): boolean;
73
+ values(): IteratorLike<RelationshipModel<M> | DeploymentRelationModel<M>>;
74
+ /**
75
+ * Merge with another connection, if it has the same source and target.
76
+ * Returns new connection with union of relationships.
77
+ */
78
+ mergeWith(other: DeploymentConnectionModel<M>): DeploymentConnectionModel<M>;
79
+ difference(other: DeploymentConnectionModel<M>): DeploymentConnectionModel<M>;
80
+ intersect(other: DeploymentConnectionModel<M>): DeploymentConnectionModel<M>;
81
+ equals(other: Connection): boolean;
82
+ /**
83
+ * Creates a clone of the current `DeploymentConnectionModel` instance with optional overrides.
84
+ * if `null` is provided in overrides, the corresponding relation set will be empty.
85
+ */
86
+ update(overrides?: {
87
+ model?: ReadonlySet<RelationshipModel<M>> | null;
88
+ deployment?: ReadonlySet<DeploymentRelationModel<M>> | null;
89
+ }): DeploymentConnectionModel<M>;
90
+ }
91
+
92
+ /**
93
+ * Connection refers to any relationships between two elements,
94
+ * both direct and implicit ones (between their nested elements).
95
+ *
96
+ * Merges relationships together to an single edge on the diagram.
97
+ */
98
+ declare class ConnectionModel<M extends AnyAux = AnyAux> implements Connection<ElementModel<M>, M['EdgeId']> {
99
+ readonly source: ElementModel<M>;
100
+ readonly target: ElementModel<M>;
101
+ readonly relations: ReadonlySet<RelationshipModel<M>>;
102
+ readonly id: M['EdgeId'];
103
+ constructor(source: ElementModel<M>, target: ElementModel<M>, relations?: ReadonlySet<RelationshipModel<M>>);
104
+ private _boundary;
105
+ /**
106
+ * Common ancestor of the source and target elements.
107
+ * Represents the boundary of the connection.
108
+ */
109
+ get boundary(): ElementModel<M> | null;
110
+ /**
111
+ * Human readable expression of the connection
112
+ * Mostly used for testing and debugging
113
+ */
114
+ get expression(): string;
115
+ /**
116
+ * Returns true if only includes relations between the source and target elements.
117
+ */
118
+ get isDirect(): boolean;
119
+ /**
120
+ * Returns true if includes relations between nested elements of the source and target elements.
121
+ */
122
+ get isImplicit(): boolean;
123
+ get directRelations(): ReadonlySet<RelationshipModel<M>>;
124
+ nonEmpty(): boolean;
125
+ mergeWith(other: ConnectionModel<M>): ConnectionModel<M>;
126
+ difference(other: ConnectionModel<M>): ConnectionModel<M>;
127
+ intersect(other: ConnectionModel<M>): ConnectionModel<M>;
128
+ equals(other: Connection): boolean;
129
+ /**
130
+ * Returns a new instance with the updated relations.
131
+ *
132
+ * @param relations - A readonly set of `RelationshipModel` instances representing the new relations.
133
+ * @returns A new `ConnectionModel` instance with the updated relations.
134
+ */
135
+ update(relations: ReadonlySet<RelationshipModel<M>>): ConnectionModel<M>;
136
+ [customInspectSymbol](depth: any, inspectOptions: any, inspect: any): string;
137
+ toString(): string;
138
+ /**
139
+ * Creates a new connection with reversed direction (target becomes source and vice versa)
140
+ * @param search - When true, attempts to find an existing connection between the reversed nodes
141
+ */
142
+ reversed(search?: boolean): ConnectionModel<M>;
143
+ }
144
+
145
+ /**
146
+ * Check if connection is nested inside another connection
147
+ * (i.e. between descendants)
148
+ */
149
+ declare function isNestedConnection<T extends {
150
+ id: string;
151
+ }>(parent: WithSourceTarget<NoInfer<T>>): (nested: WithSourceTarget<T>) => boolean;
152
+ declare function isNestedConnection<T extends {
153
+ id: string;
154
+ }>(nested: WithSourceTarget<T>, parent: WithSourceTarget<T>): boolean;
155
+ type ConnectionElemId = Connection<{
156
+ readonly id: string;
157
+ }, any>;
158
+ declare function findDeepestNestedConnection<C extends ConnectionElemId>(connections: ReadonlyArray<C>, connection: C): C | null;
159
+ declare function sortDeepestFirst<C extends ConnectionElemId>(connections: ReadonlyArray<C>): C[];
160
+ type WithBoundary = {
161
+ boundary: null | {
162
+ id: string;
163
+ };
164
+ };
165
+ declare function sortConnectionsByBoundaryHierarchy(sort?: 'asc' | 'desc'): <T extends WithBoundary, A extends IterableContainer<T>>(array: A) => ReorderedArray<A>;
166
+ declare function sortConnectionsByBoundaryHierarchy<T extends WithBoundary, A extends IterableContainer<T>>(array: A, sort?: 'asc' | 'desc'): ReorderedArray<A>;
167
+ /**
168
+ * Find connections that includes given connection (i.e between it's ancestors)
169
+ */
170
+ declare function findAscendingConnections<C extends ConnectionElemId>(connections: ReadonlyArray<C>, connection: C): Array<C>;
171
+ /**
172
+ * Find connections that includes given connection (i.e between it's descendants)
173
+ */
174
+ declare function findDescendantConnections<C extends ConnectionElemId>(connections: ReadonlyArray<C>, connection: C): Array<C>;
175
+ declare function mergeConnections<C extends Connection>(connections: ReadonlyArray<C>): C[];
176
+ /**
177
+ * Excludes the values existing in `other` array.
178
+ * The output maintains the same order as the input.
179
+ */
180
+ declare function differenceConnections<C extends Connection>(source: Iterable<C>, exclude: Iterable<C>): C[];
181
+ type WithSourceTarget<T = unknown> = {
182
+ source: T;
183
+ target: T;
184
+ };
185
+ declare function hasSameSourceTarget<T>(a: WithSourceTarget<NoInfer<T>>): (b: WithSourceTarget<T>) => boolean;
186
+ declare function hasSameSourceTarget<T>(a: WithSourceTarget<T>, b: WithSourceTarget<T>): boolean;
187
+ declare function hasSameSource<T>(a: WithSourceTarget<NoInfer<T>>): (b: WithSourceTarget<T>) => boolean;
188
+ declare function hasSameSource<T>(a: WithSourceTarget<T>, b: WithSourceTarget<T>): boolean;
189
+ declare function hasSameTarget<T>(a: WithSourceTarget<NoInfer<T>>): (b: WithSourceTarget<T>) => boolean;
190
+ declare function hasSameTarget<T>(a: WithSourceTarget<T>, b: WithSourceTarget<T>): boolean;
191
+ type WithId<T> = {
192
+ id: T;
193
+ };
194
+ declare function isOutgoing<T extends string>(source: WithId<NoInfer<T>>): (a: WithSourceTarget<WithId<T>>) => boolean;
195
+ declare function isOutgoing<T extends string>(a: WithSourceTarget<WithId<T>>, source: WithId<T>): boolean;
196
+ declare function isIncoming<T extends string>(target: WithId<NoInfer<T>>): (a: WithSourceTarget<WithId<T>>) => boolean;
197
+ declare function isIncoming<T extends string>(a: WithSourceTarget<WithId<T>>, target: WithId<T>): boolean;
198
+ declare function isAnyInOut<T extends string>(source: WithId<NoInfer<T>>): (a: WithSourceTarget<WithId<T>>) => boolean;
199
+ declare function isAnyInOut<T extends string>(a: WithSourceTarget<WithId<T>>, source: WithId<T>): boolean;
200
+
201
+ /**
202
+ * Resolve connection from source to target
203
+ * If direction is `both`, also look for reverse connection
204
+ *
205
+ * @default direction directed
206
+ */
207
+ declare function findConnection$1<M extends AnyAux>(source: DeploymentElementModel<M>, target: DeploymentElementModel<NoInfer<M>>, direction: 'directed'): readonly [DeploymentConnectionModel<M>] | readonly [];
208
+ declare function findConnection$1<M extends AnyAux>(source: DeploymentElementModel<M>, target: DeploymentElementModel<NoInfer<M>>, direction: 'both'): readonly [DeploymentConnectionModel<M>, DeploymentConnectionModel<M>] | readonly [DeploymentConnectionModel<M>] | readonly [];
209
+ declare function findConnection$1<M extends AnyAux>(source: DeploymentElementModel<M>, target: DeploymentElementModel<NoInfer<M>>, direction?: 'directed' | 'both'): readonly [DeploymentConnectionModel<M>, DeploymentConnectionModel<M>] | readonly [DeploymentConnectionModel<M>] | readonly [];
210
+ /**
211
+ * Resolve all connections between element and others
212
+ * By default, look for both directions.
213
+ *
214
+ * @default direction both
215
+ */
216
+ declare function findConnectionsBetween$1<M extends AnyAux>(element: DeploymentElementModel<M>, others: Iterable<DeploymentElementModel<NoInfer<M>>>, direction?: 'directed' | 'both'): readonly DeploymentConnectionModel<M>[];
217
+ /**
218
+ * Resolve all connections within a given set of elements
219
+ */
220
+ declare function findConnectionsWithin$1<M extends AnyAux>(elements: Iterable<DeploymentElementModel<M>>): readonly DeploymentConnectionModel<M>[];
221
+
222
+ declare namespace find$1 {
223
+ export { findConnection$1 as findConnection, findConnectionsBetween$1 as findConnectionsBetween, findConnectionsWithin$1 as findConnectionsWithin };
224
+ }
225
+
226
+ /**
227
+ * Resolve connection from source to target
228
+ *
229
+ * @param direction - if 'both', also returns connection from target to source
230
+ * @default `directed`
231
+ */
232
+ declare function findConnection<M extends AnyAux>(source: ElementModel<M>, target: ElementModel<M>, direction?: 'directed' | 'both'): [ConnectionModel<M>, ConnectionModel<M>] | [ConnectionModel<M>] | [];
233
+ /**
234
+ * Resolve all connections between element and others
235
+ * @param direction - if 'directed', only look for outgoing connections from the element to others
236
+ * @default `both`
237
+ */
238
+ declare function findConnectionsBetween<M extends AnyAux>(element: ElementModel<M>, others: Iterable<ElementModel<NoInfer<M>>>, direction?: 'directed' | 'both'): readonly ConnectionModel<M>[];
239
+ /**
240
+ * Resolve all connections within a given set of elements
241
+ */
242
+ declare function findConnectionsWithin<M extends AnyAux>(elements: Iterable<ElementModel<M>>): readonly ConnectionModel<M>[];
243
+
244
+ declare const find_findConnection: typeof findConnection;
245
+ declare const find_findConnectionsBetween: typeof findConnectionsBetween;
246
+ declare const find_findConnectionsWithin: typeof findConnectionsWithin;
247
+ declare namespace find {
248
+ export { find_findConnection as findConnection, find_findConnectionsBetween as findConnectionsBetween, find_findConnectionsWithin as findConnectionsWithin };
249
+ }
250
+
251
+ declare function isDeploymentNode(model: DeploymentElementModel): model is DeploymentNodeModel;
252
+ declare function isDeployedInstance(model: DeploymentElementModel): model is DeployedInstanceModel;
253
+
254
+ export { AnyAux, Connection, ConnectionModel, DeployedInstanceModel, DeploymentConnectionModel, DeploymentElementModel, DeploymentNodeModel, DeploymentRelationModel, ElementModel, RelationshipModel, find$1 as deploymentConnection, differenceConnections, findAscendingConnections, findDeepestNestedConnection, findDescendantConnections, hasSameSource, hasSameSourceTarget, hasSameTarget, isAnyInOut, isDeployedInstance, isDeploymentNode, isIncoming, isNestedConnection, isOutgoing, mergeConnections, find as modelConnection, sortConnectionsByBoundaryHierarchy, sortDeepestFirst };
@@ -0,0 +1,254 @@
1
+ import { E as ElementModel, D as DeploymentElementModel, A as AnyAux, f as DeploymentNodeModel, g as DeployedInstanceModel, R as RelationshipsAccum, h as RelationshipModel, i as DeploymentRelationModel } from '../shared/core.BIfgabEw.js';
2
+ export { b as Aux, j as EdgeModel, L as LikeC4DeploymentModel, d as LikeC4Model, e as LikeC4ViewModel, N as NodeModel } from '../shared/core.BIfgabEw.js';
3
+ import { F as Fqn, a as IteratorLike } from '../shared/core.D74xkKkG.js';
4
+ import { I as IterableContainer, R as ReorderedArray } from '../shared/core.D6-fWbM3.js';
5
+ import 'type-fest';
6
+ import '../shared/core.C05RDLhi.js';
7
+
8
+ interface Connection<Elem = ElementModel | DeploymentElementModel, Id = string> {
9
+ readonly id: Id;
10
+ readonly source: Elem;
11
+ readonly target: Elem;
12
+ /**
13
+ * Common ancestor of the source and target elements.
14
+ * Represents the boundary of the connection.
15
+ */
16
+ readonly boundary: Elem | null;
17
+ /**
18
+ * Human readable expression of the connection
19
+ * Mostly used for testing and debugging
20
+ */
21
+ readonly expression: string;
22
+ mergeWith(this: Connection<Elem, Id>, other: typeof this): typeof this;
23
+ nonEmpty(): boolean;
24
+ difference(this: Connection<Elem, Id>, other: typeof this): typeof this;
25
+ intersect(this: Connection<Elem, Id>, other: typeof this): typeof this;
26
+ equals(other: Connection): boolean;
27
+ }
28
+ declare namespace Connection {
29
+ type ConnectionPredicate = <C extends Connection<{
30
+ id: string;
31
+ }, any>>(connection: C) => boolean;
32
+ type ElementId = Fqn | string;
33
+ export const isInside: (fqn: ElementId) => ConnectionPredicate;
34
+ export const isDirectedBetween: (source: ElementId, target: ElementId) => ConnectionPredicate;
35
+ export const isAnyBetween: (source: ElementId, target: ElementId) => ConnectionPredicate;
36
+ export const isIncoming: (target: ElementId) => ConnectionPredicate;
37
+ export const isOutgoing: (source: ElementId) => ConnectionPredicate;
38
+ export const isAnyInOut: (source: ElementId) => ConnectionPredicate;
39
+ export { };
40
+ }
41
+
42
+ declare const customInspectSymbol: unique symbol;
43
+
44
+ /**
45
+ * Connection is ephemeral entity, result of a resolving relationships between source and target.
46
+ * Includes direct relationships and/or between their nested elements.
47
+ */
48
+ declare class DeploymentConnectionModel<M extends AnyAux = AnyAux> implements Connection<DeploymentElementModel<M>, M['EdgeId']> {
49
+ readonly source: DeploymentNodeModel<M> | DeployedInstanceModel<M>;
50
+ readonly target: DeploymentNodeModel<M> | DeployedInstanceModel<M>;
51
+ readonly relations: RelationshipsAccum<M>;
52
+ constructor(source: DeploymentNodeModel<M> | DeployedInstanceModel<M>, target: DeploymentNodeModel<M> | DeployedInstanceModel<M>, relations: RelationshipsAccum<M>);
53
+ readonly id: M['EdgeId'];
54
+ /**
55
+ * Human readable expression of the connection
56
+ * Mostly used for testing and debugging
57
+ */
58
+ get expression(): string;
59
+ private _boundary;
60
+ /**
61
+ * Common ancestor of the source and target elements.
62
+ * Represents the boundary of the connection.
63
+ */
64
+ get boundary(): DeploymentNodeModel<M> | null;
65
+ nonEmpty(): boolean;
66
+ [customInspectSymbol](depth: any, inspectOptions: any, inspect: any): string;
67
+ toString(): string;
68
+ /**
69
+ * Check if connection contains deployment relation,
70
+ * that is directly connected to source or target.
71
+ */
72
+ hasDirectDeploymentRelation(): boolean;
73
+ values(): IteratorLike<RelationshipModel<M> | DeploymentRelationModel<M>>;
74
+ /**
75
+ * Merge with another connection, if it has the same source and target.
76
+ * Returns new connection with union of relationships.
77
+ */
78
+ mergeWith(other: DeploymentConnectionModel<M>): DeploymentConnectionModel<M>;
79
+ difference(other: DeploymentConnectionModel<M>): DeploymentConnectionModel<M>;
80
+ intersect(other: DeploymentConnectionModel<M>): DeploymentConnectionModel<M>;
81
+ equals(other: Connection): boolean;
82
+ /**
83
+ * Creates a clone of the current `DeploymentConnectionModel` instance with optional overrides.
84
+ * if `null` is provided in overrides, the corresponding relation set will be empty.
85
+ */
86
+ update(overrides?: {
87
+ model?: ReadonlySet<RelationshipModel<M>> | null;
88
+ deployment?: ReadonlySet<DeploymentRelationModel<M>> | null;
89
+ }): DeploymentConnectionModel<M>;
90
+ }
91
+
92
+ /**
93
+ * Connection refers to any relationships between two elements,
94
+ * both direct and implicit ones (between their nested elements).
95
+ *
96
+ * Merges relationships together to an single edge on the diagram.
97
+ */
98
+ declare class ConnectionModel<M extends AnyAux = AnyAux> implements Connection<ElementModel<M>, M['EdgeId']> {
99
+ readonly source: ElementModel<M>;
100
+ readonly target: ElementModel<M>;
101
+ readonly relations: ReadonlySet<RelationshipModel<M>>;
102
+ readonly id: M['EdgeId'];
103
+ constructor(source: ElementModel<M>, target: ElementModel<M>, relations?: ReadonlySet<RelationshipModel<M>>);
104
+ private _boundary;
105
+ /**
106
+ * Common ancestor of the source and target elements.
107
+ * Represents the boundary of the connection.
108
+ */
109
+ get boundary(): ElementModel<M> | null;
110
+ /**
111
+ * Human readable expression of the connection
112
+ * Mostly used for testing and debugging
113
+ */
114
+ get expression(): string;
115
+ /**
116
+ * Returns true if only includes relations between the source and target elements.
117
+ */
118
+ get isDirect(): boolean;
119
+ /**
120
+ * Returns true if includes relations between nested elements of the source and target elements.
121
+ */
122
+ get isImplicit(): boolean;
123
+ get directRelations(): ReadonlySet<RelationshipModel<M>>;
124
+ nonEmpty(): boolean;
125
+ mergeWith(other: ConnectionModel<M>): ConnectionModel<M>;
126
+ difference(other: ConnectionModel<M>): ConnectionModel<M>;
127
+ intersect(other: ConnectionModel<M>): ConnectionModel<M>;
128
+ equals(other: Connection): boolean;
129
+ /**
130
+ * Returns a new instance with the updated relations.
131
+ *
132
+ * @param relations - A readonly set of `RelationshipModel` instances representing the new relations.
133
+ * @returns A new `ConnectionModel` instance with the updated relations.
134
+ */
135
+ update(relations: ReadonlySet<RelationshipModel<M>>): ConnectionModel<M>;
136
+ [customInspectSymbol](depth: any, inspectOptions: any, inspect: any): string;
137
+ toString(): string;
138
+ /**
139
+ * Creates a new connection with reversed direction (target becomes source and vice versa)
140
+ * @param search - When true, attempts to find an existing connection between the reversed nodes
141
+ */
142
+ reversed(search?: boolean): ConnectionModel<M>;
143
+ }
144
+
145
+ /**
146
+ * Check if connection is nested inside another connection
147
+ * (i.e. between descendants)
148
+ */
149
+ declare function isNestedConnection<T extends {
150
+ id: string;
151
+ }>(parent: WithSourceTarget<NoInfer<T>>): (nested: WithSourceTarget<T>) => boolean;
152
+ declare function isNestedConnection<T extends {
153
+ id: string;
154
+ }>(nested: WithSourceTarget<T>, parent: WithSourceTarget<T>): boolean;
155
+ type ConnectionElemId = Connection<{
156
+ readonly id: string;
157
+ }, any>;
158
+ declare function findDeepestNestedConnection<C extends ConnectionElemId>(connections: ReadonlyArray<C>, connection: C): C | null;
159
+ declare function sortDeepestFirst<C extends ConnectionElemId>(connections: ReadonlyArray<C>): C[];
160
+ type WithBoundary = {
161
+ boundary: null | {
162
+ id: string;
163
+ };
164
+ };
165
+ declare function sortConnectionsByBoundaryHierarchy(sort?: 'asc' | 'desc'): <T extends WithBoundary, A extends IterableContainer<T>>(array: A) => ReorderedArray<A>;
166
+ declare function sortConnectionsByBoundaryHierarchy<T extends WithBoundary, A extends IterableContainer<T>>(array: A, sort?: 'asc' | 'desc'): ReorderedArray<A>;
167
+ /**
168
+ * Find connections that includes given connection (i.e between it's ancestors)
169
+ */
170
+ declare function findAscendingConnections<C extends ConnectionElemId>(connections: ReadonlyArray<C>, connection: C): Array<C>;
171
+ /**
172
+ * Find connections that includes given connection (i.e between it's descendants)
173
+ */
174
+ declare function findDescendantConnections<C extends ConnectionElemId>(connections: ReadonlyArray<C>, connection: C): Array<C>;
175
+ declare function mergeConnections<C extends Connection>(connections: ReadonlyArray<C>): C[];
176
+ /**
177
+ * Excludes the values existing in `other` array.
178
+ * The output maintains the same order as the input.
179
+ */
180
+ declare function differenceConnections<C extends Connection>(source: Iterable<C>, exclude: Iterable<C>): C[];
181
+ type WithSourceTarget<T = unknown> = {
182
+ source: T;
183
+ target: T;
184
+ };
185
+ declare function hasSameSourceTarget<T>(a: WithSourceTarget<NoInfer<T>>): (b: WithSourceTarget<T>) => boolean;
186
+ declare function hasSameSourceTarget<T>(a: WithSourceTarget<T>, b: WithSourceTarget<T>): boolean;
187
+ declare function hasSameSource<T>(a: WithSourceTarget<NoInfer<T>>): (b: WithSourceTarget<T>) => boolean;
188
+ declare function hasSameSource<T>(a: WithSourceTarget<T>, b: WithSourceTarget<T>): boolean;
189
+ declare function hasSameTarget<T>(a: WithSourceTarget<NoInfer<T>>): (b: WithSourceTarget<T>) => boolean;
190
+ declare function hasSameTarget<T>(a: WithSourceTarget<T>, b: WithSourceTarget<T>): boolean;
191
+ type WithId<T> = {
192
+ id: T;
193
+ };
194
+ declare function isOutgoing<T extends string>(source: WithId<NoInfer<T>>): (a: WithSourceTarget<WithId<T>>) => boolean;
195
+ declare function isOutgoing<T extends string>(a: WithSourceTarget<WithId<T>>, source: WithId<T>): boolean;
196
+ declare function isIncoming<T extends string>(target: WithId<NoInfer<T>>): (a: WithSourceTarget<WithId<T>>) => boolean;
197
+ declare function isIncoming<T extends string>(a: WithSourceTarget<WithId<T>>, target: WithId<T>): boolean;
198
+ declare function isAnyInOut<T extends string>(source: WithId<NoInfer<T>>): (a: WithSourceTarget<WithId<T>>) => boolean;
199
+ declare function isAnyInOut<T extends string>(a: WithSourceTarget<WithId<T>>, source: WithId<T>): boolean;
200
+
201
+ /**
202
+ * Resolve connection from source to target
203
+ * If direction is `both`, also look for reverse connection
204
+ *
205
+ * @default direction directed
206
+ */
207
+ declare function findConnection$1<M extends AnyAux>(source: DeploymentElementModel<M>, target: DeploymentElementModel<NoInfer<M>>, direction: 'directed'): readonly [DeploymentConnectionModel<M>] | readonly [];
208
+ declare function findConnection$1<M extends AnyAux>(source: DeploymentElementModel<M>, target: DeploymentElementModel<NoInfer<M>>, direction: 'both'): readonly [DeploymentConnectionModel<M>, DeploymentConnectionModel<M>] | readonly [DeploymentConnectionModel<M>] | readonly [];
209
+ declare function findConnection$1<M extends AnyAux>(source: DeploymentElementModel<M>, target: DeploymentElementModel<NoInfer<M>>, direction?: 'directed' | 'both'): readonly [DeploymentConnectionModel<M>, DeploymentConnectionModel<M>] | readonly [DeploymentConnectionModel<M>] | readonly [];
210
+ /**
211
+ * Resolve all connections between element and others
212
+ * By default, look for both directions.
213
+ *
214
+ * @default direction both
215
+ */
216
+ declare function findConnectionsBetween$1<M extends AnyAux>(element: DeploymentElementModel<M>, others: Iterable<DeploymentElementModel<NoInfer<M>>>, direction?: 'directed' | 'both'): readonly DeploymentConnectionModel<M>[];
217
+ /**
218
+ * Resolve all connections within a given set of elements
219
+ */
220
+ declare function findConnectionsWithin$1<M extends AnyAux>(elements: Iterable<DeploymentElementModel<M>>): readonly DeploymentConnectionModel<M>[];
221
+
222
+ declare namespace find$1 {
223
+ export { findConnection$1 as findConnection, findConnectionsBetween$1 as findConnectionsBetween, findConnectionsWithin$1 as findConnectionsWithin };
224
+ }
225
+
226
+ /**
227
+ * Resolve connection from source to target
228
+ *
229
+ * @param direction - if 'both', also returns connection from target to source
230
+ * @default `directed`
231
+ */
232
+ declare function findConnection<M extends AnyAux>(source: ElementModel<M>, target: ElementModel<M>, direction?: 'directed' | 'both'): [ConnectionModel<M>, ConnectionModel<M>] | [ConnectionModel<M>] | [];
233
+ /**
234
+ * Resolve all connections between element and others
235
+ * @param direction - if 'directed', only look for outgoing connections from the element to others
236
+ * @default `both`
237
+ */
238
+ declare function findConnectionsBetween<M extends AnyAux>(element: ElementModel<M>, others: Iterable<ElementModel<NoInfer<M>>>, direction?: 'directed' | 'both'): readonly ConnectionModel<M>[];
239
+ /**
240
+ * Resolve all connections within a given set of elements
241
+ */
242
+ declare function findConnectionsWithin<M extends AnyAux>(elements: Iterable<ElementModel<M>>): readonly ConnectionModel<M>[];
243
+
244
+ declare const find_findConnection: typeof findConnection;
245
+ declare const find_findConnectionsBetween: typeof findConnectionsBetween;
246
+ declare const find_findConnectionsWithin: typeof findConnectionsWithin;
247
+ declare namespace find {
248
+ export { find_findConnection as findConnection, find_findConnectionsBetween as findConnectionsBetween, find_findConnectionsWithin as findConnectionsWithin };
249
+ }
250
+
251
+ declare function isDeploymentNode(model: DeploymentElementModel): model is DeploymentNodeModel;
252
+ declare function isDeployedInstance(model: DeploymentElementModel): model is DeployedInstanceModel;
253
+
254
+ export { AnyAux, Connection, ConnectionModel, DeployedInstanceModel, DeploymentConnectionModel, DeploymentElementModel, DeploymentNodeModel, DeploymentRelationModel, ElementModel, RelationshipModel, find$1 as deploymentConnection, differenceConnections, findAscendingConnections, findDeepestNestedConnection, findDescendantConnections, hasSameSource, hasSameSourceTarget, hasSameTarget, isAnyInOut, isDeployedInstance, isDeploymentNode, isIncoming, isNestedConnection, isOutgoing, mergeConnections, find as modelConnection, sortConnectionsByBoundaryHierarchy, sortDeepestFirst };
@@ -0,0 +1 @@
1
+ export { C as Connection, f as ConnectionModel, F as DeployedInstanceModel, D as DeploymentConnectionModel, H as DeploymentNodeModel, I as DeploymentRelationModel, J as EdgeModel, E as ElementModel, b as LikeC4DeploymentModel, L as LikeC4Model, e as LikeC4ViewModel, N as NodeModel, R as RelationshipModel, g as deploymentConnection, h as differenceConnections, j as findAscendingConnections, k as findDeepestNestedConnection, m as findDescendantConnections, n as hasSameSource, o as hasSameSourceTarget, p as hasSameTarget, q as isAnyInOut, K as isDeployedInstance, M as isDeploymentNode, s as isIncoming, v as isNestedConnection, x as isOutgoing, y as mergeConnections, z as modelConnection, A as sortConnectionsByBoundaryHierarchy, B as sortDeepestFirst } from '../shared/index.-BdzdI2C.js';
@@ -0,0 +1,21 @@
1
+ function nonNullable(value, message) {
2
+ if (typeof value === "undefined" || value == null) {
3
+ throw new Error(message ?? `Expected defined value, but received ${value}`);
4
+ }
5
+ return value;
6
+ }
7
+ function invariant(condition, message) {
8
+ if (condition) {
9
+ return;
10
+ }
11
+ throw new Error(message ?? "Invariant failed");
12
+ }
13
+ function nonexhaustive(value) {
14
+ throw new Error(`NonExhaustive value: ${value}`);
15
+ }
16
+
17
+ function u$1(t,n,a){let o=r=>t(r,...n);return a===void 0?o:Object.assign(o,{lazy:a,lazyArgs:n})}
18
+
19
+ function u(r,n,a){let o=r.length-n.length;if(o===0)return r(...n);if(o===1)return u$1(r,n,a);throw new Error("Wrong number of arguments")}
20
+
21
+ export { nonNullable as a, invariant as i, nonexhaustive as n, u };