@likec4/core 1.7.2 → 1.7.3
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/expression.d.ts +2 -2
- package/dist/types/operators.d.ts +31 -22
- package/dist/types/view-changes.d.ts +7 -3
- package/dist/types/view.d.ts +3 -1
- package/package.json +2 -2
- package/src/types/expression.ts +2 -2
- package/src/types/operators.ts +32 -29
- package/src/types/view-changes.ts +9 -4
- package/src/types/view.ts +3 -1
|
@@ -64,7 +64,7 @@ export declare function isElement(expr: Expression): expr is ElementExpression;
|
|
|
64
64
|
export interface ElementWhereExpr extends Omit<BaseExpr, 'where'> {
|
|
65
65
|
where: {
|
|
66
66
|
expr: ElementExpression;
|
|
67
|
-
condition: WhereOperator
|
|
67
|
+
condition: WhereOperator<string, string>;
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
export declare function isElementWhere(expr: Expression): expr is ElementWhereExpr;
|
|
@@ -93,7 +93,7 @@ export declare function isRelationExpression(expr: Expression): expr is Relation
|
|
|
93
93
|
export interface RelationWhereExpr extends Omit<BaseExpr, 'where'> {
|
|
94
94
|
where: {
|
|
95
95
|
expr: RelationExpression;
|
|
96
|
-
condition: WhereOperator
|
|
96
|
+
condition: WhereOperator<string, string>;
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
export declare function isRelationWhere(expr: Expression): expr is RelationWhereExpr;
|
|
@@ -1,35 +1,44 @@
|
|
|
1
1
|
import type { NonEmptyArray } from './_common';
|
|
2
2
|
export type EqualOperator<V> = {
|
|
3
3
|
eq: V;
|
|
4
|
+
neq?: never;
|
|
4
5
|
} | {
|
|
6
|
+
eq?: never;
|
|
5
7
|
neq: V;
|
|
6
8
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
kind
|
|
13
|
-
}
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export
|
|
27
|
-
|
|
9
|
+
type AllNever = {
|
|
10
|
+
not?: never;
|
|
11
|
+
and?: never;
|
|
12
|
+
or?: never;
|
|
13
|
+
tag?: never;
|
|
14
|
+
kind?: never;
|
|
15
|
+
};
|
|
16
|
+
export type TagEqual<Tag> = Omit<AllNever, 'tag'> & {
|
|
17
|
+
tag: EqualOperator<Tag>;
|
|
18
|
+
};
|
|
19
|
+
export declare const isTagEqual: <Tag>(operator: WhereOperator<Tag, any>) => operator is TagEqual<Tag>;
|
|
20
|
+
export type KindEqual<Kind> = Omit<AllNever, 'kind'> & {
|
|
21
|
+
kind: EqualOperator<Kind>;
|
|
22
|
+
};
|
|
23
|
+
export declare const isKindEqual: <Kind>(operator: WhereOperator<any, Kind>) => operator is KindEqual<Kind>;
|
|
24
|
+
export type NotOperator<Tag, Kind> = Omit<AllNever, 'not'> & {
|
|
25
|
+
not: WhereOperator<Tag, Kind>;
|
|
26
|
+
};
|
|
27
|
+
export declare const isNotOperator: <Tag, Kind>(operator: WhereOperator<Tag, Kind>) => operator is NotOperator<Tag, Kind>;
|
|
28
|
+
export type AndOperator<Tag, Kind> = Omit<AllNever, 'and'> & {
|
|
29
|
+
and: NonEmptyArray<WhereOperator<Tag, Kind>>;
|
|
30
|
+
};
|
|
31
|
+
export declare const isAndOperator: <Tag, Kind>(operator: WhereOperator<Tag, Kind>) => operator is AndOperator<Tag, Kind>;
|
|
32
|
+
export type OrOperator<Tag, Kind> = Omit<AllNever, 'or'> & {
|
|
33
|
+
or: NonEmptyArray<WhereOperator<Tag, Kind>>;
|
|
34
|
+
};
|
|
35
|
+
export declare const isOrOperator: <Tag, Kind>(operator: WhereOperator<Tag, Kind>) => operator is OrOperator<Tag, Kind>;
|
|
36
|
+
export type WhereOperator<Tag, Kind> = TagEqual<Tag> | KindEqual<Kind> | NotOperator<Tag, Kind> | AndOperator<Tag, Kind> | OrOperator<Tag, Kind>;
|
|
28
37
|
type Filterable<FTag extends string = string, FKind extends string = string> = {
|
|
29
38
|
tags?: FTag[] | null;
|
|
30
39
|
kind?: FKind;
|
|
31
40
|
};
|
|
32
41
|
type OperatorPredicate<V extends Filterable> = (value: V) => boolean;
|
|
33
|
-
export declare function whereOperatorAsPredicate<FTag extends string = string, FKind extends string = string>(operator: WhereOperator): OperatorPredicate<Filterable<FTag, FKind>>;
|
|
42
|
+
export declare function whereOperatorAsPredicate<FTag extends string = string, FKind extends string = string>(operator: WhereOperator<FTag, FKind>): OperatorPredicate<Filterable<FTag, FKind>>;
|
|
34
43
|
export {};
|
|
35
44
|
//# sourceMappingURL=operators.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { NonEmptyArray } from './_common';
|
|
2
2
|
import type { BorderStyle, ElementShape, Fqn } from './element';
|
|
3
3
|
import type { ThemeColor } from './theme';
|
|
4
|
-
import type { ViewManualLayout } from './view';
|
|
5
|
-
export declare namespace
|
|
4
|
+
import type { AutoLayoutDirection, ViewManualLayout } from './view';
|
|
5
|
+
export declare namespace ViewChange {
|
|
6
6
|
interface ChangeElementStyle {
|
|
7
7
|
op: 'change-element-style';
|
|
8
8
|
style: {
|
|
@@ -17,6 +17,10 @@ export declare namespace ViewChanges {
|
|
|
17
17
|
op: 'save-manual-layout';
|
|
18
18
|
layout: ViewManualLayout;
|
|
19
19
|
}
|
|
20
|
+
interface ChangeAutoLayout {
|
|
21
|
+
op: 'change-autolayout';
|
|
22
|
+
layout: AutoLayoutDirection;
|
|
23
|
+
}
|
|
20
24
|
}
|
|
21
|
-
export type
|
|
25
|
+
export type ViewChange = ViewChange.ChangeElementStyle | ViewChange.SaveManualLayout | ViewChange.ChangeAutoLayout;
|
|
22
26
|
//# sourceMappingURL=view-changes.d.ts.map
|
package/dist/types/view.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { IconUrl, NonEmptyArray, Point, XYPoint } from './_common';
|
|
|
2
2
|
import type { ElementKind, ElementShape, ElementStyle, Fqn, Tag } from './element';
|
|
3
3
|
import type { ElementExpression, ElementPredicateExpression, Expression } from './expression';
|
|
4
4
|
import type { Opaque } from './opaque';
|
|
5
|
-
import type { RelationID, RelationshipArrowType, RelationshipLineType } from './relation';
|
|
5
|
+
import type { RelationID, RelationshipArrowType, RelationshipKind, RelationshipLineType } from './relation';
|
|
6
6
|
import type { ThemeColor } from './theme';
|
|
7
7
|
export type ViewID = Opaque<string, 'ViewID'>;
|
|
8
8
|
export type ViewRulePredicate = {
|
|
@@ -138,10 +138,12 @@ export interface ComputedEdge {
|
|
|
138
138
|
description?: string;
|
|
139
139
|
technology?: string;
|
|
140
140
|
relations: RelationID[];
|
|
141
|
+
kind?: RelationshipKind;
|
|
141
142
|
color?: ThemeColor;
|
|
142
143
|
line?: RelationshipLineType;
|
|
143
144
|
head?: RelationshipArrowType;
|
|
144
145
|
tail?: RelationshipArrowType;
|
|
146
|
+
tags?: NonEmptyArray<Tag>;
|
|
145
147
|
/**
|
|
146
148
|
* If this edge is derived from custom relationship predicate
|
|
147
149
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/core",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://likec4.dev",
|
|
6
6
|
"author": "Denis Davydkov <denis@davydkov.com>",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"type-fest": "^4.21.0"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@likec4/tsconfig": "1.7.
|
|
74
|
+
"@likec4/tsconfig": "1.7.3",
|
|
75
75
|
"@total-typescript/ts-reset": "^0.5.1",
|
|
76
76
|
"execa": "^9.3.0",
|
|
77
77
|
"typescript": "^5.5.4",
|
package/src/types/expression.ts
CHANGED
|
@@ -96,7 +96,7 @@ export function isElement(expr: Expression): expr is ElementExpression {
|
|
|
96
96
|
export interface ElementWhereExpr extends Omit<BaseExpr, 'where'> {
|
|
97
97
|
where: {
|
|
98
98
|
expr: ElementExpression
|
|
99
|
-
condition: WhereOperator
|
|
99
|
+
condition: WhereOperator<string, string>
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
export function isElementWhere(expr: Expression): expr is ElementWhereExpr {
|
|
@@ -146,7 +146,7 @@ export function isRelationExpression(expr: Expression): expr is RelationExpressi
|
|
|
146
146
|
export interface RelationWhereExpr extends Omit<BaseExpr, 'where'> {
|
|
147
147
|
where: {
|
|
148
148
|
expr: RelationExpression
|
|
149
|
-
condition: WhereOperator
|
|
149
|
+
condition: WhereOperator<string, string>
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
export function isRelationWhere(expr: Expression): expr is RelationWhereExpr {
|
package/src/types/operators.ts
CHANGED
|
@@ -4,58 +4,61 @@ import type { NonEmptyArray } from './_common'
|
|
|
4
4
|
|
|
5
5
|
export type EqualOperator<V> = {
|
|
6
6
|
eq: V
|
|
7
|
+
neq?: never
|
|
7
8
|
} | {
|
|
9
|
+
eq?: never
|
|
8
10
|
neq: V
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
type AllNever = {
|
|
14
|
+
not?: never
|
|
15
|
+
and?: never
|
|
16
|
+
or?: never
|
|
17
|
+
tag?: never
|
|
18
|
+
kind?: never
|
|
13
19
|
}
|
|
14
|
-
|
|
20
|
+
|
|
21
|
+
export type TagEqual<Tag> = Omit<AllNever, 'tag'> & {
|
|
22
|
+
tag: EqualOperator<Tag>
|
|
23
|
+
}
|
|
24
|
+
export const isTagEqual = <Tag>(operator: WhereOperator<Tag, any>): operator is TagEqual<Tag> => {
|
|
15
25
|
return 'tag' in operator
|
|
16
26
|
}
|
|
17
27
|
|
|
18
|
-
export
|
|
19
|
-
kind: EqualOperator<
|
|
28
|
+
export type KindEqual<Kind> = Omit<AllNever, 'kind'> & {
|
|
29
|
+
kind: EqualOperator<Kind>
|
|
20
30
|
}
|
|
21
|
-
export const isKindEqual = (operator: WhereOperator): operator is KindEqual => {
|
|
31
|
+
export const isKindEqual = <Kind>(operator: WhereOperator<any, Kind>): operator is KindEqual<Kind> => {
|
|
22
32
|
return 'kind' in operator
|
|
23
33
|
}
|
|
24
34
|
|
|
25
|
-
export
|
|
26
|
-
not:
|
|
35
|
+
export type NotOperator<Tag, Kind> = Omit<AllNever, 'not'> & {
|
|
36
|
+
not: WhereOperator<Tag, Kind>
|
|
27
37
|
}
|
|
28
|
-
export const isNotOperator = (operator: WhereOperator): operator is NotOperator<
|
|
38
|
+
export const isNotOperator = <Tag, Kind>(operator: WhereOperator<Tag, Kind>): operator is NotOperator<Tag, Kind> => {
|
|
29
39
|
return 'not' in operator
|
|
30
40
|
}
|
|
31
41
|
|
|
32
|
-
export
|
|
33
|
-
and: NonEmptyArray<
|
|
42
|
+
export type AndOperator<Tag, Kind> = Omit<AllNever, 'and'> & {
|
|
43
|
+
and: NonEmptyArray<WhereOperator<Tag, Kind>>
|
|
34
44
|
}
|
|
35
|
-
export const isAndOperator = (operator: WhereOperator): operator is AndOperator<
|
|
45
|
+
export const isAndOperator = <Tag, Kind>(operator: WhereOperator<Tag, Kind>): operator is AndOperator<Tag, Kind> => {
|
|
36
46
|
return 'and' in operator
|
|
37
47
|
}
|
|
38
48
|
|
|
39
|
-
export
|
|
40
|
-
or: NonEmptyArray<
|
|
49
|
+
export type OrOperator<Tag, Kind> = Omit<AllNever, 'or'> & {
|
|
50
|
+
or: NonEmptyArray<WhereOperator<Tag, Kind>>
|
|
41
51
|
}
|
|
42
|
-
export const isOrOperator = (operator: WhereOperator): operator is OrOperator<
|
|
52
|
+
export const isOrOperator = <Tag, Kind>(operator: WhereOperator<Tag, Kind>): operator is OrOperator<Tag, Kind> => {
|
|
43
53
|
return 'or' in operator
|
|
44
54
|
}
|
|
45
55
|
|
|
46
|
-
export type WhereOperator =
|
|
47
|
-
| TagEqual
|
|
48
|
-
| KindEqual
|
|
49
|
-
| NotOperator<
|
|
50
|
-
| AndOperator<
|
|
51
|
-
| OrOperator<
|
|
52
|
-
// type Ops<T> = UnionToIntersection<Op<T>>
|
|
53
|
-
// type Op1<T> = RequireExactlyOne<T>
|
|
54
|
-
|
|
55
|
-
// export type Operator1<T> = T extends Op<T> ? Op1<Ops<T>> : never
|
|
56
|
-
// export type Operator = Operator1<any>
|
|
57
|
-
|
|
58
|
-
// type L = keyof UnionToIntersection<Op<any>>
|
|
56
|
+
export type WhereOperator<Tag, Kind> =
|
|
57
|
+
| TagEqual<Tag>
|
|
58
|
+
| KindEqual<Kind>
|
|
59
|
+
| NotOperator<Tag, Kind>
|
|
60
|
+
| AndOperator<Tag, Kind>
|
|
61
|
+
| OrOperator<Tag, Kind>
|
|
59
62
|
|
|
60
63
|
type Filterable<
|
|
61
64
|
FTag extends string = string,
|
|
@@ -70,7 +73,7 @@ type OperatorPredicate<V extends Filterable> = (value: V) => boolean
|
|
|
70
73
|
export function whereOperatorAsPredicate<
|
|
71
74
|
FTag extends string = string,
|
|
72
75
|
FKind extends string = string
|
|
73
|
-
>(operator: WhereOperator): OperatorPredicate<Filterable<FTag, FKind>> {
|
|
76
|
+
>(operator: WhereOperator<FTag, FKind>): OperatorPredicate<Filterable<FTag, FKind>> {
|
|
74
77
|
switch (true) {
|
|
75
78
|
case isTagEqual(operator): {
|
|
76
79
|
if ('eq' in operator.tag) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { NonEmptyArray
|
|
1
|
+
import type { NonEmptyArray } from './_common'
|
|
2
2
|
import type { BorderStyle, ElementShape, Fqn } from './element'
|
|
3
3
|
import type { ThemeColor } from './theme'
|
|
4
|
-
import type {
|
|
4
|
+
import type { AutoLayoutDirection, ViewManualLayout } from './view'
|
|
5
5
|
|
|
6
|
-
export namespace
|
|
6
|
+
export namespace ViewChange {
|
|
7
7
|
export interface ChangeElementStyle {
|
|
8
8
|
op: 'change-element-style'
|
|
9
9
|
style: {
|
|
@@ -19,5 +19,10 @@ export namespace ViewChanges {
|
|
|
19
19
|
op: 'save-manual-layout'
|
|
20
20
|
layout: ViewManualLayout
|
|
21
21
|
}
|
|
22
|
+
|
|
23
|
+
export interface ChangeAutoLayout {
|
|
24
|
+
op: 'change-autolayout'
|
|
25
|
+
layout: AutoLayoutDirection
|
|
26
|
+
}
|
|
22
27
|
}
|
|
23
|
-
export type
|
|
28
|
+
export type ViewChange = ViewChange.ChangeElementStyle | ViewChange.SaveManualLayout | ViewChange.ChangeAutoLayout
|
package/src/types/view.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { IconUrl, NonEmptyArray, Point, XYPoint } from './_common'
|
|
|
3
3
|
import type { ElementKind, ElementShape, ElementStyle, Fqn, Tag } from './element'
|
|
4
4
|
import type { ElementExpression, ElementPredicateExpression, Expression } from './expression'
|
|
5
5
|
import type { Opaque } from './opaque'
|
|
6
|
-
import type { RelationID, RelationshipArrowType, RelationshipLineType } from './relation'
|
|
6
|
+
import type { RelationID, RelationshipArrowType, RelationshipKind, RelationshipLineType } from './relation'
|
|
7
7
|
import type { ThemeColor } from './theme'
|
|
8
8
|
|
|
9
9
|
// Full-qualified-name
|
|
@@ -196,10 +196,12 @@ export interface ComputedEdge {
|
|
|
196
196
|
description?: string
|
|
197
197
|
technology?: string
|
|
198
198
|
relations: RelationID[]
|
|
199
|
+
kind?: RelationshipKind
|
|
199
200
|
color?: ThemeColor
|
|
200
201
|
line?: RelationshipLineType
|
|
201
202
|
head?: RelationshipArrowType
|
|
202
203
|
tail?: RelationshipArrowType
|
|
204
|
+
tags?: NonEmptyArray<Tag>
|
|
203
205
|
/**
|
|
204
206
|
* If this edge is derived from custom relationship predicate
|
|
205
207
|
*/
|