@idb-orm/zod-adapter 0.0.1 → 0.0.3
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/README.md +5 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.ts +8 -22
- package/dist/index.es.js +1 -0
- package/package.json +19 -8
- package/dist/index.js +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -3,3 +3,8 @@
|
|
|
3
3
|
An adapter for `@idb-orm` that adds support for using [Zod](https://zod.dev/) schemas.
|
|
4
4
|
|
|
5
5
|
This is still a work in progress, please check back soon for more updates.
|
|
6
|
+
|
|
7
|
+
## Roadmap:
|
|
8
|
+
- [x] Add subclasses for `String`, `Number` class to use zod specialization schemas (like z.number().positive())
|
|
9
|
+
- [ ] Make an object static helper. Make it a subclass for helpers as before
|
|
10
|
+
- [ ] Enum static method
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@idb-orm/core"),r=require("zod");function n(e){return n=>{const t=e.safeParse(n);return{success:t.success,data:t.data,error:t?.error?r.prettifyError(t.error):void 0}}}e.core.PrimaryKey;const t=e.core.Type;function o(r){switch(r.type){case"array":return t.Array(o(r.element));case"bigint":return t.BigInt;case"number":return t.Number;case"string":return t.String;case"boolean":return t.Boolean;case"date":return t.Date;case"file":return t.File;case"symbol":return t.Symbol;case"literal":return e.core.AbstractProperty.nameToType(typeof Array.from(r.values)[0]);case"optional":return t.Optional(o(r.unwrap()));case"set":return t.Set(o(r._zod.def.valueType));case"enum":return t.Union(r.options.map(e=>t.Literal(e)));case"union":return t.Union(r.options.map(e=>o(e)));case"object":{const e={};for(const n in r.shape)Object.hasOwn(r.shape,n)&&(e[n]=o(r.shape[n]));return t.Object(e)}default:return t.Unknown}}function a(t){const s=t;return new e.core.Property(n(s),o(t)),t instanceof r.ZodDefault?a(s.unwrap()):new e.core.Property(n(s),o(t))}exports.zodModel=function(n,t){const o={};for(const e in t){if(!Object.hasOwn(t,e))continue;const n=t[e];n instanceof r.ZodType?o[e]=a(n):o[e]=n}return new e.Model(n,o)};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { z } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
static readonly zodValidators: {
|
|
10
|
-
string: z.ZodString;
|
|
11
|
-
number: z.ZodNumber;
|
|
12
|
-
boolean: z.ZodBoolean;
|
|
13
|
-
};
|
|
14
|
-
static literal<const T extends util.Literable>(value: T, options?: PropertyInputOptions): Property<T, false>;
|
|
15
|
-
static string(options?: PropertyInputOptions): Property<string, false>;
|
|
16
|
-
static number(options?: PropertyInputOptions): Property<number, false>;
|
|
17
|
-
static boolean(options?: PropertyInputOptions): Property<boolean, false>;
|
|
18
|
-
static union<const T extends readonly z.core.SomeType[]>(items: T, options?: PropertyInputOptions): Property<z.output<z.ZodUnion<T>>, false>;
|
|
19
|
-
static custom<T>(schema: z.ZodType<T>, options?: PropertyInputOptions): Property<T, false>;
|
|
20
|
-
static array<T>(schema: z.ZodType<T>, options?: PropertyInputOptions): Property<T[], false>;
|
|
21
|
-
private regenerateValidator;
|
|
22
|
-
}
|
|
1
|
+
import { core, Model } from '@idb-orm/core';
|
|
2
|
+
import { default as z } from 'zod';
|
|
3
|
+
type ZodHasDefault<S extends z.ZodType> = S extends z.ZodDefault<any> ? true : false;
|
|
4
|
+
export type ZodTranslation<R extends Record<string, z.ZodType | core.ValidValue>> = {
|
|
5
|
+
[K in keyof R]: R[K] extends z.ZodType ? core.Property<z.output<R[K]>, ZodHasDefault<R[K]>> : R[K] extends core.ValidValue ? R[K] : never;
|
|
6
|
+
};
|
|
7
|
+
export declare function zodModel<Name extends string, ZodFields extends Record<string, core.ValidValue | z.ZodType>>(name: Name, fields: ZodFields): Model<Name, core.Simplify<ZodTranslation<ZodFields>>, core.FindPrimaryKey<core.Simplify<ZodTranslation<ZodFields>>>>;
|
|
8
|
+
export {};
|
package/dist/index.es.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{core as e,Model as r}from"@idb-orm/core";import n from"zod";function t(e){return r=>{const t=e.safeParse(r);return{success:t.success,data:t.data,error:t?.error?n.prettifyError(t.error):void 0}}}e.PrimaryKey;const o=e.Type;function a(r){switch(r.type){case"array":return o.Array(a(r.element));case"bigint":return o.BigInt;case"number":return o.Number;case"string":return o.String;case"boolean":return o.Boolean;case"date":return o.Date;case"file":return o.File;case"symbol":return o.Symbol;case"literal":return e.AbstractProperty.nameToType(typeof Array.from(r.values)[0]);case"optional":return o.Optional(a(r.unwrap()));case"set":return o.Set(a(r._zod.def.valueType));case"enum":return o.Union(r.options.map(e=>o.Literal(e)));case"union":return o.Union(r.options.map(e=>a(e)));case"object":{const e={};for(const n in r.shape)Object.hasOwn(r.shape,n)&&(e[n]=a(r.shape[n]));return o.Object(e)}default:return o.Unknown}}function s(r){const o=r;return new e.Property(t(o),a(r)),r instanceof n.ZodDefault?s(o.unwrap()):new e.Property(t(o),a(r))}function c(e,t){const o={};for(const r in t){if(!Object.hasOwn(t,r))continue;const e=t[r];e instanceof n.ZodType?o[r]=s(e):o[r]=e}return new r(e,o)}export{c as zodModel};
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idb-orm/zod-adapter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "An adapter for the Zod validation library for @idb-orm",
|
|
5
|
-
"main": "index.js",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "
|
|
7
|
+
"build": "vite build",
|
|
8
|
+
"build-test": "vite --config vite.config-test.ts build"
|
|
8
9
|
},
|
|
9
10
|
"keywords": [
|
|
10
11
|
"typescript",
|
|
@@ -13,10 +14,22 @@
|
|
|
13
14
|
"validation",
|
|
14
15
|
"idb-orm"
|
|
15
16
|
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.es.js",
|
|
21
|
+
"require": "./dist/index.cjs.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
16
24
|
"author": "jtb",
|
|
17
25
|
"license": "ISC",
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@idb-orm/core": "^1.0.7",
|
|
28
|
+
"zod": "^4.1.12"
|
|
29
|
+
},
|
|
18
30
|
"devDependencies": {
|
|
19
31
|
"@eslint/js": "^9.38.0",
|
|
32
|
+
"@rollup/plugin-alias": "^6.0.0",
|
|
20
33
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
21
34
|
"@rollup/plugin-terser": "^0.4.4",
|
|
22
35
|
"@rollup/plugin-typescript": "^12.1.4",
|
|
@@ -26,10 +39,8 @@
|
|
|
26
39
|
"serve": "^14.2.5",
|
|
27
40
|
"tslib": "^2.8.1",
|
|
28
41
|
"typescript": "^5.9.3",
|
|
29
|
-
"typescript-eslint": "^8.46.2"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"@idb-orm/core": "^1.0.5",
|
|
33
|
-
"zod": "^4.1.12"
|
|
42
|
+
"typescript-eslint": "^8.46.2",
|
|
43
|
+
"vite": "^7.2.4",
|
|
44
|
+
"vite-plugin-dts": "^4.5.4"
|
|
34
45
|
}
|
|
35
46
|
}
|
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{AbstractProperty as e}from"@idb-orm/core/dev";function t(e,t,n){function i(n,i){var r;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(r=n._zod).traits??(r.traits=new Set),n._zod.traits.add(e),t(n,i);for(const e in s.prototype)e in n||Object.defineProperty(n,e,{value:s.prototype[e].bind(n)});n._zod.constr=s,n._zod.def=i}const r=n?.Parent??Object;class o extends r{}function s(e){var t;const r=n?.Parent?new o:this;i(r,e),(t=r._zod).deferred??(t.deferred=[]);for(const e of r._zod.deferred)e();return r}return Object.defineProperty(o,"name",{value:e}),Object.defineProperty(s,"init",{value:i}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class n extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class i extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const r={};function o(e){return r}function s(e,t){return"bigint"==typeof t?t.toString():t}function a(e){return null==e}function u(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const c=Symbol("evaluating");function d(e,t,n){let i;Object.defineProperty(e,t,{get(){if(i!==c)return void 0===i&&(i=c,i=n()),i},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}const p="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function l(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function f(e){if(!1===l(e))return!1;const t=e.constructor;if(void 0===t)return!0;const n=t.prototype;return!1!==l(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function h(e){return f(e)?{...e}:Array.isArray(e)?[...e]:e}function m(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function v(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const _={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function g(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function y(e){return"string"==typeof e?e:e?.message}function z(e,t,n){const i={...e,path:e.path??[]};if(!e.message){const r=y(e.inst?._zod.def?.error?.(e))??y(t?.error?.(e))??y(n.customError?.(e))??y(n.localeError?.(e))??"Invalid input";i.message=r}return delete i.inst,delete i.continue,t?.reportInput||delete i.input,i}function b(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function w(...e){const[t,n,i]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:i}:{...t}}const k=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,s,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},$=t("$ZodError",k),Z=t("$ZodError",k,{Parent:Error});function I(e){const t=[],n=e.map(e=>"object"==typeof e?e.key:e);for(const e of n)"number"==typeof e?t.push(`[${e}]`):"symbol"==typeof e?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push("."),t.push(e));return t.join("")}function A(e){const t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(const e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${I(e.path)}`);return t.join("\n")}const E=e=>(t,i,r,s)=>{const a=r?Object.assign(r,{async:!1}):{async:!1},u=t._zod.run({value:i,issues:[]},a);if(u instanceof Promise)throw new n;if(u.issues.length){const t=new(s?.Err??e)(u.issues.map(e=>z(e,a,o())));throw p(t,s?.callee),t}return u.value},x=e=>async(t,n,i,r)=>{const s=i?Object.assign(i,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(r?.Err??e)(a.issues.map(e=>z(e,s,o())));throw p(t,r?.callee),t}return a.value},T=e=>(t,i,r)=>{const s=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:i,issues:[]},s);if(a instanceof Promise)throw new n;return a.issues.length?{success:!1,error:new(e??$)(a.issues.map(e=>z(e,s,o())))}:{success:!0,data:a.value}},P=T(Z),N=e=>async(t,n,i)=>{const r=i?Object.assign(i,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(e=>z(e,r,o())))}:{success:!0,data:s.value}},O=N(Z),S=e=>(t,n,i)=>{const r=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return E(e)(t,n,r)},F=e=>(t,n,i)=>E(e)(t,n,i),j=e=>async(t,n,i)=>{const r=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return x(e)(t,n,r)},C=e=>async(t,n,i)=>x(e)(t,n,i),D=e=>(t,n,i)=>{const r=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return T(e)(t,n,r)},V=e=>(t,n,i)=>T(e)(t,n,i),U=e=>async(t,n,i)=>{const r=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return N(e)(t,n,r)},R=e=>async(t,n,i)=>N(e)(t,n,i),M=/^[cC][^\s-]{8,}$/,L=/^[0-9a-z]+$/,W=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,G=/^[0-9a-vA-V]{20}$/,J=/^[A-Za-z0-9]{27}$/,B=/^[a-zA-Z0-9_-]{21}$/,Y=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,X=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,K=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,q=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const H=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Q=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ee=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,te=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ne=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ie=/^[A-Za-z0-9_-]*$/,re=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,oe=/^\+(?:[0-9]){6,14}[0-9]$/,se="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",ae=new RegExp(`^${se}$`);function ue(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const ce=/^-?\d+$/,de=/^-?\d+(?:\.\d+)?/,pe=/^(?:true|false)$/i,le=/^[^A-Z]*$/,fe=/^[^a-z]*$/,he=t("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),me={number:"number",bigint:"bigint",object:"date"},ve=t("$ZodCheckLessThan",(e,t)=>{he.init(e,t);const n=me[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,i=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:n,code:"too_big",maximum:t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),_e=t("$ZodCheckGreaterThan",(e,t)=>{he.init(e,t);const n=me[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,i=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:n,code:"too_small",minimum:t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ge=t("$ZodCheckMultipleOf",(e,t)=>{he.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?n.value%t.value===BigInt(0):0===function(e,t){const n=(e.toString().split(".")[1]||"").length,i=t.toString();let r=(i.split(".")[1]||"").length;if(0===r&&/\d?e-\d?/.test(i)){const e=i.match(/\d?e-(\d?)/);e?.[1]&&(r=Number.parseInt(e[1]))}const o=n>r?n:r;return Number.parseInt(e.toFixed(o).replace(".",""))%Number.parseInt(t.toFixed(o).replace(".",""))/10**o}(n.value,t.value))||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),ye=t("$ZodCheckNumberFormat",(e,t)=>{he.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),i=n?"int":"number",[r,o]=_[t.format];e._zod.onattach.push(e=>{const i=e._zod.bag;i.format=t.format,i.minimum=r,i.maximum=o,n&&(i.pattern=ce)}),e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a))return void s.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,continue:!t.abort}))}a<r&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inst:e})}}),ze=t("$ZodCheckMaxLength",(e,t)=>{var n;he.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!a(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const i=n.value;if(i.length<=t.maximum)return;const r=b(i);n.issues.push({origin:r,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),be=t("$ZodCheckMinLength",(e,t)=>{var n;he.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!a(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const i=n.value;if(i.length>=t.minimum)return;const r=b(i);n.issues.push({origin:r,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),we=t("$ZodCheckLengthEquals",(e,t)=>{var n;he.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!a(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{const i=n.value,r=i.length;if(r===t.length)return;const o=b(i),s=r>t.length;n.issues.push({origin:o,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),ke=t("$ZodCheckStringFormat",(e,t)=>{var n,i;he.init(e,t),e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),$e=t("$ZodCheckRegex",(e,t)=>{ke.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ze=t("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=le),ke.init(e,t)}),Ie=t("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=fe),ke.init(e,t)}),Ae=t("$ZodCheckIncludes",(e,t)=>{he.init(e,t);const n=m(t.includes),i=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=i,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(i)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Ee=t("$ZodCheckStartsWith",(e,t)=>{he.init(e,t);const n=new RegExp(`^${m(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),xe=t("$ZodCheckEndsWith",(e,t)=>{he.init(e,t);const n=new RegExp(`.*${m(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Te=t("$ZodCheckOverwrite",(e,t)=>{he.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Pe={major:4,minor:1,patch:12},Ne=t("$ZodType",(e,t)=>{var i;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Pe;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const t of r)for(const n of t._zod.onattach)n(e);if(0===r.length)(i=e._zod).deferred??(i.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,i)=>{let r,o=g(e);for(const s of t){if(s._zod.def.when){if(!s._zod.def.when(e))continue}else if(o)continue;const t=e.issues.length,a=s._zod.check(e);if(a instanceof Promise&&!1===i?.async)throw new n;if(r||a instanceof Promise)r=(r??Promise.resolve()).then(async()=>{await a;e.issues.length!==t&&(o||(o=g(e,t)))});else{if(e.issues.length===t)continue;o||(o=g(e,t))}}return r?r.then(()=>e):e},i=(i,o,s)=>{if(g(i))return i.aborted=!0,i;const a=t(o,r,s);if(a instanceof Promise){if(!1===s.async)throw new n;return a.then(t=>e._zod.parse(t,s))}return e._zod.parse(a,s)};e._zod.run=(o,s)=>{if(s.skipChecks)return e._zod.parse(o,s);if("backward"===s.direction){const t=e._zod.parse({value:o.value,issues:[]},{...s,skipChecks:!0});return t instanceof Promise?t.then(e=>i(e,o,s)):i(t,o,s)}const a=e._zod.parse(o,s);if(a instanceof Promise){if(!1===s.async)throw new n;return a.then(e=>t(e,r,s))}return t(a,r,s)}}e["~standard"]={validate:t=>{try{const n=P(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return O(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}}),Oe=t("$ZodString",(e,t)=>{var n;Ne.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(i){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Se=t("$ZodStringFormat",(e,t)=>{ke.init(e,t),Oe.init(e,t)}),Fe=t("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=X),Se.init(e,t)}),je=t("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=K(e))}else t.pattern??(t.pattern=K());Se.init(e,t)}),Ce=t("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=q),Se.init(e,t)}),De=t("$ZodURL",(e,t)=>{Se.init(e,t),e._zod.check=n=>{try{const i=n.value.trim(),r=new URL(i);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:re.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=r.href:n.value=i)}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Ve=t("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Se.init(e,t)}),Ue=t("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=B),Se.init(e,t)}),Re=t("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=M),Se.init(e,t)}),Me=t("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=L),Se.init(e,t)}),Le=t("$ZodULID",(e,t)=>{t.pattern??(t.pattern=W),Se.init(e,t)}),We=t("$ZodXID",(e,t)=>{t.pattern??(t.pattern=G),Se.init(e,t)}),Ge=t("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=J),Se.init(e,t)}),Je=t("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=ue({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const i=`${t}(?:${n.join("|")})`;return new RegExp(`^${se}T(?:${i})$`)}(t)),Se.init(e,t)}),Be=t("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ae),Se.init(e,t)}),Ye=t("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${ue(t)}$`)),Se.init(e,t)}),Xe=t("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Y),Se.init(e,t)}),Ke=t("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=H),Se.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.format="ipv4"})}),qe=t("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Q),Se.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.format="ipv6"}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),He=t("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ee),Se.init(e,t)}),Qe=t("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=te),Se.init(e,t),e._zod.check=n=>{const i=n.value.split("/");try{if(2!==i.length)throw new Error;const[e,t]=i;if(!t)throw new Error;const n=Number(t);if(`${n}`!==t)throw new Error;if(n<0||n>128)throw new Error;new URL(`http://[${e}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function et(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const tt=t("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ne),Se.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding="base64"}),e._zod.check=n=>{et(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});const nt=t("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ie),Se.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding="base64url"}),e._zod.check=n=>{(function(e){if(!ie.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return et(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),it=t("$ZodE164",(e,t)=>{t.pattern??(t.pattern=oe),Se.init(e,t)});const rt=t("$ZodJWT",(e,t)=>{Se.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[i]=n;if(!i)return!1;const r=JSON.parse(atob(i));return!("typ"in r&&"JWT"!==r?.typ||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ot=t("$ZodNumber",(e,t)=>{Ne.init(e,t),e._zod.pattern=e._zod.bag.pattern??de,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(e){}const r=n.value;if("number"==typeof r&&!Number.isNaN(r)&&Number.isFinite(r))return n;const o="number"==typeof r?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...o?{received:o}:{}}),n}}),st=t("$ZodNumber",(e,t)=>{ye.init(e,t),ot.init(e,t)}),at=t("$ZodBoolean",(e,t)=>{Ne.init(e,t),e._zod.pattern=pe,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(e){}const r=n.value;return"boolean"==typeof r||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}});function ut(e,t,n){var i,r;e.issues.length&&t.issues.push(...(i=n,r=e.issues,r.map(e=>{var t;return(t=e).path??(t.path=[]),e.path.unshift(i),e}))),t.value[n]=e.value}const ct=t("$ZodArray",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const o=[];for(let e=0;e<r.length;e++){const s=r[e],a=t.element._zod.run({value:s,issues:[]},i);a instanceof Promise?o.push(a.then(t=>ut(t,n,e))):ut(a,n,e)}return o.length?Promise.all(o).then(()=>n):n}});function dt(e,t,n,i){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;const r=e.filter(e=>!g(e));return 1===r.length?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>z(e,i,o())))}),t)}const pt=t("$ZodUnion",(e,t)=>{Ne.init(e,t),d(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),d(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),d(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),d(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>u(e.source)).join("|")})$`)}});const n=1===t.options.length,i=t.options[0]._zod.run;e._zod.parse=(r,o)=>{if(n)return i(r,o);let s=!1;const a=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},o);if(t instanceof Promise)a.push(t),s=!0;else{if(0===t.issues.length)return t;a.push(t)}}return s?Promise.all(a).then(t=>dt(t,r,e,o)):dt(a,r,e,o)}}),lt=t("$ZodIntersection",(e,t)=>{Ne.init(e,t),e._zod.parse=(e,n)=>{const i=e.value,r=t.left._zod.run({value:i,issues:[]},n),o=t.right._zod.run({value:i,issues:[]},n);return r instanceof Promise||o instanceof Promise?Promise.all([r,o]).then(([t,n])=>ht(e,t,n)):ht(e,r,o)}});function ft(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(f(e)&&f(t)){const n=Object.keys(t),i=Object.keys(e).filter(e=>-1!==n.indexOf(e)),r={...e,...t};for(const n of i){const i=ft(e[n],t[n]);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r[n]=i.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let i=0;i<e.length;i++){const r=ft(e[i],t[i]);if(!r.valid)return{valid:!1,mergeErrorPath:[i,...r.mergeErrorPath]};n.push(r.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ht(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),g(e))return e;const i=ft(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const mt=t("$ZodLiteral",(e,t)=>{if(Ne.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?m(e):e?m(e.toString()):String(e)).join("|")})$`),e._zod.parse=(n,i)=>{const r=n.value;return e._zod.values.has(r)||n.issues.push({code:"invalid_value",values:t.values,input:r,inst:e}),n}}),vt=t("$ZodTransform",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{if("backward"===o.direction)throw new i(e.constructor.name);const s=t.transform(r.value,r);if(o.async){return(s instanceof Promise?s:Promise.resolve(s)).then(e=>(r.value=e,r))}if(s instanceof Promise)throw new n;return r.value=s,r}});function _t(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const gt=t("$ZodOptional",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",e._zod.optout="optional",d(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),d(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${u(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(t=>_t(t,e.value)):_t(i,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),yt=t("$ZodNullable",(e,t)=>{Ne.init(e,t),d(e._zod,"optin",()=>t.innerType._zod.optin),d(e._zod,"optout",()=>t.innerType._zod.optout),d(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${u(e.source)}|null)$`):void 0}),d(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),zt=t("$ZodDefault",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",d(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>bt(e,t)):bt(i,t)}});function bt(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const wt=t("$ZodPrefault",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",d(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),kt=t("$ZodNonOptional",(e,t)=>{Ne.init(e,t),d(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,i)=>{const r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(t=>$t(t,e)):$t(r,e)}});function $t(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Zt=t("$ZodCatch",(e,t)=>{Ne.init(e,t),d(e._zod,"optin",()=>t.innerType._zod.optin),d(e._zod,"optout",()=>t.innerType._zod.optout),d(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(i=>(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(e=>z(e,n,o()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(e=>z(e,n,o()))},input:e.value}),e.issues=[]),e)}}),It=t("$ZodPipe",(e,t)=>{Ne.init(e,t),d(e._zod,"values",()=>t.in._zod.values),d(e._zod,"optin",()=>t.in._zod.optin),d(e._zod,"optout",()=>t.out._zod.optout),d(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){const i=t.out._zod.run(e,n);return i instanceof Promise?i.then(e=>At(e,t.in,n)):At(i,t.in,n)}const i=t.in._zod.run(e,n);return i instanceof Promise?i.then(e=>At(e,t.out,n)):At(i,t.out,n)}});function At(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Et=t("$ZodReadonly",(e,t)=>{Ne.init(e,t),d(e._zod,"propValues",()=>t.innerType._zod.propValues),d(e._zod,"values",()=>t.innerType._zod.values),d(e._zod,"optin",()=>t.innerType._zod.optin),d(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(xt):xt(i)}});function xt(e){return e.value=Object.freeze(e.value),e}const Tt=t("$ZodCustom",(e,t)=>{he.init(e,t),Ne.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then(t=>Pt(t,n,i,e));Pt(r,n,i,e)}});function Pt(e,t,n,i){if(!e){const e={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(e.params=i._zod.def.params),t.issues.push(w(e))}}class Nt{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];if(this._map.set(e,n),n&&"object"==typeof n&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Ot(){return new Nt}const St=Ot();function Ft(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...v(t)})}function jt(e,t){return new ve({check:"less_than",...v(t),value:e,inclusive:!1})}function Ct(e,t){return new ve({check:"less_than",...v(t),value:e,inclusive:!0})}function Dt(e,t){return new _e({check:"greater_than",...v(t),value:e,inclusive:!1})}function Vt(e,t){return new _e({check:"greater_than",...v(t),value:e,inclusive:!0})}function Ut(e,t){return new ge({check:"multiple_of",...v(t),value:e})}function Rt(e,t){return new ze({check:"max_length",...v(t),maximum:e})}function Mt(e,t){return new be({check:"min_length",...v(t),minimum:e})}function Lt(e,t){return new we({check:"length_equals",...v(t),length:e})}function Wt(e){return new Te({check:"overwrite",tx:e})}function Gt(e){const t=function(e,t){const n=new he({check:"custom",...v(t)});return n._zod.check=e,n}(n=>(n.addIssue=e=>{if("string"==typeof e)n.issues.push(w(e,n.value,t._zod.def));else{const i=e;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),n.issues.push(w(i))}},e(n.value,n)));return t}const Jt=t("ZodISODateTime",(e,t)=>{Je.init(e,t),gn.init(e,t)});function Bt(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...v(t)})}(Jt,e)}const Yt=t("ZodISODate",(e,t)=>{Be.init(e,t),gn.init(e,t)});function Xt(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...v(t)})}(Yt,e)}const Kt=t("ZodISOTime",(e,t)=>{Ye.init(e,t),gn.init(e,t)});function qt(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...v(t)})}(Kt,e)}const Ht=t("ZodISODuration",(e,t)=>{Xe.init(e,t),gn.init(e,t)});function Qt(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...v(t)})}(Ht,e)}const en=t("ZodError",(e,t)=>{$.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},i=e=>{for(const r of e.issues)if("invalid_union"===r.code&&r.errors.length)r.errors.map(e=>i({issues:e}));else if("invalid_key"===r.code)i({issues:r.issues});else if("invalid_element"===r.code)i({issues:r.issues});else if(0===r.path.length)n._errors.push(t(r));else{let e=n,i=0;for(;i<r.path.length;){const n=r.path[i];i===r.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(r))):e[n]=e[n]||{_errors:[]},e=e[n],i++}}};return i(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},i=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):i.push(t(r));return{formErrors:i,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,s,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,s,2)}},isEmpty:{get:()=>0===e.issues.length}})},{Parent:Error}),tn=E(en),nn=x(en),rn=T(en),on=N(en),sn=S(en),an=F(en),un=j(en),cn=C(en),dn=D(en),pn=V(en),ln=U(en),fn=R(en),hn=t("ZodType",(e,t)=>(Ne.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(function(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}(t,{checks:[...t.checks??[],...n.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]})),e.clone=(t,n)=>function(e,t,n){const i=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(i._zod.parent=e),i}(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>tn(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>rn(e,t,n),e.parseAsync=async(t,n)=>nn(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>on(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>sn(e,t,n),e.decode=(t,n)=>an(e,t,n),e.encodeAsync=async(t,n)=>un(e,t,n),e.decodeAsync=async(t,n)=>cn(e,t,n),e.safeEncode=(t,n)=>dn(e,t,n),e.safeDecode=(t,n)=>pn(e,t,n),e.safeEncodeAsync=async(t,n)=>ln(e,t,n),e.safeDecodeAsync=async(t,n)=>fn(e,t,n),e.refine=(t,n)=>e.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...v(n)})}(ui,e,t)}(t,n)),e.superRefine=t=>e.check(Gt(t)),e.overwrite=t=>e.check(Wt(t)),e.optional=()=>Hn(e),e.nullable=()=>ei(e),e.nullish=()=>Hn(ei(e)),e.nonoptional=t=>function(e,t){return new ii({type:"nonoptional",innerType:e,...v(t)})}(e,t),e.array=()=>Gn(e),e.or=t=>Bn([e,t]),e.and=t=>new Yn({type:"intersection",left:e,right:t}),e.transform=t=>si(e,new Kn({type:"transform",transform:t})),e.default=t=>{return n=t,new ti({type:"default",innerType:e,get defaultValue(){return"function"==typeof n?n():h(n)}});var n},e.prefault=t=>{return n=t,new ni({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof n?n():h(n)}});var n},e.catch=t=>{return new ri({type:"catch",innerType:e,catchValue:"function"==typeof(n=t)?n:()=>n});var n},e.pipe=t=>si(e,t),e.readonly=()=>new ai({type:"readonly",innerType:e}),e.describe=t=>{const n=e.clone();return St.add(n,{description:t}),n},Object.defineProperty(e,"description",{get:()=>St.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return St.get(e);const n=e.clone();return St.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),mn=t("_ZodString",(e,t)=>{Oe.init(e,t),hn.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new $e({check:"string_format",format:"regex",...v(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new Ae({check:"string_format",format:"includes",...v(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new Ee({check:"string_format",format:"starts_with",...v(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new xe({check:"string_format",format:"ends_with",...v(t),suffix:e})}(...t)),e.min=(...t)=>e.check(Mt(...t)),e.max=(...t)=>e.check(Rt(...t)),e.length=(...t)=>e.check(Lt(...t)),e.nonempty=(...t)=>e.check(Mt(1,...t)),e.lowercase=t=>e.check(function(e){return new Ze({check:"string_format",format:"lowercase",...v(e)})}(t)),e.uppercase=t=>e.check(function(e){return new Ie({check:"string_format",format:"uppercase",...v(e)})}(t)),e.trim=()=>e.check(Wt(e=>e.trim())),e.normalize=(...t)=>e.check(function(e){return Wt(t=>t.normalize(e))}(...t)),e.toLowerCase=()=>e.check(Wt(e=>e.toLowerCase())),e.toUpperCase=()=>e.check(Wt(e=>e.toUpperCase()))}),vn=t("ZodString",(e,t)=>{Oe.init(e,t),mn.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...v(t)})}(yn,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...v(t)})}(wn,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...v(t)})}(Cn,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...v(t)})}(kn,t)),e.guid=t=>e.check(Ft(zn,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...v(t)})}(bn,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...v(t)})}(bn,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...v(t)})}(bn,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...v(t)})}(bn,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...v(t)})}($n,t)),e.guid=t=>e.check(Ft(zn,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...v(t)})}(Zn,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...v(t)})}(In,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...v(t)})}(An,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...v(t)})}(Sn,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...v(t)})}(Fn,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...v(t)})}(En,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...v(t)})}(xn,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...v(t)})}(Tn,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...v(t)})}(Pn,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...v(t)})}(Nn,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...v(t)})}(On,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...v(t)})}(jn,t)),e.datetime=t=>e.check(Bt(t)),e.date=t=>e.check(Xt(t)),e.time=t=>e.check(qt(t)),e.duration=t=>e.check(Qt(t))});function _n(e){return function(e,t){return new e({type:"string",...v(t)})}(vn,e)}const gn=t("ZodStringFormat",(e,t)=>{Se.init(e,t),mn.init(e,t)}),yn=t("ZodEmail",(e,t)=>{Ce.init(e,t),gn.init(e,t)}),zn=t("ZodGUID",(e,t)=>{Fe.init(e,t),gn.init(e,t)}),bn=t("ZodUUID",(e,t)=>{je.init(e,t),gn.init(e,t)}),wn=t("ZodURL",(e,t)=>{De.init(e,t),gn.init(e,t)}),kn=t("ZodEmoji",(e,t)=>{Ve.init(e,t),gn.init(e,t)}),$n=t("ZodNanoID",(e,t)=>{Ue.init(e,t),gn.init(e,t)}),Zn=t("ZodCUID",(e,t)=>{Re.init(e,t),gn.init(e,t)}),In=t("ZodCUID2",(e,t)=>{Me.init(e,t),gn.init(e,t)}),An=t("ZodULID",(e,t)=>{Le.init(e,t),gn.init(e,t)}),En=t("ZodXID",(e,t)=>{We.init(e,t),gn.init(e,t)}),xn=t("ZodKSUID",(e,t)=>{Ge.init(e,t),gn.init(e,t)}),Tn=t("ZodIPv4",(e,t)=>{Ke.init(e,t),gn.init(e,t)}),Pn=t("ZodIPv6",(e,t)=>{qe.init(e,t),gn.init(e,t)}),Nn=t("ZodCIDRv4",(e,t)=>{He.init(e,t),gn.init(e,t)}),On=t("ZodCIDRv6",(e,t)=>{Qe.init(e,t),gn.init(e,t)}),Sn=t("ZodBase64",(e,t)=>{tt.init(e,t),gn.init(e,t)}),Fn=t("ZodBase64URL",(e,t)=>{nt.init(e,t),gn.init(e,t)}),jn=t("ZodE164",(e,t)=>{it.init(e,t),gn.init(e,t)}),Cn=t("ZodJWT",(e,t)=>{rt.init(e,t),gn.init(e,t)}),Dn=t("ZodNumber",(e,t)=>{ot.init(e,t),hn.init(e,t),e.gt=(t,n)=>e.check(Dt(t,n)),e.gte=(t,n)=>e.check(Vt(t,n)),e.min=(t,n)=>e.check(Vt(t,n)),e.lt=(t,n)=>e.check(jt(t,n)),e.lte=(t,n)=>e.check(Ct(t,n)),e.max=(t,n)=>e.check(Ct(t,n)),e.int=t=>e.check(Rn(t)),e.safe=t=>e.check(Rn(t)),e.positive=t=>e.check(Dt(0,t)),e.nonnegative=t=>e.check(Vt(0,t)),e.negative=t=>e.check(jt(0,t)),e.nonpositive=t=>e.check(Ct(0,t)),e.multipleOf=(t,n)=>e.check(Ut(t,n)),e.step=(t,n)=>e.check(Ut(t,n)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Vn(e){return function(e,t){return new e({type:"number",checks:[],...v(t)})}(Dn,e)}const Un=t("ZodNumberFormat",(e,t)=>{st.init(e,t),Dn.init(e,t)});function Rn(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...v(t)})}(Un,e)}const Mn=t("ZodBoolean",(e,t)=>{at.init(e,t),hn.init(e,t)});function Ln(e){return function(e,t){return new e({type:"boolean",...v(t)})}(Mn,e)}const Wn=t("ZodArray",(e,t)=>{ct.init(e,t),hn.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(Mt(t,n)),e.nonempty=t=>e.check(Mt(1,t)),e.max=(t,n)=>e.check(Rt(t,n)),e.length=(t,n)=>e.check(Lt(t,n)),e.unwrap=()=>e.element});function Gn(e,t){return function(e,t,n){return new e({type:"array",element:t,...v(n)})}(Wn,e,t)}const Jn=t("ZodUnion",(e,t)=>{pt.init(e,t),hn.init(e,t),e.options=t.options});function Bn(e,t){return new Jn({type:"union",options:e,...v(t)})}const Yn=t("ZodIntersection",(e,t)=>{lt.init(e,t),hn.init(e,t)});const Xn=t("ZodLiteral",(e,t)=>{mt.init(e,t),hn.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});const Kn=t("ZodTransform",(e,t)=>{vt.init(e,t),hn.init(e,t),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new i(e.constructor.name);n.addIssue=i=>{if("string"==typeof i)n.issues.push(w(i,n.value,t));else{const t=i;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(w(t))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(e=>(n.value=e,n)):(n.value=o,n)}});const qn=t("ZodOptional",(e,t)=>{gt.init(e,t),hn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Hn(e){return new qn({type:"optional",innerType:e})}const Qn=t("ZodNullable",(e,t)=>{yt.init(e,t),hn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ei(e){return new Qn({type:"nullable",innerType:e})}const ti=t("ZodDefault",(e,t)=>{zt.init(e,t),hn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});const ni=t("ZodPrefault",(e,t)=>{wt.init(e,t),hn.init(e,t),e.unwrap=()=>e._zod.def.innerType});const ii=t("ZodNonOptional",(e,t)=>{kt.init(e,t),hn.init(e,t),e.unwrap=()=>e._zod.def.innerType});const ri=t("ZodCatch",(e,t)=>{Zt.init(e,t),hn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});const oi=t("ZodPipe",(e,t)=>{It.init(e,t),hn.init(e,t),e.in=t.in,e.out=t.out});function si(e,t){return new oi({type:"pipe",in:e,out:t})}const ai=t("ZodReadonly",(e,t)=>{Et.init(e,t),hn.init(e,t),e.unwrap=()=>e._zod.def.innerType});const ui=t("ZodCustom",(e,t)=>{Tt.init(e,t),hn.init(e,t)});function ci(e){return t=>{const n=e.safeParse(t);return{success:n.success,data:n.data,error:n?.error?A(n.error):void 0}}}class di extends e{schema;constructor(t,n){super(ci(t),e.nameToType(t.type),n),this.schema=t}array(){return this.schema=this.schema.array(),this.regenerateValidator(),this}default(e){return this.schema=this.schema.default(e),this.hasDefault=!0,this.regenerateValidator(),this}optional(){return this.schema=this.schema.optional(),this.regenerateValidator(),this}static zodValidators={string:_n(),number:Vn(),boolean:Ln()};static literal(e,t){return new di(function(e,t){return new Xn({type:"literal",values:Array.isArray(e)?e:[e],...v(t)})}(e),t)}static string(e){return new di(di.zodValidators.string,e)}static number(e){return new di(di.zodValidators.number,e)}static boolean(e){return new di(di.zodValidators.boolean,e)}static union(e,t){return new di(Bn(e),t)}static custom(e,t){return new di(e,t)}static array(e,t){return new di(Gn(e),t)}regenerateValidator(){this.validateFn=ci(this.schema)}}export{di as Property};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["../src/index.ts"],"version":"5.9.3"}
|