@likec4/core 1.31.0 → 1.32.1
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.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.DXzRBkuI.d.mts +1264 -0
- package/dist/shared/core.DoK86JEe.mjs +518 -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/shared/core.znRaUX_A.d.mts +920 -0
- 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 +16 -8
- 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/{theme.ts → styles.ts} +55 -15
- 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/view-notation.ts +0 -9
- package/src/utils/graphlib.ts +0 -10
- /package/src/{errors/index.ts → utils/invariant.ts} +0 -0
package/src/types/deployments.ts
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import type { MergeExclusive, Simplify, Tagged } from 'type-fest'
|
|
2
|
-
import type { NonEmptyArray } from './_common'
|
|
3
|
-
import type { ElementShape, ElementStyle, Link } from './element'
|
|
4
|
-
import type { AbstractRelation, RelationId } from './relation'
|
|
5
|
-
import type { Fqn, IconUrl, Tag } from './scalars'
|
|
6
|
-
import type { Color } from './theme'
|
|
7
|
-
|
|
8
|
-
export type DeploymentNodeKind<Kinds extends string = string> = Tagged<Kinds, 'DeploymentNodeKind'>
|
|
9
|
-
|
|
10
|
-
export type DeploymentElementStyle = ElementStyle & {
|
|
11
|
-
readonly icon?: IconUrl
|
|
12
|
-
readonly shape?: ElementShape
|
|
13
|
-
readonly color?: Color
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface DeploymentNodeKindSpecification {
|
|
17
|
-
readonly technology?: string
|
|
18
|
-
readonly notation?: string
|
|
19
|
-
readonly style: DeploymentElementStyle
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface DeploymentNode {
|
|
23
|
-
// Full-qualified-name for Deployment model
|
|
24
|
-
readonly id: Fqn
|
|
25
|
-
readonly kind: DeploymentNodeKind
|
|
26
|
-
readonly title: string
|
|
27
|
-
readonly description?: string | null
|
|
28
|
-
readonly technology?: string | null
|
|
29
|
-
readonly tags?: NonEmptyArray<Tag> | null
|
|
30
|
-
readonly links?: NonEmptyArray<Link> | null
|
|
31
|
-
readonly style?: DeploymentElementStyle
|
|
32
|
-
readonly notation?: string
|
|
33
|
-
readonly metadata?: Record<string, string>
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface DeployedInstance {
|
|
37
|
-
/**
|
|
38
|
-
* Format: `<DeploymentNode Fqn>.<Instance Id>`
|
|
39
|
-
* i.e parent fqn is deployment target
|
|
40
|
-
*/
|
|
41
|
-
readonly id: Fqn
|
|
42
|
-
readonly element: Fqn
|
|
43
|
-
readonly title?: string
|
|
44
|
-
readonly description?: string | null
|
|
45
|
-
readonly technology?: string | null
|
|
46
|
-
readonly tags?: NonEmptyArray<Tag> | null
|
|
47
|
-
readonly links?: NonEmptyArray<Link> | null
|
|
48
|
-
readonly style?: DeploymentElementStyle
|
|
49
|
-
readonly notation?: string
|
|
50
|
-
readonly metadata?: Record<string, string>
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export type DeploymentElement = Simplify<MergeExclusive<DeploymentNode, DeployedInstance>>
|
|
54
|
-
|
|
55
|
-
export namespace DeploymentElement {
|
|
56
|
-
export const isDeploymentNode = (el: DeploymentElement): el is DeploymentNode => {
|
|
57
|
-
return 'kind' in el && !('element' in el)
|
|
58
|
-
}
|
|
59
|
-
export const isInstance = (el: DeploymentElement): el is DeployedInstance => {
|
|
60
|
-
return 'element' in el && !('kind' in el)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export type PredicateSelector =
|
|
65
|
-
| 'children' // ele.*
|
|
66
|
-
| 'expanded' // ele._
|
|
67
|
-
| 'descendants' // ele.**
|
|
68
|
-
|
|
69
|
-
export interface DeploymentRef {
|
|
70
|
-
// Reference to DeploymentNode or DeployedInstance
|
|
71
|
-
readonly id: Fqn
|
|
72
|
-
// Reference to element within DeployedInstance
|
|
73
|
-
readonly element?: Fqn
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* NOTE:
|
|
78
|
-
*/
|
|
79
|
-
export interface DeploymentRelation extends AbstractRelation {
|
|
80
|
-
readonly id: RelationId
|
|
81
|
-
readonly source: DeploymentRef
|
|
82
|
-
readonly target: DeploymentRef
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// export namespace DeploymentRelationExpression {
|
|
86
|
-
// // type LogicalRefEndpoint = {
|
|
87
|
-
// // logicalRef: ElementRefExpr
|
|
88
|
-
// // }
|
|
89
|
-
// // export type DirectEndpoint = ExclusiveUnion<{
|
|
90
|
-
// // DeploymentElementExpression: DeploymentElementExpression
|
|
91
|
-
// // Logical: LogicalRefEndpoint
|
|
92
|
-
// // }>
|
|
93
|
-
|
|
94
|
-
// // export const isLogicalEndpoint = (expr: DirectEndpoint): expr is LogicalRefEndpoint => {
|
|
95
|
-
// // return 'logicalRef' in expr
|
|
96
|
-
// // }
|
|
97
|
-
|
|
98
|
-
// export type Direct = {
|
|
99
|
-
// source: FqnExpression.Element
|
|
100
|
-
// target: FqnExpression.Element
|
|
101
|
-
// isBidirectional?: boolean
|
|
102
|
-
// }
|
|
103
|
-
// export const isDirect = (expr: DeploymentExpression): expr is Direct => {
|
|
104
|
-
// return 'source' in expr && 'target' in expr
|
|
105
|
-
// }
|
|
106
|
-
// export type Incoming = {
|
|
107
|
-
// incoming: FqnExpression.Element
|
|
108
|
-
// }
|
|
109
|
-
// export const isIncoming = (expr: DeploymentExpression): expr is Incoming => {
|
|
110
|
-
// return 'incoming' in expr
|
|
111
|
-
// }
|
|
112
|
-
// export type Outgoing = {
|
|
113
|
-
// outgoing: FqnExpression.Element
|
|
114
|
-
// }
|
|
115
|
-
// export const isOutgoing = (expr: DeploymentExpression): expr is Outgoing => {
|
|
116
|
-
// return 'outgoing' in expr
|
|
117
|
-
// }
|
|
118
|
-
// export type InOut = {
|
|
119
|
-
// inout: FqnExpression.Element
|
|
120
|
-
// }
|
|
121
|
-
// export const isInOut = (expr: DeploymentExpression): expr is InOut => {
|
|
122
|
-
// return 'inout' in expr
|
|
123
|
-
// }
|
|
124
|
-
// }
|
|
125
|
-
|
|
126
|
-
// export type DeploymentRelationExpression = ExclusiveUnion<{
|
|
127
|
-
// Direct: DeploymentRelationExpression.Direct
|
|
128
|
-
// Incoming: DeploymentRelationExpression.Incoming
|
|
129
|
-
// Outgoing: DeploymentRelationExpression.Outgoing
|
|
130
|
-
// InOut: DeploymentRelationExpression.InOut
|
|
131
|
-
// }>
|
|
132
|
-
|
|
133
|
-
// export namespace DeploymentElementExpression {
|
|
134
|
-
// export type Ref = {
|
|
135
|
-
// ref: DeploymentRef
|
|
136
|
-
// selector?: PredicateSelector
|
|
137
|
-
// }
|
|
138
|
-
// export const isRef = (expr: DeploymentExpression): expr is Ref => {
|
|
139
|
-
// return 'ref' in expr
|
|
140
|
-
// }
|
|
141
|
-
|
|
142
|
-
// export type Wildcard = {
|
|
143
|
-
// wildcard: true
|
|
144
|
-
// }
|
|
145
|
-
// export const isWildcard = (expr: DeploymentExpression): expr is Wildcard => {
|
|
146
|
-
// return 'wildcard' in expr && expr.wildcard === true
|
|
147
|
-
// }
|
|
148
|
-
// }
|
|
149
|
-
|
|
150
|
-
// export type DeploymentElementExpression = ExclusiveUnion<{
|
|
151
|
-
// DeploymentRef: DeploymentElementExpression.Ref
|
|
152
|
-
// Wildcard: DeploymentElementExpression.Wildcard
|
|
153
|
-
// }>
|
|
154
|
-
|
|
155
|
-
// export type DeploymentExpression = ExclusiveUnion<{
|
|
156
|
-
// Element: DeploymentElementExpression
|
|
157
|
-
// Relation: DeploymentRelationExpression
|
|
158
|
-
// }>
|
|
159
|
-
|
|
160
|
-
// export namespace DeploymentExpression {
|
|
161
|
-
// export type Element = DeploymentElementExpression
|
|
162
|
-
// export type Relation = DeploymentRelationExpression
|
|
163
|
-
|
|
164
|
-
// export const isElement = (expr: DeploymentExpression): expr is DeploymentElementExpression => {
|
|
165
|
-
// return DeploymentElementExpression.isRef(expr) || DeploymentElementExpression.isWildcard(expr)
|
|
166
|
-
// }
|
|
167
|
-
// export const isRelation = (expr: DeploymentExpression): expr is DeploymentRelationExpression => {
|
|
168
|
-
// return !DeploymentExpression.isElement(expr)
|
|
169
|
-
// }
|
|
170
|
-
// }
|
package/src/types/element.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import type { Tagged, TupleToUnion } from 'type-fest'
|
|
2
|
-
import type { NonEmptyArray } from './_common'
|
|
3
|
-
import type { Fqn, IconUrl, Tag } from './scalars'
|
|
4
|
-
import type { Color, ShapeSize, SpacingSize, TextSize, ThemeColor } from './theme'
|
|
5
|
-
|
|
6
|
-
export const BorderStyles = ['solid', 'dashed', 'dotted', 'none'] as const
|
|
7
|
-
|
|
8
|
-
export type BorderStyle = TupleToUnion<typeof BorderStyles>
|
|
9
|
-
|
|
10
|
-
export type ElementKind<Kinds extends string = string> = Tagged<Kinds, 'ElementKind'>
|
|
11
|
-
export namespace ElementKind {
|
|
12
|
-
export const Group = '@group' as ElementKind
|
|
13
|
-
}
|
|
14
|
-
export const ElementShapes = [
|
|
15
|
-
'rectangle',
|
|
16
|
-
'person',
|
|
17
|
-
'browser',
|
|
18
|
-
'mobile',
|
|
19
|
-
'cylinder',
|
|
20
|
-
'storage',
|
|
21
|
-
'queue',
|
|
22
|
-
] as const
|
|
23
|
-
|
|
24
|
-
export type ElementShape = TupleToUnion<typeof ElementShapes>
|
|
25
|
-
export const DefaultThemeColor: ThemeColor = 'primary'
|
|
26
|
-
export const DefaultElementShape: ElementShape = 'rectangle'
|
|
27
|
-
export const DefaultShapeSize: ShapeSize = 'md'
|
|
28
|
-
export const DefaultPaddingSize: SpacingSize = 'md'
|
|
29
|
-
export const DefaultTextSize: TextSize = 'md'
|
|
30
|
-
|
|
31
|
-
export interface ElementStyle {
|
|
32
|
-
readonly border?: BorderStyle
|
|
33
|
-
/**
|
|
34
|
-
* In percentage 0-100, 0 is fully transparent
|
|
35
|
-
*
|
|
36
|
-
* @default 100
|
|
37
|
-
*/
|
|
38
|
-
readonly opacity?: number
|
|
39
|
-
/**
|
|
40
|
-
* If true, the element is rendered as multiple shapes
|
|
41
|
-
* @default false
|
|
42
|
-
*/
|
|
43
|
-
readonly multiple?: boolean
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Shape size
|
|
47
|
-
*
|
|
48
|
-
* @default 'md'
|
|
49
|
-
*/
|
|
50
|
-
readonly size?: ShapeSize
|
|
51
|
-
|
|
52
|
-
readonly padding?: SpacingSize
|
|
53
|
-
|
|
54
|
-
readonly textSize?: TextSize
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface TagSpec {
|
|
58
|
-
readonly id: Tag
|
|
59
|
-
readonly style: ElementStyle
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface Link {
|
|
63
|
-
readonly title?: string
|
|
64
|
-
// Value from Likec4 DSL
|
|
65
|
-
readonly url: string
|
|
66
|
-
// Relative to workspace root (if url is relative),
|
|
67
|
-
readonly relative?: string
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface TypedElement<
|
|
71
|
-
Ids extends string,
|
|
72
|
-
Kinds extends string,
|
|
73
|
-
Tags extends string,
|
|
74
|
-
MetadataKeys extends string = never,
|
|
75
|
-
> {
|
|
76
|
-
readonly id: Fqn<Ids>
|
|
77
|
-
readonly kind: ElementKind<Kinds>
|
|
78
|
-
readonly title: string
|
|
79
|
-
readonly description: string | null
|
|
80
|
-
readonly technology: string | null
|
|
81
|
-
readonly tags: NonEmptyArray<Tag<Tags>> | null
|
|
82
|
-
readonly links: NonEmptyArray<Link> | null
|
|
83
|
-
readonly icon?: IconUrl
|
|
84
|
-
readonly shape?: ElementShape
|
|
85
|
-
readonly color?: Color
|
|
86
|
-
readonly style?: ElementStyle
|
|
87
|
-
readonly notation?: string
|
|
88
|
-
readonly metadata?: Record<MetadataKeys, string>
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface Element extends TypedElement<string, string, string, string> {
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface ElementKindSpecificationStyle {
|
|
95
|
-
shape?: ElementShape
|
|
96
|
-
icon?: IconUrl
|
|
97
|
-
color?: Color
|
|
98
|
-
border?: BorderStyle
|
|
99
|
-
opacity?: number
|
|
100
|
-
size?: ShapeSize
|
|
101
|
-
padding?: SpacingSize
|
|
102
|
-
textSize?: TextSize
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export interface ElementKindSpecification {
|
|
106
|
-
readonly technology?: string
|
|
107
|
-
readonly notation?: string
|
|
108
|
-
readonly style: ElementKindSpecificationStyle
|
|
109
|
-
}
|
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
import type { ExclusiveUnion } from './_common'
|
|
2
|
-
import type { PredicateSelector } from './deployments'
|
|
3
|
-
import type { BorderStyle, ElementKind, ElementShape } from './element'
|
|
4
|
-
import type { WhereOperator } from './operators'
|
|
5
|
-
import type { RelationshipArrowType, RelationshipLineType } from './relation'
|
|
6
|
-
import { type Fqn, type IconUrl, type ProjectId, type Tag, GlobalFqn } from './scalars'
|
|
7
|
-
import type { Color, ShapeSize } from './theme'
|
|
8
|
-
import type { ViewId } from './view'
|
|
9
|
-
|
|
10
|
-
export namespace ModelLayer {
|
|
11
|
-
export namespace FqnRef {
|
|
12
|
-
/**
|
|
13
|
-
* Reference to logical model element
|
|
14
|
-
*/
|
|
15
|
-
export type ModelRef<F = Fqn> = {
|
|
16
|
-
model: F
|
|
17
|
-
}
|
|
18
|
-
export const isModelRef = (ref: FqnRef): ref is ModelRef => {
|
|
19
|
-
return 'model' in ref && !('project' in ref)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Reference to imported logical model element
|
|
24
|
-
*/
|
|
25
|
-
export type ImportRef<F = Fqn> = {
|
|
26
|
-
project: ProjectId
|
|
27
|
-
model: F
|
|
28
|
-
}
|
|
29
|
-
export const isImportRef = (ref: FqnRef): ref is ImportRef => {
|
|
30
|
-
return 'project' in ref && 'model' in ref
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const toFqn = (ref: FqnRef): Fqn => {
|
|
34
|
-
if (isImportRef(ref)) {
|
|
35
|
-
return GlobalFqn(ref.project, ref.model)
|
|
36
|
-
}
|
|
37
|
-
if (isModelRef(ref)) {
|
|
38
|
-
return ref.model
|
|
39
|
-
}
|
|
40
|
-
throw new Error('Expected FqnRef.ModelRef or FqnRef.ImportRef')
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export type FqnRef<M = Fqn> = ExclusiveUnion<{
|
|
45
|
-
ModelRef: FqnRef.ModelRef<M>
|
|
46
|
-
ImportRef: FqnRef.ImportRef<M>
|
|
47
|
-
}>
|
|
48
|
-
|
|
49
|
-
export namespace FqnExpr {
|
|
50
|
-
export type Wildcard = {
|
|
51
|
-
wildcard: true
|
|
52
|
-
}
|
|
53
|
-
export const isWildcard = (expr: Expression): expr is FqnExpr.Wildcard => {
|
|
54
|
-
return 'wildcard' in expr && expr.wildcard === true
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export type ModelRef<M = Fqn> = {
|
|
58
|
-
ref: FqnRef.ModelRef<M> | FqnRef.ImportRef<M>
|
|
59
|
-
selector?: PredicateSelector
|
|
60
|
-
}
|
|
61
|
-
export const isModelRef = (ref: Expression): ref is FqnExpr.ModelRef => {
|
|
62
|
-
return 'ref' in ref
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export type ElementKindExpr = {
|
|
66
|
-
elementKind: ElementKind
|
|
67
|
-
isEqual: boolean
|
|
68
|
-
}
|
|
69
|
-
export function isElementKindExpr(expr: Expression): expr is ElementKindExpr {
|
|
70
|
-
return 'elementKind' in expr && 'isEqual' in expr
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export type ElementTagExpr = {
|
|
74
|
-
elementTag: Tag
|
|
75
|
-
isEqual: boolean
|
|
76
|
-
}
|
|
77
|
-
export function isElementTagExpr(expr: Expression): expr is ElementTagExpr {
|
|
78
|
-
return 'elementTag' in expr && 'isEqual' in expr
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export type NonWildcard<M = Fqn> = ExclusiveUnion<{
|
|
82
|
-
ModelRef: ModelRef<M>
|
|
83
|
-
ElementKind: ElementKindExpr
|
|
84
|
-
ElementTag: ElementTagExpr
|
|
85
|
-
}>
|
|
86
|
-
|
|
87
|
-
export type Where<M = Fqn> = {
|
|
88
|
-
where: {
|
|
89
|
-
expr: ExclusiveUnion<{
|
|
90
|
-
Wildcard: Wildcard
|
|
91
|
-
ModelRef: ModelRef<M>
|
|
92
|
-
ElementKind: ElementKindExpr
|
|
93
|
-
ElementTag: ElementTagExpr
|
|
94
|
-
}>
|
|
95
|
-
condition: WhereOperator<string, string>
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export const isWhere = (expr: Expression): expr is FqnExpr.Where => {
|
|
100
|
-
return 'where' in expr && is(expr.where.expr)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export type Custom<M = Fqn> = {
|
|
104
|
-
custom: {
|
|
105
|
-
expr: FqnExprOrWhere<M>
|
|
106
|
-
title?: string
|
|
107
|
-
description?: string
|
|
108
|
-
technology?: string
|
|
109
|
-
notation?: string
|
|
110
|
-
shape?: ElementShape
|
|
111
|
-
color?: Color
|
|
112
|
-
icon?: IconUrl
|
|
113
|
-
border?: BorderStyle
|
|
114
|
-
opacity?: number
|
|
115
|
-
navigateTo?: ViewId
|
|
116
|
-
multiple?: boolean
|
|
117
|
-
size?: ShapeSize
|
|
118
|
-
padding?: ShapeSize
|
|
119
|
-
textSize?: ShapeSize
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export const isCustom = (expr: Expression): expr is FqnExpr.Custom => {
|
|
124
|
-
return 'custom' in expr && (is(expr.custom.expr) || isWhere(expr.custom.expr))
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export const is = (expr: Expression): expr is FqnExpr => {
|
|
128
|
-
return isWildcard(expr)
|
|
129
|
-
|| isModelRef(expr)
|
|
130
|
-
|| isElementKindExpr(expr)
|
|
131
|
-
|| isElementTagExpr(expr)
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export type FqnExpr<M = Fqn> = ExclusiveUnion<{
|
|
136
|
-
Wildcard: FqnExpr.Wildcard
|
|
137
|
-
ModelRef: FqnExpr.ModelRef<M>
|
|
138
|
-
ElementKind: FqnExpr.ElementKindExpr
|
|
139
|
-
ElementTag: FqnExpr.ElementTagExpr
|
|
140
|
-
}>
|
|
141
|
-
|
|
142
|
-
export type FqnExprOrWhere<M = Fqn> = ExclusiveUnion<{
|
|
143
|
-
Wildcard: FqnExpr.Wildcard
|
|
144
|
-
ModelRef: FqnExpr.ModelRef<M>
|
|
145
|
-
ElementKind: FqnExpr.ElementKindExpr
|
|
146
|
-
ElementTag: FqnExpr.ElementTagExpr
|
|
147
|
-
Where: FqnExpr.Where<M>
|
|
148
|
-
}>
|
|
149
|
-
|
|
150
|
-
export type AnyFqnExpr<M = Fqn> = ExclusiveUnion<{
|
|
151
|
-
Wildcard: FqnExpr.Wildcard
|
|
152
|
-
ModelRef: FqnExpr.ModelRef<M>
|
|
153
|
-
ElementKind: FqnExpr.ElementKindExpr
|
|
154
|
-
ElementTag: FqnExpr.ElementTagExpr
|
|
155
|
-
Where: FqnExpr.Where<M>
|
|
156
|
-
Custom: FqnExpr.Custom<M>
|
|
157
|
-
}>
|
|
158
|
-
|
|
159
|
-
export function isAnyFqnExpr(expr: Expression): expr is AnyFqnExpr {
|
|
160
|
-
return FqnExpr.is(expr)
|
|
161
|
-
|| FqnExpr.isWhere(expr)
|
|
162
|
-
|| FqnExpr.isCustom(expr)
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export namespace RelationExpr {
|
|
166
|
-
export type Direct<M = Fqn> = {
|
|
167
|
-
source: FqnExpr<M>
|
|
168
|
-
target: FqnExpr<M>
|
|
169
|
-
isBidirectional?: boolean
|
|
170
|
-
}
|
|
171
|
-
export const isDirect = (expr: Expression): expr is RelationExpr.Direct => {
|
|
172
|
-
return 'source' in expr && 'target' in expr
|
|
173
|
-
}
|
|
174
|
-
export type Incoming<M = Fqn> = {
|
|
175
|
-
incoming: FqnExpr<M>
|
|
176
|
-
}
|
|
177
|
-
export const isIncoming = (expr: Expression): expr is RelationExpr.Incoming => {
|
|
178
|
-
return 'incoming' in expr
|
|
179
|
-
}
|
|
180
|
-
export type Outgoing<M = Fqn> = {
|
|
181
|
-
outgoing: FqnExpr<M>
|
|
182
|
-
}
|
|
183
|
-
export const isOutgoing = (expr: Expression): expr is RelationExpr.Outgoing => {
|
|
184
|
-
return 'outgoing' in expr
|
|
185
|
-
}
|
|
186
|
-
export type InOut<M = Fqn> = {
|
|
187
|
-
inout: FqnExpr<M>
|
|
188
|
-
}
|
|
189
|
-
export const isInOut = (expr: Expression): expr is RelationExpr.InOut => {
|
|
190
|
-
return 'inout' in expr
|
|
191
|
-
}
|
|
192
|
-
export type Where<M = Fqn> = {
|
|
193
|
-
where: {
|
|
194
|
-
expr: ExclusiveUnion<{
|
|
195
|
-
Direct: RelationExpr.Direct<M>
|
|
196
|
-
Incoming: RelationExpr.Incoming<M>
|
|
197
|
-
Outgoing: RelationExpr.Outgoing<M>
|
|
198
|
-
InOut: RelationExpr.InOut<M>
|
|
199
|
-
}>
|
|
200
|
-
condition: WhereOperator<string, string>
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
export const isWhere = (expr: Expression): expr is RelationExpr.Where => {
|
|
204
|
-
return 'where' in expr && is(expr.where.expr)
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
export type Custom<M = Fqn> = {
|
|
208
|
-
customRelation: {
|
|
209
|
-
expr: RelationExprOrWhere<M>
|
|
210
|
-
title?: string
|
|
211
|
-
description?: string
|
|
212
|
-
technology?: string
|
|
213
|
-
notation?: string
|
|
214
|
-
// Link to dynamic view
|
|
215
|
-
navigateTo?: ViewId
|
|
216
|
-
// Notes for walkthrough
|
|
217
|
-
notes?: string
|
|
218
|
-
color?: Color
|
|
219
|
-
line?: RelationshipLineType
|
|
220
|
-
head?: RelationshipArrowType
|
|
221
|
-
tail?: RelationshipArrowType
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export const isCustom = (expr: Expression): expr is Custom => {
|
|
226
|
-
return 'customRelation' in expr
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export const is = (expr: Expression): expr is RelationExpr => {
|
|
230
|
-
return isDirect(expr)
|
|
231
|
-
|| isIncoming(expr)
|
|
232
|
-
|| isOutgoing(expr)
|
|
233
|
-
|| isInOut(expr)
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
export type RelationExpr<M = Fqn> = ExclusiveUnion<{
|
|
238
|
-
Direct: RelationExpr.Direct<M>
|
|
239
|
-
Incoming: RelationExpr.Incoming<M>
|
|
240
|
-
Outgoing: RelationExpr.Outgoing<M>
|
|
241
|
-
InOut: RelationExpr.InOut<M>
|
|
242
|
-
}>
|
|
243
|
-
|
|
244
|
-
export type RelationExprOrWhere<M = Fqn> = ExclusiveUnion<{
|
|
245
|
-
Direct: RelationExpr.Direct<M>
|
|
246
|
-
Incoming: RelationExpr.Incoming<M>
|
|
247
|
-
Outgoing: RelationExpr.Outgoing<M>
|
|
248
|
-
InOut: RelationExpr.InOut<M>
|
|
249
|
-
Where: RelationExpr.Where<M>
|
|
250
|
-
}>
|
|
251
|
-
|
|
252
|
-
export type AnyRelationExpr<M = Fqn> = ExclusiveUnion<{
|
|
253
|
-
Direct: RelationExpr.Direct<M>
|
|
254
|
-
Incoming: RelationExpr.Incoming<M>
|
|
255
|
-
Outgoing: RelationExpr.Outgoing<M>
|
|
256
|
-
InOut: RelationExpr.InOut<M>
|
|
257
|
-
Where: RelationExpr.Where<M>
|
|
258
|
-
CustomRelation: RelationExpr.Custom<M>
|
|
259
|
-
}>
|
|
260
|
-
|
|
261
|
-
export function isAnyRelationExpr(expr: Expression): expr is AnyRelationExpr {
|
|
262
|
-
return RelationExpr.is(expr)
|
|
263
|
-
|| RelationExpr.isWhere(expr)
|
|
264
|
-
|| RelationExpr.isCustom(expr)
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Represents a version 2 expression which can be one of several types.
|
|
269
|
-
*
|
|
270
|
-
* @template M - The type for the model FQN, defaults to `Fqn`.
|
|
271
|
-
*/
|
|
272
|
-
export type Expression<M = Fqn> = ExclusiveUnion<{
|
|
273
|
-
Wildcard: FqnExpr.Wildcard
|
|
274
|
-
ModelRef: FqnExpr.ModelRef<M>
|
|
275
|
-
ElementKind: FqnExpr.ElementKindExpr
|
|
276
|
-
ElementTag: FqnExpr.ElementTagExpr
|
|
277
|
-
Custom: FqnExpr.Custom<M>
|
|
278
|
-
Direct: RelationExpr.Direct<M>
|
|
279
|
-
Incoming: RelationExpr.Incoming<M>
|
|
280
|
-
Outgoing: RelationExpr.Outgoing<M>
|
|
281
|
-
InOut: RelationExpr.InOut<M>
|
|
282
|
-
CustomRelation: RelationExpr.Custom<M>
|
|
283
|
-
Where: Expression.Where<M>
|
|
284
|
-
}>
|
|
285
|
-
|
|
286
|
-
export function isExpression(expr: any): expr is Expression {
|
|
287
|
-
return isAnyFqnExpr(expr)
|
|
288
|
-
|| isAnyRelationExpr(expr)
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
export namespace Expression {
|
|
292
|
-
export type Where<M = Fqn> = FqnExpr.Where<M> | RelationExpr.Where<M>
|
|
293
|
-
|
|
294
|
-
export const isWhere = (expr: Expression): expr is Expression.Where => {
|
|
295
|
-
return 'where' in expr
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
export const isCustomFqnExpr = (expr: Expression): expr is FqnExpr.Custom => {
|
|
299
|
-
return FqnExpr.isCustom(expr)
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
export const isCustomRelationExpr = (expr: Expression): expr is RelationExpr.Custom => {
|
|
303
|
-
return RelationExpr.isCustom(expr)
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
export const isFqnExpr = (expr: Expression): expr is FqnExpr => {
|
|
307
|
-
return FqnExpr.is(expr)
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
export const isRelation = (expr: Expression): expr is RelationExpr => {
|
|
311
|
-
return RelationExpr.is(expr)
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
}
|