@likec4/core 1.10.0 → 1.11.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 +610 -223
- package/dist/index.d.cts +202 -221
- package/dist/index.d.mts +202 -221
- package/dist/index.d.ts +202 -221
- package/dist/index.mjs +611 -225
- package/dist/shared/{core.DeifT5lC.mjs → core.CUlHblBQ.mjs} +5 -5
- package/dist/shared/{core.CpR2fq5B.d.cts → core.aVt8heZL.d.cts} +199 -354
- package/dist/shared/{core.CpR2fq5B.d.mts → core.aVt8heZL.d.mts} +199 -354
- package/dist/shared/{core.CpR2fq5B.d.ts → core.aVt8heZL.d.ts} +199 -354
- package/dist/types/index.cjs +1 -2
- package/dist/types/index.d.cts +2 -1
- package/dist/types/index.d.mts +2 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.mjs +1 -1
- package/package.json +14 -10
- package/src/index.ts +2 -0
- package/src/model/LikeC4DiagramModel.ts +338 -0
- package/src/model/LikeC4Model.ts +227 -145
- package/src/model/LikeC4ViewModel.ts +45 -43
- package/src/model/index.ts +3 -2
- package/src/model/types.ts +13 -0
- package/src/types/_common.ts +2 -0
- package/src/types/index.ts +0 -2
- package/src/types/model.ts +10 -1
- package/src/utils/promises.ts +13 -2
- package/src/model/__test__/LikeC4Model.spec.ts +0 -79
- package/src/utils/compare-natural.spec.ts +0 -37
- package/src/utils/fqn.spec.ts +0 -202
- package/src/utils/relations.spec.ts +0 -266
- package/dist/shared/{core.Db3ntVII.cjs → core.D78YmZ_A.cjs} +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,157 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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;
|
|
1
|
+
import { H as HexColorLiteral, T as ThemeColorValues, 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, L as LayoutedLikeC4Model, h as Element, i as Relation, j as RelationshipKind, D as DiagramView, k as DiagramNode, l as DiagramEdge, m as NonEmptyArray } from './shared/core.aVt8heZL.cjs';
|
|
2
|
+
export { at as AndOperator, A as AsFqn, aS as AutoLayoutDirection, bo as BBox, aX as BasicElementView, aW as BasicView, q as BorderStyle, B as BorderStyles, aH as ColorLiteral, bl as ComputedDynamicView, bk as ComputedElementView, p as CustomColor, b7 as CustomColorDefinitions, M as CustomElementExpr, ag as CustomRelationExpr, aD as DefaultArrowType, t as DefaultElementShape, aC as DefaultLineStyle, aE as DefaultRelationshipColor, s as DefaultThemeColor, b5 as DynamicView, b2 as DynamicViewIncludeRule, b0 as DynamicViewParallelSteps, b4 as DynamicViewRule, a$ as DynamicViewStep, b1 as DynamicViewStepOrParallel, _ as ElementExpression, S as ElementKindExpr, y as ElementKindSpecification, x as ElementKindSpecificationStyle, bs as ElementNotation, a2 as ElementPredicateExpression, z as ElementRefExpr, r as ElementShapes, u as ElementStyle, Y as ElementTagExpr, aJ as ElementThemeColorValues, aK as ElementThemeColors, a_ as ElementView, a0 as ElementWhereExpr, am as EqualOperator, J as ExpandedElementExpr, n as Expr, ak as Expression, aZ as ExtendsElementView, I as IconUrl, a6 as InOutExpr, a8 as IncomingExpr, ap as KindEqual, aN as LikeC4Theme, b8 as LikeC4View, w as Link, o as NonEmptyReadonlyArray, ar as NotOperator, av as OrOperator, aa as OutgoingExpr, az as OverviewGraph, al as ParsedLikeC4Model, P as Point, a4 as RelationExpr, ac as RelationExpression, ai as RelationPredicateExpression, ae as RelationWhereExpr, aB as RelationshipArrowType, aF as RelationshipKindSpecification, aA as RelationshipLineType, aL as RelationshipThemeColorValues, aM as RelationshipThemeColors, aY as ScopedElementView, be as StepEdgeId, bd as StepEdgeIdLiteral, an as TagEqual, v as TagSpec, aG as ThemeColor, br as ViewChange, bq as ViewManualLayout, aV as ViewRule, aT as ViewRuleAutoLayout, aO as ViewRulePredicate, aQ as ViewRuleStyle, bi as ViewWithHash, bj as ViewWithNotation, ax as WhereOperator, W as WildcardExpr, X as XYPoint, bg as extractStep, bp as getBBoxCenter, bh as getParallelStepsPrefix, au as isAndOperator, bm as isComputedDynamicView, bn as isComputedElementView, O as isCustomElement, ah as isCustomRelationExpr, b9 as isDynamicView, b3 as isDynamicViewIncludeRule, b6 as isDynamicViewParallelSteps, $ as isElement, U as isElementKindExpr, a3 as isElementPredicateExpr, G as isElementRef, Z as isElementTagExpr, ba as isElementView, a1 as isElementWhere, K as isExpandedElementExpr, bb as isExtendsElementView, a7 as isInOut, a9 as isIncoming, aq as isKindEqual, as as isNotOperator, aw as isOrOperator, ab as isOutgoing, a5 as isRelation, ad as isRelationExpression, aj as isRelationPredicateExpr, af as isRelationWhere, bc as isScopedElementView, bf as isStepEdgeId, ao as isTagEqual, aI as isThemeColor, aU as isViewRuleAutoLayout, aP as isViewRulePredicate, aR as isViewRuleStyle, Q as isWildcard, ay as whereOperatorAsPredicate } from './shared/core.aVt8heZL.cjs';
|
|
3
|
+
import { LiteralUnion, IsNumericLiteral } from 'type-fest';
|
|
155
4
|
|
|
156
5
|
declare const ElementColors: {
|
|
157
6
|
readonly primary: {
|
|
@@ -419,19 +268,25 @@ type Fqn = LiteralUnion<Fqn$1, string>;
|
|
|
419
268
|
type RelationID = LiteralUnion<RelationID$1, string>;
|
|
420
269
|
type ViewID = LiteralUnion<ViewID$1, string>;
|
|
421
270
|
type EdgeId = LiteralUnion<EdgeId$1, string>;
|
|
271
|
+
type IncomingFilter = 'all' | 'direct' | 'to-descendants';
|
|
272
|
+
type OutgoingFilter = 'all' | 'direct' | 'from-descendants';
|
|
273
|
+
type ElementOrFqn = Fqn | {
|
|
274
|
+
id: Fqn;
|
|
275
|
+
};
|
|
422
276
|
|
|
423
|
-
type ElementOrFqn$1 = Fqn | LikeC4ViewModel.Element;
|
|
424
277
|
/**
|
|
425
278
|
* All methods are view-scoped, i.e. only return elements and connections in the view.
|
|
426
279
|
*/
|
|
427
280
|
declare class LikeC4ViewModel {
|
|
428
|
-
#private;
|
|
429
281
|
readonly view: ComputedView;
|
|
430
|
-
readonly model: LikeC4Model
|
|
431
|
-
|
|
282
|
+
readonly model: LikeC4Model<LikeC4ViewModel>;
|
|
283
|
+
private _rootElements;
|
|
284
|
+
private _elements;
|
|
285
|
+
private _connections;
|
|
286
|
+
constructor(view: ComputedView, model: LikeC4Model<LikeC4ViewModel>);
|
|
432
287
|
get id(): ViewID$1;
|
|
433
288
|
get title(): string;
|
|
434
|
-
get viewOf(): LikeC4Model.
|
|
289
|
+
get viewOf(): LikeC4Model.ElementModel<LikeC4ViewModel>;
|
|
435
290
|
get tags(): Tag[];
|
|
436
291
|
roots(): ReadonlyArray<LikeC4ViewModel.Element>;
|
|
437
292
|
elements(): ReadonlyArray<LikeC4ViewModel.Element>;
|
|
@@ -439,23 +294,23 @@ declare class LikeC4ViewModel {
|
|
|
439
294
|
hasElement(id: Fqn): boolean;
|
|
440
295
|
connections(): ReadonlyArray<LikeC4ViewModel.Connection>;
|
|
441
296
|
connection(id: EdgeId): LikeC4ViewModel.Connection;
|
|
442
|
-
findConnections(source: ElementOrFqn
|
|
443
|
-
parent(element: ElementOrFqn
|
|
444
|
-
children(element: ElementOrFqn
|
|
445
|
-
siblings(element: ElementOrFqn
|
|
297
|
+
findConnections(source: ElementOrFqn, target: ElementOrFqn, direction?: 'both' | 'direct'): ReadonlyArray<LikeC4ViewModel.Connection>;
|
|
298
|
+
parent(element: ElementOrFqn): LikeC4ViewModel.Element | null;
|
|
299
|
+
children(element: ElementOrFqn): ReadonlyArray<LikeC4ViewModel.Element>;
|
|
300
|
+
siblings(element: ElementOrFqn): ReadonlyArray<LikeC4ViewModel.Element>;
|
|
446
301
|
/**
|
|
447
302
|
* Get all ancestor elements (i.e. parent, parent’s parent, etc.)
|
|
448
303
|
* (from closest to root)
|
|
449
304
|
*/
|
|
450
|
-
ancestors(element: ElementOrFqn
|
|
451
|
-
descendants(element: ElementOrFqn
|
|
452
|
-
incoming(element: ElementOrFqn
|
|
453
|
-
incomers(element: ElementOrFqn
|
|
305
|
+
ancestors(element: ElementOrFqn): ReadonlyArray<LikeC4ViewModel.Element>;
|
|
306
|
+
descendants(element: ElementOrFqn): ReadonlyArray<LikeC4ViewModel.Element>;
|
|
307
|
+
incoming(element: ElementOrFqn, filter?: IncomingFilter): ReadonlyArray<LikeC4ViewModel.Connection>;
|
|
308
|
+
incomers(element: ElementOrFqn, filter?: IncomingFilter): ReadonlyArray<LikeC4ViewModel.Element>;
|
|
454
309
|
/**
|
|
455
310
|
* Outgoing relationships from the element and its descendants
|
|
456
311
|
*/
|
|
457
|
-
outgoing(element: ElementOrFqn
|
|
458
|
-
outgoers(element: ElementOrFqn
|
|
312
|
+
outgoing(element: ElementOrFqn, filter?: OutgoingFilter): ReadonlyArray<LikeC4ViewModel.Connection>;
|
|
313
|
+
outgoers(element: ElementOrFqn, filter?: OutgoingFilter): ReadonlyArray<LikeC4ViewModel.Element>;
|
|
459
314
|
}
|
|
460
315
|
declare namespace LikeC4ViewModel {
|
|
461
316
|
/**
|
|
@@ -474,7 +329,7 @@ declare namespace LikeC4ViewModel {
|
|
|
474
329
|
get shape(): ElementShape;
|
|
475
330
|
get color(): Color;
|
|
476
331
|
get tags(): Tag[];
|
|
477
|
-
model(): LikeC4Model.
|
|
332
|
+
model(): LikeC4Model.ElementModel<LikeC4ViewModel>;
|
|
478
333
|
parent(): LikeC4ViewModel.Element | null;
|
|
479
334
|
metadata(key: string): string | undefined;
|
|
480
335
|
metadata(key: string, defaultValue: string): string;
|
|
@@ -485,8 +340,8 @@ declare namespace LikeC4ViewModel {
|
|
|
485
340
|
children(): ReadonlyArray<LikeC4ViewModel.Element>;
|
|
486
341
|
incoming(filter?: 'all' | 'direct' | 'to-descendants'): ReadonlyArray<LikeC4ViewModel.Connection>;
|
|
487
342
|
incomers(filter?: 'all' | 'direct' | 'to-descendants'): ReadonlyArray<LikeC4ViewModel.Element>;
|
|
488
|
-
outgoing(filter?:
|
|
489
|
-
outgoers(filter?:
|
|
343
|
+
outgoing(filter?: OutgoingFilter): ReadonlyArray<LikeC4ViewModel.Connection>;
|
|
344
|
+
outgoers(filter?: OutgoingFilter): ReadonlyArray<LikeC4ViewModel.Element>;
|
|
490
345
|
connectionsTo(target: Fqn | LikeC4ViewModel.Element): ReadonlyArray<LikeC4ViewModel.Connection>;
|
|
491
346
|
}
|
|
492
347
|
/**
|
|
@@ -504,98 +359,110 @@ declare namespace LikeC4ViewModel {
|
|
|
504
359
|
/**
|
|
505
360
|
* Model relationships
|
|
506
361
|
*/
|
|
507
|
-
relationships(): ReadonlyArray<LikeC4Model.Relationship
|
|
362
|
+
relationships(): ReadonlyArray<LikeC4Model.Relationship<LikeC4ViewModel>>;
|
|
508
363
|
}
|
|
509
364
|
}
|
|
510
365
|
|
|
511
|
-
type
|
|
512
|
-
declare class LikeC4Model {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
366
|
+
type PickBySource<Source> = Source extends LikeC4Model.Layouted.SourceModel ? LikeC4Model.Layouted : Source extends LikeC4Model.Computed.SourceModel ? LikeC4Model.Computed : never;
|
|
367
|
+
declare class LikeC4Model<M extends LikeC4Model.ViewModel = LikeC4Model.ViewModel> {
|
|
368
|
+
readonly type: LikeC4Model.ModelType<M>;
|
|
369
|
+
readonly sourcemodel: LikeC4Model.SourceModel<M>;
|
|
370
|
+
private _elements;
|
|
371
|
+
private _parents;
|
|
372
|
+
private _children;
|
|
373
|
+
private _rootElements;
|
|
374
|
+
private _relations;
|
|
375
|
+
private _incoming;
|
|
376
|
+
private _outgoing;
|
|
377
|
+
private _internal;
|
|
378
|
+
private _cacheAscendingSiblings;
|
|
379
|
+
private _views;
|
|
380
|
+
static create(source: LikeC4Model.SourceModel): PickBySource<typeof source>;
|
|
381
|
+
static computed(source: ComputedLikeC4Model): LikeC4Model<LikeC4ViewModel>;
|
|
382
|
+
static layouted(source: LayoutedLikeC4Model): LikeC4Model<LikeC4DiagramModel>;
|
|
383
|
+
protected constructor(type: LikeC4Model.ModelType<M>, sourcemodel: LikeC4Model.SourceModel<M>, elements: Element[], relations: Relation[]);
|
|
517
384
|
/**
|
|
518
385
|
* Returns the root elements of the model.
|
|
519
386
|
*/
|
|
520
|
-
roots(): ReadonlyArray<LikeC4Model.
|
|
387
|
+
roots(): ReadonlyArray<LikeC4Model.ElementModel<M>>;
|
|
521
388
|
/**
|
|
522
389
|
* Returns all elements in the model.
|
|
523
390
|
*/
|
|
524
|
-
elements(): ReadonlyArray<LikeC4Model.
|
|
391
|
+
elements(): ReadonlyArray<LikeC4Model.ElementModel<M>>;
|
|
525
392
|
/**
|
|
526
393
|
* Returns a specific element by its FQN.
|
|
527
394
|
*/
|
|
528
|
-
element(id: Fqn): LikeC4Model.
|
|
395
|
+
element(id: Fqn): LikeC4Model.ElementModel<M>;
|
|
529
396
|
/**
|
|
530
397
|
* Returns all relationships in the model.
|
|
531
398
|
*/
|
|
532
|
-
relationships(): ReadonlyArray<LikeC4Model.Relationship
|
|
399
|
+
relationships(): ReadonlyArray<LikeC4Model.Relationship<M>>;
|
|
533
400
|
/**
|
|
534
401
|
* Returns a specific relationship by its ID.
|
|
535
402
|
*/
|
|
536
|
-
relationship(id: RelationID): LikeC4Model.Relationship
|
|
403
|
+
relationship(id: RelationID): LikeC4Model.Relationship<M>;
|
|
537
404
|
/**
|
|
538
405
|
* Returns all views in the model.
|
|
539
406
|
*/
|
|
540
|
-
views(): ReadonlyArray<
|
|
407
|
+
views(): ReadonlyArray<M>;
|
|
541
408
|
/**
|
|
542
409
|
* Returns a specific view by its ID.
|
|
543
410
|
*/
|
|
544
|
-
view(viewId: ViewID):
|
|
411
|
+
view(viewId: ViewID): M;
|
|
545
412
|
/**
|
|
546
413
|
* Returns the parent element of given element.
|
|
547
414
|
* @see ancestors
|
|
548
415
|
*/
|
|
549
|
-
parent(element: ElementOrFqn): LikeC4Model.
|
|
416
|
+
parent(element: ElementOrFqn): LikeC4Model.ElementModel<M> | null;
|
|
550
417
|
/**
|
|
551
418
|
* Get all children of the element (only direct children),
|
|
552
419
|
* @see descendants
|
|
553
420
|
*/
|
|
554
|
-
children(element: ElementOrFqn): ReadonlyArray<LikeC4Model.
|
|
421
|
+
children(element: ElementOrFqn): ReadonlyArray<LikeC4Model.ElementModel<M>>;
|
|
555
422
|
/**
|
|
556
423
|
* Get all sibling (i.e. same parent)
|
|
557
424
|
*/
|
|
558
|
-
siblings(element: ElementOrFqn): ReadonlyArray<LikeC4Model.
|
|
425
|
+
siblings(element: ElementOrFqn): ReadonlyArray<LikeC4Model.ElementModel<M>>;
|
|
559
426
|
/**
|
|
560
427
|
* Get all ancestor elements (i.e. parent, parent’s parent, etc.)
|
|
561
428
|
* (from closest to root)
|
|
562
429
|
*/
|
|
563
|
-
ancestors(element: ElementOrFqn): ReadonlyArray<LikeC4Model.
|
|
430
|
+
ancestors(element: ElementOrFqn): ReadonlyArray<LikeC4Model.ElementModel<M>>;
|
|
564
431
|
/**
|
|
565
432
|
* Get all descendant elements (i.e. children, children’s children, etc.)
|
|
566
433
|
*/
|
|
567
|
-
descendants(element: ElementOrFqn): ReadonlyArray<LikeC4Model.
|
|
434
|
+
descendants(element: ElementOrFqn): ReadonlyArray<LikeC4Model.ElementModel<M>>;
|
|
568
435
|
/**
|
|
569
436
|
* Incoming relationships to the element and its descendants
|
|
570
437
|
* @see incomers
|
|
571
438
|
*/
|
|
572
|
-
incoming(element: ElementOrFqn, filter?:
|
|
439
|
+
incoming(element: ElementOrFqn, filter?: IncomingFilter): ReadonlyArray<LikeC4Model.Relationship<M>>;
|
|
573
440
|
/**
|
|
574
441
|
* Source elements of incoming relationships
|
|
575
442
|
*/
|
|
576
|
-
incomers(element: ElementOrFqn, filter?:
|
|
443
|
+
incomers(element: ElementOrFqn, filter?: IncomingFilter): ReadonlyArray<LikeC4Model.ElementModel<M>>;
|
|
577
444
|
/**
|
|
578
445
|
* Outgoing relationships from the element and its descendants
|
|
579
446
|
* @see outgoers
|
|
580
447
|
*/
|
|
581
|
-
outgoing(element: ElementOrFqn, filter?:
|
|
448
|
+
outgoing(element: ElementOrFqn, filter?: OutgoingFilter): ReadonlyArray<LikeC4Model.Relationship<M>>;
|
|
582
449
|
/**
|
|
583
450
|
* Target elements of outgoing relationships
|
|
584
451
|
*/
|
|
585
|
-
outgoers(element: ElementOrFqn, filter?:
|
|
452
|
+
outgoers(element: ElementOrFqn, filter?: OutgoingFilter): ReadonlyArray<LikeC4Model.ElementModel<M>>;
|
|
586
453
|
/**
|
|
587
454
|
* Relationships inside the element, among descendants
|
|
588
455
|
*/
|
|
589
|
-
internal(element: ElementOrFqn): ReadonlyArray<LikeC4Model.Relationship
|
|
456
|
+
internal(element: ElementOrFqn): ReadonlyArray<LikeC4Model.Relationship<M>>;
|
|
590
457
|
/**
|
|
591
458
|
* Resolve siblings of the element and siblings of ancestors
|
|
592
459
|
* (from closest to root)
|
|
593
460
|
*/
|
|
594
|
-
ascendingSiblings(element: ElementOrFqn): ReadonlyArray<LikeC4Model.
|
|
461
|
+
ascendingSiblings(element: ElementOrFqn): ReadonlyArray<LikeC4Model.ElementModel<M>>;
|
|
595
462
|
/**
|
|
596
463
|
* Resolve all views that contain the element
|
|
597
464
|
*/
|
|
598
|
-
viewsWithElement(element: ElementOrFqn): ReadonlyArray<
|
|
465
|
+
viewsWithElement(element: ElementOrFqn): ReadonlyArray<M>;
|
|
599
466
|
private addElement;
|
|
600
467
|
private addRelation;
|
|
601
468
|
private _childrenOf;
|
|
@@ -604,10 +471,43 @@ declare class LikeC4Model {
|
|
|
604
471
|
private _internalOf;
|
|
605
472
|
}
|
|
606
473
|
declare namespace LikeC4Model {
|
|
607
|
-
|
|
474
|
+
function isModel(model: any): model is LikeC4Model;
|
|
475
|
+
type SourceModel<M extends ViewModel = ViewModel> = M extends LikeC4DiagramModel ? LayoutedLikeC4Model : ComputedLikeC4Model;
|
|
476
|
+
type ViewModel = LikeC4ViewModel | LikeC4DiagramModel;
|
|
477
|
+
namespace ViewModel {
|
|
478
|
+
type Relationship = LikeC4Model.Relationship<ViewModel>;
|
|
479
|
+
function isLayouted(model: ViewModel): model is LikeC4DiagramModel;
|
|
480
|
+
}
|
|
481
|
+
type Computed = LikeC4Model<LikeC4ViewModel>;
|
|
482
|
+
namespace Computed {
|
|
483
|
+
type ViewModel = LikeC4ViewModel;
|
|
484
|
+
type SourceModel = LikeC4Model.SourceModel<ViewModel>;
|
|
485
|
+
}
|
|
486
|
+
type Layouted = LikeC4Model<LikeC4DiagramModel>;
|
|
487
|
+
namespace Layouted {
|
|
488
|
+
type ViewModel = LikeC4DiagramModel;
|
|
489
|
+
type SourceModel = LikeC4Model.SourceModel<ViewModel>;
|
|
490
|
+
}
|
|
491
|
+
type ModelType<M extends ViewModel = ViewModel> = M extends LikeC4DiagramModel ? 'layouted' : M extends LikeC4ViewModel ? 'computed' : never;
|
|
492
|
+
function isLayouted(model: LikeC4Model): model is Layouted;
|
|
493
|
+
class Relationship<M extends ViewModel> {
|
|
494
|
+
readonly relationship: Relation;
|
|
495
|
+
private model;
|
|
496
|
+
constructor(relationship: Relation, model: LikeC4Model<M>);
|
|
497
|
+
get id(): RelationID$1;
|
|
498
|
+
get title(): string;
|
|
499
|
+
get kind(): RelationshipKind;
|
|
500
|
+
get tags(): Tag[];
|
|
501
|
+
get source(): ElementModel<M>;
|
|
502
|
+
get target(): ElementModel<M>;
|
|
503
|
+
metadata(key: string): string | undefined;
|
|
504
|
+
metadata(key: string, defaultValue: string): string;
|
|
505
|
+
hasMetadata(key: string): boolean;
|
|
506
|
+
}
|
|
507
|
+
class ElementModel<M extends ViewModel> {
|
|
608
508
|
readonly element: Element;
|
|
609
509
|
private model;
|
|
610
|
-
constructor(element: Element, model: LikeC4Model);
|
|
510
|
+
constructor(element: Element, model: LikeC4Model<M>);
|
|
611
511
|
get id(): Fqn$1;
|
|
612
512
|
get title(): string;
|
|
613
513
|
get kind(): ElementKind;
|
|
@@ -616,37 +516,116 @@ declare namespace LikeC4Model {
|
|
|
616
516
|
get shape(): ElementShape;
|
|
617
517
|
get color(): Color;
|
|
618
518
|
get tags(): Tag[];
|
|
619
|
-
parent():
|
|
519
|
+
parent(): ElementModel<M> | null;
|
|
620
520
|
metadata(key: string): string | undefined;
|
|
621
521
|
metadata(key: string, defaultValue: string): string;
|
|
622
522
|
hasMetadata(key: string): boolean;
|
|
623
|
-
ancestors(): readonly
|
|
624
|
-
siblings(): readonly
|
|
625
|
-
descendants(): readonly
|
|
626
|
-
children(): readonly
|
|
523
|
+
ancestors(): readonly ElementModel<M>[];
|
|
524
|
+
siblings(): readonly ElementModel<M>[];
|
|
525
|
+
descendants(): readonly ElementModel<M>[];
|
|
526
|
+
children(): readonly ElementModel<M>[];
|
|
627
527
|
/**
|
|
628
528
|
* Views that contain this element
|
|
629
529
|
*/
|
|
630
|
-
views(): readonly
|
|
631
|
-
incoming(filter?:
|
|
632
|
-
incomers(filter?:
|
|
633
|
-
outgoing(filter?:
|
|
634
|
-
outgoers(filter?:
|
|
635
|
-
internal(): readonly Relationship[];
|
|
530
|
+
views(): readonly M[];
|
|
531
|
+
incoming(filter?: IncomingFilter): readonly Relationship<M>[];
|
|
532
|
+
incomers(filter?: IncomingFilter): readonly ElementModel<M>[];
|
|
533
|
+
outgoing(filter?: OutgoingFilter): readonly Relationship<M>[];
|
|
534
|
+
outgoers(filter?: OutgoingFilter): readonly ElementModel<M>[];
|
|
535
|
+
internal(): readonly Relationship<M>[];
|
|
636
536
|
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* All methods are view-scoped, i.e. only return elements and connections in the view.
|
|
541
|
+
*/
|
|
542
|
+
declare class LikeC4DiagramModel {
|
|
543
|
+
readonly view: DiagramView;
|
|
544
|
+
readonly model: LikeC4Model.Layouted;
|
|
545
|
+
private _rootElements;
|
|
546
|
+
private _elements;
|
|
547
|
+
private _connections;
|
|
548
|
+
constructor(view: DiagramView, model: LikeC4Model.Layouted);
|
|
549
|
+
get isDynamic(): boolean;
|
|
550
|
+
get id(): ViewID$1;
|
|
551
|
+
get title(): string;
|
|
552
|
+
get viewOf(): LikeC4Model.ElementModel<LikeC4DiagramModel>;
|
|
553
|
+
get tags(): Tag[];
|
|
554
|
+
roots(): ReadonlyArray<LikeC4DiagramModel.Element>;
|
|
555
|
+
elements(): ReadonlyArray<LikeC4DiagramModel.Element>;
|
|
556
|
+
element(id: Fqn): LikeC4DiagramModel.Element;
|
|
557
|
+
hasElement(id: Fqn): boolean;
|
|
558
|
+
connections(): ReadonlyArray<LikeC4DiagramModel.Connection>;
|
|
559
|
+
connection(id: EdgeId): LikeC4DiagramModel.Connection;
|
|
560
|
+
findConnections(source: ElementOrFqn, target: ElementOrFqn, direction?: 'both' | 'direct'): ReadonlyArray<LikeC4DiagramModel.Connection>;
|
|
561
|
+
parent(element: ElementOrFqn): LikeC4DiagramModel.Element | null;
|
|
562
|
+
children(element: ElementOrFqn): ReadonlyArray<LikeC4DiagramModel.Element>;
|
|
563
|
+
siblings(element: ElementOrFqn): ReadonlyArray<LikeC4DiagramModel.Element>;
|
|
564
|
+
/**
|
|
565
|
+
* Get all ancestor elements (i.e. parent, parent’s parent, etc.)
|
|
566
|
+
* (from closest to root)
|
|
567
|
+
*/
|
|
568
|
+
ancestors(element: ElementOrFqn): ReadonlyArray<LikeC4DiagramModel.Element>;
|
|
569
|
+
descendants(element: ElementOrFqn): ReadonlyArray<LikeC4DiagramModel.Element>;
|
|
570
|
+
incoming(element: ElementOrFqn, filter?: IncomingFilter): ReadonlyArray<LikeC4DiagramModel.Connection>;
|
|
571
|
+
incomers(element: ElementOrFqn, filter?: IncomingFilter): ReadonlyArray<LikeC4DiagramModel.Element>;
|
|
572
|
+
/**
|
|
573
|
+
* Outgoing relationships from the element and its descendants
|
|
574
|
+
*/
|
|
575
|
+
outgoing(element: ElementOrFqn, filter?: OutgoingFilter): ReadonlyArray<LikeC4DiagramModel.Connection>;
|
|
576
|
+
outgoers(element: ElementOrFqn, filter?: OutgoingFilter): ReadonlyArray<LikeC4DiagramModel.Element>;
|
|
577
|
+
}
|
|
578
|
+
declare namespace LikeC4DiagramModel {
|
|
579
|
+
/**
|
|
580
|
+
* Represents an element in the view. (Diagram node)
|
|
581
|
+
* All methods are view-scoped, i.e. `children` returns only children of the element in the view.
|
|
582
|
+
*/
|
|
583
|
+
class Element {
|
|
584
|
+
readonly node: DiagramNode;
|
|
585
|
+
private view;
|
|
586
|
+
constructor(node: DiagramNode, view: LikeC4DiagramModel);
|
|
587
|
+
get id(): NodeId;
|
|
642
588
|
get title(): string;
|
|
643
|
-
get kind():
|
|
589
|
+
get kind(): ElementKind;
|
|
590
|
+
get isRoot(): boolean;
|
|
591
|
+
get hasNested(): boolean;
|
|
592
|
+
get shape(): ElementShape;
|
|
593
|
+
get color(): Color;
|
|
644
594
|
get tags(): Tag[];
|
|
645
|
-
get
|
|
646
|
-
get
|
|
595
|
+
get level(): number;
|
|
596
|
+
get depth(): number;
|
|
597
|
+
model(): LikeC4Model.ElementModel<LikeC4DiagramModel>;
|
|
598
|
+
parent(): LikeC4DiagramModel.Element | null;
|
|
647
599
|
metadata(key: string): string | undefined;
|
|
648
600
|
metadata(key: string, defaultValue: string): string;
|
|
649
601
|
hasMetadata(key: string): boolean;
|
|
602
|
+
ancestors(): ReadonlyArray<LikeC4DiagramModel.Element>;
|
|
603
|
+
siblings(): ReadonlyArray<LikeC4DiagramModel.Element>;
|
|
604
|
+
descendants(): ReadonlyArray<LikeC4DiagramModel.Element>;
|
|
605
|
+
children(): ReadonlyArray<LikeC4DiagramModel.Element>;
|
|
606
|
+
incoming(filter?: IncomingFilter): ReadonlyArray<LikeC4DiagramModel.Connection>;
|
|
607
|
+
incomers(filter?: IncomingFilter): ReadonlyArray<LikeC4DiagramModel.Element>;
|
|
608
|
+
outgoing(filter?: OutgoingFilter): ReadonlyArray<LikeC4DiagramModel.Connection>;
|
|
609
|
+
outgoers(filter?: OutgoingFilter): ReadonlyArray<LikeC4DiagramModel.Element>;
|
|
610
|
+
connectionsTo(target: Fqn | LikeC4DiagramModel.Element): ReadonlyArray<LikeC4DiagramModel.Connection>;
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Represents a connection between two elements.
|
|
614
|
+
* May be source from multiple model relationships.
|
|
615
|
+
*/
|
|
616
|
+
class Connection {
|
|
617
|
+
readonly edge: DiagramEdge;
|
|
618
|
+
private view;
|
|
619
|
+
constructor(edge: DiagramEdge, view: LikeC4DiagramModel);
|
|
620
|
+
get id(): EdgeId$1;
|
|
621
|
+
get source(): LikeC4DiagramModel.Element;
|
|
622
|
+
get target(): LikeC4DiagramModel.Element;
|
|
623
|
+
get tags(): Tag[];
|
|
624
|
+
get color(): Color;
|
|
625
|
+
/**
|
|
626
|
+
* Model relationships
|
|
627
|
+
*/
|
|
628
|
+
relationships(): ReadonlyArray<LikeC4Model.Relationship<LikeC4DiagramModel>>;
|
|
650
629
|
}
|
|
651
630
|
}
|
|
652
631
|
|
|
@@ -779,7 +758,9 @@ declare function hasAtLeast(minimum: number): (data: IterableContainer) => boole
|
|
|
779
758
|
declare function isString(value: unknown): value is string;
|
|
780
759
|
declare function isNonEmptyArray<A>(arr: ArrayLike<A> | undefined): arr is NonEmptyArray<A>;
|
|
781
760
|
|
|
782
|
-
declare function delay(
|
|
761
|
+
declare function delay(): Promise<string>;
|
|
762
|
+
declare function delay(ms: number): Promise<string>;
|
|
763
|
+
declare function delay(randomFrom: number, randomTo: number): Promise<string>;
|
|
783
764
|
|
|
784
765
|
/**
|
|
785
766
|
* Compares two relations hierarchically.
|
|
@@ -790,4 +771,4 @@ declare const compareRelations: <T extends {
|
|
|
790
771
|
target: string;
|
|
791
772
|
}>(a: T, b: T) => 0 | 1 | -1;
|
|
792
773
|
|
|
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 };
|
|
774
|
+
export { Color, ComputedEdge, ComputedLikeC4Model, ComputedNode, ComputedView, DiagramEdge, DiagramNode, DiagramView, EdgeId$1 as EdgeId, Element, ElementColors, ElementKind, ElementShape, Fqn$1 as Fqn, HexColorLiteral, LayoutedLikeC4Model, LikeC4DiagramModel, 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 };
|