@temporary-name/server 1.9.3-alpha.16e8a4f82a5b0af6e22263774a4af4e6f9afd8bc → 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 -6
- 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 -6
- 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 -6
- 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 -6
- package/dist/index.d.mts +41 -319
- package/dist/index.d.ts +41 -319
- package/dist/index.mjs +102 -352
- 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.DLsti1Pv.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.BKh8I1Ny.mjs +0 -239
|
@@ -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 };
|
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.26612c2cf6a7177d2b500d984d282309d8320ca3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|
|
@@ -71,16 +71,17 @@
|
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"cookie": "^1.0.2",
|
|
74
|
-
"@standard-schema/spec": "^1.0.0",
|
|
75
74
|
"rou3": "^0.7.7",
|
|
76
75
|
"zod": "^4.1.12",
|
|
77
|
-
"@temporary-name/contract": "1.9.3-alpha.
|
|
78
|
-
"@temporary-name/
|
|
79
|
-
"@temporary-name/
|
|
80
|
-
"@temporary-name/
|
|
81
|
-
"@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.
|
|
82
|
-
"@temporary-name/
|
|
83
|
-
"@temporary-name/standard-server-
|
|
76
|
+
"@temporary-name/contract": "1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3",
|
|
77
|
+
"@temporary-name/shared": "1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3",
|
|
78
|
+
"@temporary-name/json-schema": "1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3",
|
|
79
|
+
"@temporary-name/standard-server": "1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3",
|
|
80
|
+
"@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3",
|
|
81
|
+
"@temporary-name/interop": "1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3",
|
|
82
|
+
"@temporary-name/standard-server-fetch": "1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3",
|
|
83
|
+
"@temporary-name/zod": "1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3",
|
|
84
|
+
"@temporary-name/standard-server-node": "1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3"
|
|
84
85
|
},
|
|
85
86
|
"devDependencies": {
|
|
86
87
|
"@types/supertest": "^6.0.3",
|