@astrale-os/kernel-client 0.6.0-beta.47 → 0.6.0-beta.49
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.
|
@@ -78,6 +78,13 @@ void methodlessParentAcceptsChild;
|
|
|
78
78
|
const documentRejectsResource = resourceProjection;
|
|
79
79
|
void documentRejectsResource;
|
|
80
80
|
async function typeProof() {
|
|
81
|
+
await graph.get(definitionRef);
|
|
82
|
+
await graph.getOrThrow(definitionRef);
|
|
83
|
+
await graph.get(Work.classes.Resource.ref);
|
|
84
|
+
await graph.neighbors(definitionRef, Work.classes.Related.ref, {
|
|
85
|
+
direction: 'outgoing',
|
|
86
|
+
page: { size: 1 },
|
|
87
|
+
});
|
|
81
88
|
const page = await binding.query(query, { page: { size: 10 } });
|
|
82
89
|
const resource = page.nodes[0];
|
|
83
90
|
const title = resource.title;
|
package/dist/graph/errors.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isNodeId } from '@astrale-os/kernel-core/graph/node';
|
|
2
1
|
import { Path } from '@astrale-os/kernel-core/path';
|
|
3
2
|
import { ClientError } from '../errors/index.js';
|
|
4
3
|
/** Required point read whose absence and authorization masking are intentionally indistinguishable. */
|
|
@@ -6,7 +5,7 @@ export class NodeUnavailableError extends ClientError {
|
|
|
6
5
|
code = 'NODE_UNAVAILABLE';
|
|
7
6
|
path;
|
|
8
7
|
constructor(path) {
|
|
9
|
-
const admitted =
|
|
8
|
+
const admitted = Path.target(path).raw;
|
|
10
9
|
super(`Node ${JSON.stringify(admitted)} is unavailable.`);
|
|
11
10
|
this.name = 'NodeUnavailableError';
|
|
12
11
|
this.path = admitted;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Query } from '@astrale-os/kernel-core/graph/query';
|
|
2
|
+
import { queryNodePath } from '../query.js';
|
|
2
3
|
import { createNodePage } from './page.js';
|
|
3
4
|
export async function readNeighbors(query, source, via, options) {
|
|
4
5
|
if (options === null || typeof options !== 'object') {
|
|
@@ -15,7 +16,7 @@ export async function readNeighbors(query, source, via, options) {
|
|
|
15
16
|
: options.direction === 'incident'
|
|
16
17
|
? options.direction
|
|
17
18
|
: invalidDirection(options.direction);
|
|
18
|
-
const ast = Query.from({ nodes: [source] })
|
|
19
|
+
const ast = Query.from({ nodes: [queryNodePath(source)] })
|
|
19
20
|
.expand({ via: [classInput, ...additionalClasses], direction })
|
|
20
21
|
.select({ kind: 'graph' });
|
|
21
22
|
const { direction: _, page, ...request } = options;
|
package/dist/graph/query.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { QueryAST as QueryASTValue, QueryResultFor } from '@astrale-os/kernel-core/graph/query';
|
|
2
|
+
import { Path, type NodeTarget } from '@astrale-os/kernel-core/path';
|
|
2
3
|
import type { GraphCall, GraphQueryOptions } from './graph.js';
|
|
3
4
|
import type { QueryResponse } from './page-contract.js';
|
|
5
|
+
/** Point/neighbor reads are exact targets, unlike Query's overloaded Class sources. */
|
|
6
|
+
export declare function queryNodePath(target: NodeTarget): Path;
|
|
4
7
|
export declare function queryGraph<Query extends QueryASTValue>(call: GraphCall, input: Query, options: GraphQueryOptions): Promise<QueryResponse<QueryResultFor<Query>>>;
|
package/dist/graph/query.js
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import { QueryAST, QueryResult } from '@astrale-os/kernel-core/graph/query';
|
|
2
|
-
import { Path } from '@astrale-os/kernel-core/path';
|
|
1
|
+
import { QueryAST, QueryASTDecodeError, QueryResult } from '@astrale-os/kernel-core/graph/query';
|
|
2
|
+
import { Path, PathError } from '@astrale-os/kernel-core/path';
|
|
3
3
|
import { query } from '@astrale-os/kernel-core/schema/kernel/syscalls/references';
|
|
4
4
|
import { call as invocation } from '../client/index.js';
|
|
5
5
|
import { captureExpected } from './expectation.js';
|
|
6
6
|
import { retainQueryProvenance } from './provenance.js';
|
|
7
7
|
const KERNEL_QUERY_PATH = Path.project(query).raw;
|
|
8
|
+
/** Point/neighbor reads are exact targets, unlike Query's overloaded Class sources. */
|
|
9
|
+
export function queryNodePath(target) {
|
|
10
|
+
try {
|
|
11
|
+
return Path.target(target);
|
|
12
|
+
}
|
|
13
|
+
catch (cause) {
|
|
14
|
+
// Preserve the graph-read Query error contract; do not relabel unexpected defects.
|
|
15
|
+
if (!(cause instanceof PathError))
|
|
16
|
+
throw cause;
|
|
17
|
+
throw new QueryASTDecodeError('/source/nodes/0', 'Invalid Node target', { cause });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
8
20
|
export async function queryGraph(call, input, options) {
|
|
9
21
|
const ast = QueryAST.decode(input);
|
|
10
22
|
const { expected, page, ...request } = options;
|
package/dist/graph/read.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Query } from '@astrale-os/kernel-core/graph/query';
|
|
2
2
|
import { NodeUnavailableError } from './errors.js';
|
|
3
|
-
import { queryGraph } from './query.js';
|
|
3
|
+
import { queryGraph, queryNodePath } from './query.js';
|
|
4
4
|
export async function getNode(call, path, options) {
|
|
5
|
-
const ast = Query.from({ nodes: [path] }).select({ kind: 'graph' });
|
|
5
|
+
const ast = Query.from({ nodes: [queryNodePath(path)] }).select({ kind: 'graph' });
|
|
6
6
|
const response = await queryGraph(call, ast, { ...options, page: { size: 1 } });
|
|
7
7
|
const { result } = response;
|
|
8
8
|
if (result.kind !== 'graph')
|
|
@@ -10,8 +10,10 @@ export async function getNode(call, path, options) {
|
|
|
10
10
|
return result.graph.nodes[0] ?? null;
|
|
11
11
|
}
|
|
12
12
|
export async function requireNode(call, path, options) {
|
|
13
|
-
|
|
13
|
+
// Retain one immutable target across I/O, including unavailable-error rendering.
|
|
14
|
+
const target = queryNodePath(path);
|
|
15
|
+
const node = await getNode(call, target, options);
|
|
14
16
|
if (node === null)
|
|
15
|
-
throw new NodeUnavailableError(
|
|
17
|
+
throw new NodeUnavailableError(target);
|
|
16
18
|
return node;
|
|
17
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrale-os/kernel-client",
|
|
3
|
-
"version": "0.6.0-beta.
|
|
3
|
+
"version": "0.6.0-beta.49",
|
|
4
4
|
"description": "Universal Client — protocol-first, transport-agnostic",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astrale",
|
|
@@ -65,14 +65,14 @@
|
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@astrale-os/kernel-core": "0.9.0-beta.
|
|
69
|
-
"@astrale-os/kernel-dsl": "0.2.0-beta.
|
|
70
|
-
"@astrale-os/kernel-protocol": "0.5.0-beta.
|
|
68
|
+
"@astrale-os/kernel-core": "0.9.0-beta.37",
|
|
69
|
+
"@astrale-os/kernel-dsl": "0.2.0-beta.28",
|
|
70
|
+
"@astrale-os/kernel-protocol": "0.5.0-beta.40",
|
|
71
71
|
"@tanstack/pacer": "0.20.1",
|
|
72
72
|
"msgpackr": "^2.0.5"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@astrale-os/kernel-server": "0.5.0-beta.
|
|
75
|
+
"@astrale-os/kernel-server": "0.5.0-beta.42",
|
|
76
76
|
"@astrale/typescript-config": "npm:@jsr/astrale__typescript-config@~1.1.0",
|
|
77
77
|
"@types/node": "^22.0.0",
|
|
78
78
|
"typescript": "7.0.2",
|