@astrale-os/kernel-protocol 0.5.0-beta.47 → 0.5.0-beta.48

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.
@@ -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';
@@ -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 { Call } from '@astrale-os/kernel-core/callable';
2
- export type { Call } from '@astrale-os/kernel-core/callable';
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 { exactFields, nodePath, portableObject, required } from './admission.js';
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: nodePath(object.target, 'call.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
+ }
@@ -57,7 +57,7 @@ function addClassMethods(result, origin, definitions) {
57
57
  if (declaration.kind !== 'node')
58
58
  continue;
59
59
  for (const [name, method] of Object.entries(declaration.methods)) {
60
- if (method.inheritance === 'abstract')
60
+ if (method.abstract === true)
61
61
  continue;
62
62
  result.add(MethodKey.of({ origin, kind: 'class', name: owner }, name));
63
63
  }
@@ -282,5 +282,5 @@ function hasCallable(dependency, callable) {
282
282
  return dependency.functions[coordinate.name] !== undefined;
283
283
  const declaration = dependency.classes[coordinate.owner.name];
284
284
  const method = declaration?.kind === 'node' ? declaration.methods[coordinate.name] : undefined;
285
- return method !== undefined && method.inheritance !== 'abstract';
285
+ return method !== undefined && method.abstract !== true;
286
286
  }
@@ -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', `Unknown callable ${declaration.callable}.`);
14
+ if (meaning === undefined || (isMethod(meaning) && meaning.abstract)) {
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 };
@@ -1,5 +1,4 @@
1
- import { NodePath, Path } from '@astrale-os/kernel-core/path';
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 coordinate = callableAddress(entry.callable);
116
- const target = coordinate.kind === 'method'
117
- ? receiver === undefined
118
- ? Path.staticMethod(Path.project(coordinate.owner), coordinate.name).raw
119
- : Path.instanceMethod(Path.from(receiver), coordinate.name).raw
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 }),
@@ -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, methodName).raw
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({
@@ -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.abstract &&
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.47",
3
+ "version": "0.5.0-beta.48",
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.43",
141
- "@astrale-os/kernel-dsl": "0.2.0-beta.31",
140
+ "@astrale-os/kernel-core": "0.9.0-beta.44",
141
+ "@astrale-os/kernel-dsl": "0.2.0-beta.32",
142
142
  "@noble/hashes": "2.3.0"
143
143
  },
144
144
  "devDependencies": {