@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.
Files changed (91) hide show
  1. package/dist/builder/index.cjs +881 -0
  2. package/dist/builder/index.d.cts +503 -0
  3. package/dist/builder/index.d.mts +5 -4
  4. package/dist/builder/index.d.ts +5 -4
  5. package/dist/builder/{index.js → index.mjs} +14 -4
  6. package/dist/compute-view/index.cjs +86 -0
  7. package/dist/compute-view/index.d.cts +23 -0
  8. package/dist/compute-view/index.d.mts +3 -2
  9. package/dist/compute-view/index.d.ts +3 -2
  10. package/dist/compute-view/{index.js → index.mjs} +6 -5
  11. package/dist/index.cjs +4320 -0
  12. package/dist/index.d.cts +270 -0
  13. package/dist/index.d.mts +130 -4
  14. package/dist/index.d.ts +130 -4
  15. package/dist/{index.js → index.mjs} +512 -7
  16. package/dist/model/index.cjs +40 -0
  17. package/dist/model/index.d.cts +259 -0
  18. package/dist/model/index.d.mts +8 -3
  19. package/dist/model/index.d.ts +8 -3
  20. package/dist/model/index.mjs +1 -0
  21. package/dist/shared/core.B2QYWlYe.cjs +435 -0
  22. package/dist/shared/core.B72vUaNB.d.cts +850 -0
  23. package/dist/shared/core.BGus30EM.cjs +8027 -0
  24. package/dist/shared/core.BRuJ3Wzf.d.mts +12 -0
  25. package/dist/shared/{core.BZ9Msq7w.d.mts → core.BdbFkE_p.d.cts} +14 -4
  26. package/dist/shared/core.BvdNMbcA.d.cts +12 -0
  27. package/dist/shared/{object_hash.CE_oF3I3.js → core.BxvDITEI.mjs} +26 -389
  28. package/dist/shared/core.ByNgh-mC.d.cts +127 -0
  29. package/dist/shared/core.C9DCnJh8.cjs +908 -0
  30. package/dist/shared/{index.DafVOuVd.js → core.CqCTxzMY.mjs} +1111 -572
  31. package/dist/shared/core.D74xkKkG.d.cts +148 -0
  32. package/dist/shared/{core.C05RDLhi.d.ts → core.D_Gc58Gt.d.ts} +23 -5
  33. package/dist/shared/core.Damrzla-.d.ts +12 -0
  34. package/dist/shared/{core.CmYMqgha.d.mts → core.Dfzrh1VA.d.mts} +23 -5
  35. package/dist/shared/core.DsoCu540.cjs +26 -0
  36. package/dist/shared/{view.CyZrG8BJ.js → core.DunIMHRf.mjs} +27 -1
  37. package/dist/shared/{core.BIfgabEw.d.ts → core.ZWiGANIJ.d.ts} +14 -4
  38. package/dist/shared/core.gv1bMwCC.cjs +39 -0
  39. package/dist/shared/core.jy6z2iRn.d.mts +729 -0
  40. package/dist/shared/core.m3rCQAv6.mjs +37 -0
  41. package/dist/types/index.cjs +107 -0
  42. package/dist/types/index.d.cts +72 -0
  43. package/dist/types/index.d.mts +2 -2
  44. package/dist/types/index.d.ts +2 -2
  45. package/dist/types/{index.js → index.mjs} +1 -1
  46. package/dist/utils/index.cjs +95 -0
  47. package/dist/utils/index.d.cts +356 -0
  48. package/dist/utils/index.d.mts +1 -64
  49. package/dist/utils/index.d.ts +1 -64
  50. package/dist/utils/index.mjs +56 -0
  51. package/package.json +52 -26
  52. package/src/builder/Builder.view-common.ts +21 -1
  53. package/src/compute-view/deployment-view/__test__/fixture.ts +31 -3
  54. package/src/compute-view/deployment-view/_types.ts +2 -1
  55. package/src/compute-view/deployment-view/compute.ts +4 -36
  56. package/src/compute-view/deployment-view/predicates/index.ts +8 -0
  57. package/src/compute-view/deployment-view/predicates/relation-direct.ts +125 -99
  58. package/src/compute-view/deployment-view/predicates/relation-in-out.ts +16 -8
  59. package/src/compute-view/deployment-view/predicates/relation-incoming.ts +18 -12
  60. package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +16 -9
  61. package/src/compute-view/deployment-view/predicates/relation-where.ts +18 -0
  62. package/src/compute-view/deployment-view/predicates/utils.ts +214 -0
  63. package/src/compute-view/element-view/__test__/fixture.ts +17 -4
  64. package/src/compute-view/element-view/compute.ts +3 -2
  65. package/src/compute-view/element-view/predicates.ts +520 -0
  66. package/src/compute-view/element-view/utils.ts +11 -7
  67. package/src/compute-view/index.ts +1 -0
  68. package/src/compute-view/relationships-view/_types.ts +16 -0
  69. package/src/compute-view/relationships-view/compute.ts +74 -0
  70. package/src/compute-view/relationships-view/layout.ts +357 -0
  71. package/src/compute-view/relationships-view/utils.ts +40 -0
  72. package/src/compute-view/utils/relationExpressionToPredicates.ts +11 -4
  73. package/src/index.ts +16 -0
  74. package/src/model/DeploymentElementModel.ts +18 -1
  75. package/src/model/ElementModel.ts +13 -0
  76. package/src/model/LikeC4Model.ts +2 -2
  77. package/src/model/RelationModel.ts +9 -0
  78. package/src/model/connection/deployment/DeploymentConnectionModel.ts +11 -1
  79. package/src/model/guards.ts +17 -1
  80. package/src/model/view/LikeC4ViewModel.ts +7 -1
  81. package/src/model/view/NodeModel.ts +5 -0
  82. package/src/types/deployments.ts +1 -0
  83. package/src/types/expression-v2.ts +12 -0
  84. package/src/types/index.ts +1 -0
  85. package/src/types/operators.ts +46 -6
  86. package/src/types/view.ts +2 -2
  87. package/src/utils/index.ts +0 -5
  88. package/src/utils/iterable/unique.ts +1 -7
  89. package/dist/model/index.js +0 -1
  90. package/dist/utils/index.js +0 -347
  91. /package/dist/shared/{chunk-RAAYCPUM.M-JWF7SS.js → core.M-JWF7SS.mjs} +0 -0
@@ -2,6 +2,7 @@ import { invariant } from '../errors'
2
2
  import type { ExclusiveUnion } from './_common'
3
3
  import type { DeploymentRef as DeploymentModelRef, PredicateSelector } from './deployments'
4
4
  import type { Fqn } from './element'
5
+ import type { WhereOperator } from './operators'
5
6
 
6
7
  export namespace FqnRef {
7
8
  /**
@@ -131,6 +132,15 @@ export namespace RelationExpr {
131
132
  export const isInOut = (expr: ExpressionV2): expr is InOut => {
132
133
  return 'inout' in expr
133
134
  }
135
+ export type Where<D = Fqn, M = Fqn> = {
136
+ where: {
137
+ expr: ExpressionV2<D, M>
138
+ condition: WhereOperator<string, string>
139
+ }
140
+ }
141
+ export const isWhere = (expr: ExpressionV2): expr is Where => {
142
+ return 'where' in expr
143
+ }
134
144
  }
135
145
 
136
146
  export type RelationExpr<D = Fqn, M = Fqn> = ExclusiveUnion<{
@@ -138,6 +148,7 @@ export type RelationExpr<D = Fqn, M = Fqn> = ExclusiveUnion<{
138
148
  Incoming: RelationExpr.Incoming<D, M>
139
149
  Outgoing: RelationExpr.Outgoing<D, M>
140
150
  InOut: RelationExpr.InOut<D, M>
151
+ Where: RelationExpr.Where<D, M>
141
152
  }>
142
153
 
143
154
  /**
@@ -154,6 +165,7 @@ export type ExpressionV2<D = Fqn, M = Fqn> = ExclusiveUnion<{
154
165
  Incoming: RelationExpr.Incoming<D, M>
155
166
  Outgoing: RelationExpr.Outgoing<D, M>
156
167
  InOut: RelationExpr.InOut<D, M>
168
+ RelationPredicateOrWhere: RelationExpr.Where<D, M>
157
169
  }>
158
170
 
159
171
  export namespace ExpressionV2 {
@@ -121,6 +121,7 @@ export type {
121
121
  Filterable,
122
122
  KindEqual,
123
123
  NotOperator,
124
+ OperatorPredicate,
124
125
  OrOperator,
125
126
  TagEqual,
126
127
  WhereOperator,
@@ -16,6 +16,7 @@ type AllNever = {
16
16
  or?: never
17
17
  tag?: never
18
18
  kind?: never
19
+ participant?: never
19
20
  }
20
21
 
21
22
  export type TagEqual<Tag> = Omit<AllNever, 'tag'> & {
@@ -32,6 +33,17 @@ export const isKindEqual = <Kind>(operator: WhereOperator<any, Kind>): operator
32
33
  return 'kind' in operator
33
34
  }
34
35
 
36
+ export type Participant = 'source' | 'target'
37
+ export type ParticipantOperator<Tag, Kind> = Omit<AllNever, 'participant'> & {
38
+ participant: Participant
39
+ operator: KindEqual<Kind> | TagEqual<Tag>
40
+ }
41
+ export const isParticipantOperator = <Tag, Kind>(
42
+ operator: WhereOperator<Tag, any>,
43
+ ): operator is ParticipantOperator<Tag, Kind> => {
44
+ return 'participant' in operator
45
+ }
46
+
35
47
  export type NotOperator<Tag, Kind> = Omit<AllNever, 'not'> & {
36
48
  not: WhereOperator<Tag, Kind>
37
49
  }
@@ -56,25 +68,34 @@ export const isOrOperator = <Tag, Kind>(operator: WhereOperator<Tag, Kind>): ope
56
68
  export type WhereOperator<Tag, Kind> =
57
69
  | TagEqual<Tag>
58
70
  | KindEqual<Kind>
71
+ | ParticipantOperator<Tag, Kind>
59
72
  | NotOperator<Tag, Kind>
60
73
  | AndOperator<Tag, Kind>
61
74
  | OrOperator<Tag, Kind>
62
75
 
63
76
  export type Filterable<
64
- FTag extends string = string,
65
- FKind extends string = string
77
+ FTag extends string | null = string | null,
78
+ FKind extends string | null = string | null,
66
79
  > = {
67
80
  tags?: readonly FTag[] | null
68
81
  kind?: FKind
82
+ source?: Filterable<FTag, FKind>
83
+ target?: Filterable<FTag, FKind>
69
84
  }
70
85
 
71
- type OperatorPredicate<V extends Filterable> = (value: V) => boolean
86
+ export type OperatorPredicate<V extends Filterable> = (value: V) => boolean
72
87
 
73
88
  export function whereOperatorAsPredicate<
74
- FTag extends string = string,
75
- FKind extends string = string
76
- >(operator: WhereOperator<FTag, FKind>): OperatorPredicate<Filterable<FTag, FKind>> {
89
+ FTag extends string | null = string | null,
90
+ FKind extends string | null = string | null,
91
+ >(operator: WhereOperator<FTag, FKind>): OperatorPredicate<Filterable> {
77
92
  switch (true) {
93
+ case isParticipantOperator(operator): {
94
+ const participant = operator.participant
95
+ const participantPredicate = whereOperatorAsPredicate(operator.operator)
96
+
97
+ return participantIs(participant, participantPredicate)
98
+ }
78
99
  case isTagEqual(operator): {
79
100
  if ('eq' in operator.tag) {
80
101
  const tag = operator.tag.eq
@@ -115,3 +136,22 @@ export function whereOperatorAsPredicate<
115
136
  nonexhaustive(operator)
116
137
  }
117
138
  }
139
+
140
+ function participantIs<FTag extends string | null, FKind extends string | null>(
141
+ participant: Participant,
142
+ predicate: OperatorPredicate<Filterable<FTag, FKind>>,
143
+ ): OperatorPredicate<Filterable<FTag, FKind>> {
144
+ return (value) => {
145
+ if (!value.source || !value.target) {
146
+ return false
147
+ }
148
+ switch (participant) {
149
+ case 'source': {
150
+ return predicate(value.source)
151
+ }
152
+ case 'target': {
153
+ return predicate(value.target)
154
+ }
155
+ }
156
+ }
157
+ }
package/src/types/view.ts CHANGED
@@ -3,12 +3,12 @@ import type { Tagged } from 'type-fest'
3
3
  import type { IconUrl, NonEmptyArray, Point, XYPoint } from './_common'
4
4
  import {
5
5
  type BorderStyle,
6
- ElementKind,
7
6
  type ElementShape,
8
7
  type ElementStyle,
9
8
  type Fqn,
10
9
  type Link,
11
10
  type Tag,
11
+ ElementKind,
12
12
  } from './element'
13
13
  import type { ElementExpression, ElementPredicateExpression, Expression } from './expression'
14
14
  import type { ExpressionV2, FqnExpr } from './expression-v2'
@@ -335,7 +335,7 @@ export interface ComputedNode {
335
335
  */
336
336
  icon?: IconUrl
337
337
  style: ElementStyle
338
- navigateTo?: ViewId
338
+ navigateTo?: ViewId | null
339
339
  level: number
340
340
  // For compound nodes, the max depth of nested nodes
341
341
  depth?: number
@@ -1,8 +1,3 @@
1
- import DefaultMap from 'mnemonist/default-map'
2
- import LinkedList from 'mnemonist/linked-list'
3
-
4
- export { DefaultMap, LinkedList }
5
-
6
1
  export {
7
2
  commonHead,
8
3
  } from './common-head'
@@ -8,13 +8,7 @@ export function iunique(): <T>(iterable: Iterable<T>) => IteratorLike<T>
8
8
  export function iunique<T>(iterable: Iterable<T>): IteratorLike<T>
9
9
 
10
10
  export function iunique<T>(iterable?: Iterable<T>): IteratorLike<T> | ((iterable: Iterable<T>) => IteratorLike<T>) {
11
- if (iterable) {
12
- return (function*(): IteratorLike<T> {
13
- yield* _iunique(iterable)
14
- return
15
- })()
16
- }
17
- return _iunique
11
+ return iterable ? _iunique(iterable) : _iunique
18
12
  }
19
13
 
20
14
  function* _iunique<T>(iterable: Iterable<T>): IteratorLike<T> {
@@ -1 +0,0 @@
1
- export { C as Connection, f as ConnectionModel, F as DeployedInstanceModel, D as DeploymentConnectionModel, H as DeploymentNodeModel, I as DeploymentRelationModel, J as EdgeModel, E as ElementModel, b as LikeC4DeploymentModel, L as LikeC4Model, e as LikeC4ViewModel, N as NodeModel, R as RelationshipModel, g as deploymentConnection, h as differenceConnections, j as findAscendingConnections, k as findDeepestNestedConnection, m as findDescendantConnections, n as hasSameSource, o as hasSameSourceTarget, p as hasSameTarget, q as isAnyInOut, K as isDeployedInstance, M as isDeploymentNode, s as isIncoming, v as isNestedConnection, x as isOutgoing, y as mergeConnections, z as modelConnection, A as sortConnectionsByBoundaryHierarchy, B as sortDeepestFirst } from '../shared/index.DafVOuVd.js';
@@ -1,347 +0,0 @@
1
- import { T as requireIterator, S as requireForeach, R as getDefaultExportFromCjs, b as t, W as n, f as commonAncestor, h as compareFqnHierarchically } from '../shared/object_hash.CE_oF3I3.js';
2
- export { D as DefaultMap, e as ancestorsFqn, c as commonHead, g as compareByFqnHierarchically, d as compareNatural, H as difference, I as equalsSet, v as getOrCreate, i as hasAtLeast, j as hierarchyDistance, k as hierarchyLevel, y as ifilter, z as iflat, A as imap, J as intersection, o as isAncestor, q as isDescendantOf, B as isIterable, w as isNonEmptyArray, a as isSameHierarchy, x as isString, C as isome, E as iunique, n as nameFromFqn, N as objectHash, p as parentFqn, s as sortByFqnHierarchically, r as sortNaturalByFqn, u as sortParentsFirst, M as stringHash, K as symmetricDifference, F as toArray, G as toSet, L as union } from '../shared/object_hash.CE_oF3I3.js';
3
- import { i as invariant } from '../shared/chunk-RAAYCPUM.M-JWF7SS.js';
4
-
5
- function o(r,n){let e=Math.ceil(r),t=Math.floor(n);if(t<e)throw new RangeError(`randomInteger: The range [${r.toString()},${n.toString()}] contains no integer`);return Math.floor(Math.random()*(t-e+1)+e)}
6
-
7
- /**
8
- * Mnemonist Linked List
9
- * ======================
10
- *
11
- * Singly linked list implementation. Uses raw JavaScript objects as nodes
12
- * as benchmarks proved it was the fastest thing to do.
13
- */
14
-
15
- var linkedList$1;
16
- var hasRequiredLinkedList;
17
-
18
- function requireLinkedList () {
19
- if (hasRequiredLinkedList) return linkedList$1;
20
- hasRequiredLinkedList = 1;
21
- var Iterator = requireIterator(),
22
- forEach = requireForeach();
23
-
24
- /**
25
- * Linked List.
26
- *
27
- * @constructor
28
- */
29
- function LinkedList() {
30
- this.clear();
31
- }
32
-
33
- /**
34
- * Method used to clear the list.
35
- *
36
- * @return {undefined}
37
- */
38
- LinkedList.prototype.clear = function() {
39
-
40
- // Properties
41
- this.head = null;
42
- this.tail = null;
43
- this.size = 0;
44
- };
45
-
46
- /**
47
- * Method used to get the first item of the list.
48
- *
49
- * @return {any}
50
- */
51
- LinkedList.prototype.first = function() {
52
- return this.head ? this.head.item : undefined;
53
- };
54
- LinkedList.prototype.peek = LinkedList.prototype.first;
55
-
56
- /**
57
- * Method used to get the last item of the list.
58
- *
59
- * @return {any}
60
- */
61
- LinkedList.prototype.last = function() {
62
- return this.tail ? this.tail.item : undefined;
63
- };
64
-
65
- /**
66
- * Method used to add an item at the end of the list.
67
- *
68
- * @param {any} item - The item to add.
69
- * @return {number}
70
- */
71
- LinkedList.prototype.push = function(item) {
72
- var node = {item: item, next: null};
73
-
74
- if (!this.head) {
75
- this.head = node;
76
- this.tail = node;
77
- }
78
- else {
79
- this.tail.next = node;
80
- this.tail = node;
81
- }
82
-
83
- this.size++;
84
-
85
- return this.size;
86
- };
87
-
88
- /**
89
- * Method used to add an item at the beginning of the list.
90
- *
91
- * @param {any} item - The item to add.
92
- * @return {number}
93
- */
94
- LinkedList.prototype.unshift = function(item) {
95
- var node = {item: item, next: null};
96
-
97
- if (!this.head) {
98
- this.head = node;
99
- this.tail = node;
100
- }
101
- else {
102
- if (!this.head.next)
103
- this.tail = this.head;
104
- node.next = this.head;
105
- this.head = node;
106
- }
107
-
108
- this.size++;
109
-
110
- return this.size;
111
- };
112
-
113
- /**
114
- * Method used to retrieve & remove the first item of the list.
115
- *
116
- * @return {any}
117
- */
118
- LinkedList.prototype.shift = function() {
119
- if (!this.size)
120
- return undefined;
121
-
122
- var node = this.head;
123
-
124
- this.head = node.next;
125
- this.size--;
126
-
127
- return node.item;
128
- };
129
-
130
- /**
131
- * Method used to iterate over the list.
132
- *
133
- * @param {function} callback - Function to call for each item.
134
- * @param {object} scope - Optional scope.
135
- * @return {undefined}
136
- */
137
- LinkedList.prototype.forEach = function(callback, scope) {
138
- if (!this.size)
139
- return;
140
-
141
- scope = arguments.length > 1 ? scope : this;
142
-
143
- var n = this.head,
144
- i = 0;
145
-
146
- while (n) {
147
- callback.call(scope, n.item, i, this);
148
- n = n.next;
149
- i++;
150
- }
151
- };
152
-
153
- /**
154
- * Method used to convert the list into an array.
155
- *
156
- * @return {array}
157
- */
158
- LinkedList.prototype.toArray = function() {
159
- if (!this.size)
160
- return [];
161
-
162
- var array = new Array(this.size);
163
-
164
- for (var i = 0, l = this.size, n = this.head; i < l; i++) {
165
- array[i] = n.item;
166
- n = n.next;
167
- }
168
-
169
- return array;
170
- };
171
-
172
- /**
173
- * Method used to create an iterator over a list's values.
174
- *
175
- * @return {Iterator}
176
- */
177
- LinkedList.prototype.values = function() {
178
- var n = this.head;
179
-
180
- return new Iterator(function() {
181
- if (!n)
182
- return {
183
- done: true
184
- };
185
-
186
- var value = n.item;
187
- n = n.next;
188
-
189
- return {
190
- value: value,
191
- done: false
192
- };
193
- });
194
- };
195
-
196
- /**
197
- * Method used to create an iterator over a list's entries.
198
- *
199
- * @return {Iterator}
200
- */
201
- LinkedList.prototype.entries = function() {
202
- var n = this.head,
203
- i = 0;
204
-
205
- return new Iterator(function() {
206
- if (!n)
207
- return {
208
- done: true
209
- };
210
-
211
- var value = n.item;
212
- n = n.next;
213
- i++;
214
-
215
- return {
216
- value: [i - 1, value],
217
- done: false
218
- };
219
- });
220
- };
221
-
222
- /**
223
- * Attaching the #.values method to Symbol.iterator if possible.
224
- */
225
- if (typeof Symbol !== 'undefined')
226
- LinkedList.prototype[Symbol.iterator] = LinkedList.prototype.values;
227
-
228
- /**
229
- * Convenience known methods.
230
- */
231
- LinkedList.prototype.toString = function() {
232
- return this.toArray().join(',');
233
- };
234
-
235
- LinkedList.prototype.toJSON = function() {
236
- return this.toArray();
237
- };
238
-
239
- LinkedList.prototype.inspect = function() {
240
- var array = this.toArray();
241
-
242
- // Trick so that node displays the name of the constructor
243
- Object.defineProperty(array, 'constructor', {
244
- value: LinkedList,
245
- enumerable: false
246
- });
247
-
248
- return array;
249
- };
250
-
251
- if (typeof Symbol !== 'undefined')
252
- LinkedList.prototype[Symbol.for('nodejs.util.inspect.custom')] = LinkedList.prototype.inspect;
253
-
254
- /**
255
- * Static @.from function taking an arbitrary iterable & converting it into
256
- * a list.
257
- *
258
- * @param {Iterable} iterable - Target iterable.
259
- * @return {LinkedList}
260
- */
261
- LinkedList.from = function(iterable) {
262
- var list = new LinkedList();
263
-
264
- forEach(iterable, function(value) {
265
- list.push(value);
266
- });
267
-
268
- return list;
269
- };
270
-
271
- /**
272
- * Exporting.
273
- */
274
- linkedList$1 = LinkedList;
275
- return linkedList$1;
276
- }
277
-
278
- var linkedListExports = requireLinkedList();
279
- const linkedList = /*@__PURE__*/getDefaultExportFromCjs(linkedListExports);
280
-
281
- function ifind(arg1, arg2) {
282
- const pred = arg2 ?? arg1;
283
- invariant(t(pred));
284
- function _find(iter) {
285
- for (const value of iter) {
286
- if (pred(value)) {
287
- return value;
288
- }
289
- }
290
- return;
291
- }
292
- if (!arg2) {
293
- return _find;
294
- }
295
- return _find(arg1);
296
- }
297
-
298
- function ireduce(arg1, arg2, arg3) {
299
- const reducer = n(arg3) ? arg2 : arg1;
300
- const initialValue = arg3 ?? arg2;
301
- invariant(t(reducer));
302
- function _reduce(iter) {
303
- let acc = initialValue;
304
- for (const value of iter) {
305
- acc = reducer(acc, value);
306
- }
307
- return acc;
308
- }
309
- return n(arg3) ? _reduce(arg1) : _reduce;
310
- }
311
-
312
- const DELAY = "LIKEC4_DELAY";
313
- function delay(...args) {
314
- let ms = 100;
315
- if (args.length === 2) {
316
- ms = o(args[0], args[1]);
317
- } else if (args.length === 1) {
318
- ms = args[0];
319
- }
320
- return new Promise((resolve) => {
321
- setTimeout(() => {
322
- resolve(DELAY);
323
- }, ms ?? 100);
324
- });
325
- }
326
-
327
- const compareRelations = (a, b) => {
328
- const parentA = commonAncestor(a.source, a.target);
329
- const parentB = commonAncestor(b.source, b.target);
330
- if (parentA && !parentB) {
331
- return 1;
332
- }
333
- if (!parentA && parentB) {
334
- return -1;
335
- }
336
- const compareParents = parentA && parentB ? compareFqnHierarchically(parentA, parentB) : 0;
337
- if (compareParents !== 0) {
338
- return compareParents;
339
- }
340
- const compareSource = compareFqnHierarchically(a.source, b.source);
341
- if (compareSource !== 0) {
342
- return compareSource;
343
- }
344
- return compareFqnHierarchically(a.target, b.target);
345
- };
346
-
347
- export { linkedList as LinkedList, commonAncestor, compareFqnHierarchically, compareRelations, delay, ifind, ireduce };