likec4 1.30.0 → 1.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/react/index.d.mts CHANGED
@@ -2,16 +2,72 @@
2
2
 
3
3
  import { CSSProperties, ComponentType, DependencyList, HTMLAttributes, JSX, MouseEvent as ReactMouseEvent, PropsWithChildren, ReactNode, WheelEvent as WheelEvent$1 } from 'react';
4
4
 
5
- type Primitive = null | undefined | string | number | boolean | symbol | bigint;
6
5
  type UnionToIntersection<Union> = (
7
6
  // `extends unknown` is always going to be the case and is used to convert the
8
7
  // `Union` into a [distributive conditional
9
8
  // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
10
9
  Union extends unknown ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection & Union : never;
10
+ type KeysOfUnion<ObjectType> =
11
+ // Hack to fix https://github.com/sindresorhus/type-fest/issues/1008
12
+ keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
13
+ type OptionalKeysOf<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
14
+ ? (keyof {
15
+ [Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never;
16
+ }) & (keyof BaseType) // Intersect with `keyof BaseType` to ensure result of `OptionalKeysOf<BaseType>` is always assignable to `keyof BaseType`
17
+ : never;
18
+ type RequiredKeysOf<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
19
+ ? Exclude<keyof BaseType, OptionalKeysOf<BaseType>> : never;
20
+ type IsNever<T> = [
21
+ T
22
+ ] extends [
23
+ never
24
+ ] ? true : false;
25
+ type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (IsNever<T> extends true ? TypeIfNever : TypeIfNotNever);
26
+ type UnknownArray = readonly unknown[];
27
+ type IsArrayReadonly<T extends UnknownArray> = IfNever<T, false, T extends unknown[] ? false : true>;
28
+ type IfArrayReadonly<T extends UnknownArray, TypeIfArrayReadonly = true, TypeIfNotArrayReadonly = false> = IsArrayReadonly<T> extends infer Result ? Result extends true ? TypeIfArrayReadonly : TypeIfNotArrayReadonly : never;
29
+ type NoInfer$1<T> = T extends infer U ? U : never;
30
+ type IsAny<T> = 0 extends 1 & NoInfer$1<T> ? true : false;
31
+ type IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
11
32
  type Simplify<T> = {
12
33
  [KeyType in keyof T]: T[KeyType];
13
34
  } & {};
14
- type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
35
+ type OmitIndexSignature<ObjectType> = {
36
+ [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType];
37
+ };
38
+ type PickIndexSignature<ObjectType> = {
39
+ [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType];
40
+ };
41
+ type SimpleMerge<Destination, Source> = {
42
+ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
43
+ } & Source;
44
+ type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
45
+ type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny<T> extends true ? TypeIfAny : TypeIfNotAny);
46
+ type HomomorphicPick<T, Keys extends KeysOfUnion<T>> = {
47
+ [P in keyof T as Extract<P, Keys>]: T[P];
48
+ };
49
+ type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = IfAny<SpecifiedOptions, Defaults, IfNever<SpecifiedOptions, Defaults, Simplify<Merge<Defaults, {
50
+ [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? Extract<SpecifiedOptions[Key], undefined> extends never ? Key : never : Key]: SpecifiedOptions[Key];
51
+ }> & Required<Options>> // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
52
+ >>;
53
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
54
+ type ExceptOptions = {
55
+ /**
56
+ Disallow assigning non-specified properties.
57
+
58
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
59
+
60
+ @default false
61
+ */
62
+ requireExactProps?: boolean;
63
+ };
64
+ type DefaultExceptOptions = {
65
+ requireExactProps: false;
66
+ };
67
+ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
68
+ type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = {
69
+ [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
70
+ } & (Options["requireExactProps"] extends true ? Partial<Record<KeysType, never>> : {});
15
71
  declare const tag: unique symbol;
16
72
  type TagContainer<Token> = {
17
73
  readonly [tag]: Token;
@@ -20,114 +76,111 @@ type Tag<Token extends PropertyKey, TagMetadata> = TagContainer<{
20
76
  [K in Token]: TagMetadata;
21
77
  }>;
22
78
  type Tagged<Type, TagName extends PropertyKey, TagMetadata = never> = Type & Tag<TagName, TagMetadata>;
79
+ type SetRequired<BaseType, Keys extends keyof BaseType> = BaseType extends UnknownArray ? SetArrayRequired<BaseType, Keys> extends infer ResultantArray ? IfArrayReadonly<BaseType, Readonly<ResultantArray>, ResultantArray> : never : Simplify<
80
+ // Pick just the keys that are optional from the base type.
81
+ Except<BaseType, Keys> &
82
+ // Pick the keys that should be required from the base type and make them required.
83
+ Required<HomomorphicPick<BaseType, Keys>>>;
84
+ type SetArrayRequired<TArray extends UnknownArray, Keys, Counter extends any[] = [
85
+ ], Accumulator extends UnknownArray = [
86
+ ]> = TArray extends unknown // For distributing `TArray` when it's a union
87
+ ? keyof TArray & `${number}` extends never ? [
88
+ ...Accumulator,
89
+ ...TArray
90
+ ] : TArray extends readonly [
91
+ (infer First)?,
92
+ ...infer Rest
93
+ ] ? "0" extends OptionalKeysOf<TArray> // If the first element of `TArray` is optional
94
+ ? `${Counter["length"]}` extends `${Keys & (string | number)}` // If the current index needs to be required
95
+ ? SetArrayRequired<Rest, Keys, [
96
+ ...Counter,
97
+ any
98
+ ], [
99
+ ...Accumulator,
100
+ First
101
+ ]> : [
102
+ ...Accumulator,
103
+ ...TArray
104
+ ] : SetArrayRequired<Rest, Keys, [
105
+ ...Counter,
106
+ any
107
+ ], [
108
+ ...Accumulator,
109
+ TArray[0]
110
+ ]> : never // Should never happen, since `[(infer F)?, ...infer R]` is a top-type for arrays.
111
+ : never;
23
112
  type TupleToUnion<ArrayType> = ArrayType extends readonly unknown[] ? ArrayType[number] : never;
24
113
  type NonEmptyArray<T> = [
25
114
  T,
26
115
  ...T[]
27
116
  ];
28
- type Point = readonly [
29
- x: number,
30
- y: number
31
- ];
32
- interface XYPoint {
33
- x: number;
34
- y: number;
35
- }
36
- type AllNever<Expressions> = UnionToIntersection<{
37
- [Name in keyof Expressions]: {
38
- -readonly [Key in keyof Expressions[Name]]?: never;
39
- };
40
- }[keyof Expressions]>;
41
- type ExclusiveUnion<Expressions> = Expressions extends object ? {
42
- [Name in keyof Expressions]: Simplify<Omit<AllNever<Expressions>, keyof Expressions[Name]> & Expressions[Name]>;
43
- }[keyof Expressions] : Expressions;
44
- type ProjectId = Tagged<string, "ProjectID">;
45
- type IconUrl = Tagged<string, "IconUrl"> | "none";
46
- type Fqn<Id extends string = string> = Tagged<Id, "Fqn">;
47
- type Tag$1<Tags extends string = string> = Tagged<Tags, "Tag">;
48
- declare const ThemeColors: readonly [
49
- "amber",
50
- "blue",
51
- "gray",
52
- "slate",
53
- "green",
54
- "indigo",
55
- "muted",
56
- "primary",
57
- "red",
58
- "secondary",
59
- "sky"
60
- ];
61
- type ThemeColor = typeof ThemeColors[number];
62
- type HexColorLiteral = `#${string}`;
63
- type ColorLiteral = HexColorLiteral;
64
- type Color = LiteralUnion<ThemeColor, string>;
65
- type ShapeSize = "xs" | "sm" | "md" | "lg" | "xl";
66
- type SpacingSize = "xs" | "sm" | "md" | "lg" | "xl";
67
- type TextSize = "xs" | "sm" | "md" | "lg" | "xl";
68
- interface ElementThemeColorValues {
69
- fill: ColorLiteral;
70
- stroke: ColorLiteral;
71
- hiContrast: ColorLiteral;
72
- loContrast: ColorLiteral;
73
- }
74
- interface RelationshipThemeColorValues {
75
- lineColor: ColorLiteral;
76
- labelBgColor: ColorLiteral;
77
- labelColor: ColorLiteral;
78
- }
79
- interface ThemeColorValues {
80
- elements: ElementThemeColorValues;
81
- relationships: RelationshipThemeColorValues;
82
- }
83
- declare const BorderStyles: readonly [
84
- "solid",
85
- "dashed",
86
- "dotted",
87
- "none"
88
- ];
89
- type BorderStyle = TupleToUnion<typeof BorderStyles>;
90
- type ElementKind<Kinds extends string = string> = Tagged<Kinds, "ElementKind">;
91
- declare namespace ElementKind {
92
- const Group: ElementKind;
117
+ interface Link {
118
+ title?: string;
119
+ url: string;
120
+ relative?: string;
93
121
  }
94
- declare const ElementShapes: readonly [
95
- "rectangle",
96
- "person",
97
- "browser",
98
- "mobile",
99
- "cylinder",
100
- "storage",
101
- "queue"
102
- ];
103
- type ElementShape = TupleToUnion<typeof ElementShapes>;
104
- interface ElementStyle {
105
- readonly border?: BorderStyle;
106
- /**
107
- * In percentage 0-100, 0 is fully transparent
108
- *
109
- * @default 100
110
- */
111
- readonly opacity?: number;
112
- /**
113
- * If true, the element is rendered as multiple shapes
114
- * @default false
115
- */
116
- readonly multiple?: boolean;
117
- /**
118
- * Shape size
119
- *
120
- * @default 'md'
121
- */
122
- readonly size?: ShapeSize;
123
- readonly padding?: SpacingSize;
124
- readonly textSize?: TextSize;
122
+ type Coalesce<V extends string, OrIfAny = string> = IsAny<V> extends true ? OrIfAny : V;
123
+ type BuiltInIcon = "none" | `${"aws" | "azure" | "gcp" | "tech"}:${string}`;
124
+ type Icon = Tagged<string, "Icon"> | BuiltInIcon;
125
+ type IconUrl = Icon;
126
+ type Fqn<Id = string> = Tagged<Id, "Fqn">;
127
+ declare function Fqn(name: string, parent?: Fqn | null): Fqn;
128
+ type DeploymentFqn<T = string> = Tagged<T, "DeploymentFqn">;
129
+ declare function DeploymentFqn(name: string, parent?: DeploymentFqn | null): DeploymentFqn;
130
+ type ViewId<Id = string> = Tagged<Id, "ViewId">;
131
+ declare function ViewId(id: string): ViewId;
132
+ type RelationId<Id = string> = Tagged<Id, "RelationId">;
133
+ declare function RelationId(id: string): RelationId;
134
+ type NodeId = Tagged<string, "NodeId" | "Fqn" | "DeploymentFqn">;
135
+ declare function NodeId(id: string): NodeId;
136
+ type EdgeId = Tagged<string, "EdgeId">;
137
+ declare function EdgeId(id: string): EdgeId;
138
+ declare const StepEdgeKind = "@step";
139
+ type ModelStage = "parsed" | "computed" | "layouted";
140
+ declare const _stage = "_stage";
141
+ type _stage = typeof _stage;
142
+ declare const _type = "_type";
143
+ type _type = typeof _type;
144
+ interface SpecAux<ElementKind extends string, DeploymentKind extends string, RelationKind extends string, Tag extends string, MetadataKey extends string> {
145
+ ElementKind: ElementKind;
146
+ DeploymentKind: DeploymentKind;
147
+ RelationKind: RelationKind;
148
+ Tag: Tag;
149
+ MetadataKey: MetadataKey;
125
150
  }
126
- interface Link {
127
- readonly title?: string;
128
- readonly url: string;
129
- readonly relative?: string;
151
+ interface Aux<Stage extends ModelStage, Element extends string, Deployment extends string, View extends string, Project extends string, Spec extends SpecAux<string, string, string, string, string>> {
152
+ Stage: Stage;
153
+ ProjectId: Project;
154
+ ElementId: Element;
155
+ DeploymentId: Deployment;
156
+ ViewId: View;
157
+ ElementKind: Spec["ElementKind"];
158
+ DeploymentKind: Spec["DeploymentKind"];
159
+ RelationKind: Spec["RelationKind"];
160
+ Tag: Spec["Tag"];
161
+ MetadataKey: Spec["MetadataKey"];
130
162
  }
163
+ type Any = Aux<any, any, any, any, any, SpecAux<any, any, any, any, any>>;
164
+ type UnknownLayouted = Aux<"layouted", string, string, string, string, SpecAux<string, string, string, string, string>>;
165
+ type Fqn$1<A> = A extends infer T extends Any ? Fqn<ElementId<T>> : never;
166
+ type ElementId<A> = A extends infer T extends Any ? Coalesce<T["ElementId"]> : never;
167
+ type DeploymentFqn$1<A> = A extends infer T extends Any ? DeploymentFqn<DeploymentId<T>> : never;
168
+ type DeploymentId<A> = A extends infer T extends Any ? Coalesce<T["DeploymentId"]> : never;
169
+ type ViewId$1<A> = A extends infer T extends Any ? Coalesce<T["ViewId"]> : never;
170
+ type RelationId$1 = RelationId;
171
+ type ElementKind<A> = A extends infer T extends Any ? Coalesce<T["ElementKind"]> : never;
172
+ type DeploymentKind<A> = A extends infer T extends Any ? Coalesce<T["DeploymentKind"]> : never;
173
+ type RelationKind<A> = A extends infer T extends Any ? Coalesce<T["RelationKind"]> : never;
174
+ type Tag$1<A> = A extends infer T extends Any ? Coalesce<T["Tag"]> : never;
175
+ type Tags<A extends Any> = readonly Tag$1<A>[];
176
+ type AllKinds<A> = ElementKind<A> | DeploymentKind<A> | RelationKind<A>;
177
+ type StrictViewId<A> = A extends infer T extends Any ? ViewId<ViewId$1<T>> : never;
178
+ type WithOptionalTags<A extends Any> = {
179
+ readonly tags?: Tags<A> | null;
180
+ };
181
+ type WithOptionalLinks = {
182
+ readonly links?: readonly Link[] | null;
183
+ };
131
184
  type EqualOperator<V> = {
132
185
  eq: V;
133
186
  neq?: never;
@@ -135,504 +188,105 @@ type EqualOperator<V> = {
135
188
  eq?: never;
136
189
  neq: V;
137
190
  };
138
- type AllNever$1 = {
191
+ type AllNever = {
139
192
  not?: never;
140
193
  and?: never;
141
194
  or?: never;
142
195
  tag?: never;
143
196
  kind?: never;
144
197
  participant?: never;
198
+ operator?: never;
145
199
  };
146
- type TagEqual<Tag> = Omit<AllNever$1, "tag"> & {
147
- tag: EqualOperator<Tag>;
200
+ type TagEqual<A extends Any> = Omit<AllNever, "tag"> & {
201
+ tag: EqualOperator<Tag$1<A>> | Tag$1<A>;
148
202
  };
149
- type KindEqual<Kind> = Omit<AllNever$1, "kind"> & {
150
- kind: EqualOperator<Kind>;
203
+ type KindEqual<A extends Any> = Omit<AllNever, "kind"> & {
204
+ kind: EqualOperator<AllKinds<A>> | AllKinds<A>;
151
205
  };
152
206
  type Participant = "source" | "target";
153
- type ParticipantOperator<Tag, Kind> = Omit<AllNever$1, "participant"> & {
207
+ type ParticipantOperator<A extends Any> = Omit<AllNever, "participant" | "operator"> & {
154
208
  participant: Participant;
155
- operator: KindEqual<Kind> | TagEqual<Tag>;
209
+ operator: KindEqual<A> | TagEqual<A>;
156
210
  };
157
- type NotOperator<Tag, Kind> = Omit<AllNever$1, "not"> & {
158
- not: WhereOperator<Tag, Kind>;
211
+ type NotOperator<A extends Any> = Omit<AllNever, "not"> & {
212
+ not: WhereOperator<A>;
159
213
  };
160
- type AndOperator<Tag, Kind> = Omit<AllNever$1, "and"> & {
161
- and: NonEmptyArray<WhereOperator<Tag, Kind>>;
214
+ type AndOperator<A extends Any> = Omit<AllNever, "and"> & {
215
+ and: NonEmptyArray<WhereOperator<A>>;
162
216
  };
163
- type OrOperator<Tag, Kind> = Omit<AllNever$1, "or"> & {
164
- or: NonEmptyArray<WhereOperator<Tag, Kind>>;
217
+ type OrOperator<A extends Any> = Omit<AllNever, "or"> & {
218
+ or: NonEmptyArray<WhereOperator<A>>;
165
219
  };
166
- type WhereOperator<Tag, Kind> = TagEqual<Tag> | KindEqual<Kind> | ParticipantOperator<Tag, Kind> | NotOperator<Tag, Kind> | AndOperator<Tag, Kind> | OrOperator<Tag, Kind>;
167
- declare namespace FqnRef {
168
- /**
169
- * Represents a reference to an instance within a deployment.
170
- *
171
- * @template D - The type representing the deployment fqn. Defaults to `Fqn`.
172
- * @template M - The type representing the model fqn. Defaults to `Fqn`.
173
- *
174
- * @property {D} deployment - TThe fully qualified name (FQN) of the deployed instance.
175
- * @property {M} element - The element reference within the deployment.
176
- */
177
- type InsideInstanceRef<D = Fqn, M = Fqn> = {
178
- deployment: D;
179
- element: M;
180
- };
181
- const isInsideInstanceRef: (ref: FqnRef) => ref is InsideInstanceRef;
182
- /**
183
- * Represents a reference to a deployment element.
184
- *
185
- * @template F - The type of the fully qualified name (FQN) of the deployment element. Defaults to `Fqn`.
186
- * @property {F} deployment - The fully qualified name (FQN) of the deployment element.
187
- */
188
- type DeploymentElementRef<F = Fqn> = {
189
- deployment: F;
190
- };
191
- const isDeploymentElementRef: (ref: FqnRef) => ref is DeploymentElementRef;
192
- type DeploymentRef<D = Fqn, M = Fqn> = DeploymentElementRef<D> | InsideInstanceRef<D, M>;
193
- const isDeploymentRef: (ref: FqnRef) => ref is DeploymentRef;
194
- /**
195
- * Reference to logical model element
196
- */
197
- type ModelRef<F = Fqn> = {
198
- model: F;
199
- };
200
- const isModelRef: (ref: FqnRef) => ref is ModelRef;
201
- /**
202
- * Reference to imported logical model element
203
- */
204
- type ImportRef<F = Fqn> = {
205
- project: ProjectId;
206
- model: F;
207
- };
208
- const isImportRef: (ref: FqnRef) => ref is ImportRef;
209
- const toDeploymentRef: (ref: FqnRef) => DeploymentRef;
210
- const toModelFqn: (ref: FqnRef) => Fqn;
211
- }
212
- type FqnRef<D = Fqn, M = Fqn> = ExclusiveUnion<{
213
- InsideInstanceRef: FqnRef.InsideInstanceRef<D, M>;
214
- DeploymentRef: FqnRef.DeploymentRef<D>;
215
- ModelRef: FqnRef.ModelRef<M>;
216
- ImportRef: FqnRef.ImportRef<M>;
217
- }>;
218
- declare namespace FqnExpr {
219
- type Wildcard = {
220
- wildcard: true;
221
- };
222
- const isWildcard: (expr: ExpressionV2) => expr is FqnExpr.Wildcard;
223
- type ModelRef<M = Fqn> = {
224
- ref: FqnRef.ModelRef<M> | FqnRef.ImportRef<M>;
225
- selector?: PredicateSelector;
226
- };
227
- const isModelRef: (ref: ExpressionV2) => ref is FqnExpr.ModelRef;
228
- type DeploymentRef<D = Fqn, M = Fqn> = {
229
- ref: FqnRef.DeploymentRef<D> | FqnRef.InsideInstanceRef<D, M>;
230
- selector?: PredicateSelector;
231
- };
232
- const isDeploymentRef: (ref: ExpressionV2) => ref is FqnExpr.DeploymentRef;
233
- type ElementKindExpr = {
234
- elementKind: ElementKind;
235
- isEqual: boolean;
236
- };
237
- function isElementKindExpr(expr: ExpressionV2): expr is ElementKindExpr;
238
- type ElementTagExpr = {
239
- elementTag: Tag$1;
240
- isEqual: boolean;
241
- };
242
- function isElementTagExpr(expr: ExpressionV2): expr is ElementTagExpr;
243
- type NonWildcard<D = Fqn, M = Fqn> = ExclusiveUnion<{
244
- ModelRef: ModelRef<M>;
245
- DeploymentRef: DeploymentRef<D, M>;
246
- ElementKind: ElementKindExpr;
247
- ElementTag: ElementTagExpr;
248
- }>;
249
- type Where<D = Fqn, M = Fqn> = {
250
- where: {
251
- expr: ExclusiveUnion<{
252
- Wildcard: Wildcard;
253
- ModelRef: ModelRef<M>;
254
- DeploymentRef: DeploymentRef<D, M>;
255
- ElementKind: ElementKindExpr;
256
- ElementTag: ElementTagExpr;
257
- }>;
258
- condition: WhereOperator<string, string>;
259
- };
260
- };
261
- const isWhere: (expr: ExpressionV2) => expr is FqnExpr.Where;
262
- type Custom<D = Fqn, M = Fqn> = {
263
- custom: {
264
- expr: OrWhere<D, M>;
265
- title?: string;
266
- description?: string;
267
- technology?: string;
268
- notation?: string;
269
- shape?: ElementShape;
270
- color?: Color;
271
- icon?: IconUrl;
272
- border?: BorderStyle;
273
- opacity?: number;
274
- navigateTo?: ViewId;
275
- multiple?: boolean;
276
- size?: ShapeSize;
277
- padding?: ShapeSize;
278
- textSize?: ShapeSize;
279
- };
280
- };
281
- const isCustom: (expr: ExpressionV2) => expr is Custom;
282
- const is: (expr: ExpressionV2) => expr is FqnExpr;
283
- type OrWhere<D = Fqn, M = Fqn> = ExclusiveUnion<{
284
- Wildcard: FqnExpr.Wildcard;
285
- ModelRef: FqnExpr.ModelRef<M>;
286
- DeploymentRef: FqnExpr.DeploymentRef<D, M>;
287
- ElementKind: ElementKindExpr;
288
- ElementTag: ElementTagExpr;
289
- Where: FqnExpr.Where<D, M>;
290
- }>;
291
- type Any<D = Fqn, M = Fqn> = ExclusiveUnion<{
292
- Wildcard: Wildcard;
293
- ModelRef: ModelRef<M>;
294
- DeploymentRef: DeploymentRef<D, M>;
295
- ElementKind: ElementKindExpr;
296
- ElementTag: ElementTagExpr;
297
- Where: Where<D, M>;
298
- Custom: Custom<D, M>;
299
- }>;
300
- const unwrap: (expr: FqnExpr) => Wildcard | ModelRef | DeploymentRef | ElementKindExpr | ElementTagExpr;
301
- }
302
- type FqnExpr<D = Fqn, M = Fqn> = ExclusiveUnion<{
303
- Wildcard: FqnExpr.Wildcard;
304
- ModelRef: FqnExpr.ModelRef<M>;
305
- DeploymentRef: FqnExpr.DeploymentRef<D, M>;
306
- ElementKind: FqnExpr.ElementKindExpr;
307
- ElementTag: FqnExpr.ElementTagExpr;
308
- }>;
309
- declare namespace RelationExpr {
310
- type Endpoint<D = Fqn, M = Fqn> = FqnExpr.Where<D, M>["where"]["expr"];
311
- type Direct<D = Fqn, M = Fqn> = {
312
- source: Endpoint<D, M>;
313
- target: Endpoint<D, M>;
314
- isBidirectional?: boolean;
315
- };
316
- const isDirect: (expr: ExpressionV2) => expr is RelationExpr.Direct;
317
- type Incoming<D = Fqn, M = Fqn> = {
318
- incoming: Endpoint<D, M>;
319
- };
320
- const isIncoming: (expr: ExpressionV2) => expr is RelationExpr.Incoming;
321
- type Outgoing<D = Fqn, M = Fqn> = {
322
- outgoing: Endpoint<D, M>;
323
- };
324
- const isOutgoing: (expr: ExpressionV2) => expr is RelationExpr.Outgoing;
325
- type InOut<D = Fqn, M = Fqn> = {
326
- inout: Endpoint<D, M>;
327
- };
328
- const isInOut: (expr: ExpressionV2) => expr is RelationExpr.InOut;
329
- type Where<D = Fqn, M = Fqn> = {
330
- where: {
331
- expr: ExclusiveUnion<{
332
- Direct: RelationExpr.Direct<D, M>;
333
- Incoming: RelationExpr.Incoming<D, M>;
334
- Outgoing: RelationExpr.Outgoing<D, M>;
335
- InOut: RelationExpr.InOut<D, M>;
336
- }>;
337
- condition: WhereOperator<string, string>;
338
- };
339
- };
340
- const isWhere: (expr: ExpressionV2) => expr is RelationExpr.Where;
341
- type Custom<D = Fqn, M = Fqn> = {
342
- customRelation: {
343
- expr: OrWhere<D, M>;
344
- title?: string;
345
- description?: string;
346
- technology?: string;
347
- notation?: string;
348
- navigateTo?: ViewId;
349
- notes?: string;
350
- color?: Color;
351
- line?: RelationshipLineType;
352
- head?: RelationshipArrowType;
353
- tail?: RelationshipArrowType;
354
- };
355
- };
356
- const isCustom: (expr: ExpressionV2) => expr is Custom;
357
- const is: (expr: ExpressionV2) => expr is RelationExpr;
358
- type OrWhere<D = Fqn, M = Fqn> = ExclusiveUnion<{
359
- Direct: Direct<D, M>;
360
- Incoming: Incoming<D, M>;
361
- Outgoing: Outgoing<D, M>;
362
- InOut: InOut<D, M>;
363
- Where: Where<D, M>;
364
- }>;
365
- type Any<D = Fqn, M = Fqn> = ExclusiveUnion<{
366
- Direct: Direct<D, M>;
367
- Incoming: Incoming<D, M>;
368
- Outgoing: Outgoing<D, M>;
369
- InOut: InOut<D, M>;
370
- Where: Where<D, M>;
371
- Custom: Custom<D, M>;
372
- }>;
373
- const unwrap: (expr: RelationExpr) => Direct | Incoming | Outgoing | InOut;
374
- }
375
- type RelationExpr<D = Fqn, M = Fqn> = ExclusiveUnion<{
376
- Direct: RelationExpr.Direct<D, M>;
377
- Incoming: RelationExpr.Incoming<D, M>;
378
- Outgoing: RelationExpr.Outgoing<D, M>;
379
- InOut: RelationExpr.InOut<D, M>;
380
- }>;
381
- type ExpressionV2<D = Fqn, M = Fqn> = ExclusiveUnion<{
382
- Wildcard: FqnExpr.Wildcard;
383
- ModelRef: FqnExpr.ModelRef<M>;
384
- DeploymentRef: FqnExpr.DeploymentRef<D, M>;
385
- ElementKind: FqnExpr.ElementKindExpr;
386
- ElementTag: FqnExpr.ElementTagExpr;
387
- Custom: FqnExpr.Custom<D, M>;
388
- Direct: RelationExpr.Direct<D, M>;
389
- Incoming: RelationExpr.Incoming<D, M>;
390
- Outgoing: RelationExpr.Outgoing<D, M>;
391
- InOut: RelationExpr.InOut<D, M>;
392
- Where: ExpressionV2.Where<D, M>;
393
- CustomRelation: RelationExpr.Custom<D, M>;
394
- }>;
395
- declare namespace ExpressionV2 {
396
- type Where<D = Fqn, M = Fqn> = FqnExpr.Where<D, M> | RelationExpr.Where<D, M>;
397
- const isWhere: (expr: ExpressionV2) => expr is ExpressionV2.Where;
398
- const isRelationWhere: (expr: ExpressionV2) => expr is RelationExpr.Where;
399
- const isFqnExprWhere: (expr: ExpressionV2) => expr is FqnExpr.Where;
400
- const isFqnExpr: (expr: ExpressionV2) => expr is FqnExpr.Any;
401
- const isRelation: (expr: ExpressionV2) => expr is RelationExpr.Any;
220
+ type WhereOperator<A extends Any = Any> = TagEqual<A> | KindEqual<A> | ParticipantOperator<A> | NotOperator<A> | AndOperator<A> | OrOperator<A>;
221
+ type SpacingSize = "xs" | "sm" | "md" | "lg" | "xl";
222
+ type TextSize = "xs" | "sm" | "md" | "lg" | "xl";
223
+ type ShapeSize = "xs" | "sm" | "md" | "lg" | "xl";
224
+ declare const BorderStyles: readonly [
225
+ "solid",
226
+ "dashed",
227
+ "dotted",
228
+ "none"
229
+ ];
230
+ type BorderStyle = TupleToUnion<typeof BorderStyles>;
231
+ declare const ElementShapes: readonly [
232
+ "rectangle",
233
+ "person",
234
+ "browser",
235
+ "mobile",
236
+ "cylinder",
237
+ "storage",
238
+ "queue"
239
+ ];
240
+ type ElementShape = TupleToUnion<typeof ElementShapes>;
241
+ type HexColor = `#${string}`;
242
+ type RelationshipLineType = "dashed" | "solid" | "dotted";
243
+ type RelationshipArrowType = "none" | "normal" | "onormal" | "dot" | "odot" | "diamond" | "odiamond" | "crow" | "open" | "vee";
244
+ declare const ThemeColors: readonly [
245
+ "amber",
246
+ "blue",
247
+ "gray",
248
+ "slate",
249
+ "green",
250
+ "indigo",
251
+ "muted",
252
+ "primary",
253
+ "red",
254
+ "secondary",
255
+ "sky"
256
+ ];
257
+ type ThemeColor = typeof ThemeColors[number];
258
+ type Color = ThemeColor | HexColor;
259
+ type Point = readonly [
260
+ x: number,
261
+ y: number
262
+ ];
263
+ interface XYPoint {
264
+ x: number;
265
+ y: number;
402
266
  }
403
- declare namespace ModelLayer {
404
- namespace FqnRef {
405
- /**
406
- * Reference to logical model element
407
- */
408
- type ModelRef<F = Fqn> = {
409
- model: F;
410
- };
411
- const isModelRef: (ref: FqnRef) => ref is ModelRef;
412
- /**
413
- * Reference to imported logical model element
414
- */
415
- type ImportRef<F = Fqn> = {
416
- project: ProjectId;
417
- model: F;
418
- };
419
- const isImportRef: (ref: FqnRef) => ref is ImportRef;
420
- const toFqn: (ref: FqnRef) => Fqn;
421
- }
422
- type FqnRef<M = Fqn> = ExclusiveUnion<{
423
- ModelRef: FqnRef.ModelRef<M>;
424
- ImportRef: FqnRef.ImportRef<M>;
425
- }>;
426
- namespace FqnExpr {
427
- type Wildcard = {
428
- wildcard: true;
429
- };
430
- const isWildcard: (expr: Expression) => expr is FqnExpr.Wildcard;
431
- type ModelRef<M = Fqn> = {
432
- ref: FqnRef.ModelRef<M> | FqnRef.ImportRef<M>;
433
- selector?: PredicateSelector;
434
- };
435
- const isModelRef: (ref: Expression) => ref is FqnExpr.ModelRef;
436
- type ElementKindExpr = {
437
- elementKind: ElementKind;
438
- isEqual: boolean;
439
- };
440
- function isElementKindExpr(expr: Expression): expr is ElementKindExpr;
441
- type ElementTagExpr = {
442
- elementTag: Tag$1;
443
- isEqual: boolean;
444
- };
445
- function isElementTagExpr(expr: Expression): expr is ElementTagExpr;
446
- type NonWildcard<M = Fqn> = ExclusiveUnion<{
447
- ModelRef: ModelRef<M>;
448
- ElementKind: ElementKindExpr;
449
- ElementTag: ElementTagExpr;
450
- }>;
451
- type Where<M = Fqn> = {
452
- where: {
453
- expr: ExclusiveUnion<{
454
- Wildcard: Wildcard;
455
- ModelRef: ModelRef<M>;
456
- ElementKind: ElementKindExpr;
457
- ElementTag: ElementTagExpr;
458
- }>;
459
- condition: WhereOperator<string, string>;
460
- };
461
- };
462
- const isWhere: (expr: Expression) => expr is FqnExpr.Where;
463
- type Custom<M = Fqn> = {
464
- custom: {
465
- expr: FqnExprOrWhere<M>;
466
- title?: string;
467
- description?: string;
468
- technology?: string;
469
- notation?: string;
470
- shape?: ElementShape;
471
- color?: Color;
472
- icon?: IconUrl;
473
- border?: BorderStyle;
474
- opacity?: number;
475
- navigateTo?: ViewId;
476
- multiple?: boolean;
477
- size?: ShapeSize;
478
- padding?: ShapeSize;
479
- textSize?: ShapeSize;
480
- };
481
- };
482
- const isCustom: (expr: Expression) => expr is FqnExpr.Custom;
483
- const is: (expr: Expression) => expr is FqnExpr;
484
- }
485
- type FqnExpr<M = Fqn> = ExclusiveUnion<{
486
- Wildcard: FqnExpr.Wildcard;
487
- ModelRef: FqnExpr.ModelRef<M>;
488
- ElementKind: FqnExpr.ElementKindExpr;
489
- ElementTag: FqnExpr.ElementTagExpr;
490
- }>;
491
- type FqnExprOrWhere<M = Fqn> = ExclusiveUnion<{
492
- Wildcard: FqnExpr.Wildcard;
493
- ModelRef: FqnExpr.ModelRef<M>;
494
- ElementKind: FqnExpr.ElementKindExpr;
495
- ElementTag: FqnExpr.ElementTagExpr;
496
- Where: FqnExpr.Where<M>;
497
- }>;
498
- type AnyFqnExpr<M = Fqn> = ExclusiveUnion<{
499
- Wildcard: FqnExpr.Wildcard;
500
- ModelRef: FqnExpr.ModelRef<M>;
501
- ElementKind: FqnExpr.ElementKindExpr;
502
- ElementTag: FqnExpr.ElementTagExpr;
503
- Where: FqnExpr.Where<M>;
504
- Custom: FqnExpr.Custom<M>;
505
- }>;
506
- function isAnyFqnExpr(expr: Expression): expr is AnyFqnExpr;
507
- namespace RelationExpr {
508
- type Direct<M = Fqn> = {
509
- source: FqnExpr<M>;
510
- target: FqnExpr<M>;
511
- isBidirectional?: boolean;
512
- };
513
- const isDirect: (expr: Expression) => expr is RelationExpr.Direct;
514
- type Incoming<M = Fqn> = {
515
- incoming: FqnExpr<M>;
516
- };
517
- const isIncoming: (expr: Expression) => expr is RelationExpr.Incoming;
518
- type Outgoing<M = Fqn> = {
519
- outgoing: FqnExpr<M>;
520
- };
521
- const isOutgoing: (expr: Expression) => expr is RelationExpr.Outgoing;
522
- type InOut<M = Fqn> = {
523
- inout: FqnExpr<M>;
524
- };
525
- const isInOut: (expr: Expression) => expr is RelationExpr.InOut;
526
- type Where<M = Fqn> = {
527
- where: {
528
- expr: ExclusiveUnion<{
529
- Direct: RelationExpr.Direct<M>;
530
- Incoming: RelationExpr.Incoming<M>;
531
- Outgoing: RelationExpr.Outgoing<M>;
532
- InOut: RelationExpr.InOut<M>;
533
- }>;
534
- condition: WhereOperator<string, string>;
535
- };
536
- };
537
- const isWhere: (expr: Expression) => expr is RelationExpr.Where;
538
- type Custom<M = Fqn> = {
539
- customRelation: {
540
- expr: RelationExprOrWhere<M>;
541
- title?: string;
542
- description?: string;
543
- technology?: string;
544
- notation?: string;
545
- navigateTo?: ViewId;
546
- notes?: string;
547
- color?: Color;
548
- line?: RelationshipLineType;
549
- head?: RelationshipArrowType;
550
- tail?: RelationshipArrowType;
551
- };
552
- };
553
- const isCustom: (expr: Expression) => expr is Custom;
554
- const is: (expr: Expression) => expr is RelationExpr;
555
- }
556
- type RelationExpr<M = Fqn> = ExclusiveUnion<{
557
- Direct: RelationExpr.Direct<M>;
558
- Incoming: RelationExpr.Incoming<M>;
559
- Outgoing: RelationExpr.Outgoing<M>;
560
- InOut: RelationExpr.InOut<M>;
561
- }>;
562
- type RelationExprOrWhere<M = Fqn> = ExclusiveUnion<{
563
- Direct: RelationExpr.Direct<M>;
564
- Incoming: RelationExpr.Incoming<M>;
565
- Outgoing: RelationExpr.Outgoing<M>;
566
- InOut: RelationExpr.InOut<M>;
567
- Where: RelationExpr.Where<M>;
568
- }>;
569
- type AnyRelationExpr<M = Fqn> = ExclusiveUnion<{
570
- Direct: RelationExpr.Direct<M>;
571
- Incoming: RelationExpr.Incoming<M>;
572
- Outgoing: RelationExpr.Outgoing<M>;
573
- InOut: RelationExpr.InOut<M>;
574
- Where: RelationExpr.Where<M>;
575
- CustomRelation: RelationExpr.Custom<M>;
576
- }>;
577
- function isAnyRelationExpr(expr: Expression): expr is AnyRelationExpr;
578
- /**
579
- * Represents a version 2 expression which can be one of several types.
580
- *
581
- * @template M - The type for the model FQN, defaults to `Fqn`.
582
- */
583
- type Expression<M = Fqn> = ExclusiveUnion<{
584
- Wildcard: FqnExpr.Wildcard;
585
- ModelRef: FqnExpr.ModelRef<M>;
586
- ElementKind: FqnExpr.ElementKindExpr;
587
- ElementTag: FqnExpr.ElementTagExpr;
588
- Custom: FqnExpr.Custom<M>;
589
- Direct: RelationExpr.Direct<M>;
590
- Incoming: RelationExpr.Incoming<M>;
591
- Outgoing: RelationExpr.Outgoing<M>;
592
- InOut: RelationExpr.InOut<M>;
593
- CustomRelation: RelationExpr.Custom<M>;
594
- Where: Expression.Where<M>;
595
- }>;
596
- function isExpression(expr: any): expr is Expression;
597
- namespace Expression {
598
- type Where<M = Fqn> = FqnExpr.Where<M> | RelationExpr.Where<M>;
599
- const isWhere: (expr: Expression) => expr is Expression.Where;
600
- const isCustomFqnExpr: (expr: Expression) => expr is FqnExpr.Custom;
601
- const isCustomRelationExpr: (expr: Expression) => expr is RelationExpr.Custom;
602
- const isFqnExpr: (expr: Expression) => expr is FqnExpr;
603
- const isRelation: (expr: Expression) => expr is RelationExpr;
604
- }
267
+ interface BBox {
268
+ x: number;
269
+ y: number;
270
+ width: number;
271
+ height: number;
605
272
  }
606
- type GlobalPredicateId = Tagged<string, "GlobalPredicateId">;
607
- type GlobalStyleID = Tagged<string, "GlobalStyleID">;
608
- type ElementNotation = {
609
- kinds: string[];
610
- shape: ElementShape;
611
- color: Color;
612
- title: string;
613
- };
614
- type ViewId<Id extends string = string> = Tagged<Id, "ViewID">;
615
- type ViewRulePredicate = {
616
- include: ModelLayer.Expression[];
617
- exclude?: never;
618
- } | {
619
- include?: never;
620
- exclude: ModelLayer.Expression[];
621
- };
622
- interface ViewRuleGlobalPredicateRef {
623
- predicateId: GlobalPredicateId;
273
+ declare namespace BBox {
274
+ function center({ x, y, width, height }: BBox): XYPoint;
275
+ function fromPoints(points: Point[]): BBox;
276
+ function merge(...boxes: BBox[]): BBox;
277
+ function toRectBox(box: BBox): RectBox;
624
278
  }
625
- interface ViewRuleStyle {
626
- targets: ModelLayer.FqnExpr[];
627
- notation?: string;
628
- style: ElementStyle & {
629
- color?: Color;
630
- shape?: ElementShape;
631
- icon?: IconUrl;
632
- };
279
+ interface RectBox {
280
+ x1: number;
281
+ y1: number;
282
+ x2: number;
283
+ y2: number;
633
284
  }
634
- interface ViewRuleGlobalStyle {
635
- styleId: GlobalStyleID;
285
+ declare namespace RectBox {
286
+ function center({ x1, y1, x2, y2 }: RectBox): XYPoint;
287
+ function fromPoints(points: Point[]): RectBox;
288
+ function merge(...boxes: RectBox[]): RectBox;
289
+ function toBBox(box: RectBox): BBox;
636
290
  }
637
291
  type AutoLayoutDirection = "TB" | "BT" | "LR" | "RL";
638
292
  interface ViewRuleAutoLayout {
@@ -640,30 +294,36 @@ interface ViewRuleAutoLayout {
640
294
  nodeSep?: number;
641
295
  rankSep?: number;
642
296
  }
643
- interface ViewRuleGroup {
644
- groupRules: Array<ViewRulePredicate | ViewRuleGroup>;
645
- title: string | null;
646
- color?: Color;
647
- border?: BorderStyle;
648
- opacity?: number;
649
- multiple?: boolean;
650
- size?: ShapeSize;
651
- padding?: SpacingSize;
652
- textSize?: TextSize;
297
+ interface ViewAutoLayout {
298
+ direction: ViewRuleAutoLayout["direction"];
299
+ rankSep?: number;
300
+ nodeSep?: number;
653
301
  }
654
- type ViewRule = ViewRulePredicate | ViewRuleGlobalPredicateRef | ViewRuleGroup | ViewRuleStyle | ViewRuleGlobalStyle | ViewRuleAutoLayout;
655
- interface BasicView<ViewType extends "element" | "dynamic" | "deployment", ViewIDs extends string, Tags extends string> {
656
- readonly __?: ViewType;
657
- readonly id: ViewId<ViewIDs>;
302
+ type ViewManualLayout = {
303
+ readonly hash: string;
304
+ readonly x: number;
305
+ readonly y: number;
306
+ readonly width: number;
307
+ readonly height: number;
308
+ readonly autoLayout: ViewAutoLayout;
309
+ readonly nodes: Record<string, {
310
+ isCompound: boolean;
311
+ x: number;
312
+ y: number;
313
+ width: number;
314
+ height: number;
315
+ }>;
316
+ readonly edges: Record<string, {
317
+ dotpos?: string;
318
+ points: NonEmptyArray<Point>;
319
+ controlPoints?: NonEmptyArray<XYPoint>;
320
+ labelBBox?: BBox;
321
+ }>;
322
+ };
323
+ interface BaseViewProperties<A extends Any> extends WithOptionalTags<A>, WithOptionalLinks {
324
+ readonly id: StrictViewId<A>;
658
325
  readonly title: string | null;
659
326
  readonly description: string | null;
660
- readonly tags: NonEmptyArray<Tag$1<Tags>> | null;
661
- readonly links: NonEmptyArray<Link> | null;
662
- /**
663
- * URI to the source file of this view.
664
- * Undefined if the view is auto-generated.
665
- */
666
- readonly docUri?: string;
667
327
  /**
668
328
  * For all views we find common ancestor path.
669
329
  * This is used to generate relative paths, i.e.:
@@ -672,110 +332,75 @@ interface BasicView<ViewType extends "element" | "dynamic" | "deployment", ViewI
672
332
  *
673
333
  * Undefined if the view is auto-generated.
674
334
  */
675
- readonly relativePath?: string;
676
- /**
677
- * If the view is changed manually this field contains the layout data.
678
- */
679
- readonly manualLayout?: ViewManualLayout | undefined;
680
- readonly customColorDefinitions: CustomColorDefinitions;
681
- }
682
- interface BasicElementView<ViewIDs extends string, Tags extends string> extends BasicView<"element", ViewIDs, Tags> {
683
- readonly viewOf?: Fqn;
684
- readonly rules: ViewRule[];
685
- }
686
- interface ScopedElementView<ViewIDs extends string, Tags extends string> extends BasicElementView<ViewIDs, Tags> {
687
- readonly viewOf: Fqn;
688
- }
689
- interface ExtendsElementView<ViewIDs extends string, Tags extends string> extends BasicElementView<ViewIDs, Tags> {
690
- readonly extends: ViewId<ViewIDs>;
691
- }
692
- type ElementView<ViewIDs extends string = string, Tags extends string = string> = ScopedElementView<ViewIDs, Tags> | ExtendsElementView<ViewIDs, Tags> | BasicElementView<ViewIDs, Tags>;
693
- interface DynamicViewStep {
694
- readonly source: Fqn;
695
- readonly target: Fqn;
696
- readonly title: string | null;
697
- readonly description?: string;
698
- readonly technology?: string;
699
- readonly notation?: string;
700
- readonly notes?: string;
701
- readonly color?: Color;
702
- readonly line?: RelationshipLineType;
703
- readonly head?: RelationshipArrowType;
704
- readonly tail?: RelationshipArrowType;
705
- readonly isBackward?: boolean;
706
- readonly navigateTo?: ViewId;
707
- __parallel?: never;
335
+ readonly relativePath?: string | undefined;
708
336
  }
709
- interface DynamicViewParallelSteps {
710
- readonly __parallel: DynamicViewStep[];
711
- }
712
- type DynamicViewStepOrParallel = DynamicViewStep | DynamicViewParallelSteps;
713
- type DynamicViewIncludeRule = {
714
- include: ModelLayer.AnyFqnExpr[];
715
- };
716
- type DynamicViewRule = DynamicViewIncludeRule | ViewRuleGlobalPredicateRef | ViewRuleStyle | ViewRuleGlobalStyle | ViewRuleAutoLayout;
717
- interface DynamicView<ViewIDs extends string = string, Tags extends string = string> extends BasicView<"dynamic", ViewIDs, Tags> {
718
- readonly __: "dynamic";
719
- readonly steps: DynamicViewStepOrParallel[];
720
- readonly rules: DynamicViewRule[];
721
- }
722
- type CustomColorDefinitions = {
723
- [key: string]: ThemeColorValues;
724
- };
725
- type DeploymentViewRulePredicate = {
726
- include: ExpressionV2[];
727
- exclude?: never;
728
- } | {
729
- include?: never;
730
- exclude: ExpressionV2[];
337
+ type NodeNotation = {
338
+ kinds: string[];
339
+ shape: ElementShape;
340
+ color: Color;
341
+ title: string;
731
342
  };
732
- type DeploymentViewRuleStyle = {
733
- targets: FqnExpr[];
734
- notation?: string;
735
- style: ElementStyle & {
736
- color?: Color;
737
- shape?: ElementShape;
738
- icon?: IconUrl;
343
+ interface ViewWithNotation {
344
+ notation?: {
345
+ nodes: NodeNotation[];
739
346
  };
740
- };
741
- type DeploymentViewRule = DeploymentViewRulePredicate | ViewRuleAutoLayout | DeploymentViewRuleStyle;
742
- interface DeploymentView<ViewIDs extends string = string, Tags extends string = string> extends BasicView<"deployment", ViewIDs, Tags> {
743
- readonly __: "deployment";
744
- readonly rules: DeploymentViewRule[];
745
347
  }
746
- type NodeId<IDs extends string = string> = Tagged<IDs, "Fqn">;
747
- type EdgeId = Tagged<string, "EdgeId">;
748
- interface ComputedNode {
348
+ interface ViewWithHash {
349
+ /**
350
+ * Hash of the view object.
351
+ * This is used to detect changes in layout
352
+ */
353
+ hash: string;
354
+ }
355
+ interface ElementStyle {
356
+ readonly border?: BorderStyle;
357
+ /**
358
+ * In percentage 0-100, 0 is fully transparent
359
+ *
360
+ * @default 100
361
+ */
362
+ readonly opacity?: number;
363
+ /**
364
+ * If true, the element is rendered as multiple shapes
365
+ * @default false
366
+ */
367
+ readonly multiple?: boolean;
368
+ /**
369
+ * Shape size
370
+ *
371
+ * @default 'md'
372
+ */
373
+ readonly size?: ShapeSize;
374
+ readonly padding?: SpacingSize;
375
+ readonly textSize?: TextSize;
376
+ }
377
+ interface ComputedNode<A extends Any = Any> extends WithOptionalLinks {
749
378
  id: NodeId;
750
- kind: string;
379
+ kind: ElementKind<A> | DeploymentKind<A> | "@group";
751
380
  parent: NodeId | null;
752
381
  /**
753
382
  * Reference to model element
754
383
  * If 1 - node id is a reference
755
384
  */
756
- modelRef?: 1 | Fqn;
385
+ modelRef?: Fqn$1<A> | undefined;
757
386
  /**
758
387
  * Reference to deployment element
759
388
  * If 1 - node id is a reference
760
389
  */
761
- deploymentRef?: 1 | Fqn;
390
+ deploymentRef?: DeploymentFqn$1<A> | undefined;
762
391
  title: string;
763
- description: string | null;
764
- technology: string | null;
392
+ description?: string | null;
393
+ technology?: string | null;
765
394
  notation?: string;
766
- tags: NonEmptyArray<Tag$1> | null;
767
- links: NonEmptyArray<Link> | null;
768
395
  children: NodeId[];
769
396
  inEdges: EdgeId[];
770
397
  outEdges: EdgeId[];
398
+ tags: Tags<A>;
771
399
  shape: ElementShape;
772
400
  color: Color;
773
- /**
774
- * @deprecated Use `style` instead
775
- */
776
- icon?: IconUrl;
401
+ icon?: Icon;
777
402
  style: ElementStyle;
778
- navigateTo?: ViewId | null;
403
+ navigateTo?: StrictViewId<A> | null;
779
404
  level: number;
780
405
  depth?: number;
781
406
  /**
@@ -783,15 +408,7 @@ interface ComputedNode {
783
408
  */
784
409
  isCustomized?: boolean;
785
410
  }
786
- declare namespace ComputedNode {
787
- function modelRef(node: ComputedNode): Fqn | null;
788
- function deploymentRef(node: ComputedNode): Fqn | null;
789
- /**
790
- * Nodes group is a special kind of node, exisiting only in view
791
- */
792
- function isNodesGroup(node: ComputedNode): boolean;
793
- }
794
- interface ComputedEdge {
411
+ interface ComputedEdge<A extends Any = Any> extends WithOptionalTags<A> {
795
412
  id: EdgeId;
796
413
  parent: NodeId | null;
797
414
  source: NodeId;
@@ -800,15 +417,14 @@ interface ComputedEdge {
800
417
  description?: string;
801
418
  technology?: string;
802
419
  relations: RelationId[];
803
- kind?: RelationshipKind;
420
+ kind?: RelationKind<A> | typeof StepEdgeKind;
804
421
  notation?: string;
805
422
  notes?: string;
806
423
  color?: Color;
807
424
  line?: RelationshipLineType;
808
425
  head?: RelationshipArrowType;
809
426
  tail?: RelationshipArrowType;
810
- tags?: NonEmptyArray<Tag$1>;
811
- navigateTo?: ViewId;
427
+ navigateTo?: StrictViewId<A> | null;
812
428
  /**
813
429
  * If this edge is derived from custom relationship predicate
814
430
  */
@@ -819,115 +435,70 @@ interface ComputedEdge {
819
435
  */
820
436
  dir?: "forward" | "back" | "both";
821
437
  }
822
- interface ViewWithHash {
823
- /**
824
- * Hash of the view object.
825
- * This is used to detect changes in layout
826
- */
827
- hash: string;
828
- }
829
- interface ViewWithNotation {
830
- notation?: {
831
- elements: ElementNotation[];
832
- };
833
- }
834
- interface ViewAutoLayout {
835
- direction: ViewRuleAutoLayout["direction"];
836
- rankSep?: number;
837
- nodeSep?: number;
838
- }
839
- interface ComputedElementView<ViewIDs extends string = string, Tags extends string = string> extends Omit<ElementView<ViewIDs, Tags>, "rules" | "docUri">, ViewWithHash, ViewWithNotation {
840
- readonly extends?: ViewId<ViewIDs>;
841
- readonly autoLayout: ViewAutoLayout;
842
- readonly nodes: ComputedNode[];
843
- readonly edges: ComputedEdge[];
844
- rules?: never;
845
- docUri?: never;
846
- }
847
- interface ComputedDynamicView<ViewIDs extends string = string, Tags extends string = string> extends Omit<DynamicView<ViewIDs, Tags>, "rules" | "steps" | "docUri">, ViewWithHash, ViewWithNotation {
848
- readonly autoLayout: ViewAutoLayout;
849
- readonly nodes: ComputedNode[];
850
- readonly edges: ComputedEdge[];
851
- steps?: never;
852
- rules?: never;
853
- docUri?: never;
854
- }
855
- interface ComputedDeploymentView<ViewIDs extends string = string, Tags extends string = string> extends Omit<DeploymentView<ViewIDs, Tags>, "rules" | "docUri">, ViewWithHash, ViewWithNotation {
856
- readonly autoLayout: ViewAutoLayout;
857
- readonly nodes: ComputedNode[];
858
- readonly edges: ComputedEdge[];
859
- rules?: never;
860
- docUri?: never;
861
- }
862
- type ComputedView<ViewIDs extends string = string, Tags extends string = string> = ComputedElementView<ViewIDs, Tags> | ComputedDynamicView<ViewIDs, Tags> | ComputedDeploymentView<ViewIDs, Tags>;
863
- declare namespace ComputedView {
864
- function isDeployment(view: ComputedView): view is ComputedDeploymentView;
865
- function isDynamic(view: ComputedView): view is ComputedDynamicView;
866
- function isElement(view: ComputedView): view is ComputedElementView;
867
- }
868
- type BBox = {
438
+ interface DiagramNode<A extends Any = Any> extends ComputedNode<A>, BBox {
869
439
  x: number;
870
440
  y: number;
871
441
  width: number;
872
442
  height: number;
873
- };
874
- interface DiagramNode extends ComputedNode {
875
- width: number;
876
- height: number;
443
+ /**
444
+ * Absolute position, top left
445
+ * @deprecated Use `x` and `y` instead
446
+ */
877
447
  position: Point;
448
+ /**
449
+ * Bounding box of label
450
+ * (Absolute coordinates)
451
+ */
878
452
  labelBBox: BBox;
879
453
  }
880
- declare namespace DiagramNode {
881
- function modelRef(node: Pick<DiagramNode, "id" | "modelRef">): Fqn | null;
882
- function deploymentRef(node: Pick<DiagramNode, "id" | "deploymentRef">): Fqn | null;
454
+ interface DiagramEdge<A extends Any = Any> extends ComputedEdge<A> {
883
455
  /**
884
- * Nodes group is a special kind of node, exisiting only in view
456
+ * Bezier points
457
+ * (Absolute coordinates)
885
458
  */
886
- function isNodesGroup(node: Pick<DiagramNode, "kind">): boolean;
887
- }
888
- interface DiagramEdge extends ComputedEdge {
889
459
  points: NonEmptyArray<Point>;
460
+ /**
461
+ * Control points to adjust the edge
462
+ * (Absolute coordinates)
463
+ */
890
464
  controlPoints?: NonEmptyArray<XYPoint>;
465
+ /**
466
+ * Bounding box of label
467
+ * (Absolute coordinates)
468
+ */
891
469
  labelBBox?: BBox | null;
470
+ /**
471
+ * Graphviz edge POS
472
+ *
473
+ * TODO: temporary solution, should be moved out
474
+ * @deprecated
475
+ */
892
476
  dotpos?: string;
893
477
  }
894
- interface DiagramView<ViewIDs extends string = string, Tags extends string = string> extends Omit<ComputedView<ViewIDs, Tags>, "nodes" | "edges" | "manualLayout"> {
895
- readonly nodes: DiagramNode[];
896
- readonly edges: DiagramEdge[];
478
+ interface BaseLayoutedViewProperties<A extends Any> extends BaseViewProperties<A>, ViewWithHash, ViewWithNotation {
479
+ readonly [_stage]: "layouted";
480
+ readonly autoLayout: ViewAutoLayout;
481
+ readonly nodes: DiagramNode<A>[];
482
+ readonly edges: DiagramEdge<A>[];
897
483
  readonly bounds: BBox;
898
484
  /**
899
485
  * If diagram has manual layout
900
486
  * But was changed and layout should be recalculated
901
487
  */
902
488
  hasLayoutDrift?: boolean;
903
- manualLayout?: never;
904
489
  }
905
- type ViewManualLayout = {
906
- readonly hash: string;
907
- readonly x: number;
908
- readonly y: number;
909
- readonly width: number;
910
- readonly height: number;
911
- readonly autoLayout: ViewAutoLayout;
912
- readonly nodes: Record<string, {
913
- isCompound: boolean;
914
- x: number;
915
- y: number;
916
- width: number;
917
- height: number;
918
- }>;
919
- readonly edges: Record<string, {
920
- dotpos?: string;
921
- points: NonEmptyArray<Point>;
922
- controlPoints?: NonEmptyArray<XYPoint>;
923
- labelBBox?: BBox;
924
- }>;
925
- };
926
- type RelationId = Tagged<string, "RelationID">;
927
- type RelationshipKind<Kinds extends string = string> = Tagged<Kinds, "RelationshipKind">;
928
- type RelationshipLineType = "dashed" | "solid" | "dotted";
929
- type RelationshipArrowType = "none" | "normal" | "onormal" | "dot" | "odot" | "diamond" | "odiamond" | "crow" | "open" | "vee";
930
- type PredicateSelector = "children" | "expanded" | "descendants";
490
+ interface LayoutedElementView<A extends Any = Any> extends BaseLayoutedViewProperties<A> {
491
+ readonly [_type]: "element";
492
+ readonly viewOf?: Fqn$1<A>;
493
+ readonly extends?: StrictViewId<A>;
494
+ }
495
+ interface LayoutedDeploymentView<A extends Any = Any> extends BaseLayoutedViewProperties<A> {
496
+ readonly [_type]: "deployment";
497
+ }
498
+ interface LayoutedDynamicView<A extends Any = Any> extends BaseLayoutedViewProperties<A> {
499
+ readonly [_type]: "dynamic";
500
+ }
501
+ type LayoutedView<A extends Any = Any> = LayoutedElementView<A> | LayoutedDeploymentView<A> | LayoutedDynamicView<A>;
931
502
  declare namespace ViewChange {
932
503
  interface ChangeElementStyle {
933
504
  op: "change-element-style";
@@ -937,7 +508,7 @@ declare namespace ViewChange {
937
508
  shape?: ElementShape;
938
509
  color?: ThemeColor;
939
510
  };
940
- targets: NonEmptyArray<Fqn>;
511
+ targets: NonEmptyArray<Fqn | DeploymentFqn>;
941
512
  }
942
513
  interface SaveManualLayout {
943
514
  op: "save-manual-layout";
@@ -958,7 +529,7 @@ type NodeDimensionChange = {
958
529
  type: "dimensions";
959
530
  dimensions?: Dimensions;
960
531
  resizing?: boolean;
961
- setAttributes?: boolean;
532
+ setAttributes?: boolean | "width" | "height";
962
533
  };
963
534
  type NodePositionChange = {
964
535
  id: string;
@@ -1182,6 +753,7 @@ type OnConnectStartParams = {
1182
753
  type OnConnectStart = (event: MouseEvent | TouchEvent, params: OnConnectStartParams) => void;
1183
754
  type OnConnect = (connection: Connection) => void;
1184
755
  type OnConnectEnd = (event: MouseEvent | TouchEvent, connectionState: FinalConnectionState) => void;
756
+ type OnReconnect<EdgeType extends EdgeBase = EdgeBase> = (oldEdge: EdgeType, newConnection: Connection) => void;
1185
757
  type PaddingUnit = "px" | "%";
1186
758
  type PaddingWithUnit = `${number}${PaddingUnit}` | number;
1187
759
  type Padding = PaddingWithUnit | {
@@ -1511,7 +1083,6 @@ type EdgeProps<EdgeType extends Edge = Edge> = Pick<EdgeType, "id" | "animated"
1511
1083
  pathOptions?: any;
1512
1084
  interactionWidth?: number;
1513
1085
  };
1514
- type OnReconnect<EdgeType extends Edge = Edge> = (oldEdge: EdgeType, newConnection: Connection) => void;
1515
1086
  type ConnectionLineComponentProps<NodeType extends Node$1 = Node$1> = {
1516
1087
  connectionLineStyle?: CSSProperties;
1517
1088
  connectionLineType: ConnectionLineType;
@@ -1568,22 +1139,11 @@ interface ReactFlowProps<NodeType extends Node$1 = Node$1, EdgeType extends Edge
1568
1139
  defaultEdges?: EdgeType[];
1569
1140
  /**
1570
1141
  * Defaults to be applied to all new edges that are added to the flow.
1571
- *
1572
1142
  * Properties on a new edge will override these defaults if they exist.
1573
1143
  * @example
1574
1144
  * const defaultEdgeOptions = {
1575
1145
  * type: 'customEdgeType',
1576
- * animated: true,
1577
- * interactionWidth: 10,
1578
- * data: { label: 'custom label' },
1579
- * hidden: false,
1580
- * deletable: true,
1581
- * selected: false,
1582
- * focusable: true,
1583
- * markerStart: EdgeMarker.ArrowClosed,
1584
- * markerEnd: EdgeMarker.ArrowClosed,
1585
- * zIndex: 12,
1586
- * ariaLabel: 'custom aria label'
1146
+ * animated: true
1587
1147
  * }
1588
1148
  */
1589
1149
  defaultEdgeOptions?: DefaultEdgeOptions;
@@ -1620,7 +1180,6 @@ interface ReactFlowProps<NodeType extends Node$1 = Node$1, EdgeType extends Edge
1620
1180
  /**
1621
1181
  * This handler is called when the source or target of a reconnectable edge is dragged from the
1622
1182
  * current node. It will fire even if the edge's source or target do not end up changing.
1623
- *
1624
1183
  * You can use the `reconnectEdge` utility to convert the connection to a new edge.
1625
1184
  */
1626
1185
  onReconnect?: OnReconnect<EdgeType>;
@@ -1631,7 +1190,6 @@ interface ReactFlowProps<NodeType extends Node$1 = Node$1, EdgeType extends Edge
1631
1190
  /**
1632
1191
  * This event fires when the user releases the source or target of an editable edge. It is called
1633
1192
  * even if an edge update does not occur.
1634
- *
1635
1193
  */
1636
1194
  onReconnectEnd?: (event: MouseEvent | TouchEvent, edge: EdgeType, handleType: HandleType) => void;
1637
1195
  /**
@@ -1692,7 +1250,6 @@ interface ReactFlowProps<NodeType extends Node$1 = Node$1, EdgeType extends Edge
1692
1250
  onSelectionContextMenu?: (event: ReactMouseEvent, nodes: NodeType[]) => void;
1693
1251
  /**
1694
1252
  * When a connection line is completed and two nodes are connected by the user, this event fires with the new connection.
1695
- *
1696
1253
  * You can use the `addEdge` utility to convert the connection to a complete edge.
1697
1254
  * @example // Use helper function to update edges onConnect
1698
1255
  * import ReactFlow, { addEdge } from '@xyflow/react';
@@ -1760,9 +1317,7 @@ interface ReactFlowProps<NodeType extends Node$1 = Node$1, EdgeType extends Edge
1760
1317
  onBeforeDelete?: OnBeforeDelete<NodeType, EdgeType>;
1761
1318
  /**
1762
1319
  * Custom node types to be available in a flow.
1763
- *
1764
1320
  * React Flow matches a node's type to a component in the `nodeTypes` object.
1765
- * @TODO check if @default is correct
1766
1321
  * @default {
1767
1322
  * input: InputNode,
1768
1323
  * default: DefaultNode,
@@ -1777,9 +1332,7 @@ interface ReactFlowProps<NodeType extends Node$1 = Node$1, EdgeType extends Edge
1777
1332
  nodeTypes?: NodeTypes;
1778
1333
  /**
1779
1334
  * Custom edge types to be available in a flow.
1780
- *
1781
1335
  * React Flow matches an edge's type to a component in the `edgeTypes` object.
1782
- * @TODO check if @default is correct
1783
1336
  * @default {
1784
1337
  * default: BezierEdge,
1785
1338
  * straight: StraightEdge,
@@ -1795,7 +1348,6 @@ interface ReactFlowProps<NodeType extends Node$1 = Node$1, EdgeType extends Edge
1795
1348
  edgeTypes?: EdgeTypes;
1796
1349
  /**
1797
1350
  * The type of edge path to use for connection lines.
1798
- *
1799
1351
  * Although created edges can be of any type, React Flow needs to know what type of path to render for the connection line before the edge is created!
1800
1352
  * @default ConnectionLineType.Bezier
1801
1353
  */
@@ -1816,7 +1368,7 @@ interface ReactFlowProps<NodeType extends Node$1 = Node$1, EdgeType extends Edge
1816
1368
  /**
1817
1369
  * If set, pressing the key or chord will delete any selected nodes and edges. Passing an array
1818
1370
  * represents multiple keys that can be pressed.
1819
- *
1371
+
1820
1372
  * For example, `["Delete", "Backspace"]` will delete selected elements when either key is pressed.
1821
1373
  * @default 'Backspace'
1822
1374
  */
@@ -1933,7 +1485,6 @@ interface ReactFlowProps<NodeType extends Node$1 = Node$1, EdgeType extends Edge
1933
1485
  selectNodesOnDrag?: boolean;
1934
1486
  /**
1935
1487
  * Enabling this prop allows users to pan the viewport by clicking and dragging.
1936
- *
1937
1488
  * You can also set this prop to an array of numbers to limit which mouse buttons can activate panning.
1938
1489
  * @default true
1939
1490
  * @example [0, 2] // allows panning with the left and right mouse buttons
@@ -1972,7 +1523,6 @@ interface ReactFlowProps<NodeType extends Node$1 = Node$1, EdgeType extends Edge
1972
1523
  onViewportChange?: (viewport: Viewport) => void;
1973
1524
  /**
1974
1525
  * By default, the viewport extends infinitely. You can use this prop to set a boundary.
1975
- *
1976
1526
  * The first pair of coordinates is the top left boundary and the second pair is the bottom right.
1977
1527
  * @default [[-∞, -∞], [+∞, +∞]]
1978
1528
  * @example [[-1000, -10000], [1000, 1000]]
@@ -1985,7 +1535,6 @@ interface ReactFlowProps<NodeType extends Node$1 = Node$1, EdgeType extends Edge
1985
1535
  preventScrolling?: boolean;
1986
1536
  /**
1987
1537
  * By default, nodes can be placed on an infinite flow. You can use this prop to set a boundary.
1988
- *
1989
1538
  * The first pair of coordinates is the top left boundary and the second pair is the bottom right.
1990
1539
  * @example [[-1000, -10000], [1000, 1000]]
1991
1540
  */
@@ -2007,21 +1556,18 @@ interface ReactFlowProps<NodeType extends Node$1 = Node$1, EdgeType extends Edge
2007
1556
  zoomOnPinch?: boolean;
2008
1557
  /**
2009
1558
  * Controls if the viewport should pan by scrolling inside the container.
2010
- *
2011
1559
  * Can be limited to a specific direction with `panOnScrollMode`.
2012
1560
  * @default false
2013
1561
  */
2014
1562
  panOnScroll?: boolean;
2015
1563
  /**
2016
1564
  * Controls how fast viewport should be panned on scroll.
2017
- *
2018
1565
  * Use together with `panOnScroll` prop.
2019
1566
  * @default 0.5
2020
1567
  */
2021
1568
  panOnScrollSpeed?: number;
2022
1569
  /**
2023
1570
  * This prop is used to limit the direction of panning when `panOnScroll` is enabled.
2024
- *
2025
1571
  * The `"free"` option allows panning in any direction.
2026
1572
  * @default "free"
2027
1573
  * @example "horizontal" | "vertical"
@@ -2154,10 +1700,8 @@ interface ReactFlowProps<NodeType extends Node$1 = Node$1, EdgeType extends Edge
2154
1700
  isValidConnection?: IsValidConnection<EdgeType>;
2155
1701
  /**
2156
1702
  * With a threshold greater than zero you can delay node drag events.
2157
- *
2158
1703
  * If threshold equals 1, you need to drag the node 1 pixel before a drag event is fired.
2159
- *
2160
- * 1 is the default value, so clicks don't trigger drag events.
1704
+ * 1 is the default value, so that clicks don't trigger drag events.
2161
1705
  * @default 1
2162
1706
  */
2163
1707
  nodeDragThreshold?: number;
@@ -2403,20 +1947,158 @@ type ControlsCustomLayoutProps = {
2403
1947
  syncInProgressBadge: ReactNode;
2404
1948
  };
2405
1949
  type ControlsCustomLayout = (props: ControlsCustomLayoutProps) => ReactNode;
2406
- type DiagramNodeWithNavigate<ID = ViewId> = Omit<DiagramNode, "navigateTo"> & {
2407
- navigateTo: ID;
1950
+ type Dimmed = "immediate" | boolean;
1951
+ type NodeData = {
1952
+ /**
1953
+ * Whether the cursor is hovering over the node
1954
+ */
1955
+ hovered?: boolean;
1956
+ /**
1957
+ * Whether the node is dimmed
1958
+ * 'immediate' means that the node is dimmed without delay
1959
+ */
1960
+ dimmed?: Dimmed;
1961
+ };
1962
+ type Node$1 = Node$1<NodeData>;
1963
+ type NodeProps$2 = NodeProps$1<Node$1<NodeData, any>>;
1964
+ type EdgeData = {
1965
+ /**
1966
+ * Whether the cursor is hovering over the edge
1967
+ */
1968
+ hovered?: boolean;
1969
+ /**
1970
+ * Whether the edge is active (animated and highlighted)
1971
+ */
1972
+ active?: boolean;
1973
+ /**
1974
+ * Whether the edge is dimmed
1975
+ * 'immediate' means that the edge is dimmed without delay
1976
+ */
1977
+ dimmed?: Dimmed;
1978
+ };
1979
+ type Edge$1 = Simplify<Omit<Edge, "data"> & {
1980
+ data: EdgeData;
1981
+ }>;
1982
+ type WithDimmed = {
1983
+ data: {
1984
+ dimmed?: Dimmed;
1985
+ };
2408
1986
  };
1987
+ type WithHovered = {
1988
+ data: {
1989
+ hovered?: boolean;
1990
+ };
1991
+ };
1992
+ declare function setDimmed<T extends WithDimmed>(value: T, dimmed: "immediate" | boolean): T;
1993
+ declare function setDimmed(dimmed: "immediate" | boolean): <T extends WithDimmed>(value: T) => T;
1994
+ declare function setHovered<T extends WithHovered>(value: T, hovered: boolean): T;
1995
+ declare function setHovered(hovered: boolean): <T extends WithHovered>(value: T) => T;
1996
+ type WithData<D> = {
1997
+ data: D;
1998
+ };
1999
+ declare function setData<E extends WithData<any>>(value: E, state: Partial<E["data"]>): E;
2000
+ declare function setData<E extends WithData<any>>(state: Partial<E["data"]>): (value: E) => E;
2001
+ type NodeProps$3<T extends Record<string, unknown> = {}, NodeType extends string = string> = NodeProps$1<Node$1<Base.NodeData & T, NodeType>>;
2002
+ type ReactFlowNode<Data extends Record<string, unknown>, NodeType extends string> = SetRequired<Node$1<Data, NodeType>, "type" | "initialWidth" | "initialHeight">;
2003
+ type ReactFlowEdge<Data extends Record<string, unknown>, EdgeType extends string> = SetRequired<Edge<Data, EdgeType>, "type" | "data">;
2004
+ type NonOptional<T extends object> = Simplify<{
2005
+ [P in Exclude<keyof T, OptionalKeysOf<T>>]: T[P];
2006
+ } & {
2007
+ [P in OptionalKeysOf<T>]-?: T[P] | undefined;
2008
+ }>;
2009
+ declare namespace Types {
2010
+ type LeafNodeData = Base.NodeData & NonOptional<Pick<DiagramNode, "id" | "title" | "technology" | "description" | "color" | "shape" | "width" | "level" | "height" | "style" | "tags" | "position">> & {
2011
+ /**
2012
+ * View this node belongs to
2013
+ */
2014
+ viewId: ViewId;
2015
+ isMultiple?: boolean | undefined;
2016
+ icon: string | null;
2017
+ };
2018
+ /**
2019
+ * Represents element from logical model
2020
+ */
2021
+ type ElementNodeData = LeafNodeData & {
2022
+ modelFqn: Fqn;
2023
+ deploymentFqn?: never;
2024
+ /**
2025
+ * If set - this node has navigation to another view and diagram has handler for this
2026
+ */
2027
+ navigateTo: ViewId | null;
2028
+ };
2029
+ /**
2030
+ * Represents element from deployment model
2031
+ */
2032
+ type DeploymentElementNodeData = LeafNodeData & {
2033
+ navigateTo: ViewId | null;
2034
+ deploymentFqn: DeploymentFqn;
2035
+ modelFqn: Fqn | null;
2036
+ };
2037
+ type CompoundNodeData = Base.NodeData & NonOptional<Pick<DiagramNode, "id" | "title" | "color" | "shape" | "style" | "tags" | "position">> & {
2038
+ /**
2039
+ * View this node belongs to
2040
+ */
2041
+ viewId: ViewId;
2042
+ depth: number;
2043
+ icon?: IconUrl;
2044
+ };
2045
+ type CompoundElementNodeData = CompoundNodeData & {
2046
+ modelFqn: Fqn;
2047
+ deploymentFqn?: never;
2048
+ /**
2049
+ * If set - this node has navigation to another view and diagram has handler for this
2050
+ */
2051
+ navigateTo: ViewId | null;
2052
+ };
2053
+ type CompoundDeploymentNodeData = CompoundNodeData & {
2054
+ deploymentFqn: DeploymentFqn;
2055
+ /**
2056
+ * If set - this node refers to a model element
2057
+ */
2058
+ modelFqn: Fqn | null;
2059
+ /**
2060
+ * If set - this node has navigation to another view and diagram has handler for this
2061
+ */
2062
+ navigateTo: ViewId | null;
2063
+ };
2064
+ type ViewGroupNodeData = CompoundNodeData & {
2065
+ isViewGroup: true;
2066
+ };
2067
+ type ElementNode = ReactFlowNode<ElementNodeData, "element">;
2068
+ type DeploymentElementNode = ReactFlowNode<DeploymentElementNodeData, "deployment">;
2069
+ type CompoundElementNode = ReactFlowNode<CompoundElementNodeData, "compound-element">;
2070
+ type CompoundDeploymentNode = ReactFlowNode<CompoundDeploymentNodeData, "compound-deployment">;
2071
+ type ViewGroupNode = ReactFlowNode<ViewGroupNodeData, "view-group">;
2072
+ type Node = ElementNode | DeploymentElementNode | CompoundElementNode | CompoundDeploymentNode | ViewGroupNode;
2073
+ type NodeData = Node["data"];
2074
+ type RelationshipEdgeData = Simplify<Base.EdgeData & NonOptional<Pick<DiagramEdge, "id" | "label" | "labelBBox" | "technology" | "points" | "dir" | "color" | "line" | "head" | "tail" | "navigateTo" | "notes">> & {
2075
+ labelXY: XYPosition | null;
2076
+ controlPoints: XYPosition[] | undefined | null;
2077
+ }>;
2078
+ type RelationshipEdge = ReactFlowEdge<RelationshipEdgeData, "relationship">;
2079
+ type Edge = RelationshipEdge;
2080
+ type EdgeData = RelationshipEdgeData;
2081
+ }
2082
+ interface CustomNodes {
2083
+ element?: undefined | ((props: NodeProps$3<Types.ElementNodeData, "element">) => ReactNode);
2084
+ deployment?: undefined | ((props: NodeProps$3<Types.DeploymentElementNodeData, "deployment">) => ReactNode);
2085
+ compoundElement?: undefined | ((props: NodeProps$3<Types.CompoundElementNodeData, "compound-element">) => ReactNode);
2086
+ compoundDeployment?: undefined | ((props: NodeProps$3<Types.CompoundDeploymentNodeData, "compound-deployment">) => ReactNode);
2087
+ viewGroup?: undefined | ((props: NodeProps$3<Types.ViewGroupNodeData, "view-group">) => ReactNode);
2088
+ }
2089
+ type DiagramNodeWithNavigate<A extends Any> = SetRequired<DiagramNode<A>, "navigateTo">;
2409
2090
  type ElementIconRendererProps = {
2410
2091
  node: {
2411
2092
  id: string;
2412
2093
  title: string;
2413
2094
  icon?: string | null | undefined;
2414
2095
  };
2096
+ className?: string;
2415
2097
  };
2416
- type ElementIconRenderer = (props: ElementIconRendererProps) => ReactNode;
2417
- type OnNavigateTo<ID = ViewId> = (to: ID, event?: ReactMouseEvent, element?: DiagramNodeWithNavigate<ID>) => void;
2418
- type OnNodeClick = (node: DiagramNode, event: ReactMouseEvent) => void;
2419
- type OnEdgeClick = (edge: DiagramEdge, event: ReactMouseEvent) => void;
2098
+ export type ElementIconRenderer = (props: ElementIconRendererProps) => ReactNode;
2099
+ type OnNavigateTo<A extends Any> = (to: ViewId$1<A>, event?: ReactMouseEvent, element?: DiagramNodeWithNavigate<A>) => void;
2100
+ type OnNodeClick<A extends Any> = (node: DiagramNode<A>, event: ReactMouseEvent) => void;
2101
+ type OnEdgeClick<A extends Any> = (edge: DiagramEdge<A>, event: ReactMouseEvent) => void;
2420
2102
  type OnCanvasClick = (event: ReactMouseEvent) => void;
2421
2103
  type ChangeEvent = {
2422
2104
  change: ViewChange;
@@ -2425,8 +2107,8 @@ type OnChange = (event: ChangeEvent) => void;
2425
2107
  type OverrideReactFlowProps = Pick<ReactFlowProps, "paneClickDistance" | "nodeClickDistance" | "selectionKeyCode" | "panActivationKeyCode" | "multiSelectionKeyCode" | "zoomActivationKeyCode" | "snapToGrid" | "snapGrid" | "onlyRenderVisibleElements" | "nodesDraggable" | "nodesFocusable" | "elementsSelectable" | "selectNodesOnDrag" | "panOnDrag" | "preventScrolling" | "zoomOnScroll" | "zoomOnPinch" | "panOnScroll" | "panOnScrollSpeed" | "panOnScrollMode" | "zoomOnDoubleClick" | "nodeDragThreshold">;
2426
2108
  type PaddingUnit$1 = "px" | "%";
2427
2109
  type PaddingWithUnit$1 = `${number}${PaddingUnit$1}` | number;
2428
- interface LikeC4DiagramProperties {
2429
- view: DiagramView;
2110
+ interface LikeC4DiagramProperties<A extends Any> {
2111
+ view: LayoutedView<A>;
2430
2112
  className?: string | undefined;
2431
2113
  /**
2432
2114
  * Enable/disable panning
@@ -2520,6 +2202,11 @@ interface LikeC4DiagramProperties {
2520
2202
  * @default false
2521
2203
  */
2522
2204
  enableDynamicViewWalkthrough?: boolean | undefined;
2205
+ /**
2206
+ * Display element tags in the bottom left corner
2207
+ * @default true
2208
+ */
2209
+ enableElementTags?: boolean | undefined;
2523
2210
  /**
2524
2211
  * Experimental feature to enable edge editing
2525
2212
  * @default false
@@ -2540,44 +2227,48 @@ interface LikeC4DiagramProperties {
2540
2227
  * Customize layout of the controls on the top left
2541
2228
  */
2542
2229
  renderControls?: ControlsCustomLayout | undefined;
2230
+ /**
2231
+ * Override node renderers
2232
+ */
2233
+ renderNodes?: CustomNodes | undefined;
2543
2234
  /**
2544
2235
  * Dynamic filter, applies both to nodes and edges
2545
2236
  */
2546
- where?: WhereOperator<string, string> | undefined;
2237
+ where?: WhereOperator<A> | undefined;
2547
2238
  /**
2548
2239
  * Override ReactFlow props
2549
2240
  */
2550
2241
  reactFlowProps?: OverrideReactFlowProps | undefined;
2551
2242
  }
2552
- type OpenSourceParams = {
2553
- element: Fqn;
2243
+ type OpenSourceParams<A extends Any = Any> = {
2244
+ element: Fqn$1<A>;
2554
2245
  property?: string;
2555
2246
  } | {
2556
- relation: RelationId;
2247
+ relation: RelationId$1;
2557
2248
  } | {
2558
- deployment: Fqn;
2249
+ deployment: DeploymentFqn$1<A>;
2559
2250
  property?: string;
2560
2251
  } | {
2561
- view: ViewId;
2252
+ view: StrictViewId<A>;
2562
2253
  };
2563
- interface LikeC4DiagramEventHandlers {
2254
+ interface LikeC4DiagramEventHandlers<A extends Any> {
2564
2255
  onChange?: OnChange | null | undefined;
2565
- onNavigateTo?: OnNavigateTo | null | undefined;
2566
- onNodeClick?: OnNodeClick | null | undefined;
2567
- onNodeContextMenu?: OnNodeClick | null | undefined;
2256
+ onNavigateTo?: OnNavigateTo<A> | null | undefined;
2257
+ onNodeClick?: OnNodeClick<A> | null | undefined;
2258
+ onNodeContextMenu?: OnNodeClick<A> | null | undefined;
2568
2259
  onCanvasContextMenu?: OnCanvasClick | null | undefined;
2569
- onEdgeClick?: OnEdgeClick | null | undefined;
2570
- onEdgeContextMenu?: OnEdgeClick | null | undefined;
2260
+ onEdgeClick?: OnEdgeClick<A> | null | undefined;
2261
+ onEdgeContextMenu?: OnEdgeClick<A> | null | undefined;
2571
2262
  onCanvasClick?: OnCanvasClick | null | undefined;
2572
2263
  onCanvasDblClick?: OnCanvasClick | null | undefined;
2573
2264
  onBurgerMenuClick?: null | undefined | (() => void);
2574
- onOpenSource?: null | undefined | ((params: OpenSourceParams) => void);
2265
+ onOpenSource?: null | undefined | ((params: OpenSourceParams<A>) => void);
2575
2266
  }
2576
- export interface LikeC4ViewProps<ViewId = string, Tag = string, Kind = string> {
2267
+ export interface LikeC4ViewProps<A extends Any> {
2577
2268
  /**
2578
2269
  * View to display.
2579
2270
  */
2580
- viewId: ViewId;
2271
+ viewId: ViewId$1<A>;
2581
2272
  /**
2582
2273
  * Enable/disable panning
2583
2274
  * @default false
@@ -2664,6 +2355,11 @@ export interface LikeC4ViewProps<ViewId = string, Tag = string, Kind = string> {
2664
2355
  * @default false
2665
2356
  */
2666
2357
  enableElementDetails?: boolean | undefined;
2358
+ /**
2359
+ * Display element tags in the bottom left corner
2360
+ * @default false
2361
+ */
2362
+ enableElementTags?: boolean | undefined;
2667
2363
  /**
2668
2364
  * Experimental feature to browse relationships
2669
2365
  *
@@ -2681,7 +2377,7 @@ export interface LikeC4ViewProps<ViewId = string, Tag = string, Kind = string> {
2681
2377
  * @default 'auto' - will be set to true if view is pannable and has more than 3000 * 2000 pixels
2682
2378
  */
2683
2379
  reduceGraphics?: "auto" | boolean | undefined;
2684
- where?: WhereOperator<Tag, Kind> | undefined;
2380
+ where?: WhereOperator<A> | undefined;
2685
2381
  /**
2686
2382
  * Override some react flow props
2687
2383
  */
@@ -2694,6 +2390,10 @@ export interface LikeC4ViewProps<ViewId = string, Tag = string, Kind = string> {
2694
2390
  mantineTheme?: any;
2695
2391
  /** Function to generate nonce attribute added to all generated `<style />` tags */
2696
2392
  styleNonce?: string | (() => string) | undefined;
2393
+ /**
2394
+ * Override node renderers
2395
+ */
2396
+ renderNodes?: CustomNodes | undefined;
2697
2397
  /**
2698
2398
  * Render custom icon for a node
2699
2399
  * By default, if icon is http:// or https://, it will be rendered as an image
@@ -2759,6 +2459,11 @@ interface LikeC4BrowserProps {
2759
2459
  * @default enableRelationshipBrowser
2760
2460
  */
2761
2461
  enableRelationshipDetails?: boolean | undefined;
2462
+ /**
2463
+ * Display element tags in the bottom left corner
2464
+ * @default true
2465
+ */
2466
+ enableElementTags?: boolean | undefined;
2762
2467
  /**
2763
2468
  * Display notations of the view
2764
2469
  * @default true
@@ -2777,10 +2482,10 @@ interface LikeC4BrowserProps {
2777
2482
  */
2778
2483
  reactFlowProps?: OverrideReactFlowProps | undefined;
2779
2484
  }
2780
- export declare function LikeC4View<ViewId extends string = string, Tag = string, Kind = string>({ viewId, ...props }: LikeC4ViewProps<ViewId, Tag, Kind>): import("react/jsx-runtime").JSX.Element;
2781
- type LikeC4DiagramProps = PropsWithChildren<LikeC4DiagramProperties & LikeC4DiagramEventHandlers>;
2782
- export type ReactLikeC4Props<ViewId = string, Tag = string, Kind = string> = Omit<LikeC4DiagramProps, "view" | "where" | "onNavigateTo"> & {
2783
- viewId: ViewId;
2485
+ export declare function LikeC4View<A extends Any = UnknownLayouted>({ viewId, ...props }: LikeC4ViewProps<A>): import("react/jsx-runtime").JSX.Element;
2486
+ type LikeC4DiagramProps<A extends Any = Any> = PropsWithChildren<LikeC4DiagramProperties<A> & LikeC4DiagramEventHandlers<A>>;
2487
+ export type ReactLikeC4Props<A extends Any> = Omit<LikeC4DiagramProps<A>, "view"> & {
2488
+ viewId: ViewId$1<A>;
2784
2489
  /**
2785
2490
  * Keep aspect ratio of the diagram
2786
2491
  * Disable if you need to manage the viewport (use className)
@@ -2801,13 +2506,11 @@ export type ReactLikeC4Props<ViewId = string, Tag = string, Kind = string> = Omi
2801
2506
  */
2802
2507
  injectFontCss?: boolean | undefined;
2803
2508
  style?: CSSProperties | undefined;
2804
- where?: WhereOperator<Tag, Kind> | undefined;
2805
- onNavigateTo?: OnNavigateTo<ViewId> | undefined;
2806
2509
  mantineTheme?: any;
2807
2510
  /** Function to generate nonce attribute added to all generated `<style />` tags */
2808
2511
  styleNonce?: string | (() => string) | undefined;
2809
2512
  };
2810
- export declare function ReactLikeC4<ViewId extends string = string, Tag = string, Kind = string>({ viewId, ...props }: ReactLikeC4Props<ViewId, Tag, Kind>): import("react/jsx-runtime").JSX.Element;
2513
+ export declare function ReactLikeC4<A extends Any = UnknownLayouted>({ viewId, ...props }: ReactLikeC4Props<A>): import("react/jsx-runtime").JSX.Element;
2811
2514
  export declare namespace ReactLikeC4 {
2812
2515
  var displayName: string;
2813
2516
  }
@@ -2819,9 +2522,12 @@ type LikeC4ModelProviderProps = PropsWithChildren<{
2819
2522
  likec4model: any;
2820
2523
  }>;
2821
2524
  export declare const LikeC4ModelProvider: (props: LikeC4ModelProviderProps) => JSX.Element;
2525
+ export declare const ViewNotFound: ({ viewId }: {
2526
+ viewId: string;
2527
+ }) => import("react/jsx-runtime").JSX.Element;
2822
2528
  type AllKeys<T> = T extends any ? keyof T : never;
2823
- type Primitive$1 = boolean | number | string;
2824
- type ReadonlyIfObject<Value> = Value extends undefined ? Value : Value extends (...args: any) => any ? Value : Value extends Primitive$1 ? Value : Value extends object ? Readonly<Value> : Value;
2529
+ type Primitive = boolean | number | string;
2530
+ type ReadonlyIfObject<Value> = Value extends undefined ? Value : Value extends (...args: any) => any ? Value : Value extends Primitive ? Value : Value extends object ? Readonly<Value> : Value;
2825
2531
  interface ReadableAtom<Value = any> {
2826
2532
  /**
2827
2533
  * Get store value.
@@ -3036,6 +2742,27 @@ interface Computed {
3036
2742
  ], cb: (...values: StoreValues<OriginStores>) => Task<Value> | Value): ReadableAtom<Value>;
3037
2743
  }
3038
2744
  declare const computed: Computed;
2745
+ interface Batched {
2746
+ <Value, OriginStore extends Store>(stores: OriginStore, cb: (value: StoreValue<OriginStore>) => Task<Value> | Value): ReadableAtom<Value>;
2747
+ /**
2748
+ * Create derived store, which use generates value from another stores.
2749
+ *
2750
+ * ```js
2751
+ * import { batched } from 'nanostores'
2752
+ *
2753
+ * const $sortBy = atom('id')
2754
+ * const $category = atom('')
2755
+ *
2756
+ * export const $link = batched([$sortBy, $category], (sortBy, category) => {
2757
+ * return `/api/entities?sortBy=${sortBy}&category=${category}`
2758
+ * })
2759
+ * ```
2760
+ */
2761
+ <Value, OriginStores extends AnyStore[]>(stores: [
2762
+ ...OriginStores
2763
+ ], cb: (...values: StoreValues<OriginStores>) => Task<Value> | Value): ReadableAtom<Value>;
2764
+ }
2765
+ declare const batched: Batched;
3039
2766
  type StoreKeys<T> = T extends {
3040
2767
  setKey: (k: infer K, v: any) => unknown;
3041
2768
  } ? K : never;
@@ -3055,8 +2782,11 @@ interface UseStoreOptions<SomeStore> {
3055
2782
  declare function useStore<SomeStore extends Store>(store: SomeStore, options?: UseStoreOptions<SomeStore>): StoreValue<SomeStore>;
3056
2783
  export declare const createHooksForModel: ($atom: WritableAtom) => any;
3057
2784
 
2785
+ declare namespace Base {
2786
+ export { Dimmed, Edge$1 as Edge, EdgeData, Node$1 as Node, NodeData, NodeProps$2 as NodeProps, setData, setDimmed, setHovered };
2787
+ }
3058
2788
  declare namespace nano {
3059
- export { Atom, WritableAtom, atom, computed, map, useStore };
2789
+ export { Atom, ReadableAtom, WritableAtom, atom, batched, computed, map, useStore };
3060
2790
  }
3061
2791
 
3062
2792
  export {