@express-zod-api/zod-plugin 2.1.0 → 3.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 +7 -0
- package/README.md +1 -1
- package/dist/augmentation.d.ts +4 -4
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/dist/augmentation.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
3
|
//#region src/remap.d.ts
|
|
4
|
-
type TuplesFromObject<T
|
|
5
|
-
type GetKeyByValue<T
|
|
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;
|
|
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
|
|
12
|
-
type Intact<T
|
|
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] };
|
|
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
|
|
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": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Zod plugin for express-zod-api",
|
|
6
6
|
"sideEffects": true,
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"ramda": "^0.32.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"zod": "^4.
|
|
39
|
+
"zod": "^4.1.13"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/ramda": "^0.31.0",
|
|
43
43
|
"camelize-ts": "^3.0.0",
|
|
44
44
|
"typescript": "^5.9.2",
|
|
45
|
-
"zod": "^4.
|
|
45
|
+
"zod": "^4.1.13"
|
|
46
46
|
},
|
|
47
47
|
"keywords": [
|
|
48
48
|
"zod",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"typescript"
|
|
53
53
|
],
|
|
54
54
|
"scripts": {
|
|
55
|
-
"pretest": "tsc
|
|
55
|
+
"pretest": "tsc",
|
|
56
56
|
"test": "vitest run",
|
|
57
57
|
"build": "tsdown"
|
|
58
58
|
}
|