@likec4/core 1.10.1 → 1.12.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 +461 -167
- package/dist/index.d.cts +202 -242
- package/dist/index.d.mts +202 -242
- package/dist/index.d.ts +202 -242
- package/dist/index.mjs +461 -169
- package/dist/shared/{core.DeifT5lC.mjs → core.BvFch1jG.mjs} +9 -6
- package/dist/shared/{core.Db3ntVII.cjs → core.CTiE4teS.cjs} +9 -5
- package/dist/shared/{core.Czd51Dd8.d.cts → core.Ik3-ZP2n.d.cts} +210 -358
- package/dist/shared/{core.Czd51Dd8.d.mts → core.Ik3-ZP2n.d.mts} +210 -358
- package/dist/shared/{core.Czd51Dd8.d.ts → core.Ik3-ZP2n.d.ts} +210 -358
- package/dist/types/index.cjs +2 -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 +13 -9
- 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/index.ts +0 -2
- package/src/types/model.ts +10 -1
- package/src/types/view.ts +16 -6
- 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/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { H as HexColorLiteral, T as ThemeColorValues,
|
|
2
|
-
export {
|
|
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.Ik3-ZP2n.mjs';
|
|
2
|
+
export { at as AndOperator, A as AsFqn, aS as AutoLayoutDirection, bq as BBox, aY as BasicElementView, aX as BasicView, q as BorderStyle, B as BorderStyles, aH as ColorLiteral, bn as ComputedDynamicView, bm as ComputedElementView, p as CustomColor, b8 as CustomColorDefinitions, M as CustomElementExpr, ag as CustomRelationExpr, aD as DefaultArrowType, t as DefaultElementShape, aC as DefaultLineStyle, aE as DefaultRelationshipColor, s as DefaultThemeColor, b6 as DynamicView, b3 as DynamicViewIncludeRule, b1 as DynamicViewParallelSteps, b5 as DynamicViewRule, b0 as DynamicViewStep, b2 as DynamicViewStepOrParallel, _ as ElementExpression, S as ElementKindExpr, y as ElementKindSpecification, x as ElementKindSpecificationStyle, bu 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, a_ as ExtendsElementView, I as IconUrl, a6 as InOutExpr, a8 as IncomingExpr, ap as KindEqual, aN as LikeC4Theme, b9 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, aZ as ScopedElementView, bf as StepEdgeId, be as StepEdgeIdLiteral, an as TagEqual, v as TagSpec, aG as ThemeColor, bl as ViewAutoLayout, bt as ViewChange, bs as ViewManualLayout, aW as ViewRule, aU as ViewRuleAutoLayout, aO as ViewRulePredicate, aQ as ViewRuleStyle, bj as ViewWithHash, bk as ViewWithNotation, ax as WhereOperator, W as WildcardExpr, X as XYPoint, bh as extractStep, br as getBBoxCenter, bi as getParallelStepsPrefix, au as isAndOperator, aT as isAutoLayoutDirection, bo as isComputedDynamicView, bp as isComputedElementView, O as isCustomElement, ah as isCustomRelationExpr, ba as isDynamicView, b4 as isDynamicViewIncludeRule, b7 as isDynamicViewParallelSteps, $ as isElement, U as isElementKindExpr, a3 as isElementPredicateExpr, G as isElementRef, Z as isElementTagExpr, bb as isElementView, a1 as isElementWhere, K as isExpandedElementExpr, bc 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, bd as isScopedElementView, bg as isStepEdgeId, ao as isTagEqual, aI as isThemeColor, aV as isViewRuleAutoLayout, aP as isViewRulePredicate, aR as isViewRuleStyle, Q as isWildcard, ay as whereOperatorAsPredicate } from './shared/core.Ik3-ZP2n.mjs';
|
|
3
|
+
import { LiteralUnion, IsNumericLiteral } from 'type-fest';
|
|
3
4
|
|
|
4
5
|
declare const ElementColors: {
|
|
5
6
|
readonly primary: {
|
|
@@ -267,19 +268,25 @@ type Fqn = LiteralUnion<Fqn$1, string>;
|
|
|
267
268
|
type RelationID = LiteralUnion<RelationID$1, string>;
|
|
268
269
|
type ViewID = LiteralUnion<ViewID$1, string>;
|
|
269
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
|
+
};
|
|
270
276
|
|
|
271
|
-
type ElementOrFqn$1 = Fqn | LikeC4ViewModel.Element;
|
|
272
277
|
/**
|
|
273
278
|
* All methods are view-scoped, i.e. only return elements and connections in the view.
|
|
274
279
|
*/
|
|
275
280
|
declare class LikeC4ViewModel {
|
|
276
|
-
#private;
|
|
277
281
|
readonly view: ComputedView;
|
|
278
|
-
readonly model: LikeC4Model
|
|
279
|
-
|
|
282
|
+
readonly model: LikeC4Model<LikeC4ViewModel>;
|
|
283
|
+
private _rootElements;
|
|
284
|
+
private _elements;
|
|
285
|
+
private _connections;
|
|
286
|
+
constructor(view: ComputedView, model: LikeC4Model<LikeC4ViewModel>);
|
|
280
287
|
get id(): ViewID$1;
|
|
281
288
|
get title(): string;
|
|
282
|
-
get viewOf(): LikeC4Model.
|
|
289
|
+
get viewOf(): LikeC4Model.ElementModel<LikeC4ViewModel>;
|
|
283
290
|
get tags(): Tag[];
|
|
284
291
|
roots(): ReadonlyArray<LikeC4ViewModel.Element>;
|
|
285
292
|
elements(): ReadonlyArray<LikeC4ViewModel.Element>;
|
|
@@ -287,23 +294,23 @@ declare class LikeC4ViewModel {
|
|
|
287
294
|
hasElement(id: Fqn): boolean;
|
|
288
295
|
connections(): ReadonlyArray<LikeC4ViewModel.Connection>;
|
|
289
296
|
connection(id: EdgeId): LikeC4ViewModel.Connection;
|
|
290
|
-
findConnections(source: ElementOrFqn
|
|
291
|
-
parent(element: ElementOrFqn
|
|
292
|
-
children(element: ElementOrFqn
|
|
293
|
-
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>;
|
|
294
301
|
/**
|
|
295
302
|
* Get all ancestor elements (i.e. parent, parent’s parent, etc.)
|
|
296
303
|
* (from closest to root)
|
|
297
304
|
*/
|
|
298
|
-
ancestors(element: ElementOrFqn
|
|
299
|
-
descendants(element: ElementOrFqn
|
|
300
|
-
incoming(element: ElementOrFqn
|
|
301
|
-
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>;
|
|
302
309
|
/**
|
|
303
310
|
* Outgoing relationships from the element and its descendants
|
|
304
311
|
*/
|
|
305
|
-
outgoing(element: ElementOrFqn
|
|
306
|
-
outgoers(element: ElementOrFqn
|
|
312
|
+
outgoing(element: ElementOrFqn, filter?: OutgoingFilter): ReadonlyArray<LikeC4ViewModel.Connection>;
|
|
313
|
+
outgoers(element: ElementOrFqn, filter?: OutgoingFilter): ReadonlyArray<LikeC4ViewModel.Element>;
|
|
307
314
|
}
|
|
308
315
|
declare namespace LikeC4ViewModel {
|
|
309
316
|
/**
|
|
@@ -322,7 +329,7 @@ declare namespace LikeC4ViewModel {
|
|
|
322
329
|
get shape(): ElementShape;
|
|
323
330
|
get color(): Color;
|
|
324
331
|
get tags(): Tag[];
|
|
325
|
-
model(): LikeC4Model.
|
|
332
|
+
model(): LikeC4Model.ElementModel<LikeC4ViewModel>;
|
|
326
333
|
parent(): LikeC4ViewModel.Element | null;
|
|
327
334
|
metadata(key: string): string | undefined;
|
|
328
335
|
metadata(key: string, defaultValue: string): string;
|
|
@@ -333,8 +340,8 @@ declare namespace LikeC4ViewModel {
|
|
|
333
340
|
children(): ReadonlyArray<LikeC4ViewModel.Element>;
|
|
334
341
|
incoming(filter?: 'all' | 'direct' | 'to-descendants'): ReadonlyArray<LikeC4ViewModel.Connection>;
|
|
335
342
|
incomers(filter?: 'all' | 'direct' | 'to-descendants'): ReadonlyArray<LikeC4ViewModel.Element>;
|
|
336
|
-
outgoing(filter?:
|
|
337
|
-
outgoers(filter?:
|
|
343
|
+
outgoing(filter?: OutgoingFilter): ReadonlyArray<LikeC4ViewModel.Connection>;
|
|
344
|
+
outgoers(filter?: OutgoingFilter): ReadonlyArray<LikeC4ViewModel.Element>;
|
|
338
345
|
connectionsTo(target: Fqn | LikeC4ViewModel.Element): ReadonlyArray<LikeC4ViewModel.Connection>;
|
|
339
346
|
}
|
|
340
347
|
/**
|
|
@@ -352,98 +359,110 @@ declare namespace LikeC4ViewModel {
|
|
|
352
359
|
/**
|
|
353
360
|
* Model relationships
|
|
354
361
|
*/
|
|
355
|
-
relationships(): ReadonlyArray<LikeC4Model.Relationship
|
|
362
|
+
relationships(): ReadonlyArray<LikeC4Model.Relationship<LikeC4ViewModel>>;
|
|
356
363
|
}
|
|
357
364
|
}
|
|
358
365
|
|
|
359
|
-
type
|
|
360
|
-
declare class LikeC4Model {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
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[]);
|
|
365
384
|
/**
|
|
366
385
|
* Returns the root elements of the model.
|
|
367
386
|
*/
|
|
368
|
-
roots(): ReadonlyArray<LikeC4Model.
|
|
387
|
+
roots(): ReadonlyArray<LikeC4Model.ElementModel<M>>;
|
|
369
388
|
/**
|
|
370
389
|
* Returns all elements in the model.
|
|
371
390
|
*/
|
|
372
|
-
elements(): ReadonlyArray<LikeC4Model.
|
|
391
|
+
elements(): ReadonlyArray<LikeC4Model.ElementModel<M>>;
|
|
373
392
|
/**
|
|
374
393
|
* Returns a specific element by its FQN.
|
|
375
394
|
*/
|
|
376
|
-
element(id: Fqn): LikeC4Model.
|
|
395
|
+
element(id: Fqn): LikeC4Model.ElementModel<M>;
|
|
377
396
|
/**
|
|
378
397
|
* Returns all relationships in the model.
|
|
379
398
|
*/
|
|
380
|
-
relationships(): ReadonlyArray<LikeC4Model.Relationship
|
|
399
|
+
relationships(): ReadonlyArray<LikeC4Model.Relationship<M>>;
|
|
381
400
|
/**
|
|
382
401
|
* Returns a specific relationship by its ID.
|
|
383
402
|
*/
|
|
384
|
-
relationship(id: RelationID): LikeC4Model.Relationship
|
|
403
|
+
relationship(id: RelationID): LikeC4Model.Relationship<M>;
|
|
385
404
|
/**
|
|
386
405
|
* Returns all views in the model.
|
|
387
406
|
*/
|
|
388
|
-
views(): ReadonlyArray<
|
|
407
|
+
views(): ReadonlyArray<M>;
|
|
389
408
|
/**
|
|
390
409
|
* Returns a specific view by its ID.
|
|
391
410
|
*/
|
|
392
|
-
view(viewId: ViewID):
|
|
411
|
+
view(viewId: ViewID): M;
|
|
393
412
|
/**
|
|
394
413
|
* Returns the parent element of given element.
|
|
395
414
|
* @see ancestors
|
|
396
415
|
*/
|
|
397
|
-
parent(element: ElementOrFqn): LikeC4Model.
|
|
416
|
+
parent(element: ElementOrFqn): LikeC4Model.ElementModel<M> | null;
|
|
398
417
|
/**
|
|
399
418
|
* Get all children of the element (only direct children),
|
|
400
419
|
* @see descendants
|
|
401
420
|
*/
|
|
402
|
-
children(element: ElementOrFqn): ReadonlyArray<LikeC4Model.
|
|
421
|
+
children(element: ElementOrFqn): ReadonlyArray<LikeC4Model.ElementModel<M>>;
|
|
403
422
|
/**
|
|
404
423
|
* Get all sibling (i.e. same parent)
|
|
405
424
|
*/
|
|
406
|
-
siblings(element: ElementOrFqn): ReadonlyArray<LikeC4Model.
|
|
425
|
+
siblings(element: ElementOrFqn): ReadonlyArray<LikeC4Model.ElementModel<M>>;
|
|
407
426
|
/**
|
|
408
427
|
* Get all ancestor elements (i.e. parent, parent’s parent, etc.)
|
|
409
428
|
* (from closest to root)
|
|
410
429
|
*/
|
|
411
|
-
ancestors(element: ElementOrFqn): ReadonlyArray<LikeC4Model.
|
|
430
|
+
ancestors(element: ElementOrFqn): ReadonlyArray<LikeC4Model.ElementModel<M>>;
|
|
412
431
|
/**
|
|
413
432
|
* Get all descendant elements (i.e. children, children’s children, etc.)
|
|
414
433
|
*/
|
|
415
|
-
descendants(element: ElementOrFqn): ReadonlyArray<LikeC4Model.
|
|
434
|
+
descendants(element: ElementOrFqn): ReadonlyArray<LikeC4Model.ElementModel<M>>;
|
|
416
435
|
/**
|
|
417
436
|
* Incoming relationships to the element and its descendants
|
|
418
437
|
* @see incomers
|
|
419
438
|
*/
|
|
420
|
-
incoming(element: ElementOrFqn, filter?:
|
|
439
|
+
incoming(element: ElementOrFqn, filter?: IncomingFilter): ReadonlyArray<LikeC4Model.Relationship<M>>;
|
|
421
440
|
/**
|
|
422
441
|
* Source elements of incoming relationships
|
|
423
442
|
*/
|
|
424
|
-
incomers(element: ElementOrFqn, filter?:
|
|
443
|
+
incomers(element: ElementOrFqn, filter?: IncomingFilter): ReadonlyArray<LikeC4Model.ElementModel<M>>;
|
|
425
444
|
/**
|
|
426
445
|
* Outgoing relationships from the element and its descendants
|
|
427
446
|
* @see outgoers
|
|
428
447
|
*/
|
|
429
|
-
outgoing(element: ElementOrFqn, filter?:
|
|
448
|
+
outgoing(element: ElementOrFqn, filter?: OutgoingFilter): ReadonlyArray<LikeC4Model.Relationship<M>>;
|
|
430
449
|
/**
|
|
431
450
|
* Target elements of outgoing relationships
|
|
432
451
|
*/
|
|
433
|
-
outgoers(element: ElementOrFqn, filter?:
|
|
452
|
+
outgoers(element: ElementOrFqn, filter?: OutgoingFilter): ReadonlyArray<LikeC4Model.ElementModel<M>>;
|
|
434
453
|
/**
|
|
435
454
|
* Relationships inside the element, among descendants
|
|
436
455
|
*/
|
|
437
|
-
internal(element: ElementOrFqn): ReadonlyArray<LikeC4Model.Relationship
|
|
456
|
+
internal(element: ElementOrFqn): ReadonlyArray<LikeC4Model.Relationship<M>>;
|
|
438
457
|
/**
|
|
439
458
|
* Resolve siblings of the element and siblings of ancestors
|
|
440
459
|
* (from closest to root)
|
|
441
460
|
*/
|
|
442
|
-
ascendingSiblings(element: ElementOrFqn): ReadonlyArray<LikeC4Model.
|
|
461
|
+
ascendingSiblings(element: ElementOrFqn): ReadonlyArray<LikeC4Model.ElementModel<M>>;
|
|
443
462
|
/**
|
|
444
463
|
* Resolve all views that contain the element
|
|
445
464
|
*/
|
|
446
|
-
viewsWithElement(element: ElementOrFqn): ReadonlyArray<
|
|
465
|
+
viewsWithElement(element: ElementOrFqn): ReadonlyArray<M>;
|
|
447
466
|
private addElement;
|
|
448
467
|
private addRelation;
|
|
449
468
|
private _childrenOf;
|
|
@@ -452,10 +471,43 @@ declare class LikeC4Model {
|
|
|
452
471
|
private _internalOf;
|
|
453
472
|
}
|
|
454
473
|
declare namespace LikeC4Model {
|
|
455
|
-
|
|
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> {
|
|
456
508
|
readonly element: Element;
|
|
457
509
|
private model;
|
|
458
|
-
constructor(element: Element, model: LikeC4Model);
|
|
510
|
+
constructor(element: Element, model: LikeC4Model<M>);
|
|
459
511
|
get id(): Fqn$1;
|
|
460
512
|
get title(): string;
|
|
461
513
|
get kind(): ElementKind;
|
|
@@ -464,37 +516,116 @@ declare namespace LikeC4Model {
|
|
|
464
516
|
get shape(): ElementShape;
|
|
465
517
|
get color(): Color;
|
|
466
518
|
get tags(): Tag[];
|
|
467
|
-
parent():
|
|
519
|
+
parent(): ElementModel<M> | null;
|
|
468
520
|
metadata(key: string): string | undefined;
|
|
469
521
|
metadata(key: string, defaultValue: string): string;
|
|
470
522
|
hasMetadata(key: string): boolean;
|
|
471
|
-
ancestors(): readonly
|
|
472
|
-
siblings(): readonly
|
|
473
|
-
descendants(): readonly
|
|
474
|
-
children(): readonly
|
|
523
|
+
ancestors(): readonly ElementModel<M>[];
|
|
524
|
+
siblings(): readonly ElementModel<M>[];
|
|
525
|
+
descendants(): readonly ElementModel<M>[];
|
|
526
|
+
children(): readonly ElementModel<M>[];
|
|
475
527
|
/**
|
|
476
528
|
* Views that contain this element
|
|
477
529
|
*/
|
|
478
|
-
views(): readonly
|
|
479
|
-
incoming(filter?:
|
|
480
|
-
incomers(filter?:
|
|
481
|
-
outgoing(filter?:
|
|
482
|
-
outgoers(filter?:
|
|
483
|
-
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>[];
|
|
484
536
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
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;
|
|
490
588
|
get title(): string;
|
|
491
|
-
get kind():
|
|
589
|
+
get kind(): ElementKind;
|
|
590
|
+
get isRoot(): boolean;
|
|
591
|
+
get hasNested(): boolean;
|
|
592
|
+
get shape(): ElementShape;
|
|
593
|
+
get color(): Color;
|
|
492
594
|
get tags(): Tag[];
|
|
493
|
-
get
|
|
494
|
-
get
|
|
595
|
+
get level(): number;
|
|
596
|
+
get depth(): number;
|
|
597
|
+
model(): LikeC4Model.ElementModel<LikeC4DiagramModel>;
|
|
598
|
+
parent(): LikeC4DiagramModel.Element | null;
|
|
495
599
|
metadata(key: string): string | undefined;
|
|
496
600
|
metadata(key: string, defaultValue: string): string;
|
|
497
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>>;
|
|
498
629
|
}
|
|
499
630
|
}
|
|
500
631
|
|
|
@@ -547,179 +678,6 @@ declare function sortNaturalByFqn<T extends {
|
|
|
547
678
|
id: string;
|
|
548
679
|
}, A extends IterableContainer$1<T>>(array: A): ReorderedArray<A>;
|
|
549
680
|
|
|
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
681
|
/**
|
|
724
682
|
* This should only be used for defining generics which extend any kind of JS
|
|
725
683
|
* array under the hood, this includes arrays *AND* tuples (of the form [x, y],
|
|
@@ -800,7 +758,9 @@ declare function hasAtLeast(minimum: number): (data: IterableContainer) => boole
|
|
|
800
758
|
declare function isString(value: unknown): value is string;
|
|
801
759
|
declare function isNonEmptyArray<A>(arr: ArrayLike<A> | undefined): arr is NonEmptyArray<A>;
|
|
802
760
|
|
|
803
|
-
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>;
|
|
804
764
|
|
|
805
765
|
/**
|
|
806
766
|
* Compares two relations hierarchically.
|
|
@@ -811,4 +771,4 @@ declare const compareRelations: <T extends {
|
|
|
811
771
|
target: string;
|
|
812
772
|
}>(a: T, b: T) => 0 | 1 | -1;
|
|
813
773
|
|
|
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 };
|
|
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 };
|