@likec4/core 1.17.1 → 1.19.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/LICENSE +1 -1
- package/dist/builder/index.d.mts +502 -0
- package/dist/builder/index.d.ts +502 -0
- package/dist/builder/index.js +871 -0
- package/dist/compute-view/index.d.mts +22 -0
- package/dist/compute-view/index.d.ts +22 -0
- package/dist/compute-view/index.js +78 -0
- package/dist/index.d.mts +10 -919
- package/dist/index.d.ts +10 -919
- package/dist/{index.mjs → index.js} +7 -1688
- package/dist/model/index.d.mts +254 -0
- package/dist/model/index.d.ts +254 -0
- package/dist/model/index.js +1 -0
- package/dist/shared/chunk-RAAYCPUM.M-JWF7SS.js +21 -0
- package/dist/shared/core.BIfgabEw.d.ts +719 -0
- package/dist/shared/core.BZ9Msq7w.d.mts +719 -0
- package/dist/shared/{core.CoLQkcYL.d.cts → core.C05RDLhi.d.ts} +460 -362
- package/dist/shared/{core.CoLQkcYL.d.mts → core.CmYMqgha.d.mts} +460 -362
- package/dist/shared/core.D6-fWbM3.d.ts +127 -0
- package/dist/shared/core.D74xkKkG.d.mts +148 -0
- package/dist/shared/core.D74xkKkG.d.ts +148 -0
- package/dist/shared/core.sLaWHBjR.d.mts +127 -0
- package/dist/shared/index.-BdzdI2C.js +7443 -0
- package/dist/shared/object_hash.CE_oF3I3.js +1222 -0
- package/dist/shared/{core.BXTs-8n7.mjs → view.CyZrG8BJ.js} +108 -47
- package/dist/types/index.d.mts +71 -1
- package/dist/types/index.d.ts +71 -1
- package/dist/types/index.js +20 -0
- package/dist/utils/index.d.mts +404 -0
- package/dist/utils/index.d.ts +404 -0
- package/dist/utils/index.js +330 -0
- package/package.json +59 -47
- package/src/builder/Builder-style1.test-d.ts +190 -0
- package/src/builder/Builder-style2.test-d.ts +175 -0
- package/src/builder/Builder.deployment.ts +224 -0
- package/src/builder/Builder.deploymentModel.ts +385 -0
- package/src/builder/Builder.element.ts +19 -19
- package/src/builder/Builder.model.ts +67 -42
- package/src/builder/Builder.ts +533 -367
- package/src/builder/Builder.view-common.ts +234 -0
- package/src/builder/Builder.view-deployment.ts +135 -0
- package/src/builder/Builder.view-element.ts +189 -0
- package/src/builder/Builder.views.ts +109 -33
- package/src/builder/Builder.with.ts +475 -0
- package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +374 -0
- package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +183 -0
- package/src/builder/__snapshots__/Builder.spec.ts.snap +374 -0
- package/src/builder/_types.ts +113 -18
- package/src/builder/index.ts +10 -4
- package/src/colors/index.ts +2 -2
- package/src/compute-view/compute-view.ts +83 -0
- package/src/compute-view/deployment-view/__test__/TestHelper.ts +236 -0
- package/src/compute-view/deployment-view/__test__/fixture.ts +198 -0
- package/src/compute-view/deployment-view/_types.ts +37 -0
- package/src/compute-view/deployment-view/clean-connections.ts +238 -0
- package/src/compute-view/deployment-view/compute.ts +125 -0
- package/src/compute-view/deployment-view/memory/index.ts +9 -0
- package/src/compute-view/deployment-view/memory/memory.ts +97 -0
- package/src/compute-view/deployment-view/predicates/elements.ts +144 -0
- package/src/compute-view/deployment-view/predicates/relation-direct.ts +237 -0
- package/src/compute-view/deployment-view/predicates/relation-in-out.ts +61 -0
- package/src/compute-view/deployment-view/predicates/relation-incoming.ts +95 -0
- package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +88 -0
- package/src/compute-view/deployment-view/predicates/wildcard.ts +29 -0
- package/src/compute-view/deployment-view/stages/stage-exclude.ts +5 -0
- package/src/compute-view/deployment-view/stages/stage-final.ts +245 -0
- package/src/compute-view/deployment-view/stages/stage-include.ts +95 -0
- package/src/compute-view/deployment-view/utils.ts +276 -0
- package/src/compute-view/dynamic-view/__test__/fixture.ts +58 -0
- package/src/compute-view/dynamic-view/compute.ts +324 -0
- package/src/compute-view/element-view/__test__/TestHelper.ts +258 -0
- package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +458 -0
- package/src/compute-view/element-view/__test__/fixture.ts +675 -0
- package/src/compute-view/element-view/_types.ts +48 -0
- package/src/compute-view/element-view/clean-connections.ts +113 -0
- package/src/compute-view/element-view/compute.ts +315 -0
- package/src/compute-view/element-view/memory/NodeGroup.ts +31 -0
- package/src/compute-view/element-view/memory/index.ts +10 -0
- package/src/compute-view/element-view/memory/memory.ts +177 -0
- package/src/compute-view/element-view/memory/stage-exclude.ts +59 -0
- package/src/compute-view/element-view/memory/stage-final.ts +129 -0
- package/src/compute-view/element-view/memory/stage-include.ts +128 -0
- package/src/compute-view/element-view/predicates/_utils.ts +86 -0
- package/src/compute-view/element-view/predicates/element-expand.ts +33 -0
- package/src/compute-view/element-view/predicates/element-kind-tag.ts +26 -0
- package/src/compute-view/element-view/predicates/element-ref.ts +37 -0
- package/src/compute-view/element-view/predicates/relation-direct.ts +309 -0
- package/src/compute-view/element-view/predicates/relation-in-out.ts +66 -0
- package/src/compute-view/element-view/predicates/relation-in.ts +118 -0
- package/src/compute-view/element-view/predicates/relation-out.ts +116 -0
- package/src/compute-view/element-view/predicates/wildcard.ts +88 -0
- package/src/compute-view/element-view/utils.ts +59 -0
- package/src/compute-view/index.ts +4 -0
- package/src/compute-view/memory/AbstractMemory.ts +45 -0
- package/src/compute-view/memory/AbstractStageExclude.ts +216 -0
- package/src/compute-view/memory/AbstractStageInclude.ts +200 -0
- package/src/compute-view/memory/_types.ts +147 -0
- package/src/compute-view/memory/index.ts +5 -0
- package/src/compute-view/memory/ops.ts +43 -0
- package/src/compute-view/utils/__snapshots__/sortNodes.spec.ts.snap +113 -0
- package/src/compute-view/utils/ancestorsOfNode.ts +19 -0
- package/src/compute-view/utils/applyCustomElementProperties.ts +66 -0
- package/src/compute-view/utils/applyCustomRelationProperties.ts +41 -0
- package/src/compute-view/utils/applyViewRuleStyles.ts +53 -0
- package/src/compute-view/utils/buildComputedNodes.ts +148 -0
- package/src/compute-view/utils/buildElementNotations.ts +63 -0
- package/src/compute-view/utils/elementExpressionToPredicate.ts +50 -0
- package/src/compute-view/utils/link-nodes-with-edges.ts +54 -0
- package/src/compute-view/utils/merge-props-from-relationships.ts +128 -0
- package/src/compute-view/utils/relationExpressionToPredicates.ts +55 -0
- package/src/compute-view/utils/resolve-extended-views.ts +69 -0
- package/src/compute-view/utils/resolve-global-rules.ts +83 -0
- package/src/compute-view/utils/topological-sort.ts +256 -0
- package/src/compute-view/utils/uniqueTags.test.ts +42 -0
- package/src/compute-view/utils/uniqueTags.ts +21 -0
- package/src/compute-view/utils/view-hash.ts +27 -0
- package/src/compute-view/utils/with-readable-edges.ts +36 -0
- package/src/index.ts +22 -12
- package/src/model/DeploymentElementModel.ts +599 -0
- package/src/model/DeploymentModel.ts +370 -0
- package/src/model/ElementModel.ts +221 -0
- package/src/model/LikeC4Model.test-d.ts +152 -0
- package/src/model/LikeC4Model.ts +336 -457
- package/src/model/RelationModel.ts +85 -0
- package/src/model/__test__/fixture.ts +149 -338
- package/src/model/connection/Connection.ts +72 -0
- package/src/model/connection/deployment/DeploymentConnectionModel.ts +178 -0
- package/src/model/connection/deployment/find.ts +120 -0
- package/src/model/connection/deployment/index.ts +8 -0
- package/src/model/connection/index.ts +22 -0
- package/src/model/connection/model/ConnectionModel.ts +157 -0
- package/src/model/connection/model/find.ts +117 -0
- package/src/model/connection/model/index.ts +8 -0
- package/src/model/connection/ops.ts +274 -0
- package/src/model/guards.ts +9 -0
- package/src/model/index.ts +46 -2
- package/src/model/types.ts +112 -15
- package/src/model/view/EdgeModel.ts +103 -0
- package/src/model/view/LikeC4ViewModel.ts +226 -0
- package/src/model/view/NodeModel.ts +229 -0
- package/src/types/_common.ts +55 -1
- package/src/types/deployments.ts +169 -0
- package/src/types/element.ts +9 -5
- package/src/types/expression-v2.ts +172 -0
- package/src/types/expression.ts +17 -11
- package/src/types/global.ts +3 -3
- package/src/types/index.ts +220 -12
- package/src/types/model.ts +75 -12
- package/src/types/operators.ts +1 -1
- package/src/types/overview-graph.ts +2 -2
- package/src/types/relation.ts +18 -14
- package/src/types/theme.ts +0 -1
- package/src/types/view-notation.ts +2 -2
- package/src/types/view.ts +117 -41
- package/src/utils/{commonHead.ts → common-head.ts} +2 -0
- package/src/utils/const.ts +1 -0
- package/src/utils/fqn.ts +203 -56
- package/src/utils/getOrCreate.ts +42 -0
- package/src/utils/graphlib.ts +10 -0
- package/src/utils/index.ts +74 -6
- package/src/utils/iterable/_types.ts +5 -0
- package/src/utils/iterable/filter.ts +55 -0
- package/src/utils/iterable/flat.ts +17 -0
- package/src/utils/iterable/index.ts +12 -0
- package/src/utils/iterable/map.ts +40 -0
- package/src/utils/iterable/reduce.ts +24 -0
- package/src/utils/iterable/some.ts +36 -0
- package/src/utils/iterable/to.ts +19 -0
- package/src/utils/iterable/unique.ts +29 -0
- package/src/utils/object-hash.ts +3 -0
- package/src/utils/relations.ts +3 -64
- package/src/utils/set.ts +78 -0
- package/src/utils/string-hash.ts +16 -0
- package/dist/index.cjs +0 -5452
- package/dist/index.d.cts +0 -1053
- package/dist/shared/core.CoLQkcYL.d.ts +0 -734
- package/dist/shared/core.DIYZvpVg.cjs +0 -353
- package/dist/types/index.cjs +0 -70
- package/dist/types/index.d.cts +0 -2
- package/dist/types/index.mjs +0 -1
- package/src/builder/Builder.test-d.ts +0 -69
- package/src/builder/Builder.view.ts +0 -358
- package/src/model/LikeC4DiagramModel.ts +0 -338
- package/src/model/LikeC4ViewModel.ts +0 -320
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { invariant } from '../errors'
|
|
2
|
+
import type { ExclusiveUnion } from './_common'
|
|
3
|
+
import type { DeploymentRef as DeploymentModelRef, PredicateSelector } from './deployments'
|
|
4
|
+
import type { Fqn } from './element'
|
|
5
|
+
|
|
6
|
+
export namespace FqnRef {
|
|
7
|
+
/**
|
|
8
|
+
* Represents a reference to an instance within a deployment.
|
|
9
|
+
*
|
|
10
|
+
* @template D - The type representing the deployment fqn. Defaults to `Fqn`.
|
|
11
|
+
* @template M - The type representing the model fqn. Defaults to `Fqn`.
|
|
12
|
+
*
|
|
13
|
+
* @property {D} deployment - TThe fully qualified name (FQN) of the deployed instance.
|
|
14
|
+
* @property {M} element - The element reference within the deployment.
|
|
15
|
+
*/
|
|
16
|
+
export type InsideInstanceRef<D = Fqn, M = Fqn> = {
|
|
17
|
+
deployment: D
|
|
18
|
+
element: M
|
|
19
|
+
}
|
|
20
|
+
export const isInsideInstanceRef = (ref: FqnRef): ref is InsideInstanceRef => {
|
|
21
|
+
return 'deployment' in ref && 'element' in ref
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Represents a reference to a deployment element.
|
|
26
|
+
*
|
|
27
|
+
* @template F - The type of the fully qualified name (FQN) of the deployment element. Defaults to `Fqn`.
|
|
28
|
+
* @property {F} deployment - The fully qualified name (FQN) of the deployment element.
|
|
29
|
+
*/
|
|
30
|
+
export type DeploymentElementRef<F = Fqn> = {
|
|
31
|
+
deployment: F
|
|
32
|
+
}
|
|
33
|
+
export const isDeploymentElementRef = (ref: FqnRef): ref is DeploymentElementRef => {
|
|
34
|
+
return 'deployment' in ref && !('element' in ref)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type DeploymentRef<D = Fqn, M = Fqn> = DeploymentElementRef<D> | InsideInstanceRef<D, M>
|
|
38
|
+
export const isDeploymentRef = (ref: FqnRef): ref is DeploymentRef => {
|
|
39
|
+
return !isModelRef(ref)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Reference to logical model element
|
|
44
|
+
*/
|
|
45
|
+
export type ModelRef<F = Fqn> = {
|
|
46
|
+
model: F
|
|
47
|
+
}
|
|
48
|
+
export const isModelRef = (ref: FqnRef): ref is ModelRef => {
|
|
49
|
+
return 'model' in ref
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const toDeploymentRef = (ref: FqnRef): DeploymentModelRef => {
|
|
53
|
+
invariant(isDeploymentRef(ref), 'Expected DeploymentRef')
|
|
54
|
+
return isInsideInstanceRef(ref)
|
|
55
|
+
? {
|
|
56
|
+
id: ref.deployment,
|
|
57
|
+
element: ref.element,
|
|
58
|
+
}
|
|
59
|
+
: {
|
|
60
|
+
id: ref.deployment,
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type FqnRef<D = Fqn, M = Fqn> = ExclusiveUnion<{
|
|
66
|
+
InsideInstanceRef: FqnRef.InsideInstanceRef<D, M>
|
|
67
|
+
DeploymentRef: FqnRef.DeploymentRef<D>
|
|
68
|
+
ModelRef: FqnRef.ModelRef<M>
|
|
69
|
+
}>
|
|
70
|
+
|
|
71
|
+
export namespace FqnExpr {
|
|
72
|
+
export type Wildcard = {
|
|
73
|
+
wildcard: true
|
|
74
|
+
}
|
|
75
|
+
export const isWildcard = (expr: ExpressionV2): expr is Wildcard => {
|
|
76
|
+
return 'wildcard' in expr && expr.wildcard === true
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type ModelRef<M = Fqn> = {
|
|
80
|
+
ref: FqnRef.ModelRef<M>
|
|
81
|
+
selector?: PredicateSelector
|
|
82
|
+
}
|
|
83
|
+
export const isModelRef = (ref: ExpressionV2): ref is ModelRef => {
|
|
84
|
+
return 'ref' in ref && FqnRef.isModelRef(ref.ref)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type DeploymentRef<D = Fqn, M = Fqn> = {
|
|
88
|
+
ref: FqnRef.DeploymentRef<D> | FqnRef.InsideInstanceRef<D, M>
|
|
89
|
+
selector?: PredicateSelector
|
|
90
|
+
}
|
|
91
|
+
export const isDeploymentRef = (ref: ExpressionV2): ref is FqnExpr.DeploymentRef => {
|
|
92
|
+
return 'ref' in ref && FqnRef.isDeploymentRef(ref.ref)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export type NonWildcard<D = Fqn, M = Fqn> = ExclusiveUnion<{
|
|
96
|
+
ModelRef: ModelRef<M>
|
|
97
|
+
DeploymentRef: DeploymentRef<D, M>
|
|
98
|
+
}>
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export type FqnExpr<D = Fqn, M = Fqn> = ExclusiveUnion<{
|
|
102
|
+
Wildcard: FqnExpr.Wildcard
|
|
103
|
+
ModelRef: FqnExpr.ModelRef<M>
|
|
104
|
+
DeploymentRef: FqnExpr.DeploymentRef<D, M>
|
|
105
|
+
}>
|
|
106
|
+
|
|
107
|
+
export namespace RelationExpr {
|
|
108
|
+
export type Direct<D = Fqn, M = Fqn> = {
|
|
109
|
+
source: FqnExpr<D, M>
|
|
110
|
+
target: FqnExpr<D, M>
|
|
111
|
+
isBidirectional?: boolean
|
|
112
|
+
}
|
|
113
|
+
export const isDirect = (expr: ExpressionV2): expr is Direct => {
|
|
114
|
+
return 'source' in expr && 'target' in expr
|
|
115
|
+
}
|
|
116
|
+
export type Incoming<D = Fqn, M = Fqn> = {
|
|
117
|
+
incoming: FqnExpr<D, M>
|
|
118
|
+
}
|
|
119
|
+
export const isIncoming = (expr: ExpressionV2): expr is Incoming => {
|
|
120
|
+
return 'incoming' in expr
|
|
121
|
+
}
|
|
122
|
+
export type Outgoing<D = Fqn, M = Fqn> = {
|
|
123
|
+
outgoing: FqnExpr<D, M>
|
|
124
|
+
}
|
|
125
|
+
export const isOutgoing = (expr: ExpressionV2): expr is Outgoing => {
|
|
126
|
+
return 'outgoing' in expr
|
|
127
|
+
}
|
|
128
|
+
export type InOut<D = Fqn, M = Fqn> = {
|
|
129
|
+
inout: FqnExpr<D, M>
|
|
130
|
+
}
|
|
131
|
+
export const isInOut = (expr: ExpressionV2): expr is InOut => {
|
|
132
|
+
return 'inout' in expr
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export type RelationExpr<D = Fqn, M = Fqn> = ExclusiveUnion<{
|
|
137
|
+
Direct: RelationExpr.Direct<D, M>
|
|
138
|
+
Incoming: RelationExpr.Incoming<D, M>
|
|
139
|
+
Outgoing: RelationExpr.Outgoing<D, M>
|
|
140
|
+
InOut: RelationExpr.InOut<D, M>
|
|
141
|
+
}>
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Represents a version 2 expression which can be one of several types.
|
|
145
|
+
*
|
|
146
|
+
* @template D - The type for the deployment FQN, defaults to `Fqn`.
|
|
147
|
+
* @template M - The type for the model FQN, defaults to `Fqn`.
|
|
148
|
+
*/
|
|
149
|
+
export type ExpressionV2<D = Fqn, M = Fqn> = ExclusiveUnion<{
|
|
150
|
+
Wildcard: FqnExpr.Wildcard
|
|
151
|
+
ModelRef: FqnExpr.ModelRef<M>
|
|
152
|
+
DeploymentRef: FqnExpr.DeploymentRef<D, M>
|
|
153
|
+
Direct: RelationExpr.Direct<D, M>
|
|
154
|
+
Incoming: RelationExpr.Incoming<D, M>
|
|
155
|
+
Outgoing: RelationExpr.Outgoing<D, M>
|
|
156
|
+
InOut: RelationExpr.InOut<D, M>
|
|
157
|
+
}>
|
|
158
|
+
|
|
159
|
+
export namespace ExpressionV2 {
|
|
160
|
+
export const isFqnExpr = (expr: ExpressionV2): expr is FqnExpr => {
|
|
161
|
+
return FqnExpr.isWildcard(expr)
|
|
162
|
+
|| FqnExpr.isModelRef(expr)
|
|
163
|
+
|| FqnExpr.isDeploymentRef(expr)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export const isRelation = (expr: ExpressionV2): expr is RelationExpr => {
|
|
167
|
+
return RelationExpr.isDirect(expr)
|
|
168
|
+
|| RelationExpr.isIncoming(expr)
|
|
169
|
+
|| RelationExpr.isOutgoing(expr)
|
|
170
|
+
|| RelationExpr.isInOut(expr)
|
|
171
|
+
}
|
|
172
|
+
}
|
package/src/types/expression.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { BorderStyle, ElementKind, ElementShape, Fqn, Tag } from './element
|
|
|
3
3
|
import type { WhereOperator } from './operators'
|
|
4
4
|
import type { RelationshipArrowType, RelationshipLineType } from './relation'
|
|
5
5
|
import type { Color } from './theme'
|
|
6
|
-
import type {
|
|
6
|
+
import type { ViewId } from './view'
|
|
7
7
|
|
|
8
8
|
interface BaseExpr {
|
|
9
9
|
where?: never
|
|
@@ -13,7 +13,8 @@ interface BaseExpr {
|
|
|
13
13
|
elementKind?: never
|
|
14
14
|
elementTag?: never
|
|
15
15
|
isEqual?: never
|
|
16
|
-
|
|
16
|
+
isChildren?: never
|
|
17
|
+
isDescendants?: never
|
|
17
18
|
wildcard?: never
|
|
18
19
|
source?: never
|
|
19
20
|
target?: never
|
|
@@ -23,9 +24,10 @@ interface BaseExpr {
|
|
|
23
24
|
customRelation?: never
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
export interface ElementRefExpr extends Omit<BaseExpr, 'element' | '
|
|
27
|
+
export interface ElementRefExpr extends Omit<BaseExpr, 'element' | 'isChildren' | 'isDescendants'> {
|
|
27
28
|
element: Fqn
|
|
28
|
-
|
|
29
|
+
isChildren?: boolean
|
|
30
|
+
isDescendants?: boolean
|
|
29
31
|
}
|
|
30
32
|
export function isElementRef(expr: Expression): expr is ElementRefExpr {
|
|
31
33
|
return 'element' in expr
|
|
@@ -50,7 +52,7 @@ export interface CustomElementExpr extends Omit<BaseExpr, 'custom'> {
|
|
|
50
52
|
icon?: IconUrl
|
|
51
53
|
border?: BorderStyle
|
|
52
54
|
opacity?: number
|
|
53
|
-
navigateTo?:
|
|
55
|
+
navigateTo?: ViewId
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
|
|
@@ -80,12 +82,16 @@ export function isElementTagExpr(expr: Expression): expr is ElementTagExpr {
|
|
|
80
82
|
return 'elementTag' in expr && 'isEqual' in expr
|
|
81
83
|
}
|
|
82
84
|
|
|
83
|
-
export type
|
|
85
|
+
export type NonWilcard =
|
|
84
86
|
| ElementRefExpr
|
|
85
|
-
| WildcardExpr
|
|
86
87
|
| ElementKindExpr
|
|
87
88
|
| ElementTagExpr
|
|
88
89
|
| ExpandedElementExpr
|
|
90
|
+
|
|
91
|
+
export type ElementExpression =
|
|
92
|
+
| NonWilcard
|
|
93
|
+
| WildcardExpr
|
|
94
|
+
|
|
89
95
|
export function isElement(expr: Expression): expr is ElementExpression {
|
|
90
96
|
return isElementRef(expr)
|
|
91
97
|
|| isWildcard(expr)
|
|
@@ -109,12 +115,12 @@ export function isElementPredicateExpr(expr: Expression): expr is ElementPredica
|
|
|
109
115
|
return isElement(expr) || isElementWhere(expr) || isCustomElement(expr)
|
|
110
116
|
}
|
|
111
117
|
|
|
112
|
-
export interface
|
|
118
|
+
export interface DirectRelationExpr extends Omit<BaseExpr, 'source' | 'target'> {
|
|
113
119
|
source: ElementExpression
|
|
114
120
|
target: ElementExpression
|
|
115
121
|
isBidirectional?: boolean
|
|
116
122
|
}
|
|
117
|
-
export function isRelation(expr: Expression): expr is
|
|
123
|
+
export function isRelation(expr: Expression): expr is DirectRelationExpr {
|
|
118
124
|
return 'source' in expr && 'target' in expr
|
|
119
125
|
}
|
|
120
126
|
|
|
@@ -138,7 +144,7 @@ export function isOutgoing(expr: Expression): expr is OutgoingExpr {
|
|
|
138
144
|
return 'outgoing' in expr
|
|
139
145
|
}
|
|
140
146
|
|
|
141
|
-
export type RelationExpression =
|
|
147
|
+
export type RelationExpression = DirectRelationExpr | InOutExpr | IncomingExpr | OutgoingExpr
|
|
142
148
|
|
|
143
149
|
export function isRelationExpression(expr: Expression): expr is RelationExpression {
|
|
144
150
|
return isRelation(expr) || isInOut(expr) || isIncoming(expr) || isOutgoing(expr)
|
|
@@ -162,7 +168,7 @@ export interface CustomRelationExpr extends Omit<BaseExpr, 'customRelation'> {
|
|
|
162
168
|
technology?: string
|
|
163
169
|
notation?: string
|
|
164
170
|
// Link to dynamic view
|
|
165
|
-
navigateTo?:
|
|
171
|
+
navigateTo?: ViewId
|
|
166
172
|
// Notes for walkthrough
|
|
167
173
|
notes?: string
|
|
168
174
|
color?: Color
|
package/src/types/global.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type GlobalStyleID = Tagged<string, 'GlobalStyleID'>
|
|
|
13
13
|
export type GlobalStyles = NonEmptyTuple<ViewRuleStyle>
|
|
14
14
|
|
|
15
15
|
export interface ModelGlobals {
|
|
16
|
-
predicates: Record<GlobalPredicateId, GlobalPredicates>
|
|
17
|
-
dynamicPredicates: Record<GlobalPredicateId, GlobalDynamicPredicates>
|
|
18
|
-
styles: Record<GlobalStyleID, GlobalStyles>
|
|
16
|
+
readonly predicates: Record<GlobalPredicateId, GlobalPredicates>
|
|
17
|
+
readonly dynamicPredicates: Record<GlobalPredicateId, GlobalDynamicPredicates>
|
|
18
|
+
readonly styles: Record<GlobalStyleID, GlobalStyles>
|
|
19
19
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -1,12 +1,220 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
export type {
|
|
2
|
+
CustomColor,
|
|
3
|
+
ExclusiveUnion,
|
|
4
|
+
IconUrl,
|
|
5
|
+
IteratorLike,
|
|
6
|
+
KeysOf,
|
|
7
|
+
NonEmptyArray,
|
|
8
|
+
NonEmptyReadonlyArray,
|
|
9
|
+
NTuple,
|
|
10
|
+
Point,
|
|
11
|
+
Predicate,
|
|
12
|
+
XYPoint,
|
|
13
|
+
} from './_common'
|
|
14
|
+
|
|
15
|
+
export { DeploymentElement } from './deployments'
|
|
16
|
+
export type {
|
|
17
|
+
DeployedInstance,
|
|
18
|
+
DeploymentElementStyle,
|
|
19
|
+
DeploymentNode,
|
|
20
|
+
DeploymentNodeKind,
|
|
21
|
+
DeploymentNodeKindSpecification,
|
|
22
|
+
DeploymentRef,
|
|
23
|
+
DeploymentRelation,
|
|
24
|
+
PredicateSelector,
|
|
25
|
+
} from './deployments'
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
AsFqn,
|
|
29
|
+
BorderStyles,
|
|
30
|
+
DefaultElementShape,
|
|
31
|
+
DefaultThemeColor,
|
|
32
|
+
ElementKind,
|
|
33
|
+
ElementShapes,
|
|
34
|
+
} from './element'
|
|
35
|
+
export type {
|
|
36
|
+
BorderStyle,
|
|
37
|
+
Element,
|
|
38
|
+
ElementKindSpecification,
|
|
39
|
+
ElementKindSpecificationStyle,
|
|
40
|
+
ElementShape,
|
|
41
|
+
ElementStyle,
|
|
42
|
+
Fqn,
|
|
43
|
+
Link,
|
|
44
|
+
Tag,
|
|
45
|
+
TagSpec,
|
|
46
|
+
TypedElement,
|
|
47
|
+
} from './element'
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
isCustomElement,
|
|
51
|
+
isCustomRelationExpr,
|
|
52
|
+
isElement,
|
|
53
|
+
isElementKindExpr,
|
|
54
|
+
isElementPredicateExpr,
|
|
55
|
+
isElementRef,
|
|
56
|
+
isElementTagExpr,
|
|
57
|
+
isElementWhere,
|
|
58
|
+
isExpandedElementExpr,
|
|
59
|
+
isIncoming,
|
|
60
|
+
isInOut,
|
|
61
|
+
isOutgoing,
|
|
62
|
+
isRelation,
|
|
63
|
+
isRelationExpression,
|
|
64
|
+
isRelationPredicateExpr,
|
|
65
|
+
isRelationWhere,
|
|
66
|
+
isWildcard,
|
|
67
|
+
} from './expression'
|
|
68
|
+
export type {
|
|
69
|
+
CustomElementExpr,
|
|
70
|
+
CustomRelationExpr,
|
|
71
|
+
DirectRelationExpr,
|
|
72
|
+
ElementExpression,
|
|
73
|
+
ElementKindExpr,
|
|
74
|
+
ElementPredicateExpression,
|
|
75
|
+
ElementRefExpr,
|
|
76
|
+
ElementTagExpr,
|
|
77
|
+
ElementWhereExpr,
|
|
78
|
+
ExpandedElementExpr,
|
|
79
|
+
Expression,
|
|
80
|
+
IncomingExpr,
|
|
81
|
+
InOutExpr,
|
|
82
|
+
NonWilcard,
|
|
83
|
+
OutgoingExpr,
|
|
84
|
+
RelationExpression,
|
|
85
|
+
RelationPredicateExpression,
|
|
86
|
+
RelationWhereExpr,
|
|
87
|
+
WildcardExpr,
|
|
88
|
+
} from './expression'
|
|
89
|
+
|
|
90
|
+
export { ExpressionV2, FqnExpr, FqnRef, RelationExpr } from './expression-v2'
|
|
91
|
+
|
|
92
|
+
export type {
|
|
93
|
+
GlobalDynamicPredicates,
|
|
94
|
+
GlobalPredicateId,
|
|
95
|
+
GlobalPredicates,
|
|
96
|
+
GlobalStyleID,
|
|
97
|
+
GlobalStyles,
|
|
98
|
+
ModelGlobals,
|
|
99
|
+
} from './global'
|
|
100
|
+
|
|
101
|
+
export type {
|
|
102
|
+
AnyParsedLikeC4Model,
|
|
103
|
+
ComputedLikeC4Model,
|
|
104
|
+
GenericLikeC4Model,
|
|
105
|
+
LayoutedLikeC4Model,
|
|
106
|
+
LikeC4ModelDump,
|
|
107
|
+
ParsedLikeC4Model,
|
|
108
|
+
} from './model'
|
|
109
|
+
|
|
110
|
+
export {
|
|
111
|
+
isAndOperator,
|
|
112
|
+
isKindEqual,
|
|
113
|
+
isNotOperator,
|
|
114
|
+
isOrOperator,
|
|
115
|
+
isTagEqual,
|
|
116
|
+
whereOperatorAsPredicate,
|
|
117
|
+
} from './operators'
|
|
118
|
+
export type {
|
|
119
|
+
AndOperator,
|
|
120
|
+
EqualOperator,
|
|
121
|
+
Filterable,
|
|
122
|
+
KindEqual,
|
|
123
|
+
NotOperator,
|
|
124
|
+
OrOperator,
|
|
125
|
+
TagEqual,
|
|
126
|
+
WhereOperator,
|
|
127
|
+
} from './operators'
|
|
128
|
+
export type { OverviewGraph } from './overview-graph'
|
|
129
|
+
export { DefaultArrowType, DefaultLineStyle, DefaultRelationshipColor } from './relation'
|
|
130
|
+
export type {
|
|
131
|
+
AbstractRelation,
|
|
132
|
+
ModelRelation,
|
|
133
|
+
RelationId,
|
|
134
|
+
RelationshipArrowType,
|
|
135
|
+
RelationshipKind,
|
|
136
|
+
RelationshipKindSpecification,
|
|
137
|
+
RelationshipLineType,
|
|
138
|
+
} from './relation'
|
|
139
|
+
export { isThemeColor } from './theme'
|
|
140
|
+
export type {
|
|
141
|
+
Color,
|
|
142
|
+
ColorLiteral,
|
|
143
|
+
ElementThemeColors,
|
|
144
|
+
ElementThemeColorValues,
|
|
145
|
+
HexColorLiteral,
|
|
146
|
+
LikeC4Theme,
|
|
147
|
+
RelationshipThemeColors,
|
|
148
|
+
RelationshipThemeColorValues,
|
|
149
|
+
ThemeColor,
|
|
150
|
+
ThemeColorValues,
|
|
151
|
+
} from './theme'
|
|
152
|
+
export {
|
|
153
|
+
ComputedNode, // namespace
|
|
154
|
+
ComputedView, // namespace
|
|
155
|
+
DiagramNode, // namespace
|
|
156
|
+
extractStep,
|
|
157
|
+
getBBoxCenter,
|
|
158
|
+
getParallelStepsPrefix,
|
|
159
|
+
isAutoLayoutDirection,
|
|
160
|
+
isDeploymentView,
|
|
161
|
+
isDynamicView,
|
|
162
|
+
isDynamicViewParallelSteps,
|
|
163
|
+
isElementView,
|
|
164
|
+
isExtendsElementView,
|
|
165
|
+
isScopedElementView,
|
|
166
|
+
isStepEdgeId,
|
|
167
|
+
isViewRuleAutoLayout,
|
|
168
|
+
isViewRuleGlobalPredicateRef,
|
|
169
|
+
isViewRuleGlobalStyle,
|
|
170
|
+
isViewRuleGroup,
|
|
171
|
+
isViewRulePredicate,
|
|
172
|
+
isViewRuleStyle,
|
|
173
|
+
stepEdgeId,
|
|
174
|
+
} from './view'
|
|
175
|
+
export type {
|
|
176
|
+
AutoLayoutDirection,
|
|
177
|
+
BasicElementView,
|
|
178
|
+
BasicView,
|
|
179
|
+
BBox,
|
|
180
|
+
ComputedDeploymentView,
|
|
181
|
+
ComputedDynamicView,
|
|
182
|
+
ComputedEdge,
|
|
183
|
+
ComputedElementView,
|
|
184
|
+
CustomColorDefinitions,
|
|
185
|
+
DeploymentView,
|
|
186
|
+
DeploymentViewRule,
|
|
187
|
+
DeploymentViewRulePredicate,
|
|
188
|
+
DeploymentViewRuleStyle,
|
|
189
|
+
DiagramEdge,
|
|
190
|
+
DiagramView,
|
|
191
|
+
DynamicView,
|
|
192
|
+
DynamicViewIncludeRule,
|
|
193
|
+
DynamicViewParallelSteps,
|
|
194
|
+
DynamicViewRule,
|
|
195
|
+
DynamicViewStep,
|
|
196
|
+
DynamicViewStepOrParallel,
|
|
197
|
+
EdgeId,
|
|
198
|
+
ElementView,
|
|
199
|
+
ExtendsElementView,
|
|
200
|
+
LikeC4View,
|
|
201
|
+
NodeId,
|
|
202
|
+
ScopedElementView,
|
|
203
|
+
StepEdgeId,
|
|
204
|
+
StepEdgeIdLiteral,
|
|
205
|
+
ViewAutoLayout,
|
|
206
|
+
ViewId,
|
|
207
|
+
ViewManualLayout,
|
|
208
|
+
ViewRule,
|
|
209
|
+
ViewRuleAutoLayout,
|
|
210
|
+
ViewRuleGlobalPredicateRef,
|
|
211
|
+
ViewRuleGlobalStyle,
|
|
212
|
+
ViewRuleGroup,
|
|
213
|
+
ViewRulePredicate,
|
|
214
|
+
ViewRuleStyle,
|
|
215
|
+
ViewRuleStyleOrGlobalRef,
|
|
216
|
+
ViewWithHash,
|
|
217
|
+
ViewWithNotation,
|
|
218
|
+
} from './view'
|
|
219
|
+
export type { ViewChange } from './view-changes'
|
|
220
|
+
export type { ElementNotation } from './view-notation'
|
package/src/types/model.ts
CHANGED
|
@@ -1,41 +1,104 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DeploymentElement,
|
|
3
|
+
DeploymentNodeKind,
|
|
4
|
+
DeploymentNodeKindSpecification,
|
|
5
|
+
DeploymentRelation
|
|
6
|
+
} from './deployments'
|
|
1
7
|
import type { ElementKindSpecification, Tag, TypedElement } from './element'
|
|
2
8
|
import type { ModelGlobals } from './global'
|
|
3
|
-
import type {
|
|
4
|
-
import type { ComputedView, DiagramView, LikeC4View
|
|
9
|
+
import type { ModelRelation, RelationId, RelationshipKindSpecification } from './relation'
|
|
10
|
+
import type { ComputedView, DiagramView, LikeC4View } from './view'
|
|
5
11
|
|
|
6
12
|
/**
|
|
7
|
-
*
|
|
13
|
+
* Represents a LikeC4 model with customizable type parameters,
|
|
14
|
+
* parsed from DSL or result from Builder
|
|
15
|
+
*
|
|
16
|
+
* !IMPORTANT: This is a low-level type, use `LikeC4Model` instead.
|
|
17
|
+
* !NOTE: Views are not computed yet.
|
|
18
|
+
*
|
|
19
|
+
* @typeParam ElementKinds - Types of elements in the model (defaults to string)
|
|
20
|
+
* @typeParam RelationKinds - Types of relationships (defaults to string)
|
|
21
|
+
* @typeParam Tags - Types of tags that can be applied (defaults to string)
|
|
22
|
+
* @typeParam Fqns - Fully Qualified Names for elements (defaults to string)
|
|
23
|
+
* @typeParam Views - Types of views in the model (defaults to string)
|
|
24
|
+
* @typeParam DeploymentFqns - Fully Qualified Names for deployment nodes (defaults to string)
|
|
8
25
|
*/
|
|
9
26
|
export interface ParsedLikeC4Model<
|
|
10
27
|
ElementKinds extends string = string,
|
|
11
28
|
RelationKinds extends string = string,
|
|
12
29
|
Tags extends string = string,
|
|
13
30
|
Fqns extends string = string,
|
|
14
|
-
Views extends string = string
|
|
31
|
+
Views extends string = string,
|
|
32
|
+
DeploymentFqns extends string = string
|
|
15
33
|
> {
|
|
34
|
+
// To prevent accidental use of this type
|
|
35
|
+
__?: never
|
|
16
36
|
specification: {
|
|
17
37
|
tags: Tag<Tags>[]
|
|
18
38
|
elements: Record<ElementKinds, ElementKindSpecification>
|
|
39
|
+
deployments: Record<DeploymentNodeKind, DeploymentNodeKindSpecification>
|
|
19
40
|
relationships: Record<RelationKinds, RelationshipKindSpecification>
|
|
20
41
|
}
|
|
21
42
|
elements: Record<Fqns, TypedElement<Fqns, ElementKinds, Tags>>
|
|
22
|
-
relations: Record<
|
|
43
|
+
relations: Record<RelationId, ModelRelation>
|
|
23
44
|
globals: ModelGlobals
|
|
24
45
|
views: Record<Views, LikeC4View<Views, Tags>>
|
|
46
|
+
/**
|
|
47
|
+
* Deployment Model.
|
|
48
|
+
*/
|
|
49
|
+
deployments: {
|
|
50
|
+
elements: Record<DeploymentFqns, DeploymentElement>
|
|
51
|
+
relations: Record<RelationId, DeploymentRelation>
|
|
52
|
+
}
|
|
25
53
|
}
|
|
26
54
|
|
|
55
|
+
export type AnyParsedLikeC4Model = ParsedLikeC4Model<any, any, any, any, any, any>
|
|
27
56
|
/**
|
|
28
|
-
*
|
|
57
|
+
* Hook to get types from dump
|
|
29
58
|
*/
|
|
30
|
-
export
|
|
31
|
-
|
|
32
|
-
|
|
59
|
+
export type LikeC4ModelDump = {
|
|
60
|
+
elements: {
|
|
61
|
+
[kind: string]: object
|
|
62
|
+
}
|
|
63
|
+
deployments: {
|
|
64
|
+
elements: {
|
|
65
|
+
[kind: string]: object
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
views: {
|
|
69
|
+
[kind: string]: object
|
|
70
|
+
}
|
|
33
71
|
}
|
|
34
72
|
|
|
35
73
|
/**
|
|
36
|
-
* Same as
|
|
74
|
+
* Same as {@link ParsedLikeC4Model}, but with computed views or layouted views.
|
|
37
75
|
*/
|
|
38
|
-
export interface
|
|
76
|
+
export interface GenericLikeC4Model<
|
|
77
|
+
Fqns extends string = string,
|
|
78
|
+
DeploymentFqns extends string = string,
|
|
79
|
+
Views extends string = string,
|
|
80
|
+
Tags extends string = string,
|
|
81
|
+
T = 'computed' | 'layouted'
|
|
82
|
+
> extends Omit<ParsedLikeC4Model<string, string, Tags, Fqns, Views, DeploymentFqns>, 'views' | '__'> {
|
|
83
|
+
__?: T
|
|
84
|
+
views: Record<Views, ComputedView<Views> | DiagramView<Views>>
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface ComputedLikeC4Model<
|
|
88
|
+
Fqns extends string = string,
|
|
89
|
+
DeploymentFqns extends string = string,
|
|
90
|
+
Views extends string = string,
|
|
91
|
+
Tags extends string = string
|
|
92
|
+
> extends Omit<GenericLikeC4Model<Fqns, DeploymentFqns, Views, Tags, 'computed'>, 'views'> {
|
|
93
|
+
views: Record<Views, ComputedView<Views>>
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface LayoutedLikeC4Model<
|
|
97
|
+
Fqns extends string = string,
|
|
98
|
+
DeploymentFqns extends string = string,
|
|
99
|
+
Views extends string = string,
|
|
100
|
+
Tags extends string = string
|
|
101
|
+
> extends Omit<GenericLikeC4Model<Fqns, DeploymentFqns, Views, Tags, 'layouted'>, 'views'> {
|
|
39
102
|
__: 'layouted'
|
|
40
|
-
views: Record<
|
|
103
|
+
views: Record<Views, DiagramView<Views, Tags>>
|
|
41
104
|
}
|
package/src/types/operators.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NonEmptyArray, Point, XYPoint } from './_common'
|
|
2
|
-
import type { BBox,
|
|
2
|
+
import type { BBox, ViewId } from './view'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* OverviewGraph is a graph representation of all views in a model
|
|
@@ -17,7 +17,7 @@ export namespace OverviewGraph {
|
|
|
17
17
|
} | {
|
|
18
18
|
id: string
|
|
19
19
|
type: 'view'
|
|
20
|
-
viewId:
|
|
20
|
+
viewId: ViewId
|
|
21
21
|
label: string
|
|
22
22
|
parentId: string | null
|
|
23
23
|
position: XYPoint
|