@astrale-os/kernel-client 1.0.0-beta.4 → 1.0.0-beta.41
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/index.d.ts +1 -0
- package/dist/client/admission.js +3 -1
- package/dist/client/client.d.ts +19 -2
- package/dist/client/client.js +62 -30
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.js +2 -2
- package/dist/client/request.d.ts +8 -2
- package/dist/client/request.js +28 -7
- package/dist/client/result.d.ts +10 -1
- package/dist/client/result.js +10 -4
- package/dist/client/routing-control.d.ts +11 -15
- package/dist/client/routing-control.js +21 -29
- package/dist/errors/index.d.ts +3 -0
- package/dist/errors/index.js +3 -0
- package/dist/errors/query-input.d.ts +47 -0
- package/dist/errors/query-input.js +85 -0
- package/dist/errors/refusal.d.ts +24 -0
- package/dist/errors/refusal.js +78 -0
- package/dist/errors/response-too-large-error.d.ts +11 -0
- package/dist/errors/response-too-large-error.js +15 -0
- package/dist/errors/stale-route-error.d.ts +1 -1
- package/dist/errors/stale-route-error.js +1 -1
- package/dist/{schema → execution}/admission.d.ts +2 -2
- package/dist/{schema → execution}/admission.js +3 -3
- package/dist/execution/contracts.d.ts +76 -0
- package/dist/execution/contracts.js +1 -0
- package/dist/execution/deadline.d.ts +18 -0
- package/dist/execution/deadline.js +25 -0
- package/dist/execution/execution.d.ts +61 -0
- package/dist/execution/execution.js +132 -0
- package/dist/execution/index.d.ts +4 -0
- package/dist/execution/index.js +3 -0
- package/dist/graph/domain/binding.d.ts +2 -2
- package/dist/graph/domain/binding.js +24 -17
- package/dist/graph/domain/conformance.d.ts +12 -0
- package/dist/graph/domain/conformance.js +18 -0
- package/dist/graph/domain/index.d.ts +1 -0
- package/dist/graph/domain/index.js +1 -1
- package/dist/graph/domain/provenance.d.ts +0 -2
- package/dist/graph/domain/provenance.js +0 -4
- package/dist/graph/graph.d.ts +17 -3
- package/dist/graph/graph.js +4 -1
- package/dist/graph/index.d.ts +3 -3
- package/dist/graph/index.js +1 -1
- package/dist/graph/page-contract.d.ts +66 -1
- package/dist/graph/provenance.d.ts +4 -5
- package/dist/graph/provenance.js +5 -6
- package/dist/graph/query.d.ts +10 -4
- package/dist/graph/query.js +149 -7
- package/dist/graph/query.typecheck.d.ts +79 -0
- package/dist/graph/query.typecheck.js +34 -0
- package/dist/pacer/index.d.ts +1 -1
- package/dist/pacer/index.js +1 -1
- package/dist/pacer/retry/index.d.ts +1 -0
- package/dist/pacer/retry/index.js +1 -0
- package/dist/pacer/retry/refusals.d.ts +7 -0
- package/dist/pacer/retry/refusals.js +10 -0
- package/dist/pacer/retry/retry.d.ts +2 -0
- package/dist/pacer/retry/retry.js +33 -1
- package/dist/schema/contracts.d.ts +77 -9
- package/dist/schema/index.d.ts +3 -2
- package/dist/schema/index.js +1 -1
- package/dist/schema/installation.d.ts +76 -0
- package/dist/schema/installation.js +82 -0
- package/dist/schema/schema.d.ts +22 -13
- package/dist/schema/schema.js +67 -48
- package/dist/session/admission.js +10 -3
- package/dist/session/bound.d.ts +12 -3
- package/dist/session/bound.js +66 -20
- package/dist/session/content/api.d.ts +20 -2
- package/dist/session/content/api.js +17 -7
- package/dist/session/content/files.d.ts +12 -0
- package/dist/session/content/files.js +47 -0
- package/dist/session/content/index.d.ts +1 -1
- package/dist/session/content/input.d.ts +13 -2
- package/dist/session/content/input.js +25 -4
- package/dist/session/content/retry.d.ts +5 -1
- package/dist/session/content/retry.js +21 -31
- package/dist/session/context/index.d.ts +1 -1
- package/dist/session/context/index.js +1 -1
- package/dist/session/context/operation.d.ts +2 -0
- package/dist/session/context/operation.js +5 -0
- package/dist/session/credential/credentials.js +43 -28
- package/dist/session/discovery/bundle.d.ts +9 -4
- package/dist/session/discovery/bundle.js +28 -35
- package/dist/session/discovery/discovery.d.ts +1 -1
- package/dist/session/discovery/discovery.js +8 -11
- package/dist/session/discovery/release.js +18 -28
- package/dist/session/discovery/snapshot.d.ts +5 -1
- package/dist/session/discovery/transport.d.ts +35 -3
- package/dist/session/discovery/transport.js +40 -1
- package/dist/session/durable.d.ts +13 -0
- package/dist/session/durable.js +39 -0
- package/dist/session/exchange/exchange.d.ts +3 -2
- package/dist/session/exchange/exchange.js +10 -7
- package/dist/session/exchange/index.d.ts +1 -1
- package/dist/session/exchange/index.js +1 -1
- package/dist/session/exchange/presentation.js +28 -10
- package/dist/session/exchange/source.d.ts +7 -7
- package/dist/session/exchange/source.js +26 -27
- package/dist/session/index.d.ts +5 -4
- package/dist/session/index.js +0 -1
- package/dist/session/options.d.ts +0 -2
- package/dist/session/options.js +0 -3
- package/dist/session/reference.d.ts +27 -6
- package/dist/session/reference.js +18 -3
- package/dist/session/retry.d.ts +12 -0
- package/dist/session/retry.js +23 -0
- package/dist/session/routing/auth.d.ts +9 -3
- package/dist/session/routing/auth.js +4 -3
- package/dist/session/routing/cache.d.ts +12 -5
- package/dist/session/routing/cache.js +56 -48
- package/dist/session/routing/dispatch.d.ts +26 -3
- package/dist/session/routing/dispatch.js +112 -67
- package/dist/session/routing/envelope.d.ts +3 -3
- package/dist/session/routing/index.d.ts +1 -1
- package/dist/session/routing/legacy/release-route.d.ts +12 -0
- package/dist/session/routing/legacy/release-route.js +6 -0
- package/dist/session/routing/recovery.d.ts +3 -6
- package/dist/session/routing/recovery.js +3 -14
- package/dist/session/routing/request.d.ts +6 -1
- package/dist/session/routing/request.js +13 -2
- package/dist/session/routing/result.d.ts +1 -1
- package/dist/session/routing/result.js +5 -1
- package/dist/session/routing/store.js +4 -5
- package/dist/session/session.d.ts +31 -5
- package/dist/session/session.js +67 -20
- package/dist/session/session.typecheck.js +20 -6
- package/dist/session/views/index.d.ts +2 -2
- package/dist/session/views/index.js +2 -2
- package/dist/session/views/kernel.d.ts +31 -0
- package/dist/session/views/kernel.js +30 -0
- package/dist/session/views/legacy/catalog.d.ts +21 -0
- package/dist/session/views/{catalog.js → legacy/catalog.js} +7 -31
- package/dist/session/views/legacy/index.d.ts +14 -0
- package/dist/session/views/legacy/index.js +14 -0
- package/dist/session/views/legacy/resolve.d.ts +46 -0
- package/dist/session/views/legacy/resolve.js +83 -0
- package/dist/session/views/legacy/unplaced.d.ts +22 -0
- package/dist/session/views/legacy/unplaced.js +26 -0
- package/dist/session/views/read.d.ts +49 -0
- package/dist/session/views/read.js +148 -0
- package/dist/session/views/view.d.ts +48 -0
- package/dist/session/views/view.js +74 -0
- package/dist/store/memory.d.ts +1 -3
- package/dist/store/memory.js +73 -105
- package/dist/store/shape.d.ts +33 -12
- package/dist/store/shape.js +125 -16
- package/dist/store/store.d.ts +6 -6
- package/dist/store/store.js +1 -1
- package/dist/transport/auto/decision.d.ts +26 -14
- package/dist/transport/auto/decision.js +35 -32
- package/dist/transport/auto/fallback.d.ts +1 -1
- package/dist/transport/auto/fallback.js +5 -10
- package/dist/transport/auto/transport.d.ts +0 -2
- package/dist/transport/auto/transport.js +24 -32
- package/dist/transport/deadline.d.ts +2 -0
- package/dist/transport/deadline.js +18 -0
- package/dist/transport/failure.d.ts +28 -1
- package/dist/transport/failure.js +63 -1
- package/dist/transport/http/admission.js +7 -34
- package/dist/transport/http/binary-request.d.ts +44 -0
- package/dist/transport/http/binary-request.js +110 -0
- package/dist/transport/http/binary.js +3 -3
- package/dist/transport/http/byte-stream.d.ts +2 -1
- package/dist/transport/http/byte-stream.js +12 -8
- package/dist/transport/http/index.d.ts +1 -1
- package/dist/transport/http/index.js +1 -1
- package/dist/transport/http/response.d.ts +3 -1
- package/dist/transport/http/response.js +7 -9
- package/dist/transport/http/stream.d.ts +8 -13
- package/dist/transport/http/stream.js +34 -81
- package/dist/transport/http/transport.d.ts +10 -0
- package/dist/transport/http/transport.js +87 -32
- package/dist/transport/http/unprocessed.d.ts +5 -0
- package/dist/transport/http/unprocessed.js +28 -0
- package/dist/transport/index.d.ts +1 -1
- package/dist/transport/index.js +1 -1
- package/dist/transport/stream.d.ts +52 -0
- package/dist/transport/stream.js +101 -0
- package/dist/transport/transport.d.ts +10 -0
- package/dist/transport/unary.d.ts +8 -0
- package/dist/transport/unary.js +34 -0
- package/dist/transport/websocket/connection.d.ts +7 -3
- package/dist/transport/websocket/connection.js +103 -92
- package/dist/transport/websocket/exchange.d.ts +12 -19
- package/dist/transport/websocket/exchange.js +86 -184
- package/dist/transport/websocket/transport.js +11 -19
- package/package.json +9 -7
- package/dist/session/execution.d.ts +0 -65
- package/dist/session/execution.js +0 -34
- package/dist/session/views/catalog.d.ts +0 -19
- package/dist/session/views/resolve.d.ts +0 -13
- package/dist/session/views/resolve.js +0 -21
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as invocationProtocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
|
+
import { replayableBody } from '../../transport/http/binary-request.js';
|
|
2
3
|
import { admitControlOptions } from '../context/index.js';
|
|
3
4
|
export function admitInvocationOptions(input) {
|
|
4
5
|
if (input === undefined)
|
|
@@ -15,7 +16,7 @@ export function admitInvocationOptions(input) {
|
|
|
15
16
|
if (options.idempotencyKey !== undefined) {
|
|
16
17
|
throw new TypeError('Binary requests cannot carry an idempotency key.');
|
|
17
18
|
}
|
|
18
|
-
return Object.freeze({ options: admitRequestOptions(options), body });
|
|
19
|
+
return Object.freeze({ options: admitRequestOptions(options), body: replayableBody(body) });
|
|
19
20
|
}
|
|
20
21
|
export function admitRequestOptions(input = {}) {
|
|
21
22
|
if (input === null || typeof input !== 'object' || Array.isArray(input)) {
|
|
@@ -23,17 +24,27 @@ export function admitRequestOptions(input = {}) {
|
|
|
23
24
|
}
|
|
24
25
|
const control = admitControlOptions(input);
|
|
25
26
|
const fields = Reflect.ownKeys(input);
|
|
26
|
-
if (fields.some((field) => !['signal', 'timeoutMs', 'idempotencyKey'].includes(String(field)))) {
|
|
27
|
+
if (fields.some((field) => !['signal', 'timeoutMs', 'idempotencyKey', 'maintenance'].includes(String(field)))) {
|
|
27
28
|
throw new TypeError('Session request options contain unsupported fields.');
|
|
28
29
|
}
|
|
29
30
|
const idempotencyKey = input.idempotencyKey === undefined
|
|
30
31
|
? undefined
|
|
31
32
|
: invocationProtocol.acceptIdempotencyKey(input.idempotencyKey, 'request.idempotencyKey');
|
|
33
|
+
const maintenance = input.maintenance === undefined ? undefined : admitMaintenance(input.maintenance);
|
|
32
34
|
return Object.freeze({
|
|
33
35
|
...control,
|
|
34
36
|
...(idempotencyKey === undefined ? {} : { idempotencyKey }),
|
|
37
|
+
...(maintenance === undefined ? {} : { maintenance }),
|
|
35
38
|
});
|
|
36
39
|
}
|
|
40
|
+
function admitMaintenance(input) {
|
|
41
|
+
try {
|
|
42
|
+
return invocationProtocol.acceptMaintenance(input);
|
|
43
|
+
}
|
|
44
|
+
catch (cause) {
|
|
45
|
+
throw new TypeError('Session maintenance guard is invalid.', { cause });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
37
48
|
export function admitEnvelopeTransport(input) {
|
|
38
49
|
if (input !== 'auto' && input !== 'http' && input !== 'websocket') {
|
|
39
50
|
throw new TypeError('Session envelope transport is invalid.');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Result } from '../../client/index.js';
|
|
2
2
|
/** Narrow a Result to the kind a sugar requires, releasing a live body before rejecting it. */
|
|
3
|
-
export declare function requireResultKind<Kind extends '
|
|
3
|
+
export declare function requireResultKind<Kind extends Exclude<Result['kind'], 'redirect'>>(expected: Kind, result: Result): Extract<Result, {
|
|
4
4
|
kind: Kind;
|
|
5
5
|
}>;
|
|
@@ -8,5 +8,9 @@ export function requireResultKind(expected, result) {
|
|
|
8
8
|
if (result.kind === 'binary' && !(result.value.body instanceof Uint8Array)) {
|
|
9
9
|
void result.value.body[Symbol.asyncIterator]().return?.();
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
// A started Execution is named so its caller never starts it again.
|
|
12
|
+
const returned = result.kind === 'execution'
|
|
13
|
+
? `Function started Execution ${result.execution}`
|
|
14
|
+
: `Function returned ${result.kind}`;
|
|
15
|
+
throw new ClientError(`${returned}; ${expected} was required.`);
|
|
12
16
|
}
|
|
@@ -46,14 +46,14 @@ export function restoreRoutes(input, now, maximumAgeMs, maximumSize) {
|
|
|
46
46
|
}
|
|
47
47
|
/** The artifact persisting every integrity-bound entry, as it was sealed. */
|
|
48
48
|
export function routeArtifact(entries) {
|
|
49
|
-
const persisted = Object.fromEntries([...entries].flatMap(([key, cached]) => cached.
|
|
49
|
+
const persisted = Object.fromEntries([...entries].flatMap(([key, cached]) => cached.persisted === undefined
|
|
50
50
|
? []
|
|
51
51
|
: [
|
|
52
52
|
[
|
|
53
53
|
key,
|
|
54
54
|
Object.freeze({
|
|
55
|
-
...
|
|
56
|
-
integrity: cached.integrity,
|
|
55
|
+
...cached.persisted.sealed,
|
|
56
|
+
integrity: cached.persisted.integrity,
|
|
57
57
|
}),
|
|
58
58
|
],
|
|
59
59
|
]));
|
|
@@ -88,8 +88,7 @@ function admitStoredEntry(input, now, maximumAgeMs) {
|
|
|
88
88
|
...(sealed.credential === undefined ? {} : { credential: sealed.credential }),
|
|
89
89
|
expiresAt,
|
|
90
90
|
}),
|
|
91
|
-
sealed,
|
|
92
|
-
integrity: value.integrity,
|
|
91
|
+
persisted: Object.freeze({ sealed, integrity: value.integrity }),
|
|
93
92
|
...(expiry === undefined ? {} : { credentialRefreshBoundary: refreshBoundary(expiry) }),
|
|
94
93
|
});
|
|
95
94
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
2
|
-
import type { PathLike } from '@astrale-os/kernel-core/path';
|
|
2
|
+
import type { NodeTarget, PathLike } from '@astrale-os/kernel-core/path';
|
|
3
3
|
import type { Domain } from '@astrale-os/kernel-dsl/v1/domain';
|
|
4
4
|
import type { AuthApi } from '../auth/index.js';
|
|
5
5
|
import type { Call, Input, Result } from '../client/index.js';
|
|
6
|
+
import type { ExecutionApi } from '../execution/index.js';
|
|
6
7
|
import type { DomainBinding, GraphApi } from '../graph/index.js';
|
|
7
8
|
import type { SchemaApi } from '../schema/index.js';
|
|
8
9
|
import type { ContentApi } from './content/index.js';
|
|
@@ -12,7 +13,8 @@ import type { IntrinsicRelease, SessionSnapshot } from './discovery/index.js';
|
|
|
12
13
|
import type { SessionExchangeRequest } from './exchange/index.js';
|
|
13
14
|
import type { CallableReference, InputModeOfReference, InputOfReference, OutputOfReference } from './reference.js';
|
|
14
15
|
import type { SessionRequestOptions, SessionRequestOptionsWithBody } from './routing/index.js';
|
|
15
|
-
import type {
|
|
16
|
+
import type { View, ViewsOf } from './views/index.js';
|
|
17
|
+
import type { ViewCatalog } from './views/legacy/index.js';
|
|
16
18
|
import { type ClientSessionOptions } from './options.js';
|
|
17
19
|
export type ConnectOptions = Omit<ClientSessionOptions, 'kernel' | 'policy'> & {
|
|
18
20
|
readonly url: string;
|
|
@@ -22,6 +24,8 @@ export type ConnectOptions = Omit<ClientSessionOptions, 'kernel' | 'policy'> & {
|
|
|
22
24
|
export declare class ClientSession {
|
|
23
25
|
readonly kernel: IssuerId;
|
|
24
26
|
readonly schema: SchemaApi;
|
|
27
|
+
/** The `K.Execution` Methods of any Execution, a durable call's or an install's. */
|
|
28
|
+
readonly execution: ExecutionApi;
|
|
25
29
|
readonly graph: GraphApi;
|
|
26
30
|
readonly auth: AuthApi;
|
|
27
31
|
readonly content: ContentApi;
|
|
@@ -33,7 +37,9 @@ export declare class ClientSession {
|
|
|
33
37
|
private readonly routes;
|
|
34
38
|
private readonly exchangeDependencies;
|
|
35
39
|
private readonly callExchange?;
|
|
36
|
-
private readonly
|
|
40
|
+
private readonly viewReader;
|
|
41
|
+
/** The deprecated View.resolve reads: `viewsFor`, and the Views of a Kernel that places none. */
|
|
42
|
+
private readonly resolvedViews;
|
|
37
43
|
private closed;
|
|
38
44
|
constructor(options: ClientSessionOptions);
|
|
39
45
|
/** Bind one admitted DSL Domain to authenticated graph projection and Method dispatch. */
|
|
@@ -50,14 +56,34 @@ export declare class ClientSession {
|
|
|
50
56
|
release(options?: SessionControlOptions): Promise<IntrinsicRelease>;
|
|
51
57
|
snapshot(options?: SessionControlOptions): Promise<SessionSnapshot>;
|
|
52
58
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
59
|
+
* Read one View by any Path, under the caller's own read authority, within one operation budget:
|
|
60
|
+
* its declaration `/:<origin>:view.<name>`, an exact `@<id>` or a traversal, such as the
|
|
61
|
+
* entrypoint `Path.domain(origin).in(K.classes.entrypoint.key)`, whether its Domain declares it or
|
|
62
|
+
* a Mutation created it. A missing or masked Node rejects with NodeUnavailableError, and a Node
|
|
63
|
+
* without a placement is refused.
|
|
64
|
+
*/
|
|
65
|
+
view(target: NodeTarget, options?: SessionControlOptions): Promise<View>;
|
|
66
|
+
/**
|
|
67
|
+
* Read the Views one Domain declares, in Path order, under the caller's own read authority, within
|
|
68
|
+
* one operation budget. The Domain is named by its origin or its exact Domain Path `/:<origin>`;
|
|
69
|
+
* any other Path rejects with a TypeError before the Query.
|
|
70
|
+
*/
|
|
71
|
+
view(of: ViewsOf, options?: SessionControlOptions): Promise<readonly View[]>;
|
|
72
|
+
/**
|
|
73
|
+
* @deprecated Read a Domain's Views with `view({ domain })`, or one View with `view(path)`. This
|
|
74
|
+
* lists them through the deprecated View.resolve, each with the Release digest that owns it, and
|
|
75
|
+
* never names the entrypoint. Only an exact Domain Path `/:<origin>` is accepted; any other Path
|
|
76
|
+
* rejects with a TypeError before the call.
|
|
55
77
|
*/
|
|
56
78
|
viewsFor(domain: PathLike, options?: SessionControlOptions): Promise<ViewCatalog>;
|
|
57
79
|
dispatch(call: Call, options?: SessionRequestOptions): Promise<Result>;
|
|
58
80
|
dispatch(call: Call, options: SessionRequestOptionsWithBody): Promise<Result>;
|
|
59
81
|
call(call: Call, options?: SessionRequestOptions): Promise<Input>;
|
|
60
82
|
call(call: Call, options: SessionRequestOptionsWithBody): Promise<Input>;
|
|
83
|
+
/**
|
|
84
|
+
* Invoke one typed reference. A durable callable's call is keyed, by the caller's key or by one
|
|
85
|
+
* created for this call, and sent again with that key while its outcome is unknown.
|
|
86
|
+
*/
|
|
61
87
|
invoke<const Reference extends CallableReference<unknown>>(reference: InputModeOfReference<Reference> extends 'binary' ? never : Reference, input: InputOfReference<Reference>, options?: SessionRequestOptions): Promise<OutputOfReference<Reference>>;
|
|
62
88
|
invoke<const Reference extends CallableReference<unknown, unknown, 'binary'>>(reference: Reference, input: InputOfReference<Reference>, options: SessionRequestOptionsWithBody): Promise<OutputOfReference<Reference>>;
|
|
63
89
|
private dispatchWith;
|
package/dist/session/session.js
CHANGED
|
@@ -3,23 +3,29 @@ import { callableFingerprint } from '@astrale-os/kernel-dsl/v1/schema/fingerprin
|
|
|
3
3
|
import { createAuth } from '../auth/auth.js';
|
|
4
4
|
import { acceptCall } from '../client/index.js';
|
|
5
5
|
import { SessionError } from '../errors/index.js';
|
|
6
|
+
import { createExecution } from '../execution/index.js';
|
|
6
7
|
import { createDomainBinding } from '../graph/domain/binding.js';
|
|
7
8
|
import { createGraph } from '../graph/index.js';
|
|
8
9
|
import { createSchema } from '../schema/index.js';
|
|
9
10
|
import { admitFunction } from './admission.js';
|
|
11
|
+
import { uploadFiles } from './content/files.js';
|
|
10
12
|
import { createContentApi } from './content/index.js';
|
|
11
|
-
import { admitControlOptions, allowEndpoint, createSessionOperation } from './context/index.js';
|
|
13
|
+
import { admitControlOptions, allowEndpoint, createSessionOperation, sessionTransportOptions, } from './context/index.js';
|
|
12
14
|
import { createSessionDiscovery } from './discovery/index.js';
|
|
15
|
+
import { attemptDurable, durableOptions } from './durable.js';
|
|
13
16
|
import { acquireDomainCredential, admitExchangeRequest, createSessionExchange, } from './exchange/index.js';
|
|
14
17
|
import { acceptSessionOptions } from './options.js';
|
|
15
|
-
import { admitReference } from './reference.js';
|
|
18
|
+
import { admitReference, filesOf, outputModeOf } from './reference.js';
|
|
16
19
|
import { admitInvocationOptions, requireResultKind, SessionDispatcher } from './routing/index.js';
|
|
17
|
-
import {
|
|
20
|
+
import { admitView } from './views/index.js';
|
|
21
|
+
import { readDomainViewsOrResolved, readViewOrResolved, resolvedViewSource, } from './views/legacy/index.js';
|
|
18
22
|
const DEFAULT_SESSION_POLICY = Object.freeze({ maximumRouteAgeMs: 60_000 });
|
|
19
23
|
/** Caller-owned discovery and redirect-following conversation with one exact source Kernel. */
|
|
20
24
|
export class ClientSession {
|
|
21
25
|
kernel;
|
|
22
26
|
schema;
|
|
27
|
+
/** The `K.Execution` Methods of any Execution, a durable call's or an install's. */
|
|
28
|
+
execution;
|
|
23
29
|
graph;
|
|
24
30
|
auth;
|
|
25
31
|
content;
|
|
@@ -31,7 +37,9 @@ export class ClientSession {
|
|
|
31
37
|
routes;
|
|
32
38
|
exchangeDependencies;
|
|
33
39
|
callExchange;
|
|
34
|
-
|
|
40
|
+
viewReader;
|
|
41
|
+
/** The deprecated View.resolve reads: `viewsFor`, and the Views of a Kernel that places none. */
|
|
42
|
+
resolvedViews;
|
|
35
43
|
closed = false;
|
|
36
44
|
constructor(options) {
|
|
37
45
|
const settled = acceptSessionOptions(options);
|
|
@@ -41,7 +49,12 @@ export class ClientSession {
|
|
|
41
49
|
this.timeoutMs = settled.timeoutMs;
|
|
42
50
|
this.ownedPool = settled.ownedPool;
|
|
43
51
|
this.routes = settled.routes;
|
|
44
|
-
this.
|
|
52
|
+
this.viewReader = Object.freeze({
|
|
53
|
+
query: (ast, page, operation) => this.graph.query(ast, { ...sessionTransportOptions(operation), page }),
|
|
54
|
+
read: (target, operation) => this.graph.getOrThrow(target, sessionTransportOptions(operation)),
|
|
55
|
+
admit: (node, declaration) => admitView(node, declaration, kernel, policy),
|
|
56
|
+
});
|
|
57
|
+
this.resolvedViews = resolvedViewSource(async (call, operation) => requireResultKind('value', await this.dispatcher.dispatch(call, {}, operation)).value, policy);
|
|
45
58
|
this.discovery = createSessionDiscovery({
|
|
46
59
|
kernel,
|
|
47
60
|
fetch,
|
|
@@ -92,8 +105,8 @@ export class ClientSession {
|
|
|
92
105
|
this.schema = createSchema((request, options) => this.dispatch(request, options), {
|
|
93
106
|
maximumReleaseBytes,
|
|
94
107
|
maximumBundleBytes,
|
|
95
|
-
lifecycleTimeoutMs: settled.schemaLifecycleTimeoutMs,
|
|
96
108
|
});
|
|
109
|
+
this.execution = createExecution((request, options) => this.dispatch(request, options));
|
|
97
110
|
this.graph = createGraph((call, options) => this.call(call, options));
|
|
98
111
|
this.auth = createAuth((target, input, options) => this.call({ target, input }, options), (call, options) => {
|
|
99
112
|
const operation = this.operation(admitControlOptions(options));
|
|
@@ -122,13 +135,22 @@ export class ClientSession {
|
|
|
122
135
|
snapshot(options) {
|
|
123
136
|
return this.discovery.snapshot(this.operation(admitControlOptions(options)));
|
|
124
137
|
}
|
|
138
|
+
view(input, options) {
|
|
139
|
+
this.requireOpen();
|
|
140
|
+
const operation = this.operation(admitControlOptions(options));
|
|
141
|
+
return isViewsOf(input)
|
|
142
|
+
? readDomainViewsOrResolved(this.viewReader, this.resolvedViews.views, input.domain, operation)
|
|
143
|
+
: readViewOrResolved(this.viewReader, this.resolvedViews.views, input, operation);
|
|
144
|
+
}
|
|
125
145
|
/**
|
|
126
|
-
*
|
|
127
|
-
*
|
|
146
|
+
* @deprecated Read a Domain's Views with `view({ domain })`, or one View with `view(path)`. This
|
|
147
|
+
* lists them through the deprecated View.resolve, each with the Release digest that owns it, and
|
|
148
|
+
* never names the entrypoint. Only an exact Domain Path `/:<origin>` is accepted; any other Path
|
|
149
|
+
* rejects with a TypeError before the call.
|
|
128
150
|
*/
|
|
129
151
|
viewsFor(domain, options) {
|
|
130
152
|
this.requireOpen();
|
|
131
|
-
return
|
|
153
|
+
return this.resolvedViews.catalog(domain, this.operation(admitControlOptions(options)));
|
|
132
154
|
}
|
|
133
155
|
dispatch(call, options) {
|
|
134
156
|
return this.dispatchWith(call, options);
|
|
@@ -140,6 +162,10 @@ export class ClientSession {
|
|
|
140
162
|
async invoke(reference, input, options) {
|
|
141
163
|
const admittedReference = admitReference(reference);
|
|
142
164
|
const admitted = admitInvocationOptions(options);
|
|
165
|
+
// A file field may hold the Blob itself: it is uploaded, and its receipt is sent.
|
|
166
|
+
const sent = admittedReference.files === undefined
|
|
167
|
+
? input
|
|
168
|
+
: await uploadFiles(admittedReference.files, input, (source, uploadOptions) => this.content.upload(source, uploadOptions), admitted.options.signal === undefined ? {} : { signal: admitted.options.signal });
|
|
143
169
|
const { anchor, steps } = admittedReference.target.ast;
|
|
144
170
|
const last = steps.at(-1);
|
|
145
171
|
const instance = last?.kind === 'method' && last.dispatch === 'instance'
|
|
@@ -155,18 +181,31 @@ export class ClientSession {
|
|
|
155
181
|
: { fingerprint: admittedReference.fingerprint }),
|
|
156
182
|
...(instance === undefined ? {} : { instance }),
|
|
157
183
|
}),
|
|
158
|
-
input,
|
|
184
|
+
input: sent,
|
|
159
185
|
};
|
|
160
|
-
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
186
|
+
// A durable call is keyed, so an attempt whose outcome is unknown can be sent again.
|
|
187
|
+
const durable = admittedReference.outputMode === 'execution';
|
|
188
|
+
const requested = durable ? durableOptions(admitted.options) : admitted.options;
|
|
189
|
+
const operation = this.operation(requested);
|
|
190
|
+
const streaming = admitted.body === undefined && admittedReference.outputMode !== 'binary'
|
|
191
|
+
? undefined
|
|
192
|
+
: { body: admitted.body };
|
|
193
|
+
// Resolved once: every attempt presents the principal and caller its key names an Execution with.
|
|
194
|
+
const resolved = await this.dispatcher.resolve(call, operation);
|
|
195
|
+
const attempt = () => this.dispatcher.dispatchResolved(resolved, requested, operation, streaming);
|
|
196
|
+
const result = await (durable ? attemptDurable(operation, attempt) : attempt());
|
|
164
197
|
const narrowed = requireResultKind(admittedReference.outputMode, result);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
198
|
+
switch (narrowed.kind) {
|
|
199
|
+
case 'stream':
|
|
200
|
+
return narrowed.stream;
|
|
201
|
+
case 'execution':
|
|
202
|
+
return Object.freeze({
|
|
203
|
+
id: narrowed.execution,
|
|
204
|
+
...(narrowed.replayed === undefined ? {} : { replayed: narrowed.replayed }),
|
|
205
|
+
});
|
|
206
|
+
default:
|
|
207
|
+
return narrowed.value;
|
|
208
|
+
}
|
|
170
209
|
}
|
|
171
210
|
dispatchWith(call, options, requireHttp = false) {
|
|
172
211
|
const admitted = admitInvocationOptions(options);
|
|
@@ -209,7 +248,8 @@ export class ClientSession {
|
|
|
209
248
|
fingerprint: callableFingerprint(method),
|
|
210
249
|
callable: method.key,
|
|
211
250
|
target: Path.instanceMethod(Path.id(node.id), method.key),
|
|
212
|
-
outputMode: method
|
|
251
|
+
outputMode: outputModeOf(method),
|
|
252
|
+
files: filesOf(method),
|
|
213
253
|
}, input);
|
|
214
254
|
}
|
|
215
255
|
operation(options) {
|
|
@@ -217,6 +257,13 @@ export class ClientSession {
|
|
|
217
257
|
return createSessionOperation(this.lifecycle.signal, options, this.timeoutMs);
|
|
218
258
|
}
|
|
219
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* Whether `view` reads a Domain's Views: its input is then a plain `{ domain }` object, while one
|
|
262
|
+
* View is read by a NodeId, a Path value or string, or a DefinitionRef.
|
|
263
|
+
*/
|
|
264
|
+
function isViewsOf(input) {
|
|
265
|
+
return typeof input === 'object' && !(input instanceof Path) && 'domain' in input;
|
|
266
|
+
}
|
|
220
267
|
/** Open a Kernel conversation with secure defaults and automatic Domain exchange when authenticated. */
|
|
221
268
|
export function connect(options) {
|
|
222
269
|
if (options === null || typeof options !== 'object') {
|
|
@@ -4,7 +4,7 @@ import { K, KernelSchema } from '@astrale-os/kernel-core/schema';
|
|
|
4
4
|
import { defineSchema, func, method, nodeClass, schema, valueSchema, } from '@astrale-os/kernel-dsl/v1';
|
|
5
5
|
import { isBinaryInput } from '@astrale-os/kernel-dsl/v1/language';
|
|
6
6
|
import { call } from '../client/index.js';
|
|
7
|
-
import { ClientSession, credentials,
|
|
7
|
+
import { ClientSession, credentials, reference } from './index.js';
|
|
8
8
|
void new ClientSession(options);
|
|
9
9
|
void auth;
|
|
10
10
|
void control;
|
|
@@ -110,6 +110,10 @@ const boundBlobReceipt = boundSession.content
|
|
|
110
110
|
.then(({ receipt }) => receipt);
|
|
111
111
|
void blobReceipt;
|
|
112
112
|
void boundBlobReceipt;
|
|
113
|
+
void session.content.upload(received, { mediaType: 'image/png' });
|
|
114
|
+
void boundSession.content.upload({ body: new ReadableStream(), length: 0 }, { mediaType: 'image/png' });
|
|
115
|
+
// @ts-expect-error A stream upload declares its exact length.
|
|
116
|
+
void session.content.upload({ body: new ReadableStream() }, { mediaType: 'image/png' });
|
|
113
117
|
void session.invoke(registerReference, registration);
|
|
114
118
|
void boundSession.invoke(staticRegisterReference, registration);
|
|
115
119
|
void session.invoke(renameReference, renameRequest);
|
|
@@ -121,6 +125,12 @@ void client.dispatch(rawBinaryCall, { body: new Blob() });
|
|
|
121
125
|
void client.as('credential').call(rawBinaryCall, { body: new Blob() });
|
|
122
126
|
// @ts-expect-error Binary Functions require a byte source.
|
|
123
127
|
void session.invoke(binaryUploadReference, { mediaType: 'image/png' });
|
|
128
|
+
// @ts-expect-error A Session invocation sends a re-readable Blob: it may follow a Redirect.
|
|
129
|
+
void session.invoke(binaryUploadReference, { mediaType: 'image/png' }, { body: received });
|
|
130
|
+
// @ts-expect-error A raw Client sends a re-readable Blob: it cannot resend a stream a Redirect answers.
|
|
131
|
+
void client.dispatch(rawBinaryCall, { body: received });
|
|
132
|
+
// @ts-expect-error The public HTTP transport sends a re-readable Blob too.
|
|
133
|
+
void httpTransport.dispatchBinary(rawEnvelope, received);
|
|
124
134
|
// @ts-expect-error Value Functions reject binary bodies.
|
|
125
135
|
void session.invoke(registerReference, registration, { body: new Blob() });
|
|
126
136
|
// @ts-expect-error Bound binary Functions require a byte source.
|
|
@@ -189,12 +199,13 @@ const durableDomain = schema.resolve(defineSchema('client.durable.typecheck', {
|
|
|
189
199
|
}));
|
|
190
200
|
const remindReference = reference(durableDomain, durableDomain.classes.Invoice.methods.remind)(Path.id(NodeId('invoice-1')));
|
|
191
201
|
const durableReturnsExecution = true;
|
|
202
|
+
const outcome = session.execution.result(run, { waitMs: 1_000 });
|
|
192
203
|
const outcomeIsTyped = true;
|
|
204
|
+
const status = session.execution.status(run);
|
|
193
205
|
const statusIsTyped = true;
|
|
194
|
-
void session.
|
|
195
|
-
void session.invoke(execution.signal(run), { name: 'approval', value: { by: 'billing' } });
|
|
206
|
+
void session.execution.signal(run, { name: 'approval', value: { by: 'billing' } });
|
|
196
207
|
// @ts-expect-error Force is the only cancellation option.
|
|
197
|
-
void session.
|
|
208
|
+
void session.execution.cancel(run, { waitMs: 1_000 });
|
|
198
209
|
void durableReturnsExecution;
|
|
199
210
|
void outcomeIsTyped;
|
|
200
211
|
void statusIsTyped;
|
|
@@ -206,5 +217,8 @@ void session.invoke(dynamicReference, dynamicInput, { expect: undefined });
|
|
|
206
217
|
const unsupportedClientOptions = { expect: undefined };
|
|
207
218
|
void unsupportedClientOptions;
|
|
208
219
|
// @ts-expect-error Internal metadata dispatch is absent from the public package facade.
|
|
209
|
-
import {
|
|
210
|
-
void
|
|
220
|
+
import { dispatchInternal } from '../index.js';
|
|
221
|
+
void dispatchInternal;
|
|
222
|
+
// @ts-expect-error The stream-capable HTTP binary path is absent from the public package facade.
|
|
223
|
+
import { dispatchBinaryBody } from '../index.js';
|
|
224
|
+
void dispatchBinaryBody;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { admitView, admitViewPlacement, declaredView, type Declaration, type View } from './view.js';
|
|
2
|
+
export { readDomainViews, readView, type ViewAnswer, type ViewReader, type ViewsOf, type ViewsQuery, } from './read.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { admitView, admitViewPlacement, declaredView } from './view.js';
|
|
2
|
+
export { readDomainViews, readView, } from './read.js';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** The Kernel `View` Class. */
|
|
2
|
+
export declare const VIEW_CLASS: Readonly<{
|
|
3
|
+
origin: 'kernel.astrale.ai';
|
|
4
|
+
kind: 'class';
|
|
5
|
+
name: "View";
|
|
6
|
+
}>;
|
|
7
|
+
/** The Kernel `of_domain` Edge Class, which only projection writes. */
|
|
8
|
+
export declare const OF_DOMAIN_CLASS: Readonly<{
|
|
9
|
+
origin: 'kernel.astrale.ai';
|
|
10
|
+
kind: 'class';
|
|
11
|
+
name: "of_domain";
|
|
12
|
+
}>;
|
|
13
|
+
/** The Kernel `Domain` Class. */
|
|
14
|
+
export declare const DOMAIN_CLASS: Readonly<{
|
|
15
|
+
origin: 'kernel.astrale.ai';
|
|
16
|
+
kind: 'class';
|
|
17
|
+
name: "Domain";
|
|
18
|
+
}>;
|
|
19
|
+
export declare const VIEW: "kernel.astrale.ai:class.View";
|
|
20
|
+
export declare const OF_DOMAIN: "kernel.astrale.ai:class.of_domain";
|
|
21
|
+
export declare const DOMAIN: "kernel.astrale.ai:class.Domain";
|
|
22
|
+
/** `View.placement`: where and how a Shell mounts the View. */
|
|
23
|
+
export declare const PLACEMENT: "kernel.astrale.ai:class.View.property.placement";
|
|
24
|
+
/** `of_domain.member`: the member name under which a Domain declares the Node. */
|
|
25
|
+
export declare const MEMBER: "kernel.astrale.ai:class.of_domain.property.member";
|
|
26
|
+
/** `Domain.origin`. */
|
|
27
|
+
export declare const ORIGIN: "kernel.astrale.ai:class.Domain.property.origin";
|
|
28
|
+
/** `Descriptable.description`. */
|
|
29
|
+
export declare const DESCRIPTION: "kernel.astrale.ai:class.Descriptable.property.description";
|
|
30
|
+
/** `Identity.iss`. */
|
|
31
|
+
export declare const ISSUER: "kernel.astrale.ai:class.Identity.property.iss";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ClassKey, PropertyKey } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
2
|
+
// The Kernel Classes a View read names, by their coordinates. `K` is built by the DSL builder when
|
|
3
|
+
// its module loads, and the Session must not resolve the Kernel Schema on loading, so these are
|
|
4
|
+
// written out here and the tests hold them equal to `K`.
|
|
5
|
+
function kernelClass(name) {
|
|
6
|
+
return Object.freeze({
|
|
7
|
+
origin: 'kernel.astrale.ai',
|
|
8
|
+
kind: 'class',
|
|
9
|
+
name,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
/** The Kernel `View` Class. */
|
|
13
|
+
export const VIEW_CLASS = kernelClass('View');
|
|
14
|
+
/** The Kernel `of_domain` Edge Class, which only projection writes. */
|
|
15
|
+
export const OF_DOMAIN_CLASS = kernelClass('of_domain');
|
|
16
|
+
/** The Kernel `Domain` Class. */
|
|
17
|
+
export const DOMAIN_CLASS = kernelClass('Domain');
|
|
18
|
+
export const VIEW = ClassKey.of(VIEW_CLASS);
|
|
19
|
+
export const OF_DOMAIN = ClassKey.of(OF_DOMAIN_CLASS);
|
|
20
|
+
export const DOMAIN = ClassKey.of(DOMAIN_CLASS);
|
|
21
|
+
/** `View.placement`: where and how a Shell mounts the View. */
|
|
22
|
+
export const PLACEMENT = PropertyKey.of(VIEW_CLASS, 'placement');
|
|
23
|
+
/** `of_domain.member`: the member name under which a Domain declares the Node. */
|
|
24
|
+
export const MEMBER = PropertyKey.of(OF_DOMAIN_CLASS, 'member');
|
|
25
|
+
/** `Domain.origin`. */
|
|
26
|
+
export const ORIGIN = PropertyKey.of(DOMAIN_CLASS, 'origin');
|
|
27
|
+
/** `Descriptable.description`. */
|
|
28
|
+
export const DESCRIPTION = PropertyKey.of(kernelClass('Descriptable'), 'description');
|
|
29
|
+
/** `Identity.iss`. */
|
|
30
|
+
export const ISSUER = PropertyKey.of(kernelClass('Identity'), 'iss');
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The View catalog before Views carried their placement: `ResolvedView`, keyed by declaration and
|
|
3
|
+
* carrying the Release digest that owns it. `viewsFor` lists it through View.resolve
|
|
4
|
+
* (`resolve.ts`), and `SessionSnapshot.views` joins the source Kernel's Release to its root Schema.
|
|
5
|
+
* A client reads a View from its Node instead, as a `View` (`../view.ts`).
|
|
6
|
+
*/
|
|
7
|
+
import type { ResolvedView } from '@astrale-os/kernel-core/schema/kernel/syscalls/view-resolution';
|
|
8
|
+
import type { bundle } from '@astrale-os/kernel-dsl/v1';
|
|
9
|
+
import type { DomainRelease } from '@astrale-os/kernel-protocol/release';
|
|
10
|
+
import type { SessionPolicy } from '../../context/index.js';
|
|
11
|
+
/** @deprecated One View as View.resolve lists it, with its Release digest; read it as a `View`. */
|
|
12
|
+
export type { ResolvedView };
|
|
13
|
+
/** @deprecated Immutable canonical-key-ordered inventory of Views; read them with `view`. */
|
|
14
|
+
export interface ViewCatalog {
|
|
15
|
+
readonly entrypoint?: ResolvedView;
|
|
16
|
+
readonly views: readonly ResolvedView[];
|
|
17
|
+
}
|
|
18
|
+
/** @deprecated The `viewsFor` of a bound Session whose source serves none: it throws. */
|
|
19
|
+
export declare function unavailableViewCatalog(): never;
|
|
20
|
+
/** @deprecated Join each root Domain View to its exact release binding. */
|
|
21
|
+
export declare function rootViewCatalog(release: DomainRelease, artifact: bundle.Bundle, policy: Readonly<SessionPolicy>): ViewCatalog;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { acceptViewResolution, } from '@astrale-os/kernel-core/schema/kernel/syscalls/view-resolution';
|
|
2
1
|
import { Key as ViewKey } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
3
|
-
import { ClientError } from '
|
|
4
|
-
import { allowEndpoint } from '
|
|
5
|
-
/**
|
|
2
|
+
import { ClientError } from '../../../errors/index.js';
|
|
3
|
+
import { allowEndpoint } from '../../context/index.js';
|
|
4
|
+
/** @deprecated The `viewsFor` of a bound Session whose source serves none: it throws. */
|
|
5
|
+
export function unavailableViewCatalog() {
|
|
6
|
+
throw new TypeError('The View catalog is unavailable from this bound Session source.');
|
|
7
|
+
}
|
|
8
|
+
/** @deprecated Join each root Domain View to its exact release binding. */
|
|
6
9
|
export function rootViewCatalog(release, artifact, policy) {
|
|
7
10
|
const views = release.bindings.views
|
|
8
11
|
.flatMap((binding) => {
|
|
@@ -38,33 +41,6 @@ export function rootViewCatalog(release, artifact, policy) {
|
|
|
38
41
|
views: catalogViews,
|
|
39
42
|
});
|
|
40
43
|
}
|
|
41
|
-
export function catalogFromKeys(root, keys) {
|
|
42
|
-
const selected = new Set(keys);
|
|
43
|
-
const views = Object.freeze(root.views.filter(({ key }) => selected.has(key)));
|
|
44
|
-
return Object.freeze({
|
|
45
|
-
...(root.entrypoint !== undefined && selected.has(root.entrypoint.key)
|
|
46
|
-
? { entrypoint: root.entrypoint }
|
|
47
|
-
: {}),
|
|
48
|
-
views,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Re-admit one Runtime-resolved Domain View catalog at the Client trust boundary. Only Views that
|
|
53
|
-
* the requested Domain declares for itself are kept.
|
|
54
|
-
*/
|
|
55
|
-
export function domainViewCatalog(input, domain, policy) {
|
|
56
|
-
let resolution;
|
|
57
|
-
try {
|
|
58
|
-
resolution = acceptViewResolution(input);
|
|
59
|
-
}
|
|
60
|
-
catch (cause) {
|
|
61
|
-
throw new ClientError('Resolved View catalog is invalid.', { cause });
|
|
62
|
-
}
|
|
63
|
-
const views = resolution.views.filter((view) => ViewKey.origin(view.key) === domain);
|
|
64
|
-
for (const view of views)
|
|
65
|
-
allowEndpoint(view.href, policy);
|
|
66
|
-
return Object.freeze({ views: Object.freeze(views) });
|
|
67
|
-
}
|
|
68
44
|
function compareKeys(left, right) {
|
|
69
45
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
70
46
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a client keeps only to stay compatible. Every export is deprecated, the Session composes
|
|
3
|
+
* them, and no durable View code imports them.
|
|
4
|
+
*
|
|
5
|
+
* - `unplaced.ts` answers `view` from View.resolve when the Kernel that answers places no View.
|
|
6
|
+
* Delete it, with the `unplaced` answer of `../read.ts` and `ResolvedViewSource.views`, when every
|
|
7
|
+
* Kernel a client may reach places Views.
|
|
8
|
+
* - `catalog.ts` and `resolve.ts` serve `viewsFor` and `SessionSnapshot.views`: the View catalog
|
|
9
|
+
* keyed by declaration, with the Release digest that owns each View. Delete them with those two
|
|
10
|
+
* members, and `resolve.ts` only once `unplaced.ts` is gone too, since it lists through it.
|
|
11
|
+
*/
|
|
12
|
+
export { rootViewCatalog, unavailableViewCatalog, type ResolvedView, type ViewCatalog, } from './catalog.js';
|
|
13
|
+
export { domainViewCatalog, resolvedViews, resolvedViewSource, resolveViewsFor, type ResolvedViews, type ResolvedViewSource, type ViewCatalogAdmission, type ViewInvoker, } from './resolve.js';
|
|
14
|
+
export { readDomainViewsOrResolved, readViewOrResolved } from './unplaced.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a client keeps only to stay compatible. Every export is deprecated, the Session composes
|
|
3
|
+
* them, and no durable View code imports them.
|
|
4
|
+
*
|
|
5
|
+
* - `unplaced.ts` answers `view` from View.resolve when the Kernel that answers places no View.
|
|
6
|
+
* Delete it, with the `unplaced` answer of `../read.ts` and `ResolvedViewSource.views`, when every
|
|
7
|
+
* Kernel a client may reach places Views.
|
|
8
|
+
* - `catalog.ts` and `resolve.ts` serve `viewsFor` and `SessionSnapshot.views`: the View catalog
|
|
9
|
+
* keyed by declaration, with the Release digest that owns each View. Delete them with those two
|
|
10
|
+
* members, and `resolve.ts` only once `unplaced.ts` is gone too, since it lists through it.
|
|
11
|
+
*/
|
|
12
|
+
export { rootViewCatalog, unavailableViewCatalog, } from './catalog.js';
|
|
13
|
+
export { domainViewCatalog, resolvedViews, resolvedViewSource, resolveViewsFor, } from './resolve.js';
|
|
14
|
+
export { readDomainViewsOrResolved, readViewOrResolved } from './unplaced.js';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every read through View.resolve, the one source of a Domain's Views before they carried their
|
|
3
|
+
* placement: the deprecated `viewsFor`, exactly as it listed them, each with the Release digest that
|
|
4
|
+
* owns it, and the same listing as Views for `unplaced.ts`. A Session composes both through
|
|
5
|
+
* `resolvedViewSource`.
|
|
6
|
+
*/
|
|
7
|
+
import type { PathLike } from '@astrale-os/kernel-core/path';
|
|
8
|
+
import type { Key } from '@astrale-os/kernel-dsl/v1';
|
|
9
|
+
import type { Call, Input } from '../../../client/index.js';
|
|
10
|
+
import type { SessionOperation, SessionPolicy } from '../../context/index.js';
|
|
11
|
+
import type { View } from '../view.js';
|
|
12
|
+
import type { ViewCatalog } from './catalog.js';
|
|
13
|
+
/** @deprecated How `viewsFor` sends its View.resolve call. */
|
|
14
|
+
export type ViewInvoker = (call: Call, operation: SessionOperation) => Promise<Input>;
|
|
15
|
+
/** @deprecated How `viewsFor` admits the catalog View.resolve answers for one Domain. */
|
|
16
|
+
export type ViewCatalogAdmission = (input: unknown, domain: Key.Origin) => ViewCatalog;
|
|
17
|
+
/** @deprecated The Views of one Domain as its Kernel's View.resolve lists them. */
|
|
18
|
+
export type ResolvedViews = (domain: Key.Origin, operation: SessionOperation) => Promise<readonly View[]>;
|
|
19
|
+
/** @deprecated What one Session reads through View.resolve. */
|
|
20
|
+
export interface ResolvedViewSource {
|
|
21
|
+
/** The catalog `viewsFor` answers for one exact Domain Path. */
|
|
22
|
+
readonly catalog: (domain: PathLike, operation: SessionOperation) => Promise<ViewCatalog>;
|
|
23
|
+
/** The Views of one Domain, for a Kernel that places none (`unplaced.ts`). */
|
|
24
|
+
readonly views: ResolvedViews;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated The View.resolve reads of one Session: each Call sent by `invoke`, each answer admitted
|
|
28
|
+
* under the Session endpoint policy.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolvedViewSource(invoke: ViewInvoker, policy: Readonly<SessionPolicy>): ResolvedViewSource;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated Resolve the per-Domain View catalog through the canonical source Kernel call, then
|
|
33
|
+
* admit the Release evidence it answers with. Every View targets its owning Domain, so only an exact
|
|
34
|
+
* Domain Path `/:<origin>` is meaningful; any other Path is refused before the call.
|
|
35
|
+
*/
|
|
36
|
+
export declare function resolveViewsFor(invoke: ViewInvoker, admitCatalog: ViewCatalogAdmission, domain: PathLike, operation: SessionOperation): Promise<ViewCatalog>;
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated Re-admit one Runtime-resolved Domain View catalog at the Client trust boundary. Only
|
|
39
|
+
* Views that the requested Domain declares for itself are kept.
|
|
40
|
+
*/
|
|
41
|
+
export declare function domainViewCatalog(input: unknown, domain: Key.Origin, policy: Readonly<SessionPolicy>): ViewCatalog;
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated The Views View.resolve lists for one Domain, each named by its declaration and
|
|
44
|
+
* answered for by the issuer of the Release that binds it, its Domain's.
|
|
45
|
+
*/
|
|
46
|
+
export declare function resolvedViews(invoke: ViewInvoker, admitCatalog: ViewCatalogAdmission): ResolvedViews;
|