@temporary-name/server 1.9.3-alpha.e2d8d164da72fb570c2b14a4fa956c80f9e33cdc → 1.9.3-alpha.edd373b82156a10608d43b19a44b75ae72e72de7

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.
Files changed (44) hide show
  1. package/dist/adapters/aws-lambda/index.d.mts +4 -6
  2. package/dist/adapters/aws-lambda/index.d.ts +4 -6
  3. package/dist/adapters/aws-lambda/index.mjs +4 -4
  4. package/dist/adapters/fetch/index.d.mts +8 -86
  5. package/dist/adapters/fetch/index.d.ts +8 -86
  6. package/dist/adapters/fetch/index.mjs +16 -155
  7. package/dist/adapters/node/index.d.mts +8 -63
  8. package/dist/adapters/node/index.d.ts +8 -63
  9. package/dist/adapters/node/index.mjs +14 -120
  10. package/dist/adapters/standard/index.d.mts +10 -7
  11. package/dist/adapters/standard/index.d.ts +10 -7
  12. package/dist/adapters/standard/index.mjs +4 -4
  13. package/dist/helpers/index.mjs +3 -29
  14. package/dist/index.d.mts +376 -242
  15. package/dist/index.d.ts +376 -242
  16. package/dist/index.mjs +482 -359
  17. package/dist/openapi/index.d.mts +18 -53
  18. package/dist/openapi/index.d.ts +18 -53
  19. package/dist/openapi/index.mjs +337 -347
  20. package/dist/shared/server.BCY45g2x.mjs +160 -0
  21. package/dist/shared/server.BETu17rq.mjs +319 -0
  22. package/dist/shared/server.B_oW_rPl.mjs +525 -0
  23. package/dist/shared/server.C1RJffw4.mjs +30 -0
  24. package/dist/shared/server.CQIFwyhc.mjs +40 -0
  25. package/dist/shared/server.CjPiuQYH.d.mts +51 -0
  26. package/dist/shared/server.CjPiuQYH.d.ts +51 -0
  27. package/dist/shared/server.Cq7SBLD5.mjs +403 -0
  28. package/dist/shared/server.DGH2Bq4t.d.mts +41 -0
  29. package/dist/shared/server.nQoUObAJ.d.ts +41 -0
  30. package/dist/shared/server.zsKBRxsz.d.mts +388 -0
  31. package/dist/shared/server.zsKBRxsz.d.ts +388 -0
  32. package/package.json +10 -28
  33. package/dist/plugins/index.d.mts +0 -160
  34. package/dist/plugins/index.d.ts +0 -160
  35. package/dist/plugins/index.mjs +0 -288
  36. package/dist/shared/server.B93y_8tj.d.mts +0 -23
  37. package/dist/shared/server.BYYf0Wn6.mjs +0 -202
  38. package/dist/shared/server.C3RuMHWl.d.mts +0 -192
  39. package/dist/shared/server.C3RuMHWl.d.ts +0 -192
  40. package/dist/shared/server.CT1xhSmE.d.mts +0 -56
  41. package/dist/shared/server.CqTex_jI.mjs +0 -265
  42. package/dist/shared/server.D_fags8X.d.ts +0 -23
  43. package/dist/shared/server.Kxw442A9.mjs +0 -247
  44. package/dist/shared/server.cjcgLdr1.d.ts +0 -56
@@ -1,192 +0,0 @@
1
- import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@temporary-name/contract';
2
- import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError, Promisable, HTTPPath, ClientContext, Interceptor, PromiseWithError, Value, Client } from '@temporary-name/shared';
3
-
4
- type Context = Record<PropertyKey, any>;
5
- type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
6
- type MergedCurrentContext<T extends Context, U extends Context> = Omit<T, keyof U> & U;
7
- declare function mergeCurrentContext<T extends Context, U extends Context>(context: T, other: U): MergedCurrentContext<T, U>;
8
-
9
- type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
10
- type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
11
- type ORPCErrorConstructorMap<T extends ErrorMap> = {
12
- [K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, InferSchemaInput<UInputSchema>> : never : never;
13
- };
14
- declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
15
-
16
- interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
17
- context: TCurrentContext;
18
- input: TInput;
19
- path: readonly string[];
20
- procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
21
- signal?: AbortSignal;
22
- lastEventId: string | undefined;
23
- errors: TErrorConstructorMap;
24
- }
25
- interface ProcedureHandler<TCurrentContext extends Context, TInput, THandlerOutput, TErrorMap extends ErrorMap, TMeta extends Meta> {
26
- (opt: ProcedureHandlerOptions<TCurrentContext, TInput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<THandlerOutput>;
27
- }
28
- interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
29
- __initialContext?: (type: TInitialContext) => unknown;
30
- middlewares: readonly AnyMiddleware[];
31
- inputValidationIndex: number;
32
- outputValidationIndex: number;
33
- handler: ProcedureHandler<TCurrentContext, any, any, any, any>;
34
- }
35
- /**
36
- * This class represents a procedure.
37
- *
38
- * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
39
- */
40
- declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
41
- /**
42
- * This property holds the defined options.
43
- */
44
- '~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
45
- constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
46
- }
47
- type AnyProcedure = Procedure<any, any, AnySchema, AnySchema, any, any>;
48
- declare function isProcedure(item: unknown): item is AnyProcedure;
49
-
50
- type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
51
- output: TOutput;
52
- context: TOutContext;
53
- }>;
54
- type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never, never> extends TOutContext ? {
55
- context?: TOutContext;
56
- } : {
57
- context: TOutContext;
58
- };
59
- interface MiddlewareNextFn<TOutput> {
60
- <U extends Context = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
61
- }
62
- interface MiddlewareOutputFn<TOutput> {
63
- (output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
64
- }
65
- interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
66
- context: TInContext;
67
- path: readonly string[];
68
- procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
69
- signal?: AbortSignal;
70
- lastEventId: string | undefined;
71
- next: MiddlewareNextFn<TOutput>;
72
- errors: TErrorConstructorMap;
73
- }
74
- /**
75
- * A function that represents a middleware.
76
- *
77
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
78
- */
79
- interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
80
- (options: MiddlewareOptions<TInContext, TOutput, TErrorConstructorMap, TMeta>, input: TInput, output: MiddlewareOutputFn<TOutput>): Promisable<MiddlewareResult<TOutContext, TOutput>>;
81
- }
82
- type AnyMiddleware = Middleware<any, any, any, any, any, any>;
83
- interface MapInputMiddleware<TInput, TMappedInput> {
84
- (input: TInput): TMappedInput;
85
- }
86
- declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
87
-
88
- declare const LAZY_SYMBOL: unique symbol;
89
- interface LazyMeta {
90
- prefix?: HTTPPath;
91
- }
92
- interface Lazy<T> {
93
- [LAZY_SYMBOL]: {
94
- loader: () => Promise<{
95
- default: T;
96
- }>;
97
- meta: LazyMeta;
98
- };
99
- }
100
- type Lazyable<T> = T | Lazy<T>;
101
- /**
102
- * Creates a lazy-loaded item.
103
- *
104
- * @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
105
- */
106
- declare function lazy<T>(loader: () => Promise<{
107
- default: T;
108
- }>, meta?: LazyMeta): Lazy<T>;
109
- declare function isLazy(item: unknown): item is Lazy<any>;
110
- declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
111
- declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
112
- default: T extends Lazy<infer U> ? U : T;
113
- }>;
114
-
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
- /**
144
- * Represents a router, which defines a hierarchical structure of procedures.
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 };
@@ -1,192 +0,0 @@
1
- import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@temporary-name/contract';
2
- import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError, Promisable, HTTPPath, ClientContext, Interceptor, PromiseWithError, Value, Client } from '@temporary-name/shared';
3
-
4
- type Context = Record<PropertyKey, any>;
5
- type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
6
- type MergedCurrentContext<T extends Context, U extends Context> = Omit<T, keyof U> & U;
7
- declare function mergeCurrentContext<T extends Context, U extends Context>(context: T, other: U): MergedCurrentContext<T, U>;
8
-
9
- type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
10
- type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
11
- type ORPCErrorConstructorMap<T extends ErrorMap> = {
12
- [K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, InferSchemaInput<UInputSchema>> : never : never;
13
- };
14
- declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
15
-
16
- interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
17
- context: TCurrentContext;
18
- input: TInput;
19
- path: readonly string[];
20
- procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
21
- signal?: AbortSignal;
22
- lastEventId: string | undefined;
23
- errors: TErrorConstructorMap;
24
- }
25
- interface ProcedureHandler<TCurrentContext extends Context, TInput, THandlerOutput, TErrorMap extends ErrorMap, TMeta extends Meta> {
26
- (opt: ProcedureHandlerOptions<TCurrentContext, TInput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<THandlerOutput>;
27
- }
28
- interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
29
- __initialContext?: (type: TInitialContext) => unknown;
30
- middlewares: readonly AnyMiddleware[];
31
- inputValidationIndex: number;
32
- outputValidationIndex: number;
33
- handler: ProcedureHandler<TCurrentContext, any, any, any, any>;
34
- }
35
- /**
36
- * This class represents a procedure.
37
- *
38
- * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
39
- */
40
- declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
41
- /**
42
- * This property holds the defined options.
43
- */
44
- '~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
45
- constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
46
- }
47
- type AnyProcedure = Procedure<any, any, AnySchema, AnySchema, any, any>;
48
- declare function isProcedure(item: unknown): item is AnyProcedure;
49
-
50
- type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
51
- output: TOutput;
52
- context: TOutContext;
53
- }>;
54
- type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never, never> extends TOutContext ? {
55
- context?: TOutContext;
56
- } : {
57
- context: TOutContext;
58
- };
59
- interface MiddlewareNextFn<TOutput> {
60
- <U extends Context = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
61
- }
62
- interface MiddlewareOutputFn<TOutput> {
63
- (output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
64
- }
65
- interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
66
- context: TInContext;
67
- path: readonly string[];
68
- procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
69
- signal?: AbortSignal;
70
- lastEventId: string | undefined;
71
- next: MiddlewareNextFn<TOutput>;
72
- errors: TErrorConstructorMap;
73
- }
74
- /**
75
- * A function that represents a middleware.
76
- *
77
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
78
- */
79
- interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
80
- (options: MiddlewareOptions<TInContext, TOutput, TErrorConstructorMap, TMeta>, input: TInput, output: MiddlewareOutputFn<TOutput>): Promisable<MiddlewareResult<TOutContext, TOutput>>;
81
- }
82
- type AnyMiddleware = Middleware<any, any, any, any, any, any>;
83
- interface MapInputMiddleware<TInput, TMappedInput> {
84
- (input: TInput): TMappedInput;
85
- }
86
- declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
87
-
88
- declare const LAZY_SYMBOL: unique symbol;
89
- interface LazyMeta {
90
- prefix?: HTTPPath;
91
- }
92
- interface Lazy<T> {
93
- [LAZY_SYMBOL]: {
94
- loader: () => Promise<{
95
- default: T;
96
- }>;
97
- meta: LazyMeta;
98
- };
99
- }
100
- type Lazyable<T> = T | Lazy<T>;
101
- /**
102
- * Creates a lazy-loaded item.
103
- *
104
- * @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
105
- */
106
- declare function lazy<T>(loader: () => Promise<{
107
- default: T;
108
- }>, meta?: LazyMeta): Lazy<T>;
109
- declare function isLazy(item: unknown): item is Lazy<any>;
110
- declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
111
- declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
112
- default: T extends Lazy<infer U> ? U : T;
113
- }>;
114
-
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
- /**
144
- * Represents a router, which defines a hierarchical structure of procedures.
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 };
@@ -1,56 +0,0 @@
1
- import { Meta } from '@temporary-name/contract';
2
- import { HTTPPath, Interceptor } from '@temporary-name/shared';
3
- import { StandardLazyRequest, StandardResponse } from '@temporary-name/standard-server';
4
- import { C as Context, R as Router, E as ProcedureClientInterceptorOptions } from './server.C3RuMHWl.mjs';
5
-
6
- interface StandardHandlerPlugin<T extends Context> {
7
- order?: number;
8
- init?(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
9
- }
10
- declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends StandardHandlerPlugin<T>> implements StandardHandlerPlugin<T> {
11
- protected readonly plugins: TPlugin[];
12
- constructor(plugins?: readonly TPlugin[]);
13
- init(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
14
- }
15
-
16
- interface StandardHandleOptions<T extends Context> {
17
- prefix?: HTTPPath;
18
- context: T;
19
- }
20
- type StandardHandleResult = {
21
- matched: true;
22
- response: StandardResponse;
23
- } | {
24
- matched: false;
25
- response: undefined;
26
- };
27
- interface StandardHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
28
- request: StandardLazyRequest;
29
- }
30
- interface StandardHandlerOptions<TContext extends Context> {
31
- plugins?: StandardHandlerPlugin<TContext>[];
32
- /**
33
- * Interceptors at the request level, helpful when you want catch errors
34
- */
35
- interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, Promise<StandardHandleResult>>[];
36
- /**
37
- * Interceptors at the root level, helpful when you want override the request/response
38
- */
39
- rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, Promise<StandardHandleResult>>[];
40
- /**
41
- *
42
- * Interceptors for procedure client.
43
- */
44
- clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, Promise<unknown>>[];
45
- }
46
- declare class StandardHandler<T extends Context> {
47
- private readonly interceptors;
48
- private readonly clientInterceptors;
49
- private readonly rootInterceptors;
50
- private readonly matcher;
51
- constructor(router: Router<any, T>, options: NoInfer<StandardHandlerOptions<T>>);
52
- handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
53
- }
54
-
55
- export { CompositeStandardHandlerPlugin as C, StandardHandler as e };
56
- export type { StandardHandlerInterceptorOptions as S, StandardHandlerPlugin as a, StandardHandlerOptions as b, StandardHandleOptions as c, StandardHandleResult as d };