express-zod-api 18.4.0-beta1 → 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 +33 -2
- package/README.md +6 -6
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +65 -312
- package/dist/index.d.ts +65 -312
- package/dist/index.js +6 -6
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -205,174 +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
|
-
/**
|
|
353
|
-
* @todo if the following PR merged, use native branding instead:
|
|
354
|
-
* @link https://github.com/colinhacks/zod/pull/2860
|
|
355
|
-
* */
|
|
356
|
-
kind?: ProprietaryKind;
|
|
357
|
-
examples: z.input<T>[];
|
|
358
|
-
/** @override ZodDefault::_def.defaultValue() in depictDefault */
|
|
359
|
-
defaultLabel?: string;
|
|
360
|
-
}
|
|
361
|
-
declare const metaProp = "expressZodApiMeta";
|
|
362
|
-
type ExampleSetter<T extends z.ZodTypeAny> = (example: z.input<T>) => WithMeta<T>;
|
|
363
|
-
type DefaultDescriber<T extends z.ZodDefault<z.ZodTypeAny>> = (label: string) => WithMeta<T>;
|
|
364
|
-
type ProprietaryMethods<T extends z.ZodTypeAny> = {
|
|
365
|
-
/** @desc Add an example value (before any transformations, can be called multiple times) */
|
|
366
|
-
example: ExampleSetter<T>;
|
|
367
|
-
} & (T extends z.ZodDefault<z.ZodTypeAny> ? {
|
|
368
|
-
/** @desc Change the default value in the generated Documentation to a label */
|
|
369
|
-
describeDefault: DefaultDescriber<T>;
|
|
370
|
-
} : {});
|
|
371
|
-
type WithMeta<T extends z.ZodTypeAny> = T & {
|
|
372
|
-
_def: T["_def"] & Record<typeof metaProp, Metadata<T>>;
|
|
373
|
-
} & ProprietaryMethods<T>;
|
|
374
|
-
declare const withMeta: <T extends z.ZodType<any, z.ZodTypeDef, any>>(schema: T) => WithMeta<T>;
|
|
375
|
-
|
|
376
208
|
interface ResultHandlerParams<RES> {
|
|
377
209
|
/** null in case of failure to parse or to find the matching endpoint (error: not found) */
|
|
378
210
|
input: FlatObject | null;
|
|
@@ -403,49 +235,7 @@ declare const defaultResultHandler: ResultHandlerDefinition<z.ZodObject<{
|
|
|
403
235
|
}, {
|
|
404
236
|
status: "success";
|
|
405
237
|
data?: unknown;
|
|
406
|
-
}
|
|
407
|
-
_def: z.ZodObjectDef<{
|
|
408
|
-
status: z.ZodLiteral<"success">;
|
|
409
|
-
data: IOSchema;
|
|
410
|
-
}, "strip", z.ZodTypeAny> & Record<"expressZodApiMeta", Metadata<z.ZodObject<{
|
|
411
|
-
status: z.ZodLiteral<"success">;
|
|
412
|
-
data: IOSchema;
|
|
413
|
-
}, "strip", z.ZodTypeAny, {
|
|
414
|
-
status: "success";
|
|
415
|
-
data?: unknown;
|
|
416
|
-
}, {
|
|
417
|
-
status: "success";
|
|
418
|
-
data?: unknown;
|
|
419
|
-
}>>>;
|
|
420
|
-
} & {
|
|
421
|
-
example: (example: {
|
|
422
|
-
status: "success";
|
|
423
|
-
data?: unknown;
|
|
424
|
-
}) => z.ZodObject<{
|
|
425
|
-
status: z.ZodLiteral<"success">;
|
|
426
|
-
data: IOSchema;
|
|
427
|
-
}, "strip", z.ZodTypeAny, {
|
|
428
|
-
status: "success";
|
|
429
|
-
data?: unknown;
|
|
430
|
-
}, {
|
|
431
|
-
status: "success";
|
|
432
|
-
data?: unknown;
|
|
433
|
-
}> & {
|
|
434
|
-
_def: z.ZodObjectDef<{
|
|
435
|
-
status: z.ZodLiteral<"success">;
|
|
436
|
-
data: IOSchema;
|
|
437
|
-
}, "strip", z.ZodTypeAny> & Record<"expressZodApiMeta", Metadata<z.ZodObject<{
|
|
438
|
-
status: z.ZodLiteral<"success">;
|
|
439
|
-
data: IOSchema;
|
|
440
|
-
}, "strip", z.ZodTypeAny, {
|
|
441
|
-
status: "success";
|
|
442
|
-
data?: unknown;
|
|
443
|
-
}, {
|
|
444
|
-
status: "success";
|
|
445
|
-
data?: unknown;
|
|
446
|
-
}>>>;
|
|
447
|
-
} & any;
|
|
448
|
-
}, z.ZodObject<{
|
|
238
|
+
}>, z.ZodObject<{
|
|
449
239
|
status: z.ZodLiteral<"error">;
|
|
450
240
|
error: z.ZodObject<{
|
|
451
241
|
message: z.ZodString;
|
|
@@ -464,111 +254,13 @@ declare const defaultResultHandler: ResultHandlerDefinition<z.ZodObject<{
|
|
|
464
254
|
error: {
|
|
465
255
|
message: string;
|
|
466
256
|
};
|
|
467
|
-
}
|
|
468
|
-
_def: z.ZodObjectDef<{
|
|
469
|
-
status: z.ZodLiteral<"error">;
|
|
470
|
-
error: z.ZodObject<{
|
|
471
|
-
message: z.ZodString;
|
|
472
|
-
}, "strip", z.ZodTypeAny, {
|
|
473
|
-
message: string;
|
|
474
|
-
}, {
|
|
475
|
-
message: string;
|
|
476
|
-
}>;
|
|
477
|
-
}, "strip", z.ZodTypeAny> & Record<"expressZodApiMeta", Metadata<z.ZodObject<{
|
|
478
|
-
status: z.ZodLiteral<"error">;
|
|
479
|
-
error: z.ZodObject<{
|
|
480
|
-
message: z.ZodString;
|
|
481
|
-
}, "strip", z.ZodTypeAny, {
|
|
482
|
-
message: string;
|
|
483
|
-
}, {
|
|
484
|
-
message: string;
|
|
485
|
-
}>;
|
|
486
|
-
}, "strip", z.ZodTypeAny, {
|
|
487
|
-
status: "error";
|
|
488
|
-
error: {
|
|
489
|
-
message: string;
|
|
490
|
-
};
|
|
491
|
-
}, {
|
|
492
|
-
status: "error";
|
|
493
|
-
error: {
|
|
494
|
-
message: string;
|
|
495
|
-
};
|
|
496
|
-
}>>>;
|
|
497
|
-
} & {
|
|
498
|
-
example: (example: {
|
|
499
|
-
status: "error";
|
|
500
|
-
error: {
|
|
501
|
-
message: string;
|
|
502
|
-
};
|
|
503
|
-
}) => z.ZodObject<{
|
|
504
|
-
status: z.ZodLiteral<"error">;
|
|
505
|
-
error: z.ZodObject<{
|
|
506
|
-
message: z.ZodString;
|
|
507
|
-
}, "strip", z.ZodTypeAny, {
|
|
508
|
-
message: string;
|
|
509
|
-
}, {
|
|
510
|
-
message: string;
|
|
511
|
-
}>;
|
|
512
|
-
}, "strip", z.ZodTypeAny, {
|
|
513
|
-
status: "error";
|
|
514
|
-
error: {
|
|
515
|
-
message: string;
|
|
516
|
-
};
|
|
517
|
-
}, {
|
|
518
|
-
status: "error";
|
|
519
|
-
error: {
|
|
520
|
-
message: string;
|
|
521
|
-
};
|
|
522
|
-
}> & {
|
|
523
|
-
_def: z.ZodObjectDef<{
|
|
524
|
-
status: z.ZodLiteral<"error">;
|
|
525
|
-
error: z.ZodObject<{
|
|
526
|
-
message: z.ZodString;
|
|
527
|
-
}, "strip", z.ZodTypeAny, {
|
|
528
|
-
message: string;
|
|
529
|
-
}, {
|
|
530
|
-
message: string;
|
|
531
|
-
}>;
|
|
532
|
-
}, "strip", z.ZodTypeAny> & Record<"expressZodApiMeta", Metadata<z.ZodObject<{
|
|
533
|
-
status: z.ZodLiteral<"error">;
|
|
534
|
-
error: z.ZodObject<{
|
|
535
|
-
message: z.ZodString;
|
|
536
|
-
}, "strip", z.ZodTypeAny, {
|
|
537
|
-
message: string;
|
|
538
|
-
}, {
|
|
539
|
-
message: string;
|
|
540
|
-
}>;
|
|
541
|
-
}, "strip", z.ZodTypeAny, {
|
|
542
|
-
status: "error";
|
|
543
|
-
error: {
|
|
544
|
-
message: string;
|
|
545
|
-
};
|
|
546
|
-
}, {
|
|
547
|
-
status: "error";
|
|
548
|
-
error: {
|
|
549
|
-
message: string;
|
|
550
|
-
};
|
|
551
|
-
}>>>;
|
|
552
|
-
} & any;
|
|
553
|
-
}>;
|
|
257
|
+
}>>;
|
|
554
258
|
/**
|
|
555
259
|
* @deprecated Resist the urge of using it: this handler is designed only to simplify the migration of legacy APIs.
|
|
556
260
|
* @desc Responding with array is a bad practice keeping your endpoints from evolving without breaking changes.
|
|
557
261
|
* @desc This handler expects your endpoint to have the property 'items' in the output object schema
|
|
558
262
|
* */
|
|
559
|
-
declare const arrayResultHandler: ResultHandlerDefinition<z.ZodArray<z.ZodTypeAny, "many"
|
|
560
|
-
_def: z.ZodArrayDef<z.ZodTypeAny> & Record<"expressZodApiMeta", Metadata<z.ZodArray<z.ZodTypeAny, "many">>>;
|
|
561
|
-
} & {
|
|
562
|
-
example: (example: any[]) => z.ZodArray<z.ZodTypeAny, "many"> & {
|
|
563
|
-
_def: z.ZodArrayDef<z.ZodTypeAny> & Record<"expressZodApiMeta", Metadata<z.ZodArray<z.ZodTypeAny, "many">>>;
|
|
564
|
-
} & any;
|
|
565
|
-
}, z.ZodString & {
|
|
566
|
-
_def: z.ZodStringDef & Record<"expressZodApiMeta", Metadata<z.ZodString>>;
|
|
567
|
-
} & {
|
|
568
|
-
example: (example: string) => z.ZodString & {
|
|
569
|
-
_def: z.ZodStringDef & Record<"expressZodApiMeta", Metadata<z.ZodString>>;
|
|
570
|
-
} & any;
|
|
571
|
-
}>;
|
|
263
|
+
declare const arrayResultHandler: ResultHandlerDefinition<z.ZodArray<z.ZodTypeAny, "many">, z.ZodString>;
|
|
572
264
|
|
|
573
265
|
type Handler<IN, OUT, OPT> = (params: {
|
|
574
266
|
input: IN;
|
|
@@ -879,6 +571,41 @@ declare class Documentation extends OpenApiBuilder {
|
|
|
879
571
|
constructor({ routing, config, title, version, serverUrl, descriptions, hasSummaryFromDescription, composition, serializer, }: DocumentationParams);
|
|
880
572
|
}
|
|
881
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
|
+
|
|
882
609
|
interface OpenAPIContext extends FlatObject {
|
|
883
610
|
isResponse: boolean;
|
|
884
611
|
serializer: (schema: z.ZodTypeAny) => string;
|
|
@@ -922,6 +649,32 @@ declare class MissingPeerError extends Error {
|
|
|
922
649
|
constructor(module: string | string[]);
|
|
923
650
|
}
|
|
924
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
|
+
|
|
925
678
|
/**
|
|
926
679
|
* @desc Using module augmentation approach you can set the Mock type of your actual testing framework.
|
|
927
680
|
* @example declare module "express-zod-api" { interface MockOverrides extends Mock {} }
|
|
@@ -1073,4 +826,4 @@ declare class Integration {
|
|
|
1073
826
|
printFormatted({ printerOptions, format: userDefined, }?: FormattedPrintingOptions): Promise<string>;
|
|
1074
827
|
}
|
|
1075
828
|
|
|
1076
|
-
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 };
|