@orpc/server 2.0.0-beta.49 → 2.0.0-beta.50
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/adapters/aws-lambda/handler.d.ts +17 -15
- package/dist/adapters/aws-lambda/handler.js +23 -23
- package/dist/adapters/aws-lambda/index.d.ts +4 -16
- package/dist/adapters/aws-lambda/index.js +2 -2
- package/dist/adapters/aws-lambda/rpc-handler.d.ts +9 -9
- package/dist/adapters/aws-lambda/rpc-handler.js +20 -17
- package/dist/adapters/crossws/handler.d.ts +44 -42
- package/dist/adapters/crossws/handler.js +53 -60
- package/dist/adapters/crossws/index.d.ts +3 -2
- package/dist/adapters/crossws/index.js +2 -2
- package/dist/adapters/crossws/rpc-handler.d.ts +10 -10
- package/dist/adapters/crossws/rpc-handler.js +17 -14
- package/dist/adapters/fastify/handler.d.ts +17 -15
- package/dist/adapters/fastify/handler.js +20 -20
- package/dist/adapters/fastify/index.d.ts +3 -2
- package/dist/adapters/fastify/index.js +2 -2
- package/dist/adapters/fastify/rpc-handler.d.ts +9 -9
- package/dist/adapters/fastify/rpc-handler.js +16 -13
- package/dist/adapters/fetch/handler.d.ts +19 -17
- package/dist/adapters/fetch/handler.js +22 -22
- package/dist/adapters/fetch/index.d.ts +4 -7
- package/dist/adapters/fetch/index.js +3 -7
- package/dist/adapters/fetch/rpc-handler.d.ts +9 -9
- package/dist/adapters/fetch/rpc-handler.js +18 -15
- package/dist/adapters/message-port/handler.d.ts +58 -60
- package/dist/adapters/message-port/handler.js +72 -86
- package/dist/adapters/message-port/index.d.ts +3 -2
- package/dist/adapters/message-port/index.js +2 -2
- package/dist/adapters/message-port/rpc-handler.d.ts +9 -9
- package/dist/adapters/message-port/rpc-handler.js +17 -14
- package/dist/adapters/node/handler.d.ts +17 -15
- package/dist/adapters/node/handler.js +20 -20
- package/dist/adapters/node/index.d.ts +4 -7
- package/dist/adapters/node/index.js +3 -7
- package/dist/adapters/node/rpc-handler.d.ts +9 -9
- package/dist/adapters/node/rpc-handler.js +17 -14
- package/dist/adapters/standard/codec.d.ts +13 -13
- package/dist/adapters/standard/handler.d.ts +49 -49
- package/dist/adapters/standard/handler.js +205 -205
- package/dist/adapters/standard/index.d.ts +7 -6
- package/dist/adapters/standard/index.js +4 -5
- package/dist/adapters/standard/plugin.d.ts +25 -31
- package/dist/adapters/standard/plugin.js +14 -16
- package/dist/adapters/standard/rpc-handler-codec.d.ts +39 -43
- package/dist/adapters/standard/rpc-handler-codec.js +50 -51
- package/dist/adapters/standard/rpc-matcher.d.ts +40 -40
- package/dist/adapters/standard/rpc-matcher.js +103 -149
- package/dist/adapters/standard/utils.d.ts +8 -8
- package/dist/adapters/standard/utils.js +7 -5
- package/dist/adapters/standard-peer/index.d.ts +2 -1
- package/dist/adapters/standard-peer/index.js +1 -1
- package/dist/adapters/standard-peer/utils.d.ts +6 -4
- package/dist/adapters/standard-peer/utils.js +12 -6
- package/dist/adapters/websocket/handler.d.ts +52 -50
- package/dist/adapters/websocket/handler.js +75 -85
- package/dist/adapters/websocket/index.d.ts +3 -2
- package/dist/adapters/websocket/index.js +2 -2
- package/dist/adapters/websocket/rpc-handler.d.ts +9 -9
- package/dist/adapters/websocket/rpc-handler.js +17 -14
- package/dist/builder-variants.d.ts +195 -195
- package/dist/builder.d.ts +103 -104
- package/dist/builder.js +198 -224
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +4 -2
- package/dist/context.d.ts +3 -3
- package/dist/extensions/callable.d.ts +11 -11
- package/dist/extensions/callable.js +6 -5
- package/dist/helpers/base64url.d.ts +1 -1
- package/dist/helpers/base64url.js +44 -49
- package/dist/helpers/cookie.d.ts +10 -11
- package/dist/helpers/cookie.js +56 -63
- package/dist/helpers/encryption.d.ts +1 -1
- package/dist/helpers/encryption.js +80 -70
- package/dist/helpers/index.d.ts +5 -4
- package/dist/helpers/index.js +4 -4
- package/dist/helpers/signing.d.ts +1 -1
- package/dist/helpers/signing.js +72 -82
- package/dist/implementer-procedure.d.ts +12 -13
- package/dist/implementer-procedure.js +37 -44
- package/dist/implementer-router.d.ts +30 -36
- package/dist/implementer-router.js +92 -111
- package/dist/implementer.d.ts +8 -8
- package/dist/implementer.js +28 -35
- package/dist/index.d.ts +22 -61
- package/dist/index.js +16 -48
- package/dist/lazy.d.ts +14 -14
- package/dist/lazy.js +19 -30
- package/dist/middleware-decorated.d.ts +8 -9
- package/dist/middleware-decorated.js +66 -70
- package/dist/middleware.d.ts +34 -34
- package/dist/plugins/batch.d.ts +75 -75
- package/dist/plugins/batch.js +345 -379
- package/dist/plugins/cors.d.ts +60 -64
- package/dist/plugins/cors.js +118 -111
- package/dist/plugins/get-method-csrf-protection.d.ts +8 -6
- package/dist/plugins/get-method-csrf-protection.js +47 -63
- package/dist/plugins/head-method.d.ts +11 -9
- package/dist/plugins/head-method.js +97 -94
- package/dist/plugins/index.d.ts +15 -39
- package/dist/plugins/index.js +14 -29
- package/dist/plugins/method-override.d.ts +30 -28
- package/dist/plugins/method-override.js +53 -49
- package/dist/plugins/request-compression.d.ts +11 -9
- package/dist/plugins/request-compression.js +52 -79
- package/dist/plugins/request-headers.d.ts +10 -8
- package/dist/plugins/request-headers.js +27 -29
- package/dist/plugins/request-limit.d.ts +21 -19
- package/dist/plugins/request-limit.js +60 -67
- package/dist/plugins/response-compression.d.ts +42 -39
- package/dist/plugins/response-compression.js +150 -202
- package/dist/plugins/response-headers.d.ts +15 -13
- package/dist/plugins/response-headers.js +43 -46
- package/dist/plugins/rethrow.d.ts +25 -23
- package/dist/plugins/rethrow.js +46 -58
- package/dist/plugins/signal-sync.d.ts +7 -5
- package/dist/plugins/signal-sync.js +71 -86
- package/dist/plugins/timeout.d.ts +29 -27
- package/dist/plugins/timeout.js +61 -58
- package/dist/procedure-client.d.ts +14 -15
- package/dist/procedure-client.js +149 -166
- package/dist/procedure-decorated.d.ts +9 -9
- package/dist/procedure-decorated.js +36 -44
- package/dist/procedure-utils.d.ts +10 -30
- package/dist/procedure-utils.js +39 -40
- package/dist/procedure.d.ts +60 -60
- package/dist/procedure.js +18 -24
- package/dist/router-client.d.ts +9 -11
- package/dist/router-client.js +33 -41
- package/dist/router-hidden.js +10 -12
- package/dist/router-utils.d.ts +13 -30
- package/dist/router-utils.js +146 -191
- package/dist/router.d.ts +12 -26
- package/package.json +10 -10
- package/dist/adapters/standard/codec.js +0 -1
- package/dist/builder-variants.js +0 -1
- package/dist/context.js +0 -1
- package/dist/middleware.js +0 -1
- package/dist/router-hidden.d.ts +0 -5
- package/dist/router.js +0 -1
|
@@ -1,40 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import type { ContractedRouter } from './router.ts';
|
|
1
|
+
import { Context, MergedContext, MergedInitialContext } from "./context.js";
|
|
2
|
+
import { ProcedureImplementer } from "./implementer-procedure.js";
|
|
3
|
+
import { Lazy } from "./lazy.js";
|
|
4
|
+
import { AnyMiddleware, Middleware } from "./middleware.js";
|
|
5
|
+
import { DecoratedMiddleware } from "./middleware-decorated.js";
|
|
6
|
+
import { ProcedureConfig } from "./procedure.js";
|
|
7
|
+
import { ContractedRouter } from "./router.js";
|
|
8
|
+
import { AugmentedRouterWithMiddlewares } from "./router-utils.js";
|
|
9
|
+
import { ErrorMap, InferRouterContractErrorMap, ProcedureContract, RouterContract } from "@orpc/contract";
|
|
10
|
+
import { IntersectPick, Public } from "@orpc/shared";
|
|
12
11
|
export declare class SharedRouterImplementer<TContract extends RouterContract, TInitialContext extends Context> {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
private readonly contract;
|
|
13
|
+
private readonly config;
|
|
14
|
+
private readonly middlewares;
|
|
15
|
+
private constructor();
|
|
16
|
+
static create<TContract extends RouterContract, TInitialContext extends Context>(contract: TContract, config: ProcedureConfig): SharedRouterImplementer<TContract, TInitialContext>;
|
|
17
|
+
static create<TContract extends RouterContract, TInitialContext extends Context, TInjectedContext extends Context>(contract: TContract, config: ProcedureConfig, middlewares: AnyMiddleware[]): SharedRouterImplementerWithMiddlewares<TContract, TInitialContext, TInjectedContext>;
|
|
18
|
+
use<$OutContext extends IntersectPick<TInitialContext, $OutContext>, $InContext extends Context = TInitialContext, $ErrorMap extends ErrorMap = InferRouterContractErrorMap<TContract>>(middleware: Middleware<$InContext | TInitialContext, $OutContext, unknown, unknown, $ErrorMap>): RouterImplementerWithMiddlewares<TContract, MergedInitialContext<TInitialContext, object, $InContext>, $OutContext>;
|
|
19
|
+
middleware<$OutContext extends IntersectPick<TInitialContext, $OutContext>, $Input, $InContext extends Context = TInitialContext, $Output = any>(middleware: Middleware<$InContext | TInitialContext, $OutContext, $Input, $Output, InferRouterContractErrorMap<TContract>>): DecoratedMiddleware<MergedInitialContext<TInitialContext, object, $InContext>, $OutContext, $Input, $Output, object>;
|
|
20
|
+
router<T extends ContractedRouter<TContract, any>>(router: T): T;
|
|
21
|
+
lazy<T extends ContractedRouter<TContract, any>>(loader: () => Promise<{
|
|
22
|
+
default: T;
|
|
23
|
+
}>): Lazy<T>;
|
|
25
24
|
}
|
|
26
25
|
export interface SharedRouterImplementerWithMiddlewares<TContract extends RouterContract, TInitialContext extends Context, TInjectedContext extends Context> {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
use<$OutContext extends IntersectPick<MergedContext<TInitialContext, TInjectedContext>, $OutContext>, $InContext extends Context = MergedContext<TInitialContext, TInjectedContext>, $ErrorMap extends ErrorMap = InferRouterContractErrorMap<TContract>>(middleware: Middleware<$InContext | MergedContext<TInitialContext, TInjectedContext>, $OutContext, unknown, unknown, $ErrorMap>): RouterImplementerWithMiddlewares<TContract, MergedInitialContext<TInitialContext, TInjectedContext, $InContext>, MergedContext<TInjectedContext, $OutContext>>;
|
|
27
|
+
middleware<$OutContext extends IntersectPick<MergedContext<TInitialContext, TInjectedContext>, $OutContext>, $Input, $InContext extends Context = MergedContext<TInitialContext, TInjectedContext>, $Output = any>(middleware: Middleware<$InContext | MergedContext<TInitialContext, TInjectedContext>, $OutContext, $Input, $Output, InferRouterContractErrorMap<TContract>>): DecoratedMiddleware<MergedInitialContext<TInitialContext, TInjectedContext, $InContext>, MergedContext<TInjectedContext, $OutContext>, $Input, $Output, object>;
|
|
28
|
+
router<T extends ContractedRouter<TContract, MergedContext<TInitialContext, TInjectedContext>>>(router: T): AugmentedRouterWithMiddlewares<T, TInitialContext, TInjectedContext, object>;
|
|
29
|
+
lazy<T extends ContractedRouter<TContract, any>>(loader: () => Promise<{
|
|
30
|
+
default: T;
|
|
31
|
+
}>): Lazy<AugmentedRouterWithMiddlewares<T, TInitialContext, TInjectedContext, object>>;
|
|
33
32
|
}
|
|
34
|
-
export type RouterImplementer<TContract extends RouterContract, TInitialContext extends Context> = TContract extends ProcedureContract<infer $InputSchema, infer $OutputSchema, infer $ErrorMap> ? ProcedureImplementer<TInitialContext, object, $InputSchema, $OutputSchema, $ErrorMap> : Public<SharedRouterImplementer<TContract, TInitialContext>> & {
|
|
35
|
-
|
|
36
|
-
};
|
|
37
|
-
export type RouterImplementerWithMiddlewares<TContract extends RouterContract, TInitialContext extends Context, TInjectedContext extends Context> = TContract extends ProcedureContract<infer $InputSchema, infer $OutputSchema, infer $ErrorMap> ? ProcedureImplementer<TInitialContext, TInjectedContext, $InputSchema, $OutputSchema, $ErrorMap> : SharedRouterImplementerWithMiddlewares<TContract, TInitialContext, TInjectedContext> & {
|
|
38
|
-
[K in keyof TContract]: TContract[K] extends RouterContract ? RouterImplementerWithMiddlewares<TContract[K], TInitialContext, TInjectedContext> : never;
|
|
39
|
-
};
|
|
40
|
-
export declare function createRouterImplementer<TContract extends RouterContract, TInitialContext extends Context>(contract: TContract, config: ProcedureConfig): RouterImplementer<TContract, TInitialContext>;
|
|
33
|
+
export type RouterImplementer<TContract extends RouterContract, TInitialContext extends Context> = TContract extends ProcedureContract<infer $InputSchema, infer $OutputSchema, infer $ErrorMap> ? ProcedureImplementer<TInitialContext, object, $InputSchema, $OutputSchema, $ErrorMap> : Public<SharedRouterImplementer<TContract, TInitialContext>> & { [K in keyof TContract]: TContract[K] extends RouterContract ? RouterImplementer<TContract[K], TInitialContext> : never; };
|
|
34
|
+
export type RouterImplementerWithMiddlewares<TContract extends RouterContract, TInitialContext extends Context, TInjectedContext extends Context> = TContract extends ProcedureContract<infer $InputSchema, infer $OutputSchema, infer $ErrorMap> ? ProcedureImplementer<TInitialContext, TInjectedContext, $InputSchema, $OutputSchema, $ErrorMap> : SharedRouterImplementerWithMiddlewares<TContract, TInitialContext, TInjectedContext> & { [K in keyof TContract]: TContract[K] extends RouterContract ? RouterImplementerWithMiddlewares<TContract[K], TInitialContext, TInjectedContext> : never; };
|
|
@@ -1,117 +1,98 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
meta: {},
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
export function createRouterImplementer(contract, config) {
|
|
55
|
-
return createRouterImplementerInternal(toPlainRouterContract(contract), config, []);
|
|
1
|
+
import { ProcedureImplementer } from "./implementer-procedure.js";
|
|
2
|
+
import { Lazy } from "./lazy.js";
|
|
3
|
+
import { decorateMiddleware } from "./middleware-decorated.js";
|
|
4
|
+
import { Procedure } from "./procedure.js";
|
|
5
|
+
import { withHiddenRouterContract } from "./router-hidden.js";
|
|
6
|
+
import { augmentImplementedRouter } from "./router-utils.js";
|
|
7
|
+
import { ProcedureContract } from "@orpc/contract";
|
|
8
|
+
import { bindMethods, omit, setOwn } from "@orpc/shared";
|
|
9
|
+
// src/implementer-router.ts
|
|
10
|
+
var SharedRouterImplementer = class SharedRouterImplementer {
|
|
11
|
+
contract;
|
|
12
|
+
config;
|
|
13
|
+
middlewares;
|
|
14
|
+
constructor(contract, config, middlewares) {
|
|
15
|
+
this.contract = contract;
|
|
16
|
+
this.config = config;
|
|
17
|
+
this.middlewares = middlewares;
|
|
18
|
+
}
|
|
19
|
+
static create(contract, config, middlewares = []) {
|
|
20
|
+
return new SharedRouterImplementer(contract, config, middlewares);
|
|
21
|
+
}
|
|
22
|
+
use(middleware) {
|
|
23
|
+
return createRouterImplementerInternal(this.contract, this.config, [...this.middlewares, middleware]);
|
|
24
|
+
}
|
|
25
|
+
middleware(middleware) {
|
|
26
|
+
const allMiddlewares = [...this.middlewares, middleware];
|
|
27
|
+
let current = decorateMiddleware(allMiddlewares.shift());
|
|
28
|
+
for (const mid of allMiddlewares) current = current.use(mid);
|
|
29
|
+
return current;
|
|
30
|
+
}
|
|
31
|
+
router(router) {
|
|
32
|
+
if (this.middlewares.length) router = augmentImplementedRouter(router, {
|
|
33
|
+
...this.config,
|
|
34
|
+
middlewares: this.middlewares
|
|
35
|
+
});
|
|
36
|
+
return withHiddenRouterContract(router, this.contract);
|
|
37
|
+
}
|
|
38
|
+
lazy(loader) {
|
|
39
|
+
return new Lazy({
|
|
40
|
+
loader: async () => {
|
|
41
|
+
const { default: router } = await loader();
|
|
42
|
+
return { default: this.router(router) };
|
|
43
|
+
},
|
|
44
|
+
meta: {}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
function createRouterImplementer(contract, config) {
|
|
49
|
+
return createRouterImplementerInternal(toPlainRouterContract(contract), config, []);
|
|
56
50
|
}
|
|
57
51
|
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
52
|
+
* A normal router can be used as a contract (e.g. for mocking), but its procedures carry a handler,
|
|
53
|
+
* middlewares and config. Kept as is, unimplemented procedures would pass as procedures, their config
|
|
54
|
+
* would override the config passed to `implement`, and handlers serving the hidden contract would run
|
|
55
|
+
* the contract's procedures instead of the actual implementation.
|
|
56
|
+
*
|
|
57
|
+
* Rebuilds the contract with every procedure turned into a plain {@link ProcedureContract}
|
|
58
|
+
* (without `handler`, `orderedMiddlewares` and procedure config), copying only the routers that contain one,
|
|
59
|
+
* so contract-first contracts are returned as is.
|
|
60
|
+
*/
|
|
67
61
|
function toPlainRouterContract(contract) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return (copied ?? contract);
|
|
62
|
+
if (contract instanceof ProcedureContract) {
|
|
63
|
+
if (!(contract instanceof Procedure)) return contract;
|
|
64
|
+
return new ProcedureContract(omit(contract["~orpc"], [
|
|
65
|
+
"handler",
|
|
66
|
+
"orderedMiddlewares",
|
|
67
|
+
"disableInputValidation",
|
|
68
|
+
"disableOutputValidation"
|
|
69
|
+
]));
|
|
70
|
+
}
|
|
71
|
+
let copied;
|
|
72
|
+
for (const [key, child] of Object.entries(contract)) {
|
|
73
|
+
const plainChild = toPlainRouterContract(child);
|
|
74
|
+
if (plainChild !== child) {
|
|
75
|
+
copied ??= { ...contract };
|
|
76
|
+
copied[key] = plainChild;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return copied ?? contract;
|
|
89
80
|
}
|
|
90
81
|
function createRouterImplementerInternal(contract, config, middlewares) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
implementer[key] = new Proxy(method, {
|
|
107
|
-
get(_, p) {
|
|
108
|
-
return Reflect.get(child, p);
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
implementer[key] = method;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return implementer;
|
|
82
|
+
if (contract instanceof ProcedureContract) return new ProcedureImplementer({
|
|
83
|
+
...config,
|
|
84
|
+
...contract["~orpc"],
|
|
85
|
+
orderedMiddlewares: middlewares.map((middleware) => ({ middleware }))
|
|
86
|
+
});
|
|
87
|
+
const implementer = {};
|
|
88
|
+
for (const [key, child] of Object.entries(contract)) setOwn(implementer, key, createRouterImplementerInternal(child, config, middlewares));
|
|
89
|
+
const shared = bindMethods(SharedRouterImplementer.create(contract, config, middlewares));
|
|
90
|
+
for (const [key, method] of Object.entries(shared)) if (Object.hasOwn(implementer, key)) {
|
|
91
|
+
const child = implementer[key];
|
|
92
|
+
implementer[key] = new Proxy(method, { get(_, p) {
|
|
93
|
+
return Reflect.get(child, p);
|
|
94
|
+
} });
|
|
95
|
+
} else implementer[key] = method;
|
|
96
|
+
return implementer;
|
|
117
97
|
}
|
|
98
|
+
export { SharedRouterImplementer, createRouterImplementer };
|
package/dist/implementer.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import { DefaultInitialContext } from "./builder.js";
|
|
2
|
+
import { Context } from "./context.js";
|
|
3
|
+
import { RouterImplementer } from "./implementer-router.js";
|
|
4
|
+
import { ProcedureConfig } from "./procedure.js";
|
|
5
|
+
import { RouterContract } from "@orpc/contract";
|
|
6
6
|
export type Implementer<TContract extends RouterContract, TInitialContext extends Context> = {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
$context<T extends Context = DefaultInitialContext>(): Implementer<TContract, T & object>;
|
|
8
|
+
$config(config: ProcedureConfig): Implementer<TContract, TInitialContext>;
|
|
9
9
|
} & RouterImplementer<TContract, TInitialContext>;
|
|
10
10
|
/**
|
|
11
11
|
* Turns a contract into an implementer, used to implement the contract's
|
|
@@ -13,4 +13,4 @@ export type Implementer<TContract extends RouterContract, TInitialContext extend
|
|
|
13
13
|
*
|
|
14
14
|
* @see {@link https://orpc.dev/docs/contract/implementation#implementer | Contract Implementation - Implementer}
|
|
15
15
|
*/
|
|
16
|
-
export declare function implement<TContract extends RouterContract, TInitialContext extends Context = DefaultInitialContext>(contract: TContract, config?: ProcedureConfig): Implementer<TContract, TInitialContext & object>;
|
|
16
|
+
export declare function implement<TContract extends RouterContract, TInitialContext extends Context = DefaultInitialContext>(contract: TContract, config?: ProcedureConfig): Implementer<TContract, TInitialContext & object>;
|
package/dist/implementer.js
CHANGED
|
@@ -1,37 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createRouterImplementer } from "./implementer-router.js";
|
|
2
|
+
import { isNonPrimitive } from "@orpc/shared";
|
|
3
|
+
// src/implementer.ts
|
|
3
4
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
get(_, p) {
|
|
29
|
-
return Reflect.get(value, p);
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
return value;
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
return implementer;
|
|
5
|
+
* Turns a contract into an implementer, used to implement the contract's
|
|
6
|
+
* procedures, routers, and middleware with full type safety.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://orpc.dev/docs/contract/implementation#implementer | Contract Implementation - Implementer}
|
|
9
|
+
*/
|
|
10
|
+
function implement(contract, config = {}) {
|
|
11
|
+
const routerImplementer = createRouterImplementer(contract, config);
|
|
12
|
+
const implementer = new Proxy(routerImplementer, { get(_, p) {
|
|
13
|
+
let method;
|
|
14
|
+
if (p === "$context") method = () => implementer;
|
|
15
|
+
else if (p === "$config") method = (incoming) => implement(contract, {
|
|
16
|
+
...config,
|
|
17
|
+
...incoming
|
|
18
|
+
});
|
|
19
|
+
const value = Reflect.get(routerImplementer, p);
|
|
20
|
+
if (method) {
|
|
21
|
+
if (!isNonPrimitive(value)) return method;
|
|
22
|
+
return new Proxy(method, { get(_, p) {
|
|
23
|
+
return Reflect.get(value, p);
|
|
24
|
+
} });
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
} });
|
|
28
|
+
return implementer;
|
|
37
29
|
}
|
|
30
|
+
export { implement };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,61 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
InferRouterFinalContexts as InferRouterCurrentContexts,
|
|
23
|
-
export * from './router-client.ts';
|
|
24
|
-
export { getRouter, resolveContractProcedure, unlazyRouter, walkProcedureContractsAsync, walkProcedureContractsSync, } from './router-utils.ts';
|
|
25
|
-
export type { AugmentedRouter, AugmentedRouterWithMiddlewares, UnlaziedRouter, WalkProcedureContractsLazyResult, } from './router-utils.ts';
|
|
26
|
-
export type { AnyORPCError, AnyORPCErrorJSON, Client, ClientContext, ClientOptions, ClientRest, FriendlyClientOptions, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, RPCJsonSerialization, RPCJsonSerializationMeta, RPCJsonSerializerHandler, RPCJsonSerializerOptions, RPCSerializerOptions, RPCSerializerSerializeOptions, SafeResult, } from '@orpc/client';
|
|
27
|
-
export { COMMON_ERROR_STATUS_MAP, isDefinedError, ORPCError, RPCJsonSerializer, RPCSerializer, safe, toORPCError, } from '@orpc/client';
|
|
28
|
-
export type { AnyMetaPlugin, AnySchema, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InitialInputSchema, InitialOutputSchema, MergedErrorMap, MergedSchema, Meta, MetaPlugin, MetaPluginDefinition, ORPCErrorConstructorMap, ORPCErrorConstructorMapItem, ORPCErrorConstructorMapItemOptions, ORPCErrorFactory, ORPCErrorFactoryOptions, ORPCErrorFromErrorMap, ProcedureContract, ProcedureContractDefinition, RouterContract, Schema, } from '@orpc/contract';
|
|
29
|
-
export { asyncIteratorObject, defineMeta, error, eventIterator, type, ValidationError, } from '@orpc/contract';
|
|
30
|
-
export type { AsyncCleanupFn, AsyncIteratorClassNextFn, DistributiveOmit, IntersectPick, MaybeOptionalOptions, PromiseWithError, Public, Registry, ThrowableError, } from '@orpc/shared';
|
|
31
|
-
export { AsyncIteratorClass, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream,
|
|
32
|
-
/**
|
|
33
|
-
* @deprecated Use `asyncIteratorToStream` instead.
|
|
34
|
-
*/
|
|
35
|
-
asyncIteratorToStream as eventIteratorToStream,
|
|
36
|
-
/**
|
|
37
|
-
* @deprecated Use `asyncIteratorToUnproxiedDataStream` instead.
|
|
38
|
-
*/
|
|
39
|
-
asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject,
|
|
40
|
-
/**
|
|
41
|
-
* @deprecated Use `streamToAsyncIteratorObject` instead.
|
|
42
|
-
*/
|
|
43
|
-
streamToAsyncIteratorObject as streamToEventIterator, } from '@orpc/shared';
|
|
44
|
-
export type { EventMeta, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl, } from '@standard-server/core';
|
|
45
|
-
export {
|
|
46
|
-
/**
|
|
47
|
-
* @deprecated Use `EventStreamErrorEvent` instead.
|
|
48
|
-
*/
|
|
49
|
-
EventStreamErrorEvent as ErrorEvent, EventStreamErrorEvent,
|
|
50
|
-
/**
|
|
51
|
-
* Retrieves metadata attached to a single iterator event value.
|
|
52
|
-
*
|
|
53
|
-
* @see {@link https://orpc.dev/docs/helpers/publisher | Publisher Helpers}
|
|
54
|
-
*/
|
|
55
|
-
getEventMeta, unwrapEvent,
|
|
56
|
-
/**
|
|
57
|
-
* Returns a new iterator event value with attached, validated metadata.
|
|
58
|
-
*
|
|
59
|
-
* @see {@link https://orpc.dev/docs/async-iterator-object#last-event-id--event-metadata | AsyncIteratorObject (SSE) - Last Event ID & Event Metadata}
|
|
60
|
-
*/
|
|
61
|
-
withEventMeta, } from '@standard-server/core';
|
|
1
|
+
import { Builder, BuilderDefinition, DefaultInitialContext, os } from "./builder.js";
|
|
2
|
+
import { BuilderWithInput, BuilderWithInputOutput, BuilderWithMiddlewares, BuilderWithOutput } from "./builder-variants.js";
|
|
3
|
+
import { DEFAULT_ERROR_STATUS, DEFAULT_SUCCESS_STATUS } from "./constants.js";
|
|
4
|
+
import { Context, MergedContext, MergedInitialContext } from "./context.js";
|
|
5
|
+
import { Implementer, implement } from "./implementer.js";
|
|
6
|
+
import { ImplementedProcedure, ProcedureImplementer } from "./implementer-procedure.js";
|
|
7
|
+
import { RouterImplementer, RouterImplementerWithMiddlewares, SharedRouterImplementer, SharedRouterImplementerWithMiddlewares } from "./implementer-router.js";
|
|
8
|
+
import { Lazy, LazyDefinition, Lazyable, unlazy } from "./lazy.js";
|
|
9
|
+
import { AnyMiddleware, Middleware, MiddlewareDefinition, MiddlewareDone, MiddlewareDoneOptions, MiddlewareNext, MiddlewareNextOptions, MiddlewareOptions, MiddlewareResult } from "./middleware.js";
|
|
10
|
+
import { DecoratedMiddleware } from "./middleware-decorated.js";
|
|
11
|
+
import { AnyProcedure, OrderedMiddleware, Procedure, ProcedureConfig, ProcedureDefinition, ProcedureHandler, ProcedureHandlerOptions } from "./procedure.js";
|
|
12
|
+
import { ProcedureClient, ProcedureClientInterceptor, ProcedureClientInterceptorOptions, ProcedureClientOptions, createProcedureClient } from "./procedure-client.js";
|
|
13
|
+
import { DecoratedProcedure } from "./procedure-decorated.js";
|
|
14
|
+
import { CallOptions, CallRest, call } from "./procedure-utils.js";
|
|
15
|
+
import { AnyRouter, ContractedRouter, InferRouterError, InferRouterErrors, InferRouterFinalContexts, InferRouterInitialContext, InferRouterInitialContexts, InferRouterInputs, InferRouterOutputs, Router } from "./router.js";
|
|
16
|
+
import { RouterClient, createRouterClient } from "./router-client.js";
|
|
17
|
+
import { AugmentedRouter, AugmentedRouterWithMiddlewares, UnlaziedRouter, WalkProcedureContractsLazyResult, getRouter, resolveContractProcedure, unlazyRouter, walkProcedureContractsAsync, walkProcedureContractsSync } from "./router-utils.js";
|
|
18
|
+
import { AnyMetaPlugin, AnySchema, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InitialInputSchema, InitialOutputSchema, MergedErrorMap, MergedSchema, Meta, MetaPlugin, MetaPluginDefinition, ORPCErrorConstructorMap, ORPCErrorConstructorMapItem, ORPCErrorConstructorMapItemOptions, ORPCErrorFactory, ORPCErrorFactoryOptions, ORPCErrorFromErrorMap, ProcedureContract, ProcedureContractDefinition, RouterContract, Schema, ValidationError, asyncIteratorObject, defineMeta, error, eventIterator, type } from "@orpc/contract";
|
|
19
|
+
import { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, DistributiveOmit, IntersectPick, MaybeOptionalOptions, PromiseWithError, Public, Registry, ThrowableError, asyncIteratorToStream, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from "@orpc/shared";
|
|
20
|
+
import { AnyORPCError, AnyORPCErrorJSON, COMMON_ERROR_STATUS_MAP, Client, ClientContext, ClientOptions, ClientRest, FriendlyClientOptions, ORPCError, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, RPCJsonSerialization, RPCJsonSerializationMeta, RPCJsonSerializer, RPCJsonSerializerHandler, RPCJsonSerializerOptions, RPCSerializer, RPCSerializerOptions, RPCSerializerSerializeOptions, SafeResult, isDefinedError, safe, toORPCError } from "@orpc/client";
|
|
21
|
+
import { EventMeta, EventStreamErrorEvent, EventStreamErrorEvent as ErrorEvent, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl, getEventMeta, unwrapEvent, withEventMeta } from "@standard-server/core";
|
|
22
|
+
export { type AnyMetaPlugin, AnyMiddleware, type AnyORPCError, type AnyORPCErrorJSON, AnyProcedure, AnyRouter, type AnySchema, type AsyncCleanupFn, AsyncIteratorClass, type AsyncIteratorClassNextFn, type AugmentedRouter, type AugmentedRouterWithMiddlewares, Builder, BuilderDefinition, BuilderWithInput, BuilderWithInputOutput, BuilderWithMiddlewares, BuilderWithOutput, COMMON_ERROR_STATUS_MAP, type CallOptions, type CallRest, type Client, type ClientContext, type ClientOptions, type ClientRest, Context, ContractedRouter, DEFAULT_ERROR_STATUS, DEFAULT_SUCCESS_STATUS, type DecoratedMiddleware, DecoratedProcedure, DefaultInitialContext, type DistributiveOmit, ErrorEvent, type ErrorMap, type ErrorMapItem, type EventMeta, EventStreamErrorEvent, type FriendlyClientOptions, ImplementedProcedure, Implementer, type InferRouterFinalContexts as InferRouterCurrentContexts, InferRouterError, InferRouterErrors, InferRouterFinalContexts, InferRouterInitialContext, InferRouterInitialContexts, InferRouterInputs, InferRouterOutputs, type InferSchemaInput, type InferSchemaOutput, type InitialInputSchema, type InitialOutputSchema, type IntersectPick, Lazy, LazyDefinition, Lazyable, type MaybeOptionalOptions, MergedContext, type MergedErrorMap, MergedInitialContext, type MergedSchema, type Meta, type MetaPlugin, type MetaPluginDefinition, Middleware, MiddlewareDefinition, MiddlewareDone, MiddlewareDoneOptions, MiddlewareNext, MiddlewareNextOptions, MiddlewareOptions, MiddlewareResult, ORPCError, type ORPCErrorCode, type ORPCErrorConstructorMap, type ORPCErrorConstructorMapItem, type ORPCErrorConstructorMapItemOptions, type ORPCErrorFactory, type ORPCErrorFactoryOptions, type ORPCErrorFromErrorMap, type ORPCErrorJSON, type ORPCErrorOptions, OrderedMiddleware, Procedure, ProcedureClient, ProcedureClientInterceptor, ProcedureClientInterceptorOptions, ProcedureClientOptions, ProcedureConfig, type ProcedureContract, type ProcedureContractDefinition, ProcedureDefinition, ProcedureHandler, ProcedureHandlerOptions, ProcedureImplementer, type PromiseWithError, type Public, type RPCJsonSerialization, type RPCJsonSerializationMeta, RPCJsonSerializer, type RPCJsonSerializerHandler, type RPCJsonSerializerOptions, RPCSerializer, type RPCSerializerOptions, type RPCSerializerSerializeOptions, type Registry, Router, RouterClient, type RouterContract, type RouterImplementer, type RouterImplementerWithMiddlewares, type SafeResult, type Schema, SharedRouterImplementer, type SharedRouterImplementerWithMiddlewares, type StandardBody, type StandardBodyHint, type StandardHeaders, type StandardLazyRequest, type StandardLazyResponse, type StandardMethod, type StandardRequest, type StandardResponse, type StandardUrl, type ThrowableError, type UnlaziedRouter, ValidationError, type WalkProcedureContractsLazyResult, asyncIteratorObject, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, call, createProcedureClient, createRouterClient, defineMeta, error, eventIterator, eventIteratorToStream, eventIteratorToUnproxiedDataStream, getEventMeta, getRouter, implement, isDefinedError, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, os, resolveContractProcedure, safe, streamToAsyncIteratorObject, streamToEventIterator, toORPCError, type, unlazy, unlazyRouter, unwrapEvent, walkProcedureContractsAsync, walkProcedureContractsSync, withEventMeta };
|
package/dist/index.js
CHANGED
|
@@ -1,48 +1,16 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export {
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export {
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export {
|
|
17
|
-
export { COMMON_ERROR_STATUS_MAP, isDefinedError, ORPCError, RPCJsonSerializer, RPCSerializer, safe, toORPCError, } from '@orpc/client';
|
|
18
|
-
export { asyncIteratorObject, defineMeta, error, eventIterator, type, ValidationError, } from '@orpc/contract';
|
|
19
|
-
export { AsyncIteratorClass, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream,
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Use `asyncIteratorToStream` instead.
|
|
22
|
-
*/
|
|
23
|
-
asyncIteratorToStream as eventIteratorToStream,
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated Use `asyncIteratorToUnproxiedDataStream` instead.
|
|
26
|
-
*/
|
|
27
|
-
asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject,
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated Use `streamToAsyncIteratorObject` instead.
|
|
30
|
-
*/
|
|
31
|
-
streamToAsyncIteratorObject as streamToEventIterator, } from '@orpc/shared';
|
|
32
|
-
export {
|
|
33
|
-
/**
|
|
34
|
-
* @deprecated Use `EventStreamErrorEvent` instead.
|
|
35
|
-
*/
|
|
36
|
-
EventStreamErrorEvent as ErrorEvent, EventStreamErrorEvent,
|
|
37
|
-
/**
|
|
38
|
-
* Retrieves metadata attached to a single iterator event value.
|
|
39
|
-
*
|
|
40
|
-
* @see {@link https://orpc.dev/docs/helpers/publisher | Publisher Helpers}
|
|
41
|
-
*/
|
|
42
|
-
getEventMeta, unwrapEvent,
|
|
43
|
-
/**
|
|
44
|
-
* Returns a new iterator event value with attached, validated metadata.
|
|
45
|
-
*
|
|
46
|
-
* @see {@link https://orpc.dev/docs/async-iterator-object#last-event-id--event-metadata | AsyncIteratorObject (SSE) - Last Event ID & Event Metadata}
|
|
47
|
-
*/
|
|
48
|
-
withEventMeta, } from '@standard-server/core';
|
|
1
|
+
export { Builder, os } from "./builder.js";
|
|
2
|
+
export { DEFAULT_ERROR_STATUS, DEFAULT_SUCCESS_STATUS } from "./constants.js";
|
|
3
|
+
export { implement } from "./implementer.js";
|
|
4
|
+
export { ImplementedProcedure, ProcedureImplementer } from "./implementer-procedure.js";
|
|
5
|
+
export { SharedRouterImplementer } from "./implementer-router.js";
|
|
6
|
+
export { Lazy, unlazy } from "./lazy.js";
|
|
7
|
+
export { Procedure } from "./procedure.js";
|
|
8
|
+
export { createProcedureClient } from "./procedure-client.js";
|
|
9
|
+
export { DecoratedProcedure } from "./procedure-decorated.js";
|
|
10
|
+
export { call } from "./procedure-utils.js";
|
|
11
|
+
export { createRouterClient } from "./router-client.js";
|
|
12
|
+
export { getRouter, resolveContractProcedure, unlazyRouter, walkProcedureContractsAsync, walkProcedureContractsSync } from "./router-utils.js";
|
|
13
|
+
export { ValidationError, asyncIteratorObject, defineMeta, error, eventIterator, type } from "@orpc/contract";
|
|
14
|
+
export { AsyncIteratorClass, asyncIteratorToStream, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from "@orpc/shared";
|
|
15
|
+
export { COMMON_ERROR_STATUS_MAP, ORPCError, RPCJsonSerializer, RPCSerializer, isDefinedError, safe, toORPCError } from "@orpc/client";
|
|
16
|
+
export { EventStreamErrorEvent, EventStreamErrorEvent as ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from "@standard-server/core";
|
package/dist/lazy.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AnyMetaPlugin, Meta } from "@orpc/contract";
|
|
2
2
|
export interface LazyDefinition<T> {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
meta: Meta;
|
|
4
|
+
metaPlugins?: AnyMetaPlugin[] | undefined;
|
|
5
|
+
loader: () => Promise<{
|
|
6
|
+
default: T;
|
|
7
|
+
}>;
|
|
8
8
|
}
|
|
9
9
|
export declare class Lazy<T> {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
"~orpc": LazyDefinition<T>;
|
|
11
|
+
"constructor"(def: LazyDefinition<T>);
|
|
12
|
+
/**
|
|
13
|
+
* Checks if the given instance satisfies the {@link Lazy} class/interface.
|
|
14
|
+
*/
|
|
15
|
+
static [Symbol.hasInstance](instance: unknown): boolean;
|
|
16
16
|
}
|
|
17
17
|
export type Lazyable<T> = T | Lazy<T>;
|
|
18
18
|
export declare function unlazy<T extends Lazyable<any>>(maybeLazy: T): Promise<{
|
|
19
|
-
|
|
20
|
-
}>;
|
|
19
|
+
default: T extends Lazy<infer U> ? U : T;
|
|
20
|
+
}>;
|