@astrale-os/kernel-client 0.6.0-beta.86 → 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/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/bound.d.ts +1 -1
- package/dist/session/bound.js +2 -1
- 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/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 -178
- 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 +6 -50
- package/dist/session/session.js +28 -134
- package/dist/session/session.typecheck.js +8 -3
- package/dist/session/views/catalog.d.ts +5 -9
- package/dist/session/views/catalog.js +12 -24
- package/dist/session/views/resolve.d.ts +1 -1
- package/dist/session/views/resolve.js +1 -1
- 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 -299
- 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,33 +0,0 @@
|
|
|
1
|
-
import type { release } from '@astrale-os/kernel-protocol';
|
|
2
|
-
import type { SessionOperation } from '../../context/index.js';
|
|
3
|
-
import type { IntrinsicRelease } from '../release.js';
|
|
4
|
-
import type { PublicationDiscovery } from './publication.js';
|
|
5
|
-
/** Reprobe absent `release.json` after this interval so Host upgrades become visible. */
|
|
6
|
-
export declare const RELEASE_ABSENCE_MAXIMUM_AGE_MS = 60000;
|
|
7
|
-
export interface ReleaseReader {
|
|
8
|
-
current(): release.DomainRelease | undefined;
|
|
9
|
-
revalidate(operation: SessionOperation): Promise<release.DomainRelease | undefined>;
|
|
10
|
-
invalidate(): void;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* The intrinsic release of a Host whichever document it serves. `release.json` is read first; the
|
|
14
|
-
* version 3 Publication at `domain.json` is read in its place only when that URL answers its exact
|
|
15
|
-
* 404, or, while no `DomainRelease` has been admitted since construction, the last `invalidate()`
|
|
16
|
-
* or the last 404, when its Fetch fails before any response, which is how a browser reports a
|
|
17
|
-
* cross-origin 404 without CORS headers. Once a release is admitted, a failed Fetch is the release
|
|
18
|
-
* acquisition failure it is. An observed absence is trusted for `RELEASE_ABSENCE_MAXIMUM_AGE_MS`.
|
|
19
|
-
*
|
|
20
|
-
* @deprecated Successor: `ReleaseDiscovery` alone, once no supported Host predates intrinsic
|
|
21
|
-
* `release.json`. Deleted with this folder (see `index.ts`).
|
|
22
|
-
*/
|
|
23
|
-
export declare class IntrinsicReleaseDiscovery {
|
|
24
|
-
private readonly releases;
|
|
25
|
-
private readonly publications;
|
|
26
|
-
private absentUntil;
|
|
27
|
-
private revision;
|
|
28
|
-
constructor(releases: ReleaseReader, publications: PublicationDiscovery);
|
|
29
|
-
revalidate(operation: SessionOperation): Promise<IntrinsicRelease>;
|
|
30
|
-
invalidate(): void;
|
|
31
|
-
}
|
|
32
|
-
/** The digest designating one intrinsic release: its release digest, or a pre-v4 ETag. */
|
|
33
|
-
export declare function designation(input: IntrinsicRelease): string;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { TransportError } from '../../../errors/index.js';
|
|
2
|
-
/** Reprobe absent `release.json` after this interval so Host upgrades become visible. */
|
|
3
|
-
export const RELEASE_ABSENCE_MAXIMUM_AGE_MS = 60_000;
|
|
4
|
-
/**
|
|
5
|
-
* The intrinsic release of a Host whichever document it serves. `release.json` is read first; the
|
|
6
|
-
* version 3 Publication at `domain.json` is read in its place only when that URL answers its exact
|
|
7
|
-
* 404, or, while no `DomainRelease` has been admitted since construction, the last `invalidate()`
|
|
8
|
-
* or the last 404, when its Fetch fails before any response, which is how a browser reports a
|
|
9
|
-
* cross-origin 404 without CORS headers. Once a release is admitted, a failed Fetch is the release
|
|
10
|
-
* acquisition failure it is. An observed absence is trusted for `RELEASE_ABSENCE_MAXIMUM_AGE_MS`.
|
|
11
|
-
*
|
|
12
|
-
* @deprecated Successor: `ReleaseDiscovery` alone, once no supported Host predates intrinsic
|
|
13
|
-
* `release.json`. Deleted with this folder (see `index.ts`).
|
|
14
|
-
*/
|
|
15
|
-
export class IntrinsicReleaseDiscovery {
|
|
16
|
-
releases;
|
|
17
|
-
publications;
|
|
18
|
-
absentUntil;
|
|
19
|
-
revision = 0;
|
|
20
|
-
constructor(releases, publications) {
|
|
21
|
-
this.releases = releases;
|
|
22
|
-
this.publications = publications;
|
|
23
|
-
}
|
|
24
|
-
async revalidate(operation) {
|
|
25
|
-
const revision = this.revision;
|
|
26
|
-
if (this.absentUntil === undefined || Date.now() >= this.absentUntil) {
|
|
27
|
-
const admitted = this.releases.current() !== undefined;
|
|
28
|
-
let served;
|
|
29
|
-
try {
|
|
30
|
-
served = await this.releases.revalidate(operation);
|
|
31
|
-
}
|
|
32
|
-
catch (cause) {
|
|
33
|
-
if (admitted || !isUnreadableAbsence(cause))
|
|
34
|
-
throw cause;
|
|
35
|
-
served = undefined;
|
|
36
|
-
}
|
|
37
|
-
if (revision !== this.revision)
|
|
38
|
-
return this.revalidate(operation);
|
|
39
|
-
this.absentUntil = undefined;
|
|
40
|
-
if (served !== undefined)
|
|
41
|
-
return served;
|
|
42
|
-
}
|
|
43
|
-
const legacy = await this.publications.revalidate(operation);
|
|
44
|
-
if (revision !== this.revision)
|
|
45
|
-
return this.revalidate(operation);
|
|
46
|
-
this.absentUntil ??= Date.now() + RELEASE_ABSENCE_MAXIMUM_AGE_MS;
|
|
47
|
-
return legacy;
|
|
48
|
-
}
|
|
49
|
-
invalidate() {
|
|
50
|
-
this.revision += 1;
|
|
51
|
-
this.absentUntil = undefined;
|
|
52
|
-
this.releases.invalidate();
|
|
53
|
-
this.publications.invalidate();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/** The digest designating one intrinsic release: its release digest, or a pre-v4 ETag. */
|
|
57
|
-
export function designation(input) {
|
|
58
|
-
return input.version === 4 ? input.digest : input.etag;
|
|
59
|
-
}
|
|
60
|
-
/** A `release.json` request that failed with the Fetch-standard network error, before any response. */
|
|
61
|
-
function isUnreadableAbsence(cause) {
|
|
62
|
-
return (cause instanceof TransportError &&
|
|
63
|
-
cause.phase === 'unknown' &&
|
|
64
|
-
cause.context.kind === 'acquisition' &&
|
|
65
|
-
cause.context.resource === 'release' &&
|
|
66
|
-
cause.cause instanceof TypeError);
|
|
67
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { publication } from '@astrale-os/kernel-protocol';
|
|
2
|
-
import type { IntrinsicRelease } from '../release.js';
|
|
3
|
-
/**
|
|
4
|
-
* Retain one Publication object per admitted release; bundle and View provenance use its ETag.
|
|
5
|
-
*
|
|
6
|
-
* @deprecated Use `IntrinsicRelease`.
|
|
7
|
-
*/
|
|
8
|
-
export declare function publicationOf(input: IntrinsicRelease): publication.Publication;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as releaseLegacy from '@astrale-os/kernel-protocol/release/legacy';
|
|
2
|
-
const projections = new WeakMap();
|
|
3
|
-
/**
|
|
4
|
-
* Retain one Publication object per admitted release; bundle and View provenance use its ETag.
|
|
5
|
-
*
|
|
6
|
-
* @deprecated Use `IntrinsicRelease`.
|
|
7
|
-
*/
|
|
8
|
-
export function publicationOf(input) {
|
|
9
|
-
if (input.version !== 4)
|
|
10
|
-
return input;
|
|
11
|
-
const retained = projections.get(input);
|
|
12
|
-
if (retained !== undefined)
|
|
13
|
-
return retained;
|
|
14
|
-
const projected = releaseLegacy.publication(input);
|
|
15
|
-
projections.set(input, projected);
|
|
16
|
-
return projected;
|
|
17
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
2
|
-
import type { publication } from '@astrale-os/kernel-protocol';
|
|
3
|
-
import type { Fetch } from '../../../transport/http/index.js';
|
|
4
|
-
import type { SessionOperation } from '../../context/index.js';
|
|
5
|
-
import { type SessionPolicy } from '../../context/index.js';
|
|
6
|
-
export interface PublicationDiscoveryOptions {
|
|
7
|
-
readonly kernel: IssuerId;
|
|
8
|
-
readonly fetch: Fetch;
|
|
9
|
-
readonly policy: Readonly<SessionPolicy>;
|
|
10
|
-
readonly maximumBytes: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Conditionally revalidate `domain.json` by ETag when intrinsic release discovery is unavailable.
|
|
14
|
-
*
|
|
15
|
-
* @deprecated Use `ReleaseDiscovery`.
|
|
16
|
-
*/
|
|
17
|
-
export declare class PublicationDiscovery {
|
|
18
|
-
private readonly options;
|
|
19
|
-
private publication;
|
|
20
|
-
private revision;
|
|
21
|
-
constructor(options: PublicationDiscoveryOptions);
|
|
22
|
-
current(): publication.Publication | undefined;
|
|
23
|
-
revalidate(operation: SessionOperation): Promise<publication.Publication>;
|
|
24
|
-
invalidate(): void;
|
|
25
|
-
private fetch;
|
|
26
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
2
|
-
import * as publicationCodec from '@astrale-os/kernel-protocol/publication/publication';
|
|
3
|
-
import { ClientError } from '../../../errors/index.js';
|
|
4
|
-
import { allowEndpoint } from '../../context/index.js';
|
|
5
|
-
import { boundedResponse, requireExactResponse } from '../response.js';
|
|
6
|
-
import { runAcquisition } from '../transport.js';
|
|
7
|
-
/**
|
|
8
|
-
* Conditionally revalidate `domain.json` by ETag when intrinsic release discovery is unavailable.
|
|
9
|
-
*
|
|
10
|
-
* @deprecated Use `ReleaseDiscovery`.
|
|
11
|
-
*/
|
|
12
|
-
export class PublicationDiscovery {
|
|
13
|
-
options;
|
|
14
|
-
publication;
|
|
15
|
-
revision = 0;
|
|
16
|
-
constructor(options) {
|
|
17
|
-
this.options = options;
|
|
18
|
-
}
|
|
19
|
-
current() {
|
|
20
|
-
return this.publication;
|
|
21
|
-
}
|
|
22
|
-
async revalidate(operation) {
|
|
23
|
-
const revision = this.revision;
|
|
24
|
-
const previous = this.publication;
|
|
25
|
-
const discovered = await this.fetch(operation, previous);
|
|
26
|
-
if (revision !== this.revision)
|
|
27
|
-
return this.revalidate(operation);
|
|
28
|
-
const retained = previous?.etag === discovered.etag ? previous : discovered;
|
|
29
|
-
this.publication = retained;
|
|
30
|
-
return retained;
|
|
31
|
-
}
|
|
32
|
-
invalidate() {
|
|
33
|
-
this.revision += 1;
|
|
34
|
-
this.publication = undefined;
|
|
35
|
-
}
|
|
36
|
-
async fetch(operation, previous) {
|
|
37
|
-
const url = publicationCodec.url(this.options.kernel);
|
|
38
|
-
allowEndpoint(url, this.options.policy);
|
|
39
|
-
const response = await runAcquisition(operation, 'publication', 'unknown', 'Kernel Publication could not be retrieved.', (signal) => this.options.fetch(url, {
|
|
40
|
-
headers: {
|
|
41
|
-
accept: 'application/json',
|
|
42
|
-
...(previous === undefined ? {} : { 'if-none-match': `"${previous.etag}"` }),
|
|
43
|
-
},
|
|
44
|
-
redirect: 'manual',
|
|
45
|
-
signal,
|
|
46
|
-
}));
|
|
47
|
-
requireExactResponse(response, url, 'Publication discovery');
|
|
48
|
-
if (response.status === 304) {
|
|
49
|
-
if (previous === undefined) {
|
|
50
|
-
throw new ClientError('Publication discovery returned an unexpected not-modified response.');
|
|
51
|
-
}
|
|
52
|
-
const etag = response.headers.get('etag');
|
|
53
|
-
if (etag !== null && etag !== `"${previous.etag}"`) {
|
|
54
|
-
throw new ClientError('Publication not-modified ETag differs from the cached snapshot.');
|
|
55
|
-
}
|
|
56
|
-
return previous;
|
|
57
|
-
}
|
|
58
|
-
if (!response.ok) {
|
|
59
|
-
throw new ClientError(`Publication discovery returned HTTP ${response.status}.`);
|
|
60
|
-
}
|
|
61
|
-
const body = await runAcquisition(operation, 'publication', 'receive', 'Kernel Publication response could not be read.', (signal) => boundedResponse(response, this.options.maximumBytes, signal));
|
|
62
|
-
const admitted = publicationCodec.accept(codecs.json.decode(body));
|
|
63
|
-
// Version 2 is only a retained Kernel-side format; a live Kernel serves version 3.
|
|
64
|
-
if (admitted.version !== 3) {
|
|
65
|
-
throw new ClientError('Kernel Publication version 2 is no longer supported; the Kernel must serve Publication version 3.');
|
|
66
|
-
}
|
|
67
|
-
if (admitted.identity.issuer !== this.options.kernel) {
|
|
68
|
-
throw new ClientError('Publication issuer differs from the requested Kernel issuer.');
|
|
69
|
-
}
|
|
70
|
-
const etag = response.headers.get('etag');
|
|
71
|
-
if (etag !== null && etag !== `"${admitted.etag}"`) {
|
|
72
|
-
throw new ClientError('Publication response ETag differs from its canonical content.');
|
|
73
|
-
}
|
|
74
|
-
return admitted;
|
|
75
|
-
}
|
|
76
|
-
}
|