@likec4/core 1.18.0 → 1.19.1
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/LICENSE +1 -1
- package/dist/builder/index.d.mts +502 -0
- package/dist/builder/index.d.ts +502 -0
- package/dist/builder/index.js +871 -0
- package/dist/compute-view/index.d.mts +9 -78
- package/dist/compute-view/index.d.ts +9 -78
- package/dist/compute-view/index.js +78 -0
- package/dist/index.d.mts +9 -730
- package/dist/index.d.ts +9 -730
- package/dist/{index.mjs → index.js} +7 -784
- package/dist/model/index.d.mts +218 -606
- package/dist/model/index.d.ts +218 -606
- package/dist/model/index.js +1 -0
- package/dist/shared/chunk-RAAYCPUM.M-JWF7SS.js +21 -0
- package/dist/shared/core.BIfgabEw.d.ts +719 -0
- package/dist/shared/core.BZ9Msq7w.d.mts +719 -0
- package/dist/shared/{core.DMYY7C8s.d.mts → core.C05RDLhi.d.ts} +179 -230
- package/dist/shared/{core.DMYY7C8s.d.ts → core.CmYMqgha.d.mts} +179 -230
- package/dist/shared/core.D6-fWbM3.d.ts +127 -0
- package/dist/shared/core.D74xkKkG.d.mts +148 -0
- package/dist/shared/core.D74xkKkG.d.ts +148 -0
- package/dist/shared/core.sLaWHBjR.d.mts +127 -0
- package/dist/shared/index.DafVOuVd.js +7443 -0
- package/dist/shared/object_hash.CE_oF3I3.js +1222 -0
- package/dist/shared/view.CyZrG8BJ.js +354 -0
- package/dist/types/index.d.mts +4 -2
- package/dist/types/index.d.ts +4 -2
- package/dist/types/index.js +20 -0
- package/dist/utils/index.d.mts +419 -0
- package/dist/utils/index.d.ts +419 -0
- package/dist/utils/index.js +347 -0
- package/package.json +47 -33
- package/src/builder/Builder-style1.test-d.ts +190 -0
- package/src/builder/Builder-style2.test-d.ts +175 -0
- package/src/builder/Builder.deployment.ts +25 -20
- package/src/builder/Builder.deploymentModel.ts +80 -55
- package/src/builder/Builder.element.ts +2 -0
- package/src/builder/Builder.model.ts +57 -43
- package/src/builder/Builder.ts +412 -431
- package/src/builder/Builder.view-common.ts +234 -0
- package/src/builder/Builder.view-deployment.ts +135 -0
- package/src/builder/Builder.view-element.ts +189 -0
- package/src/builder/Builder.views.ts +109 -33
- package/src/builder/Builder.with.ts +475 -0
- package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +374 -0
- package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +183 -0
- package/src/builder/__snapshots__/Builder.spec.ts.snap +374 -0
- package/src/builder/_types.ts +28 -5
- package/src/builder/index.ts +10 -4
- package/src/colors/index.ts +2 -2
- package/src/compute-view/compute-view.ts +45 -54
- package/src/compute-view/deployment-view/__test__/TestHelper.ts +236 -0
- package/src/compute-view/deployment-view/__test__/fixture.ts +50 -62
- package/src/compute-view/deployment-view/_types.ts +26 -18
- package/src/compute-view/deployment-view/clean-connections.ts +173 -164
- package/src/compute-view/deployment-view/compute.ts +51 -37
- package/src/compute-view/deployment-view/memory/index.ts +9 -0
- package/src/compute-view/deployment-view/memory/memory.ts +97 -0
- package/src/compute-view/deployment-view/predicates/elements.ts +144 -0
- package/src/compute-view/deployment-view/predicates/relation-direct.ts +183 -76
- package/src/compute-view/deployment-view/predicates/relation-in-out.ts +38 -20
- package/src/compute-view/deployment-view/predicates/relation-incoming.ts +72 -23
- package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +61 -22
- package/src/compute-view/deployment-view/predicates/wildcard.ts +15 -15
- package/src/compute-view/deployment-view/stages/stage-exclude.ts +5 -0
- package/src/compute-view/deployment-view/stages/stage-final.ts +245 -0
- package/src/compute-view/deployment-view/stages/stage-include.ts +95 -0
- package/src/compute-view/deployment-view/utils.ts +95 -31
- package/src/compute-view/dynamic-view/__test__/fixture.ts +4 -4
- package/src/compute-view/dynamic-view/compute.ts +59 -45
- package/src/compute-view/element-view/__test__/TestHelper.ts +258 -0
- package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +64 -62
- package/src/compute-view/element-view/__test__/fixture.ts +147 -117
- package/src/compute-view/element-view/_types.ts +48 -0
- package/src/compute-view/element-view/clean-connections.ts +113 -0
- package/src/compute-view/element-view/compute.ts +264 -683
- package/src/compute-view/element-view/memory/NodeGroup.ts +31 -0
- package/src/compute-view/element-view/memory/index.ts +10 -0
- package/src/compute-view/element-view/memory/memory.ts +177 -0
- package/src/compute-view/element-view/memory/stage-exclude.ts +59 -0
- package/src/compute-view/element-view/memory/stage-final.ts +129 -0
- package/src/compute-view/element-view/memory/stage-include.ts +128 -0
- package/src/compute-view/element-view/predicates/_utils.ts +86 -0
- package/src/compute-view/element-view/predicates/element-expand.ts +33 -0
- package/src/compute-view/element-view/predicates/element-kind-tag.ts +26 -0
- package/src/compute-view/element-view/predicates/element-ref.ts +37 -0
- package/src/compute-view/element-view/predicates/relation-direct.ts +309 -0
- package/src/compute-view/element-view/predicates/relation-in-out.ts +66 -0
- package/src/compute-view/element-view/predicates/relation-in.ts +118 -0
- package/src/compute-view/element-view/predicates/relation-out.ts +116 -0
- package/src/compute-view/element-view/predicates/wildcard.ts +88 -0
- package/src/compute-view/element-view/utils.ts +59 -0
- package/src/compute-view/index.ts +3 -4
- package/src/compute-view/memory/AbstractMemory.ts +45 -0
- package/src/compute-view/memory/AbstractStageExclude.ts +216 -0
- package/src/compute-view/memory/AbstractStageInclude.ts +200 -0
- package/src/compute-view/memory/_types.ts +147 -0
- package/src/compute-view/memory/index.ts +5 -0
- package/src/compute-view/memory/ops.ts +43 -0
- package/src/compute-view/utils/buildComputedNodes.ts +4 -4
- package/src/compute-view/utils/elementExpressionToPredicate.ts +1 -3
- package/src/compute-view/utils/link-nodes-with-edges.ts +3 -7
- package/src/compute-view/utils/{derive-edge-props-from-relationships.ts → merge-props-from-relationships.ts} +54 -23
- package/src/compute-view/utils/relationExpressionToPredicates.ts +2 -2
- package/src/compute-view/utils/resolve-extended-views.ts +44 -40
- package/src/compute-view/utils/resolve-global-rules.ts +6 -6
- package/src/compute-view/utils/topological-sort.ts +167 -71
- package/src/compute-view/utils/with-readable-edges.ts +14 -9
- package/src/index.ts +22 -16
- package/src/model/DeploymentElementModel.ts +150 -85
- package/src/model/DeploymentModel.ts +27 -21
- package/src/model/ElementModel.ts +51 -25
- package/src/model/LikeC4Model.test-d.ts +4 -3
- package/src/model/LikeC4Model.ts +98 -42
- package/src/model/RelationModel.ts +5 -4
- package/src/model/__test__/fixture.ts +5 -9
- package/src/model/connection/Connection.ts +72 -0
- package/src/model/connection/deployment/DeploymentConnectionModel.ts +178 -0
- package/src/model/connection/{deployment.ts → deployment/find.ts} +14 -18
- package/src/model/connection/deployment/index.ts +8 -0
- package/src/model/connection/index.ts +22 -0
- package/src/model/connection/model/ConnectionModel.ts +157 -0
- package/src/model/connection/{model.ts → model/find.ts} +43 -49
- package/src/model/connection/model/index.ts +8 -0
- package/src/model/connection/ops.ts +274 -0
- package/src/model/guards.ts +9 -0
- package/src/model/index.ts +45 -3
- package/src/model/types.ts +35 -18
- package/src/model/view/EdgeModel.ts +6 -6
- package/src/model/view/LikeC4ViewModel.ts +14 -8
- package/src/model/view/NodeModel.ts +6 -5
- package/src/types/_common.ts +53 -1
- package/src/types/deployments.ts +88 -156
- package/src/types/element.ts +2 -2
- package/src/types/expression-v2.ts +172 -0
- package/src/types/expression.ts +9 -5
- package/src/types/global.ts +3 -3
- package/src/types/index.ts +220 -13
- package/src/types/model.ts +28 -24
- package/src/types/operators.ts +1 -1
- package/src/types/relation.ts +14 -10
- package/src/types/theme.ts +0 -1
- package/src/types/view.ts +20 -18
- package/src/utils/const.ts +1 -0
- package/src/utils/fqn.ts +140 -49
- package/src/utils/getOrCreate.ts +1 -1
- package/src/utils/index.ts +75 -9
- package/src/utils/iterable/_types.ts +5 -0
- package/src/utils/iterable/filter.ts +55 -0
- package/src/utils/iterable/find.ts +36 -0
- package/src/utils/iterable/flat.ts +17 -0
- package/src/utils/iterable/index.ts +13 -0
- package/src/utils/iterable/map.ts +40 -0
- package/src/utils/iterable/reduce.ts +24 -0
- package/src/utils/iterable/some.ts +36 -0
- package/src/utils/iterable/to.ts +19 -0
- package/src/utils/iterable/unique.ts +29 -0
- package/src/utils/relations.ts +3 -64
- package/src/utils/set.ts +11 -9
- package/src/utils/string-hash.ts +1 -1
- package/dist/compute-view/index.mjs +0 -79
- package/dist/model/index.mjs +0 -2
- package/dist/shared/core.BBgiAAv1.mjs +0 -144
- package/dist/shared/core.BPyJvuMU.mjs +0 -2420
- package/dist/shared/core.BQ4AbfvB.mjs +0 -9228
- package/dist/shared/core.k12s_keD.mjs +0 -203
- package/dist/types/index.mjs +0 -21
- package/src/builder/Builder.test-d.ts +0 -124
- package/src/builder/Builder.view.ts +0 -543
- package/src/compute-view/LikeC4ModelGraph.ts +0 -330
- package/src/compute-view/deployment-view/Memory.ts +0 -108
- package/src/compute-view/deployment-view/Stage.ts +0 -145
- package/src/compute-view/deployment-view/predicates/deployment-ref.ts +0 -146
- package/src/compute-view/element-view/predicates.ts +0 -517
- package/src/compute-view/utils/sortNodes.ts +0 -101
- package/src/model/connection/ConnectionModel.ts +0 -94
- package/src/model/connection/DeploymentConnectionModel.ts +0 -99
package/src/utils/relations.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import type { Fqn } from '../types'
|
|
2
2
|
import { commonAncestor, compareFqnHierarchically, isAncestor } from './fqn'
|
|
3
3
|
|
|
4
|
-
type Relation = {
|
|
4
|
+
export type Relation = {
|
|
5
5
|
source: string
|
|
6
6
|
target: string
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
type RelationPredicate = (rel: Relation) => boolean
|
|
9
|
+
export type RelationPredicate = (rel: Relation) => boolean
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Compares two relations hierarchically.
|
|
13
13
|
* From the most general (implicit) to the most specific.
|
|
14
14
|
*/
|
|
15
|
-
export const compareRelations = <T extends { source: string; target: string }>(a: T, b: T) => {
|
|
15
|
+
export const compareRelations = <T extends { source: string; target: string }>(a: T, b: T): number => {
|
|
16
16
|
const parentA = commonAncestor(a.source as Fqn, a.target as Fqn)
|
|
17
17
|
const parentB = commonAncestor(b.source as Fqn, b.target as Fqn)
|
|
18
18
|
if (parentA && !parentB) {
|
|
@@ -31,64 +31,3 @@ export const compareRelations = <T extends { source: string; target: string }>(a
|
|
|
31
31
|
}
|
|
32
32
|
return compareFqnHierarchically(a.target, b.target)
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
export const isInside = (parent: Fqn): RelationPredicate => {
|
|
36
|
-
const prefix = parent + '.'
|
|
37
|
-
return (rel: Relation) => {
|
|
38
|
-
return rel.source.startsWith(prefix) && rel.target.startsWith(prefix)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export const isBetween = (source: Fqn, target: Fqn): RelationPredicate => {
|
|
43
|
-
const sourcePrefix = source + '.'
|
|
44
|
-
const targetPrefix = target + '.'
|
|
45
|
-
return (rel: Relation) => {
|
|
46
|
-
return (
|
|
47
|
-
(rel.source === source || (rel.source + '.').startsWith(sourcePrefix))
|
|
48
|
-
&& (rel.target === target || (rel.target + '.').startsWith(targetPrefix))
|
|
49
|
-
)
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export const isAnyBetween = (source: Fqn, target: Fqn): RelationPredicate => {
|
|
54
|
-
const predicates = [isBetween(source, target), isBetween(target, source)]
|
|
55
|
-
return (rel) => predicates.some(p => p(rel))
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const isIncoming = (target: Fqn): RelationPredicate => {
|
|
59
|
-
const targetPrefix = target + '.'
|
|
60
|
-
return (rel: Relation) => {
|
|
61
|
-
return (
|
|
62
|
-
!(rel.source + '.').startsWith(targetPrefix)
|
|
63
|
-
&& (rel.target === target || (rel.target + '.').startsWith(targetPrefix))
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export const isOutgoing = (source: Fqn): RelationPredicate => {
|
|
69
|
-
const sourcePrefix = source + '.'
|
|
70
|
-
return (rel: Relation) => {
|
|
71
|
-
return (
|
|
72
|
-
(rel.source === source || (rel.source + '.').startsWith(sourcePrefix))
|
|
73
|
-
&& !(rel.target + '.').startsWith(sourcePrefix)
|
|
74
|
-
)
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export const isAnyInOut = (source: Fqn): RelationPredicate => {
|
|
79
|
-
const predicates = [isIncoming(source), isOutgoing(source)]
|
|
80
|
-
return (rel: Relation) => {
|
|
81
|
-
return predicates.some(p => p(rel))
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export const hasRelation = <R extends { source: Fqn; target: Fqn }>(rel: R) => {
|
|
86
|
-
return <E extends { id: Fqn }>(element: E) => {
|
|
87
|
-
return (
|
|
88
|
-
rel.source === element.id
|
|
89
|
-
|| rel.target === element.id
|
|
90
|
-
|| isAncestor(element.id, rel.source)
|
|
91
|
-
|| isAncestor(element.id, rel.target)
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
}
|
package/src/utils/set.ts
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
intersection as _intersection,
|
|
3
|
-
symmetricDifference as _symmetricDifference,
|
|
4
|
-
union as _union
|
|
5
|
-
} from 'mnemonist/set'
|
|
1
|
+
import { intersection as _intersection, symmetricDifference as _symmetricDifference } from 'mnemonist/set'
|
|
6
2
|
import type { NonEmptyArray } from '../types/_common'
|
|
7
3
|
|
|
8
4
|
/**
|
|
9
5
|
* Returns new set as a union of given sets
|
|
10
6
|
* Keeps order of elements
|
|
11
7
|
*/
|
|
12
|
-
export function union<T>(...sets:
|
|
13
|
-
|
|
8
|
+
export function union<T>(...sets: ReadonlySet<T>[]): Set<T> {
|
|
9
|
+
let result = new Set<T>()
|
|
10
|
+
for (const set of sets) {
|
|
11
|
+
for (const value of set) {
|
|
12
|
+
result.add(value)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return result
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* Returns new set as an intersection of all sets
|
|
18
20
|
* Keeps order from the first set
|
|
19
21
|
*/
|
|
20
|
-
export function intersection<T>(first: ReadonlySet<T>, ...sets: NonEmptyArray<ReadonlySet<T
|
|
22
|
+
export function intersection<T>(first: ReadonlySet<T>, ...sets: NonEmptyArray<ReadonlySet<NoInfer<T>>>): Set<T> {
|
|
21
23
|
let result = new Set<T>()
|
|
22
24
|
// If first set is empty, return empty set
|
|
23
25
|
if (first.size === 0) {
|
|
@@ -35,7 +37,7 @@ export function intersection<T>(first: ReadonlySet<T>, ...sets: NonEmptyArray<Re
|
|
|
35
37
|
return result
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
export function difference<T>(a: ReadonlySet<T>, b: ReadonlySet<T
|
|
40
|
+
export function difference<T>(a: ReadonlySet<T>, b: ReadonlySet<NoInfer<T>>): Set<T> {
|
|
39
41
|
if (a.size === 0) {
|
|
40
42
|
return new Set<T>()
|
|
41
43
|
}
|
package/src/utils/string-hash.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { invariant } from '../errors'
|
|
|
3
3
|
/**
|
|
4
4
|
* @see https://gist.github.com/victor-homyakov/bcb7d7911e4a388b1c810f8c3ce17bcf
|
|
5
5
|
*/
|
|
6
|
-
export function stringHash(str: string) {
|
|
6
|
+
export function stringHash(str: string): string {
|
|
7
7
|
let hash = 5381
|
|
8
8
|
const len = str.length
|
|
9
9
|
invariant(len > 0, 'stringHash: empty string')
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { G as Graph, i as isAcyclic, d, f as findCycles, a, p as postorder, l, m, b as i } from '../shared/core.BQ4AbfvB.mjs';
|
|
2
|
-
export { L as LikeC4ModelGraph, c as computeViews, e as mkComputeView } from '../shared/core.BQ4AbfvB.mjs';
|
|
3
|
-
import { r } from '../shared/core.BPyJvuMU.mjs';
|
|
4
|
-
import { i as isExtendsElementView } from '../shared/core.k12s_keD.mjs';
|
|
5
|
-
import '../shared/core.BBgiAAv1.mjs';
|
|
6
|
-
|
|
7
|
-
function resolveRulesExtendedViews(unresolvedViews) {
|
|
8
|
-
const g = new Graph({
|
|
9
|
-
directed: true,
|
|
10
|
-
multigraph: false,
|
|
11
|
-
compound: false
|
|
12
|
-
});
|
|
13
|
-
for (const view of r(unresolvedViews)) {
|
|
14
|
-
g.setNode(view.id, view.id);
|
|
15
|
-
if (isExtendsElementView(view)) {
|
|
16
|
-
g.setEdge(view.id, view.extends);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (g.edgeCount() === 0) {
|
|
20
|
-
return unresolvedViews;
|
|
21
|
-
}
|
|
22
|
-
while (!isAcyclic(g)) {
|
|
23
|
-
const firstCycle = d(findCycles(g));
|
|
24
|
-
if (!firstCycle) {
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
const cycledNode = a(firstCycle);
|
|
28
|
-
if (!cycledNode) {
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
g.removeNode(cycledNode);
|
|
32
|
-
}
|
|
33
|
-
const ordered = postorder(g, g.sources());
|
|
34
|
-
return ordered.reduce((acc, id) => {
|
|
35
|
-
const view = unresolvedViews[id];
|
|
36
|
-
if (!view) {
|
|
37
|
-
return acc;
|
|
38
|
-
}
|
|
39
|
-
if (isExtendsElementView(view)) {
|
|
40
|
-
const extendsFrom = acc[view.extends];
|
|
41
|
-
if (!extendsFrom) {
|
|
42
|
-
console.warn(`View "${view.id}" extends from "${view.extends}" which does not exist`);
|
|
43
|
-
return acc;
|
|
44
|
-
}
|
|
45
|
-
return Object.assign(acc, {
|
|
46
|
-
[view.id]: {
|
|
47
|
-
...extendsFrom,
|
|
48
|
-
...view,
|
|
49
|
-
rules: [...extendsFrom.rules, ...view.rules]
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return Object.assign(acc, { [view.id]: view });
|
|
54
|
-
}, {});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function withReadableEdges({ edges, nodes, ...view }) {
|
|
58
|
-
const edgeids = l(edges, (e) => [e.id, `${e.source}:${e.target}`]);
|
|
59
|
-
return {
|
|
60
|
-
...view,
|
|
61
|
-
edges: edges.map((e) => ({
|
|
62
|
-
...e,
|
|
63
|
-
id: edgeids[e.id]
|
|
64
|
-
})),
|
|
65
|
-
nodes: nodes.map((n) => ({
|
|
66
|
-
...n,
|
|
67
|
-
inEdges: m(n.inEdges, (e) => edgeids[e]),
|
|
68
|
-
outEdges: m(n.outEdges, (e) => edgeids[e])
|
|
69
|
-
}))
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
function viewsWithReadableEdges({ views, ...model }) {
|
|
73
|
-
return {
|
|
74
|
-
...model,
|
|
75
|
-
views: i(views, withReadableEdges)
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export { resolveRulesExtendedViews, viewsWithReadableEdges, withReadableEdges };
|
package/dist/model/index.mjs
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { u, n as nonexhaustive, a as n } from './core.k12s_keD.mjs';
|
|
2
|
-
|
|
3
|
-
function o(a){return t=>!a(t)}
|
|
4
|
-
|
|
5
|
-
function t(...a){return u(e,a)}var e=(a,o)=>o.every(l=>l(a));
|
|
6
|
-
|
|
7
|
-
function y(...a){return u(r,a)}var r=(a,o)=>o.some(e=>e(a));
|
|
8
|
-
|
|
9
|
-
function isElementRef(expr) {
|
|
10
|
-
return "element" in expr;
|
|
11
|
-
}
|
|
12
|
-
function isExpandedElementExpr(expr) {
|
|
13
|
-
return "expanded" in expr;
|
|
14
|
-
}
|
|
15
|
-
function isCustomElement(expr) {
|
|
16
|
-
return "custom" in expr && (isElement(expr.custom.expr) || isElementWhere(expr.custom.expr));
|
|
17
|
-
}
|
|
18
|
-
function isWildcard(expr) {
|
|
19
|
-
return "wildcard" in expr;
|
|
20
|
-
}
|
|
21
|
-
function isElementKindExpr(expr) {
|
|
22
|
-
return "elementKind" in expr && "isEqual" in expr;
|
|
23
|
-
}
|
|
24
|
-
function isElementTagExpr(expr) {
|
|
25
|
-
return "elementTag" in expr && "isEqual" in expr;
|
|
26
|
-
}
|
|
27
|
-
function isElement(expr) {
|
|
28
|
-
return isElementRef(expr) || isWildcard(expr) || isElementKindExpr(expr) || isElementTagExpr(expr) || isExpandedElementExpr(expr);
|
|
29
|
-
}
|
|
30
|
-
function isElementWhere(expr) {
|
|
31
|
-
return "where" in expr && isElement(expr.where.expr);
|
|
32
|
-
}
|
|
33
|
-
function isElementPredicateExpr(expr) {
|
|
34
|
-
return isElement(expr) || isElementWhere(expr) || isCustomElement(expr);
|
|
35
|
-
}
|
|
36
|
-
function isRelation(expr) {
|
|
37
|
-
return "source" in expr && "target" in expr;
|
|
38
|
-
}
|
|
39
|
-
function isInOut(expr) {
|
|
40
|
-
return "inout" in expr;
|
|
41
|
-
}
|
|
42
|
-
function isIncoming(expr) {
|
|
43
|
-
return "incoming" in expr;
|
|
44
|
-
}
|
|
45
|
-
function isOutgoing(expr) {
|
|
46
|
-
return "outgoing" in expr;
|
|
47
|
-
}
|
|
48
|
-
function isRelationExpression(expr) {
|
|
49
|
-
return isRelation(expr) || isInOut(expr) || isIncoming(expr) || isOutgoing(expr);
|
|
50
|
-
}
|
|
51
|
-
function isRelationWhere(expr) {
|
|
52
|
-
return "where" in expr && isRelationExpression(expr.where.expr);
|
|
53
|
-
}
|
|
54
|
-
function isCustomRelationExpr(expr) {
|
|
55
|
-
return "customRelation" in expr;
|
|
56
|
-
}
|
|
57
|
-
function isRelationPredicateExpr(expr) {
|
|
58
|
-
return isRelationExpression(expr) || isRelationWhere(expr) || isCustomRelationExpr(expr);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const expression = {
|
|
62
|
-
__proto__: null,
|
|
63
|
-
isCustomElement: isCustomElement,
|
|
64
|
-
isCustomRelationExpr: isCustomRelationExpr,
|
|
65
|
-
isElement: isElement,
|
|
66
|
-
isElementKindExpr: isElementKindExpr,
|
|
67
|
-
isElementPredicateExpr: isElementPredicateExpr,
|
|
68
|
-
isElementRef: isElementRef,
|
|
69
|
-
isElementTagExpr: isElementTagExpr,
|
|
70
|
-
isElementWhere: isElementWhere,
|
|
71
|
-
isExpandedElementExpr: isExpandedElementExpr,
|
|
72
|
-
isInOut: isInOut,
|
|
73
|
-
isIncoming: isIncoming,
|
|
74
|
-
isOutgoing: isOutgoing,
|
|
75
|
-
isRelation: isRelation,
|
|
76
|
-
isRelationExpression: isRelationExpression,
|
|
77
|
-
isRelationPredicateExpr: isRelationPredicateExpr,
|
|
78
|
-
isRelationWhere: isRelationWhere,
|
|
79
|
-
isWildcard: isWildcard
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const isTagEqual = (operator) => {
|
|
83
|
-
return "tag" in operator;
|
|
84
|
-
};
|
|
85
|
-
const isKindEqual = (operator) => {
|
|
86
|
-
return "kind" in operator;
|
|
87
|
-
};
|
|
88
|
-
const isNotOperator = (operator) => {
|
|
89
|
-
return "not" in operator;
|
|
90
|
-
};
|
|
91
|
-
const isAndOperator = (operator) => {
|
|
92
|
-
return "and" in operator;
|
|
93
|
-
};
|
|
94
|
-
const isOrOperator = (operator) => {
|
|
95
|
-
return "or" in operator;
|
|
96
|
-
};
|
|
97
|
-
function whereOperatorAsPredicate(operator) {
|
|
98
|
-
switch (true) {
|
|
99
|
-
case isTagEqual(operator): {
|
|
100
|
-
if ("eq" in operator.tag) {
|
|
101
|
-
const tag2 = operator.tag.eq;
|
|
102
|
-
return (value) => {
|
|
103
|
-
return Array.isArray(value.tags) && value.tags.includes(tag2);
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
const tag = operator.tag.neq;
|
|
107
|
-
return (value) => {
|
|
108
|
-
return !Array.isArray(value.tags) || !value.tags.includes(tag);
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
case isKindEqual(operator): {
|
|
112
|
-
if ("eq" in operator.kind) {
|
|
113
|
-
const kind2 = operator.kind.eq;
|
|
114
|
-
return (value) => {
|
|
115
|
-
return value.kind === kind2;
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
const kind = operator.kind.neq;
|
|
119
|
-
return (value) => {
|
|
120
|
-
return n(value.kind) || value.kind !== kind;
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
case isNotOperator(operator): {
|
|
124
|
-
const predicate = whereOperatorAsPredicate(operator.not);
|
|
125
|
-
return o(predicate);
|
|
126
|
-
}
|
|
127
|
-
case isAndOperator(operator): {
|
|
128
|
-
const predicates = operator.and.map(whereOperatorAsPredicate);
|
|
129
|
-
return t(predicates);
|
|
130
|
-
}
|
|
131
|
-
case isOrOperator(operator): {
|
|
132
|
-
const predicates = operator.or.map(whereOperatorAsPredicate);
|
|
133
|
-
return y(predicates);
|
|
134
|
-
}
|
|
135
|
-
default:
|
|
136
|
-
nonexhaustive(operator);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const DefaultLineStyle = "dashed";
|
|
141
|
-
const DefaultArrowType = "normal";
|
|
142
|
-
const DefaultRelationshipColor = "gray";
|
|
143
|
-
|
|
144
|
-
export { y as A, o as B, t as C, DefaultLineStyle as D, isElementRef as a, isExpandedElementExpr as b, isCustomElement as c, isWildcard as d, expression as e, isElementKindExpr as f, isElementTagExpr as g, isElement as h, isElementPredicateExpr as i, isElementWhere as j, isRelation as k, isInOut as l, isIncoming as m, isOutgoing as n, isRelationExpression as o, isRelationWhere as p, isCustomRelationExpr as q, isRelationPredicateExpr as r, isTagEqual as s, isKindEqual as t, isNotOperator as u, isAndOperator as v, isOrOperator as w, whereOperatorAsPredicate as x, DefaultArrowType as y, DefaultRelationshipColor as z };
|