@astrale-os/kernel-protocol 1.0.0-beta.5 → 1.0.0-beta.6
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.
|
@@ -12,7 +12,7 @@ export { decodeRequest, type Request } from './request.js';
|
|
|
12
12
|
export { admitTrace, MAXIMUM_TRACEPARENT_BYTES, MAXIMUM_TRACESTATE_BYTES, MAXIMUM_TRACESTATE_MEMBERS, type Trace, } from './trace.js';
|
|
13
13
|
export { acceptRouting, routedDigest, routedRevision, type Refresh, type Routing, type Via, } from './routing.js';
|
|
14
14
|
export { acceptSchemaTarget, type SchemaTarget } from './schema.js';
|
|
15
|
-
export { decodeResponse, type ErrorResponse, type Response, type ResponseContext, type SuccessResponse, } from './response.js';
|
|
15
|
+
export { decodeResponse, type ErrorResponse, type ExecutionResponse, type Response, type ResponseContext, type SuccessResponse, } from './response.js';
|
|
16
16
|
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';
|
|
17
17
|
export { decodeStale, stale, type Stale } from './stale-route.js';
|
|
18
18
|
export { decodeStreamFrame, type StreamEndFrame, type StreamErrorFrame, type StreamFrame, type StreamItemFrame, type StreamStartFrame, } from './stream.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Value } from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import { type NodeId } from '@astrale-os/kernel-core/graph/node';
|
|
2
3
|
import type { ErrorPayload } from '../errors/index.js';
|
|
3
4
|
import type { RequestId } from './correlation.js';
|
|
4
5
|
import type { InvocationId } from './identity.js';
|
|
@@ -15,5 +16,9 @@ export interface SuccessResponse<Result extends Value = Value> extends ResponseC
|
|
|
15
16
|
export interface ErrorResponse extends ResponseContext {
|
|
16
17
|
readonly error: ErrorPayload;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
/** A durable call's answer: the Execution it started or recovered, never a handler result. */
|
|
20
|
+
export interface ExecutionResponse extends ResponseContext {
|
|
21
|
+
readonly execution: NodeId;
|
|
22
|
+
}
|
|
23
|
+
export type Response<Result extends Value = Value> = SuccessResponse<Result> | ErrorResponse | ExecutionResponse | RedirectResponse | Stale | Miss;
|
|
19
24
|
export declare function decodeResponse(input: unknown): Response;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
import { isNodeId } from '@astrale-os/kernel-core/graph/node';
|
|
1
2
|
import { errorPayload, exactFields, invalid, invocation, portableObject, requestId, required, } from './admission.js';
|
|
2
3
|
import { decodeMiss } from './miss.js';
|
|
3
4
|
import { decodeRedirectResponse } from './redirect.js';
|
|
4
5
|
import { decodeStale } from './stale-route.js';
|
|
5
6
|
const SUCCESS_FIELDS = new Set(['result', 'requestId', 'invocation']);
|
|
6
7
|
const ERROR_FIELDS = new Set(['error', 'requestId', 'invocation']);
|
|
8
|
+
const EXECUTION_FIELDS = new Set(['execution', 'requestId', 'invocation']);
|
|
7
9
|
export function decodeResponse(input) {
|
|
8
10
|
const object = portableObject(input, 'response');
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (hasResult) {
|
|
11
|
+
const outcomes = ['result', 'error', 'execution'].filter((field) => Object.hasOwn(object, field));
|
|
12
|
+
if (outcomes.length > 1)
|
|
13
|
+
invalid('response must contain exactly one of result, error or execution');
|
|
14
|
+
switch (outcomes[0]) {
|
|
15
|
+
case 'result':
|
|
15
16
|
exactFields(object, SUCCESS_FIELDS, 'response');
|
|
16
17
|
required(object, ['requestId', 'invocation'], 'response');
|
|
17
18
|
return Object.freeze({
|
|
@@ -19,14 +20,24 @@ export function decodeResponse(input) {
|
|
|
19
20
|
requestId: requestId(object.requestId, 'response.requestId'),
|
|
20
21
|
invocation: invocation(object.invocation, 'response.invocation'),
|
|
21
22
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
case 'error':
|
|
24
|
+
exactFields(object, ERROR_FIELDS, 'response');
|
|
25
|
+
required(object, ['requestId', 'error', 'invocation'], 'response');
|
|
26
|
+
return Object.freeze({
|
|
27
|
+
error: errorPayload(object.error, 'response.error'),
|
|
28
|
+
requestId: requestId(object.requestId, 'response.requestId'),
|
|
29
|
+
invocation: invocation(object.invocation, 'response.invocation'),
|
|
30
|
+
});
|
|
31
|
+
case 'execution':
|
|
32
|
+
exactFields(object, EXECUTION_FIELDS, 'response');
|
|
33
|
+
required(object, ['requestId', 'execution', 'invocation'], 'response');
|
|
34
|
+
if (!isNodeId(object.execution))
|
|
35
|
+
invalid('response.execution must be a NodeId');
|
|
36
|
+
return Object.freeze({
|
|
37
|
+
execution: object.execution,
|
|
38
|
+
requestId: requestId(object.requestId, 'response.requestId'),
|
|
39
|
+
invocation: invocation(object.invocation, 'response.invocation'),
|
|
40
|
+
});
|
|
30
41
|
}
|
|
31
42
|
if (object.kind === 'redirect')
|
|
32
43
|
return decodeRedirectResponse(object);
|
|
@@ -34,5 +45,5 @@ export function decodeResponse(input) {
|
|
|
34
45
|
return decodeStale(object);
|
|
35
46
|
if (object.kind === 'miss')
|
|
36
47
|
return decodeMiss(object);
|
|
37
|
-
return invalid('response must contain a result, error, redirect, stale, or miss control');
|
|
48
|
+
return invalid('response must contain a result, error, execution, redirect, stale, or miss control');
|
|
38
49
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrale-os/kernel-protocol",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.6",
|
|
4
4
|
"description": "Portable Astrale invocation, Release, installation, routing, and issuer protocols",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"access": "public"
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
|
-
"@astrale-os/kernel-core": "1.0.0-beta.
|
|
92
|
+
"@astrale-os/kernel-core": "1.0.0-beta.6",
|
|
93
93
|
"@astrale-os/kernel-dsl": "1.0.0-beta.3",
|
|
94
94
|
"@noble/hashes": "2.3.0"
|
|
95
95
|
},
|