@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 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,aAAa,EACb,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAGnF,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AACvF,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAUhE,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAC3D,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAcpG,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,YAAY,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAGzC,YAAY,EACV,UAAU,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,UAAU,EACV,SAAS,EACT,UAAU,GACX,MAAM,+BAA+B,CAAA;AAGtC,YAAY,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AACtE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAChF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAClF,YAAY,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,UAAU,EACV,UAAU,EACV,QAAQ,GACT,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAGnD,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACpE,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,YAAY,CAAA;AACnB,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export { remoteMethod, remoteClassMethods, remoteInterfaceMethods } from './method';
|
|
2
|
+
// ─── Domain ──────────────────────────────────────────────────────────────
|
|
3
|
+
export { defineRemoteDomain, buildInstallGraph, buildInstallGraphHash } from './domain';
|
|
4
|
+
// ─── Declarative resource helpers ────────────────────────────────────────
|
|
5
|
+
// Author Views (iframe-mountable) and RemoteFunctions (standalone callables)
|
|
6
|
+
// at the domain definition site. Each `defineView` / `defineRemoteFunction`
|
|
7
|
+
// entry is auto-materialized by `defineRemoteDomain` into a graph node (a
|
|
8
|
+
// `View`, or the canonical kernel `Function` for standalone callables) under
|
|
9
|
+
// the reserved views / functions folder, keyed by its map slug; the same
|
|
10
|
+
// entry's `render` / `execute` (+ auth hooks) is mounted as a worker route by
|
|
11
|
+
// `createRemoteServer`.
|
|
12
|
+
export { defineView, defineRemoteFunction } from './define';
|
|
13
|
+
// ─── Server ──────────────────────────────────────────────────────────────
|
|
14
|
+
// `createRemoteServer` dynamically imports `@hono/node-server` via `./server/start`.
|
|
15
|
+
// Exporting the server surface from the barrel poisons browser bundlers
|
|
16
|
+
// (Vite/esbuild) that traverse every re-export and try to bundle the dynamic
|
|
17
|
+
// chunk — which fails on Node built-ins. Consumers that need the server
|
|
18
|
+
// runtime import from '@astrale-os/sdk/server' directly.
|
|
19
|
+
// ─── Deploy ──────────────────────────────────────────────────────────────
|
|
20
|
+
// `deployCheck` and `hashSpecFile` use Node-only modules (`node:crypto`,
|
|
21
|
+
// `node:fs`, `node:child_process`) at module load time. Exporting them from
|
|
22
|
+
// the barrel poisons browser bundlers (Vite/esbuild) that transitively load
|
|
23
|
+
// every re-export. Consumers that need them import from './deploy' directly.
|
|
24
|
+
export { MetaSchema } from './deploy/meta';
|
|
25
|
+
export { authenticateRequest, buildComposedGrant, signCredential } from './auth';
|
|
26
|
+
export { AuthMissingError, AuthInvalidError } from './auth';
|
|
27
|
+
export { assertPerm, requireOwnership, READ, EDIT, USE, SHARE, ALL } from './auth';
|
|
28
|
+
export { selfGrant } from '@astrale-os/kernel-core';
|
|
29
|
+
// ─── Dispatch (escape hatch for custom integrations) ─────────────────────
|
|
30
|
+
export { SdkDispatcher } from './dispatch';
|
|
31
|
+
export { AuthorizationDeniedError, MethodNotFoundError, SdkValidationError, SdkResultValidationError, } from './dispatch';
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAEnF,4EAA4E;AAC5E,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAGvF,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,0EAA0E;AAC1E,6EAA6E;AAC7E,yEAAyE;AACzE,8EAA8E;AAC9E,wBAAwB;AACxB,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAG3D,4EAA4E;AAC5E,qFAAqF;AACrF,wEAAwE;AACxE,6EAA6E;AAC7E,wEAAwE;AACxE,yDAAyD;AAEzD,4EAA4E;AAC5E,yEAAyE;AACzE,4EAA4E;AAC5E,4EAA4E;AAC5E,6EAA6E;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAiB1C,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAChF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AASlF,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAEnD,4EAA4E;AAC5E,OAAO,EAAE,aAAa,EAA4B,MAAM,YAAY,CAAA;AACpE,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class-level method aggregation.
|
|
3
|
+
*
|
|
4
|
+
* Where `RemoteHandler` describes one method, the types here describe a
|
|
5
|
+
* whole class's worth of methods. `ClassMethodsImpl<S, K, TDeps>` enforces
|
|
6
|
+
* that every implementable method on class `K` is provided. The interface
|
|
7
|
+
* variant handles abstract definitions; the schema variant indexes by class
|
|
8
|
+
* name.
|
|
9
|
+
*
|
|
10
|
+
* `remoteClassMethods` is the identity helper an author calls when supplying
|
|
11
|
+
* a class's full method record — it gives full inference for the class
|
|
12
|
+
* methods at once, complementing `remoteMethod` (one method at a time).
|
|
13
|
+
*/
|
|
14
|
+
import type { DefForInterface, InterfaceMethodDefs, InterfaceMethodKeys, MethodClassKeys, NonSealedMethodKeys, OwnMethodKeys, ResolveParams, ResolveReturn, SealedKeys } from '@astrale-os/kernel-core/domain';
|
|
15
|
+
import type { ImplementableOwnKeys, Schema } from '@astrale-os/kernel-dsl';
|
|
16
|
+
import type { SelfResult } from '../dispatch/self';
|
|
17
|
+
import type { MethodImpl, RemoteHandler } from './single';
|
|
18
|
+
/** Per-class method implementations for a remote domain. */
|
|
19
|
+
export type ClassMethodsImpl<S extends Schema, K extends MethodClassKeys<S> & string, TDeps = unknown> = {
|
|
20
|
+
[M in OwnMethodKeys<S, K>]: MethodImpl<S, K, M, TDeps>;
|
|
21
|
+
} & {
|
|
22
|
+
[M in NonSealedMethodKeys<S, K>]: MethodImpl<S, K, M, TDeps>;
|
|
23
|
+
} & {
|
|
24
|
+
[M in SealedKeys<S, K>]?: never;
|
|
25
|
+
};
|
|
26
|
+
/** Resolve interface method handler directly (InterfaceMethodKeys ≠ MethodKeys). */
|
|
27
|
+
type InterfaceMethodHandler<S extends Schema, K extends string, M extends string, TDeps> = M extends keyof InterfaceMethodDefs<S, K> ? InterfaceMethodDefs<S, K>[M] extends {
|
|
28
|
+
readonly config: infer MC;
|
|
29
|
+
} ? MC extends {
|
|
30
|
+
readonly static: true;
|
|
31
|
+
} ? RemoteHandler<ResolveParams<MC>, ResolveReturn<MC>, undefined, TDeps> : RemoteHandler<ResolveParams<MC>, ResolveReturn<MC>, SelfResult, TDeps> : never : never;
|
|
32
|
+
/** Per-interface method implementations. */
|
|
33
|
+
export type InterfaceMethodsImpl<S extends Schema, K extends InterfaceMethodKeys<S> & string, TDeps = unknown> = {
|
|
34
|
+
[M in ImplementableOwnKeys<DefForInterface<S, K>> & string]: InterfaceMethodHandler<S, K, M, TDeps>;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Namespace-keyed full schema methods map, parameterized by deps.
|
|
38
|
+
* Handlers for classes and interfaces live under distinct `class` / `interface`
|
|
39
|
+
* slots, preventing name collisions between a class and an interface with the
|
|
40
|
+
* same name.
|
|
41
|
+
*
|
|
42
|
+
* `interface` is optional — schemas without non-abstract interface methods
|
|
43
|
+
* (or with no interfaces at all) do not need to provide it.
|
|
44
|
+
*/
|
|
45
|
+
export type SchemaMethodsImpl<S extends Schema, TDeps = unknown> = {
|
|
46
|
+
class: {
|
|
47
|
+
[K in MethodClassKeys<S> & string]: ClassMethodsImpl<S, K, TDeps>;
|
|
48
|
+
};
|
|
49
|
+
interface?: {
|
|
50
|
+
[K in InterfaceMethodKeys<S> & string]: InterfaceMethodsImpl<S, K, TDeps>;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
type RejectSealedKeys<S extends Schema, K extends string, I> = keyof I & SealedKeys<S, K> extends never ? I : `Error: sealed methods must not be implemented by class '${K}': ${keyof I & SealedKeys<S, K> & string}`;
|
|
54
|
+
/** Identity helper for authoring one class's remote methods with full schema typing. */
|
|
55
|
+
export declare function remoteClassMethods<TDeps>(): <S extends Schema, K extends MethodClassKeys<S> & string, I extends ClassMethodsImpl<S, K, TDeps>>(schema: S, className: K, impl: I & RejectSealedKeys<S, K, I>) => I;
|
|
56
|
+
export declare function remoteClassMethods<S extends Schema, K extends MethodClassKeys<S> & string, I extends ClassMethodsImpl<S, K>>(schema: S, className: K, impl: I & RejectSealedKeys<S, K, I>): I;
|
|
57
|
+
/**
|
|
58
|
+
* Identity helper for authoring one interface's remote methods with full
|
|
59
|
+
* schema typing — the interface-hosted counterpart of `remoteClassMethods`.
|
|
60
|
+
*
|
|
61
|
+
* Methods declared on an interface (e.g. a static `createNote` on `NoteOps`)
|
|
62
|
+
* live under the `interface:` slot of `SchemaMethodsImpl`. Without this helper
|
|
63
|
+
* an author has to fall back to `any` (there is no other way to name the
|
|
64
|
+
* per-method handler type — `InterfaceMethodHandler` is internal). Returns the
|
|
65
|
+
* per-interface impl object the `interface: { <Name>: … }` slot expects.
|
|
66
|
+
*/
|
|
67
|
+
export declare function remoteInterfaceMethods<TDeps>(): <S extends Schema, K extends InterfaceMethodKeys<S> & string, I extends InterfaceMethodsImpl<S, K, TDeps>>(schema: S, interfaceName: K, impl: I) => I;
|
|
68
|
+
export declare function remoteInterfaceMethods<S extends Schema, K extends InterfaceMethodKeys<S> & string, I extends InterfaceMethodsImpl<S, K>>(schema: S, interfaceName: K, impl: I): I;
|
|
69
|
+
export {};
|
|
70
|
+
//# sourceMappingURL=class.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/method/class.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,aAAa,EACb,UAAU,EACX,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAE1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAEzD,4DAA4D;AAC5D,MAAM,MAAM,gBAAgB,CAC1B,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,GAAG,MAAM,EACrC,KAAK,GAAG,OAAO,IACb;KACD,CAAC,IAAI,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC;CACvD,GAAG;KACD,CAAC,IAAI,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAA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,CAAC,CAAC,CAAC,GAAG,MAAM,EACzC,CAAC,SAAS,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,EAE3C,MAAM,EAAE,CAAC,EACT,aAAa,EAAE,CAAC,EAChB,IAAI,EAAE,CAAC,KACJ,CAAC,CAAA;AACN,wBAAgB,sBAAsB,CACpC,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,mBAAmB,CAAC,CAAC,CAAC,GAAG,MAAM,EACzC,CAAC,SAAS,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,EACpC,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class-level method aggregation.
|
|
3
|
+
*
|
|
4
|
+
* Where `RemoteHandler` describes one method, the types here describe a
|
|
5
|
+
* whole class's worth of methods. `ClassMethodsImpl<S, K, TDeps>` enforces
|
|
6
|
+
* that every implementable method on class `K` is provided. The interface
|
|
7
|
+
* variant handles abstract definitions; the schema variant indexes by class
|
|
8
|
+
* name.
|
|
9
|
+
*
|
|
10
|
+
* `remoteClassMethods` is the identity helper an author calls when supplying
|
|
11
|
+
* a class's full method record — it gives full inference for the class
|
|
12
|
+
* methods at once, complementing `remoteMethod` (one method at a time).
|
|
13
|
+
*/
|
|
14
|
+
export function remoteClassMethods(...args) {
|
|
15
|
+
if (args.length === 0) {
|
|
16
|
+
return (...innerArgs) => innerArgs[2];
|
|
17
|
+
}
|
|
18
|
+
return args[2];
|
|
19
|
+
}
|
|
20
|
+
export function remoteInterfaceMethods(...args) {
|
|
21
|
+
if (args.length === 0) {
|
|
22
|
+
return (...innerArgs) => innerArgs[2];
|
|
23
|
+
}
|
|
24
|
+
return args[2];
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/method/class.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAiGH,MAAM,UAAU,kBAAkB,CAAC,GAAG,IAAe;IACnD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,SAAoB,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IAClD,CAAC;IAED,OAAO,IAAI,CAAC,CAAC,CAAC,CAAA;AAChB,CAAC;AA0BD,MAAM,UAAU,sBAAsB,CAAC,GAAG,IAAe;IACvD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,SAAoB,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IAClD,CAAC;IAED,OAAO,IAAI,CAAC,CAAC,CAAC,CAAA;AAChB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `RemoteContext` — what every remote method handler receives at runtime.
|
|
3
|
+
*
|
|
4
|
+
* Assembled by the dispatch pipeline before calling `execute`. Carries the
|
|
5
|
+
* validated params, the resolved auth context, the bound node instance (for
|
|
6
|
+
* non-static methods), the typed dependency container, and a
|
|
7
|
+
* `BoundClientSessionView` to call back into the parent kernel.
|
|
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 '../dispatch/call-remote';
|
|
13
|
+
export type RemoteContext<TParams, TSelf, TDeps> = {
|
|
14
|
+
/** Validated params (Zod-checked against the method's `inputSchema`). */
|
|
15
|
+
params: TParams;
|
|
16
|
+
/** Auth context resolved from the inbound delegation credential. `null` for public or unauthenticated optional methods. */
|
|
17
|
+
auth: AuthContext | null;
|
|
18
|
+
/** Bound node instance — `undefined` for static methods. */
|
|
19
|
+
self: TSelf;
|
|
20
|
+
/** Typed dependency container injected at server startup. */
|
|
21
|
+
deps: TDeps;
|
|
22
|
+
/** The worker's own serving URL */
|
|
23
|
+
url: string;
|
|
24
|
+
/**
|
|
25
|
+
* `BoundClientSessionView` to the parent kernel, bound to the composed
|
|
26
|
+
* credential `union(delegation, self)`. `null` when `auth: 'public'`, or
|
|
27
|
+
* `auth: 'optional'` with no inbound credential. Use for kernel syscalls +
|
|
28
|
+
* same-domain methods. For ANOTHER worker's remote method use
|
|
29
|
+
* {@link RemoteContext.callRemote} — `kernel.call` to a remote method fails
|
|
30
|
+
* the audience check.
|
|
31
|
+
*/
|
|
32
|
+
kernel: BoundClientSessionView<FnMap> | null;
|
|
33
|
+
/**
|
|
34
|
+
* Call another worker's remote method (a Function with `binding.remoteUrl`),
|
|
35
|
+
* re-minting the credential for the target's audience so it isn't rejected at
|
|
36
|
+
* authentication. Throws on a public/unauthenticated request (no credential
|
|
37
|
+
* to mint from). The calling Function's identity must hold `USE` on
|
|
38
|
+
* `Identity.mintDelegationCredential` AND the target method's own grants —
|
|
39
|
+
* `callRemote` fixes the audience, not authorization.
|
|
40
|
+
*/
|
|
41
|
+
callRemote: CallRemoteFn;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/method/context.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,yBAAyB,CAAA;AAE3D,MAAM,MAAM,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI;IACjD,yEAAyE;IACzE,MAAM,EAAE,OAAO,CAAA;IACf,2HAA2H;IAC3H,IAAI,EAAE,WAAW,GAAG,IAAI,CAAA;IACxB,4DAA4D;IAC5D,IAAI,EAAE,KAAK,CAAA;IACX,6DAA6D;IAC7D,IAAI,EAAE,KAAK,CAAA;IACX,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAA;IACX;;;;;;;OAOG;IACH,MAAM,EAAE,sBAAsB,CAAC,KAAK,CAAC,GAAG,IAAI,CAAA;IAC5C;;;;;;;OAOG;IACH,UAAU,EAAE,YAAY,CAAA;CACzB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `RemoteContext` — what every remote method handler receives at runtime.
|
|
3
|
+
*
|
|
4
|
+
* Assembled by the dispatch pipeline before calling `execute`. Carries the
|
|
5
|
+
* validated params, the resolved auth context, the bound node instance (for
|
|
6
|
+
* non-static methods), the typed dependency container, and a
|
|
7
|
+
* `BoundClientSessionView` to call back into the parent kernel.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/method/context.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { RemoteContext } from './context';
|
|
2
|
+
export type { RemoteHandler, AnyRemoteHandler, MethodImpl } from './single';
|
|
3
|
+
export { remoteMethod } from './single';
|
|
4
|
+
export type { ClassMethodsImpl, InterfaceMethodsImpl, SchemaMethodsImpl } from './class';
|
|
5
|
+
export { remoteClassMethods, remoteInterfaceMethods } from './class';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/method/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC9C,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AACxF,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/method/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEvC,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authoring a single remote method.
|
|
3
|
+
*
|
|
4
|
+
* `RemoteHandler` is the typed shape an author writes for ONE method:
|
|
5
|
+
* an `execute` body plus optional REST `route` (using the kernel's
|
|
6
|
+
* canonical `RouteBinding`) and optional anchor `remoteUrl`.
|
|
7
|
+
*
|
|
8
|
+
* `MethodImpl` resolves params/result/self from a schema for a given
|
|
9
|
+
* `(class, method)` pair. `remoteMethod` is the identity helper an author
|
|
10
|
+
* calls per method to get full inference without writing generics by hand.
|
|
11
|
+
*/
|
|
12
|
+
import type { AuthPolicy, RouteBinding } from '@astrale-os/kernel-api/routed';
|
|
13
|
+
import type { MethodClassKeys, ClassMethodConfig, NonSealedMethodKeys, OwnMethodKeys } from '@astrale-os/kernel-core/domain';
|
|
14
|
+
import type { Schema } from '@astrale-os/kernel-dsl';
|
|
15
|
+
import type { SelfResult } from '../dispatch/self';
|
|
16
|
+
import type { RemoteContext } from './context';
|
|
17
|
+
/**
|
|
18
|
+
* Remote function handler — execute with full typed context.
|
|
19
|
+
*
|
|
20
|
+
* `execute` is **optional** at the type level: a handler may be a pure
|
|
21
|
+
* binding stub (only `remoteUrl` / `route` set) when authored as a spec-side
|
|
22
|
+
* declaration that never runs locally — the kernel resolver short-circuits
|
|
23
|
+
* via `binding.remoteUrl` before reaching the handler body. The worker-side
|
|
24
|
+
* declaration that actually serves the call MUST provide `execute`.
|
|
25
|
+
*
|
|
26
|
+
* Runtime guard: if dispatch routes to a handler that has no `execute`, the
|
|
27
|
+
* dispatcher throws — that's a programmer error indicating a stub leaked into
|
|
28
|
+
* a code path that was supposed to execute it.
|
|
29
|
+
*/
|
|
30
|
+
export type RemoteHandler<TParams, TResult, TSelf, TDeps> = {
|
|
31
|
+
/** The handler body. May be async or an async generator (for `output: 'stream'`). */
|
|
32
|
+
execute?: (ctx: RemoteContext<TParams, TSelf, TDeps>) => TResult | Promise<TResult> | AsyncGenerator<TResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Optional REST binding — attaches a native HTTP route to this method.
|
|
35
|
+
* Uses the kernel's canonical `RouteBinding` type directly.
|
|
36
|
+
*/
|
|
37
|
+
route?: RouteBinding;
|
|
38
|
+
/**
|
|
39
|
+
* Optional anchor URL — marks this method as anchored to a specific host.
|
|
40
|
+
* May contain `{name}` placeholders matching fields in the input schema.
|
|
41
|
+
* If absent, the method is ambient (mounts on whatever server loads the domain).
|
|
42
|
+
*/
|
|
43
|
+
remoteUrl?: string;
|
|
44
|
+
/** Optional human-readable description. Appears in generated docs. */
|
|
45
|
+
description?: string;
|
|
46
|
+
/** Authentication policy. Defaults to `'required'` when absent. */
|
|
47
|
+
auth?: AuthPolicy;
|
|
48
|
+
/**
|
|
49
|
+
* Optional pre-execute authorization check. Runs after auth resolution and
|
|
50
|
+
* `_self` resolution, before `execute`. Throw any error to deny the call —
|
|
51
|
+
* the SDK wraps it as `AuthorizationDeniedError` (mapped to wire-level
|
|
52
|
+
* `PERMISSION_DENIED`).
|
|
53
|
+
*
|
|
54
|
+
* Use for fine-grained checks the kernel's bit-level perms can't express
|
|
55
|
+
* (e.g. "only the project lead can addMember"). For straight bit-level
|
|
56
|
+
* checks, prefer the helpers in `@astrale-os/sdk` (`assertPerm`,
|
|
57
|
+
* `requireOwnership`).
|
|
58
|
+
*
|
|
59
|
+
* The kernel still enforces `has_perm` independently — `authorize` is
|
|
60
|
+
* additive ergonomic gating on top, not a replacement.
|
|
61
|
+
*/
|
|
62
|
+
authorize?: (ctx: RemoteContext<TParams, TSelf, TDeps>) => void | Promise<void>;
|
|
63
|
+
};
|
|
64
|
+
export type AnyRemoteHandler = RemoteHandler<any, any, any, any>;
|
|
65
|
+
/**
|
|
66
|
+
* Fully typed method implementation — resolves params/result/self from the
|
|
67
|
+
* schema, wraps in `RemoteHandler` with deps.
|
|
68
|
+
*/
|
|
69
|
+
export type MethodImpl<S extends Schema, K extends MethodClassKeys<S> & string, M extends string, TDeps = unknown> = ClassMethodConfig<S, K, M> extends {
|
|
70
|
+
params: infer P;
|
|
71
|
+
result: infer R;
|
|
72
|
+
self: unknown;
|
|
73
|
+
isStatic: infer St;
|
|
74
|
+
} ? RemoteHandler<P, R, St extends true ? undefined : SelfResult, TDeps> : never;
|
|
75
|
+
type ImplementableMethodName<S extends Schema, K extends MethodClassKeys<S> & string> = (OwnMethodKeys<S, K> | NonSealedMethodKeys<S, K>) & string;
|
|
76
|
+
/**
|
|
77
|
+
* Identity helper for authoring one remote method with full schema-driven typing.
|
|
78
|
+
*
|
|
79
|
+
* Two-form calling convention:
|
|
80
|
+
* - `remoteMethod<TDeps>()` — curried form; captures deps type, returns a
|
|
81
|
+
* per-schema helper. Use when you want deps typed.
|
|
82
|
+
* - `remoteMethod(schema, className, methodName, impl)` — direct form with
|
|
83
|
+
* `unknown` deps.
|
|
84
|
+
*/
|
|
85
|
+
export declare function remoteMethod<TDeps>(): <S extends Schema, K extends MethodClassKeys<S> & string, M extends ImplementableMethodName<S, K>>(schema: S, className: K, methodName: M, impl: MethodImpl<S, K, M, TDeps>) => MethodImpl<S, K, M, TDeps>;
|
|
86
|
+
export declare function remoteMethod<S extends Schema, K extends MethodClassKeys<S> & string, M extends ImplementableMethodName<S, K>>(schema: S, className: K, methodName: M, impl: MethodImpl<S, K, M>): MethodImpl<S, K, M>;
|
|
87
|
+
export {};
|
|
88
|
+
//# sourceMappingURL=single.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"single.d.ts","sourceRoot":"","sources":["../../src/method/single.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAC7E,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACd,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAE9C;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI;IAC1D,qFAAqF;IACrF,OAAO,CAAC,EAAE,CACR,GAAG,EAAE,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KACtC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAA;IACzD;;;OAGG;IACH,KAAK,CAAC,EAAE,YAAY,CAAA;IACpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,mEAAmE;IACnE,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,GAAG,OAAO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AE,KAAK,CAAC,CAAA;AAC/B,wBAAgB,YAAY,CAC1B,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,GAAG,MAAM,EACrC,CAAC,SAAS,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,EACvC,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authoring a single remote method.
|
|
3
|
+
*
|
|
4
|
+
* `RemoteHandler` is the typed shape an author writes for ONE method:
|
|
5
|
+
* an `execute` body plus optional REST `route` (using the kernel's
|
|
6
|
+
* canonical `RouteBinding`) and optional anchor `remoteUrl`.
|
|
7
|
+
*
|
|
8
|
+
* `MethodImpl` resolves params/result/self from a schema for a given
|
|
9
|
+
* `(class, method)` pair. `remoteMethod` is the identity helper an author
|
|
10
|
+
* calls per method to get full inference without writing generics by hand.
|
|
11
|
+
*/
|
|
12
|
+
export function remoteMethod(...args) {
|
|
13
|
+
if (args.length === 0) {
|
|
14
|
+
return (...innerArgs) => innerArgs[3];
|
|
15
|
+
}
|
|
16
|
+
return args[3];
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=single.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"single.js","sourceRoot":"","sources":["../../src/method/single.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAoHH,MAAM,UAAU,YAAY,CAAC,GAAG,IAAe;IAC7C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,SAAoB,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IAClD,CAAC;IAED,OAAO,IAAI,CAAC,CAAC,CAAC,CAAA;AAChB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mount worker-side routes for `defineView` and `defineRemoteFunction` entries.
|
|
3
|
+
*
|
|
4
|
+
* Each entry's effective `FunctionBinding` is resolved once at boot (host
|
|
5
|
+
* pattern, path, http verb) and a Hono route is registered that runs the
|
|
6
|
+
* shared SDK auth pipeline (verify inbound credential, optionally enforce /
|
|
7
|
+
* optional / public), Zod validation of input AND output (RemoteFunction
|
|
8
|
+
* only — Views are transport-only), the author's `authorize` hook, and
|
|
9
|
+
* finally `render` / `execute`.
|
|
10
|
+
*
|
|
11
|
+
* Bindings whose host is not a sub-domain of this worker's host are skipped
|
|
12
|
+
* (the graph node was still materialized; the route lives elsewhere).
|
|
13
|
+
*/
|
|
14
|
+
import type { Hono } from 'hono';
|
|
15
|
+
import { type FunctionBinding } from '@astrale-os/kernel-api/routed';
|
|
16
|
+
import { type CorsConfig } from '@astrale-os/kernel-server';
|
|
17
|
+
import type { AnyRemoteFunctionDef } from '../define/remote-function';
|
|
18
|
+
import type { ViewDef } from '../define/view';
|
|
19
|
+
import type { AuxIdentityMap } from '../dispatch/identity';
|
|
20
|
+
export type AuxiliaryRoutesConfig<TDeps> = {
|
|
21
|
+
app: Hono;
|
|
22
|
+
/** This worker's serving URL — used to filter bindings that point elsewhere. */
|
|
23
|
+
url: string;
|
|
24
|
+
views?: Record<string, ViewDef<TDeps>>;
|
|
25
|
+
viewBindings?: Record<string, FunctionBinding>;
|
|
26
|
+
remoteFunctions?: Record<string, AnyRemoteFunctionDef>;
|
|
27
|
+
remoteFunctionBindings?: Record<string, FunctionBinding>;
|
|
28
|
+
deps: TDeps;
|
|
29
|
+
/**
|
|
30
|
+
* Per-route identity configs (keyed by slug) — one entry per View and
|
|
31
|
+
* one per RemoteFunction. Build via `buildAuxIdentityMap(compiled, key, issuer)`
|
|
32
|
+
* from `sdk/src/dispatch/identity.ts`.
|
|
33
|
+
*/
|
|
34
|
+
identities: AuxIdentityMap;
|
|
35
|
+
/**
|
|
36
|
+
* CORS policy applied to every mounted route: per-route `app.options(...)`
|
|
37
|
+
* preflight and `Access-Control-Allow-*` headers on success + error
|
|
38
|
+
* responses. Required so callers (always `createRemoteServer`) keep the
|
|
39
|
+
* kernel-envelope and aux-route policies in sync.
|
|
40
|
+
*/
|
|
41
|
+
cors: CorsConfig;
|
|
42
|
+
};
|
|
43
|
+
export declare function mountAuxiliaryRoutes<TDeps>(config: AuxiliaryRoutesConfig<TDeps>): void;
|
|
44
|
+
//# sourceMappingURL=auxiliary-routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auxiliary-routes.d.ts","sourceRoot":"","sources":["../../src/server/auxiliary-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAA;AAQzC,OAAO,EAKL,KAAK,eAAe,EAErB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAG7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAS1D,MAAM,MAAM,qBAAqB,CAAC,KAAK,IAAI;IACzC,GAAG,EAAE,IAAI,CAAA;IACT,gFAAgF;IAChF,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC9C,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;IACtD,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IACxD,IAAI,EAAE,KAAK,CAAA;IACX;;;;OAIG;IACH,UAAU,EAAE,cAAc,CAAA;IAC1B;;;;;OAKG;IACH,IAAI,EAAE,UAAU,CAAA;CACjB,CAAA;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,qBAAqB,CAAC,KAAK,CAAC,GAAG,IAAI,CA4EtF"}
|