express-zod-api 18.4.0 → 18.5.0-beta1
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/CHANGELOG.md +31 -0
- package/README.md +6 -6
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +65 -308
- package/dist/index.d.ts +65 -308
- package/dist/index.js +6 -6
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -205,170 +205,6 @@ type Refined<T extends z.ZodTypeAny> = T extends z.ZodType<infer O> ? z.ZodEffec
|
|
|
205
205
|
type IOSchema<U extends z.UnknownKeysParam = any> = z.ZodObject<any, U> | z.ZodUnion<[IOSchema<U>, ...IOSchema<U>[]]> | z.ZodIntersection<IOSchema<U>, IOSchema<U>> | z.ZodDiscriminatedUnion<string, z.ZodObject<any, U>[]> | Refined<z.ZodObject<any, U>>;
|
|
206
206
|
type ProbableIntersection<A extends IOSchema<"strip"> | null, B extends IOSchema> = A extends null ? B : A extends IOSchema<"strip"> ? z.ZodIntersection<A, B> : never;
|
|
207
207
|
|
|
208
|
-
declare const ezDateInKind = "DateIn";
|
|
209
|
-
|
|
210
|
-
declare const ezDateOutKind = "DateOut";
|
|
211
|
-
|
|
212
|
-
declare const ezFileKind = "File";
|
|
213
|
-
declare const variants: {
|
|
214
|
-
buffer: () => z.ZodType<Buffer, z.ZodTypeDef, Buffer> & {
|
|
215
|
-
_def: z.ZodTypeDef & Record<"expressZodApiMeta", Metadata<z.ZodType<Buffer, z.ZodTypeDef, Buffer>>>;
|
|
216
|
-
} & {
|
|
217
|
-
example: (example: Buffer) => z.ZodType<Buffer, z.ZodTypeDef, Buffer> & {
|
|
218
|
-
_def: z.ZodTypeDef & Record<"expressZodApiMeta", Metadata<z.ZodType<Buffer, z.ZodTypeDef, Buffer>>>;
|
|
219
|
-
} & any;
|
|
220
|
-
};
|
|
221
|
-
string: () => z.ZodString & {
|
|
222
|
-
_def: z.ZodStringDef & Record<"expressZodApiMeta", Metadata<z.ZodString>>;
|
|
223
|
-
} & {
|
|
224
|
-
example: (example: string) => z.ZodString & {
|
|
225
|
-
_def: z.ZodStringDef & Record<"expressZodApiMeta", Metadata<z.ZodString>>;
|
|
226
|
-
} & any;
|
|
227
|
-
};
|
|
228
|
-
binary: () => z.ZodUnion<[z.ZodType<Buffer, z.ZodTypeDef, Buffer>, z.ZodString]> & {
|
|
229
|
-
_def: z.ZodUnionDef<[z.ZodType<Buffer, z.ZodTypeDef, Buffer>, z.ZodString]> & Record<"expressZodApiMeta", Metadata<z.ZodUnion<[z.ZodType<Buffer, z.ZodTypeDef, Buffer>, z.ZodString]>>>;
|
|
230
|
-
} & {
|
|
231
|
-
example: (example: string | Buffer) => z.ZodUnion<[z.ZodType<Buffer, z.ZodTypeDef, Buffer>, z.ZodString]> & {
|
|
232
|
-
_def: z.ZodUnionDef<[z.ZodType<Buffer, z.ZodTypeDef, Buffer>, z.ZodString]> & Record<"expressZodApiMeta", Metadata<z.ZodUnion<[z.ZodType<Buffer, z.ZodTypeDef, Buffer>, z.ZodString]>>>;
|
|
233
|
-
} & any;
|
|
234
|
-
};
|
|
235
|
-
base64: () => z.ZodString & {
|
|
236
|
-
_def: z.ZodStringDef & Record<"expressZodApiMeta", Metadata<z.ZodString>>;
|
|
237
|
-
} & {
|
|
238
|
-
example: (example: string) => z.ZodString & {
|
|
239
|
-
_def: z.ZodStringDef & Record<"expressZodApiMeta", Metadata<z.ZodString>>;
|
|
240
|
-
} & any;
|
|
241
|
-
};
|
|
242
|
-
};
|
|
243
|
-
type Variants = typeof variants;
|
|
244
|
-
type Variant = keyof Variants;
|
|
245
|
-
declare function file(): ReturnType<Variants["string"]>;
|
|
246
|
-
declare function file<K extends Variant>(variant: K): ReturnType<Variants[K]>;
|
|
247
|
-
|
|
248
|
-
declare const ezRawKind = "Raw";
|
|
249
|
-
|
|
250
|
-
declare const ezUploadKind = "Upload";
|
|
251
|
-
|
|
252
|
-
declare const ez: {
|
|
253
|
-
dateIn: () => (zod.ZodPipeline<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodString, zod.ZodString]>, Date, string>, zod.ZodEffects<zod.ZodDate, Date, Date>> | zod.ZodPipeline<zod.ZodEffects<zod.ZodString, Date, string>, zod.ZodEffects<zod.ZodDate, Date, Date>>) & {
|
|
254
|
-
_def: (zod.ZodPipelineDef<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodString, zod.ZodString]>, Date, string>, zod.ZodEffects<zod.ZodDate, Date, Date>> | zod.ZodPipelineDef<zod.ZodEffects<zod.ZodString, Date, string>, zod.ZodEffects<zod.ZodDate, Date, Date>>) & Record<"expressZodApiMeta", Metadata<zod.ZodPipeline<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodString, zod.ZodString]>, Date, string>, zod.ZodEffects<zod.ZodDate, Date, Date>> | zod.ZodPipeline<zod.ZodEffects<zod.ZodString, Date, string>, zod.ZodEffects<zod.ZodDate, Date, Date>>>>;
|
|
255
|
-
} & {
|
|
256
|
-
example: (example: string) => (zod.ZodPipeline<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodString, zod.ZodString]>, Date, string>, zod.ZodEffects<zod.ZodDate, Date, Date>> | zod.ZodPipeline<zod.ZodEffects<zod.ZodString, Date, string>, zod.ZodEffects<zod.ZodDate, Date, Date>>) & {
|
|
257
|
-
_def: (zod.ZodPipelineDef<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodString, zod.ZodString]>, Date, string>, zod.ZodEffects<zod.ZodDate, Date, Date>> | zod.ZodPipelineDef<zod.ZodEffects<zod.ZodString, Date, string>, zod.ZodEffects<zod.ZodDate, Date, Date>>) & Record<"expressZodApiMeta", Metadata<zod.ZodPipeline<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodString, zod.ZodString]>, Date, string>, zod.ZodEffects<zod.ZodDate, Date, Date>> | zod.ZodPipeline<zod.ZodEffects<zod.ZodString, Date, string>, zod.ZodEffects<zod.ZodDate, Date, Date>>>>;
|
|
258
|
-
} & any;
|
|
259
|
-
};
|
|
260
|
-
dateOut: () => zod.ZodEffects<zod.ZodEffects<zod.ZodDate, Date, Date>, string, Date> & {
|
|
261
|
-
_def: zod.ZodEffectsDef<zod.ZodEffects<zod.ZodDate, Date, Date>> & Record<"expressZodApiMeta", Metadata<zod.ZodEffects<zod.ZodEffects<zod.ZodDate, Date, Date>, string, Date>>>;
|
|
262
|
-
} & {
|
|
263
|
-
example: (example: Date) => zod.ZodEffects<zod.ZodEffects<zod.ZodDate, Date, Date>, string, Date> & {
|
|
264
|
-
_def: zod.ZodEffectsDef<zod.ZodEffects<zod.ZodDate, Date, Date>> & Record<"expressZodApiMeta", Metadata<zod.ZodEffects<zod.ZodEffects<zod.ZodDate, Date, Date>, string, Date>>>;
|
|
265
|
-
} & any;
|
|
266
|
-
};
|
|
267
|
-
file: typeof file;
|
|
268
|
-
upload: () => zod.ZodType<express_fileupload.UploadedFile, zod.ZodTypeDef, express_fileupload.UploadedFile> & {
|
|
269
|
-
_def: zod.ZodTypeDef & Record<"expressZodApiMeta", Metadata<zod.ZodType<express_fileupload.UploadedFile, zod.ZodTypeDef, express_fileupload.UploadedFile>>>;
|
|
270
|
-
} & {
|
|
271
|
-
example: (example: express_fileupload.UploadedFile) => zod.ZodType<express_fileupload.UploadedFile, zod.ZodTypeDef, express_fileupload.UploadedFile> & {
|
|
272
|
-
_def: zod.ZodTypeDef & Record<"expressZodApiMeta", Metadata<zod.ZodType<express_fileupload.UploadedFile, zod.ZodTypeDef, express_fileupload.UploadedFile>>>;
|
|
273
|
-
} & any;
|
|
274
|
-
};
|
|
275
|
-
raw: () => zod.ZodObject<{
|
|
276
|
-
raw: zod.ZodType<Buffer, zod.ZodTypeDef, Buffer> & {
|
|
277
|
-
_def: zod.ZodTypeDef & Record<"expressZodApiMeta", Metadata<zod.ZodType<Buffer, zod.ZodTypeDef, Buffer>>>;
|
|
278
|
-
} & {
|
|
279
|
-
example: (example: Buffer) => zod.ZodType<Buffer, zod.ZodTypeDef, Buffer> & {
|
|
280
|
-
_def: zod.ZodTypeDef & Record<"expressZodApiMeta", Metadata<zod.ZodType<Buffer, zod.ZodTypeDef, Buffer>>>;
|
|
281
|
-
} & any;
|
|
282
|
-
};
|
|
283
|
-
}, "strip", zod.ZodTypeAny, {
|
|
284
|
-
raw: Buffer;
|
|
285
|
-
}, {
|
|
286
|
-
raw: Buffer;
|
|
287
|
-
}> & {
|
|
288
|
-
_def: zod.ZodObjectDef<{
|
|
289
|
-
raw: zod.ZodType<Buffer, zod.ZodTypeDef, Buffer> & {
|
|
290
|
-
_def: zod.ZodTypeDef & Record<"expressZodApiMeta", Metadata<zod.ZodType<Buffer, zod.ZodTypeDef, Buffer>>>;
|
|
291
|
-
} & {
|
|
292
|
-
example: (example: Buffer) => zod.ZodType<Buffer, zod.ZodTypeDef, Buffer> & {
|
|
293
|
-
_def: zod.ZodTypeDef & Record<"expressZodApiMeta", Metadata<zod.ZodType<Buffer, zod.ZodTypeDef, Buffer>>>;
|
|
294
|
-
} & any;
|
|
295
|
-
};
|
|
296
|
-
}, "strip", zod.ZodTypeAny> & Record<"expressZodApiMeta", Metadata<zod.ZodObject<{
|
|
297
|
-
raw: zod.ZodType<Buffer, zod.ZodTypeDef, Buffer> & {
|
|
298
|
-
_def: zod.ZodTypeDef & Record<"expressZodApiMeta", Metadata<zod.ZodType<Buffer, zod.ZodTypeDef, Buffer>>>;
|
|
299
|
-
} & {
|
|
300
|
-
example: (example: Buffer) => zod.ZodType<Buffer, zod.ZodTypeDef, Buffer> & {
|
|
301
|
-
_def: zod.ZodTypeDef & Record<"expressZodApiMeta", Metadata<zod.ZodType<Buffer, zod.ZodTypeDef, Buffer>>>;
|
|
302
|
-
} & any;
|
|
303
|
-
};
|
|
304
|
-
}, "strip", zod.ZodTypeAny, {
|
|
305
|
-
raw: Buffer;
|
|
306
|
-
}, {
|
|
307
|
-
raw: Buffer;
|
|
308
|
-
}>>>;
|
|
309
|
-
} & {
|
|
310
|
-
example: (example: {
|
|
311
|
-
raw: Buffer;
|
|
312
|
-
}) => zod.ZodObject<{
|
|
313
|
-
raw: zod.ZodType<Buffer, zod.ZodTypeDef, Buffer> & {
|
|
314
|
-
_def: zod.ZodTypeDef & Record<"expressZodApiMeta", Metadata<zod.ZodType<Buffer, zod.ZodTypeDef, Buffer>>>;
|
|
315
|
-
} & {
|
|
316
|
-
example: (example: Buffer) => zod.ZodType<Buffer, zod.ZodTypeDef, Buffer> & {
|
|
317
|
-
_def: zod.ZodTypeDef & Record<"expressZodApiMeta", Metadata<zod.ZodType<Buffer, zod.ZodTypeDef, Buffer>>>;
|
|
318
|
-
} & any;
|
|
319
|
-
};
|
|
320
|
-
}, "strip", zod.ZodTypeAny, {
|
|
321
|
-
raw: Buffer;
|
|
322
|
-
}, {
|
|
323
|
-
raw: Buffer;
|
|
324
|
-
}> & {
|
|
325
|
-
_def: zod.ZodObjectDef<{
|
|
326
|
-
raw: zod.ZodType<Buffer, zod.ZodTypeDef, Buffer> & {
|
|
327
|
-
_def: zod.ZodTypeDef & Record<"expressZodApiMeta", Metadata<zod.ZodType<Buffer, zod.ZodTypeDef, Buffer>>>;
|
|
328
|
-
} & {
|
|
329
|
-
example: (example: Buffer) => zod.ZodType<Buffer, zod.ZodTypeDef, Buffer> & {
|
|
330
|
-
_def: zod.ZodTypeDef & Record<"expressZodApiMeta", Metadata<zod.ZodType<Buffer, zod.ZodTypeDef, Buffer>>>;
|
|
331
|
-
} & any;
|
|
332
|
-
};
|
|
333
|
-
}, "strip", zod.ZodTypeAny> & Record<"expressZodApiMeta", Metadata<zod.ZodObject<{
|
|
334
|
-
raw: zod.ZodType<Buffer, zod.ZodTypeDef, Buffer> & {
|
|
335
|
-
_def: zod.ZodTypeDef & Record<"expressZodApiMeta", Metadata<zod.ZodType<Buffer, zod.ZodTypeDef, Buffer>>>;
|
|
336
|
-
} & {
|
|
337
|
-
example: (example: Buffer) => zod.ZodType<Buffer, zod.ZodTypeDef, Buffer> & {
|
|
338
|
-
_def: zod.ZodTypeDef & Record<"expressZodApiMeta", Metadata<zod.ZodType<Buffer, zod.ZodTypeDef, Buffer>>>;
|
|
339
|
-
} & any;
|
|
340
|
-
};
|
|
341
|
-
}, "strip", zod.ZodTypeAny, {
|
|
342
|
-
raw: Buffer;
|
|
343
|
-
}, {
|
|
344
|
-
raw: Buffer;
|
|
345
|
-
}>>>;
|
|
346
|
-
} & any;
|
|
347
|
-
};
|
|
348
|
-
};
|
|
349
|
-
type ProprietaryKind = typeof ezFileKind | typeof ezDateInKind | typeof ezDateOutKind | typeof ezUploadKind | typeof ezRawKind;
|
|
350
|
-
|
|
351
|
-
interface Metadata<T extends z.ZodTypeAny> {
|
|
352
|
-
kind?: ProprietaryKind;
|
|
353
|
-
examples: z.input<T>[];
|
|
354
|
-
/** @override ZodDefault::_def.defaultValue() in depictDefault */
|
|
355
|
-
defaultLabel?: string;
|
|
356
|
-
}
|
|
357
|
-
declare const metaProp = "expressZodApiMeta";
|
|
358
|
-
type ExampleSetter<T extends z.ZodTypeAny> = (example: z.input<T>) => WithMeta<T>;
|
|
359
|
-
type DefaultDescriber<T extends z.ZodDefault<z.ZodTypeAny>> = (label: string) => WithMeta<T>;
|
|
360
|
-
type ProprietaryMethods<T extends z.ZodTypeAny> = {
|
|
361
|
-
/** @desc Add an example value (before any transformations, can be called multiple times) */
|
|
362
|
-
example: ExampleSetter<T>;
|
|
363
|
-
} & (T extends z.ZodDefault<z.ZodTypeAny> ? {
|
|
364
|
-
/** @desc Change the default value in the generated Documentation to a label */
|
|
365
|
-
label: DefaultDescriber<T>;
|
|
366
|
-
} : {});
|
|
367
|
-
type WithMeta<T extends z.ZodTypeAny> = T & {
|
|
368
|
-
_def: T["_def"] & Record<typeof metaProp, Metadata<T>>;
|
|
369
|
-
} & ProprietaryMethods<T>;
|
|
370
|
-
declare const withMeta: <T extends z.ZodType<any, z.ZodTypeDef, any>>(schema: T) => WithMeta<T>;
|
|
371
|
-
|
|
372
208
|
interface ResultHandlerParams<RES> {
|
|
373
209
|
/** null in case of failure to parse or to find the matching endpoint (error: not found) */
|
|
374
210
|
input: FlatObject | null;
|
|
@@ -399,49 +235,7 @@ declare const defaultResultHandler: ResultHandlerDefinition<z.ZodObject<{
|
|
|
399
235
|
}, {
|
|
400
236
|
status: "success";
|
|
401
237
|
data?: unknown;
|
|
402
|
-
}
|
|
403
|
-
_def: z.ZodObjectDef<{
|
|
404
|
-
status: z.ZodLiteral<"success">;
|
|
405
|
-
data: IOSchema;
|
|
406
|
-
}, "strip", z.ZodTypeAny> & Record<"expressZodApiMeta", Metadata<z.ZodObject<{
|
|
407
|
-
status: z.ZodLiteral<"success">;
|
|
408
|
-
data: IOSchema;
|
|
409
|
-
}, "strip", z.ZodTypeAny, {
|
|
410
|
-
status: "success";
|
|
411
|
-
data?: unknown;
|
|
412
|
-
}, {
|
|
413
|
-
status: "success";
|
|
414
|
-
data?: unknown;
|
|
415
|
-
}>>>;
|
|
416
|
-
} & {
|
|
417
|
-
example: (example: {
|
|
418
|
-
status: "success";
|
|
419
|
-
data?: unknown;
|
|
420
|
-
}) => z.ZodObject<{
|
|
421
|
-
status: z.ZodLiteral<"success">;
|
|
422
|
-
data: IOSchema;
|
|
423
|
-
}, "strip", z.ZodTypeAny, {
|
|
424
|
-
status: "success";
|
|
425
|
-
data?: unknown;
|
|
426
|
-
}, {
|
|
427
|
-
status: "success";
|
|
428
|
-
data?: unknown;
|
|
429
|
-
}> & {
|
|
430
|
-
_def: z.ZodObjectDef<{
|
|
431
|
-
status: z.ZodLiteral<"success">;
|
|
432
|
-
data: IOSchema;
|
|
433
|
-
}, "strip", z.ZodTypeAny> & Record<"expressZodApiMeta", Metadata<z.ZodObject<{
|
|
434
|
-
status: z.ZodLiteral<"success">;
|
|
435
|
-
data: IOSchema;
|
|
436
|
-
}, "strip", z.ZodTypeAny, {
|
|
437
|
-
status: "success";
|
|
438
|
-
data?: unknown;
|
|
439
|
-
}, {
|
|
440
|
-
status: "success";
|
|
441
|
-
data?: unknown;
|
|
442
|
-
}>>>;
|
|
443
|
-
} & any;
|
|
444
|
-
}, z.ZodObject<{
|
|
238
|
+
}>, z.ZodObject<{
|
|
445
239
|
status: z.ZodLiteral<"error">;
|
|
446
240
|
error: z.ZodObject<{
|
|
447
241
|
message: z.ZodString;
|
|
@@ -460,111 +254,13 @@ declare const defaultResultHandler: ResultHandlerDefinition<z.ZodObject<{
|
|
|
460
254
|
error: {
|
|
461
255
|
message: string;
|
|
462
256
|
};
|
|
463
|
-
}
|
|
464
|
-
_def: z.ZodObjectDef<{
|
|
465
|
-
status: z.ZodLiteral<"error">;
|
|
466
|
-
error: z.ZodObject<{
|
|
467
|
-
message: z.ZodString;
|
|
468
|
-
}, "strip", z.ZodTypeAny, {
|
|
469
|
-
message: string;
|
|
470
|
-
}, {
|
|
471
|
-
message: string;
|
|
472
|
-
}>;
|
|
473
|
-
}, "strip", z.ZodTypeAny> & Record<"expressZodApiMeta", Metadata<z.ZodObject<{
|
|
474
|
-
status: z.ZodLiteral<"error">;
|
|
475
|
-
error: z.ZodObject<{
|
|
476
|
-
message: z.ZodString;
|
|
477
|
-
}, "strip", z.ZodTypeAny, {
|
|
478
|
-
message: string;
|
|
479
|
-
}, {
|
|
480
|
-
message: string;
|
|
481
|
-
}>;
|
|
482
|
-
}, "strip", z.ZodTypeAny, {
|
|
483
|
-
status: "error";
|
|
484
|
-
error: {
|
|
485
|
-
message: string;
|
|
486
|
-
};
|
|
487
|
-
}, {
|
|
488
|
-
status: "error";
|
|
489
|
-
error: {
|
|
490
|
-
message: string;
|
|
491
|
-
};
|
|
492
|
-
}>>>;
|
|
493
|
-
} & {
|
|
494
|
-
example: (example: {
|
|
495
|
-
status: "error";
|
|
496
|
-
error: {
|
|
497
|
-
message: string;
|
|
498
|
-
};
|
|
499
|
-
}) => z.ZodObject<{
|
|
500
|
-
status: z.ZodLiteral<"error">;
|
|
501
|
-
error: z.ZodObject<{
|
|
502
|
-
message: z.ZodString;
|
|
503
|
-
}, "strip", z.ZodTypeAny, {
|
|
504
|
-
message: string;
|
|
505
|
-
}, {
|
|
506
|
-
message: string;
|
|
507
|
-
}>;
|
|
508
|
-
}, "strip", z.ZodTypeAny, {
|
|
509
|
-
status: "error";
|
|
510
|
-
error: {
|
|
511
|
-
message: string;
|
|
512
|
-
};
|
|
513
|
-
}, {
|
|
514
|
-
status: "error";
|
|
515
|
-
error: {
|
|
516
|
-
message: string;
|
|
517
|
-
};
|
|
518
|
-
}> & {
|
|
519
|
-
_def: z.ZodObjectDef<{
|
|
520
|
-
status: z.ZodLiteral<"error">;
|
|
521
|
-
error: z.ZodObject<{
|
|
522
|
-
message: z.ZodString;
|
|
523
|
-
}, "strip", z.ZodTypeAny, {
|
|
524
|
-
message: string;
|
|
525
|
-
}, {
|
|
526
|
-
message: string;
|
|
527
|
-
}>;
|
|
528
|
-
}, "strip", z.ZodTypeAny> & Record<"expressZodApiMeta", Metadata<z.ZodObject<{
|
|
529
|
-
status: z.ZodLiteral<"error">;
|
|
530
|
-
error: z.ZodObject<{
|
|
531
|
-
message: z.ZodString;
|
|
532
|
-
}, "strip", z.ZodTypeAny, {
|
|
533
|
-
message: string;
|
|
534
|
-
}, {
|
|
535
|
-
message: string;
|
|
536
|
-
}>;
|
|
537
|
-
}, "strip", z.ZodTypeAny, {
|
|
538
|
-
status: "error";
|
|
539
|
-
error: {
|
|
540
|
-
message: string;
|
|
541
|
-
};
|
|
542
|
-
}, {
|
|
543
|
-
status: "error";
|
|
544
|
-
error: {
|
|
545
|
-
message: string;
|
|
546
|
-
};
|
|
547
|
-
}>>>;
|
|
548
|
-
} & any;
|
|
549
|
-
}>;
|
|
257
|
+
}>>;
|
|
550
258
|
/**
|
|
551
259
|
* @deprecated Resist the urge of using it: this handler is designed only to simplify the migration of legacy APIs.
|
|
552
260
|
* @desc Responding with array is a bad practice keeping your endpoints from evolving without breaking changes.
|
|
553
261
|
* @desc This handler expects your endpoint to have the property 'items' in the output object schema
|
|
554
262
|
* */
|
|
555
|
-
declare const arrayResultHandler: ResultHandlerDefinition<z.ZodArray<z.ZodTypeAny, "many"
|
|
556
|
-
_def: z.ZodArrayDef<z.ZodTypeAny> & Record<"expressZodApiMeta", Metadata<z.ZodArray<z.ZodTypeAny, "many">>>;
|
|
557
|
-
} & {
|
|
558
|
-
example: (example: any[]) => z.ZodArray<z.ZodTypeAny, "many"> & {
|
|
559
|
-
_def: z.ZodArrayDef<z.ZodTypeAny> & Record<"expressZodApiMeta", Metadata<z.ZodArray<z.ZodTypeAny, "many">>>;
|
|
560
|
-
} & any;
|
|
561
|
-
}, z.ZodString & {
|
|
562
|
-
_def: z.ZodStringDef & Record<"expressZodApiMeta", Metadata<z.ZodString>>;
|
|
563
|
-
} & {
|
|
564
|
-
example: (example: string) => z.ZodString & {
|
|
565
|
-
_def: z.ZodStringDef & Record<"expressZodApiMeta", Metadata<z.ZodString>>;
|
|
566
|
-
} & any;
|
|
567
|
-
}>;
|
|
263
|
+
declare const arrayResultHandler: ResultHandlerDefinition<z.ZodArray<z.ZodTypeAny, "many">, z.ZodString>;
|
|
568
264
|
|
|
569
265
|
type Handler<IN, OUT, OPT> = (params: {
|
|
570
266
|
input: IN;
|
|
@@ -875,6 +571,41 @@ declare class Documentation extends OpenApiBuilder {
|
|
|
875
571
|
constructor({ routing, config, title, version, serverUrl, descriptions, hasSummaryFromDescription, composition, serializer, }: DocumentationParams);
|
|
876
572
|
}
|
|
877
573
|
|
|
574
|
+
declare const ezRawKind = "Raw";
|
|
575
|
+
|
|
576
|
+
declare const ezDateInKind = "DateIn";
|
|
577
|
+
|
|
578
|
+
declare const ezDateOutKind = "DateOut";
|
|
579
|
+
|
|
580
|
+
declare const ezFileKind = "File";
|
|
581
|
+
declare const variants: {
|
|
582
|
+
buffer: () => z.ZodType<Buffer, z.ZodTypeDef, Buffer>;
|
|
583
|
+
string: () => z.ZodString;
|
|
584
|
+
binary: () => z.ZodUnion<[z.ZodType<Buffer, z.ZodTypeDef, Buffer>, z.ZodString]>;
|
|
585
|
+
base64: () => z.ZodString;
|
|
586
|
+
};
|
|
587
|
+
type Variants = typeof variants;
|
|
588
|
+
type Variant = keyof Variants;
|
|
589
|
+
declare function file(): ReturnType<Variants["string"]>;
|
|
590
|
+
declare function file<K extends Variant>(variant: K): ReturnType<Variants[K]>;
|
|
591
|
+
|
|
592
|
+
declare const ezUploadKind = "Upload";
|
|
593
|
+
|
|
594
|
+
declare const ez: {
|
|
595
|
+
dateIn: () => zod.ZodPipeline<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodString, zod.ZodString]>, Date, string>, zod.ZodEffects<zod.ZodDate, Date, Date>> | zod.ZodPipeline<zod.ZodEffects<zod.ZodString, Date, string>, zod.ZodEffects<zod.ZodDate, Date, Date>>;
|
|
596
|
+
dateOut: () => zod.ZodEffects<zod.ZodEffects<zod.ZodDate, Date, Date>, string, Date>;
|
|
597
|
+
file: typeof file;
|
|
598
|
+
upload: () => zod.ZodType<express_fileupload.UploadedFile, zod.ZodTypeDef, express_fileupload.UploadedFile>;
|
|
599
|
+
raw: () => zod.ZodObject<{
|
|
600
|
+
raw: zod.ZodType<Buffer, zod.ZodTypeDef, Buffer>;
|
|
601
|
+
}, "strip", zod.ZodTypeAny, {
|
|
602
|
+
raw: Buffer;
|
|
603
|
+
}, {
|
|
604
|
+
raw: Buffer;
|
|
605
|
+
}>;
|
|
606
|
+
};
|
|
607
|
+
type ProprietaryKind = typeof ezFileKind | typeof ezDateInKind | typeof ezDateOutKind | typeof ezUploadKind | typeof ezRawKind;
|
|
608
|
+
|
|
878
609
|
interface OpenAPIContext extends FlatObject {
|
|
879
610
|
isResponse: boolean;
|
|
880
611
|
serializer: (schema: z.ZodTypeAny) => string;
|
|
@@ -918,6 +649,32 @@ declare class MissingPeerError extends Error {
|
|
|
918
649
|
constructor(module: string | string[]);
|
|
919
650
|
}
|
|
920
651
|
|
|
652
|
+
declare const metaSymbol: unique symbol;
|
|
653
|
+
interface Metadata<T extends z.ZodTypeAny> {
|
|
654
|
+
kind?: ProprietaryKind;
|
|
655
|
+
examples: z.input<T>[];
|
|
656
|
+
/** @override ZodDefault::_def.defaultValue() in depictDefault */
|
|
657
|
+
defaultLabel?: string;
|
|
658
|
+
}
|
|
659
|
+
declare module "zod" {
|
|
660
|
+
interface ZodTypeDef {
|
|
661
|
+
[metaSymbol]?: Metadata<z.ZodTypeAny>;
|
|
662
|
+
}
|
|
663
|
+
interface ZodType {
|
|
664
|
+
/** @desc Add an example value (before any transformations, can be called multiple times) */
|
|
665
|
+
example(example: this["_input"]): this;
|
|
666
|
+
}
|
|
667
|
+
interface ZodDefault<T extends z.ZodTypeAny> {
|
|
668
|
+
/** @desc Change the default value in the generated Documentation to a label */
|
|
669
|
+
label(label: string): this;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* @deprecated no longer required
|
|
674
|
+
* @todo remove in v19
|
|
675
|
+
* */
|
|
676
|
+
declare const withMeta: <T extends z.ZodTypeAny>(schema: T) => T;
|
|
677
|
+
|
|
921
678
|
/**
|
|
922
679
|
* @desc Using module augmentation approach you can set the Mock type of your actual testing framework.
|
|
923
680
|
* @example declare module "express-zod-api" { interface MockOverrides extends Mock {} }
|
|
@@ -1069,4 +826,4 @@ declare class Integration {
|
|
|
1069
826
|
printFormatted({ printerOptions, format: userDefined, }?: FormattedPrintingOptions): Promise<string>;
|
|
1070
827
|
}
|
|
1071
828
|
|
|
1072
|
-
export { AbstractEndpoint, type ApiResponse, type AppConfig, type BasicSecurity, type BearerSecurity, type CommonConfig, type CookieSecurity, type CustomHeaderSecurity, DependsOnMethod, Documentation, DocumentationError, EndpointsFactory, type FlatObject, type IOSchema, type InputSecurity, InputValidationError, Integration, type LoggerOverrides, type Metadata, type Method, type MiddlewareDefinition, MissingPeerError, type MockOverrides, type OAuth2Security, type OpenIdSecurity, OutputValidationError, type
|
|
829
|
+
export { AbstractEndpoint, type ApiResponse, type AppConfig, type BasicSecurity, type BearerSecurity, type CommonConfig, type CookieSecurity, type CustomHeaderSecurity, DependsOnMethod, Documentation, DocumentationError, EndpointsFactory, type FlatObject, type IOSchema, type InputSecurity, InputValidationError, Integration, type LoggerOverrides, type Metadata, type Method, type MiddlewareDefinition, MissingPeerError, type MockOverrides, type OAuth2Security, type OpenIdSecurity, OutputValidationError, type ResultHandlerDefinition, type Routing, RoutingError, ServeStatic, type ServerConfig, arrayEndpointsFactory, arrayResultHandler, attachRouting, createConfig, createLogger, createMiddleware, createResultHandler, createServer, defaultEndpointsFactory, defaultResultHandler, ez, getExamples, getMessageFromError, getStatusCodeFromError, testEndpoint, withMeta };
|