From 2b4e7966d8367c7695749ca0e162d765822c90d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=A3=20Rinaldi?= Date: Tue, 23 Jul 2024 16:30:10 -0300 Subject: [PATCH] Fix: zod path in fork (#51) * Revert "Fix: Zod instanceof not working in lib (#50)" This reverts commit 36bd442d0a8a33fdac24e9b9d4947d0516d8fc94. * Use zod from fork * Test back * Use commit --- package.json | 5 +---- patches/zod@3.22.3.patch | 32 -------------------------------- pnpm-lock.yaml | 16 ++++++---------- 3 files changed, 7 insertions(+), 46 deletions(-) delete mode 100644 patches/zod@3.22.3.patch diff --git a/package.json b/package.json index 16b88b3..1a88a39 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "ts-node": "^10.9.1", "type-assertions": "^1.1.0", "typescript": "^4.9.5", - "zod": "3.22.3" + "zod": "github:cau777/zod#7a619722ad5105fda5968a84200198a6c8850ad4" }, "pnpm": { "overrides": { @@ -59,9 +59,6 @@ "semver": ">=7.5.2", "word-wrap": ">=1.2.4", "braces": ">=3.0.3" - }, - "patchedDependencies": { - "zod@3.22.3": "patches/zod@3.22.3.patch" } }, "exports": { diff --git a/patches/zod@3.22.3.patch b/patches/zod@3.22.3.patch deleted file mode 100644 index e385d71..0000000 --- a/patches/zod@3.22.3.patch +++ /dev/null @@ -1,32 +0,0 @@ -diff --git a/lib/types.js b/lib/types.js -index be6b81d2d1a6d317f535cfd76ba9e77ab1c3f2ad..6f05b4464d4ee079f61ce82b3e6a3b395af05cec 100644 ---- a/lib/types.js -+++ b/lib/types.js -@@ -95,6 +95,27 @@ class ZodType { - this.isNullable = this.isNullable.bind(this); - this.isOptional = this.isOptional.bind(this); - } -+ // The instanceof operator does not work properly when ts-mongo is imported from another library -+ // https://stackoverflow.com/questions/59265098/instanceof-not-work-correctly-in-typescript-library-project -+ // This alternative implementation checks the constructor names of the object and its inherited classes -+ static [Symbol.hasInstance](instance) { -+ if ( -+ typeof instance !== 'object' || -+ instance === null || -+ !('_def' in instance) -+ ) -+ return false -+ -+ // Also check inherited prototypes -+ const getPrototypeChain = (prototype) => { -+ if (!prototype) return [] -+ return [prototype, ...getPrototypeChain(prototype.__proto__)] -+ } -+ -+ const prototypes = getPrototypeChain(instance) -+ const className = this.name -+ return prototypes.some((proto) => proto.constructor.name === className) -+ } - get description() { - return this._def.description; - } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 40371cb..44b1cc1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,11 +13,6 @@ overrides: word-wrap: '>=1.2.4' braces: '>=3.0.3' -patchedDependencies: - zod@3.22.3: - hash: av6zrty743wz35jpsfng5vefxy - path: patches/zod@3.22.3.patch - importers: .: @@ -83,8 +78,8 @@ importers: specifier: ^4.9.5 version: 4.9.5 zod: - specifier: 3.22.3 - version: 3.22.3(patch_hash=av6zrty743wz35jpsfng5vefxy) + specifier: github:cau777/zod#7a619722ad5105fda5968a84200198a6c8850ad4 + version: https://codeload.github.com/cau777/zod/tar.gz/7a619722ad5105fda5968a84200198a6c8850ad4 packages: @@ -3050,8 +3045,9 @@ packages: resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==} engines: {node: '>=12.20'} - zod@3.22.3: - resolution: {integrity: sha512-EjIevzuJRiRPbVH4mGc8nApb/lVLKVpmUhAaR5R5doKGfAnGJ6Gr3CViAVjP+4FWSxCsybeWQdcgCtbX+7oZug==} + zod@https://codeload.github.com/cau777/zod/tar.gz/7a619722ad5105fda5968a84200198a6c8850ad4: + resolution: {tarball: https://codeload.github.com/cau777/zod/tar.gz/7a619722ad5105fda5968a84200198a6c8850ad4} + version: 3.23.8 snapshots: @@ -6411,4 +6407,4 @@ snapshots: yocto-queue@1.0.0: {} - zod@3.22.3(patch_hash=av6zrty743wz35jpsfng5vefxy): {} + zod@https://codeload.github.com/cau777/zod/tar.gz/7a619722ad5105fda5968a84200198a6c8850ad4: {}