@astrale-os/kernel-client 1.0.0-beta.23 → 1.0.0-beta.25

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.
Files changed (51) hide show
  1. package/dist/errors/index.d.ts +1 -0
  2. package/dist/errors/index.js +1 -0
  3. package/dist/errors/query-input.d.ts +47 -0
  4. package/dist/errors/query-input.js +84 -0
  5. package/dist/execution/deadline.d.ts +10 -0
  6. package/dist/execution/deadline.js +12 -0
  7. package/dist/execution/execution.d.ts +5 -1
  8. package/dist/execution/execution.js +2 -7
  9. package/dist/execution/index.d.ts +1 -1
  10. package/dist/execution/index.js +1 -1
  11. package/dist/schema/contracts.d.ts +21 -10
  12. package/dist/schema/index.d.ts +1 -1
  13. package/dist/schema/installation.d.ts +11 -1
  14. package/dist/schema/installation.js +45 -1
  15. package/dist/schema/schema.d.ts +4 -4
  16. package/dist/schema/schema.js +34 -24
  17. package/dist/session/admission.js +6 -1
  18. package/dist/session/bound.d.ts +10 -3
  19. package/dist/session/bound.js +8 -1
  20. package/dist/session/context/operation.js +2 -16
  21. package/dist/session/discovery/discovery.js +1 -1
  22. package/dist/session/discovery/snapshot.d.ts +5 -1
  23. package/dist/session/index.d.ts +2 -1
  24. package/dist/session/routing/dispatch.js +11 -8
  25. package/dist/session/routing/envelope.d.ts +3 -3
  26. package/dist/session/routing/legacy/release-route.d.ts +12 -0
  27. package/dist/session/routing/legacy/release-route.js +6 -0
  28. package/dist/session/session.d.ts +24 -5
  29. package/dist/session/session.js +31 -7
  30. package/dist/session/views/index.d.ts +2 -2
  31. package/dist/session/views/index.js +2 -2
  32. package/dist/session/views/legacy/catalog.d.ts +21 -0
  33. package/dist/session/views/{catalog.js → legacy/catalog.js} +7 -31
  34. package/dist/session/views/legacy/index.d.ts +14 -0
  35. package/dist/session/views/legacy/index.js +14 -0
  36. package/dist/session/views/legacy/resolve.d.ts +46 -0
  37. package/dist/session/views/legacy/resolve.js +83 -0
  38. package/dist/session/views/legacy/unplaced.d.ts +22 -0
  39. package/dist/session/views/legacy/unplaced.js +26 -0
  40. package/dist/session/views/read.d.ts +49 -0
  41. package/dist/session/views/read.js +153 -0
  42. package/dist/session/views/view.d.ts +48 -0
  43. package/dist/session/views/view.js +79 -0
  44. package/dist/transport/deadline.d.ts +2 -0
  45. package/dist/transport/deadline.js +18 -0
  46. package/dist/transport/index.d.ts +1 -1
  47. package/dist/transport/index.js +1 -1
  48. package/package.json +5 -5
  49. package/dist/session/views/catalog.d.ts +0 -19
  50. package/dist/session/views/resolve.d.ts +0 -13
  51. package/dist/session/views/resolve.js +0 -21
@@ -1,4 +1,5 @@
1
1
  import { SessionError } from '../../errors/index.js';
2
+ import { pause } from '../../transport/index.js';
2
3
  /** Create one total wall-clock budget for a complete public Client Session operation. */
3
4
  export function createSessionOperation(lifecycle, input, defaultTimeoutMs) {
4
5
  const timeoutMs = input?.timeoutMs ?? defaultTimeoutMs;
@@ -56,22 +57,7 @@ export async function runSessionOperation(operation, task) {
56
57
  }
57
58
  /** Wait `ms` before another attempt, ending early with the operation's interruption. */
58
59
  export function pauseSessionOperation(operation, ms) {
59
- return runSessionOperation(operation, (signal) => delay(ms, signal));
60
- }
61
- function delay(ms, signal) {
62
- return new Promise((resolve, reject) => {
63
- if (signal.aborted)
64
- return reject(signal.reason);
65
- const timer = setTimeout(() => {
66
- signal.removeEventListener('abort', abort);
67
- resolve();
68
- }, ms);
69
- const abort = () => {
70
- clearTimeout(timer);
71
- reject(signal.reason);
72
- };
73
- signal.addEventListener('abort', abort, { once: true });
74
- });
60
+ return runSessionOperation(operation, (signal) => pause(ms, signal));
75
61
  }
76
62
  function requireSessionOperation(operation) {
77
63
  if (!operation.signal.aborted)
@@ -1,5 +1,5 @@
1
1
  import { runSessionOperation } from '../context/index.js';
2
- import { rootViewCatalog } from '../views/index.js';
2
+ import { rootViewCatalog } from '../views/legacy/index.js';
3
3
  import { BundleUnavailableError } from './bundle.js';
4
4
  import { createSessionSnapshot } from './snapshot.js';
5
5
  export class SessionDiscovery {
@@ -1,12 +1,16 @@
1
1
  import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
2
2
  import type { bundle } from '@astrale-os/kernel-dsl/v1';
3
- import type { ViewCatalog } from '../views/index.js';
3
+ import type { ViewCatalog } from '../views/legacy/index.js';
4
4
  import type { IntrinsicRelease } from './release.js';
5
5
  /** Coherent public observation acquired through one Client Session at one intrinsic release. */
6
6
  export interface SessionSnapshot {
7
7
  readonly kernel: IssuerId;
8
8
  readonly release: IntrinsicRelease;
9
9
  readonly bundle: bundle.Bundle;
10
+ /**
11
+ * @deprecated The root Domain's Views as its Release binds them, each with its Release digest.
12
+ * Read them with `ClientSession.view({ domain })`.
13
+ */
10
14
  readonly views: ViewCatalog;
11
15
  }
12
16
  export declare function createSessionSnapshot(kernel: IssuerId, release: IntrinsicRelease, artifact: bundle.Bundle, views: ViewCatalog): SessionSnapshot;
@@ -10,5 +10,6 @@ export { ClientSession, connect, type ConnectOptions } from './session.js';
10
10
  export type { CallableReference, InputOfReference, InputModeOfReference, InstanceCallableReference, OutputOfReference, } from './reference.js';
11
11
  export { reference } from './reference.js';
12
12
  export type { DeletedExecutionStatus, ExecutionApi, ExecutionFailure, ExecutionNodeStatus, ExecutionOutcome, ExecutionRef, ExecutionState, ExecutionStatus, ExecutionTarget, ExecutionWait, } from '../execution/index.js';
13
- export type { ResolvedView, ViewCatalog } from './views/index.js';
13
+ export type { View, ViewsOf } from './views/index.js';
14
+ export type { ResolvedView, ViewCatalog } from './views/legacy/index.js';
14
15
  export type { DomainBinding } from '../graph/domain/index.js';
@@ -1,9 +1,9 @@
1
- import { Key } from '@astrale-os/kernel-dsl/v1/addressing';
2
1
  import { acceptCall, Client, dispatchInternal } from '../../client/index.js';
3
2
  import { ClientError } from '../../errors/index.js';
4
3
  import { runSessionOperation, remainingSessionTime, sessionTransportOptions, allowEndpoint, } from '../context/index.js';
5
4
  import { resolveAuth } from './auth.js';
6
5
  import { selectEnvelope, selectEnvelopeTarget } from './envelope.js';
6
+ import { releaseRoutesDeclaration } from './legacy/release-route.js';
7
7
  import { isRouteCompatibilityConflict, recoveryRefresh, routingControl } from './recovery.js';
8
8
  export class SessionDispatcher {
9
9
  state;
@@ -82,7 +82,7 @@ export class SessionDispatcher {
82
82
  if (redirect.route.via.issuer !== state.source) {
83
83
  throw new ClientError('Redirect issuer differs from the session-pinned source Kernel identity.');
84
84
  }
85
- requireTargetRelease(redirect.route, state.call.target);
85
+ requireRouteForTarget(redirect.route, state.call.target);
86
86
  const learned = await runSessionOperation(operation, () => this.state.cache.learn(state.cacheKey, redirect.route, redirect.credential, state.auth.credential));
87
87
  return this.dispatchDestinationWithRecovery(learned, state, options, operation, redirect.trace, streaming);
88
88
  }
@@ -158,15 +158,18 @@ function requireLearnedRoute(learned, source, target) {
158
158
  if (learned.route.via.issuer !== source) {
159
159
  throw new ClientError('Learned route issuer differs from the session-pinned source Kernel.');
160
160
  }
161
- requireTargetRelease(learned.route, target);
161
+ requireRouteForTarget(learned.route, target);
162
162
  }
163
- function requireTargetRelease(route, target) {
163
+ /** A Target names a declaration: only a witness of that declaration routes it. */
164
+ function requireRouteForTarget(route, target) {
164
165
  if (typeof target === 'string')
165
166
  return;
166
- const actual = route.via.release;
167
- if (actual.origin !== Key.origin(target.callable)) {
168
- throw new ClientError('Resolved route does not match the Target origin.');
169
- }
167
+ const { via } = route;
168
+ const routes = 'function' in via
169
+ ? via.function.declaration === target.callable
170
+ : releaseRoutesDeclaration(via, target.callable);
171
+ if (!routes)
172
+ throw new ClientError('Resolved route does not name the Target declaration.');
170
173
  }
171
174
  /**
172
175
  * Send one call, presenting the Trace only on the attempt that carries it. A call with a body goes
@@ -1,4 +1,4 @@
1
- import type * as release from '@astrale-os/kernel-protocol/release';
1
+ import type * as placement from '@astrale-os/kernel-protocol/placement';
2
2
  import type { Client } from '../../client/index.js';
3
3
  import type { ClientTarget } from '../../pool/index.js';
4
4
  import type { SessionPolicy } from '../context/index.js';
@@ -10,6 +10,6 @@ export interface EnvelopeSelection {
10
10
  readonly client: Client;
11
11
  readonly destination: ClientTarget;
12
12
  }
13
- export declare function selectEnvelope(endpoints: release.InvocationEndpoints, preference: SessionEnvelopeTransport, websocketAvailable: boolean, pool: ClientPoolCapability, policy: Readonly<SessionPolicy>): EnvelopeSelection;
13
+ export declare function selectEnvelope(endpoints: placement.InvocationEndpoints, preference: SessionEnvelopeTransport, websocketAvailable: boolean, pool: ClientPoolCapability, policy: Readonly<SessionPolicy>): EnvelopeSelection;
14
14
  /** Resolve and admit one route endpoint without acquiring a transport Client. */
15
- export declare function selectEnvelopeTarget(endpoints: release.InvocationEndpoints, preference: SessionEnvelopeTransport, websocketAvailable: boolean, policy: Readonly<SessionPolicy>): ClientTarget;
15
+ export declare function selectEnvelopeTarget(endpoints: placement.InvocationEndpoints, preference: SessionEnvelopeTransport, websocketAvailable: boolean, policy: Readonly<SessionPolicy>): ClientTarget;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * A Kernel routes a declaration by its Release witness while published destinations verify only it
3
+ * (`invocation/legacy/release-via.ts` of the Protocol). That witness names a Release, not the
4
+ * declaration: the Session can only check that the Release is of the origin that declares the
5
+ * Target.
6
+ *
7
+ * Retirement: once no supported Kernel routes a declaration by its Release, delete this folder.
8
+ */
9
+ import type * as invocation from '@astrale-os/kernel-protocol/invocation';
10
+ import { Key } from '@astrale-os/kernel-dsl/v1/addressing';
11
+ /** @deprecated Whether `via` is the Release witness of the origin that declares `callable`. */
12
+ export declare function releaseRoutesDeclaration(via: invocation.Via, callable: Key.Callable): boolean;
@@ -0,0 +1,6 @@
1
+ import { Key } from '@astrale-os/kernel-dsl/v1/addressing';
2
+ import { isReleaseVia } from '@astrale-os/kernel-protocol/invocation';
3
+ /** @deprecated Whether `via` is the Release witness of the origin that declares `callable`. */
4
+ export function releaseRoutesDeclaration(via, callable) {
5
+ return isReleaseVia(via) && via.release.origin === Key.origin(callable);
6
+ }
@@ -1,5 +1,5 @@
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';
@@ -13,7 +13,8 @@ import type { IntrinsicRelease, SessionSnapshot } from './discovery/index.js';
13
13
  import type { SessionExchangeRequest } from './exchange/index.js';
14
14
  import type { CallableReference, InputModeOfReference, InputOfReference, OutputOfReference } from './reference.js';
15
15
  import type { SessionRequestOptions, SessionRequestOptionsWithBody } from './routing/index.js';
16
- import type { ViewCatalog } from './views/index.js';
16
+ import type { View, ViewsOf } from './views/index.js';
17
+ import type { ViewCatalog } from './views/legacy/index.js';
17
18
  import { type ClientSessionOptions } from './options.js';
18
19
  export type ConnectOptions = Omit<ClientSessionOptions, 'kernel' | 'policy'> & {
19
20
  readonly url: string;
@@ -36,7 +37,9 @@ export declare class ClientSession {
36
37
  private readonly routes;
37
38
  private readonly exchangeDependencies;
38
39
  private readonly callExchange?;
39
- private readonly admitDomainViews;
40
+ private readonly viewReader;
41
+ /** The deprecated View.resolve reads: `viewsFor`, and the Views of a Kernel that places none. */
42
+ private readonly resolvedViews;
40
43
  private closed;
41
44
  constructor(options: ClientSessionOptions);
42
45
  /** Bind one admitted DSL Domain to authenticated graph projection and Method dispatch. */
@@ -53,8 +56,24 @@ export declare class ClientSession {
53
56
  release(options?: SessionControlOptions): Promise<IntrinsicRelease>;
54
57
  snapshot(options?: SessionControlOptions): Promise<SessionSnapshot>;
55
58
  /**
56
- * Resolve the View catalog of one installed Domain. Only an exact Domain Path `/:<origin>` is
57
- * accepted; any other Path rejects with a TypeError before the call.
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.
58
77
  */
59
78
  viewsFor(domain: PathLike, options?: SessionControlOptions): Promise<ViewCatalog>;
60
79
  dispatch(call: Call, options?: SessionRequestOptions): Promise<Result>;
@@ -9,14 +9,15 @@ import { createGraph } from '../graph/index.js';
9
9
  import { createSchema } from '../schema/index.js';
10
10
  import { admitFunction } from './admission.js';
11
11
  import { createContentApi } from './content/index.js';
12
- import { admitControlOptions, allowEndpoint, createSessionOperation } from './context/index.js';
12
+ import { admitControlOptions, allowEndpoint, createSessionOperation, sessionTransportOptions, } from './context/index.js';
13
13
  import { createSessionDiscovery } from './discovery/index.js';
14
14
  import { attemptDurable, durableOptions } from './durable.js';
15
15
  import { acquireDomainCredential, admitExchangeRequest, createSessionExchange, } from './exchange/index.js';
16
16
  import { acceptSessionOptions } from './options.js';
17
17
  import { admitReference, outputModeOf } from './reference.js';
18
18
  import { admitInvocationOptions, requireResultKind, SessionDispatcher } from './routing/index.js';
19
- import { domainViewCatalog, resolveViewsFor } from './views/index.js';
19
+ import { admitView } from './views/index.js';
20
+ import { readDomainViewsOrResolved, readViewOrResolved, resolvedViewSource, } from './views/legacy/index.js';
20
21
  const DEFAULT_SESSION_POLICY = Object.freeze({ maximumRouteAgeMs: 60_000 });
21
22
  /** Caller-owned discovery and redirect-following conversation with one exact source Kernel. */
22
23
  export class ClientSession {
@@ -35,7 +36,9 @@ export class ClientSession {
35
36
  routes;
36
37
  exchangeDependencies;
37
38
  callExchange;
38
- admitDomainViews;
39
+ viewReader;
40
+ /** The deprecated View.resolve reads: `viewsFor`, and the Views of a Kernel that places none. */
41
+ resolvedViews;
39
42
  closed = false;
40
43
  constructor(options) {
41
44
  const settled = acceptSessionOptions(options);
@@ -45,7 +48,12 @@ export class ClientSession {
45
48
  this.timeoutMs = settled.timeoutMs;
46
49
  this.ownedPool = settled.ownedPool;
47
50
  this.routes = settled.routes;
48
- this.admitDomainViews = (input, domain) => domainViewCatalog(input, domain, policy);
51
+ this.viewReader = Object.freeze({
52
+ query: (ast, page, operation) => this.graph.query(ast, { ...sessionTransportOptions(operation), page }),
53
+ read: (target, operation) => this.graph.getOrThrow(target, sessionTransportOptions(operation)),
54
+ admit: (node, declaration) => admitView(node, declaration, kernel, policy),
55
+ });
56
+ this.resolvedViews = resolvedViewSource(async (call, operation) => requireResultKind('value', await this.dispatcher.dispatch(call, {}, operation)).value, policy);
49
57
  this.discovery = createSessionDiscovery({
50
58
  kernel,
51
59
  fetch,
@@ -126,13 +134,22 @@ export class ClientSession {
126
134
  snapshot(options) {
127
135
  return this.discovery.snapshot(this.operation(admitControlOptions(options)));
128
136
  }
137
+ view(input, options) {
138
+ this.requireOpen();
139
+ const operation = this.operation(admitControlOptions(options));
140
+ return isViewsOf(input)
141
+ ? readDomainViewsOrResolved(this.viewReader, this.resolvedViews.views, input.domain, operation)
142
+ : readViewOrResolved(this.viewReader, this.resolvedViews.views, input, operation);
143
+ }
129
144
  /**
130
- * Resolve the View catalog of one installed Domain. Only an exact Domain Path `/:<origin>` is
131
- * accepted; any other Path rejects with a TypeError before the call.
145
+ * @deprecated Read a Domain's Views with `view({ domain })`, or one View with `view(path)`. This
146
+ * lists them through the deprecated View.resolve, each with the Release digest that owns it, and
147
+ * never names the entrypoint. Only an exact Domain Path `/:<origin>` is accepted; any other Path
148
+ * rejects with a TypeError before the call.
132
149
  */
133
150
  viewsFor(domain, options) {
134
151
  this.requireOpen();
135
- return resolveViewsFor(async (call, operation) => requireResultKind('value', await this.dispatcher.dispatch(call, {}, operation)).value, this.admitDomainViews, domain, this.operation(admitControlOptions(options)));
152
+ return this.resolvedViews.catalog(domain, this.operation(admitControlOptions(options)));
136
153
  }
137
154
  dispatch(call, options) {
138
155
  return this.dispatchWith(call, options);
@@ -234,6 +251,13 @@ export class ClientSession {
234
251
  return createSessionOperation(this.lifecycle.signal, options, this.timeoutMs);
235
252
  }
236
253
  }
254
+ /**
255
+ * Whether `view` reads a Domain's Views: its input is then a plain `{ domain }` object, while one
256
+ * View is read by a NodeId, a Path value or string, or a DefinitionRef.
257
+ */
258
+ function isViewsOf(input) {
259
+ return typeof input === 'object' && !(input instanceof Path) && 'domain' in input;
260
+ }
237
261
  /** Open a Kernel conversation with secure defaults and automatic Domain exchange when authenticated. */
238
262
  export function connect(options) {
239
263
  if (options === null || typeof options !== 'object') {
@@ -1,2 +1,2 @@
1
- export { catalogFromKeys, domainViewCatalog, rootViewCatalog, type ResolvedView, type ViewCatalog, } from './catalog.js';
2
- export { resolveViewsFor, type ViewCatalogAdmission, type ViewInvoker } from './resolve.js';
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 { catalogFromKeys, domainViewCatalog, rootViewCatalog, } from './catalog.js';
2
- export { resolveViewsFor } from './resolve.js';
1
+ export { admitView, admitViewPlacement, declaredView } from './view.js';
2
+ export { readDomainViews, readView, } from './read.js';
@@ -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 * as resolution 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 = resolution.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 '../../errors/index.js';
4
- import { allowEndpoint } from '../context/index.js';
5
- /** Join each root Domain View to its exact release binding. */
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;
@@ -0,0 +1,83 @@
1
+ import { Path } from '@astrale-os/kernel-core/path';
2
+ import { view } from '@astrale-os/kernel-core/schema/kernel/syscalls/references';
3
+ import { acceptViewResolution, } from '@astrale-os/kernel-core/schema/kernel/syscalls/view-resolution';
4
+ import { Key as ViewKey } from '@astrale-os/kernel-dsl/v1/addressing';
5
+ import { call } from '../../../client/index.js';
6
+ import { ClientError } from '../../../errors/index.js';
7
+ import { allowEndpoint } from '../../context/index.js';
8
+ /**
9
+ * @deprecated The View.resolve reads of one Session: each Call sent by `invoke`, each answer admitted
10
+ * under the Session endpoint policy.
11
+ */
12
+ export function resolvedViewSource(invoke, policy) {
13
+ const admit = (input, domain) => domainViewCatalog(input, domain, policy);
14
+ return Object.freeze({
15
+ catalog: (domain, operation) => resolveViewsFor(invoke, admit, domain, operation),
16
+ views: resolvedViews(invoke, admit),
17
+ });
18
+ }
19
+ /**
20
+ * @deprecated Resolve the per-Domain View catalog through the canonical source Kernel call, then
21
+ * admit the Release evidence it answers with. Every View targets its owning Domain, so only an exact
22
+ * Domain Path `/:<origin>` is meaningful; any other Path is refused before the call.
23
+ */
24
+ export async function resolveViewsFor(invoke, admitCatalog, domain, operation) {
25
+ const origin = domainOrigin(domain);
26
+ const owner = Path.project(view.resolve.owner);
27
+ const resolve = Path.staticMethod(owner, view.resolve.name);
28
+ return admitCatalog(await invoke(call(resolve, { target: Path.domain(origin).raw }), operation), origin);
29
+ }
30
+ /**
31
+ * @deprecated Re-admit one Runtime-resolved Domain View catalog at the Client trust boundary. Only
32
+ * Views that the requested Domain declares for itself are kept.
33
+ */
34
+ export function domainViewCatalog(input, domain, policy) {
35
+ let resolution;
36
+ try {
37
+ resolution = acceptViewResolution(input);
38
+ }
39
+ catch (cause) {
40
+ throw new ClientError('Resolved View catalog is invalid.', { cause });
41
+ }
42
+ const views = resolution.views.filter((view) => ViewKey.origin(view.key) === domain);
43
+ for (const view of views)
44
+ allowEndpoint(view.href, policy);
45
+ return Object.freeze({ views: Object.freeze(views) });
46
+ }
47
+ /**
48
+ * @deprecated The Views View.resolve lists for one Domain, each named by its declaration and
49
+ * answered for by the issuer of the Release that binds it, its Domain's.
50
+ */
51
+ export function resolvedViews(invoke, admitCatalog) {
52
+ return async (domain, operation) => {
53
+ const { views } = await resolveViewsFor(invoke, admitCatalog, Path.domain(domain), operation);
54
+ return Object.freeze(views.map(viewOf));
55
+ };
56
+ }
57
+ /**
58
+ * One View View.resolve listed, as the graph places it. Its Release digest and revision name what
59
+ * owns the View, not where it is mounted, and a View carries neither.
60
+ */
61
+ function viewOf(resolved) {
62
+ const domain = ViewKey.origin(resolved.key);
63
+ const name = resolved.key.slice(resolved.key.indexOf(':') + 1).slice('view.'.length);
64
+ const { description } = resolved.declaration;
65
+ return Object.freeze({
66
+ path: Path.project({ origin: domain, kind: 'view', name }).raw,
67
+ domain,
68
+ ...(description === undefined ? {} : { description }),
69
+ placement: Object.freeze({
70
+ href: resolved.href,
71
+ handshake: resolved.handshake,
72
+ ...(resolved.host === undefined ? {} : { host: resolved.host }),
73
+ }),
74
+ issuer: resolved.issuer,
75
+ });
76
+ }
77
+ function domainOrigin(input) {
78
+ const { anchor, steps } = Path.from(input).ast;
79
+ if (anchor.kind !== 'domain' || steps.length !== 0) {
80
+ throw new TypeError('View catalog requires a Domain Path /:<origin>; Views never target a Node.');
81
+ }
82
+ return anchor.origin;
83
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * A Kernel released before placement keeps no placement on its View Nodes and lists a Domain's
3
+ * Views only through View.resolve. A Release binds every View its Domain declares
4
+ * (`RELEASE_VIEW_INVALID`) and projection places each binding, so a read `../read.ts` answers
5
+ * `unplaced` comes from such a Kernel: these reads answer it from that Kernel's View.resolve, so a
6
+ * Shell built on this client keeps working against a Host not yet upgraded.
7
+ */
8
+ import type { NodeTarget } from '@astrale-os/kernel-core/path';
9
+ import type { SessionOperation } from '../../context/index.js';
10
+ import type { ViewReader, ViewsOf } from '../read.js';
11
+ import type { View } from '../view.js';
12
+ import type { ResolvedViews } from './resolve.js';
13
+ /**
14
+ * @deprecated Read one View from the graph, or, when the graph declares it without a placement, as
15
+ * View.resolve lists it; a View it does not list is refused.
16
+ */
17
+ export declare function readViewOrResolved(reader: ViewReader, resolved: ResolvedViews, target: NodeTarget, operation: SessionOperation): Promise<View>;
18
+ /**
19
+ * @deprecated Read the Views one Domain declares from the graph, or, when the graph places none of
20
+ * them, as View.resolve lists them: in canonical key order, which is their Path order.
21
+ */
22
+ export declare function readDomainViewsOrResolved(reader: ViewReader, resolved: ResolvedViews, domain: ViewsOf['domain'], operation: SessionOperation): Promise<readonly View[]>;
@@ -0,0 +1,26 @@
1
+ import { ClientError } from '../../../errors/index.js';
2
+ import { readDomainViews, readView } from '../read.js';
3
+ /**
4
+ * @deprecated Read one View from the graph, or, when the graph declares it without a placement, as
5
+ * View.resolve lists it; a View it does not list is refused.
6
+ */
7
+ export async function readViewOrResolved(reader, resolved, target, operation) {
8
+ const answer = await readView(reader, target, operation);
9
+ if ('placed' in answer)
10
+ return answer.placed;
11
+ const { path, domain } = answer.unplaced;
12
+ const listed = (await resolved(domain, operation)).find((view) => view.path === path);
13
+ if (listed === undefined)
14
+ throw new ClientError('Node is not a placed View.');
15
+ return listed;
16
+ }
17
+ /**
18
+ * @deprecated Read the Views one Domain declares from the graph, or, when the graph places none of
19
+ * them, as View.resolve lists them: in canonical key order, which is their Path order.
20
+ */
21
+ export async function readDomainViewsOrResolved(reader, resolved, domain, operation) {
22
+ const answer = await readDomainViews(reader, domain, operation);
23
+ if ('placed' in answer)
24
+ return answer.placed;
25
+ return resolved(answer.unplaced, operation);
26
+ }