From fa72b4dbc371fc18732a6f7272e56d000aab362f Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 20 Oct 2024 13:09:01 -0400 Subject: [PATCH 1/3] Use deepmerge instead of merge-deep --- packages/nestjs-zod/package.json | 2 +- .../nestjs-zod/src/openapi/zod-to-openapi.ts | 12 +- pnpm-lock.yaml | 112 +----------------- 3 files changed, 13 insertions(+), 113 deletions(-) diff --git a/packages/nestjs-zod/package.json b/packages/nestjs-zod/package.json index f837ca6..654c1f3 100755 --- a/packages/nestjs-zod/package.json +++ b/packages/nestjs-zod/package.json @@ -81,7 +81,7 @@ } }, "dependencies": { - "merge-deep": "^3.0.3", + "deepmerge": "^4.3.1", "@nest-zod/z": "*" } } \ No newline at end of file diff --git a/packages/nestjs-zod/src/openapi/zod-to-openapi.ts b/packages/nestjs-zod/src/openapi/zod-to-openapi.ts index 4757105..66e8d66 100644 --- a/packages/nestjs-zod/src/openapi/zod-to-openapi.ts +++ b/packages/nestjs-zod/src/openapi/zod-to-openapi.ts @@ -1,7 +1,7 @@ import { Type } from '@nestjs/common' import { SchemaObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface' -import mergeDeep from 'merge-deep' import { z } from '@nest-zod/z' +import deepmerge from 'deepmerge' interface ExtendedSchemaObject extends SchemaObject { // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -225,9 +225,15 @@ export function zodToOpenAPI( if (is(zodType, z.ZodIntersection)) { const { left, right } = zodType._def - const merged = mergeDeep( + const merged = deepmerge( zodToOpenAPI(left, visited), - zodToOpenAPI(right, visited) + zodToOpenAPI(right, visited), + { + arrayMerge: (target, source) => { + const mergedSet = new Set([...target, ...source]); + return Array.from(mergedSet); + } + } ) Object.assign(object, merged) } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aa6c6f3..1846800 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -111,9 +111,9 @@ importers: '@nest-zod/z': specifier: '*' version: link:../z - merge-deep: - specifier: ^3.0.3 - version: 3.0.3 + deepmerge: + specifier: ^4.3.1 + version: 4.3.1 devDependencies: '@golevelup/ts-jest': specifier: ^0.3.3 @@ -2223,11 +2223,6 @@ packages: '@babel/runtime-corejs3': 7.25.7 dev: true - /arr-union@3.1.0: - resolution: {integrity: sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==} - engines: {node: '>=0.10.0'} - dev: false - /array-buffer-byte-length@1.0.1: resolution: {integrity: sha512-ahC5W1xgou+KTXix4sAO8Ki12Q+jf4i0+tmk3sC+zgcynshkHxzpXdImBehiUYKKKDwvfFiJl1tZt6ewscS1Mg==} engines: {node: '>= 0.4'} @@ -2691,17 +2686,6 @@ packages: wrap-ansi: 7.0.0 dev: true - /clone-deep@0.2.4: - resolution: {integrity: sha512-we+NuQo2DHhSl+DP6jlUiAhyAjBQrYnpOk15rN6c6JSPScjiCLh8IbSU+VTcph6YS3o7mASE8a0+gbZ7ChLpgg==} - engines: {node: '>=0.10.0'} - dependencies: - for-own: 0.1.5 - is-plain-object: 2.0.4 - kind-of: 3.2.2 - lazy-cache: 1.0.4 - shallow-clone: 0.1.2 - dev: false - /clone@1.0.4: resolution: {integrity: sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==} engines: {node: '>=0.8'} @@ -2978,7 +2962,6 @@ packages: /deepmerge@4.3.1: resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} engines: {node: '>=0.10.0'} - dev: true /defaults@1.0.4: resolution: {integrity: sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==} @@ -4176,23 +4159,6 @@ packages: is-callable: 1.2.7 dev: true - /for-in@0.1.8: - resolution: {integrity: sha512-F0to7vbBSHP8E3l6dCjxNOLuSFAACIxFy3UehTUlG7svlXi37HHsDkyVcHo0Pq8QwrE+pXvWSVX3ZT1T9wAZ9g==} - engines: {node: '>=0.10.0'} - dev: false - - /for-in@1.0.2: - resolution: {integrity: sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ==} - engines: {node: '>=0.10.0'} - dev: false - - /for-own@0.1.5: - resolution: {integrity: sha512-SKmowqGTJoPzLO1T0BBJpkfp3EMacCMOuH40hOUbrbzElVktk4DioXVM99QkLCyKoiuOmyjgcWMpVz2xjE7LZw==} - engines: {node: '>=0.10.0'} - dependencies: - for-in: 1.0.2 - dev: false - /foreground-child@3.3.0: resolution: {integrity: sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==} engines: {node: '>=14'} @@ -4721,10 +4687,6 @@ packages: has-tostringtag: 1.0.2 dev: true - /is-buffer@1.1.6: - resolution: {integrity: sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==} - dev: false - /is-builtin-module@3.2.1: resolution: {integrity: sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==} engines: {node: '>=6'} @@ -4758,11 +4720,6 @@ packages: has-tostringtag: 1.0.2 dev: true - /is-extendable@0.1.1: - resolution: {integrity: sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==} - engines: {node: '>=0.10.0'} - dev: false - /is-extglob@2.1.1: resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} engines: {node: '>=0.10.0'} @@ -4821,13 +4778,6 @@ packages: engines: {node: '>=8'} dev: true - /is-plain-object@2.0.4: - resolution: {integrity: sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==} - engines: {node: '>=0.10.0'} - dependencies: - isobject: 3.0.1 - dev: false - /is-plain-object@3.0.1: resolution: {integrity: sha512-Xnpx182SBMrr/aBik8y+GuR4U1L9FqMSojwDQwPMmxyC6bvEqly9UBCxhauBF5vNh2gwWJNX6oDV7O+OM4z34g==} engines: {node: '>=0.10.0'} @@ -4906,11 +4856,6 @@ packages: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} dev: true - /isobject@3.0.1: - resolution: {integrity: sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==} - engines: {node: '>=0.10.0'} - dev: false - /istanbul-lib-coverage@3.2.2: resolution: {integrity: sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==} engines: {node: '>=8'} @@ -5523,20 +5468,6 @@ packages: json-buffer: 3.0.1 dev: true - /kind-of@2.0.1: - resolution: {integrity: sha512-0u8i1NZ/mg0b+W3MGGw5I7+6Eib2nx72S/QvXa0hYjEkjTknYmEYQJwGu3mLC0BrhtJjtQafTkyRUQ75Kx0LVg==} - engines: {node: '>=0.10.0'} - dependencies: - is-buffer: 1.1.6 - dev: false - - /kind-of@3.2.2: - resolution: {integrity: sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==} - engines: {node: '>=0.10.0'} - dependencies: - is-buffer: 1.1.6 - dev: false - /kleur@3.0.3: resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==} engines: {node: '>=6'} @@ -5556,16 +5487,6 @@ packages: language-subtag-registry: 0.3.23 dev: true - /lazy-cache@0.2.7: - resolution: {integrity: sha512-gkX52wvU/R8DVMMt78ATVPFMJqfW8FPz1GZ1sVHBVQHmu/WvhIWE4cE1GBzhJNFicDeYhnwp6Rl35BcAIM3YOQ==} - engines: {node: '>=0.10.0'} - dev: false - - /lazy-cache@1.0.4: - resolution: {integrity: sha512-RE2g0b5VGZsOCFOCgP7omTRYFqydmZkBwl5oNnQ1lDYC57uyO9KqNnNVxT7COSHTxrRCWVcAVOcbjk+tvh/rgQ==} - engines: {node: '>=0.10.0'} - dev: false - /leven@3.1.0: resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==} engines: {node: '>=6'} @@ -5696,15 +5617,6 @@ packages: fs-monkey: 1.0.6 dev: true - /merge-deep@3.0.3: - resolution: {integrity: sha512-qtmzAS6t6grwEkNrunqTBdn0qKwFgNWvlxUbAV8es9M7Ot1EbyApytCnvE0jALPa46ZpKDUo527kKiaWplmlFA==} - engines: {node: '>=0.10.0'} - dependencies: - arr-union: 3.1.0 - clone-deep: 0.2.4 - kind-of: 3.2.2 - dev: false - /merge-descriptors@1.0.3: resolution: {integrity: sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==} @@ -5784,14 +5696,6 @@ packages: engines: {node: '>=16 || 14 >=14.17'} dev: true - /mixin-object@2.0.1: - resolution: {integrity: sha512-ALGF1Jt9ouehcaXaHhn6t1yGWRqGaHkPFndtFVHfZXOvkIZ/yoGaSi0AHVTafb3ZBGg4dr/bDwnaEKqCXzchMA==} - engines: {node: '>=0.10.0'} - dependencies: - for-in: 0.1.8 - is-extendable: 0.1.1 - dev: false - /mkdirp@0.5.6: resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==} hasBin: true @@ -6673,16 +6577,6 @@ packages: /setprototypeof@1.2.0: resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==} - /shallow-clone@0.1.2: - resolution: {integrity: sha512-J1zdXCky5GmNnuauESROVu31MQSnLoYvlyEn6j2Ztk6Q5EHFIhxkMhYcv6vuDzl2XEzoRr856QwzMgWM/TmZgw==} - engines: {node: '>=0.10.0'} - dependencies: - is-extendable: 0.1.1 - kind-of: 2.0.1 - lazy-cache: 0.2.7 - mixin-object: 2.0.1 - dev: false - /shebang-command@2.0.0: resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} engines: {node: '>=8'} From 853809ccfe1d3bf74f02de1f471e1144f180765e Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 20 Oct 2024 13:10:36 -0400 Subject: [PATCH 2/3] Fix missing logo in readme --- packages/nestjs-zod/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/nestjs-zod/package.json b/packages/nestjs-zod/package.json index 654c1f3..04ec7ee 100755 --- a/packages/nestjs-zod/package.json +++ b/packages/nestjs-zod/package.json @@ -18,6 +18,7 @@ "types": "./dist/index.d.ts", "files": [ "dist", + "logo.svg", "dto.d.ts" ], "sideEffects": false, From 166c192467a45622caef861c9599193d8ecffc83 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 20 Oct 2024 13:14:28 -0400 Subject: [PATCH 3/3] Update README with another deprecation warning --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e25059e..06b3666 100755 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ - `zodToOpenAPI` - generate highly accurate Swagger Schema - Zod DTOs can be used in any `@nestjs/swagger` decorator - Extended Zod schemas for NestJS (`@nest-zod/z`) + - **Note:** _`@nest-zod/z` is deprecated and will not be supported soon. It is recommended to use `zod` directly. See [MIGRATION.md](./MIGRATION.md) for more information._ - `dateString` for dates (supports casting to `Date`) - `password` for passwords (more complex string rules + OpenAPI conversion) - Customization - change exception format easily