@astrale-os/sdk 0.2.0 → 0.4.0
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/LICENSE +202 -0
- package/dist/auth/check.d.ts +1 -2
- package/dist/auth/check.d.ts.map +1 -1
- package/dist/auth/check.js +2 -6
- package/dist/auth/check.js.map +1 -1
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +1 -0
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/issuer-mint.d.ts +53 -0
- package/dist/auth/issuer-mint.d.ts.map +1 -0
- package/dist/auth/issuer-mint.js +35 -0
- package/dist/auth/issuer-mint.js.map +1 -0
- package/dist/auth/kernel-client.d.ts +8 -2
- package/dist/auth/kernel-client.d.ts.map +1 -1
- package/dist/auth/kernel-client.js +22 -46
- package/dist/auth/kernel-client.js.map +1 -1
- package/dist/cli/dotenv.d.ts +8 -0
- package/dist/cli/dotenv.d.ts.map +1 -1
- package/dist/cli/dotenv.js +18 -0
- package/dist/cli/dotenv.js.map +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/log.d.ts +11 -0
- package/dist/cli/log.d.ts.map +1 -0
- package/dist/cli/log.js +17 -0
- package/dist/cli/log.js.map +1 -0
- package/dist/cli/publish.d.ts +35 -0
- package/dist/cli/publish.d.ts.map +1 -0
- package/dist/cli/publish.js +271 -0
- package/dist/cli/publish.js.map +1 -0
- package/dist/cli/run.d.ts +17 -1
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +85 -101
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/spec.d.ts.map +1 -1
- package/dist/cli/spec.js +1 -0
- package/dist/cli/spec.js.map +1 -1
- package/dist/config/define-domain.d.ts +79 -2
- package/dist/config/define-domain.d.ts.map +1 -1
- package/dist/config/define-domain.js +58 -1
- package/dist/config/define-domain.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/define/remote-function.d.ts +23 -3
- package/dist/define/remote-function.d.ts.map +1 -1
- package/dist/define/remote-function.js +1 -1
- package/dist/define/remote-function.js.map +1 -1
- package/dist/deploy/check.d.ts +6 -6
- package/dist/deploy/check.d.ts.map +1 -1
- package/dist/deploy/check.js +1 -1
- package/dist/deploy/check.js.map +1 -1
- package/dist/deploy/index.d.ts +0 -1
- package/dist/deploy/index.d.ts.map +1 -1
- package/dist/deploy/index.js +0 -1
- package/dist/deploy/index.js.map +1 -1
- package/dist/deploy/meta.d.ts +11 -0
- package/dist/deploy/meta.d.ts.map +1 -1
- package/dist/deploy/meta.js +23 -0
- package/dist/deploy/meta.js.map +1 -1
- package/dist/dispatch/dispatcher.d.ts +17 -4
- package/dist/dispatch/dispatcher.d.ts.map +1 -1
- package/dist/dispatch/dispatcher.js +15 -3
- package/dist/dispatch/dispatcher.js.map +1 -1
- package/dist/dispatch/execute.d.ts +6 -2
- package/dist/dispatch/execute.d.ts.map +1 -1
- package/dist/dispatch/execute.js +1 -0
- package/dist/dispatch/execute.js.map +1 -1
- package/dist/dispatch/identity.d.ts +11 -10
- package/dist/dispatch/identity.d.ts.map +1 -1
- package/dist/dispatch/identity.js +4 -3
- package/dist/dispatch/identity.js.map +1 -1
- package/dist/dispatch/index.d.ts +1 -1
- package/dist/dispatch/index.d.ts.map +1 -1
- package/dist/dispatch/index.js +1 -1
- package/dist/dispatch/index.js.map +1 -1
- package/dist/dispatch/self.d.ts +25 -37
- package/dist/dispatch/self.d.ts.map +1 -1
- package/dist/dispatch/self.js +60 -30
- package/dist/dispatch/self.js.map +1 -1
- package/dist/domain/build-spec.d.ts.map +1 -1
- package/dist/domain/build-spec.js +15 -3
- package/dist/domain/build-spec.js.map +1 -1
- package/dist/domain/define.d.ts +17 -32
- package/dist/domain/define.d.ts.map +1 -1
- package/dist/domain/define.js +12 -31
- package/dist/domain/define.js.map +1 -1
- package/dist/domain/extend-functions.d.ts +13 -9
- package/dist/domain/extend-functions.d.ts.map +1 -1
- package/dist/domain/extend-functions.js +28 -13
- package/dist/domain/extend-functions.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/method/class.d.ts +2 -2
- package/dist/method/class.d.ts.map +1 -1
- package/dist/method/class.js.map +1 -1
- package/dist/method/context.d.ts +18 -3
- package/dist/method/context.d.ts.map +1 -1
- package/dist/method/index.d.ts +2 -2
- package/dist/method/index.d.ts.map +1 -1
- package/dist/method/index.js.map +1 -1
- package/dist/method/single.d.ts +25 -38
- package/dist/method/single.d.ts.map +1 -1
- package/dist/method/single.js +1 -11
- package/dist/method/single.js.map +1 -1
- package/dist/server/auxiliary-routes.d.ts.map +1 -1
- package/dist/server/auxiliary-routes.js +13 -2
- package/dist/server/auxiliary-routes.js.map +1 -1
- package/dist/server/create.d.ts +2 -15
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/create.js +15 -51
- package/dist/server/create.js.map +1 -1
- package/dist/server/domain-entry.d.ts +10 -0
- package/dist/server/domain-entry.d.ts.map +1 -1
- package/dist/server/domain-entry.js +2 -0
- package/dist/server/domain-entry.js.map +1 -1
- package/dist/server/index.d.ts +0 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +0 -1
- package/dist/server/index.js.map +1 -1
- package/package.json +10 -8
- package/src/auth/check.ts +2 -6
- package/src/auth/index.ts +2 -0
- package/src/auth/issuer-mint.ts +75 -0
- package/src/auth/kernel-client.ts +31 -63
- package/src/cli/dotenv.ts +20 -0
- package/src/cli/index.ts +1 -1
- package/src/cli/log.ts +18 -0
- package/src/cli/publish.ts +341 -0
- package/src/cli/run.ts +92 -113
- package/src/cli/spec.ts +1 -0
- package/src/config/define-domain.ts +158 -5
- package/src/config/index.ts +1 -1
- package/src/define/remote-function.ts +47 -7
- package/src/deploy/check.ts +7 -7
- package/src/deploy/index.ts +0 -1
- package/src/deploy/meta.ts +25 -0
- package/src/dispatch/dispatcher.ts +32 -9
- package/src/dispatch/execute.ts +7 -2
- package/src/dispatch/identity.ts +11 -10
- package/src/dispatch/index.ts +1 -1
- package/src/dispatch/self.ts +117 -41
- package/src/domain/build-spec.ts +15 -1
- package/src/domain/define.ts +26 -38
- package/src/domain/extend-functions.ts +35 -15
- package/src/index.ts +29 -5
- package/src/method/class.ts +11 -7
- package/src/method/context.ts +19 -3
- package/src/method/index.ts +8 -2
- package/src/method/single.ts +35 -42
- package/src/server/auxiliary-routes.ts +13 -2
- package/src/server/create.ts +15 -51
- package/src/server/domain-entry.ts +12 -0
- package/src/server/index.ts +0 -1
- package/dist/deploy/hash-spec.d.ts +0 -9
- package/dist/deploy/hash-spec.d.ts.map +0 -1
- package/dist/deploy/hash-spec.js +0 -29
- package/dist/deploy/hash-spec.js.map +0 -1
- package/dist/domain/extend-core.d.ts +0 -49
- package/dist/domain/extend-core.d.ts.map +0 -1
- package/dist/domain/extend-core.js +0 -190
- package/dist/domain/extend-core.js.map +0 -1
- package/dist/server/worker-meta.d.ts +0 -6
- package/dist/server/worker-meta.d.ts.map +0 -1
- package/dist/server/worker-meta.js +0 -10
- package/dist/server/worker-meta.js.map +0 -1
- package/src/deploy/hash-spec.ts +0 -31
- package/src/server/worker-meta.ts +0 -25
package/dist/dispatch/self.d.ts
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Self resolution
|
|
3
|
-
*
|
|
4
|
-
* `_self` is a path reference to the node the non-static method runs on.
|
|
5
|
-
* `resolveSelf` is a thin PARSE: the caller's string becomes a `Path`, and
|
|
6
|
-
* handlers build recursive paths as `${self.path}::method` (the `Path`'s
|
|
7
|
-
* `toString` yields its raw form, so template literals work unchanged). It does
|
|
8
|
-
* NOT touch the graph — the whole dispatch pipeline (resolve → authenticate →
|
|
9
|
-
* validate → self → execute) reaches the handler without a single `Node::get`.
|
|
10
|
-
*
|
|
11
|
-
* `resolveSelf` receives the bare self target (`@<id>` or a tree path) — the
|
|
12
|
-
* method ref travels in a separate dispatch channel, so `::method` never
|
|
13
|
-
* reaches here. For the `@<id>` form the parsed `Path` is an `IdPath` which
|
|
14
|
-
* already carries the node id; surfacing it on `SelfResult.id` saves every
|
|
15
|
-
* worker handler from parsing `self.path.raw` by hand to recover the id of the
|
|
16
|
-
* node it is already operating on.
|
|
17
|
-
*
|
|
18
|
-
* `withNode` enriches the parsed self with the lazy `node()` accessor — the one
|
|
19
|
-
* place a handler can fetch its own node's full record (`{ id, class, props }`)
|
|
20
|
-
* without hand-rolling a `::get`. Construction stays split from parsing so
|
|
21
|
-
* `resolveSelf` remains pure and trivially testable; the dispatcher attaches the
|
|
22
|
-
* accessor once it holds the request's kernel.
|
|
2
|
+
* Self resolution stays parse-only: `_self` becomes a Path/IdPath with no graph
|
|
3
|
+
* read. The dispatcher later attaches lazy node()/call helpers once it has a kernel.
|
|
23
4
|
*/
|
|
5
|
+
import type { BoundNode, InstanceDispatch, NodeBinder } from '@astrale-os/kernel-client/schema';
|
|
24
6
|
import type { Node } from '@astrale-os/kernel-core/graph';
|
|
7
|
+
import type { Schema } from '@astrale-os/kernel-dsl';
|
|
25
8
|
import { Path, type NodeId } from '@astrale-os/kernel-core';
|
|
26
9
|
import type { Kernel } from '../method/context';
|
|
27
10
|
/** The node a non-static method runs on — its full record, id guaranteed. */
|
|
@@ -36,28 +19,33 @@ export type ParsedSelf = {
|
|
|
36
19
|
};
|
|
37
20
|
export type SelfResult = ParsedSelf & {
|
|
38
21
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* single in-flight fetch, and a failure clears the cache so it stays
|
|
42
|
-
* retryable. Pass `{ reload: true }` to force a fresh read.
|
|
43
|
-
*
|
|
44
|
-
* The result is a point-in-time SNAPSHOT, not a live view — for
|
|
45
|
-
* read-modify-write, treat it as the value as of the read (or `reload`).
|
|
46
|
-
* `props` is returned structurally validated only, NOT typed against the
|
|
47
|
-
* node's declared schema: the kernel does not hydrate declared props at
|
|
48
|
-
* runtime, so a node-typed `self` would be unsound. Read the concrete backend
|
|
49
|
-
* off `node.class` (a `ClassPath`) — that is the persisted discriminator.
|
|
22
|
+
* Lazy point-in-time self read. Memoized per dispatch; `{ reload: true }`
|
|
23
|
+
* forces a fresh `function.get`.
|
|
50
24
|
*/
|
|
51
25
|
node(opts?: {
|
|
52
26
|
reload?: boolean;
|
|
53
27
|
}): Promise<ResolvedSelfNode>;
|
|
54
28
|
};
|
|
29
|
+
/** Schema-typed self: short-keyed props and typed same-instance call proxy. */
|
|
30
|
+
export type TypedSelf<D, S extends Schema = Schema> = ParsedSelf & {
|
|
31
|
+
/**
|
|
32
|
+
* Fetch THIS node as a typed `BoundNode<D>`. Memoized exactly like
|
|
33
|
+
* {@link SelfResult.node} — one in-flight `function.get`, rejection-clearing,
|
|
34
|
+
* `{ reload: true }` refetches — so the zero-extra-graph-read dispatch
|
|
35
|
+
* invariant holds: nothing is read until called, then at most once.
|
|
36
|
+
*/
|
|
37
|
+
node(opts?: {
|
|
38
|
+
reload?: boolean;
|
|
39
|
+
}): Promise<BoundNode<D, S>>;
|
|
40
|
+
/** Own instance methods — typed, address-only (`<selfPath>::method`), no read. */
|
|
41
|
+
readonly call: InstanceDispatch<D>;
|
|
42
|
+
};
|
|
55
43
|
export declare function resolveSelf(ref: string): ParsedSelf;
|
|
44
|
+
/** Attach memoized node(); unauthenticated contexts reject instead of reading. */
|
|
45
|
+
export declare function withNode(parsed: ParsedSelf, kernel: Kernel | null): SelfResult;
|
|
56
46
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* unauthenticated `optional`) — there `node()` rejects with a clear error
|
|
60
|
-
* rather than reading the graph unauthenticated.
|
|
47
|
+
* Schema-typed self helper: lazy BoundNode plus address-only call proxy. With no
|
|
48
|
+
* kernel, both node() and call thunks fail loudly.
|
|
61
49
|
*/
|
|
62
|
-
export declare function
|
|
50
|
+
export declare function withBoundNode<S extends Schema>(parsed: ParsedSelf, kernel: Kernel | null, binder: NodeBinder<S>, typeName: string): TypedSelf<unknown, S>;
|
|
63
51
|
//# sourceMappingURL=self.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"self.d.ts","sourceRoot":"","sources":["../../src/dispatch/self.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"self.d.ts","sourceRoot":"","sources":["../../src/dispatch/self.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAEV,SAAS,EACT,gBAAgB,EAChB,UAAU,EAIX,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAA;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAOpD,OAAO,EAAa,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAKtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/C,6EAA6E;AAC7E,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpD,6DAA6D;AAC7D,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,IAAI,CAAA;IACV,mEAAmE;IACnE,EAAE,CAAC,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG;IACpC;;;OAGG;IACH,IAAI,CAAC,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;CAC7D,CAAA;AAED,+EAA+E;AAC/E,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,UAAU,GAAG;IACjE;;;;;OAKG;IACH,IAAI,CAAC,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC3D,kFAAkF;IAClF,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAA;CACnC,CAAA;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAGnD;AAED,kFAAkF;AAClF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,UAAU,CAa9E;AAyBD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAC5C,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,EACrB,QAAQ,EAAE,MAAM,GACf,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAiCvB"}
|
package/dist/dispatch/self.js
CHANGED
|
@@ -1,27 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Self resolution
|
|
3
|
-
*
|
|
4
|
-
* `_self` is a path reference to the node the non-static method runs on.
|
|
5
|
-
* `resolveSelf` is a thin PARSE: the caller's string becomes a `Path`, and
|
|
6
|
-
* handlers build recursive paths as `${self.path}::method` (the `Path`'s
|
|
7
|
-
* `toString` yields its raw form, so template literals work unchanged). It does
|
|
8
|
-
* NOT touch the graph — the whole dispatch pipeline (resolve → authenticate →
|
|
9
|
-
* validate → self → execute) reaches the handler without a single `Node::get`.
|
|
10
|
-
*
|
|
11
|
-
* `resolveSelf` receives the bare self target (`@<id>` or a tree path) — the
|
|
12
|
-
* method ref travels in a separate dispatch channel, so `::method` never
|
|
13
|
-
* reaches here. For the `@<id>` form the parsed `Path` is an `IdPath` which
|
|
14
|
-
* already carries the node id; surfacing it on `SelfResult.id` saves every
|
|
15
|
-
* worker handler from parsing `self.path.raw` by hand to recover the id of the
|
|
16
|
-
* node it is already operating on.
|
|
17
|
-
*
|
|
18
|
-
* `withNode` enriches the parsed self with the lazy `node()` accessor — the one
|
|
19
|
-
* place a handler can fetch its own node's full record (`{ id, class, props }`)
|
|
20
|
-
* without hand-rolling a `::get`. Construction stays split from parsing so
|
|
21
|
-
* `resolveSelf` remains pure and trivially testable; the dispatcher attaches the
|
|
22
|
-
* accessor once it holds the request's kernel.
|
|
2
|
+
* Self resolution stays parse-only: `_self` becomes a Path/IdPath with no graph
|
|
3
|
+
* read. The dispatcher later attaches lazy node()/call helpers once it has a kernel.
|
|
23
4
|
*/
|
|
24
|
-
import {
|
|
5
|
+
import { createInstanceProxy, defaultCaller, extractMethodsByType, } from '@astrale-os/kernel-client/schema';
|
|
6
|
+
import { IdPath, K, Path } from '@astrale-os/kernel-core';
|
|
25
7
|
import { classPathSchema } from '@astrale-os/kernel-core/domain';
|
|
26
8
|
import { absolutePathSchema } from '@astrale-os/kernel-core/tree';
|
|
27
9
|
import { z } from 'zod';
|
|
@@ -29,12 +11,7 @@ export function resolveSelf(ref) {
|
|
|
29
11
|
const path = Path.parse(ref);
|
|
30
12
|
return path instanceof IdPath ? { path, id: path.id } : { path };
|
|
31
13
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Attach the memoized `node()` accessor, binding it to the handler's kernel.
|
|
34
|
-
* `kernel` is `null` for methods whose auth policy yields none (`public`, or an
|
|
35
|
-
* unauthenticated `optional`) — there `node()` rejects with a clear error
|
|
36
|
-
* rather than reading the graph unauthenticated.
|
|
37
|
-
*/
|
|
14
|
+
/** Attach memoized node(); unauthenticated contexts reject instead of reading. */
|
|
38
15
|
export function withNode(parsed, kernel) {
|
|
39
16
|
let cached;
|
|
40
17
|
const node = (opts) => {
|
|
@@ -50,6 +27,49 @@ export function withNode(parsed, kernel) {
|
|
|
50
27
|
};
|
|
51
28
|
return { ...parsed, node };
|
|
52
29
|
}
|
|
30
|
+
const EMPTY_METHODS = { kind: 'class', methods: new Set() };
|
|
31
|
+
const methodMapCache = new WeakMap();
|
|
32
|
+
/** The type's method allow-list + kind, computed once per binder. */
|
|
33
|
+
function methodsFor(binder, typeName) {
|
|
34
|
+
let map = methodMapCache.get(binder);
|
|
35
|
+
if (!map) {
|
|
36
|
+
map = extractMethodsByType(binder.schema);
|
|
37
|
+
methodMapCache.set(binder, map);
|
|
38
|
+
}
|
|
39
|
+
return map.get(typeName) ?? EMPTY_METHODS;
|
|
40
|
+
}
|
|
41
|
+
function noKernelCaller(ref) {
|
|
42
|
+
return () => Promise.reject(new Error(`self.call needs an authenticated kernel to dispatch on "${ref}", but this method ran ` +
|
|
43
|
+
`without one (its auth policy yields no kernel — e.g. 'public').`));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Schema-typed self helper: lazy BoundNode plus address-only call proxy. With no
|
|
47
|
+
* kernel, both node() and call thunks fail loudly.
|
|
48
|
+
*/
|
|
49
|
+
export function withBoundNode(parsed, kernel, binder, typeName) {
|
|
50
|
+
const ctx = kernel
|
|
51
|
+
? { caller: defaultCaller(kernel), read: kernel }
|
|
52
|
+
: { caller: null, read: null };
|
|
53
|
+
let cached;
|
|
54
|
+
const node = (opts) => {
|
|
55
|
+
if (opts?.reload)
|
|
56
|
+
cached = undefined;
|
|
57
|
+
if (!cached) {
|
|
58
|
+
cached = fetchSelfNode(parsed.path, kernel)
|
|
59
|
+
.then((record) => binder.bind(typeName, record, ctx, {
|
|
60
|
+
validate: 'warn',
|
|
61
|
+
}))
|
|
62
|
+
.catch((err) => {
|
|
63
|
+
cached = undefined; // never cache a rejection — a later call may succeed
|
|
64
|
+
throw err;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return cached;
|
|
68
|
+
};
|
|
69
|
+
const info = methodsFor(binder, typeName);
|
|
70
|
+
const call = createInstanceProxy(ctx.caller ?? noKernelCaller(parsed.path.raw), parsed.path.raw, info.methods, info.kind === 'class' ? typeName : undefined);
|
|
71
|
+
return { ...parsed, node, call };
|
|
72
|
+
}
|
|
53
73
|
/**
|
|
54
74
|
* Boundary schema for a node record off the wire. Structurally identical to
|
|
55
75
|
* kernel-core's `nodeSchema`, re-declared here from its public coercers
|
|
@@ -71,9 +91,19 @@ async function fetchSelfNode(path, kernel) {
|
|
|
71
91
|
`without one (its auth policy yields no kernel — e.g. 'public'). Read the node from a ` +
|
|
72
92
|
`method whose auth is 'required', or supply a credential.`);
|
|
73
93
|
}
|
|
74
|
-
|
|
94
|
+
// function.get soft-masks missing/unreadable roots; empty page means no self node.
|
|
95
|
+
const result = (await kernel.call(K.$.f('get').path.domain.raw, {
|
|
96
|
+
roots: [path.raw],
|
|
97
|
+
depth: 0,
|
|
98
|
+
}));
|
|
99
|
+
const first = result?.nodes?.[0];
|
|
100
|
+
if (first === undefined) {
|
|
101
|
+
throw new Error(`self.node(): "${path.raw}" was not found or is not visible to the caller ` +
|
|
102
|
+
`(function.get returned no node).`);
|
|
103
|
+
}
|
|
104
|
+
const record = nodeRecordSchema.parse(first);
|
|
75
105
|
if (record.id === undefined) {
|
|
76
|
-
throw new Error(`self.node(): "${path.raw}
|
|
106
|
+
throw new Error(`self.node(): "${path.raw}" returned a record with no id`);
|
|
77
107
|
}
|
|
78
108
|
// Validated at the wire boundary: id is now known-present, props are
|
|
79
109
|
// structurally checked. Bridge the parse output to the canonical `Node`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"self.js","sourceRoot":"","sources":["../../src/dispatch/self.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"self.js","sourceRoot":"","sources":["../../src/dispatch/self.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,oBAAoB,GACrB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAe,MAAM,yBAAyB,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM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AAE,CAAC,IAAI,CAAC,GAAG,CAAC;QACjB,KAAK,EAAE,CAAC;KACT,CAAC,CAED,CAAA;IACD,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;IAChC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,iBAAiB,IAAI,CAAC,GAAG,kDAAkD;YACzE,kCAAkC,CACrC,CAAA;IACH,CAAC;IACD,MAAM,MAAM,GAAG,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IAC5C,IAAI,MAAM,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,CAAC,GAAG,gCAAgC,CAAC,CAAA;IAC5E,CAAC;IACD,qEAAqE;IACrE,yEAAyE;IACzE,OAAO,EAAE,GAAG,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,EAAY,EAAsB,CAAA;AACnE,CAAC"}
|
|
@@ -1 +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;
|
|
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;AAMpD,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,CAkBX;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"}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* relative path into its host-graph absolute form. Wire serialization is the
|
|
17
17
|
* caller's responsibility (`graph.toWire()`).
|
|
18
18
|
*/
|
|
19
|
+
import { AbsolutePath } from '@astrale-os/kernel-core';
|
|
19
20
|
import { hashInstallGraph, serialize, zodToJsonSchema } from '@astrale-os/kernel-core/domain';
|
|
20
21
|
import { extractBinding } from './contract';
|
|
21
22
|
import { materializeRemoteDomain } from './define';
|
|
@@ -29,7 +30,15 @@ import { materializeRemoteDomain } from './define';
|
|
|
29
30
|
*/
|
|
30
31
|
export function buildInstallGraph(domain, url) {
|
|
31
32
|
const { compiled, auxiliary } = materializeRemoteDomain(domain, url);
|
|
32
|
-
|
|
33
|
+
// Two-axis placement: `parent` = the folder the Domain node physically lives
|
|
34
|
+
// under. `path` names the FULL node path (basename === origin);
|
|
35
|
+
// unset defaults to /domains/<origin> — the "/domains" placement policy lives
|
|
36
|
+
// HERE (the kernel default is Root → /<origin>). `mount` is deliberately NOT
|
|
37
|
+
// passed: installed_in + typed addresses stay root-mounted (kernel default).
|
|
38
|
+
const parent = domain.path
|
|
39
|
+
? AbsolutePath.parse(domain.path).parent()
|
|
40
|
+
: AbsolutePath.from('domains');
|
|
41
|
+
return buildSpecInternal(compiled, domain.methods, url, auxiliary?.functionSchemas ?? [], auxiliary?.viewSchemas ?? [], parent).toWire();
|
|
33
42
|
}
|
|
34
43
|
/**
|
|
35
44
|
* Content hash of the install graph. Delegates the canonical hash to kernel-core's
|
|
@@ -40,7 +49,7 @@ export function buildInstallGraphHash(domain, url) {
|
|
|
40
49
|
return hashInstallGraph(buildInstallGraph(domain, url));
|
|
41
50
|
}
|
|
42
51
|
// ── Internal ────────────────────────────────────────────────
|
|
43
|
-
function buildSpecInternal(compiled, methods, url, functionSchemas, viewSchemas) {
|
|
52
|
+
function buildSpecInternal(compiled, methods, url, functionSchemas, viewSchemas, parent) {
|
|
44
53
|
const serialized = serializeMethodsWithStubs(compiled, methods, url);
|
|
45
54
|
// Method impls + standalone-function-member impls travel in the same callable
|
|
46
55
|
// array (distinct refs: `class.X.method.y` vs `function.<slug>`); view-member
|
|
@@ -48,7 +57,10 @@ function buildSpecInternal(compiled, methods, url, functionSchemas, viewSchemas)
|
|
|
48
57
|
// view_for, View class). The serializer emits method nodes from the IR,
|
|
49
58
|
// function/view members from `compiled.$.refs.{functions,views}`, pulling each
|
|
50
59
|
// impl by ref.
|
|
51
|
-
const tree = serialize(compiled, [...serialized, ...functionSchemas], {
|
|
60
|
+
const tree = serialize(compiled, [...serialized, ...functionSchemas], {
|
|
61
|
+
views: viewSchemas,
|
|
62
|
+
parent,
|
|
63
|
+
});
|
|
52
64
|
return tree.toGraph();
|
|
53
65
|
}
|
|
54
66
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-spec.js","sourceRoot":"","sources":["../../src/domain/build-spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAK7F,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAElD;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAuB,EACvB,GAAW;IAEX,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,uBAAuB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpE,OAAO,iBAAiB,CACtB,Q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GAAG;gBACH,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC/B,YAAY,EAAE,EAAE;gBAChB,MAAM,EAAE,OAAO;gBACf,OAAO,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE;aAC5B,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,wBAAwB,CAC/B,MAAqC,EACrC,GAAW;IAEX,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC9C,OAAO;QACL,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,WAAW,EAAE,eAAe,CAAC,MAAM,CAAC,WAAW,CAAC;QAChD,YAAY,EAAE,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC;QAClD,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,SAAS;QACtC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE;KACvE,CAAA;AACH,CAAC"}
|
package/dist/domain/define.d.ts
CHANGED
|
@@ -1,24 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* `views` and `functions` entries become first-class DOMAIN MEMBERS: a `View` /
|
|
5
|
-
* `Function` node attached to the Domain via an `of_domain` edge (slug
|
|
6
|
-
* `view.<slug>` / `function.<slug>`), laid out at `/<origin>/{views,functions}/<slug>`.
|
|
7
|
-
* Their contract half (the member ref) threads through `compileDomain`; their
|
|
8
|
-
* impl/binding half threads through `serialize`. The same entries'
|
|
9
|
-
* `render` / `execute` handlers are mounted as Hono routes by
|
|
10
|
-
* `createRemoteServer` at `<url>/<viewsFolder|functionsFolder>/<slug>` (the route
|
|
11
|
-
* URL is decoupled from the graph layout). Slug = map key.
|
|
12
|
-
*
|
|
13
|
-
* The domain definition is deployment-agnostic: it carries NO serving url. The
|
|
14
|
-
* url is supplied late by the spec producer (`createRemoteServer({ url })` at
|
|
15
|
-
* runtime, the `astrale-domain` CLI offline) and stamped onto every `binding.remoteUrl`
|
|
16
|
-
* by `materializeRemoteDomain`. There is exactly one notion of `url` in the SDK
|
|
17
|
-
* — the worker serving URL, which is also `iss` and the binding base.
|
|
2
|
+
* Define a remote domain. Views/functions are first-class domain members; their
|
|
3
|
+
* serving URL is stamped later by spec producers and is also the worker issuer.
|
|
18
4
|
*/
|
|
19
5
|
import type { FunctionBinding } from '@astrale-os/kernel-api/routed';
|
|
20
6
|
import type { BoundMethod, CompiledDomain, FunctionSchema, ViewSchema } from '@astrale-os/kernel-core/domain';
|
|
21
7
|
import type { Core, Schema } from '@astrale-os/kernel-dsl';
|
|
8
|
+
import type { DomainManifest } from '../config/define-domain';
|
|
22
9
|
import type { AnyRemoteFunctionDef, ViewDef } from '../define';
|
|
23
10
|
import type { SchemaMethodsImpl } from '../method/class';
|
|
24
11
|
import type { AnyRemoteHandler } from '../method/single';
|
|
@@ -30,6 +17,10 @@ export type RemoteDomainConfig<S extends Schema, TDeps> = {
|
|
|
30
17
|
viewsFolder?: string;
|
|
31
18
|
remoteFunctions?: Record<string, AnyRemoteFunctionDef>;
|
|
32
19
|
functionsFolder?: string;
|
|
20
|
+
/** Presentation metadata for `/meta` (logo / entry view). Carried verbatim. */
|
|
21
|
+
manifest?: DomainManifest;
|
|
22
|
+
/** Physical tree path for the Domain node (absolute, e.g. `/domains/acme`); default `/domains/<origin>`. */
|
|
23
|
+
path?: string;
|
|
33
24
|
};
|
|
34
25
|
/** Effective bindings + folder layout + member schemas for auxiliary routes, resolved against `url`. */
|
|
35
26
|
export type AuxiliaryMetadata = {
|
|
@@ -44,19 +35,21 @@ export type AuxiliaryMetadata = {
|
|
|
44
35
|
viewSchemas: ViewSchema[];
|
|
45
36
|
};
|
|
46
37
|
export type RemoteDomain<S extends Schema = Schema> = {
|
|
47
|
-
/**
|
|
48
|
-
* Define-time compile: full domain STRUCTURE (classes, methods, and the
|
|
49
|
-
* view/function members' paths/names/refs — what identity, subs, and contract
|
|
50
|
-
* resolution need). It carries NO `binding` values: bindings derive from the
|
|
51
|
-
* serving url, which only the spec producers know — they call
|
|
52
|
-
* `materializeRemoteDomain(domain, url)` for the install-ready compile.
|
|
53
|
-
*/
|
|
38
|
+
/** Define-time compile has structure only; bindings are stamped at materialization. */
|
|
54
39
|
compiled: CompiledDomain<S>;
|
|
55
40
|
methods: BoundMethod<AnyRemoteHandler>[];
|
|
56
41
|
views?: Record<string, ViewDef<any>>;
|
|
57
42
|
remoteFunctions?: Record<string, AnyRemoteFunctionDef>;
|
|
43
|
+
/** Presentation metadata for `/meta` (logo / entry view); `createRemoteServer` stamps it. */
|
|
44
|
+
manifest?: DomainManifest;
|
|
58
45
|
/** The original config, so `materializeRemoteDomain` re-materializes from source. */
|
|
59
46
|
config: MaterializeInputs;
|
|
47
|
+
/**
|
|
48
|
+
* Physical tree path for the Domain node (absolute string, e.g. `/domains/acme`).
|
|
49
|
+
* Read by `buildInstallGraph` and passed to `serialize` as `treeMount`; unset =>
|
|
50
|
+
* `/domains/<origin>` (applied in build-spec). Addressing is unaffected.
|
|
51
|
+
*/
|
|
52
|
+
path?: string;
|
|
60
53
|
};
|
|
61
54
|
/** The defineRemoteDomain inputs `materializeRemoteDomain` needs to re-materialize. */
|
|
62
55
|
type MaterializeInputs = {
|
|
@@ -65,15 +58,7 @@ type MaterializeInputs = {
|
|
|
65
58
|
functionsFolder: string;
|
|
66
59
|
};
|
|
67
60
|
export declare function defineRemoteDomain<TDeps>(): <S extends Schema>(config: RemoteDomainConfig<S, TDeps>) => RemoteDomain<S>;
|
|
68
|
-
/**
|
|
69
|
-
* Materialize a `RemoteDomain` at its real serving `url`: re-compiles the domain
|
|
70
|
-
* and builds every member's url-stamped impl schema + binding, returning the
|
|
71
|
-
* binding maps the auxiliary routes mount from and the member schemas `serialize`
|
|
72
|
-
* emits from. Called by the only two spec producers — `createRemoteServer`
|
|
73
|
-
* (`config.url`) and the `astrale-domain` CLI. Returns the define-time `compiled`
|
|
74
|
-
* untouched when there is no aux to stamp. Pure, so safe to call repeatedly (and
|
|
75
|
-
* memoized per cold isolate by the callers).
|
|
76
|
-
*/
|
|
61
|
+
/** Materialize aux member bindings against the real serving URL. Pure and repeatable. */
|
|
77
62
|
export declare function materializeRemoteDomain<S extends Schema>(domain: RemoteDomain<S>, url: string): {
|
|
78
63
|
compiled: CompiledDomain<S>;
|
|
79
64
|
auxiliary: AuxiliaryMetadata | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../src/domain/define.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../src/domain/define.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,cAAc,EACd,UAAU,EACX,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAI1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AASxD,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,IAAI;IACxD,MAAM,EAAE,CAAC,CAAA;IACT,OAAO,EAAE,iBAAiB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;IACpC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC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AAED,uFAAuF;AACvF,KAAK,iBAAiB,GAAG;IACvB,QAAQ,CAAC,EAAE,IAAI,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,wBAAgB,kBAAkB,CAAC,KAAK,MACrB,CAAC,SAAS,MAAM,UAAU,kBAAkB,CAAC,CAAC,EAAE,KAAK,CAAC,KAAG,YAAY,CAAC,CAAC,CAAC,CAmC1F;AAED,yFAAyF;AACzF,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,EACtD,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EACvB,GAAG,EAAE,MAAM,GACV;IAAE,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAAC,SAAS,EAAE,iBAAiB,GAAG,SAAS,CAAA;CAAE,CAiC3E"}
|
package/dist/domain/define.js
CHANGED
|
@@ -1,32 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* `views` and `functions` entries become first-class DOMAIN MEMBERS: a `View` /
|
|
5
|
-
* `Function` node attached to the Domain via an `of_domain` edge (slug
|
|
6
|
-
* `view.<slug>` / `function.<slug>`), laid out at `/<origin>/{views,functions}/<slug>`.
|
|
7
|
-
* Their contract half (the member ref) threads through `compileDomain`; their
|
|
8
|
-
* impl/binding half threads through `serialize`. The same entries'
|
|
9
|
-
* `render` / `execute` handlers are mounted as Hono routes by
|
|
10
|
-
* `createRemoteServer` at `<url>/<viewsFolder|functionsFolder>/<slug>` (the route
|
|
11
|
-
* URL is decoupled from the graph layout). Slug = map key.
|
|
12
|
-
*
|
|
13
|
-
* The domain definition is deployment-agnostic: it carries NO serving url. The
|
|
14
|
-
* url is supplied late by the spec producer (`createRemoteServer({ url })` at
|
|
15
|
-
* runtime, the `astrale-domain` CLI offline) and stamped onto every `binding.remoteUrl`
|
|
16
|
-
* by `materializeRemoteDomain`. There is exactly one notion of `url` in the SDK
|
|
17
|
-
* — the worker serving URL, which is also `iss` and the binding base.
|
|
2
|
+
* Define a remote domain. Views/functions are first-class domain members; their
|
|
3
|
+
* serving URL is stamped later by spec producers and is also the worker issuer.
|
|
18
4
|
*/
|
|
19
5
|
import { bindMethods, compileDomain } from '@astrale-os/kernel-core/domain';
|
|
20
|
-
import {
|
|
6
|
+
import { assertFunctionsMatchSchema, buildFunctionSchemas, DEFAULT_FUNCTIONS_FOLDER, } from './extend-functions';
|
|
21
7
|
import { buildViewDeclarations, buildViewSchemas, DEFAULT_VIEWS_FOLDER } from './extend-views';
|
|
22
8
|
export function defineRemoteDomain() {
|
|
23
9
|
return function (config) {
|
|
24
10
|
const viewsFolder = config.viewsFolder ?? DEFAULT_VIEWS_FOLDER;
|
|
25
11
|
const functionsFolder = config.functionsFolder ?? DEFAULT_FUNCTIONS_FOLDER;
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
//
|
|
29
|
-
|
|
12
|
+
// Standalone function handlers must match schema-declared function members.
|
|
13
|
+
assertFunctionsMatchSchema(config.schema, config.remoteFunctions);
|
|
14
|
+
// Standalone function handlers must match schema-declared function members.
|
|
15
|
+
assertFunctionsMatchSchema(config.schema, config.remoteFunctions);
|
|
16
|
+
const compiled = compileDomain(config.schema, config.core, undefined, config.views ? buildViewDeclarations(config.views) : undefined);
|
|
30
17
|
const methods = bindMethods(compiled.$.schema, compiled.$.methods,
|
|
31
18
|
// oxlint-disable-next-line no-explicit-any
|
|
32
19
|
config.methods);
|
|
@@ -35,6 +22,8 @@ export function defineRemoteDomain() {
|
|
|
35
22
|
methods,
|
|
36
23
|
...(config.views ? { views: config.views } : {}),
|
|
37
24
|
...(config.remoteFunctions ? { remoteFunctions: config.remoteFunctions } : {}),
|
|
25
|
+
...(config.manifest ? { manifest: config.manifest } : {}),
|
|
26
|
+
...(config.path ? { path: config.path } : {}),
|
|
38
27
|
config: {
|
|
39
28
|
userCore: config.core,
|
|
40
29
|
viewsFolder,
|
|
@@ -43,22 +32,14 @@ export function defineRemoteDomain() {
|
|
|
43
32
|
});
|
|
44
33
|
};
|
|
45
34
|
}
|
|
46
|
-
/**
|
|
47
|
-
* Materialize a `RemoteDomain` at its real serving `url`: re-compiles the domain
|
|
48
|
-
* and builds every member's url-stamped impl schema + binding, returning the
|
|
49
|
-
* binding maps the auxiliary routes mount from and the member schemas `serialize`
|
|
50
|
-
* emits from. Called by the only two spec producers — `createRemoteServer`
|
|
51
|
-
* (`config.url`) and the `astrale-domain` CLI. Returns the define-time `compiled`
|
|
52
|
-
* untouched when there is no aux to stamp. Pure, so safe to call repeatedly (and
|
|
53
|
-
* memoized per cold isolate by the callers).
|
|
54
|
-
*/
|
|
35
|
+
/** Materialize aux member bindings against the real serving URL. Pure and repeatable. */
|
|
55
36
|
export function materializeRemoteDomain(domain, url) {
|
|
56
37
|
const hasAux = Boolean(domain.views || domain.remoteFunctions);
|
|
57
38
|
if (!hasAux)
|
|
58
39
|
return { compiled: domain.compiled, auxiliary: undefined };
|
|
59
40
|
const { config } = domain;
|
|
60
41
|
const schema = domain.compiled.$.schema;
|
|
61
|
-
const compiled = compileDomain(schema, config.userCore, undefined, domain.
|
|
42
|
+
const compiled = compileDomain(schema, config.userCore, undefined, domain.views ? buildViewDeclarations(domain.views) : undefined);
|
|
62
43
|
const fns = domain.remoteFunctions
|
|
63
44
|
? buildFunctionSchemas(domain.remoteFunctions, url, config.functionsFolder)
|
|
64
45
|
: { schemas: [], bindings: {} };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.js","sourceRoot":"","sources":["../../src/domain/define.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../../src/domain/define.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAO3E,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,oBAAoB,CAAA;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,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;IAEjC,OAAO;QACL,QAAQ;QACR,SAAS,EAAE;YACT,GAAG;YACH,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,YAAY,EAAE,GAAG,CAAC,QAAQ;YAC1B,sBAAsB,EAAE,GAAG,CAAC,QAAQ;YACpC,eAAe,EAAE,GAAG,CAAC,OAAO;YAC5B,WAAW,EAAE,GAAG,CAAC,OAAO;SACzB;KACF,CAAA;AACH,CAAC"}
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
* halves a standalone-function DOMAIN MEMBER contributes — mirroring how a class
|
|
4
4
|
* method splits across compile + serialize:
|
|
5
5
|
*
|
|
6
|
-
* -
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* from the map key; the kernel owns that mapping.
|
|
6
|
+
* - the CONTRACT half — a `func({ input, output })` per slug, declared in the
|
|
7
|
+
* schema's `functions` group so the compiled domain carries `function.<slug>`
|
|
8
|
+
* on `refs.functions` (the kernel owns the ref/layout/of_domain mapping).
|
|
10
9
|
* - `FunctionSchema[]` + per-slug `FunctionBinding` — the IMPL/BINDING half,
|
|
11
10
|
* fed to `serialize` (url-stamped). The worker route is
|
|
12
11
|
* `<url>/<functionsFolder>/<slug>`, DECOUPLED from the graph layout — so
|
|
@@ -17,7 +16,8 @@
|
|
|
17
16
|
* touches `Core`.
|
|
18
17
|
*/
|
|
19
18
|
import type { FunctionBinding } from '@astrale-os/kernel-api/routed';
|
|
20
|
-
import type {
|
|
19
|
+
import type { FunctionSchema } from '@astrale-os/kernel-core/domain';
|
|
20
|
+
import type { Schema } from '@astrale-os/kernel-dsl';
|
|
21
21
|
import type { AnyRemoteFunctionDef } from '../define/remote-function';
|
|
22
22
|
/**
|
|
23
23
|
* Default URL segment for a function's worker route (`<url>/functions/<slug>`).
|
|
@@ -26,11 +26,15 @@ import type { AnyRemoteFunctionDef } from '../define/remote-function';
|
|
|
26
26
|
*/
|
|
27
27
|
export declare const DEFAULT_FUNCTIONS_FOLDER = "functions";
|
|
28
28
|
/**
|
|
29
|
-
* Contract half —
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* Contract half — since "functions as first-class defineSchema members", a
|
|
30
|
+
* standalone function's CONTRACT is declared in the SCHEMA (`defineSchema(...,
|
|
31
|
+
* { functions: { seed: func({ input, output }) } })`) and `compileDomain` builds
|
|
32
|
+
* the member refs from it; the SDK map supplies the HANDLER half. This check
|
|
33
|
+
* pins the two halves together at define time: every schema-declared function
|
|
34
|
+
* needs a handler, every handler a declaration — a drifted key fails loudly at
|
|
35
|
+
* authoring, never as a boot-time missing-identity or a dangling graph member.
|
|
32
36
|
*/
|
|
33
|
-
export declare function
|
|
37
|
+
export declare function assertFunctionsMatchSchema(schema: Schema, functions: Record<string, AnyRemoteFunctionDef> | undefined): void;
|
|
34
38
|
/**
|
|
35
39
|
* Impl/binding half — `FunctionSchema[]` for `serialize` plus the per-slug
|
|
36
40
|
* `FunctionBinding` map the worker mounts routes from. `ref` is the canonical
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extend-functions.d.ts","sourceRoot":"","sources":["../../src/domain/extend-functions.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"extend-functions.d.ts","sourceRoot":"","sources":["../../src/domain/extend-functions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAIpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAIrE;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,cAAc,CAAA;AAanD;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,GAAG,SAAS,GAC1D,IAAI,CAoBN;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAC/C,GAAG,EAAE,MAAM,EACX,eAAe,EAAE,MAAM,GACtB;IAAE,OAAO,EAAE,cAAc,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CAAE,CAe1E"}
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
* halves a standalone-function DOMAIN MEMBER contributes — mirroring how a class
|
|
4
4
|
* method splits across compile + serialize:
|
|
5
5
|
*
|
|
6
|
-
* -
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* from the map key; the kernel owns that mapping.
|
|
6
|
+
* - the CONTRACT half — a `func({ input, output })` per slug, declared in the
|
|
7
|
+
* schema's `functions` group so the compiled domain carries `function.<slug>`
|
|
8
|
+
* on `refs.functions` (the kernel owns the ref/layout/of_domain mapping).
|
|
10
9
|
* - `FunctionSchema[]` + per-slug `FunctionBinding` — the IMPL/BINDING half,
|
|
11
10
|
* fed to `serialize` (url-stamped). The worker route is
|
|
12
11
|
* `<url>/<functionsFolder>/<slug>`, DECOUPLED from the graph layout — so
|
|
@@ -33,16 +32,32 @@ function assertValidSlugs(functions) {
|
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
/**
|
|
36
|
-
* Contract half —
|
|
37
|
-
*
|
|
38
|
-
*
|
|
35
|
+
* Contract half — since "functions as first-class defineSchema members", a
|
|
36
|
+
* standalone function's CONTRACT is declared in the SCHEMA (`defineSchema(...,
|
|
37
|
+
* { functions: { seed: func({ input, output }) } })`) and `compileDomain` builds
|
|
38
|
+
* the member refs from it; the SDK map supplies the HANDLER half. This check
|
|
39
|
+
* pins the two halves together at define time: every schema-declared function
|
|
40
|
+
* needs a handler, every handler a declaration — a drifted key fails loudly at
|
|
41
|
+
* authoring, never as a boot-time missing-identity or a dangling graph member.
|
|
39
42
|
*/
|
|
40
|
-
export function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
export function assertFunctionsMatchSchema(schema, functions) {
|
|
44
|
+
if (functions)
|
|
45
|
+
assertValidSlugs(functions);
|
|
46
|
+
const declared = Object.keys(schema.functions ?? {});
|
|
47
|
+
const handled = Object.keys(functions ?? {});
|
|
48
|
+
const missingHandler = declared.filter((slug) => !handled.includes(slug));
|
|
49
|
+
const missingDecl = handled.filter((slug) => !declared.includes(slug));
|
|
50
|
+
if (missingHandler.length === 0 && missingDecl.length === 0)
|
|
51
|
+
return;
|
|
52
|
+
const parts = [];
|
|
53
|
+
if (missingHandler.length > 0) {
|
|
54
|
+
parts.push(`schema declares function(s) with no handler: ${missingHandler.map((s) => `"${s}"`).join(', ')}`);
|
|
55
|
+
}
|
|
56
|
+
if (missingDecl.length > 0) {
|
|
57
|
+
parts.push(`handler(s) with no schema declaration: ${missingDecl.map((s) => `"${s}"`).join(', ')} ` +
|
|
58
|
+
`(declare them in defineSchema's \`functions\` group via \`func({ input, output })\`)`);
|
|
59
|
+
}
|
|
60
|
+
throw new Error(`defineRemoteDomain: functions/schema mismatch — ${parts.join('; ')}.`);
|
|
46
61
|
}
|
|
47
62
|
/**
|
|
48
63
|
* Impl/binding half — `FunctionSchema[]` for `serialize` plus the per-slug
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extend-functions.js","sourceRoot":"","sources":["../../src/domain/extend-functions.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"extend-functions.js","sourceRoot":"","sources":["../../src/domain/extend-functions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,OAAO,EAAE,eAAe,EAAE,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