@stlmpp/nestjs-zod 1.0.0 → 1.0.1

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/dto.d.cts CHANGED
@@ -1,2 +1,21 @@
1
- import { n as createZodDto, r as isZodDto, t as ZodDto } from "./dto-CMhDHMJh.cjs";
1
+ import { ZodType } from "zod";
2
+ import { input, output } from "zod/v4/core";
3
+
4
+ //#region src/dto.d.ts
5
+ type ZodDtoInstance<TSchema extends ZodType, Type extends 'input' | 'output'> = Type extends 'output' ? output<TSchema> : input<TSchema>;
6
+ interface ZodDto<TSchema extends ZodType = ZodType, TCodec extends boolean = boolean, Type extends 'input' | 'output' = 'input'> {
7
+ new (): ZodDtoInstance<TSchema, Type>;
8
+ isZodDto: true;
9
+ schema: TSchema;
10
+ codec: TCodec;
11
+ create(input: unknown): ZodDtoInstance<TSchema, Type>;
12
+ Output: ZodDto<ZodType, TCodec>;
13
+ _OPENAPI_METADATA_FACTORY(): unknown;
14
+ }
15
+ declare function createZodDto<TSchema extends ZodType, TCodec extends boolean = false, Type extends 'input' | 'output' = 'input'>(schema: TSchema, options?: {
16
+ codec?: TCodec;
17
+ type?: Type;
18
+ }): ZodDto<TSchema, TCodec, Type>;
19
+ declare function isZodDto(metatype: unknown): metatype is ZodDto<ZodType, boolean, 'input' | 'output'>;
20
+ //#endregion
2
21
  export { ZodDto, createZodDto, isZodDto };
package/dist/dto.d.mts CHANGED
@@ -1,2 +1,21 @@
1
- import { n as createZodDto, r as isZodDto, t as ZodDto } from "./dto-CMhDHMJh.mjs";
1
+ import { input, output } from "zod/v4/core";
2
+ import { ZodType } from "zod";
3
+
4
+ //#region src/dto.d.ts
5
+ type ZodDtoInstance<TSchema extends ZodType, Type extends 'input' | 'output'> = Type extends 'output' ? output<TSchema> : input<TSchema>;
6
+ interface ZodDto<TSchema extends ZodType = ZodType, TCodec extends boolean = boolean, Type extends 'input' | 'output' = 'input'> {
7
+ new (): ZodDtoInstance<TSchema, Type>;
8
+ isZodDto: true;
9
+ schema: TSchema;
10
+ codec: TCodec;
11
+ create(input: unknown): ZodDtoInstance<TSchema, Type>;
12
+ Output: ZodDto<ZodType, TCodec>;
13
+ _OPENAPI_METADATA_FACTORY(): unknown;
14
+ }
15
+ declare function createZodDto<TSchema extends ZodType, TCodec extends boolean = false, Type extends 'input' | 'output' = 'input'>(schema: TSchema, options?: {
16
+ codec?: TCodec;
17
+ type?: Type;
18
+ }): ZodDto<TSchema, TCodec, Type>;
19
+ declare function isZodDto(metatype: unknown): metatype is ZodDto<ZodType, boolean, 'input' | 'output'>;
20
+ //#endregion
2
21
  export { ZodDto, createZodDto, isZodDto };
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
- import { a as UnknownSchema, i as RequiredBy, n as createZodDto, t as ZodDto } from "./dto-CMhDHMJh.cjs";
1
+ import { ZodDto, createZodDto } from "./dto.cjs";
2
+ import { ZodType } from "zod";
2
3
  import { input, output } from "zod/v4/core";
3
4
  import { BadRequestException, CallHandler, CanActivate, ExecutionContext, InternalServerErrorException, PipeTransform } from "@nestjs/common";
4
5
  import { z } from "zod/v3";
@@ -33,6 +34,19 @@ declare class ZodSerializationException extends InternalServerErrorException {
33
34
  }
34
35
  type ZodExceptionCreator = (error: unknown) => Error;
35
36
  //#endregion
37
+ //#region src/types.d.ts
38
+ interface UnknownSchema {
39
+ parse(input: unknown, options?: {
40
+ reportInput?: boolean;
41
+ [x: string | number | symbol]: unknown;
42
+ }): unknown;
43
+ encode?(input: unknown, options?: {
44
+ reportInput?: boolean;
45
+ [x: string | number | symbol]: unknown;
46
+ }): unknown;
47
+ array?: () => UnknownSchema;
48
+ }
49
+ //#endregion
36
50
  //#region src/guard.d.ts
37
51
  type Source = 'body' | 'query' | 'params';
38
52
  interface ZodBodyGuardOptions {
@@ -113,7 +127,7 @@ declare const ZodSerializerInterceptor: ZodSerializerInterceptorClass;
113
127
  * @deprecated `validate` will be removed in a future version. It is
114
128
  * recommended to use `.parse` directly
115
129
  */
116
- declare function validate<TSchema extends UnknownSchema>(value: unknown, schemaOrDto: TSchema | ZodDto<TSchema, boolean>, createValidationException?: ZodExceptionCreator): ReturnType<TSchema['parse']>;
130
+ declare function validate(value: unknown, schemaOrDto: UnknownSchema | ZodDto, createValidationException?: ZodExceptionCreator): unknown;
117
131
  //#endregion
118
132
  //#region src/cleanupOpenApiDoc.d.ts
119
133
  /**
@@ -188,7 +202,7 @@ declare function cleanupOpenApiDoc(doc: OpenAPIObject, {
188
202
  * return [{ id: '1' }, { id: '2' }];
189
203
  * }
190
204
  */
191
- declare function ZodResponse<TSchema extends UnknownSchema>({
205
+ declare function ZodResponse<TSchema extends ZodType>({
192
206
  status,
193
207
  description,
194
208
  type
@@ -197,7 +211,7 @@ declare function ZodResponse<TSchema extends UnknownSchema>({
197
211
  description?: string;
198
212
  type: ZodDto<TSchema, true, 'input' | 'output'>;
199
213
  }): (target: object, propertyKey?: string | symbol, descriptor?: Pick<TypedPropertyDescriptor<(...args: any[]) => output<TSchema> | Promise<output<TSchema>>>, 'value'>) => void;
200
- declare function ZodResponse<TSchema extends RequiredBy<UnknownSchema, 'array'>>({
214
+ declare function ZodResponse<TSchema extends ZodType>({
201
215
  status,
202
216
  description,
203
217
  type
@@ -206,7 +220,7 @@ declare function ZodResponse<TSchema extends RequiredBy<UnknownSchema, 'array'>>
206
220
  description?: string;
207
221
  type: [ZodDto<TSchema, true, 'input' | 'output'>];
208
222
  }): (target: object, propertyKey?: string | symbol, descriptor?: Pick<TypedPropertyDescriptor<(...args: any[]) => Array<output<TSchema>> | Promise<Array<output<TSchema>>>>, 'value'>) => void;
209
- declare function ZodResponse<TSchema extends UnknownSchema>({
223
+ declare function ZodResponse<TSchema extends ZodType>({
210
224
  status,
211
225
  description,
212
226
  type
@@ -215,7 +229,7 @@ declare function ZodResponse<TSchema extends UnknownSchema>({
215
229
  description?: string;
216
230
  type: ZodDto<TSchema, false, 'input' | 'output'>;
217
231
  }): (target: object, propertyKey?: string | symbol, descriptor?: Pick<TypedPropertyDescriptor<(...args: any[]) => input<TSchema> | Promise<input<TSchema>>>, 'value'>) => void;
218
- declare function ZodResponse<TSchema extends RequiredBy<UnknownSchema, 'array'>>({
232
+ declare function ZodResponse<TSchema extends ZodType>({
219
233
  status,
220
234
  description,
221
235
  type
package/dist/index.d.mts CHANGED
@@ -1,9 +1,10 @@
1
- import { a as UnknownSchema, i as RequiredBy, n as createZodDto, t as ZodDto } from "./dto-CMhDHMJh.mjs";
1
+ import { ZodDto, createZodDto } from "./dto.mjs";
2
2
  import { input, output } from "zod/v4/core";
3
3
  import { z } from "zod/v3";
4
4
  import { BadRequestException, CallHandler, CanActivate, ExecutionContext, InternalServerErrorException, PipeTransform } from "@nestjs/common";
5
5
  import { Observable } from "rxjs";
6
6
  import { OpenAPIObject } from "@nestjs/swagger";
7
+ import { ZodType } from "zod";
7
8
 
8
9
  //#region src/config.d.ts
9
10
  interface ZodDtoConfig {
@@ -33,6 +34,19 @@ declare class ZodSerializationException extends InternalServerErrorException {
33
34
  }
34
35
  type ZodExceptionCreator = (error: unknown) => Error;
35
36
  //#endregion
37
+ //#region src/types.d.ts
38
+ interface UnknownSchema {
39
+ parse(input: unknown, options?: {
40
+ reportInput?: boolean;
41
+ [x: string | number | symbol]: unknown;
42
+ }): unknown;
43
+ encode?(input: unknown, options?: {
44
+ reportInput?: boolean;
45
+ [x: string | number | symbol]: unknown;
46
+ }): unknown;
47
+ array?: () => UnknownSchema;
48
+ }
49
+ //#endregion
36
50
  //#region src/guard.d.ts
37
51
  type Source = 'body' | 'query' | 'params';
38
52
  interface ZodBodyGuardOptions {
@@ -113,7 +127,7 @@ declare const ZodSerializerInterceptor: ZodSerializerInterceptorClass;
113
127
  * @deprecated `validate` will be removed in a future version. It is
114
128
  * recommended to use `.parse` directly
115
129
  */
116
- declare function validate<TSchema extends UnknownSchema>(value: unknown, schemaOrDto: TSchema | ZodDto<TSchema, boolean>, createValidationException?: ZodExceptionCreator): ReturnType<TSchema['parse']>;
130
+ declare function validate(value: unknown, schemaOrDto: UnknownSchema | ZodDto, createValidationException?: ZodExceptionCreator): unknown;
117
131
  //#endregion
118
132
  //#region src/cleanupOpenApiDoc.d.ts
119
133
  /**
@@ -188,7 +202,7 @@ declare function cleanupOpenApiDoc(doc: OpenAPIObject, {
188
202
  * return [{ id: '1' }, { id: '2' }];
189
203
  * }
190
204
  */
191
- declare function ZodResponse<TSchema extends UnknownSchema>({
205
+ declare function ZodResponse<TSchema extends ZodType>({
192
206
  status,
193
207
  description,
194
208
  type
@@ -197,7 +211,7 @@ declare function ZodResponse<TSchema extends UnknownSchema>({
197
211
  description?: string;
198
212
  type: ZodDto<TSchema, true, 'input' | 'output'>;
199
213
  }): (target: object, propertyKey?: string | symbol, descriptor?: Pick<TypedPropertyDescriptor<(...args: any[]) => output<TSchema> | Promise<output<TSchema>>>, 'value'>) => void;
200
- declare function ZodResponse<TSchema extends RequiredBy<UnknownSchema, 'array'>>({
214
+ declare function ZodResponse<TSchema extends ZodType>({
201
215
  status,
202
216
  description,
203
217
  type
@@ -206,7 +220,7 @@ declare function ZodResponse<TSchema extends RequiredBy<UnknownSchema, 'array'>>
206
220
  description?: string;
207
221
  type: [ZodDto<TSchema, true, 'input' | 'output'>];
208
222
  }): (target: object, propertyKey?: string | symbol, descriptor?: Pick<TypedPropertyDescriptor<(...args: any[]) => Array<output<TSchema>> | Promise<Array<output<TSchema>>>>, 'value'>) => void;
209
- declare function ZodResponse<TSchema extends UnknownSchema>({
223
+ declare function ZodResponse<TSchema extends ZodType>({
210
224
  status,
211
225
  description,
212
226
  type
@@ -215,7 +229,7 @@ declare function ZodResponse<TSchema extends UnknownSchema>({
215
229
  description?: string;
216
230
  type: ZodDto<TSchema, false, 'input' | 'output'>;
217
231
  }): (target: object, propertyKey?: string | symbol, descriptor?: Pick<TypedPropertyDescriptor<(...args: any[]) => input<TSchema> | Promise<input<TSchema>>>, 'value'>) => void;
218
- declare function ZodResponse<TSchema extends RequiredBy<UnknownSchema, 'array'>>({
232
+ declare function ZodResponse<TSchema extends ZodType>({
219
233
  status,
220
234
  description,
221
235
  type
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stlmpp/nestjs-zod",
3
3
  "description": "All NestJS + Zod utilities you need",
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
5
5
  "main": "./dist/index.cjs",
6
6
  "exports": {
7
7
  ".": {
@@ -1,61 +0,0 @@
1
- import { input, output } from "zod/v4/core";
2
-
3
- //#region src/types.d.ts
4
- interface UnknownSchema {
5
- parse(input: unknown, options?: {
6
- reportInput?: boolean;
7
- [x: string | number | symbol]: unknown;
8
- }): unknown;
9
- encode?(input: unknown, options?: {
10
- reportInput?: boolean;
11
- [x: string | number | symbol]: unknown;
12
- }): unknown;
13
- array?: () => UnknownSchema;
14
- }
15
- /**
16
- * RequiredBy
17
- * @desc From `T` make a set of properties by key `K` become required
18
- * @example
19
- * type Props = {
20
- * name?: string;
21
- * age?: number;
22
- * visible?: boolean;
23
- * };
24
- *
25
- * // Expect: { name: string; age: number; visible: boolean; }
26
- * type Props = RequiredBy<Props>;
27
- *
28
- * // Expect: { name?: string; age: number; visible: boolean; }
29
- * type Props = RequiredBy<Props, 'age' | 'visible'>;
30
- */
31
- type RequiredBy<T extends object, K extends keyof T = keyof T> = Omit<T, K> & Required<Pick<T, K>>;
32
- //#endregion
33
- //#region src/dto.d.ts
34
- /**
35
- * `input`/`output` from `zod/v4/core` fall back to `unknown` for schemas
36
- * that don't expose v4-style `_zod` internals (zod v3 schemas, zod-mini
37
- * schemas, or duck-typed `UnknownSchema` objects). For those, fall back to
38
- * the schema's `parse` return type, same as before `Type` existed.
39
- */
40
- type ZodDtoInstance<TSchema extends UnknownSchema, Type extends 'input' | 'output'> = TSchema extends {
41
- _zod: {
42
- input: unknown;
43
- output: unknown;
44
- };
45
- } ? Type extends 'output' ? output<TSchema> : input<TSchema> : ReturnType<TSchema['parse']>;
46
- interface ZodDto<TSchema extends UnknownSchema = UnknownSchema, TCodec extends boolean = boolean, Type extends 'input' | 'output' = 'input'> {
47
- new (): ZodDtoInstance<TSchema, Type>;
48
- isZodDto: true;
49
- schema: TSchema;
50
- codec: TCodec;
51
- create(input: unknown): ZodDtoInstance<TSchema, Type>;
52
- Output: ZodDto<UnknownSchema, TCodec>;
53
- _OPENAPI_METADATA_FACTORY(): unknown;
54
- }
55
- declare function createZodDto<TSchema extends UnknownSchema, TCodec extends boolean = false, Type extends 'input' | 'output' = 'input'>(schema: TSchema, options?: {
56
- codec?: TCodec;
57
- type?: Type;
58
- }): ZodDto<TSchema, TCodec, Type>;
59
- declare function isZodDto(metatype: unknown): metatype is ZodDto<UnknownSchema, boolean, 'input' | 'output'>;
60
- //#endregion
61
- export { UnknownSchema as a, RequiredBy as i, createZodDto as n, isZodDto as r, ZodDto as t };
@@ -1,61 +0,0 @@
1
- import { input, output } from "zod/v4/core";
2
-
3
- //#region src/types.d.ts
4
- interface UnknownSchema {
5
- parse(input: unknown, options?: {
6
- reportInput?: boolean;
7
- [x: string | number | symbol]: unknown;
8
- }): unknown;
9
- encode?(input: unknown, options?: {
10
- reportInput?: boolean;
11
- [x: string | number | symbol]: unknown;
12
- }): unknown;
13
- array?: () => UnknownSchema;
14
- }
15
- /**
16
- * RequiredBy
17
- * @desc From `T` make a set of properties by key `K` become required
18
- * @example
19
- * type Props = {
20
- * name?: string;
21
- * age?: number;
22
- * visible?: boolean;
23
- * };
24
- *
25
- * // Expect: { name: string; age: number; visible: boolean; }
26
- * type Props = RequiredBy<Props>;
27
- *
28
- * // Expect: { name?: string; age: number; visible: boolean; }
29
- * type Props = RequiredBy<Props, 'age' | 'visible'>;
30
- */
31
- type RequiredBy<T extends object, K extends keyof T = keyof T> = Omit<T, K> & Required<Pick<T, K>>;
32
- //#endregion
33
- //#region src/dto.d.ts
34
- /**
35
- * `input`/`output` from `zod/v4/core` fall back to `unknown` for schemas
36
- * that don't expose v4-style `_zod` internals (zod v3 schemas, zod-mini
37
- * schemas, or duck-typed `UnknownSchema` objects). For those, fall back to
38
- * the schema's `parse` return type, same as before `Type` existed.
39
- */
40
- type ZodDtoInstance<TSchema extends UnknownSchema, Type extends 'input' | 'output'> = TSchema extends {
41
- _zod: {
42
- input: unknown;
43
- output: unknown;
44
- };
45
- } ? Type extends 'output' ? output<TSchema> : input<TSchema> : ReturnType<TSchema['parse']>;
46
- interface ZodDto<TSchema extends UnknownSchema = UnknownSchema, TCodec extends boolean = boolean, Type extends 'input' | 'output' = 'input'> {
47
- new (): ZodDtoInstance<TSchema, Type>;
48
- isZodDto: true;
49
- schema: TSchema;
50
- codec: TCodec;
51
- create(input: unknown): ZodDtoInstance<TSchema, Type>;
52
- Output: ZodDto<UnknownSchema, TCodec>;
53
- _OPENAPI_METADATA_FACTORY(): unknown;
54
- }
55
- declare function createZodDto<TSchema extends UnknownSchema, TCodec extends boolean = false, Type extends 'input' | 'output' = 'input'>(schema: TSchema, options?: {
56
- codec?: TCodec;
57
- type?: Type;
58
- }): ZodDto<TSchema, TCodec, Type>;
59
- declare function isZodDto(metatype: unknown): metatype is ZodDto<UnknownSchema, boolean, 'input' | 'output'>;
60
- //#endregion
61
- export { UnknownSchema as a, RequiredBy as i, createZodDto as n, isZodDto as r, ZodDto as t };