@express-zod-api/zod-plugin 2.0.0 → 2.1.0-beta.1
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 +4 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +28 -0
- package/dist/index.js +1 -1
- package/package.json +11 -5
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
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 };
|
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];
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@express-zod-api/zod-plugin",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.1.0-beta.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Zod plugin for express-zod-api",
|
|
6
6
|
"sideEffects": true,
|
|
@@ -16,13 +16,19 @@
|
|
|
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.
|
|
19
|
+
"main": "dist/index.cjs",
|
|
20
20
|
"types": "dist/index.d.ts",
|
|
21
21
|
"module": "dist/index.js",
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
|
-
"
|
|
25
|
-
|
|
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
|
+
}
|
|
26
32
|
}
|
|
27
33
|
},
|
|
28
34
|
"files": [
|
|
@@ -41,7 +47,7 @@
|
|
|
41
47
|
"devDependencies": {
|
|
42
48
|
"@types/ramda": "^0.31.0",
|
|
43
49
|
"camelize-ts": "^3.0.0",
|
|
44
|
-
"typescript": "^5.
|
|
50
|
+
"typescript": "^5.9.2",
|
|
45
51
|
"zod": "^4.0.0"
|
|
46
52
|
},
|
|
47
53
|
"keywords": [
|