@temporary-name/server 1.9.3-alpha.fb7b7d19964e1b2def7056f4345b63d6fcacce10 → 1.9.3-alpha.fb7e3a67f82deaeffad5063e136b2f3c03c4b5b3
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 +4 -4
- package/dist/adapters/aws-lambda/index.d.ts +4 -4
- package/dist/adapters/aws-lambda/index.mjs +5 -6
- package/dist/adapters/fetch/index.d.mts +4 -4
- package/dist/adapters/fetch/index.d.ts +4 -4
- package/dist/adapters/fetch/index.mjs +5 -6
- package/dist/adapters/node/index.d.mts +5 -5
- package/dist/adapters/node/index.d.ts +5 -5
- package/dist/adapters/node/index.mjs +5 -6
- package/dist/{adapters/standard → handler}/index.d.mts +4 -5
- package/dist/{adapters/standard → handler}/index.d.ts +4 -5
- package/dist/handler/index.mjs +8 -0
- package/dist/index.d.mts +273 -34
- package/dist/index.d.ts +273 -34
- package/dist/index.mjs +347 -35
- package/dist/openapi/index.d.mts +3 -2
- package/dist/openapi/index.d.ts +3 -2
- package/dist/openapi/index.mjs +64 -13
- package/dist/shared/server.-tR-4rQ5.mjs +523 -0
- package/dist/shared/{server.DXPMDozZ.d.mts → server.BwcJq6aP.d.mts} +462 -42
- package/dist/shared/{server.DXPMDozZ.d.ts → server.BwcJq6aP.d.ts} +462 -42
- package/dist/shared/server.CjPiuQYH.d.mts +51 -0
- package/dist/shared/server.CjPiuQYH.d.ts +51 -0
- package/dist/shared/{server.Cza0RB3u.mjs → server.D2NXNHIf.mjs} +5 -9
- package/dist/shared/{server.B0LJ_wu-.d.ts → server.Deg5phAY.d.ts} +4 -6
- package/dist/shared/{server.ChOv1yG3.mjs → server.DvgWQUGK.mjs} +189 -12
- package/dist/shared/{server.BQZMQrPe.d.mts → server.hAH-LVh_.d.mts} +4 -6
- package/dist/shared/{server.CYa9puL2.mjs → server.n1y5fcVQ.mjs} +24 -112
- package/package.json +11 -12
- package/dist/adapters/standard/index.mjs +0 -9
- package/dist/shared/server.CQIFwyhc.mjs +0 -40
- package/dist/shared/server.YUvuxHty.mjs +0 -48
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Promisable, HTTPMethod, HTTPPath, OutputStructure, OpenAPI,
|
|
1
|
+
import { Promisable, IsEqual, StandardResponse, HTTPMethod, HTTPPath, OutputStructure, OpenAPI, StandardLazyRequest } from '@temporary-name/shared';
|
|
2
2
|
import * as z from '@temporary-name/zod';
|
|
3
3
|
|
|
4
4
|
type Context = object;
|
|
@@ -12,6 +12,464 @@ declare function mergeCurrentContext<T extends Context, U extends Context>(conte
|
|
|
12
12
|
type Meta = Record<string, any>;
|
|
13
13
|
declare function mergeMeta<T extends Meta>(meta1: T, meta2: T): T;
|
|
14
14
|
|
|
15
|
+
type Schema<TInput, TOutput> = z.core.$ZodType<TOutput, TInput>;
|
|
16
|
+
type AnySchema = z.core.$ZodType<any, any>;
|
|
17
|
+
type AnyShape = Readonly<Record<string, AnySchema>>;
|
|
18
|
+
type UnionToIntersection<T extends readonly object[]> = T extends readonly [infer First, ...infer Rest] ? First & (Rest extends readonly object[] ? UnionToIntersection<Rest> : {}) : {};
|
|
19
|
+
type WrapShape<U extends AnySchema | AnyShape> = U extends AnySchema ? U : U extends AnyShape ? z.KrustyObject<U, z.core.$strip> : never;
|
|
20
|
+
type SchemaIssue = z.core.$ZodIssue;
|
|
21
|
+
type InferSchemaInput<T extends AnySchema> = z.input<T>;
|
|
22
|
+
type InferSchemaOutput<T extends AnySchema> = z.output<T>;
|
|
23
|
+
type InferHandlerInputs<TSchemas extends Schemas> = {
|
|
24
|
+
path: InferSchemaOutput<TSchemas['pathSchema']>;
|
|
25
|
+
query: InferSchemaOutput<TSchemas['querySchema']>;
|
|
26
|
+
body: InferSchemaOutput<TSchemas['bodySchema']>;
|
|
27
|
+
};
|
|
28
|
+
type InferProcedureClientInputs<TSchemas extends Schemas> = {
|
|
29
|
+
path: InferSchemaInput<TSchemas['pathSchema']>;
|
|
30
|
+
query: InferSchemaInput<TSchemas['querySchema']>;
|
|
31
|
+
body: InferSchemaInput<TSchemas['bodySchema']>;
|
|
32
|
+
};
|
|
33
|
+
type TypeRest<TInput, TOutput> = [map: (input: TInput) => Promisable<TOutput>] | (IsEqual<TInput, TOutput> extends true ? [] : never);
|
|
34
|
+
interface Schemas {
|
|
35
|
+
pathSchema: AnySchema;
|
|
36
|
+
querySchema: AnySchema;
|
|
37
|
+
bodySchema: AnySchema;
|
|
38
|
+
outputSchema: AnySchema;
|
|
39
|
+
}
|
|
40
|
+
declare const initialSchemas: {
|
|
41
|
+
pathSchema: z.KrustyObject<{}, z.core.$strict, z.KrustyInternals<string>>;
|
|
42
|
+
querySchema: z.KrustyObject<{}, z.core.$strict, z.KrustyInternals<string>>;
|
|
43
|
+
bodySchema: z.KrustyObject<{}, z.core.$strict, z.KrustyInternals<string>>;
|
|
44
|
+
outputSchema: z.KrustyUnknown<z.KrustyInternals<string>>;
|
|
45
|
+
};
|
|
46
|
+
type InitialSchemas = typeof initialSchemas;
|
|
47
|
+
type MergedSchemas<T1 extends Schemas, T2 extends Partial<Schemas>> = {
|
|
48
|
+
pathSchema: T2['pathSchema'] extends AnySchema ? T2['pathSchema'] : T1['pathSchema'];
|
|
49
|
+
querySchema: T2['querySchema'] extends AnySchema ? T2['querySchema'] : T1['querySchema'];
|
|
50
|
+
bodySchema: T2['bodySchema'] extends AnySchema ? T2['bodySchema'] : T1['bodySchema'];
|
|
51
|
+
outputSchema: T2['outputSchema'] extends AnySchema ? T2['outputSchema'] : T1['outputSchema'];
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
interface ValidationErrorOptions extends ErrorOptions {
|
|
55
|
+
issues: readonly SchemaIssue[];
|
|
56
|
+
data: unknown;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* This errors usually used for APIError.cause when the error is a validation error.
|
|
60
|
+
*
|
|
61
|
+
* @see {@link https://orpc.unnoq.com/docs/advanced/validation-errors Validation Errors Docs}
|
|
62
|
+
*/
|
|
63
|
+
declare class ValidationError extends Error {
|
|
64
|
+
readonly issues: readonly SchemaIssue[];
|
|
65
|
+
readonly data: unknown;
|
|
66
|
+
constructor(options: ValidationErrorOptions);
|
|
67
|
+
}
|
|
68
|
+
type Extra = Record<string, any>;
|
|
69
|
+
type ErrorOpts = {
|
|
70
|
+
message?: string;
|
|
71
|
+
cause?: unknown;
|
|
72
|
+
};
|
|
73
|
+
type APIErrorConstructorArgs<TExtra extends Extra> = {} extends TExtra ? [options?: ErrorOpts & TExtra] : [options: ErrorOpts & TExtra];
|
|
74
|
+
type APIErrorConstructor<TExtra extends Extra, TKlass extends (typeof COMMON_ERRORS)[keyof typeof COMMON_ERRORS]> = {
|
|
75
|
+
new (...args: APIErrorConstructorArgs<TExtra & $InferObjectOutput<TKlass['extraSchema']>>): TExtra extends Record<string, never> ? InstanceType<TKlass> : InstanceType<TKlass> & {
|
|
76
|
+
extra: TExtra;
|
|
77
|
+
};
|
|
78
|
+
extraSchema: z.core.$ZodShape;
|
|
79
|
+
};
|
|
80
|
+
type CustomAPIErrorConstructor<TStatus extends number, TType extends string, TDefaultMessage extends string, TExtra extends Extra> = {
|
|
81
|
+
new (...args: APIErrorConstructorArgs<TExtra>): APIError<TExtra>;
|
|
82
|
+
status: TStatus;
|
|
83
|
+
type: TType;
|
|
84
|
+
defaultMessage: TDefaultMessage;
|
|
85
|
+
extraSchema: z.core.$ZodShape;
|
|
86
|
+
};
|
|
87
|
+
type SubclassOf<T> = {
|
|
88
|
+
new (...args: any[]): T;
|
|
89
|
+
extraSchema: z.core.$ZodShape;
|
|
90
|
+
};
|
|
91
|
+
declare abstract class APIError<TExtra extends Extra> extends Error {
|
|
92
|
+
extra: TExtra;
|
|
93
|
+
static extraSchema: z.core.$ZodShape;
|
|
94
|
+
static status: number;
|
|
95
|
+
static type: string;
|
|
96
|
+
static staticDefaultMessage: string | undefined;
|
|
97
|
+
constructor(...args: APIErrorConstructorArgs<TExtra>);
|
|
98
|
+
static get defaultMessage(): string;
|
|
99
|
+
toJSON(): {
|
|
100
|
+
type: string;
|
|
101
|
+
message: string;
|
|
102
|
+
} & TExtra;
|
|
103
|
+
}
|
|
104
|
+
declare class BadRequestError extends APIError<{
|
|
105
|
+
code: string;
|
|
106
|
+
}> {
|
|
107
|
+
static status: number;
|
|
108
|
+
static type: string;
|
|
109
|
+
static extraSchema: {
|
|
110
|
+
code: z.KrustyString<z.KrustyInternals<string>>;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
declare class UnauthorizedError extends APIError<{}> {
|
|
114
|
+
static status: number;
|
|
115
|
+
static type: string;
|
|
116
|
+
}
|
|
117
|
+
declare class ForbiddenError extends APIError<{}> {
|
|
118
|
+
static status: number;
|
|
119
|
+
static type: string;
|
|
120
|
+
}
|
|
121
|
+
declare class NotFoundError extends APIError<{}> {
|
|
122
|
+
static status: number;
|
|
123
|
+
static type: string;
|
|
124
|
+
}
|
|
125
|
+
declare class InternalServerError extends APIError<{}> {
|
|
126
|
+
static status: number;
|
|
127
|
+
static type: string;
|
|
128
|
+
}
|
|
129
|
+
declare const COMMON_ERRORS: {
|
|
130
|
+
readonly BadRequestError: typeof BadRequestError;
|
|
131
|
+
readonly UnauthorizedError: typeof UnauthorizedError;
|
|
132
|
+
readonly ForbiddenError: typeof ForbiddenError;
|
|
133
|
+
readonly NotFoundError: typeof NotFoundError;
|
|
134
|
+
readonly MethodNotAllowedError: {
|
|
135
|
+
new (options?: ErrorOpts | undefined): {
|
|
136
|
+
extra: {};
|
|
137
|
+
toJSON(): {
|
|
138
|
+
type: string;
|
|
139
|
+
message: string;
|
|
140
|
+
};
|
|
141
|
+
name: string;
|
|
142
|
+
message: string;
|
|
143
|
+
stack?: string;
|
|
144
|
+
cause?: unknown;
|
|
145
|
+
};
|
|
146
|
+
status: number;
|
|
147
|
+
type: string;
|
|
148
|
+
extraSchema: z.core.$ZodShape;
|
|
149
|
+
staticDefaultMessage: string | undefined;
|
|
150
|
+
get defaultMessage(): string;
|
|
151
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
152
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
153
|
+
stackTraceLimit: number;
|
|
154
|
+
};
|
|
155
|
+
readonly NotAcceptableError: {
|
|
156
|
+
new (options?: ErrorOpts | undefined): {
|
|
157
|
+
extra: {};
|
|
158
|
+
toJSON(): {
|
|
159
|
+
type: string;
|
|
160
|
+
message: string;
|
|
161
|
+
};
|
|
162
|
+
name: string;
|
|
163
|
+
message: string;
|
|
164
|
+
stack?: string;
|
|
165
|
+
cause?: unknown;
|
|
166
|
+
};
|
|
167
|
+
status: number;
|
|
168
|
+
type: string;
|
|
169
|
+
extraSchema: z.core.$ZodShape;
|
|
170
|
+
staticDefaultMessage: string | undefined;
|
|
171
|
+
get defaultMessage(): string;
|
|
172
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
173
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
174
|
+
stackTraceLimit: number;
|
|
175
|
+
};
|
|
176
|
+
readonly RequestTimeoutError: {
|
|
177
|
+
new (options?: ErrorOpts | undefined): {
|
|
178
|
+
extra: {};
|
|
179
|
+
toJSON(): {
|
|
180
|
+
type: string;
|
|
181
|
+
message: string;
|
|
182
|
+
};
|
|
183
|
+
name: string;
|
|
184
|
+
message: string;
|
|
185
|
+
stack?: string;
|
|
186
|
+
cause?: unknown;
|
|
187
|
+
};
|
|
188
|
+
status: number;
|
|
189
|
+
type: string;
|
|
190
|
+
extraSchema: z.core.$ZodShape;
|
|
191
|
+
staticDefaultMessage: string | undefined;
|
|
192
|
+
get defaultMessage(): string;
|
|
193
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
194
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
195
|
+
stackTraceLimit: number;
|
|
196
|
+
};
|
|
197
|
+
readonly ConflictError: {
|
|
198
|
+
new (options?: ErrorOpts | undefined): {
|
|
199
|
+
extra: {};
|
|
200
|
+
toJSON(): {
|
|
201
|
+
type: string;
|
|
202
|
+
message: string;
|
|
203
|
+
};
|
|
204
|
+
name: string;
|
|
205
|
+
message: string;
|
|
206
|
+
stack?: string;
|
|
207
|
+
cause?: unknown;
|
|
208
|
+
};
|
|
209
|
+
status: number;
|
|
210
|
+
type: string;
|
|
211
|
+
extraSchema: z.core.$ZodShape;
|
|
212
|
+
staticDefaultMessage: string | undefined;
|
|
213
|
+
get defaultMessage(): string;
|
|
214
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
215
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
216
|
+
stackTraceLimit: number;
|
|
217
|
+
};
|
|
218
|
+
readonly PreconditionFailedError: {
|
|
219
|
+
new (options?: ErrorOpts | undefined): {
|
|
220
|
+
extra: {};
|
|
221
|
+
toJSON(): {
|
|
222
|
+
type: string;
|
|
223
|
+
message: string;
|
|
224
|
+
};
|
|
225
|
+
name: string;
|
|
226
|
+
message: string;
|
|
227
|
+
stack?: string;
|
|
228
|
+
cause?: unknown;
|
|
229
|
+
};
|
|
230
|
+
status: number;
|
|
231
|
+
type: string;
|
|
232
|
+
extraSchema: z.core.$ZodShape;
|
|
233
|
+
staticDefaultMessage: string | undefined;
|
|
234
|
+
get defaultMessage(): string;
|
|
235
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
236
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
237
|
+
stackTraceLimit: number;
|
|
238
|
+
};
|
|
239
|
+
readonly ContentTooLargeError: {
|
|
240
|
+
new (options?: ErrorOpts | undefined): {
|
|
241
|
+
extra: {};
|
|
242
|
+
toJSON(): {
|
|
243
|
+
type: string;
|
|
244
|
+
message: string;
|
|
245
|
+
};
|
|
246
|
+
name: string;
|
|
247
|
+
message: string;
|
|
248
|
+
stack?: string;
|
|
249
|
+
cause?: unknown;
|
|
250
|
+
};
|
|
251
|
+
status: number;
|
|
252
|
+
type: string;
|
|
253
|
+
extraSchema: z.core.$ZodShape;
|
|
254
|
+
staticDefaultMessage: string | undefined;
|
|
255
|
+
get defaultMessage(): string;
|
|
256
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
257
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
258
|
+
stackTraceLimit: number;
|
|
259
|
+
};
|
|
260
|
+
readonly UnsupportedMediaTypeError: {
|
|
261
|
+
new (options?: ErrorOpts | undefined): {
|
|
262
|
+
extra: {};
|
|
263
|
+
toJSON(): {
|
|
264
|
+
type: string;
|
|
265
|
+
message: string;
|
|
266
|
+
};
|
|
267
|
+
name: string;
|
|
268
|
+
message: string;
|
|
269
|
+
stack?: string;
|
|
270
|
+
cause?: unknown;
|
|
271
|
+
};
|
|
272
|
+
status: number;
|
|
273
|
+
type: string;
|
|
274
|
+
extraSchema: z.core.$ZodShape;
|
|
275
|
+
staticDefaultMessage: string | undefined;
|
|
276
|
+
get defaultMessage(): string;
|
|
277
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
278
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
279
|
+
stackTraceLimit: number;
|
|
280
|
+
};
|
|
281
|
+
readonly UnprocessableContentError: {
|
|
282
|
+
new (options?: ErrorOpts | undefined): {
|
|
283
|
+
extra: {};
|
|
284
|
+
toJSON(): {
|
|
285
|
+
type: string;
|
|
286
|
+
message: string;
|
|
287
|
+
};
|
|
288
|
+
name: string;
|
|
289
|
+
message: string;
|
|
290
|
+
stack?: string;
|
|
291
|
+
cause?: unknown;
|
|
292
|
+
};
|
|
293
|
+
status: number;
|
|
294
|
+
type: string;
|
|
295
|
+
extraSchema: z.core.$ZodShape;
|
|
296
|
+
staticDefaultMessage: string | undefined;
|
|
297
|
+
get defaultMessage(): string;
|
|
298
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
299
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
300
|
+
stackTraceLimit: number;
|
|
301
|
+
};
|
|
302
|
+
readonly TooManyRequestsError: {
|
|
303
|
+
new (options?: ErrorOpts | undefined): {
|
|
304
|
+
extra: {};
|
|
305
|
+
toJSON(): {
|
|
306
|
+
type: string;
|
|
307
|
+
message: string;
|
|
308
|
+
};
|
|
309
|
+
name: string;
|
|
310
|
+
message: string;
|
|
311
|
+
stack?: string;
|
|
312
|
+
cause?: unknown;
|
|
313
|
+
};
|
|
314
|
+
status: number;
|
|
315
|
+
type: string;
|
|
316
|
+
extraSchema: z.core.$ZodShape;
|
|
317
|
+
staticDefaultMessage: string | undefined;
|
|
318
|
+
get defaultMessage(): string;
|
|
319
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
320
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
321
|
+
stackTraceLimit: number;
|
|
322
|
+
};
|
|
323
|
+
readonly InternalServerError: typeof InternalServerError;
|
|
324
|
+
readonly NotImplementedError: {
|
|
325
|
+
new (options?: ErrorOpts | undefined): {
|
|
326
|
+
extra: {};
|
|
327
|
+
toJSON(): {
|
|
328
|
+
type: string;
|
|
329
|
+
message: string;
|
|
330
|
+
};
|
|
331
|
+
name: string;
|
|
332
|
+
message: string;
|
|
333
|
+
stack?: string;
|
|
334
|
+
cause?: unknown;
|
|
335
|
+
};
|
|
336
|
+
status: number;
|
|
337
|
+
type: string;
|
|
338
|
+
extraSchema: z.core.$ZodShape;
|
|
339
|
+
staticDefaultMessage: string | undefined;
|
|
340
|
+
get defaultMessage(): string;
|
|
341
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
342
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
343
|
+
stackTraceLimit: number;
|
|
344
|
+
};
|
|
345
|
+
readonly BadGatewayError: {
|
|
346
|
+
new (options?: ErrorOpts | undefined): {
|
|
347
|
+
extra: {};
|
|
348
|
+
toJSON(): {
|
|
349
|
+
type: string;
|
|
350
|
+
message: string;
|
|
351
|
+
};
|
|
352
|
+
name: string;
|
|
353
|
+
message: string;
|
|
354
|
+
stack?: string;
|
|
355
|
+
cause?: unknown;
|
|
356
|
+
};
|
|
357
|
+
status: number;
|
|
358
|
+
type: string;
|
|
359
|
+
extraSchema: z.core.$ZodShape;
|
|
360
|
+
staticDefaultMessage: string | undefined;
|
|
361
|
+
get defaultMessage(): string;
|
|
362
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
363
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
364
|
+
stackTraceLimit: number;
|
|
365
|
+
};
|
|
366
|
+
readonly ServiceUnavailableError: {
|
|
367
|
+
new (options?: ErrorOpts | undefined): {
|
|
368
|
+
extra: {};
|
|
369
|
+
toJSON(): {
|
|
370
|
+
type: string;
|
|
371
|
+
message: string;
|
|
372
|
+
};
|
|
373
|
+
name: string;
|
|
374
|
+
message: string;
|
|
375
|
+
stack?: string;
|
|
376
|
+
cause?: unknown;
|
|
377
|
+
};
|
|
378
|
+
status: number;
|
|
379
|
+
type: string;
|
|
380
|
+
extraSchema: z.core.$ZodShape;
|
|
381
|
+
staticDefaultMessage: string | undefined;
|
|
382
|
+
get defaultMessage(): string;
|
|
383
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
384
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
385
|
+
stackTraceLimit: number;
|
|
386
|
+
};
|
|
387
|
+
readonly GatewayTimeoutError: {
|
|
388
|
+
new (options?: ErrorOpts | undefined): {
|
|
389
|
+
extra: {};
|
|
390
|
+
toJSON(): {
|
|
391
|
+
type: string;
|
|
392
|
+
message: string;
|
|
393
|
+
};
|
|
394
|
+
name: string;
|
|
395
|
+
message: string;
|
|
396
|
+
stack?: string;
|
|
397
|
+
cause?: unknown;
|
|
398
|
+
};
|
|
399
|
+
status: number;
|
|
400
|
+
type: string;
|
|
401
|
+
extraSchema: z.core.$ZodShape;
|
|
402
|
+
staticDefaultMessage: string | undefined;
|
|
403
|
+
get defaultMessage(): string;
|
|
404
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
405
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
406
|
+
stackTraceLimit: number;
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
type ErrorMap = Record<string, SubclassOf<APIError<any>>>;
|
|
410
|
+
type ErrorClassName = keyof typeof COMMON_ERRORS;
|
|
411
|
+
type ErrorConfig<TExtraFields extends z.core.$ZodShape = {}> = {
|
|
412
|
+
extraFields?: TExtraFields;
|
|
413
|
+
};
|
|
414
|
+
type CustomErrorConfig<TExtraFields extends z.core.$ZodShape = {}> = ErrorConfig<TExtraFields> & {
|
|
415
|
+
status: number;
|
|
416
|
+
defaultMessage: string;
|
|
417
|
+
type: string;
|
|
418
|
+
};
|
|
419
|
+
type ValidateErrorsConfig<T extends ErrorsConfig> = {} extends T ? T : {
|
|
420
|
+
[K in keyof T]: K extends ErrorClassName ? T[K] extends ErrorConfig | boolean ? unknown : never : T[K] extends CustomErrorConfig ? unknown : never;
|
|
421
|
+
}[keyof T] extends never ? {
|
|
422
|
+
[K in keyof T]: K extends ErrorClassName ? ErrorConfig | boolean : CustomErrorConfig;
|
|
423
|
+
} : T;
|
|
424
|
+
type ErrorsConfig = {
|
|
425
|
+
[K in ErrorClassName]?: ErrorConfig | boolean;
|
|
426
|
+
} & {
|
|
427
|
+
[key: string]: CustomErrorConfig | ErrorConfig | boolean;
|
|
428
|
+
};
|
|
429
|
+
declare const DEFAULT_ERRORS_CONFIG: {
|
|
430
|
+
readonly BadRequestError: {
|
|
431
|
+
readonly extraFields: {
|
|
432
|
+
readonly code: z.KrustyString<z.KrustyInternals<string>>;
|
|
433
|
+
};
|
|
434
|
+
};
|
|
435
|
+
readonly UnauthorizedError: true;
|
|
436
|
+
readonly ForbiddenError: true;
|
|
437
|
+
readonly NotFoundError: true;
|
|
438
|
+
readonly InternalServerError: true;
|
|
439
|
+
};
|
|
440
|
+
type OptionalOutSchema = {
|
|
441
|
+
_zod: {
|
|
442
|
+
optout: 'optional';
|
|
443
|
+
};
|
|
444
|
+
};
|
|
445
|
+
type $InferObjectOutput<T extends z.core.$ZodLooseShape> = string extends keyof T ? z.core.util.IsAny<T[keyof T]> extends true ? Record<string, unknown> : Record<string, z.core.output<T[keyof T]>> : keyof (T & Extra) extends never ? Record<string, never> : z.core.util.Prettify<{
|
|
446
|
+
-readonly [k in keyof T as T[k] extends OptionalOutSchema ? never : k]: T[k]['_zod']['output'];
|
|
447
|
+
} & {
|
|
448
|
+
-readonly [k in keyof T as T[k] extends OptionalOutSchema ? k : never]?: T[k]['_zod']['output'];
|
|
449
|
+
}>;
|
|
450
|
+
type ErrorsReturn<T extends ErrorsConfig> = {
|
|
451
|
+
[K in keyof T]: K extends ErrorClassName ? T[K] extends true ? APIErrorConstructor<{}, (typeof COMMON_ERRORS)[K]> : T[K] extends {
|
|
452
|
+
extraFields?: any;
|
|
453
|
+
} ? T[K] extends {
|
|
454
|
+
extraFields: infer E extends z.core.$ZodShape;
|
|
455
|
+
} ? APIErrorConstructor<$InferObjectOutput<E>, (typeof COMMON_ERRORS)[K]> : APIErrorConstructor<{}, (typeof COMMON_ERRORS)[K]> : never : T[K] extends ({
|
|
456
|
+
status: infer Status extends number;
|
|
457
|
+
defaultMessage: infer DefaultMessage extends string;
|
|
458
|
+
type: infer Type extends string;
|
|
459
|
+
extraFields: z.core.$ZodShape;
|
|
460
|
+
}) ? CustomAPIErrorConstructor<Status, Type, DefaultMessage, $InferObjectOutput<T[K]['extraFields']>> : never;
|
|
461
|
+
};
|
|
462
|
+
type WithDefaultErrorConfig<T extends ErrorsConfig> = {
|
|
463
|
+
[K in keyof T]: T[K];
|
|
464
|
+
} & {
|
|
465
|
+
[K in keyof typeof DEFAULT_ERRORS_CONFIG as Exclude<K, keyof T>]: (typeof DEFAULT_ERRORS_CONFIG)[K];
|
|
466
|
+
};
|
|
467
|
+
declare function makeErrors(): ErrorsReturn<WithDefaultErrorConfig<{}>>;
|
|
468
|
+
declare function makeErrors<T extends ErrorsConfig>(config: ValidateErrorsConfig<T>): ErrorsReturn<WithDefaultErrorConfig<T>>;
|
|
469
|
+
declare function isAPIErrorStatus(status: number): boolean;
|
|
470
|
+
declare function toAPIError(error: unknown): APIError<any>;
|
|
471
|
+
declare function encodeError(error: APIError<any>): StandardResponse;
|
|
472
|
+
|
|
15
473
|
type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
|
16
474
|
output: TOutput;
|
|
17
475
|
context: TOutContext;
|
|
@@ -145,45 +603,6 @@ interface EnhanceRouteOptions {
|
|
|
145
603
|
tags?: readonly string[];
|
|
146
604
|
}
|
|
147
605
|
|
|
148
|
-
type Schema<TInput, TOutput> = z.core.$ZodType<TOutput, TInput>;
|
|
149
|
-
type AnySchema = z.core.$ZodType<any, any>;
|
|
150
|
-
type AnyShape = Readonly<Record<string, AnySchema>>;
|
|
151
|
-
type UnionToIntersection<T extends readonly object[]> = T extends readonly [infer First, ...infer Rest] ? First & (Rest extends readonly object[] ? UnionToIntersection<Rest> : {}) : {};
|
|
152
|
-
type WrapShape<U extends AnySchema | AnyShape> = U extends AnySchema ? U : U extends AnyShape ? z.KrustyObject<U, z.core.$strip> : never;
|
|
153
|
-
type SchemaIssue = z.core.$ZodIssue;
|
|
154
|
-
type InferSchemaInput<T extends AnySchema> = z.input<T>;
|
|
155
|
-
type InferSchemaOutput<T extends AnySchema> = z.output<T>;
|
|
156
|
-
type InferHandlerInputs<TSchemas extends Schemas> = {
|
|
157
|
-
path: InferSchemaOutput<TSchemas['pathSchema']>;
|
|
158
|
-
query: InferSchemaOutput<TSchemas['querySchema']>;
|
|
159
|
-
body: InferSchemaOutput<TSchemas['bodySchema']>;
|
|
160
|
-
};
|
|
161
|
-
type InferProcedureClientInputs<TSchemas extends Schemas> = {
|
|
162
|
-
path: InferSchemaInput<TSchemas['pathSchema']>;
|
|
163
|
-
query: InferSchemaInput<TSchemas['querySchema']>;
|
|
164
|
-
body: InferSchemaInput<TSchemas['bodySchema']>;
|
|
165
|
-
};
|
|
166
|
-
type TypeRest<TInput, TOutput> = [map: (input: TInput) => Promisable<TOutput>] | (IsEqual<TInput, TOutput> extends true ? [] : never);
|
|
167
|
-
interface Schemas {
|
|
168
|
-
pathSchema: AnySchema;
|
|
169
|
-
querySchema: AnySchema;
|
|
170
|
-
bodySchema: AnySchema;
|
|
171
|
-
outputSchema: AnySchema;
|
|
172
|
-
}
|
|
173
|
-
declare const initialSchemas: {
|
|
174
|
-
pathSchema: z.KrustyObject<{}, z.core.$strict, z.KrustyInternals<string>>;
|
|
175
|
-
querySchema: z.KrustyObject<{}, z.core.$strict, z.KrustyInternals<string>>;
|
|
176
|
-
bodySchema: z.KrustyObject<{}, z.core.$strict, z.KrustyInternals<string>>;
|
|
177
|
-
outputSchema: z.KrustyUnknown<z.KrustyInternals<string>>;
|
|
178
|
-
};
|
|
179
|
-
type InitialSchemas = typeof initialSchemas;
|
|
180
|
-
type MergedSchemas<T1 extends Schemas, T2 extends Partial<Schemas>> = {
|
|
181
|
-
pathSchema: T2['pathSchema'] extends AnySchema ? T2['pathSchema'] : T1['pathSchema'];
|
|
182
|
-
querySchema: T2['querySchema'] extends AnySchema ? T2['querySchema'] : T1['querySchema'];
|
|
183
|
-
bodySchema: T2['bodySchema'] extends AnySchema ? T2['bodySchema'] : T1['bodySchema'];
|
|
184
|
-
outputSchema: T2['outputSchema'] extends AnySchema ? T2['outputSchema'] : T1['outputSchema'];
|
|
185
|
-
};
|
|
186
|
-
|
|
187
606
|
interface ProcedureHandlerOptions<TCurrentContext extends Context, TMeta extends Meta> {
|
|
188
607
|
context: TCurrentContext;
|
|
189
608
|
path: readonly string[];
|
|
@@ -202,6 +621,7 @@ interface ProcedureHandler<TCurrentContext extends Context, TInput extends {
|
|
|
202
621
|
interface ContractDef<TSchemas extends Schemas, TMeta extends Meta> {
|
|
203
622
|
meta: TMeta;
|
|
204
623
|
route: Route;
|
|
624
|
+
errorMap: ErrorMap;
|
|
205
625
|
schemas: TSchemas;
|
|
206
626
|
middlewares: readonly AnyMiddleware[];
|
|
207
627
|
authConfigs: AnyAuthConfig[];
|
|
@@ -384,5 +804,5 @@ declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
|
|
384
804
|
default: T extends Lazy<infer U> ? U : T;
|
|
385
805
|
}>;
|
|
386
806
|
|
|
387
|
-
export {
|
|
388
|
-
export type {
|
|
807
|
+
export { isLazy as $, APIError as D, BadRequestError as F, UnauthorizedError as G, ForbiddenError as H, InternalServerError as J, makeErrors as K, NotFoundError as N, isAPIErrorStatus as O, Procedure as P, toAPIError as Q, encodeError as T, LAZY_SYMBOL as X, lazyInternal as Z, lazy as _, getLazyMeta as a0, unlazy as a1, mergeMeta as a2, middlewareOutputFn as a7, isProcedure as ab, getRouter as aj, createAccessibleLazyRouter as al, enhanceRouter as am, traverseContractProcedures as ar, resolveContractProcedures as as, unlazyRouter as au, initialSchemas as aw, Contract as b, mergeCurrentContext as v, ValidationError as x };
|
|
808
|
+
export type { AnyShape as A, BuildContextWithAuth as B, Context as C, ErrorMap as E, InferProcedureClientInputs as I, Lazyable as L, Meta as M, Route as R, Schemas as S, UnionToIntersection as U, ValidatedAuthContext as V, WrapShape as W, LazyMeta as Y, InferSchemaOutput as a, MiddlewareResult as a3, MiddlewareNextFn as a4, MiddlewareOutputFn as a5, MiddlewareOptions as a6, ProcedureHandlerOptions as a8, AnyContractDef as a9, ProcedureDef as aa, ContractRouter as ac, AnyRouter as ad, InferRouterInitialContext as ae, InferRouterInitialContexts as af, InferRouterCurrentContexts as ag, InferRouterInputs as ah, InferRouterOutputs as ai, AccessibleLazyRouter as ak, TraverseContractProceduresOptions as an, TraverseContractProcedureCallbackOptions as ao, ContractProcedureCallbackOptions as ap, LazyTraverseContractProceduresOptions as aq, UnlaziedRouter as at, TypeRest as av, InitialSchemas as ax, MergedSchemas as c, AnySchema as d, Middleware as e, MergedCurrentContext as f, MergedInitialContext as g, AuthConfig as h, ProcedureHandler as i, InferHandlerInputs as j, InferSchemaInput as k, EnhanceRouterOptions as l, Router as m, EnhancedRouter as n, MapInputMiddleware as o, ContractDef as p, Schema as q, AnyMiddleware as r, Lazy as s, AnyProcedure as t, SchemaIssue as u, ValidationErrorOptions as w, APIErrorConstructor as y, CustomAPIErrorConstructor as z };
|