@likec4/core 1.41.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.
- package/builder/package.json +4 -0
- package/compute-view/package.json +4 -0
- package/compute-view/relationships/package.json +4 -0
- package/dist/builder/index.d.mts +13 -11
- package/dist/builder/index.mjs +111 -91
- package/dist/compute-view/index.d.mts +8 -7
- package/dist/compute-view/index.mjs +14 -11
- package/dist/compute-view/relationships-view/index.d.mts +9 -8
- package/dist/compute-view/relationships-view/index.mjs +6 -6
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +11 -11
- package/dist/model/connection/deployment/index.d.mts +11 -10
- package/dist/model/connection/deployment/index.mjs +2 -2
- package/dist/model/connection/index.d.mts +12 -11
- package/dist/model/connection/index.mjs +3 -3
- package/dist/model/connection/model/index.d.mts +11 -10
- package/dist/model/connection/model/index.mjs +2 -2
- package/dist/model/index.d.mts +14 -14
- package/dist/model/index.mjs +4 -5
- package/dist/shared/{core.Ae86Y3tB.mjs → core.01VTr9qu.mjs} +8 -26
- package/dist/shared/core.1vX5a9AY.mjs +86 -0
- package/dist/shared/{core.BVNaR17u.mjs → core.B7KhhkRY.mjs} +1 -1
- package/dist/shared/core.B85MJLTf.mjs +5 -0
- package/dist/shared/{core.DA5vzwZ9.mjs → core.BIqHjQiH.mjs} +56 -42
- package/dist/shared/core.BKlholso.mjs +3 -0
- package/dist/shared/core.BR4zXDH-.mjs +13 -0
- package/dist/shared/{core.CXy1NLUG.mjs → core.BYNkXQ8A.mjs} +21 -12
- package/dist/shared/{core.BuoXfSMj.mjs → core.BbE4y-yl.mjs} +1 -1
- package/dist/shared/core.BoYfZOBm.mjs +3 -0
- package/dist/shared/core.BsSXS-_R.mjs +7 -0
- package/dist/shared/{core.DJp8fgok.mjs → core.BzTakU3I.mjs} +14 -10
- package/dist/shared/{core.4u1dVmfX.mjs → core.C2TiyjI6.mjs} +2 -2
- package/dist/shared/{core.DLpidoWc.mjs → core.C3JowhaZ.mjs} +3 -3
- package/dist/shared/{core.CNGyqkJh.mjs → core.C4x8aaWa.mjs} +3 -1
- package/dist/shared/{core.BB6zA-UU.mjs → core.C8YY6Uub.mjs} +38 -9
- package/dist/shared/{core.Asc11Mjy.mjs → core.C8sl5Y8Z.mjs} +122 -58
- package/dist/shared/{core.BvMRMo7Z.mjs → core.CNgZvKb8.mjs} +3 -5198
- package/dist/shared/{core.CUG6vpyL.d.mts → core.CQngdcuj.d.mts} +85 -4
- package/dist/shared/{core.Be1n9a0i.mjs → core.C_Ni6yHl.mjs} +5 -4
- package/dist/shared/core.CbT8JVYL.mjs +5 -0
- package/dist/shared/core.CqAJJpK_.mjs +3 -0
- package/dist/shared/{core.BXsxn-hf.d.mts → core.D0PjZzIS.d.mts} +27 -15
- package/dist/shared/{core.DgesAwC8.d.mts → core.D5fzJWbF.d.mts} +2 -2
- package/dist/shared/{core.hfOE3RfK.d.mts → core.DACpKp35.d.mts} +5 -5
- package/dist/shared/core.DFi2dOTl.mjs +39548 -0
- package/dist/shared/{core.xSQO0XYD.d.mts → core.DIol3syK.d.mts} +2 -2
- package/dist/shared/{core.DlG1xWt2.mjs → core.DMMOWQqc.mjs} +3 -2
- package/dist/shared/core.DNbUPnve.mjs +3990 -0
- package/dist/shared/{core.CCD1ID81.mjs → core.DRJma0Ol.mjs} +4 -3
- package/dist/shared/{core.DgttqsJc.mjs → core.DRhg-gVU.mjs} +9 -9
- package/dist/shared/core.DSO_rTC2.mjs +5322 -0
- package/dist/shared/{core.FUPplpae.d.mts → core.D_vkffV4.d.mts} +4 -2
- package/dist/shared/core.DdMJk7nx.d.mts +476 -0
- package/dist/shared/{core.BhpgpOep.d.mts → core.Dgs6-nuz.d.mts} +2 -2
- package/dist/shared/{core.Be4Jy9Qx.mjs → core.FZ305VYd.mjs} +2 -2
- package/dist/shared/core.OHD4KXm9.mjs +5 -0
- package/dist/shared/{core.GTgsmXS_.mjs → core.QJD_fcrc.mjs} +2 -2
- package/dist/shared/core.RfnaEmgA.mjs +7 -0
- package/dist/shared/core.fHR_8Tnq.d.mts +450 -0
- package/dist/shared/{core.D0EgVMQK.mjs → core.lRvxPoao.mjs} +14 -12
- package/dist/shared/{core.CaT0SUUK.mjs → core.rCeaAqgW.mjs} +1 -84
- package/dist/shared/{core.zxTBF_PD.d.mts → core.s9uwOt60.d.mts} +4 -4
- package/dist/shared/core.yna0OdV5.d.mts +98 -0
- package/dist/styles/index.d.mts +106 -0
- package/dist/styles/index.mjs +1 -0
- package/dist/types/_aux.d.mts +2 -2
- package/dist/types/expression-model.d.mts +3 -4
- package/dist/types/expression.d.mts +3 -4
- package/dist/types/fqnRef.d.mts +2 -2
- package/dist/types/fqnRef.mjs +3 -3
- package/dist/types/index.d.mts +8 -8
- package/dist/types/index.mjs +150 -5
- package/dist/types/scalar.mjs +3 -2
- package/dist/utils/graphology/index.d.mts +1864 -0
- package/dist/utils/graphology/index.mjs +1 -0
- package/dist/utils/index.d.mts +11 -6
- package/dist/utils/index.mjs +21 -37
- package/dist/utils/iterable/index.d.mts +1 -1
- package/dist/utils/iterable/index.mjs +45 -7
- package/model/package.json +4 -0
- package/package.json +42 -24
- package/styles/package.json +4 -0
- package/types/package.json +4 -0
- package/utils/graphology/package.json +4 -0
- package/utils/package.json +4 -0
- package/dist/shared/core.6_Vp2iiN.mjs +0 -172
- package/dist/shared/core.CUw_2J9j.mjs +0 -47
- package/dist/shared/core.CzdwsPmY.d.mts +0 -69
- package/dist/shared/core.D-ZGWDDt.d.mts +0 -831
- package/dist/shared/core.DoM6aM9N.mjs +0 -7
- package/dist/shared/core.ILwny7BV.mjs +0 -38
- package/dist/theme/index.d.mts +0 -11
- package/dist/theme/index.mjs +0 -232
- package/src/builder/Builder.deployment.ts +0 -224
- package/src/builder/Builder.deploymentModel.ts +0 -449
- package/src/builder/Builder.element.ts +0 -241
- package/src/builder/Builder.model.ts +0 -494
- package/src/builder/Builder.ts +0 -946
- package/src/builder/Builder.view-common.ts +0 -273
- package/src/builder/Builder.view-deployment.ts +0 -135
- package/src/builder/Builder.view-element.ts +0 -202
- package/src/builder/Builder.views.ts +0 -399
- package/src/builder/Builder.with.ts +0 -156
- package/src/builder/_types.ts +0 -324
- package/src/builder/index.ts +0 -11
- package/src/compute-view/compute-view.ts +0 -80
- package/src/compute-view/deployment-view/_types.ts +0 -38
- package/src/compute-view/deployment-view/clean-connections.ts +0 -236
- package/src/compute-view/deployment-view/compute.ts +0 -94
- package/src/compute-view/deployment-view/memory/index.ts +0 -9
- package/src/compute-view/deployment-view/memory/memory.ts +0 -96
- package/src/compute-view/deployment-view/predicates/deploymentRefs-where.ts +0 -18
- package/src/compute-view/deployment-view/predicates/deploymentRefs.ts +0 -154
- package/src/compute-view/deployment-view/predicates/index.ts +0 -8
- package/src/compute-view/deployment-view/predicates/relation-direct.ts +0 -243
- package/src/compute-view/deployment-view/predicates/relation-in-out.ts +0 -70
- package/src/compute-view/deployment-view/predicates/relation-incoming.ts +0 -101
- package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +0 -95
- package/src/compute-view/deployment-view/predicates/relation-where.ts +0 -18
- package/src/compute-view/deployment-view/predicates/utils.ts +0 -282
- package/src/compute-view/deployment-view/predicates/wildcard.ts +0 -41
- package/src/compute-view/deployment-view/stages/stage-exclude.ts +0 -5
- package/src/compute-view/deployment-view/stages/stage-final.ts +0 -245
- package/src/compute-view/deployment-view/stages/stage-include.ts +0 -95
- package/src/compute-view/deployment-view/utils.ts +0 -297
- package/src/compute-view/dynamic-view/compute.ts +0 -312
- package/src/compute-view/element-view/_types.ts +0 -47
- package/src/compute-view/element-view/clean-connections.ts +0 -117
- package/src/compute-view/element-view/compute.ts +0 -324
- package/src/compute-view/element-view/memory/NodeGroup.ts +0 -31
- package/src/compute-view/element-view/memory/index.ts +0 -10
- package/src/compute-view/element-view/memory/memory.ts +0 -178
- package/src/compute-view/element-view/memory/stage-exclude.ts +0 -59
- package/src/compute-view/element-view/memory/stage-final.ts +0 -129
- package/src/compute-view/element-view/memory/stage-include.ts +0 -130
- package/src/compute-view/element-view/predicates/_utils.ts +0 -91
- package/src/compute-view/element-view/predicates/element-expand.ts +0 -29
- package/src/compute-view/element-view/predicates/element-kind-tag.ts +0 -27
- package/src/compute-view/element-view/predicates/element-ref.ts +0 -24
- package/src/compute-view/element-view/predicates/relation-direct.ts +0 -321
- package/src/compute-view/element-view/predicates/relation-in-out.ts +0 -64
- package/src/compute-view/element-view/predicates/relation-in.ts +0 -115
- package/src/compute-view/element-view/predicates/relation-out.ts +0 -119
- package/src/compute-view/element-view/predicates/wildcard.ts +0 -88
- package/src/compute-view/element-view/utils.ts +0 -65
- package/src/compute-view/index.ts +0 -4
- package/src/compute-view/memory/AbstractMemory.ts +0 -45
- package/src/compute-view/memory/AbstractStageExclude.ts +0 -215
- package/src/compute-view/memory/AbstractStageInclude.ts +0 -200
- package/src/compute-view/memory/_types.ts +0 -148
- package/src/compute-view/memory/index.ts +0 -5
- package/src/compute-view/memory/ops.ts +0 -43
- package/src/compute-view/relationships-view/_types.ts +0 -16
- package/src/compute-view/relationships-view/compute.ts +0 -159
- package/src/compute-view/relationships-view/index.ts +0 -3
- package/src/compute-view/relationships-view/layout.ts +0 -358
- package/src/compute-view/relationships-view/utils.ts +0 -73
- package/src/compute-view/utils/ancestorsOfNode.ts +0 -19
- package/src/compute-view/utils/applyCustomElementProperties.ts +0 -107
- package/src/compute-view/utils/applyCustomRelationProperties.ts +0 -58
- package/src/compute-view/utils/applyViewRuleStyles.ts +0 -73
- package/src/compute-view/utils/buildComputedNodes.ts +0 -166
- package/src/compute-view/utils/buildElementNotations.ts +0 -64
- package/src/compute-view/utils/elementExpressionToPredicate.ts +0 -50
- package/src/compute-view/utils/link-nodes-with-edges.ts +0 -56
- package/src/compute-view/utils/merge-props-from-relationships.ts +0 -161
- package/src/compute-view/utils/relationExpressionToPredicates.ts +0 -55
- package/src/compute-view/utils/resolve-extended-views.ts +0 -85
- package/src/compute-view/utils/resolve-global-rules.ts +0 -88
- package/src/compute-view/utils/topological-sort.ts +0 -256
- package/src/compute-view/utils/view-hash.ts +0 -45
- package/src/compute-view/utils/with-readable-edges.ts +0 -40
- package/src/index.ts +0 -32
- package/src/model/DeploymentElementModel.ts +0 -712
- package/src/model/DeploymentModel.ts +0 -393
- package/src/model/ElementModel.ts +0 -316
- package/src/model/LikeC4Model.ts +0 -882
- package/src/model/RelationModel.ts +0 -152
- package/src/model/connection/Connection.ts +0 -72
- package/src/model/connection/deployment/DeploymentConnectionModel.ts +0 -185
- package/src/model/connection/deployment/find.ts +0 -120
- package/src/model/connection/deployment/index.ts +0 -8
- package/src/model/connection/index.ts +0 -22
- package/src/model/connection/model/ConnectionModel.ts +0 -158
- package/src/model/connection/model/find.ts +0 -117
- package/src/model/connection/model/index.ts +0 -8
- package/src/model/connection/ops.ts +0 -276
- package/src/model/guards.ts +0 -77
- package/src/model/index.ts +0 -72
- package/src/model/types.ts +0 -67
- package/src/model/utils.ts +0 -66
- package/src/model/view/EdgeModel.ts +0 -121
- package/src/model/view/LikeC4ViewModel.ts +0 -361
- package/src/model/view/LikeC4ViewsFolder.ts +0 -151
- package/src/model/view/NodeModel.ts +0 -247
- package/src/theme/element.ts +0 -61
- package/src/theme/index.ts +0 -127
- package/src/theme/relationships.ts +0 -54
- package/src/types/RichText.ts +0 -205
- package/src/types/_aux.ts +0 -317
- package/src/types/_common.ts +0 -102
- package/src/types/const.ts +0 -34
- package/src/types/expression-model.ts +0 -294
- package/src/types/expression.ts +0 -313
- package/src/types/fqnRef.ts +0 -91
- package/src/types/geometry.ts +0 -159
- package/src/types/global.ts +0 -21
- package/src/types/index.ts +0 -44
- package/src/types/model-data.ts +0 -77
- package/src/types/model-deployment.ts +0 -78
- package/src/types/model-dump.ts +0 -79
- package/src/types/model-logical.ts +0 -126
- package/src/types/model-spec.ts +0 -88
- package/src/types/operators.ts +0 -156
- package/src/types/project.ts +0 -14
- package/src/types/scalar.ts +0 -162
- package/src/types/styles.ts +0 -122
- package/src/types/view-changes.ts +0 -32
- package/src/types/view-common.ts +0 -157
- package/src/types/view-computed.ts +0 -126
- package/src/types/view-layouted.ts +0 -94
- package/src/types/view-parsed.deployment.ts +0 -39
- package/src/types/view-parsed.dynamic.ts +0 -89
- package/src/types/view-parsed.element.ts +0 -65
- package/src/types/view.ts +0 -113
- package/src/utils/common-head.ts +0 -22
- package/src/utils/compare-natural.ts +0 -60
- package/src/utils/const.ts +0 -1
- package/src/utils/fqn.ts +0 -302
- package/src/utils/getOrCreate.ts +0 -8
- package/src/utils/guards.ts +0 -9
- package/src/utils/index.ts +0 -68
- package/src/utils/invariant.ts +0 -29
- package/src/utils/iterable/_types.ts +0 -5
- package/src/utils/iterable/filter.ts +0 -55
- package/src/utils/iterable/find.ts +0 -38
- package/src/utils/iterable/first.ts +0 -48
- package/src/utils/iterable/flat.ts +0 -17
- package/src/utils/iterable/head.ts +0 -22
- package/src/utils/iterable/index.ts +0 -15
- package/src/utils/iterable/map.ts +0 -40
- package/src/utils/iterable/reduce.ts +0 -24
- package/src/utils/iterable/some.ts +0 -36
- package/src/utils/iterable/to.ts +0 -19
- package/src/utils/iterable/unique.ts +0 -23
- package/src/utils/markdown/index.ts +0 -2
- package/src/utils/markdown/to-html.ts +0 -32
- package/src/utils/markdown/to-text.ts +0 -14
- package/src/utils/memoize-prop.ts +0 -30
- package/src/utils/mnemonist.ts +0 -9
- package/src/utils/object-hash.ts +0 -14
- package/src/utils/promises.ts +0 -24
- package/src/utils/relations.ts +0 -36
- package/src/utils/set.ts +0 -83
- package/src/utils/string-hash.ts +0 -16
package/src/types/RichText.ts
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { markdownToHtml, markdownToText, memoizeProp, nonexhaustive } from '../utils'
|
|
2
|
-
import type { MarkdownOrString } from './scalar'
|
|
3
|
-
|
|
4
|
-
const symb_text = Symbol.for('text')
|
|
5
|
-
const symb_html = Symbol.for('html')
|
|
6
|
-
|
|
7
|
-
const emptyTxt = ''
|
|
8
|
-
|
|
9
|
-
export interface RichTextEmpty {
|
|
10
|
-
readonly isEmpty: true
|
|
11
|
-
readonly isMarkdown: false
|
|
12
|
-
readonly nonEmpty: false
|
|
13
|
-
readonly $source: null
|
|
14
|
-
readonly text: null
|
|
15
|
-
readonly md: null
|
|
16
|
-
readonly html: null
|
|
17
|
-
equals(other: unknown): boolean
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface RichTextNonEmpty {
|
|
21
|
-
readonly isEmpty: false
|
|
22
|
-
readonly nonEmpty: true
|
|
23
|
-
readonly isMarkdown: boolean
|
|
24
|
-
readonly $source: MarkdownOrString
|
|
25
|
-
readonly text: string
|
|
26
|
-
readonly md: string
|
|
27
|
-
readonly html: string
|
|
28
|
-
equals(other: unknown): boolean
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export type RichTextOrEmpty = RichTextNonEmpty | RichTextEmpty
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* RichText is a class that represents a potentially markdown string.
|
|
35
|
-
* It can be either a plain text or a markdown.
|
|
36
|
-
* It is used to represent the content of a node or a link.
|
|
37
|
-
*/
|
|
38
|
-
export class RichText {
|
|
39
|
-
private static _cache = new WeakMap<MarkdownOrString, RichTextOrEmpty>()
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Creates and memoizes a RichText instance.
|
|
43
|
-
* @see ElementModel.description
|
|
44
|
-
* @example
|
|
45
|
-
*
|
|
46
|
-
* get description(): RichTextOrEmpty {
|
|
47
|
-
* return RichText.memoize(this, this.$element.description)
|
|
48
|
-
* }
|
|
49
|
-
*/
|
|
50
|
-
static memoize(obj: object, tag: symbol | string, source: MarkdownOrString | null | undefined): RichTextOrEmpty {
|
|
51
|
-
return memoizeProp(obj, tag, () => RichText.from(source))
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Creates a RichText instance from a source.
|
|
56
|
-
*/
|
|
57
|
-
static from(source: RichTextOrEmpty | MarkdownOrString | string | null | undefined): RichTextOrEmpty {
|
|
58
|
-
if (source === null || source === undefined || source === RichText.EMPTY) {
|
|
59
|
-
return RichText.EMPTY
|
|
60
|
-
}
|
|
61
|
-
if (source instanceof RichText) {
|
|
62
|
-
return source as RichTextOrEmpty
|
|
63
|
-
}
|
|
64
|
-
if (typeof source === 'string') {
|
|
65
|
-
if (source.trim() === emptyTxt) {
|
|
66
|
-
return RichText.EMPTY
|
|
67
|
-
}
|
|
68
|
-
return new RichText({ txt: source }) as RichTextOrEmpty
|
|
69
|
-
}
|
|
70
|
-
if ('isEmpty' in source && source.isEmpty) {
|
|
71
|
-
return RichText.EMPTY
|
|
72
|
-
}
|
|
73
|
-
if ('md' in source && source.md.trim() === emptyTxt) {
|
|
74
|
-
return RichText.EMPTY
|
|
75
|
-
}
|
|
76
|
-
if ('txt' in source && source.txt.trim() === emptyTxt) {
|
|
77
|
-
return RichText.EMPTY
|
|
78
|
-
}
|
|
79
|
-
const _source = source as MarkdownOrString
|
|
80
|
-
const cached = RichText._cache.get(_source)
|
|
81
|
-
if (cached) {
|
|
82
|
-
return cached
|
|
83
|
-
}
|
|
84
|
-
const rt = new RichText(_source) as RichTextOrEmpty
|
|
85
|
-
RichText._cache.set(_source, rt)
|
|
86
|
-
return rt
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* This is a workaround for the fact that we need instance of RichText for `instanceof` checks
|
|
91
|
-
* It is invalid inheritance (returning `null` from getters), and we cast to @see RichTextEmpty
|
|
92
|
-
*/
|
|
93
|
-
static EMPTY: RichTextEmpty = new class extends RichText {
|
|
94
|
-
public override readonly isEmpty: true = true
|
|
95
|
-
public override readonly nonEmpty: false = false
|
|
96
|
-
public override readonly isMarkdown: false = false
|
|
97
|
-
public override readonly $source: null = null
|
|
98
|
-
constructor() {
|
|
99
|
-
super({ txt: emptyTxt })
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
override get text(): any {
|
|
103
|
-
return null
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
override get md(): any {
|
|
107
|
-
return null
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
override get html(): any {
|
|
111
|
-
return null
|
|
112
|
-
}
|
|
113
|
-
}()
|
|
114
|
-
|
|
115
|
-
public readonly $source: Readonly<MarkdownOrString> | null
|
|
116
|
-
|
|
117
|
-
public readonly isEmpty: boolean
|
|
118
|
-
public readonly nonEmpty: boolean
|
|
119
|
-
public readonly isMarkdown: boolean
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Private constructor to prevent direct instantiation.
|
|
123
|
-
* Use {@link RichText.from} or {@link RichText.memoize} instead.
|
|
124
|
-
*/
|
|
125
|
-
private constructor(source: MarkdownOrString | string) {
|
|
126
|
-
this.isMarkdown = false
|
|
127
|
-
if (typeof source === 'string') {
|
|
128
|
-
this.$source = { txt: source }
|
|
129
|
-
this.isEmpty = source.trim() === emptyTxt
|
|
130
|
-
} else {
|
|
131
|
-
this.$source = source
|
|
132
|
-
this.isEmpty = true
|
|
133
|
-
if ('md' in source) {
|
|
134
|
-
this.isEmpty = source.md === emptyTxt
|
|
135
|
-
this.isMarkdown = true
|
|
136
|
-
} else {
|
|
137
|
-
this.isEmpty = source.txt === emptyTxt
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
this.nonEmpty = !this.isEmpty
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Returns the text content of the rich text.
|
|
145
|
-
* If the source is a string, it returns the string.
|
|
146
|
-
* If the source is a markdown, it returns the markdown.
|
|
147
|
-
*/
|
|
148
|
-
get text(): string {
|
|
149
|
-
if (this.isEmpty || this.$source === null) {
|
|
150
|
-
return emptyTxt
|
|
151
|
-
}
|
|
152
|
-
const source = this.$source
|
|
153
|
-
if ('txt' in source) {
|
|
154
|
-
return source.txt
|
|
155
|
-
}
|
|
156
|
-
return memoizeProp(this, symb_text, () => markdownToText(source.md!))
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Returns the markdown content of the rich text.
|
|
161
|
-
* If the source is a string, it returns the string.
|
|
162
|
-
* If the source is a markdown, it returns the markdown.
|
|
163
|
-
*/
|
|
164
|
-
get md(): string {
|
|
165
|
-
if (this.isEmpty || this.$source === null) {
|
|
166
|
-
return emptyTxt
|
|
167
|
-
}
|
|
168
|
-
const source = this.$source
|
|
169
|
-
if ('md' in source) {
|
|
170
|
-
return source.md
|
|
171
|
-
}
|
|
172
|
-
if ('txt' in source) {
|
|
173
|
-
return source.txt
|
|
174
|
-
}
|
|
175
|
-
nonexhaustive(source)
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Returns the html content of the rich text.
|
|
180
|
-
* If the source is a string, it returns the string.
|
|
181
|
-
* If the source is a markdown, it returns the HTML.
|
|
182
|
-
*/
|
|
183
|
-
get html(): string {
|
|
184
|
-
if (this.isEmpty || this.$source === null) {
|
|
185
|
-
return emptyTxt
|
|
186
|
-
}
|
|
187
|
-
const source = this.$source
|
|
188
|
-
if ('txt' in source) {
|
|
189
|
-
return source.txt
|
|
190
|
-
}
|
|
191
|
-
return memoizeProp(this, symb_html, () => markdownToHtml(source.md!))
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
equals(other: unknown): boolean {
|
|
195
|
-
if (this === other) return true
|
|
196
|
-
if (!(other instanceof RichText)) return false
|
|
197
|
-
if (this.isEmpty && other.isEmpty) return true
|
|
198
|
-
if (this.isEmpty !== other.isEmpty || this.isMarkdown !== other.isMarkdown) return false
|
|
199
|
-
|
|
200
|
-
if (this.isMarkdown) {
|
|
201
|
-
return this.$source?.md === other.$source?.md
|
|
202
|
-
}
|
|
203
|
-
return this.$source?.txt === other.$source?.txt
|
|
204
|
-
}
|
|
205
|
-
}
|
package/src/types/_aux.ts
DELETED
|
@@ -1,317 +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 WithDescriptionAndTech = {
|
|
259
|
-
// short summary (displayed in the diagram)
|
|
260
|
-
readonly summary?: scalar.MarkdownOrString | null
|
|
261
|
-
// long description (displayed in the details panel, or in the diagram if summary is not set)
|
|
262
|
-
readonly description?: scalar.MarkdownOrString | null
|
|
263
|
-
readonly technology?: string | null
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Returns summary if it is not null, otherwise returns description
|
|
268
|
-
*/
|
|
269
|
-
export function preferSummary(a: WithDescriptionAndTech): scalar.MarkdownOrString | null | undefined {
|
|
270
|
-
return a.summary ?? a.description
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Returns description if it is not null, otherwise returns summary
|
|
275
|
-
*/
|
|
276
|
-
export function preferDescription(a: WithDescriptionAndTech): scalar.MarkdownOrString | null | undefined {
|
|
277
|
-
return a.description ?? a.summary
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
export type WithTags<A extends Any> = {
|
|
281
|
-
readonly tags: Tags<A>
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
export type WithOptionalTags<A extends Any> = {
|
|
285
|
-
readonly tags?: Tags<A> | null
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
export type WithLinks = {
|
|
289
|
-
readonly links: readonly Link[]
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
export type WithOptionalLinks = {
|
|
293
|
-
readonly links?: readonly Link[] | null
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export type WithMetadata<A extends Any> = {
|
|
297
|
-
readonly metadata?: Metadata<A>
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
export type WithNotation = {
|
|
301
|
-
readonly notation?: string | null
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* @see {@link LiteralUnion} from type-fest (https://github.com/sindresorhus/type-fest/blob/main/source/literal-union.d.ts)
|
|
306
|
-
*/
|
|
307
|
-
export type OrString = string & Record<never, never>
|
|
308
|
-
|
|
309
|
-
export type LooseElementId<A extends Any> = Coalesce<A['ElementId']> | OrString
|
|
310
|
-
export type LooseDeploymentId<A extends Any> = Coalesce<A['DeploymentId']> | OrString
|
|
311
|
-
export type LooseViewId<A extends Any> = Coalesce<A['ViewId']> | OrString
|
|
312
|
-
export type LooseTag<A extends Any> = Coalesce<A['Tag']> | OrString
|
|
313
|
-
export type LooseTags<A extends Any> = readonly (Coalesce<A['Tag']> | OrString)[]
|
|
314
|
-
|
|
315
|
-
export type LooseElementKind<A extends Any> = Coalesce<A['ElementKind']> | OrString
|
|
316
|
-
export type LooseDeploymentKind<A extends Any> = Coalesce<A['DeploymentKind']> | OrString
|
|
317
|
-
export type LooseRelationKind<A extends Any> = Coalesce<A['RelationKind']> | OrString
|
package/src/types/_common.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { omitBy } from 'remeda'
|
|
2
|
-
import type {
|
|
3
|
-
Exact,
|
|
4
|
-
IsAny,
|
|
5
|
-
KeysOfUnion,
|
|
6
|
-
Simplify,
|
|
7
|
-
UnionToIntersection,
|
|
8
|
-
} from 'type-fest'
|
|
9
|
-
|
|
10
|
-
export type NonEmptyArray<T> = [T, ...T[]]
|
|
11
|
-
|
|
12
|
-
export type NonEmptyReadonlyArray<T> = readonly [T, ...T[]]
|
|
13
|
-
|
|
14
|
-
export type IterableContainer<T = unknown> = ReadonlyArray<T> | readonly []
|
|
15
|
-
|
|
16
|
-
export type ReorderedArray<T extends IterableContainer> = {
|
|
17
|
-
-readonly [P in keyof T]: T[number]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// dprint-ignore
|
|
21
|
-
export type KeysOf<T> = keyof T extends infer K extends string ? K : never
|
|
22
|
-
|
|
23
|
-
type AllNever<Expressions> = UnionToIntersection<
|
|
24
|
-
{
|
|
25
|
-
[Name in keyof Expressions]: {
|
|
26
|
-
-readonly [Key in keyof Expressions[Name]]?: never
|
|
27
|
-
}
|
|
28
|
-
}[keyof Expressions]
|
|
29
|
-
>
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @example
|
|
33
|
-
* ```ts
|
|
34
|
-
* type Variant1 = {
|
|
35
|
-
* a: string
|
|
36
|
-
* }
|
|
37
|
-
* type Variant2 = {
|
|
38
|
-
* b: number
|
|
39
|
-
* }
|
|
40
|
-
*
|
|
41
|
-
* type Variants = ExclusiveUnion<{
|
|
42
|
-
* Variant1: Variant1,
|
|
43
|
-
* Variant2: Variant2
|
|
44
|
-
* }>
|
|
45
|
-
*
|
|
46
|
-
* // Fail here
|
|
47
|
-
* const variant1: Variants = {
|
|
48
|
-
* a: 'one',
|
|
49
|
-
* b: 1
|
|
50
|
-
* }
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
export type ExclusiveUnion<Expressions, All = AllNever<Expressions>> = Expressions extends object ? {
|
|
54
|
-
[Name in keyof Expressions]: Simplify<Omit<All, keyof Expressions[Name]> & Expressions[Name]>
|
|
55
|
-
}[keyof Expressions]
|
|
56
|
-
: never
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Copy from https://github.com/remeda/remeda/blob/main/src/internal/types/NTuple.ts
|
|
60
|
-
* An array with *exactly* N elements in it.
|
|
61
|
-
*
|
|
62
|
-
* Only literal N values are supported. For very large N the type might result
|
|
63
|
-
* in a recurse depth error. For negative N the type would result in an infinite
|
|
64
|
-
* recursion. None of these have protections because this is an internal type!
|
|
65
|
-
*/
|
|
66
|
-
export type NTuple<
|
|
67
|
-
T,
|
|
68
|
-
N extends number,
|
|
69
|
-
Result extends Array<unknown> = [],
|
|
70
|
-
> = Result['length'] extends N ? Result : NTuple<T, N, [...Result, T]>
|
|
71
|
-
|
|
72
|
-
export type IteratorLike<T> = IteratorObject<T, BuiltinIteratorReturn, unknown>
|
|
73
|
-
|
|
74
|
-
export type Predicate<T> = (x: T) => boolean
|
|
75
|
-
|
|
76
|
-
export interface Link {
|
|
77
|
-
title?: string
|
|
78
|
-
// Value from Likec4 DSL
|
|
79
|
-
url: string
|
|
80
|
-
// Relative to workspace root (if url is relative),
|
|
81
|
-
relative?: string
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Coalesce `V` to a string if it is `any`
|
|
86
|
-
*/
|
|
87
|
-
export type Coalesce<V extends string, OrIfAny = string> = IsAny<V> extends true ? OrIfAny : V
|
|
88
|
-
|
|
89
|
-
type ExactObject<T, InputType = unknown> =
|
|
90
|
-
& {
|
|
91
|
-
[KeyType in keyof T]: undefined extends T[KeyType] ? T[KeyType] | undefined : T[KeyType]
|
|
92
|
-
}
|
|
93
|
-
& Record<Exclude<keyof InputType, KeysOfUnion<T>>, never>
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Allows only exact properties of `U` to be present in `T` and omits undefined values
|
|
97
|
-
*
|
|
98
|
-
* See {@link Exact} for more details (this version is non-deep)
|
|
99
|
-
*/
|
|
100
|
-
export function omitUndefined<Expected, T extends ExactObject<Expected, T>>(a: T): Expected {
|
|
101
|
-
return omitBy(a, v => v === undefined) as Expected
|
|
102
|
-
}
|
package/src/types/const.ts
DELETED
|
@@ -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
|