@astrale-os/kernel-client 0.6.0-beta.10 → 0.6.0-beta.12
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.
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DomainDependency } from '@astrale-os/kernel-dsl/v1/schema';
|
|
2
|
+
/** Detach one caller-owned expected closure before crossing the Client boundary. */
|
|
3
|
+
export declare function captureExpected(input: readonly DomainDependency[] | undefined): readonly DomainDependency[] | undefined;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Detach one caller-owned expected closure before crossing the Client boundary. */
|
|
2
|
+
export function captureExpected(input) {
|
|
3
|
+
if (input === undefined)
|
|
4
|
+
return undefined;
|
|
5
|
+
return Object.freeze(input.map(({ origin, revision }) => Object.freeze({ origin, revision })));
|
|
6
|
+
}
|
package/dist/graph/graph.d.ts
CHANGED
|
@@ -13,11 +13,14 @@ export interface GraphQueryOptions extends RequestOptions {
|
|
|
13
13
|
readonly expected?: readonly DomainDependency[];
|
|
14
14
|
readonly page: QueryPageRequest;
|
|
15
15
|
}
|
|
16
|
+
export interface GraphMutationOptions extends RequestOptions {
|
|
17
|
+
readonly expected?: readonly DomainDependency[];
|
|
18
|
+
}
|
|
16
19
|
export type MutationAuthor = (mutation: MutationBuilder) => undefined;
|
|
17
20
|
export interface GraphApi {
|
|
18
21
|
query<Query extends QueryASTValue>(ast: Query, options: GraphQueryOptions): Promise<QueryResponse<QueryResultFor<Query>>>;
|
|
19
|
-
mutate(author: MutationAuthor, options?:
|
|
20
|
-
mutate(ast: MutationASTValue | MutationInput | GraphSpec, options?:
|
|
22
|
+
mutate(author: MutationAuthor, options?: GraphMutationOptions): Promise<MutationResultValue>;
|
|
23
|
+
mutate(ast: MutationASTValue | MutationInput | GraphSpec, options?: GraphMutationOptions): Promise<MutationResultValue>;
|
|
21
24
|
get(target: NodeTarget, options?: RequestOptions): Promise<Node | null>;
|
|
22
25
|
getOrThrow(target: NodeTarget, options?: RequestOptions): Promise<Node>;
|
|
23
26
|
neighbors(source: NodeTarget, via: QueryEdgeClassInput | readonly [QueryEdgeClassInput, ...QueryEdgeClassInput[]], options: NeighborsOptions): Promise<NodePage>;
|
package/dist/graph/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createGraph, type GraphApi, type GraphCall, type GraphQueryOptions, type MutationAuthor, } from './graph.js';
|
|
1
|
+
export { createGraph, type GraphApi, type GraphCall, type GraphMutationOptions, type GraphQueryOptions, type MutationAuthor, } from './graph.js';
|
|
2
2
|
export type { QueryPageRequest, QueryResponse } from './page-contract.js';
|
|
3
3
|
export { type BoundEdge, type BoundEdgePage, type BoundGraphValue, type BoundNode, type BoundNodeFor, type BoundNodePage, type BoundQueryPage, type DomainBinding, type DomainQueryOptions, } from './domain/index.js';
|
|
4
4
|
export { NodeUnavailableError } from './errors.js';
|
package/dist/graph/mutation.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { GraphSpec } from '@astrale-os/kernel-core/graph/graph';
|
|
2
2
|
import type { MutationAST as MutationASTValue, MutationInput, MutationResult as MutationResultValue } from '@astrale-os/kernel-core/graph/mutate';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
export declare function mutateGraph(call: GraphCall, input: MutationAuthor | MutationASTValue | MutationInput | GraphSpec, options?: RequestOptions): Promise<MutationResultValue>;
|
|
3
|
+
import type { GraphCall, GraphMutationOptions, MutationAuthor } from './graph.js';
|
|
4
|
+
export declare function mutateGraph(call: GraphCall, input: MutationAuthor | MutationASTValue | MutationInput | GraphSpec, options?: GraphMutationOptions): Promise<MutationResultValue>;
|
package/dist/graph/mutation.js
CHANGED
|
@@ -2,10 +2,19 @@ import { MutationAST, MutationResult } from '@astrale-os/kernel-core/graph/mutat
|
|
|
2
2
|
import { Path } from '@astrale-os/kernel-core/path';
|
|
3
3
|
import { mutate } from '@astrale-os/kernel-core/schema/kernel/syscalls/references';
|
|
4
4
|
import { call as invocation } from '../client/index.js';
|
|
5
|
+
import { captureExpected } from './expectation.js';
|
|
5
6
|
const KERNEL_MUTATE_PATH = Path.project(mutate).raw;
|
|
6
7
|
export async function mutateGraph(call, input, options) {
|
|
7
8
|
const ast = typeof input === 'function' ? MutationAST.build(input) : admitMutation(input);
|
|
8
|
-
const
|
|
9
|
+
const expected = options?.expected;
|
|
10
|
+
const request = options === undefined
|
|
11
|
+
? undefined
|
|
12
|
+
: (({ expected: _expected, ...rest }) => rest)(options);
|
|
13
|
+
const capturedExpected = captureExpected(expected);
|
|
14
|
+
const output = await call(invocation(KERNEL_MUTATE_PATH, Object.freeze({
|
|
15
|
+
ast,
|
|
16
|
+
...(capturedExpected === undefined ? {} : { expected: capturedExpected }),
|
|
17
|
+
})), request);
|
|
9
18
|
return MutationResult.decode(output);
|
|
10
19
|
}
|
|
11
20
|
function admitMutation(input) {
|
package/dist/graph/query.js
CHANGED
|
@@ -2,6 +2,7 @@ import { QueryAST, QueryResult } from '@astrale-os/kernel-core/graph/query';
|
|
|
2
2
|
import { Path } 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
|
+
import { captureExpected } from './expectation.js';
|
|
5
6
|
import { retainQueryProvenance } from './provenance.js';
|
|
6
7
|
const KERNEL_QUERY_PATH = Path.project(query).raw;
|
|
7
8
|
export async function queryGraph(call, input, options) {
|
|
@@ -19,11 +20,6 @@ export async function queryGraph(call, input, options) {
|
|
|
19
20
|
? response
|
|
20
21
|
: retainQueryProvenance(response, capturedExpected);
|
|
21
22
|
}
|
|
22
|
-
function captureExpected(input) {
|
|
23
|
-
if (input === undefined)
|
|
24
|
-
return undefined;
|
|
25
|
-
return Object.freeze(input.map(({ origin, revision }) => Object.freeze({ origin, revision })));
|
|
26
|
-
}
|
|
27
23
|
function admitPage(input) {
|
|
28
24
|
if (input === null || typeof input !== 'object' || Array.isArray(input)) {
|
|
29
25
|
throw new TypeError('Graph query page is invalid.');
|
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.12",
|
|
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.10 <1.0.0",
|
|
69
|
+
"@astrale-os/kernel-dsl": ">=0.2.0-beta.8 <1.0.0",
|
|
70
|
+
"@astrale-os/kernel-protocol": ">=0.5.0-beta.10 <1.0.0",
|
|
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.11 <1.0.0",
|
|
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",
|