@likec4/core 1.19.1 → 1.20.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/builder/index.cjs +881 -0
- package/dist/builder/index.d.cts +503 -0
- package/dist/builder/index.d.mts +5 -4
- package/dist/builder/index.d.ts +5 -4
- package/dist/builder/{index.js → index.mjs} +14 -4
- package/dist/compute-view/index.cjs +86 -0
- package/dist/compute-view/index.d.cts +23 -0
- package/dist/compute-view/index.d.mts +3 -2
- package/dist/compute-view/index.d.ts +3 -2
- package/dist/compute-view/{index.js → index.mjs} +6 -5
- package/dist/index.cjs +4320 -0
- package/dist/index.d.cts +270 -0
- package/dist/index.d.mts +130 -4
- package/dist/index.d.ts +130 -4
- package/dist/{index.js → index.mjs} +512 -7
- package/dist/model/index.cjs +40 -0
- package/dist/model/index.d.cts +259 -0
- package/dist/model/index.d.mts +8 -3
- package/dist/model/index.d.ts +8 -3
- package/dist/model/index.mjs +1 -0
- package/dist/shared/core.B2QYWlYe.cjs +435 -0
- package/dist/shared/core.B72vUaNB.d.cts +850 -0
- package/dist/shared/core.BGus30EM.cjs +8027 -0
- package/dist/shared/core.BRuJ3Wzf.d.mts +12 -0
- package/dist/shared/{core.BZ9Msq7w.d.mts → core.BdbFkE_p.d.cts} +14 -4
- package/dist/shared/core.BvdNMbcA.d.cts +12 -0
- package/dist/shared/{object_hash.CE_oF3I3.js → core.BxvDITEI.mjs} +26 -389
- package/dist/shared/core.ByNgh-mC.d.cts +127 -0
- package/dist/shared/core.C9DCnJh8.cjs +908 -0
- package/dist/shared/{index.DafVOuVd.js → core.CqCTxzMY.mjs} +1111 -572
- package/dist/shared/core.D74xkKkG.d.cts +148 -0
- package/dist/shared/{core.C05RDLhi.d.ts → core.D_Gc58Gt.d.ts} +23 -5
- package/dist/shared/core.Damrzla-.d.ts +12 -0
- package/dist/shared/{core.CmYMqgha.d.mts → core.Dfzrh1VA.d.mts} +23 -5
- package/dist/shared/core.DsoCu540.cjs +26 -0
- package/dist/shared/{view.CyZrG8BJ.js → core.DunIMHRf.mjs} +27 -1
- package/dist/shared/{core.BIfgabEw.d.ts → core.ZWiGANIJ.d.ts} +14 -4
- package/dist/shared/core.gv1bMwCC.cjs +39 -0
- package/dist/shared/core.jy6z2iRn.d.mts +729 -0
- package/dist/shared/core.m3rCQAv6.mjs +37 -0
- package/dist/types/index.cjs +107 -0
- package/dist/types/index.d.cts +72 -0
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/{index.js → index.mjs} +1 -1
- package/dist/utils/index.cjs +95 -0
- package/dist/utils/index.d.cts +356 -0
- package/dist/utils/index.d.mts +1 -64
- package/dist/utils/index.d.ts +1 -64
- package/dist/utils/index.mjs +56 -0
- package/package.json +52 -26
- package/src/builder/Builder.view-common.ts +21 -1
- package/src/compute-view/deployment-view/__test__/fixture.ts +31 -3
- package/src/compute-view/deployment-view/_types.ts +2 -1
- package/src/compute-view/deployment-view/compute.ts +4 -36
- package/src/compute-view/deployment-view/predicates/index.ts +8 -0
- package/src/compute-view/deployment-view/predicates/relation-direct.ts +125 -99
- package/src/compute-view/deployment-view/predicates/relation-in-out.ts +16 -8
- package/src/compute-view/deployment-view/predicates/relation-incoming.ts +18 -12
- package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +16 -9
- package/src/compute-view/deployment-view/predicates/relation-where.ts +18 -0
- package/src/compute-view/deployment-view/predicates/utils.ts +214 -0
- package/src/compute-view/element-view/__test__/fixture.ts +17 -4
- package/src/compute-view/element-view/compute.ts +3 -2
- package/src/compute-view/element-view/predicates.ts +520 -0
- package/src/compute-view/element-view/utils.ts +11 -7
- package/src/compute-view/index.ts +1 -0
- package/src/compute-view/relationships-view/_types.ts +16 -0
- package/src/compute-view/relationships-view/compute.ts +74 -0
- package/src/compute-view/relationships-view/layout.ts +357 -0
- package/src/compute-view/relationships-view/utils.ts +40 -0
- package/src/compute-view/utils/relationExpressionToPredicates.ts +11 -4
- package/src/index.ts +16 -0
- package/src/model/DeploymentElementModel.ts +18 -1
- package/src/model/ElementModel.ts +13 -0
- package/src/model/LikeC4Model.ts +2 -2
- package/src/model/RelationModel.ts +9 -0
- package/src/model/connection/deployment/DeploymentConnectionModel.ts +11 -1
- package/src/model/guards.ts +17 -1
- package/src/model/view/LikeC4ViewModel.ts +7 -1
- package/src/model/view/NodeModel.ts +5 -0
- package/src/types/deployments.ts +1 -0
- package/src/types/expression-v2.ts +12 -0
- package/src/types/index.ts +1 -0
- package/src/types/operators.ts +46 -6
- package/src/types/view.ts +2 -2
- package/src/utils/index.ts +0 -5
- package/src/utils/iterable/unique.ts +1 -7
- package/dist/model/index.js +0 -1
- package/dist/utils/index.js +0 -347
- /package/dist/shared/{chunk-RAAYCPUM.M-JWF7SS.js → core.M-JWF7SS.mjs} +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { L as LikeC4Model, E as ElementModel, R as RelationshipModel } from './core.jy6z2iRn.mjs';
|
|
2
|
+
import { F as Fqn } from './core.D74xkKkG.mjs';
|
|
3
|
+
|
|
4
|
+
declare function computeRelationshipsView(subjectId: Fqn, likec4model: LikeC4Model): {
|
|
5
|
+
incomers: Set<ElementModel<LikeC4Model.Any>>;
|
|
6
|
+
incoming: Set<RelationshipModel<LikeC4Model.Any>>;
|
|
7
|
+
subjects: Set<ElementModel<LikeC4Model.Any>>;
|
|
8
|
+
outgoing: Set<RelationshipModel<LikeC4Model.Any>>;
|
|
9
|
+
outgoers: Set<ElementModel<LikeC4Model.Any>>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { computeRelationshipsView as c };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IsStringLiteral, LiteralUnion, Simplify, SetRequired } from 'type-fest';
|
|
2
|
-
import { C as ComputedView, L as LikeC4View, a9 as ParsedLikeC4Model, a as ComputedLikeC4Model,
|
|
3
|
-
import { F as Fqn, K as KeysOf, f as ElementKind, l as ElementShape, s as Color, o as Tag, n as Link, a as IteratorLike, x as ThemeColor, i as Element } from './core.D74xkKkG.
|
|
2
|
+
import { C as ComputedView, L as LikeC4View, a9 as ParsedLikeC4Model, a as ComputedLikeC4Model, bk as ViewId, au as RelationId, bf as NodeId, bc as EdgeId, a6 as GenericLikeC4Model, a7 as LayoutedLikeC4Model, b5 as DiagramView, a8 as LikeC4ModelDump, f as DeploymentNodeKind, aY as ComputedDynamicView, bh as StepEdgeId, a_ as ComputedElementView, aX as ComputedDeploymentView, at as ModelRelation, a5 as AnyParsedLikeC4Model, a4 as ModelGlobals, h as DeploymentRef, d as DeploymentNode, b as DeployedInstance, c as DeploymentElementStyle, i as DeploymentRelation, aw as RelationshipKind } from './core.B72vUaNB.cjs';
|
|
3
|
+
import { F as Fqn, K as KeysOf, f as ElementKind, l as ElementShape, s as Color, I as IconUrl, o as Tag, n as Link, a as IteratorLike, x as ThemeColor, i as Element } from './core.D74xkKkG.cjs';
|
|
4
4
|
|
|
5
5
|
type ComputeViewResult<V extends ComputedView = ComputedView> = {
|
|
6
6
|
isSuccess: true;
|
|
@@ -90,6 +90,7 @@ declare class NodeModel<M extends AnyAux, V extends ComputedView | DiagramView =
|
|
|
90
90
|
get deployment(): DeploymentElementModel<M> | null;
|
|
91
91
|
get shape(): ElementShape;
|
|
92
92
|
get color(): Color;
|
|
93
|
+
get icon(): IconUrl | null;
|
|
93
94
|
get tags(): ReadonlyArray<Tag>;
|
|
94
95
|
get links(): ReadonlyArray<Link>;
|
|
95
96
|
get navigateTo(): LikeC4ViewModel<M> | null;
|
|
@@ -185,6 +186,7 @@ declare class LikeC4ViewModel<M extends AnyAux, V extends ComputedView | Diagram
|
|
|
185
186
|
* Find node by id.
|
|
186
187
|
*/
|
|
187
188
|
findNode(node: M['NodeOrId']): NodeModel<M, V> | null;
|
|
189
|
+
findNodeWithElement(fqn: M['Element']): NodeModel.WithElement<M, V> | null;
|
|
188
190
|
/**
|
|
189
191
|
* Iterate over all nodes.
|
|
190
192
|
*/
|
|
@@ -240,11 +242,13 @@ declare class RelationshipModel<M extends AnyAux = AnyAux> {
|
|
|
240
242
|
get description(): string | null;
|
|
241
243
|
get navigateTo(): LikeC4ViewModel<M> | null;
|
|
242
244
|
get tags(): ReadonlyArray<Tag>;
|
|
245
|
+
get kind(): string | null;
|
|
243
246
|
get links(): ReadonlyArray<Link>;
|
|
244
247
|
/**
|
|
245
248
|
* Iterate over all views that include this relationship.
|
|
246
249
|
*/
|
|
247
250
|
views(): ViewsIterator<M>;
|
|
251
|
+
isDeploymentRelation(): this is DeploymentRelationModel<M>;
|
|
248
252
|
}
|
|
249
253
|
|
|
250
254
|
declare class LikeC4Model<M extends AnyAux = LikeC4Model.Any> {
|
|
@@ -325,7 +329,7 @@ declare class LikeC4Model<M extends AnyAux = LikeC4Model.Any> {
|
|
|
325
329
|
* Returns a specific view by its ID.
|
|
326
330
|
*/
|
|
327
331
|
view(viewId: M['View']): LikeC4ViewModel<M>;
|
|
328
|
-
findView(viewId: M['View']): LikeC4ViewModel<M
|
|
332
|
+
findView(viewId: M['View']): LikeC4ViewModel<M> | null;
|
|
329
333
|
/**
|
|
330
334
|
* Returns the parent element of given element.
|
|
331
335
|
* @see ancestors
|
|
@@ -474,6 +478,7 @@ declare abstract class AbstractDeploymentElementModel<M extends AnyAux = AnyAux>
|
|
|
474
478
|
get shape(): ElementShape;
|
|
475
479
|
get color(): ThemeColor;
|
|
476
480
|
get tags(): ReadonlyArray<Tag>;
|
|
481
|
+
get kind(): DeploymentNodeKind | string | null;
|
|
477
482
|
get description(): string | null;
|
|
478
483
|
get technology(): string | null;
|
|
479
484
|
get links(): ReadonlyArray<Link>;
|
|
@@ -574,6 +579,7 @@ declare class DeployedInstanceModel<M extends AnyAux = AnyAux> extends AbstractD
|
|
|
574
579
|
get shape(): ElementShape;
|
|
575
580
|
get color(): ThemeColor;
|
|
576
581
|
get tags(): ReadonlyArray<Tag>;
|
|
582
|
+
get kind(): string | null;
|
|
577
583
|
get description(): string | null;
|
|
578
584
|
get technology(): string | null;
|
|
579
585
|
get links(): ReadonlyArray<Link>;
|
|
@@ -614,9 +620,11 @@ declare class DeploymentRelationModel<M extends AnyAux = AnyAux> {
|
|
|
614
620
|
get technology(): string | null;
|
|
615
621
|
get description(): string | null;
|
|
616
622
|
get tags(): ReadonlyArray<Tag>;
|
|
623
|
+
get kind(): RelationshipKind | null;
|
|
617
624
|
get navigateTo(): LikeC4ViewModel<M> | null;
|
|
618
625
|
get links(): ReadonlyArray<Link>;
|
|
619
626
|
views(): IteratorLike<LikeC4ViewModel<M, ComputedDeploymentView>>;
|
|
627
|
+
isDeploymentRelation(): this is DeploymentRelationModel<M>;
|
|
620
628
|
}
|
|
621
629
|
declare class RelationshipsAccum<M extends AnyAux> {
|
|
622
630
|
readonly model: ReadonlySet<RelationshipModel<M>>;
|
|
@@ -656,12 +664,14 @@ declare class ElementModel<M extends AnyAux = AnyAux> {
|
|
|
656
664
|
get kind(): ElementKind;
|
|
657
665
|
get shape(): ElementShape;
|
|
658
666
|
get color(): ThemeColor;
|
|
667
|
+
get icon(): IconUrl | null;
|
|
659
668
|
get tags(): ReadonlyArray<Tag>;
|
|
660
669
|
get title(): string;
|
|
661
670
|
get description(): string | null;
|
|
662
671
|
get technology(): string | null;
|
|
663
672
|
get links(): ReadonlyArray<Link>;
|
|
664
673
|
get defaultView(): LikeC4ViewModel<M> | null;
|
|
674
|
+
get isRoot(): boolean;
|
|
665
675
|
isAncestorOf(another: ElementModel<M>): boolean;
|
|
666
676
|
isDescendantOf(another: ElementModel<M>): boolean;
|
|
667
677
|
/**
|
|
@@ -716,4 +726,4 @@ declare class ElementModel<M extends AnyAux = AnyAux> {
|
|
|
716
726
|
deployments(): DeployedInstancesIterator<M>;
|
|
717
727
|
}
|
|
718
728
|
|
|
719
|
-
export { type AnyAux as A, type ComputeViewResult as C, type DeploymentElementModel as D, ElementModel as E,
|
|
729
|
+
export { type AnyAux as A, type ComputeViewResult as C, type DeploymentElementModel as D, ElementModel as E, LikeC4Model as L, NodeModel as N, RelationshipModel as R, computeViews as a, Aux as b, computeView as c, LikeC4DeploymentModel as d, LikeC4ViewModel as e, DeploymentNodeModel as f, DeployedInstanceModel as g, RelationshipsAccum as h, DeploymentRelationModel as i, EdgeModel as j, unsafeComputeView as u };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { L as LikeC4Model, E as ElementModel, R as RelationshipModel } from './core.BdbFkE_p.cjs';
|
|
2
|
+
import { F as Fqn } from './core.D74xkKkG.cjs';
|
|
3
|
+
|
|
4
|
+
declare function computeRelationshipsView(subjectId: Fqn, likec4model: LikeC4Model): {
|
|
5
|
+
incomers: Set<ElementModel<LikeC4Model.Any>>;
|
|
6
|
+
incoming: Set<RelationshipModel<LikeC4Model.Any>>;
|
|
7
|
+
subjects: Set<ElementModel<LikeC4Model.Any>>;
|
|
8
|
+
outgoing: Set<RelationshipModel<LikeC4Model.Any>>;
|
|
9
|
+
outgoers: Set<ElementModel<LikeC4Model.Any>>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { computeRelationshipsView as c };
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { u as u$1, i as invariant } from './
|
|
1
|
+
import { u as u$1, i as invariant } from './core.M-JWF7SS.mjs';
|
|
2
2
|
|
|
3
|
-
function
|
|
3
|
+
function getDefaultExportFromCjs (x) {
|
|
4
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
5
|
+
}
|
|
4
6
|
|
|
5
|
-
var e={done:!0,hasNext:!1},s={done:!1,hasNext:!1},a=()=>e;
|
|
7
|
+
var e={done:!0,hasNext:!1},s={done:!1,hasNext:!1},a$1=()=>e;
|
|
6
8
|
|
|
7
9
|
function x(t,...o){let n=t,u=o.map(e=>"lazy"in e?f(e):void 0),p=0;for(;p<o.length;){if(u[p]===void 0||!B(n)){let i=o[p];n=i(n),p+=1;continue}let r=[];for(let i=p;i<o.length;i++){let l=u[i];if(l===void 0||(r.push(l),l.isSingle))break}let a=[];for(let i of n)if(A(i,a,r))break;let{isSingle:y}=r.at(-1);n=y?a[0]:a,p+=r.length;}return n}function A(t,o,n){if(n.length===0)return o.push(t),!1;let u=t,p=s,e=!1;for(let[r,a]of n.entries()){let{index:y,items:i}=a;if(i.push(u),p=a(u,y,i),a.index+=1,p.hasNext){if(p.hasMany??!1){for(let l of p.next)if(A(l,o,n.slice(r+1)))return !0;return e}u=p.next;}if(!p.hasNext)break;p.done&&(e=!0);}return p.hasNext&&o.push(u),e}function f(t){let{lazy:o,lazyArgs:n}=t,u=o(...n);return Object.assign(u,{isSingle:o.single??!1,index:0,items:[]})}function B(t){return typeof t=="string"||typeof t=="object"&&t!==null&&Symbol.iterator in t}
|
|
8
10
|
|
|
11
|
+
function d(...e){return u$1(a,e,o$1)}var a=(e,n)=>e.length<n.length?e.map((t,r)=>[t,n[r]]):n.map((t,r)=>[e[r],t]),o$1=e=>(n,t)=>({hasNext:!0,next:[n,e[t]],done:t>=e.length-1});
|
|
12
|
+
|
|
9
13
|
function i$1(...e){return u$1(r,e)}var r=(e,t)=>e.length>=t;
|
|
10
14
|
|
|
11
15
|
function u(...e){return u$1(i,e)}function i(e,a){let n=[];for(let[o,r]of e.entries()){if(!a(r,o,e))break;n.push(r);}return n}
|
|
@@ -20,384 +24,6 @@ function l(n){return n!=null}
|
|
|
20
24
|
|
|
21
25
|
function n(e){return e!==void 0}
|
|
22
26
|
|
|
23
|
-
function getDefaultExportFromCjs (x) {
|
|
24
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Mnemonist DefaultMap
|
|
29
|
-
* =====================
|
|
30
|
-
*
|
|
31
|
-
* JavaScript implementation of a default map that will return a constructed
|
|
32
|
-
* value any time one tries to access an inexisting key. It's quite similar
|
|
33
|
-
* to python's defaultdict.
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
var defaultMap;
|
|
37
|
-
var hasRequiredDefaultMap;
|
|
38
|
-
|
|
39
|
-
function requireDefaultMap () {
|
|
40
|
-
if (hasRequiredDefaultMap) return defaultMap;
|
|
41
|
-
hasRequiredDefaultMap = 1;
|
|
42
|
-
/**
|
|
43
|
-
* DefaultMap.
|
|
44
|
-
*
|
|
45
|
-
* @constructor
|
|
46
|
-
*/
|
|
47
|
-
function DefaultMap(factory) {
|
|
48
|
-
if (typeof factory !== 'function')
|
|
49
|
-
throw new Error('mnemonist/DefaultMap.constructor: expecting a function.');
|
|
50
|
-
|
|
51
|
-
this.items = new Map();
|
|
52
|
-
this.factory = factory;
|
|
53
|
-
this.size = 0;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Method used to clear the structure.
|
|
58
|
-
*
|
|
59
|
-
* @return {undefined}
|
|
60
|
-
*/
|
|
61
|
-
DefaultMap.prototype.clear = function() {
|
|
62
|
-
|
|
63
|
-
// Properties
|
|
64
|
-
this.items.clear();
|
|
65
|
-
this.size = 0;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Method used to get the value set for given key. If the key does not exist,
|
|
70
|
-
* the value will be created using the provided factory.
|
|
71
|
-
*
|
|
72
|
-
* @param {any} key - Target key.
|
|
73
|
-
* @return {any}
|
|
74
|
-
*/
|
|
75
|
-
DefaultMap.prototype.get = function(key) {
|
|
76
|
-
var value = this.items.get(key);
|
|
77
|
-
|
|
78
|
-
if (typeof value === 'undefined') {
|
|
79
|
-
value = this.factory(key, this.size);
|
|
80
|
-
this.items.set(key, value);
|
|
81
|
-
this.size++;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return value;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Method used to get the value set for given key. If the key does not exist,
|
|
89
|
-
* a value won't be created.
|
|
90
|
-
*
|
|
91
|
-
* @param {any} key - Target key.
|
|
92
|
-
* @return {any}
|
|
93
|
-
*/
|
|
94
|
-
DefaultMap.prototype.peek = function(key) {
|
|
95
|
-
return this.items.get(key);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Method used to set a value for given key.
|
|
100
|
-
*
|
|
101
|
-
* @param {any} key - Target key.
|
|
102
|
-
* @param {any} value - Value.
|
|
103
|
-
* @return {DefaultMap}
|
|
104
|
-
*/
|
|
105
|
-
DefaultMap.prototype.set = function(key, value) {
|
|
106
|
-
this.items.set(key, value);
|
|
107
|
-
this.size = this.items.size;
|
|
108
|
-
|
|
109
|
-
return this;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Method used to test the existence of a key in the map.
|
|
114
|
-
*
|
|
115
|
-
* @param {any} key - Target key.
|
|
116
|
-
* @return {boolean}
|
|
117
|
-
*/
|
|
118
|
-
DefaultMap.prototype.has = function(key) {
|
|
119
|
-
return this.items.has(key);
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Method used to delete target key.
|
|
124
|
-
*
|
|
125
|
-
* @param {any} key - Target key.
|
|
126
|
-
* @return {boolean}
|
|
127
|
-
*/
|
|
128
|
-
DefaultMap.prototype.delete = function(key) {
|
|
129
|
-
var deleted = this.items.delete(key);
|
|
130
|
-
|
|
131
|
-
this.size = this.items.size;
|
|
132
|
-
|
|
133
|
-
return deleted;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Method used to iterate over each of the key/value pairs.
|
|
138
|
-
*
|
|
139
|
-
* @param {function} callback - Function to call for each item.
|
|
140
|
-
* @param {object} scope - Optional scope.
|
|
141
|
-
* @return {undefined}
|
|
142
|
-
*/
|
|
143
|
-
DefaultMap.prototype.forEach = function(callback, scope) {
|
|
144
|
-
scope = arguments.length > 1 ? scope : this;
|
|
145
|
-
|
|
146
|
-
this.items.forEach(callback, scope);
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Iterators.
|
|
151
|
-
*/
|
|
152
|
-
DefaultMap.prototype.entries = function() {
|
|
153
|
-
return this.items.entries();
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
DefaultMap.prototype.keys = function() {
|
|
157
|
-
return this.items.keys();
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
DefaultMap.prototype.values = function() {
|
|
161
|
-
return this.items.values();
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Attaching the #.entries method to Symbol.iterator if possible.
|
|
166
|
-
*/
|
|
167
|
-
if (typeof Symbol !== 'undefined')
|
|
168
|
-
DefaultMap.prototype[Symbol.iterator] = DefaultMap.prototype.entries;
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Convenience known methods.
|
|
172
|
-
*/
|
|
173
|
-
DefaultMap.prototype.inspect = function() {
|
|
174
|
-
return this.items;
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
if (typeof Symbol !== 'undefined')
|
|
178
|
-
DefaultMap.prototype[Symbol.for('nodejs.util.inspect.custom')] = DefaultMap.prototype.inspect;
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Typical factories.
|
|
182
|
-
*/
|
|
183
|
-
DefaultMap.autoIncrement = function() {
|
|
184
|
-
var i = 0;
|
|
185
|
-
|
|
186
|
-
return function() {
|
|
187
|
-
return i++;
|
|
188
|
-
};
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Exporting.
|
|
193
|
-
*/
|
|
194
|
-
defaultMap = DefaultMap;
|
|
195
|
-
return defaultMap;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
var defaultMapExports = requireDefaultMap();
|
|
199
|
-
const DefaultMap = /*@__PURE__*/getDefaultExportFromCjs(defaultMapExports);
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Obliterator Iterator Class
|
|
203
|
-
* ===========================
|
|
204
|
-
*
|
|
205
|
-
* Simple class representing the library's iterators.
|
|
206
|
-
*/
|
|
207
|
-
|
|
208
|
-
var iterator;
|
|
209
|
-
var hasRequiredIterator;
|
|
210
|
-
|
|
211
|
-
function requireIterator () {
|
|
212
|
-
if (hasRequiredIterator) return iterator;
|
|
213
|
-
hasRequiredIterator = 1;
|
|
214
|
-
/**
|
|
215
|
-
* Iterator class.
|
|
216
|
-
*
|
|
217
|
-
* @constructor
|
|
218
|
-
* @param {function} next - Next function.
|
|
219
|
-
*/
|
|
220
|
-
function Iterator(next) {
|
|
221
|
-
if (typeof next !== 'function')
|
|
222
|
-
throw new Error('obliterator/iterator: expecting a function!');
|
|
223
|
-
|
|
224
|
-
this.next = next;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* If symbols are supported, we add `next` to `Symbol.iterator`.
|
|
229
|
-
*/
|
|
230
|
-
if (typeof Symbol !== 'undefined')
|
|
231
|
-
Iterator.prototype[Symbol.iterator] = function () {
|
|
232
|
-
return this;
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Returning an iterator of the given values.
|
|
237
|
-
*
|
|
238
|
-
* @param {any...} values - Values.
|
|
239
|
-
* @return {Iterator}
|
|
240
|
-
*/
|
|
241
|
-
Iterator.of = function () {
|
|
242
|
-
var args = arguments,
|
|
243
|
-
l = args.length,
|
|
244
|
-
i = 0;
|
|
245
|
-
|
|
246
|
-
return new Iterator(function () {
|
|
247
|
-
if (i >= l) return {done: true};
|
|
248
|
-
|
|
249
|
-
return {done: false, value: args[i++]};
|
|
250
|
-
});
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Returning an empty iterator.
|
|
255
|
-
*
|
|
256
|
-
* @return {Iterator}
|
|
257
|
-
*/
|
|
258
|
-
Iterator.empty = function () {
|
|
259
|
-
var iterator = new Iterator(function () {
|
|
260
|
-
return {done: true};
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
return iterator;
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Returning an iterator over the given indexed sequence.
|
|
268
|
-
*
|
|
269
|
-
* @param {string|Array} sequence - Target sequence.
|
|
270
|
-
* @return {Iterator}
|
|
271
|
-
*/
|
|
272
|
-
Iterator.fromSequence = function (sequence) {
|
|
273
|
-
var i = 0,
|
|
274
|
-
l = sequence.length;
|
|
275
|
-
|
|
276
|
-
return new Iterator(function () {
|
|
277
|
-
if (i >= l) return {done: true};
|
|
278
|
-
|
|
279
|
-
return {done: false, value: sequence[i++]};
|
|
280
|
-
});
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Returning whether the given value is an iterator.
|
|
285
|
-
*
|
|
286
|
-
* @param {any} value - Value.
|
|
287
|
-
* @return {boolean}
|
|
288
|
-
*/
|
|
289
|
-
Iterator.is = function (value) {
|
|
290
|
-
if (value instanceof Iterator) return true;
|
|
291
|
-
|
|
292
|
-
return (
|
|
293
|
-
typeof value === 'object' &&
|
|
294
|
-
value !== null &&
|
|
295
|
-
typeof value.next === 'function'
|
|
296
|
-
);
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Exporting.
|
|
301
|
-
*/
|
|
302
|
-
iterator = Iterator;
|
|
303
|
-
return iterator;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
var support = {};
|
|
307
|
-
|
|
308
|
-
var hasRequiredSupport;
|
|
309
|
-
|
|
310
|
-
function requireSupport () {
|
|
311
|
-
if (hasRequiredSupport) return support;
|
|
312
|
-
hasRequiredSupport = 1;
|
|
313
|
-
support.ARRAY_BUFFER_SUPPORT = typeof ArrayBuffer !== 'undefined';
|
|
314
|
-
support.SYMBOL_SUPPORT = typeof Symbol !== 'undefined';
|
|
315
|
-
return support;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Obliterator ForEach Function
|
|
320
|
-
* =============================
|
|
321
|
-
*
|
|
322
|
-
* Helper function used to easily iterate over mixed values.
|
|
323
|
-
*/
|
|
324
|
-
|
|
325
|
-
var foreach;
|
|
326
|
-
var hasRequiredForeach;
|
|
327
|
-
|
|
328
|
-
function requireForeach () {
|
|
329
|
-
if (hasRequiredForeach) return foreach;
|
|
330
|
-
hasRequiredForeach = 1;
|
|
331
|
-
var support = requireSupport();
|
|
332
|
-
|
|
333
|
-
var ARRAY_BUFFER_SUPPORT = support.ARRAY_BUFFER_SUPPORT;
|
|
334
|
-
var SYMBOL_SUPPORT = support.SYMBOL_SUPPORT;
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Function able to iterate over almost any iterable JS value.
|
|
338
|
-
*
|
|
339
|
-
* @param {any} iterable - Iterable value.
|
|
340
|
-
* @param {function} callback - Callback function.
|
|
341
|
-
*/
|
|
342
|
-
foreach = function forEach(iterable, callback) {
|
|
343
|
-
var iterator, k, i, l, s;
|
|
344
|
-
|
|
345
|
-
if (!iterable) throw new Error('obliterator/forEach: invalid iterable.');
|
|
346
|
-
|
|
347
|
-
if (typeof callback !== 'function')
|
|
348
|
-
throw new Error('obliterator/forEach: expecting a callback.');
|
|
349
|
-
|
|
350
|
-
// The target is an array or a string or function arguments
|
|
351
|
-
if (
|
|
352
|
-
Array.isArray(iterable) ||
|
|
353
|
-
(ARRAY_BUFFER_SUPPORT && ArrayBuffer.isView(iterable)) ||
|
|
354
|
-
typeof iterable === 'string' ||
|
|
355
|
-
iterable.toString() === '[object Arguments]'
|
|
356
|
-
) {
|
|
357
|
-
for (i = 0, l = iterable.length; i < l; i++) callback(iterable[i], i);
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// The target has a #.forEach method
|
|
362
|
-
if (typeof iterable.forEach === 'function') {
|
|
363
|
-
iterable.forEach(callback);
|
|
364
|
-
return;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
// The target is iterable
|
|
368
|
-
if (
|
|
369
|
-
SYMBOL_SUPPORT &&
|
|
370
|
-
Symbol.iterator in iterable &&
|
|
371
|
-
typeof iterable.next !== 'function'
|
|
372
|
-
) {
|
|
373
|
-
iterable = iterable[Symbol.iterator]();
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// The target is an iterator
|
|
377
|
-
if (typeof iterable.next === 'function') {
|
|
378
|
-
iterator = iterable;
|
|
379
|
-
i = 0;
|
|
380
|
-
|
|
381
|
-
while (((s = iterator.next()), s.done !== true)) {
|
|
382
|
-
callback(s.value, i);
|
|
383
|
-
i++;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
// The target is a plain object
|
|
390
|
-
for (k in iterable) {
|
|
391
|
-
if (iterable.hasOwnProperty(k)) {
|
|
392
|
-
callback(iterable[k], k);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
return;
|
|
397
|
-
};
|
|
398
|
-
return foreach;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
27
|
function commonHead(sources, targets, equals) {
|
|
402
28
|
if (sources.length === 0 || targets.length === 0) {
|
|
403
29
|
return [];
|
|
@@ -683,6 +309,23 @@ function ifilter(arg1, arg2) {
|
|
|
683
309
|
return _filter(arg1);
|
|
684
310
|
}
|
|
685
311
|
|
|
312
|
+
function ifind(arg1, arg2) {
|
|
313
|
+
const pred = arg2 ?? arg1;
|
|
314
|
+
invariant(t(pred));
|
|
315
|
+
function _find(iter) {
|
|
316
|
+
for (const value of iter) {
|
|
317
|
+
if (pred(value)) {
|
|
318
|
+
return value;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
if (!arg2) {
|
|
324
|
+
return _find;
|
|
325
|
+
}
|
|
326
|
+
return _find(arg1);
|
|
327
|
+
}
|
|
328
|
+
|
|
686
329
|
function iflat(iterable) {
|
|
687
330
|
return iterable ? _iflat(iterable) : _iflat;
|
|
688
331
|
}
|
|
@@ -739,13 +382,7 @@ function toSet(iterable) {
|
|
|
739
382
|
}
|
|
740
383
|
|
|
741
384
|
function iunique(iterable) {
|
|
742
|
-
|
|
743
|
-
return function* () {
|
|
744
|
-
yield* _iunique(iterable);
|
|
745
|
-
return;
|
|
746
|
-
}();
|
|
747
|
-
}
|
|
748
|
-
return _iunique;
|
|
385
|
+
return iterable ? _iunique(iterable) : _iunique;
|
|
749
386
|
}
|
|
750
387
|
function* _iunique(iterable) {
|
|
751
388
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -1219,4 +856,4 @@ function requireObject_hash () {
|
|
|
1219
856
|
var object_hashExports = requireObject_hash();
|
|
1220
857
|
const objectHash = /*@__PURE__*/getDefaultExportFromCjs(object_hashExports);
|
|
1221
858
|
|
|
1222
|
-
export {
|
|
859
|
+
export { isString as A, ifilter as B, iflat as C, imap as D, isIterable as E, isome as F, iunique as G, toArray as H, difference as I, equals as J, intersection as K, symmetricDifference as L, union as M, stringHash as N, objectHash as O, x as P, s as Q, a$1 as R, u as S, d as T, n as U, hasIntersection as V, i$1 as a, t$1 as b, isSameHierarchy as c, t as d, commonHead as e, compareNatural as f, getDefaultExportFromCjs as g, ancestorsFqn as h, ifind as i, commonAncestor as j, compareByFqnHierarchically as k, l, m, nameFromFqn as n, compareFqnHierarchically as o, parentFqn as p, hierarchyDistance as q, hierarchyLevel as r, isAncestor as s, toSet as t, isDescendantOf as u, sortByFqnHierarchically as v, sortNaturalByFqn as w, sortParentsFirst as x, getOrCreate as y, isNonEmptyArray as z };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { F as Fqn } from './core.D74xkKkG.cjs';
|
|
2
|
+
|
|
3
|
+
declare function parentFqn<E extends string>(fqn: E): E | null;
|
|
4
|
+
declare function nameFromFqn<E extends string>(fqn: E): string;
|
|
5
|
+
/**
|
|
6
|
+
* Check if one element is an ancestor of another
|
|
7
|
+
* Composable version
|
|
8
|
+
* @signature
|
|
9
|
+
* isAncestor(another)(ancestor)
|
|
10
|
+
*/
|
|
11
|
+
declare function isAncestor<A extends string | {
|
|
12
|
+
id: string;
|
|
13
|
+
}>(another: NoInfer<A>): (ancestor: A) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Check if one element is an ancestor of another
|
|
16
|
+
* @signature
|
|
17
|
+
* isAncestor(ancestor, another)
|
|
18
|
+
*/
|
|
19
|
+
declare function isAncestor<A extends string | {
|
|
20
|
+
id: string;
|
|
21
|
+
}>(ancestor: A, another: A): boolean;
|
|
22
|
+
declare function isSameHierarchy<T extends string>(one: NoInfer<T> | WithId<NoInfer<T>>): (another: T | WithId<T>) => boolean;
|
|
23
|
+
declare function isSameHierarchy<T extends string>(one: T | WithId<T>, another: T | WithId<T>): boolean;
|
|
24
|
+
type WithId<T> = {
|
|
25
|
+
id: T;
|
|
26
|
+
};
|
|
27
|
+
declare function isDescendantOf<T extends string>(ancestor: WithId<T>): (descedant: WithId<T>) => boolean;
|
|
28
|
+
declare function isDescendantOf<T extends string>(descedant: WithId<T>, ancestor: WithId<T>): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* How deep in the hierarchy the element is.
|
|
31
|
+
* Root element has depth 1
|
|
32
|
+
*/
|
|
33
|
+
declare function hierarchyLevel<E extends string | {
|
|
34
|
+
id: Fqn;
|
|
35
|
+
}>(elementOfFqn: E): number;
|
|
36
|
+
/**
|
|
37
|
+
* Calculate the distance as number of steps from one element to another, i.e.
|
|
38
|
+
* going up to the common ancestor, then going down to the other element.
|
|
39
|
+
* Sibling distance is always 1
|
|
40
|
+
*
|
|
41
|
+
* Can be used for hierarchical clustering
|
|
42
|
+
*/
|
|
43
|
+
declare function hierarchyDistance<E extends string | {
|
|
44
|
+
id: Fqn;
|
|
45
|
+
}>(one: E, another: E): number;
|
|
46
|
+
declare function commonAncestor<E extends string>(first: E, second: E): E | null;
|
|
47
|
+
/**
|
|
48
|
+
* Get all ancestor elements (i.e. parent, parent’s parent, etc.)
|
|
49
|
+
* going up from parent to the root
|
|
50
|
+
*/
|
|
51
|
+
declare function ancestorsFqn<Id extends string>(fqn: Id): Id[];
|
|
52
|
+
/**
|
|
53
|
+
* Compares two fully qualified names (fqns) hierarchically based on their depth.
|
|
54
|
+
* From parent nodes to leaves
|
|
55
|
+
*
|
|
56
|
+
* @param {string} a - The first fqn to compare.
|
|
57
|
+
* @param {string} b - The second fqn to compare.
|
|
58
|
+
* @returns {number} - 0 if the fqns have the same depth.
|
|
59
|
+
* - Positive number if a is deeper than b.
|
|
60
|
+
* - Negative number if b is deeper than a.
|
|
61
|
+
*/
|
|
62
|
+
declare function compareFqnHierarchically<T extends string = string>(a: T, b: T): -1 | 0 | 1;
|
|
63
|
+
declare function compareByFqnHierarchically<T extends {
|
|
64
|
+
id: string;
|
|
65
|
+
}>(a: T, b: T): -1 | 0 | 1;
|
|
66
|
+
type IterableContainer<T = unknown> = ReadonlyArray<T> | readonly [];
|
|
67
|
+
type ReorderedArray<T extends IterableContainer> = {
|
|
68
|
+
-readonly [P in keyof T]: T[number];
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Sorts an array of objects hierarchically based on their fully qualified names (FQN).
|
|
72
|
+
* Objects are sorted by the number of segments in their FQN (defined by dot-separated ID).
|
|
73
|
+
*
|
|
74
|
+
* @typeParam T - Object type that contains an 'id' string property
|
|
75
|
+
* @typeParam A - Type extending IterableContainer of T
|
|
76
|
+
*
|
|
77
|
+
* @param array - Array of objects to be sorted
|
|
78
|
+
* @returns A new array with items sorted by their FQN hierarchy depth (number of segments)
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* const items = [
|
|
83
|
+
* { id: "a.b.c" },
|
|
84
|
+
* { id: "a" },
|
|
85
|
+
* { id: "a.b" }
|
|
86
|
+
* ];
|
|
87
|
+
* sortByFqnHierarchically(items);
|
|
88
|
+
* // Result: [
|
|
89
|
+
* // { id: "a" },
|
|
90
|
+
* // { id: "a.b" },
|
|
91
|
+
* // { id: "a.b.c" }
|
|
92
|
+
* // ]
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
declare function sortByFqnHierarchically<T extends {
|
|
96
|
+
id: string;
|
|
97
|
+
}, A extends IterableContainer<T>>(array: A): ReorderedArray<A>;
|
|
98
|
+
/**
|
|
99
|
+
* Keeps initial order of the elements, but ensures that parents are before children
|
|
100
|
+
*/
|
|
101
|
+
declare function sortParentsFirst<T extends {
|
|
102
|
+
id: string;
|
|
103
|
+
}, A extends IterableContainer<T>>(array: A): ReorderedArray<A>;
|
|
104
|
+
/**
|
|
105
|
+
* Sorts an array of objects naturally by their fully qualified name (FQN) identifier.
|
|
106
|
+
*
|
|
107
|
+
* @template T - Type of objects containing an 'id' string property
|
|
108
|
+
* @template A - Type extending IterableContainer of T
|
|
109
|
+
*
|
|
110
|
+
* @param first - Optional. Either the array to sort or the sort direction ('asc'|'desc')
|
|
111
|
+
* @param sort - Optional. The sort direction ('asc'|'desc'). Defaults to 'asc' if not specified
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* // As a function that returns a sorting function
|
|
115
|
+
* const sorted = sortNaturalByFqn('desc')(myArray);
|
|
116
|
+
*
|
|
117
|
+
* // Direct array sorting
|
|
118
|
+
* const sorted = sortNaturalByFqn(myArray, 'desc');
|
|
119
|
+
*/
|
|
120
|
+
declare function sortNaturalByFqn(sort?: 'asc' | 'desc'): <T extends {
|
|
121
|
+
id: string;
|
|
122
|
+
}, A extends IterableContainer<T>>(array: A) => ReorderedArray<A>;
|
|
123
|
+
declare function sortNaturalByFqn<T extends {
|
|
124
|
+
id: string;
|
|
125
|
+
}, A extends IterableContainer<T>>(array: A, sort?: 'asc' | 'desc'): ReorderedArray<A>;
|
|
126
|
+
|
|
127
|
+
export { type IterableContainer as I, type ReorderedArray as R, ancestorsFqn as a, compareByFqnHierarchically as b, commonAncestor as c, compareFqnHierarchically as d, hierarchyLevel as e, isDescendantOf as f, isSameHierarchy as g, hierarchyDistance as h, isAncestor as i, sortNaturalByFqn as j, sortParentsFirst as k, nameFromFqn as n, parentFqn as p, sortByFqnHierarchically as s };
|