@temporary-name/server 1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36 → 1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f

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 (36) hide show
  1. package/dist/adapters/aws-lambda/index.d.mts +3 -4
  2. package/dist/adapters/aws-lambda/index.d.ts +3 -4
  3. package/dist/adapters/aws-lambda/index.mjs +3 -3
  4. package/dist/adapters/fetch/index.d.mts +3 -4
  5. package/dist/adapters/fetch/index.d.ts +3 -4
  6. package/dist/adapters/fetch/index.mjs +3 -3
  7. package/dist/adapters/node/index.d.mts +3 -4
  8. package/dist/adapters/node/index.d.ts +3 -4
  9. package/dist/adapters/node/index.mjs +3 -3
  10. package/dist/adapters/standard/index.d.mts +10 -6
  11. package/dist/adapters/standard/index.d.ts +10 -6
  12. package/dist/adapters/standard/index.mjs +4 -4
  13. package/dist/helpers/index.mjs +3 -29
  14. package/dist/index.d.mts +73 -126
  15. package/dist/index.d.ts +73 -126
  16. package/dist/index.mjs +125 -234
  17. package/dist/openapi/index.d.mts +4 -4
  18. package/dist/openapi/index.d.ts +4 -4
  19. package/dist/openapi/index.mjs +61 -128
  20. package/dist/plugins/index.d.mts +5 -83
  21. package/dist/plugins/index.d.ts +5 -83
  22. package/dist/plugins/index.mjs +17 -189
  23. package/dist/shared/{server.Bk5r0-2R.d.ts → server.25yUS-xw.d.mts} +3 -4
  24. package/dist/shared/{server.Bs6ka_UE.d.mts → server.BKwU5-Ea.d.mts} +2 -2
  25. package/dist/shared/server.C1RJffw4.mjs +30 -0
  26. package/dist/shared/{server.CbLTWfgn.d.mts → server.Co-zpS8Y.d.ts} +3 -4
  27. package/dist/shared/{server.BVxcyR6X.mjs → server.DRYRuXpK.mjs} +17 -50
  28. package/dist/shared/{server.D2UFMrxf.d.ts → server.DV_PWBS2.d.ts} +2 -2
  29. package/dist/shared/server.DWEp52Gx.mjs +379 -0
  30. package/dist/shared/{server.BEHw7Eyx.mjs → server.JtIZ8YG7.mjs} +1 -11
  31. package/dist/shared/server.VtI8pLxV.d.mts +242 -0
  32. package/dist/shared/server.VtI8pLxV.d.ts +242 -0
  33. package/package.json +10 -22
  34. package/dist/shared/server.CZNLCQBm.d.mts +0 -192
  35. package/dist/shared/server.CZNLCQBm.d.ts +0 -192
  36. package/dist/shared/server.DcfsPloY.mjs +0 -202
@@ -0,0 +1,242 @@
1
+ import { Meta, Schemas, ContractProcedureDef, AnyContractRouter, ContractProcedure, InferProcedureClientInputs, InferSchemaOutput, EnhanceRouteOptions, AnyContractProcedure, ContractRouter, AnySchema } from '@temporary-name/contract';
2
+ import { Promisable, StandardLazyRequest, HTTPPath, ClientContext, Interceptor, Value, Client, MaybeOptionalOptions } 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
+ type BuildContextWithAuth<TContext extends Context, TAuthContext> = MergedCurrentContext<TContext, {
8
+ auth: TAuthContext | ('auth' extends keyof TContext ? TContext['auth'] : never);
9
+ }>;
10
+ declare function mergeCurrentContext<T extends Context, U extends Context>(context: T, other: U): MergedCurrentContext<T, U>;
11
+
12
+ type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
13
+ output: TOutput;
14
+ context: TOutContext;
15
+ }>;
16
+ interface MiddlewareNextFn<TOutput> {
17
+ <U extends Context = {}>(options?: {
18
+ context?: U;
19
+ }): MiddlewareResult<U, TOutput>;
20
+ }
21
+ interface MiddlewareOutputFn<TOutput> {
22
+ (output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
23
+ }
24
+ interface MiddlewareOptions<TInContext extends Context, TOutput, TMeta extends Meta> extends ProcedureHandlerOptions<TInContext, TMeta> {
25
+ next: MiddlewareNextFn<TOutput>;
26
+ }
27
+ /**
28
+ * A function that represents a middleware.
29
+ *
30
+ * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
31
+ */
32
+ interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TMeta extends Meta> {
33
+ (options: MiddlewareOptions<TInContext, TOutput, TMeta>, input: TInput, output: MiddlewareOutputFn<TOutput>): Promisable<MiddlewareResult<TOutContext, TOutput>>;
34
+ }
35
+ type AnyMiddleware = Middleware<any, any, any, any, any>;
36
+ interface MapInputMiddleware<TInput, TMappedInput> {
37
+ (input: TInput): TMappedInput;
38
+ }
39
+ declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
40
+
41
+ type DefaultProcedureHandlerOptions = ProcedureHandlerOptions<Context, Meta>;
42
+ interface ProcedureHandlerOptions<TCurrentContext extends Context, TMeta extends Meta> {
43
+ context: TCurrentContext;
44
+ path: readonly string[];
45
+ procedure: Procedure<Context, Context, Schemas, TMeta>;
46
+ signal?: AbortSignal;
47
+ request?: StandardLazyRequest;
48
+ lastEventId: string | undefined;
49
+ }
50
+ interface ProcedureHandler<TCurrentContext extends Context, TInput extends {
51
+ path: any;
52
+ query: any;
53
+ body: any;
54
+ }, THandlerOutput, TMeta extends Meta> {
55
+ (input: TInput, opt: ProcedureHandlerOptions<TCurrentContext, TMeta>): Promisable<THandlerOutput>;
56
+ }
57
+ interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta> extends ContractProcedureDef<TSchemas, TMeta> {
58
+ __initialContext?: (type: TInitialContext) => unknown;
59
+ middlewares: readonly AnyMiddleware[];
60
+ authConfigs: TypedAuthConfig[];
61
+ inputValidationIndex: number;
62
+ outputValidationIndex: number;
63
+ handler: ProcedureHandler<TCurrentContext, any, any, any>;
64
+ }
65
+ /**
66
+ * This class represents a procedure.
67
+ *
68
+ * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
69
+ */
70
+ declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta> {
71
+ /**
72
+ * This property holds the defined options.
73
+ */
74
+ '~orpc': ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TMeta>;
75
+ constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TMeta>);
76
+ }
77
+ type AnyProcedure = Procedure<any, any, Schemas, any>;
78
+ declare function isProcedure(item: unknown): item is AnyProcedure;
79
+
80
+ type ValidatedAuthContext = {};
81
+ interface BasicAuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> {
82
+ tokenPrefix?: string;
83
+ validate: (username: string, password: string, options: ProcedureHandlerOptions<TCurrentContext, TMeta>) => Promisable<TAuthContext>;
84
+ }
85
+ interface TokenAuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> {
86
+ tokenPrefix?: string;
87
+ validate: (token: string, options: ProcedureHandlerOptions<TCurrentContext, TMeta>) => Promisable<TAuthContext>;
88
+ }
89
+ interface NamedTokenAuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> extends TokenAuthConfig<TAuthContext, TCurrentContext, TMeta> {
90
+ name: string;
91
+ }
92
+ type AuthType = 'header' | 'query' | 'cookie' | 'bearer' | 'basic' | 'none';
93
+ type AuthConfig<TAuthType extends AuthType, TAuthContext extends ValidatedAuthContext = ValidatedAuthContext, TCurrentContext extends Context = Context, TMeta extends Meta = Meta> = TAuthType extends 'basic' ? BasicAuthConfig<TAuthContext, TCurrentContext, TMeta> : TAuthType extends 'bearer' ? TokenAuthConfig<TAuthContext, TCurrentContext, TMeta> : TAuthType extends 'header' ? NamedTokenAuthConfig<TAuthContext, TCurrentContext, TMeta> : TAuthType extends 'query' ? NamedTokenAuthConfig<TAuthContext, TCurrentContext, TMeta> : TAuthType extends 'cookie' ? NamedTokenAuthConfig<TAuthContext, TCurrentContext, TMeta> : TAuthType extends 'none' ? {} : never;
94
+ type TypedAuthConfig<TAuthType extends AuthType = AuthType> = {
95
+ type: TAuthType;
96
+ } & AuthConfig<TAuthType, object>;
97
+
98
+ /**
99
+ * Represents a router, which defines a hierarchical structure of procedures.
100
+ *
101
+ * @info A procedure is a router too.
102
+ * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
103
+ */
104
+ type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer USchemas, infer UMeta> ? Procedure<TInitialContext, any, USchemas, UMeta> : {
105
+ [K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
106
+ };
107
+ type AnyRouter = Router<any, any>;
108
+ type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infer UInitialContext> ? UInitialContext : never;
109
+ /**
110
+ * Infer all initial context of the router.
111
+ *
112
+ * @info A procedure is a router too.
113
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
114
+ */
115
+ type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any> ? UInitialContext : {
116
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
117
+ };
118
+ /**
119
+ * Infer all current context of the router.
120
+ *
121
+ * @info A procedure is a router too.
122
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
123
+ */
124
+ type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any> ? UCurrentContext : {
125
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
126
+ };
127
+ /**
128
+ * Infer all router inputs
129
+ *
130
+ * @info A procedure is a router too.
131
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
132
+ */
133
+ type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any> ? InferProcedureClientInputs<USchemas> : {
134
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
135
+ };
136
+ /**
137
+ * Infer all router outputs
138
+ *
139
+ * @info A procedure is a router too.
140
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
141
+ */
142
+ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any> ? InferSchemaOutput<USchemas['outputSchema']> : {
143
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
144
+ };
145
+
146
+ declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
147
+ 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> & {
148
+ [K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
149
+ };
150
+ declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
151
+ type EnhancedRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context> = T extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<EnhancedRouter<U, TInitialContext, TCurrentContext>> : T extends Procedure<infer UInitialContext, infer UCurrentContext, infer USchemas, infer UMeta> ? Procedure<MergedInitialContext<TInitialContext, UInitialContext, TCurrentContext>, UCurrentContext, USchemas, UMeta> : {
152
+ [K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext> : never;
153
+ };
154
+ interface EnhanceRouterOptions extends EnhanceRouteOptions {
155
+ middlewares: readonly AnyMiddleware[];
156
+ dedupeLeadingMiddlewares: boolean;
157
+ }
158
+ declare function enhanceRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context>(router: T, options: EnhanceRouterOptions): EnhancedRouter<T, TInitialContext, TCurrentContext>;
159
+ interface TraverseContractProceduresOptions {
160
+ router: AnyContractRouter | AnyRouter;
161
+ path: readonly string[];
162
+ }
163
+ interface TraverseContractProcedureCallbackOptions {
164
+ contract: AnyContractProcedure | AnyProcedure;
165
+ path: readonly string[];
166
+ }
167
+ /**
168
+ * @deprecated Use `TraverseContractProcedureCallbackOptions` instead.
169
+ */
170
+ type ContractProcedureCallbackOptions = TraverseContractProcedureCallbackOptions;
171
+ interface LazyTraverseContractProceduresOptions {
172
+ router: Lazy<AnyRouter>;
173
+ path: readonly string[];
174
+ }
175
+ declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
176
+ declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void): Promise<void>;
177
+ type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
178
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
179
+ };
180
+ declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
181
+
182
+ declare const LAZY_SYMBOL: unique symbol;
183
+ interface LazyMeta {
184
+ prefix?: HTTPPath;
185
+ }
186
+ interface Lazy<T> {
187
+ [LAZY_SYMBOL]: {
188
+ loader: () => Promise<{
189
+ default: T;
190
+ }>;
191
+ meta: LazyMeta;
192
+ };
193
+ }
194
+ type Lazyable<T> = T | Lazy<T>;
195
+ /**
196
+ * @internal
197
+ */
198
+ declare function lazyInternal<T>(loader: () => Promise<{
199
+ default: T;
200
+ }>, meta?: LazyMeta): Lazy<T>;
201
+ /**
202
+ * Creates a lazy-loaded item.
203
+ *
204
+ * @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
205
+ */
206
+ declare function lazy<T extends Router<ContractRouter<{}>, any>>(prefix: HTTPPath, loader: () => Promise<{
207
+ default: T;
208
+ }>): EnhancedRouter<Lazy<T>, {}, {}>;
209
+ declare function isLazy(item: unknown): item is Lazy<any>;
210
+ declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
211
+ declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
212
+ default: T extends Lazy<infer U> ? U : T;
213
+ }>;
214
+
215
+ type ProcedureClient<TClientContext extends ClientContext, TSchemas extends Schemas> = Client<TClientContext, InferProcedureClientInputs<TSchemas>, InferSchemaOutput<TSchemas['outputSchema']>>;
216
+ interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TMeta extends Meta> extends ProcedureHandlerOptions<TInitialContext, TMeta> {
217
+ input: {
218
+ path: unknown;
219
+ query: unknown;
220
+ body: unknown;
221
+ };
222
+ }
223
+ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TMeta extends Meta, TClientContext extends ClientContext> = {
224
+ /**
225
+ * This is helpful for logging and analytics.
226
+ */
227
+ path?: readonly string[];
228
+ interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TMeta>, Promise<InferSchemaOutput<TOutputSchema>>>[];
229
+ } & (Record<never, never> extends TInitialContext ? {
230
+ context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
231
+ } : {
232
+ context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
233
+ });
234
+ /**
235
+ * Create Server-side client from a procedure.
236
+ *
237
+ * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
238
+ */
239
+ declare function createProcedureClient<TInitialContext extends Context, TSchemas extends Schemas, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TSchemas, TMeta>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TSchemas['outputSchema'], TMeta, TClientContext>>): ProcedureClient<TClientContext, TSchemas>;
240
+
241
+ export { isProcedure as G, createProcedureClient as J, Procedure as P, getRouter as S, createAccessibleLazyRouter as W, enhanceRouter as X, traverseContractProcedures as a0, resolveContractProcedures as a1, unlazyRouter as a3, mergeCurrentContext as m, LAZY_SYMBOL as n, lazyInternal as p, lazy as q, isLazy as r, getLazyMeta as s, unlazy as u, middlewareOutputFn as y };
242
+ export type { LazyTraverseContractProceduresOptions as $, AuthType as A, BuildContextWithAuth as B, Context as C, DefaultProcedureHandlerOptions 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, InferRouterInputs as O, InferRouterOutputs as Q, Router as R, TypedAuthConfig as T, AccessibleLazyRouter as U, ValidatedAuthContext as V, TraverseContractProceduresOptions as Y, TraverseContractProcedureCallbackOptions as Z, ContractProcedureCallbackOptions as _, CreateProcedureClientOptions as a, UnlaziedRouter as a2, ProcedureClient as b, MergedInitialContext as c, MergedCurrentContext as d, AuthConfig as e, ProcedureHandler as f, EnhancedRouter as g, MapInputMiddleware as h, AnyMiddleware as i, AnyProcedure as j, Lazyable as k, AnyRouter as l, LazyMeta as o, MiddlewareResult as t, MiddlewareNextFn as v, MiddlewareOutputFn as w, MiddlewareOptions as x, ProcedureHandlerOptions 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.03f5d40e5b399f85012c2fb4e98167e26d551d36",
4
+ "version": "1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.stainless.com/",
7
7
  "repository": {
@@ -57,31 +57,19 @@
57
57
  "files": [
58
58
  "dist"
59
59
  ],
60
- "peerDependencies": {
61
- "drizzle-orm": "^0.44.5",
62
- "drizzle-zod": "^0.8.3"
63
- },
64
- "peerDependenciesMeta": {
65
- "drizzle-orm": {
66
- "optional": true
67
- },
68
- "drizzle-zod": {
69
- "optional": true
70
- }
71
- },
72
60
  "dependencies": {
73
61
  "cookie": "^1.0.2",
74
62
  "rou3": "^0.7.7",
75
63
  "zod": "^4.1.12",
76
- "@temporary-name/contract": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
77
- "@temporary-name/json-schema": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
78
- "@temporary-name/interop": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
79
- "@temporary-name/standard-server": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
80
- "@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
81
- "@temporary-name/shared": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
82
- "@temporary-name/standard-server-fetch": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
83
- "@temporary-name/standard-server-node": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
84
- "@temporary-name/zod": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36"
64
+ "@temporary-name/interop": "1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f",
65
+ "@temporary-name/json-schema": "1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f",
66
+ "@temporary-name/standard-server": "1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f",
67
+ "@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f",
68
+ "@temporary-name/standard-server-fetch": "1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f",
69
+ "@temporary-name/shared": "1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f",
70
+ "@temporary-name/standard-server-node": "1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f",
71
+ "@temporary-name/zod": "1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f",
72
+ "@temporary-name/contract": "1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f"
85
73
  },
86
74
  "devDependencies": {
87
75
  "@types/supertest": "^6.0.3",
@@ -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, HTTPPath, Promisable, 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
- 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
- interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
44
- context: TCurrentContext;
45
- input: TInput;
46
- path: readonly string[];
47
- procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
48
- signal?: AbortSignal;
49
- lastEventId: string | undefined;
50
- errors: TErrorConstructorMap;
51
- }
52
- interface ProcedureHandler<TCurrentContext extends Context, TInput, THandlerOutput, TErrorMap extends ErrorMap, TMeta extends Meta> {
53
- (opt: ProcedureHandlerOptions<TCurrentContext, TInput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<THandlerOutput>;
54
- }
55
- 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> {
56
- __initialContext?: (type: TInitialContext) => unknown;
57
- middlewares: readonly AnyMiddleware[];
58
- inputValidationIndex: number;
59
- outputValidationIndex: number;
60
- handler: ProcedureHandler<TCurrentContext, any, any, any, any>;
61
- }
62
- /**
63
- * This class represents a procedure.
64
- *
65
- * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
66
- */
67
- declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
68
- /**
69
- * This property holds the defined options.
70
- */
71
- '~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
72
- constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
73
- }
74
- type AnyProcedure = Procedure<any, any, AnySchema, AnySchema, any, any>;
75
- declare function isProcedure(item: unknown): item is AnyProcedure;
76
-
77
- type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
78
- output: TOutput;
79
- context: TOutContext;
80
- }>;
81
- type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never, never> extends TOutContext ? {
82
- context?: TOutContext;
83
- } : {
84
- context: TOutContext;
85
- };
86
- interface MiddlewareNextFn<TOutput> {
87
- <U extends Context = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
88
- }
89
- interface MiddlewareOutputFn<TOutput> {
90
- (output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
91
- }
92
- interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
93
- context: TInContext;
94
- path: readonly string[];
95
- procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
96
- signal?: AbortSignal;
97
- lastEventId: string | undefined;
98
- next: MiddlewareNextFn<TOutput>;
99
- errors: TErrorConstructorMap;
100
- }
101
- /**
102
- * A function that represents a middleware.
103
- *
104
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
105
- */
106
- interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
107
- (options: MiddlewareOptions<TInContext, TOutput, TErrorConstructorMap, TMeta>, input: TInput, output: MiddlewareOutputFn<TOutput>): Promisable<MiddlewareResult<TOutContext, TOutput>>;
108
- }
109
- type AnyMiddleware = Middleware<any, any, any, any, any, any>;
110
- interface MapInputMiddleware<TInput, TMappedInput> {
111
- (input: TInput): TMappedInput;
112
- }
113
- declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
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 };