@astrale-os/kernel-protocol 0.5.0-beta.66 → 0.5.0-beta.68
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/codecs/index.d.ts +1 -2
- package/dist/codecs/index.js +1 -2
- package/dist/codecs/media-types.d.ts +0 -1
- package/dist/codecs/media-types.js +0 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/invocation/admission.d.ts +2 -2
- package/dist/invocation/admission.js +5 -5
- package/dist/invocation/binding-codecs.d.ts +1 -1
- package/dist/invocation/binding-codecs.js +1 -6
- package/dist/invocation/http/negotiation.js +3 -10
- package/dist/invocation/index.d.ts +5 -2
- package/dist/invocation/index.js +4 -2
- package/dist/invocation/legacy/index.d.ts +29 -0
- package/dist/invocation/legacy/index.js +28 -0
- package/dist/invocation/legacy/route.d.ts +14 -0
- package/dist/invocation/legacy/route.js +25 -0
- package/dist/invocation/legacy/via.d.ts +30 -0
- package/dist/invocation/legacy/via.js +15 -0
- package/dist/invocation/redirect.d.ts +15 -12
- package/dist/invocation/redirect.js +9 -21
- package/dist/invocation/request.js +2 -2
- package/dist/invocation/routing.d.ts +19 -5
- package/dist/invocation/routing.js +50 -20
- package/dist/invocation/schema.d.ts +3 -8
- package/dist/invocation/schema.js +3 -10
- package/dist/invocation/service-reason.d.ts +13 -13
- package/dist/invocation/service-reason.js +13 -12
- package/dist/invocation/stale-route.d.ts +1 -1
- package/dist/invocation/target.d.ts +3 -0
- package/dist/invocation/target.js +8 -1
- package/dist/invocation/websocket/index.d.ts +1 -1
- package/dist/invocation/websocket/index.js +1 -1
- package/dist/invocation/websocket/subprotocol.d.ts +1 -2
- package/dist/invocation/websocket/subprotocol.js +3 -4
- package/dist/issuer/index.d.ts +1 -0
- package/dist/issuer/index.js +1 -0
- package/dist/issuer/paths.d.ts +2 -0
- package/dist/issuer/paths.js +1 -0
- package/dist/issuer/workflow-engine.d.ts +18 -0
- package/dist/issuer/workflow-engine.js +59 -0
- package/dist/{publication → release}/bindings/callable.js +6 -6
- package/dist/release/bindings/invocation.js +13 -0
- package/dist/{publication → release}/bindings/view.d.ts +1 -1
- package/dist/{publication → release}/bindings/view.js +10 -10
- package/dist/release/build.d.ts +6 -0
- package/dist/release/build.js +7 -0
- package/dist/release/bundle-admission.d.ts +21 -0
- package/dist/{publication → release}/bundle-admission.js +18 -18
- package/dist/{publication → release}/bundle-descriptor.js +6 -6
- package/dist/release/bundle-evidence.d.ts +3 -0
- package/dist/release/bundle-evidence.js +13 -0
- package/dist/{publication → release}/bundle.d.ts +2 -2
- package/dist/{publication → release}/bundle.js +9 -9
- package/dist/{publication → release}/delivery/attestation.d.ts +1 -0
- package/dist/release/delivery/claims.d.ts +21 -0
- package/dist/release/delivery/claims.js +68 -0
- package/dist/release/delivery/delivery.d.ts +11 -0
- package/dist/release/delivery/delivery.js +24 -0
- package/dist/{publication → release}/delivery/error.d.ts +2 -0
- package/dist/{publication → release}/delivery/error.js +1 -0
- package/dist/{publication → release}/delivery/index.d.ts +6 -1
- package/dist/{publication → release}/delivery/index.js +5 -0
- package/dist/{publication → release}/delivery/limits.d.ts +2 -1
- package/dist/release/delivery/limits.js +5 -0
- package/dist/release/delivery/request.d.ts +21 -0
- package/dist/release/delivery/request.js +60 -0
- package/dist/{publication → release}/delivery-declaration.js +4 -4
- package/dist/release/delivery-endpoint.js +22 -0
- package/dist/release/digest.d.ts +13 -0
- package/dist/{publication/etag.js → release/digest.js} +1 -10
- package/dist/release/error.d.ts +7 -0
- package/dist/release/error.js +11 -0
- package/dist/release/index.d.ts +21 -0
- package/dist/release/index.js +14 -0
- package/dist/release/issuer.d.ts +5 -0
- package/dist/release/issuer.js +34 -0
- package/dist/release/legacy/bindings.d.ts +14 -0
- package/dist/release/legacy/bindings.js +11 -0
- package/dist/release/legacy/bundle-admission.d.ts +6 -0
- package/dist/release/legacy/bundle-admission.js +10 -0
- package/dist/release/legacy/bundle-evidence.d.ts +8 -0
- package/dist/release/legacy/bundle-evidence.js +11 -0
- package/dist/release/legacy/bundle.d.ts +24 -0
- package/dist/release/legacy/bundle.js +31 -0
- package/dist/release/legacy/delivery/attestation.d.ts +6 -0
- package/dist/release/legacy/delivery/attestation.js +1 -0
- package/dist/{publication → release/legacy}/delivery/claims.d.ts +9 -0
- package/dist/{publication → release/legacy}/delivery/claims.js +7 -2
- package/dist/release/legacy/delivery/delivery.d.ts +18 -0
- package/dist/{publication → release/legacy}/delivery/delivery.js +6 -2
- package/dist/release/legacy/delivery/error.d.ts +16 -0
- package/dist/release/legacy/delivery/error.js +6 -0
- package/dist/release/legacy/delivery/index.d.ts +13 -0
- package/dist/release/legacy/delivery/index.js +13 -0
- package/dist/release/legacy/delivery/limits.d.ts +21 -0
- package/dist/release/legacy/delivery/limits.js +22 -0
- package/dist/release/legacy/delivery/request.d.ts +26 -0
- package/dist/{publication → release/legacy}/delivery/request.js +8 -3
- package/dist/release/legacy/delivery-declaration.d.ts +9 -0
- package/dist/release/legacy/delivery-declaration.js +11 -0
- package/dist/release/legacy/error.d.ts +26 -0
- package/dist/release/legacy/error.js +114 -0
- package/dist/release/legacy/etag.d.ts +12 -0
- package/dist/release/legacy/etag.js +14 -0
- package/dist/release/legacy/index.d.ts +72 -0
- package/dist/{publication → release/legacy}/index.js +7 -2
- package/dist/release/legacy/profiles.d.ts +23 -0
- package/dist/release/legacy/profiles.js +36 -0
- package/dist/release/legacy/projection.d.ts +13 -0
- package/dist/release/legacy/projection.js +25 -0
- package/dist/release/legacy/publication.d.ts +90 -0
- package/dist/release/legacy/publication.js +124 -0
- package/dist/release/legacy/reference.d.ts +47 -0
- package/dist/{publication → release/legacy}/reference.js +27 -3
- package/dist/release/legacy/requirements.d.ts +30 -0
- package/dist/release/legacy/requirements.js +20 -0
- package/dist/{publication → release}/manifest.js +6 -6
- package/dist/release/reference.d.ts +26 -0
- package/dist/release/reference.js +70 -0
- package/dist/release/release.d.ts +60 -0
- package/dist/release/release.js +123 -0
- package/dist/{publication → release}/requirements.d.ts +11 -4
- package/dist/{publication → release}/requirements.js +58 -39
- package/dist/{publication → release}/route.js +24 -24
- package/dist/{publication → release}/schema.js +4 -4
- package/dist/release/served.d.ts +26 -0
- package/dist/release/served.js +65 -0
- package/dist/release/shape.d.ts +8 -0
- package/dist/routes/admission.d.ts +1 -1
- package/dist/routes/admission.js +7 -85
- package/dist/routes/binding.d.ts +3 -3
- package/dist/routes/binding.js +10 -19
- package/dist/routes/compiler.d.ts +2 -2
- package/dist/routes/compiler.js +3 -2
- package/dist/routes/credential.d.ts +1 -1
- package/dist/routes/decode.d.ts +5 -2
- package/dist/routes/decode.js +15 -4
- package/dist/routes/deployment-retired.d.ts +30 -0
- package/dist/routes/deployment-retired.js +96 -0
- package/dist/routes/encode.js +7 -6
- package/dist/routes/entries.d.ts +23 -0
- package/dist/routes/entries.js +150 -0
- package/dist/routes/evidence.d.ts +3 -3
- package/dist/routes/evidence.js +7 -34
- package/dist/routes/header.d.ts +9 -0
- package/dist/routes/header.js +34 -0
- package/dist/routes/index.d.ts +5 -2
- package/dist/routes/index.js +5 -2
- package/dist/routes/legacy/index.d.ts +29 -0
- package/dist/routes/legacy/index.js +29 -0
- package/dist/routes/legacy/routing.d.ts +24 -0
- package/dist/routes/legacy/routing.js +45 -0
- package/dist/routes/legacy/table.d.ts +34 -0
- package/dist/routes/legacy/table.js +50 -0
- package/dist/routes/mapping.d.ts +1 -1
- package/dist/routes/mapping.js +4 -4
- package/dist/routes/match.d.ts +1 -1
- package/dist/routes/placement.d.ts +2 -2
- package/dist/routes/plan.d.ts +1 -1
- package/dist/routes/request.d.ts +3 -3
- package/dist/routes/reservation.d.ts +4 -2
- package/dist/routes/reservation.js +4 -3
- package/dist/routes/routing.d.ts +30 -6
- package/dist/routes/routing.js +34 -49
- package/dist/routes/select.d.ts +1 -1
- package/dist/routes/table.d.ts +3 -2
- package/dist/routes/target.d.ts +5 -0
- package/dist/routes/target.js +16 -0
- package/dist/runtime/artifact.d.ts +2 -2
- package/dist/runtime/artifact.js +2 -2
- package/dist/schema/installation/codec.d.ts +6 -1
- package/dist/schema/installation/codec.js +10 -7
- package/dist/schema/installation/introspection/codec.d.ts +11 -2
- package/dist/schema/installation/introspection/codec.js +59 -41
- package/dist/schema/installation/introspection/result.d.ts +8 -1
- package/dist/schema/installation/legacy/index.d.ts +39 -0
- package/dist/schema/installation/legacy/index.js +39 -0
- package/dist/schema/installation/legacy/installation.d.ts +9 -0
- package/dist/schema/installation/legacy/installation.js +28 -0
- package/dist/schema/installation/legacy/introspection.d.ts +10 -0
- package/dist/schema/installation/legacy/introspection.js +70 -0
- package/dist/schema/installation/legacy/msgpack.d.ts +1 -0
- package/dist/schema/installation/legacy/msgpack.js +143 -0
- package/package.json +59 -36
- package/dist/codecs/msgpack.d.ts +0 -4
- package/dist/codecs/msgpack.js +0 -53
- package/dist/publication/bindings/invocation.js +0 -13
- package/dist/publication/bundle-admission.d.ts +0 -4
- package/dist/publication/bundle-evidence.d.ts +0 -3
- package/dist/publication/bundle-evidence.js +0 -13
- package/dist/publication/content.d.ts +0 -10
- package/dist/publication/delivery/delivery.d.ts +0 -9
- package/dist/publication/delivery/limits.js +0 -4
- package/dist/publication/delivery/request.d.ts +0 -15
- package/dist/publication/delivery-endpoint.js +0 -22
- package/dist/publication/error.d.ts +0 -7
- package/dist/publication/error.js +0 -11
- package/dist/publication/etag.d.ts +0 -6
- package/dist/publication/index.d.ts +0 -17
- package/dist/publication/legacy-requirements.d.ts +0 -12
- package/dist/publication/legacy-requirements.js +0 -23
- package/dist/publication/publication.d.ts +0 -38
- package/dist/publication/publication.js +0 -146
- package/dist/publication/reference.d.ts +0 -17
- package/dist/routes/release-unavailable.d.ts +0 -8
- package/dist/routes/release-unavailable.js +0 -32
- /package/dist/{publication → release}/bindings/callable.d.ts +0 -0
- /package/dist/{publication → release}/bindings/index.d.ts +0 -0
- /package/dist/{publication → release}/bindings/index.js +0 -0
- /package/dist/{publication → release}/bindings/invocation.d.ts +0 -0
- /package/dist/{publication → release}/bundle-descriptor.d.ts +0 -0
- /package/dist/{publication → release}/declaration.d.ts +0 -0
- /package/dist/{publication → release}/declaration.js +0 -0
- /package/dist/{publication → release}/delivery/attestation.js +0 -0
- /package/dist/{publication → release}/delivery-declaration.d.ts +0 -0
- /package/dist/{publication → release}/delivery-endpoint.d.ts +0 -0
- /package/dist/{publication → release}/manifest.d.ts +0 -0
- /package/dist/{publication → release}/route.d.ts +0 -0
- /package/dist/{publication → release}/schema.d.ts +0 -0
- /package/dist/{publication/content.js → release/shape.js} +0 -0
package/dist/codecs/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { DecodeError, type Codec, type EncodedEnvelope } from './codec.js';
|
|
2
2
|
export { json } from './json.js';
|
|
3
|
-
export { CONTENT_TYPE_JSON
|
|
4
|
-
export { loadMsgpack } from './msgpack.js';
|
|
3
|
+
export { CONTENT_TYPE_JSON } from './media-types.js';
|
package/dist/codecs/index.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ export * as artifact from './artifact/index.js';
|
|
|
2
2
|
export * as invocation from './invocation/index.js';
|
|
3
3
|
export * as codecs from './codecs/index.js';
|
|
4
4
|
export * as errors from './errors/index.js';
|
|
5
|
-
|
|
5
|
+
/** @deprecated Use `release`; Publication v2/v3 remains available under `release.legacy`. */
|
|
6
|
+
export * as publication from './release/legacy/index.js';
|
|
7
|
+
export * as release from './release/index.js';
|
|
6
8
|
export * as schema from './schema/index.js';
|
|
7
9
|
export * as routes from './routes/index.js';
|
|
8
10
|
export * as issuer from './issuer/index.js';
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,9 @@ export * as artifact from './artifact/index.js';
|
|
|
2
2
|
export * as invocation from './invocation/index.js';
|
|
3
3
|
export * as codecs from './codecs/index.js';
|
|
4
4
|
export * as errors from './errors/index.js';
|
|
5
|
-
|
|
5
|
+
/** @deprecated Use `release`; Publication v2/v3 remains available under `release.legacy`. */
|
|
6
|
+
export * as publication from './release/legacy/index.js';
|
|
7
|
+
export * as release from './release/index.js';
|
|
6
8
|
export * as schema from './schema/index.js';
|
|
7
9
|
export * as routes from './routes/index.js';
|
|
8
10
|
export * as issuer from './issuer/index.js';
|
|
@@ -3,7 +3,7 @@ import { NodePath } from '@astrale-os/kernel-core/path';
|
|
|
3
3
|
import { Key } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
4
4
|
import { type Object as ValueObject } from '@astrale-os/kernel-dsl/value';
|
|
5
5
|
import type { ErrorPayload } from '../errors/index.js';
|
|
6
|
-
import type {
|
|
6
|
+
import type { Sha256Digest } from '../release/digest.js';
|
|
7
7
|
import { type RequestId } from './correlation.js';
|
|
8
8
|
import { type InvocationId } from './identity.js';
|
|
9
9
|
export declare function portableObject(input: unknown, label: string): ValueObject;
|
|
@@ -16,7 +16,7 @@ export declare function nodePath(input: unknown, label: string): NodePath;
|
|
|
16
16
|
export declare function issuerId(input: unknown, label: string): IssuerId;
|
|
17
17
|
export declare function string(input: unknown, label: string): string;
|
|
18
18
|
export declare function count(input: unknown, label: string): number;
|
|
19
|
-
export declare function digest(input: unknown, label: string):
|
|
19
|
+
export declare function digest(input: unknown, label: string): Sha256Digest;
|
|
20
20
|
export declare function callableKey(input: unknown, label: string): Key.Callable;
|
|
21
21
|
export declare function errorPayload(input: unknown, label: string): ErrorPayload;
|
|
22
22
|
export declare function acceptHeaders(input: unknown): Readonly<Record<string, string>>;
|
|
@@ -2,14 +2,14 @@ import { AuthValueError } from '@astrale-os/kernel-core/auth/error';
|
|
|
2
2
|
import { accept as acceptIssuer } from '@astrale-os/kernel-core/auth/issuer';
|
|
3
3
|
import { NodePath, PathError } from '@astrale-os/kernel-core/path';
|
|
4
4
|
import { callableAddress, Key } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
5
|
-
import {
|
|
5
|
+
import { acceptForRead, BoundaryError, } from '@astrale-os/kernel-dsl/value';
|
|
6
6
|
import { CODES, acceptPayload, ProtocolError } from '../errors/index.js';
|
|
7
7
|
import { acceptRequestId } from './correlation.js';
|
|
8
8
|
import { acceptInvocationId, InvocationError } from './identity.js';
|
|
9
9
|
export function portableObject(input, label) {
|
|
10
|
-
let
|
|
10
|
+
let snapshot;
|
|
11
11
|
try {
|
|
12
|
-
|
|
12
|
+
snapshot = acceptForRead(input);
|
|
13
13
|
}
|
|
14
14
|
catch (cause) {
|
|
15
15
|
if (cause instanceof BoundaryError) {
|
|
@@ -17,9 +17,9 @@ export function portableObject(input, label) {
|
|
|
17
17
|
}
|
|
18
18
|
throw cause;
|
|
19
19
|
}
|
|
20
|
-
if (!isValueObject(
|
|
20
|
+
if (!isValueObject(snapshot))
|
|
21
21
|
invalid(`${label} must be an object`);
|
|
22
|
-
return
|
|
22
|
+
return snapshot;
|
|
23
23
|
}
|
|
24
24
|
export function exactDataObject(input, label) {
|
|
25
25
|
if (input === null || typeof input !== 'object' || Array.isArray(input)) {
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { json } from '../codecs/json.js';
|
|
2
|
-
import { isMsgpackCodec } from '../codecs/msgpack.js';
|
|
3
2
|
export function codecProfile(codec) {
|
|
4
|
-
|
|
5
|
-
return 'json';
|
|
6
|
-
if (isMsgpackCodec(codec))
|
|
7
|
-
return 'msgpack';
|
|
8
|
-
return undefined;
|
|
3
|
+
return codec === json ? 'json' : undefined;
|
|
9
4
|
}
|
|
10
5
|
export function admitSupportedCodecs(supported) {
|
|
11
6
|
if (!Array.isArray(supported))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CONTENT_TYPE_JSON
|
|
1
|
+
import { CONTENT_TYPE_JSON } from '../../codecs/index.js';
|
|
2
2
|
import { admitSupportedCodecs } from '../binding-codecs.js';
|
|
3
3
|
const TOKEN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/u;
|
|
4
4
|
const QVALUE = /^(?:0(?:\.\d{0,3})?|1(?:\.0{0,3})?)$/u;
|
|
@@ -9,11 +9,7 @@ export function codecForContentType(contentType, supported) {
|
|
|
9
9
|
const mediaType = parseContentType(contentType);
|
|
10
10
|
if (mediaType === undefined)
|
|
11
11
|
return undefined;
|
|
12
|
-
const profile = mediaType === CONTENT_TYPE_JSON
|
|
13
|
-
? 'json'
|
|
14
|
-
: mediaType === CONTENT_TYPE_MSGPACK
|
|
15
|
-
? 'msgpack'
|
|
16
|
-
: undefined;
|
|
12
|
+
const profile = mediaType === CONTENT_TYPE_JSON ? 'json' : undefined;
|
|
17
13
|
return admitted.find((entry) => entry.profile === profile)?.codec;
|
|
18
14
|
}
|
|
19
15
|
export function negotiateResponseCodec(accept, requestCodec, supported) {
|
|
@@ -27,7 +23,7 @@ export function negotiateResponseCodec(accept, requestCodec, supported) {
|
|
|
27
23
|
if (ranges.length === 0)
|
|
28
24
|
return undefined;
|
|
29
25
|
const candidates = admitted.flatMap((entry) => {
|
|
30
|
-
const [type, subtype] =
|
|
26
|
+
const [type, subtype] = CONTENT_TYPE_JSON.split('/');
|
|
31
27
|
const governing = ranges
|
|
32
28
|
.filter((range) => range.mediaParameters === 0 &&
|
|
33
29
|
(range.type === '*' || range.type === type) &&
|
|
@@ -56,9 +52,6 @@ export function negotiateResponseCodec(accept, requestCodec, supported) {
|
|
|
56
52
|
});
|
|
57
53
|
return candidates[0]?.codec;
|
|
58
54
|
}
|
|
59
|
-
function contentTypeOf(profile) {
|
|
60
|
-
return profile === 'json' ? CONTENT_TYPE_JSON : CONTENT_TYPE_MSGPACK;
|
|
61
|
-
}
|
|
62
55
|
function parseContentType(input) {
|
|
63
56
|
if (splitOutsideQuotes(input, ',')?.length !== 1)
|
|
64
57
|
return undefined;
|
|
@@ -5,14 +5,17 @@ export { acceptIdempotencyKey, HTTP_IDEMPOTENCY_KEY, MAXIMUM_IDEMPOTENCY_KEY_LEN
|
|
|
5
5
|
export { acceptInvocationId, InvocationError, MAXIMUM_INVOCATION_ID_LENGTH, sameInvocationId, type InvocationId, } from './identity.js';
|
|
6
6
|
export * as http from './http/index.js';
|
|
7
7
|
export { acceptDelegate, type Delegate } from './delegate.js';
|
|
8
|
+
export type { PublicationBindingInput, PublicationVia } from './legacy/index.js';
|
|
9
|
+
/** @deprecated The legacy routed witness every Kernel emits until the breaking release (AM-1). */
|
|
10
|
+
export * as legacy from './legacy/index.js';
|
|
8
11
|
export { decodeMiss, miss, type Miss } from './miss.js';
|
|
9
12
|
export { acceptRoute, acceptRedirection, decodeRedirectResponse, remoteRoute, type RemoteBindingInput, type Redirection, type RedirectResponse, type Route, } from './redirect.js';
|
|
10
13
|
export { decodeRequest, type Request } from './request.js';
|
|
11
14
|
export { admitTrace, MAXIMUM_TRACEPARENT_BYTES, MAXIMUM_TRACESTATE_BYTES, MAXIMUM_TRACESTATE_MEMBERS, type Trace, } from './trace.js';
|
|
12
|
-
export { acceptRouting, type Refresh, type Routing, type Via } from './routing.js';
|
|
15
|
+
export { acceptRouting, routedDigest, routedRevision, type Refresh, type Routing, type Via, } from './routing.js';
|
|
13
16
|
export { acceptSchemaTarget, type SchemaTarget } from './schema.js';
|
|
14
17
|
export { decodeResponse, type ErrorResponse, type Response, type ResponseContext, type SuccessResponse, } from './response.js';
|
|
15
|
-
export { CALLABLE_FINGERPRINT_MISMATCH,
|
|
18
|
+
export { CALLABLE_FINGERPRINT_MISMATCH, DEPLOYMENT_RETIRED, SERVICE_CANDIDATE_INVALID, SERVICE_TRUST_REQUIRED, SERVICE_UNAVAILABLE, serviceErrorOf, type CallableFingerprintMismatchDetails, type CallableFingerprintMismatchReason, type DeploymentRetiredDetails, type DeploymentRetiredReason, type ServiceCandidateInvalidDetails, type ServiceCandidateInvalidReason, type ServiceErrorPayload, type ServiceReason, type ServiceTrustRequiredDetails, type ServiceTrustRequiredReason, type ServiceUnavailableDetails, type ServiceUnavailableReason, } from './service-reason.js';
|
|
16
19
|
export { decodeStale, stale, type Stale } from './stale-route.js';
|
|
17
20
|
export { decodeStreamFrame, type StreamEndFrame, type StreamErrorFrame, type StreamFrame, type StreamItemFrame, type StreamStartFrame, } from './stream.js';
|
|
18
21
|
export { Target, targetPath, acceptCall, type Call } from './target.js';
|
package/dist/invocation/index.js
CHANGED
|
@@ -5,14 +5,16 @@ export { acceptIdempotencyKey, HTTP_IDEMPOTENCY_KEY, MAXIMUM_IDEMPOTENCY_KEY_LEN
|
|
|
5
5
|
export { acceptInvocationId, InvocationError, MAXIMUM_INVOCATION_ID_LENGTH, sameInvocationId, } from './identity.js';
|
|
6
6
|
export * as http from './http/index.js';
|
|
7
7
|
export { acceptDelegate } from './delegate.js';
|
|
8
|
+
/** @deprecated The legacy routed witness every Kernel emits until the breaking release (AM-1). */
|
|
9
|
+
export * as legacy from './legacy/index.js';
|
|
8
10
|
export { decodeMiss, miss } from './miss.js';
|
|
9
11
|
export { acceptRoute, acceptRedirection, decodeRedirectResponse, remoteRoute, } from './redirect.js';
|
|
10
12
|
export { decodeRequest } from './request.js';
|
|
11
13
|
export { admitTrace, MAXIMUM_TRACEPARENT_BYTES, MAXIMUM_TRACESTATE_BYTES, MAXIMUM_TRACESTATE_MEMBERS, } from './trace.js';
|
|
12
|
-
export { acceptRouting } from './routing.js';
|
|
14
|
+
export { acceptRouting, routedDigest, routedRevision, } from './routing.js';
|
|
13
15
|
export { acceptSchemaTarget } from './schema.js';
|
|
14
16
|
export { decodeResponse, } from './response.js';
|
|
15
|
-
export { CALLABLE_FINGERPRINT_MISMATCH,
|
|
17
|
+
export { CALLABLE_FINGERPRINT_MISMATCH, DEPLOYMENT_RETIRED, SERVICE_CANDIDATE_INVALID, SERVICE_TRUST_REQUIRED, SERVICE_UNAVAILABLE, serviceErrorOf, } from './service-reason.js';
|
|
16
18
|
export { decodeStale, stale } from './stale-route.js';
|
|
17
19
|
export { decodeStreamFrame, } from './stream.js';
|
|
18
20
|
export { Target, targetPath, acceptCall } from './target.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Publication-based routing, retained for v2/v3 pins and frozen v3 projections of v4 pins.
|
|
3
|
+
* The Kernel emits this shape while decoders also accept release-based `Via`.
|
|
4
|
+
* Superseded by `Via` and `remoteRoute` from `@astrale-os/kernel-protocol/invocation`.
|
|
5
|
+
*
|
|
6
|
+
* Short-term consumers:
|
|
7
|
+
* - the Runtime redirect (`runtime/functions/runtime.ts`), the Kernel's only emitter until the
|
|
8
|
+
* breaking release (AM-1, CT5-E), because every client and View built before K5 decodes only
|
|
9
|
+
* this shape: the pinned document's own reference for a v2/v3 pin, the frozen v3 projection's
|
|
10
|
+
* for a v4 pin. The breaking release switches v4 pins to `remoteRoute`; v2/v3 pins keep this;
|
|
11
|
+
* - servers built from a v2/v3 Publication, which admit only this shape (the SDK's `requireVia`,
|
|
12
|
+
* the Server's `HandlerRequest.via`).
|
|
13
|
+
*
|
|
14
|
+
* Removal, in a separate breaking release: the conditions of `protocol/release/legacy/index.ts`
|
|
15
|
+
* hold (no installation pins a v2/v3 document) and every supported client relays `Via`. Then
|
|
16
|
+
* delete, in the same PR:
|
|
17
|
+
* - this folder, the `legacy` namespace of `invocation/index.ts` and its `PublicationVia` and
|
|
18
|
+
* `PublicationBindingInput` type exports;
|
|
19
|
+
* - the `publication` branch of `acceptVia` and of `routedRevision`/`routedDigest` in `routing.ts`;
|
|
20
|
+
* - the `PublicationVia` member of `Routing` (`routing.ts`) and of `Route.via` (`redirect.ts`);
|
|
21
|
+
* - the `PublicationVia` member of `routes.Invocation.routing` (`routes/request.ts`) and of the
|
|
22
|
+
* Server's `HandlerRequest.via` (`server/invocation/types.ts`), with the refusal of a release
|
|
23
|
+
* `Via` at a Publication-backed destination (law SV-PUBLICATION-ADMITS-LEGACY-VIA);
|
|
24
|
+
* - the legacy vectors of TEST-VIA-NAMES-EXACTLY-ONE-REFERENCE, and the Runtime redirect's last
|
|
25
|
+
* `legacy.remoteRoute` call with its dispatch test;
|
|
26
|
+
* - `PublicationVia` and `Route.via` from law PROTOCOL-LEGACY-WIRE-FIELDS and its test.
|
|
27
|
+
*/
|
|
28
|
+
export { remoteRoute } from './route.js';
|
|
29
|
+
export type { PublicationBindingInput, PublicationVia } from './via.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Publication-based routing, retained for v2/v3 pins and frozen v3 projections of v4 pins.
|
|
3
|
+
* The Kernel emits this shape while decoders also accept release-based `Via`.
|
|
4
|
+
* Superseded by `Via` and `remoteRoute` from `@astrale-os/kernel-protocol/invocation`.
|
|
5
|
+
*
|
|
6
|
+
* Short-term consumers:
|
|
7
|
+
* - the Runtime redirect (`runtime/functions/runtime.ts`), the Kernel's only emitter until the
|
|
8
|
+
* breaking release (AM-1, CT5-E), because every client and View built before K5 decodes only
|
|
9
|
+
* this shape: the pinned document's own reference for a v2/v3 pin, the frozen v3 projection's
|
|
10
|
+
* for a v4 pin. The breaking release switches v4 pins to `remoteRoute`; v2/v3 pins keep this;
|
|
11
|
+
* - servers built from a v2/v3 Publication, which admit only this shape (the SDK's `requireVia`,
|
|
12
|
+
* the Server's `HandlerRequest.via`).
|
|
13
|
+
*
|
|
14
|
+
* Removal, in a separate breaking release: the conditions of `protocol/release/legacy/index.ts`
|
|
15
|
+
* hold (no installation pins a v2/v3 document) and every supported client relays `Via`. Then
|
|
16
|
+
* delete, in the same PR:
|
|
17
|
+
* - this folder, the `legacy` namespace of `invocation/index.ts` and its `PublicationVia` and
|
|
18
|
+
* `PublicationBindingInput` type exports;
|
|
19
|
+
* - the `publication` branch of `acceptVia` and of `routedRevision`/`routedDigest` in `routing.ts`;
|
|
20
|
+
* - the `PublicationVia` member of `Routing` (`routing.ts`) and of `Route.via` (`redirect.ts`);
|
|
21
|
+
* - the `PublicationVia` member of `routes.Invocation.routing` (`routes/request.ts`) and of the
|
|
22
|
+
* Server's `HandlerRequest.via` (`server/invocation/types.ts`), with the refusal of a release
|
|
23
|
+
* `Via` at a Publication-backed destination (law SV-PUBLICATION-ADMITS-LEGACY-VIA);
|
|
24
|
+
* - the legacy vectors of TEST-VIA-NAMES-EXACTLY-ONE-REFERENCE, and the Runtime redirect's last
|
|
25
|
+
* `legacy.remoteRoute` call with its dispatch test;
|
|
26
|
+
* - `PublicationVia` and `Route.via` from law PROTOCOL-LEGACY-WIRE-FIELDS and its test.
|
|
27
|
+
*/
|
|
28
|
+
export { remoteRoute } from './route.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
2
|
+
import type { Key } from '@astrale-os/kernel-dsl/v1';
|
|
3
|
+
import type { Route } from '../redirect.js';
|
|
4
|
+
import type { PublicationBindingInput } from './via.js';
|
|
5
|
+
/**
|
|
6
|
+
* Project one remote binding into the route every Kernel emits until the breaking release (AM-1):
|
|
7
|
+
* a `PublicationVia` naming the v3 reference, the pinned document's own for a legacy pin and the
|
|
8
|
+
* frozen projection's for a v4 pin. It reads only the binding's Publication coordinates, so a
|
|
9
|
+
* binding that also carries a release digest still projects to its v3 reference.
|
|
10
|
+
*
|
|
11
|
+
* @deprecated Successor: `remoteRoute`, which projects a release binding to `Via`; the breaking
|
|
12
|
+
* release calls it instead.
|
|
13
|
+
*/
|
|
14
|
+
export declare function remoteRoute(origin: Key.Origin, binding: PublicationBindingInput, issuer: IssuerId): Route;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { acceptRoute } from '../redirect.js';
|
|
2
|
+
/**
|
|
3
|
+
* Project one remote binding into the route every Kernel emits until the breaking release (AM-1):
|
|
4
|
+
* a `PublicationVia` naming the v3 reference, the pinned document's own for a legacy pin and the
|
|
5
|
+
* frozen projection's for a v4 pin. It reads only the binding's Publication coordinates, so a
|
|
6
|
+
* binding that also carries a release digest still projects to its v3 reference.
|
|
7
|
+
*
|
|
8
|
+
* @deprecated Successor: `remoteRoute`, which projects a release binding to `Via`; the breaking
|
|
9
|
+
* release calls it instead.
|
|
10
|
+
*/
|
|
11
|
+
export function remoteRoute(origin, binding, issuer) {
|
|
12
|
+
return acceptRoute({
|
|
13
|
+
endpoint: binding.endpoint,
|
|
14
|
+
via: {
|
|
15
|
+
kind: 'via',
|
|
16
|
+
publication: {
|
|
17
|
+
origin,
|
|
18
|
+
identity: { issuer: binding.issuer, subject: binding.subject },
|
|
19
|
+
revision: binding.revision,
|
|
20
|
+
etag: binding.etag,
|
|
21
|
+
},
|
|
22
|
+
issuer,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
2
|
+
import type { InvocationEndpoints } from '../../release/bindings/invocation.js';
|
|
3
|
+
import type { Etag } from '../../release/legacy/etag.js';
|
|
4
|
+
import type { PublicationRef } from '../../release/legacy/reference.js';
|
|
5
|
+
/**
|
|
6
|
+
* Routed witness of a legacy pin, or of the v3 projection of a v4 pin: the reference keeps its
|
|
7
|
+
* Publication meaning (origin, identity, schema revision, Publication ETag).
|
|
8
|
+
*
|
|
9
|
+
* @deprecated Successor: `Via.release`, emitted by the breaking release (AM-1).
|
|
10
|
+
*/
|
|
11
|
+
export interface PublicationVia {
|
|
12
|
+
readonly kind: 'via';
|
|
13
|
+
readonly publication: PublicationRef;
|
|
14
|
+
readonly issuer: IssuerId;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Remote binding of a legacy pin, or of a v4 pin projected to its v3 Publication: the endpoint
|
|
18
|
+
* and the Publication reference coordinates the Kernel routes it with.
|
|
19
|
+
*
|
|
20
|
+
* @deprecated Successor: `RemoteBindingInput`, which carries the release digest.
|
|
21
|
+
*/
|
|
22
|
+
export interface PublicationBindingInput {
|
|
23
|
+
readonly endpoint: InvocationEndpoints;
|
|
24
|
+
readonly issuer: IssuerId;
|
|
25
|
+
readonly subject: string;
|
|
26
|
+
readonly revision: PublicationRef['revision'];
|
|
27
|
+
readonly etag: Etag;
|
|
28
|
+
}
|
|
29
|
+
/** Admit the Publication reference of one received `PublicationVia`. */
|
|
30
|
+
export declare function acceptPublicationReference(input: unknown, label: string): PublicationRef;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PublicationError } from '../../release/legacy/error.js';
|
|
2
|
+
import { acceptReference } from '../../release/legacy/reference.js';
|
|
3
|
+
import { invalid } from '../admission.js';
|
|
4
|
+
/** Admit the Publication reference of one received `PublicationVia`. */
|
|
5
|
+
export function acceptPublicationReference(input, label) {
|
|
6
|
+
try {
|
|
7
|
+
return acceptReference(input);
|
|
8
|
+
}
|
|
9
|
+
catch (cause) {
|
|
10
|
+
if (cause instanceof PublicationError) {
|
|
11
|
+
return invalid(`${label} is invalid: ${cause.message}`);
|
|
12
|
+
}
|
|
13
|
+
throw cause;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
2
|
-
import type { Key } from '@astrale-os/kernel-dsl/v1';
|
|
3
|
-
import type { InvocationEndpoints } from '../
|
|
4
|
-
import type {
|
|
5
|
-
import type { PublicationRef } from '../publication/reference.js';
|
|
2
|
+
import type { Key, Revision } from '@astrale-os/kernel-dsl/v1';
|
|
3
|
+
import type { InvocationEndpoints } from '../release/bindings/invocation.js';
|
|
4
|
+
import type { ReleaseDigest } from '../release/digest.js';
|
|
6
5
|
import type { RequestId } from './correlation.js';
|
|
7
6
|
import type { InvocationId } from './identity.js';
|
|
7
|
+
import type { PublicationVia } from './legacy/via.js';
|
|
8
|
+
import type { Via } from './routing.js';
|
|
8
9
|
import type { Trace } from './trace.js';
|
|
9
10
|
export interface Route {
|
|
10
11
|
readonly endpoint: InvocationEndpoints;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Routed witness of the installed release. Its `PublicationVia` shape is deprecated (legacy
|
|
14
|
+
* pins and the v3 projection of v4 pins); successor: `Via`, emitted by the breaking release
|
|
15
|
+
* (AM-1).
|
|
16
|
+
*/
|
|
17
|
+
readonly via: Via | PublicationVia;
|
|
16
18
|
}
|
|
17
19
|
export interface Redirection {
|
|
18
20
|
readonly route: Route;
|
|
@@ -26,15 +28,16 @@ export interface RedirectResponse {
|
|
|
26
28
|
readonly invocation: InvocationId;
|
|
27
29
|
readonly redirect: Redirection;
|
|
28
30
|
}
|
|
31
|
+
/** Remote binding of one installed release: the endpoint and the release it routes to. */
|
|
29
32
|
export interface RemoteBindingInput {
|
|
30
33
|
readonly endpoint: InvocationEndpoints;
|
|
31
34
|
readonly issuer: IssuerId;
|
|
32
35
|
readonly subject: string;
|
|
33
|
-
readonly revision:
|
|
34
|
-
readonly
|
|
36
|
+
readonly revision: Revision;
|
|
37
|
+
readonly release: ReleaseDigest;
|
|
35
38
|
}
|
|
36
39
|
export declare function acceptRoute(input: unknown): Route;
|
|
37
|
-
/** Project
|
|
40
|
+
/** Project an installed release binding into a release `Via`; legacy emitters use `legacy.remoteRoute`. */
|
|
38
41
|
export declare function remoteRoute(origin: Key.Origin, binding: RemoteBindingInput, issuer: IssuerId): Route;
|
|
39
42
|
export declare function acceptRedirection(input: unknown): Redirection;
|
|
40
43
|
export declare function decodeRedirectResponse(input: unknown): RedirectResponse;
|
|
@@ -1,30 +1,18 @@
|
|
|
1
|
-
import { acceptInvocationEndpoints } from '../
|
|
2
|
-
import { PublicationError } from '../
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { acceptInvocationEndpoints } from '../release/legacy/bindings.js';
|
|
2
|
+
import { PublicationError } from '../release/legacy/error.js';
|
|
3
|
+
import { exactFields, invalid, invocation, portableObject, requestId, required, string, } from './admission.js';
|
|
4
|
+
import { acceptVia } from './routing.js';
|
|
5
5
|
import { admitTrace } from './trace.js';
|
|
6
6
|
const ROUTE_FIELDS = new Set(['endpoint', 'via']);
|
|
7
|
-
const VIA_FIELDS = new Set(['kind', 'publication', 'issuer']);
|
|
8
7
|
const REDIRECTION_FIELDS = new Set(['route', 'credential', 'trace']);
|
|
9
8
|
const REDIRECT_RESPONSE_FIELDS = new Set(['kind', 'requestId', 'invocation', 'redirect']);
|
|
10
9
|
export function acceptRoute(input) {
|
|
11
10
|
const object = portableObject(input, 'route');
|
|
12
11
|
exactFields(object, ROUTE_FIELDS, 'route');
|
|
13
12
|
required(object, ['endpoint', 'via'], 'route');
|
|
13
|
+
const via = acceptVia(portableObject(object.via, 'route.via'), 'route.via');
|
|
14
14
|
try {
|
|
15
|
-
|
|
16
|
-
exactFields(via, VIA_FIELDS, 'route.via');
|
|
17
|
-
required(via, ['kind', 'publication', 'issuer'], 'route.via');
|
|
18
|
-
if (via.kind !== 'via')
|
|
19
|
-
invalid('route.via.kind must be "via"');
|
|
20
|
-
return Object.freeze({
|
|
21
|
-
endpoint: acceptInvocationEndpoints(object.endpoint),
|
|
22
|
-
via: Object.freeze({
|
|
23
|
-
kind: 'via',
|
|
24
|
-
publication: acceptReference(via.publication),
|
|
25
|
-
issuer: issuerId(via.issuer, 'route.via.issuer'),
|
|
26
|
-
}),
|
|
27
|
-
});
|
|
15
|
+
return Object.freeze({ endpoint: acceptInvocationEndpoints(object.endpoint), via });
|
|
28
16
|
}
|
|
29
17
|
catch (cause) {
|
|
30
18
|
if (cause instanceof PublicationError) {
|
|
@@ -33,17 +21,17 @@ export function acceptRoute(input) {
|
|
|
33
21
|
throw cause;
|
|
34
22
|
}
|
|
35
23
|
}
|
|
36
|
-
/** Project
|
|
24
|
+
/** Project an installed release binding into a release `Via`; legacy emitters use `legacy.remoteRoute`. */
|
|
37
25
|
export function remoteRoute(origin, binding, issuer) {
|
|
38
26
|
return acceptRoute({
|
|
39
27
|
endpoint: binding.endpoint,
|
|
40
28
|
via: {
|
|
41
29
|
kind: 'via',
|
|
42
|
-
|
|
30
|
+
release: {
|
|
43
31
|
origin,
|
|
44
32
|
identity: { issuer: binding.issuer, subject: binding.subject },
|
|
45
33
|
revision: binding.revision,
|
|
46
|
-
|
|
34
|
+
digest: binding.release,
|
|
47
35
|
},
|
|
48
36
|
issuer,
|
|
49
37
|
},
|
|
@@ -3,7 +3,7 @@ import { acceptDelegate } from './delegate.js';
|
|
|
3
3
|
import { acceptIdempotencyKey } from './idempotency.js';
|
|
4
4
|
import { acceptRouting } from './routing.js';
|
|
5
5
|
import { acceptSchemaTarget } from './schema.js';
|
|
6
|
-
import {
|
|
6
|
+
import { callFromSnapshot } from './target.js';
|
|
7
7
|
import { admitTrace } from './trace.js';
|
|
8
8
|
const REQUEST_FIELDS = new Set([
|
|
9
9
|
'version',
|
|
@@ -39,7 +39,7 @@ export function decodeRequest(input) {
|
|
|
39
39
|
return Object.freeze({
|
|
40
40
|
version: 2,
|
|
41
41
|
requestId: requestId(object.requestId, 'request.requestId'),
|
|
42
|
-
call:
|
|
42
|
+
call: callFromSnapshot(object.call),
|
|
43
43
|
...(credential === undefined ? {} : { credential }),
|
|
44
44
|
...(delegate === undefined ? {} : { delegate }),
|
|
45
45
|
...(routing === undefined ? {} : { routing }),
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { Revision } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
3
|
+
import type { Object as ValueObject } from '@astrale-os/kernel-dsl/value';
|
|
4
|
+
import type { Sha256Digest } from '../release/digest.js';
|
|
5
|
+
import type { ReleaseRef } from '../release/reference.js';
|
|
6
|
+
import type { PublicationVia } from './legacy/via.js';
|
|
7
|
+
/** Routed witness of one installed release: the Kernel routed this call to that exact release. */
|
|
4
8
|
export interface Via {
|
|
5
9
|
readonly kind: 'via';
|
|
6
|
-
readonly
|
|
10
|
+
readonly release: ReleaseRef;
|
|
7
11
|
readonly issuer: IssuerId;
|
|
8
12
|
}
|
|
9
13
|
export interface Refresh {
|
|
10
14
|
readonly kind: 'refresh';
|
|
11
|
-
readonly stale:
|
|
15
|
+
readonly stale: Sha256Digest;
|
|
12
16
|
}
|
|
13
|
-
|
|
17
|
+
/** A received `Via` names exactly one of a `ReleaseRef` or a legacy `PublicationRef`. */
|
|
18
|
+
export type Routing = Via | PublicationVia | Refresh;
|
|
14
19
|
export declare function acceptRouting(input: unknown): Routing;
|
|
20
|
+
/** Admit one routed witness carrying exactly one of `release` or legacy `publication`. */
|
|
21
|
+
export declare function acceptVia(object: ValueObject, label: string): Via | PublicationVia;
|
|
22
|
+
/** Schema revision of the release or Publication the witness routed the call to. */
|
|
23
|
+
export declare function routedRevision(via: Via | PublicationVia): Revision;
|
|
24
|
+
/**
|
|
25
|
+
* Digest designating what the witness routed the call to: the release digest of a `Via`, the
|
|
26
|
+
* Publication ETag of a legacy `PublicationVia`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function routedDigest(via: Via | PublicationVia): Sha256Digest;
|
|
@@ -1,27 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { acceptReference } from '../
|
|
1
|
+
import { ReleaseError } from '../release/error.js';
|
|
2
|
+
import { acceptReference } from '../release/reference.js';
|
|
3
3
|
import { digest, exactFields, invalid, issuerId, portableObject, required } from './admission.js';
|
|
4
|
-
|
|
4
|
+
import { acceptPublicationReference } from './legacy/via.js';
|
|
5
|
+
const VIA_FIELDS = new Set(['kind', 'release', 'publication', 'issuer']);
|
|
5
6
|
const REFRESH_FIELDS = new Set(['kind', 'stale']);
|
|
6
7
|
export function acceptRouting(input) {
|
|
7
8
|
const object = portableObject(input, 'routing');
|
|
8
|
-
if (object.kind === 'via')
|
|
9
|
-
|
|
10
|
-
required(object, ['kind', 'publication', 'issuer'], 'via routing');
|
|
11
|
-
try {
|
|
12
|
-
return Object.freeze({
|
|
13
|
-
kind: 'via',
|
|
14
|
-
publication: acceptReference(object.publication),
|
|
15
|
-
issuer: issuerId(object.issuer, 'via routing.issuer'),
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
catch (cause) {
|
|
19
|
-
if (cause instanceof PublicationError) {
|
|
20
|
-
return invalid(`via routing.publication is invalid: ${cause.message}`);
|
|
21
|
-
}
|
|
22
|
-
throw cause;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
9
|
+
if (object.kind === 'via')
|
|
10
|
+
return acceptVia(object, 'via routing');
|
|
25
11
|
if (object.kind === 'refresh') {
|
|
26
12
|
exactFields(object, REFRESH_FIELDS, 'refresh routing');
|
|
27
13
|
required(object, ['kind', 'stale'], 'refresh routing');
|
|
@@ -32,3 +18,47 @@ export function acceptRouting(input) {
|
|
|
32
18
|
}
|
|
33
19
|
return invalid('routing.kind must be "via" or "refresh"');
|
|
34
20
|
}
|
|
21
|
+
/** Admit one routed witness carrying exactly one of `release` or legacy `publication`. */
|
|
22
|
+
export function acceptVia(object, label) {
|
|
23
|
+
exactFields(object, VIA_FIELDS, label);
|
|
24
|
+
if (object.kind !== 'via')
|
|
25
|
+
invalid(`${label}.kind must be "via"`);
|
|
26
|
+
const hasRelease = Object.hasOwn(object, 'release');
|
|
27
|
+
if (hasRelease === Object.hasOwn(object, 'publication')) {
|
|
28
|
+
invalid(`${label} must contain exactly one of release or publication`);
|
|
29
|
+
}
|
|
30
|
+
required(object, ['issuer'], label);
|
|
31
|
+
if (!hasRelease) {
|
|
32
|
+
return Object.freeze({
|
|
33
|
+
kind: 'via',
|
|
34
|
+
publication: acceptPublicationReference(object.publication, `${label}.publication`),
|
|
35
|
+
issuer: issuerId(object.issuer, `${label}.issuer`),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return Object.freeze({
|
|
39
|
+
kind: 'via',
|
|
40
|
+
release: acceptReleaseReference(object.release, `${label}.release`),
|
|
41
|
+
issuer: issuerId(object.issuer, `${label}.issuer`),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/** Schema revision of the release or Publication the witness routed the call to. */
|
|
45
|
+
export function routedRevision(via) {
|
|
46
|
+
return 'release' in via ? via.release.revision : via.publication.revision;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Digest designating what the witness routed the call to: the release digest of a `Via`, the
|
|
50
|
+
* Publication ETag of a legacy `PublicationVia`.
|
|
51
|
+
*/
|
|
52
|
+
export function routedDigest(via) {
|
|
53
|
+
return 'release' in via ? via.release.digest : via.publication.etag;
|
|
54
|
+
}
|
|
55
|
+
function acceptReleaseReference(input, label) {
|
|
56
|
+
try {
|
|
57
|
+
return acceptReference(input);
|
|
58
|
+
}
|
|
59
|
+
catch (cause) {
|
|
60
|
+
if (cause instanceof ReleaseError)
|
|
61
|
+
return invalid(`${label} is invalid: ${cause.message}`);
|
|
62
|
+
throw cause;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Sha256Digest } from '../publication/index.js';
|
|
1
|
+
import type { Sha256Digest } from '../release/digest.js';
|
|
3
2
|
/**
|
|
4
|
-
* Source-Kernel precondition for one invocation: the exact installed artifact target, the
|
|
5
|
-
*
|
|
3
|
+
* Source-Kernel precondition for one invocation: the exact installed artifact target, or the
|
|
4
|
+
* fingerprint of the callable meaning the static consumer compiled against.
|
|
6
5
|
*/
|
|
7
6
|
export type SchemaTarget = {
|
|
8
7
|
readonly target: Sha256Digest;
|
|
9
|
-
}
|
|
10
|
-
/** @deprecated Pin the callable meaning with `fingerprint`; revision pinning will be removed. */
|
|
11
|
-
| {
|
|
12
|
-
readonly revision: Revision;
|
|
13
8
|
} | {
|
|
14
9
|
readonly fingerprint: Sha256Digest;
|
|
15
10
|
};
|