@likec4/core 1.8.0 → 1.9.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/index.cjs +4368 -0
- package/dist/index.d.cts +781 -0
- package/dist/index.d.mts +781 -0
- package/dist/index.mjs +4296 -0
- package/dist/shared/core.9l7eW3pn.d.cts +817 -0
- package/dist/shared/core.9l7eW3pn.d.mts +817 -0
- package/dist/shared/core.DcPLm41i.cjs +304 -0
- package/dist/shared/core.DfUTsojZ.mjs +251 -0
- package/dist/types/index.cjs +53 -0
- package/dist/types/index.d.cts +1 -0
- package/dist/types/index.d.mts +1 -0
- package/dist/types/index.mjs +1 -0
- package/package.json +41 -33
- package/src/colors/index.ts +27 -1
- package/src/errors/index.ts +3 -95
- package/src/index.ts +5 -6
- package/src/model/LikeC4Model.ts +480 -0
- package/src/model/LikeC4ViewModel.ts +318 -0
- package/src/model/__test__/LikeC4Model.spec.ts +79 -0
- package/src/model/__test__/fixture.ts +333 -0
- package/src/model/index.ts +2 -0
- package/src/model/types.ts +10 -0
- package/src/types/_common.ts +4 -2
- package/src/types/element.ts +8 -8
- package/src/types/expression.ts +3 -3
- package/src/types/index.ts +0 -1
- package/src/types/model.ts +16 -6
- package/src/types/relation.ts +15 -5
- package/src/types/theme.ts +28 -12
- package/src/types/view-notation.ts +3 -4
- package/src/types/view.ts +14 -10
- package/src/utils/fqn.ts +7 -4
- package/src/utils/relations.spec.ts +1 -3
- package/src/utils/relations.ts +7 -17
- package/dist/colors/element.d.ts +0 -69
- package/dist/colors/element.js +0 -75
- package/dist/colors/index.d.ts +0 -133
- package/dist/colors/index.js +0 -9
- package/dist/colors/relationships.d.ts +0 -58
- package/dist/colors/relationships.js +0 -49
- package/dist/errors/errors.spec.d.ts +0 -2
- package/dist/errors/errors.spec.js +0 -69
- package/dist/errors/index.d.ts +0 -39
- package/dist/errors/index.js +0 -104
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -4
- package/dist/types/_common.d.ts +0 -9
- package/dist/types/_common.js +0 -1
- package/dist/types/element.d.ts +0 -55
- package/dist/types/element.js +0 -15
- package/dist/types/expression.d.ts +0 -119
- package/dist/types/expression.js +0 -67
- package/dist/types/index.d.ts +0 -14
- package/dist/types/index.js +0 -14
- package/dist/types/model.d.ts +0 -14
- package/dist/types/model.js +0 -1
- package/dist/types/opaque.d.ts +0 -103
- package/dist/types/opaque.js +0 -1
- package/dist/types/operators.d.ts +0 -44
- package/dist/types/operators.js +0 -59
- package/dist/types/overview-graph.d.ts +0 -41
- package/dist/types/overview-graph.js +0 -1
- package/dist/types/relation.d.ts +0 -30
- package/dist/types/relation.js +0 -3
- package/dist/types/theme.d.ts +0 -27
- package/dist/types/theme.js +0 -1
- package/dist/types/view-changes.d.ts +0 -26
- package/dist/types/view-changes.js +0 -1
- package/dist/types/view-notation.d.ts +0 -9
- package/dist/types/view-notation.js +0 -1
- package/dist/types/view.d.ts +0 -243
- package/dist/types/view.js +0 -50
- package/dist/utils/fqn.d.ts +0 -39
- package/dist/utils/fqn.js +0 -102
- package/dist/utils/fqn.spec.d.ts +0 -2
- package/dist/utils/fqn.spec.js +0 -82
- package/dist/utils/guards.d.ts +0 -5
- package/dist/utils/guards.js +0 -7
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/index.js +0 -4
- package/dist/utils/promises.d.ts +0 -2
- package/dist/utils/promises.js +0 -8
- package/dist/utils/relations.d.ts +0 -30
- package/dist/utils/relations.js +0 -79
- package/dist/utils/relations.spec.d.ts +0 -2
- package/dist/utils/relations.spec.js +0 -210
- package/src/errors/errors.spec.ts +0 -88
- package/src/reset.d.ts +0 -2
- package/src/types/opaque.ts +0 -108
|
@@ -0,0 +1,817 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
3
|
+
|
|
4
|
+
@category Type
|
|
5
|
+
*/
|
|
6
|
+
type Primitive =
|
|
7
|
+
| null
|
|
8
|
+
| undefined
|
|
9
|
+
| string
|
|
10
|
+
| number
|
|
11
|
+
| boolean
|
|
12
|
+
| symbol
|
|
13
|
+
| bigint;
|
|
14
|
+
|
|
15
|
+
declare global {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
17
|
+
interface SymbolConstructor {
|
|
18
|
+
readonly observable: symbol;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
Allows creating a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
|
|
24
|
+
|
|
25
|
+
Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.
|
|
26
|
+
|
|
27
|
+
This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it's not needed anymore.
|
|
28
|
+
|
|
29
|
+
@example
|
|
30
|
+
```
|
|
31
|
+
import type {LiteralUnion} from 'type-fest';
|
|
32
|
+
|
|
33
|
+
// Before
|
|
34
|
+
|
|
35
|
+
type Pet = 'dog' | 'cat' | string;
|
|
36
|
+
|
|
37
|
+
const pet: Pet = '';
|
|
38
|
+
// Start typing in your TypeScript-enabled IDE.
|
|
39
|
+
// You **will not** get auto-completion for `dog` and `cat` literals.
|
|
40
|
+
|
|
41
|
+
// After
|
|
42
|
+
|
|
43
|
+
type Pet2 = LiteralUnion<'dog' | 'cat', string>;
|
|
44
|
+
|
|
45
|
+
const pet: Pet2 = '';
|
|
46
|
+
// You **will** get auto-completion for `dog` and `cat` literals.
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
@category Type
|
|
50
|
+
*/
|
|
51
|
+
type LiteralUnion<
|
|
52
|
+
LiteralType,
|
|
53
|
+
BaseType extends Primitive,
|
|
54
|
+
> = LiteralType | (BaseType & Record<never, never>);
|
|
55
|
+
|
|
56
|
+
declare const tag: unique symbol;
|
|
57
|
+
|
|
58
|
+
type TagContainer<Token> = {
|
|
59
|
+
readonly [tag]: Token;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
type Tag$1<Token extends PropertyKey, TagMetadata> = TagContainer<{[K in Token]: TagMetadata}>;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
Attach a "tag" to an arbitrary type. This allows you to create distinct types, that aren't assignable to one another, for distinct concepts in your program that should not be interchangeable, even if their runtime values have the same type. (See examples.)
|
|
66
|
+
|
|
67
|
+
A type returned by `Tagged` can be passed to `Tagged` again, to create a type with multiple tags.
|
|
68
|
+
|
|
69
|
+
[Read more about tagged types.](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d)
|
|
70
|
+
|
|
71
|
+
A tag's name is usually a string (and must be a string, number, or symbol), but each application of a tag can also contain an arbitrary type as its "metadata". See {@link GetTagMetadata} for examples and explanation.
|
|
72
|
+
|
|
73
|
+
A type `A` returned by `Tagged` is assignable to another type `B` returned by `Tagged` if and only if:
|
|
74
|
+
- the underlying (untagged) type of `A` is assignable to the underlying type of `B`;
|
|
75
|
+
- `A` contains at least all the tags `B` has;
|
|
76
|
+
- and the metadata type for each of `A`'s tags is assignable to the metadata type of `B`'s corresponding tag.
|
|
77
|
+
|
|
78
|
+
There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward:
|
|
79
|
+
- [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
|
|
80
|
+
- [Microsoft/TypeScript#4895](https://github.com/microsoft/TypeScript/issues/4895)
|
|
81
|
+
- [Microsoft/TypeScript#33290](https://github.com/microsoft/TypeScript/pull/33290)
|
|
82
|
+
|
|
83
|
+
@example
|
|
84
|
+
```
|
|
85
|
+
import type {Tagged} from 'type-fest';
|
|
86
|
+
|
|
87
|
+
type AccountNumber = Tagged<number, 'AccountNumber'>;
|
|
88
|
+
type AccountBalance = Tagged<number, 'AccountBalance'>;
|
|
89
|
+
|
|
90
|
+
function createAccountNumber(): AccountNumber {
|
|
91
|
+
// As you can see, casting from a `number` (the underlying type being tagged) is allowed.
|
|
92
|
+
return 2 as AccountNumber;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance {
|
|
96
|
+
return 4 as AccountBalance;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// This will compile successfully.
|
|
100
|
+
getMoneyForAccount(createAccountNumber());
|
|
101
|
+
|
|
102
|
+
// But this won't, because it has to be explicitly passed as an `AccountNumber` type!
|
|
103
|
+
// Critically, you could not accidentally use an `AccountBalance` as an `AccountNumber`.
|
|
104
|
+
getMoneyForAccount(2);
|
|
105
|
+
|
|
106
|
+
// You can also use tagged values like their underlying, untagged type.
|
|
107
|
+
// I.e., this will compile successfully because an `AccountNumber` can be used as a regular `number`.
|
|
108
|
+
// In this sense, the underlying base type is not hidden, which differentiates tagged types from opaque types in other languages.
|
|
109
|
+
const accountNumber = createAccountNumber() + 2;
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
@example
|
|
113
|
+
```
|
|
114
|
+
import type {Tagged} from 'type-fest';
|
|
115
|
+
|
|
116
|
+
// You can apply multiple tags to a type by using `Tagged` repeatedly.
|
|
117
|
+
type Url = Tagged<string, 'URL'>;
|
|
118
|
+
type SpecialCacheKey = Tagged<Url, 'SpecialCacheKey'>;
|
|
119
|
+
|
|
120
|
+
// You can also pass a union of tag names, so this is equivalent to the above, although it doesn't give you the ability to assign distinct metadata to each tag.
|
|
121
|
+
type SpecialCacheKey2 = Tagged<string, 'URL' | 'SpecialCacheKey'>;
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
@category Type
|
|
125
|
+
*/
|
|
126
|
+
type Tagged<Type, TagName extends PropertyKey, TagMetadata = never> = Type & Tag$1<TagName, TagMetadata>;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
Revert a tagged type back to its original type by removing all tags.
|
|
130
|
+
|
|
131
|
+
Why is this necessary?
|
|
132
|
+
|
|
133
|
+
1. Use a `Tagged` type as object keys
|
|
134
|
+
2. Prevent TS4058 error: "Return type of exported function has or is using name X from external module Y but cannot be named"
|
|
135
|
+
|
|
136
|
+
@example
|
|
137
|
+
```
|
|
138
|
+
import type {Tagged, UnwrapTagged} from 'type-fest';
|
|
139
|
+
|
|
140
|
+
type AccountType = Tagged<'SAVINGS' | 'CHECKING', 'AccountType'>;
|
|
141
|
+
|
|
142
|
+
const moneyByAccountType: Record<UnwrapTagged<AccountType>, number> = {
|
|
143
|
+
SAVINGS: 99,
|
|
144
|
+
CHECKING: 0.1
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// Without UnwrapTagged, the following expression would throw a type error.
|
|
148
|
+
const money = moneyByAccountType.SAVINGS; // TS error: Property 'SAVINGS' does not exist
|
|
149
|
+
|
|
150
|
+
// Attempting to pass an non-Tagged type to UnwrapTagged will raise a type error.
|
|
151
|
+
type WontWork = UnwrapTagged<string>;
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
@category Type
|
|
155
|
+
*/
|
|
156
|
+
type UnwrapTagged<TaggedType extends Tag$1<PropertyKey, any>> =
|
|
157
|
+
RemoveAllTags<TaggedType>;
|
|
158
|
+
|
|
159
|
+
type RemoveAllTags<T> = T extends Tag$1<PropertyKey, any>
|
|
160
|
+
? {
|
|
161
|
+
[ThisTag in keyof T[typeof tag]]: T extends Tagged<infer Type, ThisTag, T[typeof tag][ThisTag]>
|
|
162
|
+
? RemoveAllTags<Type>
|
|
163
|
+
: never
|
|
164
|
+
}[keyof T[typeof tag]]
|
|
165
|
+
: T;
|
|
166
|
+
|
|
167
|
+
declare const ThemeColors: readonly ["amber", "blue", "gray", "slate", "green", "indigo", "muted", "primary", "red", "secondary", "sky"];
|
|
168
|
+
type ThemeColor = typeof ThemeColors[number];
|
|
169
|
+
type HexColorLiteral = `#${string}`;
|
|
170
|
+
type ColorLiteral = HexColorLiteral;
|
|
171
|
+
type Color = LiteralUnion<ThemeColor, string>;
|
|
172
|
+
declare function isThemeColor(color: Color): color is ThemeColor;
|
|
173
|
+
interface ElementThemeColorValues {
|
|
174
|
+
fill: ColorLiteral;
|
|
175
|
+
stroke: ColorLiteral;
|
|
176
|
+
hiContrast: ColorLiteral;
|
|
177
|
+
loContrast: ColorLiteral;
|
|
178
|
+
}
|
|
179
|
+
type ElementThemeColors = {
|
|
180
|
+
[key in ThemeColor]: ElementThemeColorValues;
|
|
181
|
+
};
|
|
182
|
+
interface RelationshipThemeColorValues {
|
|
183
|
+
lineColor: ColorLiteral;
|
|
184
|
+
labelBgColor: ColorLiteral;
|
|
185
|
+
labelColor: ColorLiteral;
|
|
186
|
+
}
|
|
187
|
+
interface ThemeColorValues {
|
|
188
|
+
elements: ElementThemeColorValues;
|
|
189
|
+
relationships: RelationshipThemeColorValues;
|
|
190
|
+
}
|
|
191
|
+
type RelationshipThemeColors = {
|
|
192
|
+
[key in ThemeColor]: RelationshipThemeColorValues;
|
|
193
|
+
};
|
|
194
|
+
interface LikeC4Theme {
|
|
195
|
+
font: 'Arial';
|
|
196
|
+
shadow: ColorLiteral;
|
|
197
|
+
relationships: RelationshipThemeColors;
|
|
198
|
+
elements: ElementThemeColors;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
type NonEmptyArray<T> = [T, ...T[]];
|
|
202
|
+
type IconUrl = Tagged<string, 'IconUrl'>;
|
|
203
|
+
type CustomColor = string;
|
|
204
|
+
type Point = readonly [x: number, y: number];
|
|
205
|
+
interface XYPoint {
|
|
206
|
+
x: number;
|
|
207
|
+
y: number;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
type Fqn = Tagged<string, 'Fqn'>;
|
|
211
|
+
declare function AsFqn(name: string, parent?: Fqn | null): Fqn;
|
|
212
|
+
declare const BorderStyles: readonly ["solid", "dashed", "dotted", "none"];
|
|
213
|
+
type BorderStyle = typeof BorderStyles[number];
|
|
214
|
+
type ElementKind = Tagged<string, 'ElementKind'>;
|
|
215
|
+
declare const ElementShapes: readonly ["rectangle", "person", "browser", "mobile", "cylinder", "storage", "queue"];
|
|
216
|
+
type ElementShape = typeof ElementShapes[number];
|
|
217
|
+
declare const DefaultThemeColor = "primary";
|
|
218
|
+
declare const DefaultElementShape = "rectangle";
|
|
219
|
+
interface ElementStyle {
|
|
220
|
+
border?: BorderStyle;
|
|
221
|
+
opacity?: number;
|
|
222
|
+
}
|
|
223
|
+
type Tag = Tagged<string, 'Tag'>;
|
|
224
|
+
interface TagSpec {
|
|
225
|
+
readonly id: Tag;
|
|
226
|
+
readonly style: ElementStyle;
|
|
227
|
+
}
|
|
228
|
+
interface Link {
|
|
229
|
+
readonly title?: string;
|
|
230
|
+
readonly url: string;
|
|
231
|
+
}
|
|
232
|
+
interface Element {
|
|
233
|
+
readonly id: Fqn;
|
|
234
|
+
readonly kind: ElementKind;
|
|
235
|
+
readonly title: string;
|
|
236
|
+
readonly description: string | null;
|
|
237
|
+
readonly technology: string | null;
|
|
238
|
+
readonly tags: NonEmptyArray<Tag> | null;
|
|
239
|
+
readonly links: NonEmptyArray<Link> | null;
|
|
240
|
+
readonly icon?: IconUrl;
|
|
241
|
+
readonly shape?: ElementShape;
|
|
242
|
+
readonly color?: Color;
|
|
243
|
+
readonly style?: ElementStyle;
|
|
244
|
+
readonly notation?: string;
|
|
245
|
+
readonly metadata?: {
|
|
246
|
+
[key: string]: string;
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
interface ElementKindSpecificationStyle {
|
|
250
|
+
shape?: ElementShape;
|
|
251
|
+
icon?: IconUrl;
|
|
252
|
+
color?: Color;
|
|
253
|
+
border?: BorderStyle;
|
|
254
|
+
opacity?: number;
|
|
255
|
+
}
|
|
256
|
+
interface ElementKindSpecification {
|
|
257
|
+
readonly technology?: string;
|
|
258
|
+
readonly notation?: string;
|
|
259
|
+
readonly style: ElementKindSpecificationStyle;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
type EqualOperator<V> = {
|
|
263
|
+
eq: V;
|
|
264
|
+
neq?: never;
|
|
265
|
+
} | {
|
|
266
|
+
eq?: never;
|
|
267
|
+
neq: V;
|
|
268
|
+
};
|
|
269
|
+
type AllNever = {
|
|
270
|
+
not?: never;
|
|
271
|
+
and?: never;
|
|
272
|
+
or?: never;
|
|
273
|
+
tag?: never;
|
|
274
|
+
kind?: never;
|
|
275
|
+
};
|
|
276
|
+
type TagEqual<Tag> = Omit<AllNever, 'tag'> & {
|
|
277
|
+
tag: EqualOperator<Tag>;
|
|
278
|
+
};
|
|
279
|
+
declare const isTagEqual: <Tag>(operator: WhereOperator<Tag, any>) => operator is TagEqual<Tag>;
|
|
280
|
+
type KindEqual<Kind> = Omit<AllNever, 'kind'> & {
|
|
281
|
+
kind: EqualOperator<Kind>;
|
|
282
|
+
};
|
|
283
|
+
declare const isKindEqual: <Kind>(operator: WhereOperator<any, Kind>) => operator is KindEqual<Kind>;
|
|
284
|
+
type NotOperator<Tag, Kind> = Omit<AllNever, 'not'> & {
|
|
285
|
+
not: WhereOperator<Tag, Kind>;
|
|
286
|
+
};
|
|
287
|
+
declare const isNotOperator: <Tag, Kind>(operator: WhereOperator<Tag, Kind>) => operator is NotOperator<Tag, Kind>;
|
|
288
|
+
type AndOperator<Tag, Kind> = Omit<AllNever, 'and'> & {
|
|
289
|
+
and: NonEmptyArray<WhereOperator<Tag, Kind>>;
|
|
290
|
+
};
|
|
291
|
+
declare const isAndOperator: <Tag, Kind>(operator: WhereOperator<Tag, Kind>) => operator is AndOperator<Tag, Kind>;
|
|
292
|
+
type OrOperator<Tag, Kind> = Omit<AllNever, 'or'> & {
|
|
293
|
+
or: NonEmptyArray<WhereOperator<Tag, Kind>>;
|
|
294
|
+
};
|
|
295
|
+
declare const isOrOperator: <Tag, Kind>(operator: WhereOperator<Tag, Kind>) => operator is OrOperator<Tag, Kind>;
|
|
296
|
+
type WhereOperator<Tag, Kind> = TagEqual<Tag> | KindEqual<Kind> | NotOperator<Tag, Kind> | AndOperator<Tag, Kind> | OrOperator<Tag, Kind>;
|
|
297
|
+
type Filterable<FTag extends string = string, FKind extends string = string> = {
|
|
298
|
+
tags?: FTag[] | null;
|
|
299
|
+
kind?: FKind;
|
|
300
|
+
};
|
|
301
|
+
type OperatorPredicate<V extends Filterable> = (value: V) => boolean;
|
|
302
|
+
declare function whereOperatorAsPredicate<FTag extends string = string, FKind extends string = string>(operator: WhereOperator<FTag, FKind>): OperatorPredicate<Filterable<FTag, FKind>>;
|
|
303
|
+
|
|
304
|
+
type RelationID = Tagged<string, 'RelationID'>;
|
|
305
|
+
type RelationshipKind = Tagged<string, 'RelationshipKind'>;
|
|
306
|
+
type RelationshipLineType = 'dashed' | 'solid' | 'dotted';
|
|
307
|
+
type RelationshipArrowType = 'none' | 'normal' | 'onormal' | 'dot' | 'odot' | 'diamond' | 'odiamond' | 'crow' | 'open' | 'vee';
|
|
308
|
+
declare const DefaultLineStyle = "dashed";
|
|
309
|
+
declare const DefaultArrowType = "normal";
|
|
310
|
+
declare const DefaultRelationshipColor = "gray";
|
|
311
|
+
interface Relation {
|
|
312
|
+
readonly id: RelationID;
|
|
313
|
+
readonly source: Fqn;
|
|
314
|
+
readonly target: Fqn;
|
|
315
|
+
readonly title: string;
|
|
316
|
+
readonly description?: string;
|
|
317
|
+
readonly technology?: string;
|
|
318
|
+
readonly tags?: NonEmptyArray<Tag>;
|
|
319
|
+
readonly kind?: RelationshipKind;
|
|
320
|
+
readonly color?: Color;
|
|
321
|
+
readonly line?: RelationshipLineType;
|
|
322
|
+
readonly head?: RelationshipArrowType;
|
|
323
|
+
readonly tail?: RelationshipArrowType;
|
|
324
|
+
readonly links?: NonEmptyArray<Link>;
|
|
325
|
+
readonly metadata?: {
|
|
326
|
+
[key: string]: string;
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
interface RelationshipKindSpecification {
|
|
330
|
+
readonly technology?: string;
|
|
331
|
+
readonly notation?: string;
|
|
332
|
+
readonly color?: Color;
|
|
333
|
+
readonly line?: RelationshipLineType;
|
|
334
|
+
readonly head?: RelationshipArrowType;
|
|
335
|
+
readonly tail?: RelationshipArrowType;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
type ElementNotation = {
|
|
339
|
+
kinds: ElementKind[];
|
|
340
|
+
shape: ElementShape;
|
|
341
|
+
color: Color;
|
|
342
|
+
title: string;
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
type ViewID = Tagged<string, 'ViewID'>;
|
|
346
|
+
type ViewRulePredicate = {
|
|
347
|
+
include: Expression[];
|
|
348
|
+
exclude?: never;
|
|
349
|
+
} | {
|
|
350
|
+
include?: never;
|
|
351
|
+
exclude: Expression[];
|
|
352
|
+
};
|
|
353
|
+
declare function isViewRulePredicate(rule: ViewRule): rule is ViewRulePredicate;
|
|
354
|
+
interface ViewRuleStyle {
|
|
355
|
+
targets: ElementExpression[];
|
|
356
|
+
notation?: string;
|
|
357
|
+
style: ElementStyle & {
|
|
358
|
+
color?: Color;
|
|
359
|
+
shape?: ElementShape;
|
|
360
|
+
icon?: IconUrl;
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
declare function isViewRuleStyle(rule: ViewRule): rule is ViewRuleStyle;
|
|
364
|
+
type AutoLayoutDirection = 'TB' | 'BT' | 'LR' | 'RL';
|
|
365
|
+
interface ViewRuleAutoLayout {
|
|
366
|
+
autoLayout: AutoLayoutDirection;
|
|
367
|
+
}
|
|
368
|
+
declare function isViewRuleAutoLayout(rule: ViewRule): rule is ViewRuleAutoLayout;
|
|
369
|
+
type ViewRule = ViewRulePredicate | ViewRuleStyle | ViewRuleAutoLayout;
|
|
370
|
+
interface BasicView<ViewType extends 'element' | 'dynamic'> {
|
|
371
|
+
readonly __?: ViewType;
|
|
372
|
+
readonly id: ViewID;
|
|
373
|
+
readonly title: string | null;
|
|
374
|
+
readonly description: string | null;
|
|
375
|
+
readonly tags: NonEmptyArray<Tag> | null;
|
|
376
|
+
readonly links: NonEmptyArray<Link> | null;
|
|
377
|
+
/**
|
|
378
|
+
* URI to the source file of this view.
|
|
379
|
+
* Undefined if the view is auto-generated.
|
|
380
|
+
*/
|
|
381
|
+
readonly docUri?: string;
|
|
382
|
+
/**
|
|
383
|
+
* For all views we find common ancestor path.
|
|
384
|
+
* This is used to generate relative paths, i.e.:
|
|
385
|
+
* - "/home/project/index.c4" becomes "index.c4"
|
|
386
|
+
* - "/home/project/subdir/views.c4" becomes "subdir/views.c4"
|
|
387
|
+
*
|
|
388
|
+
* Undefined if the view is auto-generated.
|
|
389
|
+
*/
|
|
390
|
+
readonly relativePath?: string;
|
|
391
|
+
/**
|
|
392
|
+
* If the view is changed manually this field contains the layout data.
|
|
393
|
+
*/
|
|
394
|
+
readonly manualLayout?: ViewManualLayout | undefined;
|
|
395
|
+
readonly customColorDefinitions: CustomColorDefinitions;
|
|
396
|
+
}
|
|
397
|
+
interface BasicElementView extends BasicView<'element'> {
|
|
398
|
+
readonly viewOf?: Fqn;
|
|
399
|
+
readonly rules: ViewRule[];
|
|
400
|
+
}
|
|
401
|
+
interface ScopedElementView extends BasicElementView {
|
|
402
|
+
readonly viewOf: Fqn;
|
|
403
|
+
}
|
|
404
|
+
interface ExtendsElementView extends BasicElementView {
|
|
405
|
+
readonly extends: ViewID;
|
|
406
|
+
}
|
|
407
|
+
type ElementView = ScopedElementView | ExtendsElementView | BasicElementView;
|
|
408
|
+
interface DynamicViewStep {
|
|
409
|
+
readonly source: Fqn;
|
|
410
|
+
readonly target: Fqn;
|
|
411
|
+
readonly title: string | null;
|
|
412
|
+
readonly description?: string;
|
|
413
|
+
readonly technology?: string;
|
|
414
|
+
readonly notation?: string;
|
|
415
|
+
readonly color?: Color;
|
|
416
|
+
readonly line?: RelationshipLineType;
|
|
417
|
+
readonly head?: RelationshipArrowType;
|
|
418
|
+
readonly tail?: RelationshipArrowType;
|
|
419
|
+
readonly isBackward?: boolean;
|
|
420
|
+
}
|
|
421
|
+
type DynamicViewIncludeRule = {
|
|
422
|
+
include: ElementPredicateExpression[];
|
|
423
|
+
};
|
|
424
|
+
declare function isDynamicViewIncludeRule(rule: DynamicViewRule): rule is DynamicViewIncludeRule;
|
|
425
|
+
type DynamicViewRule = DynamicViewIncludeRule | ViewRuleStyle | ViewRuleAutoLayout;
|
|
426
|
+
interface DynamicView extends BasicView<'dynamic'> {
|
|
427
|
+
readonly __: 'dynamic';
|
|
428
|
+
readonly steps: DynamicViewStep[];
|
|
429
|
+
readonly rules: DynamicViewRule[];
|
|
430
|
+
}
|
|
431
|
+
type CustomColorDefinitions = {
|
|
432
|
+
[key: string]: ThemeColorValues;
|
|
433
|
+
};
|
|
434
|
+
type LikeC4View = ElementView | DynamicView;
|
|
435
|
+
declare function isDynamicView(view: LikeC4View): view is DynamicView;
|
|
436
|
+
declare function isElementView(view: LikeC4View): view is ElementView;
|
|
437
|
+
declare function isExtendsElementView(view: LikeC4View): view is ExtendsElementView;
|
|
438
|
+
declare function isScopedElementView(view: LikeC4View): view is ScopedElementView;
|
|
439
|
+
type NodeId = Tagged<string, 'Fqn'>;
|
|
440
|
+
type EdgeId = Tagged<string, 'EdgeId'>;
|
|
441
|
+
type StepEdgeIdLiteral = `step-${number}`;
|
|
442
|
+
type StepEdgeId = Tagged<StepEdgeIdLiteral, 'EdgeId'>;
|
|
443
|
+
declare function StepEdgeId(step: number): StepEdgeId;
|
|
444
|
+
declare function isStepEdgeId(id: string): id is StepEdgeId;
|
|
445
|
+
declare function extractStep(id: EdgeId): number;
|
|
446
|
+
interface ComputedNode {
|
|
447
|
+
id: NodeId;
|
|
448
|
+
kind: ElementKind;
|
|
449
|
+
parent: NodeId | null;
|
|
450
|
+
title: string;
|
|
451
|
+
description: string | null;
|
|
452
|
+
technology: string | null;
|
|
453
|
+
notation?: string;
|
|
454
|
+
tags: NonEmptyArray<Tag> | null;
|
|
455
|
+
links: NonEmptyArray<Link> | null;
|
|
456
|
+
children: NodeId[];
|
|
457
|
+
inEdges: EdgeId[];
|
|
458
|
+
outEdges: EdgeId[];
|
|
459
|
+
shape: ElementShape;
|
|
460
|
+
/**
|
|
461
|
+
* @deprecated Use `style` instead
|
|
462
|
+
*/
|
|
463
|
+
color: Color;
|
|
464
|
+
/**
|
|
465
|
+
* @deprecated Use `style` instead
|
|
466
|
+
*/
|
|
467
|
+
icon?: IconUrl;
|
|
468
|
+
style: ElementStyle;
|
|
469
|
+
navigateTo?: ViewID;
|
|
470
|
+
level: number;
|
|
471
|
+
depth?: number;
|
|
472
|
+
/**
|
|
473
|
+
* If this node was customized in the view
|
|
474
|
+
*/
|
|
475
|
+
isCustomized?: boolean;
|
|
476
|
+
}
|
|
477
|
+
interface ComputedEdge {
|
|
478
|
+
id: EdgeId;
|
|
479
|
+
parent: NodeId | null;
|
|
480
|
+
source: NodeId;
|
|
481
|
+
target: NodeId;
|
|
482
|
+
label: string | null;
|
|
483
|
+
description?: string;
|
|
484
|
+
technology?: string;
|
|
485
|
+
relations: RelationID[];
|
|
486
|
+
kind?: RelationshipKind;
|
|
487
|
+
color?: Color;
|
|
488
|
+
line?: RelationshipLineType;
|
|
489
|
+
head?: RelationshipArrowType;
|
|
490
|
+
tail?: RelationshipArrowType;
|
|
491
|
+
tags?: NonEmptyArray<Tag>;
|
|
492
|
+
/**
|
|
493
|
+
* If this edge is derived from custom relationship predicate
|
|
494
|
+
*/
|
|
495
|
+
isCustomized?: boolean;
|
|
496
|
+
/**
|
|
497
|
+
* For layouting purposes
|
|
498
|
+
* @default 'forward'
|
|
499
|
+
*/
|
|
500
|
+
dir?: 'forward' | 'back';
|
|
501
|
+
}
|
|
502
|
+
interface ViewWithHash {
|
|
503
|
+
/**
|
|
504
|
+
* Hash of the view object.
|
|
505
|
+
* This is used to detect changes in layout
|
|
506
|
+
*/
|
|
507
|
+
hash: string;
|
|
508
|
+
}
|
|
509
|
+
interface ViewWithNotation {
|
|
510
|
+
notation?: {
|
|
511
|
+
elements: ElementNotation[];
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
interface ComputedElementView extends Omit<ElementView, 'rules' | 'docUri'>, ViewWithHash, ViewWithNotation {
|
|
515
|
+
readonly extends?: ViewID;
|
|
516
|
+
readonly autoLayout: ViewRuleAutoLayout['autoLayout'];
|
|
517
|
+
readonly nodes: ComputedNode[];
|
|
518
|
+
readonly edges: ComputedEdge[];
|
|
519
|
+
rules?: never;
|
|
520
|
+
docUri?: never;
|
|
521
|
+
}
|
|
522
|
+
interface ComputedDynamicView extends Omit<DynamicView, 'rules' | 'steps' | 'docUri'>, ViewWithHash, ViewWithNotation {
|
|
523
|
+
readonly autoLayout: ViewRuleAutoLayout['autoLayout'];
|
|
524
|
+
readonly nodes: ComputedNode[];
|
|
525
|
+
readonly edges: ComputedEdge[];
|
|
526
|
+
steps?: never;
|
|
527
|
+
rules?: never;
|
|
528
|
+
docUri?: never;
|
|
529
|
+
}
|
|
530
|
+
declare function isComputedDynamicView(view: ComputedView): view is ComputedDynamicView;
|
|
531
|
+
type ComputedView = ComputedElementView | ComputedDynamicView;
|
|
532
|
+
declare function isComputedElementView(view: ComputedView): view is ComputedElementView;
|
|
533
|
+
type BBox = {
|
|
534
|
+
x: number;
|
|
535
|
+
y: number;
|
|
536
|
+
width: number;
|
|
537
|
+
height: number;
|
|
538
|
+
};
|
|
539
|
+
declare function getBBoxCenter({ x, y, width, height }: BBox): XYPoint;
|
|
540
|
+
interface DiagramNode extends ComputedNode {
|
|
541
|
+
width: number;
|
|
542
|
+
height: number;
|
|
543
|
+
position: Point;
|
|
544
|
+
labelBBox: BBox;
|
|
545
|
+
}
|
|
546
|
+
interface DiagramEdge extends ComputedEdge {
|
|
547
|
+
points: NonEmptyArray<Point>;
|
|
548
|
+
controlPoints?: NonEmptyArray<XYPoint>;
|
|
549
|
+
labelBBox?: BBox | null;
|
|
550
|
+
dotpos?: string;
|
|
551
|
+
}
|
|
552
|
+
interface DiagramView extends Omit<ComputedView, 'nodes' | 'edges' | 'manualLayout'> {
|
|
553
|
+
readonly nodes: DiagramNode[];
|
|
554
|
+
readonly edges: DiagramEdge[];
|
|
555
|
+
readonly bounds: BBox;
|
|
556
|
+
/**
|
|
557
|
+
* If diagram has manual layout
|
|
558
|
+
* But was changed and layout should be recalculated
|
|
559
|
+
*/
|
|
560
|
+
hasLayoutDrift?: boolean;
|
|
561
|
+
manualLayout?: never;
|
|
562
|
+
}
|
|
563
|
+
type ViewManualLayout = {
|
|
564
|
+
readonly hash: string;
|
|
565
|
+
readonly x: number;
|
|
566
|
+
readonly y: number;
|
|
567
|
+
readonly width: number;
|
|
568
|
+
readonly height: number;
|
|
569
|
+
readonly autoLayout: AutoLayoutDirection;
|
|
570
|
+
readonly nodes: Record<string, {
|
|
571
|
+
isCompound: boolean;
|
|
572
|
+
x: number;
|
|
573
|
+
y: number;
|
|
574
|
+
width: number;
|
|
575
|
+
height: number;
|
|
576
|
+
}>;
|
|
577
|
+
readonly edges: Record<string, {
|
|
578
|
+
dotpos?: string;
|
|
579
|
+
points: NonEmptyArray<Point>;
|
|
580
|
+
controlPoints?: NonEmptyArray<XYPoint>;
|
|
581
|
+
labelBBox?: BBox;
|
|
582
|
+
}>;
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
interface BaseExpr {
|
|
586
|
+
where?: never;
|
|
587
|
+
element?: never;
|
|
588
|
+
custom?: never;
|
|
589
|
+
expanded?: never;
|
|
590
|
+
elementKind?: never;
|
|
591
|
+
elementTag?: never;
|
|
592
|
+
isEqual?: never;
|
|
593
|
+
isDescedants?: never;
|
|
594
|
+
wildcard?: never;
|
|
595
|
+
source?: never;
|
|
596
|
+
target?: never;
|
|
597
|
+
inout?: never;
|
|
598
|
+
incoming?: never;
|
|
599
|
+
outgoing?: never;
|
|
600
|
+
customRelation?: never;
|
|
601
|
+
}
|
|
602
|
+
interface ElementRefExpr extends Omit<BaseExpr, 'element' | 'isDescedants'> {
|
|
603
|
+
element: Fqn;
|
|
604
|
+
isDescedants?: boolean;
|
|
605
|
+
}
|
|
606
|
+
declare function isElementRef(expr: Expression): expr is ElementRefExpr;
|
|
607
|
+
interface ExpandedElementExpr extends Omit<BaseExpr, 'expanded'> {
|
|
608
|
+
expanded: Fqn;
|
|
609
|
+
}
|
|
610
|
+
declare function isExpandedElementExpr(expr: Expression): expr is ExpandedElementExpr;
|
|
611
|
+
interface CustomElementExpr extends Omit<BaseExpr, 'custom'> {
|
|
612
|
+
custom: {
|
|
613
|
+
expr: ElementExpression | ElementWhereExpr;
|
|
614
|
+
title?: string;
|
|
615
|
+
description?: string;
|
|
616
|
+
technology?: string;
|
|
617
|
+
notation?: string;
|
|
618
|
+
shape?: ElementShape;
|
|
619
|
+
color?: Color;
|
|
620
|
+
icon?: IconUrl;
|
|
621
|
+
border?: BorderStyle;
|
|
622
|
+
opacity?: number;
|
|
623
|
+
navigateTo?: ViewID;
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
declare function isCustomElement(expr: Expression): expr is CustomElementExpr;
|
|
627
|
+
interface WildcardExpr extends Omit<BaseExpr, 'wildcard'> {
|
|
628
|
+
wildcard: true;
|
|
629
|
+
}
|
|
630
|
+
declare function isWildcard(expr: Expression): expr is WildcardExpr;
|
|
631
|
+
interface ElementKindExpr extends Omit<BaseExpr, 'elementKind' | 'isEqual'> {
|
|
632
|
+
elementKind: ElementKind;
|
|
633
|
+
isEqual: boolean;
|
|
634
|
+
}
|
|
635
|
+
declare function isElementKindExpr(expr: Expression): expr is ElementKindExpr;
|
|
636
|
+
interface ElementTagExpr extends Omit<BaseExpr, 'elementTag' | 'isEqual'> {
|
|
637
|
+
elementTag: Tag;
|
|
638
|
+
isEqual: boolean;
|
|
639
|
+
}
|
|
640
|
+
declare function isElementTagExpr(expr: Expression): expr is ElementTagExpr;
|
|
641
|
+
type ElementExpression = ElementRefExpr | WildcardExpr | ElementKindExpr | ElementTagExpr | ExpandedElementExpr;
|
|
642
|
+
declare function isElement(expr: Expression): expr is ElementExpression;
|
|
643
|
+
interface ElementWhereExpr extends Omit<BaseExpr, 'where'> {
|
|
644
|
+
where: {
|
|
645
|
+
expr: ElementExpression;
|
|
646
|
+
condition: WhereOperator<string, string>;
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
declare function isElementWhere(expr: Expression): expr is ElementWhereExpr;
|
|
650
|
+
type ElementPredicateExpression = ElementExpression | ElementWhereExpr | CustomElementExpr;
|
|
651
|
+
declare function isElementPredicateExpr(expr: Expression): expr is ElementPredicateExpression;
|
|
652
|
+
interface RelationExpr extends Omit<BaseExpr, 'source' | 'target'> {
|
|
653
|
+
source: ElementExpression;
|
|
654
|
+
target: ElementExpression;
|
|
655
|
+
isBidirectional?: boolean;
|
|
656
|
+
}
|
|
657
|
+
declare function isRelation(expr: Expression): expr is RelationExpr;
|
|
658
|
+
interface InOutExpr extends Omit<BaseExpr, 'inout'> {
|
|
659
|
+
inout: ElementExpression;
|
|
660
|
+
}
|
|
661
|
+
declare function isInOut(expr: Expression): expr is InOutExpr;
|
|
662
|
+
interface IncomingExpr extends Omit<BaseExpr, 'incoming'> {
|
|
663
|
+
incoming: ElementExpression;
|
|
664
|
+
}
|
|
665
|
+
declare function isIncoming(expr: Expression): expr is IncomingExpr;
|
|
666
|
+
interface OutgoingExpr extends Omit<BaseExpr, 'outgoing'> {
|
|
667
|
+
outgoing: ElementExpression;
|
|
668
|
+
}
|
|
669
|
+
declare function isOutgoing(expr: Expression): expr is OutgoingExpr;
|
|
670
|
+
type RelationExpression = RelationExpr | InOutExpr | IncomingExpr | OutgoingExpr;
|
|
671
|
+
declare function isRelationExpression(expr: Expression): expr is RelationExpression;
|
|
672
|
+
interface RelationWhereExpr extends Omit<BaseExpr, 'where'> {
|
|
673
|
+
where: {
|
|
674
|
+
expr: RelationExpression;
|
|
675
|
+
condition: WhereOperator<string, string>;
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
declare function isRelationWhere(expr: Expression): expr is RelationWhereExpr;
|
|
679
|
+
interface CustomRelationExpr extends Omit<BaseExpr, 'customRelation'> {
|
|
680
|
+
customRelation: {
|
|
681
|
+
relation: RelationExpression | RelationWhereExpr;
|
|
682
|
+
title?: string;
|
|
683
|
+
description?: string;
|
|
684
|
+
technology?: string;
|
|
685
|
+
notation?: string;
|
|
686
|
+
color?: Color;
|
|
687
|
+
line?: RelationshipLineType;
|
|
688
|
+
head?: RelationshipArrowType;
|
|
689
|
+
tail?: RelationshipArrowType;
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
declare function isCustomRelationExpr(expr: Expression): expr is CustomRelationExpr;
|
|
693
|
+
type RelationPredicateExpression = RelationExpression | RelationWhereExpr | CustomRelationExpr;
|
|
694
|
+
declare function isRelationPredicateExpr(expr: Expression): expr is RelationPredicateExpression;
|
|
695
|
+
type Expression = ElementPredicateExpression | RelationPredicateExpression;
|
|
696
|
+
|
|
697
|
+
type expression_CustomElementExpr = CustomElementExpr;
|
|
698
|
+
type expression_CustomRelationExpr = CustomRelationExpr;
|
|
699
|
+
type expression_ElementExpression = ElementExpression;
|
|
700
|
+
type expression_ElementKindExpr = ElementKindExpr;
|
|
701
|
+
type expression_ElementPredicateExpression = ElementPredicateExpression;
|
|
702
|
+
type expression_ElementRefExpr = ElementRefExpr;
|
|
703
|
+
type expression_ElementTagExpr = ElementTagExpr;
|
|
704
|
+
type expression_ElementWhereExpr = ElementWhereExpr;
|
|
705
|
+
type expression_ExpandedElementExpr = ExpandedElementExpr;
|
|
706
|
+
type expression_Expression = Expression;
|
|
707
|
+
type expression_InOutExpr = InOutExpr;
|
|
708
|
+
type expression_IncomingExpr = IncomingExpr;
|
|
709
|
+
type expression_OutgoingExpr = OutgoingExpr;
|
|
710
|
+
type expression_RelationExpr = RelationExpr;
|
|
711
|
+
type expression_RelationExpression = RelationExpression;
|
|
712
|
+
type expression_RelationPredicateExpression = RelationPredicateExpression;
|
|
713
|
+
type expression_RelationWhereExpr = RelationWhereExpr;
|
|
714
|
+
type expression_WildcardExpr = WildcardExpr;
|
|
715
|
+
declare const expression_isCustomElement: typeof isCustomElement;
|
|
716
|
+
declare const expression_isCustomRelationExpr: typeof isCustomRelationExpr;
|
|
717
|
+
declare const expression_isElement: typeof isElement;
|
|
718
|
+
declare const expression_isElementKindExpr: typeof isElementKindExpr;
|
|
719
|
+
declare const expression_isElementPredicateExpr: typeof isElementPredicateExpr;
|
|
720
|
+
declare const expression_isElementRef: typeof isElementRef;
|
|
721
|
+
declare const expression_isElementTagExpr: typeof isElementTagExpr;
|
|
722
|
+
declare const expression_isElementWhere: typeof isElementWhere;
|
|
723
|
+
declare const expression_isExpandedElementExpr: typeof isExpandedElementExpr;
|
|
724
|
+
declare const expression_isInOut: typeof isInOut;
|
|
725
|
+
declare const expression_isIncoming: typeof isIncoming;
|
|
726
|
+
declare const expression_isOutgoing: typeof isOutgoing;
|
|
727
|
+
declare const expression_isRelation: typeof isRelation;
|
|
728
|
+
declare const expression_isRelationExpression: typeof isRelationExpression;
|
|
729
|
+
declare const expression_isRelationPredicateExpr: typeof isRelationPredicateExpr;
|
|
730
|
+
declare const expression_isRelationWhere: typeof isRelationWhere;
|
|
731
|
+
declare const expression_isWildcard: typeof isWildcard;
|
|
732
|
+
declare namespace expression {
|
|
733
|
+
export { type expression_CustomElementExpr as CustomElementExpr, type expression_CustomRelationExpr as CustomRelationExpr, type expression_ElementExpression as ElementExpression, type expression_ElementKindExpr as ElementKindExpr, type expression_ElementPredicateExpression as ElementPredicateExpression, type expression_ElementRefExpr as ElementRefExpr, type expression_ElementTagExpr as ElementTagExpr, type expression_ElementWhereExpr as ElementWhereExpr, type expression_ExpandedElementExpr as ExpandedElementExpr, type expression_Expression as Expression, type expression_InOutExpr as InOutExpr, type expression_IncomingExpr as IncomingExpr, type expression_OutgoingExpr as OutgoingExpr, type expression_RelationExpr as RelationExpr, type expression_RelationExpression as RelationExpression, type expression_RelationPredicateExpression as RelationPredicateExpression, type expression_RelationWhereExpr as RelationWhereExpr, type expression_WildcardExpr as WildcardExpr, expression_isCustomElement as isCustomElement, expression_isCustomRelationExpr as isCustomRelationExpr, expression_isElement as isElement, expression_isElementKindExpr as isElementKindExpr, expression_isElementPredicateExpr as isElementPredicateExpr, expression_isElementRef as isElementRef, expression_isElementTagExpr as isElementTagExpr, expression_isElementWhere as isElementWhere, expression_isExpandedElementExpr as isExpandedElementExpr, expression_isInOut as isInOut, expression_isIncoming as isIncoming, expression_isOutgoing as isOutgoing, expression_isRelation as isRelation, expression_isRelationExpression as isRelationExpression, expression_isRelationPredicateExpr as isRelationPredicateExpr, expression_isRelationWhere as isRelationWhere, expression_isWildcard as isWildcard };
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Parsed elements, relations, and views.
|
|
738
|
+
*/
|
|
739
|
+
interface ParsedLikeC4Model {
|
|
740
|
+
specification: {
|
|
741
|
+
tags: Tag[];
|
|
742
|
+
elements: Record<UnwrapTagged<ElementKind>, ElementKindSpecification>;
|
|
743
|
+
relationships: Record<UnwrapTagged<ElementKind>, RelationshipKindSpecification>;
|
|
744
|
+
};
|
|
745
|
+
elements: Record<Fqn, Element>;
|
|
746
|
+
relations: Record<RelationID, Relation>;
|
|
747
|
+
views: Record<ViewID, LikeC4View>;
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* Same as `ParsedLikeC4Model` but with computed views.
|
|
751
|
+
*/
|
|
752
|
+
interface ComputedLikeC4Model extends Omit<ParsedLikeC4Model, 'views'> {
|
|
753
|
+
views: Record<ViewID, ComputedView>;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* OverviewGraph is a graph representation of all views in a model
|
|
758
|
+
*/
|
|
759
|
+
declare namespace OverviewGraph {
|
|
760
|
+
type Node = {
|
|
761
|
+
id: string;
|
|
762
|
+
type: 'folder' | 'file';
|
|
763
|
+
path: string;
|
|
764
|
+
label: string;
|
|
765
|
+
parentId: string | null;
|
|
766
|
+
position: XYPoint;
|
|
767
|
+
width: number;
|
|
768
|
+
height: number;
|
|
769
|
+
} | {
|
|
770
|
+
id: string;
|
|
771
|
+
type: 'view';
|
|
772
|
+
viewId: ViewID;
|
|
773
|
+
label: string;
|
|
774
|
+
parentId: string | null;
|
|
775
|
+
position: XYPoint;
|
|
776
|
+
width: number;
|
|
777
|
+
height: number;
|
|
778
|
+
};
|
|
779
|
+
/**
|
|
780
|
+
* Edge represents a navigational link from one view to another
|
|
781
|
+
*/
|
|
782
|
+
type Edge = {
|
|
783
|
+
id: string;
|
|
784
|
+
source: string;
|
|
785
|
+
target: string;
|
|
786
|
+
points: NonEmptyArray<Point>;
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
interface OverviewGraph {
|
|
790
|
+
nodes: OverviewGraph.Node[];
|
|
791
|
+
edges: OverviewGraph.Edge[];
|
|
792
|
+
bounds: BBox;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
declare namespace ViewChange {
|
|
796
|
+
interface ChangeElementStyle {
|
|
797
|
+
op: 'change-element-style';
|
|
798
|
+
style: {
|
|
799
|
+
border?: BorderStyle;
|
|
800
|
+
opacity?: number;
|
|
801
|
+
shape?: ElementShape;
|
|
802
|
+
color?: ThemeColor;
|
|
803
|
+
};
|
|
804
|
+
targets: NonEmptyArray<Fqn>;
|
|
805
|
+
}
|
|
806
|
+
interface SaveManualLayout {
|
|
807
|
+
op: 'save-manual-layout';
|
|
808
|
+
layout: ViewManualLayout;
|
|
809
|
+
}
|
|
810
|
+
interface ChangeAutoLayout {
|
|
811
|
+
op: 'change-autolayout';
|
|
812
|
+
layout: AutoLayoutDirection;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
type ViewChange = ViewChange.ChangeElementStyle | ViewChange.SaveManualLayout | ViewChange.ChangeAutoLayout;
|
|
816
|
+
|
|
817
|
+
export { type ElementPredicateExpression as $, AsFqn as A, BorderStyles as B, type ComputedView as C, DefaultThemeColor as D, type EdgeId as E, type Fqn as F, type CustomElementExpr as G, type HexColorLiteral as H, type IconUrl as I, isCustomElement as J, isWildcard as K, type LiteralUnion as L, type ElementKindExpr as M, type NodeId as N, isElementKindExpr as O, type Primitive as P, type ElementTagExpr as Q, type RelationID as R, isElementTagExpr as S, type ThemeColorValues as T, type ElementExpression as U, type ViewID as V, type WildcardExpr as W, type XYPoint as X, isElement as Y, type ElementWhereExpr as Z, isElementWhere as _, type Tag as a, type DynamicViewRule as a$, isElementPredicateExpr as a0, type RelationExpr as a1, isRelation as a2, type InOutExpr as a3, isInOut as a4, type IncomingExpr as a5, isIncoming as a6, type OutgoingExpr as a7, isOutgoing as a8, type RelationExpression as a9, DefaultArrowType as aA, DefaultRelationshipColor as aB, type RelationshipKindSpecification as aC, type ThemeColor as aD, type ColorLiteral as aE, isThemeColor as aF, type ElementThemeColorValues as aG, type ElementThemeColors as aH, type RelationshipThemeColorValues as aI, type RelationshipThemeColors as aJ, type LikeC4Theme as aK, type ViewRulePredicate as aL, isViewRulePredicate as aM, type ViewRuleStyle as aN, isViewRuleStyle as aO, type AutoLayoutDirection as aP, type ViewRuleAutoLayout as aQ, isViewRuleAutoLayout as aR, type ViewRule as aS, type BasicView as aT, type BasicElementView as aU, type ScopedElementView as aV, type ExtendsElementView as aW, type ElementView as aX, type DynamicViewStep as aY, type DynamicViewIncludeRule as aZ, isDynamicViewIncludeRule as a_, isRelationExpression as aa, type RelationWhereExpr as ab, isRelationWhere as ac, type CustomRelationExpr as ad, isCustomRelationExpr as ae, type RelationPredicateExpression as af, isRelationPredicateExpr as ag, type Expression as ah, type ParsedLikeC4Model as ai, type EqualOperator as aj, type TagEqual as ak, isTagEqual as al, type KindEqual as am, isKindEqual as an, type NotOperator as ao, isNotOperator as ap, type AndOperator as aq, isAndOperator as ar, type OrOperator as as, isOrOperator as at, type WhereOperator as au, whereOperatorAsPredicate as av, OverviewGraph as aw, type RelationshipLineType as ax, type RelationshipArrowType as ay, DefaultLineStyle as az, type ComputedNode as b, type DynamicView as b0, type CustomColorDefinitions as b1, type LikeC4View as b2, isDynamicView as b3, isElementView as b4, isExtendsElementView as b5, isScopedElementView as b6, type StepEdgeIdLiteral as b7, StepEdgeId as b8, isStepEdgeId as b9, extractStep as ba, type ViewWithHash as bb, type ViewWithNotation as bc, type ComputedElementView as bd, type ComputedDynamicView as be, isComputedDynamicView as bf, isComputedElementView as bg, type BBox as bh, getBBoxCenter as bi, type DiagramNode as bj, type DiagramEdge as bk, type DiagramView as bl, type ViewManualLayout as bm, ViewChange as bn, type ElementNotation as bo, type ElementKind as c, type ElementShape as d, type Color as e, type ComputedEdge as f, type ComputedLikeC4Model as g, type Element as h, type Relation as i, type RelationshipKind as j, type NonEmptyArray as k, expression as l, type CustomColor as m, type Point as n, type BorderStyle as o, ElementShapes as p, DefaultElementShape as q, type ElementStyle as r, type TagSpec as s, type Link as t, type ElementKindSpecificationStyle as u, type ElementKindSpecification as v, type ElementRefExpr as w, isElementRef as x, type ExpandedElementExpr as y, isExpandedElementExpr as z };
|