@likec4/core 1.41.0 → 1.42.1

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 (255) 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 +13 -11
  5. package/dist/builder/index.mjs +111 -91
  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 +11 -11
  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.Ae86Y3tB.mjs → core.01VTr9qu.mjs} +8 -26
  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.DA5vzwZ9.mjs → core.BIqHjQiH.mjs} +56 -42
  25. package/dist/shared/core.BKlholso.mjs +3 -0
  26. package/dist/shared/core.BR4zXDH-.mjs +13 -0
  27. package/dist/shared/{core.CXy1NLUG.mjs → core.BYNkXQ8A.mjs} +21 -12
  28. package/dist/shared/{core.BuoXfSMj.mjs → core.BbE4y-yl.mjs} +1 -1
  29. package/dist/shared/core.BoYfZOBm.mjs +3 -0
  30. package/dist/shared/core.BsSXS-_R.mjs +7 -0
  31. package/dist/shared/{core.DJp8fgok.mjs → core.BzTakU3I.mjs} +14 -10
  32. package/dist/shared/{core.4u1dVmfX.mjs → core.C2TiyjI6.mjs} +2 -2
  33. package/dist/shared/{core.DLpidoWc.mjs → core.C3JowhaZ.mjs} +3 -3
  34. package/dist/shared/{core.CNGyqkJh.mjs → core.C4x8aaWa.mjs} +3 -1
  35. package/dist/shared/{core.BB6zA-UU.mjs → core.C8YY6Uub.mjs} +38 -9
  36. package/dist/shared/{core.Asc11Mjy.mjs → core.C8sl5Y8Z.mjs} +122 -58
  37. package/dist/shared/{core.BvMRMo7Z.mjs → core.CNgZvKb8.mjs} +3 -5198
  38. package/dist/shared/{core.CUG6vpyL.d.mts → core.CQngdcuj.d.mts} +85 -4
  39. package/dist/shared/{core.Be1n9a0i.mjs → core.C_Ni6yHl.mjs} +5 -4
  40. package/dist/shared/core.CbT8JVYL.mjs +5 -0
  41. package/dist/shared/core.CqAJJpK_.mjs +3 -0
  42. package/dist/shared/{core.BXsxn-hf.d.mts → core.D0PjZzIS.d.mts} +27 -15
  43. package/dist/shared/{core.DgesAwC8.d.mts → core.D5fzJWbF.d.mts} +2 -2
  44. package/dist/shared/{core.hfOE3RfK.d.mts → core.DACpKp35.d.mts} +5 -5
  45. package/dist/shared/core.DFi2dOTl.mjs +39548 -0
  46. package/dist/shared/{core.xSQO0XYD.d.mts → core.DIol3syK.d.mts} +2 -2
  47. package/dist/shared/{core.DlG1xWt2.mjs → core.DMMOWQqc.mjs} +3 -2
  48. package/dist/shared/core.DNbUPnve.mjs +3990 -0
  49. package/dist/shared/{core.CCD1ID81.mjs → core.DRJma0Ol.mjs} +4 -3
  50. package/dist/shared/{core.DgttqsJc.mjs → core.DRhg-gVU.mjs} +9 -9
  51. package/dist/shared/core.DSO_rTC2.mjs +5322 -0
  52. package/dist/shared/{core.FUPplpae.d.mts → core.D_vkffV4.d.mts} +4 -2
  53. package/dist/shared/core.DdMJk7nx.d.mts +476 -0
  54. package/dist/shared/{core.BhpgpOep.d.mts → core.Dgs6-nuz.d.mts} +2 -2
  55. package/dist/shared/{core.Be4Jy9Qx.mjs → core.FZ305VYd.mjs} +2 -2
  56. package/dist/shared/core.OHD4KXm9.mjs +5 -0
  57. package/dist/shared/{core.GTgsmXS_.mjs → core.QJD_fcrc.mjs} +2 -2
  58. package/dist/shared/core.RfnaEmgA.mjs +7 -0
  59. package/dist/shared/core.fHR_8Tnq.d.mts +450 -0
  60. package/dist/shared/{core.D0EgVMQK.mjs → core.lRvxPoao.mjs} +14 -12
  61. package/dist/shared/{core.CaT0SUUK.mjs → core.rCeaAqgW.mjs} +1 -84
  62. package/dist/shared/{core.zxTBF_PD.d.mts → core.s9uwOt60.d.mts} +4 -4
  63. package/dist/shared/core.yna0OdV5.d.mts +98 -0
  64. package/dist/styles/index.d.mts +106 -0
  65. package/dist/styles/index.mjs +1 -0
  66. package/dist/types/_aux.d.mts +2 -2
  67. package/dist/types/expression-model.d.mts +3 -4
  68. package/dist/types/expression.d.mts +3 -4
  69. package/dist/types/fqnRef.d.mts +2 -2
  70. package/dist/types/fqnRef.mjs +3 -3
  71. package/dist/types/index.d.mts +8 -8
  72. package/dist/types/index.mjs +150 -5
  73. package/dist/types/scalar.mjs +3 -2
  74. package/dist/utils/graphology/index.d.mts +1864 -0
  75. package/dist/utils/graphology/index.mjs +1 -0
  76. package/dist/utils/index.d.mts +11 -6
  77. package/dist/utils/index.mjs +21 -37
  78. package/dist/utils/iterable/index.d.mts +1 -1
  79. package/dist/utils/iterable/index.mjs +45 -7
  80. package/model/package.json +4 -0
  81. package/package.json +42 -24
  82. package/styles/package.json +4 -0
  83. package/types/package.json +4 -0
  84. package/utils/graphology/package.json +4 -0
  85. package/utils/package.json +4 -0
  86. package/dist/shared/core.6_Vp2iiN.mjs +0 -172
  87. package/dist/shared/core.CUw_2J9j.mjs +0 -47
  88. package/dist/shared/core.CzdwsPmY.d.mts +0 -69
  89. package/dist/shared/core.D-ZGWDDt.d.mts +0 -831
  90. package/dist/shared/core.DoM6aM9N.mjs +0 -7
  91. package/dist/shared/core.ILwny7BV.mjs +0 -38
  92. package/dist/theme/index.d.mts +0 -11
  93. package/dist/theme/index.mjs +0 -232
  94. package/src/builder/Builder.deployment.ts +0 -224
  95. package/src/builder/Builder.deploymentModel.ts +0 -449
  96. package/src/builder/Builder.element.ts +0 -241
  97. package/src/builder/Builder.model.ts +0 -494
  98. package/src/builder/Builder.ts +0 -946
  99. package/src/builder/Builder.view-common.ts +0 -273
  100. package/src/builder/Builder.view-deployment.ts +0 -135
  101. package/src/builder/Builder.view-element.ts +0 -202
  102. package/src/builder/Builder.views.ts +0 -399
  103. package/src/builder/Builder.with.ts +0 -156
  104. package/src/builder/_types.ts +0 -324
  105. package/src/builder/index.ts +0 -11
  106. package/src/compute-view/compute-view.ts +0 -80
  107. package/src/compute-view/deployment-view/_types.ts +0 -38
  108. package/src/compute-view/deployment-view/clean-connections.ts +0 -236
  109. package/src/compute-view/deployment-view/compute.ts +0 -94
  110. package/src/compute-view/deployment-view/memory/index.ts +0 -9
  111. package/src/compute-view/deployment-view/memory/memory.ts +0 -96
  112. package/src/compute-view/deployment-view/predicates/deploymentRefs-where.ts +0 -18
  113. package/src/compute-view/deployment-view/predicates/deploymentRefs.ts +0 -154
  114. package/src/compute-view/deployment-view/predicates/index.ts +0 -8
  115. package/src/compute-view/deployment-view/predicates/relation-direct.ts +0 -243
  116. package/src/compute-view/deployment-view/predicates/relation-in-out.ts +0 -70
  117. package/src/compute-view/deployment-view/predicates/relation-incoming.ts +0 -101
  118. package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +0 -95
  119. package/src/compute-view/deployment-view/predicates/relation-where.ts +0 -18
  120. package/src/compute-view/deployment-view/predicates/utils.ts +0 -282
  121. package/src/compute-view/deployment-view/predicates/wildcard.ts +0 -41
  122. package/src/compute-view/deployment-view/stages/stage-exclude.ts +0 -5
  123. package/src/compute-view/deployment-view/stages/stage-final.ts +0 -245
  124. package/src/compute-view/deployment-view/stages/stage-include.ts +0 -95
  125. package/src/compute-view/deployment-view/utils.ts +0 -297
  126. package/src/compute-view/dynamic-view/compute.ts +0 -312
  127. package/src/compute-view/element-view/_types.ts +0 -47
  128. package/src/compute-view/element-view/clean-connections.ts +0 -117
  129. package/src/compute-view/element-view/compute.ts +0 -324
  130. package/src/compute-view/element-view/memory/NodeGroup.ts +0 -31
  131. package/src/compute-view/element-view/memory/index.ts +0 -10
  132. package/src/compute-view/element-view/memory/memory.ts +0 -178
  133. package/src/compute-view/element-view/memory/stage-exclude.ts +0 -59
  134. package/src/compute-view/element-view/memory/stage-final.ts +0 -129
  135. package/src/compute-view/element-view/memory/stage-include.ts +0 -130
  136. package/src/compute-view/element-view/predicates/_utils.ts +0 -91
  137. package/src/compute-view/element-view/predicates/element-expand.ts +0 -29
  138. package/src/compute-view/element-view/predicates/element-kind-tag.ts +0 -27
  139. package/src/compute-view/element-view/predicates/element-ref.ts +0 -24
  140. package/src/compute-view/element-view/predicates/relation-direct.ts +0 -321
  141. package/src/compute-view/element-view/predicates/relation-in-out.ts +0 -64
  142. package/src/compute-view/element-view/predicates/relation-in.ts +0 -115
  143. package/src/compute-view/element-view/predicates/relation-out.ts +0 -119
  144. package/src/compute-view/element-view/predicates/wildcard.ts +0 -88
  145. package/src/compute-view/element-view/utils.ts +0 -65
  146. package/src/compute-view/index.ts +0 -4
  147. package/src/compute-view/memory/AbstractMemory.ts +0 -45
  148. package/src/compute-view/memory/AbstractStageExclude.ts +0 -215
  149. package/src/compute-view/memory/AbstractStageInclude.ts +0 -200
  150. package/src/compute-view/memory/_types.ts +0 -148
  151. package/src/compute-view/memory/index.ts +0 -5
  152. package/src/compute-view/memory/ops.ts +0 -43
  153. package/src/compute-view/relationships-view/_types.ts +0 -16
  154. package/src/compute-view/relationships-view/compute.ts +0 -159
  155. package/src/compute-view/relationships-view/index.ts +0 -3
  156. package/src/compute-view/relationships-view/layout.ts +0 -358
  157. package/src/compute-view/relationships-view/utils.ts +0 -73
  158. package/src/compute-view/utils/ancestorsOfNode.ts +0 -19
  159. package/src/compute-view/utils/applyCustomElementProperties.ts +0 -107
  160. package/src/compute-view/utils/applyCustomRelationProperties.ts +0 -58
  161. package/src/compute-view/utils/applyViewRuleStyles.ts +0 -73
  162. package/src/compute-view/utils/buildComputedNodes.ts +0 -166
  163. package/src/compute-view/utils/buildElementNotations.ts +0 -64
  164. package/src/compute-view/utils/elementExpressionToPredicate.ts +0 -50
  165. package/src/compute-view/utils/link-nodes-with-edges.ts +0 -56
  166. package/src/compute-view/utils/merge-props-from-relationships.ts +0 -161
  167. package/src/compute-view/utils/relationExpressionToPredicates.ts +0 -55
  168. package/src/compute-view/utils/resolve-extended-views.ts +0 -85
  169. package/src/compute-view/utils/resolve-global-rules.ts +0 -88
  170. package/src/compute-view/utils/topological-sort.ts +0 -256
  171. package/src/compute-view/utils/view-hash.ts +0 -45
  172. package/src/compute-view/utils/with-readable-edges.ts +0 -40
  173. package/src/index.ts +0 -32
  174. package/src/model/DeploymentElementModel.ts +0 -712
  175. package/src/model/DeploymentModel.ts +0 -393
  176. package/src/model/ElementModel.ts +0 -316
  177. package/src/model/LikeC4Model.ts +0 -882
  178. package/src/model/RelationModel.ts +0 -152
  179. package/src/model/connection/Connection.ts +0 -72
  180. package/src/model/connection/deployment/DeploymentConnectionModel.ts +0 -185
  181. package/src/model/connection/deployment/find.ts +0 -120
  182. package/src/model/connection/deployment/index.ts +0 -8
  183. package/src/model/connection/index.ts +0 -22
  184. package/src/model/connection/model/ConnectionModel.ts +0 -158
  185. package/src/model/connection/model/find.ts +0 -117
  186. package/src/model/connection/model/index.ts +0 -8
  187. package/src/model/connection/ops.ts +0 -276
  188. package/src/model/guards.ts +0 -77
  189. package/src/model/index.ts +0 -72
  190. package/src/model/types.ts +0 -67
  191. package/src/model/utils.ts +0 -66
  192. package/src/model/view/EdgeModel.ts +0 -121
  193. package/src/model/view/LikeC4ViewModel.ts +0 -361
  194. package/src/model/view/LikeC4ViewsFolder.ts +0 -151
  195. package/src/model/view/NodeModel.ts +0 -247
  196. package/src/theme/element.ts +0 -61
  197. package/src/theme/index.ts +0 -127
  198. package/src/theme/relationships.ts +0 -54
  199. package/src/types/RichText.ts +0 -205
  200. package/src/types/_aux.ts +0 -317
  201. package/src/types/_common.ts +0 -102
  202. package/src/types/const.ts +0 -34
  203. package/src/types/expression-model.ts +0 -294
  204. package/src/types/expression.ts +0 -313
  205. package/src/types/fqnRef.ts +0 -91
  206. package/src/types/geometry.ts +0 -159
  207. package/src/types/global.ts +0 -21
  208. package/src/types/index.ts +0 -44
  209. package/src/types/model-data.ts +0 -77
  210. package/src/types/model-deployment.ts +0 -78
  211. package/src/types/model-dump.ts +0 -79
  212. package/src/types/model-logical.ts +0 -126
  213. package/src/types/model-spec.ts +0 -88
  214. package/src/types/operators.ts +0 -156
  215. package/src/types/project.ts +0 -14
  216. package/src/types/scalar.ts +0 -162
  217. package/src/types/styles.ts +0 -122
  218. package/src/types/view-changes.ts +0 -32
  219. package/src/types/view-common.ts +0 -157
  220. package/src/types/view-computed.ts +0 -126
  221. package/src/types/view-layouted.ts +0 -94
  222. package/src/types/view-parsed.deployment.ts +0 -39
  223. package/src/types/view-parsed.dynamic.ts +0 -89
  224. package/src/types/view-parsed.element.ts +0 -65
  225. package/src/types/view.ts +0 -113
  226. package/src/utils/common-head.ts +0 -22
  227. package/src/utils/compare-natural.ts +0 -60
  228. package/src/utils/const.ts +0 -1
  229. package/src/utils/fqn.ts +0 -302
  230. package/src/utils/getOrCreate.ts +0 -8
  231. package/src/utils/guards.ts +0 -9
  232. package/src/utils/index.ts +0 -68
  233. package/src/utils/invariant.ts +0 -29
  234. package/src/utils/iterable/_types.ts +0 -5
  235. package/src/utils/iterable/filter.ts +0 -55
  236. package/src/utils/iterable/find.ts +0 -38
  237. package/src/utils/iterable/first.ts +0 -48
  238. package/src/utils/iterable/flat.ts +0 -17
  239. package/src/utils/iterable/head.ts +0 -22
  240. package/src/utils/iterable/index.ts +0 -15
  241. package/src/utils/iterable/map.ts +0 -40
  242. package/src/utils/iterable/reduce.ts +0 -24
  243. package/src/utils/iterable/some.ts +0 -36
  244. package/src/utils/iterable/to.ts +0 -19
  245. package/src/utils/iterable/unique.ts +0 -23
  246. package/src/utils/markdown/index.ts +0 -2
  247. package/src/utils/markdown/to-html.ts +0 -32
  248. package/src/utils/markdown/to-text.ts +0 -14
  249. package/src/utils/memoize-prop.ts +0 -30
  250. package/src/utils/mnemonist.ts +0 -9
  251. package/src/utils/object-hash.ts +0 -14
  252. package/src/utils/promises.ts +0 -24
  253. package/src/utils/relations.ts +0 -36
  254. package/src/utils/set.ts +0 -83
  255. package/src/utils/string-hash.ts +0 -16
@@ -1,159 +0,0 @@
1
- import { hasAtLeast } from 'remeda'
2
- import { invariant } from '../utils/invariant'
3
-
4
- export type Point = readonly [x: number, y: number]
5
-
6
- export interface XYPoint {
7
- x: number
8
- y: number
9
- }
10
-
11
- // Bounding box
12
- export interface BBox {
13
- x: number
14
- y: number
15
- width: number
16
- height: number
17
- }
18
-
19
- export namespace BBox {
20
- export function center({ x, y, width, height }: BBox): XYPoint {
21
- return {
22
- x: x + width / 2,
23
- y: y + height / 2,
24
- }
25
- }
26
-
27
- export function fromPoints(points: Point[]): BBox {
28
- const { x1, y1, x2, y2 } = RectBox.fromPoints(points)
29
- return {
30
- x: x1,
31
- y: y1,
32
- width: x2 - x1,
33
- height: y2 - y1,
34
- }
35
- }
36
-
37
- export function merge(...boxes: BBox[]): BBox {
38
- invariant(hasAtLeast(boxes, 1), 'No boxes provided')
39
- if (boxes.length === 1) {
40
- return boxes[0]
41
- }
42
- let minX = Infinity
43
- let minY = Infinity
44
- let maxX = -Infinity
45
- let maxY = -Infinity
46
- for (const box of boxes) {
47
- minX = Math.min(minX, box.x)
48
- minY = Math.min(minY, box.y)
49
- maxX = Math.max(maxX, box.x + box.width)
50
- maxY = Math.max(maxY, box.y + box.height)
51
- }
52
- return {
53
- x: minX,
54
- y: minY,
55
- width: maxX - minX,
56
- height: maxY - minY,
57
- }
58
- }
59
-
60
- export function toRectBox(box: BBox): RectBox {
61
- return {
62
- x1: box.x,
63
- y1: box.y,
64
- x2: box.x + box.width,
65
- y2: box.y + box.height,
66
- }
67
- }
68
-
69
- export function expand(box: BBox, plus: number): BBox {
70
- if (plus === 0) {
71
- return box
72
- }
73
- return {
74
- x: box.x - plus,
75
- y: box.y - plus,
76
- width: box.width + plus * 2,
77
- height: box.height + plus * 2,
78
- }
79
- }
80
-
81
- export function shrink(box: BBox, minus: number): BBox {
82
- if (minus === 0) {
83
- return box
84
- }
85
- return {
86
- x: box.x + minus,
87
- y: box.y + minus,
88
- width: box.width - minus * 2,
89
- height: box.height - minus * 2,
90
- }
91
- }
92
- }
93
-
94
- export interface RectBox {
95
- // Top left
96
- x1: number
97
- y1: number
98
- // Bottom right
99
- x2: number
100
- y2: number
101
- }
102
-
103
- export namespace RectBox {
104
- export function center({ x1, y1, x2, y2 }: RectBox): XYPoint {
105
- return {
106
- x: (x1 + x2) / 2,
107
- y: (y1 + y2) / 2,
108
- }
109
- }
110
-
111
- export function fromPoints(points: Point[]): RectBox {
112
- invariant(points.length > 0, 'At least one point is required')
113
- let minX = Infinity
114
- let minY = Infinity
115
- let maxX = -Infinity
116
- let maxY = -Infinity
117
- for (const [x, y] of points) {
118
- minX = Math.min(minX, x)
119
- minY = Math.min(minY, y)
120
- maxX = Math.max(maxX, x)
121
- maxY = Math.max(maxY, y)
122
- }
123
- return {
124
- x1: minX,
125
- y1: minY,
126
- x2: maxX,
127
- y2: maxY,
128
- }
129
- }
130
-
131
- export function merge(...boxes: RectBox[]): RectBox {
132
- invariant(boxes.length > 0, 'No boxes provided')
133
- let minX = Infinity
134
- let minY = Infinity
135
- let maxX = -Infinity
136
- let maxY = -Infinity
137
- for (const box of boxes) {
138
- minX = Math.min(minX, box.x1)
139
- minY = Math.min(minY, box.y1)
140
- maxX = Math.max(maxX, box.x2)
141
- maxY = Math.max(maxY, box.y2)
142
- }
143
- return {
144
- x1: minX,
145
- y1: minY,
146
- x2: maxX,
147
- y2: maxY,
148
- }
149
- }
150
-
151
- export function toBBox(box: RectBox): BBox {
152
- return {
153
- x: box.x1,
154
- y: box.y1,
155
- width: box.x2 - box.x1,
156
- height: box.y2 - box.y1,
157
- }
158
- }
159
- }
@@ -1,21 +0,0 @@
1
- import type { NonEmptyTuple, Tagged } from 'type-fest'
2
- import type { Any } from './_aux'
3
- import type { NonEmptyArray } from './_common'
4
- import type { DynamicViewIncludeRule } from './view-parsed.dynamic'
5
- import type { ElementViewPredicate, ElementViewRuleStyle } from './view-parsed.element'
6
-
7
- export type GlobalPredicateId = Tagged<string, 'GlobalPredicateId'>
8
-
9
- export type GlobalPredicates<A extends Any = Any> = NonEmptyArray<ElementViewPredicate<A>>
10
-
11
- export type GlobalDynamicPredicates<A extends Any = Any> = NonEmptyArray<DynamicViewIncludeRule<A>>
12
-
13
- export type GlobalStyleID = Tagged<string, 'GlobalStyleID'>
14
-
15
- export type GlobalStyles<A extends Any = Any> = NonEmptyTuple<ElementViewRuleStyle<A>>
16
-
17
- export interface ModelGlobals<A extends Any = Any> {
18
- readonly predicates: Record<GlobalPredicateId, GlobalPredicates<A>>
19
- readonly dynamicPredicates: Record<GlobalPredicateId, GlobalDynamicPredicates<A>>
20
- readonly styles: Record<GlobalStyleID, GlobalStyles<A>>
21
- }
@@ -1,44 +0,0 @@
1
- export * from './_common'
2
-
3
- export * as aux from './_aux'
4
-
5
- export type {
6
- Any,
7
- AnyAux,
8
- Aux,
9
- SpecAux,
10
- Unknown,
11
- UnknownComputed,
12
- UnknownLayouted,
13
- UnknownParsed,
14
- } from './_aux'
15
-
16
- export { preferDescription, preferSummary } from './_aux'
17
-
18
- export * from './const'
19
- export * from './expression'
20
- export * from './expression-model'
21
- export * from './fqnRef'
22
- export * from './geometry'
23
- export * from './global'
24
- export * from './model-data'
25
- export * from './model-deployment'
26
- export * from './model-dump'
27
- export * from './model-logical'
28
- export * from './model-spec'
29
- export * from './operators'
30
- export * from './project'
31
- export * from './scalar'
32
- export * from './styles'
33
- export * from './view'
34
- export * from './view-changes'
35
- export * from './view-common'
36
- export * from './view-computed'
37
- export * from './view-layouted'
38
- export * from './view-parsed.deployment'
39
- export * from './view-parsed.dynamic'
40
- export * from './view-parsed.element'
41
-
42
- export * as scalar from './scalar'
43
-
44
- export { RichText, type RichTextEmpty, type RichTextOrEmpty } from './RichText'
@@ -1,77 +0,0 @@
1
- import type { IsAny } from 'type-fest'
2
- import type * as aux from './_aux'
3
- import type { Any } from './_aux'
4
- import type { NonEmptyArray } from './_common'
5
- import type { _stage } from './const'
6
- import type { ModelGlobals } from './global'
7
- import type { DeploymentElement, DeploymentRelationship } from './model-deployment'
8
- import type { Element, Relationship } from './model-logical'
9
- import type { Specification } from './model-spec'
10
- import type { LikeC4Project } from './project'
11
- import type * as scalar from './scalar'
12
- import type { ComputedView, LayoutedView, ParsedView } from './view'
13
-
14
- interface BaseLikeC4ModelData<A extends aux.Any> {
15
- projectId: aux.ProjectId<A>
16
- project: LikeC4Project
17
- specification: Specification<A>
18
- elements: Record<aux.ElementId<A>, Element<A>>
19
- deployments: {
20
- elements: Record<aux.DeploymentId<A>, DeploymentElement<A>>
21
- relations: Record<scalar.RelationId, DeploymentRelationship<A>>
22
- }
23
- relations: Record<scalar.RelationId, Relationship<A>>
24
- globals: ModelGlobals
25
- imports: Record<string, NonEmptyArray<Element<A>>>
26
- }
27
-
28
- export type AuxFromLikeC4ModelData<D> =
29
- // dprint-ignore
30
- D extends BaseLikeC4ModelData<infer A extends Any>
31
- ? IsAny<A> extends true
32
- ? never
33
- : A
34
- : never
35
-
36
- /**
37
- * Represents a LikeC4 model with customizable type parameters,
38
- * parsed from DSL or result from Builder
39
- *
40
- * !IMPORTANT: This is a low-level type, use `LikeC4Model` instead.
41
- * !NOTE: Views are not computed yet.
42
- *
43
- * @typeParam ElementKinds - Types of elements in the model (defaults to string)
44
- * @typeParam RelationKinds - Types of relationships (defaults to string)
45
- * @typeParam Tags - Types of tags that can be applied (defaults to string)
46
- * @typeParam Fqns - Fully Qualified Names for elements (defaults to string)
47
- * @typeParam Views - Types of views in the model (defaults to string)
48
- * @typeParam DeploymentFqns - Fully Qualified Names for deployment nodes (defaults to string)
49
- */
50
- export interface ParsedLikeC4ModelData<A extends Any = aux.UnknownParsed> extends BaseLikeC4ModelData<A> {
51
- [_stage]: 'parsed'
52
- // globals: ModelGlobals<A
53
- views: Record<aux.ViewId<A>, ParsedView<A>>
54
- }
55
-
56
- export interface ComputedLikeC4ModelData<A extends Any = aux.UnknownComputed> extends BaseLikeC4ModelData<A> {
57
- [_stage]: 'computed'
58
- // specification: Specification<A>
59
- // globals: ModelGlobals<A>
60
- views: Record<aux.ViewId<A>, ComputedView<A>>
61
- }
62
-
63
- export interface LayoutedLikeC4ModelData<A extends Any = aux.UnknownLayouted> extends BaseLikeC4ModelData<A> {
64
- [_stage]: 'layouted'
65
- // globals: ModelGlobals<A>
66
- views: Record<aux.ViewId<A>, LayoutedView<A>>
67
- }
68
-
69
- export type LikeC4ModelData<A extends Any> =
70
- | ParsedLikeC4ModelData<A>
71
- | ComputedLikeC4ModelData<A>
72
- | LayoutedLikeC4ModelData<A>
73
- // ExclusiveUnion<{
74
- // Parsed: ParsedLikeC4ModelData<A>
75
- // Computed: ComputedLikeC4ModelData<A>
76
- // Layouted: LayoutedLikeC4ModelData<A>
77
- // }>
@@ -1,78 +0,0 @@
1
- import { isTruthy } from 'remeda'
2
- import type * as aux from './_aux'
3
- import type { AnyAux, Unknown } from './_aux'
4
- import type { FqnRef } from './fqnRef'
5
- import type { AbstractRelationship, ElementStyle } from './model-logical'
6
- import type { Icon } from './scalar'
7
- import type { Color, ElementShape } from './styles'
8
-
9
- export interface DeploymentElementStyle extends ElementStyle {
10
- readonly icon?: Icon
11
- readonly shape?: ElementShape
12
- readonly color?: Color
13
- }
14
-
15
- // dprint-ignore
16
- export interface DeploymentNode<A extends AnyAux = Unknown>
17
- extends
18
- aux.WithDescriptionAndTech,
19
- aux.WithOptionalTags<A>,
20
- aux.WithOptionalLinks,
21
- aux.WithMetadata<A>,
22
- aux.WithNotation
23
- {
24
- element?: never
25
- // Full-qualified-name for Deployment model
26
- readonly id: aux.StrictDeploymentFqn<A>
27
- readonly kind: aux.DeploymentKind<A>
28
- readonly title: string
29
- readonly style: DeploymentElementStyle
30
- }
31
-
32
- // dprint-ignore
33
- export interface DeployedInstance<A extends AnyAux = Unknown>
34
- extends
35
- aux.WithDescriptionAndTech,
36
- aux.WithOptionalTags<A>,
37
- aux.WithOptionalLinks,
38
- aux.WithMetadata<A>,
39
- aux.WithNotation
40
- {
41
- kind?: never
42
- /**
43
- * Format: `<DeploymentNode Fqn>.<Instance Id>`
44
- * i.e parent fqn is deployment target
45
- */
46
- readonly id: aux.StrictDeploymentFqn<A>
47
- readonly element: aux.StrictFqn<A>
48
- readonly title?: string
49
- readonly style?: DeploymentElementStyle
50
- }
51
-
52
- export type DeploymentElement<A extends AnyAux = Unknown> = DeploymentNode<A> | DeployedInstance<A>
53
-
54
- export type DeploymentElementRef<A extends AnyAux = Unknown> = {
55
- readonly id: aux.StrictDeploymentFqn<A>
56
- readonly element?: aux.StrictFqn<A>
57
- }
58
-
59
- export function isDeploymentNode<A extends AnyAux>(el: DeploymentElement<A>): el is DeploymentNode<A> {
60
- return isTruthy(el.kind) && !isTruthy(el.element)
61
- }
62
-
63
- export function isDeployedInstance<A extends AnyAux>(el: DeploymentElement<A>): el is DeployedInstance<A> {
64
- return isTruthy(el.element) && !isTruthy(el.kind)
65
- }
66
-
67
- /**
68
- * Relationship in deployment model
69
- */
70
- export interface DeploymentRelationship<A extends AnyAux = Unknown> extends AbstractRelationship<A> {
71
- readonly source: FqnRef.DeploymentRef<A>
72
- readonly target: FqnRef.DeploymentRef<A>
73
- }
74
- /**
75
- * Backward compatibility alias
76
- * @deprecated Use {@link DeploymentRelationship} instead
77
- */
78
- export type DeploymentRelation<A extends AnyAux = Unknown> = DeploymentRelationship<A>
@@ -1,79 +0,0 @@
1
- import type * as aux from './_aux'
2
- import type { KeysOf } from './_common'
3
- import type { _stage } from './const'
4
- import type { ParsedLikeC4ModelData } from './model-data'
5
-
6
- /**
7
- * JSON representation of {@link Specification}
8
- */
9
- export interface SpecificationDump {
10
- elements: {
11
- [kind: string]: object
12
- }
13
- tags?: {
14
- [tag: string]: object
15
- }
16
- deployments?: {
17
- [kind: string]: object
18
- }
19
- relationships?: {
20
- [kind: string]: object
21
- }
22
- metadataKeys?: string[]
23
- customColors?: {
24
- [kind: string]: object
25
- }
26
- }
27
- export type SpecTypesFromDump<J> = J extends SpecificationDump ? aux.SpecAux<
28
- KeysOf<J['elements']>,
29
- KeysOf<J['deployments']>,
30
- KeysOf<J['relationships']>,
31
- KeysOf<J['tags']>,
32
- J['metadataKeys'] extends readonly [string, ...string[]] ? J['metadataKeys'][number] : never
33
- >
34
- : aux.SpecAux<never, never, never, never, never>
35
-
36
- /**
37
- * Dump differs from {@link ParsedLikeC4ModelData} by the fact that it is computed or layouted
38
- */
39
- export type LikeC4ModelDump = {
40
- [_stage]?: 'computed' | 'layouted'
41
- projectId?: string
42
- project?: ProjectDump
43
- specification: SpecificationDump
44
- elements?: {
45
- [kind: string]: object
46
- }
47
- deployments: {
48
- elements?: {
49
- [kind: string]: object
50
- }
51
- relations?: {}
52
- }
53
- views?: {
54
- [kind: string]: object
55
- }
56
- relations?: {}
57
- globals?: {
58
- predicates?: {}
59
- dynamicPredicates?: {}
60
- styles?: {}
61
- }
62
- imports?: {}
63
- }
64
-
65
- export type ProjectDump = {
66
- id: string
67
- name?: string
68
- title?: string | undefined
69
- }
70
-
71
- export type AuxFromDump<D> = D extends LikeC4ModelDump ? aux.Aux<
72
- D[_stage] extends infer S extends string & 'computed' | 'layouted' ? S : 'computed' | 'layouted' | 'parsed',
73
- KeysOf<D['elements']>,
74
- KeysOf<D['deployments']['elements']>,
75
- KeysOf<D['views']>,
76
- D['projectId'] extends infer PID extends string ? PID : never,
77
- SpecTypesFromDump<D['specification']>
78
- >
79
- : aux.Never
@@ -1,126 +0,0 @@
1
- import type * as aux from './_aux'
2
- import type { AnyAux } from './_aux'
3
- import type { FqnRef } from './fqnRef'
4
- import type * as scalar from './scalar'
5
- import type {
6
- BorderStyle,
7
- Color,
8
- ElementShape,
9
- RelationshipArrowType,
10
- RelationshipLineType,
11
- ShapeSize,
12
- SpacingSize,
13
- TextSize,
14
- ThemeColor,
15
- } from './styles'
16
-
17
- export const DefaultThemeColor: ThemeColor = 'primary'
18
- export const DefaultElementShape: ElementShape = 'rectangle'
19
- export const DefaultSize = 'md'
20
- export const DefaultShapeSize: ShapeSize = DefaultSize
21
- export const DefaultPaddingSize: SpacingSize = DefaultSize
22
- export const DefaultTextSize: TextSize = DefaultSize
23
-
24
- export interface ElementStyle {
25
- readonly border?: BorderStyle
26
- /**
27
- * In percentage 0-100, 0 is fully transparent
28
- *
29
- * @default 100
30
- */
31
- readonly opacity?: number
32
- /**
33
- * If true, the element is rendered as multiple shapes
34
- * @default false
35
- */
36
- readonly multiple?: boolean
37
-
38
- /**
39
- * Shape size
40
- *
41
- * @default 'md'
42
- */
43
- readonly size?: ShapeSize
44
-
45
- readonly padding?: SpacingSize
46
-
47
- readonly textSize?: TextSize
48
- }
49
-
50
- type WithSizes = Pick<ElementStyle, 'size' | 'padding' | 'textSize'>
51
-
52
- /**
53
- * Ensures that the sizes are set to default values if they are not set
54
- */
55
- export function ensureSizes<S extends WithSizes>({
56
- size,
57
- padding,
58
- textSize,
59
- ...rest
60
- }: S): Omit<S, 'size' | 'padding' | 'textSize'> & Required<WithSizes> {
61
- size ??= DefaultSize
62
- textSize ??= size
63
- padding ??= size
64
-
65
- return {
66
- ...rest,
67
- size,
68
- padding,
69
- textSize,
70
- }
71
- }
72
-
73
- // dprint-ignore
74
- export interface Element<A extends AnyAux = AnyAux>
75
- extends
76
- aux.WithDescriptionAndTech,
77
- aux.WithOptionalTags<A>,
78
- aux.WithOptionalLinks,
79
- aux.WithMetadata<A>,
80
- aux.WithNotation
81
- {
82
- readonly id: aux.StrictFqn<A>
83
- readonly kind: aux.ElementKind<A>
84
- readonly title: string
85
- readonly icon?: scalar.Icon
86
- readonly shape?: ElementShape
87
- readonly color?: Color
88
- readonly style?: ElementStyle
89
- }
90
-
91
- export const DefaultLineStyle: RelationshipLineType = 'dashed'
92
- export const DefaultArrowType: RelationshipArrowType = 'normal'
93
- export const DefaultRelationshipColor: ThemeColor = 'gray'
94
-
95
- // dprint-ignore
96
- export interface AbstractRelationship<A extends AnyAux>
97
- extends
98
- aux.WithDescriptionAndTech,
99
- aux.WithOptionalTags<A>,
100
- aux.WithOptionalLinks,
101
- aux.WithMetadata<A>
102
- {
103
- readonly id: scalar.RelationId
104
- readonly title?: string | null
105
- readonly kind?: aux.RelationKind<A>
106
- readonly color?: Color
107
- readonly line?: RelationshipLineType
108
- readonly head?: RelationshipArrowType
109
- readonly tail?: RelationshipArrowType
110
- // Link to dynamic view
111
- readonly navigateTo?: aux.ViewId<A>
112
- }
113
-
114
- /**
115
- * Relationship between two model elements
116
- */
117
- export interface Relationship<A extends AnyAux = AnyAux> extends AbstractRelationship<A> {
118
- readonly source: FqnRef.ModelRef<A>
119
- readonly target: FqnRef.ModelRef<A>
120
- }
121
-
122
- /**
123
- * Backward compatibility alias
124
- * @deprecated Use {@link Relationship} instead
125
- */
126
- export type ModelRelation<A extends AnyAux = AnyAux> = Relationship<A>
@@ -1,88 +0,0 @@
1
- import type { IsNever } from 'type-fest'
2
- import type * as aux from './_aux'
3
- import type { Any } from './_aux'
4
- import type { Link, NonEmptyArray } from './_common'
5
- import type * as scalar from './scalar'
6
- import type {
7
- Icon,
8
- } from './scalar'
9
- import type {
10
- BorderStyle,
11
- Color,
12
- ColorLiteral,
13
- CustomColorDefinitions,
14
- ElementShape,
15
- RelationshipArrowType,
16
- RelationshipLineType,
17
- ShapeSize,
18
- SpacingSize,
19
- TextSize,
20
- ThemeColor,
21
- } from './styles'
22
-
23
- /**
24
- * Element and deployment kind specification
25
- */
26
- export interface ElementSpecification {
27
- tags?: scalar.Tag[]
28
- title?: string
29
- // short summary
30
- summary?: scalar.MarkdownOrString
31
- // long description
32
- description?: scalar.MarkdownOrString
33
- technology?: string
34
- notation?: string
35
- links?: NonEmptyArray<Link>
36
- style: {
37
- shape?: ElementShape
38
- icon?: Icon
39
- color?: Color
40
- border?: BorderStyle
41
- opacity?: number
42
- size?: ShapeSize
43
- padding?: SpacingSize
44
- textSize?: TextSize
45
- multiple?: boolean
46
- }
47
- }
48
-
49
- export interface TagSpecification {
50
- color: ThemeColor | ColorLiteral
51
- }
52
-
53
- /**
54
- * Checks if tag color is defined in the specification
55
- * Expects HEX, `rgb(...)` or `rgba(...)` color
56
- */
57
- export function isTagColorSpecified(spec: string | TagSpecification): spec is { color: ColorLiteral } {
58
- const color = typeof spec === 'string' ? spec : spec.color
59
- return color.startsWith('#') || color.startsWith('rgb')
60
- }
61
-
62
- export interface RelationshipSpecification {
63
- technology?: string
64
- notation?: string
65
- color?: Color
66
- line?: RelationshipLineType
67
- head?: RelationshipArrowType
68
- tail?: RelationshipArrowType
69
- }
70
-
71
- export type Specification<A> = A extends Any ? {
72
- tags: {
73
- [key in aux.Tag<A>]: TagSpecification
74
- }
75
- elements: {
76
- [key in aux.ElementKind<A>]: Partial<ElementSpecification>
77
- }
78
- deployments: {
79
- [key in aux.DeploymentKind<A>]: Partial<ElementSpecification>
80
- }
81
- relationships: {
82
- [key in aux.RelationKind<A>]: Partial<RelationshipSpecification>
83
- }
84
- // dprint-ignore
85
- metadataKeys?: IsNever<aux.MetadataKey<A>> extends true ? never : aux.MetadataKey<A>[]
86
- customColors?: CustomColorDefinitions
87
- } :
88
- never