@likec4/core 1.9.0 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,814 @@
1
+ import { H as HexColorLiteral, T as ThemeColorValues, L as LiteralUnion, F as Fqn$1, R as RelationID$1, V as ViewID$1, E as EdgeId$1, C as ComputedView, a as Tag, b as ComputedNode, N as NodeId, c as ElementKind, d as ElementShape, e as Color, f as ComputedEdge, g as ComputedLikeC4Model, h as Element, i as Relation, j as RelationshipKind, k as NonEmptyArray } from './shared/core.Czd51Dd8.js';
2
+ export { aq as AndOperator, A as AsFqn, aP as AutoLayoutDirection, bl as BBox, aU as BasicElementView, aT as BasicView, o as BorderStyle, B as BorderStyles, aE as ColorLiteral, bi as ComputedDynamicView, bh as ComputedElementView, n as CustomColor, b4 as CustomColorDefinitions, G as CustomElementExpr, ad as CustomRelationExpr, aA as DefaultArrowType, q as DefaultElementShape, az as DefaultLineStyle, aB as DefaultRelationshipColor, D as DefaultThemeColor, bo as DiagramEdge, bn as DiagramNode, bp as DiagramView, b2 as DynamicView, a$ as DynamicViewIncludeRule, aZ as DynamicViewParallelSteps, b1 as DynamicViewRule, aY as DynamicViewStep, a_ as DynamicViewStepOrParallel, U as ElementExpression, M as ElementKindExpr, v as ElementKindSpecification, u as ElementKindSpecificationStyle, bs as ElementNotation, $ as ElementPredicateExpression, w as ElementRefExpr, p as ElementShapes, r as ElementStyle, Q as ElementTagExpr, aG as ElementThemeColorValues, aH as ElementThemeColors, aX as ElementView, Z as ElementWhereExpr, aj as EqualOperator, y as ExpandedElementExpr, l as Expr, ah as Expression, aW as ExtendsElementView, I as IconUrl, a3 as InOutExpr, a5 as IncomingExpr, am as KindEqual, aK as LikeC4Theme, b5 as LikeC4View, t as Link, m as NonEmptyReadonlyArray, ao as NotOperator, as as OrOperator, a7 as OutgoingExpr, aw as OverviewGraph, ai as ParsedLikeC4Model, P as Point, a1 as RelationExpr, a9 as RelationExpression, af as RelationPredicateExpression, ab as RelationWhereExpr, ay as RelationshipArrowType, aC as RelationshipKindSpecification, ax as RelationshipLineType, aI as RelationshipThemeColorValues, aJ as RelationshipThemeColors, aV as ScopedElementView, bb as StepEdgeId, ba as StepEdgeIdLiteral, ak as TagEqual, s as TagSpec, aD as ThemeColor, br as ViewChange, bq as ViewManualLayout, aS as ViewRule, aQ as ViewRuleAutoLayout, aL as ViewRulePredicate, aN as ViewRuleStyle, bf as ViewWithHash, bg as ViewWithNotation, au as WhereOperator, W as WildcardExpr, X as XYPoint, bd as extractStep, bm as getBBoxCenter, be as getParallelStepsPrefix, ar as isAndOperator, bj as isComputedDynamicView, bk as isComputedElementView, J as isCustomElement, ae as isCustomRelationExpr, b6 as isDynamicView, b0 as isDynamicViewIncludeRule, b3 as isDynamicViewParallelSteps, Y as isElement, O as isElementKindExpr, a0 as isElementPredicateExpr, x as isElementRef, S as isElementTagExpr, b7 as isElementView, _ as isElementWhere, z as isExpandedElementExpr, b8 as isExtendsElementView, a4 as isInOut, a6 as isIncoming, an as isKindEqual, ap as isNotOperator, at as isOrOperator, a8 as isOutgoing, a2 as isRelation, aa as isRelationExpression, ag as isRelationPredicateExpr, ac as isRelationWhere, b9 as isScopedElementView, bc as isStepEdgeId, al as isTagEqual, aF as isThemeColor, aR as isViewRuleAutoLayout, aM as isViewRulePredicate, aO as isViewRuleStyle, K as isWildcard, av as whereOperatorAsPredicate } from './shared/core.Czd51Dd8.js';
3
+
4
+ declare const ElementColors: {
5
+ readonly primary: {
6
+ fill: "#3b82f6";
7
+ stroke: "#2563eb";
8
+ hiContrast: "#eff6ff";
9
+ loContrast: "#bfdbfe";
10
+ };
11
+ readonly blue: {
12
+ fill: "#3b82f6";
13
+ stroke: "#2563eb";
14
+ hiContrast: "#eff6ff";
15
+ loContrast: "#bfdbfe";
16
+ };
17
+ readonly secondary: {
18
+ fill: "#0284c7";
19
+ stroke: "#0369a1";
20
+ hiContrast: "#f0f9ff";
21
+ loContrast: "#B6ECF7";
22
+ };
23
+ readonly sky: {
24
+ fill: "#0284c7";
25
+ stroke: "#0369a1";
26
+ hiContrast: "#f0f9ff";
27
+ loContrast: "#B6ECF7";
28
+ };
29
+ readonly muted: {
30
+ fill: "#64748b";
31
+ stroke: "#475569";
32
+ hiContrast: "#f8fafc";
33
+ loContrast: "#cbd5e1";
34
+ };
35
+ readonly slate: {
36
+ fill: "#64748b";
37
+ stroke: "#475569";
38
+ hiContrast: "#f8fafc";
39
+ loContrast: "#cbd5e1";
40
+ };
41
+ readonly gray: {
42
+ readonly fill: "#737373";
43
+ readonly stroke: "#525252";
44
+ readonly hiContrast: "#fafafa";
45
+ readonly loContrast: "#d4d4d4";
46
+ };
47
+ readonly red: {
48
+ readonly fill: "#AC4D39";
49
+ readonly stroke: "#853A2D";
50
+ readonly hiContrast: "#FBD3CB";
51
+ readonly loContrast: "#f5b2a3";
52
+ };
53
+ readonly green: {
54
+ readonly fill: "#428a4f";
55
+ readonly stroke: "#2d5d39";
56
+ readonly hiContrast: "#f8fafc";
57
+ readonly loContrast: "#c2f0c2";
58
+ };
59
+ readonly amber: {
60
+ readonly fill: "#A35829";
61
+ readonly stroke: "#7E451D";
62
+ readonly hiContrast: "#FFE0C2";
63
+ readonly loContrast: "#f9b27c";
64
+ };
65
+ readonly indigo: {
66
+ readonly fill: "#6366f1";
67
+ readonly stroke: "#4f46e5";
68
+ readonly hiContrast: "#eef2ff";
69
+ readonly loContrast: "#c7d2fe";
70
+ };
71
+ };
72
+
73
+ declare const RelationshipColors: {
74
+ amber: {
75
+ lineColor: "#b45309";
76
+ labelBgColor: "#78350f";
77
+ labelColor: "#FFE0C2";
78
+ };
79
+ blue: {
80
+ lineColor: "#3b82f6";
81
+ labelBgColor: "#172554";
82
+ labelColor: "#60a5fa";
83
+ };
84
+ gray: {
85
+ lineColor: "#6E6E6E";
86
+ labelBgColor: "#18191b";
87
+ labelColor: "#C6C6C6";
88
+ };
89
+ green: {
90
+ lineColor: "#15803d";
91
+ labelBgColor: "#052e16";
92
+ labelColor: "#22c55e";
93
+ };
94
+ indigo: {
95
+ lineColor: "#6366f1";
96
+ labelBgColor: "#1e1b4b";
97
+ labelColor: "#818cf8";
98
+ };
99
+ muted: {
100
+ lineColor: "#64748b";
101
+ labelBgColor: "#0f172a";
102
+ labelColor: "#cbd5e1";
103
+ };
104
+ primary: {
105
+ lineColor: "#3b82f6";
106
+ labelBgColor: "#172554";
107
+ labelColor: "#60a5fa";
108
+ };
109
+ red: {
110
+ lineColor: "#AC4D39";
111
+ labelBgColor: "#b91c1c";
112
+ labelColor: "#f5b2a3";
113
+ };
114
+ secondary: {
115
+ lineColor: "#0ea5e9";
116
+ labelBgColor: "#082f49";
117
+ labelColor: "#38bdf8";
118
+ };
119
+ sky: {
120
+ lineColor: "#0ea5e9";
121
+ labelBgColor: "#082f49";
122
+ labelColor: "#38bdf8";
123
+ };
124
+ slate: {
125
+ lineColor: "#64748b";
126
+ labelBgColor: "#0f172a";
127
+ labelColor: "#cbd5e1";
128
+ };
129
+ };
130
+
131
+ declare const defaultTheme: {
132
+ elements: {
133
+ readonly primary: {
134
+ fill: "#3b82f6";
135
+ stroke: "#2563eb";
136
+ hiContrast: "#eff6ff";
137
+ loContrast: "#bfdbfe";
138
+ };
139
+ readonly blue: {
140
+ fill: "#3b82f6";
141
+ stroke: "#2563eb";
142
+ hiContrast: "#eff6ff";
143
+ loContrast: "#bfdbfe";
144
+ };
145
+ readonly secondary: {
146
+ fill: "#0284c7";
147
+ stroke: "#0369a1";
148
+ hiContrast: "#f0f9ff";
149
+ loContrast: "#B6ECF7";
150
+ };
151
+ readonly sky: {
152
+ fill: "#0284c7";
153
+ stroke: "#0369a1";
154
+ hiContrast: "#f0f9ff";
155
+ loContrast: "#B6ECF7";
156
+ };
157
+ readonly muted: {
158
+ fill: "#64748b";
159
+ stroke: "#475569";
160
+ hiContrast: "#f8fafc";
161
+ loContrast: "#cbd5e1";
162
+ };
163
+ readonly slate: {
164
+ fill: "#64748b";
165
+ stroke: "#475569";
166
+ hiContrast: "#f8fafc";
167
+ loContrast: "#cbd5e1";
168
+ };
169
+ readonly gray: {
170
+ readonly fill: "#737373";
171
+ readonly stroke: "#525252";
172
+ readonly hiContrast: "#fafafa";
173
+ readonly loContrast: "#d4d4d4";
174
+ };
175
+ readonly red: {
176
+ readonly fill: "#AC4D39";
177
+ readonly stroke: "#853A2D";
178
+ readonly hiContrast: "#FBD3CB";
179
+ readonly loContrast: "#f5b2a3";
180
+ };
181
+ readonly green: {
182
+ readonly fill: "#428a4f";
183
+ readonly stroke: "#2d5d39";
184
+ readonly hiContrast: "#f8fafc";
185
+ readonly loContrast: "#c2f0c2";
186
+ };
187
+ readonly amber: {
188
+ readonly fill: "#A35829";
189
+ readonly stroke: "#7E451D";
190
+ readonly hiContrast: "#FFE0C2";
191
+ readonly loContrast: "#f9b27c";
192
+ };
193
+ readonly indigo: {
194
+ readonly fill: "#6366f1";
195
+ readonly stroke: "#4f46e5";
196
+ readonly hiContrast: "#eef2ff";
197
+ readonly loContrast: "#c7d2fe";
198
+ };
199
+ };
200
+ relationships: {
201
+ amber: {
202
+ lineColor: "#b45309";
203
+ labelBgColor: "#78350f";
204
+ labelColor: "#FFE0C2";
205
+ };
206
+ blue: {
207
+ lineColor: "#3b82f6";
208
+ labelBgColor: "#172554";
209
+ labelColor: "#60a5fa";
210
+ };
211
+ gray: {
212
+ lineColor: "#6E6E6E";
213
+ labelBgColor: "#18191b";
214
+ labelColor: "#C6C6C6";
215
+ };
216
+ green: {
217
+ lineColor: "#15803d";
218
+ labelBgColor: "#052e16";
219
+ labelColor: "#22c55e";
220
+ };
221
+ indigo: {
222
+ lineColor: "#6366f1";
223
+ labelBgColor: "#1e1b4b";
224
+ labelColor: "#818cf8";
225
+ };
226
+ muted: {
227
+ lineColor: "#64748b";
228
+ labelBgColor: "#0f172a";
229
+ labelColor: "#cbd5e1";
230
+ };
231
+ primary: {
232
+ lineColor: "#3b82f6";
233
+ labelBgColor: "#172554";
234
+ labelColor: "#60a5fa";
235
+ };
236
+ red: {
237
+ lineColor: "#AC4D39";
238
+ labelBgColor: "#b91c1c";
239
+ labelColor: "#f5b2a3";
240
+ };
241
+ secondary: {
242
+ lineColor: "#0ea5e9";
243
+ labelBgColor: "#082f49";
244
+ labelColor: "#38bdf8";
245
+ };
246
+ sky: {
247
+ lineColor: "#0ea5e9";
248
+ labelBgColor: "#082f49";
249
+ labelColor: "#38bdf8";
250
+ };
251
+ slate: {
252
+ lineColor: "#64748b";
253
+ labelBgColor: "#0f172a";
254
+ labelColor: "#cbd5e1";
255
+ };
256
+ };
257
+ font: "Arial";
258
+ shadow: "#0a0a0a";
259
+ };
260
+ declare function computeColorValues(color: HexColorLiteral): ThemeColorValues;
261
+
262
+ declare function nonNullable<T>(value: T, message?: string): NonNullable<T>;
263
+ declare function invariant(condition: any, message?: string): asserts condition;
264
+ declare function nonexhaustive(value: never): never;
265
+
266
+ type Fqn = LiteralUnion<Fqn$1, string>;
267
+ type RelationID = LiteralUnion<RelationID$1, string>;
268
+ type ViewID = LiteralUnion<ViewID$1, string>;
269
+ type EdgeId = LiteralUnion<EdgeId$1, string>;
270
+
271
+ type ElementOrFqn$1 = Fqn | LikeC4ViewModel.Element;
272
+ /**
273
+ * All methods are view-scoped, i.e. only return elements and connections in the view.
274
+ */
275
+ declare class LikeC4ViewModel {
276
+ #private;
277
+ readonly view: ComputedView;
278
+ readonly model: LikeC4Model;
279
+ constructor(view: ComputedView, model: LikeC4Model);
280
+ get id(): ViewID$1;
281
+ get title(): string;
282
+ get viewOf(): LikeC4Model.Element;
283
+ get tags(): Tag[];
284
+ roots(): ReadonlyArray<LikeC4ViewModel.Element>;
285
+ elements(): ReadonlyArray<LikeC4ViewModel.Element>;
286
+ element(id: Fqn): LikeC4ViewModel.Element;
287
+ hasElement(id: Fqn): boolean;
288
+ connections(): ReadonlyArray<LikeC4ViewModel.Connection>;
289
+ connection(id: EdgeId): LikeC4ViewModel.Connection;
290
+ findConnections(source: ElementOrFqn$1, target: ElementOrFqn$1, direction?: 'both' | 'direct'): ReadonlyArray<LikeC4ViewModel.Connection>;
291
+ parent(element: ElementOrFqn$1): LikeC4ViewModel.Element | null;
292
+ children(element: ElementOrFqn$1): ReadonlyArray<LikeC4ViewModel.Element>;
293
+ siblings(element: ElementOrFqn$1): ReadonlyArray<LikeC4ViewModel.Element>;
294
+ /**
295
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
296
+ * (from closest to root)
297
+ */
298
+ ancestors(element: ElementOrFqn$1): ReadonlyArray<LikeC4ViewModel.Element>;
299
+ descendants(element: ElementOrFqn$1): ReadonlyArray<LikeC4ViewModel.Element>;
300
+ incoming(element: ElementOrFqn$1, filter?: 'all' | 'direct' | 'to-descendants'): ReadonlyArray<LikeC4ViewModel.Connection>;
301
+ incomers(element: ElementOrFqn$1, filter?: 'all' | 'direct' | 'to-descendants'): ReadonlyArray<LikeC4ViewModel.Element>;
302
+ /**
303
+ * Outgoing relationships from the element and its descendants
304
+ */
305
+ outgoing(element: ElementOrFqn$1, filter?: 'all' | 'direct' | 'from-descendants'): ReadonlyArray<LikeC4ViewModel.Connection>;
306
+ outgoers(element: ElementOrFqn$1, filter?: 'all' | 'direct' | 'from-descendants'): ReadonlyArray<LikeC4ViewModel.Element>;
307
+ }
308
+ declare namespace LikeC4ViewModel {
309
+ /**
310
+ * Represents an element in the view. (Diagram node)
311
+ * All methods are view-scoped, i.e. `children` returns only children of the element in the view.
312
+ */
313
+ class Element {
314
+ readonly node: ComputedNode;
315
+ private viewmodel;
316
+ constructor(node: ComputedNode, viewmodel: LikeC4ViewModel);
317
+ get id(): NodeId;
318
+ get title(): string;
319
+ get kind(): ElementKind;
320
+ get isRoot(): boolean;
321
+ get hasNested(): boolean;
322
+ get shape(): ElementShape;
323
+ get color(): Color;
324
+ get tags(): Tag[];
325
+ model(): LikeC4Model.Element;
326
+ parent(): LikeC4ViewModel.Element | null;
327
+ metadata(key: string): string | undefined;
328
+ metadata(key: string, defaultValue: string): string;
329
+ hasMetadata(key: string): boolean;
330
+ ancestors(): ReadonlyArray<LikeC4ViewModel.Element>;
331
+ siblings(): ReadonlyArray<LikeC4ViewModel.Element>;
332
+ descendants(): ReadonlyArray<LikeC4ViewModel.Element>;
333
+ children(): ReadonlyArray<LikeC4ViewModel.Element>;
334
+ incoming(filter?: 'all' | 'direct' | 'to-descendants'): ReadonlyArray<LikeC4ViewModel.Connection>;
335
+ incomers(filter?: 'all' | 'direct' | 'to-descendants'): ReadonlyArray<LikeC4ViewModel.Element>;
336
+ outgoing(filter?: 'all' | 'direct' | 'from-descendants'): ReadonlyArray<LikeC4ViewModel.Connection>;
337
+ outgoers(filter?: 'all' | 'direct' | 'from-descendants'): ReadonlyArray<LikeC4ViewModel.Element>;
338
+ connectionsTo(target: Fqn | LikeC4ViewModel.Element): ReadonlyArray<LikeC4ViewModel.Connection>;
339
+ }
340
+ /**
341
+ * Represents a connection between two elements.
342
+ * May be source from multiple model relationships.
343
+ */
344
+ class Connection {
345
+ readonly edge: ComputedEdge;
346
+ private viewmodel;
347
+ constructor(edge: ComputedEdge, viewmodel: LikeC4ViewModel);
348
+ get id(): EdgeId$1;
349
+ get source(): LikeC4ViewModel.Element;
350
+ get target(): LikeC4ViewModel.Element;
351
+ get tags(): Tag[];
352
+ /**
353
+ * Model relationships
354
+ */
355
+ relationships(): ReadonlyArray<LikeC4Model.Relationship>;
356
+ }
357
+ }
358
+
359
+ type ElementOrFqn = Fqn | LikeC4Model.Element;
360
+ declare class LikeC4Model {
361
+ #private;
362
+ protected computed: ComputedLikeC4Model;
363
+ static from(computed: ComputedLikeC4Model): LikeC4Model;
364
+ protected constructor(computed: ComputedLikeC4Model);
365
+ /**
366
+ * Returns the root elements of the model.
367
+ */
368
+ roots(): ReadonlyArray<LikeC4Model.Element>;
369
+ /**
370
+ * Returns all elements in the model.
371
+ */
372
+ elements(): ReadonlyArray<LikeC4Model.Element>;
373
+ /**
374
+ * Returns a specific element by its FQN.
375
+ */
376
+ element(id: Fqn): LikeC4Model.Element;
377
+ /**
378
+ * Returns all relationships in the model.
379
+ */
380
+ relationships(): ReadonlyArray<LikeC4Model.Relationship>;
381
+ /**
382
+ * Returns a specific relationship by its ID.
383
+ */
384
+ relationship(id: RelationID): LikeC4Model.Relationship;
385
+ /**
386
+ * Returns all views in the model.
387
+ */
388
+ views(): ReadonlyArray<LikeC4ViewModel>;
389
+ /**
390
+ * Returns a specific view by its ID.
391
+ */
392
+ view(viewId: ViewID): LikeC4ViewModel;
393
+ /**
394
+ * Returns the parent element of given element.
395
+ * @see ancestors
396
+ */
397
+ parent(element: ElementOrFqn): LikeC4Model.Element | null;
398
+ /**
399
+ * Get all children of the element (only direct children),
400
+ * @see descendants
401
+ */
402
+ children(element: ElementOrFqn): ReadonlyArray<LikeC4Model.Element>;
403
+ /**
404
+ * Get all sibling (i.e. same parent)
405
+ */
406
+ siblings(element: ElementOrFqn): ReadonlyArray<LikeC4Model.Element>;
407
+ /**
408
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
409
+ * (from closest to root)
410
+ */
411
+ ancestors(element: ElementOrFqn): ReadonlyArray<LikeC4Model.Element>;
412
+ /**
413
+ * Get all descendant elements (i.e. children, children’s children, etc.)
414
+ */
415
+ descendants(element: ElementOrFqn): ReadonlyArray<LikeC4Model.Element>;
416
+ /**
417
+ * Incoming relationships to the element and its descendants
418
+ * @see incomers
419
+ */
420
+ incoming(element: ElementOrFqn, filter?: 'all' | 'direct' | 'to-descendants'): ReadonlyArray<LikeC4Model.Relationship>;
421
+ /**
422
+ * Source elements of incoming relationships
423
+ */
424
+ incomers(element: ElementOrFqn, filter?: 'all' | 'direct' | 'to-descendants'): ReadonlyArray<LikeC4Model.Element>;
425
+ /**
426
+ * Outgoing relationships from the element and its descendants
427
+ * @see outgoers
428
+ */
429
+ outgoing(element: ElementOrFqn, filter?: 'all' | 'direct' | 'from-descendants'): ReadonlyArray<LikeC4Model.Relationship>;
430
+ /**
431
+ * Target elements of outgoing relationships
432
+ */
433
+ outgoers(element: ElementOrFqn, filter?: 'all' | 'direct' | 'from-descendants'): ReadonlyArray<LikeC4Model.Element>;
434
+ /**
435
+ * Relationships inside the element, among descendants
436
+ */
437
+ internal(element: ElementOrFqn): ReadonlyArray<LikeC4Model.Relationship>;
438
+ /**
439
+ * Resolve siblings of the element and siblings of ancestors
440
+ * (from closest to root)
441
+ */
442
+ ascendingSiblings(element: ElementOrFqn): ReadonlyArray<LikeC4Model.Element>;
443
+ /**
444
+ * Resolve all views that contain the element
445
+ */
446
+ viewsWithElement(element: ElementOrFqn): ReadonlyArray<LikeC4ViewModel>;
447
+ private addElement;
448
+ private addRelation;
449
+ private _childrenOf;
450
+ private _incomingTo;
451
+ private _outgoingFrom;
452
+ private _internalOf;
453
+ }
454
+ declare namespace LikeC4Model {
455
+ class Element {
456
+ readonly element: Element;
457
+ private model;
458
+ constructor(element: Element, model: LikeC4Model);
459
+ get id(): Fqn$1;
460
+ get title(): string;
461
+ get kind(): ElementKind;
462
+ get isRoot(): boolean;
463
+ get hasNested(): boolean;
464
+ get shape(): ElementShape;
465
+ get color(): Color;
466
+ get tags(): Tag[];
467
+ parent(): LikeC4Model.Element | null;
468
+ metadata(key: string): string | undefined;
469
+ metadata(key: string, defaultValue: string): string;
470
+ hasMetadata(key: string): boolean;
471
+ ancestors(): readonly Element[];
472
+ siblings(): readonly Element[];
473
+ descendants(): readonly Element[];
474
+ children(): readonly Element[];
475
+ /**
476
+ * Views that contain this element
477
+ */
478
+ views(): readonly LikeC4ViewModel[];
479
+ incoming(filter?: 'all' | 'direct' | 'to-descendants'): readonly Relationship[];
480
+ incomers(filter?: 'all' | 'direct' | 'to-descendants'): readonly Element[];
481
+ outgoing(filter?: 'all' | 'direct' | 'from-descendants'): readonly Relationship[];
482
+ outgoers(filter?: 'all' | 'direct' | 'from-descendants'): readonly Element[];
483
+ internal(): readonly Relationship[];
484
+ }
485
+ class Relationship {
486
+ readonly relationship: Relation;
487
+ private model;
488
+ constructor(relationship: Relation, model: LikeC4Model);
489
+ get id(): RelationID$1;
490
+ get title(): string;
491
+ get kind(): RelationshipKind;
492
+ get tags(): Tag[];
493
+ get source(): LikeC4Model.Element;
494
+ get target(): LikeC4Model.Element;
495
+ metadata(key: string): string | undefined;
496
+ metadata(key: string, defaultValue: string): string;
497
+ hasMetadata(key: string): boolean;
498
+ }
499
+ }
500
+
501
+ declare function compareNatural(a: string | undefined, b: string | undefined): -1 | 0 | 1;
502
+
503
+ type Predicate<T> = (x: T) => boolean;
504
+ declare function nameFromFqn(fqn: Fqn$1): string;
505
+ declare function isAncestor<E extends {
506
+ id: Fqn$1;
507
+ }>(...args: [ancestor: string, another: string] | [ancestor: E, another: E]): boolean;
508
+ declare function isSameHierarchy<E extends {
509
+ id: Fqn$1;
510
+ }>(one: E | Fqn$1, another: E | Fqn$1): boolean;
511
+ declare function isDescendantOf<E extends {
512
+ id: Fqn$1;
513
+ }>(ancestors: E[]): (e: E) => boolean;
514
+ declare function notDescendantOf(ancestors: Element[]): (e: Element) => boolean;
515
+ declare function commonAncestor(first: Fqn$1, second: Fqn$1): Fqn$1;
516
+ declare function parentFqn(fqn: Fqn$1): Fqn$1 | null;
517
+ declare function parentFqnPredicate<T extends {
518
+ parent: Fqn$1 | null;
519
+ }>(parent: Fqn$1): Predicate<T>;
520
+ /**
521
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
522
+ * (from closest to root)
523
+ */
524
+ declare function ancestorsFqn(fqn: Fqn$1): Fqn$1[];
525
+ /**
526
+ * Compares two fully qualified names (fqns) hierarchically based on their depth.
527
+ * From parent nodes to leaves
528
+ *
529
+ * @param {string} a - The first fqn to compare.
530
+ * @param {string} b - The second fqn to compare.
531
+ * @returns {number} - 0 if the fqns have the same depth.
532
+ * - Positive number if a is deeper than b.
533
+ * - Negative number if b is deeper than a.
534
+ */
535
+ declare function compareFqnHierarchically<T extends string = string>(a: T, b: T): -1 | 0 | 1;
536
+ declare function compareByFqnHierarchically<T extends {
537
+ id: string;
538
+ }>(a: T, b: T): 0 | 1 | -1;
539
+ type IterableContainer$1<T = unknown> = ReadonlyArray<T> | readonly [];
540
+ type ReorderedArray<T extends IterableContainer$1> = {
541
+ -readonly [P in keyof T]: T[number];
542
+ };
543
+ declare function sortByFqnHierarchically<T extends {
544
+ id: string;
545
+ }, A extends IterableContainer$1<T>>(array: A): ReorderedArray<A>;
546
+ declare function sortNaturalByFqn<T extends {
547
+ id: string;
548
+ }, A extends IterableContainer$1<T>>(array: A): ReorderedArray<A>;
549
+
550
+ /**
551
+ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
552
+
553
+ @category Type
554
+ */
555
+ type Primitive =
556
+ | null
557
+ | undefined
558
+ | string
559
+ | number
560
+ | boolean
561
+ | symbol
562
+ | bigint;
563
+
564
+ declare global {
565
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
566
+ interface SymbolConstructor {
567
+ readonly observable: symbol;
568
+ }
569
+ }
570
+
571
+ type Numeric = number | bigint;
572
+
573
+ /**
574
+ Returns a boolean for whether the given type is `never`.
575
+
576
+ @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
577
+ @link https://stackoverflow.com/a/53984913/10292952
578
+ @link https://www.zhenghao.io/posts/ts-never
579
+
580
+ Useful in type utilities, such as checking if something does not occur.
581
+
582
+ @example
583
+ ```
584
+ import type {IsNever, And} from 'type-fest';
585
+
586
+ // https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
587
+ type AreStringsEqual<A extends string, B extends string> =
588
+ And<
589
+ IsNever<Exclude<A, B>> extends true ? true : false,
590
+ IsNever<Exclude<B, A>> extends true ? true : false
591
+ >;
592
+
593
+ type EndIfEqual<I extends string, O extends string> =
594
+ AreStringsEqual<I, O> extends true
595
+ ? never
596
+ : void;
597
+
598
+ function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
599
+ if (input === output) {
600
+ process.exit(0);
601
+ }
602
+ }
603
+
604
+ endIfEqual('abc', 'abc');
605
+ //=> never
606
+
607
+ endIfEqual('abc', '123');
608
+ //=> void
609
+ ```
610
+
611
+ @category Type Guard
612
+ @category Utilities
613
+ */
614
+ type IsNever<T> = [T] extends [never] ? true : false;
615
+
616
+ /**
617
+ Returns a boolean for whether the given type `T` is the specified `LiteralType`.
618
+
619
+ @link https://stackoverflow.com/a/52806744/10292952
620
+
621
+ @example
622
+ ```
623
+ LiteralCheck<1, number>
624
+ //=> true
625
+
626
+ LiteralCheck<number, number>
627
+ //=> false
628
+
629
+ LiteralCheck<1, string>
630
+ //=> false
631
+ ```
632
+ */
633
+ type LiteralCheck<T, LiteralType extends Primitive> = (
634
+ IsNever<T> extends false // Must be wider than `never`
635
+ ? [T] extends [LiteralType & infer U] // Remove any branding
636
+ ? [U] extends [LiteralType] // Must be narrower than `LiteralType`
637
+ ? [LiteralType] extends [U] // Cannot be wider than `LiteralType`
638
+ ? false
639
+ : true
640
+ : false
641
+ : false
642
+ : false
643
+ );
644
+
645
+ /**
646
+ Returns a boolean for whether the given type `T` is one of the specified literal types in `LiteralUnionType`.
647
+
648
+ @example
649
+ ```
650
+ LiteralChecks<1, Numeric>
651
+ //=> true
652
+
653
+ LiteralChecks<1n, Numeric>
654
+ //=> true
655
+
656
+ LiteralChecks<bigint, Numeric>
657
+ //=> false
658
+ ```
659
+ */
660
+ type LiteralChecks<T, LiteralUnionType> = (
661
+ // Conditional type to force union distribution.
662
+ // If `T` is none of the literal types in the union `LiteralUnionType`, then `LiteralCheck<T, LiteralType>` will evaluate to `false` for the whole union.
663
+ // If `T` is one of the literal types in the union, it will evaluate to `boolean` (i.e. `true | false`)
664
+ IsNotFalse<LiteralUnionType extends Primitive
665
+ ? LiteralCheck<T, LiteralUnionType>
666
+ : never
667
+ >
668
+ );
669
+
670
+ /**
671
+ Returns a boolean for whether the given type is a `number` or `bigint` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
672
+
673
+ Useful for:
674
+ - providing strongly-typed functions when given literal arguments
675
+ - type utilities, such as when constructing parsers and ASTs
676
+
677
+ @example
678
+ ```
679
+ import type {IsNumericLiteral} from 'type-fest';
680
+
681
+ // https://github.com/inocan-group/inferred-types/blob/master/src/types/boolean-logic/EndsWith.ts
682
+ type EndsWith<TValue, TEndsWith extends string> =
683
+ TValue extends string
684
+ ? IsStringLiteral<TEndsWith> extends true
685
+ ? IsStringLiteral<TValue> extends true
686
+ ? TValue extends `${string}${TEndsWith}`
687
+ ? true
688
+ : false
689
+ : boolean
690
+ : boolean
691
+ : TValue extends number
692
+ ? IsNumericLiteral<TValue> extends true
693
+ ? EndsWith<`${TValue}`, TEndsWith>
694
+ : false
695
+ : false;
696
+
697
+ function endsWith<Input extends string | number, End extends string>(input: Input, end: End) {
698
+ return `${input}`.endsWith(end) as EndsWith<Input, End>;
699
+ }
700
+
701
+ endsWith('abc', 'c');
702
+ //=> true
703
+
704
+ endsWith(123456, '456');
705
+ //=> true
706
+
707
+ const end = '123' as string;
708
+
709
+ endsWith('abc123', end);
710
+ //=> boolean
711
+ ```
712
+
713
+ @category Type Guard
714
+ @category Utilities
715
+ */
716
+ type IsNumericLiteral<T> = LiteralChecks<T, Numeric>;
717
+
718
+ /**
719
+ Returns a boolean for whether the given `boolean` is not `false`.
720
+ */
721
+ type IsNotFalse<T extends boolean> = [T] extends [false] ? false : true;
722
+
723
+ /**
724
+ * This should only be used for defining generics which extend any kind of JS
725
+ * array under the hood, this includes arrays *AND* tuples (of the form [x, y],
726
+ * and of the form [x, ...y[]], etc...), and their readonly equivalent. This
727
+ * allows us to be more inclusive to what functions can process.
728
+ *
729
+ * @example map<T extends ArrayLike>(items: T) { ... }
730
+ *
731
+ * We would've named this `ArrayLike`, but that's already used by typescript...
732
+ * @see This was inspired by the type-definition of Promise.all (https://github.com/microsoft/TypeScript/blob/1df5717b120cddd325deab8b0f2b2c3eecaf2b01/src/lib/es2015.promise.d.ts#L21)
733
+ */
734
+ type IterableContainer<T = unknown> = ReadonlyArray<T> | readonly [];
735
+
736
+ type ArraySetRequired<T extends IterableContainer, Min extends number, Iteration extends ReadonlyArray<unknown> = []> = number extends Min ? never : Iteration["length"] extends Min ? T : T extends readonly [] ? never : T extends [infer Head, ...infer Rest] ? [
737
+ Head,
738
+ ...ArraySetRequired<Rest, Min, [unknown, ...Iteration]>
739
+ ] : T extends readonly [infer Head, ...infer Rest] ? readonly [
740
+ Head,
741
+ ...ArraySetRequired<Rest, Min, [unknown, ...Iteration]>
742
+ ] : T extends Array<infer Item> ? [
743
+ Item,
744
+ ...ArraySetRequired<T, Min, [unknown, ...Iteration]>
745
+ ] : T extends ReadonlyArray<infer Item> ? readonly [
746
+ Item,
747
+ ...ArraySetRequired<T, Min, [unknown, ...Iteration]>
748
+ ] : never;
749
+ /**
750
+ * Checks if the given array has at least the defined number of elements. When
751
+ * the minimum used is a literal (e.g. `3`) the output is refined accordingly so
752
+ * that those indices are defined when accessing the array even when using
753
+ * typescript's 'noUncheckedIndexAccess'.
754
+ *
755
+ * @param data - The input array.
756
+ * @param minimum - The minimum number of elements the array must have.
757
+ * @returns True if the array's length is *at least* `minimum`. When `minimum`
758
+ * is a literal value, the output is narrowed to ensure the first items are
759
+ * guaranteed.
760
+ * @signature
761
+ * R.hasAtLeast(data, minimum)
762
+ * @example
763
+ * R.hasAtLeast([], 4); // => false
764
+ *
765
+ * const data: number[] = [1,2,3,4];
766
+ * R.hasAtLeast(data, 1); // => true
767
+ * data[0]; // 1, with type `number`
768
+ * @dataFirst
769
+ * @category Array
770
+ */
771
+ declare function hasAtLeast<T extends IterableContainer, N extends number>(data: IterableContainer | T, minimum: IsNumericLiteral<N> extends true ? N : never): data is ArraySetRequired<T, N>;
772
+ declare function hasAtLeast(data: IterableContainer, minimum: number): boolean;
773
+ /**
774
+ * Checks if the given array has at least the defined number of elements. When
775
+ * the minimum used is a literal (e.g. `3`) the output is refined accordingly so
776
+ * that those indices are defined when accessing the array even when using
777
+ * typescript's 'noUncheckedIndexAccess'.
778
+ *
779
+ * @param minimum - The minimum number of elements the array must have.
780
+ * @returns True if the array's length is *at least* `minimum`. When `minimum`
781
+ * is a literal value, the output is narrowed to ensure the first items are
782
+ * guaranteed.
783
+ * @signature
784
+ * R.hasAtLeast(minimum)(data)
785
+ * @example
786
+ * R.pipe([], R.hasAtLeast(4)); // => false
787
+ *
788
+ * const data = [[1,2], [3], [4,5]];
789
+ * R.pipe(
790
+ * data,
791
+ * R.filter(R.hasAtLeast(2)),
792
+ * R.map(([, second]) => second),
793
+ * ); // => [2,5], with type `number[]`
794
+ * @dataLast
795
+ * @category Array
796
+ */
797
+ declare function hasAtLeast<N extends number>(minimum: IsNumericLiteral<N> extends true ? N : never): <T extends IterableContainer>(data: IterableContainer | T) => data is ArraySetRequired<T, N>;
798
+ declare function hasAtLeast(minimum: number): (data: IterableContainer) => boolean;
799
+
800
+ declare function isString(value: unknown): value is string;
801
+ declare function isNonEmptyArray<A>(arr: ArrayLike<A> | undefined): arr is NonEmptyArray<A>;
802
+
803
+ declare function delay(ms?: number): Promise<unknown>;
804
+
805
+ /**
806
+ * Compares two relations hierarchically.
807
+ * From the most general (implicit) to the most specific.
808
+ */
809
+ declare const compareRelations: <T extends {
810
+ source: string;
811
+ target: string;
812
+ }>(a: T, b: T) => 0 | 1 | -1;
813
+
814
+ export { Color, ComputedEdge, ComputedLikeC4Model, ComputedNode, ComputedView, EdgeId$1 as EdgeId, Element, ElementColors, ElementKind, ElementShape, Fqn$1 as Fqn, HexColorLiteral, LikeC4Model, LikeC4ViewModel, NodeId, NonEmptyArray, Relation, RelationID$1 as RelationID, RelationshipColors, RelationshipKind, Tag, ThemeColorValues, ViewID$1 as ViewID, ancestorsFqn, commonAncestor, compareByFqnHierarchically, compareFqnHierarchically, compareNatural, compareRelations, computeColorValues, defaultTheme, delay, hasAtLeast, invariant, isAncestor, isDescendantOf, isNonEmptyArray, isSameHierarchy, isString, nameFromFqn, nonNullable, nonexhaustive, notDescendantOf, parentFqn, parentFqnPredicate, sortByFqnHierarchically, sortNaturalByFqn };