@likec4/core 1.40.0 → 1.42.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 (257) hide show
  1. package/builder/package.json +4 -0
  2. package/compute-view/package.json +4 -0
  3. package/compute-view/relationships/package.json +4 -0
  4. package/dist/builder/index.d.mts +83 -20
  5. package/dist/builder/index.mjs +210 -126
  6. package/dist/compute-view/index.d.mts +8 -7
  7. package/dist/compute-view/index.mjs +14 -11
  8. package/dist/compute-view/relationships-view/index.d.mts +9 -8
  9. package/dist/compute-view/relationships-view/index.mjs +6 -6
  10. package/dist/index.d.mts +7 -7
  11. package/dist/index.mjs +12 -12
  12. package/dist/model/connection/deployment/index.d.mts +11 -10
  13. package/dist/model/connection/deployment/index.mjs +2 -2
  14. package/dist/model/connection/index.d.mts +12 -11
  15. package/dist/model/connection/index.mjs +3 -3
  16. package/dist/model/connection/model/index.d.mts +11 -10
  17. package/dist/model/connection/model/index.mjs +2 -2
  18. package/dist/model/index.d.mts +14 -14
  19. package/dist/model/index.mjs +4 -5
  20. package/dist/shared/{core.DHQ32OHa.mjs → core.01VTr9qu.mjs} +10 -29
  21. package/dist/shared/core.1vX5a9AY.mjs +86 -0
  22. package/dist/shared/{core.BVNaR17u.mjs → core.B7KhhkRY.mjs} +1 -1
  23. package/dist/shared/core.B85MJLTf.mjs +5 -0
  24. package/dist/shared/{core.BIAlzwKc.mjs → core.BIqHjQiH.mjs} +85 -45
  25. package/dist/shared/core.BKlholso.mjs +3 -0
  26. package/dist/shared/core.BR4zXDH-.mjs +13 -0
  27. package/dist/shared/{core.yHe79zEl.mjs → core.BYNkXQ8A.mjs} +21 -12
  28. package/dist/shared/core.BazD6cot.mjs +14 -0
  29. package/dist/shared/{core.BuoXfSMj.mjs → core.BbE4y-yl.mjs} +1 -1
  30. package/dist/shared/core.BoYfZOBm.mjs +3 -0
  31. package/dist/shared/core.BsSXS-_R.mjs +7 -0
  32. package/dist/shared/{core.T-eLZTW_.mjs → core.BzTakU3I.mjs} +15 -7
  33. package/dist/shared/{core.4u1dVmfX.mjs → core.C2TiyjI6.mjs} +2 -2
  34. package/dist/shared/{core.DLpidoWc.mjs → core.C3JowhaZ.mjs} +3 -3
  35. package/dist/shared/{core.CNGyqkJh.mjs → core.C4x8aaWa.mjs} +3 -1
  36. package/dist/shared/{core.BB6zA-UU.mjs → core.C8YY6Uub.mjs} +38 -9
  37. package/dist/shared/{core.FPITT8Vx.mjs → core.C8sl5Y8Z.mjs} +144 -61
  38. package/dist/shared/{core.DuR3R-xJ.mjs → core.CNgZvKb8.mjs} +3 -5176
  39. package/dist/shared/{core.BbThmf6M.d.mts → core.CQngdcuj.d.mts} +85 -4
  40. package/dist/shared/{core.Be1n9a0i.mjs → core.C_Ni6yHl.mjs} +5 -4
  41. package/dist/shared/core.CbT8JVYL.mjs +5 -0
  42. package/dist/shared/core.CqAJJpK_.mjs +3 -0
  43. package/dist/shared/{core.CySf-2gP.d.mts → core.D0PjZzIS.d.mts} +52 -15
  44. package/dist/shared/{core.DrvfVXkh.d.mts → core.D5fzJWbF.d.mts} +11 -2
  45. package/dist/shared/{core.DrVOJuxX.d.mts → core.DACpKp35.d.mts} +5 -5
  46. package/dist/shared/core.DFi2dOTl.mjs +39548 -0
  47. package/dist/shared/{core.D704WZES.d.mts → core.DIol3syK.d.mts} +2 -2
  48. package/dist/shared/{core.DlG1xWt2.mjs → core.DMMOWQqc.mjs} +3 -2
  49. package/dist/shared/core.DNbUPnve.mjs +3990 -0
  50. package/dist/shared/{core.CCD1ID81.mjs → core.DRJma0Ol.mjs} +4 -3
  51. package/dist/shared/{core.DgttqsJc.mjs → core.DRhg-gVU.mjs} +9 -9
  52. package/dist/shared/core.DSO_rTC2.mjs +5322 -0
  53. package/dist/shared/{core.vWJTxpLV.d.mts → core.D_vkffV4.d.mts} +4 -2
  54. package/dist/shared/core.DdMJk7nx.d.mts +476 -0
  55. package/dist/shared/{core.D_fI5Lf6.d.mts → core.Dgs6-nuz.d.mts} +24 -4
  56. package/dist/shared/{core.Be4Jy9Qx.mjs → core.FZ305VYd.mjs} +2 -2
  57. package/dist/shared/core.OHD4KXm9.mjs +5 -0
  58. package/dist/shared/{core.GTgsmXS_.mjs → core.QJD_fcrc.mjs} +2 -2
  59. package/dist/shared/core.RfnaEmgA.mjs +7 -0
  60. package/dist/shared/core.fHR_8Tnq.d.mts +450 -0
  61. package/dist/shared/{core.D0EgVMQK.mjs → core.lRvxPoao.mjs} +14 -12
  62. package/dist/shared/{core.CaT0SUUK.mjs → core.rCeaAqgW.mjs} +1 -84
  63. package/dist/shared/{core.kxeJe0OY.d.mts → core.s9uwOt60.d.mts} +4 -4
  64. package/dist/shared/core.yna0OdV5.d.mts +98 -0
  65. package/dist/styles/index.d.mts +106 -0
  66. package/dist/styles/index.mjs +1 -0
  67. package/dist/types/_aux.d.mts +2 -2
  68. package/dist/types/_aux.mjs +1 -5
  69. package/dist/types/expression-model.d.mts +3 -4
  70. package/dist/types/expression.d.mts +3 -4
  71. package/dist/types/fqnRef.d.mts +2 -2
  72. package/dist/types/fqnRef.mjs +3 -3
  73. package/dist/types/index.d.mts +8 -8
  74. package/dist/types/index.mjs +151 -6
  75. package/dist/types/scalar.mjs +3 -2
  76. package/dist/utils/graphology/index.d.mts +1864 -0
  77. package/dist/utils/graphology/index.mjs +1 -0
  78. package/dist/utils/index.d.mts +11 -6
  79. package/dist/utils/index.mjs +21 -37
  80. package/dist/utils/iterable/index.d.mts +1 -1
  81. package/dist/utils/iterable/index.mjs +45 -7
  82. package/model/package.json +4 -0
  83. package/package.json +42 -24
  84. package/styles/package.json +4 -0
  85. package/types/package.json +4 -0
  86. package/utils/graphology/package.json +4 -0
  87. package/utils/package.json +4 -0
  88. package/dist/shared/core.6_Vp2iiN.mjs +0 -172
  89. package/dist/shared/core.Bpou6c2f.d.mts +0 -850
  90. package/dist/shared/core.CUw_2J9j.mjs +0 -47
  91. package/dist/shared/core.CzdwsPmY.d.mts +0 -69
  92. package/dist/shared/core.DoM6aM9N.mjs +0 -7
  93. package/dist/shared/core.ILwny7BV.mjs +0 -38
  94. package/dist/theme/index.d.mts +0 -11
  95. package/dist/theme/index.mjs +0 -232
  96. package/src/builder/Builder.deployment.ts +0 -224
  97. package/src/builder/Builder.deploymentModel.ts +0 -449
  98. package/src/builder/Builder.element.ts +0 -241
  99. package/src/builder/Builder.model.ts +0 -494
  100. package/src/builder/Builder.ts +0 -870
  101. package/src/builder/Builder.view-common.ts +0 -273
  102. package/src/builder/Builder.view-deployment.ts +0 -135
  103. package/src/builder/Builder.view-element.ts +0 -202
  104. package/src/builder/Builder.views.ts +0 -399
  105. package/src/builder/Builder.with.ts +0 -156
  106. package/src/builder/_types.ts +0 -320
  107. package/src/builder/index.ts +0 -11
  108. package/src/compute-view/compute-view.ts +0 -80
  109. package/src/compute-view/deployment-view/_types.ts +0 -38
  110. package/src/compute-view/deployment-view/clean-connections.ts +0 -236
  111. package/src/compute-view/deployment-view/compute.ts +0 -94
  112. package/src/compute-view/deployment-view/memory/index.ts +0 -9
  113. package/src/compute-view/deployment-view/memory/memory.ts +0 -96
  114. package/src/compute-view/deployment-view/predicates/deploymentRefs-where.ts +0 -18
  115. package/src/compute-view/deployment-view/predicates/deploymentRefs.ts +0 -154
  116. package/src/compute-view/deployment-view/predicates/index.ts +0 -8
  117. package/src/compute-view/deployment-view/predicates/relation-direct.ts +0 -243
  118. package/src/compute-view/deployment-view/predicates/relation-in-out.ts +0 -70
  119. package/src/compute-view/deployment-view/predicates/relation-incoming.ts +0 -101
  120. package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +0 -95
  121. package/src/compute-view/deployment-view/predicates/relation-where.ts +0 -18
  122. package/src/compute-view/deployment-view/predicates/utils.ts +0 -282
  123. package/src/compute-view/deployment-view/predicates/wildcard.ts +0 -41
  124. package/src/compute-view/deployment-view/stages/stage-exclude.ts +0 -5
  125. package/src/compute-view/deployment-view/stages/stage-final.ts +0 -245
  126. package/src/compute-view/deployment-view/stages/stage-include.ts +0 -95
  127. package/src/compute-view/deployment-view/utils.ts +0 -286
  128. package/src/compute-view/dynamic-view/compute.ts +0 -312
  129. package/src/compute-view/element-view/_types.ts +0 -47
  130. package/src/compute-view/element-view/clean-connections.ts +0 -117
  131. package/src/compute-view/element-view/compute.ts +0 -324
  132. package/src/compute-view/element-view/memory/NodeGroup.ts +0 -31
  133. package/src/compute-view/element-view/memory/index.ts +0 -10
  134. package/src/compute-view/element-view/memory/memory.ts +0 -178
  135. package/src/compute-view/element-view/memory/stage-exclude.ts +0 -59
  136. package/src/compute-view/element-view/memory/stage-final.ts +0 -129
  137. package/src/compute-view/element-view/memory/stage-include.ts +0 -130
  138. package/src/compute-view/element-view/predicates/_utils.ts +0 -91
  139. package/src/compute-view/element-view/predicates/element-expand.ts +0 -29
  140. package/src/compute-view/element-view/predicates/element-kind-tag.ts +0 -27
  141. package/src/compute-view/element-view/predicates/element-ref.ts +0 -24
  142. package/src/compute-view/element-view/predicates/relation-direct.ts +0 -321
  143. package/src/compute-view/element-view/predicates/relation-in-out.ts +0 -64
  144. package/src/compute-view/element-view/predicates/relation-in.ts +0 -115
  145. package/src/compute-view/element-view/predicates/relation-out.ts +0 -119
  146. package/src/compute-view/element-view/predicates/wildcard.ts +0 -88
  147. package/src/compute-view/element-view/utils.ts +0 -65
  148. package/src/compute-view/index.ts +0 -4
  149. package/src/compute-view/memory/AbstractMemory.ts +0 -45
  150. package/src/compute-view/memory/AbstractStageExclude.ts +0 -215
  151. package/src/compute-view/memory/AbstractStageInclude.ts +0 -200
  152. package/src/compute-view/memory/_types.ts +0 -148
  153. package/src/compute-view/memory/index.ts +0 -5
  154. package/src/compute-view/memory/ops.ts +0 -43
  155. package/src/compute-view/relationships-view/_types.ts +0 -16
  156. package/src/compute-view/relationships-view/compute.ts +0 -159
  157. package/src/compute-view/relationships-view/index.ts +0 -3
  158. package/src/compute-view/relationships-view/layout.ts +0 -357
  159. package/src/compute-view/relationships-view/utils.ts +0 -73
  160. package/src/compute-view/utils/ancestorsOfNode.ts +0 -19
  161. package/src/compute-view/utils/applyCustomElementProperties.ts +0 -107
  162. package/src/compute-view/utils/applyCustomRelationProperties.ts +0 -58
  163. package/src/compute-view/utils/applyViewRuleStyles.ts +0 -73
  164. package/src/compute-view/utils/buildComputedNodes.ts +0 -153
  165. package/src/compute-view/utils/buildElementNotations.ts +0 -63
  166. package/src/compute-view/utils/elementExpressionToPredicate.ts +0 -50
  167. package/src/compute-view/utils/link-nodes-with-edges.ts +0 -56
  168. package/src/compute-view/utils/merge-props-from-relationships.ts +0 -161
  169. package/src/compute-view/utils/relationExpressionToPredicates.ts +0 -55
  170. package/src/compute-view/utils/resolve-extended-views.ts +0 -85
  171. package/src/compute-view/utils/resolve-global-rules.ts +0 -88
  172. package/src/compute-view/utils/topological-sort.ts +0 -256
  173. package/src/compute-view/utils/view-hash.ts +0 -45
  174. package/src/compute-view/utils/with-readable-edges.ts +0 -40
  175. package/src/index.ts +0 -32
  176. package/src/model/DeploymentElementModel.ts +0 -682
  177. package/src/model/DeploymentModel.ts +0 -393
  178. package/src/model/ElementModel.ts +0 -293
  179. package/src/model/LikeC4Model.ts +0 -882
  180. package/src/model/RelationModel.ts +0 -152
  181. package/src/model/connection/Connection.ts +0 -72
  182. package/src/model/connection/deployment/DeploymentConnectionModel.ts +0 -185
  183. package/src/model/connection/deployment/find.ts +0 -120
  184. package/src/model/connection/deployment/index.ts +0 -8
  185. package/src/model/connection/index.ts +0 -22
  186. package/src/model/connection/model/ConnectionModel.ts +0 -158
  187. package/src/model/connection/model/find.ts +0 -117
  188. package/src/model/connection/model/index.ts +0 -8
  189. package/src/model/connection/ops.ts +0 -276
  190. package/src/model/guards.ts +0 -77
  191. package/src/model/index.ts +0 -72
  192. package/src/model/types.ts +0 -67
  193. package/src/model/utils.ts +0 -66
  194. package/src/model/view/EdgeModel.ts +0 -120
  195. package/src/model/view/LikeC4ViewModel.ts +0 -361
  196. package/src/model/view/LikeC4ViewsFolder.ts +0 -151
  197. package/src/model/view/NodeModel.ts +0 -247
  198. package/src/theme/element.ts +0 -61
  199. package/src/theme/index.ts +0 -127
  200. package/src/theme/relationships.ts +0 -54
  201. package/src/types/RichText.ts +0 -206
  202. package/src/types/_aux.ts +0 -291
  203. package/src/types/_common.ts +0 -80
  204. package/src/types/const.ts +0 -34
  205. package/src/types/expression-model.ts +0 -294
  206. package/src/types/expression.ts +0 -313
  207. package/src/types/fqnRef.ts +0 -91
  208. package/src/types/geometry.ts +0 -159
  209. package/src/types/global.ts +0 -21
  210. package/src/types/index.ts +0 -42
  211. package/src/types/model-data.ts +0 -77
  212. package/src/types/model-deployment.ts +0 -88
  213. package/src/types/model-dump.ts +0 -79
  214. package/src/types/model-logical.ts +0 -135
  215. package/src/types/model-spec.ts +0 -85
  216. package/src/types/operators.ts +0 -156
  217. package/src/types/project.ts +0 -14
  218. package/src/types/scalar.ts +0 -162
  219. package/src/types/styles.ts +0 -122
  220. package/src/types/view-changes.ts +0 -32
  221. package/src/types/view-common.ts +0 -157
  222. package/src/types/view-computed.ts +0 -118
  223. package/src/types/view-layouted.ts +0 -98
  224. package/src/types/view-parsed.deployment.ts +0 -39
  225. package/src/types/view-parsed.dynamic.ts +0 -89
  226. package/src/types/view-parsed.element.ts +0 -65
  227. package/src/types/view.ts +0 -113
  228. package/src/utils/common-head.ts +0 -22
  229. package/src/utils/compare-natural.ts +0 -60
  230. package/src/utils/const.ts +0 -1
  231. package/src/utils/fqn.ts +0 -302
  232. package/src/utils/getOrCreate.ts +0 -8
  233. package/src/utils/guards.ts +0 -9
  234. package/src/utils/index.ts +0 -68
  235. package/src/utils/invariant.ts +0 -29
  236. package/src/utils/iterable/_types.ts +0 -5
  237. package/src/utils/iterable/filter.ts +0 -55
  238. package/src/utils/iterable/find.ts +0 -38
  239. package/src/utils/iterable/first.ts +0 -48
  240. package/src/utils/iterable/flat.ts +0 -17
  241. package/src/utils/iterable/head.ts +0 -22
  242. package/src/utils/iterable/index.ts +0 -15
  243. package/src/utils/iterable/map.ts +0 -40
  244. package/src/utils/iterable/reduce.ts +0 -24
  245. package/src/utils/iterable/some.ts +0 -36
  246. package/src/utils/iterable/to.ts +0 -19
  247. package/src/utils/iterable/unique.ts +0 -23
  248. package/src/utils/markdown/index.ts +0 -2
  249. package/src/utils/markdown/to-html.ts +0 -32
  250. package/src/utils/markdown/to-text.ts +0 -14
  251. package/src/utils/memoize-prop.ts +0 -30
  252. package/src/utils/mnemonist.ts +0 -9
  253. package/src/utils/object-hash.ts +0 -14
  254. package/src/utils/promises.ts +0 -24
  255. package/src/utils/relations.ts +0 -36
  256. package/src/utils/set.ts +0 -83
  257. package/src/utils/string-hash.ts +0 -16
@@ -1,320 +0,0 @@
1
- import type { IfNever, IsLiteral, IsNever, Tagged, TupleToUnion } from 'type-fest'
2
- import type {
3
- AnyAux,
4
- Aux,
5
- BorderStyle,
6
- ElementShape,
7
- ElementSpecification as ElementKindSpecification,
8
- Expression,
9
- KeysOf,
10
- NonEmptyArray,
11
- RelationshipArrowType,
12
- RelationshipLineType,
13
- RelationshipSpecification as RelationshipKindSpecification,
14
- ShapeSize,
15
- SpacingSize,
16
- SpecAux,
17
- TagSpecification,
18
- TextSize,
19
- ThemeColor as Color,
20
- } from '../types'
21
- import type { Builder } from './Builder'
22
- import type { DeploymentRulesBuilderOp } from './Builder.view-deployment'
23
-
24
- type ElementSpecification = Omit<ElementKindSpecification, 'tags'> & {
25
- tags?: string[]
26
- }
27
-
28
- export type BuilderSpecification = {
29
- elements: {
30
- [kind: string]: Partial<ElementSpecification>
31
- }
32
- relationships?: {
33
- [kind: string]: Partial<RelationshipKindSpecification>
34
- }
35
- deployments?: {
36
- [kind: string]: Partial<ElementSpecification>
37
- }
38
- tags?: {
39
- [kind: string]: Partial<TagSpecification>
40
- }
41
- metadataKeys?: string[]
42
- }
43
-
44
- /**
45
- * We need with `id: string` to be able to derive the project id
46
- *
47
- * @see {@link LikeC4Project}
48
- */
49
- export type BuilderProjectSpecification = {
50
- id: string
51
- title?: string
52
- }
53
-
54
- export type Metadata<MetadataKey extends string> = IsNever<MetadataKey> extends true ? never :
55
- IsLiteral<MetadataKey> extends true ? {
56
- [key in MetadataKey]?: string
57
- } :
58
- Record<string, string>
59
-
60
- export type NewElementProps<Tag, Metadata> = {
61
- title?: string
62
- description?: string
63
- technology?: string
64
- tags?: IfNever<Tag, never, [Tag, ...Tag[]]>
65
- metadata?: Metadata
66
- icon?: string
67
- shape?: ElementShape
68
- color?: Color
69
- links?: Array<string | { title?: string; url: string }>
70
- style?: {
71
- border?: BorderStyle
72
- // 0-100
73
- opacity?: number
74
- size?: ShapeSize
75
- padding?: SpacingSize
76
- textSize?: TextSize
77
- }
78
- }
79
-
80
- export type NewDeploymentNodeProps<Tag, Metadata> = {
81
- title?: string
82
- description?: string
83
- technology?: string
84
- tags?: IfNever<Tag, never, [Tag, ...Tag[]]>
85
- metadata?: Metadata
86
- icon?: string
87
- shape?: ElementShape
88
- color?: Color
89
- links?: NonEmptyArray<string | { title?: string; url: string }>
90
- style?: {
91
- border?: BorderStyle
92
- // 0-100
93
- opacity?: number
94
- size?: ShapeSize
95
- padding?: SpacingSize
96
- textSize?: TextSize
97
- }
98
- }
99
-
100
- export type NewViewProps<Tag> = {
101
- title?: string
102
- description?: string
103
- tags?: IfNever<Tag, never, [Tag, ...Tag[]]>
104
- links?: Array<string | { title?: string; url: string }>
105
- }
106
-
107
- export type NewRelationProps<Kind, Tag, Metadata> = {
108
- kind?: Kind
109
- title?: string
110
- description?: string
111
- technology?: string
112
- tags?: IfNever<Tag, never, [Tag, ...Tag[]]>
113
- metadata?: Metadata
114
- head?: RelationshipArrowType
115
- tail?: RelationshipArrowType
116
- line?: RelationshipLineType
117
- color?: Color
118
- links?: NonEmptyArray<string | { title?: string; url: string }>
119
- }
120
-
121
- export type Invalid<Message extends string> = Tagged<Message, 'Error'>
122
- export type Warn<Id, Existing> = IsLiteral<Existing> extends true ? Id extends Existing ? Invalid<'Already exists'> : Id
123
- : Id
124
-
125
- export type ValidId<Id> =
126
- // Id extends `${string}.${string}` ? Invalid<'Id must not contain dot'>
127
- Id extends `${number}${string}` ? Invalid<'Id must not start with number'>
128
- : IsLiteral<Id> extends true ? Id
129
- : Invalid<'Id must be a literal'>
130
-
131
- /**
132
- * Auxilary type to keep track of the types in builder
133
- */
134
- export interface Types<
135
- ElementKind extends string,
136
- Fqn extends string,
137
- ViewId extends string,
138
- RelationshipKind extends string,
139
- Tag extends string,
140
- MetadataKey extends string,
141
- DeploymentKind extends string,
142
- DeploymentFqn extends string,
143
- > {
144
- ElementKind: ElementKind
145
- Fqn: Fqn
146
- ViewId: ViewId
147
- RelationshipKind: RelationshipKind
148
- Tag: Tag
149
- MetadataKey: MetadataKey
150
- DeploymentKind: DeploymentKind
151
- DeploymentFqn: DeploymentFqn
152
-
153
- Tags: IfNever<Tag, never, [Tag, ...Tag[]]>
154
- // Metadata: Metadata<MetadataKey>
155
-
156
- NewElementProps: NewElementProps<Tag, Metadata<MetadataKey>>
157
- NewRelationshipProps: NewRelationProps<RelationshipKind, Tag, Metadata<MetadataKey>>
158
- NewViewProps: NewViewProps<Tag>
159
-
160
- NewDeploymentNodeProps: NewDeploymentNodeProps<Tag, Metadata<MetadataKey>>
161
- }
162
-
163
- /**
164
- * When building nested objects
165
- */
166
- export interface TypesNested<
167
- Parent extends string,
168
- ElementKind extends string,
169
- Fqn extends string,
170
- ViewId extends string,
171
- RelationshipKind extends string,
172
- Tag extends string,
173
- MetadataKey extends string,
174
- DeploymentKind extends string,
175
- DeploymentFqn extends string,
176
- > extends
177
- Types<
178
- ElementKind,
179
- Fqn,
180
- ViewId,
181
- RelationshipKind,
182
- Tag,
183
- MetadataKey,
184
- DeploymentKind,
185
- DeploymentFqn
186
- >
187
- {
188
- Parent: Parent
189
- }
190
-
191
- export type AnyTypes = Types<
192
- any,
193
- any,
194
- any,
195
- any,
196
- any,
197
- any,
198
- any,
199
- any
200
- >
201
-
202
- export type AnyTypesNested = TypesNested<
203
- any,
204
- any,
205
- any,
206
- any,
207
- any,
208
- any,
209
- any,
210
- any,
211
- any
212
- >
213
-
214
- export namespace Types {
215
- export type FromSpecification<Spec> = Spec extends BuilderSpecification ? Types<
216
- KeysOf<Spec['elements']>,
217
- never,
218
- never,
219
- KeysOf<Spec['relationships']>,
220
- KeysOf<Spec['tags']>,
221
- TupleToUnion<Spec['metadataKeys']>,
222
- KeysOf<Spec['deployments']>,
223
- never
224
- >
225
- : never
226
-
227
- export type AddFqn<T, Id extends string> = T extends TypesNested<infer P, any, any, any, any, any, any, any, any>
228
- ? TypesNested<
229
- P,
230
- T['ElementKind'],
231
- `${P}.${Id}` | T['Fqn'],
232
- T['ViewId'],
233
- T['RelationshipKind'],
234
- T['Tag'],
235
- T['MetadataKey'],
236
- T['DeploymentKind'],
237
- T['DeploymentFqn']
238
- >
239
- : T extends AnyTypes ? Types<
240
- T['ElementKind'],
241
- Id | T['Fqn'],
242
- T['ViewId'],
243
- T['RelationshipKind'],
244
- T['Tag'],
245
- T['MetadataKey'],
246
- T['DeploymentKind'],
247
- T['DeploymentFqn']
248
- >
249
- : never
250
-
251
- export type AddDeploymentFqn<T, Id extends string> = T extends
252
- TypesNested<infer P, any, any, any, any, any, any, any, any> ? TypesNested<
253
- P,
254
- T['ElementKind'],
255
- T['Fqn'],
256
- T['ViewId'],
257
- T['RelationshipKind'],
258
- T['Tag'],
259
- T['MetadataKey'],
260
- T['DeploymentKind'],
261
- `${P}.${Id}` | T['DeploymentFqn']
262
- >
263
- : T extends AnyTypes ? Types<
264
- T['ElementKind'],
265
- T['Fqn'],
266
- T['ViewId'],
267
- T['RelationshipKind'],
268
- T['Tag'],
269
- T['MetadataKey'],
270
- T['DeploymentKind'],
271
- Id | T['DeploymentFqn']
272
- >
273
- : never
274
-
275
- export type AddView<T, Id extends string> = T extends TypesNested<infer P, any, any, any, any, any, any, any, any>
276
- ? TypesNested<
277
- P,
278
- T['ElementKind'],
279
- T['Fqn'],
280
- Id | T['ViewId'],
281
- T['RelationshipKind'],
282
- T['Tag'],
283
- T['MetadataKey'],
284
- T['DeploymentKind'],
285
- T['DeploymentFqn']
286
- >
287
- : T extends AnyTypes ? Types<
288
- T['ElementKind'],
289
- T['Fqn'],
290
- Id | T['ViewId'],
291
- T['RelationshipKind'],
292
- T['Tag'],
293
- T['MetadataKey'],
294
- T['DeploymentKind'],
295
- T['DeploymentFqn']
296
- >
297
- : never
298
-
299
- export type ToAux<T> = T extends AnyTypes ? Aux<
300
- 'parsed',
301
- T['Fqn'],
302
- T['DeploymentFqn'],
303
- T['ViewId'],
304
- 'from-builder',
305
- SpecAux<
306
- T['ElementKind'],
307
- T['DeploymentKind'],
308
- T['RelationshipKind'],
309
- T['Tag'],
310
- T['MetadataKey']
311
- >
312
- >
313
- : AnyAux
314
-
315
- export type ToExpression<T> = T extends AnyTypes ? Expression<ToAux<T>> : never
316
-
317
- export type From<B> = B extends Builder<infer T> ? B['Types'] extends AnyTypes ? T : AnyTypes : never
318
-
319
- export type DeploymentRules<B> = DeploymentRulesBuilderOp<From<B>>
320
- }
@@ -1,11 +0,0 @@
1
- export type * from './_types'
2
- export { Builder } from './Builder'
3
- export type * from './Builder.deployment'
4
- export type * from './Builder.deploymentModel'
5
- export type * from './Builder.element'
6
- export type * from './Builder.model'
7
- export type * from './Builder.view-common'
8
- export type * from './Builder.view-deployment'
9
- export type * from './Builder.view-element'
10
- export type * from './Builder.views'
11
- export type * from './Builder.with'
@@ -1,80 +0,0 @@
1
- import { indexBy, values } from 'remeda'
2
- import { LikeC4Model } from '../model'
3
- import {
4
- type AnyAux,
5
- type ComputedLikeC4ModelData,
6
- type ComputedView,
7
- type ParsedLikeC4ModelData,
8
- type ParsedView,
9
- _stage,
10
- isDeploymentView,
11
- isDynamicView,
12
- isElementView,
13
- } from '../types'
14
- import { nonexhaustive } from '../utils'
15
- import { computeDeploymentView } from './deployment-view/compute'
16
- import { computeDynamicView } from './dynamic-view/compute'
17
- import { computeElementView } from './element-view/compute'
18
-
19
- export type ComputeViewResult<V> =
20
- | {
21
- isSuccess: true
22
- error?: undefined
23
- view: V
24
- }
25
- | {
26
- isSuccess: false
27
- error: Error
28
- view: undefined
29
- }
30
-
31
- export function unsafeComputeView<A extends AnyAux>(
32
- viewsource: ParsedView<A>,
33
- likec4model: LikeC4Model<any>,
34
- ): ComputedView<A> {
35
- switch (true) {
36
- case isElementView(viewsource):
37
- return computeElementView(likec4model, viewsource)
38
- case isDeploymentView(viewsource):
39
- return computeDeploymentView(likec4model, viewsource)
40
- case isDynamicView(viewsource):
41
- return computeDynamicView(likec4model, viewsource)
42
- default:
43
- nonexhaustive(viewsource)
44
- }
45
- }
46
-
47
- export function computeView<A extends AnyAux>(
48
- viewsource: ParsedView<A>,
49
- likec4model: LikeC4Model<A>,
50
- ): ComputeViewResult<ComputedView<A>> {
51
- try {
52
- return {
53
- isSuccess: true,
54
- view: unsafeComputeView(viewsource, likec4model),
55
- }
56
- } catch (e) {
57
- return {
58
- isSuccess: false,
59
- error: e instanceof Error ? e : new Error(`Unknown error: ${e}`),
60
- view: undefined,
61
- }
62
- }
63
- }
64
-
65
- export function computeParsedModelData<A extends AnyAux>(
66
- parsed: ParsedLikeC4ModelData<A>,
67
- ): ComputedLikeC4ModelData<A> {
68
- const likec4model = LikeC4Model.create(parsed)
69
- const views = values(parsed.views as Record<string, ParsedView<A>>)
70
- .map(v => unsafeComputeView(v, likec4model))
71
- return {
72
- ...parsed,
73
- [_stage]: 'computed',
74
- views: indexBy(views, v => v.id),
75
- } as ComputedLikeC4ModelData<A>
76
- }
77
-
78
- export function computeLikeC4Model<A extends AnyAux>(parsed: ParsedLikeC4ModelData<A>): LikeC4Model.Computed<A> {
79
- return LikeC4Model.create(computeParsedModelData(parsed))
80
- }
@@ -1,38 +0,0 @@
1
- import type { RelationshipModel } from '../../model'
2
- import { LikeC4DeploymentModel } from '../../model'
3
- import type { AnyAux, Expression, OperatorPredicate } from '../../types'
4
- import type { Ctx, Memory, Stage, StageExclude, StageInclude } from './memory'
5
-
6
- export { Memory, type Stage } from './memory'
7
-
8
- export type Where<T extends {}> = (x: T) => boolean
9
-
10
- export type Elem = Ctx['Element']
11
- export type Connection = Ctx['Connection']
12
-
13
- export type ElementWhere = Where<Elem>
14
- export type ElementWhereFilter = (elements: readonly Elem[]) => Elem[]
15
- export type ConnectionWhere = Where<Connection>
16
- export type RelationshipWhere = Where<RelationshipModel<any>>
17
- export type ConnectionWhereFilter = (connections: readonly Connection[]) => Connection[]
18
-
19
- export type Connections = ReadonlyArray<Connection>
20
-
21
- export interface PredicateCtx<Expr = Expression<AnyAux>> {
22
- expr: Expr
23
- stage: Stage
24
- model: LikeC4DeploymentModel<AnyAux>
25
- memory: Memory
26
- where: OperatorPredicate<AnyAux> | null
27
- }
28
- export interface IncludePredicateCtx<Expr = Expression<AnyAux>> extends PredicateCtx<Expr> {
29
- stage: StageInclude
30
- }
31
- export interface ExcludePredicateCtx<Expr = Expression<AnyAux>> extends PredicateCtx<Expr> {
32
- stage: StageExclude
33
- }
34
-
35
- export interface PredicateExecutor<Expr extends Expression<AnyAux> = Expression<AnyAux>> {
36
- include(ctx: IncludePredicateCtx<Expr>): StageInclude | undefined
37
- exclude(ctx: ExcludePredicateCtx<Expr>): StageExclude | undefined
38
- }
@@ -1,236 +0,0 @@
1
- import {
2
- dropWhile,
3
- filter,
4
- flatMap,
5
- forEach,
6
- groupBy,
7
- hasAtLeast,
8
- map,
9
- pipe,
10
- piped,
11
- prop,
12
- reduce,
13
- values,
14
- } from 'remeda'
15
- import type { RelationshipModel } from '../../model'
16
- import {
17
- DeploymentConnectionModel,
18
- differenceConnections,
19
- isNestedConnection,
20
- mergeConnections,
21
- RelationshipsAccum,
22
- sortConnectionsByBoundaryHierarchy,
23
- } from '../../model'
24
- import { invariant } from '../../utils'
25
- import { imap, toArray } from '../../utils/iterable'
26
- import { DefaultMap } from '../../utils/mnemonist'
27
- import { intersection, union } from '../../utils/set'
28
- import type { Connection, Connections } from './_types'
29
- import { findConnection } from './utils'
30
-
31
- type MapOfExcludesFromConnection = DefaultMap<DeploymentConnectionModel, Set<RelationshipModel>>
32
- function findCrossBoundarySameSourceOrTarget(connections: Connections): MapOfExcludesFromConnection {
33
- // Also find connections based on same relation
34
- const groupedByRelation = new DefaultMap<RelationshipModel, Array<DeploymentConnectionModel>>(() => [])
35
- for (const conn of connections) {
36
- for (const relation of conn.relations.model) {
37
- groupedByRelation.get(relation).push(conn)
38
- }
39
- }
40
-
41
- // Aggreate excluded relations for each connection
42
- const excludedRelations = new DefaultMap<
43
- DeploymentConnectionModel,
44
- Set<RelationshipModel>
45
- >(() => new Set())
46
-
47
- // In each group, find connected to same leaf
48
- for (const [relation, sameRelationGroup] of groupedByRelation) {
49
- if (!hasAtLeast(sameRelationGroup, 2)) {
50
- continue
51
- }
52
-
53
- // Outgoing from same source
54
- pipe(
55
- sameRelationGroup,
56
- flatMap(conn => [
57
- { group: `$source-${conn.source.id}`, conn },
58
- { group: `$target-${conn.target.id}`, conn },
59
- ]),
60
- groupBy(prop('group')),
61
- values(),
62
- filter(hasAtLeast(2)),
63
- forEach(
64
- // In each group, sort by hierarchy, first are deepest
65
- piped(
66
- map(prop('conn')),
67
- sortConnectionsByBoundaryHierarchy('desc'),
68
- // Drop first, as it is the deepest
69
- // Drop if boundary is same as previous
70
- dropWhile((conn, i, all) => i === 0 || conn.boundary === all[i - 1]!.boundary),
71
- // Drop relations from boundaries above
72
- forEach((conn) => {
73
- excludedRelations.get(conn).add(relation)
74
- }),
75
- ),
76
- ),
77
- )
78
- }
79
-
80
- return excludedRelations
81
- }
82
-
83
- /**
84
- * Identifies and processes cross-boundary connections in a deployment diagram.
85
- * This function analyzes connections between nodes and removes redundant relations
86
- * when multiple connections exist between the same elements across different boundaries.
87
- *
88
- * The function performs the following:
89
- * 1. Groups connections by their relationship type
90
- * 2. For each relationship group, identifies connections that:
91
- * - Share the same source
92
- * - Share the same target
93
- * 3. When multiple connections are found in the same group, keeps only the most specific
94
- * (deepest in hierarchy) connection and removes the relationship from others
95
- *
96
- * @param connections - The input collection of deployment connections to analyze
97
- * @returns connections with redundant cross-boundary relationships
98
- */
99
- export function findCrossBoundaryConnections(connections: Connections): Array<Connection> {
100
- // Ensure connections are merged
101
- connections = mergeConnections(connections)
102
-
103
- const excludedRelations = findCrossBoundarySameSourceOrTarget(connections)
104
-
105
- for (const c of connections) {
106
- const { source, target } = c
107
- const connectionModelRelations = c.relations.model
108
- // Connections between node and instance
109
- // Exclude internal relations of the node (otherwise they are cross-boundary)
110
- if (source.isDeploymentNode() !== target.isDeploymentNode()) {
111
- const node = source.isDeploymentNode() ? source : c.target
112
- invariant(node.isDeploymentNode())
113
- const nodeInternals = node.internalModelRelationships()
114
- const toExclude = intersection(
115
- connectionModelRelations,
116
- nodeInternals,
117
- )
118
- for (const relation of toExclude) {
119
- excludedRelations.get(c).add(relation)
120
- }
121
-
122
- continue
123
- }
124
-
125
- // Connection between nodes
126
- if (source.isDeploymentNode() && target.isDeploymentNode()) {
127
- const toExclude = union(
128
- // Exclude node internals (otherwise thay are cross-boundary)
129
- intersection(
130
- c.relations.model,
131
- source.internalModelRelationships(),
132
- ),
133
- intersection(
134
- c.relations.model,
135
- target.internalModelRelationships(),
136
- ),
137
- )
138
- for (const relation of toExclude) {
139
- excludedRelations.get(c).add(relation)
140
- }
141
- }
142
- }
143
-
144
- return pipe(
145
- excludedRelations.entries(),
146
- imap(([c, excluded]) =>
147
- c.update({
148
- model: excluded,
149
- deployment: null,
150
- })
151
- ),
152
- toArray(),
153
- )
154
- }
155
-
156
- /**
157
- * Cleans connections that cross boundaries by removing overlapping parts.
158
- * @example
159
- * ```ts
160
- * const connections = getConnections();
161
- * const cleanedConnections = cleanCrossBoundary(connections);
162
- * ```
163
- */
164
- export function cleanCrossBoundary(connections: Connections): Array<Connection> {
165
- return differenceConnections(
166
- connections,
167
- findCrossBoundaryConnections(connections),
168
- )
169
- }
170
-
171
- /**
172
- * Identifies and returns redundant connections in a deployment view.
173
- * A connection is considered redundant if its relationships are already implied
174
- * through other connections
175
- *
176
- * @returns Array of redundant connections that can be safely removed
177
- */
178
- export function findRedundantConnections(connections: Connections): Array<Connection> {
179
- return pipe(
180
- connections,
181
- mergeConnections,
182
- reduce((redundants, connection) => {
183
- const { source, target, relations } = connection
184
-
185
- // Connection between instances is always explicit
186
- if (source.isInstance() && target.isInstance()) {
187
- return redundants
188
- }
189
-
190
- let redundantAccum = RelationshipsAccum.empty()
191
-
192
- if (source.isDeploymentNode() && target.isDeploymentNode()) {
193
- const [reversed] = findConnection(target, source, 'directed')
194
- if (reversed) {
195
- redundantAccum = relations.intersect(reversed.relations)
196
- }
197
- }
198
-
199
- for (const c of connections) {
200
- if (isNestedConnection(c, connection)) {
201
- redundantAccum = redundantAccum.union(
202
- relations.intersect(c.relations),
203
- )
204
- }
205
- }
206
-
207
- if (redundantAccum.nonEmpty) {
208
- redundants.push(
209
- new DeploymentConnectionModel(
210
- source,
211
- target,
212
- redundantAccum,
213
- ),
214
- )
215
- }
216
-
217
- return redundants
218
- }, [] as DeploymentConnectionModel[]),
219
- )
220
- }
221
-
222
- /**
223
- * Remove relationships from connection model, that are already included in the connections between descendants.
224
- * In other words - if there is same connection down the hierarchy.
225
- *
226
- * @returns New connection without redundant relationships
227
- * Connection may be empty if all relationships are redundant, in this case it should be removed
228
- */
229
- export function cleanRedundantRelationships(
230
- connections: Connections,
231
- ): Array<Connection> {
232
- return differenceConnections(
233
- connections,
234
- findRedundantConnections(connections),
235
- )
236
- }