@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,118 +0,0 @@
1
- import type * as aux from './_aux'
2
- import type { Any } from './_aux'
3
- import type { _stage, _type } from './const'
4
- import type { ElementStyle } from './model-logical'
5
- import type * as scalar from './scalar'
6
- import {
7
- type Icon,
8
- } from './scalar'
9
- import type {
10
- Color,
11
- ElementShape,
12
- RelationshipArrowType,
13
- RelationshipLineType,
14
- } from './styles'
15
- import type {
16
- BaseViewProperties,
17
- ViewAutoLayout,
18
- ViewManualLayout,
19
- ViewWithHash,
20
- ViewWithNotation,
21
- } from './view-common'
22
- import type { DynamicViewDisplayVariant } from './view-parsed.dynamic'
23
-
24
- export interface ComputedNode<A extends Any = Any> extends aux.WithOptionalLinks {
25
- id: scalar.NodeId
26
- kind: aux.ElementKind<A> | aux.DeploymentKind<A> | '@group'
27
- parent: scalar.NodeId | null
28
- /**
29
- * Reference to model element
30
- */
31
- modelRef?: aux.Fqn<A> | undefined
32
- /**
33
- * Reference to deployment element
34
- */
35
- deploymentRef?: aux.DeploymentFqn<A> | undefined
36
- title: string
37
- description?: scalar.MarkdownOrString | null
38
- technology?: string | null
39
- notation?: string
40
- children: scalar.NodeId[]
41
- inEdges: scalar.EdgeId[]
42
- outEdges: scalar.EdgeId[]
43
- tags: aux.Tags<A>
44
- shape: ElementShape
45
- color: Color
46
- icon?: Icon
47
- style: ElementStyle
48
- navigateTo?: aux.StrictViewId<A> | null
49
- level: number
50
- // For compound nodes, the max depth of nested nodes
51
- depth?: number
52
- /**
53
- * If this node was customized in the view
54
- */
55
- isCustomized?: boolean
56
- }
57
-
58
- export interface ComputedEdge<A extends Any = Any> extends aux.WithOptionalTags<A> {
59
- id: scalar.EdgeId
60
- parent: scalar.NodeId | null
61
- source: scalar.NodeId
62
- target: scalar.NodeId
63
- label: string | null
64
- description?: scalar.MarkdownOrString | null
65
- technology?: string
66
- relations: scalar.RelationId[]
67
- kind?: aux.RelationKind<A> | typeof scalar.StepEdgeKind
68
- notation?: string
69
- // Notes for walkthrough
70
- notes?: scalar.MarkdownOrString
71
- color?: Color
72
- line?: RelationshipLineType
73
- head?: RelationshipArrowType
74
- tail?: RelationshipArrowType
75
- // Link to dynamic view
76
- navigateTo?: aux.StrictViewId<A> | null
77
- /**
78
- * If this edge is derived from custom relationship predicate
79
- */
80
- isCustomized?: boolean
81
- /**
82
- * For layouting purposes
83
- * @default 'forward'
84
- */
85
- dir?: 'forward' | 'back' | 'both'
86
- }
87
-
88
- interface BaseComputedViewProperties<A extends Any> extends BaseViewProperties<A>, ViewWithHash, ViewWithNotation {
89
- readonly [_stage]: 'computed'
90
- readonly autoLayout: ViewAutoLayout
91
- readonly nodes: ComputedNode<A>[]
92
- readonly edges: ComputedEdge<A>[]
93
-
94
- /**
95
- * If the view is changed manually this field contains the layout data.
96
- */
97
- readonly manualLayout?: ViewManualLayout | undefined
98
- }
99
-
100
- export interface ComputedElementView<A extends Any = Any> extends BaseComputedViewProperties<A> {
101
- readonly [_type]: 'element'
102
- readonly viewOf?: aux.StrictFqn<A>
103
- readonly extends?: aux.StrictViewId<A>
104
- }
105
-
106
- export interface ComputedDeploymentView<A extends Any = Any> extends BaseComputedViewProperties<A> {
107
- readonly [_type]: 'deployment'
108
- }
109
-
110
- export interface ComputedDynamicView<A extends Any = Any> extends BaseComputedViewProperties<A> {
111
- readonly [_type]: 'dynamic'
112
- /**
113
- * How to display the dynamic view
114
- * - `diagram`: display as a regular likec4 view
115
- * - `sequence`: display as a sequence diagram
116
- */
117
- readonly variant: DynamicViewDisplayVariant
118
- }
@@ -1,98 +0,0 @@
1
- import type * as aux from './_aux'
2
- import type { AnyAux } from './_aux'
3
- import type { NonEmptyArray } from './_common'
4
- import type { _stage, _type } from './const'
5
- import type { BBox, Point, XYPoint } from './geometry'
6
- import type {
7
- BaseViewProperties,
8
- ViewAutoLayout,
9
- ViewWithHash,
10
- ViewWithNotation,
11
- } from './view-common'
12
- import type { ComputedEdge, ComputedNode } from './view-computed'
13
- import type { DynamicViewDisplayVariant } from './view-parsed.dynamic'
14
-
15
- export interface DiagramNode<A extends AnyAux = AnyAux> extends ComputedNode<A>, BBox {
16
- x: number
17
- y: number
18
- width: number
19
- height: number
20
- /**
21
- * Absolute position, top left
22
- * @deprecated Use `x` and `y` instead
23
- */
24
- position: Point
25
- /**
26
- * Bounding box of label
27
- * (Absolute coordinates)
28
- */
29
- labelBBox: BBox
30
-
31
- // description?: scalar.HtmlOrString | null
32
- // technology?: scalar.HtmlOrString | null
33
- // notation?: scalar.HtmlOrString | null
34
- }
35
-
36
- export interface DiagramEdge<A extends AnyAux = AnyAux> extends ComputedEdge<A> {
37
- /**
38
- * Bezier points
39
- * (Absolute coordinates)
40
- */
41
- points: NonEmptyArray<Point>
42
- /**
43
- * Control points to adjust the edge
44
- * (Absolute coordinates)
45
- */
46
- controlPoints?: NonEmptyArray<XYPoint>
47
- /**
48
- * Bounding box of label
49
- * (Absolute coordinates)
50
- */
51
- labelBBox?: BBox | null
52
- /**
53
- * Graphviz edge POS
54
- *
55
- * TODO: temporary solution, should be moved out
56
- * @deprecated
57
- */
58
- dotpos?: string
59
- // label: scalar.HtmlOrString | null
60
- // description?: scalar.HtmlOrString | null
61
- // technology?: scalar.HtmlOrString | null
62
- // notation?: scalar.HtmlOrString | null
63
- // notes?: scalar.HtmlOrString | null
64
- }
65
-
66
- interface BaseLayoutedViewProperties<A extends AnyAux> extends BaseViewProperties<A>, ViewWithHash, ViewWithNotation {
67
- readonly [_stage]: 'layouted'
68
- readonly autoLayout: ViewAutoLayout
69
- readonly nodes: DiagramNode<A>[]
70
- readonly edges: DiagramEdge<A>[]
71
- readonly bounds: BBox
72
-
73
- /**
74
- * If diagram has manual layout
75
- * But was changed and layout should be recalculated
76
- */
77
- hasLayoutDrift?: boolean
78
- }
79
-
80
- export interface LayoutedElementView<A extends AnyAux = AnyAux> extends BaseLayoutedViewProperties<A> {
81
- readonly [_type]: 'element'
82
- readonly viewOf?: aux.Fqn<A>
83
- readonly extends?: aux.StrictViewId<A>
84
- }
85
-
86
- export interface LayoutedDeploymentView<A extends AnyAux = AnyAux> extends BaseLayoutedViewProperties<A> {
87
- readonly [_type]: 'deployment'
88
- }
89
-
90
- export interface LayoutedDynamicView<A extends AnyAux = AnyAux> extends BaseLayoutedViewProperties<A> {
91
- readonly [_type]: 'dynamic'
92
- /**
93
- * How to display the dynamic view
94
- * - `diagram`: display as a regular likec4 view
95
- * - `sequence`: display as a sequence diagram
96
- */
97
- readonly variant: DynamicViewDisplayVariant
98
- }
@@ -1,39 +0,0 @@
1
- import type { AnyAux, Unknown } from './_aux'
2
- import type { ExclusiveUnion } from './_common'
3
- import type { _type } from './const'
4
- import type { Expression, FqnExpr } from './expression'
5
- import type {
6
- AnyExcludePredicate,
7
- AnyIncludePredicate,
8
- AnyViewRuleStyle,
9
- BaseParsedViewProperties,
10
- ViewRuleAutoLayout,
11
- } from './view-common'
12
-
13
- /**
14
- * Predicates scoped to deployment model
15
- */
16
- export interface DeploymentViewIncludePredicate<A extends AnyAux = Unknown>
17
- extends AnyIncludePredicate<Expression<A>>
18
- {}
19
- export interface DeploymentViewExcludePredicate<A extends AnyAux = Unknown>
20
- extends AnyExcludePredicate<Expression<A>>
21
- {}
22
-
23
- export type DeploymentViewPredicate<A extends AnyAux = Unknown> =
24
- | DeploymentViewIncludePredicate<A>
25
- | DeploymentViewExcludePredicate<A>
26
-
27
- export interface DeploymentViewRuleStyle<A extends AnyAux = Unknown> extends AnyViewRuleStyle<FqnExpr<A>> {}
28
-
29
- export type DeploymentViewRule<A extends AnyAux = Unknown> = ExclusiveUnion<{
30
- Include: DeploymentViewIncludePredicate<A>
31
- Exclude: DeploymentViewExcludePredicate<A>
32
- Style: DeploymentViewRuleStyle<A>
33
- AutoLayout: ViewRuleAutoLayout
34
- }>
35
-
36
- export interface ParsedDeploymentView<A extends AnyAux = Unknown> extends BaseParsedViewProperties<A> {
37
- [_type]: 'deployment'
38
- readonly rules: DeploymentViewRule<A>[]
39
- }
@@ -1,89 +0,0 @@
1
- import { isArray } from 'remeda'
2
- import type { MergeExclusive, Simplify } from 'type-fest'
3
- import type * as aux from './_aux'
4
- import type { AnyAux } from './_aux'
5
- import type { ExclusiveUnion } from './_common'
6
- import type { _type } from './const'
7
- import type { ModelFqnExpr } from './expression-model'
8
- import { type MarkdownOrString, isStepEdgeId } from './scalar'
9
- import type { Color, RelationshipArrowType, RelationshipLineType } from './styles'
10
- import type {
11
- BaseParsedViewProperties,
12
- ViewRuleAutoLayout,
13
- ViewRuleGlobalPredicateRef,
14
- ViewRuleGlobalStyle,
15
- } from './view-common'
16
- import type { ElementViewRuleStyle } from './view-parsed.element'
17
-
18
- export interface DynamicViewStep<A extends AnyAux = AnyAux> {
19
- readonly source: aux.StrictFqn<A>
20
- readonly target: aux.StrictFqn<A>
21
- readonly title: string | null
22
- readonly description?: string
23
- readonly technology?: string
24
- readonly notation?: string
25
- // Notes for walkthrough
26
- readonly notes?: MarkdownOrString
27
- readonly color?: Color
28
- readonly line?: RelationshipLineType
29
- readonly head?: RelationshipArrowType
30
- readonly tail?: RelationshipArrowType
31
- readonly isBackward?: boolean
32
- // Link to dynamic view
33
- readonly navigateTo?: aux.StrictViewId<A>
34
- }
35
-
36
- export interface DynamicViewParallelSteps<A extends AnyAux = AnyAux> {
37
- readonly __parallel: DynamicViewStep<A>[]
38
- }
39
-
40
- // Get the prefix of the parallel steps
41
- // i.e. step-01.1 -> step-01.
42
- export function getParallelStepsPrefix(id: string): string | null {
43
- if (isStepEdgeId(id) && id.includes('.')) {
44
- return id.slice(0, id.indexOf('.') + 1)
45
- }
46
- return null
47
- }
48
-
49
- export type DynamicViewStepOrParallel<A extends AnyAux = AnyAux> = Simplify<
50
- MergeExclusive<
51
- DynamicViewStep<A>,
52
- DynamicViewParallelSteps<A>
53
- >
54
- >
55
-
56
- export interface DynamicViewIncludeRule<A extends AnyAux = AnyAux> {
57
- include: ModelFqnExpr.Any<A>[]
58
- }
59
-
60
- export type DynamicViewRule<A extends AnyAux = AnyAux> = ExclusiveUnion<{
61
- Include: DynamicViewIncludeRule<A>
62
- GlobalPredicateRef: ViewRuleGlobalPredicateRef
63
- ElementViewRuleStyle: ElementViewRuleStyle<A>
64
- GlobalStyle: ViewRuleGlobalStyle
65
- AutoLayout: ViewRuleAutoLayout
66
- }>
67
-
68
- export type DynamicViewDisplayVariant = 'diagram' | 'sequence'
69
-
70
- export interface ParsedDynamicView<A extends AnyAux = AnyAux> extends BaseParsedViewProperties<A> {
71
- [_type]: 'dynamic'
72
- /**
73
- * How to display the dynamic view
74
- * - `diagram`: display as a regular likec4 view
75
- * - `sequence`: display as a sequence diagram
76
- *
77
- * @default 'diagram'
78
- */
79
- readonly variant?: DynamicViewDisplayVariant
80
-
81
- readonly steps: DynamicViewStepOrParallel<A>[]
82
- readonly rules: DynamicViewRule<A>[]
83
- }
84
-
85
- export function isDynamicViewParallelSteps<A extends AnyAux>(
86
- step: DynamicViewStepOrParallel<A>,
87
- ): step is DynamicViewParallelSteps<A> {
88
- return '__parallel' in step && isArray(step.__parallel)
89
- }
@@ -1,65 +0,0 @@
1
- import type * as aux from './_aux'
2
- import type { AnyAux } from './_aux'
3
- import type { ExclusiveUnion } from './_common'
4
- import type { _type } from './const'
5
- import type { ModelExpression, ModelFqnExpr } from './expression-model'
6
- import type { BorderStyle, Color, ShapeSize, SpacingSize, TextSize } from './styles'
7
- import type {
8
- AnyExcludePredicate,
9
- AnyIncludePredicate,
10
- AnyViewRuleStyle,
11
- BaseParsedViewProperties,
12
- ViewRuleAutoLayout,
13
- ViewRuleGlobalPredicateRef,
14
- ViewRuleGlobalStyle,
15
- } from './view-common'
16
-
17
- /**
18
- * Predicates scoped to logical model
19
- */
20
- export interface ElementViewIncludePredicate<A extends AnyAux = AnyAux>
21
- extends AnyIncludePredicate<ModelExpression<A>>
22
- {}
23
- export interface ElementViewExcludePredicate<A extends AnyAux = AnyAux>
24
- extends AnyExcludePredicate<ModelExpression<A>>
25
- {}
26
-
27
- export type ElementViewPredicate<A extends AnyAux = AnyAux> =
28
- | ElementViewIncludePredicate<A>
29
- | ElementViewExcludePredicate<A>
30
-
31
- export interface ElementViewRuleGroup<A extends AnyAux = AnyAux> {
32
- groupRules: Array<ElementViewPredicate<A> | ElementViewRuleGroup<A>>
33
- title: string | null
34
- color?: Color
35
- border?: BorderStyle
36
- // 0-100
37
- opacity?: number
38
- multiple?: boolean
39
- size?: ShapeSize
40
- padding?: SpacingSize
41
- textSize?: TextSize
42
- }
43
-
44
- export function isViewRuleGroup<A extends AnyAux>(rule: ElementViewRule<A>): rule is ElementViewRuleGroup<A> {
45
- return 'title' in rule && 'groupRules' in rule && Array.isArray(rule.groupRules)
46
- }
47
-
48
- export interface ElementViewRuleStyle<A extends AnyAux = AnyAux> extends AnyViewRuleStyle<ModelFqnExpr<A>> {}
49
-
50
- export type ElementViewRule<A extends AnyAux = AnyAux> = ExclusiveUnion<{
51
- IncludePredicate: ElementViewIncludePredicate<A>
52
- ExcludePredicate: ElementViewExcludePredicate<A>
53
- Group: ElementViewRuleGroup<A>
54
- Style: ElementViewRuleStyle<A>
55
- GlobalStyle: ViewRuleGlobalStyle
56
- GlobalPredicateRef: ViewRuleGlobalPredicateRef
57
- AutoLayout: ViewRuleAutoLayout
58
- }>
59
-
60
- export interface ParsedElementView<A extends AnyAux = AnyAux> extends BaseParsedViewProperties<A> {
61
- [_type]: 'element'
62
- readonly rules: ElementViewRule<A>[]
63
- readonly viewOf?: aux.StrictFqn<A>
64
- readonly extends?: aux.StrictViewId<A>
65
- }
package/src/types/view.ts DELETED
@@ -1,113 +0,0 @@
1
- import { isTruthy } from 'remeda'
2
- import type { Any } from './_aux'
3
- import * as aux from './_aux'
4
- import type { _stage, _type, ExtractOnStage, ModelStage } from './const'
5
- import type { ViewType } from './view-common'
6
- import type {
7
- ComputedDeploymentView,
8
- ComputedDynamicView,
9
- ComputedElementView,
10
- } from './view-computed'
11
- import type {
12
- LayoutedDeploymentView,
13
- LayoutedDynamicView,
14
- LayoutedElementView,
15
- } from './view-layouted'
16
- import type { ParsedDeploymentView } from './view-parsed.deployment'
17
- import type { ParsedDynamicView } from './view-parsed.dynamic'
18
- import type { ParsedElementView } from './view-parsed.element'
19
-
20
- export type ParsedView<A extends Any = Any> =
21
- | ParsedElementView<A>
22
- | ParsedDeploymentView<A>
23
- | ParsedDynamicView<A>
24
-
25
- /**
26
- * Should be `ParsedView` but keep it for backward compatibility
27
- * @deprecated use `ParsedView`
28
- */
29
- export type { ParsedView as LikeC4View }
30
-
31
- export type ComputedView<A extends Any = Any> =
32
- | ComputedElementView<A>
33
- | ComputedDeploymentView<A>
34
- | ComputedDynamicView<A>
35
-
36
- export type LayoutedView<A extends Any = Any> =
37
- | LayoutedElementView<A>
38
- | LayoutedDeploymentView<A>
39
- | LayoutedDynamicView<A>
40
-
41
- export type ProcessedView<A extends Any = Any> =
42
- | ComputedView<A>
43
- | LayoutedView<A>
44
-
45
- /**
46
- * @alias DiagramView
47
- */
48
- export type { LayoutedView as DiagramView }
49
- export type AnyView<A extends Any = Any> =
50
- | ParsedElementView<A>
51
- | ParsedDeploymentView<A>
52
- | ParsedDynamicView<A>
53
- | ComputedElementView<A>
54
- | ComputedDeploymentView<A>
55
- | ComputedDynamicView<A>
56
- | LayoutedElementView<A>
57
- | LayoutedDeploymentView<A>
58
- | LayoutedDynamicView<A>
59
-
60
- export type ViewOnStage<V extends AnyView<Any>, T extends ModelStage> = Extract<V, { [_stage]: T }>
61
- export type ViewWithType<V extends AnyView<Any>, T extends ViewType> = Extract<V, { [_type]: T }>
62
-
63
- export type ViewRule<A extends Any = Any> = ParsedView<A>['rules'][number]
64
- export type ViewRulePredicate<A extends Any = Any> = Extract<
65
- ViewRule<A>,
66
- { include: any[] } | { exclude: any[] }
67
- >
68
-
69
- export function isViewRulePredicate<V extends ViewRule<any>>(rule: V): rule is Extract<
70
- V,
71
- { include: any[] } | { exclude: any[] }
72
- > {
73
- return 'include' in rule || 'exclude' in rule
74
- }
75
-
76
- export function isViewRuleStyle<V extends ViewRule<any>>(
77
- rule: V,
78
- ): rule is Extract<V, { targets: any[]; style: {} }> {
79
- return 'targets' in rule && 'style' in rule
80
- }
81
-
82
- export function isComputedView<V extends AnyView<any>>(view: V): view is ExtractOnStage<V, 'computed'> {
83
- return view._stage === 'computed'
84
- }
85
-
86
- export function isDiagramView<V extends AnyView<any>>(view: V): view is ExtractOnStage<V, 'layouted'> {
87
- return view._stage === 'layouted'
88
- }
89
- export { isDiagramView as isLayoutedView }
90
-
91
- export function isElementView<V extends AnyView<any>>(view: V): view is ViewWithType<V, 'element'> {
92
- return view._type === 'element'
93
- }
94
-
95
- export function isScopedElementView<V extends AnyView<any>>(
96
- view: V,
97
- ): view is ViewWithType<V, 'element'> & { viewOf: aux.StrictFqn<Any> } {
98
- return isElementView(view) && isTruthy(view.viewOf)
99
- }
100
-
101
- export function isExtendsElementView<V extends AnyView<any>>(
102
- view: V,
103
- ): view is ViewWithType<V, 'element'> & { extends: aux.StrictViewId<Any> } {
104
- return isElementView(view) && isTruthy(view.extends)
105
- }
106
-
107
- export function isDeploymentView<V extends AnyView<any>>(view: V): view is ViewWithType<V, 'deployment'> {
108
- return view._type === 'deployment'
109
- }
110
-
111
- export function isDynamicView<V extends AnyView<any>>(view: V): view is ViewWithType<V, 'dynamic'> {
112
- return view._type === 'dynamic'
113
- }
@@ -1,22 +0,0 @@
1
- import { map, pipe, takeWhile, zip } from 'remeda'
2
-
3
- /**
4
- * Common head of two arrays
5
- *
6
- * @param equals - Equality function, defaults to `Object.is`
7
- */
8
- export function commonHead<T>(
9
- sources: ReadonlyArray<T>,
10
- targets: ReadonlyArray<T>,
11
- equals?: (a: T, b: T) => boolean
12
- ): T[] {
13
- if (sources.length === 0 || targets.length === 0) {
14
- return []
15
- }
16
- equals ??= Object.is
17
- return pipe(
18
- zip(sources, targets),
19
- takeWhile(([source, target]) => equals(source, target)),
20
- map(([source, _]) => source)
21
- )
22
- }
@@ -1,60 +0,0 @@
1
- import compare from 'natural-compare-lite'
2
- import { isString } from 'remeda'
3
-
4
- export function compareNatural(a: string | undefined, b: string | undefined): -1 | 0 | 1 {
5
- if (a === b) return 0
6
- if (isString(a)) {
7
- if (isString(b)) {
8
- return compare(a, b)
9
- }
10
- return 1
11
- }
12
- return isString(b) ? -1 : 0
13
- }
14
-
15
- /**
16
- * Compares two strings lexicographically first, then hierarchically based on their depth.\
17
- * From parent nodes to leaves
18
- *
19
- * @example
20
- * const lines = [
21
- * 'b.c',
22
- * 'b',
23
- * 'a.b.c',
24
- * ]
25
- * lines.sort(compareNaturalHierarchically('.'))
26
- * // [
27
- * // 'a.b.c',
28
- * // 'b',
29
- * // 'b.c',
30
- * // ]
31
- */
32
- export function compareNaturalHierarchically(
33
- separator = '.',
34
- deepestFirst = false,
35
- ): (a: string | undefined, b: string | undefined) => number {
36
- return (a, b) => {
37
- if (a === b) return 0
38
- if (!a) return -1
39
- if (!b) return 1
40
- const aParts = a.split(separator)
41
- const bParts = b.split(separator)
42
-
43
- // Find the minimum length to avoid out-of-bounds access
44
- const minLength = Math.min(aParts.length, bParts.length)
45
-
46
- // Compare segments until we find a difference
47
- for (let i = 0; i < minLength; i++) {
48
- const aPart = aParts[i]!
49
- const bPart = bParts[i]!
50
- const comparison = compare(aPart, bPart)
51
- if (comparison !== 0) {
52
- return comparison
53
- }
54
- }
55
-
56
- // If all common segments are equal, shorter paths come first (if deepestFirst is false)
57
- const diff = aParts.length - bParts.length
58
- return deepestFirst ? -1 * diff : diff
59
- }
60
- }
@@ -1 +0,0 @@
1
- export const customInspectSymbol = Symbol.for('nodejs.util.inspect.custom')