@likec4/core 1.7.4 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import type { Opaque } from './opaque';
2
- export type NonEmptyArray<T> = [T, ...T[]] | [...T[], T];
2
+ export type NonEmptyArray<T> = [T, ...T[]];
3
3
  export type IconUrl = Opaque<string, 'IconUrl'>;
4
4
  export type Point = readonly [x: number, y: number];
5
5
  export interface XYPoint {
@@ -19,6 +19,10 @@ export interface TagSpec {
19
19
  readonly id: Tag;
20
20
  readonly style: ElementStyle;
21
21
  }
22
+ export interface Link {
23
+ readonly title?: string;
24
+ readonly url: string;
25
+ }
22
26
  export interface Element {
23
27
  readonly id: Fqn;
24
28
  readonly kind: ElementKind;
@@ -26,10 +30,26 @@ export interface Element {
26
30
  readonly description: string | null;
27
31
  readonly technology: string | null;
28
32
  readonly tags: NonEmptyArray<Tag> | null;
29
- readonly links: NonEmptyArray<string> | null;
33
+ readonly links: NonEmptyArray<Link> | null;
30
34
  readonly icon?: IconUrl;
31
35
  readonly shape?: ElementShape;
32
36
  readonly color?: ThemeColor;
33
37
  readonly style?: ElementStyle;
38
+ readonly notation?: string;
39
+ readonly metadata?: {
40
+ [key: string]: string;
41
+ };
42
+ }
43
+ export interface ElementKindSpecificationStyle {
44
+ shape?: ElementShape;
45
+ icon?: IconUrl;
46
+ color?: ThemeColor;
47
+ border?: BorderStyle;
48
+ opacity?: number;
49
+ }
50
+ export interface ElementKindSpecification {
51
+ readonly technology?: string;
52
+ readonly notation?: string;
53
+ readonly style: ElementKindSpecificationStyle;
34
54
  }
35
55
  //# sourceMappingURL=element.d.ts.map
@@ -36,6 +36,7 @@ export interface CustomElementExpr extends Omit<BaseExpr, 'custom'> {
36
36
  title?: string;
37
37
  description?: string;
38
38
  technology?: string;
39
+ notation?: string;
39
40
  shape?: ElementShape;
40
41
  color?: ThemeColor;
41
42
  icon?: IconUrl;
@@ -103,6 +104,7 @@ export interface CustomRelationExpr extends Omit<BaseExpr, 'customRelation'> {
103
104
  title?: string;
104
105
  description?: string;
105
106
  technology?: string;
107
+ notation?: string;
106
108
  color?: ThemeColor;
107
109
  line?: RelationshipLineType;
108
110
  head?: RelationshipArrowType;
@@ -4,9 +4,11 @@ export * from './expression';
4
4
  export * from './model';
5
5
  export * from './opaque';
6
6
  export * from './operators';
7
+ export * from './overview-graph';
7
8
  export * from './relation';
8
9
  export * from './theme';
9
10
  export * from './view';
10
11
  export * from './view-changes';
12
+ export * from './view-notation';
11
13
  export * as Expr from './expression';
12
14
  //# sourceMappingURL=index.d.ts.map
@@ -4,9 +4,11 @@ export * from './expression';
4
4
  export * from './model';
5
5
  export * from './opaque';
6
6
  export * from './operators';
7
+ export * from './overview-graph';
7
8
  export * from './relation';
8
9
  export * from './theme';
9
10
  export * from './view';
10
11
  export * from './view-changes';
12
+ export * from './view-notation';
11
13
  import * as Expr_1 from './expression';
12
14
  export { Expr_1 as Expr };
@@ -0,0 +1,41 @@
1
+ import type { NonEmptyArray, Point, XYPoint } from './_common';
2
+ import type { BBox, ViewID } from './view';
3
+ /**
4
+ * OverviewGraph is a graph representation of all views in a model
5
+ */
6
+ export declare namespace OverviewGraph {
7
+ type Node = {
8
+ id: string;
9
+ type: 'folder' | 'file';
10
+ path: string;
11
+ label: string;
12
+ parentId: string | null;
13
+ position: XYPoint;
14
+ width: number;
15
+ height: number;
16
+ } | {
17
+ id: string;
18
+ type: 'view';
19
+ viewId: ViewID;
20
+ label: string;
21
+ parentId: string | null;
22
+ position: XYPoint;
23
+ width: number;
24
+ height: number;
25
+ };
26
+ /**
27
+ * Edge represents a navigational link from one view to another
28
+ */
29
+ type Edge = {
30
+ id: string;
31
+ source: string;
32
+ target: string;
33
+ points: NonEmptyArray<Point>;
34
+ };
35
+ }
36
+ export interface OverviewGraph {
37
+ nodes: OverviewGraph.Node[];
38
+ edges: OverviewGraph.Edge[];
39
+ bounds: BBox;
40
+ }
41
+ //# sourceMappingURL=overview-graph.d.ts.map
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import type { NonEmptyArray } from './_common';
2
- import type { Fqn, Tag } from './element';
2
+ import type { Fqn, Link, Tag } from './element';
3
3
  import type { Opaque } from './opaque';
4
4
  import type { ThemeColor } from './theme';
5
5
  export type RelationID = Opaque<string, 'RelationID'>;
@@ -22,6 +22,9 @@ export interface Relation {
22
22
  readonly line?: RelationshipLineType;
23
23
  readonly head?: RelationshipArrowType;
24
24
  readonly tail?: RelationshipArrowType;
25
- readonly links?: NonEmptyArray<string>;
25
+ readonly links?: NonEmptyArray<Link>;
26
+ readonly metadata?: {
27
+ [key: string]: string;
28
+ };
26
29
  }
27
30
  //# sourceMappingURL=relation.d.ts.map
@@ -0,0 +1,9 @@
1
+ import type { ElementKind, ElementShape } from './element';
2
+ import type { ThemeColor } from './theme';
3
+ export type ElementNotation = {
4
+ kinds: ElementKind[];
5
+ shape: ElementShape;
6
+ color: ThemeColor;
7
+ title: string;
8
+ };
9
+ //# sourceMappingURL=view-notation.d.ts.map
@@ -0,0 +1 @@
1
+ export {};
@@ -1,9 +1,10 @@
1
1
  import type { IconUrl, NonEmptyArray, Point, XYPoint } from './_common';
2
- import type { ElementKind, ElementShape, ElementStyle, Fqn, Tag } from './element';
2
+ import type { ElementKind, ElementShape, ElementStyle, Fqn, Link, Tag } from './element';
3
3
  import type { ElementExpression, ElementPredicateExpression, Expression } from './expression';
4
4
  import type { Opaque } from './opaque';
5
5
  import type { RelationID, RelationshipArrowType, RelationshipKind, RelationshipLineType } from './relation';
6
6
  import type { ThemeColor } from './theme';
7
+ import type { ElementNotation } from './view-notation';
7
8
  export type ViewID = Opaque<string, 'ViewID'>;
8
9
  export type ViewRulePredicate = {
9
10
  include: Expression[];
@@ -15,6 +16,7 @@ export type ViewRulePredicate = {
15
16
  export declare function isViewRulePredicate(rule: ViewRule): rule is ViewRulePredicate;
16
17
  export interface ViewRuleStyle {
17
18
  targets: ElementExpression[];
19
+ notation?: string;
18
20
  style: ElementStyle & {
19
21
  color?: ThemeColor;
20
22
  shape?: ElementShape;
@@ -34,7 +36,7 @@ export interface BasicView<ViewType extends 'element' | 'dynamic'> {
34
36
  readonly title: string | null;
35
37
  readonly description: string | null;
36
38
  readonly tags: NonEmptyArray<Tag> | null;
37
- readonly links: NonEmptyArray<string> | null;
39
+ readonly links: NonEmptyArray<Link> | null;
38
40
  /**
39
41
  * URI to the source file of this view.
40
42
  * Undefined if the view is auto-generated.
@@ -71,6 +73,7 @@ export interface DynamicViewStep {
71
73
  readonly title: string | null;
72
74
  readonly description?: string;
73
75
  readonly technology?: string;
76
+ readonly notation?: string;
74
77
  readonly color?: ThemeColor;
75
78
  readonly line?: RelationshipLineType;
76
79
  readonly head?: RelationshipArrowType;
@@ -106,8 +109,9 @@ export interface ComputedNode {
106
109
  title: string;
107
110
  description: string | null;
108
111
  technology: string | null;
112
+ notation?: string;
109
113
  tags: NonEmptyArray<Tag> | null;
110
- links: NonEmptyArray<string> | null;
114
+ links: NonEmptyArray<Link> | null;
111
115
  children: NodeId[];
112
116
  inEdges: EdgeId[];
113
117
  outEdges: EdgeId[];
@@ -154,31 +158,33 @@ export interface ComputedEdge {
154
158
  */
155
159
  dir?: 'forward' | 'back';
156
160
  }
157
- export interface ComputedElementView extends Omit<ElementView, 'rules' | 'docUri'> {
161
+ export interface ViewWithHash {
162
+ /**
163
+ * Hash of the view object.
164
+ * This is used to detect changes in layout
165
+ */
166
+ hash: string;
167
+ }
168
+ export interface ViewWithNotation {
169
+ notation?: {
170
+ elements: ElementNotation[];
171
+ };
172
+ }
173
+ export interface ComputedElementView extends Omit<ElementView, 'rules' | 'docUri'>, ViewWithHash, ViewWithNotation {
158
174
  readonly extends?: ViewID;
159
175
  readonly autoLayout: ViewRuleAutoLayout['autoLayout'];
160
176
  readonly nodes: ComputedNode[];
161
177
  readonly edges: ComputedEdge[];
162
178
  rules?: never;
163
179
  docUri?: never;
164
- /**
165
- * Hash of the view object.
166
- * This is used to detect changes in layout
167
- */
168
- hash: string;
169
180
  }
170
- export interface ComputedDynamicView extends Omit<DynamicView, 'rules' | 'steps' | 'docUri'> {
181
+ export interface ComputedDynamicView extends Omit<DynamicView, 'rules' | 'steps' | 'docUri'>, ViewWithHash, ViewWithNotation {
171
182
  readonly autoLayout: ViewRuleAutoLayout['autoLayout'];
172
183
  readonly nodes: ComputedNode[];
173
184
  readonly edges: ComputedEdge[];
174
185
  steps?: never;
175
186
  rules?: never;
176
187
  docUri?: never;
177
- /**
178
- * Hash of the view object.
179
- * This is used to detect changes in layout
180
- */
181
- hash: string;
182
188
  }
183
189
  export declare function isComputedDynamicView(view: ComputedView): view is ComputedDynamicView;
184
190
  export type ComputedView = ComputedElementView | ComputedDynamicView;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/core",
3
- "version": "1.7.4",
3
+ "version": "1.8.1",
4
4
  "license": "MIT",
5
5
  "homepage": "https://likec4.dev",
6
6
  "author": "Denis Davydkov <denis@davydkov.com>",
@@ -66,14 +66,14 @@
66
66
  }
67
67
  },
68
68
  "dependencies": {
69
- "remeda": "^2.3.0",
69
+ "remeda": "^2.11.0",
70
70
  "ts-custom-error": "^3.3.1",
71
71
  "type-fest": "^4.21.0"
72
72
  },
73
73
  "devDependencies": {
74
- "@likec4/tsconfig": "1.7.4",
74
+ "@likec4/tsconfig": "1.8.1",
75
75
  "@total-typescript/ts-reset": "^0.5.1",
76
- "execa": "^9.3.0",
76
+ "execa": "^9.3.1",
77
77
  "typescript": "^5.5.4",
78
78
  "vitest": "~2.0.5"
79
79
  },
@@ -1,6 +1,6 @@
1
1
  import type { Opaque } from './opaque'
2
2
 
3
- export type NonEmptyArray<T> = [T, ...T[]] | [...T[], T]
3
+ export type NonEmptyArray<T> = [T, ...T[]]
4
4
 
5
5
  export type IconUrl = Opaque<string, 'IconUrl'>
6
6
 
@@ -41,6 +41,11 @@ export interface TagSpec {
41
41
  readonly style: ElementStyle
42
42
  }
43
43
 
44
+ export interface Link {
45
+ readonly title?: string,
46
+ readonly url: string
47
+ }
48
+
44
49
  export interface Element {
45
50
  readonly id: Fqn
46
51
  readonly kind: ElementKind
@@ -48,9 +53,24 @@ export interface Element {
48
53
  readonly description: string | null
49
54
  readonly technology: string | null
50
55
  readonly tags: NonEmptyArray<Tag> | null
51
- readonly links: NonEmptyArray<string> | null
56
+ readonly links: NonEmptyArray<Link> | null
52
57
  readonly icon?: IconUrl
53
58
  readonly shape?: ElementShape
54
59
  readonly color?: ThemeColor
55
60
  readonly style?: ElementStyle
61
+ readonly notation?: string
62
+ readonly metadata?: { [key: string]: string }
63
+ }
64
+
65
+ export interface ElementKindSpecificationStyle {
66
+ shape?: ElementShape
67
+ icon?: IconUrl
68
+ color?: ThemeColor
69
+ border?: BorderStyle
70
+ opacity?: number
71
+ }
72
+ export interface ElementKindSpecification {
73
+ readonly technology?: string
74
+ readonly notation?: string
75
+ readonly style: ElementKindSpecificationStyle
56
76
  }
@@ -44,6 +44,7 @@ export interface CustomElementExpr extends Omit<BaseExpr, 'custom'> {
44
44
  title?: string
45
45
  description?: string
46
46
  technology?: string
47
+ notation?: string
47
48
  shape?: ElementShape
48
49
  color?: ThemeColor
49
50
  icon?: IconUrl
@@ -159,6 +160,7 @@ export interface CustomRelationExpr extends Omit<BaseExpr, 'customRelation'> {
159
160
  title?: string
160
161
  description?: string
161
162
  technology?: string
163
+ notation?: string
162
164
  color?: ThemeColor
163
165
  line?: RelationshipLineType
164
166
  head?: RelationshipArrowType
@@ -4,9 +4,11 @@ export * from './expression'
4
4
  export * from './model'
5
5
  export * from './opaque'
6
6
  export * from './operators'
7
+ export * from './overview-graph'
7
8
  export * from './relation'
8
9
  export * from './theme'
9
10
  export * from './view'
10
11
  export * from './view-changes'
12
+ export * from './view-notation'
11
13
 
12
14
  export * as Expr from './expression'
@@ -0,0 +1,43 @@
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
+ }
@@ -1,5 +1,5 @@
1
1
  import type { NonEmptyArray } from './_common'
2
- import type { Fqn, Tag } from './element'
2
+ import type { Fqn, Link, Tag } from './element'
3
3
  import type { Opaque } from './opaque'
4
4
  import type { ThemeColor } from './theme'
5
5
 
@@ -38,5 +38,6 @@ export interface Relation {
38
38
  readonly line?: RelationshipLineType
39
39
  readonly head?: RelationshipArrowType
40
40
  readonly tail?: RelationshipArrowType
41
- readonly links?: NonEmptyArray<string>
41
+ readonly links?: NonEmptyArray<Link>
42
+ readonly metadata?: { [key: string]: string }
42
43
  }
@@ -0,0 +1,10 @@
1
+ import type { RequireAtLeastOne } from 'type-fest'
2
+ import type { BorderStyle, ElementKind, ElementShape } from './element'
3
+ import type { ThemeColor } from './theme'
4
+
5
+ export type ElementNotation = {
6
+ kinds: ElementKind[]
7
+ shape: ElementShape
8
+ color: ThemeColor
9
+ title: string
10
+ }
package/src/types/view.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { isNullish } from 'remeda'
2
2
  import type { IconUrl, NonEmptyArray, Point, XYPoint } from './_common'
3
- import type { ElementKind, ElementShape, ElementStyle, Fqn, Tag } from './element'
3
+ import type { ElementKind, ElementShape, ElementStyle, Fqn, Link, Tag } from './element'
4
4
  import type { ElementExpression, ElementPredicateExpression, Expression } from './expression'
5
5
  import type { Opaque } from './opaque'
6
6
  import type { RelationID, RelationshipArrowType, RelationshipKind, RelationshipLineType } from './relation'
7
7
  import type { ThemeColor } from './theme'
8
+ import type { ElementNotation } from './view-notation'
8
9
 
9
10
  // Full-qualified-name
10
11
  export type ViewID = Opaque<string, 'ViewID'>
@@ -27,6 +28,7 @@ export function isViewRulePredicate(rule: ViewRule): rule is ViewRulePredicate {
27
28
 
28
29
  export interface ViewRuleStyle {
29
30
  targets: ElementExpression[]
31
+ notation?: string
30
32
  style: ElementStyle & {
31
33
  color?: ThemeColor
32
34
  shape?: ElementShape
@@ -53,7 +55,7 @@ export interface BasicView<ViewType extends 'element' | 'dynamic'> {
53
55
  readonly title: string | null
54
56
  readonly description: string | null
55
57
  readonly tags: NonEmptyArray<Tag> | null
56
- readonly links: NonEmptyArray<string> | null
58
+ readonly links: NonEmptyArray<Link> | null
57
59
 
58
60
  /**
59
61
  * URI to the source file of this view.
@@ -95,6 +97,7 @@ export interface DynamicViewStep {
95
97
  readonly title: string | null
96
98
  readonly description?: string
97
99
  readonly technology?: string
100
+ readonly notation?: string
98
101
  readonly color?: ThemeColor
99
102
  readonly line?: RelationshipLineType
100
103
  readonly head?: RelationshipArrowType
@@ -162,8 +165,9 @@ export interface ComputedNode {
162
165
  title: string
163
166
  description: string | null
164
167
  technology: string | null
168
+ notation?: string
165
169
  tags: NonEmptyArray<Tag> | null
166
- links: NonEmptyArray<string> | null
170
+ links: NonEmptyArray<Link> | null
167
171
  children: NodeId[]
168
172
  inEdges: EdgeId[]
169
173
  outEdges: EdgeId[]
@@ -213,33 +217,37 @@ export interface ComputedEdge {
213
217
  dir?: 'forward' | 'back'
214
218
  }
215
219
 
216
- export interface ComputedElementView extends Omit<ElementView, 'rules' | 'docUri'> {
220
+ export interface ViewWithHash {
221
+ /**
222
+ * Hash of the view object.
223
+ * This is used to detect changes in layout
224
+ */
225
+ hash: string
226
+ }
227
+
228
+ export interface ViewWithNotation {
229
+ notation?: {
230
+ elements: ElementNotation[]
231
+ }
232
+ }
233
+
234
+ export interface ComputedElementView extends Omit<ElementView, 'rules' | 'docUri'>, ViewWithHash, ViewWithNotation {
217
235
  readonly extends?: ViewID
218
236
  readonly autoLayout: ViewRuleAutoLayout['autoLayout']
219
237
  readonly nodes: ComputedNode[]
220
238
  readonly edges: ComputedEdge[]
221
239
  rules?: never
222
240
  docUri?: never
223
-
224
- /**
225
- * Hash of the view object.
226
- * This is used to detect changes in layout
227
- */
228
- hash: string
229
241
  }
230
- export interface ComputedDynamicView extends Omit<DynamicView, 'rules' | 'steps' | 'docUri'> {
242
+ export interface ComputedDynamicView
243
+ extends Omit<DynamicView, 'rules' | 'steps' | 'docUri'>, ViewWithHash, ViewWithNotation
244
+ {
231
245
  readonly autoLayout: ViewRuleAutoLayout['autoLayout']
232
246
  readonly nodes: ComputedNode[]
233
247
  readonly edges: ComputedEdge[]
234
248
  steps?: never
235
249
  rules?: never
236
250
  docUri?: never
237
-
238
- /**
239
- * Hash of the view object.
240
- * This is used to detect changes in layout
241
- */
242
- hash: string
243
251
  }
244
252
  export function isComputedDynamicView(view: ComputedView): view is ComputedDynamicView {
245
253
  return view.__ === 'dynamic'