@temporary-name/server 1.9.3-alpha.121f1a14eceb7f2aa23c6993c2adce0ccca377db → 1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3
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/index.d.mts +3 -3
- package/dist/adapters/aws-lambda/index.d.ts +3 -3
- package/dist/adapters/aws-lambda/index.mjs +4 -3
- package/dist/adapters/fetch/index.d.mts +3 -3
- package/dist/adapters/fetch/index.d.ts +3 -3
- package/dist/adapters/fetch/index.mjs +4 -3
- package/dist/adapters/node/index.d.mts +3 -3
- package/dist/adapters/node/index.d.ts +3 -3
- package/dist/adapters/node/index.mjs +4 -3
- package/dist/adapters/standard/index.d.mts +14 -30
- package/dist/adapters/standard/index.d.ts +14 -30
- package/dist/adapters/standard/index.mjs +4 -3
- package/dist/index.d.mts +19 -1018
- package/dist/index.d.ts +19 -1018
- package/dist/index.mjs +47 -1878
- package/dist/openapi/index.mjs +27 -61
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/{server.BeuTpcmO.d.mts → server.BYnDyuDL.d.mts} +2 -2
- package/dist/shared/{server.CQyYNJ1H.d.ts → server.BlJrjUA9.d.mts} +1 -2
- package/dist/shared/{server.C1fnTLq0.d.mts → server.C-tNYmY_.d.ts} +1 -2
- package/dist/shared/server.CjkiSCui.mjs +396 -0
- package/dist/shared/{server.CMTfy2UB.mjs → server.DdHBdcen.mjs} +58 -89
- package/dist/shared/{server.SLLuK6_v.d.ts → server.JI4dqTgD.d.ts} +2 -2
- package/dist/shared/{server.BEHw7Eyx.mjs → server.Kxw442A9.mjs} +1 -1
- package/dist/shared/{server.BKSOrA6h.d.mts → server.WsFQIubj.d.mts} +103 -60
- package/dist/shared/{server.BKSOrA6h.d.ts → server.WsFQIubj.d.ts} +103 -60
- package/package.json +10 -9
- package/dist/shared/server.BZtKt8i8.mjs +0 -201
|
@@ -1,67 +1,45 @@
|
|
|
1
|
-
import { isObject, stringifyJSON, isORPCErrorStatus, tryDecodeURIComponent,
|
|
1
|
+
import { isObject, stringifyJSON, isORPCErrorStatus, tryDecodeURIComponent, toHttpPath, toArray, intercept, runWithSpan, ORPC_NAME, isAsyncIteratorObject, asyncIteratorWithSpan, setSpanError, ORPCError, toORPCError } from '@temporary-name/shared';
|
|
2
2
|
import { flattenHeader } from '@temporary-name/standard-server';
|
|
3
|
-
import { c as createProcedureClient } from './server.
|
|
3
|
+
import { c as createProcedureClient } from './server.CjkiSCui.mjs';
|
|
4
4
|
import { fallbackContractConfig } from '@temporary-name/contract';
|
|
5
|
-
import { d as deserialize, s as serialize, a as standardizeHTTPPath } from './server.
|
|
5
|
+
import { d as deserialize, s as serialize, b as bracketNotationDeserialize, a as standardizeHTTPPath } from './server.Kxw442A9.mjs';
|
|
6
6
|
import { traverseContractProcedures, isProcedure, getLazyMeta, unlazy, getRouter, createContractedProcedure } from '@temporary-name/server';
|
|
7
7
|
import { createRouter, addRoute, findRoute } from 'rou3';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
async function decode(request, pathParams) {
|
|
10
|
+
const deserializeSearchParams = () => {
|
|
11
|
+
return bracketNotationDeserialize(Array.from(request.url.searchParams.entries()));
|
|
12
|
+
};
|
|
13
|
+
const data = request.method === "GET" ? deserializeSearchParams() : deserialize(await request.body());
|
|
14
|
+
if (data === void 0) {
|
|
15
|
+
return pathParams;
|
|
11
16
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
);
|
|
17
|
-
if (inputStructure === "compact") {
|
|
18
|
-
const data = request.method === "GET" ? deserialize(request.url.searchParams) : deserialize(await request.body());
|
|
19
|
-
if (data === void 0) {
|
|
20
|
-
return params;
|
|
21
|
-
}
|
|
22
|
-
if (isObject(data)) {
|
|
23
|
-
return {
|
|
24
|
-
...params,
|
|
25
|
-
...data
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
return data;
|
|
29
|
-
}
|
|
30
|
-
const deserializeSearchParams = () => {
|
|
31
|
-
return deserialize(request.url.searchParams);
|
|
17
|
+
if (isObject(data)) {
|
|
18
|
+
return {
|
|
19
|
+
...pathParams,
|
|
20
|
+
...data
|
|
32
21
|
};
|
|
22
|
+
}
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
25
|
+
function encode(output, procedure) {
|
|
26
|
+
const successStatus = fallbackContractConfig(
|
|
27
|
+
"defaultSuccessStatus",
|
|
28
|
+
procedure["~orpc"].route.successStatus
|
|
29
|
+
);
|
|
30
|
+
const outputStructure = fallbackContractConfig(
|
|
31
|
+
"defaultOutputStructure",
|
|
32
|
+
procedure["~orpc"].route.outputStructure
|
|
33
|
+
);
|
|
34
|
+
if (outputStructure === "compact") {
|
|
33
35
|
return {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Object.defineProperty(this, "query", { value, writable: true });
|
|
38
|
-
return value;
|
|
39
|
-
},
|
|
40
|
-
set query(value) {
|
|
41
|
-
Object.defineProperty(this, "query", { value, writable: true });
|
|
42
|
-
},
|
|
43
|
-
headers: request.headers,
|
|
44
|
-
body: deserialize(await request.body())
|
|
36
|
+
status: successStatus,
|
|
37
|
+
headers: {},
|
|
38
|
+
body: serialize(output)
|
|
45
39
|
};
|
|
46
40
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"defaultSuccessStatus",
|
|
50
|
-
procedure["~orpc"].route.successStatus
|
|
51
|
-
);
|
|
52
|
-
const outputStructure = fallbackContractConfig(
|
|
53
|
-
"defaultOutputStructure",
|
|
54
|
-
procedure["~orpc"].route.outputStructure
|
|
55
|
-
);
|
|
56
|
-
if (outputStructure === "compact") {
|
|
57
|
-
return {
|
|
58
|
-
status: successStatus,
|
|
59
|
-
headers: {},
|
|
60
|
-
body: serialize(output)
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
if (!this.#isDetailedOutput(output)) {
|
|
64
|
-
throw new Error(`
|
|
41
|
+
if (!isDetailedOutput(output)) {
|
|
42
|
+
throw new Error(`
|
|
65
43
|
Invalid "detailed" output structure:
|
|
66
44
|
\u2022 Expected an object with optional properties:
|
|
67
45
|
- status (number 200-399)
|
|
@@ -72,32 +50,31 @@ class StandardOpenAPICodec {
|
|
|
72
50
|
Actual value:
|
|
73
51
|
${stringifyJSON(output)}
|
|
74
52
|
`);
|
|
75
|
-
}
|
|
76
|
-
return {
|
|
77
|
-
status: output.status ?? successStatus,
|
|
78
|
-
headers: output.headers ?? {},
|
|
79
|
-
body: serialize(output.body)
|
|
80
|
-
};
|
|
81
53
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
54
|
+
return {
|
|
55
|
+
status: output.status ?? successStatus,
|
|
56
|
+
headers: output.headers ?? {},
|
|
57
|
+
body: serialize(output.body)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function encodeError(error) {
|
|
61
|
+
return {
|
|
62
|
+
status: error.status,
|
|
63
|
+
headers: {},
|
|
64
|
+
body: serialize(error.toJSON(), { outputFormat: "plain" })
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function isDetailedOutput(output) {
|
|
68
|
+
if (!isObject(output)) {
|
|
69
|
+
return false;
|
|
88
70
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
if (output.status !== void 0 && (typeof output.status !== "number" || !Number.isInteger(output.status) || isORPCErrorStatus(output.status))) {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
return true;
|
|
71
|
+
if (output.headers && !isObject(output.headers)) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (output.status !== void 0 && (typeof output.status !== "number" || !Number.isInteger(output.status) || isORPCErrorStatus(output.status))) {
|
|
75
|
+
return false;
|
|
100
76
|
}
|
|
77
|
+
return true;
|
|
101
78
|
}
|
|
102
79
|
|
|
103
80
|
function resolveFriendlyStandardHandleOptions(options) {
|
|
@@ -121,9 +98,6 @@ class StandardOpenAPIMatcher {
|
|
|
121
98
|
pendingRouters = [];
|
|
122
99
|
init(router, path = []) {
|
|
123
100
|
const laziedOptions = traverseContractProcedures({ router, path }, (traverseOptions) => {
|
|
124
|
-
if (!value(true, traverseOptions)) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
101
|
const { path: path2, contract } = traverseOptions;
|
|
128
102
|
const method = fallbackContractConfig("defaultMethod", contract["~orpc"].route.method);
|
|
129
103
|
const httpPath = toRou3Pattern(contract["~orpc"].route.path ?? toHttpPath(path2));
|
|
@@ -204,10 +178,8 @@ class StandardHandler {
|
|
|
204
178
|
clientInterceptors;
|
|
205
179
|
rootInterceptors;
|
|
206
180
|
matcher;
|
|
207
|
-
codec;
|
|
208
181
|
constructor(router, options) {
|
|
209
182
|
this.matcher = new StandardOpenAPIMatcher();
|
|
210
|
-
this.codec = new StandardOpenAPICodec();
|
|
211
183
|
const plugins = new CompositeStandardHandlerPlugin(options.plugins);
|
|
212
184
|
plugins.init(options, router);
|
|
213
185
|
this.interceptors = toArray(options.interceptors);
|
|
@@ -242,10 +214,7 @@ class StandardHandler {
|
|
|
242
214
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
243
215
|
span?.setAttribute("rpc.method", match.path.join("."));
|
|
244
216
|
step = "decode_input";
|
|
245
|
-
let input = await runWithSpan(
|
|
246
|
-
{ name: "decode_input" },
|
|
247
|
-
() => this.codec.decode(request2, match.params, match.procedure)
|
|
248
|
-
);
|
|
217
|
+
let input = await runWithSpan({ name: "decode_input" }, () => decode(request2, match.params));
|
|
249
218
|
step = void 0;
|
|
250
219
|
if (isAsyncIteratorObject(input)) {
|
|
251
220
|
input = asyncIteratorWithSpan(
|
|
@@ -264,7 +233,7 @@ class StandardHandler {
|
|
|
264
233
|
lastEventId: flattenHeader(request2.headers["last-event-id"])
|
|
265
234
|
});
|
|
266
235
|
step = void 0;
|
|
267
|
-
const response =
|
|
236
|
+
const response = encode(output, match.procedure);
|
|
268
237
|
return {
|
|
269
238
|
matched: true,
|
|
270
239
|
response
|
|
@@ -279,7 +248,7 @@ class StandardHandler {
|
|
|
279
248
|
message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
|
|
280
249
|
cause: e
|
|
281
250
|
}) : toORPCError(e);
|
|
282
|
-
const response =
|
|
251
|
+
const response = encodeError(error);
|
|
283
252
|
return {
|
|
284
253
|
matched: true,
|
|
285
254
|
response
|
|
@@ -290,4 +259,4 @@ class StandardHandler {
|
|
|
290
259
|
}
|
|
291
260
|
}
|
|
292
261
|
|
|
293
|
-
export { CompositeStandardHandlerPlugin as C, StandardHandler as S,
|
|
262
|
+
export { CompositeStandardHandlerPlugin as C, StandardHandler as S, encodeError as a, StandardOpenAPIMatcher as b, decodeParams as c, decode as d, encode as e, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HTTPPath } from '@temporary-name/shared';
|
|
2
|
-
import { C as Context } from './server.
|
|
3
|
-
import { c as StandardHandleOptions } from './server.
|
|
2
|
+
import { C as Context } from './server.WsFQIubj.js';
|
|
3
|
+
import { c as StandardHandleOptions } from './server.C-tNYmY_.js';
|
|
4
4
|
|
|
5
5
|
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
6
6
|
context?: T;
|
|
@@ -244,4 +244,4 @@ function getDynamicParams(path) {
|
|
|
244
244
|
})) : void 0;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
export { standardizeHTTPPath as a, deserialize as d, getDynamicParams as g, jsonSerialize as j, serialize as s };
|
|
247
|
+
export { standardizeHTTPPath as a, bracketNotationDeserialize as b, deserialize as d, getDynamicParams as g, jsonSerialize as j, serialize as s };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput,
|
|
2
|
-
import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError,
|
|
1
|
+
import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, AnyContractRouter, ContractProcedure, InferSchemaOutput, EnhanceRouteOptions, MergedErrorMap, AnyContractProcedure, ContractRouter, ErrorFromErrorMap } from '@temporary-name/contract';
|
|
2
|
+
import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError, Promisable, HTTPPath, ClientContext, Interceptor, PromiseWithError, Value, Client } from '@temporary-name/shared';
|
|
3
3
|
|
|
4
4
|
type Context = Record<PropertyKey, any>;
|
|
5
5
|
type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
|
|
@@ -13,33 +13,6 @@ type ORPCErrorConstructorMap<T extends ErrorMap> = {
|
|
|
13
13
|
};
|
|
14
14
|
declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
|
|
15
15
|
|
|
16
|
-
declare const LAZY_SYMBOL: unique symbol;
|
|
17
|
-
interface LazyMeta {
|
|
18
|
-
prefix?: HTTPPath;
|
|
19
|
-
}
|
|
20
|
-
interface Lazy<T> {
|
|
21
|
-
[LAZY_SYMBOL]: {
|
|
22
|
-
loader: () => Promise<{
|
|
23
|
-
default: T;
|
|
24
|
-
}>;
|
|
25
|
-
meta: LazyMeta;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
type Lazyable<T> = T | Lazy<T>;
|
|
29
|
-
/**
|
|
30
|
-
* Creates a lazy-loaded item.
|
|
31
|
-
*
|
|
32
|
-
* @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
|
|
33
|
-
*/
|
|
34
|
-
declare function lazy<T>(loader: () => Promise<{
|
|
35
|
-
default: T;
|
|
36
|
-
}>, meta?: LazyMeta): Lazy<T>;
|
|
37
|
-
declare function isLazy(item: unknown): item is Lazy<any>;
|
|
38
|
-
declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
|
|
39
|
-
declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
|
40
|
-
default: T extends Lazy<infer U> ? U : T;
|
|
41
|
-
}>;
|
|
42
|
-
|
|
43
16
|
interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
|
44
17
|
context: TCurrentContext;
|
|
45
18
|
input: TInput;
|
|
@@ -71,7 +44,7 @@ declare class Procedure<TInitialContext extends Context, TCurrentContext extends
|
|
|
71
44
|
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
72
45
|
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
|
73
46
|
}
|
|
74
|
-
type AnyProcedure = Procedure<any, any,
|
|
47
|
+
type AnyProcedure = Procedure<any, any, AnySchema, AnySchema, any, any>;
|
|
75
48
|
declare function isProcedure(item: unknown): item is AnyProcedure;
|
|
76
49
|
|
|
77
50
|
type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
|
@@ -112,34 +85,6 @@ interface MapInputMiddleware<TInput, TMappedInput> {
|
|
|
112
85
|
}
|
|
113
86
|
declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
|
114
87
|
|
|
115
|
-
type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
|
116
|
-
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
117
|
-
context: TInitialContext;
|
|
118
|
-
input: unknown;
|
|
119
|
-
errors: ORPCErrorConstructorMap<TErrorMap>;
|
|
120
|
-
path: readonly string[];
|
|
121
|
-
procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
|
|
122
|
-
signal?: AbortSignal;
|
|
123
|
-
lastEventId: string | undefined;
|
|
124
|
-
}
|
|
125
|
-
type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
|
|
126
|
-
/**
|
|
127
|
-
* This is helpful for logging and analytics.
|
|
128
|
-
*/
|
|
129
|
-
path?: readonly string[];
|
|
130
|
-
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, PromiseWithError<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>>[];
|
|
131
|
-
} & (Record<never, never> extends TInitialContext ? {
|
|
132
|
-
context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
133
|
-
} : {
|
|
134
|
-
context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
135
|
-
});
|
|
136
|
-
/**
|
|
137
|
-
* Create Server-side client from a procedure.
|
|
138
|
-
*
|
|
139
|
-
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
140
|
-
*/
|
|
141
|
-
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
142
|
-
|
|
143
88
|
/**
|
|
144
89
|
* Represents a router, which defines a hierarchical structure of procedures.
|
|
145
90
|
*
|
|
@@ -188,5 +133,103 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
|
|
|
188
133
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
|
189
134
|
};
|
|
190
135
|
|
|
191
|
-
|
|
192
|
-
|
|
136
|
+
declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
|
|
137
|
+
type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : T extends AnyProcedure | undefined ? Lazy<T> : Lazy<T> & {
|
|
138
|
+
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
|
|
139
|
+
};
|
|
140
|
+
declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
|
|
141
|
+
type EnhancedRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap> = T extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>> : T extends (Procedure<infer UInitialContext, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta>) ? Procedure<MergedInitialContext<TInitialContext, UInitialContext, TCurrentContext>, UCurrentContext, UInputSchema, UOutputSchema, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
|
|
142
|
+
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext, TErrorMap> : never;
|
|
143
|
+
};
|
|
144
|
+
interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
|
|
145
|
+
middlewares: readonly AnyMiddleware[];
|
|
146
|
+
errorMap: TErrorMap;
|
|
147
|
+
dedupeLeadingMiddlewares: boolean;
|
|
148
|
+
}
|
|
149
|
+
declare function enhanceRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap>(router: T, options: EnhanceRouterOptions<TErrorMap>): EnhancedRouter<T, TInitialContext, TCurrentContext, TErrorMap>;
|
|
150
|
+
interface TraverseContractProceduresOptions {
|
|
151
|
+
router: AnyContractRouter | AnyRouter;
|
|
152
|
+
path: readonly string[];
|
|
153
|
+
}
|
|
154
|
+
interface TraverseContractProcedureCallbackOptions {
|
|
155
|
+
contract: AnyContractProcedure | AnyProcedure;
|
|
156
|
+
path: readonly string[];
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* @deprecated Use `TraverseContractProcedureCallbackOptions` instead.
|
|
160
|
+
*/
|
|
161
|
+
type ContractProcedureCallbackOptions = TraverseContractProcedureCallbackOptions;
|
|
162
|
+
interface LazyTraverseContractProceduresOptions {
|
|
163
|
+
router: Lazy<AnyRouter>;
|
|
164
|
+
path: readonly string[];
|
|
165
|
+
}
|
|
166
|
+
declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
|
|
167
|
+
declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void): Promise<void>;
|
|
168
|
+
type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
|
|
169
|
+
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
|
|
170
|
+
};
|
|
171
|
+
declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
|
|
172
|
+
|
|
173
|
+
declare const LAZY_SYMBOL: unique symbol;
|
|
174
|
+
interface LazyMeta {
|
|
175
|
+
prefix?: HTTPPath;
|
|
176
|
+
}
|
|
177
|
+
interface Lazy<T> {
|
|
178
|
+
[LAZY_SYMBOL]: {
|
|
179
|
+
loader: () => Promise<{
|
|
180
|
+
default: T;
|
|
181
|
+
}>;
|
|
182
|
+
meta: LazyMeta;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
type Lazyable<T> = T | Lazy<T>;
|
|
186
|
+
/**
|
|
187
|
+
* @internal
|
|
188
|
+
*/
|
|
189
|
+
declare function lazyInternal<T>(loader: () => Promise<{
|
|
190
|
+
default: T;
|
|
191
|
+
}>, meta?: LazyMeta): Lazy<T>;
|
|
192
|
+
/**
|
|
193
|
+
* Creates a lazy-loaded item.
|
|
194
|
+
*
|
|
195
|
+
* @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
|
|
196
|
+
*/
|
|
197
|
+
declare function lazy<T extends Router<ContractRouter<{}>, any>>(prefix: HTTPPath, loader: () => Promise<{
|
|
198
|
+
default: T;
|
|
199
|
+
}>): EnhancedRouter<Lazy<T>, {}, {}, {}>;
|
|
200
|
+
declare function isLazy(item: unknown): item is Lazy<any>;
|
|
201
|
+
declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
|
|
202
|
+
declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
|
203
|
+
default: T extends Lazy<infer U> ? U : T;
|
|
204
|
+
}>;
|
|
205
|
+
|
|
206
|
+
type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
|
207
|
+
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
208
|
+
context: TInitialContext;
|
|
209
|
+
input: unknown;
|
|
210
|
+
errors: ORPCErrorConstructorMap<TErrorMap>;
|
|
211
|
+
path: readonly string[];
|
|
212
|
+
procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
|
|
213
|
+
signal?: AbortSignal;
|
|
214
|
+
lastEventId: string | undefined;
|
|
215
|
+
}
|
|
216
|
+
type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
|
|
217
|
+
/**
|
|
218
|
+
* This is helpful for logging and analytics.
|
|
219
|
+
*/
|
|
220
|
+
path?: readonly string[];
|
|
221
|
+
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, PromiseWithError<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>>[];
|
|
222
|
+
} & (Record<never, never> extends TInitialContext ? {
|
|
223
|
+
context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
224
|
+
} : {
|
|
225
|
+
context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
226
|
+
});
|
|
227
|
+
/**
|
|
228
|
+
* Create Server-side client from a procedure.
|
|
229
|
+
*
|
|
230
|
+
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
231
|
+
*/
|
|
232
|
+
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
233
|
+
|
|
234
|
+
export { traverseContractProcedures as $, middlewareOutputFn as B, isProcedure as G, createProcedureClient as J, Procedure as P, getRouter as T, createAccessibleLazyRouter as V, enhanceRouter as W, resolveContractProcedures as a0, unlazyRouter as a2, mergeCurrentContext as m, createORPCErrorConstructorMap as n, LAZY_SYMBOL as o, lazyInternal as q, lazy as r, isLazy as s, getLazyMeta as t, unlazy as u };
|
|
235
|
+
export type { AnyMiddleware as A, Context as C, ProcedureHandlerOptions as D, EnhanceRouterOptions as E, ProcedureDef as F, ProcedureClientInterceptorOptions as H, InferRouterInitialContext as I, InferRouterInitialContexts as K, Lazy as L, Middleware as M, InferRouterCurrentContexts as N, ORPCErrorConstructorMap as O, InferRouterInputs as Q, Router as R, InferRouterOutputs as S, AccessibleLazyRouter as U, TraverseContractProceduresOptions as X, TraverseContractProcedureCallbackOptions as Y, ContractProcedureCallbackOptions as Z, LazyTraverseContractProceduresOptions as _, CreateProcedureClientOptions as a, UnlaziedRouter as a1, ProcedureClient as b, MergedInitialContext as c, MergedCurrentContext as d, ProcedureHandler as e, EnhancedRouter as f, MapInputMiddleware as g, AnyProcedure as h, Lazyable as i, AnyRouter as j, ORPCErrorConstructorMapItemOptions as k, ORPCErrorConstructorMapItem as l, LazyMeta as p, MiddlewareResult as v, MiddlewareNextFnOptions as w, MiddlewareNextFn as x, MiddlewareOutputFn as y, MiddlewareOptions as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput,
|
|
2
|
-
import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError,
|
|
1
|
+
import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, AnyContractRouter, ContractProcedure, InferSchemaOutput, EnhanceRouteOptions, MergedErrorMap, AnyContractProcedure, ContractRouter, ErrorFromErrorMap } from '@temporary-name/contract';
|
|
2
|
+
import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError, Promisable, HTTPPath, ClientContext, Interceptor, PromiseWithError, Value, Client } from '@temporary-name/shared';
|
|
3
3
|
|
|
4
4
|
type Context = Record<PropertyKey, any>;
|
|
5
5
|
type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
|
|
@@ -13,33 +13,6 @@ type ORPCErrorConstructorMap<T extends ErrorMap> = {
|
|
|
13
13
|
};
|
|
14
14
|
declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
|
|
15
15
|
|
|
16
|
-
declare const LAZY_SYMBOL: unique symbol;
|
|
17
|
-
interface LazyMeta {
|
|
18
|
-
prefix?: HTTPPath;
|
|
19
|
-
}
|
|
20
|
-
interface Lazy<T> {
|
|
21
|
-
[LAZY_SYMBOL]: {
|
|
22
|
-
loader: () => Promise<{
|
|
23
|
-
default: T;
|
|
24
|
-
}>;
|
|
25
|
-
meta: LazyMeta;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
type Lazyable<T> = T | Lazy<T>;
|
|
29
|
-
/**
|
|
30
|
-
* Creates a lazy-loaded item.
|
|
31
|
-
*
|
|
32
|
-
* @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
|
|
33
|
-
*/
|
|
34
|
-
declare function lazy<T>(loader: () => Promise<{
|
|
35
|
-
default: T;
|
|
36
|
-
}>, meta?: LazyMeta): Lazy<T>;
|
|
37
|
-
declare function isLazy(item: unknown): item is Lazy<any>;
|
|
38
|
-
declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
|
|
39
|
-
declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
|
40
|
-
default: T extends Lazy<infer U> ? U : T;
|
|
41
|
-
}>;
|
|
42
|
-
|
|
43
16
|
interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
|
44
17
|
context: TCurrentContext;
|
|
45
18
|
input: TInput;
|
|
@@ -71,7 +44,7 @@ declare class Procedure<TInitialContext extends Context, TCurrentContext extends
|
|
|
71
44
|
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
72
45
|
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
|
73
46
|
}
|
|
74
|
-
type AnyProcedure = Procedure<any, any,
|
|
47
|
+
type AnyProcedure = Procedure<any, any, AnySchema, AnySchema, any, any>;
|
|
75
48
|
declare function isProcedure(item: unknown): item is AnyProcedure;
|
|
76
49
|
|
|
77
50
|
type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
|
@@ -112,34 +85,6 @@ interface MapInputMiddleware<TInput, TMappedInput> {
|
|
|
112
85
|
}
|
|
113
86
|
declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
|
114
87
|
|
|
115
|
-
type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
|
116
|
-
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
117
|
-
context: TInitialContext;
|
|
118
|
-
input: unknown;
|
|
119
|
-
errors: ORPCErrorConstructorMap<TErrorMap>;
|
|
120
|
-
path: readonly string[];
|
|
121
|
-
procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
|
|
122
|
-
signal?: AbortSignal;
|
|
123
|
-
lastEventId: string | undefined;
|
|
124
|
-
}
|
|
125
|
-
type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
|
|
126
|
-
/**
|
|
127
|
-
* This is helpful for logging and analytics.
|
|
128
|
-
*/
|
|
129
|
-
path?: readonly string[];
|
|
130
|
-
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, PromiseWithError<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>>[];
|
|
131
|
-
} & (Record<never, never> extends TInitialContext ? {
|
|
132
|
-
context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
133
|
-
} : {
|
|
134
|
-
context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
135
|
-
});
|
|
136
|
-
/**
|
|
137
|
-
* Create Server-side client from a procedure.
|
|
138
|
-
*
|
|
139
|
-
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
140
|
-
*/
|
|
141
|
-
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
142
|
-
|
|
143
88
|
/**
|
|
144
89
|
* Represents a router, which defines a hierarchical structure of procedures.
|
|
145
90
|
*
|
|
@@ -188,5 +133,103 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
|
|
|
188
133
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
|
189
134
|
};
|
|
190
135
|
|
|
191
|
-
|
|
192
|
-
|
|
136
|
+
declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
|
|
137
|
+
type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : T extends AnyProcedure | undefined ? Lazy<T> : Lazy<T> & {
|
|
138
|
+
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
|
|
139
|
+
};
|
|
140
|
+
declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
|
|
141
|
+
type EnhancedRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap> = T extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>> : T extends (Procedure<infer UInitialContext, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta>) ? Procedure<MergedInitialContext<TInitialContext, UInitialContext, TCurrentContext>, UCurrentContext, UInputSchema, UOutputSchema, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
|
|
142
|
+
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext, TErrorMap> : never;
|
|
143
|
+
};
|
|
144
|
+
interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
|
|
145
|
+
middlewares: readonly AnyMiddleware[];
|
|
146
|
+
errorMap: TErrorMap;
|
|
147
|
+
dedupeLeadingMiddlewares: boolean;
|
|
148
|
+
}
|
|
149
|
+
declare function enhanceRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap>(router: T, options: EnhanceRouterOptions<TErrorMap>): EnhancedRouter<T, TInitialContext, TCurrentContext, TErrorMap>;
|
|
150
|
+
interface TraverseContractProceduresOptions {
|
|
151
|
+
router: AnyContractRouter | AnyRouter;
|
|
152
|
+
path: readonly string[];
|
|
153
|
+
}
|
|
154
|
+
interface TraverseContractProcedureCallbackOptions {
|
|
155
|
+
contract: AnyContractProcedure | AnyProcedure;
|
|
156
|
+
path: readonly string[];
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* @deprecated Use `TraverseContractProcedureCallbackOptions` instead.
|
|
160
|
+
*/
|
|
161
|
+
type ContractProcedureCallbackOptions = TraverseContractProcedureCallbackOptions;
|
|
162
|
+
interface LazyTraverseContractProceduresOptions {
|
|
163
|
+
router: Lazy<AnyRouter>;
|
|
164
|
+
path: readonly string[];
|
|
165
|
+
}
|
|
166
|
+
declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
|
|
167
|
+
declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void): Promise<void>;
|
|
168
|
+
type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
|
|
169
|
+
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
|
|
170
|
+
};
|
|
171
|
+
declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
|
|
172
|
+
|
|
173
|
+
declare const LAZY_SYMBOL: unique symbol;
|
|
174
|
+
interface LazyMeta {
|
|
175
|
+
prefix?: HTTPPath;
|
|
176
|
+
}
|
|
177
|
+
interface Lazy<T> {
|
|
178
|
+
[LAZY_SYMBOL]: {
|
|
179
|
+
loader: () => Promise<{
|
|
180
|
+
default: T;
|
|
181
|
+
}>;
|
|
182
|
+
meta: LazyMeta;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
type Lazyable<T> = T | Lazy<T>;
|
|
186
|
+
/**
|
|
187
|
+
* @internal
|
|
188
|
+
*/
|
|
189
|
+
declare function lazyInternal<T>(loader: () => Promise<{
|
|
190
|
+
default: T;
|
|
191
|
+
}>, meta?: LazyMeta): Lazy<T>;
|
|
192
|
+
/**
|
|
193
|
+
* Creates a lazy-loaded item.
|
|
194
|
+
*
|
|
195
|
+
* @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
|
|
196
|
+
*/
|
|
197
|
+
declare function lazy<T extends Router<ContractRouter<{}>, any>>(prefix: HTTPPath, loader: () => Promise<{
|
|
198
|
+
default: T;
|
|
199
|
+
}>): EnhancedRouter<Lazy<T>, {}, {}, {}>;
|
|
200
|
+
declare function isLazy(item: unknown): item is Lazy<any>;
|
|
201
|
+
declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
|
|
202
|
+
declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
|
203
|
+
default: T extends Lazy<infer U> ? U : T;
|
|
204
|
+
}>;
|
|
205
|
+
|
|
206
|
+
type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
|
207
|
+
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
208
|
+
context: TInitialContext;
|
|
209
|
+
input: unknown;
|
|
210
|
+
errors: ORPCErrorConstructorMap<TErrorMap>;
|
|
211
|
+
path: readonly string[];
|
|
212
|
+
procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
|
|
213
|
+
signal?: AbortSignal;
|
|
214
|
+
lastEventId: string | undefined;
|
|
215
|
+
}
|
|
216
|
+
type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
|
|
217
|
+
/**
|
|
218
|
+
* This is helpful for logging and analytics.
|
|
219
|
+
*/
|
|
220
|
+
path?: readonly string[];
|
|
221
|
+
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, PromiseWithError<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>>[];
|
|
222
|
+
} & (Record<never, never> extends TInitialContext ? {
|
|
223
|
+
context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
224
|
+
} : {
|
|
225
|
+
context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
226
|
+
});
|
|
227
|
+
/**
|
|
228
|
+
* Create Server-side client from a procedure.
|
|
229
|
+
*
|
|
230
|
+
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
231
|
+
*/
|
|
232
|
+
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
233
|
+
|
|
234
|
+
export { traverseContractProcedures as $, middlewareOutputFn as B, isProcedure as G, createProcedureClient as J, Procedure as P, getRouter as T, createAccessibleLazyRouter as V, enhanceRouter as W, resolveContractProcedures as a0, unlazyRouter as a2, mergeCurrentContext as m, createORPCErrorConstructorMap as n, LAZY_SYMBOL as o, lazyInternal as q, lazy as r, isLazy as s, getLazyMeta as t, unlazy as u };
|
|
235
|
+
export type { AnyMiddleware as A, Context as C, ProcedureHandlerOptions as D, EnhanceRouterOptions as E, ProcedureDef as F, ProcedureClientInterceptorOptions as H, InferRouterInitialContext as I, InferRouterInitialContexts as K, Lazy as L, Middleware as M, InferRouterCurrentContexts as N, ORPCErrorConstructorMap as O, InferRouterInputs as Q, Router as R, InferRouterOutputs as S, AccessibleLazyRouter as U, TraverseContractProceduresOptions as X, TraverseContractProcedureCallbackOptions as Y, ContractProcedureCallbackOptions as Z, LazyTraverseContractProceduresOptions as _, CreateProcedureClientOptions as a, UnlaziedRouter as a1, ProcedureClient as b, MergedInitialContext as c, MergedCurrentContext as d, ProcedureHandler as e, EnhancedRouter as f, MapInputMiddleware as g, AnyProcedure as h, Lazyable as i, AnyRouter as j, ORPCErrorConstructorMapItemOptions as k, ORPCErrorConstructorMapItem as l, LazyMeta as p, MiddlewareResult as v, MiddlewareNextFnOptions as w, MiddlewareNextFn as x, MiddlewareOutputFn as y, MiddlewareOptions as z };
|