@likec4/core 1.31.0 → 1.32.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/README.md +407 -5
- package/dist/builder/index.d.mts +221 -42
- package/dist/builder/index.mjs +118 -65
- package/dist/compute-view/index.d.mts +23 -7
- package/dist/compute-view/index.mjs +11 -6
- package/dist/compute-view/relationships-view/index.d.mts +9 -7
- package/dist/compute-view/relationships-view/index.mjs +3 -2
- package/dist/index.d.mts +10 -14
- package/dist/index.mjs +9 -6
- package/dist/model/index.d.mts +173 -19
- package/dist/model/index.mjs +6 -1
- package/dist/shared/core.BaYE_r29.d.mts +258 -0
- package/dist/shared/core.Bk7wEZFG.mjs +276 -0
- package/dist/shared/core.BrCnZFTn.mjs +32 -0
- package/dist/shared/core.BuO4ncfY.d.mts +146 -0
- package/dist/shared/{core.Bq753SYD.mjs → core.CBpKAlhj.mjs} +2012 -4422
- package/dist/shared/core.CCWXGc6G.d.mts +920 -0
- package/dist/shared/core.CUYDgv2-.mjs +214 -0
- package/dist/shared/{core.Cu-UdkSl.mjs → core.CpXlRyE5.mjs} +7 -494
- package/dist/shared/{core.C-YXI-43.mjs → core.Cy9smucx.mjs} +3 -1
- package/dist/shared/core.CywrQs86.d.mts +31 -0
- package/dist/shared/core.DoK86JEe.mjs +518 -0
- package/dist/shared/core.Dpq3P3YJ.d.mts +1265 -0
- package/dist/shared/{core.D2830qgg.d.mts → core.Pf5I9o0e.d.mts} +1 -1
- package/dist/shared/core.cbA9VZ02.mjs +2681 -0
- package/dist/shared/{core.CQXU9DF7.mjs → core.rmvsy0n3.mjs} +23 -32
- package/dist/types/aux.d.mts +3 -0
- package/dist/types/aux.mjs +1 -0
- package/dist/types/index.d.mts +7 -45
- package/dist/types/index.mjs +130 -3
- package/dist/utils/index.d.mts +221 -53
- package/dist/utils/index.mjs +14 -10
- package/package.json +15 -7
- package/src/builder/Builder.deploymentModel.ts +82 -18
- package/src/builder/Builder.element.ts +40 -20
- package/src/builder/Builder.model.ts +66 -17
- package/src/builder/Builder.ts +168 -76
- package/src/builder/Builder.view-common.ts +35 -17
- package/src/builder/Builder.view-deployment.ts +25 -25
- package/src/builder/Builder.view-element.ts +13 -12
- package/src/builder/Builder.views.ts +12 -7
- package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +62 -34
- package/src/builder/__snapshots__/Builder-style2.compute-model.json5 +319 -0
- package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +45 -24
- package/src/builder/_types.ts +34 -27
- package/src/compute-view/compute-view.ts +31 -34
- package/src/compute-view/deployment-view/__test__/TestHelper.ts +27 -14
- package/src/compute-view/deployment-view/__test__/fixture.ts +15 -13
- package/src/compute-view/deployment-view/_types.ts +10 -10
- package/src/compute-view/deployment-view/clean-connections.ts +5 -7
- package/src/compute-view/deployment-view/compute.ts +16 -13
- package/src/compute-view/deployment-view/memory/memory.ts +5 -6
- package/src/compute-view/deployment-view/predicates/deploymentRefs.ts +4 -5
- package/src/compute-view/deployment-view/predicates/relation-direct.ts +25 -50
- package/src/compute-view/deployment-view/predicates/relation-in-out.ts +5 -7
- package/src/compute-view/deployment-view/predicates/relation-incoming.ts +7 -11
- package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +7 -10
- package/src/compute-view/deployment-view/predicates/utils.ts +37 -31
- package/src/compute-view/deployment-view/predicates/wildcard.ts +3 -2
- package/src/compute-view/deployment-view/stages/stage-final.ts +2 -2
- package/src/compute-view/deployment-view/stages/stage-include.ts +1 -1
- package/src/compute-view/deployment-view/utils.ts +79 -72
- package/src/compute-view/dynamic-view/__test__/fixture.ts +20 -11
- package/src/compute-view/dynamic-view/compute.ts +60 -53
- package/src/compute-view/element-view/__test__/TestHelper.ts +53 -29
- package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +26 -26
- package/src/compute-view/element-view/__test__/fixture.ts +134 -83
- package/src/compute-view/element-view/_types.ts +14 -19
- package/src/compute-view/element-view/clean-connections.ts +12 -8
- package/src/compute-view/element-view/compute.ts +61 -51
- package/src/compute-view/element-view/memory/NodeGroup.ts +8 -9
- package/src/compute-view/element-view/memory/memory.ts +22 -22
- package/src/compute-view/element-view/memory/stage-include.ts +5 -3
- package/src/compute-view/element-view/predicates/_utils.ts +18 -14
- package/src/compute-view/element-view/predicates/element-expand.ts +4 -5
- package/src/compute-view/element-view/predicates/element-kind-tag.ts +3 -4
- package/src/compute-view/element-view/predicates/element-ref.ts +3 -4
- package/src/compute-view/element-view/predicates/relation-direct.ts +16 -12
- package/src/compute-view/element-view/predicates/relation-in-out.ts +7 -8
- package/src/compute-view/element-view/predicates/relation-in.ts +19 -26
- package/src/compute-view/element-view/predicates/relation-out.ts +20 -21
- package/src/compute-view/element-view/predicates/wildcard.ts +3 -3
- package/src/compute-view/element-view/utils.ts +25 -23
- package/src/compute-view/index.ts +1 -1
- package/src/compute-view/memory/AbstractStageExclude.ts +3 -4
- package/src/compute-view/memory/AbstractStageInclude.ts +1 -1
- package/src/compute-view/memory/_types.ts +3 -2
- package/src/compute-view/relationships-view/_types.ts +3 -4
- package/src/compute-view/relationships-view/compute.ts +8 -11
- package/src/compute-view/relationships-view/layout.ts +6 -6
- package/src/compute-view/relationships-view/utils.ts +4 -4
- package/src/compute-view/utils/ancestorsOfNode.ts +7 -7
- package/src/compute-view/utils/applyCustomElementProperties.ts +16 -8
- package/src/compute-view/utils/applyCustomRelationProperties.ts +19 -9
- package/src/compute-view/utils/applyViewRuleStyles.ts +18 -10
- package/src/compute-view/utils/buildComputedNodes.ts +40 -40
- package/src/compute-view/utils/buildElementNotations.ts +14 -14
- package/src/compute-view/utils/elementExpressionToPredicate.ts +14 -15
- package/src/compute-view/utils/link-nodes-with-edges.ts +6 -4
- package/src/compute-view/utils/merge-props-from-relationships.ts +52 -20
- package/src/compute-view/utils/relationExpressionToPredicates.ts +19 -19
- package/src/compute-view/utils/resolve-extended-views.ts +8 -7
- package/src/compute-view/utils/resolve-global-rules.ts +31 -26
- package/src/compute-view/utils/topological-sort.ts +14 -14
- package/src/compute-view/utils/view-hash.ts +2 -2
- package/src/compute-view/utils/with-readable-edges.ts +9 -5
- package/src/index.ts +0 -32
- package/src/model/DeploymentElementModel.ts +171 -144
- package/src/model/DeploymentModel.ts +88 -65
- package/src/model/ElementModel.ts +85 -74
- package/src/model/LikeC4Model.ts +430 -241
- package/src/model/RelationModel.ts +63 -29
- package/src/model/__test__/fixture.ts +50 -36
- package/src/model/connection/Connection.ts +2 -2
- package/src/model/connection/deployment/DeploymentConnectionModel.ts +21 -24
- package/src/model/connection/deployment/find.ts +1 -1
- package/src/model/connection/model/ConnectionModel.ts +21 -20
- package/src/model/connection/model/find.ts +7 -7
- package/src/model/connection/ops.ts +6 -6
- package/src/model/guards.ts +66 -14
- package/src/model/index.ts +20 -7
- package/src/model/types.ts +41 -97
- package/src/model/view/EdgeModel.ts +47 -41
- package/src/model/view/LikeC4ViewModel.ts +130 -80
- package/src/model/view/NodeModel.ts +102 -96
- package/src/theme/element.ts +1 -1
- package/src/theme/index.ts +9 -9
- package/src/theme/relationships.ts +1 -1
- package/src/types/_common.ts +21 -15
- package/src/types/aux.ts +285 -0
- package/src/types/const.ts +34 -0
- package/src/types/expression-model.ts +292 -0
- package/src/types/expression.ts +311 -0
- package/src/types/fqnRef.ts +88 -0
- package/src/types/geometry.ts +131 -0
- package/src/types/global.ts +10 -8
- package/src/types/index.ts +39 -201
- package/src/types/model-data.ts +52 -84
- package/src/types/model-deployment.ts +87 -0
- package/src/types/model-dump.ts +72 -0
- package/src/types/model-logical.ts +111 -0
- package/src/types/model-spec.ts +81 -0
- package/src/types/operators.ts +51 -52
- package/src/types/scalar.ts +114 -0
- package/src/types/styles.ts +123 -0
- package/src/types/view-changes.ts +4 -5
- package/src/types/view-common.ts +157 -0
- package/src/types/view-computed.ts +113 -0
- package/src/types/view-layouted.ts +82 -0
- package/src/types/view-parsed.deployment.ts +40 -0
- package/src/types/view-parsed.dynamic.ts +78 -0
- package/src/types/view-parsed.element.ts +65 -0
- package/src/types/view.ts +122 -542
- package/src/utils/compare-natural.ts +43 -1
- package/src/utils/getOrCreate.ts +0 -34
- package/src/utils/index.ts +7 -12
- package/src/utils/iterable/filter.ts +1 -1
- package/src/utils/iterable/find.ts +3 -1
- package/src/utils/iterable/head.ts +22 -0
- package/src/utils/iterable/index.ts +1 -0
- package/src/utils/iterable/map.ts +1 -1
- package/src/utils/iterable/reduce.ts +1 -1
- package/src/utils/iterable/some.ts +1 -1
- package/src/utils/memoize-prop.ts +30 -0
- package/src/utils/object-hash.ts +1 -1
- package/src/utils/relations.ts +14 -11
- package/src/utils/string-hash.ts +1 -1
- package/dist/shared/core.CQDU11hR.d.mts +0 -753
- package/dist/shared/core.DJvmfnEi.d.mts +0 -1153
- package/dist/shared/core.DgfwjBtu.mjs +0 -495
- package/dist/shared/core.Dx7siloV.d.mts +0 -146
- package/dist/shared/core.SjLhMA7a.d.mts +0 -62
- package/src/builder/__snapshots__/Builder.spec.ts.snap +0 -374
- package/src/compute-view/element-view/predicates.ts +0 -520
- package/src/compute-view/utils/uniqueTags.ts +0 -21
- package/src/types/deployments.ts +0 -170
- package/src/types/element.ts +0 -109
- package/src/types/expression-v2-model.ts +0 -314
- package/src/types/expression-v2.ts +0 -392
- package/src/types/overview-graph.ts +0 -43
- package/src/types/relation.ts +0 -61
- package/src/types/scalars.ts +0 -39
- package/src/types/theme.ts +0 -82
- package/src/types/view-notation.ts +0 -9
- package/src/utils/graphlib.ts +0 -10
- /package/src/{errors/index.ts → utils/invariant.ts} +0 -0
package/src/theme/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { generateColors } from '@mantine/colors-generator'
|
|
2
|
-
import type {
|
|
2
|
+
import type { ColorLiteral, HexColor, LikeC4Theme, ThemeColorValues } from '../types'
|
|
3
3
|
import { ElementColors } from './element'
|
|
4
4
|
import { RelationshipColors } from './relationships'
|
|
5
5
|
|
|
@@ -46,21 +46,21 @@ export const defaultTheme: LikeC4Theme = {
|
|
|
46
46
|
},
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export function computeColorValues(color:
|
|
49
|
+
export function computeColorValues(color: ColorLiteral): ThemeColorValues {
|
|
50
50
|
if (color.match(/^#([0-9a-f]{3}){1,2}$/i)) {
|
|
51
51
|
const colors = generateColors(color)
|
|
52
52
|
|
|
53
53
|
return {
|
|
54
54
|
elements: {
|
|
55
|
-
fill: colors[6] as
|
|
56
|
-
stroke: colors[7] as
|
|
57
|
-
hiContrast: colors[0] as
|
|
58
|
-
loContrast: colors[1] as
|
|
55
|
+
fill: colors[6] as HexColor,
|
|
56
|
+
stroke: colors[7] as HexColor,
|
|
57
|
+
hiContrast: colors[0] as HexColor,
|
|
58
|
+
loContrast: colors[1] as HexColor,
|
|
59
59
|
},
|
|
60
60
|
relationships: {
|
|
61
|
-
lineColor: colors[4] as
|
|
62
|
-
labelColor: colors[3] as
|
|
63
|
-
labelBgColor: colors[9] as
|
|
61
|
+
lineColor: colors[4] as HexColor,
|
|
62
|
+
labelColor: colors[3] as HexColor,
|
|
63
|
+
labelBgColor: colors[9] as HexColor,
|
|
64
64
|
},
|
|
65
65
|
}
|
|
66
66
|
} else {
|
package/src/types/_common.ts
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IsAny, Simplify, UnionToIntersection } from 'type-fest'
|
|
2
2
|
|
|
3
3
|
export type NonEmptyArray<T> = [T, ...T[]]
|
|
4
4
|
|
|
5
5
|
export type NonEmptyReadonlyArray<T> = readonly [T, ...T[]]
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export type Point = readonly [x: number, y: number]
|
|
10
|
-
|
|
11
|
-
export interface XYPoint {
|
|
12
|
-
x: number
|
|
13
|
-
y: number
|
|
14
|
-
}
|
|
15
|
-
|
|
7
|
+
// dprint-ignore
|
|
16
8
|
export type KeysOf<T> = keyof T extends infer K extends string ? K : never
|
|
17
9
|
|
|
18
10
|
type AllNever<Expressions> = UnionToIntersection<
|
|
@@ -25,6 +17,7 @@ type AllNever<Expressions> = UnionToIntersection<
|
|
|
25
17
|
|
|
26
18
|
/**
|
|
27
19
|
* @example
|
|
20
|
+
* ```ts
|
|
28
21
|
* type Variant1 = {
|
|
29
22
|
* a: string
|
|
30
23
|
* }
|
|
@@ -37,17 +30,17 @@ type AllNever<Expressions> = UnionToIntersection<
|
|
|
37
30
|
* Variant2: Variant2
|
|
38
31
|
* }>
|
|
39
32
|
*
|
|
40
|
-
* Fail here
|
|
33
|
+
* // Fail here
|
|
41
34
|
* const variant1: Variants = {
|
|
42
35
|
* a: 'one',
|
|
43
36
|
* b: 1
|
|
44
37
|
* }
|
|
38
|
+
* ```
|
|
45
39
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
[Name in keyof Expressions]: Simplify<Omit<AllNever<Expressions>, keyof Expressions[Name]> & Expressions[Name]>
|
|
40
|
+
export type ExclusiveUnion<Expressions, All = AllNever<Expressions>> = Expressions extends object ? {
|
|
41
|
+
[Name in keyof Expressions]: Simplify<Omit<All, keyof Expressions[Name]> & Expressions[Name]>
|
|
49
42
|
}[keyof Expressions]
|
|
50
|
-
:
|
|
43
|
+
: never
|
|
51
44
|
|
|
52
45
|
/**
|
|
53
46
|
* Copy from https://github.com/remeda/remeda/blob/main/src/internal/types/NTuple.ts
|
|
@@ -66,3 +59,16 @@ export type NTuple<
|
|
|
66
59
|
export type IteratorLike<T> = IteratorObject<T, BuiltinIteratorReturn>
|
|
67
60
|
|
|
68
61
|
export type Predicate<T> = (x: T) => boolean
|
|
62
|
+
|
|
63
|
+
export interface Link {
|
|
64
|
+
title?: string
|
|
65
|
+
// Value from Likec4 DSL
|
|
66
|
+
url: string
|
|
67
|
+
// Relative to workspace root (if url is relative),
|
|
68
|
+
relative?: string
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Coalesce `V` to a string if it is `any`
|
|
73
|
+
*/
|
|
74
|
+
export type Coalesce<V extends string, OrIfAny = string> = IsAny<V> extends true ? OrIfAny : V
|
package/src/types/aux.ts
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
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
|
+
/**
|
|
153
|
+
* Element FQN from Aux as branded type
|
|
154
|
+
*/
|
|
155
|
+
export type Fqn<A> = A extends infer T extends Any ? scalar.Fqn<ElementId<T>> : never
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Element FQN from Aux as a literal union
|
|
159
|
+
*/
|
|
160
|
+
export type ElementId<A> = A extends infer T extends Any ? Coalesce<T['ElementId']> : never
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Deployment FQN from Aux as branded type
|
|
164
|
+
*/
|
|
165
|
+
export type DeploymentFqn<A> = A extends infer T extends Any ? scalar.DeploymentFqn<DeploymentId<T>> : never
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Deployment FQN from Aux as a literal union
|
|
169
|
+
* @alias {@link DeploymentFqn}
|
|
170
|
+
*/
|
|
171
|
+
export type DeploymentId<A> = A extends infer T extends Any ? Coalesce<T['DeploymentId']> : never
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* View identifier from Aux as a literal union
|
|
175
|
+
*/
|
|
176
|
+
export type ViewId<A> = A extends infer T extends Any ? Coalesce<T['ViewId']> : never
|
|
177
|
+
|
|
178
|
+
export type RelationId = scalar.RelationId
|
|
179
|
+
export type NodeId = scalar.NodeId
|
|
180
|
+
export type EdgeId = scalar.EdgeId
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* ElementKind from Aux as a literal union
|
|
184
|
+
*/
|
|
185
|
+
export type ElementKind<A> = A extends infer T extends Any ? Coalesce<T['ElementKind']> : never
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* DeploymentKind from Aux as a literal union
|
|
189
|
+
*/
|
|
190
|
+
export type DeploymentKind<A> = A extends infer T extends Any ? Coalesce<T['DeploymentKind']> : never
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* RelationKind from Aux as a literal union
|
|
194
|
+
*/
|
|
195
|
+
export type RelationKind<A> = A extends infer T extends Any ? Coalesce<T['RelationKind']> : never
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Tags from Aux as a literal union
|
|
199
|
+
*/
|
|
200
|
+
export type Tag<A> = A extends infer T extends Any ? Coalesce<T['Tag']> : never
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Array of tags from Aux
|
|
204
|
+
*/
|
|
205
|
+
export type Tags<A extends Any> = readonly Tag<A>[]
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Metadata key from Aux
|
|
209
|
+
*/
|
|
210
|
+
export type MetadataKey<A> = A extends infer T extends Any ? Coalesce<T['MetadataKey']> : never
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Metadata object from Aux
|
|
214
|
+
*/
|
|
215
|
+
export type Metadata<A extends Any> =
|
|
216
|
+
// dprint-ignore
|
|
217
|
+
IsNever<A['MetadataKey']> extends true
|
|
218
|
+
? never
|
|
219
|
+
: IsLiteral<A['MetadataKey']> extends true
|
|
220
|
+
? {
|
|
221
|
+
[key in Coalesce<A['MetadataKey']>]?: string
|
|
222
|
+
}
|
|
223
|
+
: Record<string, string>
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* All known kinds from Aux as a literal union.
|
|
227
|
+
*/
|
|
228
|
+
export type AllKinds<A> = ElementKind<A> | DeploymentKind<A> | RelationKind<A>
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Specification from Aux
|
|
232
|
+
*/
|
|
233
|
+
export type Spec<A> = A extends Aux<any, any, any, any, any, infer S> ? S : never
|
|
234
|
+
|
|
235
|
+
export type StrictProjectId<A> = A extends infer T extends Any ? scalar.ProjectId<ProjectId<T>> : never
|
|
236
|
+
|
|
237
|
+
export type {
|
|
238
|
+
DeploymentFqn as StrictDeploymentFqn,
|
|
239
|
+
Fqn as StrictFqn,
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export type StrictViewId<A> = A extends infer T extends Any ? scalar.ViewId<ViewId<T>> : never
|
|
243
|
+
|
|
244
|
+
export type StrictTag<A> = A extends infer T extends Any ? scalar.Tag<Tag<T>> : never
|
|
245
|
+
|
|
246
|
+
// dprint-ignore
|
|
247
|
+
export type StrictElementKind<A> = A extends infer T extends Any ? scalar.ElementKind<ElementKind<T>> : never
|
|
248
|
+
export type StrictDeploymentKind<A> = A extends infer T extends Any ? scalar.DeploymentKind<DeploymentKind<T>>
|
|
249
|
+
: never
|
|
250
|
+
export type StrictRelationKind<A> = A extends infer T extends Any ? scalar.RelationshipKind<RelationKind<T>> : never
|
|
251
|
+
|
|
252
|
+
export type WithTags<A extends Any> = {
|
|
253
|
+
readonly tags: Tags<A>
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export type WithOptionalTags<A extends Any> = {
|
|
257
|
+
readonly tags?: Tags<A> | null
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export type WithLinks = {
|
|
261
|
+
readonly links: readonly Link[]
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export type WithOptionalLinks = {
|
|
265
|
+
readonly links?: readonly Link[] | null
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export type WithMetadata<A extends Any> = {
|
|
269
|
+
readonly metadata?: Metadata<A>
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* @see {@link LiteralUnion} from type-fest (https://github.com/sindresorhus/type-fest/blob/main/source/literal-union.d.ts)
|
|
274
|
+
*/
|
|
275
|
+
export type OrString = string & Record<never, never>
|
|
276
|
+
|
|
277
|
+
export type LooseElementId<A extends Any> = Coalesce<A['ElementId']> | OrString
|
|
278
|
+
export type LooseDeploymentId<A extends Any> = Coalesce<A['DeploymentId']> | OrString
|
|
279
|
+
export type LooseViewId<A extends Any> = Coalesce<A['ViewId']> | OrString
|
|
280
|
+
export type LooseTag<A extends Any> = Coalesce<A['Tag']> | OrString
|
|
281
|
+
export type LooseTags<A extends Any> = readonly (Coalesce<A['Tag']> | OrString)[]
|
|
282
|
+
|
|
283
|
+
export type LooseElementKind<A extends Any> = Coalesce<A['ElementKind']> | OrString
|
|
284
|
+
export type LooseDeploymentKind<A extends Any> = Coalesce<A['DeploymentKind']> | OrString
|
|
285
|
+
export type LooseRelationKind<A extends Any> = Coalesce<A['RelationKind']> | OrString
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|