@astrale-os/kernel-protocol 0.5.0-beta.47 → 0.5.0-beta.49
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/invocation/index.d.ts +1 -1
- package/dist/invocation/index.js +1 -1
- package/dist/invocation/target.d.ts +2 -2
- package/dist/invocation/target.js +17 -2
- package/dist/publication/bundle-admission.js +2 -1
- package/dist/publication/requirements.js +2 -1
- package/dist/routes/compiler.js +2 -2
- package/dist/routes/decode.js +6 -12
- package/dist/routes/encode.js +8 -2
- package/dist/routes/evidence.js +1 -0
- package/package.json +3 -3
|
@@ -15,6 +15,6 @@ export { decodeResponse, type ErrorResponse, type Response, type ResponseContext
|
|
|
15
15
|
export { SCHEMA_REVISION_MISMATCH, SERVICE_CANDIDATE_INVALID, SERVICE_TRUST_REQUIRED, SERVICE_UNAVAILABLE, serviceErrorOf, type SchemaRevisionMismatchDetails, type SchemaRevisionMismatchReason, type ServiceCandidateInvalidDetails, type ServiceCandidateInvalidReason, type ServiceErrorPayload, type ServiceReason, type ServiceTrustRequiredDetails, type ServiceTrustRequiredReason, type ServiceUnavailableDetails, type ServiceUnavailableReason, } from './service-reason.js';
|
|
16
16
|
export { decodeStale, stale, type Stale } from './stale-route.js';
|
|
17
17
|
export { decodeStreamFrame, type StreamEndFrame, type StreamErrorFrame, type StreamFrame, type StreamItemFrame, type StreamStartFrame, } from './stream.js';
|
|
18
|
-
export { acceptCall, type Call } from './target.js';
|
|
18
|
+
export { Target, targetPath, acceptCall, type Call } from './target.js';
|
|
19
19
|
export { VERSION, type Version } from './version.js';
|
|
20
20
|
export * as websocket from './websocket/index.js';
|
package/dist/invocation/index.js
CHANGED
|
@@ -15,6 +15,6 @@ export { decodeResponse, } from './response.js';
|
|
|
15
15
|
export { SCHEMA_REVISION_MISMATCH, SERVICE_CANDIDATE_INVALID, SERVICE_TRUST_REQUIRED, SERVICE_UNAVAILABLE, serviceErrorOf, } from './service-reason.js';
|
|
16
16
|
export { decodeStale, stale } from './stale-route.js';
|
|
17
17
|
export { decodeStreamFrame, } from './stream.js';
|
|
18
|
-
export { acceptCall } from './target.js';
|
|
18
|
+
export { Target, targetPath, acceptCall } from './target.js';
|
|
19
19
|
export { VERSION } from './version.js';
|
|
20
20
|
export * as websocket from './websocket/index.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export type
|
|
1
|
+
import { type Call } from '@astrale-os/kernel-core/callable';
|
|
2
|
+
export { Target, targetPath, type Call } from '@astrale-os/kernel-core/callable';
|
|
3
3
|
export declare function acceptCall(input: unknown): Call;
|
|
@@ -1,11 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Target } from '@astrale-os/kernel-core/callable';
|
|
2
|
+
import { PathError } from '@astrale-os/kernel-core/path';
|
|
3
|
+
import { exactFields, invalid, nodePath, portableObject, required } from './admission.js';
|
|
4
|
+
export { Target, targetPath } from '@astrale-os/kernel-core/callable';
|
|
2
5
|
const CALL_FIELDS = new Set(['target', 'input']);
|
|
3
6
|
export function acceptCall(input) {
|
|
4
7
|
const object = portableObject(input, 'call');
|
|
5
8
|
exactFields(object, CALL_FIELDS, 'call');
|
|
6
9
|
required(object, ['target', 'input'], 'call');
|
|
7
10
|
return Object.freeze({
|
|
8
|
-
target:
|
|
11
|
+
target: acceptTarget(object.target),
|
|
9
12
|
input: object.input,
|
|
10
13
|
});
|
|
11
14
|
}
|
|
15
|
+
function acceptTarget(input) {
|
|
16
|
+
if (typeof input === 'string')
|
|
17
|
+
return nodePath(input, 'call.target');
|
|
18
|
+
try {
|
|
19
|
+
return Target(input);
|
|
20
|
+
}
|
|
21
|
+
catch (cause) {
|
|
22
|
+
if (cause instanceof TypeError || cause instanceof PathError)
|
|
23
|
+
return invalid('call.target must be a canonical NodePath or declaration Target');
|
|
24
|
+
throw cause;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Key, MethodKey } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
2
2
|
import * as dslBundle from '@astrale-os/kernel-dsl/v1/bundle';
|
|
3
|
+
import { isMethodExecutable } from '@astrale-os/kernel-dsl/v1/language';
|
|
3
4
|
import { revision } from '@astrale-os/kernel-dsl/v1/schema/revision';
|
|
4
5
|
import { acceptBundleValue, decodeBundleValue, verifyBundleBytes } from './bundle.js';
|
|
5
6
|
import { fail } from './error.js';
|
|
@@ -57,7 +58,7 @@ function addClassMethods(result, origin, definitions) {
|
|
|
57
58
|
if (declaration.kind !== 'node')
|
|
58
59
|
continue;
|
|
59
60
|
for (const [name, method] of Object.entries(declaration.methods)) {
|
|
60
|
-
if (method
|
|
61
|
+
if (!isMethodExecutable(declaration, method))
|
|
61
62
|
continue;
|
|
62
63
|
result.add(MethodKey.of({ origin, kind: 'class', name: owner }, name));
|
|
63
64
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AuthorityOperationOrder } from '@astrale-os/kernel-core/schema/authority/operation';
|
|
2
2
|
import { acceptDefinitionRef, callableAddress, Key } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
3
|
+
import { isMethodExecutable } from '@astrale-os/kernel-dsl/v1/language';
|
|
3
4
|
import { revision } from '@astrale-os/kernel-dsl/v1/schema/revision';
|
|
4
5
|
import { array, deepFreeze, exact, record, unique } from './content.js';
|
|
5
6
|
import { fail } from './error.js';
|
|
@@ -282,5 +283,5 @@ function hasCallable(dependency, callable) {
|
|
|
282
283
|
return dependency.functions[coordinate.name] !== undefined;
|
|
283
284
|
const declaration = dependency.classes[coordinate.owner.name];
|
|
284
285
|
const method = declaration?.kind === 'node' ? declaration.methods[coordinate.name] : undefined;
|
|
285
|
-
return method !== undefined && method
|
|
286
|
+
return method !== undefined && isMethodExecutable(declaration, method);
|
|
286
287
|
}
|
package/dist/routes/compiler.js
CHANGED
|
@@ -11,8 +11,8 @@ export function compile(input) {
|
|
|
11
11
|
const authored = input.routes.map((entry) => admitRouteDeclaration(entry, input.domain.origin));
|
|
12
12
|
const entries = authored.map((declaration) => {
|
|
13
13
|
const meaning = input.domain.callable(declaration.callable);
|
|
14
|
-
if (meaning === undefined) {
|
|
15
|
-
fail('NATIVE_ROUTE_BINDING_INVALID', `
|
|
14
|
+
if (meaning === undefined || (isMethod(meaning) && !meaning.executable)) {
|
|
15
|
+
fail('NATIVE_ROUTE_BINDING_INVALID', `Unavailable callable ${declaration.callable}.`);
|
|
16
16
|
}
|
|
17
17
|
const href = placePath(declaration.path, 'https://routes.invalid');
|
|
18
18
|
const route = { ...declaration, href };
|
package/dist/routes/decode.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { NodePath
|
|
2
|
-
import { callableAddress } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
1
|
+
import { NodePath } from '@astrale-os/kernel-core/path';
|
|
3
2
|
import * as portable from '@astrale-os/kernel-dsl/value';
|
|
4
3
|
import { readCredential, specificHeaderWires, withoutCredentialHeaders } from './credential.js';
|
|
5
4
|
import { fail, invalidRequest } from './error.js';
|
|
@@ -112,16 +111,11 @@ export function decode(entry, request, domain, served) {
|
|
|
112
111
|
}
|
|
113
112
|
throw cause;
|
|
114
113
|
}
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
: Path.project({
|
|
121
|
-
origin: coordinate.origin,
|
|
122
|
-
kind: 'function',
|
|
123
|
-
name: coordinate.name,
|
|
124
|
-
}).raw;
|
|
114
|
+
const target = Object.freeze({
|
|
115
|
+
callable: entry.callable,
|
|
116
|
+
revision: domain.revision,
|
|
117
|
+
...(receiver === undefined ? {} : { instance: receiver }),
|
|
118
|
+
});
|
|
125
119
|
return Object.freeze({
|
|
126
120
|
call: Object.freeze({ target, input }),
|
|
127
121
|
...(credential === undefined ? {} : { credential }),
|
package/dist/routes/encode.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { targetPath } from '@astrale-os/kernel-core/callable';
|
|
1
2
|
import { Path } from '@astrale-os/kernel-core/path';
|
|
2
3
|
import { callableAddress } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
3
4
|
import * as portable from '@astrale-os/kernel-dsl/value';
|
|
@@ -9,15 +10,20 @@ import { asObject, encodeScalar, scalar } from './scalar.js';
|
|
|
9
10
|
import { requiresReceiver } from './target.js';
|
|
10
11
|
import { authorityEnd, encodeTemplate, PLACEHOLDER } from './template.js';
|
|
11
12
|
export function encode(entry, invocation, domain) {
|
|
13
|
+
if (typeof invocation.call.target !== 'string' &&
|
|
14
|
+
invocation.call.target.revision !== undefined &&
|
|
15
|
+
invocation.call.target.revision !== domain.revision) {
|
|
16
|
+
invalidRequest('Invocation Target revision does not match the selected route Domain.');
|
|
17
|
+
}
|
|
12
18
|
const input = asObject(invocation.call.input);
|
|
13
|
-
const target = Path.from(invocation.call.target);
|
|
19
|
+
const target = Path.from(targetPath(invocation.call.target));
|
|
14
20
|
const needsReceiver = requiresReceiver(entry);
|
|
15
21
|
const coordinate = callableAddress(entry.callable);
|
|
16
22
|
const methodName = coordinate.kind === 'method' ? coordinate.name : undefined;
|
|
17
23
|
const receiver = needsReceiver ? instanceSource(target, methodName) : undefined;
|
|
18
24
|
const source = receiver?.raw;
|
|
19
25
|
const expected = needsReceiver
|
|
20
|
-
? Path.instanceMethod(receiver,
|
|
26
|
+
? Path.instanceMethod(receiver, entry.callable).raw
|
|
21
27
|
: coordinate.kind === 'method'
|
|
22
28
|
? Path.staticMethod(Path.project(coordinate.owner), methodName).raw
|
|
23
29
|
: Path.project({
|
package/dist/routes/evidence.js
CHANGED
|
@@ -16,6 +16,7 @@ export function verifyTable(table, deployed, domain) {
|
|
|
16
16
|
((entry.target.kind === 'function' && !isMethod(meaning)) ||
|
|
17
17
|
(entry.target.kind === 'method' &&
|
|
18
18
|
isMethod(meaning) &&
|
|
19
|
+
meaning.executable &&
|
|
19
20
|
entry.target.dispatch === (meaning.static ? 'static' : 'instance')));
|
|
20
21
|
if (!targetMatches || meaning.auth !== entry.auth || meaning.output.mode !== entry.output) {
|
|
21
22
|
fail('NATIVE_ROUTE_BINDING_INVALID', `Route ${entry.name} differs from Domain meaning.`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrale-os/kernel-protocol",
|
|
3
|
-
"version": "0.5.0-beta.
|
|
3
|
+
"version": "0.5.0-beta.49",
|
|
4
4
|
"description": "Portable Astrale invocation, publication, installation, routing, and issuer protocols",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -137,8 +137,8 @@
|
|
|
137
137
|
"access": "public"
|
|
138
138
|
},
|
|
139
139
|
"dependencies": {
|
|
140
|
-
"@astrale-os/kernel-core": "0.9.0-beta.
|
|
141
|
-
"@astrale-os/kernel-dsl": "0.2.0-beta.
|
|
140
|
+
"@astrale-os/kernel-core": "0.9.0-beta.45",
|
|
141
|
+
"@astrale-os/kernel-dsl": "0.2.0-beta.33",
|
|
142
142
|
"@noble/hashes": "2.3.0"
|
|
143
143
|
},
|
|
144
144
|
"devDependencies": {
|