@temporary-name/server 1.9.3-alpha.3f3cdc28e4c507442c043c8988bb757a44b8785b → 1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a
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 +2 -2
- package/dist/adapters/fetch/index.d.mts +3 -3
- package/dist/adapters/fetch/index.d.ts +3 -3
- package/dist/adapters/fetch/index.mjs +2 -2
- package/dist/adapters/node/index.d.mts +3 -3
- package/dist/adapters/node/index.d.ts +3 -3
- package/dist/adapters/node/index.mjs +2 -2
- package/dist/adapters/standard/index.d.mts +3 -3
- package/dist/adapters/standard/index.d.ts +3 -3
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/index.d.mts +6 -43
- package/dist/index.d.ts +6 -43
- package/dist/index.mjs +5 -202
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/{server.B93y_8tj.d.mts → server.BYnDyuDL.d.mts} +2 -2
- package/dist/shared/{server.CT1xhSmE.d.mts → server.BlJrjUA9.d.mts} +1 -1
- package/dist/shared/{server.cjcgLdr1.d.ts → server.C-tNYmY_.d.ts} +1 -1
- package/dist/shared/{server.BYYf0Wn6.mjs → server.CjkiSCui.mjs} +197 -3
- package/dist/shared/{server.DIOj33oh.mjs → server.DdHBdcen.mjs} +1 -1
- package/dist/shared/{server.D_fags8X.d.ts → server.JI4dqTgD.d.ts} +2 -2
- package/dist/shared/{server.C3RuMHWl.d.mts → server.WsFQIubj.d.mts} +96 -53
- package/dist/shared/{server.C3RuMHWl.d.ts → server.WsFQIubj.d.ts} +96 -53
- package/package.json +10 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Meta } from '@temporary-name/contract';
|
|
2
2
|
import { HTTPPath, Interceptor } from '@temporary-name/shared';
|
|
3
3
|
import { StandardLazyRequest, StandardResponse } from '@temporary-name/standard-server';
|
|
4
|
-
import { C as Context, R as Router,
|
|
4
|
+
import { C as Context, R as Router, H as ProcedureClientInterceptorOptions } from './server.WsFQIubj.js';
|
|
5
5
|
|
|
6
6
|
interface StandardHandlerPlugin<T extends Context> {
|
|
7
7
|
order?: number;
|
|
@@ -1,8 +1,48 @@
|
|
|
1
|
-
import { validateORPCError, ValidationError } from '@temporary-name/contract';
|
|
1
|
+
import { isContractProcedure, mergePrefix, mergeErrorMap, enhanceRoute, validateORPCError, ValidationError } from '@temporary-name/contract';
|
|
2
2
|
import { resolveMaybeOptionalOptions, ORPCError, toArray, value, runWithSpan, intercept, isAsyncIteratorObject, overlayProxy, asyncIteratorWithSpan } from '@temporary-name/shared';
|
|
3
3
|
import { HibernationEventIterator, mapEventIterator } from '@temporary-name/standard-server';
|
|
4
4
|
import { safeParseAsync } from '@temporary-name/zod';
|
|
5
5
|
|
|
6
|
+
function isStartWithMiddlewares(middlewares, compare) {
|
|
7
|
+
if (compare.length > middlewares.length) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
for (let i = 0; i < middlewares.length; i++) {
|
|
11
|
+
if (compare[i] === void 0) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
if (middlewares[i] !== compare[i]) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
function mergeMiddlewares(first, second, options) {
|
|
21
|
+
if (options.dedupeLeading && isStartWithMiddlewares(second, first)) {
|
|
22
|
+
return second;
|
|
23
|
+
}
|
|
24
|
+
return [...first, ...second];
|
|
25
|
+
}
|
|
26
|
+
function addMiddleware(middlewares, addition) {
|
|
27
|
+
return [...middlewares, addition];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
class Procedure {
|
|
31
|
+
/**
|
|
32
|
+
* This property holds the defined options.
|
|
33
|
+
*/
|
|
34
|
+
"~orpc";
|
|
35
|
+
constructor(def) {
|
|
36
|
+
this["~orpc"] = def;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function isProcedure(item) {
|
|
40
|
+
if (item instanceof Procedure) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
return isContractProcedure(item) && "middlewares" in item["~orpc"] && "handler" in item["~orpc"];
|
|
44
|
+
}
|
|
45
|
+
|
|
6
46
|
function mergeCurrentContext(context, other) {
|
|
7
47
|
return { ...context, ...other };
|
|
8
48
|
}
|
|
@@ -30,8 +70,154 @@ function createORPCErrorConstructorMap(errors) {
|
|
|
30
70
|
return proxy;
|
|
31
71
|
}
|
|
32
72
|
|
|
73
|
+
const HIDDEN_ROUTER_CONTRACT_SYMBOL = Symbol("ORPC_HIDDEN_ROUTER_CONTRACT");
|
|
74
|
+
function setHiddenRouterContract(router, contract) {
|
|
75
|
+
return new Proxy(router, {
|
|
76
|
+
get(target, key) {
|
|
77
|
+
if (key === HIDDEN_ROUTER_CONTRACT_SYMBOL) {
|
|
78
|
+
return contract;
|
|
79
|
+
}
|
|
80
|
+
return Reflect.get(target, key);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function getHiddenRouterContract(router) {
|
|
85
|
+
return router[HIDDEN_ROUTER_CONTRACT_SYMBOL];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function getRouter(router, path) {
|
|
89
|
+
let current = router;
|
|
90
|
+
for (let i = 0; i < path.length; i++) {
|
|
91
|
+
const segment = path[i];
|
|
92
|
+
if (!current) {
|
|
93
|
+
return void 0;
|
|
94
|
+
}
|
|
95
|
+
if (isProcedure(current)) {
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
if (!isLazy(current)) {
|
|
99
|
+
current = current[segment];
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const lazied = current;
|
|
103
|
+
const rest = path.slice(i);
|
|
104
|
+
return lazyInternal(async () => {
|
|
105
|
+
const unwrapped = await unlazy(lazied);
|
|
106
|
+
const next = getRouter(unwrapped.default, rest);
|
|
107
|
+
return unlazy(next);
|
|
108
|
+
}, getLazyMeta(lazied));
|
|
109
|
+
}
|
|
110
|
+
return current;
|
|
111
|
+
}
|
|
112
|
+
function createAccessibleLazyRouter(lazied) {
|
|
113
|
+
const recursive = new Proxy(lazied, {
|
|
114
|
+
get(target, key) {
|
|
115
|
+
if (typeof key !== "string") {
|
|
116
|
+
return Reflect.get(target, key);
|
|
117
|
+
}
|
|
118
|
+
const next = getRouter(lazied, [key]);
|
|
119
|
+
return createAccessibleLazyRouter(next);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return recursive;
|
|
123
|
+
}
|
|
124
|
+
function enhanceRouter(router, options) {
|
|
125
|
+
if (isLazy(router)) {
|
|
126
|
+
const laziedMeta = getLazyMeta(router);
|
|
127
|
+
const enhancedPrefix = laziedMeta?.prefix ? mergePrefix(options.prefix, laziedMeta?.prefix) : options.prefix;
|
|
128
|
+
const enhanced2 = lazyInternal(
|
|
129
|
+
async () => {
|
|
130
|
+
const { default: unlaziedRouter } = await unlazy(router);
|
|
131
|
+
const enhanced3 = enhanceRouter(unlaziedRouter, options);
|
|
132
|
+
return unlazy(enhanced3);
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
...laziedMeta,
|
|
136
|
+
prefix: enhancedPrefix
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
const accessible = createAccessibleLazyRouter(enhanced2);
|
|
140
|
+
return accessible;
|
|
141
|
+
}
|
|
142
|
+
if (isProcedure(router)) {
|
|
143
|
+
const newMiddlewares = mergeMiddlewares(options.middlewares, router["~orpc"].middlewares, {
|
|
144
|
+
dedupeLeading: options.dedupeLeadingMiddlewares
|
|
145
|
+
});
|
|
146
|
+
const newMiddlewareAdded = newMiddlewares.length - router["~orpc"].middlewares.length;
|
|
147
|
+
const enhanced2 = new Procedure({
|
|
148
|
+
...router["~orpc"],
|
|
149
|
+
route: enhanceRoute(router["~orpc"].route, options),
|
|
150
|
+
errorMap: mergeErrorMap(options.errorMap, router["~orpc"].errorMap),
|
|
151
|
+
middlewares: newMiddlewares,
|
|
152
|
+
inputValidationIndex: router["~orpc"].inputValidationIndex + newMiddlewareAdded,
|
|
153
|
+
outputValidationIndex: router["~orpc"].outputValidationIndex + newMiddlewareAdded
|
|
154
|
+
});
|
|
155
|
+
return enhanced2;
|
|
156
|
+
}
|
|
157
|
+
const enhanced = {};
|
|
158
|
+
for (const key in router) {
|
|
159
|
+
enhanced[key] = enhanceRouter(router[key], options);
|
|
160
|
+
}
|
|
161
|
+
return enhanced;
|
|
162
|
+
}
|
|
163
|
+
function traverseContractProcedures(options, callback, lazyOptions = []) {
|
|
164
|
+
let currentRouter = options.router;
|
|
165
|
+
const hiddenContract = getHiddenRouterContract(options.router);
|
|
166
|
+
if (hiddenContract !== void 0) {
|
|
167
|
+
currentRouter = hiddenContract;
|
|
168
|
+
}
|
|
169
|
+
if (isLazy(currentRouter)) {
|
|
170
|
+
lazyOptions.push({
|
|
171
|
+
router: currentRouter,
|
|
172
|
+
path: options.path
|
|
173
|
+
});
|
|
174
|
+
} else if (isContractProcedure(currentRouter)) {
|
|
175
|
+
callback({
|
|
176
|
+
contract: currentRouter,
|
|
177
|
+
path: options.path
|
|
178
|
+
});
|
|
179
|
+
} else {
|
|
180
|
+
for (const key in currentRouter) {
|
|
181
|
+
traverseContractProcedures(
|
|
182
|
+
{
|
|
183
|
+
router: currentRouter[key],
|
|
184
|
+
path: [...options.path, key]
|
|
185
|
+
},
|
|
186
|
+
callback,
|
|
187
|
+
lazyOptions
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return lazyOptions;
|
|
192
|
+
}
|
|
193
|
+
async function resolveContractProcedures(options, callback) {
|
|
194
|
+
const pending = [options];
|
|
195
|
+
for (const options2 of pending) {
|
|
196
|
+
const lazyOptions = traverseContractProcedures(options2, callback);
|
|
197
|
+
for (const options3 of lazyOptions) {
|
|
198
|
+
const { default: router } = await unlazy(options3.router);
|
|
199
|
+
pending.push({
|
|
200
|
+
router,
|
|
201
|
+
path: options3.path
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async function unlazyRouter(router) {
|
|
207
|
+
if (isProcedure(router)) {
|
|
208
|
+
return router;
|
|
209
|
+
}
|
|
210
|
+
const unlazied = {};
|
|
211
|
+
for (const key in router) {
|
|
212
|
+
const item = router[key];
|
|
213
|
+
const { default: unlaziedRouter } = await unlazy(item);
|
|
214
|
+
unlazied[key] = await unlazyRouter(unlaziedRouter);
|
|
215
|
+
}
|
|
216
|
+
return unlazied;
|
|
217
|
+
}
|
|
218
|
+
|
|
33
219
|
const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
|
|
34
|
-
function
|
|
220
|
+
function lazyInternal(loader, meta = {}) {
|
|
35
221
|
return {
|
|
36
222
|
[LAZY_SYMBOL]: {
|
|
37
223
|
loader,
|
|
@@ -39,6 +225,14 @@ function lazy(loader, meta = {}) {
|
|
|
39
225
|
}
|
|
40
226
|
};
|
|
41
227
|
}
|
|
228
|
+
function lazy(prefix, loader) {
|
|
229
|
+
return enhanceRouter(lazyInternal(loader), {
|
|
230
|
+
middlewares: [],
|
|
231
|
+
errorMap: {},
|
|
232
|
+
dedupeLeadingMiddlewares: true,
|
|
233
|
+
prefix
|
|
234
|
+
});
|
|
235
|
+
}
|
|
42
236
|
function isLazy(item) {
|
|
43
237
|
return (typeof item === "object" || typeof item === "function") && item !== null && LAZY_SYMBOL in item;
|
|
44
238
|
}
|
|
@@ -199,4 +393,4 @@ async function executeProcedureInternal(procedure, options) {
|
|
|
199
393
|
return next(0, options.context, options.input);
|
|
200
394
|
}
|
|
201
395
|
|
|
202
|
-
export { LAZY_SYMBOL as L,
|
|
396
|
+
export { LAZY_SYMBOL as L, Procedure as P, addMiddleware as a, isLazy as b, createProcedureClient as c, getRouter as d, enhanceRouter as e, createORPCErrorConstructorMap as f, getLazyMeta as g, lazy as h, isProcedure as i, middlewareOutputFn as j, isStartWithMiddlewares as k, lazyInternal as l, mergeCurrentContext as m, mergeMiddlewares as n, getHiddenRouterContract as o, createAccessibleLazyRouter as p, unlazyRouter as q, resolveContractProcedures as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
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
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';
|
|
@@ -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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput,
|
|
1
|
+
import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, AnyContractRouter, ContractProcedure, InferSchemaOutput, EnhanceRouteOptions, MergedErrorMap, AnyContractProcedure, ContractRouter, ErrorFromErrorMap } from '@temporary-name/contract';
|
|
2
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>;
|
|
@@ -85,6 +85,91 @@ interface MapInputMiddleware<TInput, TMappedInput> {
|
|
|
85
85
|
}
|
|
86
86
|
declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Represents a router, which defines a hierarchical structure of procedures.
|
|
90
|
+
*
|
|
91
|
+
* @info A procedure is a router too.
|
|
92
|
+
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
|
|
93
|
+
*/
|
|
94
|
+
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, UErrorMap, UMeta> : {
|
|
95
|
+
[K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
|
|
96
|
+
};
|
|
97
|
+
type AnyRouter = Router<any, any>;
|
|
98
|
+
type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infer UInitialContext> ? UInitialContext : never;
|
|
99
|
+
/**
|
|
100
|
+
* Infer all initial context of the router.
|
|
101
|
+
*
|
|
102
|
+
* @info A procedure is a router too.
|
|
103
|
+
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
104
|
+
*/
|
|
105
|
+
type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any, any> ? UInitialContext : {
|
|
106
|
+
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Infer all current context of the router.
|
|
110
|
+
*
|
|
111
|
+
* @info A procedure is a router too.
|
|
112
|
+
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
113
|
+
*/
|
|
114
|
+
type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any, any> ? UCurrentContext : {
|
|
115
|
+
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Infer all router inputs
|
|
119
|
+
*
|
|
120
|
+
* @info A procedure is a router too.
|
|
121
|
+
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
122
|
+
*/
|
|
123
|
+
type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
|
|
124
|
+
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Infer all router outputs
|
|
128
|
+
*
|
|
129
|
+
* @info A procedure is a router too.
|
|
130
|
+
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
131
|
+
*/
|
|
132
|
+
type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
|
|
133
|
+
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
|
134
|
+
};
|
|
135
|
+
|
|
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
|
+
|
|
88
173
|
declare const LAZY_SYMBOL: unique symbol;
|
|
89
174
|
interface LazyMeta {
|
|
90
175
|
prefix?: HTTPPath;
|
|
@@ -98,14 +183,20 @@ interface Lazy<T> {
|
|
|
98
183
|
};
|
|
99
184
|
}
|
|
100
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>;
|
|
101
192
|
/**
|
|
102
193
|
* Creates a lazy-loaded item.
|
|
103
194
|
*
|
|
104
195
|
* @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
|
|
105
196
|
*/
|
|
106
|
-
declare function lazy<T
|
|
197
|
+
declare function lazy<T extends Router<ContractRouter<{}>, any>>(prefix: HTTPPath, loader: () => Promise<{
|
|
107
198
|
default: T;
|
|
108
|
-
}
|
|
199
|
+
}>): EnhancedRouter<Lazy<T>, {}, {}, {}>;
|
|
109
200
|
declare function isLazy(item: unknown): item is Lazy<any>;
|
|
110
201
|
declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
|
|
111
202
|
declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
|
@@ -140,53 +231,5 @@ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema
|
|
|
140
231
|
*/
|
|
141
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>;
|
|
142
233
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
*
|
|
146
|
-
* @info A procedure is a router too.
|
|
147
|
-
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
|
|
148
|
-
*/
|
|
149
|
-
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, UErrorMap, UMeta> : {
|
|
150
|
-
[K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
|
|
151
|
-
};
|
|
152
|
-
type AnyRouter = Router<any, any>;
|
|
153
|
-
type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infer UInitialContext> ? UInitialContext : never;
|
|
154
|
-
/**
|
|
155
|
-
* Infer all initial context of the router.
|
|
156
|
-
*
|
|
157
|
-
* @info A procedure is a router too.
|
|
158
|
-
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
159
|
-
*/
|
|
160
|
-
type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any, any> ? UInitialContext : {
|
|
161
|
-
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Infer all current context of the router.
|
|
165
|
-
*
|
|
166
|
-
* @info A procedure is a router too.
|
|
167
|
-
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
168
|
-
*/
|
|
169
|
-
type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any, any> ? UCurrentContext : {
|
|
170
|
-
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
|
|
171
|
-
};
|
|
172
|
-
/**
|
|
173
|
-
* Infer all router inputs
|
|
174
|
-
*
|
|
175
|
-
* @info A procedure is a router too.
|
|
176
|
-
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
177
|
-
*/
|
|
178
|
-
type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
|
|
179
|
-
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* Infer all router outputs
|
|
183
|
-
*
|
|
184
|
-
* @info A procedure is a router too.
|
|
185
|
-
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
186
|
-
*/
|
|
187
|
-
type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
|
|
188
|
-
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
export { isProcedure as D, createProcedureClient as F, Procedure as P, createORPCErrorConstructorMap as l, mergeCurrentContext as m, LAZY_SYMBOL as n, lazy as p, isLazy as q, getLazyMeta as r, unlazy as u, middlewareOutputFn as y };
|
|
192
|
-
export type { AnyMiddleware as A, ProcedureDef as B, Context as C, ProcedureClientInterceptorOptions as E, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L, MergedInitialContext as M, ORPCErrorConstructorMap as O, Router as R, CreateProcedureClientOptions as a, ProcedureClient as b, AnyRouter as c, Lazy as d, AnyProcedure as e, Middleware as f, MergedCurrentContext as g, ProcedureHandler as h, MapInputMiddleware as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as v, MiddlewareOutputFn as w, MiddlewareOptions as x, ProcedureHandlerOptions as z };
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput,
|
|
1
|
+
import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, AnyContractRouter, ContractProcedure, InferSchemaOutput, EnhanceRouteOptions, MergedErrorMap, AnyContractProcedure, ContractRouter, ErrorFromErrorMap } from '@temporary-name/contract';
|
|
2
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>;
|
|
@@ -85,6 +85,91 @@ interface MapInputMiddleware<TInput, TMappedInput> {
|
|
|
85
85
|
}
|
|
86
86
|
declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Represents a router, which defines a hierarchical structure of procedures.
|
|
90
|
+
*
|
|
91
|
+
* @info A procedure is a router too.
|
|
92
|
+
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
|
|
93
|
+
*/
|
|
94
|
+
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, UErrorMap, UMeta> : {
|
|
95
|
+
[K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
|
|
96
|
+
};
|
|
97
|
+
type AnyRouter = Router<any, any>;
|
|
98
|
+
type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infer UInitialContext> ? UInitialContext : never;
|
|
99
|
+
/**
|
|
100
|
+
* Infer all initial context of the router.
|
|
101
|
+
*
|
|
102
|
+
* @info A procedure is a router too.
|
|
103
|
+
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
104
|
+
*/
|
|
105
|
+
type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any, any> ? UInitialContext : {
|
|
106
|
+
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Infer all current context of the router.
|
|
110
|
+
*
|
|
111
|
+
* @info A procedure is a router too.
|
|
112
|
+
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
113
|
+
*/
|
|
114
|
+
type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any, any> ? UCurrentContext : {
|
|
115
|
+
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Infer all router inputs
|
|
119
|
+
*
|
|
120
|
+
* @info A procedure is a router too.
|
|
121
|
+
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
122
|
+
*/
|
|
123
|
+
type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
|
|
124
|
+
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Infer all router outputs
|
|
128
|
+
*
|
|
129
|
+
* @info A procedure is a router too.
|
|
130
|
+
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
131
|
+
*/
|
|
132
|
+
type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
|
|
133
|
+
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
|
134
|
+
};
|
|
135
|
+
|
|
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
|
+
|
|
88
173
|
declare const LAZY_SYMBOL: unique symbol;
|
|
89
174
|
interface LazyMeta {
|
|
90
175
|
prefix?: HTTPPath;
|
|
@@ -98,14 +183,20 @@ interface Lazy<T> {
|
|
|
98
183
|
};
|
|
99
184
|
}
|
|
100
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>;
|
|
101
192
|
/**
|
|
102
193
|
* Creates a lazy-loaded item.
|
|
103
194
|
*
|
|
104
195
|
* @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
|
|
105
196
|
*/
|
|
106
|
-
declare function lazy<T
|
|
197
|
+
declare function lazy<T extends Router<ContractRouter<{}>, any>>(prefix: HTTPPath, loader: () => Promise<{
|
|
107
198
|
default: T;
|
|
108
|
-
}
|
|
199
|
+
}>): EnhancedRouter<Lazy<T>, {}, {}, {}>;
|
|
109
200
|
declare function isLazy(item: unknown): item is Lazy<any>;
|
|
110
201
|
declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
|
|
111
202
|
declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
|
@@ -140,53 +231,5 @@ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema
|
|
|
140
231
|
*/
|
|
141
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>;
|
|
142
233
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
*
|
|
146
|
-
* @info A procedure is a router too.
|
|
147
|
-
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
|
|
148
|
-
*/
|
|
149
|
-
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, UErrorMap, UMeta> : {
|
|
150
|
-
[K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
|
|
151
|
-
};
|
|
152
|
-
type AnyRouter = Router<any, any>;
|
|
153
|
-
type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infer UInitialContext> ? UInitialContext : never;
|
|
154
|
-
/**
|
|
155
|
-
* Infer all initial context of the router.
|
|
156
|
-
*
|
|
157
|
-
* @info A procedure is a router too.
|
|
158
|
-
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
159
|
-
*/
|
|
160
|
-
type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any, any> ? UInitialContext : {
|
|
161
|
-
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Infer all current context of the router.
|
|
165
|
-
*
|
|
166
|
-
* @info A procedure is a router too.
|
|
167
|
-
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
168
|
-
*/
|
|
169
|
-
type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any, any> ? UCurrentContext : {
|
|
170
|
-
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
|
|
171
|
-
};
|
|
172
|
-
/**
|
|
173
|
-
* Infer all router inputs
|
|
174
|
-
*
|
|
175
|
-
* @info A procedure is a router too.
|
|
176
|
-
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
177
|
-
*/
|
|
178
|
-
type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
|
|
179
|
-
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* Infer all router outputs
|
|
183
|
-
*
|
|
184
|
-
* @info A procedure is a router too.
|
|
185
|
-
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
186
|
-
*/
|
|
187
|
-
type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
|
|
188
|
-
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
export { isProcedure as D, createProcedureClient as F, Procedure as P, createORPCErrorConstructorMap as l, mergeCurrentContext as m, LAZY_SYMBOL as n, lazy as p, isLazy as q, getLazyMeta as r, unlazy as u, middlewareOutputFn as y };
|
|
192
|
-
export type { AnyMiddleware as A, ProcedureDef as B, Context as C, ProcedureClientInterceptorOptions as E, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L, MergedInitialContext as M, ORPCErrorConstructorMap as O, Router as R, CreateProcedureClientOptions as a, ProcedureClient as b, AnyRouter as c, Lazy as d, AnyProcedure as e, Middleware as f, MergedCurrentContext as g, ProcedureHandler as h, MapInputMiddleware as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as v, MiddlewareOutputFn as w, MiddlewareOptions as x, ProcedureHandlerOptions as z };
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporary-name/server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.9.3-alpha.
|
|
4
|
+
"version": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|
|
@@ -73,15 +73,15 @@
|
|
|
73
73
|
"cookie": "^1.0.2",
|
|
74
74
|
"rou3": "^0.7.7",
|
|
75
75
|
"zod": "^4.1.12",
|
|
76
|
-
"@temporary-name/contract": "1.9.3-alpha.
|
|
77
|
-
"@temporary-name/interop": "1.9.3-alpha.
|
|
78
|
-
"@temporary-name/json-schema": "1.9.3-alpha.
|
|
79
|
-
"@temporary-name/shared": "1.9.3-alpha.
|
|
80
|
-
"@temporary-name/standard-server": "1.9.3-alpha.
|
|
81
|
-
"@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.
|
|
82
|
-
"@temporary-name/standard-server-fetch": "1.9.3-alpha.
|
|
83
|
-
"@temporary-name/
|
|
84
|
-
"@temporary-name/
|
|
76
|
+
"@temporary-name/contract": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a",
|
|
77
|
+
"@temporary-name/interop": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a",
|
|
78
|
+
"@temporary-name/json-schema": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a",
|
|
79
|
+
"@temporary-name/shared": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a",
|
|
80
|
+
"@temporary-name/standard-server": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a",
|
|
81
|
+
"@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a",
|
|
82
|
+
"@temporary-name/standard-server-fetch": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a",
|
|
83
|
+
"@temporary-name/zod": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a",
|
|
84
|
+
"@temporary-name/standard-server-node": "1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@types/supertest": "^6.0.3",
|