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

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
@@ -4,7 +4,7 @@
4
4
 
5
5
  ### v2.1.0
6
6
 
7
- - Add CJS build in order to patch both bundles that Zod exports.
7
+ - `ZodObject::remap()` now throws an `Error` if duplicate target keys found in its argument.
8
8
 
9
9
  ### v2.0.0
10
10
 
@@ -1,15 +1,15 @@
1
1
  import { z } from "zod";
2
2
 
3
3
  //#region src/remap.d.ts
4
- type TuplesFromObject<T> = { [P in keyof T]: [P, T[P]] }[keyof T];
5
- type GetKeyByValue<T, V> = TuplesFromObject<T> extends infer TT ? TT extends [infer P, V] ? P : never : never;
4
+ type TuplesFromObject<T$1> = { [P in keyof T$1]: [P, T$1[P]] }[keyof T$1];
5
+ type GetKeyByValue<T$1, V$1> = TuplesFromObject<T$1> extends infer TT ? TT extends [infer P, V$1] ? P : never : never;
6
6
  /**
7
7
  * @fileoverview Mapping utils for Zod Runtime Plugin (remap)
8
8
  * @link https://stackoverflow.com/questions/55454125/typescript-remapping-object-properties-in-typesafe
9
9
  * @todo try to reuse R.Remap from Ramda (requires to move its types to prod dependencies)
10
10
  */
11
- type Remap<T, U extends { [P in keyof T]?: V }, V extends string> = { [P in NonNullable<U[keyof U]>]: T[GetKeyByValue<U, P>] };
12
- type Intact<T, U> = { [K in Exclude<keyof T, keyof U>]: T[K] };
11
+ type Remap<T$1, U$1 extends { [P in keyof T$1]?: V$1 }, V$1 extends string> = { [P in NonNullable<U$1[keyof U$1]>]: T$1[GetKeyByValue<U$1, P>] };
12
+ type Intact<T$1, U$1> = { [K in Exclude<keyof T$1, keyof U$1>]: T$1[K] };
13
13
  //#endregion
14
14
  //#region src/augmentation.d.ts
15
15
  declare module "zod/v4/core" {
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{globalRegistry as e,z as t}from"zod";import*as n from"ramda";const r=(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}))},i=e=>e._zod.bag,a=`brand`,o=function(e){return r(this,{[a]:e})},s=e=>{let{[a]:t}=i(e)||{};if(typeof t==`symbol`||typeof t==`string`||typeof t==`number`)return t},c=e=>{let t=n.reject(n.isNil,e),r=Object.values(t);if(new Set(r).size!==r.length)throw Error(`remap(): duplicate target keys`,{cause:e});return n.renameKeys(t)},l=function(e){let r=typeof e==`function`?e:c(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(`@express-zod-api/zod-plugin`);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 o.bind(this)}}})}Object.defineProperty(t.ZodDefault.prototype,`label`,{value:f,writable:!1}),Object.defineProperty(t.ZodObject.prototype,`remap`,{value:l,writable:!1})}export{s as getBrand,r as pack,i 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": "2.1.0",
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,7 +33,7 @@
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
39
  "zod": "^4.0.0"
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 };