@express-zod-api/zod-plugin 2.1.0-beta.1 → 3.0.0-beta.2

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 CHANGED
@@ -1,10 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 3
4
+
5
+ ### v3.0.0
6
+
7
+ - Supported `zod` versions: `^4.1.13`;
8
+ - The plugin now also patches the CJS exports of `zod`.
9
+
3
10
  ## Version 2
4
11
 
5
12
  ### v2.1.0
6
13
 
7
- - Add CJS build in order to patch both bundles that Zod exports.
14
+ - `ZodObject::remap()` now throws an `Error` if duplicate target keys found in its argument.
8
15
 
9
16
  ### v2.0.0
10
17
 
package/README.md CHANGED
@@ -18,7 +18,7 @@ This module extends Zod functionality when it's imported:
18
18
 
19
19
  ## Requirements
20
20
 
21
- - Zod `^4.0.0`
21
+ - Zod `^4.1.13`
22
22
 
23
23
  ## Basic usage
24
24
 
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{globalRegistry as e,z as t}from"zod";import*as n from"ramda";var r=`@express-zod-api/zod-plugin`;const i=(e,n)=>{let r=t.core.$constructor(`$Packer`,(e,n)=>{t.core.$ZodCheck.init(e,n),e._zod.onattach.push(e=>{Object.assign(e._zod.bag,n.bag)}),e._zod.check=()=>{}});return e.check(new r({check:`$Packer`,bag:n}))},a=e=>e._zod.bag,o=`brand`,s=function(e){return i(this,{[o]:e})},c=e=>{let{[o]:t}=a(e)||{};if(typeof t==`symbol`||typeof t==`string`||typeof t==`number`)return t},l=function(e){let r=typeof e==`function`?e:n.renameKeys(n.reject(n.isNil,e)),i=r(n.map(n.invoker(0,`clone`),this._zod.def.shape)),a=(this._zod.def.catchall instanceof t.ZodUnknown?t.looseObject:t.object)(i);return this.transform(r).pipe(a)},u=function(t){let n=e.get(this)?.examples?.slice()||[];return n.push(t),this.meta({examples:n})},d=function(){return this.meta({deprecated:!0})},f=function(e){return this.meta({default:e})},p=Symbol.for(r);if(!(p in globalThis)){globalThis[p]=!0;for(let e of Object.keys(t)){if(!e.startsWith(`Zod`)||/(Success|Error|Function)$/.test(e))continue;let n=t[e];typeof n==`function`&&Object.defineProperties(n.prototype,{example:{value:u,writable:!1},deprecated:{value:d,writable:!1},brand:{set(){},get(){return s.bind(this)}}})}Object.defineProperty(t.ZodDefault.prototype,`label`,{value:f,writable:!1}),Object.defineProperty(t.ZodObject.prototype,`remap`,{value:l,writable:!1})}export{c as getBrand,i as pack,a as unpack};
1
+ import{createRequire as e}from"node:module";import{globalRegistry as t,z as n}from"zod";import*as r from"ramda";const i=(e,t)=>{let r=n.core.$constructor(`$Packer`,(e,t)=>{n.core.$ZodCheck.init(e,t),e._zod.onattach.push(e=>{Object.assign(e._zod.bag,t.bag)}),e._zod.check=()=>{}});return e.check(new r({check:`$Packer`,bag:t}))},a=e=>e._zod.bag,o=`brand`,s=function(e){return i(this,{[o]:e})},c=e=>{let{[o]:t}=a(e)||{};if(typeof t==`symbol`||typeof t==`string`||typeof t==`number`)return t},l=e=>{let t=r.reject(r.isNil,e),n=Object.values(t);if(new Set(n).size!==n.length)throw Error(`remap(): duplicate target keys`,{cause:e});return r.renameKeys(t)},u=function(e){let t=typeof e==`function`?e:l(e),i=t(r.map(r.invoker(0,`clone`),this._zod.def.shape)),a=(this._zod.def.catchall instanceof n.ZodUnknown?n.looseObject:n.object)(i);return this.transform(t).pipe(a)},d=function(e){let n=t.get(this)?.examples?.slice()||[];return n.push(e),this.meta({examples:n})},f=function(){return this.meta({deprecated:!0})},p=function(e){return this.meta({default:e})},m=()=>{let t=[n],{z:r}=e(import.meta.url)(`zod`);return n!==r&&t.push(r),t},h=e=>Object.keys(e).filter(e=>e.startsWith(`Zod`)&&!/(Success|Error|Function)$/.test(e)).map(t=>e[t]).filter(e=>typeof e==`function`),g=Symbol.for(`@express-zod-api/zod-plugin`);if(!(g in globalThis)){globalThis[g]=!0;for(let e of m()){for(let t of h(e))Object.defineProperties(t.prototype,{example:{value:d,writable:!1},deprecated:{value:f,writable:!1},brand:{set(){},get(){return s.bind(this)}}});Object.defineProperty(e.ZodDefault.prototype,`label`,{value:p,writable:!1}),Object.defineProperty(e.ZodObject.prototype,`remap`,{value:u,writable:!1})}}export{c as getBrand,i as pack,a as unpack};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@express-zod-api/zod-plugin",
3
- "version": "2.1.0-beta.1",
3
+ "version": "3.0.0-beta.2",
4
4
  "license": "MIT",
5
5
  "description": "Zod plugin for express-zod-api",
6
6
  "sideEffects": true,
@@ -16,19 +16,13 @@
16
16
  "bugs": "https://github.com/RobinTail/express-zod-api/issues",
17
17
  "funding": "https://github.com/sponsors/RobinTail",
18
18
  "type": "module",
19
- "main": "dist/index.cjs",
19
+ "main": "dist/index.js",
20
20
  "types": "dist/index.d.ts",
21
21
  "module": "dist/index.js",
22
22
  "exports": {
23
23
  ".": {
24
- "import": {
25
- "types": "./dist/index.d.ts",
26
- "default": "./dist/index.js"
27
- },
28
- "require": {
29
- "types": "./dist/index.d.cts",
30
- "default": "./dist/index.cjs"
31
- }
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.js"
32
26
  }
33
27
  },
34
28
  "files": [
@@ -39,16 +33,16 @@
39
33
  "node": "^20.19.0 || ^22.12.0 || ^24.0.0"
40
34
  },
41
35
  "dependencies": {
42
- "ramda": "^0.31.3"
36
+ "ramda": "^0.32.0"
43
37
  },
44
38
  "peerDependencies": {
45
- "zod": "^4.0.0"
39
+ "zod": "^4.1.13"
46
40
  },
47
41
  "devDependencies": {
48
42
  "@types/ramda": "^0.31.0",
49
43
  "camelize-ts": "^3.0.0",
50
44
  "typescript": "^5.9.2",
51
- "zod": "^4.0.0"
45
+ "zod": "^4.1.13"
52
46
  },
53
47
  "keywords": [
54
48
  "zod",
@@ -58,7 +52,7 @@
58
52
  "typescript"
59
53
  ],
60
54
  "scripts": {
61
- "pretest": "tsc --noEmit",
55
+ "pretest": "tsc",
62
56
  "test": "vitest run",
63
57
  "build": "tsdown"
64
58
  }
package/dist/index.cjs DELETED
@@ -1 +0,0 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`zod`);c=s(c);let l=require(`ramda`);l=s(l);var u=`@express-zod-api/zod-plugin`;const d=(e,t)=>{let n=c.z.core.$constructor(`$Packer`,(e,t)=>{c.z.core.$ZodCheck.init(e,t),e._zod.onattach.push(e=>{Object.assign(e._zod.bag,t.bag)}),e._zod.check=()=>{}});return e.check(new n({check:`$Packer`,bag:t}))},f=e=>e._zod.bag,p=`brand`,m=function(e){return d(this,{[p]:e})},h=e=>{let{[p]:t}=f(e)||{};if(typeof t==`symbol`||typeof t==`string`||typeof t==`number`)return t},g=function(e){let t=typeof e==`function`?e:l.renameKeys(l.reject(l.isNil,e)),n=t(l.map(l.invoker(0,`clone`),this._zod.def.shape)),r=(this._zod.def.catchall instanceof c.z.ZodUnknown?c.z.looseObject:c.z.object)(n);return this.transform(t).pipe(r)},_=function(e){let t=c.globalRegistry.get(this)?.examples?.slice()||[];return t.push(e),this.meta({examples:t})},v=function(){return this.meta({deprecated:!0})},y=function(e){return this.meta({default:e})},b=Symbol.for(u);if(!(b in globalThis)){globalThis[b]=!0;for(let e of Object.keys(c.z)){if(!e.startsWith(`Zod`)||/(Success|Error|Function)$/.test(e))continue;let t=c.z[e];typeof t==`function`&&Object.defineProperties(t.prototype,{example:{value:_,writable:!1},deprecated:{value:v,writable:!1},brand:{set(){},get(){return m.bind(this)}}})}Object.defineProperty(c.z.ZodDefault.prototype,`label`,{value:y,writable:!1}),Object.defineProperty(c.z.ZodObject.prototype,`remap`,{value:g,writable:!1})}exports.getBrand=h,exports.pack=d,exports.unpack=f;
package/dist/index.d.cts DELETED
@@ -1,28 +0,0 @@
1
- import './augmentation.js';
2
- import { z } from "zod";
3
-
4
- //#region src/packer.d.ts
5
-
6
- /**
7
- * @public
8
- * @desc Attaches an inheritable attributes to the schema (withstands refinements).
9
- */
10
- declare const pack: <T extends z.ZodType, B extends object>(subject: T, bag: B) => T & {
11
- _zod: {
12
- bag: T["_zod"]["bag"] & B;
13
- };
14
- };
15
- /**
16
- * @public
17
- * @desc Retrieves the attributes attached to the schema by pack() method.
18
- */
19
- declare const unpack: <T extends z.core.$ZodType>(subject: T) => T["_zod"]["bag"];
20
- //#endregion
21
- //#region src/brand.d.ts
22
- /**
23
- * @public
24
- * @desc Retrieves the brand from the schema set by its .brand() method.
25
- * */
26
- declare const getBrand: (subject: z.core.$ZodType) => string | number | symbol | undefined;
27
- //#endregion
28
- export { getBrand, pack, unpack };