@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
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { invariant } from '../utils/invariant'
|
|
2
|
+
|
|
3
|
+
export type Point = readonly [x: number, y: number]
|
|
4
|
+
|
|
5
|
+
export interface XYPoint {
|
|
6
|
+
x: number
|
|
7
|
+
y: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Bounding box
|
|
11
|
+
export interface BBox {
|
|
12
|
+
x: number
|
|
13
|
+
y: number
|
|
14
|
+
width: number
|
|
15
|
+
height: number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export namespace BBox {
|
|
19
|
+
export function center({ x, y, width, height }: BBox): XYPoint {
|
|
20
|
+
return {
|
|
21
|
+
x: x + width / 2,
|
|
22
|
+
y: y + height / 2,
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function fromPoints(points: Point[]): BBox {
|
|
27
|
+
const { x1, y1, x2, y2 } = RectBox.fromPoints(points)
|
|
28
|
+
return {
|
|
29
|
+
x: x1,
|
|
30
|
+
y: y1,
|
|
31
|
+
width: x2 - x1,
|
|
32
|
+
height: y2 - y1,
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function merge(...boxes: BBox[]): BBox {
|
|
37
|
+
invariant(boxes.length > 0, 'No boxes provided')
|
|
38
|
+
let minX = Infinity
|
|
39
|
+
let minY = Infinity
|
|
40
|
+
let maxX = -Infinity
|
|
41
|
+
let maxY = -Infinity
|
|
42
|
+
for (const box of boxes) {
|
|
43
|
+
minX = Math.min(minX, box.x)
|
|
44
|
+
minY = Math.min(minY, box.y)
|
|
45
|
+
maxX = Math.max(maxX, box.x + box.width)
|
|
46
|
+
maxY = Math.max(maxY, box.y + box.height)
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
x: minX,
|
|
50
|
+
y: minY,
|
|
51
|
+
width: maxX - minX,
|
|
52
|
+
height: maxY - minY,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function toRectBox(box: BBox): RectBox {
|
|
57
|
+
return {
|
|
58
|
+
x1: box.x,
|
|
59
|
+
y1: box.y,
|
|
60
|
+
x2: box.x + box.width,
|
|
61
|
+
y2: box.y + box.height,
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface RectBox {
|
|
67
|
+
// Top left
|
|
68
|
+
x1: number
|
|
69
|
+
y1: number
|
|
70
|
+
// Bottom right
|
|
71
|
+
x2: number
|
|
72
|
+
y2: number
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export namespace RectBox {
|
|
76
|
+
export function center({ x1, y1, x2, y2 }: RectBox): XYPoint {
|
|
77
|
+
return {
|
|
78
|
+
x: (x1 + x2) / 2,
|
|
79
|
+
y: (y1 + y2) / 2,
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function fromPoints(points: Point[]): RectBox {
|
|
84
|
+
invariant(points.length > 0, 'At least one point is required')
|
|
85
|
+
let minX = Infinity
|
|
86
|
+
let minY = Infinity
|
|
87
|
+
let maxX = -Infinity
|
|
88
|
+
let maxY = -Infinity
|
|
89
|
+
for (const [x, y] of points) {
|
|
90
|
+
minX = Math.min(minX, x)
|
|
91
|
+
minY = Math.min(minY, y)
|
|
92
|
+
maxX = Math.max(maxX, x)
|
|
93
|
+
maxY = Math.max(maxY, y)
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
x1: minX,
|
|
97
|
+
y1: minY,
|
|
98
|
+
x2: maxX,
|
|
99
|
+
y2: maxY,
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function merge(...boxes: RectBox[]): RectBox {
|
|
104
|
+
invariant(boxes.length > 0, 'No boxes provided')
|
|
105
|
+
let minX = Infinity
|
|
106
|
+
let minY = Infinity
|
|
107
|
+
let maxX = -Infinity
|
|
108
|
+
let maxY = -Infinity
|
|
109
|
+
for (const box of boxes) {
|
|
110
|
+
minX = Math.min(minX, box.x1)
|
|
111
|
+
minY = Math.min(minY, box.y1)
|
|
112
|
+
maxX = Math.max(maxX, box.x2)
|
|
113
|
+
maxY = Math.max(maxY, box.y2)
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
x1: minX,
|
|
117
|
+
y1: minY,
|
|
118
|
+
x2: maxX,
|
|
119
|
+
y2: maxY,
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function toBBox(box: RectBox): BBox {
|
|
124
|
+
return {
|
|
125
|
+
x: box.x1,
|
|
126
|
+
y: box.y1,
|
|
127
|
+
width: box.x2 - box.x1,
|
|
128
|
+
height: box.y2 - box.y1,
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
package/src/types/global.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import type { NonEmptyTuple, Tagged } from 'type-fest'
|
|
2
2
|
import type { NonEmptyArray } from './_common'
|
|
3
|
-
import type {
|
|
3
|
+
import type { Any } from './aux'
|
|
4
|
+
import type { DynamicViewIncludeRule } from './view-parsed.dynamic'
|
|
5
|
+
import type { ElementViewPredicate, ElementViewRuleStyle } from './view-parsed.element'
|
|
4
6
|
|
|
5
7
|
export type GlobalPredicateId = Tagged<string, 'GlobalPredicateId'>
|
|
6
8
|
|
|
7
|
-
export type GlobalPredicates = NonEmptyArray<
|
|
9
|
+
export type GlobalPredicates<A extends Any = Any> = NonEmptyArray<ElementViewPredicate<A>>
|
|
8
10
|
|
|
9
|
-
export type GlobalDynamicPredicates = NonEmptyArray<DynamicViewIncludeRule
|
|
11
|
+
export type GlobalDynamicPredicates<A extends Any = Any> = NonEmptyArray<DynamicViewIncludeRule<A>>
|
|
10
12
|
|
|
11
13
|
export type GlobalStyleID = Tagged<string, 'GlobalStyleID'>
|
|
12
14
|
|
|
13
|
-
export type GlobalStyles = NonEmptyTuple<
|
|
15
|
+
export type GlobalStyles<A extends Any = Any> = NonEmptyTuple<ElementViewRuleStyle<A>>
|
|
14
16
|
|
|
15
|
-
export interface ModelGlobals {
|
|
16
|
-
readonly predicates: Record<GlobalPredicateId, GlobalPredicates
|
|
17
|
-
readonly dynamicPredicates: Record<GlobalPredicateId, GlobalDynamicPredicates
|
|
18
|
-
readonly styles: Record<GlobalStyleID, GlobalStyles
|
|
17
|
+
export interface ModelGlobals<A extends Any = Any> {
|
|
18
|
+
readonly predicates: Record<GlobalPredicateId, GlobalPredicates<A>>
|
|
19
|
+
readonly dynamicPredicates: Record<GlobalPredicateId, GlobalDynamicPredicates<A>>
|
|
20
|
+
readonly styles: Record<GlobalStyleID, GlobalStyles<A>>
|
|
19
21
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -1,201 +1,39 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export {
|
|
41
|
-
BorderStyles,
|
|
42
|
-
DefaultElementShape,
|
|
43
|
-
DefaultPaddingSize,
|
|
44
|
-
DefaultShapeSize,
|
|
45
|
-
DefaultTextSize,
|
|
46
|
-
DefaultThemeColor,
|
|
47
|
-
ElementKind,
|
|
48
|
-
ElementShapes,
|
|
49
|
-
} from './element'
|
|
50
|
-
export type {
|
|
51
|
-
BorderStyle,
|
|
52
|
-
Element,
|
|
53
|
-
ElementKindSpecification,
|
|
54
|
-
ElementKindSpecificationStyle,
|
|
55
|
-
ElementShape,
|
|
56
|
-
ElementStyle,
|
|
57
|
-
Link,
|
|
58
|
-
TagSpec,
|
|
59
|
-
TypedElement,
|
|
60
|
-
} from './element'
|
|
61
|
-
|
|
62
|
-
export { ExpressionV2, FqnExpr, FqnRef, RelationExpr } from './expression-v2'
|
|
63
|
-
export { ModelLayer } from './expression-v2-model'
|
|
64
|
-
|
|
65
|
-
export type {
|
|
66
|
-
GlobalDynamicPredicates,
|
|
67
|
-
GlobalPredicateId,
|
|
68
|
-
GlobalPredicates,
|
|
69
|
-
GlobalStyleID,
|
|
70
|
-
GlobalStyles,
|
|
71
|
-
ModelGlobals,
|
|
72
|
-
} from './global'
|
|
73
|
-
|
|
74
|
-
export type {
|
|
75
|
-
AnyParsedLikeC4ModelData,
|
|
76
|
-
ComputedLikeC4ModelData,
|
|
77
|
-
GenericLikeC4ModelData,
|
|
78
|
-
LayoutedLikeC4ModelData,
|
|
79
|
-
LikeC4ModelDump,
|
|
80
|
-
ParsedLikeC4ModelData,
|
|
81
|
-
} from './model-data'
|
|
82
|
-
|
|
83
|
-
export {
|
|
84
|
-
isAndOperator,
|
|
85
|
-
isKindEqual,
|
|
86
|
-
isNotOperator,
|
|
87
|
-
isOrOperator,
|
|
88
|
-
isParticipantOperator,
|
|
89
|
-
isTagEqual,
|
|
90
|
-
whereOperatorAsPredicate,
|
|
91
|
-
} from './operators'
|
|
92
|
-
export type {
|
|
93
|
-
AllNever,
|
|
94
|
-
AndOperator,
|
|
95
|
-
EqualOperator,
|
|
96
|
-
Filterable,
|
|
97
|
-
KindEqual,
|
|
98
|
-
NotOperator,
|
|
99
|
-
OperatorPredicate,
|
|
100
|
-
OrOperator,
|
|
101
|
-
Participant,
|
|
102
|
-
ParticipantOperator,
|
|
103
|
-
TagEqual,
|
|
104
|
-
WhereOperator,
|
|
105
|
-
} from './operators'
|
|
106
|
-
export type { OverviewGraph } from './overview-graph'
|
|
107
|
-
export { DefaultArrowType, DefaultLineStyle, DefaultRelationshipColor } from './relation'
|
|
108
|
-
export type {
|
|
109
|
-
AbstractRelation,
|
|
110
|
-
ModelRelation,
|
|
111
|
-
RelationId,
|
|
112
|
-
RelationshipArrowType,
|
|
113
|
-
RelationshipKind,
|
|
114
|
-
RelationshipKindSpecification,
|
|
115
|
-
RelationshipLineType,
|
|
116
|
-
} from './relation'
|
|
117
|
-
export { isThemeColor, ThemeColors } from './theme'
|
|
118
|
-
export type {
|
|
119
|
-
Color,
|
|
120
|
-
ColorLiteral,
|
|
121
|
-
ElementThemeColors,
|
|
122
|
-
ElementThemeColorValues,
|
|
123
|
-
HexColorLiteral,
|
|
124
|
-
LikeC4Theme,
|
|
125
|
-
RelationshipThemeColors,
|
|
126
|
-
RelationshipThemeColorValues,
|
|
127
|
-
ShapeSize,
|
|
128
|
-
SpacingSize,
|
|
129
|
-
TextSize,
|
|
130
|
-
ThemeColor,
|
|
131
|
-
ThemeColorValues,
|
|
132
|
-
} from './theme'
|
|
133
|
-
export {
|
|
134
|
-
ComputedNode, // namespace
|
|
135
|
-
ComputedView, // namespace
|
|
136
|
-
DiagramNode, // namespace
|
|
137
|
-
extractStep,
|
|
138
|
-
getBBoxCenter,
|
|
139
|
-
getParallelStepsPrefix,
|
|
140
|
-
isAutoLayoutDirection,
|
|
141
|
-
isDeploymentView,
|
|
142
|
-
isDynamicView,
|
|
143
|
-
isDynamicViewParallelSteps,
|
|
144
|
-
isElementView,
|
|
145
|
-
isExtendsElementView,
|
|
146
|
-
isScopedElementView,
|
|
147
|
-
isStepEdgeId,
|
|
148
|
-
isViewRuleAutoLayout,
|
|
149
|
-
isViewRuleGlobalPredicateRef,
|
|
150
|
-
isViewRuleGlobalStyle,
|
|
151
|
-
isViewRuleGroup,
|
|
152
|
-
isViewRulePredicate,
|
|
153
|
-
isViewRuleStyle,
|
|
154
|
-
stepEdgeId,
|
|
155
|
-
} from './view'
|
|
156
|
-
export type {
|
|
157
|
-
AutoLayoutDirection,
|
|
158
|
-
BasicElementView,
|
|
159
|
-
BasicView,
|
|
160
|
-
BBox,
|
|
161
|
-
ComputedDeploymentView,
|
|
162
|
-
ComputedDynamicView,
|
|
163
|
-
ComputedEdge,
|
|
164
|
-
ComputedElementView,
|
|
165
|
-
CustomColorDefinitions,
|
|
166
|
-
DeploymentView,
|
|
167
|
-
DeploymentViewRule,
|
|
168
|
-
DeploymentViewRulePredicate,
|
|
169
|
-
DeploymentViewRuleStyle,
|
|
170
|
-
DiagramEdge,
|
|
171
|
-
DiagramView,
|
|
172
|
-
DynamicView,
|
|
173
|
-
DynamicViewIncludeRule,
|
|
174
|
-
DynamicViewParallelSteps,
|
|
175
|
-
DynamicViewRule,
|
|
176
|
-
DynamicViewStep,
|
|
177
|
-
DynamicViewStepOrParallel,
|
|
178
|
-
EdgeId,
|
|
179
|
-
ElementView,
|
|
180
|
-
ExtendsElementView,
|
|
181
|
-
LikeC4View,
|
|
182
|
-
NodeId,
|
|
183
|
-
ScopedElementView,
|
|
184
|
-
StepEdgeId,
|
|
185
|
-
StepEdgeIdLiteral,
|
|
186
|
-
ViewAutoLayout,
|
|
187
|
-
ViewId,
|
|
188
|
-
ViewManualLayout,
|
|
189
|
-
ViewRule,
|
|
190
|
-
ViewRuleAutoLayout,
|
|
191
|
-
ViewRuleGlobalPredicateRef,
|
|
192
|
-
ViewRuleGlobalStyle,
|
|
193
|
-
ViewRuleGroup,
|
|
194
|
-
ViewRulePredicate,
|
|
195
|
-
ViewRuleStyle,
|
|
196
|
-
ViewRuleStyleOrGlobalRef,
|
|
197
|
-
ViewWithHash,
|
|
198
|
-
ViewWithNotation,
|
|
199
|
-
} from './view'
|
|
200
|
-
export type { ViewChange } from './view-changes'
|
|
201
|
-
export type { ElementNotation } from './view-notation'
|
|
1
|
+
export * from './_common'
|
|
2
|
+
|
|
3
|
+
export type * as aux from './aux'
|
|
4
|
+
|
|
5
|
+
export type {
|
|
6
|
+
Any,
|
|
7
|
+
AnyAux,
|
|
8
|
+
Aux,
|
|
9
|
+
SpecAux,
|
|
10
|
+
Unknown,
|
|
11
|
+
UnknownComputed,
|
|
12
|
+
UnknownLayouted,
|
|
13
|
+
UnknownParsed,
|
|
14
|
+
} from './aux'
|
|
15
|
+
|
|
16
|
+
export * from './const'
|
|
17
|
+
export * from './expression'
|
|
18
|
+
export * from './expression-model'
|
|
19
|
+
export * from './fqnRef'
|
|
20
|
+
export * from './geometry'
|
|
21
|
+
export * from './global'
|
|
22
|
+
export * from './model-data'
|
|
23
|
+
export * from './model-deployment'
|
|
24
|
+
export * from './model-dump'
|
|
25
|
+
export * from './model-logical'
|
|
26
|
+
export * from './model-spec'
|
|
27
|
+
export * from './operators'
|
|
28
|
+
export * from './scalar'
|
|
29
|
+
export * from './styles'
|
|
30
|
+
export * from './view'
|
|
31
|
+
export * from './view-changes'
|
|
32
|
+
export * from './view-common'
|
|
33
|
+
export * from './view-computed'
|
|
34
|
+
export * from './view-layouted'
|
|
35
|
+
export * from './view-parsed.deployment'
|
|
36
|
+
export * from './view-parsed.dynamic'
|
|
37
|
+
export * from './view-parsed.element'
|
|
38
|
+
|
|
39
|
+
export type * as scalar from './scalar'
|
package/src/types/model-data.ts
CHANGED
|
@@ -1,15 +1,35 @@
|
|
|
1
|
+
import type { IsAny } from 'type-fest'
|
|
1
2
|
import type { NonEmptyArray } from './_common'
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
DeploymentNodeKindSpecification,
|
|
6
|
-
DeploymentRelation,
|
|
7
|
-
} from './deployments'
|
|
8
|
-
import type { Element, ElementKindSpecification, TypedElement } from './element'
|
|
3
|
+
import type * as aux from './aux'
|
|
4
|
+
import type { Any } from './aux'
|
|
5
|
+
import type { _stage } from './const'
|
|
9
6
|
import type { ModelGlobals } from './global'
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
7
|
+
import type { DeploymentElement, DeploymentRelationship } from './model-deployment'
|
|
8
|
+
import type { Element, Relationship } from './model-logical'
|
|
9
|
+
import type { Specification } from './model-spec'
|
|
10
|
+
import type * as scalar from './scalar'
|
|
11
|
+
import type { ComputedView, LayoutedView, ParsedView } from './view'
|
|
12
|
+
|
|
13
|
+
interface BaseLikeC4ModelData<A extends aux.Any> {
|
|
14
|
+
projectId: aux.ProjectId<A>
|
|
15
|
+
specification: Specification<A>
|
|
16
|
+
elements: Record<aux.ElementId<A>, Element<A>>
|
|
17
|
+
deployments: {
|
|
18
|
+
elements: Record<aux.DeploymentId<A>, DeploymentElement<A>>
|
|
19
|
+
relations: Record<scalar.RelationId, DeploymentRelationship<A>>
|
|
20
|
+
}
|
|
21
|
+
relations: Record<scalar.RelationId, Relationship<A>>
|
|
22
|
+
globals: ModelGlobals
|
|
23
|
+
imports: Record<string, NonEmptyArray<Element<A>>>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type AuxFromLikeC4ModelData<D> =
|
|
27
|
+
// dprint-ignore
|
|
28
|
+
D extends BaseLikeC4ModelData<infer A extends Any>
|
|
29
|
+
? IsAny<A> extends true
|
|
30
|
+
? never
|
|
31
|
+
: A
|
|
32
|
+
: never
|
|
13
33
|
|
|
14
34
|
/**
|
|
15
35
|
* Represents a LikeC4 model with customizable type parameters,
|
|
@@ -25,83 +45,31 @@ import type { ComputedView, DiagramView, LikeC4View } from './view'
|
|
|
25
45
|
* @typeParam Views - Types of views in the model (defaults to string)
|
|
26
46
|
* @typeParam DeploymentFqns - Fully Qualified Names for deployment nodes (defaults to string)
|
|
27
47
|
*/
|
|
28
|
-
export interface ParsedLikeC4ModelData<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Fqns extends string = string,
|
|
33
|
-
Views extends string = string,
|
|
34
|
-
DeploymentFqns extends string = string,
|
|
35
|
-
> {
|
|
36
|
-
// To prevent accidental use of this type
|
|
37
|
-
__?: never
|
|
38
|
-
specification: {
|
|
39
|
-
tags: Tag<Tags>[]
|
|
40
|
-
elements: Record<ElementKinds, ElementKindSpecification>
|
|
41
|
-
deployments: Record<DeploymentNodeKind, DeploymentNodeKindSpecification>
|
|
42
|
-
relationships: Record<RelationKinds, RelationshipKindSpecification>
|
|
43
|
-
}
|
|
44
|
-
elements: Record<Fqns, TypedElement<Fqns, ElementKinds, Tags>>
|
|
45
|
-
relations: Record<RelationId, ModelRelation>
|
|
46
|
-
globals: ModelGlobals
|
|
47
|
-
views: Record<Views, LikeC4View<Views, Tags>>
|
|
48
|
-
/**
|
|
49
|
-
* Deployment Model.
|
|
50
|
-
*/
|
|
51
|
-
deployments: {
|
|
52
|
-
elements: Record<DeploymentFqns, DeploymentElement>
|
|
53
|
-
relations: Record<RelationId, DeploymentRelation>
|
|
54
|
-
}
|
|
55
|
-
imports: Record<ProjectId, NonEmptyArray<Element>>
|
|
48
|
+
export interface ParsedLikeC4ModelData<A extends Any = aux.UnknownParsed> extends BaseLikeC4ModelData<A> {
|
|
49
|
+
[_stage]: 'parsed'
|
|
50
|
+
// globals: ModelGlobals<A
|
|
51
|
+
views: Record<aux.ViewId<A>, ParsedView<A>>
|
|
56
52
|
}
|
|
57
53
|
|
|
58
|
-
export
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
elements: {
|
|
64
|
-
[kind: string]: object
|
|
65
|
-
}
|
|
66
|
-
deployments: {
|
|
67
|
-
elements: {
|
|
68
|
-
[kind: string]: object
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
views: {
|
|
72
|
-
[kind: string]: object
|
|
73
|
-
}
|
|
54
|
+
export interface ComputedLikeC4ModelData<A extends Any = aux.UnknownComputed> extends BaseLikeC4ModelData<A> {
|
|
55
|
+
[_stage]: 'computed'
|
|
56
|
+
// specification: Specification<A>
|
|
57
|
+
// globals: ModelGlobals<A>
|
|
58
|
+
views: Record<aux.ViewId<A>, ComputedView<A>>
|
|
74
59
|
}
|
|
75
60
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
Fqns extends string = string,
|
|
81
|
-
DeploymentFqns extends string = string,
|
|
82
|
-
Views extends string = string,
|
|
83
|
-
Tags extends string = string,
|
|
84
|
-
T = 'computed' | 'layouted',
|
|
85
|
-
> extends Omit<ParsedLikeC4ModelData<string, string, Tags, Fqns, Views, DeploymentFqns>, 'views' | '__'> {
|
|
86
|
-
__?: T
|
|
87
|
-
views: Record<Views, ComputedView<Views> | DiagramView<Views>>
|
|
61
|
+
export interface LayoutedLikeC4ModelData<A extends Any = aux.UnknownLayouted> extends BaseLikeC4ModelData<A> {
|
|
62
|
+
[_stage]: 'layouted'
|
|
63
|
+
// globals: ModelGlobals<A>
|
|
64
|
+
views: Record<aux.ViewId<A>, LayoutedView<A>>
|
|
88
65
|
}
|
|
89
66
|
|
|
90
|
-
export
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
export interface LayoutedLikeC4ModelData<
|
|
100
|
-
Fqns extends string = string,
|
|
101
|
-
DeploymentFqns extends string = string,
|
|
102
|
-
Views extends string = string,
|
|
103
|
-
Tags extends string = string,
|
|
104
|
-
> extends Omit<GenericLikeC4ModelData<Fqns, DeploymentFqns, Views, Tags, 'layouted'>, 'views'> {
|
|
105
|
-
__: 'layouted'
|
|
106
|
-
views: Record<Views, DiagramView<Views, Tags>>
|
|
107
|
-
}
|
|
67
|
+
export type LikeC4ModelData<A extends Any> =
|
|
68
|
+
| ParsedLikeC4ModelData<A>
|
|
69
|
+
| ComputedLikeC4ModelData<A>
|
|
70
|
+
| LayoutedLikeC4ModelData<A>
|
|
71
|
+
// ExclusiveUnion<{
|
|
72
|
+
// Parsed: ParsedLikeC4ModelData<A>
|
|
73
|
+
// Computed: ComputedLikeC4ModelData<A>
|
|
74
|
+
// Layouted: LayoutedLikeC4ModelData<A>
|
|
75
|
+
// }>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { isTruthy } from 'remeda'
|
|
2
|
+
import type { Link } from './_common'
|
|
3
|
+
import type * as aux from './aux'
|
|
4
|
+
import type { AnyAux, Unknown } from './aux'
|
|
5
|
+
import type { FqnRef } from './fqnRef'
|
|
6
|
+
import type { AbstractRelationship, ElementStyle } from './model-logical'
|
|
7
|
+
import type { Icon } from './scalar'
|
|
8
|
+
import type { Color, ElementShape } from './styles'
|
|
9
|
+
|
|
10
|
+
export interface DeploymentElementStyle extends ElementStyle {
|
|
11
|
+
readonly icon?: Icon
|
|
12
|
+
readonly shape?: ElementShape
|
|
13
|
+
readonly color?: Color
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// dprint-ignore
|
|
17
|
+
export interface DeploymentNode<A extends AnyAux = Unknown>
|
|
18
|
+
extends
|
|
19
|
+
aux.WithOptionalTags<A>,
|
|
20
|
+
aux.WithOptionalLinks,
|
|
21
|
+
aux.WithMetadata<A>
|
|
22
|
+
{
|
|
23
|
+
element?: never
|
|
24
|
+
// Full-qualified-name for Deployment model
|
|
25
|
+
readonly id: aux.StrictDeploymentFqn<A>
|
|
26
|
+
readonly kind: aux.DeploymentKind<A>
|
|
27
|
+
readonly title: string
|
|
28
|
+
readonly description?: string | null
|
|
29
|
+
readonly technology?: string | null
|
|
30
|
+
readonly tags?: aux.Tags<A> | null
|
|
31
|
+
readonly links?: readonly Link[] | null
|
|
32
|
+
readonly style: DeploymentElementStyle
|
|
33
|
+
readonly notation?: string
|
|
34
|
+
readonly metadata?: aux.Metadata<A>
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// dprint-ignore
|
|
38
|
+
export interface DeployedInstance<A extends AnyAux = Unknown>
|
|
39
|
+
extends
|
|
40
|
+
aux.WithOptionalTags<A>,
|
|
41
|
+
aux.WithOptionalLinks,
|
|
42
|
+
aux.WithMetadata<A>
|
|
43
|
+
{
|
|
44
|
+
kind?: never
|
|
45
|
+
/**
|
|
46
|
+
* Format: `<DeploymentNode Fqn>.<Instance Id>`
|
|
47
|
+
* i.e parent fqn is deployment target
|
|
48
|
+
*/
|
|
49
|
+
readonly id: aux.StrictDeploymentFqn<A>
|
|
50
|
+
readonly element: aux.StrictFqn<A>
|
|
51
|
+
readonly title?: string
|
|
52
|
+
readonly description?: string | null
|
|
53
|
+
readonly technology?: string | null
|
|
54
|
+
readonly tags?: aux.Tags<A> | null
|
|
55
|
+
readonly links?: readonly Link[] | null
|
|
56
|
+
readonly style?: DeploymentElementStyle
|
|
57
|
+
readonly notation?: string
|
|
58
|
+
readonly metadata?: aux.Metadata<A>
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type DeploymentElement<A extends AnyAux = Unknown> = DeploymentNode<A> | DeployedInstance<A>
|
|
62
|
+
|
|
63
|
+
export type DeploymentElementRef<A extends AnyAux = Unknown> = {
|
|
64
|
+
readonly id: aux.StrictDeploymentFqn<A>
|
|
65
|
+
readonly element?: aux.StrictFqn<A>
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function isDeploymentNode<A extends AnyAux>(el: DeploymentElement<A>): el is DeploymentNode<A> {
|
|
69
|
+
return 'kind' in el && !isTruthy(el.element)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function isDeployedInstance<A extends AnyAux>(el: DeploymentElement<A>): el is DeployedInstance<A> {
|
|
73
|
+
return 'element' in el && isTruthy(el.element)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Relationship in deployment model
|
|
78
|
+
*/
|
|
79
|
+
export interface DeploymentRelationship<A extends AnyAux = Unknown> extends AbstractRelationship<A> {
|
|
80
|
+
readonly source: FqnRef.DeploymentRef<A>
|
|
81
|
+
readonly target: FqnRef.DeploymentRef<A>
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Backward compatibility alias
|
|
85
|
+
* @deprecated Use {@link DeploymentRelationship} instead
|
|
86
|
+
*/
|
|
87
|
+
export type DeploymentRelation<A extends AnyAux = Unknown> = DeploymentRelationship<A>
|