@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
|
@@ -1,392 +0,0 @@
|
|
|
1
|
-
import { invariant } from '../errors'
|
|
2
|
-
import type { ExclusiveUnion } from './_common'
|
|
3
|
-
import type { DeploymentRef as DeploymentModelRef, PredicateSelector } from './deployments'
|
|
4
|
-
import type { BorderStyle, ElementKind, ElementShape } from './element'
|
|
5
|
-
import type { WhereOperator } from './operators'
|
|
6
|
-
import type { RelationshipArrowType, RelationshipLineType } from './relation'
|
|
7
|
-
import { type Fqn, type IconUrl, type ProjectId, type Tag, GlobalFqn } from './scalars'
|
|
8
|
-
import type { Color, ShapeSize } from './theme'
|
|
9
|
-
import type { ViewId } from './view'
|
|
10
|
-
|
|
11
|
-
export namespace FqnRef {
|
|
12
|
-
/**
|
|
13
|
-
* Represents a reference to an instance within a deployment.
|
|
14
|
-
*
|
|
15
|
-
* @template D - The type representing the deployment fqn. Defaults to `Fqn`.
|
|
16
|
-
* @template M - The type representing the model fqn. Defaults to `Fqn`.
|
|
17
|
-
*
|
|
18
|
-
* @property {D} deployment - TThe fully qualified name (FQN) of the deployed instance.
|
|
19
|
-
* @property {M} element - The element reference within the deployment.
|
|
20
|
-
*/
|
|
21
|
-
export type InsideInstanceRef<D = Fqn, M = Fqn> = {
|
|
22
|
-
deployment: D
|
|
23
|
-
element: M
|
|
24
|
-
}
|
|
25
|
-
export const isInsideInstanceRef = (ref: FqnRef): ref is InsideInstanceRef => {
|
|
26
|
-
return 'deployment' in ref && 'element' in ref
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Represents a reference to a deployment element.
|
|
31
|
-
*
|
|
32
|
-
* @template F - The type of the fully qualified name (FQN) of the deployment element. Defaults to `Fqn`.
|
|
33
|
-
* @property {F} deployment - The fully qualified name (FQN) of the deployment element.
|
|
34
|
-
*/
|
|
35
|
-
export type DeploymentElementRef<F = Fqn> = {
|
|
36
|
-
deployment: F
|
|
37
|
-
}
|
|
38
|
-
export const isDeploymentElementRef = (ref: FqnRef): ref is DeploymentElementRef => {
|
|
39
|
-
return 'deployment' in ref && !('element' in ref)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type DeploymentRef<D = Fqn, M = Fqn> = DeploymentElementRef<D> | InsideInstanceRef<D, M>
|
|
43
|
-
export const isDeploymentRef = (ref: FqnRef): ref is DeploymentRef => {
|
|
44
|
-
return !isModelRef(ref) && !isImportRef(ref)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Reference to logical model element
|
|
49
|
-
*/
|
|
50
|
-
export type ModelRef<F = Fqn> = {
|
|
51
|
-
model: F
|
|
52
|
-
}
|
|
53
|
-
export const isModelRef = (ref: FqnRef): ref is ModelRef => {
|
|
54
|
-
return 'model' in ref && !('project' in ref)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Reference to imported logical model element
|
|
59
|
-
*/
|
|
60
|
-
export type ImportRef<F = Fqn> = {
|
|
61
|
-
project: ProjectId
|
|
62
|
-
model: F
|
|
63
|
-
}
|
|
64
|
-
export const isImportRef = (ref: FqnRef): ref is ImportRef => {
|
|
65
|
-
return 'project' in ref && 'model' in ref
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export const toDeploymentRef = (ref: FqnRef): DeploymentModelRef => {
|
|
69
|
-
invariant(isDeploymentRef(ref), 'Expected DeploymentRef')
|
|
70
|
-
return isInsideInstanceRef(ref)
|
|
71
|
-
? {
|
|
72
|
-
id: ref.deployment,
|
|
73
|
-
element: ref.element,
|
|
74
|
-
}
|
|
75
|
-
: {
|
|
76
|
-
id: ref.deployment,
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export const toModelFqn = (ref: FqnRef): Fqn => {
|
|
81
|
-
if (isImportRef(ref)) {
|
|
82
|
-
return GlobalFqn(ref.project, ref.model)
|
|
83
|
-
}
|
|
84
|
-
if (isModelRef(ref)) {
|
|
85
|
-
return ref.model
|
|
86
|
-
}
|
|
87
|
-
throw new Error('Expected FqnRef.ModelRef or FqnRef.ImportRef')
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export type FqnRef<D = Fqn, M = Fqn> = ExclusiveUnion<{
|
|
92
|
-
InsideInstanceRef: FqnRef.InsideInstanceRef<D, M>
|
|
93
|
-
DeploymentRef: FqnRef.DeploymentRef<D>
|
|
94
|
-
ModelRef: FqnRef.ModelRef<M>
|
|
95
|
-
ImportRef: FqnRef.ImportRef<M>
|
|
96
|
-
}>
|
|
97
|
-
|
|
98
|
-
export namespace FqnExpr {
|
|
99
|
-
export type Wildcard = {
|
|
100
|
-
wildcard: true
|
|
101
|
-
}
|
|
102
|
-
export const isWildcard = (expr: ExpressionV2): expr is FqnExpr.Wildcard => {
|
|
103
|
-
return 'wildcard' in expr && expr.wildcard === true
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export type ModelRef<M = Fqn> = {
|
|
107
|
-
ref: FqnRef.ModelRef<M> | FqnRef.ImportRef<M>
|
|
108
|
-
selector?: PredicateSelector
|
|
109
|
-
}
|
|
110
|
-
export const isModelRef = (ref: ExpressionV2): ref is FqnExpr.ModelRef => {
|
|
111
|
-
return 'ref' in ref && (FqnRef.isModelRef(ref.ref) || FqnRef.isImportRef(ref.ref))
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export type DeploymentRef<D = Fqn, M = Fqn> = {
|
|
115
|
-
ref: FqnRef.DeploymentRef<D> | FqnRef.InsideInstanceRef<D, M>
|
|
116
|
-
selector?: PredicateSelector
|
|
117
|
-
}
|
|
118
|
-
export const isDeploymentRef = (ref: ExpressionV2): ref is FqnExpr.DeploymentRef => {
|
|
119
|
-
return 'ref' in ref && FqnRef.isDeploymentRef(ref.ref)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export type ElementKindExpr = {
|
|
123
|
-
elementKind: ElementKind
|
|
124
|
-
isEqual: boolean
|
|
125
|
-
}
|
|
126
|
-
export function isElementKindExpr(expr: ExpressionV2): expr is ElementKindExpr {
|
|
127
|
-
return 'elementKind' in expr && 'isEqual' in expr
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export type ElementTagExpr = {
|
|
131
|
-
elementTag: Tag
|
|
132
|
-
isEqual: boolean
|
|
133
|
-
}
|
|
134
|
-
export function isElementTagExpr(expr: ExpressionV2): expr is ElementTagExpr {
|
|
135
|
-
return 'elementTag' in expr && 'isEqual' in expr
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export type NonWildcard<D = Fqn, M = Fqn> = ExclusiveUnion<{
|
|
139
|
-
ModelRef: ModelRef<M>
|
|
140
|
-
DeploymentRef: DeploymentRef<D, M>
|
|
141
|
-
ElementKind: ElementKindExpr
|
|
142
|
-
ElementTag: ElementTagExpr
|
|
143
|
-
}>
|
|
144
|
-
|
|
145
|
-
export type Where<D = Fqn, M = Fqn> = {
|
|
146
|
-
where: {
|
|
147
|
-
expr: ExclusiveUnion<{
|
|
148
|
-
Wildcard: Wildcard
|
|
149
|
-
ModelRef: ModelRef<M>
|
|
150
|
-
DeploymentRef: DeploymentRef<D, M>
|
|
151
|
-
ElementKind: ElementKindExpr
|
|
152
|
-
ElementTag: ElementTagExpr
|
|
153
|
-
}>
|
|
154
|
-
condition: WhereOperator<string, string>
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export const isWhere = (expr: ExpressionV2): expr is FqnExpr.Where => {
|
|
159
|
-
return 'where' in expr && is(expr.where.expr)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export type Custom<D = Fqn, M = Fqn> = {
|
|
163
|
-
custom: {
|
|
164
|
-
expr: OrWhere<D, M>
|
|
165
|
-
title?: string
|
|
166
|
-
description?: string
|
|
167
|
-
technology?: string
|
|
168
|
-
notation?: string
|
|
169
|
-
shape?: ElementShape
|
|
170
|
-
color?: Color
|
|
171
|
-
icon?: IconUrl
|
|
172
|
-
border?: BorderStyle
|
|
173
|
-
opacity?: number
|
|
174
|
-
navigateTo?: ViewId
|
|
175
|
-
multiple?: boolean
|
|
176
|
-
size?: ShapeSize
|
|
177
|
-
padding?: ShapeSize
|
|
178
|
-
textSize?: ShapeSize
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export const isCustom = (expr: ExpressionV2): expr is Custom => {
|
|
183
|
-
return 'custom' in expr && (is(expr.custom.expr) || isWhere(expr.custom.expr))
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export const is = (expr: ExpressionV2): expr is FqnExpr => {
|
|
187
|
-
return isWildcard(expr)
|
|
188
|
-
|| isModelRef(expr)
|
|
189
|
-
|| isDeploymentRef(expr)
|
|
190
|
-
|| isElementKindExpr(expr)
|
|
191
|
-
|| isElementTagExpr(expr)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export type OrWhere<D = Fqn, M = Fqn> = ExclusiveUnion<{
|
|
195
|
-
Wildcard: FqnExpr.Wildcard
|
|
196
|
-
ModelRef: FqnExpr.ModelRef<M>
|
|
197
|
-
DeploymentRef: FqnExpr.DeploymentRef<D, M>
|
|
198
|
-
ElementKind: ElementKindExpr
|
|
199
|
-
ElementTag: ElementTagExpr
|
|
200
|
-
Where: FqnExpr.Where<D, M>
|
|
201
|
-
}>
|
|
202
|
-
|
|
203
|
-
export type Any<D = Fqn, M = Fqn> = ExclusiveUnion<{
|
|
204
|
-
Wildcard: Wildcard
|
|
205
|
-
ModelRef: ModelRef<M>
|
|
206
|
-
DeploymentRef: DeploymentRef<D, M>
|
|
207
|
-
ElementKind: ElementKindExpr
|
|
208
|
-
ElementTag: ElementTagExpr
|
|
209
|
-
Where: Where<D, M>
|
|
210
|
-
Custom: Custom<D, M>
|
|
211
|
-
}>
|
|
212
|
-
|
|
213
|
-
export const unwrap = (expr: FqnExpr): Wildcard | ModelRef | DeploymentRef | ElementKindExpr | ElementTagExpr => {
|
|
214
|
-
if (isCustom(expr)) {
|
|
215
|
-
expr = expr.custom.expr
|
|
216
|
-
}
|
|
217
|
-
if (isWhere(expr)) {
|
|
218
|
-
expr = expr.where.expr
|
|
219
|
-
}
|
|
220
|
-
return expr
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
export type FqnExpr<D = Fqn, M = Fqn> = ExclusiveUnion<{
|
|
225
|
-
Wildcard: FqnExpr.Wildcard
|
|
226
|
-
ModelRef: FqnExpr.ModelRef<M>
|
|
227
|
-
DeploymentRef: FqnExpr.DeploymentRef<D, M>
|
|
228
|
-
ElementKind: FqnExpr.ElementKindExpr
|
|
229
|
-
ElementTag: FqnExpr.ElementTagExpr
|
|
230
|
-
}>
|
|
231
|
-
|
|
232
|
-
export namespace RelationExpr {
|
|
233
|
-
export type Endpoint<D = Fqn, M = Fqn> = FqnExpr.Where<D, M>['where']['expr']
|
|
234
|
-
|
|
235
|
-
export type Direct<D = Fqn, M = Fqn> = {
|
|
236
|
-
source: Endpoint<D, M>
|
|
237
|
-
target: Endpoint<D, M>
|
|
238
|
-
isBidirectional?: boolean
|
|
239
|
-
}
|
|
240
|
-
export const isDirect = (expr: ExpressionV2): expr is RelationExpr.Direct => {
|
|
241
|
-
return 'source' in expr && 'target' in expr
|
|
242
|
-
}
|
|
243
|
-
export type Incoming<D = Fqn, M = Fqn> = {
|
|
244
|
-
incoming: Endpoint<D, M>
|
|
245
|
-
}
|
|
246
|
-
export const isIncoming = (expr: ExpressionV2): expr is RelationExpr.Incoming => {
|
|
247
|
-
return 'incoming' in expr
|
|
248
|
-
}
|
|
249
|
-
export type Outgoing<D = Fqn, M = Fqn> = {
|
|
250
|
-
outgoing: Endpoint<D, M>
|
|
251
|
-
}
|
|
252
|
-
export const isOutgoing = (expr: ExpressionV2): expr is RelationExpr.Outgoing => {
|
|
253
|
-
return 'outgoing' in expr
|
|
254
|
-
}
|
|
255
|
-
export type InOut<D = Fqn, M = Fqn> = {
|
|
256
|
-
inout: Endpoint<D, M>
|
|
257
|
-
}
|
|
258
|
-
export const isInOut = (expr: ExpressionV2): expr is RelationExpr.InOut => {
|
|
259
|
-
return 'inout' in expr
|
|
260
|
-
}
|
|
261
|
-
export type Where<D = Fqn, M = Fqn> = {
|
|
262
|
-
where: {
|
|
263
|
-
expr: ExclusiveUnion<{
|
|
264
|
-
Direct: RelationExpr.Direct<D, M>
|
|
265
|
-
Incoming: RelationExpr.Incoming<D, M>
|
|
266
|
-
Outgoing: RelationExpr.Outgoing<D, M>
|
|
267
|
-
InOut: RelationExpr.InOut<D, M>
|
|
268
|
-
}>
|
|
269
|
-
condition: WhereOperator<string, string>
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
export const isWhere = (expr: ExpressionV2): expr is RelationExpr.Where => {
|
|
273
|
-
return 'where' in expr &&
|
|
274
|
-
(isDirect(expr.where.expr) || isIncoming(expr.where.expr) || isOutgoing(expr.where.expr) ||
|
|
275
|
-
isInOut(expr.where.expr))
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
export type Custom<D = Fqn, M = Fqn> = {
|
|
279
|
-
customRelation: {
|
|
280
|
-
expr: OrWhere<D, M>
|
|
281
|
-
title?: string
|
|
282
|
-
description?: string
|
|
283
|
-
technology?: string
|
|
284
|
-
notation?: string
|
|
285
|
-
// Link to dynamic view
|
|
286
|
-
navigateTo?: ViewId
|
|
287
|
-
// Notes for walkthrough
|
|
288
|
-
notes?: string
|
|
289
|
-
color?: Color
|
|
290
|
-
line?: RelationshipLineType
|
|
291
|
-
head?: RelationshipArrowType
|
|
292
|
-
tail?: RelationshipArrowType
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export const isCustom = (expr: ExpressionV2): expr is Custom => {
|
|
297
|
-
return 'customRelation' in expr
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
export const is = (expr: ExpressionV2): expr is RelationExpr => {
|
|
301
|
-
return isDirect(expr)
|
|
302
|
-
|| isIncoming(expr)
|
|
303
|
-
|| isOutgoing(expr)
|
|
304
|
-
|| isInOut(expr)
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
export type OrWhere<D = Fqn, M = Fqn> = ExclusiveUnion<{
|
|
308
|
-
Direct: Direct<D, M>
|
|
309
|
-
Incoming: Incoming<D, M>
|
|
310
|
-
Outgoing: Outgoing<D, M>
|
|
311
|
-
InOut: InOut<D, M>
|
|
312
|
-
Where: Where<D, M>
|
|
313
|
-
}>
|
|
314
|
-
|
|
315
|
-
export type Any<D = Fqn, M = Fqn> = ExclusiveUnion<{
|
|
316
|
-
Direct: Direct<D, M>
|
|
317
|
-
Incoming: Incoming<D, M>
|
|
318
|
-
Outgoing: Outgoing<D, M>
|
|
319
|
-
InOut: InOut<D, M>
|
|
320
|
-
Where: Where<D, M>
|
|
321
|
-
Custom: Custom<D, M>
|
|
322
|
-
}>
|
|
323
|
-
|
|
324
|
-
export const unwrap = (expr: RelationExpr): Direct | Incoming | Outgoing | InOut => {
|
|
325
|
-
if (isCustom(expr)) {
|
|
326
|
-
expr = expr.customRelation.expr
|
|
327
|
-
}
|
|
328
|
-
if (isWhere(expr)) {
|
|
329
|
-
expr = expr.where.expr
|
|
330
|
-
}
|
|
331
|
-
return expr
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
export type RelationExpr<D = Fqn, M = Fqn> = ExclusiveUnion<{
|
|
336
|
-
Direct: RelationExpr.Direct<D, M>
|
|
337
|
-
Incoming: RelationExpr.Incoming<D, M>
|
|
338
|
-
Outgoing: RelationExpr.Outgoing<D, M>
|
|
339
|
-
InOut: RelationExpr.InOut<D, M>
|
|
340
|
-
}>
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Represents a version 2 expression which can be one of several types.
|
|
344
|
-
*
|
|
345
|
-
* @template D - The type for the deployment FQN, defaults to `Fqn`.
|
|
346
|
-
* @template M - The type for the model FQN, defaults to `Fqn`.
|
|
347
|
-
*/
|
|
348
|
-
export type ExpressionV2<D = Fqn, M = Fqn> = ExclusiveUnion<{
|
|
349
|
-
Wildcard: FqnExpr.Wildcard
|
|
350
|
-
ModelRef: FqnExpr.ModelRef<M>
|
|
351
|
-
DeploymentRef: FqnExpr.DeploymentRef<D, M>
|
|
352
|
-
ElementKind: FqnExpr.ElementKindExpr
|
|
353
|
-
ElementTag: FqnExpr.ElementTagExpr
|
|
354
|
-
Custom: FqnExpr.Custom<D, M>
|
|
355
|
-
Direct: RelationExpr.Direct<D, M>
|
|
356
|
-
Incoming: RelationExpr.Incoming<D, M>
|
|
357
|
-
Outgoing: RelationExpr.Outgoing<D, M>
|
|
358
|
-
InOut: RelationExpr.InOut<D, M>
|
|
359
|
-
Where: ExpressionV2.Where<D, M>
|
|
360
|
-
CustomRelation: RelationExpr.Custom<D, M>
|
|
361
|
-
}>
|
|
362
|
-
|
|
363
|
-
export namespace ExpressionV2 {
|
|
364
|
-
export type Where<D = Fqn, M = Fqn> = FqnExpr.Where<D, M> | RelationExpr.Where<D, M>
|
|
365
|
-
// export type Where<D = Fqn, M = Fqn> = {
|
|
366
|
-
// where: ExclusiveUnion<{
|
|
367
|
-
// Fqn: FqnExpr.Where<D, M>['where']['expr']
|
|
368
|
-
// Relation: RelationExpr.Where<D, M>['where']['expr']
|
|
369
|
-
// }>
|
|
370
|
-
// condition: WhereOperator<string, string>
|
|
371
|
-
// }
|
|
372
|
-
|
|
373
|
-
export const isWhere = (expr: ExpressionV2): expr is ExpressionV2.Where => {
|
|
374
|
-
return 'where' in expr
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
export const isRelationWhere = (expr: ExpressionV2): expr is RelationExpr.Where => {
|
|
378
|
-
return RelationExpr.isWhere(expr)
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
export const isFqnExprWhere = (expr: ExpressionV2): expr is FqnExpr.Where => {
|
|
382
|
-
return FqnExpr.isWhere(expr)
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
export const isFqnExpr = (expr: ExpressionV2): expr is FqnExpr.Any => {
|
|
386
|
-
return FqnExpr.is(expr) || FqnExpr.isWhere(expr) || FqnExpr.isCustom(expr)
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
export const isRelation = (expr: ExpressionV2): expr is RelationExpr.Any => {
|
|
390
|
-
return RelationExpr.is(expr) || RelationExpr.isWhere(expr) || RelationExpr.isCustom(expr)
|
|
391
|
-
}
|
|
392
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { NonEmptyArray, Point, XYPoint } from './_common'
|
|
2
|
-
import type { BBox, ViewId } from './view'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* OverviewGraph is a graph representation of all views in a model
|
|
6
|
-
*/
|
|
7
|
-
export namespace OverviewGraph {
|
|
8
|
-
export type Node = {
|
|
9
|
-
id: string
|
|
10
|
-
type: 'folder' | 'file'
|
|
11
|
-
path: string
|
|
12
|
-
label: string
|
|
13
|
-
parentId: string | null
|
|
14
|
-
position: XYPoint
|
|
15
|
-
width: number
|
|
16
|
-
height: number
|
|
17
|
-
} | {
|
|
18
|
-
id: string
|
|
19
|
-
type: 'view'
|
|
20
|
-
viewId: ViewId
|
|
21
|
-
label: string
|
|
22
|
-
parentId: string | null
|
|
23
|
-
position: XYPoint
|
|
24
|
-
width: number
|
|
25
|
-
height: number
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Edge represents a navigational link from one view to another
|
|
30
|
-
*/
|
|
31
|
-
export type Edge = {
|
|
32
|
-
id: string
|
|
33
|
-
source: string
|
|
34
|
-
target: string
|
|
35
|
-
points: NonEmptyArray<Point>
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface OverviewGraph {
|
|
40
|
-
nodes: OverviewGraph.Node[]
|
|
41
|
-
edges: OverviewGraph.Edge[]
|
|
42
|
-
bounds: BBox
|
|
43
|
-
}
|
package/src/types/relation.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { Tagged } from 'type-fest'
|
|
2
|
-
import type { NonEmptyArray } from './_common'
|
|
3
|
-
import type { Link } from './element'
|
|
4
|
-
import type { Fqn, Tag } from './scalars'
|
|
5
|
-
import type { Color, ThemeColor } from './theme'
|
|
6
|
-
import type { ViewId } from './view'
|
|
7
|
-
|
|
8
|
-
export type RelationId = Tagged<string, 'RelationID'>
|
|
9
|
-
export type RelationshipKind<Kinds extends string = string> = Tagged<Kinds, 'RelationshipKind'>
|
|
10
|
-
|
|
11
|
-
export type RelationshipLineType = 'dashed' | 'solid' | 'dotted'
|
|
12
|
-
|
|
13
|
-
// reference: https://graphviz.org/docs/attr-types/arrowType/
|
|
14
|
-
export type RelationshipArrowType =
|
|
15
|
-
| 'none'
|
|
16
|
-
| 'normal'
|
|
17
|
-
| 'onormal'
|
|
18
|
-
| 'dot'
|
|
19
|
-
| 'odot'
|
|
20
|
-
| 'diamond'
|
|
21
|
-
| 'odiamond'
|
|
22
|
-
| 'crow'
|
|
23
|
-
| 'open'
|
|
24
|
-
| 'vee'
|
|
25
|
-
|
|
26
|
-
export const DefaultLineStyle: RelationshipLineType = 'dashed'
|
|
27
|
-
export const DefaultArrowType: RelationshipArrowType = 'normal'
|
|
28
|
-
export const DefaultRelationshipColor: ThemeColor = 'gray'
|
|
29
|
-
|
|
30
|
-
export interface AbstractRelation {
|
|
31
|
-
readonly id: RelationId
|
|
32
|
-
readonly title?: string
|
|
33
|
-
readonly description?: string
|
|
34
|
-
readonly technology?: string
|
|
35
|
-
readonly tags?: NonEmptyArray<Tag> | null
|
|
36
|
-
readonly kind?: RelationshipKind
|
|
37
|
-
readonly color?: Color
|
|
38
|
-
readonly line?: RelationshipLineType
|
|
39
|
-
readonly head?: RelationshipArrowType
|
|
40
|
-
readonly tail?: RelationshipArrowType
|
|
41
|
-
readonly links?: NonEmptyArray<Link> | null
|
|
42
|
-
// Link to dynamic view
|
|
43
|
-
readonly navigateTo?: ViewId
|
|
44
|
-
readonly metadata?: { [key: string]: string }
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// TODO: rename to Relationship
|
|
48
|
-
export interface ModelRelation extends AbstractRelation {
|
|
49
|
-
readonly source: Fqn
|
|
50
|
-
readonly target: Fqn
|
|
51
|
-
readonly title: string
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface RelationshipKindSpecification {
|
|
55
|
-
readonly technology?: string
|
|
56
|
-
readonly notation?: string
|
|
57
|
-
readonly color?: Color
|
|
58
|
-
readonly line?: RelationshipLineType
|
|
59
|
-
readonly head?: RelationshipArrowType
|
|
60
|
-
readonly tail?: RelationshipArrowType
|
|
61
|
-
}
|
package/src/types/scalars.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { isTruthy } from 'remeda'
|
|
2
|
-
import type { Tagged } from 'type-fest'
|
|
3
|
-
import { invariant } from '../errors'
|
|
4
|
-
|
|
5
|
-
export type ProjectId = Tagged<string, 'ProjectID'>
|
|
6
|
-
|
|
7
|
-
export type IconUrl = Tagged<string, 'IconUrl'> | 'none'
|
|
8
|
-
|
|
9
|
-
// Full-qualified-name
|
|
10
|
-
export type Fqn<Id extends string = string> = Tagged<Id, 'Fqn'>
|
|
11
|
-
|
|
12
|
-
export type Tag<Tags extends string = string> = Tagged<Tags, 'Tag'>
|
|
13
|
-
|
|
14
|
-
export function AsFqn(name: string, parent?: Fqn | null): Fqn {
|
|
15
|
-
return (parent ? parent + '.' + name : name) as Fqn
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type GlobalFqn<Id extends string = string> = Tagged<Fqn<Id>, 'GlobalFqn'>
|
|
19
|
-
export function GlobalFqn(projectId: ProjectId, name: string): GlobalFqn {
|
|
20
|
-
invariant(isTruthy(projectId), 'Project ID must start with @')
|
|
21
|
-
return '@' + projectId + '.' + name as GlobalFqn
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function isGlobalFqn(fqn: string): fqn is GlobalFqn {
|
|
25
|
-
return fqn.startsWith('@')
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function splitGlobalFqn<Id extends string>(fqn: Fqn<Id> | GlobalFqn<Id>): [ProjectId | null, Fqn<Id>] {
|
|
29
|
-
if (!fqn.startsWith('@')) {
|
|
30
|
-
return [null, fqn]
|
|
31
|
-
}
|
|
32
|
-
const firstDot = fqn.indexOf('.')
|
|
33
|
-
if (firstDot < 2) {
|
|
34
|
-
throw new Error('Invalid global FQN')
|
|
35
|
-
}
|
|
36
|
-
const projectId = fqn.slice(1, firstDot) as ProjectId
|
|
37
|
-
const name = fqn.slice(firstDot + 1) as Fqn<Id>
|
|
38
|
-
return [projectId, name]
|
|
39
|
-
}
|
package/src/types/theme.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { LiteralUnion } from 'type-fest'
|
|
2
|
-
|
|
3
|
-
export const ThemeColors = [
|
|
4
|
-
'amber',
|
|
5
|
-
'blue',
|
|
6
|
-
'gray',
|
|
7
|
-
'slate',
|
|
8
|
-
'green',
|
|
9
|
-
'indigo',
|
|
10
|
-
'muted',
|
|
11
|
-
'primary',
|
|
12
|
-
'red',
|
|
13
|
-
'secondary',
|
|
14
|
-
'sky',
|
|
15
|
-
] as const
|
|
16
|
-
export type ThemeColor = typeof ThemeColors[number]
|
|
17
|
-
|
|
18
|
-
export type HexColorLiteral = `#${string}`
|
|
19
|
-
|
|
20
|
-
export type ColorLiteral = HexColorLiteral
|
|
21
|
-
|
|
22
|
-
export type Color = LiteralUnion<ThemeColor, string>
|
|
23
|
-
|
|
24
|
-
export type ShapeSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* For padding, margin, etc.
|
|
28
|
-
*/
|
|
29
|
-
export type SpacingSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
|
30
|
-
|
|
31
|
-
export type TextSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
|
32
|
-
|
|
33
|
-
export function isThemeColor(color: Color): color is ThemeColor {
|
|
34
|
-
return color in ThemeColors
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface ElementThemeColorValues {
|
|
38
|
-
fill: ColorLiteral
|
|
39
|
-
stroke: ColorLiteral
|
|
40
|
-
// Main text (title, etc.)
|
|
41
|
-
hiContrast: ColorLiteral
|
|
42
|
-
// Secondary text (description, etc.)
|
|
43
|
-
loContrast: ColorLiteral
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export type ElementThemeColors = {
|
|
47
|
-
[key in ThemeColor]: ElementThemeColorValues
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface RelationshipThemeColorValues {
|
|
51
|
-
lineColor: ColorLiteral
|
|
52
|
-
labelBgColor: ColorLiteral
|
|
53
|
-
labelColor: ColorLiteral
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface ThemeColorValues {
|
|
57
|
-
elements: ElementThemeColorValues
|
|
58
|
-
relationships: RelationshipThemeColorValues
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export type RelationshipThemeColors = {
|
|
62
|
-
[key in ThemeColor]: RelationshipThemeColorValues
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface LikeC4Theme {
|
|
66
|
-
font: 'Arial'
|
|
67
|
-
shadow: ColorLiteral
|
|
68
|
-
relationships: RelationshipThemeColors
|
|
69
|
-
elements: ElementThemeColors
|
|
70
|
-
sizes: {
|
|
71
|
-
[key in ShapeSize]: {
|
|
72
|
-
width: number
|
|
73
|
-
height: number
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
spacing: {
|
|
77
|
-
[key in SpacingSize]: number
|
|
78
|
-
}
|
|
79
|
-
textSizes: {
|
|
80
|
-
[key in TextSize]: number
|
|
81
|
-
}
|
|
82
|
-
}
|
package/src/utils/graphlib.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import dagre from '@dagrejs/dagre'
|
|
2
|
-
|
|
3
|
-
const Graph = dagre.graphlib.Graph
|
|
4
|
-
|
|
5
|
-
export { Graph }
|
|
6
|
-
|
|
7
|
-
export const postorder = dagre.graphlib.alg.postorder
|
|
8
|
-
export const preorder = dagre.graphlib.alg.preorder
|
|
9
|
-
export const findCycles = dagre.graphlib.alg.findCycles
|
|
10
|
-
export const isAcyclic = dagre.graphlib.alg.isAcyclic
|
|
File without changes
|