@oxog/vld 2.1.0 → 2.2.7

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.
Files changed (228) hide show
  1. package/CHANGELOG.md +113 -0
  2. package/README.md +413 -1235
  3. package/dist/chunks/errors-core-CerMg2rq.js +1 -0
  4. package/dist/chunks/index-CkbfQQ4n.js +1 -0
  5. package/dist/chunks/index-yjpbvFgw.js +1 -0
  6. package/dist/chunks/ip-validation-g5LWgy9t.js +1 -0
  7. package/dist/chunks/security-Dy24T8N7.js +1 -0
  8. package/dist/cjs/chunks/errors-core-DrydF46s.cjs +1 -0
  9. package/dist/cjs/chunks/index-BEV9nG0N.cjs +1 -0
  10. package/dist/cjs/chunks/index-ZjHAxYdA.cjs +1 -0
  11. package/dist/cjs/chunks/ip-validation-BZqPamPC.cjs +1 -0
  12. package/dist/cjs/chunks/security-aXZVI7qW.cjs +1 -0
  13. package/dist/cjs/cli/bin.cjs +1 -505
  14. package/dist/cjs/cli/index.cjs +1 -209
  15. package/dist/cjs/codecs/index.cjs +1 -45
  16. package/dist/cjs/coercion/index.cjs +1 -588
  17. package/dist/cjs/compat/emitter.cjs +1 -184
  18. package/dist/cjs/compat/result.cjs +1 -189
  19. package/dist/cjs/errors.cjs +1 -180
  20. package/dist/cjs/index.cjs +1 -1894
  21. package/dist/cjs/kernel.cjs +1 -415
  22. package/dist/cjs/locales/af.cjs +1 -108
  23. package/dist/cjs/locales/ar.cjs +1 -108
  24. package/dist/cjs/locales/bn.cjs +1 -108
  25. package/dist/cjs/locales/da.cjs +1 -108
  26. package/dist/cjs/locales/de.cjs +1 -108
  27. package/dist/cjs/locales/en.cjs +1 -108
  28. package/dist/cjs/locales/es-MX.cjs +1 -107
  29. package/dist/cjs/locales/es.cjs +1 -96
  30. package/dist/cjs/locales/fi.cjs +1 -108
  31. package/dist/cjs/locales/fr.cjs +1 -96
  32. package/dist/cjs/locales/hi.cjs +1 -108
  33. package/dist/cjs/locales/id.cjs +1 -108
  34. package/dist/cjs/locales/index.cjs +1 -43
  35. package/dist/cjs/locales/it.cjs +1 -108
  36. package/dist/cjs/locales/ja.cjs +1 -108
  37. package/dist/cjs/locales/ko.cjs +1 -108
  38. package/dist/cjs/locales/lazy.cjs +1 -188
  39. package/dist/cjs/locales/nl.cjs +1 -108
  40. package/dist/cjs/locales/no.cjs +1 -108
  41. package/dist/cjs/locales/pl.cjs +1 -108
  42. package/dist/cjs/locales/pt-BR.cjs +1 -108
  43. package/dist/cjs/locales/pt.cjs +1 -108
  44. package/dist/cjs/locales/ru.cjs +1 -108
  45. package/dist/cjs/locales/runtime.cjs +1 -51
  46. package/dist/cjs/locales/sv.cjs +1 -108
  47. package/dist/cjs/locales/sw.cjs +1 -108
  48. package/dist/cjs/locales/th.cjs +1 -108
  49. package/dist/cjs/locales/tr.cjs +1 -108
  50. package/dist/cjs/locales/vi.cjs +1 -108
  51. package/dist/cjs/locales/zh.cjs +1 -108
  52. package/dist/cjs/mini.cjs +1 -242
  53. package/dist/cjs/pigment.cjs +1 -207
  54. package/dist/cjs/plugins/index.cjs +1 -12
  55. package/dist/cjs/registry.cjs +1 -37
  56. package/dist/cjs/v3/index.cjs +1 -425
  57. package/dist/cjs/v4/core/index.cjs +1 -894
  58. package/dist/cjs/v4/index.cjs +1 -425
  59. package/dist/cjs/v4/locales/index.cjs +1 -130
  60. package/dist/cjs/v4/mini/index.cjs +1 -509
  61. package/dist/cjs/v4-mini/index.cjs +1 -532
  62. package/dist/cjs/validators/any.cjs +1 -40
  63. package/dist/cjs/validators/array.cjs +1 -283
  64. package/dist/cjs/validators/base.cjs +1 -887
  65. package/dist/cjs/validators/base64.cjs +1 -73
  66. package/dist/cjs/validators/bigint.cjs +1 -232
  67. package/dist/cjs/validators/boolean.cjs +1 -146
  68. package/dist/cjs/validators/codec.cjs +1 -205
  69. package/dist/cjs/validators/custom.cjs +1 -71
  70. package/dist/cjs/validators/date.cjs +1 -278
  71. package/dist/cjs/validators/discriminated-union.cjs +1 -130
  72. package/dist/cjs/validators/enum.cjs +1 -154
  73. package/dist/cjs/validators/file.cjs +1 -130
  74. package/dist/cjs/validators/function.cjs +1 -63
  75. package/dist/cjs/validators/hex.cjs +1 -70
  76. package/dist/cjs/validators/index.cjs +1 -123
  77. package/dist/cjs/validators/intersection.cjs +1 -120
  78. package/dist/cjs/validators/json.cjs +1 -70
  79. package/dist/cjs/validators/lazy.cjs +1 -53
  80. package/dist/cjs/validators/literal.cjs +1 -64
  81. package/dist/cjs/validators/map.cjs +1 -218
  82. package/dist/cjs/validators/nan.cjs +1 -41
  83. package/dist/cjs/validators/never.cjs +1 -36
  84. package/dist/cjs/validators/null.cjs +1 -43
  85. package/dist/cjs/validators/number.cjs +1 -427
  86. package/dist/cjs/validators/object.cjs +1 -868
  87. package/dist/cjs/validators/promise.cjs +1 -115
  88. package/dist/cjs/validators/record.cjs +1 -262
  89. package/dist/cjs/validators/set.cjs +1 -203
  90. package/dist/cjs/validators/string-bool.cjs +1 -124
  91. package/dist/cjs/validators/string-formats.cjs +1 -168
  92. package/dist/cjs/validators/string.cjs +1 -12
  93. package/dist/cjs/validators/symbol.cjs +1 -62
  94. package/dist/cjs/validators/template-literal.cjs +1 -108
  95. package/dist/cjs/validators/tuple.cjs +1 -187
  96. package/dist/cjs/validators/uint8array.cjs +1 -106
  97. package/dist/cjs/validators/undefined.cjs +1 -43
  98. package/dist/cjs/validators/union.cjs +1 -191
  99. package/dist/cjs/validators/unknown.cjs +1 -40
  100. package/dist/cjs/validators/void.cjs +1 -48
  101. package/dist/cjs/validators/xor.cjs +1 -69
  102. package/dist/cli/bin.js +1 -406
  103. package/dist/cli/index.js +1 -205
  104. package/dist/codecs/index.js +1 -11
  105. package/dist/coercion/index.js +1 -579
  106. package/dist/compat/emitter.js +1 -180
  107. package/dist/compat/result.js +1 -170
  108. package/dist/errors-core.d.ts +32 -2
  109. package/dist/errors.js +1 -171
  110. package/dist/index.d.ts +315 -361
  111. package/dist/index.js +1 -1534
  112. package/dist/kernel.js +1 -409
  113. package/dist/locales/af.js +1 -106
  114. package/dist/locales/ar.js +1 -106
  115. package/dist/locales/bn.js +1 -106
  116. package/dist/locales/da.js +1 -106
  117. package/dist/locales/de.js +1 -106
  118. package/dist/locales/en.js +1 -106
  119. package/dist/locales/es-MX.js +1 -105
  120. package/dist/locales/es.js +1 -94
  121. package/dist/locales/fi.js +1 -106
  122. package/dist/locales/fr.js +1 -94
  123. package/dist/locales/hi.js +1 -106
  124. package/dist/locales/id.js +1 -106
  125. package/dist/locales/index.js +1 -29
  126. package/dist/locales/it.js +1 -106
  127. package/dist/locales/ja.js +1 -106
  128. package/dist/locales/ko.js +1 -106
  129. package/dist/locales/lazy.js +1 -177
  130. package/dist/locales/nl.js +1 -106
  131. package/dist/locales/no.js +1 -106
  132. package/dist/locales/pl.js +1 -106
  133. package/dist/locales/pt-BR.js +1 -106
  134. package/dist/locales/pt.js +1 -106
  135. package/dist/locales/ru.js +1 -106
  136. package/dist/locales/runtime.js +1 -41
  137. package/dist/locales/sv.js +1 -106
  138. package/dist/locales/sw.js +1 -106
  139. package/dist/locales/th.js +1 -106
  140. package/dist/locales/tr.js +1 -106
  141. package/dist/locales/vi.js +1 -106
  142. package/dist/locales/zh.js +1 -106
  143. package/dist/mini.d.ts +3 -3
  144. package/dist/mini.js +1 -156
  145. package/dist/pigment.js +1 -180
  146. package/dist/plugins/index.js +1 -1
  147. package/dist/registry.js +1 -34
  148. package/dist/utils/json-schema.d.ts +10 -1
  149. package/dist/v3/index.js +1 -46
  150. package/dist/v4/core/index.d.ts +28 -16
  151. package/dist/v4/core/index.js +1 -277
  152. package/dist/v4/index.js +1 -50
  153. package/dist/v4/locales/index.d.ts +4 -0
  154. package/dist/v4/locales/index.js +1 -77
  155. package/dist/v4/mini/index.js +1 -47
  156. package/dist/v4-mini/index.d.ts +1 -1
  157. package/dist/v4-mini/index.js +1 -75
  158. package/dist/validators/any.js +1 -37
  159. package/dist/validators/array.d.ts +7 -0
  160. package/dist/validators/array.js +1 -279
  161. package/dist/validators/base.d.ts +210 -17
  162. package/dist/validators/base.js +1 -868
  163. package/dist/validators/base64.js +1 -68
  164. package/dist/validators/bigint.d.ts +7 -0
  165. package/dist/validators/bigint.js +1 -228
  166. package/dist/validators/boolean.js +1 -142
  167. package/dist/validators/codec.js +1 -200
  168. package/dist/validators/custom.d.ts +20 -10
  169. package/dist/validators/custom.js +1 -67
  170. package/dist/validators/date.d.ts +2 -0
  171. package/dist/validators/date.js +1 -274
  172. package/dist/validators/discriminated-union.d.ts +4 -2
  173. package/dist/validators/discriminated-union.js +1 -123
  174. package/dist/validators/enum.d.ts +8 -2
  175. package/dist/validators/enum.js +1 -150
  176. package/dist/validators/file.js +1 -125
  177. package/dist/validators/function.js +1 -58
  178. package/dist/validators/hex.js +1 -65
  179. package/dist/validators/index.d.ts +1 -1
  180. package/dist/validators/index.js +1 -35
  181. package/dist/validators/intersection.js +1 -116
  182. package/dist/validators/json.js +1 -66
  183. package/dist/validators/lazy.js +1 -50
  184. package/dist/validators/literal.d.ts +8 -3
  185. package/dist/validators/literal.js +1 -60
  186. package/dist/validators/map.d.ts +7 -0
  187. package/dist/validators/map.js +1 -214
  188. package/dist/validators/nan.js +1 -38
  189. package/dist/validators/never.js +1 -32
  190. package/dist/validators/null.js +1 -40
  191. package/dist/validators/number.d.ts +25 -1
  192. package/dist/validators/number.js +1 -423
  193. package/dist/validators/object.d.ts +18 -2
  194. package/dist/validators/object.js +1 -864
  195. package/dist/validators/promise.d.ts +6 -7
  196. package/dist/validators/promise.js +1 -111
  197. package/dist/validators/record.d.ts +13 -8
  198. package/dist/validators/record.js +1 -258
  199. package/dist/validators/set.d.ts +5 -0
  200. package/dist/validators/set.js +1 -199
  201. package/dist/validators/string-bool.js +1 -120
  202. package/dist/validators/string-formats.d.ts +58 -62
  203. package/dist/validators/string-formats.js +1 -135
  204. package/dist/validators/string.d.ts +49 -10
  205. package/dist/validators/string.js +1 -4
  206. package/dist/validators/symbol.js +1 -58
  207. package/dist/validators/template-literal.js +1 -103
  208. package/dist/validators/tuple.d.ts +17 -13
  209. package/dist/validators/tuple.js +1 -183
  210. package/dist/validators/uint8array.js +1 -101
  211. package/dist/validators/undefined.js +1 -40
  212. package/dist/validators/union.d.ts +1 -0
  213. package/dist/validators/union.js +1 -187
  214. package/dist/validators/unknown.js +1 -37
  215. package/dist/validators/void.js +1 -44
  216. package/dist/validators/xor.d.ts +2 -2
  217. package/dist/validators/xor.js +1 -66
  218. package/package.json +240 -238
  219. package/dist/chunks/errors-core-BeiFUtZM.js +0 -81
  220. package/dist/chunks/index-0R2ntSud.js +0 -508
  221. package/dist/chunks/index-BvH403Yy.js +0 -88
  222. package/dist/chunks/security-B0Pd_vSY.js +0 -35
  223. package/dist/chunks/string-BJRQod3t.js +0 -530
  224. package/dist/cjs/chunks/errors-core-DWxLFs2f.cjs +0 -83
  225. package/dist/cjs/chunks/index-BkI37108.cjs +0 -538
  226. package/dist/cjs/chunks/index-Cc3bjUMX.cjs +0 -91
  227. package/dist/cjs/chunks/security-Dc3Jh13T.cjs +0 -37
  228. package/dist/cjs/chunks/string-BKZrc4hs.cjs +0 -533
@@ -0,0 +1 @@
1
+ function e(e){return null===e?"null":void 0===e?"undefined":Array.isArray(e)?"array":"number"==typeof e?Number.isNaN(e)?"nan":e===1/0?"Infinity":e===-1/0?"-Infinity":"number":e instanceof Date?"date":e instanceof Map?"map":e instanceof Set?"set":typeof e}function s(e,s,r){return{code:"invalid_type",path:[],expected:e,received:s,message:r??`Invalid input: expected ${e}, received ${s}`}}function r(e){const s={code:e.code,path:e.path,message:e.message};return void 0!==e.expected&&(s.expected=e.expected),void 0!==e.received&&(s.received=e.received),void 0!==e.keys&&(s.keys=e.keys),void 0!==e.minimum&&(s.minimum=e.minimum),void 0!==e.maximum&&(s.maximum=e.maximum),void 0!==e.exact&&(s.exact=e.exact),void 0!==e.inclusive&&(s.inclusive=e.inclusive),void 0!==e.origin&&(s.origin=e.origin),void 0!==e.format&&(s.format=e.format),void 0!==e.values&&(s.values=e.values),void 0!==e.pattern&&(s.pattern=e.pattern),s}function i(e){const s={code:e.code,path:e.path,message:e.message};return void 0!==e.expected&&(s.expected=e.expected),void 0!==e.received&&(s.received=e.received),void 0!==e.keys&&(s.keys=e.keys),void 0!==e.minimum&&(s.minimum=e.minimum),void 0!==e.maximum&&(s.maximum=e.maximum),void 0!==e.exact&&(s.exact=e.exact),void 0!==e.inclusive&&(s.inclusive=e.inclusive),void 0!==e.origin&&(s.origin=e.origin),void 0!==e.format&&(s.format=e.format),void 0!==e.values&&(s.values=e.values),void 0!==e.pattern&&(s.pattern=e.pattern),s}class VldError extends Error{constructor(e,s){const r=e[0];super(void 0!==s?s:1===e.length&&void 0!==r?r.message:`${e.length} validation errors`),this.name="VldError",this.issues=e,Error.captureStackTrace&&Error.captureStackTrace(this,VldError)}get firstError(){return this.issues[0]}get errors(){return this.issues}get isEmpty(){return 0===this.issues.length}get formattedErrors(){return this.issues.map(e=>e.message)}addIssue(e){this.issues.push(e)}addIssues(e=[]){this.issues.push(...e)}format(){const e={_errors:[]};for(const s of this.issues)if(s.path&&0!==s.path.length){let r=e;for(const e of s.path)r[e]||(r[e]={_errors:[]}),r=r[e];r._errors.push(s.message)}else e._errors.push(s.message);return e}flatten(e){const s=e??(e=>e.message),r=[],i={};for(const e of this.issues)if(e.path&&0!==e.path.length){const r=String(e.path[0]);i[r]=i[r]??[],i[r].push(s(e))}else r.push(s(e));return{formErrors:r,fieldErrors:i}}toJSON(){return{name:this.name,message:this.message,code:"VLD_VALIDATION_ERROR",issues:this.issues.map(r)}}static fromJSON(e){const s=e.issues.map(i);return new VldError(s)}static isVldError(e){return e instanceof VldError}}export{VldError as V,s as c,e as g};
@@ -0,0 +1 @@
1
+ import{VldCodec as e}from"../validators/codec.js";import{VldBase64 as r}from"../validators/base64.js";import{VldHex as t}from"../validators/hex.js";import{VldUint8Array as o}from"../validators/uint8array.js";import{VldString as n}from"../validators/string.js";import{VldNumber as a}from"../validators/number.js";import{VldBigInt as c}from"../validators/bigint.js";import{VldBoolean as i}from"../validators/boolean.js";import{VldDate as s}from"../validators/date.js";import{VldUnknown as d}from"../validators/unknown.js";function l(e){const r=e.replace(/-/g,"+").replace(/_/g,"/"),t=function(e){if(function(e){if(null==e)throw new Error("Base64 input cannot be null or undefined");if("string"!=typeof e)throw new Error("Base64 input must be a string");if(e.length>1e7)throw new Error("Base64 input is too large");if(!/^[A-Za-z0-9+/]*={0,2}$/.test(e))throw new Error("Invalid base64 format");const r=e.indexOf("=");if(-1!==r){const t=e.substring(r);if(!/^={1,2}$/.test(t))throw new Error("Invalid base64 padding");if(r<e.length-2)throw new Error("Base64 padding must be at the end")}const t=[/eval/i,/function/i,/javascript:/i,/<script/i,/on\w+\s*=/i,/__proto__/i,/constructor/i,/prototype/i];try{const r=Math.min(100,e.length),o=e.substring(0,r),n="undefined"!=typeof atob?atob(o):Buffer.from(o,"base64").toString("utf8",0,50);for(const e of t)if(e.test(n))throw new Error("Suspicious content detected in base64 input")}catch(e){if(e instanceof Error&&e.message.includes("Suspicious content"))throw e}}(e),"undefined"!=typeof atob)try{return atob(e)}catch{throw new Error("Failed to decode base64 data")}if(m())try{const r=Buffer.from(e,"base64");if(r.length>5e6)throw new Error("Decoded base64 data is too large");return r.toString("binary")}catch(e){if(e instanceof Error&&e.message.includes("Invalid base64"))throw new Error("Invalid base64 format");throw new Error("Failed to decode base64 data in Node.js environment")}throw new Error("Base64 decoding not supported in this environment")}(r.padEnd(r.length+(4-r.length%4)%4,"=")),o=new Uint8Array(t.length);for(let e=0;e<t.length;e++)o[e]=t.charCodeAt(e);return o}function f(e){let r="";for(let t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);return function(e){if("undefined"!=typeof btoa)return btoa(e);if(m())return Buffer.from(e,"binary").toString("base64");throw new Error("Base64 encoding not supported in this environment")}(r)}function u(e){return f(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function h(e){if(e.length>2e7)throw new Error("Hex string is too large (max 10MB)");const r=e.startsWith("0x")?e.slice(2):e;if(!/^[0-9a-fA-F]*$/.test(r))throw new Error("Invalid hex string: contains non-hexadecimal characters");const t=r.length%2==0?r:"0"+r,o=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2)o[e/2]=parseInt(t.substring(e,e+2),16);return o}function g(e){let r="";for(let t=0;t<e.length;t++){const o=e[t].toString(16);r+=1===o.length?"0"+o:o}return r}function w(e){const r=1e7;if(e.length>r)throw new Error("String is too large for UTF-8 encoding (max 10000000 characters)");return(new TextEncoder).encode(e)}function p(e){const r=1e7;if(e.length>r)throw new Error("Byte array is too large for UTF-8 decoding (max 10000000 bytes)");return(new TextDecoder).decode(e)}function m(){return"undefined"!=typeof globalThis&&void 0!==globalThis.process&&null!=globalThis.process.versions&&null!=globalThis.process.versions.node}function b(e){return e.invert()}const v=e.create(n.create(),a.create(),{decode:e=>{const r=Number(e);if(isNaN(r))throw new Error("Invalid number");return r},encode:e=>e.toString()}),E=e.create(n.create(),a.create().int(),{decode:e=>{const r=parseInt(e,10);if(isNaN(r))throw new Error("Invalid integer");return r},encode:e=>Math.floor(e).toString()}),y=e.create(n.create(),c.create(),{decode:e=>{try{return BigInt(e)}catch{throw new Error("Invalid BigInt")}},encode:e=>e.toString()}),S=e.create(a.create().int(),c.create(),{decode:e=>BigInt(Math.floor(e)),encode:e=>Number(e)}),T=e.create(n.create().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?$/,"Invalid ISO datetime format"),s.create(),{decode:e=>{const r=new Date(e);if(isNaN(r.getTime()))throw new Error("Invalid date");return r},encode:e=>e.toISOString()}),I=e.create(a.create(),s.create(),{decode:e=>new Date(1e3*e),encode:e=>Math.floor(e.getTime()/1e3)}),x=e.create(a.create(),s.create(),{decode:e=>new Date(e),encode:e=>e.getTime()}),N=r=>{const t=r||d.create();return e.create(n.create(),t,{decode:e=>{try{return JSON.parse(e)}catch{throw new Error("Invalid JSON")}},encode:e=>JSON.stringify(e)})},B=e.create(n.create().url(),d.create(),{decode:e=>{try{return new URL(e)}catch{throw new Error("Invalid URL")}},encode:e=>e.toString()}),j=e.create(n.create().regex(/^https?:\/\//,"Must be HTTP or HTTPS URL"),d.create(),{decode:e=>{try{const r=new URL(e);if(!["http:","https:"].includes(r.protocol))throw new Error("Must be HTTP or HTTPS");return r}catch{throw new Error("Invalid HTTP URL")}},encode:e=>e.toString()}),J=e.create(n.create(),n.create(),{decode:e=>{try{return decodeURIComponent(e)}catch{throw new Error("Invalid URI component")}},encode:e=>encodeURIComponent(e)}),U=e.create(n.create(),i.create(),{decode:e=>{const r=e.toLowerCase();if("true"===r||"1"===r||"yes"===r||"on"===r)return!0;if("false"===r||"0"===r||"no"===r||"off"===r)return!1;throw new Error("Invalid boolean string")},encode:e=>e.toString()}),M=e.create(r.create(),o.create(),{decode:l,encode:f}),O=e.create(r.create().urlSafeMode(),o.create(),{decode:l,encode:u}),C=e.create(t.create(),o.create(),{decode:h,encode:g}),R=e.create(t.create().lowercaseMode(),o.create(),{decode:h,encode:e=>g(e).toLowerCase()}),F=e.create(n.create(),o.create(),{decode:w,encode:p}),L=e.create(o.create(),n.create(),{decode:p,encode:w}),W=e.create(r.create().urlSafeMode(),o.create(),{decode:l,encode:u}),_=t=>{const o=t||d.create();return e.create(r.create(),o,{decode:e=>{try{const r=p(l(e));return JSON.parse(r)}catch(e){throw new Error(`Failed to parse base64 JSON: ${e.message}`)}},encode:e=>f(w(JSON.stringify(e)))})},A=r=>{const t=r||d.create();return e.create(n.create().refine(e=>3===e.split(".").length,"Invalid JWT format"),t,{decode:e=>{try{const r=e.split(".");if(3!==r.length)throw new Error("JWT must have exactly 3 parts");const t=r[1];if(!t)throw new Error("JWT payload is empty");const o=p(l(t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"=")));return JSON.parse(o)}catch(e){throw new Error(`Failed to decode JWT payload: ${e.message}`)}},encode:()=>{throw new Error("JWT encoding not supported - use a proper JWT library")}})};export{p as A,J as B,F as C,M as a,_ as b,l as c,O as d,W as e,L as f,x as g,I as h,R as i,C as j,h as k,b as l,T as m,N as n,A as o,S as p,U as q,j as r,y as s,E as t,v as u,B as v,w,f as x,u as y,g as z};
@@ -0,0 +1 @@
1
+ import{registerLocale as o,registerFallbackLocale as s,setLocale as r,getLocale as l,getMessages as e,getMessagesForLocale as t,getSupportedLocales as m,isLocaleLoaded as a,isLocaleSupported as i}from"../locales/runtime.js";import{en as c}from"../locales/en.js";import{tr as f}from"../locales/tr.js";import{es as p}from"../locales/es.js";import{fr as j}from"../locales/fr.js";import{de as n}from"../locales/de.js";import{it as d}from"../locales/it.js";import{pt as h}from"../locales/pt.js";import{ru as u}from"../locales/ru.js";import{ja as g}from"../locales/ja.js";import{ko as k}from"../locales/ko.js";import{zh as v}from"../locales/zh.js";import{ar as L}from"../locales/ar.js";import{hi as y}from"../locales/hi.js";import{nl as z}from"../locales/nl.js";import{pl as b}from"../locales/pl.js";import{da as M}from"../locales/da.js";import{sv as R}from"../locales/sv.js";import{no as _}from"../locales/no.js";import{fi as w}from"../locales/fi.js";import{th as A}from"../locales/th.js";import{vi as B}from"../locales/vi.js";import{id as X}from"../locales/id.js";import{bn as q}from"../locales/bn.js";import{sw as x}from"../locales/sw.js";import{af as S}from"../locales/af.js";import{ptBR as C}from"../locales/pt-BR.js";import{esMX as F}from"../locales/es-MX.js";const O=["en","tr","es","fr","de","it","pt","ru","ja","ko","zh","ar","hi","nl","pl","da","sv","no","fi","th","vi","id","bn","sw","af","pt-BR","es-MX"],D=["is","cs","sk","hu","ro","bg","hr","sl","lv","lt","et","el","mk","sq","sr","bs","me","mt","ga","cy","eu","ca","ms","tl","ur","fa","he","ka","am","hy","az","kk","ky","uz","tg","mn","my","km","lo","si","ta","te","ml","kn","gu","pa","or","as","ne","mr","sd","dv","ha","yo","ig","zu","xh","st","tn","ts","ve","nr","ss","es-AR","fr-CA","qu","gn","ay"],E={en:c,tr:f,es:p,fr:j,de:n,it:d,pt:h,ru:u,ja:g,ko:k,zh:v,ar:L,hi:y,nl:z,pl:b,da:M,sv:R,no:_,fi:w,th:A,vi:B,id:X,bn:q,sw:x,af:S,"pt-BR":C,"es-MX":F};for(const s of O)o(s,E[s]);for(const o of D)s(o);async function G(o){r(o)}var H=Object.freeze({__proto__:null,getLocale:l,getMessages:e,getMessagesForLocale:t,getSupportedLocales:m,isLocaleLoaded:a,isLocaleSupported:i,registerLocale:o,setLocale:r,setLocaleAsync:G});export{H as l,G as s};
@@ -0,0 +1 @@
1
+ function t(t){if(0===t.length||t.length>64)return!1;const e=t.split("%"),n=e[0],r=e[1]?n:t;if(r.includes(".")){const t=r.lastIndexOf(":");if(-1===t)return!1;const e=r.substring(t+1),n=r.substring(0,t);return!!/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(e)&&!!n.includes("::")}if(!/^[0-9a-fA-F:]+$/.test(r))return!1;if(r.length>45)return!1;if(r.includes(":::"))return!1;if(["2001:0db8:85a3:0000:0000:8a2e:0370:7334","2001:db8:85a3::8a2e:370:7334","::1","fe80::1ff:fe23:4567:890a","2001:db8::","::ffff:192.0.2.1"].includes(r))return!0;if((r.match(/::/g)||[]).length>1)return!1;const f=r.includes("::"),i=r.split(":").filter(t=>""!==t);if(f){if(i.length>7)return!1}else if(8!==i.length)return!1;for(const t of i){if(0===t.length||t.length>4)return!1;if(!/^[0-9a-fA-F]+$/.test(t))return!1}return!0}export{t as i};
@@ -0,0 +1 @@
1
+ const _=new Set(["__proto__","constructor","prototype","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]);function t(t){return _.has(t)}export{t as i};
@@ -0,0 +1 @@
1
+ "use strict";function e(e){const s={code:e.code,path:e.path,message:e.message};return void 0!==e.expected&&(s.expected=e.expected),void 0!==e.received&&(s.received=e.received),void 0!==e.keys&&(s.keys=e.keys),void 0!==e.minimum&&(s.minimum=e.minimum),void 0!==e.maximum&&(s.maximum=e.maximum),void 0!==e.exact&&(s.exact=e.exact),void 0!==e.inclusive&&(s.inclusive=e.inclusive),void 0!==e.origin&&(s.origin=e.origin),void 0!==e.format&&(s.format=e.format),void 0!==e.values&&(s.values=e.values),void 0!==e.pattern&&(s.pattern=e.pattern),s}function s(e){const s={code:e.code,path:e.path,message:e.message};return void 0!==e.expected&&(s.expected=e.expected),void 0!==e.received&&(s.received=e.received),void 0!==e.keys&&(s.keys=e.keys),void 0!==e.minimum&&(s.minimum=e.minimum),void 0!==e.maximum&&(s.maximum=e.maximum),void 0!==e.exact&&(s.exact=e.exact),void 0!==e.inclusive&&(s.inclusive=e.inclusive),void 0!==e.origin&&(s.origin=e.origin),void 0!==e.format&&(s.format=e.format),void 0!==e.values&&(s.values=e.values),void 0!==e.pattern&&(s.pattern=e.pattern),s}class VldError extends Error{constructor(e,s){const r=e[0];super(void 0!==s?s:1===e.length&&void 0!==r?r.message:`${e.length} validation errors`),this.name="VldError",this.issues=e,Error.captureStackTrace&&Error.captureStackTrace(this,VldError)}get firstError(){return this.issues[0]}get errors(){return this.issues}get isEmpty(){return 0===this.issues.length}get formattedErrors(){return this.issues.map(e=>e.message)}addIssue(e){this.issues.push(e)}addIssues(e=[]){this.issues.push(...e)}format(){const e={_errors:[]};for(const s of this.issues)if(s.path&&0!==s.path.length){let r=e;for(const e of s.path)r[e]||(r[e]={_errors:[]}),r=r[e];r._errors.push(s.message)}else e._errors.push(s.message);return e}flatten(e){const s=e??(e=>e.message),r=[],t={};for(const e of this.issues)if(e.path&&0!==e.path.length){const r=String(e.path[0]);t[r]=t[r]??[],t[r].push(s(e))}else r.push(s(e));return{formErrors:r,fieldErrors:t}}toJSON(){return{name:this.name,message:this.message,code:"VLD_VALIDATION_ERROR",issues:this.issues.map(e)}}static fromJSON(e){const r=e.issues.map(s);return new VldError(r)}static isVldError(e){return e instanceof VldError}}exports.VldError=VldError,exports.createInvalidTypeIssue=function(e,s,r){return{code:"invalid_type",path:[],expected:e,received:s,message:r??`Invalid input: expected ${e}, received ${s}`}},exports.getTypeName=function(e){return null===e?"null":void 0===e?"undefined":Array.isArray(e)?"array":"number"==typeof e?Number.isNaN(e)?"nan":e===1/0?"Infinity":e===-1/0?"-Infinity":"number":e instanceof Date?"date":e instanceof Map?"map":e instanceof Set?"set":typeof e};
@@ -0,0 +1 @@
1
+ "use strict";var e=require("../locales/runtime.cjs"),s=require("../locales/en.cjs"),r=require("../locales/tr.cjs"),l=require("../locales/es.cjs"),c=require("../locales/fr.cjs"),a=require("../locales/de.cjs"),o=require("../locales/it.cjs"),i=require("../locales/pt.cjs"),t=require("../locales/ru.cjs"),u=require("../locales/ja.cjs"),j=require("../locales/ko.cjs"),n=require("../locales/zh.cjs"),q=require("../locales/ar.cjs"),p=require("../locales/hi.cjs"),d=require("../locales/nl.cjs"),g=require("../locales/pl.cjs"),L=require("../locales/da.cjs"),f=require("../locales/sv.cjs"),h=require("../locales/no.cjs"),k=require("../locales/fi.cjs"),v=require("../locales/th.cjs"),m=require("../locales/vi.cjs"),y=require("../locales/id.cjs"),b=require("../locales/bn.cjs"),z=require("../locales/sw.cjs"),M=require("../locales/af.cjs"),R=require("../locales/pt-BR.cjs"),w=require("../locales/es-MX.cjs");const A=["en","tr","es","fr","de","it","pt","ru","ja","ko","zh","ar","hi","nl","pl","da","sv","no","fi","th","vi","id","bn","sw","af","pt-BR","es-MX"],B=["is","cs","sk","hu","ro","bg","hr","sl","lv","lt","et","el","mk","sq","sr","bs","me","mt","ga","cy","eu","ca","ms","tl","ur","fa","he","ka","am","hy","az","kk","ky","uz","tg","mn","my","km","lo","si","ta","te","ml","kn","gu","pa","or","as","ne","mr","sd","dv","ha","yo","ig","zu","xh","st","tn","ts","ve","nr","ss","es-AR","fr-CA","qu","gn","ay"],S={en:s.en,tr:r.tr,es:l.es,fr:c.fr,de:a.de,it:o.it,pt:i.pt,ru:t.ru,ja:u.ja,ko:j.ko,zh:n.zh,ar:q.ar,hi:p.hi,nl:d.nl,pl:g.pl,da:L.da,sv:f.sv,no:h.no,fi:k.fi,th:v.th,vi:m.vi,id:y.id,bn:b.bn,sw:z.sw,af:M.af,"pt-BR":R.ptBR,"es-MX":w.esMX};for(const s of A)e.registerLocale(s,S[s]);for(const s of B)e.registerFallbackLocale(s);async function X(s){e.setLocale(s)}var _=Object.freeze({__proto__:null,getLocale:e.getLocale,getMessages:e.getMessages,getMessagesForLocale:e.getMessagesForLocale,getSupportedLocales:e.getSupportedLocales,isLocaleLoaded:e.isLocaleLoaded,isLocaleSupported:e.isLocaleSupported,registerLocale:e.registerLocale,setLocale:e.setLocale,setLocaleAsync:X});exports.localeNamespace=_,exports.setLocaleAsync=X;
@@ -0,0 +1 @@
1
+ "use strict";var e=require("../validators/codec.cjs"),r=require("../validators/base64.cjs"),t=require("../validators/hex.cjs"),o=require("../validators/uint8array.cjs"),n=require("../validators/string.cjs"),a=require("../validators/number.cjs"),d=require("../validators/bigint.cjs"),c=require("../validators/boolean.cjs"),i=require("../validators/date.cjs"),s=require("../validators/unknown.cjs");function l(e){const r=e.replace(/-/g,"+").replace(/_/g,"/"),t=function(e){if(function(e){if(null==e)throw new Error("Base64 input cannot be null or undefined");if("string"!=typeof e)throw new Error("Base64 input must be a string");if(e.length>1e7)throw new Error("Base64 input is too large");if(!/^[A-Za-z0-9+/]*={0,2}$/.test(e))throw new Error("Invalid base64 format");const r=e.indexOf("=");if(-1!==r){const t=e.substring(r);if(!/^={1,2}$/.test(t))throw new Error("Invalid base64 padding");if(r<e.length-2)throw new Error("Base64 padding must be at the end")}const t=[/eval/i,/function/i,/javascript:/i,/<script/i,/on\w+\s*=/i,/__proto__/i,/constructor/i,/prototype/i];try{const r=Math.min(100,e.length),o=e.substring(0,r),n="undefined"!=typeof atob?atob(o):Buffer.from(o,"base64").toString("utf8",0,50);for(const e of t)if(e.test(n))throw new Error("Suspicious content detected in base64 input")}catch(e){if(e instanceof Error&&e.message.includes("Suspicious content"))throw e}}(e),"undefined"!=typeof atob)try{return atob(e)}catch{throw new Error("Failed to decode base64 data")}if(V())try{const r=Buffer.from(e,"base64");if(r.length>5e6)throw new Error("Decoded base64 data is too large");return r.toString("binary")}catch(e){if(e instanceof Error&&e.message.includes("Invalid base64"))throw new Error("Invalid base64 format");throw new Error("Failed to decode base64 data in Node.js environment")}throw new Error("Base64 decoding not supported in this environment")}(r.padEnd(r.length+(4-r.length%4)%4,"=")),o=new Uint8Array(t.length);for(let e=0;e<t.length;e++)o[e]=t.charCodeAt(e);return o}function u(e){let r="";for(let t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);return function(e){if("undefined"!=typeof btoa)return btoa(e);if(V())return Buffer.from(e,"binary").toString("base64");throw new Error("Base64 encoding not supported in this environment")}(r)}function g(e){return u(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function h(e){if(e.length>2e7)throw new Error("Hex string is too large (max 10MB)");const r=e.startsWith("0x")?e.slice(2):e;if(!/^[0-9a-fA-F]*$/.test(r))throw new Error("Invalid hex string: contains non-hexadecimal characters");const t=r.length%2==0?r:"0"+r,o=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2)o[e/2]=parseInt(t.substring(e,e+2),16);return o}function f(e){let r="";for(let t=0;t<e.length;t++){const o=e[t].toString(16);r+=1===o.length?"0"+o:o}return r}function p(e){const r=1e7;if(e.length>r)throw new Error("String is too large for UTF-8 encoding (max 10000000 characters)");return(new TextEncoder).encode(e)}function w(e){const r=1e7;if(e.length>r)throw new Error("Byte array is too large for UTF-8 decoding (max 10000000 bytes)");return(new TextDecoder).decode(e)}function V(){return"undefined"!=typeof globalThis&&void 0!==globalThis.process&&null!=globalThis.process.versions&&null!=globalThis.process.versions.node}const b=e.VldCodec.create(n.VldString.create(),a.VldNumber.create(),{decode:e=>{const r=Number(e);if(isNaN(r))throw new Error("Invalid number");return r},encode:e=>e.toString()}),y=e.VldCodec.create(n.VldString.create(),a.VldNumber.create().int(),{decode:e=>{const r=parseInt(e,10);if(isNaN(r))throw new Error("Invalid integer");return r},encode:e=>Math.floor(e).toString()}),T=e.VldCodec.create(n.VldString.create(),d.VldBigInt.create(),{decode:e=>{try{return BigInt(e)}catch{throw new Error("Invalid BigInt")}},encode:e=>e.toString()}),x=e.VldCodec.create(a.VldNumber.create().int(),d.VldBigInt.create(),{decode:e=>BigInt(Math.floor(e)),encode:e=>Number(e)}),m=e.VldCodec.create(n.VldString.create().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?$/,"Invalid ISO datetime format"),i.VldDate.create(),{decode:e=>{const r=new Date(e);if(isNaN(r.getTime()))throw new Error("Invalid date");return r},encode:e=>e.toISOString()}),S=e.VldCodec.create(a.VldNumber.create(),i.VldDate.create(),{decode:e=>new Date(1e3*e),encode:e=>Math.floor(e.getTime()/1e3)}),v=e.VldCodec.create(a.VldNumber.create(),i.VldDate.create(),{decode:e=>new Date(e),encode:e=>e.getTime()}),E=e.VldCodec.create(n.VldString.create().url(),s.VldUnknown.create(),{decode:e=>{try{return new URL(e)}catch{throw new Error("Invalid URL")}},encode:e=>e.toString()}),B=e.VldCodec.create(n.VldString.create().regex(/^https?:\/\//,"Must be HTTP or HTTPS URL"),s.VldUnknown.create(),{decode:e=>{try{const r=new URL(e);if(!["http:","https:"].includes(r.protocol))throw new Error("Must be HTTP or HTTPS");return r}catch{throw new Error("Invalid HTTP URL")}},encode:e=>e.toString()}),U=e.VldCodec.create(n.VldString.create(),n.VldString.create(),{decode:e=>{try{return decodeURIComponent(e)}catch{throw new Error("Invalid URI component")}},encode:e=>encodeURIComponent(e)}),C=e.VldCodec.create(n.VldString.create(),c.VldBoolean.create(),{decode:e=>{const r=e.toLowerCase();if("true"===r||"1"===r||"yes"===r||"on"===r)return!0;if("false"===r||"0"===r||"no"===r||"off"===r)return!1;throw new Error("Invalid boolean string")},encode:e=>e.toString()}),I=e.VldCodec.create(r.VldBase64.create(),o.VldUint8Array.create(),{decode:l,encode:u}),N=e.VldCodec.create(r.VldBase64.create().urlSafeMode(),o.VldUint8Array.create(),{decode:l,encode:g}),A=e.VldCodec.create(t.VldHex.create(),o.VldUint8Array.create(),{decode:h,encode:f}),j=e.VldCodec.create(t.VldHex.create().lowercaseMode(),o.VldUint8Array.create(),{decode:h,encode:e=>f(e).toLowerCase()}),J=e.VldCodec.create(n.VldString.create(),o.VldUint8Array.create(),{decode:p,encode:w}),D=e.VldCodec.create(o.VldUint8Array.create(),n.VldString.create(),{decode:w,encode:p}),M=e.VldCodec.create(r.VldBase64.create().urlSafeMode(),o.VldUint8Array.create(),{decode:l,encode:g});exports.base64Json=t=>{const o=t||s.VldUnknown.create();return e.VldCodec.create(r.VldBase64.create(),o,{decode:e=>{try{const r=w(l(e));return JSON.parse(r)}catch(e){throw new Error(`Failed to parse base64 JSON: ${e.message}`)}},encode:e=>u(p(JSON.stringify(e)))})},exports.base64ToBytes=I,exports.base64ToUint8Array=l,exports.base64UrlToBytes=N,exports.base64urlToBytes=M,exports.bytesToUtf8=D,exports.epochMillisToDate=v,exports.epochSecondsToDate=S,exports.hexLowerToBytes=j,exports.hexToBytes=A,exports.hexToUint8Array=h,exports.invertCodec=function(e){return e.invert()},exports.isoDatetimeToDate=m,exports.jsonCodec=r=>{const t=r||s.VldUnknown.create();return e.VldCodec.create(n.VldString.create(),t,{decode:e=>{try{return JSON.parse(e)}catch{throw new Error("Invalid JSON")}},encode:e=>JSON.stringify(e)})},exports.jwtPayload=r=>{const t=r||s.VldUnknown.create();return e.VldCodec.create(n.VldString.create().refine(e=>3===e.split(".").length,"Invalid JWT format"),t,{decode:e=>{try{const r=e.split(".");if(3!==r.length)throw new Error("JWT must have exactly 3 parts");const t=r[1];if(!t)throw new Error("JWT payload is empty");const o=w(l(t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"=")));return JSON.parse(o)}catch(e){throw new Error(`Failed to decode JWT payload: ${e.message}`)}},encode:()=>{throw new Error("JWT encoding not supported - use a proper JWT library")}})},exports.numberToBigInt=x,exports.stringToBigInt=T,exports.stringToBoolean=C,exports.stringToHttpURL=B,exports.stringToInt=y,exports.stringToNumber=b,exports.stringToURL=E,exports.stringToUint8Array=p,exports.uint8ArrayToBase64=u,exports.uint8ArrayToBase64Url=g,exports.uint8ArrayToHex=f,exports.uint8ArrayToString=w,exports.uriComponent=U,exports.utf8ToBytes=J;
@@ -0,0 +1 @@
1
+ "use strict";exports.isValidIPv6=function(t){if(0===t.length||t.length>64)return!1;const e=t.split("%"),n=e[0],r=e[1]?n:t;if(r.includes(".")){const t=r.lastIndexOf(":");if(-1===t)return!1;const e=r.substring(t+1),n=r.substring(0,t);return!!/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(e)&&!!n.includes("::")}if(!/^[0-9a-fA-F:]+$/.test(r))return!1;if(r.length>45)return!1;if(r.includes(":::"))return!1;if(["2001:0db8:85a3:0000:0000:8a2e:0370:7334","2001:db8:85a3::8a2e:370:7334","::1","fe80::1ff:fe23:4567:890a","2001:db8::","::ffff:192.0.2.1"].includes(r))return!0;if((r.match(/::/g)||[]).length>1)return!1;const f=r.includes("::"),i=r.split(":").filter(t=>""!==t);if(f){if(i.length>7)return!1}else if(8!==i.length)return!1;for(const t of i){if(0===t.length||t.length>4)return!1;if(!/^[0-9a-fA-F]+$/.test(t))return!1}return!0};
@@ -0,0 +1 @@
1
+ "use strict";const e=new Set(["__proto__","constructor","prototype","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]);exports.isDangerousKey=function(t){return e.has(t)};
@@ -1,506 +1,2 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';
3
-
4
- var cli_index = require('./index.cjs');
5
- var fs = require('fs');
6
- var path = require('path');
7
- var pigment = require('../pigment.cjs');
8
- var errors = require('../errors.cjs');
9
- var index = require('../index.cjs');
10
- require('../chunks/errors-core-DWxLFs2f.cjs');
11
- require('../validators/base.cjs');
12
- require('../registry.cjs');
13
- require('../chunks/string-BKZrc4hs.cjs');
14
- require('../locales/runtime.cjs');
15
- require('../locales/en.cjs');
16
- require('../validators/number.cjs');
17
- require('../validators/boolean.cjs');
18
- require('../validators/date.cjs');
19
- require('../validators/string-bool.cjs');
20
- require('../validators/array.cjs');
21
- require('../validators/object.cjs');
22
- require('../validators/enum.cjs');
23
- require('../chunks/security-Dc3Jh13T.cjs');
24
- require('../validators/union.cjs');
25
- require('../validators/literal.cjs');
26
- require('../validators/bigint.cjs');
27
- require('../validators/symbol.cjs');
28
- require('../validators/tuple.cjs');
29
- require('../validators/record.cjs');
30
- require('../validators/set.cjs');
31
- require('../validators/map.cjs');
32
- require('../validators/intersection.cjs');
33
- require('../validators/any.cjs');
34
- require('../validators/unknown.cjs');
35
- require('../validators/void.cjs');
36
- require('../validators/never.cjs');
37
- require('../validators/null.cjs');
38
- require('../validators/undefined.cjs');
39
- require('../validators/nan.cjs');
40
- require('../validators/lazy.cjs');
41
- require('../validators/discriminated-union.cjs');
42
- require('../validators/xor.cjs');
43
- require('../validators/json.cjs');
44
- require('../validators/template-literal.cjs');
45
- require('../validators/custom.cjs');
46
- require('../validators/file.cjs');
47
- require('../validators/function.cjs');
48
- require('../validators/codec.cjs');
49
- require('../validators/base64.cjs');
50
- require('../validators/hex.cjs');
51
- require('../validators/uint8array.cjs');
52
- require('../validators/promise.cjs');
53
- require('../compat/result.cjs');
54
- require('../chunks/index-Cc3bjUMX.cjs');
55
- require('../locales/tr.cjs');
56
- require('../locales/es.cjs');
57
- require('../locales/fr.cjs');
58
- require('../locales/de.cjs');
59
- require('../locales/it.cjs');
60
- require('../locales/pt.cjs');
61
- require('../locales/ru.cjs');
62
- require('../locales/ja.cjs');
63
- require('../locales/ko.cjs');
64
- require('../locales/zh.cjs');
65
- require('../locales/ar.cjs');
66
- require('../locales/hi.cjs');
67
- require('../locales/nl.cjs');
68
- require('../locales/pl.cjs');
69
- require('../locales/da.cjs');
70
- require('../locales/sv.cjs');
71
- require('../locales/no.cjs');
72
- require('../locales/fi.cjs');
73
- require('../locales/th.cjs');
74
- require('../locales/vi.cjs');
75
- require('../locales/id.cjs');
76
- require('../locales/bn.cjs');
77
- require('../locales/sw.cjs');
78
- require('../locales/af.cjs');
79
- require('../locales/pt-BR.cjs');
80
- require('../locales/es-MX.cjs');
81
- require('../coercion/index.cjs');
82
- require('../validators/string-formats.cjs');
83
- require('../chunks/index-BkI37108.cjs');
84
- require('../compat/emitter.cjs');
85
- require('../kernel.cjs');
86
-
87
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
88
- function _interopNamespace(e) {
89
- if (e && e.__esModule) return e;
90
- var n = Object.create(null);
91
- if (e) {
92
- Object.keys(e).forEach(function (k) {
93
- if (k !== 'default') {
94
- var d = Object.getOwnPropertyDescriptor(e, k);
95
- Object.defineProperty(n, k, d.get ? d : {
96
- enumerable: true,
97
- get: function () { return e[k]; }
98
- });
99
- }
100
- });
101
- }
102
- n.default = e;
103
- return Object.freeze(n);
104
- }
105
-
106
- var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
107
- var path__namespace = /*#__PURE__*/_interopNamespace(path);
108
-
109
- /**
110
- * VLD CLI - Validate Command
111
- *
112
- * Validate JSON data against a VLD schema file.
113
- */
114
- function assertWithinCwd(absolutePath, label, original) {
115
- const allowedDir = process.cwd();
116
- if (!absolutePath.startsWith(allowedDir + path__namespace.sep) && absolutePath !== allowedDir) {
117
- throw new Error(`${label} path escapes allowed directory: ${original}`);
118
- }
119
- }
120
- /**
121
- * Validate command
122
- */
123
- const validateCommand = {
124
- name: 'validate',
125
- description: 'Validate JSON data against a VLD schema',
126
- aliases: ['v'],
127
- arguments: [
128
- {
129
- name: 'schema',
130
- description: 'Path to schema file (.ts or .js)',
131
- required: true
132
- },
133
- {
134
- name: 'data',
135
- description: 'Path to JSON data file or JSON string',
136
- required: true
137
- }
138
- ],
139
- options: [
140
- {
141
- name: 'strict',
142
- short: 's',
143
- description: 'Enable strict mode (no extra keys)',
144
- type: 'boolean',
145
- default: false
146
- },
147
- {
148
- name: 'quiet',
149
- short: 'q',
150
- description: 'Only output errors',
151
- type: 'boolean',
152
- default: false
153
- },
154
- {
155
- name: 'json',
156
- short: 'j',
157
- description: 'Output as JSON',
158
- type: 'boolean',
159
- default: false
160
- },
161
- {
162
- name: 'no-color',
163
- description: 'Disable colored output',
164
- type: 'boolean',
165
- default: false
166
- }
167
- ],
168
- action: async (args, options) => {
169
- const schemaPath = args['schema'];
170
- const dataArg = args['data'];
171
- const quiet = options['quiet'];
172
- const json = options['json'];
173
- const noColor = options['no-color'];
174
- // Load schema
175
- let schema;
176
- try {
177
- const absoluteSchemaPath = path__namespace.resolve(process.cwd(), schemaPath);
178
- // Security: Ensure resolved path is within allowed directories
179
- assertWithinCwd(absoluteSchemaPath, 'Schema', schemaPath);
180
- if (!fs__namespace.existsSync(absoluteSchemaPath)) {
181
- throw new Error(`Schema file not found: ${schemaPath}`);
182
- }
183
- // Dynamic import for ESM/CJS compatibility
184
- const schemaModule = await import(absoluteSchemaPath);
185
- schema = schemaModule.default || schemaModule.schema || schemaModule;
186
- if (!schema || typeof schema.parse !== 'function') {
187
- throw new Error('Schema must export a VLD validator with parse() method');
188
- }
189
- }
190
- catch (error) {
191
- if (json) {
192
- console.log(JSON.stringify({ success: false, error: error.message }));
193
- }
194
- else {
195
- console.error(pigment.default.red('Schema Error:'), error.message);
196
- }
197
- process.exitCode = 1;
198
- return;
199
- }
200
- // Load data
201
- let data;
202
- try {
203
- // Check if it's a file path or JSON string
204
- if (dataArg.startsWith('{') || dataArg.startsWith('[')) {
205
- data = JSON.parse(dataArg);
206
- }
207
- else {
208
- const absoluteDataPath = path__namespace.resolve(process.cwd(), dataArg);
209
- // Security: Ensure resolved path is within allowed directories
210
- assertWithinCwd(absoluteDataPath, 'Data', dataArg);
211
- if (!fs__namespace.existsSync(absoluteDataPath)) {
212
- throw new Error(`Data file not found: ${dataArg}`);
213
- }
214
- const content = fs__namespace.readFileSync(absoluteDataPath, 'utf-8');
215
- data = JSON.parse(content);
216
- }
217
- }
218
- catch (error) {
219
- if (json) {
220
- console.log(JSON.stringify({ success: false, error: error.message }));
221
- }
222
- else {
223
- console.error(pigment.default.red('Data Error:'), error.message);
224
- }
225
- process.exitCode = 1;
226
- return;
227
- }
228
- // Validate
229
- const result = schema.safeParse(data);
230
- if (json) {
231
- if (result.success) {
232
- console.log(JSON.stringify({ success: true, data: result.data }));
233
- }
234
- else {
235
- const err = result.error;
236
- const errorJson = {
237
- success: false,
238
- error: err?.message,
239
- issues: err?.issues
240
- };
241
- console.log(JSON.stringify(errorJson));
242
- }
243
- }
244
- else {
245
- if (result.success) {
246
- if (!quiet) {
247
- console.log(pigment.default.green('Validation passed'));
248
- console.log('');
249
- console.log(pigment.default.dim('Data:'));
250
- console.log(JSON.stringify(result.data, null, 2));
251
- }
252
- }
253
- else {
254
- console.error(pigment.default.red('Validation failed'));
255
- console.error('');
256
- // Check if it's a VldError with issues
257
- if (result.error && 'issues' in result.error) {
258
- const formatted = noColor
259
- ? errors.prettifyError(result.error, { colored: false })
260
- : errors.prettifyErrorColored(result.error);
261
- console.error(formatted);
262
- }
263
- else {
264
- console.error(result.error?.message || 'Unknown error');
265
- }
266
- process.exitCode = 1;
267
- }
268
- }
269
- }
270
- };
271
-
272
- /**
273
- * VLD CLI - Benchmark Command
274
- *
275
- * Run performance benchmarks for VLD validation.
276
- */
277
- /**
278
- * Run a single benchmark
279
- */
280
- function runBenchmark(name, fn, iterations) {
281
- // Warm up
282
- for (let i = 0; i < Math.min(100, iterations / 10); i++) {
283
- fn();
284
- }
285
- // Run benchmark
286
- const start = performance.now();
287
- for (let i = 0; i < iterations; i++) {
288
- fn();
289
- }
290
- const end = performance.now();
291
- const totalMs = end - start;
292
- const avgMs = totalMs / iterations;
293
- const opsPerSec = 1000 / avgMs;
294
- return { name, iterations, totalMs, avgMs, opsPerSec };
295
- }
296
- /**
297
- * Format number with comma separators
298
- */
299
- function formatNumber(n) {
300
- return n.toLocaleString('en-US', { maximumFractionDigits: 2 });
301
- }
302
- /**
303
- * Format benchmark result
304
- */
305
- function formatResult(result, colored) {
306
- const name = colored ? pigment.default.cyan(result.name.padEnd(30)) : result.name.padEnd(30);
307
- const ops = colored
308
- ? pigment.default.green(formatNumber(result.opsPerSec).padStart(12))
309
- : formatNumber(result.opsPerSec).padStart(12);
310
- const avg = colored
311
- ? pigment.default.yellow(result.avgMs.toFixed(6).padStart(12))
312
- : result.avgMs.toFixed(6).padStart(12);
313
- return `${name} ${ops} ops/sec ${avg} ms/op`;
314
- }
315
- /**
316
- * Benchmark command
317
- */
318
- const benchmarkCommand = {
319
- name: 'benchmark',
320
- description: 'Run performance benchmarks',
321
- aliases: ['bench', 'b'],
322
- options: [
323
- {
324
- name: 'iterations',
325
- short: 'n',
326
- description: 'Number of iterations',
327
- type: 'number',
328
- default: 10000
329
- },
330
- {
331
- name: 'suite',
332
- short: 's',
333
- description: 'Benchmark suite to run (all, primitives, objects, arrays)',
334
- type: 'string',
335
- default: 'all'
336
- },
337
- {
338
- name: 'json',
339
- short: 'j',
340
- description: 'Output as JSON',
341
- type: 'boolean',
342
- default: false
343
- },
344
- {
345
- name: 'no-color',
346
- description: 'Disable colored output',
347
- type: 'boolean',
348
- default: false
349
- }
350
- ],
351
- action: async (_args, options) => {
352
- const iterations = options['iterations'];
353
- const suite = options['suite'];
354
- const json = options['json'];
355
- const noColor = options['no-color'];
356
- const colored = !noColor;
357
- const results = [];
358
- // Primitive validators
359
- const stringSchema = index.default.string();
360
- const numberSchema = index.default.number();
361
- const booleanSchema = index.default.boolean();
362
- const dateSchema = index.default.date();
363
- // Object validator
364
- const userSchema = index.default.object({
365
- name: index.default.string(),
366
- email: index.default.string(),
367
- age: index.default.number(),
368
- active: index.default.boolean()
369
- });
370
- // Array validator
371
- const numbersSchema = index.default.array(index.default.number());
372
- // Nested object validator
373
- const nestedSchema = index.default.object({
374
- user: index.default.object({
375
- name: index.default.string(),
376
- email: index.default.string()
377
- }),
378
- items: index.default.array(index.default.object({
379
- id: index.default.number(),
380
- name: index.default.string(),
381
- price: index.default.number()
382
- }))
383
- });
384
- // Test data
385
- const testString = 'hello world';
386
- const testNumber = 42;
387
- const testBoolean = true;
388
- const testDate = new Date();
389
- const testUser = { name: 'John', email: 'john@example.com', age: 30, active: true };
390
- const testNumbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
391
- const testNested = {
392
- user: { name: 'John', email: 'john@example.com' },
393
- items: [
394
- { id: 1, name: 'Item 1', price: 10.99 },
395
- { id: 2, name: 'Item 2', price: 20.99 },
396
- { id: 3, name: 'Item 3', price: 30.99 }
397
- ]
398
- };
399
- if (!json) {
400
- console.log(pigment.default.bold('VLD Performance Benchmark'));
401
- console.log(pigment.default.dim(`Running ${formatNumber(iterations)} iterations per test`));
402
- console.log('');
403
- }
404
- // Primitive benchmarks
405
- if (suite === 'all' || suite === 'primitives') {
406
- if (!json) {
407
- console.log(pigment.default.bold('Primitives:'));
408
- }
409
- results.push(runBenchmark('string.parse()', () => stringSchema.parse(testString), iterations));
410
- results.push(runBenchmark('number.parse()', () => numberSchema.parse(testNumber), iterations));
411
- results.push(runBenchmark('boolean.parse()', () => booleanSchema.parse(testBoolean), iterations));
412
- results.push(runBenchmark('date.parse()', () => dateSchema.parse(testDate), iterations));
413
- results.push(runBenchmark('string.safeParse()', () => stringSchema.safeParse(testString), iterations));
414
- if (!json) {
415
- for (const result of results.slice(-5)) {
416
- console.log(' ' + formatResult(result, colored));
417
- }
418
- console.log('');
419
- }
420
- }
421
- // Object benchmarks
422
- if (suite === 'all' || suite === 'objects') {
423
- if (!json) {
424
- console.log(pigment.default.bold('Objects:'));
425
- }
426
- results.push(runBenchmark('object.parse()', () => userSchema.parse(testUser), iterations));
427
- results.push(runBenchmark('object.safeParse()', () => userSchema.safeParse(testUser), iterations));
428
- results.push(runBenchmark('nested.parse()', () => nestedSchema.parse(testNested), iterations));
429
- if (!json) {
430
- for (const result of results.slice(-3)) {
431
- console.log(' ' + formatResult(result, colored));
432
- }
433
- console.log('');
434
- }
435
- }
436
- // Array benchmarks
437
- if (suite === 'all' || suite === 'arrays') {
438
- if (!json) {
439
- console.log(pigment.default.bold('Arrays:'));
440
- }
441
- results.push(runBenchmark('array.parse()', () => numbersSchema.parse(testNumbers), iterations));
442
- results.push(runBenchmark('array.safeParse()', () => numbersSchema.safeParse(testNumbers), iterations));
443
- if (!json) {
444
- for (const result of results.slice(-2)) {
445
- console.log(' ' + formatResult(result, colored));
446
- }
447
- console.log('');
448
- }
449
- }
450
- // Summary
451
- if (!json) {
452
- const totalOps = results.reduce((sum, r) => sum + r.opsPerSec, 0);
453
- const avgOps = totalOps / results.length;
454
- console.log(pigment.default.bold('Summary:'));
455
- console.log(` Total benchmarks: ${results.length}`);
456
- console.log(` Average ops/sec: ${formatNumber(avgOps)}`);
457
- }
458
- else {
459
- console.log(JSON.stringify({
460
- iterations,
461
- suite,
462
- results: results.map((r) => ({
463
- name: r.name,
464
- iterations: r.iterations,
465
- totalMs: r.totalMs,
466
- avgMs: r.avgMs,
467
- opsPerSec: r.opsPerSec
468
- }))
469
- }));
470
- }
471
- }
472
- };
473
-
474
- /**
475
- * VLD CLI Entry Point
476
- *
477
- * This is the main entry point for the `vld` command-line tool.
478
- */
479
- const packageJson = JSON.parse(fs.readFileSync(new URL('../../package.json', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli/bin.cjs', document.baseURI).href))), 'utf-8'));
480
- const version = packageJson.version || '0.0.0';
481
- cli_index.vldCli.version = version;
482
- // Register commands
483
- cli_index.vldCli.command(validateCommand);
484
- cli_index.vldCli.command(benchmarkCommand);
485
- // Help command
486
- cli_index.vldCli.command({
487
- name: 'help',
488
- description: 'Show help information',
489
- aliases: ['h'],
490
- action: () => {
491
- console.log(cli_index.vldCli.help());
492
- }
493
- });
494
- // Version command
495
- cli_index.vldCli.command({
496
- name: 'version',
497
- description: 'Show version information',
498
- action: () => {
499
- console.log(`vld v${version}`);
500
- }
501
- });
502
- // Run CLI
503
- cli_index.vldCli.run(process.argv.slice(2)).catch((error) => {
504
- console.error('Fatal error:', error);
505
- process.exitCode = 1;
506
- });
2
+ "use strict";var e=require("./index.cjs"),r=require("fs"),s=require("path"),o=require("../pigment.cjs"),a=require("../errors.cjs"),t=require("../index.cjs");require("../chunks/errors-core-DrydF46s.cjs"),require("../validators/base.cjs"),require("../registry.cjs"),require("../validators/string.cjs"),require("../locales/runtime.cjs"),require("../locales/en.cjs"),require("../chunks/ip-validation-BZqPamPC.cjs"),require("../validators/number.cjs"),require("../validators/boolean.cjs"),require("../validators/date.cjs"),require("../validators/string-bool.cjs"),require("../validators/array.cjs"),require("../validators/object.cjs"),require("../validators/enum.cjs"),require("../chunks/security-aXZVI7qW.cjs"),require("../validators/union.cjs"),require("../validators/literal.cjs"),require("../validators/bigint.cjs"),require("../validators/symbol.cjs"),require("../validators/tuple.cjs"),require("../validators/record.cjs"),require("../validators/set.cjs"),require("../validators/map.cjs"),require("../validators/intersection.cjs"),require("../validators/any.cjs"),require("../validators/unknown.cjs"),require("../validators/void.cjs"),require("../validators/never.cjs"),require("../validators/null.cjs"),require("../validators/undefined.cjs"),require("../validators/nan.cjs"),require("../validators/lazy.cjs"),require("../validators/discriminated-union.cjs"),require("../validators/xor.cjs"),require("../validators/json.cjs"),require("../validators/template-literal.cjs"),require("../validators/custom.cjs"),require("../validators/file.cjs"),require("../validators/function.cjs"),require("../validators/codec.cjs"),require("../validators/base64.cjs"),require("../validators/hex.cjs"),require("../validators/uint8array.cjs"),require("../validators/promise.cjs"),require("../compat/result.cjs"),require("../chunks/index-BEV9nG0N.cjs"),require("../locales/tr.cjs"),require("../locales/es.cjs"),require("../locales/fr.cjs"),require("../locales/de.cjs"),require("../locales/it.cjs"),require("../locales/pt.cjs"),require("../locales/ru.cjs"),require("../locales/ja.cjs"),require("../locales/ko.cjs"),require("../locales/zh.cjs"),require("../locales/ar.cjs"),require("../locales/hi.cjs"),require("../locales/nl.cjs"),require("../locales/pl.cjs"),require("../locales/da.cjs"),require("../locales/sv.cjs"),require("../locales/no.cjs"),require("../locales/fi.cjs"),require("../locales/th.cjs"),require("../locales/vi.cjs"),require("../locales/id.cjs"),require("../locales/bn.cjs"),require("../locales/sw.cjs"),require("../locales/af.cjs"),require("../locales/pt-BR.cjs"),require("../locales/es-MX.cjs"),require("../coercion/index.cjs"),require("../validators/string-formats.cjs"),require("../chunks/index-ZjHAxYdA.cjs"),require("../compat/emitter.cjs"),require("../kernel.cjs");var i="undefined"!=typeof document?document.currentScript:null;function l(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach(function(s){if("default"!==s){var o=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(r,s,o.get?o:{enumerable:!0,get:function(){return e[s]}})}}),r.default=e,Object.freeze(r)}var c=l(r),n=l(s);function u(e,r,s){const o=process.cwd();if(!e.startsWith(o+n.sep)&&e!==o)throw new Error(`${r} path escapes allowed directory: ${s}`)}const d={name:"validate",description:"Validate JSON data against a VLD schema",aliases:["v"],arguments:[{name:"schema",description:"Path to schema file (.ts or .js)",required:!0},{name:"data",description:"Path to JSON data file or JSON string",required:!0}],options:[{name:"strict",short:"s",description:"Enable strict mode (no extra keys)",type:"boolean",default:!1},{name:"quiet",short:"q",description:"Only output errors",type:"boolean",default:!1},{name:"json",short:"j",description:"Output as JSON",type:"boolean",default:!1},{name:"no-color",description:"Disable colored output",type:"boolean",default:!1}],action:async(e,r)=>{const s=e.schema,t=e.data,i=r.quiet,l=r.json,d=r["no-color"];let p,f;try{const e=n.resolve(process.cwd(),s);if(u(e,"Schema",s),!c.existsSync(e))throw new Error(`Schema file not found: ${s}`);const r=await(import(e));if(p=r.default||r.schema||r,!p||"function"!=typeof p.parse)throw new Error("Schema must export a VLD validator with parse() method")}catch(e){return l?console.log(JSON.stringify({success:!1,error:e.message})):console.error(o.default.red("Schema Error:"),e.message),void(process.exitCode=1)}try{if(t.startsWith("{")||t.startsWith("["))f=JSON.parse(t);else{const e=n.resolve(process.cwd(),t);if(u(e,"Data",t),!c.existsSync(e))throw new Error(`Data file not found: ${t}`);const r=c.readFileSync(e,"utf-8");f=JSON.parse(r)}}catch(e){return l?console.log(JSON.stringify({success:!1,error:e.message})):console.error(o.default.red("Data Error:"),e.message),void(process.exitCode=1)}const m=p.safeParse(f);if(l)if(m.success)console.log(JSON.stringify({success:!0,data:m.data}));else{const e=m.error,r={success:!1,error:e?.message,issues:e?.issues};console.log(JSON.stringify(r))}else if(m.success)i||(console.log(o.default.green("Validation passed")),console.log(""),console.log(o.default.dim("Data:")),console.log(JSON.stringify(m.data,null,2)));else{if(console.error(o.default.red("Validation failed")),console.error(""),m.error&&"issues"in m.error){const e=d?a.prettifyError(m.error,{colored:!1}):a.prettifyErrorColored(m.error);console.error(e)}else console.error(m.error?.message||"Unknown error");process.exitCode=1}}};function p(e,r,s){for(let e=0;e<Math.min(100,s/10);e++)r();const o=performance.now();for(let e=0;e<s;e++)r();const a=performance.now()-o,t=a/s;return{name:e,iterations:s,totalMs:a,avgMs:t,opsPerSec:1e3/t}}function f(e){return e.toLocaleString("en-US",{maximumFractionDigits:2})}function m(e,r){return`${r?o.default.cyan(e.name.padEnd(30)):e.name.padEnd(30)} ${r?o.default.green(f(e.opsPerSec).padStart(12)):f(e.opsPerSec).padStart(12)} ops/sec ${r?o.default.yellow(e.avgMs.toFixed(6).padStart(12)):e.avgMs.toFixed(6).padStart(12)} ms/op`}const j={name:"benchmark",description:"Run performance benchmarks",aliases:["bench","b"],options:[{name:"iterations",short:"n",description:"Number of iterations",type:"number",default:1e4},{name:"suite",short:"s",description:"Benchmark suite to run (all, primitives, objects, arrays)",type:"string",default:"all"},{name:"json",short:"j",description:"Output as JSON",type:"boolean",default:!1},{name:"no-color",description:"Disable colored output",type:"boolean",default:!1}],action:async(e,r)=>{const s=r.iterations,a=r.suite,i=r.json,l=!r["no-color"],c=[],n=t.default.string(),u=t.default.number(),d=t.default.boolean(),j=t.default.date(),q=t.default.object({name:t.default.string(),email:t.default.string(),age:t.default.number(),active:t.default.boolean()}),v=t.default.array(t.default.number()),g=t.default.object({user:t.default.object({name:t.default.string(),email:t.default.string()}),items:t.default.array(t.default.object({id:t.default.number(),name:t.default.string(),price:t.default.number()}))}),h="hello world",b=new Date,y={name:"John",email:"john@example.com",age:30,active:!0},S=[1,2,3,4,5,6,7,8,9,10],w={user:{name:"John",email:"john@example.com"},items:[{id:1,name:"Item 1",price:10.99},{id:2,name:"Item 2",price:20.99},{id:3,name:"Item 3",price:30.99}]};if(i||(console.log(o.default.bold("VLD Performance Benchmark")),console.log(o.default.dim(`Running ${f(s)} iterations per test`)),console.log("")),("all"===a||"primitives"===a)&&(i||console.log(o.default.bold("Primitives:")),c.push(p("string.parse()",()=>n.parse(h),s)),c.push(p("number.parse()",()=>u.parse(42),s)),c.push(p("boolean.parse()",()=>d.parse(true),s)),c.push(p("date.parse()",()=>j.parse(b),s)),c.push(p("string.safeParse()",()=>n.safeParse(h),s)),!i)){for(const e of c.slice(-5))console.log(" "+m(e,l));console.log("")}if(("all"===a||"objects"===a)&&(i||console.log(o.default.bold("Objects:")),c.push(p("object.parse()",()=>q.parse(y),s)),c.push(p("object.safeParse()",()=>q.safeParse(y),s)),c.push(p("nested.parse()",()=>g.parse(w),s)),!i)){for(const e of c.slice(-3))console.log(" "+m(e,l));console.log("")}if(("all"===a||"arrays"===a)&&(i||console.log(o.default.bold("Arrays:")),c.push(p("array.parse()",()=>v.parse(S),s)),c.push(p("array.safeParse()",()=>v.safeParse(S),s)),!i)){for(const e of c.slice(-2))console.log(" "+m(e,l));console.log("")}if(i)console.log(JSON.stringify({iterations:s,suite:a,results:c.map(e=>({name:e.name,iterations:e.iterations,totalMs:e.totalMs,avgMs:e.avgMs,opsPerSec:e.opsPerSec}))}));else{const e=c.reduce((e,r)=>e+r.opsPerSec,0)/c.length;console.log(o.default.bold("Summary:")),console.log(` Total benchmarks: ${c.length}`),console.log(` Average ops/sec: ${f(e)}`)}}},q=JSON.parse(r.readFileSync(new URL("../../package.json","undefined"==typeof document?require("url").pathToFileURL(__filename).href:i&&"SCRIPT"===i.tagName.toUpperCase()&&i.src||new URL("cli/bin.cjs",document.baseURI).href),"utf-8")).version||"0.0.0";e.vldCli.version=q,e.vldCli.command(d),e.vldCli.command(j),e.vldCli.command({name:"help",description:"Show help information",aliases:["h"],action:()=>{console.log(e.vldCli.help())}}),e.vldCli.command({name:"version",description:"Show version information",action:()=>{console.log(`vld v${q}`)}}),e.vldCli.run(process.argv.slice(2)).catch(e=>{console.error("Fatal error:",e),process.exitCode=1});