@astrale-os/kernel-client 0.6.0-beta.85 → 0.6.0-beta.87
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/auth.d.ts +2 -8
- package/dist/auth/credential.d.ts +1 -7
- package/dist/auth/identity.d.ts +2 -1
- package/dist/client/credential.d.ts +2 -1
- package/dist/errors/stale-route-error.d.ts +4 -14
- package/dist/errors/stale-route-error.js +2 -13
- package/dist/errors/transport-error.d.ts +1 -1
- package/dist/graph/domain/domain.typecheck.js +1 -0
- package/dist/graph/index.d.ts +1 -1
- package/dist/graph/index.js +1 -1
- package/dist/schema/introspection.js +1 -5
- package/dist/schema/schema.js +4 -8
- package/dist/session/admission.js +3 -3
- package/dist/session/bound.d.ts +2 -2
- package/dist/session/bound.js +3 -2
- package/dist/session/content/api.d.ts +45 -0
- package/dist/session/content/api.js +28 -0
- package/dist/session/content/batch.d.ts +5 -0
- package/dist/session/content/batch.js +93 -0
- package/dist/session/content/index.d.ts +1 -0
- package/dist/session/content/index.js +1 -0
- package/dist/session/content/input.d.ts +9 -0
- package/dist/session/content/input.js +33 -0
- package/dist/session/content/parts.d.ts +36 -0
- package/dist/session/content/parts.js +154 -0
- package/dist/session/content/retry.d.ts +3 -0
- package/dist/session/content/retry.js +41 -0
- package/dist/session/content/wire.d.ts +12 -0
- package/dist/session/content/wire.js +60 -0
- package/dist/session/context/index.d.ts +1 -1
- package/dist/session/context/index.js +1 -1
- package/dist/session/context/limits.d.ts +0 -1
- package/dist/session/context/limits.js +0 -1
- package/dist/session/context/operation.d.ts +0 -1
- package/dist/session/context/operation.js +1 -1
- package/dist/session/context/policy.d.ts +0 -1
- package/dist/session/context/policy.js +0 -16
- package/dist/session/discovery/bundle.d.ts +4 -3
- package/dist/session/discovery/bundle.js +20 -21
- package/dist/session/discovery/discovery.d.ts +0 -3
- package/dist/session/discovery/discovery.js +6 -14
- package/dist/session/discovery/index.d.ts +0 -5
- package/dist/session/discovery/index.js +1 -2
- package/dist/session/discovery/release.d.ts +6 -5
- package/dist/session/discovery/release.js +3 -3
- package/dist/session/discovery/snapshot.d.ts +1 -8
- package/dist/session/discovery/snapshot.js +2 -2
- package/dist/session/exchange/domain.js +1 -1
- package/dist/session/exchange/exchange.d.ts +1 -7
- package/dist/session/exchange/exchange.js +0 -4
- package/dist/session/exchange/index.d.ts +1 -1
- package/dist/session/exchange/index.js +1 -1
- package/dist/session/exchange/presentation.js +1 -2
- package/dist/session/exchange/source.d.ts +2 -1
- package/dist/session/index.d.ts +3 -2
- package/dist/session/index.js +1 -1
- package/dist/session/options.d.ts +65 -0
- package/dist/session/options.js +132 -0
- package/dist/session/routing/cache.d.ts +9 -14
- package/dist/session/routing/cache.js +17 -186
- package/dist/session/routing/dispatch.d.ts +4 -3
- package/dist/session/routing/dispatch.js +63 -113
- package/dist/session/routing/envelope.d.ts +3 -3
- package/dist/session/routing/expiry.d.ts +4 -0
- package/dist/session/routing/expiry.js +32 -0
- package/dist/session/routing/index.d.ts +4 -2
- package/dist/session/routing/index.js +4 -2
- package/dist/session/routing/integrity.d.ts +7 -0
- package/dist/session/routing/integrity.js +44 -0
- package/dist/session/routing/recovery.d.ts +16 -0
- package/dist/session/routing/recovery.js +41 -0
- package/dist/session/routing/result.d.ts +5 -0
- package/dist/session/routing/result.js +12 -0
- package/dist/session/routing/store.d.ts +23 -0
- package/dist/session/routing/store.js +99 -0
- package/dist/session/session.d.ts +11 -51
- package/dist/session/session.js +37 -139
- package/dist/session/session.typecheck.js +12 -4
- package/dist/session/views/catalog.d.ts +9 -5
- package/dist/session/views/catalog.js +29 -24
- package/dist/session/views/index.d.ts +1 -1
- package/dist/session/views/index.js +1 -1
- package/dist/session/views/resolve.d.ts +6 -4
- package/dist/session/views/resolve.js +14 -6
- package/dist/store/entity-index.d.ts +1 -2
- package/dist/store/entity-index.js +0 -3
- package/dist/store/memory.js +2 -2
- package/dist/store/shape.d.ts +2 -1
- package/dist/transport/auto/decision.d.ts +3 -2
- package/dist/transport/http/admission.d.ts +5 -0
- package/dist/transport/http/admission.js +101 -0
- package/dist/transport/http/binary.d.ts +5 -0
- package/dist/transport/http/binary.js +70 -0
- package/dist/transport/http/configuration.d.ts +24 -0
- package/dist/transport/http/configuration.js +116 -0
- package/dist/transport/http/index.d.ts +2 -1
- package/dist/transport/http/response.d.ts +7 -0
- package/dist/transport/http/response.js +9 -0
- package/dist/transport/http/retired.d.ts +8 -0
- package/dist/transport/http/retired.js +28 -0
- package/dist/transport/http/transport.d.ts +1 -19
- package/dist/transport/http/transport.js +17 -300
- package/dist/transport/websocket/connection.d.ts +2 -1
- package/package.json +5 -5
- package/dist/session/content.d.ts +0 -27
- package/dist/session/content.js +0 -135
- package/dist/session/discovery/legacy/index.d.ts +0 -38
- package/dist/session/discovery/legacy/index.js +0 -38
- package/dist/session/discovery/legacy/intrinsic.d.ts +0 -33
- package/dist/session/discovery/legacy/intrinsic.js +0 -67
- package/dist/session/discovery/legacy/projection.d.ts +0 -8
- package/dist/session/discovery/legacy/projection.js +0 -17
- package/dist/session/discovery/legacy/publication.d.ts +0 -26
- package/dist/session/discovery/legacy/publication.js +0 -76
|
@@ -1,55 +1,19 @@
|
|
|
1
1
|
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
2
2
|
import type { PathLike } from '@astrale-os/kernel-core/path';
|
|
3
3
|
import type { Domain } from '@astrale-os/kernel-dsl/v1/domain';
|
|
4
|
-
import type { publication } from '@astrale-os/kernel-protocol';
|
|
5
4
|
import type { AuthApi } from '../auth/index.js';
|
|
6
5
|
import type { Call, Input, Result } from '../client/index.js';
|
|
7
6
|
import type { DomainBinding, GraphApi } from '../graph/index.js';
|
|
8
|
-
import type { ClientFactory, ClientPool as ClientPoolType } from '../pool/index.js';
|
|
9
7
|
import type { SchemaApi } from '../schema/index.js';
|
|
10
|
-
import type {
|
|
11
|
-
import type { Fetch } from '../transport/http/index.js';
|
|
12
|
-
import type { WebSocketConstructor } from '../transport/websocket/index.js';
|
|
13
|
-
import type { ContentApi } from './content.js';
|
|
8
|
+
import type { ContentApi } from './content/index.js';
|
|
14
9
|
import type { SessionControlOptions, SessionPolicy } from './context/index.js';
|
|
15
10
|
import type { SessionCredential } from './credential/index.js';
|
|
16
11
|
import type { IntrinsicRelease, SessionSnapshot } from './discovery/index.js';
|
|
17
|
-
import type {
|
|
12
|
+
import type { SessionExchangeRequest } from './exchange/index.js';
|
|
18
13
|
import type { CallableReference, InputModeOfReference, InputOfReference, OutputOfReference } from './reference.js';
|
|
19
|
-
import type {
|
|
14
|
+
import type { SessionRequestOptions, SessionRequestOptionsWithBody } from './routing/index.js';
|
|
20
15
|
import type { ViewCatalog } from './views/index.js';
|
|
21
|
-
|
|
22
|
-
/** Exact canonical source Kernel identity; its invocation and discovery endpoints are derived. */
|
|
23
|
-
readonly kernel: string;
|
|
24
|
-
readonly fetch?: Fetch;
|
|
25
|
-
readonly client?: ClientFactory;
|
|
26
|
-
readonly pool?: Pick<ClientPoolType, 'clientFor'>;
|
|
27
|
-
readonly websocket?: WebSocketConstructor;
|
|
28
|
-
readonly auth?: SessionAuth;
|
|
29
|
-
/**
|
|
30
|
-
* Present each Domain callable with a credential its declaring Domain exchanges for the `auth`
|
|
31
|
-
* caller, so the Domain is the principal and the caller is `auth`. Kernel and local callables keep
|
|
32
|
-
* the `auth` credential. `connect` defaults to `auto` when `auth` is present; `new ClientSession`
|
|
33
|
-
* keeps source authority when this option is omitted. `{ mode: 'source' }` keeps it for every Call.
|
|
34
|
-
*/
|
|
35
|
-
readonly exchange?: SessionExchangeOptions;
|
|
36
|
-
/** Optional caller-owned persistence for bounded confidential route artifacts. */
|
|
37
|
-
readonly routeStore?: SessionRouteStore;
|
|
38
|
-
readonly policy: SessionPolicy;
|
|
39
|
-
readonly envelopeTransport?: SessionEnvelopeTransport;
|
|
40
|
-
readonly onWarning?: (warning: ClientWarning) => void;
|
|
41
|
-
/** Bounds the source Kernel's own `release.json`. */
|
|
42
|
-
readonly maximumReleaseBytes?: number;
|
|
43
|
-
/**
|
|
44
|
-
* Bounds every Publication the Session reads: the version 3 `domain.json` a Host that predates
|
|
45
|
-
* `release.json` serves, and the Publications Schema results carry.
|
|
46
|
-
*/
|
|
47
|
-
readonly maximumPublicationBytes?: number;
|
|
48
|
-
readonly maximumBundleBytes?: number;
|
|
49
|
-
readonly maximumResponseBytes?: number;
|
|
50
|
-
readonly timeoutMs?: number;
|
|
51
|
-
readonly schemaLifecycleTimeoutMs?: number;
|
|
52
|
-
}
|
|
16
|
+
import { type ClientSessionOptions } from './options.js';
|
|
53
17
|
export type ConnectOptions = Omit<ClientSessionOptions, 'kernel' | 'policy'> & {
|
|
54
18
|
readonly url: string;
|
|
55
19
|
readonly policy?: SessionPolicy;
|
|
@@ -61,7 +25,7 @@ export declare class ClientSession {
|
|
|
61
25
|
readonly graph: GraphApi;
|
|
62
26
|
readonly auth: AuthApi;
|
|
63
27
|
readonly content: ContentApi;
|
|
64
|
-
private readonly ownedPool
|
|
28
|
+
private readonly ownedPool;
|
|
65
29
|
private readonly discovery;
|
|
66
30
|
private readonly dispatcher;
|
|
67
31
|
private readonly lifecycle;
|
|
@@ -69,7 +33,7 @@ export declare class ClientSession {
|
|
|
69
33
|
private readonly routes;
|
|
70
34
|
private readonly exchangeDependencies;
|
|
71
35
|
private readonly callExchange?;
|
|
72
|
-
private readonly
|
|
36
|
+
private readonly admitDomainViews;
|
|
73
37
|
private closed;
|
|
74
38
|
constructor(options: ClientSessionOptions);
|
|
75
39
|
/** Bind one admitted DSL Domain to authenticated graph projection and Method dispatch. */
|
|
@@ -81,19 +45,15 @@ export declare class ClientSession {
|
|
|
81
45
|
*/
|
|
82
46
|
exchange(domain: string, options?: SessionExchangeRequest): Promise<SessionCredential>;
|
|
83
47
|
/**
|
|
84
|
-
* Revalidate the source Kernel's own release (`release.json`) without acquiring its bundle or
|
|
85
|
-
* Views; a Host that predates intrinsic `release.json` yields its version 3 Publication instead.
|
|
48
|
+
* Revalidate the source Kernel's own release (`release.json`) without acquiring its bundle or Views.
|
|
86
49
|
*/
|
|
87
50
|
release(options?: SessionControlOptions): Promise<IntrinsicRelease>;
|
|
51
|
+
snapshot(options?: SessionControlOptions): Promise<SessionSnapshot>;
|
|
88
52
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* @deprecated Use `release()`. Deleted when no supported Host predates intrinsic `release.json`.
|
|
53
|
+
* Resolve the View catalog of one installed Domain. Only an exact Domain Path `/:<origin>` is
|
|
54
|
+
* accepted; any other Path rejects with a TypeError before the call.
|
|
93
55
|
*/
|
|
94
|
-
|
|
95
|
-
snapshot(options?: SessionControlOptions): Promise<SessionSnapshot>;
|
|
96
|
-
viewsFor(target: PathLike, options?: SessionControlOptions): Promise<ViewCatalog>;
|
|
56
|
+
viewsFor(domain: PathLike, options?: SessionControlOptions): Promise<ViewCatalog>;
|
|
97
57
|
dispatch(call: Call, options?: SessionRequestOptions): Promise<Result>;
|
|
98
58
|
dispatch(call: Call, options: SessionRequestOptionsWithBody): Promise<Result>;
|
|
99
59
|
call(call: Call, options?: SessionRequestOptions): Promise<Input>;
|
package/dist/session/session.js
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import { Path } from '@astrale-os/kernel-core/path';
|
|
2
2
|
import { callableFingerprint } from '@astrale-os/kernel-dsl/v1/schema/fingerprint';
|
|
3
3
|
import { createAuth } from '../auth/auth.js';
|
|
4
|
-
import {
|
|
4
|
+
import { acceptCall } from '../client/index.js';
|
|
5
5
|
import { SessionError } from '../errors/index.js';
|
|
6
6
|
import { createDomainBinding } from '../graph/domain/binding.js';
|
|
7
7
|
import { createGraph } from '../graph/index.js';
|
|
8
|
-
import {
|
|
9
|
-
import { createSchema, DEFAULT_SCHEMA_LIFECYCLE_TIMEOUT_MS } from '../schema/index.js';
|
|
10
|
-
import { AutoTransport } from '../transport/auto/index.js';
|
|
11
|
-
import { HttpTransport } from '../transport/http/index.js';
|
|
12
|
-
import { WebSocketTransport } from '../transport/websocket/index.js';
|
|
8
|
+
import { createSchema } from '../schema/index.js';
|
|
13
9
|
import { admitFunction } from './admission.js';
|
|
14
|
-
import { createContentApi } from './content.js';
|
|
15
|
-
import { admitControlOptions,
|
|
10
|
+
import { createContentApi } from './content/index.js';
|
|
11
|
+
import { admitControlOptions, allowEndpoint, createSessionOperation } from './context/index.js';
|
|
16
12
|
import { createSessionDiscovery } from './discovery/index.js';
|
|
17
|
-
import { acquireDomainCredential,
|
|
13
|
+
import { acquireDomainCredential, admitExchangeRequest, createSessionExchange, } from './exchange/index.js';
|
|
14
|
+
import { acceptSessionOptions } from './options.js';
|
|
18
15
|
import { admitReference } from './reference.js';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
16
|
+
import { admitInvocationOptions, requireResultKind, SessionDispatcher } from './routing/index.js';
|
|
17
|
+
import { domainViewCatalog, resolveViewsFor } from './views/index.js';
|
|
21
18
|
const DEFAULT_SESSION_POLICY = Object.freeze({ maximumRouteAgeMs: 60_000 });
|
|
22
19
|
/** Caller-owned discovery and redirect-following conversation with one exact source Kernel. */
|
|
23
20
|
export class ClientSession {
|
|
@@ -34,94 +31,56 @@ export class ClientSession {
|
|
|
34
31
|
routes;
|
|
35
32
|
exchangeDependencies;
|
|
36
33
|
callExchange;
|
|
37
|
-
|
|
34
|
+
admitDomainViews;
|
|
38
35
|
closed = false;
|
|
39
36
|
constructor(options) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (typeof fetch !== 'function')
|
|
49
|
-
throw new TypeError('ClientSession requires Fetch.');
|
|
50
|
-
const fetchImpl = options.fetch === undefined ? fetch.bind(globalThis) : fetch;
|
|
51
|
-
if (options.client !== undefined && options.pool !== undefined) {
|
|
52
|
-
throw new TypeError('ClientSession accepts either client or pool, not both.');
|
|
53
|
-
}
|
|
54
|
-
const maximumReleaseBytes = positive(options.maximumReleaseBytes ?? DEFAULT_MAXIMUM_RELEASE_BYTES, 'maximumReleaseBytes');
|
|
55
|
-
const maximumPublicationBytes = positive(options.maximumPublicationBytes ?? DEFAULT_MAXIMUM_PUBLICATION_BYTES, 'maximumPublicationBytes');
|
|
56
|
-
const maximumBundleBytes = positive(options.maximumBundleBytes ?? DEFAULT_MAXIMUM_BUNDLE_BYTES, 'maximumBundleBytes');
|
|
57
|
-
const maximumResponseBytes = positive(options.maximumResponseBytes ?? DEFAULT_MAXIMUM_RESPONSE_BYTES, 'maximumResponseBytes');
|
|
58
|
-
const timeoutMs = platformDuration(options.timeoutMs ?? DEFAULT_TIMEOUT_MS, 'timeoutMs');
|
|
59
|
-
const schemaLifecycleTimeoutMs = platformDuration(options.schemaLifecycleTimeoutMs ?? DEFAULT_SCHEMA_LIFECYCLE_TIMEOUT_MS, 'schemaLifecycleTimeoutMs');
|
|
60
|
-
this.timeoutMs = timeoutMs;
|
|
61
|
-
const websocketAvailable = options.client !== undefined ||
|
|
62
|
-
options.pool !== undefined ||
|
|
63
|
-
options.websocket !== undefined ||
|
|
64
|
-
typeof WebSocket === 'function';
|
|
65
|
-
const client = options.client ??
|
|
66
|
-
defaultClientFactory({
|
|
67
|
-
fetch: fetchImpl,
|
|
68
|
-
...(options.websocket === undefined ? {} : { websocket: options.websocket }),
|
|
69
|
-
...(options.onWarning === undefined ? {} : { onWarning: options.onWarning }),
|
|
70
|
-
maximumResponseBytes,
|
|
71
|
-
timeoutMs,
|
|
72
|
-
});
|
|
73
|
-
let pool;
|
|
74
|
-
if (options.pool === undefined) {
|
|
75
|
-
const ownedPool = new ClientPool({ client });
|
|
76
|
-
this.ownedPool = ownedPool;
|
|
77
|
-
pool = admitClientPool(ownedPool);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
pool = admitClientPool(options.pool);
|
|
81
|
-
}
|
|
37
|
+
const settled = acceptSessionOptions(options);
|
|
38
|
+
const { kernel, sourceEndpoint, policy, fetch, pool, auth } = settled;
|
|
39
|
+
const { maximumReleaseBytes, maximumBundleBytes, maximumResponseBytes } = settled;
|
|
40
|
+
this.kernel = kernel;
|
|
41
|
+
this.timeoutMs = settled.timeoutMs;
|
|
42
|
+
this.ownedPool = settled.ownedPool;
|
|
43
|
+
this.routes = settled.routes;
|
|
44
|
+
this.admitDomainViews = (input, domain) => domainViewCatalog(input, domain, policy);
|
|
82
45
|
this.discovery = createSessionDiscovery({
|
|
83
|
-
kernel
|
|
84
|
-
fetch
|
|
46
|
+
kernel,
|
|
47
|
+
fetch,
|
|
85
48
|
policy,
|
|
86
49
|
maximumReleaseBytes,
|
|
87
|
-
maximumPublicationBytes,
|
|
88
50
|
maximumBundleBytes,
|
|
89
51
|
requireOpen: () => this.requireOpen(),
|
|
90
52
|
acquisitionOperation: () => this.operation(undefined),
|
|
91
53
|
});
|
|
92
|
-
this.routes = new RouteCache(policy.maximumRouteAgeMs, undefined, options.routeStore);
|
|
93
|
-
const auth = admitSessionAuth(options.auth);
|
|
94
|
-
const exchange = admitExchangeOptions(options.exchange, auth);
|
|
95
54
|
this.exchangeDependencies = Object.freeze({
|
|
96
|
-
kernel
|
|
55
|
+
kernel,
|
|
97
56
|
source: () => {
|
|
98
57
|
allowEndpoint(sourceEndpoint, policy);
|
|
99
58
|
return pool.clientFor({ transport: 'http', url: sourceEndpoint });
|
|
100
59
|
},
|
|
101
60
|
...(auth === undefined ? {} : { auth }),
|
|
102
|
-
fetch
|
|
61
|
+
fetch,
|
|
103
62
|
policy,
|
|
104
|
-
limits: {
|
|
63
|
+
limits: { maximumReleaseBytes, maximumBundleBytes },
|
|
105
64
|
maximumResponseBytes,
|
|
106
65
|
operation: (signal) => this.operation(signal === undefined ? undefined : { signal }),
|
|
107
66
|
});
|
|
108
67
|
this.callExchange =
|
|
109
|
-
exchange === undefined || auth === undefined
|
|
68
|
+
settled.exchange === undefined || auth === undefined
|
|
110
69
|
? undefined
|
|
111
|
-
: createSessionExchange({ ...this.exchangeDependencies, auth }, exchange);
|
|
70
|
+
: createSessionExchange({ ...this.exchangeDependencies, auth }, settled.exchange);
|
|
112
71
|
this.dispatcher = new SessionDispatcher({
|
|
113
|
-
kernel
|
|
72
|
+
kernel,
|
|
114
73
|
sourceEndpoint,
|
|
115
74
|
pool,
|
|
116
|
-
websocketAvailable,
|
|
75
|
+
websocketAvailable: settled.websocketAvailable,
|
|
117
76
|
auth,
|
|
118
77
|
...(this.callExchange === undefined ? {} : { exchange: this.callExchange }),
|
|
119
78
|
cache: this.routes,
|
|
120
79
|
policy,
|
|
121
|
-
envelopeTransport:
|
|
80
|
+
envelopeTransport: settled.envelopeTransport,
|
|
122
81
|
requireOpen: () => this.requireOpen(),
|
|
123
82
|
streamingHttp: {
|
|
124
|
-
fetch
|
|
83
|
+
fetch,
|
|
125
84
|
maximumResponseBytes: 100 * 1024 * 1024,
|
|
126
85
|
timeoutMs: 30 * 60 * 1_000,
|
|
127
86
|
},
|
|
@@ -131,9 +90,9 @@ export class ClientSession {
|
|
|
131
90
|
dispatch: (target, input, operation, body) => this.dispatcher.dispatchHttp({ target, input }, {}, operation, body),
|
|
132
91
|
});
|
|
133
92
|
this.schema = createSchema((request, options) => this.dispatch(request, options), {
|
|
134
|
-
|
|
93
|
+
maximumReleaseBytes,
|
|
135
94
|
maximumBundleBytes,
|
|
136
|
-
lifecycleTimeoutMs: schemaLifecycleTimeoutMs,
|
|
95
|
+
lifecycleTimeoutMs: settled.schemaLifecycleTimeoutMs,
|
|
137
96
|
});
|
|
138
97
|
this.graph = createGraph((call, options) => this.call(call, options));
|
|
139
98
|
this.auth = createAuth((target, input, options) => this.call({ target, input }, options), (call, options) => {
|
|
@@ -155,27 +114,21 @@ export class ClientSession {
|
|
|
155
114
|
return acquireDomainCredential(this.exchangeDependencies, request, this.operation(request.control));
|
|
156
115
|
}
|
|
157
116
|
/**
|
|
158
|
-
* Revalidate the source Kernel's own release (`release.json`) without acquiring its bundle or
|
|
159
|
-
* Views; a Host that predates intrinsic `release.json` yields its version 3 Publication instead.
|
|
117
|
+
* Revalidate the source Kernel's own release (`release.json`) without acquiring its bundle or Views.
|
|
160
118
|
*/
|
|
161
119
|
release(options) {
|
|
162
120
|
return this.discovery.release(this.operation(admitControlOptions(options)));
|
|
163
121
|
}
|
|
164
|
-
/**
|
|
165
|
-
* Revalidate the intrinsic release and return its v3 document: the Host's own version 3
|
|
166
|
-
* Publication, or the frozen v3 projection of its `DomainRelease`.
|
|
167
|
-
*
|
|
168
|
-
* @deprecated Use `release()`. Deleted when no supported Host predates intrinsic `release.json`.
|
|
169
|
-
*/
|
|
170
|
-
publication(options) {
|
|
171
|
-
return this.discovery.publication(this.operation(admitControlOptions(options)));
|
|
172
|
-
}
|
|
173
122
|
snapshot(options) {
|
|
174
123
|
return this.discovery.snapshot(this.operation(admitControlOptions(options)));
|
|
175
124
|
}
|
|
176
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Resolve the View catalog of one installed Domain. Only an exact Domain Path `/:<origin>` is
|
|
127
|
+
* accepted; any other Path rejects with a TypeError before the call.
|
|
128
|
+
*/
|
|
129
|
+
viewsFor(domain, options) {
|
|
177
130
|
this.requireOpen();
|
|
178
|
-
return resolveViewsFor(async (call, operation) => requireResultKind('value', await this.dispatcher.dispatch(call, {}, operation)).value, this.
|
|
131
|
+
return resolveViewsFor(async (call, operation) => requireResultKind('value', await this.dispatcher.dispatch(call, {}, operation)).value, this.admitDomainViews, domain, this.operation(admitControlOptions(options)));
|
|
179
132
|
}
|
|
180
133
|
dispatch(call, options) {
|
|
181
134
|
return this.dispatchWith(call, options);
|
|
@@ -277,58 +230,3 @@ export function connect(options) {
|
|
|
277
230
|
policy: rest.policy ?? DEFAULT_SESSION_POLICY,
|
|
278
231
|
});
|
|
279
232
|
}
|
|
280
|
-
function admitClientPool(input) {
|
|
281
|
-
if (input === null ||
|
|
282
|
-
typeof input !== 'object' ||
|
|
283
|
-
typeof input.clientFor !== 'function') {
|
|
284
|
-
throw new TypeError('Session client pool capability is invalid.');
|
|
285
|
-
}
|
|
286
|
-
return Object.freeze({
|
|
287
|
-
clientFor: (target) => admitPooledClient(input.clientFor.call(input, target)),
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
function admitPooledClient(input) {
|
|
291
|
-
if (input === null ||
|
|
292
|
-
typeof input !== 'object' ||
|
|
293
|
-
typeof input.dispatch !== 'function' ||
|
|
294
|
-
typeof input.as !== 'function' ||
|
|
295
|
-
typeof input.close !== 'function') {
|
|
296
|
-
throw new TypeError('Session client pool capability returned an invalid Client.');
|
|
297
|
-
}
|
|
298
|
-
return input;
|
|
299
|
-
}
|
|
300
|
-
function defaultClientFactory(options) {
|
|
301
|
-
return (target) => {
|
|
302
|
-
switch (target.transport) {
|
|
303
|
-
case 'http':
|
|
304
|
-
return new Client({
|
|
305
|
-
transport: new HttpTransport({
|
|
306
|
-
url: target.url,
|
|
307
|
-
fetch: options.fetch,
|
|
308
|
-
timeoutMs: options.timeoutMs,
|
|
309
|
-
maximumResponseBytes: options.maximumResponseBytes,
|
|
310
|
-
}),
|
|
311
|
-
});
|
|
312
|
-
case 'websocket':
|
|
313
|
-
return new Client({
|
|
314
|
-
transport: new WebSocketTransport({
|
|
315
|
-
url: target.url,
|
|
316
|
-
timeoutMs: options.timeoutMs,
|
|
317
|
-
maximumResponseBytes: options.maximumResponseBytes,
|
|
318
|
-
...(options.websocket === undefined ? {} : { websocket: options.websocket }),
|
|
319
|
-
}),
|
|
320
|
-
});
|
|
321
|
-
case 'auto':
|
|
322
|
-
return new Client({
|
|
323
|
-
transport: new AutoTransport({
|
|
324
|
-
endpoints: target.endpoints,
|
|
325
|
-
fetch: options.fetch,
|
|
326
|
-
timeoutMs: options.timeoutMs,
|
|
327
|
-
maximumResponseBytes: options.maximumResponseBytes,
|
|
328
|
-
...(options.websocket === undefined ? {} : { websocket: options.websocket }),
|
|
329
|
-
...(options.onWarning === undefined ? {} : { onWarning: options.onWarning }),
|
|
330
|
-
}),
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
}
|
|
@@ -14,14 +14,19 @@ void request;
|
|
|
14
14
|
void snapshot;
|
|
15
15
|
const observedRelease = session.release(control);
|
|
16
16
|
void observedRelease;
|
|
17
|
-
void observedRelease.then((current) => current.
|
|
18
|
-
|
|
19
|
-
void
|
|
17
|
+
void observedRelease.then((current) => current.build.digest);
|
|
18
|
+
// @ts-expect-error Publication discovery is absent from the public Session.
|
|
19
|
+
void session.publication(control);
|
|
20
|
+
// @ts-expect-error A coherent snapshot contains only its canonical release.
|
|
21
|
+
void snapshot.publication;
|
|
20
22
|
const admitted = session.auth.admit({
|
|
21
23
|
target: Path.parse('/:example.test:function.write'),
|
|
22
24
|
input: {},
|
|
23
|
-
},
|
|
25
|
+
}, control);
|
|
24
26
|
void admitted;
|
|
27
|
+
void session.auth.admit({ target: Path.parse('/:example.test:function.write'), input: {} },
|
|
28
|
+
// @ts-expect-error Admission carries no authority expression.
|
|
29
|
+
{ attenuation: { kind: 'identity', self: true } });
|
|
25
30
|
// @ts-expect-error Admission belongs to Auth, not the top-level Session.
|
|
26
31
|
void session.admit({ target: Path.parse('/:example.test:function.write'), input: {} });
|
|
27
32
|
const credentials = createSessionCredentialProvider({
|
|
@@ -68,6 +73,7 @@ if (isBinaryInput(registerInput))
|
|
|
68
73
|
const registrationInput = valueSchema()(registerInput);
|
|
69
74
|
const booleanOutput = valueSchema()({ type: 'boolean' });
|
|
70
75
|
const typedDomain = schema.resolve(defineSchema('client.input-witness.typecheck', {
|
|
76
|
+
name: 'Test Domain',
|
|
71
77
|
dependencies: { kernel: KernelSchema },
|
|
72
78
|
functions: {
|
|
73
79
|
registerIdentity: func({
|
|
@@ -152,6 +158,7 @@ const abstractMethod = method({
|
|
|
152
158
|
abstract: true,
|
|
153
159
|
});
|
|
154
160
|
const abstractDomain = schema.resolve(defineSchema('client.reference.typecheck', {
|
|
161
|
+
name: 'Test Domain',
|
|
155
162
|
classes: {
|
|
156
163
|
AbstractItem: nodeClass({ abstract: true, methods: { abstractMethod } }),
|
|
157
164
|
},
|
|
@@ -163,6 +170,7 @@ const reminderOutput = valueSchema()({
|
|
|
163
170
|
additionalProperties: false,
|
|
164
171
|
});
|
|
165
172
|
const durableDomain = schema.resolve(defineSchema('client.durable.typecheck', {
|
|
173
|
+
name: 'Test Domain',
|
|
166
174
|
classes: {
|
|
167
175
|
Invoice: nodeClass({
|
|
168
176
|
methods: {
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import type { Key, bundle } from '@astrale-os/kernel-dsl/v1';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DomainRelease } from '@astrale-os/kernel-protocol/release';
|
|
3
3
|
import { type ResolvedView } from '@astrale-os/kernel-core/schema/kernel/syscalls/view-resolution';
|
|
4
4
|
export type { ResolvedView } from '@astrale-os/kernel-core/schema/kernel/syscalls/view-resolution';
|
|
5
5
|
import type { SessionPolicy } from '../context/index.js';
|
|
6
|
-
/** One verified View declaration joined with its owning
|
|
6
|
+
/** One verified View declaration joined with its owning Release and provenance. */
|
|
7
7
|
/** Immutable canonical-key-ordered inventory of Views resolved under one Session revision. */
|
|
8
8
|
export interface ViewCatalog {
|
|
9
9
|
readonly entrypoint?: ResolvedView;
|
|
10
10
|
readonly views: readonly ResolvedView[];
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
/** Join each root Domain View to its exact release binding. */
|
|
13
|
+
export declare function rootViewCatalog(release: DomainRelease, artifact: bundle.Bundle, policy: Readonly<SessionPolicy>): ViewCatalog;
|
|
13
14
|
export declare function catalogFromKeys(root: ViewCatalog, keys: readonly Key.View[]): ViewCatalog;
|
|
14
|
-
/**
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Re-admit one Runtime-resolved Domain View catalog at the Client trust boundary. Only Views that
|
|
17
|
+
* the requested Domain declares for itself are kept.
|
|
18
|
+
*/
|
|
19
|
+
export declare function domainViewCatalog(input: unknown, domain: Key.Origin, policy: Readonly<SessionPolicy>): ViewCatalog;
|
|
@@ -2,35 +2,36 @@ import { acceptViewResolution, } from '@astrale-os/kernel-core/schema/kernel/sys
|
|
|
2
2
|
import { Key as ViewKey } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
3
3
|
import { ClientError } from '../../errors/index.js';
|
|
4
4
|
import { allowEndpoint } from '../context/index.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/** Join each root Domain View to its exact release binding. */
|
|
6
|
+
export function rootViewCatalog(release, artifact, policy) {
|
|
7
|
+
const views = release.bindings.views
|
|
8
|
+
.flatMap((binding) => {
|
|
8
9
|
allowEndpoint(binding.href, policy);
|
|
9
10
|
const declaration = artifact.root.views[viewName(binding.view)];
|
|
10
11
|
if (declaration === undefined) {
|
|
11
12
|
throw new ClientError('Published View has no verified root declaration.');
|
|
12
13
|
}
|
|
13
14
|
const { ref: _ref, ...viewDeclaration } = declaration;
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
return [
|
|
16
|
+
Object.freeze({
|
|
17
|
+
key: binding.view,
|
|
18
|
+
declaration: Object.freeze(viewDeclaration),
|
|
19
|
+
href: binding.href,
|
|
20
|
+
handshake: binding.handshake,
|
|
21
|
+
...(binding.host === undefined ? {} : { host: binding.host }),
|
|
22
|
+
issuer: release.identity.issuer,
|
|
23
|
+
release: release.digest,
|
|
24
|
+
revision: release.schema.revision,
|
|
25
|
+
}),
|
|
26
|
+
];
|
|
25
27
|
})
|
|
26
28
|
.sort((left, right) => compareKeys(left.key, right.key));
|
|
27
29
|
const catalogViews = Object.freeze(views);
|
|
28
|
-
const entrypointRef =
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
throw new ClientError('Published View entrypoint has no verified Publication binding.');
|
|
30
|
+
const entrypointRef = artifact.root.entrypoint;
|
|
31
|
+
const entrypointKey = entrypointRef === undefined ? undefined : ViewKey.of(entrypointRef);
|
|
32
|
+
const entrypoint = entrypointKey === undefined ? undefined : catalogViews.find(({ key }) => key === entrypointKey);
|
|
33
|
+
if (entrypointKey !== undefined && entrypoint === undefined) {
|
|
34
|
+
throw new ClientError('Published View entrypoint has no verified Release binding.');
|
|
34
35
|
}
|
|
35
36
|
return Object.freeze({
|
|
36
37
|
...(entrypoint === undefined ? {} : { entrypoint }),
|
|
@@ -47,8 +48,11 @@ export function catalogFromKeys(root, keys) {
|
|
|
47
48
|
views,
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
|
-
/**
|
|
51
|
-
|
|
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) {
|
|
52
56
|
let resolution;
|
|
53
57
|
try {
|
|
54
58
|
resolution = acceptViewResolution(input);
|
|
@@ -56,9 +60,10 @@ export function targetViewCatalog(input, policy) {
|
|
|
56
60
|
catch (cause) {
|
|
57
61
|
throw new ClientError('Resolved View catalog is invalid.', { cause });
|
|
58
62
|
}
|
|
59
|
-
|
|
63
|
+
const views = resolution.views.filter((view) => ViewKey.origin(view.key) === domain);
|
|
64
|
+
for (const view of views)
|
|
60
65
|
allowEndpoint(view.href, policy);
|
|
61
|
-
return Object.freeze({ views:
|
|
66
|
+
return Object.freeze({ views: Object.freeze(views) });
|
|
62
67
|
}
|
|
63
68
|
function compareKeys(left, right) {
|
|
64
69
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { catalogFromKeys,
|
|
1
|
+
export { catalogFromKeys, domainViewCatalog, rootViewCatalog, type ResolvedView, type ViewCatalog, } from './catalog.js';
|
|
2
2
|
export { resolveViewsFor, type ViewCatalogAdmission, type ViewInvoker } from './resolve.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { catalogFromKeys,
|
|
1
|
+
export { catalogFromKeys, domainViewCatalog, rootViewCatalog, } from './catalog.js';
|
|
2
2
|
export { resolveViewsFor } from './resolve.js';
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { PathLike } from '@astrale-os/kernel-core/path';
|
|
2
|
+
import type { Key } from '@astrale-os/kernel-dsl/v1';
|
|
2
3
|
import type { Call, Input } from '../../client/index.js';
|
|
3
4
|
import type { SessionOperation } from '../context/index.js';
|
|
4
5
|
import type { ViewCatalog } from './catalog.js';
|
|
5
6
|
export type ViewInvoker = (call: Call, operation: SessionOperation) => Promise<Input>;
|
|
6
|
-
export type ViewCatalogAdmission = (input: unknown) => ViewCatalog;
|
|
7
|
+
export type ViewCatalogAdmission = (input: unknown, domain: Key.Origin) => ViewCatalog;
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
* its
|
|
9
|
+
* Resolve the per-Domain View catalog through the canonical source Kernel call, then admit its
|
|
10
|
+
* installed Release evidence. Every View targets its owning Domain, so only an exact Domain
|
|
11
|
+
* Path `/:<origin>` is meaningful; any other Path is refused before the call.
|
|
10
12
|
*/
|
|
11
|
-
export declare function resolveViewsFor(invoke: ViewInvoker, admitCatalog: ViewCatalogAdmission,
|
|
13
|
+
export declare function resolveViewsFor(invoke: ViewInvoker, admitCatalog: ViewCatalogAdmission, domain: PathLike, operation: SessionOperation): Promise<ViewCatalog>;
|
|
@@ -2,12 +2,20 @@ import { Path } from '@astrale-os/kernel-core/path';
|
|
|
2
2
|
import { view } from '@astrale-os/kernel-core/schema/kernel/syscalls/references';
|
|
3
3
|
import { call } from '../../client/index.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* its
|
|
5
|
+
* Resolve the per-Domain View catalog through the canonical source Kernel call, then admit its
|
|
6
|
+
* installed Release evidence. Every View targets its owning Domain, so only an exact Domain
|
|
7
|
+
* Path `/:<origin>` is meaningful; any other Path is refused before the call.
|
|
7
8
|
*/
|
|
8
|
-
export async function resolveViewsFor(invoke, admitCatalog,
|
|
9
|
-
const
|
|
9
|
+
export async function resolveViewsFor(invoke, admitCatalog, domain, operation) {
|
|
10
|
+
const origin = domainOrigin(domain);
|
|
10
11
|
const owner = Path.project(view.resolve.owner);
|
|
11
|
-
const
|
|
12
|
-
return admitCatalog(await invoke(call(
|
|
12
|
+
const resolve = Path.staticMethod(owner, view.resolve.name);
|
|
13
|
+
return admitCatalog(await invoke(call(resolve, { target: Path.domain(origin).raw }), operation), origin);
|
|
14
|
+
}
|
|
15
|
+
function domainOrigin(input) {
|
|
16
|
+
const { anchor, steps } = Path.from(input).ast;
|
|
17
|
+
if (anchor.kind !== 'domain' || steps.length !== 0) {
|
|
18
|
+
throw new TypeError('View catalog requires a Domain Path /:<origin>; Views never target a Node.');
|
|
19
|
+
}
|
|
20
|
+
return anchor.origin;
|
|
13
21
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Edge
|
|
1
|
+
import type { Edge } from '@astrale-os/kernel-core/graph/edge';
|
|
2
2
|
import type { Node, NodeId } from '@astrale-os/kernel-core/graph/node';
|
|
3
3
|
import type { QueryResult } from '@astrale-os/kernel-core/graph/query';
|
|
4
4
|
export interface FactReferences {
|
|
@@ -19,4 +19,3 @@ export declare class EntityIndex {
|
|
|
19
19
|
sweep(reachableNodes: ReadonlySet<NodeId>, reachableEdges: ReadonlySet<string>): void;
|
|
20
20
|
clear(): void;
|
|
21
21
|
}
|
|
22
|
-
export declare function edgeIdentity(key: EdgeKey): string;
|
package/dist/store/memory.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { encodeEdgeKey } from '@astrale-os/kernel-core/graph/edge';
|
|
2
2
|
import { ClientError } from '../errors/index.js';
|
|
3
3
|
import { retainDerivedQueryProvenance } from '../graph/provenance.js';
|
|
4
|
-
import {
|
|
4
|
+
import { EntityIndex } from './entity-index.js';
|
|
5
5
|
import { OptimisticOverlay } from './optimistic.js';
|
|
6
6
|
import { COLD_SNAPSHOT, QueryShape } from './shape.js';
|
|
7
7
|
export class GraphMemory {
|
|
@@ -225,7 +225,7 @@ export class GraphMemory {
|
|
|
225
225
|
const edge = item.edge.kind === 'reference'
|
|
226
226
|
? item.edge
|
|
227
227
|
: (() => {
|
|
228
|
-
const value = this.entities.edge(
|
|
228
|
+
const value = this.entities.edge(encodeEdgeKey(item.edge.value));
|
|
229
229
|
return value === undefined
|
|
230
230
|
? undefined
|
|
231
231
|
: Object.freeze({ kind: 'value', value: materializeEdge(value) });
|
package/dist/store/shape.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { DomainDependency } from '@astrale-os/kernel-dsl/v1/schema';
|
|
|
4
4
|
import type { QueryPageRequest } from '../graph/index.js';
|
|
5
5
|
import type { FactReferences } from './entity-index.js';
|
|
6
6
|
import type { StoreQueryResponse, StoreSnapshot } from './store.js';
|
|
7
|
-
|
|
7
|
+
type ShapeState = StoreSnapshot['state'];
|
|
8
8
|
export declare class QueryShape {
|
|
9
9
|
readonly key: string;
|
|
10
10
|
readonly ast: QueryAST;
|
|
@@ -26,3 +26,4 @@ export declare class QueryShape {
|
|
|
26
26
|
referencesAny(nodes: ReadonlySet<NodeId>, edges: ReadonlySet<string>): boolean;
|
|
27
27
|
}
|
|
28
28
|
export declare const COLD_SNAPSHOT: StoreSnapshot;
|
|
29
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type AutoSelection = 'websocket' | 'http';
|
|
2
|
+
type AutoDecisionTicket = {
|
|
3
3
|
readonly kind: 'selected';
|
|
4
4
|
readonly selection: AutoSelection;
|
|
5
5
|
} | {
|
|
@@ -20,3 +20,4 @@ export declare class AutoDecision {
|
|
|
20
20
|
release(): void;
|
|
21
21
|
close(): void;
|
|
22
22
|
}
|
|
23
|
+
export {};
|