@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,206 +0,0 @@
1
- import { markdownToHtml, markdownToText, memoizeProp, nonexhaustive } from '../utils'
2
- import type { MarkdownOrString } from './scalar'
3
-
4
- const richtxt = Symbol.for('richtxt')
5
- const symb_text = Symbol.for('text')
6
- const symb_html = Symbol.for('html')
7
-
8
- const emptyTxt = ''
9
-
10
- export interface RichTextEmpty {
11
- readonly isEmpty: true
12
- readonly isMarkdown: false
13
- readonly nonEmpty: false
14
- readonly $source: null
15
- readonly text: null
16
- readonly md: null
17
- readonly html: null
18
- equals(other: unknown): boolean
19
- }
20
-
21
- export interface RichTextNonEmpty {
22
- readonly isEmpty: false
23
- readonly nonEmpty: true
24
- readonly isMarkdown: boolean
25
- readonly $source: MarkdownOrString
26
- readonly text: string
27
- readonly md: string
28
- readonly html: string
29
- equals(other: unknown): boolean
30
- }
31
-
32
- export type RichTextOrEmpty = RichTextNonEmpty | RichTextEmpty
33
-
34
- /**
35
- * RichText is a class that represents a potentially markdown string.
36
- * It can be either a plain text or a markdown.
37
- * It is used to represent the content of a node or a link.
38
- */
39
- export class RichText {
40
- private static _cache = new WeakMap<MarkdownOrString, RichTextOrEmpty>()
41
-
42
- /**
43
- * Creates and memoizes a RichText instance.
44
- * @see ElementModel.description
45
- * @example
46
- *
47
- * get description(): RichTextOrEmpty {
48
- * return RichText.memoize(this, this.$element.description)
49
- * }
50
- */
51
- static memoize(obj: object, source: MarkdownOrString | null | undefined): RichTextOrEmpty {
52
- return memoizeProp(obj, richtxt, () => RichText.from(source))
53
- }
54
-
55
- /**
56
- * Creates a RichText instance from a source.
57
- */
58
- static from(source: RichTextOrEmpty | MarkdownOrString | string | null | undefined): RichTextOrEmpty {
59
- if (source === null || source === undefined || source === RichText.EMPTY) {
60
- return RichText.EMPTY
61
- }
62
- if (source instanceof RichText) {
63
- return source as RichTextOrEmpty
64
- }
65
- if (typeof source === 'string') {
66
- if (source.trim() === emptyTxt) {
67
- return RichText.EMPTY
68
- }
69
- return new RichText({ txt: source }) as RichTextOrEmpty
70
- }
71
- if ('isEmpty' in source && source.isEmpty) {
72
- return RichText.EMPTY
73
- }
74
- if ('md' in source && source.md.trim() === emptyTxt) {
75
- return RichText.EMPTY
76
- }
77
- if ('txt' in source && source.txt.trim() === emptyTxt) {
78
- return RichText.EMPTY
79
- }
80
- const _source = source as MarkdownOrString
81
- const cached = RichText._cache.get(_source)
82
- if (cached) {
83
- return cached
84
- }
85
- const rt = new RichText(_source) as RichTextOrEmpty
86
- RichText._cache.set(_source, rt)
87
- return rt
88
- }
89
-
90
- /**
91
- * This is a workaround for the fact that we need instance of RichText for `instanceof` checks
92
- * It is invalid inheritance (returning `null` from getters), and we cast to @see RichTextEmpty
93
- */
94
- static EMPTY: RichTextEmpty = new class extends RichText {
95
- public override readonly isEmpty: true = true
96
- public override readonly nonEmpty: false = false
97
- public override readonly isMarkdown: false = false
98
- public override readonly $source: null = null
99
- constructor() {
100
- super({ txt: emptyTxt })
101
- }
102
-
103
- override get text(): any {
104
- return null
105
- }
106
-
107
- override get md(): any {
108
- return null
109
- }
110
-
111
- override get html(): any {
112
- return null
113
- }
114
- }()
115
-
116
- public readonly $source: Readonly<MarkdownOrString> | null
117
-
118
- public readonly isEmpty: boolean
119
- public readonly nonEmpty: boolean
120
- public readonly isMarkdown: boolean
121
-
122
- /**
123
- * Private constructor to prevent direct instantiation.
124
- * Use {@link RichText.from} or {@link RichText.memoize} instead.
125
- */
126
- private constructor(source: MarkdownOrString | string) {
127
- this.isMarkdown = false
128
- if (typeof source === 'string') {
129
- this.$source = { txt: source }
130
- this.isEmpty = source.trim() === emptyTxt
131
- } else {
132
- this.$source = source
133
- this.isEmpty = true
134
- if ('md' in source) {
135
- this.isEmpty = source.md === emptyTxt
136
- this.isMarkdown = true
137
- } else {
138
- this.isEmpty = source.txt === emptyTxt
139
- }
140
- }
141
- this.nonEmpty = !this.isEmpty
142
- }
143
-
144
- /**
145
- * Returns the text content of the rich text.
146
- * If the source is a string, it returns the string.
147
- * If the source is a markdown, it returns the markdown.
148
- */
149
- get text(): string {
150
- if (this.isEmpty || this.$source === null) {
151
- return emptyTxt
152
- }
153
- const source = this.$source
154
- if ('txt' in source) {
155
- return source.txt
156
- }
157
- return memoizeProp(this, symb_text, () => markdownToText(source.md!))
158
- }
159
-
160
- /**
161
- * Returns the markdown content of the rich text.
162
- * If the source is a string, it returns the string.
163
- * If the source is a markdown, it returns the markdown.
164
- */
165
- get md(): string {
166
- if (this.isEmpty || this.$source === null) {
167
- return emptyTxt
168
- }
169
- const source = this.$source
170
- if ('md' in source) {
171
- return source.md
172
- }
173
- if ('txt' in source) {
174
- return source.txt
175
- }
176
- nonexhaustive(source)
177
- }
178
-
179
- /**
180
- * Returns the html content of the rich text.
181
- * If the source is a string, it returns the string.
182
- * If the source is a markdown, it returns the HTML.
183
- */
184
- get html(): string {
185
- if (this.isEmpty || this.$source === null) {
186
- return emptyTxt
187
- }
188
- const source = this.$source
189
- if ('txt' in source) {
190
- return source.txt
191
- }
192
- return memoizeProp(this, symb_html, () => markdownToHtml(source.md!))
193
- }
194
-
195
- equals(other: unknown): boolean {
196
- if (this === other) return true
197
- if (!(other instanceof RichText)) return false
198
- if (this.isEmpty && other.isEmpty) return true
199
- if (this.isEmpty !== other.isEmpty || this.isMarkdown !== other.isMarkdown) return false
200
-
201
- if (this.isMarkdown) {
202
- return this.$source?.md === other.$source?.md
203
- }
204
- return this.$source?.txt === other.$source?.txt
205
- }
206
- }
package/src/types/_aux.ts DELETED
@@ -1,291 +0,0 @@
1
- import type { IfNever, IsLiteral, IsNever } from 'type-fest'
2
- import type { Coalesce, Link } from './_common'
3
- import type { ModelStage } from './const'
4
- import type * as scalar from './scalar'
5
- /**
6
- * Specification types (kinds, tags, metadata keys)
7
- *
8
- * @param ElementKind - Literal union of element kinds
9
- * @param DeploymentKind - Literal union of deployment kinds
10
- * @param RelationKind - Literal union of relationship kinds
11
- * @param Tag - Literal union of tags
12
- * @param MetadataKey - Literal union of metadata keys
13
- */
14
- export interface SpecAux<
15
- ElementKind extends string,
16
- DeploymentKind extends string,
17
- RelationKind extends string,
18
- Tag extends string,
19
- MetadataKey extends string,
20
- > {
21
- ElementKind: ElementKind
22
- DeploymentKind: DeploymentKind
23
- RelationKind: RelationKind
24
- Tag: Tag
25
- MetadataKey: MetadataKey
26
- }
27
- export type AnySpec = SpecAux<any, any, any, any, any>
28
-
29
- /**
30
- * Auxilary interface to keep inferred types
31
- *
32
- * @typeParam Stage - View stage
33
- * @typeParam Element - Literal union of FQNs of model elements
34
- * @typeParam Deployment - Literal union of FQNs of deployment elements
35
- * @typeParam View - Literal union of view identifiers
36
- * @typeParam Project - Project identifier type
37
- * @typeParam Spec - Specification types (kinds, tags, metadata keys)
38
- */
39
- export interface Aux<
40
- Stage extends ModelStage,
41
- Element extends string,
42
- Deployment extends string,
43
- View extends string,
44
- Project extends string,
45
- Spec extends SpecAux<string, string, string, string, string>,
46
- > {
47
- Stage: Stage
48
- ProjectId: Project
49
- ElementId: Element
50
- DeploymentId: Deployment
51
-
52
- ViewId: View
53
-
54
- ElementKind: Spec['ElementKind']
55
- DeploymentKind: Spec['DeploymentKind']
56
- RelationKind: Spec['RelationKind']
57
- Tag: Spec['Tag']
58
- MetadataKey: Spec['MetadataKey']
59
- }
60
-
61
- // export type AnyOnStage<Stage extends ModelStage> = Aux<Stage, any, any, any, any, SpecAux<any, any, any, any, any>>
62
-
63
- // export type AnyParsed = AnyOnStage<'parsed'>
64
- // export type AnyComputed = AnyOnStage<'computed'>
65
- // export type AnyLayouted = AnyOnStage<'layouted'>
66
-
67
- export type Any = Aux<any, any, any, any, any, SpecAux<any, any, any, any, any>>
68
- export type { Any as AnyAux }
69
-
70
- export type Never = Aux<never, never, never, never, never, SpecAux<never, never, never, never, never>>
71
-
72
- /**
73
- * Fallback when {@link Aux} can't be inferred.
74
- * By default assumes non parsed model
75
- */
76
- export type Unknown = Aux<
77
- 'layouted' | 'computed',
78
- string,
79
- string,
80
- string,
81
- string,
82
- SpecAux<string, string, string, string, string>
83
- >
84
-
85
- export type UnknownParsed = Aux<
86
- 'parsed',
87
- string,
88
- string,
89
- string,
90
- string,
91
- SpecAux<string, string, string, string, string>
92
- >
93
-
94
- export type UnknownComputed = Aux<
95
- 'computed',
96
- string,
97
- string,
98
- string,
99
- string,
100
- SpecAux<string, string, string, string, string>
101
- >
102
- export type UnknownLayouted = Aux<
103
- 'layouted',
104
- string,
105
- string,
106
- string,
107
- string,
108
- SpecAux<string, string, string, string, string>
109
- >
110
-
111
- /**
112
- * Reads stage from Aux
113
- */
114
- export type Stage<A> =
115
- // dprint-ignore
116
- A extends Aux<infer S, any, any, any, any, any>
117
- ? IfNever<S, never, Coalesce<S, ModelStage>>
118
- : never
119
-
120
- /**
121
- * Picks type based on stage from Aux
122
- */
123
- export type PickByStage<A extends Any, OnParsed, OnComputed, OnLayouted = OnComputed> = {
124
- parsed: OnParsed
125
- computed: OnComputed
126
- layouted: OnLayouted
127
- }[A['Stage']]
128
-
129
- export type setStage<A, S extends ModelStage> =
130
- // dprint-ignore
131
- A extends Aux<any, infer E, infer D, infer V, infer P, infer Spec>
132
- ? Aux<S, E, D, V, P, Spec>
133
- : never
134
-
135
- export type toParsed<A> = A extends Aux<any, infer E, infer D, infer V, infer P, infer Spec>
136
- ? Aux<'parsed', E, D, V, P, Spec>
137
- : never
138
-
139
- export type toComputed<A> = A extends Aux<any, infer E, infer D, infer V, infer P, infer Spec>
140
- ? Aux<'computed', E, D, V, P, Spec>
141
- : never
142
-
143
- export type toLayouted<A> = A extends Aux<any, infer E, infer D, infer V, infer P, infer Spec>
144
- ? Aux<'layouted', E, D, V, P, Spec>
145
- : never
146
-
147
- /**
148
- * Project identifier from Aux
149
- */
150
- export type ProjectId<A> = A extends infer T extends Any ? Coalesce<T['ProjectId']> : never
151
-
152
- export type setProject<A, P extends string> =
153
- // dprint-ignore
154
- A extends Aux<infer S, infer E, infer D, infer V, any, infer Spec>
155
- ? Aux<S, E, D, V, P, Spec>
156
- : never
157
-
158
- /**
159
- * Element FQN from Aux as branded type
160
- */
161
- export type Fqn<A> = A extends infer T extends Any ? scalar.Fqn<ElementId<T>> : never
162
-
163
- /**
164
- * Element FQN from Aux as a literal union
165
- */
166
- export type ElementId<A> = A extends infer T extends Any ? Coalesce<T['ElementId']> : never
167
-
168
- /**
169
- * Deployment FQN from Aux as branded type
170
- */
171
- export type DeploymentFqn<A> = A extends infer T extends Any ? scalar.DeploymentFqn<DeploymentId<T>> : never
172
-
173
- /**
174
- * Deployment FQN from Aux as a literal union
175
- * @alias {@link DeploymentFqn}
176
- */
177
- export type DeploymentId<A> = A extends infer T extends Any ? Coalesce<T['DeploymentId']> : never
178
-
179
- /**
180
- * View identifier from Aux as a literal union
181
- */
182
- export type ViewId<A> = A extends infer T extends Any ? Coalesce<T['ViewId']> : never
183
-
184
- export type RelationId = scalar.RelationId
185
- export type NodeId = scalar.NodeId
186
- export type EdgeId = scalar.EdgeId
187
-
188
- /**
189
- * ElementKind from Aux as a literal union
190
- */
191
- export type ElementKind<A> = A extends infer T extends Any ? Coalesce<T['ElementKind']> : never
192
-
193
- /**
194
- * DeploymentKind from Aux as a literal union
195
- */
196
- export type DeploymentKind<A> = A extends infer T extends Any ? Coalesce<T['DeploymentKind']> : never
197
-
198
- /**
199
- * RelationKind from Aux as a literal union
200
- */
201
- export type RelationKind<A> = A extends infer T extends Any ? Coalesce<T['RelationKind']> : never
202
-
203
- /**
204
- * Tags from Aux as a literal union
205
- */
206
- export type Tag<A> = A extends infer T extends Any ? Coalesce<T['Tag']> : never
207
-
208
- /**
209
- * Array of tags from Aux
210
- */
211
- export type Tags<A extends Any> = readonly Tag<A>[]
212
-
213
- /**
214
- * Metadata key from Aux
215
- */
216
- export type MetadataKey<A> = A extends infer T extends Any ? Coalesce<T['MetadataKey']> : never
217
-
218
- /**
219
- * Metadata object from Aux
220
- */
221
- export type Metadata<A extends Any> =
222
- // dprint-ignore
223
- IsNever<A['MetadataKey']> extends true
224
- ? never
225
- : IsLiteral<A['MetadataKey']> extends true
226
- ? {
227
- [key in A['MetadataKey']]?: string
228
- }
229
- : Record<string, string>
230
-
231
- /**
232
- * All known kinds from Aux as a literal union.
233
- */
234
- export type AllKinds<A> = ElementKind<A> | DeploymentKind<A> | RelationKind<A>
235
-
236
- /**
237
- * Specification from Aux
238
- */
239
- export type Spec<A> = A extends Aux<any, any, any, any, any, infer S> ? S : never
240
-
241
- export type StrictProjectId<A> = A extends infer T extends Any ? scalar.ProjectId<ProjectId<T>> : never
242
-
243
- export type {
244
- DeploymentFqn as StrictDeploymentFqn,
245
- Fqn as StrictFqn,
246
- }
247
-
248
- export type StrictViewId<A> = A extends infer T extends Any ? scalar.ViewId<ViewId<T>> : never
249
-
250
- export type StrictTag<A> = A extends infer T extends Any ? scalar.Tag<Tag<T>> : never
251
-
252
- // dprint-ignore
253
- export type StrictElementKind<A> = A extends infer T extends Any ? scalar.ElementKind<ElementKind<T>> : never
254
- export type StrictDeploymentKind<A> = A extends infer T extends Any ? scalar.DeploymentKind<DeploymentKind<T>>
255
- : never
256
- export type StrictRelationKind<A> = A extends infer T extends Any ? scalar.RelationshipKind<RelationKind<T>> : never
257
-
258
- export type WithTags<A extends Any> = {
259
- readonly tags: Tags<A>
260
- }
261
-
262
- export type WithOptionalTags<A extends Any> = {
263
- readonly tags?: Tags<A> | null
264
- }
265
-
266
- export type WithLinks = {
267
- readonly links: readonly Link[]
268
- }
269
-
270
- export type WithOptionalLinks = {
271
- readonly links?: readonly Link[] | null
272
- }
273
-
274
- export type WithMetadata<A extends Any> = {
275
- readonly metadata?: Metadata<A>
276
- }
277
-
278
- /**
279
- * @see {@link LiteralUnion} from type-fest (https://github.com/sindresorhus/type-fest/blob/main/source/literal-union.d.ts)
280
- */
281
- export type OrString = string & Record<never, never>
282
-
283
- export type LooseElementId<A extends Any> = Coalesce<A['ElementId']> | OrString
284
- export type LooseDeploymentId<A extends Any> = Coalesce<A['DeploymentId']> | OrString
285
- export type LooseViewId<A extends Any> = Coalesce<A['ViewId']> | OrString
286
- export type LooseTag<A extends Any> = Coalesce<A['Tag']> | OrString
287
- export type LooseTags<A extends Any> = readonly (Coalesce<A['Tag']> | OrString)[]
288
-
289
- export type LooseElementKind<A extends Any> = Coalesce<A['ElementKind']> | OrString
290
- export type LooseDeploymentKind<A extends Any> = Coalesce<A['DeploymentKind']> | OrString
291
- export type LooseRelationKind<A extends Any> = Coalesce<A['RelationKind']> | OrString
@@ -1,80 +0,0 @@
1
- import type { IsAny, Simplify, UnionToIntersection } from 'type-fest'
2
-
3
- export type NonEmptyArray<T> = [T, ...T[]]
4
-
5
- export type NonEmptyReadonlyArray<T> = readonly [T, ...T[]]
6
-
7
- export type IterableContainer<T = unknown> = ReadonlyArray<T> | readonly []
8
-
9
- export type ReorderedArray<T extends IterableContainer> = {
10
- -readonly [P in keyof T]: T[number]
11
- }
12
-
13
- // dprint-ignore
14
- export type KeysOf<T> = keyof T extends infer K extends string ? K : never
15
-
16
- type AllNever<Expressions> = UnionToIntersection<
17
- {
18
- [Name in keyof Expressions]: {
19
- -readonly [Key in keyof Expressions[Name]]?: never
20
- }
21
- }[keyof Expressions]
22
- >
23
-
24
- /**
25
- * @example
26
- * ```ts
27
- * type Variant1 = {
28
- * a: string
29
- * }
30
- * type Variant2 = {
31
- * b: number
32
- * }
33
- *
34
- * type Variants = ExclusiveUnion<{
35
- * Variant1: Variant1,
36
- * Variant2: Variant2
37
- * }>
38
- *
39
- * // Fail here
40
- * const variant1: Variants = {
41
- * a: 'one',
42
- * b: 1
43
- * }
44
- * ```
45
- */
46
- export type ExclusiveUnion<Expressions, All = AllNever<Expressions>> = Expressions extends object ? {
47
- [Name in keyof Expressions]: Simplify<Omit<All, keyof Expressions[Name]> & Expressions[Name]>
48
- }[keyof Expressions]
49
- : never
50
-
51
- /**
52
- * Copy from https://github.com/remeda/remeda/blob/main/src/internal/types/NTuple.ts
53
- * An array with *exactly* N elements in it.
54
- *
55
- * Only literal N values are supported. For very large N the type might result
56
- * in a recurse depth error. For negative N the type would result in an infinite
57
- * recursion. None of these have protections because this is an internal type!
58
- */
59
- export type NTuple<
60
- T,
61
- N extends number,
62
- Result extends Array<unknown> = [],
63
- > = Result['length'] extends N ? Result : NTuple<T, N, [...Result, T]>
64
-
65
- export type IteratorLike<T> = IteratorObject<T, BuiltinIteratorReturn, unknown>
66
-
67
- export type Predicate<T> = (x: T) => boolean
68
-
69
- export interface Link {
70
- title?: string
71
- // Value from Likec4 DSL
72
- url: string
73
- // Relative to workspace root (if url is relative),
74
- relative?: string
75
- }
76
-
77
- /**
78
- * Coalesce `V` to a string if it is `any`
79
- */
80
- export type Coalesce<V extends string, OrIfAny = string> = IsAny<V> extends true ? OrIfAny : V
@@ -1,34 +0,0 @@
1
- /**
2
- * Determines the stage of the model:
3
- * 1. `parsed` - parsed from DSL or returned from Builder
4
- * 2. `computed` - views are computed
5
- * 3. `layouted` - views are layouted
6
- *
7
- * @internal
8
- */
9
- export type ModelStage = 'parsed' | 'computed' | 'layouted'
10
-
11
- export type ExtractOnStage<T, S extends ModelStage> = Extract<T, { [_stage]: S }>
12
-
13
- export function isOnStage<T extends { [_stage]: ModelStage }, S extends ModelStage>(
14
- value: T,
15
- stage: S,
16
- ): value is ExtractOnStage<T, S> {
17
- return value[_stage] === stage
18
- }
19
-
20
- /**
21
- * Property name to store the stage of the model
22
- *
23
- * @internal
24
- */
25
- export const _stage = '_stage'
26
- export type _stage = typeof _stage
27
-
28
- /**
29
- * Property name to store type information, used to identify the type of the view
30
- *
31
- * @internal
32
- */
33
- export const _type = '_type'
34
- export type _type = typeof _type