@astrale-os/sdk 0.1.10 → 0.3.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 +3 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +2 -1
- 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 -2
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +102 -111
- 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/adapter.d.ts +12 -11
- package/dist/config/adapter.d.ts.map +1 -1
- package/dist/config/adapter.js.map +1 -1
- package/dist/config/define-domain.d.ts +88 -27
- package/dist/config/define-domain.d.ts.map +1 -1
- package/dist/config/define-domain.js +79 -33
- package/dist/config/define-domain.js.map +1 -1
- package/dist/config/deploy.d.ts +1 -1
- package/dist/config/deploy.js +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 +32 -17
- package/dist/define/remote-function.d.ts.map +1 -1
- package/dist/define/remote-function.js +10 -9
- package/dist/define/remote-function.js.map +1 -1
- package/dist/define/view.d.ts +8 -6
- package/dist/define/view.d.ts.map +1 -1
- package/dist/define/view.js +8 -6
- package/dist/define/view.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 +12 -10
- package/dist/dispatch/identity.d.ts.map +1 -1
- package/dist/dispatch/identity.js +10 -15
- 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/binding.d.ts +18 -0
- package/dist/domain/binding.d.ts.map +1 -0
- package/dist/domain/binding.js +29 -0
- package/dist/domain/binding.js.map +1 -0
- package/dist/domain/build-spec.d.ts.map +1 -1
- package/dist/domain/build-spec.js +22 -7
- package/dist/domain/build-spec.js.map +1 -1
- package/dist/domain/define.d.ts +28 -43
- package/dist/domain/define.d.ts.map +1 -1
- package/dist/domain/define.js +23 -60
- package/dist/domain/define.js.map +1 -1
- package/dist/domain/extend-functions.d.ts +48 -0
- package/dist/domain/extend-functions.d.ts.map +1 -0
- package/dist/domain/extend-functions.js +84 -0
- package/dist/domain/extend-functions.js.map +1 -0
- package/dist/domain/extend-views.d.ts +45 -0
- package/dist/domain/extend-views.d.ts.map +1 -0
- package/dist/domain/extend-views.js +116 -0
- package/dist/domain/extend-views.js.map +1 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -5
- 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 +14 -3
- 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/dist/server/worker-entry.d.ts +3 -3
- package/dist/server/worker-entry.js +3 -3
- package/package.json +10 -11
- package/src/auth/check.ts +2 -6
- package/src/auth/index.ts +3 -1
- 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 +109 -125
- package/src/cli/spec.ts +1 -0
- package/src/config/adapter.ts +9 -11
- package/src/config/define-domain.ts +184 -53
- package/src/config/deploy.ts +1 -1
- package/src/config/index.ts +1 -1
- package/src/define/remote-function.ts +56 -21
- package/src/define/view.ts +8 -6
- 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 +17 -22
- package/src/dispatch/index.ts +1 -1
- package/src/dispatch/self.ts +117 -41
- package/src/domain/binding.ts +37 -0
- package/src/domain/build-spec.ts +32 -7
- package/src/domain/define.ts +71 -78
- package/src/domain/extend-functions.ts +106 -0
- package/src/domain/extend-views.ts +151 -0
- package/src/index.ts +36 -7
- 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 +14 -3
- package/src/server/create.ts +15 -51
- package/src/server/domain-entry.ts +12 -0
- package/src/server/index.ts +0 -1
- package/src/server/worker-entry.ts +3 -3
- package/src/deploy/hash-spec.ts +0 -31
- package/src/domain/extend-core.ts +0 -301
- package/src/server/worker-meta.ts +0 -25
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,gCAAgC,CAAA;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAmCvB,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;AAED,kFAAkF;AAClF,MAAM,UAAU,QAAQ,CAAC,MAAkB,EAAE,MAAqB;IAChE,IAAI,MAA6C,CAAA;IACjD,MAAM,IAAI,GAAG,CAAC,IAA2B,EAA6B,EAAE;QACtE,IAAI,IAAI,EAAE,MAAM;YAAE,MAAM,GAAG,SAAS,CAAA;QACpC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,KAAK,CA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auto-materialized members (functions + views).
|
|
3
|
+
*
|
|
4
|
+
* The worker ROUTE URL a member is served at — `<url>/<folderSlug>/<slug>` — is
|
|
5
|
+
* decoupled from the member's GRAPH layout (`/<origin>/{functions,views}/<slug>`,
|
|
6
|
+
* a fixed kernel convention). `folderSlug` names only the URL segment.
|
|
7
|
+
*/
|
|
8
|
+
import type { FunctionBinding } from '@astrale-os/kernel-api/routed';
|
|
9
|
+
/** Join a worker-relative mount path onto the serving url (single slash). */
|
|
10
|
+
export declare function joinWorkerPath(url: string, mount: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Resolve a member's effective binding against the serving `url`. An explicit
|
|
13
|
+
* `override.remoteUrl` wins; otherwise defaults to `<url>/<folderSlug>/<slug>`.
|
|
14
|
+
* Same trailing-slash discipline as {@link joinWorkerPath} — a `url` ending in
|
|
15
|
+
* `/` must not produce `//` (the kernel pins `iss` by exact string).
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveBinding(override: FunctionBinding | undefined, url: string, folderSlug: string, slug: string): FunctionBinding;
|
|
18
|
+
//# sourceMappingURL=binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../../src/domain/binding.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAEpE,6EAA6E;AAC7E,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAGjE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,eAAe,GAAG,SAAS,EACrC,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,GACX,eAAe,CASjB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared binding helpers for auto-materialized members (functions + views).
|
|
3
|
+
*
|
|
4
|
+
* The worker ROUTE URL a member is served at — `<url>/<folderSlug>/<slug>` — is
|
|
5
|
+
* decoupled from the member's GRAPH layout (`/<origin>/{functions,views}/<slug>`,
|
|
6
|
+
* a fixed kernel convention). `folderSlug` names only the URL segment.
|
|
7
|
+
*/
|
|
8
|
+
/** Join a worker-relative mount path onto the serving url (single slash). */
|
|
9
|
+
export function joinWorkerPath(url, mount) {
|
|
10
|
+
const base = url.replace(/\/+$/, '');
|
|
11
|
+
return `${base}/${mount.replace(/^\/+/, '')}`;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Resolve a member's effective binding against the serving `url`. An explicit
|
|
15
|
+
* `override.remoteUrl` wins; otherwise defaults to `<url>/<folderSlug>/<slug>`.
|
|
16
|
+
* Same trailing-slash discipline as {@link joinWorkerPath} — a `url` ending in
|
|
17
|
+
* `/` must not produce `//` (the kernel pins `iss` by exact string).
|
|
18
|
+
*/
|
|
19
|
+
export function resolveBinding(override, url, folderSlug, slug) {
|
|
20
|
+
const base = url.replace(/\/+$/, '');
|
|
21
|
+
if (override) {
|
|
22
|
+
return {
|
|
23
|
+
...override,
|
|
24
|
+
remoteUrl: override.remoteUrl ?? `${base}/${folderSlug}/${slug}`,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return { remoteUrl: `${base}/${folderSlug}/${slug}` };
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=binding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding.js","sourceRoot":"","sources":["../../src/domain/binding.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,6EAA6E;AAC7E,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,KAAa;IACvD,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IACpC,OAAO,GAAG,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAA;AAC/C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,QAAqC,EACrC,GAAW,EACX,UAAkB,EAClB,IAAY;IAEZ,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IACpC,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO;YACL,GAAG,QAAQ;YACX,SAAS,EAAE,QAAQ,CAAC,SAAS,IAAI,GAAG,IAAI,IAAI,UAAU,IAAI,IAAI,EAAE;SACjE,CAAA;IACH,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,IAAI,UAAU,IAAI,IAAI,EAAE,EAAE,CAAA;AACvD,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';
|
|
@@ -28,8 +29,16 @@ import { materializeRemoteDomain } from './define';
|
|
|
28
29
|
* kernel install guard rejects it).
|
|
29
30
|
*/
|
|
30
31
|
export function buildInstallGraph(domain, url) {
|
|
31
|
-
const { compiled } = materializeRemoteDomain(domain, url);
|
|
32
|
-
|
|
32
|
+
const { compiled, auxiliary } = materializeRemoteDomain(domain, url);
|
|
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,12 +49,18 @@ export function buildInstallGraphHash(domain, url) {
|
|
|
40
49
|
return hashInstallGraph(buildInstallGraph(domain, url));
|
|
41
50
|
}
|
|
42
51
|
// ── Internal ────────────────────────────────────────────────
|
|
43
|
-
function buildSpecInternal(compiled, methods, url) {
|
|
52
|
+
function buildSpecInternal(compiled, methods, url, functionSchemas, viewSchemas, parent) {
|
|
44
53
|
const serialized = serializeMethodsWithStubs(compiled, methods, url);
|
|
45
|
-
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
54
|
+
// Method impls + standalone-function-member impls travel in the same callable
|
|
55
|
+
// array (distinct refs: `class.X.method.y` vs `function.<slug>`); view-member
|
|
56
|
+
// impls travel in `options.views` (a view differs structurally — handshake,
|
|
57
|
+
// view_for, View class). The serializer emits method nodes from the IR,
|
|
58
|
+
// function/view members from `compiled.$.refs.{functions,views}`, pulling each
|
|
59
|
+
// impl by ref.
|
|
60
|
+
const tree = serialize(compiled, [...serialized, ...functionSchemas], {
|
|
61
|
+
views: viewSchemas,
|
|
62
|
+
parent,
|
|
63
|
+
});
|
|
49
64
|
return tree.toGraph();
|
|
50
65
|
}
|
|
51
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,GAAG,uBAAuB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"build-spec.js","sourceRoot":"","sources":["../../src/domain/build-spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAE,gBA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AG,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
|
-
* When `views` and/or `remoteFunctions` entries are provided, the SDK
|
|
5
|
-
* auto-materializes graph nodes
|
|
6
|
-
* under reserved folders (`viewsFolder` / `functionsFolder`, defaults `'views'`
|
|
7
|
-
* / `'functions'`). Views and standalone functions materialize as canonical
|
|
8
|
-
* kernel `View` / `Function` classes by default (no per-domain class to
|
|
9
|
-
* configure). The same entries'
|
|
10
|
-
* `render` / `execute` handlers are mounted as Hono routes by
|
|
11
|
-
* `createRemoteServer`. 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
|
-
import type { BoundMethod, CompiledDomain } from '@astrale-os/kernel-core/domain';
|
|
21
|
-
import type {
|
|
6
|
+
import type { BoundMethod, CompiledDomain, FunctionSchema, ViewSchema } from '@astrale-os/kernel-core/domain';
|
|
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';
|
|
@@ -27,53 +14,51 @@ export type RemoteDomainConfig<S extends Schema, TDeps> = {
|
|
|
27
14
|
methods: SchemaMethodsImpl<S, TDeps>;
|
|
28
15
|
core?: Core<S>;
|
|
29
16
|
views?: Record<string, ViewDef<TDeps>>;
|
|
30
|
-
viewClass?: AnyNodeDef;
|
|
31
|
-
viewForEdgeClass?: AnyEdgeDef;
|
|
32
17
|
viewsFolder?: string;
|
|
33
18
|
remoteFunctions?: Record<string, AnyRemoteFunctionDef>;
|
|
34
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;
|
|
35
24
|
};
|
|
36
|
-
/** Effective bindings + folder layout for auxiliary routes, resolved against `url`. */
|
|
25
|
+
/** Effective bindings + folder layout + member schemas for auxiliary routes, resolved against `url`. */
|
|
37
26
|
export type AuxiliaryMetadata = {
|
|
38
27
|
url: string;
|
|
39
28
|
viewsFolder: string;
|
|
40
29
|
functionsFolder: string;
|
|
41
30
|
viewBindings: Record<string, FunctionBinding>;
|
|
42
31
|
remoteFunctionBindings: Record<string, FunctionBinding>;
|
|
32
|
+
/** Function members' impl/binding half (`function.<slug>`) for `serialize`. */
|
|
33
|
+
functionSchemas: FunctionSchema[];
|
|
34
|
+
/** View members' impl/binding half (`view.<slug>`) for `serialize`. */
|
|
35
|
+
viewSchemas: ViewSchema[];
|
|
43
36
|
};
|
|
44
37
|
export type RemoteDomain<S extends Schema = Schema> = {
|
|
45
|
-
/**
|
|
46
|
-
* Define-time compile: full domain STRUCTURE (classes, methods, and the aux
|
|
47
|
-
* View/Function nodes' paths/names/refs — what identity, subs, and contract
|
|
48
|
-
* resolution need). It carries NO `binding` values: bindings derive from the
|
|
49
|
-
* serving url, which only the spec producers know — they call
|
|
50
|
-
* `materializeRemoteDomain(domain, url)` for the install-ready compile.
|
|
51
|
-
*/
|
|
38
|
+
/** Define-time compile has structure only; bindings are stamped at materialization. */
|
|
52
39
|
compiled: CompiledDomain<S>;
|
|
53
40
|
methods: BoundMethod<AnyRemoteHandler>[];
|
|
54
41
|
views?: Record<string, ViewDef<any>>;
|
|
55
42
|
remoteFunctions?: Record<string, AnyRemoteFunctionDef>;
|
|
56
|
-
/**
|
|
57
|
-
|
|
43
|
+
/** Presentation metadata for `/meta` (logo / entry view); `createRemoteServer` stamps it. */
|
|
44
|
+
manifest?: DomainManifest;
|
|
45
|
+
/** The original config, so `materializeRemoteDomain` re-materializes from source. */
|
|
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;
|
|
58
53
|
};
|
|
59
|
-
/** The defineRemoteDomain inputs `materializeRemoteDomain` needs to re-
|
|
60
|
-
type
|
|
54
|
+
/** The defineRemoteDomain inputs `materializeRemoteDomain` needs to re-materialize. */
|
|
55
|
+
type MaterializeInputs = {
|
|
61
56
|
userCore?: Core;
|
|
62
|
-
viewClass?: AnyNodeDef;
|
|
63
|
-
viewForEdgeClass?: AnyEdgeDef;
|
|
64
57
|
viewsFolder: string;
|
|
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-runs `extendCore`
|
|
70
|
-
* so every aux View/Function `binding.remoteUrl` points at the actual host,
|
|
71
|
-
* and returns the binding maps the auxiliary routes mount from. Called by the
|
|
72
|
-
* only two spec producers — `createRemoteServer` (`config.url`) and the
|
|
73
|
-
* `astrale-domain` CLI. Returns the define-time `compiled` untouched when there is no aux to
|
|
74
|
-
* stamp. `extendCore`/`compileDomain` are pure, so this is safe to call
|
|
75
|
-
* repeatedly (and is 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,O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W,CAAC,gBAAgB,CAAC,EAAE,CAAA;IAExC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;IACpC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;IACtD,6FAA6F;IAC7F,QAAQ,CAAC,EAAE,cAAc,CAAA;IACzB,qFAAqF;IACrF,MAAM,EAAE,iBAAiB,CAAA;IACzB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;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,44 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* When `views` and/or `remoteFunctions` entries are provided, the SDK
|
|
5
|
-
* auto-materializes graph nodes
|
|
6
|
-
* under reserved folders (`viewsFolder` / `functionsFolder`, defaults `'views'`
|
|
7
|
-
* / `'functions'`). Views and standalone functions materialize as canonical
|
|
8
|
-
* kernel `View` / `Function` classes by default (no per-domain class to
|
|
9
|
-
* configure). The same entries'
|
|
10
|
-
* `render` / `execute` handlers are mounted as Hono routes by
|
|
11
|
-
* `createRemoteServer`. 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';
|
|
7
|
+
import { buildViewDeclarations, buildViewSchemas, DEFAULT_VIEWS_FOLDER } from './extend-views';
|
|
21
8
|
export function defineRemoteDomain() {
|
|
22
9
|
return function (config) {
|
|
23
|
-
const hasAux = Boolean(config.views || config.remoteFunctions);
|
|
24
10
|
const viewsFolder = config.viewsFolder ?? DEFAULT_VIEWS_FOLDER;
|
|
25
11
|
const functionsFolder = config.functionsFolder ?? DEFAULT_FUNCTIONS_FOLDER;
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
origin: config.schema.domain,
|
|
32
|
-
userCore: config.core,
|
|
33
|
-
viewClass: config.viewClass,
|
|
34
|
-
viewForEdgeClass: config.viewForEdgeClass,
|
|
35
|
-
viewsFolder,
|
|
36
|
-
views: config.views,
|
|
37
|
-
functionsFolder,
|
|
38
|
-
remoteFunctions: config.remoteFunctions,
|
|
39
|
-
}).core
|
|
40
|
-
: config.core;
|
|
41
|
-
const compiled = compileDomain(config.schema, effectiveCore);
|
|
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);
|
|
42
17
|
const methods = bindMethods(compiled.$.schema, compiled.$.methods,
|
|
43
18
|
// oxlint-disable-next-line no-explicit-any
|
|
44
19
|
config.methods);
|
|
@@ -47,52 +22,40 @@ export function defineRemoteDomain() {
|
|
|
47
22
|
methods,
|
|
48
23
|
...(config.views ? { views: config.views } : {}),
|
|
49
24
|
...(config.remoteFunctions ? { remoteFunctions: config.remoteFunctions } : {}),
|
|
25
|
+
...(config.manifest ? { manifest: config.manifest } : {}),
|
|
26
|
+
...(config.path ? { path: config.path } : {}),
|
|
50
27
|
config: {
|
|
51
28
|
userCore: config.core,
|
|
52
|
-
viewClass: config.viewClass,
|
|
53
|
-
viewForEdgeClass: config.viewForEdgeClass,
|
|
54
29
|
viewsFolder,
|
|
55
30
|
functionsFolder,
|
|
56
31
|
},
|
|
57
32
|
});
|
|
58
33
|
};
|
|
59
34
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Materialize a `RemoteDomain` at its real serving `url`: re-runs `extendCore`
|
|
62
|
-
* so every aux View/Function `binding.remoteUrl` points at the actual host,
|
|
63
|
-
* and returns the binding maps the auxiliary routes mount from. Called by the
|
|
64
|
-
* only two spec producers — `createRemoteServer` (`config.url`) and the
|
|
65
|
-
* `astrale-domain` CLI. Returns the define-time `compiled` untouched when there is no aux to
|
|
66
|
-
* stamp. `extendCore`/`compileDomain` are pure, so this is safe to call
|
|
67
|
-
* repeatedly (and is memoized per cold isolate by the callers).
|
|
68
|
-
*/
|
|
35
|
+
/** Materialize aux member bindings against the real serving URL. Pure and repeatable. */
|
|
69
36
|
export function materializeRemoteDomain(domain, url) {
|
|
70
37
|
const hasAux = Boolean(domain.views || domain.remoteFunctions);
|
|
71
38
|
if (!hasAux)
|
|
72
39
|
return { compiled: domain.compiled, auxiliary: undefined };
|
|
73
40
|
const { config } = domain;
|
|
74
41
|
const schema = domain.compiled.$.schema;
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
viewsFolder: config.viewsFolder,
|
|
83
|
-
views: domain.views,
|
|
84
|
-
functionsFolder: config.functionsFolder,
|
|
85
|
-
remoteFunctions: domain.remoteFunctions,
|
|
86
|
-
});
|
|
87
|
-
const compiled = compileDomain(schema, result.core);
|
|
42
|
+
const compiled = compileDomain(schema, config.userCore, undefined, domain.views ? buildViewDeclarations(domain.views) : undefined);
|
|
43
|
+
const fns = domain.remoteFunctions
|
|
44
|
+
? buildFunctionSchemas(domain.remoteFunctions, url, config.functionsFolder)
|
|
45
|
+
: { schemas: [], bindings: {} };
|
|
46
|
+
const vws = domain.views
|
|
47
|
+
? buildViewSchemas(domain.views, url, config.viewsFolder, schema)
|
|
48
|
+
: { schemas: [], bindings: {} };
|
|
88
49
|
return {
|
|
89
50
|
compiled,
|
|
90
51
|
auxiliary: {
|
|
91
52
|
url,
|
|
92
53
|
viewsFolder: config.viewsFolder,
|
|
93
54
|
functionsFolder: config.functionsFolder,
|
|
94
|
-
viewBindings:
|
|
95
|
-
remoteFunctionBindings:
|
|
55
|
+
viewBindings: vws.bindings,
|
|
56
|
+
remoteFunctionBindings: fns.bindings,
|
|
57
|
+
functionSchemas: fns.schemas,
|
|
58
|
+
viewSchemas: vws.schemas,
|
|
96
59
|
},
|
|
97
60
|
};
|
|
98
61
|
}
|
|
@@ -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,EAA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G,MAAM,CAAC,KAAK;QACtB,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC;QACjE,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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Materialize the `functions` map (`defineRemoteFunction` entries) into the two
|
|
3
|
+
* halves a standalone-function DOMAIN MEMBER contributes — mirroring how a class
|
|
4
|
+
* method splits across compile + serialize:
|
|
5
|
+
*
|
|
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).
|
|
9
|
+
* - `FunctionSchema[]` + per-slug `FunctionBinding` — the IMPL/BINDING half,
|
|
10
|
+
* fed to `serialize` (url-stamped). The worker route is
|
|
11
|
+
* `<url>/<functionsFolder>/<slug>`, DECOUPLED from the graph layout — so
|
|
12
|
+
* `functionsFolder` only names the URL segment, not the node position.
|
|
13
|
+
*
|
|
14
|
+
* A standalone function is NOT a core/instance node: it is attached directly to
|
|
15
|
+
* the Domain via `of_domain` by the kernel-core serializer, so this module never
|
|
16
|
+
* touches `Core`.
|
|
17
|
+
*/
|
|
18
|
+
import type { FunctionBinding } from '@astrale-os/kernel-api/routed';
|
|
19
|
+
import type { FunctionSchema } from '@astrale-os/kernel-core/domain';
|
|
20
|
+
import type { Schema } from '@astrale-os/kernel-dsl';
|
|
21
|
+
import type { AnyRemoteFunctionDef } from '../define/remote-function';
|
|
22
|
+
/**
|
|
23
|
+
* Default URL segment for a function's worker route (`<url>/functions/<slug>`).
|
|
24
|
+
* Names the HTTP route only — the graph layout (`/<origin>/functions/<slug>`) is
|
|
25
|
+
* a fixed kernel convention, independent of this.
|
|
26
|
+
*/
|
|
27
|
+
export declare const DEFAULT_FUNCTIONS_FOLDER = "functions";
|
|
28
|
+
/**
|
|
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.
|
|
36
|
+
*/
|
|
37
|
+
export declare function assertFunctionsMatchSchema(schema: Schema, functions: Record<string, AnyRemoteFunctionDef> | undefined): void;
|
|
38
|
+
/**
|
|
39
|
+
* Impl/binding half — `FunctionSchema[]` for `serialize` plus the per-slug
|
|
40
|
+
* `FunctionBinding` map the worker mounts routes from. `ref` is the canonical
|
|
41
|
+
* `function.<slug>` member ref (matching `compiled.$.refs.functions`), so the
|
|
42
|
+
* serializer's per-member impl lookup finds it.
|
|
43
|
+
*/
|
|
44
|
+
export declare function buildFunctionSchemas(functions: Record<string, AnyRemoteFunctionDef>, url: string, functionsFolder: string): {
|
|
45
|
+
schemas: FunctionSchema[];
|
|
46
|
+
bindings: Record<string, FunctionBinding>;
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=extend-functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|