@astrale-os/kernel-core 0.9.0-beta.62 → 0.9.0-beta.64
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/auth/authority/admission/admission.d.ts +2 -2
- package/dist/auth/authority/admission/admission.js +10 -8
- package/dist/auth/authority/admission/index.d.ts +1 -1
- package/dist/auth/authority/admission/index.js +1 -1
- package/dist/auth/authority/index.d.ts +7 -3
- package/dist/auth/authority/index.js +4 -2
- package/dist/auth/authority/language/index.d.ts +2 -0
- package/dist/auth/authority/language/index.js +1 -0
- package/dist/auth/authority/language/predicate.d.ts +10 -5
- package/dist/auth/authority/language/predicate.js +1 -1
- package/dist/auth/authority/language/program.d.ts +21 -0
- package/dist/auth/authority/language/program.js +2 -0
- package/dist/auth/authority/normalization/index.d.ts +1 -1
- package/dist/auth/authority/normalization/index.js +1 -1
- package/dist/auth/authority/normalization/normalize.d.ts +1 -1
- package/dist/auth/authority/normalization/normalize.js +4 -5
- package/dist/auth/authority/ownership.optimization.js +2 -2
- package/dist/auth/authority/prepare-binder-body.d.ts +4 -0
- package/dist/auth/authority/prepare-binder-body.js +31 -0
- package/dist/auth/authority/program.d.ts +28 -0
- package/dist/auth/authority/program.js +191 -0
- package/dist/auth/authority/semantics/class-authority.d.ts +8 -0
- package/dist/auth/authority/semantics/class-authority.js +26 -0
- package/dist/auth/authority/semantics/composition.d.ts +39 -0
- package/dist/auth/authority/semantics/composition.js +112 -0
- package/dist/auth/authority/semantics/failure.d.ts +21 -0
- package/dist/auth/authority/semantics/failure.js +10 -0
- package/dist/auth/authority/semantics/index.d.ts +11 -0
- package/dist/auth/authority/semantics/index.js +5 -0
- package/dist/auth/authority/semantics/interpret.d.ts +35 -0
- package/dist/auth/authority/semantics/interpret.js +215 -0
- package/dist/auth/authority/semantics/snapshot.d.ts +34 -0
- package/dist/auth/authority/semantics/terms.d.ts +20 -0
- package/dist/auth/authority/semantics/terms.js +96 -0
- package/dist/auth/authority/semantics/vocabulary.d.ts +19 -0
- package/dist/auth/authority/semantics/vocabulary.js +1 -0
- package/dist/auth/context/context.d.ts +4 -3
- package/dist/auth/expression/authoring/builder.d.ts +2 -11
- package/dist/auth/expression/authoring/builder.js +1 -45
- package/dist/auth/expression/authoring/index.d.ts +1 -1
- package/dist/auth/expression/authoring/index.js +1 -1
- package/dist/auth/expression/index.d.ts +1 -2
- package/dist/auth/expression/index.js +1 -2
- package/dist/auth/expression/language/identity-expression.d.ts +2 -22
- package/dist/auth/grant/index.d.ts +1 -1
- package/dist/auth/grant/index.js +1 -1
- package/dist/auth/grant/resolved/admission.d.ts +4 -3
- package/dist/auth/grant/resolved/admission.js +23 -13
- package/dist/auth/grant/resolved/grant.d.ts +1 -1
- package/dist/auth/grant/resolved/index.d.ts +1 -1
- package/dist/auth/grant/resolved/index.js +1 -1
- package/dist/auth/grant/unresolved/admission.d.ts +4 -1
- package/dist/auth/grant/unresolved/admission.js +27 -67
- package/dist/auth/grant/unresolved/limits.d.ts +2 -4
- package/dist/auth/grant/unresolved/limits.js +1 -5
- package/dist/auth/index.d.ts +1 -1
- package/dist/graph/graph/graph.d.ts +1 -5
- package/dist/graph/graph/graph.js +3 -27
- package/dist/graph/graph/index.d.ts +1 -3
- package/dist/graph/graph/index.js +1 -2
- package/dist/graph/query/index.d.ts +2 -0
- package/dist/graph/query/index.js +1 -0
- package/dist/graph/query/order/index.d.ts +46 -0
- package/dist/graph/query/order/index.js +59 -0
- package/dist/graph/query/reference/evaluate.js +24 -50
- package/dist/graph/reconcile/planning/canonical.d.ts +6 -0
- package/dist/graph/reconcile/planning/canonical.js +28 -0
- package/dist/graph/reconcile/planning/model.d.ts +4 -0
- package/dist/graph/reconcile/planning/plan.js +2 -1
- package/dist/schema/authority/vocabulary.d.ts +3 -0
- package/dist/schema/authority/vocabulary.js +25 -0
- package/dist/schema/identity/composition.d.ts +5 -0
- package/dist/schema/identity/composition.js +5 -0
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +1 -0
- package/dist/schema/introspection/language.d.ts +2 -0
- package/dist/schema/kernel/schema.d.ts +125 -79
- package/dist/schema/kernel/syscalls/contracts/install.d.ts +86 -7
- package/dist/schema/kernel/syscalls/contracts/install.js +6 -3
- package/dist/schema/kernel/syscalls/contracts/installation.d.ts +30 -0
- package/dist/schema/kernel/syscalls/contracts/installation.js +9 -0
- package/dist/schema/kernel/syscalls/contracts/introspect.d.ts +5 -2
- package/dist/schema/kernel/syscalls/contracts/introspect.js +9 -5
- package/dist/schema/kernel/syscalls/contracts/legacy/install.d.ts +22 -0
- package/dist/schema/kernel/syscalls/contracts/legacy/install.js +31 -0
- package/dist/schema/kernel/syscalls/contracts/uninstall.d.ts +10 -0
- package/dist/schema/kernel/syscalls/declarations/index.d.ts +49 -25
- package/dist/schema/kernel/syscalls/declarations/install.d.ts +17 -2
- package/dist/schema/kernel/syscalls/declarations/introspect.d.ts +2 -0
- package/dist/schema/kernel/syscalls/declarations/mutate.d.ts +23 -23
- package/dist/schema/kernel/syscalls/declarations/uninstall.d.ts +7 -0
- package/dist/schema/kernel/syscalls/descriptors/results/view-resolution.d.ts +7 -0
- package/package.json +2 -2
- package/dist/auth/authority/prepare-grant-body.d.ts +0 -4
- package/dist/auth/authority/prepare-grant-body.js +0 -27
- package/dist/auth/expression/normalization/canonicalize.d.ts +0 -7
- package/dist/auth/expression/normalization/canonicalize.js +0 -102
- package/dist/auth/expression/normalization/index.d.ts +0 -2
- package/dist/auth/expression/normalization/index.js +0 -2
- package/dist/auth/expression/normalization/raise-denials.d.ts +0 -3
- package/dist/auth/expression/normalization/raise-denials.js +0 -59
- package/dist/graph/graph/navigation/error.d.ts +0 -12
- package/dist/graph/graph/navigation/error.js +0 -20
- package/dist/graph/graph/navigation/index.d.ts +0 -2
- package/dist/graph/graph/navigation/index.js +0 -1
- package/dist/graph/graph/navigation/model.d.ts +0 -15
- package/dist/schema/kernel/projection/path.d.ts +0 -2
- package/dist/schema/kernel/projection/path.js +0 -113
- /package/dist/{graph/graph/navigation/model.js → auth/authority/semantics/snapshot.js} +0 -0
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as portable from '@astrale-os/kernel-dsl/value';
|
|
2
|
-
import type { IdentityExpr } from '../language/index.js';
|
|
3
|
-
export declare const EXPRESSION_DEPTH_LIMIT = 32;
|
|
4
|
-
export declare const EXPRESSION_OPERAND_LIMIT = 64;
|
|
5
|
-
/** Validate and canonicalize a resolved expression. */
|
|
6
|
-
export declare function canonicalize(expr: IdentityExpr): IdentityExpr;
|
|
7
|
-
export declare function admitResolvedExpression(input: portable.Value, path: string, depth: number): IdentityExpr;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import * as portable from '@astrale-os/kernel-dsl/value';
|
|
2
|
-
import { NodeId } from '../../../graph/node/index.js';
|
|
3
|
-
import { AuthValueError } from '../../error.js';
|
|
4
|
-
export const EXPRESSION_DEPTH_LIMIT = 32;
|
|
5
|
-
export const EXPRESSION_OPERAND_LIMIT = 64;
|
|
6
|
-
/** Validate and canonicalize a resolved expression. */
|
|
7
|
-
export function canonicalize(expr) {
|
|
8
|
-
try {
|
|
9
|
-
return admit(portable.accept(expr), '', 0);
|
|
10
|
-
}
|
|
11
|
-
catch (cause) {
|
|
12
|
-
if (cause instanceof AuthValueError)
|
|
13
|
-
throw cause;
|
|
14
|
-
throw new AuthValueError('AUTH_GRANT_INVALID', 'Expected a resolved Identity expression', '', {
|
|
15
|
-
cause,
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export function admitResolvedExpression(input, path, depth) {
|
|
20
|
-
return admit(input, path, depth);
|
|
21
|
-
}
|
|
22
|
-
function admit(input, path, depth) {
|
|
23
|
-
if (depth > EXPRESSION_DEPTH_LIMIT)
|
|
24
|
-
invalid(path, 'Identity expression exceeds its depth limit');
|
|
25
|
-
const value = record(input, path);
|
|
26
|
-
switch (value.kind) {
|
|
27
|
-
case 'identity':
|
|
28
|
-
exact(value, ['id', 'kind'], path);
|
|
29
|
-
if (typeof value.id !== 'string')
|
|
30
|
-
invalid(`${path}/id`, 'Expected a NodeId');
|
|
31
|
-
return Object.freeze({ kind: 'identity', id: NodeId(value.id) });
|
|
32
|
-
case 'union':
|
|
33
|
-
case 'intersect': {
|
|
34
|
-
exact(value, ['kind', 'operands'], path);
|
|
35
|
-
const source = list(value.operands, `${path}/operands`, 2);
|
|
36
|
-
const kind = value.kind;
|
|
37
|
-
const operands = unique(source
|
|
38
|
-
.map((operand, index) => admit(operand, `${path}/operands/${index}`, depth + 1))
|
|
39
|
-
.flatMap((operand) => (operand.kind === kind ? operand.operands : [operand])));
|
|
40
|
-
if (operands.length > EXPRESSION_OPERAND_LIMIT) {
|
|
41
|
-
invalid(`${path}/operands`, `Expected 2-${EXPRESSION_OPERAND_LIMIT} operands`);
|
|
42
|
-
}
|
|
43
|
-
return operands.length === 1
|
|
44
|
-
? operands[0]
|
|
45
|
-
: Object.freeze({ kind, operands: Object.freeze(operands) });
|
|
46
|
-
}
|
|
47
|
-
case 'exclude': {
|
|
48
|
-
exact(value, ['base', 'excluded', 'kind'], path);
|
|
49
|
-
const excluded = unique(list(value.excluded, `${path}/excluded`, 1)
|
|
50
|
-
.map((operand, index) => admit(operand, `${path}/excluded/${index}`, depth + 1))
|
|
51
|
-
.flatMap((operand) => (operand.kind === 'union' ? operand.operands : [operand])));
|
|
52
|
-
if (excluded.length > EXPRESSION_OPERAND_LIMIT) {
|
|
53
|
-
invalid(`${path}/excluded`, `Expected 1-${EXPRESSION_OPERAND_LIMIT} operands`);
|
|
54
|
-
}
|
|
55
|
-
return Object.freeze({
|
|
56
|
-
kind: 'exclude',
|
|
57
|
-
base: admit(required(value.base, `${path}/base`), `${path}/base`, depth + 1),
|
|
58
|
-
excluded: Object.freeze(excluded),
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
default:
|
|
62
|
-
invalid(`${path}/kind`, 'Expected identity, union, intersect, or exclude');
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function unique(input) {
|
|
66
|
-
const keyed = input
|
|
67
|
-
.map((expr) => ({ expr, key: portable.json.serialize(expr) }))
|
|
68
|
-
.sort((left, right) => compare(left.key, right.key));
|
|
69
|
-
return keyed
|
|
70
|
-
.filter((entry, index) => index === 0 || entry.key !== keyed[index - 1].key)
|
|
71
|
-
.map((entry) => entry.expr);
|
|
72
|
-
}
|
|
73
|
-
function record(input, path) {
|
|
74
|
-
if (input === null || Array.isArray(input) || typeof input !== 'object') {
|
|
75
|
-
invalid(path, 'Expected an object');
|
|
76
|
-
}
|
|
77
|
-
return input;
|
|
78
|
-
}
|
|
79
|
-
function list(input, path, minimum) {
|
|
80
|
-
if (!Array.isArray(input) || input.length < minimum || input.length > EXPRESSION_OPERAND_LIMIT) {
|
|
81
|
-
invalid(path, `Expected ${minimum}-${EXPRESSION_OPERAND_LIMIT} operands`);
|
|
82
|
-
}
|
|
83
|
-
return input;
|
|
84
|
-
}
|
|
85
|
-
function required(input, path) {
|
|
86
|
-
if (input === undefined)
|
|
87
|
-
invalid(path, 'Expected a value');
|
|
88
|
-
return input;
|
|
89
|
-
}
|
|
90
|
-
function exact(value, expected, path) {
|
|
91
|
-
const actual = Object.keys(value).sort(compare);
|
|
92
|
-
const wanted = [...expected].sort(compare);
|
|
93
|
-
if (actual.length !== wanted.length || actual.some((key, index) => key !== wanted[index])) {
|
|
94
|
-
invalid(path, `Expected exactly ${expected.join(', ')}`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function compare(left, right) {
|
|
98
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
99
|
-
}
|
|
100
|
-
function invalid(path, message) {
|
|
101
|
-
throw new AuthValueError('AUTH_GRANT_INVALID', message, path);
|
|
102
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/** Raise every positive-position exclusion into one Grant-wide veto. */
|
|
2
|
-
export function raiseDenials(expr) {
|
|
3
|
-
const denials = [...collectDenials(expr, new WeakMap())];
|
|
4
|
-
if (denials.length === 0)
|
|
5
|
-
return expr;
|
|
6
|
-
return Object.freeze({
|
|
7
|
-
kind: 'exclude',
|
|
8
|
-
base: stripExcludes(expr, new WeakMap()),
|
|
9
|
-
excluded: Object.freeze(denials),
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
function stripExcludes(expr, memo) {
|
|
13
|
-
const cached = memo.get(expr);
|
|
14
|
-
if (cached !== undefined)
|
|
15
|
-
return cached;
|
|
16
|
-
let stripped;
|
|
17
|
-
switch (expr.kind) {
|
|
18
|
-
case 'identity':
|
|
19
|
-
stripped = expr;
|
|
20
|
-
break;
|
|
21
|
-
case 'union':
|
|
22
|
-
case 'intersect':
|
|
23
|
-
stripped = Object.freeze({
|
|
24
|
-
kind: expr.kind,
|
|
25
|
-
operands: Object.freeze(expr.operands.map((operand) => stripExcludes(operand, memo))),
|
|
26
|
-
});
|
|
27
|
-
break;
|
|
28
|
-
case 'exclude':
|
|
29
|
-
stripped = stripExcludes(expr.base, memo);
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
memo.set(expr, stripped);
|
|
33
|
-
return stripped;
|
|
34
|
-
}
|
|
35
|
-
function collectDenials(expr, memo) {
|
|
36
|
-
const cached = memo.get(expr);
|
|
37
|
-
if (cached !== undefined)
|
|
38
|
-
return cached;
|
|
39
|
-
const denials = new Set();
|
|
40
|
-
switch (expr.kind) {
|
|
41
|
-
case 'identity':
|
|
42
|
-
break;
|
|
43
|
-
case 'union':
|
|
44
|
-
case 'intersect':
|
|
45
|
-
for (const operand of expr.operands) {
|
|
46
|
-
for (const denial of collectDenials(operand, memo))
|
|
47
|
-
denials.add(denial);
|
|
48
|
-
}
|
|
49
|
-
break;
|
|
50
|
-
case 'exclude':
|
|
51
|
-
for (const excluded of expr.excluded)
|
|
52
|
-
denials.add(excluded);
|
|
53
|
-
for (const denial of collectDenials(expr.base, memo))
|
|
54
|
-
denials.add(denial);
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
memo.set(expr, denials);
|
|
58
|
-
return denials;
|
|
59
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { NodePath } from '../../path/index.js';
|
|
2
|
-
export declare class GraphPathAmbiguousError extends Error {
|
|
3
|
-
readonly path: NodePath;
|
|
4
|
-
readonly matches: number;
|
|
5
|
-
readonly code: 'GRAPH_PATH_AMBIGUOUS';
|
|
6
|
-
constructor(path: NodePath, matches: number);
|
|
7
|
-
}
|
|
8
|
-
export declare class GraphPathWalkerRequiredError extends Error {
|
|
9
|
-
readonly path: NodePath;
|
|
10
|
-
readonly code: 'GRAPH_PATH_WALKER_REQUIRED';
|
|
11
|
-
constructor(path: NodePath);
|
|
12
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export class GraphPathAmbiguousError extends Error {
|
|
2
|
-
path;
|
|
3
|
-
matches;
|
|
4
|
-
code = 'GRAPH_PATH_AMBIGUOUS';
|
|
5
|
-
constructor(path, matches) {
|
|
6
|
-
super(`Graph Path ${JSON.stringify(path)} matched ${matches} distinct Nodes.`);
|
|
7
|
-
this.path = path;
|
|
8
|
-
this.matches = matches;
|
|
9
|
-
this.name = 'GraphPathAmbiguousError';
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export class GraphPathWalkerRequiredError extends Error {
|
|
13
|
-
path;
|
|
14
|
-
code = 'GRAPH_PATH_WALKER_REQUIRED';
|
|
15
|
-
constructor(path) {
|
|
16
|
-
super(`Graph Path ${JSON.stringify(path)} requires a walker.`);
|
|
17
|
-
this.path = path;
|
|
18
|
-
this.name = 'GraphPathWalkerRequiredError';
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { GraphPathAmbiguousError, GraphPathWalkerRequiredError } from './error.js';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ClassKey } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
2
|
-
import type { EdgeOrientation } from '@astrale-os/kernel-dsl/v1/language';
|
|
3
|
-
import type { Node } from '../../node/index.js';
|
|
4
|
-
import type { Path } from '../../path/index.js';
|
|
5
|
-
import type { GraphEdges, GraphNodes } from '../indexes/index.js';
|
|
6
|
-
/** Semantic read-only graph capabilities available to a Path walker. */
|
|
7
|
-
export interface GraphPathContext {
|
|
8
|
-
readonly nodes: GraphNodes;
|
|
9
|
-
readonly edges: GraphEdges;
|
|
10
|
-
orientation(classKey: ClassKey): EdgeOrientation | undefined;
|
|
11
|
-
}
|
|
12
|
-
/** Pure injected semantics for walking one Path against an admitted Graph. */
|
|
13
|
-
export interface GraphPathWalker {
|
|
14
|
-
walk(path: Path, context: GraphPathContext): Node | undefined;
|
|
15
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { ClassKey } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
2
|
-
import { GraphPathAmbiguousError } from '#graph/graph';
|
|
3
|
-
import { K } from '../index.js';
|
|
4
|
-
export const projectionPathWalker = Object.freeze({
|
|
5
|
-
walk: walkProjectionPath,
|
|
6
|
-
});
|
|
7
|
-
function walkProjectionPath(path, context) {
|
|
8
|
-
let candidates = anchorCandidates(path.ast, context);
|
|
9
|
-
for (const step of path.ast.steps)
|
|
10
|
-
candidates = applyStep(candidates, step, context);
|
|
11
|
-
if (candidates.length === 0)
|
|
12
|
-
return undefined;
|
|
13
|
-
if (candidates.length === 1)
|
|
14
|
-
return candidates[0];
|
|
15
|
-
throw new GraphPathAmbiguousError(path.raw, candidates.length);
|
|
16
|
-
}
|
|
17
|
-
function anchorCandidates(ast, context) {
|
|
18
|
-
if (ast.anchor.kind === 'id') {
|
|
19
|
-
const node = context.nodes.byId(ast.anchor.id);
|
|
20
|
-
return node === undefined ? [] : [node];
|
|
21
|
-
}
|
|
22
|
-
const domainClass = ClassKey.of(K.classes.Domain.ref);
|
|
23
|
-
const origin = ast.anchor.origin;
|
|
24
|
-
return context.nodes
|
|
25
|
-
.byClass(domainClass)
|
|
26
|
-
.filter((node) => node.props[K.classes.Domain.properties.origin.key] === origin);
|
|
27
|
-
}
|
|
28
|
-
function applyStep(current, step, context) {
|
|
29
|
-
switch (step.kind) {
|
|
30
|
-
case 'projection':
|
|
31
|
-
return domainMembers(current, `${step.projection.kind}.${step.projection.name}`, context);
|
|
32
|
-
case 'method':
|
|
33
|
-
return step.dispatch === 'static'
|
|
34
|
-
? directMethods(current, step.name, true, context)
|
|
35
|
-
: instanceMethods(current.filter((node) => node.class === step.class), step.name, context);
|
|
36
|
-
case 'traverse':
|
|
37
|
-
return traverse(current, step, context);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function domainMembers(domains, member, context) {
|
|
41
|
-
const domainIds = new Set(domains.map((node) => node.id));
|
|
42
|
-
return distinctNodes(edgesOf(K.classes.of_domain, context).flatMap((edge) => {
|
|
43
|
-
if (!domainIds.has(edge.target) ||
|
|
44
|
-
edge.props[K.classes.of_domain.properties.member.key] !== member) {
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
const node = context.nodes.byId(edge.source);
|
|
48
|
-
return node === undefined ? [] : [node];
|
|
49
|
-
}));
|
|
50
|
-
}
|
|
51
|
-
function directMethods(owners, name, isStatic, context) {
|
|
52
|
-
const ownerIds = new Set(owners.map((node) => node.id));
|
|
53
|
-
return distinctNodes(edgesOf(K.classes.method_of, context).flatMap((edge) => {
|
|
54
|
-
if (!ownerIds.has(edge.target) ||
|
|
55
|
-
edge.props[K.classes.method_of.properties.name.key] !== name ||
|
|
56
|
-
edge.props[K.classes.method_of.properties.static.key] !== isStatic) {
|
|
57
|
-
return [];
|
|
58
|
-
}
|
|
59
|
-
const method = context.nodes.byId(edge.source);
|
|
60
|
-
return method === undefined ? [] : [method];
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
63
|
-
function instanceMethods(instances, name, context) {
|
|
64
|
-
return distinctNodes(instances.flatMap((instance) => {
|
|
65
|
-
const owner = resolveClassProjection(instance.class, context);
|
|
66
|
-
return owner.length === 0 ? [] : directMethods(owner, name, false, context);
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
function resolveClassProjection(key, context) {
|
|
70
|
-
const domainClass = ClassKey.of(K.classes.Domain.ref);
|
|
71
|
-
const domains = context.nodes
|
|
72
|
-
.byClass(domainClass)
|
|
73
|
-
.filter((node) => node.props[K.classes.Domain.properties.origin.key] === ClassKey.ref(key).origin);
|
|
74
|
-
return domainMembers(domains, `class.${ClassKey.ref(key).name}`, context);
|
|
75
|
-
}
|
|
76
|
-
function traverse(current, step, context) {
|
|
77
|
-
const currentIds = new Set(current.map((node) => node.id));
|
|
78
|
-
const edgeClass = step.class;
|
|
79
|
-
const orientation = context.orientation(edgeClass);
|
|
80
|
-
const candidates = context.edges.byClass(edgeClass);
|
|
81
|
-
return distinctNodes(candidates.flatMap((edge) => {
|
|
82
|
-
if (step.slug !== undefined && edge.slug !== step.slug)
|
|
83
|
-
return [];
|
|
84
|
-
const endpoint = traversedEndpoint(edge, currentIds, step.direction, orientation);
|
|
85
|
-
if (endpoint === undefined)
|
|
86
|
-
return [];
|
|
87
|
-
const node = context.nodes.byId(endpoint);
|
|
88
|
-
return node === undefined ? [] : [node];
|
|
89
|
-
}));
|
|
90
|
-
}
|
|
91
|
-
function traversedEndpoint(edge, current, direction, orientation) {
|
|
92
|
-
if (orientation === 'undirected') {
|
|
93
|
-
if (current.has(edge.source))
|
|
94
|
-
return edge.target;
|
|
95
|
-
if (current.has(edge.target))
|
|
96
|
-
return edge.source;
|
|
97
|
-
return undefined;
|
|
98
|
-
}
|
|
99
|
-
if (direction === 'out' && current.has(edge.source))
|
|
100
|
-
return edge.target;
|
|
101
|
-
if (direction === 'in' && current.has(edge.target))
|
|
102
|
-
return edge.source;
|
|
103
|
-
return undefined;
|
|
104
|
-
}
|
|
105
|
-
function edgesOf(relation, context) {
|
|
106
|
-
return context.edges.byClass(ClassKey.of(relation.ref));
|
|
107
|
-
}
|
|
108
|
-
function distinctNodes(nodes) {
|
|
109
|
-
const byId = new Map();
|
|
110
|
-
for (const node of nodes)
|
|
111
|
-
byId.set(node.id, node);
|
|
112
|
-
return [...byId.values()];
|
|
113
|
-
}
|
|
File without changes
|