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