@astrale-os/sdk 0.1.1 → 0.1.3
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/authenticate.d.ts +24 -0
- package/dist/auth/authenticate.d.ts.map +1 -0
- package/dist/auth/authenticate.js +29 -0
- package/dist/auth/authenticate.js.map +1 -0
- package/dist/auth/check.d.ts +39 -0
- package/dist/auth/check.d.ts.map +1 -0
- package/dist/auth/check.js +54 -0
- package/dist/auth/check.js.map +1 -0
- package/dist/auth/compose.d.ts +41 -0
- package/dist/auth/compose.d.ts.map +1 -0
- package/dist/auth/compose.js +45 -0
- package/dist/auth/compose.js.map +1 -0
- package/dist/auth/errors.d.ts +16 -0
- package/dist/auth/errors.d.ts.map +1 -0
- package/dist/auth/errors.js +26 -0
- package/dist/auth/errors.js.map +1 -0
- package/dist/auth/identity.d.ts +16 -0
- package/dist/auth/identity.d.ts.map +1 -0
- package/dist/auth/identity.js +2 -0
- package/dist/auth/identity.js.map +1 -0
- package/dist/auth/index.d.ts +12 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +9 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/kernel-client.d.ts +43 -0
- package/dist/auth/kernel-client.d.ts.map +1 -0
- package/dist/auth/kernel-client.js +146 -0
- package/dist/auth/kernel-client.js.map +1 -0
- package/dist/auth/resolve.d.ts +19 -0
- package/dist/auth/resolve.d.ts.map +1 -0
- package/dist/auth/resolve.js +43 -0
- package/dist/auth/resolve.js.map +1 -0
- package/dist/auth/sign.d.ts +15 -0
- package/dist/auth/sign.d.ts.map +1 -0
- package/dist/auth/sign.js +24 -0
- package/dist/auth/sign.js.map +1 -0
- package/dist/auth/verify.d.ts +26 -0
- package/dist/auth/verify.d.ts.map +1 -0
- package/dist/auth/verify.js +96 -0
- package/dist/auth/verify.js.map +1 -0
- package/dist/define/index.d.ts +5 -0
- package/dist/define/index.d.ts.map +1 -0
- package/dist/define/index.js +3 -0
- package/dist/define/index.js.map +1 -0
- package/dist/define/remote-function.d.ts +96 -0
- package/dist/define/remote-function.d.ts.map +1 -0
- package/dist/define/remote-function.js +25 -0
- package/dist/define/remote-function.js.map +1 -0
- package/dist/define/view.d.ts +86 -0
- package/dist/define/view.d.ts.map +1 -0
- package/dist/define/view.js +28 -0
- package/dist/define/view.js.map +1 -0
- package/dist/deploy/check.d.ts +30 -0
- package/dist/deploy/check.d.ts.map +1 -0
- package/dist/deploy/check.js +82 -0
- package/dist/deploy/check.js.map +1 -0
- package/dist/deploy/hash-spec.d.ts +9 -0
- package/dist/deploy/hash-spec.d.ts.map +1 -0
- package/dist/deploy/hash-spec.js +29 -0
- package/dist/deploy/hash-spec.js.map +1 -0
- package/dist/deploy/index.d.ts +4 -0
- package/dist/deploy/index.d.ts.map +1 -0
- package/dist/deploy/index.js +4 -0
- package/dist/deploy/index.js.map +1 -0
- package/dist/deploy/meta.d.ts +18 -0
- package/dist/deploy/meta.d.ts.map +1 -0
- package/dist/deploy/meta.js +22 -0
- package/dist/deploy/meta.js.map +1 -0
- package/dist/dispatch/authorize.d.ts +14 -0
- package/dist/dispatch/authorize.d.ts.map +1 -0
- package/dist/dispatch/authorize.js +24 -0
- package/dist/dispatch/authorize.js.map +1 -0
- package/dist/dispatch/call-remote.d.ts +35 -0
- package/dist/dispatch/call-remote.d.ts.map +1 -0
- package/dist/dispatch/call-remote.js +37 -0
- package/dist/dispatch/call-remote.js.map +1 -0
- package/dist/dispatch/dispatcher.d.ts +60 -0
- package/dist/dispatch/dispatcher.d.ts.map +1 -0
- package/dist/dispatch/dispatcher.js +177 -0
- package/dist/dispatch/dispatcher.js.map +1 -0
- package/dist/dispatch/errors.d.ts +47 -0
- package/dist/dispatch/errors.d.ts.map +1 -0
- package/dist/dispatch/errors.js +76 -0
- package/dist/dispatch/errors.js.map +1 -0
- package/dist/dispatch/execute.d.ts +33 -0
- package/dist/dispatch/execute.d.ts.map +1 -0
- package/dist/dispatch/execute.js +24 -0
- package/dist/dispatch/execute.js.map +1 -0
- package/dist/dispatch/identity.d.ts +73 -0
- package/dist/dispatch/identity.d.ts.map +1 -0
- package/dist/dispatch/identity.js +106 -0
- package/dist/dispatch/identity.js.map +1 -0
- package/dist/dispatch/index.d.ts +8 -0
- package/dist/dispatch/index.d.ts.map +1 -0
- package/dist/dispatch/index.js +8 -0
- package/dist/dispatch/index.js.map +1 -0
- package/dist/dispatch/resolve.d.ts +27 -0
- package/dist/dispatch/resolve.d.ts.map +1 -0
- package/dist/dispatch/resolve.js +65 -0
- package/dist/dispatch/resolve.js.map +1 -0
- package/dist/dispatch/self.d.ts +27 -0
- package/dist/dispatch/self.d.ts.map +1 -0
- package/dist/dispatch/self.js +25 -0
- package/dist/dispatch/self.js.map +1 -0
- package/dist/dispatch/validate.d.ts +35 -0
- package/dist/dispatch/validate.d.ts.map +1 -0
- package/dist/dispatch/validate.js +27 -0
- package/dist/dispatch/validate.js.map +1 -0
- package/dist/domain/build-spec.d.ts +37 -0
- package/dist/domain/build-spec.d.ts.map +1 -0
- package/dist/domain/build-spec.js +95 -0
- package/dist/domain/build-spec.js.map +1 -0
- package/dist/domain/contract.d.ts +17 -0
- package/dist/domain/contract.d.ts.map +1 -0
- package/dist/domain/contract.js +26 -0
- package/dist/domain/contract.js.map +1 -0
- package/dist/domain/define.d.ts +82 -0
- package/dist/domain/define.d.ts.map +1 -0
- package/dist/domain/define.js +99 -0
- package/dist/domain/define.js.map +1 -0
- package/dist/domain/extend-core.d.ts +49 -0
- package/dist/domain/extend-core.d.ts.map +1 -0
- package/dist/domain/extend-core.js +182 -0
- package/dist/domain/extend-core.js.map +1 -0
- package/dist/domain/index.d.ts +5 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +4 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/method/class.d.ts +70 -0
- package/dist/method/class.d.ts.map +1 -0
- package/dist/method/class.js +26 -0
- package/dist/method/class.js.map +1 -0
- package/dist/method/context.d.ts +43 -0
- package/dist/method/context.d.ts.map +1 -0
- package/dist/method/context.js +10 -0
- package/dist/method/context.js.map +1 -0
- package/dist/method/index.d.ts +6 -0
- package/dist/method/index.d.ts.map +1 -0
- package/dist/method/index.js +3 -0
- package/dist/method/index.js.map +1 -0
- package/dist/method/single.d.ts +88 -0
- package/dist/method/single.d.ts.map +1 -0
- package/dist/method/single.js +18 -0
- package/dist/method/single.js.map +1 -0
- package/dist/server/auxiliary-routes.d.ts +44 -0
- package/dist/server/auxiliary-routes.d.ts.map +1 -0
- package/dist/server/auxiliary-routes.js +239 -0
- package/dist/server/auxiliary-routes.js.map +1 -0
- package/dist/server/config.d.ts +83 -0
- package/dist/server/config.d.ts.map +1 -0
- package/dist/server/config.js +8 -0
- package/dist/server/config.js.map +1 -0
- package/dist/server/create.d.ts +21 -0
- package/dist/server/create.d.ts.map +1 -0
- package/dist/server/create.js +210 -0
- package/dist/server/create.js.map +1 -0
- package/dist/server/handle.d.ts +35 -0
- package/dist/server/handle.d.ts.map +1 -0
- package/dist/server/handle.js +9 -0
- package/dist/server/handle.js.map +1 -0
- package/dist/server/index.d.ts +11 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +8 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/jwks.d.ts +11 -0
- package/dist/server/jwks.d.ts.map +1 -0
- package/dist/server/jwks.js +15 -0
- package/dist/server/jwks.js.map +1 -0
- package/dist/server/require-env.d.ts +15 -0
- package/dist/server/require-env.d.ts.map +1 -0
- package/dist/server/require-env.js +21 -0
- package/dist/server/require-env.js.map +1 -0
- package/dist/server/serving-url.d.ts +14 -0
- package/dist/server/serving-url.d.ts.map +1 -0
- package/dist/server/serving-url.js +28 -0
- package/dist/server/serving-url.js.map +1 -0
- package/dist/server/start.d.ts +11 -0
- package/dist/server/start.d.ts.map +1 -0
- package/dist/server/start.js +34 -0
- package/dist/server/start.js.map +1 -0
- package/dist/server/worker-entry.d.ts +60 -0
- package/dist/server/worker-entry.d.ts.map +1 -0
- package/dist/server/worker-entry.js +79 -0
- package/dist/server/worker-entry.js.map +1 -0
- package/dist/server/worker-meta.d.ts +6 -0
- package/dist/server/worker-meta.d.ts.map +1 -0
- package/dist/server/worker-meta.js +10 -0
- package/dist/server/worker-meta.js.map +1 -0
- package/package.json +5 -5
- package/src/auth/compose.ts +27 -2
- package/src/auth/kernel-client.ts +103 -11
- package/src/define/remote-function.ts +10 -0
- package/src/server/auxiliary-routes.ts +3 -1
- package/src/server/start.ts +5 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handler execution — pipeline step 4.
|
|
3
|
+
*
|
|
4
|
+
* Calls the resolved handler's `execute` with a fully assembled
|
|
5
|
+
* `RemoteContext`: validated params, auth context, optional bound self,
|
|
6
|
+
* typed deps, and a kernel `BoundClientSessionView`. The handler may return a
|
|
7
|
+
* value, a Promise, or an async generator (for `output: 'stream'`).
|
|
8
|
+
*/
|
|
9
|
+
import type { FnMap } from '@astrale-os/kernel-client';
|
|
10
|
+
import type { BoundClientSessionView } from '@astrale-os/kernel-client/session';
|
|
11
|
+
import type { AuthContext } from '@astrale-os/kernel-core';
|
|
12
|
+
import type { CallRemoteFn } from './call-remote';
|
|
13
|
+
import type { SelfResult } from './self';
|
|
14
|
+
type HandlerFn = (...args: any[]) => any;
|
|
15
|
+
export type ExecuteParams = {
|
|
16
|
+
/** Handler may omit `execute` when authored as a stub (spec-only binding). */
|
|
17
|
+
handler: {
|
|
18
|
+
execute?: HandlerFn;
|
|
19
|
+
};
|
|
20
|
+
/** Namespaced ref of the dispatched method — names the offending method in the
|
|
21
|
+
* stub-leak diagnostic below (the dispatcher passes `bound.ref`). */
|
|
22
|
+
ref?: string;
|
|
23
|
+
params: Record<string, unknown>;
|
|
24
|
+
auth: AuthContext | null;
|
|
25
|
+
self: SelfResult | undefined;
|
|
26
|
+
deps: unknown;
|
|
27
|
+
url: string;
|
|
28
|
+
kernel: BoundClientSessionView<FnMap> | null;
|
|
29
|
+
callRemote: CallRemoteFn;
|
|
30
|
+
};
|
|
31
|
+
export declare function executeHandler(ctx: ExecuteParams): Promise<unknown>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=execute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/dispatch/execute.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAA;AAC/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAGxC,KAAK,SAAS,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;AAExC,MAAM,MAAM,aAAa,GAAG;IAC1B,8EAA8E;IAC9E,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,SAAS,CAAA;KAAE,CAAA;IAChC;0EACsE;IACtE,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,IAAI,EAAE,WAAW,GAAG,IAAI,CAAA;IACxB,IAAI,EAAE,UAAU,GAAG,SAAS,CAAA;IAC5B,IAAI,EAAE,OAAO,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,sBAAsB,CAAC,KAAK,CAAC,GAAG,IAAI,CAAA;IAC5C,UAAU,EAAE,YAAY,CAAA;CACzB,CAAA;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAgBzE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handler execution — pipeline step 4.
|
|
3
|
+
*
|
|
4
|
+
* Calls the resolved handler's `execute` with a fully assembled
|
|
5
|
+
* `RemoteContext`: validated params, auth context, optional bound self,
|
|
6
|
+
* typed deps, and a kernel `BoundClientSessionView`. The handler may return a
|
|
7
|
+
* value, a Promise, or an async generator (for `output: 'stream'`).
|
|
8
|
+
*/
|
|
9
|
+
export async function executeHandler(ctx) {
|
|
10
|
+
if (typeof ctx.handler.execute !== 'function') {
|
|
11
|
+
throw new Error(`executeHandler: handler${ctx.ref ? ` for "${ctx.ref}"` : ''} has no \`execute\` body — ` +
|
|
12
|
+
`this is a binding stub that should have been resolved to a remote redirect upstream.`);
|
|
13
|
+
}
|
|
14
|
+
return ctx.handler.execute({
|
|
15
|
+
params: ctx.params,
|
|
16
|
+
auth: ctx.auth,
|
|
17
|
+
self: ctx.self,
|
|
18
|
+
deps: ctx.deps,
|
|
19
|
+
url: ctx.url,
|
|
20
|
+
kernel: ctx.kernel,
|
|
21
|
+
callRemote: ctx.callRemote,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/dispatch/execute.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA2BH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAkB;IACrD,IAAI,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CACb,0BAA0B,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,6BAA6B;YACvF,sFAAsF,CACzF,CAAA;IACH,CAAC;IACD,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC;QACzB,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,UAAU,EAAE,GAAG,CAAC,UAAU;KAC3B,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-callable identity — dispatcher runtime + install-time wiring.
|
|
3
|
+
*
|
|
4
|
+
* Two flavors of callable get an identity per the install-time identity
|
|
5
|
+
* binding: Methods on classes/interfaces (sub = MethodPath) and auto-
|
|
6
|
+
* materialized core function nodes — RemoteFunctions and Views (sub =
|
|
7
|
+
* AbsolutePath of the node under `core/{functions,views}/<slug>`).
|
|
8
|
+
*
|
|
9
|
+
* At server startup the method dispatcher and the View / RemoteFunction
|
|
10
|
+
* route mounter pre-compute, for every materialized callable, the
|
|
11
|
+
* `RemoteIdentityConfig` they sign outbound kernel calls with. The kernel
|
|
12
|
+
* then matches an existing function identity instead of provisioning a
|
|
13
|
+
* generic one.
|
|
14
|
+
*
|
|
15
|
+
* **Single source of truth:** every helper here is a thin lens over the
|
|
16
|
+
* canonical `resolveCallables` from `@astrale-os/kernel-core/domain`. The
|
|
17
|
+
* kernel validates install subs against the SAME function — drift = 0
|
|
18
|
+
* by construction. This closes the previous SDK-side gap where
|
|
19
|
+
* `collectMethodPaths` filtered to `own|override` and silently dropped
|
|
20
|
+
* `sealed`/`default` interface methods (which DO materialize as nodes).
|
|
21
|
+
*/
|
|
22
|
+
import type { BoundMethod, CompiledDomain } from '@astrale-os/kernel-core/domain';
|
|
23
|
+
import type { RemoteIdentityConfig } from '../auth/identity';
|
|
24
|
+
import type { AnyRemoteHandler } from '../method/single';
|
|
25
|
+
/**
|
|
26
|
+
* For each materialized method node, emit its `MethodPath` (semantic,
|
|
27
|
+
* layout-independent) keyed by the method's namespaced ref. Used to
|
|
28
|
+
* build the install `subs` claim and to look up runtime per-method
|
|
29
|
+
* subjects in `buildIdentityMap`.
|
|
30
|
+
*
|
|
31
|
+
* Includes every method node the kernel materializes — class own/override
|
|
32
|
+
* AND interface own (sealed/default/override). Inherited (non-overriding)
|
|
33
|
+
* class methods reuse the interface's node via a `method_of` edge and
|
|
34
|
+
* are correctly absent here.
|
|
35
|
+
*/
|
|
36
|
+
export declare function collectMethodPaths(compiled: CompiledDomain): Record<string, string>;
|
|
37
|
+
/** `{ views, remoteFunctions }` buckets keyed by slug — the shared shape
|
|
38
|
+
* for every per-aux-callable map (paths, identity configs). */
|
|
39
|
+
export type AuxBuckets<T> = {
|
|
40
|
+
views: Record<string, T>;
|
|
41
|
+
remoteFunctions: Record<string, T>;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* slug → `AbsolutePath.raw` for each auto-materialized aux node
|
|
45
|
+
* (RemoteFunction / View). These nodes live at
|
|
46
|
+
* `/<origin>/core/{functions,views}/<slug>` and have no class+method
|
|
47
|
+
* decomposition that would justify a MethodPath — their identity is their
|
|
48
|
+
* graph position.
|
|
49
|
+
*/
|
|
50
|
+
export type AuxIdentityPaths = AuxBuckets<string>;
|
|
51
|
+
export declare function collectAuxIdentityPaths(compiled: CompiledDomain): AuxIdentityPaths;
|
|
52
|
+
/**
|
|
53
|
+
* slug → `RemoteIdentityConfig` for each auto-materialized View /
|
|
54
|
+
* RemoteFunction. Built once at server startup; consumed by
|
|
55
|
+
* `mountAuxiliaryRoutes` so each handler signs outbound `kernel.call(...)`
|
|
56
|
+
* with its own `sub` (the node's AbsolutePath). Mirrors `buildIdentityMap`.
|
|
57
|
+
*/
|
|
58
|
+
export type AuxIdentityMap = AuxBuckets<RemoteIdentityConfig>;
|
|
59
|
+
export declare function buildAuxIdentityMap(compiled: CompiledDomain, privateKey: JsonWebKey, issuer: string): AuxIdentityMap;
|
|
60
|
+
/**
|
|
61
|
+
* Pre-resolve per-method identity configs. Lookup is by BoundMethod instance,
|
|
62
|
+
* so the dispatcher pays O(1) per call instead of re-constructing the config.
|
|
63
|
+
*
|
|
64
|
+
* `iss` = the worker's own **serving URL** (`issuer` arg, e.g.
|
|
65
|
+
* `https://crm.test.com`) — its cryptographic identity, DECOUPLED from the
|
|
66
|
+
* domain's addressing `origin` (a graph slug). The kernel stamps the same
|
|
67
|
+
* value on each function node at install (it pins `iss` to the URL it fetched
|
|
68
|
+
* the domain at) and verifies inbound credentials against that issuer's JWKS
|
|
69
|
+
* (OIDC discovery). The function `sub` stays the origin-addressed MethodPath —
|
|
70
|
+
* `sub` = which function, `iss` = who signs.
|
|
71
|
+
*/
|
|
72
|
+
export declare function buildIdentityMap(compiled: CompiledDomain, methods: BoundMethod<AnyRemoteHandler>[], privateKey: JsonWebKey, issuer: string): Map<BoundMethod<AnyRemoteHandler>, RemoteIdentityConfig>;
|
|
73
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/dispatch/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAIjF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAExD;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMnF;AAED;gEACgE;AAChE,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAC1B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IACxB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;CACnC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;AAEjD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,cAAc,GAAG,gBAAgB,CAoBlF;AAED;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAA;AAE7D,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,cAAc,EACxB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,GACb,cAAc,CAWhB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,WAAW,CAAC,gBAAgB,CAAC,EAAE,EACxC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,GACb,GAAG,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE,oBAAoB,CAAC,CAmB1D"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-callable identity — dispatcher runtime + install-time wiring.
|
|
3
|
+
*
|
|
4
|
+
* Two flavors of callable get an identity per the install-time identity
|
|
5
|
+
* binding: Methods on classes/interfaces (sub = MethodPath) and auto-
|
|
6
|
+
* materialized core function nodes — RemoteFunctions and Views (sub =
|
|
7
|
+
* AbsolutePath of the node under `core/{functions,views}/<slug>`).
|
|
8
|
+
*
|
|
9
|
+
* At server startup the method dispatcher and the View / RemoteFunction
|
|
10
|
+
* route mounter pre-compute, for every materialized callable, the
|
|
11
|
+
* `RemoteIdentityConfig` they sign outbound kernel calls with. The kernel
|
|
12
|
+
* then matches an existing function identity instead of provisioning a
|
|
13
|
+
* generic one.
|
|
14
|
+
*
|
|
15
|
+
* **Single source of truth:** every helper here is a thin lens over the
|
|
16
|
+
* canonical `resolveCallables` from `@astrale-os/kernel-core/domain`. The
|
|
17
|
+
* kernel validates install subs against the SAME function — drift = 0
|
|
18
|
+
* by construction. This closes the previous SDK-side gap where
|
|
19
|
+
* `collectMethodPaths` filtered to `own|override` and silently dropped
|
|
20
|
+
* `sealed`/`default` interface methods (which DO materialize as nodes).
|
|
21
|
+
*/
|
|
22
|
+
import { resolveCallables } from '@astrale-os/kernel-core/domain';
|
|
23
|
+
/**
|
|
24
|
+
* For each materialized method node, emit its `MethodPath` (semantic,
|
|
25
|
+
* layout-independent) keyed by the method's namespaced ref. Used to
|
|
26
|
+
* build the install `subs` claim and to look up runtime per-method
|
|
27
|
+
* subjects in `buildIdentityMap`.
|
|
28
|
+
*
|
|
29
|
+
* Includes every method node the kernel materializes — class own/override
|
|
30
|
+
* AND interface own (sealed/default/override). Inherited (non-overriding)
|
|
31
|
+
* class methods reuse the interface's node via a `method_of` edge and
|
|
32
|
+
* are correctly absent here.
|
|
33
|
+
*/
|
|
34
|
+
export function collectMethodPaths(compiled) {
|
|
35
|
+
const out = {};
|
|
36
|
+
for (const c of resolveCallables(compiled)) {
|
|
37
|
+
if (c.kind === 'method')
|
|
38
|
+
out[c.ref] = c.sub;
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
export function collectAuxIdentityPaths(compiled) {
|
|
43
|
+
const views = {};
|
|
44
|
+
const remoteFunctions = {};
|
|
45
|
+
for (const c of resolveCallables(compiled)) {
|
|
46
|
+
if (c.kind !== 'core' || !c.slug)
|
|
47
|
+
continue;
|
|
48
|
+
if (c.className === 'View') {
|
|
49
|
+
views[c.slug] = c.sub;
|
|
50
|
+
}
|
|
51
|
+
else if (c.className === 'Function') {
|
|
52
|
+
// Standalone callables (the former `RemoteFunction`) materialize as the
|
|
53
|
+
// canonical kernel `Function` class.
|
|
54
|
+
remoteFunctions[c.slug] = c.sub;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
throw new Error(`collectAuxIdentityPaths: unrecognised aux callable className "${c.className}" ` +
|
|
58
|
+
`at ${c.ref}. If you've added a new auto-materialized Function class to extendCore, ` +
|
|
59
|
+
`extend this collector + the kernel walker (resolveCallables) to handle it.`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return { views, remoteFunctions };
|
|
63
|
+
}
|
|
64
|
+
export function buildAuxIdentityMap(compiled, privateKey, issuer) {
|
|
65
|
+
const paths = collectAuxIdentityPaths(compiled);
|
|
66
|
+
const views = {};
|
|
67
|
+
for (const [slug, subject] of Object.entries(paths.views)) {
|
|
68
|
+
views[slug] = { issuer, subject, privateKey };
|
|
69
|
+
}
|
|
70
|
+
const remoteFunctions = {};
|
|
71
|
+
for (const [slug, subject] of Object.entries(paths.remoteFunctions)) {
|
|
72
|
+
remoteFunctions[slug] = { issuer, subject, privateKey };
|
|
73
|
+
}
|
|
74
|
+
return { views, remoteFunctions };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Pre-resolve per-method identity configs. Lookup is by BoundMethod instance,
|
|
78
|
+
* so the dispatcher pays O(1) per call instead of re-constructing the config.
|
|
79
|
+
*
|
|
80
|
+
* `iss` = the worker's own **serving URL** (`issuer` arg, e.g.
|
|
81
|
+
* `https://crm.test.com`) — its cryptographic identity, DECOUPLED from the
|
|
82
|
+
* domain's addressing `origin` (a graph slug). The kernel stamps the same
|
|
83
|
+
* value on each function node at install (it pins `iss` to the URL it fetched
|
|
84
|
+
* the domain at) and verifies inbound credentials against that issuer's JWKS
|
|
85
|
+
* (OIDC discovery). The function `sub` stays the origin-addressed MethodPath —
|
|
86
|
+
* `sub` = which function, `iss` = who signs.
|
|
87
|
+
*/
|
|
88
|
+
export function buildIdentityMap(compiled, methods, privateKey, issuer) {
|
|
89
|
+
const paths = collectMethodPaths(compiled);
|
|
90
|
+
const out = new Map();
|
|
91
|
+
for (const bound of methods) {
|
|
92
|
+
const subject = paths[bound.ref];
|
|
93
|
+
if (!subject) {
|
|
94
|
+
// Under the "drift = 0" invariant every dispatched method's ref is a key
|
|
95
|
+
// in `paths`. A miss means an install/index drift — fail loudly at boot
|
|
96
|
+
// rather than signing with `bound.ref` (a namespaced ref, NOT a
|
|
97
|
+
// MethodPath sub), which would silently fail kernel identity matching at
|
|
98
|
+
// call time. Mirrors `identityFor` / `requireAuxIdentity`.
|
|
99
|
+
throw new Error(`buildIdentityMap: method "${bound.ref}" is in the dispatch index but absent ` +
|
|
100
|
+
`from resolveCallables(compiled) — no identity subject to sign with.`);
|
|
101
|
+
}
|
|
102
|
+
out.set(bound, { issuer, subject, privateKey });
|
|
103
|
+
}
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/dispatch/identity.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { SdkDispatcher, type SdkDispatcherConfig } from './dispatcher';
|
|
2
|
+
export { resolveMethod, buildMethodIndex, type MethodIndex } from './resolve';
|
|
3
|
+
export { validateParams, validateResult, type ValidationResult, type ResultValidationResult, } from './validate';
|
|
4
|
+
export { resolveSelf, type SelfResult } from './self';
|
|
5
|
+
export { executeHandler, type ExecuteParams } from './execute';
|
|
6
|
+
export { makeCallRemote, type CallRemoteFn } from './call-remote';
|
|
7
|
+
export { AuthorizationDeniedError, MethodNotFoundError, SdkValidationError, SdkResultValidationError, } from './errors';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dispatch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAA;AACtE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAA;AAC7E,OAAO,EACL,cAAc,EACd,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,GAC5B,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAA;AACjE,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { SdkDispatcher } from './dispatcher';
|
|
2
|
+
export { resolveMethod, buildMethodIndex } from './resolve';
|
|
3
|
+
export { validateParams, validateResult, } from './validate';
|
|
4
|
+
export { resolveSelf } from './self';
|
|
5
|
+
export { executeHandler } from './execute';
|
|
6
|
+
export { makeCallRemote } from './call-remote';
|
|
7
|
+
export { AuthorizationDeniedError, MethodNotFoundError, SdkValidationError, SdkResultValidationError, } from './errors';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dispatch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,MAAM,cAAc,CAAA;AACtE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAoB,MAAM,WAAW,CAAA;AAC7E,OAAO,EACL,cAAc,EACd,cAAc,GAGf,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,WAAW,EAAmB,MAAM,QAAQ,CAAA;AACrD,OAAO,EAAE,cAAc,EAAsB,MAAM,WAAW,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAqB,MAAM,eAAe,CAAA;AACjE,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Method resolution — the index the dispatcher queries on every call.
|
|
3
|
+
*
|
|
4
|
+
* Owns both the index's construction and its lookup contract:
|
|
5
|
+
* - `buildMethodIndex` is called once at server startup.
|
|
6
|
+
* - `resolveMethod` is called once per inbound call.
|
|
7
|
+
*
|
|
8
|
+
* Each method is indexed under its `BoundMethod.ref`
|
|
9
|
+
* (`namespace.Owner.method.name`) and under a short alias `Owner.name`.
|
|
10
|
+
* The short alias is only registered when it is unambiguous — two methods
|
|
11
|
+
* whose owners live in different namespaces (e.g. class vs interface) and
|
|
12
|
+
* share the same local name would collide, and we refuse to register the
|
|
13
|
+
* ambiguous key rather than silently overwriting.
|
|
14
|
+
*
|
|
15
|
+
* Inbound names may arrive as `Path`, full `ref`, short alias, a tree path
|
|
16
|
+
* `/<domain>/<namespace.Owner>/<method>`, or the typed colon-form MethodPath
|
|
17
|
+
* `/:<domain>:<namespace.Owner>:<method>` (what the kernel forwards when a
|
|
18
|
+
* caller addresses the method in `:`-delimited form). All shapes normalize to
|
|
19
|
+
* the same lookup key.
|
|
20
|
+
*/
|
|
21
|
+
import type { Path } from '@astrale-os/kernel-core';
|
|
22
|
+
import type { BoundMethod } from '@astrale-os/kernel-core/domain';
|
|
23
|
+
import type { AnyRemoteHandler } from '../method/single';
|
|
24
|
+
export type MethodIndex = Map<string, BoundMethod<AnyRemoteHandler>>;
|
|
25
|
+
export declare function buildMethodIndex(methods: BoundMethod<AnyRemoteHandler>[]): MethodIndex;
|
|
26
|
+
export declare function resolveMethod(index: MethodIndex, name: Path | string): BoundMethod<AnyRemoteHandler> | null;
|
|
27
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/dispatch/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAExD,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAA;AAKpE,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,gBAAgB,CAAC,EAAE,GAAG,WAAW,CAmBtF;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,IAAI,GAAG,MAAM,GAClB,WAAW,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAEtC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Method resolution — the index the dispatcher queries on every call.
|
|
3
|
+
*
|
|
4
|
+
* Owns both the index's construction and its lookup contract:
|
|
5
|
+
* - `buildMethodIndex` is called once at server startup.
|
|
6
|
+
* - `resolveMethod` is called once per inbound call.
|
|
7
|
+
*
|
|
8
|
+
* Each method is indexed under its `BoundMethod.ref`
|
|
9
|
+
* (`namespace.Owner.method.name`) and under a short alias `Owner.name`.
|
|
10
|
+
* The short alias is only registered when it is unambiguous — two methods
|
|
11
|
+
* whose owners live in different namespaces (e.g. class vs interface) and
|
|
12
|
+
* share the same local name would collide, and we refuse to register the
|
|
13
|
+
* ambiguous key rather than silently overwriting.
|
|
14
|
+
*
|
|
15
|
+
* Inbound names may arrive as `Path`, full `ref`, short alias, a tree path
|
|
16
|
+
* `/<domain>/<namespace.Owner>/<method>`, or the typed colon-form MethodPath
|
|
17
|
+
* `/:<domain>:<namespace.Owner>:<method>` (what the kernel forwards when a
|
|
18
|
+
* caller addresses the method in `:`-delimited form). All shapes normalize to
|
|
19
|
+
* the same lookup key.
|
|
20
|
+
*/
|
|
21
|
+
const NAMESPACE_PREFIXES = ['class.', 'interface.'];
|
|
22
|
+
const METHOD_INFIX = 'method';
|
|
23
|
+
export function buildMethodIndex(methods) {
|
|
24
|
+
const index = new Map();
|
|
25
|
+
const shortFormAmbiguous = new Set();
|
|
26
|
+
for (const m of methods) {
|
|
27
|
+
index.set(m.ref, m);
|
|
28
|
+
const shortForm = `${m.owner}.${m.method}`;
|
|
29
|
+
if (shortFormAmbiguous.has(shortForm))
|
|
30
|
+
continue;
|
|
31
|
+
const existing = index.get(shortForm);
|
|
32
|
+
if (existing && existing !== m) {
|
|
33
|
+
index.delete(shortForm);
|
|
34
|
+
shortFormAmbiguous.add(shortForm);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
index.set(shortForm, m);
|
|
38
|
+
}
|
|
39
|
+
return index;
|
|
40
|
+
}
|
|
41
|
+
export function resolveMethod(index, name) {
|
|
42
|
+
return index.get(normalizeMethod(name)) ?? null;
|
|
43
|
+
}
|
|
44
|
+
function normalizeMethod(name) {
|
|
45
|
+
const raw = typeof name === 'string' ? name : name.raw;
|
|
46
|
+
if (!raw.startsWith('/'))
|
|
47
|
+
return raw;
|
|
48
|
+
// Typed colon-form MethodPath (`/:<domain>:<owner>:<method>`) vs. tree
|
|
49
|
+
// slash-form (`/<domain>/<owner>/<method>`). The owner segment carries its own
|
|
50
|
+
// `.` (e.g. `interface.NoteOps`), so the path separator is unambiguous.
|
|
51
|
+
const separator = raw.startsWith('/:') ? ':' : '/';
|
|
52
|
+
const segments = raw
|
|
53
|
+
.replace(/^\/+/, '')
|
|
54
|
+
.split(separator)
|
|
55
|
+
.filter((s) => s.length > 0);
|
|
56
|
+
if (segments.length < 3)
|
|
57
|
+
return raw;
|
|
58
|
+
const owner = segments[segments.length - 2];
|
|
59
|
+
const method = segments[segments.length - 1];
|
|
60
|
+
if (NAMESPACE_PREFIXES.some((p) => owner.startsWith(p))) {
|
|
61
|
+
return `${owner}.${METHOD_INFIX}.${method}`;
|
|
62
|
+
}
|
|
63
|
+
return `${owner}.${method}`;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/dispatch/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AASH,MAAM,kBAAkB,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAU,CAAA;AAC5D,MAAM,YAAY,GAAG,QAAQ,CAAA;AAE7B,MAAM,UAAU,gBAAgB,CAAC,OAAwC;IACvE,MAAM,KAAK,GAAgB,IAAI,GAAG,EAAE,CAAA;IACpC,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAU,CAAA;IAE5C,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;QAEnB,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAA;QAC1C,IAAI,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC;YAAE,SAAQ;QAC/C,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QACrC,IAAI,QAAQ,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;YAC/B,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;YACvB,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;YACjC,SAAQ;QACV,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;IACzB,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,KAAkB,EAClB,IAAmB;IAEnB,OAAO,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAA;AACjD,CAAC;AAED,SAAS,eAAe,CAAC,IAAmB;IAC1C,MAAM,GAAG,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAA;IACtD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAA;IACpC,uEAAuE;IACvE,+EAA+E;IAC/E,wEAAwE;IACxE,MAAM,SAAS,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;IAClD,MAAM,QAAQ,GAAG,GAAG;SACjB,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;SACnB,KAAK,CAAC,SAAS,CAAC;SAChB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAC9B,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,GAAG,CAAA;IACnC,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAE,CAAA;IAC5C,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAE,CAAA;IAC7C,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,OAAO,GAAG,KAAK,IAAI,YAAY,IAAI,MAAM,EAAE,CAAA;IAC7C,CAAC;IACD,OAAO,GAAG,KAAK,IAAI,MAAM,EAAE,CAAA;AAC7B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self resolution — pipeline step 3.
|
|
3
|
+
*
|
|
4
|
+
* `_self` is a path reference to the node the non-static method runs on.
|
|
5
|
+
* Currently a thin parse: the caller's string becomes a `Path`, and handlers
|
|
6
|
+
* build recursive paths as `${self.path}::method` (the `Path`'s `toString`
|
|
7
|
+
* yields its raw form, so template literals work unchanged).
|
|
8
|
+
*
|
|
9
|
+
* `resolveSelf` receives the bare self target (`@<id>` or a tree path) — the
|
|
10
|
+
* method ref travels in a separate dispatch channel, so `::method` never
|
|
11
|
+
* reaches here. For the `@<id>` form the parsed `Path` is an `IdPath` which
|
|
12
|
+
* already carries the node id; surfacing it on `SelfResult.id` saves every
|
|
13
|
+
* worker handler from either parsing `self.path.raw` by hand or doing a
|
|
14
|
+
* `Node::get` round-trip just to recover the id of the node it's already
|
|
15
|
+
* operating on.
|
|
16
|
+
*
|
|
17
|
+
* Kept as a distinct step so a future implementation can do a real
|
|
18
|
+
* resolution here (e.g. hydrate a node/accessor) without touching callers.
|
|
19
|
+
*/
|
|
20
|
+
import { Path, type NodeId } from '@astrale-os/kernel-core';
|
|
21
|
+
export type SelfResult = {
|
|
22
|
+
path: Path;
|
|
23
|
+
/** Set when `path` is an `IdPath` (i.e. `@<id>::method` calls). */
|
|
24
|
+
id?: NodeId;
|
|
25
|
+
};
|
|
26
|
+
export declare function resolveSelf(ref: string): SelfResult;
|
|
27
|
+
//# sourceMappingURL=self.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self.d.ts","sourceRoot":"","sources":["../../src/dispatch/self.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAU,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEnE,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,IAAI,CAAA;IACV,mEAAmE;IACnE,EAAE,CAAC,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAGnD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self resolution — pipeline step 3.
|
|
3
|
+
*
|
|
4
|
+
* `_self` is a path reference to the node the non-static method runs on.
|
|
5
|
+
* Currently a thin parse: the caller's string becomes a `Path`, and handlers
|
|
6
|
+
* build recursive paths as `${self.path}::method` (the `Path`'s `toString`
|
|
7
|
+
* yields its raw form, so template literals work unchanged).
|
|
8
|
+
*
|
|
9
|
+
* `resolveSelf` receives the bare self target (`@<id>` or a tree path) — the
|
|
10
|
+
* method ref travels in a separate dispatch channel, so `::method` never
|
|
11
|
+
* reaches here. For the `@<id>` form the parsed `Path` is an `IdPath` which
|
|
12
|
+
* already carries the node id; surfacing it on `SelfResult.id` saves every
|
|
13
|
+
* worker handler from either parsing `self.path.raw` by hand or doing a
|
|
14
|
+
* `Node::get` round-trip just to recover the id of the node it's already
|
|
15
|
+
* operating on.
|
|
16
|
+
*
|
|
17
|
+
* Kept as a distinct step so a future implementation can do a real
|
|
18
|
+
* resolution here (e.g. hydrate a node/accessor) without touching callers.
|
|
19
|
+
*/
|
|
20
|
+
import { IdPath, Path } from '@astrale-os/kernel-core';
|
|
21
|
+
export function resolveSelf(ref) {
|
|
22
|
+
const path = Path.parse(ref);
|
|
23
|
+
return path instanceof IdPath ? { path, id: path.id } : { path };
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=self.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self.js","sourceRoot":"","sources":["../../src/dispatch/self.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAe,MAAM,yBAAyB,CAAA;AAQnE,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC5B,OAAO,IAAI,YAAY,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAA;AAClE,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Param / result validation helpers — Zod `safeParse` wrappers returning a
|
|
3
|
+
* tagged result. Callers convert a `false` outcome into a typed error:
|
|
4
|
+
* `SdkValidationError` (input, → 422) or `SdkResultValidationError`
|
|
5
|
+
* (output, → 500).
|
|
6
|
+
*/
|
|
7
|
+
import type { z } from 'zod';
|
|
8
|
+
export type ValidationResult = {
|
|
9
|
+
ok: true;
|
|
10
|
+
data: Record<string, unknown>;
|
|
11
|
+
} | {
|
|
12
|
+
ok: false;
|
|
13
|
+
issues: unknown[];
|
|
14
|
+
};
|
|
15
|
+
export declare function validateParams(inputSchema: z.ZodType, params: unknown): ValidationResult;
|
|
16
|
+
/**
|
|
17
|
+
* Result of validating a handler's output against its `outputSchema`. Unlike
|
|
18
|
+
* params, an output may be any shape (object, primitive, array), so `data` is
|
|
19
|
+
* `unknown` rather than `Record<string, unknown>`.
|
|
20
|
+
*/
|
|
21
|
+
export type ResultValidationResult = {
|
|
22
|
+
ok: true;
|
|
23
|
+
data: unknown;
|
|
24
|
+
} | {
|
|
25
|
+
ok: false;
|
|
26
|
+
issues: unknown[];
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Validate a handler's return value against its `outputSchema`. Mirrors the
|
|
30
|
+
* kernel's `validateOutput` (`runtime/.../validation/output.ts`) so deployed
|
|
31
|
+
* domains enforce the same output contract as in-process methods. Returns the
|
|
32
|
+
* parsed `data` (applies Zod `default`/`transform`/coercions) on success.
|
|
33
|
+
*/
|
|
34
|
+
export declare function validateResult(outputSchema: z.ZodType, result: unknown): ResultValidationResult;
|
|
35
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/dispatch/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,MAAM,MAAM,gBAAgB,GACxB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAC3C;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,OAAO,EAAE,CAAA;CAAE,CAAA;AAEpC,wBAAgB,cAAc,CAAC,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,gBAAgB,CAMxF;AAED;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,OAAO,EAAE,CAAA;CAAE,CAAA;AAEnG;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,sBAAsB,CAM/F"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Param / result validation helpers — Zod `safeParse` wrappers returning a
|
|
3
|
+
* tagged result. Callers convert a `false` outcome into a typed error:
|
|
4
|
+
* `SdkValidationError` (input, → 422) or `SdkResultValidationError`
|
|
5
|
+
* (output, → 500).
|
|
6
|
+
*/
|
|
7
|
+
export function validateParams(inputSchema, params) {
|
|
8
|
+
const result = inputSchema.safeParse(params);
|
|
9
|
+
if (result.success) {
|
|
10
|
+
return { ok: true, data: result.data };
|
|
11
|
+
}
|
|
12
|
+
return { ok: false, issues: result.error.issues };
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Validate a handler's return value against its `outputSchema`. Mirrors the
|
|
16
|
+
* kernel's `validateOutput` (`runtime/.../validation/output.ts`) so deployed
|
|
17
|
+
* domains enforce the same output contract as in-process methods. Returns the
|
|
18
|
+
* parsed `data` (applies Zod `default`/`transform`/coercions) on success.
|
|
19
|
+
*/
|
|
20
|
+
export function validateResult(outputSchema, result) {
|
|
21
|
+
const parsed = outputSchema.safeParse(result);
|
|
22
|
+
if (parsed.success) {
|
|
23
|
+
return { ok: true, data: parsed.data };
|
|
24
|
+
}
|
|
25
|
+
return { ok: false, issues: parsed.error.issues };
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/dispatch/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,MAAM,UAAU,cAAc,CAAC,WAAsB,EAAE,MAAe;IACpE,MAAM,MAAM,GAAG,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IAC5C,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAA+B,EAAE,CAAA;IACnE,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAA;AACnD,CAAC;AASD;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,YAAuB,EAAE,MAAe;IACrE,MAAM,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IAC7C,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAA;IACxC,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAA;AACnD,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK-side spec builder: CompiledDomain → serialize → Graph.
|
|
3
|
+
*
|
|
4
|
+
* Serializes BoundMethod[] into FunctionSchema[], generates entries for
|
|
5
|
+
* inherited methods not covered by the domain's handlers, then delegates
|
|
6
|
+
* to serialize() for graph blueprint generation.
|
|
7
|
+
*
|
|
8
|
+
* Domain-side Methods are remote-bound: dispatch routes through
|
|
9
|
+
* `binding.remoteUrl` and never reaches the kernel sandbox. We therefore
|
|
10
|
+
* do NOT stamp `code` on emitted FunctionSchema entries — there is no
|
|
11
|
+
* sandbox-eval'able body. Only the kernel domain (compiled in-process)
|
|
12
|
+
* carries `code` strings.
|
|
13
|
+
*
|
|
14
|
+
* The emitted graph is absolute — the Tree produced by `serialize()` is
|
|
15
|
+
* already mounted at `/<origin>`, so `tree.toGraph()` lifts every internal
|
|
16
|
+
* relative path into its host-graph absolute form. Wire serialization is the
|
|
17
|
+
* caller's responsibility (`graph.toWire()`).
|
|
18
|
+
*/
|
|
19
|
+
import type { WireGraph } from '@astrale-os/kernel-core';
|
|
20
|
+
import type { Schema } from '@astrale-os/kernel-dsl';
|
|
21
|
+
import type { RemoteDomain } from './define';
|
|
22
|
+
/**
|
|
23
|
+
* Build the install-ready wire graph for a domain served at `url`: materialize
|
|
24
|
+
* the domain at its real serving URL (so every binding carries the live URL —
|
|
25
|
+
* the define-time compile carries none), serialize, and emit the wire form.
|
|
26
|
+
* This is the graph the kernel installs and re-hashes to verify. There is no
|
|
27
|
+
* url-less variant: an install graph without bindings is uninstallable (the
|
|
28
|
+
* kernel install guard rejects it).
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildInstallGraph<S extends Schema>(domain: RemoteDomain<S>, url: string): WireGraph;
|
|
31
|
+
/**
|
|
32
|
+
* Content hash of the install graph. Delegates the canonical hash to kernel-core's
|
|
33
|
+
* `hashInstallGraph` — the same algorithm the kernel re-runs on install to verify
|
|
34
|
+
* the received graph against the signed hash.
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildInstallGraphHash<S extends Schema>(domain: RemoteDomain<S>, url: string): Promise<string>;
|
|
37
|
+
//# sourceMappingURL=build-spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-spec.d.ts","sourceRoot":"","sources":["../../src/domain/build-spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAS,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAE/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAKpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAK5C;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAChD,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EACvB,GAAG,EAAE,MAAM,GACV,SAAS,CAGX;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,MAAM,EACpD,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EACvB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,CAEjB"}
|