@astrale-os/kernel-client 0.2.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/dist/client/batch.d.ts +26 -0
- package/dist/client/batch.d.ts.map +1 -0
- package/dist/client/batch.js +8 -0
- package/dist/client/batch.js.map +1 -0
- package/dist/client/bound.d.ts +27 -0
- package/dist/client/bound.d.ts.map +1 -0
- package/dist/client/bound.js +14 -0
- package/dist/client/bound.js.map +1 -0
- package/dist/client/client.d.ts +93 -0
- package/dist/client/client.d.ts.map +1 -0
- package/dist/client/client.js +393 -0
- package/dist/client/client.js.map +1 -0
- package/dist/client/config.d.ts +112 -0
- package/dist/client/config.d.ts.map +1 -0
- package/dist/client/config.js +10 -0
- package/dist/client/config.js.map +1 -0
- package/dist/client/fn-map.d.ts +61 -0
- package/dist/client/fn-map.d.ts.map +1 -0
- package/dist/client/fn-map.js +2 -0
- package/dist/client/fn-map.js.map +1 -0
- package/dist/client/freeze.d.ts +32 -0
- package/dist/client/freeze.d.ts.map +1 -0
- package/dist/client/freeze.js +42 -0
- package/dist/client/freeze.js.map +1 -0
- package/dist/client/hooks.d.ts +49 -0
- package/dist/client/hooks.d.ts.map +1 -0
- package/dist/client/hooks.js +2 -0
- package/dist/client/hooks.js.map +1 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +2 -0
- package/dist/client/index.js.map +1 -0
- package/dist/delegation/cache.d.ts +133 -0
- package/dist/delegation/cache.d.ts.map +1 -0
- package/dist/delegation/cache.js +258 -0
- package/dist/delegation/cache.js.map +1 -0
- package/dist/delegation/errors.d.ts +44 -0
- package/dist/delegation/errors.d.ts.map +1 -0
- package/dist/delegation/errors.js +62 -0
- package/dist/delegation/errors.js.map +1 -0
- package/dist/delegation/index.d.ts +6 -0
- package/dist/delegation/index.d.ts.map +1 -0
- package/dist/delegation/index.js +4 -0
- package/dist/delegation/index.js.map +1 -0
- package/dist/delegation/policy.d.ts +175 -0
- package/dist/delegation/policy.d.ts.map +1 -0
- package/dist/delegation/policy.js +109 -0
- package/dist/delegation/policy.js.map +1 -0
- package/dist/errors/errors.d.ts +103 -0
- package/dist/errors/errors.d.ts.map +1 -0
- package/dist/errors/errors.js +170 -0
- package/dist/errors/errors.js.map +1 -0
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +3 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/session-error.d.ts +21 -0
- package/dist/errors/session-error.d.ts.map +1 -0
- package/dist/errors/session-error.js +25 -0
- package/dist/errors/session-error.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/pacer/batcher.d.ts +11 -0
- package/dist/pacer/batcher.d.ts.map +1 -0
- package/dist/pacer/batcher.js +15 -0
- package/dist/pacer/batcher.js.map +1 -0
- package/dist/pacer/defaults.d.ts +18 -0
- package/dist/pacer/defaults.d.ts.map +1 -0
- package/dist/pacer/defaults.js +18 -0
- package/dist/pacer/defaults.js.map +1 -0
- package/dist/pacer/index.d.ts +10 -0
- package/dist/pacer/index.d.ts.map +1 -0
- package/dist/pacer/index.js +11 -0
- package/dist/pacer/index.js.map +1 -0
- package/dist/pacer/queue.d.ts +11 -0
- package/dist/pacer/queue.d.ts.map +1 -0
- package/dist/pacer/queue.js +15 -0
- package/dist/pacer/queue.js.map +1 -0
- package/dist/pacer/rate-limiter.d.ts +11 -0
- package/dist/pacer/rate-limiter.d.ts.map +1 -0
- package/dist/pacer/rate-limiter.js +15 -0
- package/dist/pacer/rate-limiter.js.map +1 -0
- package/dist/pacer/retry.d.ts +14 -0
- package/dist/pacer/retry.d.ts.map +1 -0
- package/dist/pacer/retry.js +50 -0
- package/dist/pacer/retry.js.map +1 -0
- package/dist/persistence/index.d.ts +3 -0
- package/dist/persistence/index.d.ts.map +1 -0
- package/dist/persistence/index.js +2 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/persistence/persistence.d.ts +52 -0
- package/dist/persistence/persistence.d.ts.map +1 -0
- package/dist/persistence/persistence.js +32 -0
- package/dist/persistence/persistence.js.map +1 -0
- package/dist/pool/errors.d.ts +13 -0
- package/dist/pool/errors.d.ts.map +1 -0
- package/dist/pool/errors.js +16 -0
- package/dist/pool/errors.js.map +1 -0
- package/dist/pool/index.d.ts +4 -0
- package/dist/pool/index.d.ts.map +1 -0
- package/dist/pool/index.js +3 -0
- package/dist/pool/index.js.map +1 -0
- package/dist/pool/pool.d.ts +63 -0
- package/dist/pool/pool.d.ts.map +1 -0
- package/dist/pool/pool.js +87 -0
- package/dist/pool/pool.js.map +1 -0
- package/dist/redirect/errors.d.ts +45 -0
- package/dist/redirect/errors.d.ts.map +1 -0
- package/dist/redirect/errors.js +52 -0
- package/dist/redirect/errors.js.map +1 -0
- package/dist/redirect/index.d.ts +4 -0
- package/dist/redirect/index.d.ts.map +1 -0
- package/dist/redirect/index.js +3 -0
- package/dist/redirect/index.js.map +1 -0
- package/dist/redirect/policy.d.ts +79 -0
- package/dist/redirect/policy.d.ts.map +1 -0
- package/dist/redirect/policy.js +69 -0
- package/dist/redirect/policy.js.map +1 -0
- package/dist/schema/call-args.d.ts +6 -0
- package/dist/schema/call-args.d.ts.map +1 -0
- package/dist/schema/call-args.js +21 -0
- package/dist/schema/call-args.js.map +1 -0
- package/dist/schema/class-proxy.d.ts +8 -0
- package/dist/schema/class-proxy.d.ts.map +1 -0
- package/dist/schema/class-proxy.js +38 -0
- package/dist/schema/class-proxy.js.map +1 -0
- package/dist/schema/extract.d.ts +9 -0
- package/dist/schema/extract.d.ts.map +1 -0
- package/dist/schema/extract.js +16 -0
- package/dist/schema/extract.js.map +1 -0
- package/dist/schema/from-entries.d.ts +12 -0
- package/dist/schema/from-entries.d.ts.map +1 -0
- package/dist/schema/from-entries.js +39 -0
- package/dist/schema/from-entries.js.map +1 -0
- package/dist/schema/index.d.ts +11 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +9 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/node-proxy.d.ts +9 -0
- package/dist/schema/node-proxy.d.ts.map +1 -0
- package/dist/schema/node-proxy.js +32 -0
- package/dist/schema/node-proxy.js.map +1 -0
- package/dist/schema/proxy-types.d.ts +112 -0
- package/dist/schema/proxy-types.d.ts.map +1 -0
- package/dist/schema/proxy-types.js +2 -0
- package/dist/schema/proxy-types.js.map +1 -0
- package/dist/schema/registry.d.ts +51 -0
- package/dist/schema/registry.d.ts.map +1 -0
- package/dist/schema/registry.js +111 -0
- package/dist/schema/registry.js.map +1 -0
- package/dist/schema/resolve.d.ts +26 -0
- package/dist/schema/resolve.d.ts.map +1 -0
- package/dist/schema/resolve.js +27 -0
- package/dist/schema/resolve.js.map +1 -0
- package/dist/schema/typed-client.d.ts +10 -0
- package/dist/schema/typed-client.d.ts.map +1 -0
- package/dist/schema/typed-client.js +26 -0
- package/dist/schema/typed-client.js.map +1 -0
- package/dist/schema/types.d.ts +9 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/types.js +2 -0
- package/dist/schema/types.js.map +1 -0
- package/dist/session/bound.d.ts +11 -0
- package/dist/session/bound.d.ts.map +1 -0
- package/dist/session/bound.js +24 -0
- package/dist/session/bound.js.map +1 -0
- package/dist/session/client-session.d.ts +61 -0
- package/dist/session/client-session.d.ts.map +1 -0
- package/dist/session/client-session.js +635 -0
- package/dist/session/client-session.js.map +1 -0
- package/dist/session/config.d.ts +157 -0
- package/dist/session/config.d.ts.map +1 -0
- package/dist/session/config.js +2 -0
- package/dist/session/config.js.map +1 -0
- package/dist/session/errors/index.d.ts +6 -0
- package/dist/session/errors/index.d.ts.map +1 -0
- package/dist/session/errors/index.js +8 -0
- package/dist/session/errors/index.js.map +1 -0
- package/dist/session/errors/session-errors.d.ts +52 -0
- package/dist/session/errors/session-errors.d.ts.map +1 -0
- package/dist/session/errors/session-errors.js +70 -0
- package/dist/session/errors/session-errors.js.map +1 -0
- package/dist/session/forward.d.ts +14 -0
- package/dist/session/forward.d.ts.map +1 -0
- package/dist/session/forward.js +44 -0
- package/dist/session/forward.js.map +1 -0
- package/dist/session/helpers.d.ts +23 -0
- package/dist/session/helpers.d.ts.map +1 -0
- package/dist/session/helpers.js +56 -0
- package/dist/session/helpers.js.map +1 -0
- package/dist/session/hooks.d.ts +140 -0
- package/dist/session/hooks.d.ts.map +1 -0
- package/dist/session/hooks.js +2 -0
- package/dist/session/hooks.js.map +1 -0
- package/dist/session/index.d.ts +6 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +3 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/types.d.ts +38 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +2 -0
- package/dist/session/types.js.map +1 -0
- package/dist/transport/binary.d.ts +15 -0
- package/dist/transport/binary.d.ts.map +1 -0
- package/dist/transport/binary.js +2 -0
- package/dist/transport/binary.js.map +1 -0
- package/dist/transport/contract.d.ts +58 -0
- package/dist/transport/contract.d.ts.map +1 -0
- package/dist/transport/contract.js +11 -0
- package/dist/transport/contract.js.map +1 -0
- package/dist/transport/fetch.d.ts +28 -0
- package/dist/transport/fetch.d.ts.map +1 -0
- package/dist/transport/fetch.js +74 -0
- package/dist/transport/fetch.js.map +1 -0
- package/dist/transport/http-envelope.d.ts +49 -0
- package/dist/transport/http-envelope.d.ts.map +1 -0
- package/dist/transport/http-envelope.js +405 -0
- package/dist/transport/http-envelope.js.map +1 -0
- package/dist/transport/http-routed.d.ts +61 -0
- package/dist/transport/http-routed.d.ts.map +1 -0
- package/dist/transport/http-routed.js +409 -0
- package/dist/transport/http-routed.js.map +1 -0
- package/dist/transport/index.d.ts +8 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/index.js +6 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/transport/request-id.d.ts +9 -0
- package/dist/transport/request-id.d.ts.map +1 -0
- package/dist/transport/request-id.js +12 -0
- package/dist/transport/request-id.js.map +1 -0
- package/dist/transport/ws-envelope.d.ts +74 -0
- package/dist/transport/ws-envelope.d.ts.map +1 -0
- package/dist/transport/ws-envelope.js +560 -0
- package/dist/transport/ws-envelope.js.map +1 -0
- package/dist/util/race-signal.d.ts +12 -0
- package/dist/util/race-signal.d.ts.map +1 -0
- package/dist/util/race-signal.js +34 -0
- package/dist/util/race-signal.js.map +1 -0
- package/dist/wire/controller.d.ts +38 -0
- package/dist/wire/controller.d.ts.map +1 -0
- package/dist/wire/controller.js +38 -0
- package/dist/wire/controller.js.map +1 -0
- package/dist/wire/index.d.ts +7 -0
- package/dist/wire/index.d.ts.map +1 -0
- package/dist/wire/index.js +4 -0
- package/dist/wire/index.js.map +1 -0
- package/dist/wire/meta.d.ts +81 -0
- package/dist/wire/meta.d.ts.map +1 -0
- package/dist/wire/meta.js +44 -0
- package/dist/wire/meta.js.map +1 -0
- package/dist/wire/sse.d.ts +67 -0
- package/dist/wire/sse.d.ts.map +1 -0
- package/dist/wire/sse.js +170 -0
- package/dist/wire/sse.js.map +1 -0
- package/package.json +104 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { CallRedirection } from '@astrale-os/kernel-api';
|
|
2
|
+
/**
|
|
3
|
+
* Hop record ClientSession threads through every policy call. Each entry is a
|
|
4
|
+
* URL the call dispatched to and the timestamp at which it was reached;
|
|
5
|
+
* the initial target is `hops[0]`, the current hop is `hops[hops.length-1]`.
|
|
6
|
+
*/
|
|
7
|
+
export type RedirectHop = {
|
|
8
|
+
url: string;
|
|
9
|
+
at: number;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Policy decision returned by `RedirectPolicy.decide`.
|
|
13
|
+
*
|
|
14
|
+
* `{ follow: true }` follows to `redirection.url`. `{ follow: false,
|
|
15
|
+
* reason }` causes ClientSession to throw `RedirectRefusedError(redirection,
|
|
16
|
+
* reason)`.
|
|
17
|
+
*/
|
|
18
|
+
export type RedirectDecision = {
|
|
19
|
+
follow: true;
|
|
20
|
+
} | {
|
|
21
|
+
follow: false;
|
|
22
|
+
reason: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Decision surface for ClientSession's redirect follow loop. Spec §9.4.
|
|
26
|
+
*
|
|
27
|
+
* Owns ONLY the follow/refuse decision and reason attribution. Does NOT
|
|
28
|
+
* own the follow loop (ClientSession does, §8.1), hop-cap enforcement (ClientSession
|
|
29
|
+
* checks before calling `decide`), audience derivation (that's
|
|
30
|
+
* `DelegationPolicy`, §9.3), or schema persistence (ClientSession sequences it).
|
|
31
|
+
*/
|
|
32
|
+
export interface RedirectPolicy {
|
|
33
|
+
/**
|
|
34
|
+
* Decide whether to follow. `signal` propagates the caller's abort —
|
|
35
|
+
* implementations that await UI input MUST race against it.
|
|
36
|
+
*/
|
|
37
|
+
decide(redirection: CallRedirection, hops: ReadonlyArray<RedirectHop>, correlationId: string, signal: AbortSignal | undefined): RedirectDecision | Promise<RedirectDecision>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Follow every redirect. Default when `ClientSessionConfig.redirect` is absent.
|
|
41
|
+
*
|
|
42
|
+
* Consumers who want to gate redirects on a URL allowlist use
|
|
43
|
+
* `allowlistPolicy`; consumers who want to prompt the user per hop use
|
|
44
|
+
* `promptPolicy`; consumers who want to refuse every redirect use
|
|
45
|
+
* `strictPolicy`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function allowAllPolicy(): RedirectPolicy;
|
|
48
|
+
/**
|
|
49
|
+
* Refuse every redirect. Opt-in — when a consumer wants cross-kernel
|
|
50
|
+
* follow blocked entirely and every redirect surfaced as a
|
|
51
|
+
* `RedirectRefusedError`.
|
|
52
|
+
*/
|
|
53
|
+
export declare function strictPolicy(): RedirectPolicy;
|
|
54
|
+
/**
|
|
55
|
+
* Follow only URLs that the `allow` predicate returns true for.
|
|
56
|
+
*
|
|
57
|
+
* ```ts
|
|
58
|
+
* allowlistPolicy({
|
|
59
|
+
* allow: (url) => new URL(url).host.endsWith('.trusted.kernel'),
|
|
60
|
+
* })
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function allowlistPolicy(opts: {
|
|
64
|
+
allow: (url: string) => boolean;
|
|
65
|
+
}): RedirectPolicy;
|
|
66
|
+
/**
|
|
67
|
+
* Ask the consumer for each redirect. The returned policy races the UI
|
|
68
|
+
* `onPrompt` call against the caller's `signal`, so aborting the
|
|
69
|
+
* top-level `session.call` cancels the prompt.
|
|
70
|
+
*
|
|
71
|
+
* `allow`, when provided, is a fast-path predicate that skips the
|
|
72
|
+
* prompt (for pre-approved URLs). Returning `false` from `allow` falls
|
|
73
|
+
* through to `onPrompt`.
|
|
74
|
+
*/
|
|
75
|
+
export declare function promptPolicy(opts: {
|
|
76
|
+
onPrompt: (redirection: CallRedirection, hops: ReadonlyArray<RedirectHop>) => Promise<boolean>;
|
|
77
|
+
allow?: (url: string) => boolean;
|
|
78
|
+
}): RedirectPolicy;
|
|
79
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/redirect/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAI7D;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AAErD;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAAE,MAAM,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnF;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,MAAM,CACJ,WAAW,EAAE,eAAe,EAC5B,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;CAChD;AAID;;;;;;;GAOG;AACH,wBAAgB,cAAc,IAAI,cAAc,CAI/C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,cAAc,CAI7C;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;CAAE,GAAG,cAAc,CAOzF;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE;IACjC,QAAQ,EAAE,CAAC,WAAW,EAAE,eAAe,EAAE,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IAC9F,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;CACjC,GAAG,cAAc,CAajB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { raceAgainstSignal } from '../util/race-signal';
|
|
2
|
+
// ─── Factories ───────────────────────────────────────────────────────────────
|
|
3
|
+
/**
|
|
4
|
+
* Follow every redirect. Default when `ClientSessionConfig.redirect` is absent.
|
|
5
|
+
*
|
|
6
|
+
* Consumers who want to gate redirects on a URL allowlist use
|
|
7
|
+
* `allowlistPolicy`; consumers who want to prompt the user per hop use
|
|
8
|
+
* `promptPolicy`; consumers who want to refuse every redirect use
|
|
9
|
+
* `strictPolicy`.
|
|
10
|
+
*/
|
|
11
|
+
export function allowAllPolicy() {
|
|
12
|
+
return {
|
|
13
|
+
decide: () => ({ follow: true }),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Refuse every redirect. Opt-in — when a consumer wants cross-kernel
|
|
18
|
+
* follow blocked entirely and every redirect surfaced as a
|
|
19
|
+
* `RedirectRefusedError`.
|
|
20
|
+
*/
|
|
21
|
+
export function strictPolicy() {
|
|
22
|
+
return {
|
|
23
|
+
decide: () => ({ follow: false, reason: 'strict policy refuses all redirects' }),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Follow only URLs that the `allow` predicate returns true for.
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* allowlistPolicy({
|
|
31
|
+
* allow: (url) => new URL(url).host.endsWith('.trusted.kernel'),
|
|
32
|
+
* })
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export function allowlistPolicy(opts) {
|
|
36
|
+
return {
|
|
37
|
+
decide: (redirection) => {
|
|
38
|
+
if (opts.allow(redirection.url))
|
|
39
|
+
return { follow: true };
|
|
40
|
+
return { follow: false, reason: `URL not in allowlist: ${redirection.url}` };
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Ask the consumer for each redirect. The returned policy races the UI
|
|
46
|
+
* `onPrompt` call against the caller's `signal`, so aborting the
|
|
47
|
+
* top-level `session.call` cancels the prompt.
|
|
48
|
+
*
|
|
49
|
+
* `allow`, when provided, is a fast-path predicate that skips the
|
|
50
|
+
* prompt (for pre-approved URLs). Returning `false` from `allow` falls
|
|
51
|
+
* through to `onPrompt`.
|
|
52
|
+
*/
|
|
53
|
+
export function promptPolicy(opts) {
|
|
54
|
+
return {
|
|
55
|
+
decide: async (redirection, hops, _correlationId, signal) => {
|
|
56
|
+
if (opts.allow?.(redirection.url))
|
|
57
|
+
return { follow: true };
|
|
58
|
+
// Short-circuit a pre-aborted signal before opening the prompt —
|
|
59
|
+
// otherwise the consumer's UI flashes for a call the caller already cancelled.
|
|
60
|
+
if (signal?.aborted)
|
|
61
|
+
throw signal.reason instanceof Error ? signal.reason : new Error('aborted');
|
|
62
|
+
const accepted = await raceAgainstSignal(opts.onPrompt(redirection, hops), signal);
|
|
63
|
+
if (accepted)
|
|
64
|
+
return { follow: true };
|
|
65
|
+
return { follow: false, reason: `consumer declined redirect → ${redirection.url}` };
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/redirect/policy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAuCvD,gFAAgF;AAEhF;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO;QACL,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;KACjC,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO;QACL,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,qCAAqC,EAAE,CAAC;KACjF,CAAA;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,IAAyC;IACvE,OAAO;QACL,MAAM,EAAE,CAAC,WAAW,EAAE,EAAE;YACtB,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC;gBAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;YACxD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,yBAAyB,WAAW,CAAC,GAAG,EAAE,EAAE,CAAA;QAC9E,CAAC;KACF,CAAA;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,IAG5B;IACC,OAAO;QACL,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE;YAC1D,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC;gBAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;YAC1D,iEAAiE;YACjE,+EAA+E;YAC/E,IAAI,MAAM,EAAE,OAAO;gBACjB,MAAM,MAAM,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,CAAA;YAC7E,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAA;YAClF,IAAI,QAAQ;gBAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;YACrC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,gCAAgC,WAAW,CAAC,GAAG,EAAE,EAAE,CAAA;QACrF,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ProxyCallOptions } from './proxy-types';
|
|
2
|
+
/**
|
|
3
|
+
* Distinguish between method(), method(opts), and method(params, opts).
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolveCallArgs(first?: unknown, second?: ProxyCallOptions): [Record<string, unknown>, ProxyCallOptions | undefined];
|
|
6
|
+
//# sourceMappingURL=call-args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-args.d.ts","sourceRoot":"","sources":["../../src/schema/call-args.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAErD;;GAEG;AACH,wBAAgB,eAAe,CAC7B,KAAK,CAAC,EAAE,OAAO,EACf,MAAM,CAAC,EAAE,gBAAgB,GACxB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC,CAgBzD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Distinguish between method(), method(opts), and method(params, opts).
|
|
3
|
+
*/
|
|
4
|
+
export function resolveCallArgs(first, second) {
|
|
5
|
+
// method() — no args
|
|
6
|
+
if (first === undefined)
|
|
7
|
+
return [{}, undefined];
|
|
8
|
+
// method(params, opts) — two args
|
|
9
|
+
if (second !== undefined)
|
|
10
|
+
return [first, second];
|
|
11
|
+
// method(arg) — is it params or opts?
|
|
12
|
+
if (first &&
|
|
13
|
+
typeof first === 'object' &&
|
|
14
|
+
('timeout' in first ||
|
|
15
|
+
'signal' in first ||
|
|
16
|
+
'credential' in first)) {
|
|
17
|
+
return [{}, first];
|
|
18
|
+
}
|
|
19
|
+
return [first, undefined];
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=call-args.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-args.js","sourceRoot":"","sources":["../../src/schema/call-args.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,KAAe,EACf,MAAyB;IAEzB,qBAAqB;IACrB,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,CAAC,EAAE,EAAE,SAAS,CAAC,CAAA;IAC/C,kCAAkC;IAClC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,CAAC,KAAgC,EAAE,MAAM,CAAC,CAAA;IAC3E,sCAAsC;IACtC,IACE,KAAK;QACL,OAAO,KAAK,KAAK,QAAQ;QACzB,CAAC,SAAS,IAAK,KAAgB;YAC7B,QAAQ,IAAK,KAAgB;YAC7B,YAAY,IAAK,KAAgB,CAAC,EACpC,CAAC;QACD,OAAO,CAAC,EAAE,EAAE,KAAyB,CAAC,CAAA;IACxC,CAAC;IACD,OAAO,CAAC,KAAgC,EAAE,SAAS,CAAC,CAAA;AACtD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ProxyCaller } from './proxy-types';
|
|
2
|
+
/**
|
|
3
|
+
* Create a typed Proxy for static methods on a class.
|
|
4
|
+
*
|
|
5
|
+
* Uses an allow-list (knownMethods) — only actual static methods produce call thunks.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createClassProxy(caller: ProxyCaller, domain: string, className: string, knownMethods?: Set<string>): unknown;
|
|
8
|
+
//# sourceMappingURL=class-proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class-proxy.d.ts","sourceRoot":"","sources":["../../src/schema/class-proxy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAQhD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GACzB,OAAO,CA0BT"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { MethodPath, Ref } from '@astrale-os/kernel-core/domain';
|
|
2
|
+
import { resolveCallArgs } from './call-args';
|
|
3
|
+
// Runtime walks `of_domain` via namespaced edge slugs (`class.<Name>`), so the
|
|
4
|
+
// wire path has to carry the namespace prefix too. `MethodPath.from` accepts any
|
|
5
|
+
// member string by design — it's the caller's job to pass the qualified form.
|
|
6
|
+
/**
|
|
7
|
+
* Create a typed Proxy for static methods on a class.
|
|
8
|
+
*
|
|
9
|
+
* Uses an allow-list (knownMethods) — only actual static methods produce call thunks.
|
|
10
|
+
*/
|
|
11
|
+
export function createClassProxy(caller, domain, className, knownMethods) {
|
|
12
|
+
return new Proxy(Object.create(null), {
|
|
13
|
+
get(_target, prop) {
|
|
14
|
+
if (typeof prop !== 'string')
|
|
15
|
+
return undefined;
|
|
16
|
+
if (knownMethods && !knownMethods.has(prop))
|
|
17
|
+
return undefined;
|
|
18
|
+
return (paramsOrOpts, maybeOpts) => {
|
|
19
|
+
// Wire form is the qualified `:class.X:method` slug — runtime
|
|
20
|
+
// walks `of_domain` via the namespaced edge slug.
|
|
21
|
+
const wirePath = MethodPath.from({
|
|
22
|
+
domain,
|
|
23
|
+
member: Ref.member('class', className).toString(),
|
|
24
|
+
memberKind: 'class',
|
|
25
|
+
method: prop,
|
|
26
|
+
}).raw;
|
|
27
|
+
const [params, opts] = resolveCallArgs(paramsOrOpts, maybeOpts);
|
|
28
|
+
return caller(wirePath, params, opts?.credential, {
|
|
29
|
+
timeout: opts?.timeout,
|
|
30
|
+
signal: opts?.signal,
|
|
31
|
+
correlationId: opts?.correlationId,
|
|
32
|
+
url: opts?.url,
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=class-proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class-proxy.js","sourceRoot":"","sources":["../../src/schema/class-proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAA;AAKhE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C,+EAA+E;AAC/E,iFAAiF;AACjF,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAmB,EACnB,MAAc,EACd,SAAiB,EACjB,YAA0B;IAE1B,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;QACpC,GAAG,CAAC,OAAO,EAAE,IAAI;YACf,IAAI,OAAO,IAAI,KAAK,QAAQ;gBAAE,OAAO,SAAS,CAAA;YAC9C,IAAI,YAAY,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,OAAO,SAAS,CAAA;YAE7D,OAAO,CAAC,YAAsB,EAAE,SAA4B,EAAE,EAAE;gBAC9D,8DAA8D;gBAC9D,kDAAkD;gBAClD,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC;oBAC/B,MAAM;oBACN,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,QAAQ,EAAE;oBACjD,UAAU,EAAE,OAAO;oBACnB,MAAM,EAAE,IAAI;iBACb,CAAC,CAAC,GAAG,CAAA;gBACN,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,eAAe,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA;gBAE/D,OAAO,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE;oBAChD,OAAO,EAAE,IAAI,EAAE,OAAO;oBACtB,MAAM,EAAE,IAAI,EAAE,MAAM;oBACpB,aAAa,EAAE,IAAI,EAAE,aAAa;oBAClC,GAAG,EAAE,IAAI,EAAE,GAAG;iBACf,CAAC,CAAA;YACJ,CAAC,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Schema } from '@astrale-os/kernel-dsl';
|
|
2
|
+
/**
|
|
3
|
+
* Extract method names per class from a builder Schema.
|
|
4
|
+
*
|
|
5
|
+
* Used by `withSchema()` to build proxy allow-lists — only properties
|
|
6
|
+
* that appear in this set produce call thunks on the proxy.
|
|
7
|
+
*/
|
|
8
|
+
export declare function extractMethodsByClass(schema: Schema): Map<string, Set<string>>;
|
|
9
|
+
//# sourceMappingURL=extract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../src/schema/extract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAIpD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAS9E"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { resolveAllMethods } from '@astrale-os/kernel-dsl';
|
|
2
|
+
/**
|
|
3
|
+
* Extract method names per class from a builder Schema.
|
|
4
|
+
*
|
|
5
|
+
* Used by `withSchema()` to build proxy allow-lists — only properties
|
|
6
|
+
* that appear in this set produce call thunks on the proxy.
|
|
7
|
+
*/
|
|
8
|
+
export function extractMethodsByClass(schema) {
|
|
9
|
+
const methodsByClass = new Map();
|
|
10
|
+
for (const [className, def] of Object.entries(schema.classes)) {
|
|
11
|
+
const methods = resolveAllMethods(def);
|
|
12
|
+
methodsByClass.set(className, new Set(Object.keys(methods)));
|
|
13
|
+
}
|
|
14
|
+
return methodsByClass;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=extract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../../src/schema/extract.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAc;IAClD,MAAM,cAAc,GAAG,IAAI,GAAG,EAAuB,CAAA;IAErD,KAAK,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9D,MAAM,OAAO,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAA;QACtC,cAAc,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAC9D,CAAC;IAED,OAAO,cAAc,CAAA;AACvB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert BoundMethod[] to FunctionSchema[] for the client SchemaRegistry.
|
|
3
|
+
*
|
|
4
|
+
* Extracts the routing + shape metadata from bound methods so the client can
|
|
5
|
+
* resolve target URLs and transport modes at call time. `code` is emitted as
|
|
6
|
+
* empty strings — the client never executes handler bodies, it only dispatches
|
|
7
|
+
* to the server or follows a redirect.
|
|
8
|
+
*/
|
|
9
|
+
import type { FunctionSchema } from '@astrale-os/kernel-core/domain';
|
|
10
|
+
import type { BoundMethod } from '@astrale-os/kernel-core/domain';
|
|
11
|
+
export declare function toFunctionSchemas(methods: BoundMethod[]): FunctionSchema[];
|
|
12
|
+
//# sourceMappingURL=from-entries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"from-entries.d.ts","sourceRoot":"","sources":["../../src/schema/from-entries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAIjE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,cAAc,EAAE,CAgB1E"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert BoundMethod[] to FunctionSchema[] for the client SchemaRegistry.
|
|
3
|
+
*
|
|
4
|
+
* Extracts the routing + shape metadata from bound methods so the client can
|
|
5
|
+
* resolve target URLs and transport modes at call time. `code` is emitted as
|
|
6
|
+
* empty strings — the client never executes handler bodies, it only dispatches
|
|
7
|
+
* to the server or follows a redirect.
|
|
8
|
+
*/
|
|
9
|
+
import { zodToJsonSchema } from '@astrale-os/kernel-core/domain';
|
|
10
|
+
export function toFunctionSchemas(methods) {
|
|
11
|
+
return methods.map((method) => {
|
|
12
|
+
const handler = method.handler;
|
|
13
|
+
const binding = extractBinding(handler);
|
|
14
|
+
const schema = {
|
|
15
|
+
ref: method.ref,
|
|
16
|
+
inputSchema: zodToJsonSchema(method.inputSchema),
|
|
17
|
+
outputSchema: zodToJsonSchema(method.outputSchema),
|
|
18
|
+
output: method.output,
|
|
19
|
+
// Client-side schemas carry no code bodies — the client only dispatches,
|
|
20
|
+
// it never hydrates a sandbox. Empty strings satisfy the canonical shape.
|
|
21
|
+
code: { authorize: '', execute: '' },
|
|
22
|
+
};
|
|
23
|
+
if (binding)
|
|
24
|
+
schema.binding = binding;
|
|
25
|
+
return schema;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function extractBinding(handler) {
|
|
29
|
+
const { route, remoteUrl } = handler;
|
|
30
|
+
if (route === undefined && remoteUrl === undefined)
|
|
31
|
+
return undefined;
|
|
32
|
+
const binding = {};
|
|
33
|
+
if (remoteUrl !== undefined)
|
|
34
|
+
binding.remoteUrl = remoteUrl;
|
|
35
|
+
if (route !== undefined)
|
|
36
|
+
binding.route = route;
|
|
37
|
+
return binding;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=from-entries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"from-entries.js","sourceRoot":"","sources":["../../src/schema/from-entries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAEhE,MAAM,UAAU,iBAAiB,CAAC,OAAsB;IACtD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QAC5B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAuD,CAAA;QAC9E,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,CAAA;QACvC,MAAM,MAAM,GAAmB;YAC7B,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,WAAW,EAAE,eAAe,CAAC,MAAM,CAAC,WAAW,CAAC;YAChD,YAAY,EAAE,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC;YAClD,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,yEAAyE;YACzE,0EAA0E;YAC1E,IAAI,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;SACrC,CAAA;QACD,IAAI,OAAO;YAAE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAA;QACrC,OAAO,MAAM,CAAA;IACf,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,OAGvB;IACC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;IACpC,IAAI,KAAK,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACpE,MAAM,OAAO,GAAoB,EAAE,CAAA;IACnC,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,CAAC,SAAS,GAAG,SAAS,CAAA;IAC1D,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,CAAC,KAAK,GAAG,KAAK,CAAA;IAC9C,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { SCHEMA_REGISTRY_BRAND, SchemaRegistry } from './registry';
|
|
2
|
+
export { createSchemaClient } from './typed-client';
|
|
3
|
+
export { createClassProxy } from './class-proxy';
|
|
4
|
+
export { createNodeProxy } from './node-proxy';
|
|
5
|
+
export { resolveMethodKey } from './resolve';
|
|
6
|
+
export { resolveCallArgs } from './call-args';
|
|
7
|
+
export { extractMethodsByClass } from './extract';
|
|
8
|
+
export { toFunctionSchemas } from './from-entries';
|
|
9
|
+
export type { FunctionSchema } from './types';
|
|
10
|
+
export type { ClassNames, ClassProxy, NodeProxy, ProxyCallOptions, ProxyCaller, SchemaTypedClient, } from './proxy-types';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAClD,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC7C,YAAY,EACV,UAAU,EACV,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,iBAAiB,GAClB,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { SCHEMA_REGISTRY_BRAND, SchemaRegistry } from './registry';
|
|
2
|
+
export { createSchemaClient } from './typed-client';
|
|
3
|
+
export { createClassProxy } from './class-proxy';
|
|
4
|
+
export { createNodeProxy } from './node-proxy';
|
|
5
|
+
export { resolveMethodKey } from './resolve';
|
|
6
|
+
export { resolveCallArgs } from './call-args';
|
|
7
|
+
export { extractMethodsByClass } from './extract';
|
|
8
|
+
export { toFunctionSchemas } from './from-entries';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ProxyCaller } from './proxy-types';
|
|
2
|
+
/**
|
|
3
|
+
* Create a typed Proxy for a node instance.
|
|
4
|
+
*
|
|
5
|
+
* Uses an allow-list (knownMethods) — only properties that are actual methods
|
|
6
|
+
* on the class produce call thunks. Everything else returns undefined.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createNodeProxy(caller: ProxyCaller, className: string, nodeId: string, knownMethods?: Set<string>): unknown;
|
|
9
|
+
//# sourceMappingURL=node-proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-proxy.d.ts","sourceRoot":"","sources":["../../src/schema/node-proxy.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAoB,WAAW,EAAE,MAAM,eAAe,CAAA;AAIlE;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GACzB,OAAO,CAsBT"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IdPath } from '@astrale-os/kernel-core';
|
|
2
|
+
import { InstanceMethodPath } from '@astrale-os/kernel-core/domain';
|
|
3
|
+
import { resolveCallArgs } from './call-args';
|
|
4
|
+
/**
|
|
5
|
+
* Create a typed Proxy for a node instance.
|
|
6
|
+
*
|
|
7
|
+
* Uses an allow-list (knownMethods) — only properties that are actual methods
|
|
8
|
+
* on the class produce call thunks. Everything else returns undefined.
|
|
9
|
+
*/
|
|
10
|
+
export function createNodeProxy(caller, className, nodeId, knownMethods) {
|
|
11
|
+
const source = IdPath.from(nodeId);
|
|
12
|
+
return new Proxy(Object.create(null), {
|
|
13
|
+
get(_target, prop) {
|
|
14
|
+
if (typeof prop !== 'string')
|
|
15
|
+
return undefined;
|
|
16
|
+
if (knownMethods && !knownMethods.has(prop))
|
|
17
|
+
return undefined;
|
|
18
|
+
return (paramsOrOpts, maybeOpts) => {
|
|
19
|
+
const wirePath = InstanceMethodPath.from(source, prop).raw;
|
|
20
|
+
const [params, opts] = resolveCallArgs(paramsOrOpts, maybeOpts);
|
|
21
|
+
return caller(wirePath, params, opts?.credential, {
|
|
22
|
+
timeout: opts?.timeout,
|
|
23
|
+
signal: opts?.signal,
|
|
24
|
+
class: className,
|
|
25
|
+
correlationId: opts?.correlationId,
|
|
26
|
+
url: opts?.url,
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=node-proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-proxy.js","sourceRoot":"","sources":["../../src/schema/node-proxy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAInE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAmB,EACnB,SAAiB,EACjB,MAAc,EACd,YAA0B;IAE1B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAgB,CAAC,CAAA;IAE5C,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;QACpC,GAAG,CAAC,OAAO,EAAE,IAAI;YACf,IAAI,OAAO,IAAI,KAAK,QAAQ;gBAAE,OAAO,SAAS,CAAA;YAC9C,IAAI,YAAY,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,OAAO,SAAS,CAAA;YAE7D,OAAO,CAAC,YAAsB,EAAE,SAA4B,EAAE,EAAE;gBAC9D,MAAM,QAAQ,GAAG,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,GAAG,CAAA;gBAC1D,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,eAAe,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA;gBAE/D,OAAO,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE;oBAChD,OAAO,EAAE,IAAI,EAAE,OAAO;oBACtB,MAAM,EAAE,IAAI,EAAE,MAAM;oBACpB,KAAK,EAAE,SAAS;oBAChB,aAAa,EAAE,IAAI,EAAE,aAAa;oBAClC,GAAG,EAAE,IAAI,EAAE,GAAG;iBACf,CAAC,CAAA;YACJ,CAAC,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { CredentialInput, z } from '@astrale-os/kernel-core';
|
|
2
|
+
import type { AllMethods, ExtractMethodNames, ExtractMethodParams, ExtractMethodReturnValue, Schema } from '@astrale-os/kernel-dsl';
|
|
3
|
+
import type { CallOptions } from '../client/config';
|
|
4
|
+
/** Extract a class Def from a Schema by class name. */
|
|
5
|
+
type DefOf<S extends Schema, K extends string> = K extends keyof S['classes'] ? S['classes'][K] : never;
|
|
6
|
+
/** All class names in a Schema. */
|
|
7
|
+
export type ClassNames<S extends Schema> = keyof S['classes'] & string;
|
|
8
|
+
/** True if method M on def D is static. */
|
|
9
|
+
type IsStaticMethod<D, M extends string> = M extends keyof AllMethods<D> ? AllMethods<D>[M] extends {
|
|
10
|
+
config: {
|
|
11
|
+
static: true;
|
|
12
|
+
};
|
|
13
|
+
} ? true : false : false;
|
|
14
|
+
/** Instance method names (non-static). */
|
|
15
|
+
type InstanceMethodNames<D> = {
|
|
16
|
+
[M in ExtractMethodNames<D>]: IsStaticMethod<D, M> extends true ? never : M;
|
|
17
|
+
}[ExtractMethodNames<D>];
|
|
18
|
+
/** Static method names. */
|
|
19
|
+
type StaticMethodNames<D> = {
|
|
20
|
+
[M in ExtractMethodNames<D>]: IsStaticMethod<D, M> extends true ? M : never;
|
|
21
|
+
}[ExtractMethodNames<D>];
|
|
22
|
+
/**
|
|
23
|
+
* Infer runtime param type from a Zod ParamShape.
|
|
24
|
+
*
|
|
25
|
+
* Preserves optionality: keys whose Zod schema is `z.optional()` or
|
|
26
|
+
* `z.default()` become TypeScript-optional, so callers can omit them.
|
|
27
|
+
*/
|
|
28
|
+
type OptionalKeys<P> = {
|
|
29
|
+
[K in keyof P]: P[K] extends z.ZodOptional<any> | z.ZodDefault<any> ? K : never;
|
|
30
|
+
}[keyof P];
|
|
31
|
+
type RequiredKeys<P> = Exclude<keyof P, OptionalKeys<P>>;
|
|
32
|
+
type InferParams<P> = {
|
|
33
|
+
[K in RequiredKeys<P>]: P[K] extends z.ZodType<infer T> ? T : never;
|
|
34
|
+
} & {
|
|
35
|
+
[K in OptionalKeys<P>]?: P[K] extends z.ZodType<infer T> ? T : never;
|
|
36
|
+
};
|
|
37
|
+
/** Infer runtime param type from a method's params. */
|
|
38
|
+
type MethodParams<D, M extends string> = InferParams<ExtractMethodParams<D, M>>;
|
|
39
|
+
/** True if params is empty (no required fields). */
|
|
40
|
+
type IsEmptyParams<P> = keyof P extends never ? true : false;
|
|
41
|
+
/**
|
|
42
|
+
* Call signature for a single method.
|
|
43
|
+
* Empty-params: (opts?) => Promise<R>
|
|
44
|
+
* With params: (params, opts?) => Promise<R>
|
|
45
|
+
*/
|
|
46
|
+
type MethodCall<D, M extends string> = IsEmptyParams<MethodParams<D, M>> extends true ? (opts?: ProxyCallOptions) => Promise<ExtractMethodReturnValue<D, M>> : (params: MethodParams<D, M>, opts?: ProxyCallOptions) => Promise<ExtractMethodReturnValue<D, M>>;
|
|
47
|
+
/**
|
|
48
|
+
* Typed proxy for a node instance — exposes non-static methods.
|
|
49
|
+
*
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const doc = app.node('Document', nodeId)
|
|
52
|
+
* await doc.get() // typed return
|
|
53
|
+
* await doc.summary({ maxLength: 100 }) // typed params
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export type NodeProxy<S extends Schema, K extends string> = {
|
|
57
|
+
[M in InstanceMethodNames<DefOf<S, K>>]: MethodCall<DefOf<S, K>, M & string>;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Typed proxy for static methods — no node instance needed.
|
|
61
|
+
*
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const Domain = app.static('Domain')
|
|
64
|
+
* await Domain.init({ parent: { id: rootId }, domain: 'foo' })
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export type ClassProxy<S extends Schema, K extends string> = {
|
|
68
|
+
[M in StaticMethodNames<DefOf<S, K>>]: MethodCall<DefOf<S, K>, M & string>;
|
|
69
|
+
};
|
|
70
|
+
export type ProxyCallOptions = {
|
|
71
|
+
timeout?: number;
|
|
72
|
+
signal?: AbortSignal;
|
|
73
|
+
credential?: CredentialInput;
|
|
74
|
+
/**
|
|
75
|
+
* Caller-provided correlation id — threaded into every `ClientHooks`
|
|
76
|
+
* context and onto any thrown error's `.details.correlationId`.
|
|
77
|
+
*/
|
|
78
|
+
correlationId?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Override target URL for this call only. Used by orchestrators
|
|
81
|
+
* (layer D) to retarget after a redirect.
|
|
82
|
+
*/
|
|
83
|
+
url?: string;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* A function that sends a method call through the client.
|
|
87
|
+
*
|
|
88
|
+
* Created at withSchema() time — closes over the client and its
|
|
89
|
+
* credential strategy. Proxies call this without knowing which
|
|
90
|
+
* client type they're working with.
|
|
91
|
+
*/
|
|
92
|
+
export type ProxyCaller = (method: string, params: Record<string, unknown>, credential?: CredentialInput, callOpts?: CallOptions) => Promise<unknown>;
|
|
93
|
+
/**
|
|
94
|
+
* A KernelClient view bound to a specific schema.
|
|
95
|
+
* Provides typed `node()` and `static()` without repeating the schema.
|
|
96
|
+
*/
|
|
97
|
+
export interface SchemaTypedClient<S extends Schema> {
|
|
98
|
+
/**
|
|
99
|
+
* Create a typed proxy for a node instance.
|
|
100
|
+
* Exposes non-static methods. CallTransport format: @nodeId::method
|
|
101
|
+
*/
|
|
102
|
+
node<K extends ClassNames<S>>(className: K, nodeId: string): NodeProxy<S, K>;
|
|
103
|
+
/**
|
|
104
|
+
* Create a typed proxy for static methods.
|
|
105
|
+
* CallTransport format: /:domain:ClassName:method
|
|
106
|
+
*/
|
|
107
|
+
static<K extends ClassNames<S>>(className: K): ClassProxy<S, K>;
|
|
108
|
+
/** The bound schema (runtime value). */
|
|
109
|
+
readonly schema: S;
|
|
110
|
+
}
|
|
111
|
+
export {};
|
|
112
|
+
//# sourceMappingURL=proxy-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy-types.d.ts","sourceRoot":"","sources":["../../src/schema/proxy-types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,CAAC,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,MAAM,EACP,MAAM,wBAAwB,CAAA;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAInD,uDAAuD;AACvD,KAAK,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,MAAM,CAAC,CAAC,SAAS,CAAC,GACzE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GACf,KAAK,CAAA;AAET,mCAAmC;AACnC,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,IAAI,MAAM,CAAC,CAAC,SAAS,CAAC,GAAG,MAAM,CAAA;AAItE,2CAA2C;AAC3C,KAAK,cAAc,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,MAAM,UAAU,CAAC,CAAC,CAAC,GACpE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;IAAE,MAAM,EAAE;QAAE,MAAM,EAAE,IAAI,CAAA;KAAE,CAAA;CAAE,GACnD,IAAI,GACJ,KAAK,GACP,KAAK,CAAA;AAIT,0CAA0C;AAC1C,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAC3B,CAAC,IAAI,kBAAkB,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,IAAI,GAAG,KAAK,GAAG,CAAC;CAC5E,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAA;AAExB,2BAA2B;AAC3B,KAAK,iBAAiB,CAAC,CAAC,IAAI;KACzB,CAAC,IAAI,kBAAkB,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,GAAG,KAAK;CAC5E,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAA;AAIxB;;;;;GAKG;AACH,KAAK,YAAY,CAAC,CAAC,IAAI;KACpB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK;CAChF,CAAC,MAAM,CAAC,CAAC,CAAA;AACV,KAAK,YAAY,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;AACxD,KAAK,WAAW,CAAC,CAAC,IAAI;KACnB,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CACpE,GAAG;KACD,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CACrE,CAAA;AAED,uDAAuD;AACvD,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,WAAW,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAE/E,oDAAoD;AACpD,KAAK,aAAa,CAAC,CAAC,IAAI,MAAM,CAAC,SAAS,KAAK,GAAG,IAAI,GAAG,KAAK,CAAA;AAE5D;;;;GAIG;AACH,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IACjC,aAAa,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,IAAI,GAC1C,CAAC,IAAI,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GACpE,CACE,MAAM,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,IAAI,CAAC,EAAE,gBAAgB,KACpB,OAAO,CAAC,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAIlD;;;;;;;;GAQG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI;KACzD,CAAC,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;CAC7E,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI;KAC1D,CAAC,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;CAC3E,CAAA;AAID,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,UAAU,CAAC,EAAE,eAAe,CAAA;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAID;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,UAAU,CAAC,EAAE,eAAe,EAC5B,QAAQ,CAAC,EAAE,WAAW,KACnB,OAAO,CAAC,OAAO,CAAC,CAAA;AAIrB;;;GAGG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,MAAM;IACjD;;;OAGG;IACH,IAAI,CAAC,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAE5E;;;OAGG;IACH,MAAM,CAAC,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAE/D,wCAAwC;IACxC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy-types.js","sourceRoot":"","sources":["../../src/schema/proxy-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { FunctionSchema } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Cross-realm brand so `isSchemaRegistry(x)` works even when two copies
|
|
4
|
+
* of `@astrale-os/kernel-client` end up in the same process (peer-dep
|
|
5
|
+
* drift, iframe + parent page, etc). `instanceof SchemaRegistry` fails
|
|
6
|
+
* in that case; the Symbol.for-based check does not.
|
|
7
|
+
*/
|
|
8
|
+
export declare const SCHEMA_REGISTRY_BRAND: unique symbol;
|
|
9
|
+
/**
|
|
10
|
+
* Client-side cache of function schemas keyed by canonical ref.
|
|
11
|
+
*
|
|
12
|
+
* Two ways to populate it:
|
|
13
|
+
* - `load(schemas)` — one-shot, rejects duplicates. Used when the caller
|
|
14
|
+
* brings the schemas with them (static domain imports, `Function.list`
|
|
15
|
+
* prefetch).
|
|
16
|
+
* - `save(schema)` — upsert learned from a redirect response. Strict:
|
|
17
|
+
* input/output/output-mode must match any existing entry; only `binding`
|
|
18
|
+
* is allowed to change (URL relocation is legitimate, contract drift is
|
|
19
|
+
* not).
|
|
20
|
+
*/
|
|
21
|
+
export declare class SchemaRegistry {
|
|
22
|
+
readonly [SCHEMA_REGISTRY_BRAND] = true;
|
|
23
|
+
private methods;
|
|
24
|
+
load(schemas: FunctionSchema[]): void;
|
|
25
|
+
/**
|
|
26
|
+
* Upsert a schema — typically one learned from a `redirect` response.
|
|
27
|
+
*
|
|
28
|
+
* If no entry exists for the ref, inserts verbatim. If an entry exists,
|
|
29
|
+
* asserts that the contract shape (input / output / output mode) matches
|
|
30
|
+
* and updates only the `binding`. Contract drift throws — a server that
|
|
31
|
+
* ships a mismatched schema is either misconfigured or malicious.
|
|
32
|
+
*/
|
|
33
|
+
save(schema: FunctionSchema): void;
|
|
34
|
+
get(ref: string): FunctionSchema | undefined;
|
|
35
|
+
has(ref: string): boolean;
|
|
36
|
+
clear(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Type guard for `SchemaRegistry | FunctionSchema[]` unions. Works
|
|
39
|
+
* across package-duplicate realms, unlike `instanceof`.
|
|
40
|
+
*/
|
|
41
|
+
static is(value: unknown): value is SchemaRegistry;
|
|
42
|
+
/**
|
|
43
|
+
* Resolve a wire method address to its schema entry.
|
|
44
|
+
*
|
|
45
|
+
* Delegates normalization to `resolveMethodKey`. When the input lacks a
|
|
46
|
+
* namespace (an instance dispatch or a `:member:method` path), probes the
|
|
47
|
+
* `class` and `interface` namespaces in that order.
|
|
48
|
+
*/
|
|
49
|
+
resolve(method: string, classHint?: string): FunctionSchema | undefined;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/schema/registry.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM7C;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,eAAuC,CAAA;AAEzE;;;;;;;;;;;GAWG;AACH,qBAAa,cAAc;IACzB,QAAQ,CAAC,CAAC,qBAAqB,CAAC,QAAO;IACvC,OAAO,CAAC,OAAO,CAAoC;IAEnD,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,IAAI,CAWpC;IAED;;;;;;;OAOG;IACH,IAAI,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAcjC;IAED,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAE3C;IAED,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAExB;IAED,KAAK,IAAI,IAAI,CAEZ;IAED;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAMjD;IAED;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAUtE;CACF"}
|