@express-zod-api/zod-plugin 1.2.0 → 2.0.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 +6 -0
- package/dist/augmentation.d.ts +3 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
package/dist/augmentation.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
//#region remap.d.ts
|
|
3
|
+
//#region src/remap.d.ts
|
|
4
4
|
type TuplesFromObject<T> = { [P in keyof T]: [P, T[P]] }[keyof T];
|
|
5
5
|
type GetKeyByValue<T, V> = TuplesFromObject<T> extends infer TT ? TT extends [infer P, V] ? P : never : never;
|
|
6
6
|
/**
|
|
@@ -11,7 +11,7 @@ type GetKeyByValue<T, V> = TuplesFromObject<T> extends infer TT ? TT extends [in
|
|
|
11
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
12
|
type Intact<T, U> = { [K in Exclude<keyof T, keyof U>]: T[K] };
|
|
13
13
|
//#endregion
|
|
14
|
-
//#region augmentation.d.ts
|
|
14
|
+
//#region src/augmentation.d.ts
|
|
15
15
|
declare module "zod/v4/core" {
|
|
16
16
|
interface GlobalMeta {
|
|
17
17
|
default?: unknown;
|
|
@@ -43,6 +43,4 @@ declare module "zod" {
|
|
|
43
43
|
z.ZodObject<Remap<Shape, U, V> & Intact<Shape, U>, Config>>;
|
|
44
44
|
remap<U extends z.core.$ZodShape>(mapper: (subject: Shape) => U): z.ZodPipe<z.ZodPipe<this, z.ZodTransform>, z.ZodObject<U>>;
|
|
45
45
|
}
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
export {};
|
|
46
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './augmentation.js';
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
|
-
//#region packer.d.ts
|
|
4
|
+
//#region src/packer.d.ts
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @public
|
|
@@ -18,7 +18,7 @@ declare const pack: <T extends z.ZodType, B extends object>(subject: T, bag: B)
|
|
|
18
18
|
*/
|
|
19
19
|
declare const unpack: <T extends z.core.$ZodType>(subject: T) => T["_zod"]["bag"];
|
|
20
20
|
//#endregion
|
|
21
|
-
//#region brand.d.ts
|
|
21
|
+
//#region src/brand.d.ts
|
|
22
22
|
/**
|
|
23
23
|
* @public
|
|
24
24
|
* @desc Retrieves the brand from the schema set by its .brand() method.
|
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
|
|
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];if(typeof n!=`function`)continue;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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@express-zod-api/zod-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Zod plugin for express-zod-api",
|
|
6
6
|
"sideEffects": true,
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
"dist",
|
|
30
30
|
"*.md"
|
|
31
31
|
],
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": "^20.19.0 || ^22.12.0 || ^24.0.0"
|
|
34
|
+
},
|
|
32
35
|
"dependencies": {
|
|
33
36
|
"ramda": "^0.31.3"
|
|
34
37
|
},
|