@likec4/core 1.1.1 → 1.2.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/dist/types/index.d.ts +0 -2
- package/dist/types/index.js +0 -2
- package/dist/types/model.d.ts +2 -3
- package/dist/types/view.d.ts +132 -8
- package/dist/types/view.js +31 -3
- package/package.json +3 -3
- package/dist/types/computed-view.d.ts +0 -52
- package/dist/types/computed-view.js +0 -1
- package/dist/types/diagram.d.ts +0 -40
- package/dist/types/diagram.js +0 -1
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
package/dist/types/model.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { ComputedView } from './computed-view';
|
|
2
1
|
import type { Element, Fqn } from './element';
|
|
3
2
|
import type { Relation, RelationID } from './relation';
|
|
4
|
-
import type {
|
|
3
|
+
import type { ComputedView, View, ViewID } from './view';
|
|
5
4
|
export interface LikeC4Model {
|
|
6
5
|
elements: Record<Fqn, Element>;
|
|
7
6
|
relations: Record<RelationID, Relation>;
|
|
8
|
-
views: Record<ViewID,
|
|
7
|
+
views: Record<ViewID, View>;
|
|
9
8
|
}
|
|
10
9
|
export interface LikeC4ComputedModel {
|
|
11
10
|
elements: Record<Fqn, Element>;
|
package/dist/types/view.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { IconUrl, NonEmptyArray } from './_common';
|
|
2
|
-
import type { ElementShape, ElementStyle, Fqn, Tag } from './element';
|
|
3
|
-
import type { ElementExpression, Expression } from './expression';
|
|
2
|
+
import type { ElementKind, ElementShape, ElementStyle, Fqn, Tag } from './element';
|
|
3
|
+
import type { CustomElementExpr, ElementExpression, Expression } from './expression';
|
|
4
4
|
import type { Opaque } from './opaque';
|
|
5
|
-
import type {
|
|
5
|
+
import type { RelationID, RelationshipArrowType, RelationshipLineType } from './relation';
|
|
6
|
+
import type { ColorLiteral, ThemeColor } from './theme';
|
|
6
7
|
export type ViewID = Opaque<string, 'ViewID'>;
|
|
7
8
|
export type ViewRuleExpression = {
|
|
8
9
|
include: Expression[];
|
|
@@ -27,14 +28,13 @@ export interface ViewRuleAutoLayout {
|
|
|
27
28
|
}
|
|
28
29
|
export declare function isViewRuleAutoLayout(rule: ViewRule): rule is ViewRuleAutoLayout;
|
|
29
30
|
export type ViewRule = ViewRuleExpression | ViewRuleStyle | ViewRuleAutoLayout;
|
|
30
|
-
export interface
|
|
31
|
+
export interface BasicView<ViewType extends 'element' | 'dynamic' = 'element' | 'dynamic'> {
|
|
32
|
+
readonly __?: ViewType;
|
|
31
33
|
readonly id: ViewID;
|
|
32
|
-
readonly viewOf?: Fqn;
|
|
33
34
|
readonly title: string | null;
|
|
34
35
|
readonly description: string | null;
|
|
35
36
|
readonly tags: NonEmptyArray<Tag> | null;
|
|
36
37
|
readonly links: NonEmptyArray<string> | null;
|
|
37
|
-
readonly rules: ViewRule[];
|
|
38
38
|
/**
|
|
39
39
|
* URI to the source file of this view.
|
|
40
40
|
* Undefined if the view is auto-generated.
|
|
@@ -51,12 +51,136 @@ export interface BasicElementView {
|
|
|
51
51
|
*/
|
|
52
52
|
readonly relativePath?: string;
|
|
53
53
|
}
|
|
54
|
+
export interface BasicElementView extends BasicView<'element'> {
|
|
55
|
+
readonly viewOf?: Fqn;
|
|
56
|
+
readonly rules: ViewRule[];
|
|
57
|
+
}
|
|
54
58
|
export interface StrictElementView extends BasicElementView {
|
|
55
59
|
readonly viewOf: Fqn;
|
|
56
60
|
}
|
|
57
|
-
export declare function isStrictElementView(view: ElementView): view is StrictElementView;
|
|
58
61
|
export interface ExtendsElementView extends BasicElementView {
|
|
59
62
|
readonly extends: ViewID;
|
|
60
63
|
}
|
|
61
|
-
export declare function isExtendsElementView(view: ElementView): view is ExtendsElementView;
|
|
62
64
|
export type ElementView = StrictElementView | ExtendsElementView | BasicElementView;
|
|
65
|
+
export interface DynamicViewStep {
|
|
66
|
+
readonly source: Fqn;
|
|
67
|
+
readonly target: Fqn;
|
|
68
|
+
readonly title: string | null;
|
|
69
|
+
readonly isBackward?: boolean;
|
|
70
|
+
}
|
|
71
|
+
export type DynamicViewIncludeRule = {
|
|
72
|
+
include: (ElementExpression | CustomElementExpr)[];
|
|
73
|
+
};
|
|
74
|
+
export declare function isDynamicViewIncludeRule(rule: DynamicViewRule): rule is DynamicViewIncludeRule;
|
|
75
|
+
export type DynamicViewRule = DynamicViewIncludeRule | ViewRuleStyle | ViewRuleAutoLayout;
|
|
76
|
+
export interface DynamicView extends BasicView<'dynamic'> {
|
|
77
|
+
readonly __: 'dynamic';
|
|
78
|
+
readonly steps: DynamicViewStep[];
|
|
79
|
+
readonly rules: DynamicViewRule[];
|
|
80
|
+
}
|
|
81
|
+
export type View = ElementView | DynamicView;
|
|
82
|
+
export declare function isDynamicView(view: View): view is DynamicView;
|
|
83
|
+
export declare function isElementView(view: View): view is ElementView;
|
|
84
|
+
export declare function isExtendsElementView(view: View): view is ExtendsElementView;
|
|
85
|
+
export declare function isStrictElementView(view: View): view is StrictElementView;
|
|
86
|
+
export type NodeId = Fqn;
|
|
87
|
+
export type EdgeId = Opaque<string, 'EdgeId'>;
|
|
88
|
+
export type StepEdgeIdLiteral = `step-${number}`;
|
|
89
|
+
export type StepEdgeId = Opaque<StepEdgeIdLiteral, 'EdgeId'>;
|
|
90
|
+
export declare function StepEdgeId(step: number): StepEdgeId;
|
|
91
|
+
export declare function isStepEdgeId(id: string): id is StepEdgeId;
|
|
92
|
+
export declare function extractStep(id: EdgeId): number;
|
|
93
|
+
export interface ComputedNode {
|
|
94
|
+
id: NodeId;
|
|
95
|
+
kind: ElementKind;
|
|
96
|
+
parent: NodeId | null;
|
|
97
|
+
title: string;
|
|
98
|
+
description: string | null;
|
|
99
|
+
technology: string | null;
|
|
100
|
+
tags: NonEmptyArray<Tag> | null;
|
|
101
|
+
links: NonEmptyArray<string> | null;
|
|
102
|
+
children: NodeId[];
|
|
103
|
+
inEdges: EdgeId[];
|
|
104
|
+
outEdges: EdgeId[];
|
|
105
|
+
shape: ElementShape;
|
|
106
|
+
/**
|
|
107
|
+
* @deprecated Use `style` instead
|
|
108
|
+
*/
|
|
109
|
+
color: ThemeColor;
|
|
110
|
+
/**
|
|
111
|
+
* @deprecated Use `style` instead
|
|
112
|
+
*/
|
|
113
|
+
icon?: IconUrl;
|
|
114
|
+
style: ElementStyle;
|
|
115
|
+
navigateTo?: ViewID;
|
|
116
|
+
level: number;
|
|
117
|
+
depth?: number;
|
|
118
|
+
}
|
|
119
|
+
export interface ComputedEdge {
|
|
120
|
+
id: EdgeId;
|
|
121
|
+
parent: NodeId | null;
|
|
122
|
+
source: NodeId;
|
|
123
|
+
target: NodeId;
|
|
124
|
+
label: string | null;
|
|
125
|
+
relations: RelationID[];
|
|
126
|
+
color?: ThemeColor;
|
|
127
|
+
line?: RelationshipLineType;
|
|
128
|
+
head?: RelationshipArrowType;
|
|
129
|
+
tail?: RelationshipArrowType;
|
|
130
|
+
/**
|
|
131
|
+
* For layouting purposes
|
|
132
|
+
* @default 'forward'
|
|
133
|
+
*/
|
|
134
|
+
dir?: 'forward' | 'back';
|
|
135
|
+
}
|
|
136
|
+
export interface ComputedElementView extends Omit<ElementView, 'rules'> {
|
|
137
|
+
readonly extends?: ViewID;
|
|
138
|
+
readonly autoLayout: ViewRuleAutoLayout['autoLayout'];
|
|
139
|
+
readonly nodes: ComputedNode[];
|
|
140
|
+
readonly edges: ComputedEdge[];
|
|
141
|
+
}
|
|
142
|
+
export interface ComputedDynamicView extends Omit<DynamicView, 'rules' | 'steps'> {
|
|
143
|
+
readonly autoLayout: ViewRuleAutoLayout['autoLayout'];
|
|
144
|
+
readonly nodes: ComputedNode[];
|
|
145
|
+
readonly edges: ComputedEdge[];
|
|
146
|
+
}
|
|
147
|
+
export declare function isComputedDynamicView(view: ComputedView): view is ComputedDynamicView;
|
|
148
|
+
export type ComputedView = ComputedElementView | ComputedDynamicView;
|
|
149
|
+
export declare function isComputedElementView(view: ComputedView): view is ComputedElementView;
|
|
150
|
+
export type Point = readonly [x: number, y: number];
|
|
151
|
+
export type BBox = {
|
|
152
|
+
x: number;
|
|
153
|
+
y: number;
|
|
154
|
+
width: number;
|
|
155
|
+
height: number;
|
|
156
|
+
};
|
|
157
|
+
export interface DiagramLabel {
|
|
158
|
+
align: 'left' | 'right' | 'center';
|
|
159
|
+
fontStyle?: 'bold' | 'normal';
|
|
160
|
+
color?: ColorLiteral;
|
|
161
|
+
fontSize: number;
|
|
162
|
+
pt: Point;
|
|
163
|
+
width: number;
|
|
164
|
+
text: string;
|
|
165
|
+
}
|
|
166
|
+
export interface DiagramNode extends ComputedNode {
|
|
167
|
+
width: number;
|
|
168
|
+
height: number;
|
|
169
|
+
position: Point;
|
|
170
|
+
labels: DiagramLabel[];
|
|
171
|
+
}
|
|
172
|
+
export interface DiagramEdge extends ComputedEdge {
|
|
173
|
+
points: NonEmptyArray<Point>;
|
|
174
|
+
headArrow?: NonEmptyArray<Point>;
|
|
175
|
+
headArrowPoint?: Point;
|
|
176
|
+
tailArrow?: NonEmptyArray<Point>;
|
|
177
|
+
tailArrowPoint?: Point;
|
|
178
|
+
labels?: NonEmptyArray<DiagramLabel>;
|
|
179
|
+
labelBBox?: BBox;
|
|
180
|
+
}
|
|
181
|
+
export interface DiagramView extends Omit<ComputedView, 'nodes' | 'edges'> {
|
|
182
|
+
readonly nodes: DiagramNode[];
|
|
183
|
+
readonly edges: DiagramEdge[];
|
|
184
|
+
readonly width: number;
|
|
185
|
+
readonly height: number;
|
|
186
|
+
}
|
package/dist/types/view.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isNullish } from 'remeda';
|
|
1
2
|
export function isViewRuleExpression(rule) {
|
|
2
3
|
return (('include' in rule && Array.isArray(rule.include))
|
|
3
4
|
|| ('exclude' in rule && Array.isArray(rule.exclude)));
|
|
@@ -8,9 +9,36 @@ export function isViewRuleStyle(rule) {
|
|
|
8
9
|
export function isViewRuleAutoLayout(rule) {
|
|
9
10
|
return 'autoLayout' in rule;
|
|
10
11
|
}
|
|
11
|
-
export function
|
|
12
|
-
return '
|
|
12
|
+
export function isDynamicViewIncludeRule(rule) {
|
|
13
|
+
return 'include' in rule && Array.isArray(rule.include);
|
|
14
|
+
}
|
|
15
|
+
export function isDynamicView(view) {
|
|
16
|
+
return view.__ === 'dynamic';
|
|
17
|
+
}
|
|
18
|
+
export function isElementView(view) {
|
|
19
|
+
return isNullish(view.__) || view.__ === 'element';
|
|
13
20
|
}
|
|
14
21
|
export function isExtendsElementView(view) {
|
|
15
|
-
return 'extends' in view;
|
|
22
|
+
return isElementView(view) && 'extends' in view;
|
|
23
|
+
}
|
|
24
|
+
export function isStrictElementView(view) {
|
|
25
|
+
return isElementView(view) && 'viewOf' in view;
|
|
26
|
+
}
|
|
27
|
+
export function StepEdgeId(step) {
|
|
28
|
+
return `step-${String(step).padStart(3, '0')}`;
|
|
29
|
+
}
|
|
30
|
+
export function isStepEdgeId(id) {
|
|
31
|
+
return id.startsWith('step-');
|
|
32
|
+
}
|
|
33
|
+
export function extractStep(id) {
|
|
34
|
+
if (!isStepEdgeId(id)) {
|
|
35
|
+
throw new Error(`Invalid step edge id: ${id}`);
|
|
36
|
+
}
|
|
37
|
+
return Number(id.slice('step-'.length));
|
|
38
|
+
}
|
|
39
|
+
export function isComputedDynamicView(view) {
|
|
40
|
+
return view.__ === 'dynamic';
|
|
41
|
+
}
|
|
42
|
+
export function isComputedElementView(view) {
|
|
43
|
+
return isNullish(view.__) || view.__ === 'element';
|
|
16
44
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://likec4.dev",
|
|
6
6
|
"author": "Denis Davydkov <denis@davydkov.com>",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
13
13
|
"scripts": {
|
|
14
|
-
"typecheck": "tsc
|
|
14
|
+
"typecheck": "tsc -b",
|
|
15
15
|
"build": "tsc",
|
|
16
16
|
"prepack": "tsc -p tsconfig.build.json",
|
|
17
17
|
"lint": "run -T eslint src/ --fix",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"typescript": "^5.4.5",
|
|
77
77
|
"vitest": "~1.5.2"
|
|
78
78
|
},
|
|
79
|
-
"packageManager": "yarn@4.
|
|
79
|
+
"packageManager": "yarn@4.3.0"
|
|
80
80
|
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { IconUrl, NonEmptyArray } from './_common';
|
|
2
|
-
import type { ElementKind, ElementShape, ElementStyle, Fqn, Tag } from './element';
|
|
3
|
-
import type { Opaque } from './opaque';
|
|
4
|
-
import type { RelationID, RelationshipArrowType, RelationshipLineType } from './relation';
|
|
5
|
-
import type { ThemeColor } from './theme';
|
|
6
|
-
import type { BasicElementView, ViewID, ViewRuleAutoLayout } from './view';
|
|
7
|
-
export type NodeId = Fqn;
|
|
8
|
-
export type EdgeId = Opaque<string, 'EdgeId'>;
|
|
9
|
-
export interface ComputedNode {
|
|
10
|
-
id: NodeId;
|
|
11
|
-
kind: ElementKind;
|
|
12
|
-
parent: NodeId | null;
|
|
13
|
-
title: string;
|
|
14
|
-
description: string | null;
|
|
15
|
-
technology: string | null;
|
|
16
|
-
tags: NonEmptyArray<Tag> | null;
|
|
17
|
-
links: NonEmptyArray<string> | null;
|
|
18
|
-
children: NodeId[];
|
|
19
|
-
inEdges: EdgeId[];
|
|
20
|
-
outEdges: EdgeId[];
|
|
21
|
-
shape: ElementShape;
|
|
22
|
-
/**
|
|
23
|
-
* @deprecated Use `style` instead
|
|
24
|
-
*/
|
|
25
|
-
color: ThemeColor;
|
|
26
|
-
/**
|
|
27
|
-
* @deprecated Use `style` instead
|
|
28
|
-
*/
|
|
29
|
-
icon?: IconUrl;
|
|
30
|
-
style: ElementStyle;
|
|
31
|
-
navigateTo?: ViewID;
|
|
32
|
-
level: number;
|
|
33
|
-
depth?: number;
|
|
34
|
-
}
|
|
35
|
-
export interface ComputedEdge {
|
|
36
|
-
id: EdgeId;
|
|
37
|
-
parent: NodeId | null;
|
|
38
|
-
source: NodeId;
|
|
39
|
-
target: NodeId;
|
|
40
|
-
label: string | null;
|
|
41
|
-
relations: RelationID[];
|
|
42
|
-
color?: ThemeColor;
|
|
43
|
-
line?: RelationshipLineType;
|
|
44
|
-
head?: RelationshipArrowType;
|
|
45
|
-
tail?: RelationshipArrowType;
|
|
46
|
-
}
|
|
47
|
-
export interface ComputedView extends Omit<BasicElementView, 'rules'> {
|
|
48
|
-
readonly extends?: ViewID;
|
|
49
|
-
readonly autoLayout: ViewRuleAutoLayout['autoLayout'];
|
|
50
|
-
readonly nodes: ComputedNode[];
|
|
51
|
-
readonly edges: ComputedEdge[];
|
|
52
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types/diagram.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { NonEmptyArray } from './_common';
|
|
2
|
-
import type { ComputedEdge, ComputedNode, ComputedView } from './computed-view';
|
|
3
|
-
import type { ColorLiteral } from './theme';
|
|
4
|
-
export type Point = readonly [x: number, y: number];
|
|
5
|
-
export type BBox = {
|
|
6
|
-
x: number;
|
|
7
|
-
y: number;
|
|
8
|
-
width: number;
|
|
9
|
-
height: number;
|
|
10
|
-
};
|
|
11
|
-
export interface DiagramLabel {
|
|
12
|
-
align: 'left' | 'right' | 'center';
|
|
13
|
-
fontStyle?: 'bold' | 'normal';
|
|
14
|
-
color?: ColorLiteral;
|
|
15
|
-
fontSize: number;
|
|
16
|
-
pt: Point;
|
|
17
|
-
width: number;
|
|
18
|
-
text: string;
|
|
19
|
-
}
|
|
20
|
-
export interface DiagramNode extends ComputedNode {
|
|
21
|
-
width: number;
|
|
22
|
-
height: number;
|
|
23
|
-
position: Point;
|
|
24
|
-
labels: DiagramLabel[];
|
|
25
|
-
}
|
|
26
|
-
export interface DiagramEdge extends ComputedEdge {
|
|
27
|
-
points: NonEmptyArray<Point>;
|
|
28
|
-
headArrow?: NonEmptyArray<Point>;
|
|
29
|
-
headArrowPoint?: Point;
|
|
30
|
-
tailArrow?: NonEmptyArray<Point>;
|
|
31
|
-
tailArrowPoint?: Point;
|
|
32
|
-
labels?: NonEmptyArray<DiagramLabel>;
|
|
33
|
-
labelBBox?: BBox;
|
|
34
|
-
}
|
|
35
|
-
export interface DiagramView extends Omit<ComputedView, 'nodes' | 'edges'> {
|
|
36
|
-
readonly nodes: DiagramNode[];
|
|
37
|
-
readonly edges: DiagramEdge[];
|
|
38
|
-
readonly width: number;
|
|
39
|
-
readonly height: number;
|
|
40
|
-
}
|
package/dist/types/diagram.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|