@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,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,42 +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 * from './const'
17
- export * from './expression'
18
- export * from './expression-model'
19
- export * from './fqnRef'
20
- export * from './geometry'
21
- export * from './global'
22
- export * from './model-data'
23
- export * from './model-deployment'
24
- export * from './model-dump'
25
- export * from './model-logical'
26
- export * from './model-spec'
27
- export * from './operators'
28
- export * from './project'
29
- export * from './scalar'
30
- export * from './styles'
31
- export * from './view'
32
- export * from './view-changes'
33
- export * from './view-common'
34
- export * from './view-computed'
35
- export * from './view-layouted'
36
- export * from './view-parsed.deployment'
37
- export * from './view-parsed.dynamic'
38
- export * from './view-parsed.element'
39
-
40
- export * as scalar from './scalar'
41
-
42
- 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,88 +0,0 @@
1
- import { isTruthy } from 'remeda'
2
- import type * as aux from './_aux'
3
- import type { AnyAux, Unknown } from './_aux'
4
- import type { Link } from './_common'
5
- import type { FqnRef } from './fqnRef'
6
- import type { AbstractRelationship, ElementStyle } from './model-logical'
7
- import type { Icon } from './scalar'
8
- import type * as scalar from './scalar'
9
- import type { Color, ElementShape } from './styles'
10
-
11
- export interface DeploymentElementStyle extends ElementStyle {
12
- readonly icon?: Icon
13
- readonly shape?: ElementShape
14
- readonly color?: Color
15
- }
16
-
17
- // dprint-ignore
18
- export interface DeploymentNode<A extends AnyAux = Unknown>
19
- extends
20
- aux.WithOptionalTags<A>,
21
- aux.WithOptionalLinks,
22
- aux.WithMetadata<A>
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 description?: scalar.MarkdownOrString | null
30
- readonly technology?: string | null
31
- readonly tags?: aux.Tags<A> | null
32
- readonly links?: readonly Link[] | null
33
- readonly style: DeploymentElementStyle
34
- readonly notation?: string | null
35
- readonly metadata?: aux.Metadata<A>
36
- }
37
-
38
- // dprint-ignore
39
- export interface DeployedInstance<A extends AnyAux = Unknown>
40
- extends
41
- aux.WithOptionalTags<A>,
42
- aux.WithOptionalLinks,
43
- aux.WithMetadata<A>
44
- {
45
- kind?: never
46
- /**
47
- * Format: `<DeploymentNode Fqn>.<Instance Id>`
48
- * i.e parent fqn is deployment target
49
- */
50
- readonly id: aux.StrictDeploymentFqn<A>
51
- readonly element: aux.StrictFqn<A>
52
- readonly title?: string
53
- readonly description?: scalar.MarkdownOrString | null
54
- readonly technology?: string | null
55
- readonly tags?: aux.Tags<A> | null
56
- readonly links?: readonly Link[] | null
57
- readonly style?: DeploymentElementStyle
58
- readonly notation?: string
59
- readonly metadata?: aux.Metadata<A>
60
- }
61
-
62
- export type DeploymentElement<A extends AnyAux = Unknown> = DeploymentNode<A> | DeployedInstance<A>
63
-
64
- export type DeploymentElementRef<A extends AnyAux = Unknown> = {
65
- readonly id: aux.StrictDeploymentFqn<A>
66
- readonly element?: aux.StrictFqn<A>
67
- }
68
-
69
- export function isDeploymentNode<A extends AnyAux>(el: DeploymentElement<A>): el is DeploymentNode<A> {
70
- return 'kind' in el && !isTruthy(el.element)
71
- }
72
-
73
- export function isDeployedInstance<A extends AnyAux>(el: DeploymentElement<A>): el is DeployedInstance<A> {
74
- return 'element' in el && isTruthy(el.element)
75
- }
76
-
77
- /**
78
- * Relationship in deployment model
79
- */
80
- export interface DeploymentRelationship<A extends AnyAux = Unknown> extends AbstractRelationship<A> {
81
- readonly source: FqnRef.DeploymentRef<A>
82
- readonly target: FqnRef.DeploymentRef<A>
83
- }
84
- /**
85
- * Backward compatibility alias
86
- * @deprecated Use {@link DeploymentRelationship} instead
87
- */
88
- 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,135 +0,0 @@
1
- import type * as aux from './_aux'
2
- import type { AnyAux } from './_aux'
3
- import type { Link } from './_common'
4
- import type { FqnRef } from './fqnRef'
5
- import type * as scalar from './scalar'
6
- import type {
7
- BorderStyle,
8
- Color,
9
- ElementShape,
10
- RelationshipArrowType,
11
- RelationshipLineType,
12
- ShapeSize,
13
- SpacingSize,
14
- TextSize,
15
- ThemeColor,
16
- } from './styles'
17
-
18
- export const DefaultThemeColor: ThemeColor = 'primary'
19
- export const DefaultElementShape: ElementShape = 'rectangle'
20
- export const DefaultSize = 'md'
21
- export const DefaultShapeSize: ShapeSize = DefaultSize
22
- export const DefaultPaddingSize: SpacingSize = DefaultSize
23
- export const DefaultTextSize: TextSize = DefaultSize
24
-
25
- export interface ElementStyle {
26
- readonly border?: BorderStyle
27
- /**
28
- * In percentage 0-100, 0 is fully transparent
29
- *
30
- * @default 100
31
- */
32
- readonly opacity?: number
33
- /**
34
- * If true, the element is rendered as multiple shapes
35
- * @default false
36
- */
37
- readonly multiple?: boolean
38
-
39
- /**
40
- * Shape size
41
- *
42
- * @default 'md'
43
- */
44
- readonly size?: ShapeSize
45
-
46
- readonly padding?: SpacingSize
47
-
48
- readonly textSize?: TextSize
49
- }
50
-
51
- type WithSizes = Pick<ElementStyle, 'size' | 'padding' | 'textSize'>
52
-
53
- /**
54
- * Ensures that the sizes are set to default values if they are not set
55
- */
56
- export function ensureSizes<S extends WithSizes>({
57
- size,
58
- padding,
59
- textSize,
60
- ...rest
61
- }: S): Omit<S, 'size' | 'padding' | 'textSize'> & Required<WithSizes> {
62
- size ??= DefaultSize
63
- textSize ??= size
64
- padding ??= size
65
-
66
- return {
67
- ...rest,
68
- size,
69
- padding,
70
- textSize,
71
- }
72
- }
73
-
74
- // dprint-ignore
75
- export interface Element<A extends AnyAux = AnyAux>
76
- extends
77
- aux.WithOptionalTags<A>,
78
- aux.WithOptionalLinks,
79
- aux.WithMetadata<A>
80
- {
81
- readonly id: aux.StrictFqn<A>
82
- readonly kind: aux.ElementKind<A>
83
- readonly title: string
84
- readonly description?: scalar.MarkdownOrString | null
85
- readonly technology?: string | null
86
- readonly tags?: aux.Tags<A> | null
87
- readonly links?: readonly Link[] | null
88
- readonly icon?: scalar.Icon
89
- readonly shape?: ElementShape
90
- readonly color?: Color
91
- readonly style?: ElementStyle
92
- readonly notation?: string | null
93
- readonly metadata?: aux.Metadata<A>
94
- }
95
-
96
- export const DefaultLineStyle: RelationshipLineType = 'dashed'
97
- export const DefaultArrowType: RelationshipArrowType = 'normal'
98
- export const DefaultRelationshipColor: ThemeColor = 'gray'
99
-
100
- // dprint-ignore
101
- export interface AbstractRelationship<A extends AnyAux>
102
- extends
103
- aux.WithOptionalTags<A>,
104
- aux.WithOptionalLinks,
105
- aux.WithMetadata<A>
106
- {
107
- readonly id: scalar.RelationId
108
- readonly title?: string | null
109
- readonly description?: scalar.MarkdownOrString | null
110
- readonly technology?: string | null
111
- readonly kind?: aux.RelationKind<A>
112
- readonly color?: Color
113
- readonly line?: RelationshipLineType
114
- readonly head?: RelationshipArrowType
115
- readonly tail?: RelationshipArrowType
116
- readonly tags?: aux.Tags<A> | null
117
- readonly links?: readonly Link[] | null
118
- // Link to dynamic view
119
- readonly navigateTo?: aux.ViewId<A>
120
- readonly metadata?: aux.Metadata<A>
121
- }
122
-
123
- /**
124
- * Relationship between two model elements
125
- */
126
- export interface Relationship<A extends AnyAux = AnyAux> extends AbstractRelationship<A> {
127
- readonly source: FqnRef.ModelRef<A>
128
- readonly target: FqnRef.ModelRef<A>
129
- }
130
-
131
- /**
132
- * Backward compatibility alias
133
- * @deprecated Use {@link Relationship} instead
134
- */
135
- export type ModelRelation<A extends AnyAux = AnyAux> = Relationship<A>
@@ -1,85 +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
- description?: scalar.MarkdownOrString
30
- technology?: string
31
- notation?: string
32
- links?: NonEmptyArray<Link>
33
- style: {
34
- shape?: ElementShape
35
- icon?: Icon
36
- color?: Color
37
- border?: BorderStyle
38
- opacity?: number
39
- size?: ShapeSize
40
- padding?: SpacingSize
41
- textSize?: TextSize
42
- multiple?: boolean
43
- }
44
- }
45
-
46
- export interface TagSpecification {
47
- color: ThemeColor | ColorLiteral
48
- }
49
-
50
- /**
51
- * Checks if tag color is defined in the specification
52
- * Expects HEX, `rgb(...)` or `rgba(...)` color
53
- */
54
- export function isTagColorSpecified(spec: string | TagSpecification): spec is { color: ColorLiteral } {
55
- const color = typeof spec === 'string' ? spec : spec.color
56
- return color.startsWith('#') || color.startsWith('rgb')
57
- }
58
-
59
- export interface RelationshipSpecification {
60
- technology?: string
61
- notation?: string
62
- color?: Color
63
- line?: RelationshipLineType
64
- head?: RelationshipArrowType
65
- tail?: RelationshipArrowType
66
- }
67
-
68
- export type Specification<A> = A extends Any ? {
69
- tags: {
70
- [key in aux.Tag<A>]: TagSpecification
71
- }
72
- elements: {
73
- [key in aux.ElementKind<A>]: Partial<ElementSpecification>
74
- }
75
- deployments: {
76
- [key in aux.DeploymentKind<A>]: Partial<ElementSpecification>
77
- }
78
- relationships: {
79
- [key in aux.RelationKind<A>]: Partial<RelationshipSpecification>
80
- }
81
- // dprint-ignore
82
- metadataKeys?: IsNever<aux.MetadataKey<A>> extends true ? never : aux.MetadataKey<A>[]
83
- customColors?: CustomColorDefinitions
84
- } :
85
- never