diff --git a/packages/next/package.json b/packages/next/package.json index 842f76584ca4f..fc8b1aabde29f 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -151,7 +151,6 @@ "@next/swc": "13.5.5-canary.2", "@opentelemetry/api": "1.4.1", "@playwright/test": "^1.35.1", - "@segment/ajv-human-errors": "2.1.2", "@taskr/clear": "1.1.0", "@taskr/esnext": "1.1.0", "@types/amphtml-validator": "1.0.0", @@ -194,7 +193,6 @@ "@vercel/nft": "0.22.6", "@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231002.1", "acorn": "8.5.0", - "ajv": "8.11.0", "amphtml-validator": "1.0.35", "anser": "1.4.9", "arg": "4.1.0", @@ -314,7 +312,8 @@ "webpack": "5.86.0", "webpack-sources1": "npm:webpack-sources@1.4.3", "webpack-sources3": "npm:webpack-sources@3.2.3", - "ws": "8.2.3" + "ws": "8.2.3", + "zod": "3.22.3" }, "engines": { "node": ">=16.14.0" diff --git a/packages/next/src/compiled/sass-loader/cjs.js b/packages/next/src/compiled/sass-loader/cjs.js index 558d97da1149a..f852edbe570a2 100644 --- a/packages/next/src/compiled/sass-loader/cjs.js +++ b/packages/next/src/compiled/sass-loader/cjs.js @@ -1 +1 @@ -(function(){var __webpack_modules__={12:function(e,t){function set(e,t,s){if(typeof s.value==="object")s.value=klona(s.value);if(!s.enumerable||s.get||s.set||!s.configurable||!s.writable||t==="__proto__"){Object.defineProperty(e,t,s)}else e[t]=s.value}function klona(e){if(typeof e!=="object")return e;var t=0,s,r,n,o=Object.prototype.toString.call(e);if(o==="[object Object]"){n=Object.create(e.__proto__||null)}else if(o==="[object Array]"){n=Array(e.length)}else if(o==="[object Set]"){n=new Set;e.forEach((function(e){n.add(klona(e))}))}else if(o==="[object Map]"){n=new Map;e.forEach((function(e,t){n.set(klona(t),klona(e))}))}else if(o==="[object Date]"){n=new Date(+e)}else if(o==="[object RegExp]"){n=new RegExp(e.source,e.flags)}else if(o==="[object DataView]"){n=new e.constructor(klona(e.buffer))}else if(o==="[object ArrayBuffer]"){n=e.slice(0)}else if(o.slice(-6)==="Array]"){n=new e.constructor(e)}if(n){for(r=Object.getOwnPropertySymbols(e);t{if(e){if(e.file){this.addDependency(r.default.normalize(e.file))}s(new a.default(e));return}let n=t.map?JSON.parse(t.map):null;if(n&&c){n=(0,o.normalizeSourceMap)(n,this.rootContext)}t.stats.includedFiles.forEach((e=>{const t=r.default.normalize(e);if(r.default.isAbsolute(t)){this.addDependency(t)}}));s(null,t.css.toString(),n)}))}var i=loader;t["default"]=i},636:function(__unused_webpack_module,exports,__nccwpck_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getRenderFunctionFromSassImplementation=getRenderFunctionFromSassImplementation;exports.getSassImplementation=getSassImplementation;exports.getSassOptions=getSassOptions;exports.getWebpackImporter=getWebpackImporter;exports.getWebpackResolver=getWebpackResolver;exports.isSupportedFibers=isSupportedFibers;exports.normalizeSourceMap=normalizeSourceMap;var _url=_interopRequireDefault(__nccwpck_require__(310));var _path=_interopRequireDefault(__nccwpck_require__(17));var _full=__nccwpck_require__(12);var _neoAsync=_interopRequireDefault(__nccwpck_require__(175));var _SassWarning=_interopRequireDefault(__nccwpck_require__(955));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function getDefaultSassImplementation(){let sassImplPkg="sass";try{eval("require").resolve("sass")}catch(error){try{eval("require").resolve("node-sass");sassImplPkg="node-sass"}catch(e){sassImplPkg="sass"}}return __nccwpck_require__(438)}function getSassImplementation(e,t){let s=t;if(!s){try{s=getDefaultSassImplementation()}catch(t){e.emitError(t);return}}if(typeof s==="string"){try{s=require(s)}catch(t){e.emitError(t);return}}const{info:r}=s;if(!r){e.emitError(new Error("Unknown Sass implementation."));return}const n=r.split("\t");if(n.length<2){e.emitError(new Error(`Unknown Sass implementation "${r}".`));return}const[o]=n;if(o==="dart-sass"){return s}else if(o==="node-sass"){return s}e.emitError(new Error(`Unknown Sass implementation "${o}".`))}function isProductionLikeMode(e){return e.mode==="production"||!e.mode}function proxyCustomImporters(e,t){return[].concat(e).map((e=>function proxyImporter(...s){const r={...this,webpackLoaderContext:t};return e.apply(r,s)}))}function isSupportedFibers(){const[e]=process.versions.node.split(".");return Number(e)<16}async function getSassOptions(e,t,s,r,n){const o=(0,_full.klona)(t.sassOptions?typeof t.sassOptions==="function"?t.sassOptions(e)||{}:t.sassOptions:{});const a=r.info.includes("dart-sass");if(a&&isSupportedFibers()){const e=!o.fiber&&o.fiber!==false;if(e){let e;try{e=require.resolve("fibers")}catch(e){}if(e){o.fiber=require(e)}}else if(o.fiber===false){delete o.fiber}}else{delete o.fiber}o.file=e.resourcePath;o.data=t.additionalData?typeof t.additionalData==="function"?await t.additionalData(s,e):`${t.additionalData}\n${s}`:s;if(!o.outputStyle&&isProductionLikeMode(e)){o.outputStyle="compressed"}if(n){o.sourceMap=true;o.outFile=_path.default.join(e.rootContext,"style.css.map");o.sourceMapContents=true;o.omitSourceMapUrl=true;o.sourceMapEmbed=false}const{resourcePath:i}=e;const c=_path.default.extname(i);if(c&&c.toLowerCase()===".sass"&&typeof o.indentedSyntax==="undefined"){o.indentedSyntax=true}else{o.indentedSyntax=Boolean(o.indentedSyntax)}o.importer=o.importer?proxyCustomImporters(Array.isArray(o.importer)?o.importer:[o.importer],e):[];o.includePaths=[].concat(process.cwd()).concat((o.includePaths||[]).map((e=>_path.default.isAbsolute(e)?e:_path.default.join(process.cwd(),e)))).concat(process.env.SASS_PATH?process.env.SASS_PATH.split(process.platform==="win32"?";":":"):[]);if(typeof o.charset==="undefined"){o.charset=true}if(!o.logger){const s=t.warnRuleAsWarning===true;const r=e.getLogger("sass-loader");const formatSpan=e=>`${e.url||"-"}:${e.start.line}:${e.start.column}: `;o.logger={debug(e,t){let s="";if(t.span){s=formatSpan(t.span)}s+=e;r.debug(s)},warn(t,n){let o="";if(n.deprecation){o+="Deprecation "}if(n.span&&!n.stack){o=formatSpan(n.span)}o+=t;if(n.stack){o+=`\n\n${n.stack}`}if(s){e.emitWarning(new _SassWarning.default(o,n))}else{r.warn(o)}}}}return o}const MODULE_REQUEST_REGEX=/^[^?]*~/;const IS_MODULE_IMPORT=/^~([^/]+|[^/]+\/|@[^/]+[/][^/]+|@[^/]+\/?|@[^/]+[/][^/]+\/)$/;function getPossibleRequests(e,t=false,s=false){let r=e;if(t){if(MODULE_REQUEST_REGEX.test(e)){r=r.replace(MODULE_REQUEST_REGEX,"")}if(IS_MODULE_IMPORT.test(e)){r=r[r.length-1]==="/"?r:`${r}/`;return[...new Set([r,e])]}}const n=_path.default.extname(r).toLowerCase();if(n===".css"){return[]}const o=_path.default.dirname(r);const a=o==="."?"":`${o}/`;const i=_path.default.basename(r);const c=_path.default.basename(r,n);return[...new Set([].concat(s?[`${a}_${c}.import${n}`,`${a}${c}.import${n}`]:[]).concat([`${a}_${i}`,`${a}${i}`]).concat(t?[e]:[]))]}function promiseResolve(e){return(t,s)=>new Promise(((r,n)=>{e(t,s,((e,t)=>{if(e){n(e)}else{r(t)}}))}))}const IS_SPECIAL_MODULE_IMPORT=/^~[^/]+$/;const IS_NATIVE_WIN32_PATH=/^[a-z]:[/\\]|^\\\\/i;function getWebpackResolver(e,t,s=[]){async function startResolving(e){if(e.length===0){return Promise.reject()}const[{possibleRequests:t}]=e;if(t.length===0){return Promise.reject()}const[{resolve:s,context:r}]=e;try{return await s(r,t[0])}catch(s){const[,...r]=t;if(r.length===0){const[,...t]=e;return startResolving(t)}e[0].possibleRequests=r;return startResolving(e)}}const r=t.info.includes("dart-sass");const n=promiseResolve(e({alias:[],aliasFields:[],conditionNames:[],descriptionFiles:[],extensions:[".sass",".scss",".css"],exportsFields:[],mainFields:[],mainFiles:["_index","index"],modules:[],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));const o=promiseResolve(e({alias:[],aliasFields:[],conditionNames:[],descriptionFiles:[],extensions:[".sass",".scss",".css"],exportsFields:[],mainFields:[],mainFiles:["_index.import","_index","index.import","index"],modules:[],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));const a=promiseResolve(e({dependencyType:"sass",conditionNames:["sass","style"],mainFields:["sass","style","main","..."],mainFiles:["_index","index","..."],extensions:[".sass",".scss",".css"],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));const i=promiseResolve(e({dependencyType:"sass",conditionNames:["sass","style"],mainFields:["sass","style","main","..."],mainFiles:["_index.import","_index","index.import","index","..."],extensions:[".sass",".scss",".css"],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));return(e,t,c)=>{if(!r&&!_path.default.isAbsolute(e)){return Promise.reject()}const l=t;const u=l.slice(0,5).toLowerCase()==="file:";if(u){try{t=_url.default.fileURLToPath(l)}catch(e){t=t.slice(7)}}let p=[];const f=!IS_SPECIAL_MODULE_IMPORT.test(t)&&!u&&!l.startsWith("/")&&!IS_NATIVE_WIN32_PATH.test(l);if(s.length>0&&f){const a=getPossibleRequests(t,false,c);if(!r){p=p.concat({resolve:c?o:n,context:_path.default.dirname(e),possibleRequests:a})}p=p.concat(s.map((e=>({resolve:c?o:n,context:e,possibleRequests:a}))))}const d=getPossibleRequests(t,true,c);p=p.concat({resolve:c?i:a,context:_path.default.dirname(e),possibleRequests:d});return startResolving(p)}}const MATCH_CSS=/\.css$/i;function getWebpackImporter(e,t,s){const r=getWebpackResolver(e.getResolve,t,s);return function importer(t,s,n){const{fromImport:o}=this;r(s,t,o).then((t=>{e.addDependency(_path.default.normalize(t));n({file:t.replace(MATCH_CSS,"")})})).catch((()=>{n({file:t})}))}}let nodeSassJobQueue=null;function getRenderFunctionFromSassImplementation(e){const t=e.info.includes("dart-sass");if(t){return e.render.bind(e)}if(nodeSassJobQueue===null){const t=Number(process.env.UV_THREADPOOL_SIZE||4);nodeSassJobQueue=_neoAsync.default.queue(e.render.bind(e),t-1)}return nodeSassJobQueue.push.bind(nodeSassJobQueue)}const ABSOLUTE_SCHEME=/^[A-Za-z0-9+\-.]+:/;function getURLType(e){if(e[0]==="/"){if(e[1]==="/"){return"scheme-relative"}return"path-absolute"}if(IS_NATIVE_WIN32_PATH.test(e)){return"path-absolute"}return ABSOLUTE_SCHEME.test(e)?"absolute":"path-relative"}function normalizeSourceMap(e,t){const s=e;delete s.file;s.sourceRoot="";s.sources=s.sources.map((e=>{const s=getURLType(e);if(s==="path-relative"){return _path.default.resolve(t,_path.default.normalize(e))}return e}));return s}},175:function(e){"use strict";e.exports=require("next/dist/compiled/neo-async")},17:function(e){"use strict";e.exports=require("path")},438:function(e){"use strict";e.exports=require("sass")},310:function(e){"use strict";e.exports=require("url")},921:function(e){"use strict";e.exports=JSON.parse('{"title":"Sass Loader options","type":"object","properties":{"implementation":{"description":"The implementation of the sass to be used.","link":"https://github.com/webpack-contrib/sass-loader#implementation","anyOf":[{"type":"string"},{"type":"object"}]},"sassOptions":{"description":"Options for `node-sass` or `sass` (`Dart Sass`) implementation.","link":"https://github.com/webpack-contrib/sass-loader#sassoptions","anyOf":[{"type":"object","additionalProperties":true},{"instanceof":"Function"}]},"additionalData":{"description":"Prepends/Appends `Sass`/`SCSS` code before the actual entry file.","link":"https://github.com/webpack-contrib/sass-loader#additionaldata","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"sourceMap":{"description":"Enables/Disables generation of source maps.","link":"https://github.com/webpack-contrib/sass-loader#sourcemap","type":"boolean"},"webpackImporter":{"description":"Enables/Disables default `webpack` importer.","link":"https://github.com/webpack-contrib/sass-loader#webpackimporter","type":"boolean"},"warnRuleAsWarning":{"description":"Treats the \'@warn\' rule as a webpack warning.","link":"https://github.com/webpack-contrib/sass-loader#warnruleaswarning","type":"boolean"}},"additionalProperties":false}')}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var s=__webpack_module_cache__[e]={exports:{}};var r=true;try{__webpack_modules__[e](s,s.exports,__nccwpck_require__);r=false}finally{if(r)delete __webpack_module_cache__[e]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__=__nccwpck_require__(601);module.exports=__webpack_exports__})(); \ No newline at end of file +(function(){var __webpack_modules__={12:function(e,t){function set(e,t,s){if(typeof s.value==="object")s.value=klona(s.value);if(!s.enumerable||s.get||s.set||!s.configurable||!s.writable||t==="__proto__"){Object.defineProperty(e,t,s)}else e[t]=s.value}function klona(e){if(typeof e!=="object")return e;var t=0,s,r,n,o=Object.prototype.toString.call(e);if(o==="[object Object]"){n=Object.create(e.__proto__||null)}else if(o==="[object Array]"){n=Array(e.length)}else if(o==="[object Set]"){n=new Set;e.forEach((function(e){n.add(klona(e))}))}else if(o==="[object Map]"){n=new Map;e.forEach((function(e,t){n.set(klona(t),klona(e))}))}else if(o==="[object Date]"){n=new Date(+e)}else if(o==="[object RegExp]"){n=new RegExp(e.source,e.flags)}else if(o==="[object DataView]"){n=new e.constructor(klona(e.buffer))}else if(o==="[object ArrayBuffer]"){n=e.slice(0)}else if(o.slice(-6)==="Array]"){n=new e.constructor(e)}if(n){for(r=Object.getOwnPropertySymbols(e);t{if(e){if(e.file){this.addDependency(r.default.normalize(e.file))}s(new a.default(e));return}let n=t.map?JSON.parse(t.map):null;if(n&&c){n=(0,o.normalizeSourceMap)(n,this.rootContext)}t.stats.includedFiles.forEach((e=>{const t=r.default.normalize(e);if(r.default.isAbsolute(t)){this.addDependency(t)}}));s(null,t.css.toString(),n)}))}var i=loader;t["default"]=i},125:function(__unused_webpack_module,exports,__nccwpck_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getRenderFunctionFromSassImplementation=getRenderFunctionFromSassImplementation;exports.getSassImplementation=getSassImplementation;exports.getSassOptions=getSassOptions;exports.getWebpackImporter=getWebpackImporter;exports.getWebpackResolver=getWebpackResolver;exports.isSupportedFibers=isSupportedFibers;exports.normalizeSourceMap=normalizeSourceMap;var _url=_interopRequireDefault(__nccwpck_require__(310));var _path=_interopRequireDefault(__nccwpck_require__(17));var _full=__nccwpck_require__(12);var _neoAsync=_interopRequireDefault(__nccwpck_require__(175));var _SassWarning=_interopRequireDefault(__nccwpck_require__(186));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function getDefaultSassImplementation(){let sassImplPkg="sass";try{eval("require").resolve("sass")}catch(error){try{eval("require").resolve("node-sass");sassImplPkg="node-sass"}catch(e){sassImplPkg="sass"}}return __nccwpck_require__(438)}function getSassImplementation(e,t){let s=t;if(!s){try{s=getDefaultSassImplementation()}catch(t){e.emitError(t);return}}if(typeof s==="string"){try{s=require(s)}catch(t){e.emitError(t);return}}const{info:r}=s;if(!r){e.emitError(new Error("Unknown Sass implementation."));return}const n=r.split("\t");if(n.length<2){e.emitError(new Error(`Unknown Sass implementation "${r}".`));return}const[o]=n;if(o==="dart-sass"){return s}else if(o==="node-sass"){return s}e.emitError(new Error(`Unknown Sass implementation "${o}".`))}function isProductionLikeMode(e){return e.mode==="production"||!e.mode}function proxyCustomImporters(e,t){return[].concat(e).map((e=>function proxyImporter(...s){const r={...this,webpackLoaderContext:t};return e.apply(r,s)}))}function isSupportedFibers(){const[e]=process.versions.node.split(".");return Number(e)<16}async function getSassOptions(e,t,s,r,n){const o=(0,_full.klona)(t.sassOptions?typeof t.sassOptions==="function"?t.sassOptions(e)||{}:t.sassOptions:{});const a=r.info.includes("dart-sass");if(a&&isSupportedFibers()){const e=!o.fiber&&o.fiber!==false;if(e){let e;try{e=require.resolve("fibers")}catch(e){}if(e){o.fiber=require(e)}}else if(o.fiber===false){delete o.fiber}}else{delete o.fiber}o.file=e.resourcePath;o.data=t.additionalData?typeof t.additionalData==="function"?await t.additionalData(s,e):`${t.additionalData}\n${s}`:s;if(!o.outputStyle&&isProductionLikeMode(e)){o.outputStyle="compressed"}if(n){o.sourceMap=true;o.outFile=_path.default.join(e.rootContext,"style.css.map");o.sourceMapContents=true;o.omitSourceMapUrl=true;o.sourceMapEmbed=false}const{resourcePath:i}=e;const c=_path.default.extname(i);if(c&&c.toLowerCase()===".sass"&&typeof o.indentedSyntax==="undefined"){o.indentedSyntax=true}else{o.indentedSyntax=Boolean(o.indentedSyntax)}o.importer=o.importer?proxyCustomImporters(Array.isArray(o.importer)?o.importer:[o.importer],e):[];o.includePaths=[].concat(process.cwd()).concat((o.includePaths||[]).map((e=>_path.default.isAbsolute(e)?e:_path.default.join(process.cwd(),e)))).concat(process.env.SASS_PATH?process.env.SASS_PATH.split(process.platform==="win32"?";":":"):[]);if(typeof o.charset==="undefined"){o.charset=true}if(!o.logger){const s=t.warnRuleAsWarning===true;const r=e.getLogger("sass-loader");const formatSpan=e=>`${e.url||"-"}:${e.start.line}:${e.start.column}: `;o.logger={debug(e,t){let s="";if(t.span){s=formatSpan(t.span)}s+=e;r.debug(s)},warn(t,n){let o="";if(n.deprecation){o+="Deprecation "}if(n.span&&!n.stack){o=formatSpan(n.span)}o+=t;if(n.stack){o+=`\n\n${n.stack}`}if(s){e.emitWarning(new _SassWarning.default(o,n))}else{r.warn(o)}}}}return o}const MODULE_REQUEST_REGEX=/^[^?]*~/;const IS_MODULE_IMPORT=/^~([^/]+|[^/]+\/|@[^/]+[/][^/]+|@[^/]+\/?|@[^/]+[/][^/]+\/)$/;function getPossibleRequests(e,t=false,s=false){let r=e;if(t){if(MODULE_REQUEST_REGEX.test(e)){r=r.replace(MODULE_REQUEST_REGEX,"")}if(IS_MODULE_IMPORT.test(e)){r=r[r.length-1]==="/"?r:`${r}/`;return[...new Set([r,e])]}}const n=_path.default.extname(r).toLowerCase();if(n===".css"){return[]}const o=_path.default.dirname(r);const a=o==="."?"":`${o}/`;const i=_path.default.basename(r);const c=_path.default.basename(r,n);return[...new Set([].concat(s?[`${a}_${c}.import${n}`,`${a}${c}.import${n}`]:[]).concat([`${a}_${i}`,`${a}${i}`]).concat(t?[e]:[]))]}function promiseResolve(e){return(t,s)=>new Promise(((r,n)=>{e(t,s,((e,t)=>{if(e){n(e)}else{r(t)}}))}))}const IS_SPECIAL_MODULE_IMPORT=/^~[^/]+$/;const IS_NATIVE_WIN32_PATH=/^[a-z]:[/\\]|^\\\\/i;function getWebpackResolver(e,t,s=[]){async function startResolving(e){if(e.length===0){return Promise.reject()}const[{possibleRequests:t}]=e;if(t.length===0){return Promise.reject()}const[{resolve:s,context:r}]=e;try{return await s(r,t[0])}catch(s){const[,...r]=t;if(r.length===0){const[,...t]=e;return startResolving(t)}e[0].possibleRequests=r;return startResolving(e)}}const r=t.info.includes("dart-sass");const n=promiseResolve(e({alias:[],aliasFields:[],conditionNames:[],descriptionFiles:[],extensions:[".sass",".scss",".css"],exportsFields:[],mainFields:[],mainFiles:["_index","index"],modules:[],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));const o=promiseResolve(e({alias:[],aliasFields:[],conditionNames:[],descriptionFiles:[],extensions:[".sass",".scss",".css"],exportsFields:[],mainFields:[],mainFiles:["_index.import","_index","index.import","index"],modules:[],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));const a=promiseResolve(e({dependencyType:"sass",conditionNames:["sass","style"],mainFields:["sass","style","main","..."],mainFiles:["_index","index","..."],extensions:[".sass",".scss",".css"],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));const i=promiseResolve(e({dependencyType:"sass",conditionNames:["sass","style"],mainFields:["sass","style","main","..."],mainFiles:["_index.import","_index","index.import","index","..."],extensions:[".sass",".scss",".css"],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));return(e,t,c)=>{if(!r&&!_path.default.isAbsolute(e)){return Promise.reject()}const l=t;const u=l.slice(0,5).toLowerCase()==="file:";if(u){try{t=_url.default.fileURLToPath(l)}catch(e){t=t.slice(7)}}let p=[];const f=!IS_SPECIAL_MODULE_IMPORT.test(t)&&!u&&!l.startsWith("/")&&!IS_NATIVE_WIN32_PATH.test(l);if(s.length>0&&f){const a=getPossibleRequests(t,false,c);if(!r){p=p.concat({resolve:c?o:n,context:_path.default.dirname(e),possibleRequests:a})}p=p.concat(s.map((e=>({resolve:c?o:n,context:e,possibleRequests:a}))))}const d=getPossibleRequests(t,true,c);p=p.concat({resolve:c?i:a,context:_path.default.dirname(e),possibleRequests:d});return startResolving(p)}}const MATCH_CSS=/\.css$/i;function getWebpackImporter(e,t,s){const r=getWebpackResolver(e.getResolve,t,s);return function importer(t,s,n){const{fromImport:o}=this;r(s,t,o).then((t=>{e.addDependency(_path.default.normalize(t));n({file:t.replace(MATCH_CSS,"")})})).catch((()=>{n({file:t})}))}}let nodeSassJobQueue=null;function getRenderFunctionFromSassImplementation(e){const t=e.info.includes("dart-sass");if(t){return e.render.bind(e)}if(nodeSassJobQueue===null){const t=Number(process.env.UV_THREADPOOL_SIZE||4);nodeSassJobQueue=_neoAsync.default.queue(e.render.bind(e),t-1)}return nodeSassJobQueue.push.bind(nodeSassJobQueue)}const ABSOLUTE_SCHEME=/^[A-Za-z0-9+\-.]+:/;function getURLType(e){if(e[0]==="/"){if(e[1]==="/"){return"scheme-relative"}return"path-absolute"}if(IS_NATIVE_WIN32_PATH.test(e)){return"path-absolute"}return ABSOLUTE_SCHEME.test(e)?"absolute":"path-relative"}function normalizeSourceMap(e,t){const s=e;delete s.file;s.sourceRoot="";s.sources=s.sources.map((e=>{const s=getURLType(e);if(s==="path-relative"){return _path.default.resolve(t,_path.default.normalize(e))}return e}));return s}},175:function(e){"use strict";e.exports=require("next/dist/compiled/neo-async")},17:function(e){"use strict";e.exports=require("path")},438:function(e){"use strict";e.exports=require("sass")},310:function(e){"use strict";e.exports=require("url")},596:function(e){"use strict";e.exports=JSON.parse('{"title":"Sass Loader options","type":"object","properties":{"implementation":{"description":"The implementation of the sass to be used.","link":"https://github.com/webpack-contrib/sass-loader#implementation","anyOf":[{"type":"string"},{"type":"object"}]},"sassOptions":{"description":"Options for `node-sass` or `sass` (`Dart Sass`) implementation.","link":"https://github.com/webpack-contrib/sass-loader#sassoptions","anyOf":[{"type":"object","additionalProperties":true},{"instanceof":"Function"}]},"additionalData":{"description":"Prepends/Appends `Sass`/`SCSS` code before the actual entry file.","link":"https://github.com/webpack-contrib/sass-loader#additionaldata","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"sourceMap":{"description":"Enables/Disables generation of source maps.","link":"https://github.com/webpack-contrib/sass-loader#sourcemap","type":"boolean"},"webpackImporter":{"description":"Enables/Disables default `webpack` importer.","link":"https://github.com/webpack-contrib/sass-loader#webpackimporter","type":"boolean"},"warnRuleAsWarning":{"description":"Treats the \'@warn\' rule as a webpack warning.","link":"https://github.com/webpack-contrib/sass-loader#warnruleaswarning","type":"boolean"}},"additionalProperties":false}')}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var s=__webpack_module_cache__[e]={exports:{}};var r=true;try{__webpack_modules__[e](s,s.exports,__nccwpck_require__);r=false}finally{if(r)delete __webpack_module_cache__[e]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__=__nccwpck_require__(917);module.exports=__webpack_exports__})(); \ No newline at end of file diff --git a/packages/next/src/compiled/zod/LICENSE b/packages/next/src/compiled/zod/LICENSE new file mode 100644 index 0000000000000..2c93bb52b9339 --- /dev/null +++ b/packages/next/src/compiled/zod/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Colin McDonnell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/next/src/compiled/zod/index.js b/packages/next/src/compiled/zod/index.js new file mode 100644 index 0000000000000..daacf47c5dbb3 --- /dev/null +++ b/packages/next/src/compiled/zod/index.js @@ -0,0 +1 @@ +(()=>{"use strict";var e={815:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:true});t.ZodError=t.quotelessJson=t.ZodIssueCode=void 0;const r=s(900);t.ZodIssueCode=r.util.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);const quotelessJson=e=>{const t=JSON.stringify(e,null,2);return t.replace(/"([^"]+)":/g,"$1:")};t.quotelessJson=quotelessJson;class ZodError extends Error{constructor(e){super();this.issues=[];this.addIssue=e=>{this.issues=[...this.issues,e]};this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;if(Object.setPrototypeOf){Object.setPrototypeOf(this,t)}else{this.__proto__=t}this.name="ZodError";this.issues=e}get errors(){return this.issues}format(e){const t=e||function(e){return e.message};const s={_errors:[]};const processError=e=>{for(const r of e.issues){if(r.code==="invalid_union"){r.unionErrors.map(processError)}else if(r.code==="invalid_return_type"){processError(r.returnTypeError)}else if(r.code==="invalid_arguments"){processError(r.argumentsError)}else if(r.path.length===0){s._errors.push(t(r))}else{let e=s;let a=0;while(ae.message)){const t={};const s=[];for(const r of this.issues){if(r.path.length>0){t[r.path[0]]=t[r.path[0]]||[];t[r.path[0]].push(e(r))}else{s.push(e(r))}}return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}t.ZodError=ZodError;ZodError.create=e=>{const t=new ZodError(e);return t}},564:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.getErrorMap=t.setErrorMap=t.defaultErrorMap=void 0;const a=r(s(209));t.defaultErrorMap=a.default;let n=a.default;function setErrorMap(e){n=e}t.setErrorMap=setErrorMap;function getErrorMap(){return n}t.getErrorMap=getErrorMap},631:function(e,t,s){var r=this&&this.__createBinding||(Object.create?function(e,t,s,r){if(r===undefined)r=s;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[s]}})}:function(e,t,s,r){if(r===undefined)r=s;e[r]=t[s]});var a=this&&this.__exportStar||function(e,t){for(var s in e)if(s!=="default"&&!Object.prototype.hasOwnProperty.call(t,s))r(t,e,s)};Object.defineProperty(t,"__esModule",{value:true});a(s(564),t);a(s(79),t);a(s(212),t);a(s(900),t);a(s(973),t);a(s(815),t)},97:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.errorUtil=void 0;var s;(function(e){e.errToObj=e=>typeof e==="string"?{message:e}:e||{};e.toString=e=>typeof e==="string"?e:e===null||e===void 0?void 0:e.message})(s=t.errorUtil||(t.errorUtil={}))},79:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.isAsync=t.isValid=t.isDirty=t.isAborted=t.OK=t.DIRTY=t.INVALID=t.ParseStatus=t.addIssueToContext=t.EMPTY_PATH=t.makeIssue=void 0;const a=s(564);const n=r(s(209));const makeIssue=e=>{const{data:t,path:s,errorMaps:r,issueData:a}=e;const n=[...s,...a.path||[]];const o={...a,path:n};let i="";const d=r.filter((e=>!!e)).slice().reverse();for(const e of d){i=e(o,{data:t,defaultError:i}).message}return{...a,path:n,message:a.message||i}};t.makeIssue=makeIssue;t.EMPTY_PATH=[];function addIssueToContext(e,s){const r=(0,t.makeIssue)({issueData:s,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,(0,a.getErrorMap)(),n.default].filter((e=>!!e))});e.common.issues.push(r)}t.addIssueToContext=addIssueToContext;class ParseStatus{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(e,s){const r=[];for(const a of s){if(a.status==="aborted")return t.INVALID;if(a.status==="dirty")e.dirty();r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const s=[];for(const e of t){s.push({key:await e.key,value:await e.value})}return ParseStatus.mergeObjectSync(e,s)}static mergeObjectSync(e,s){const r={};for(const a of s){const{key:s,value:n}=a;if(s.status==="aborted")return t.INVALID;if(n.status==="aborted")return t.INVALID;if(s.status==="dirty")e.dirty();if(n.status==="dirty")e.dirty();if(s.value!=="__proto__"&&(typeof n.value!=="undefined"||a.alwaysSet)){r[s.value]=n.value}}return{status:e.value,value:r}}}t.ParseStatus=ParseStatus;t.INVALID=Object.freeze({status:"aborted"});const DIRTY=e=>({status:"dirty",value:e});t.DIRTY=DIRTY;const OK=e=>({status:"valid",value:e});t.OK=OK;const isAborted=e=>e.status==="aborted";t.isAborted=isAborted;const isDirty=e=>e.status==="dirty";t.isDirty=isDirty;const isValid=e=>e.status==="valid";t.isValid=isValid;const isAsync=e=>typeof Promise!=="undefined"&&e instanceof Promise;t.isAsync=isAsync},212:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true})},900:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.getParsedType=t.ZodParsedType=t.objectUtil=t.util=void 0;var s;(function(e){e.assertEqual=e=>e;function assertIs(e){}e.assertIs=assertIs;function assertNever(e){throw new Error}e.assertNever=assertNever;e.arrayToEnum=e=>{const t={};for(const s of e){t[s]=s}return t};e.getValidEnumValues=t=>{const s=e.objectKeys(t).filter((e=>typeof t[t[e]]!=="number"));const r={};for(const e of s){r[e]=t[e]}return e.objectValues(r)};e.objectValues=t=>e.objectKeys(t).map((function(e){return t[e]}));e.objectKeys=typeof Object.keys==="function"?e=>Object.keys(e):e=>{const t=[];for(const s in e){if(Object.prototype.hasOwnProperty.call(e,s)){t.push(s)}}return t};e.find=(e,t)=>{for(const s of e){if(t(s))return s}return undefined};e.isInteger=typeof Number.isInteger==="function"?e=>Number.isInteger(e):e=>typeof e==="number"&&isFinite(e)&&Math.floor(e)===e;function joinValues(e,t=" | "){return e.map((e=>typeof e==="string"?`'${e}'`:e)).join(t)}e.joinValues=joinValues;e.jsonStringifyReplacer=(e,t)=>{if(typeof t==="bigint"){return t.toString()}return t}})(s=t.util||(t.util={}));var r;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(r=t.objectUtil||(t.objectUtil={}));t.ZodParsedType=s.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);const getParsedType=e=>{const s=typeof e;switch(s){case"undefined":return t.ZodParsedType.undefined;case"string":return t.ZodParsedType.string;case"number":return isNaN(e)?t.ZodParsedType.nan:t.ZodParsedType.number;case"boolean":return t.ZodParsedType.boolean;case"function":return t.ZodParsedType.function;case"bigint":return t.ZodParsedType.bigint;case"symbol":return t.ZodParsedType.symbol;case"object":if(Array.isArray(e)){return t.ZodParsedType.array}if(e===null){return t.ZodParsedType.null}if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function"){return t.ZodParsedType.promise}if(typeof Map!=="undefined"&&e instanceof Map){return t.ZodParsedType.map}if(typeof Set!=="undefined"&&e instanceof Set){return t.ZodParsedType.set}if(typeof Date!=="undefined"&&e instanceof Date){return t.ZodParsedType.date}return t.ZodParsedType.object;default:return t.ZodParsedType.unknown}};t.getParsedType=getParsedType},773:function(e,t,s){var r=this&&this.__createBinding||(Object.create?function(e,t,s,r){if(r===undefined)r=s;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[s]}})}:function(e,t,s,r){if(r===undefined)r=s;e[r]=t[s]});var a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var s in e)if(s!=="default"&&Object.prototype.hasOwnProperty.call(e,s))r(t,e,s);a(t,e);return t};var o=this&&this.__exportStar||function(e,t){for(var s in e)if(s!=="default"&&!Object.prototype.hasOwnProperty.call(t,s))r(t,e,s)};Object.defineProperty(t,"__esModule",{value:true});t.z=void 0;const i=n(s(631));t.z=i;o(s(631),t);t["default"]=i},209:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:true});const r=s(900);const a=s(815);const errorMap=(e,t)=>{let s;switch(e.code){case a.ZodIssueCode.invalid_type:if(e.received===r.ZodParsedType.undefined){s="Required"}else{s=`Expected ${e.expected}, received ${e.received}`}break;case a.ZodIssueCode.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(e.expected,r.util.jsonStringifyReplacer)}`;break;case a.ZodIssueCode.unrecognized_keys:s=`Unrecognized key(s) in object: ${r.util.joinValues(e.keys,", ")}`;break;case a.ZodIssueCode.invalid_union:s=`Invalid input`;break;case a.ZodIssueCode.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${r.util.joinValues(e.options)}`;break;case a.ZodIssueCode.invalid_enum_value:s=`Invalid enum value. Expected ${r.util.joinValues(e.options)}, received '${e.received}'`;break;case a.ZodIssueCode.invalid_arguments:s=`Invalid function arguments`;break;case a.ZodIssueCode.invalid_return_type:s=`Invalid function return type`;break;case a.ZodIssueCode.invalid_date:s=`Invalid date`;break;case a.ZodIssueCode.invalid_string:if(typeof e.validation==="object"){if("includes"in e.validation){s=`Invalid input: must include "${e.validation.includes}"`;if(typeof e.validation.position==="number"){s=`${s} at one or more positions greater than or equal to ${e.validation.position}`}}else if("startsWith"in e.validation){s=`Invalid input: must start with "${e.validation.startsWith}"`}else if("endsWith"in e.validation){s=`Invalid input: must end with "${e.validation.endsWith}"`}else{r.util.assertNever(e.validation)}}else if(e.validation!=="regex"){s=`Invalid ${e.validation}`}else{s="Invalid"}break;case a.ZodIssueCode.too_small:if(e.type==="array")s=`Array must contain ${e.exact?"exactly":e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`;else if(e.type==="string")s=`String must contain ${e.exact?"exactly":e.inclusive?`at least`:`over`} ${e.minimum} character(s)`;else if(e.type==="number")s=`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`;else if(e.type==="date")s=`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`;else s="Invalid input";break;case a.ZodIssueCode.too_big:if(e.type==="array")s=`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`;else if(e.type==="string")s=`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`;else if(e.type==="number")s=`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`;else if(e.type==="bigint")s=`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`;else if(e.type==="date")s=`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`;else s="Invalid input";break;case a.ZodIssueCode.custom:s=`Invalid input`;break;case a.ZodIssueCode.invalid_intersection_types:s=`Intersection results could not be merged`;break;case a.ZodIssueCode.not_multiple_of:s=`Number must be a multiple of ${e.multipleOf}`;break;case a.ZodIssueCode.not_finite:s="Number must be finite";break;default:s=t.defaultError;r.util.assertNever(e)}return{message:s}};t["default"]=errorMap},973:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:true});t.date=t.boolean=t.bigint=t.array=t.any=t.coerce=t.ZodFirstPartyTypeKind=t.late=t.ZodSchema=t.Schema=t.custom=t.ZodReadonly=t.ZodPipeline=t.ZodBranded=t.BRAND=t.ZodNaN=t.ZodCatch=t.ZodDefault=t.ZodNullable=t.ZodOptional=t.ZodTransformer=t.ZodEffects=t.ZodPromise=t.ZodNativeEnum=t.ZodEnum=t.ZodLiteral=t.ZodLazy=t.ZodFunction=t.ZodSet=t.ZodMap=t.ZodRecord=t.ZodTuple=t.ZodIntersection=t.ZodDiscriminatedUnion=t.ZodUnion=t.ZodObject=t.ZodArray=t.ZodVoid=t.ZodNever=t.ZodUnknown=t.ZodAny=t.ZodNull=t.ZodUndefined=t.ZodSymbol=t.ZodDate=t.ZodBoolean=t.ZodBigInt=t.ZodNumber=t.ZodString=t.ZodType=void 0;t.NEVER=t["void"]=t.unknown=t.union=t.undefined=t.tuple=t.transformer=t.symbol=t.string=t.strictObject=t.set=t.record=t.promise=t.preprocess=t.pipeline=t.ostring=t.optional=t.onumber=t.oboolean=t.object=t.number=t.nullable=t["null"]=t.never=t.nativeEnum=t.nan=t.map=t.literal=t.lazy=t.intersection=t["instanceof"]=t["function"]=t["enum"]=t.effect=t.discriminatedUnion=void 0;const r=s(564);const a=s(97);const n=s(79);const o=s(900);const i=s(815);class ParseInputLazyPath{constructor(e,t,s,r){this._cachedPath=[];this.parent=e;this.data=t;this._path=s;this._key=r}get path(){if(!this._cachedPath.length){if(this._key instanceof Array){this._cachedPath.push(...this._path,...this._key)}else{this._cachedPath.push(...this._path,this._key)}}return this._cachedPath}}const handleResult=(e,t)=>{if((0,n.isValid)(t)){return{success:true,data:t.value}}else{if(!e.common.issues.length){throw new Error("Validation failed but no issues detected.")}return{success:false,get error(){if(this._error)return this._error;const t=new i.ZodError(e.common.issues);this._error=t;return this._error}}}};function processCreateParams(e){if(!e)return{};const{errorMap:t,invalid_type_error:s,required_error:r,description:a}=e;if(t&&(s||r)){throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`)}if(t)return{errorMap:t,description:a};const customMap=(e,t)=>{if(e.code!=="invalid_type")return{message:t.defaultError};if(typeof t.data==="undefined"){return{message:r!==null&&r!==void 0?r:t.defaultError}}return{message:s!==null&&s!==void 0?s:t.defaultError}};return{errorMap:customMap,description:a}}class ZodType{constructor(e){this.spa=this.safeParseAsync;this._def=e;this.parse=this.parse.bind(this);this.safeParse=this.safeParse.bind(this);this.parseAsync=this.parseAsync.bind(this);this.safeParseAsync=this.safeParseAsync.bind(this);this.spa=this.spa.bind(this);this.refine=this.refine.bind(this);this.refinement=this.refinement.bind(this);this.superRefine=this.superRefine.bind(this);this.optional=this.optional.bind(this);this.nullable=this.nullable.bind(this);this.nullish=this.nullish.bind(this);this.array=this.array.bind(this);this.promise=this.promise.bind(this);this.or=this.or.bind(this);this.and=this.and.bind(this);this.transform=this.transform.bind(this);this.brand=this.brand.bind(this);this.default=this.default.bind(this);this.catch=this.catch.bind(this);this.describe=this.describe.bind(this);this.pipe=this.pipe.bind(this);this.readonly=this.readonly.bind(this);this.isNullable=this.isNullable.bind(this);this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return(0,o.getParsedType)(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:(0,o.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new n.ParseStatus,ctx:{common:e.parent.common,data:e.data,parsedType:(0,o.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if((0,n.isAsync)(t)){throw new Error("Synchronous parse encountered promise.")}return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const r={common:{issues:[],async:(s=t===null||t===void 0?void 0:t.async)!==null&&s!==void 0?s:false,contextualErrorMap:t===null||t===void 0?void 0:t.errorMap},path:(t===null||t===void 0?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,o.getParsedType)(e)};const a=this._parseSync({data:e,path:r.path,parent:r});return handleResult(r,a)}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t===null||t===void 0?void 0:t.errorMap,async:true},path:(t===null||t===void 0?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,o.getParsedType)(e)};const r=this._parse({data:e,path:s.path,parent:s});const a=await((0,n.isAsync)(r)?r:Promise.resolve(r));return handleResult(s,a)}refine(e,t){const getIssueProperties=e=>{if(typeof t==="string"||typeof t==="undefined"){return{message:t}}else if(typeof t==="function"){return t(e)}else{return t}};return this._refinement(((t,s)=>{const r=e(t);const setError=()=>s.addIssue({code:i.ZodIssueCode.custom,...getIssueProperties(t)});if(typeof Promise!=="undefined"&&r instanceof Promise){return r.then((e=>{if(!e){setError();return false}else{return true}}))}if(!r){setError();return false}else{return true}}))}refinement(e,t){return this._refinement(((s,r)=>{if(!e(s)){r.addIssue(typeof t==="function"?t(s,r):t);return false}else{return true}}))}_refinement(e){return new ZodEffects({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ZodOptional.create(this,this._def)}nullable(){return ZodNullable.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ZodArray.create(this,this._def)}promise(){return ZodPromise.create(this,this._def)}or(e){return ZodUnion.create([this,e],this._def)}and(e){return ZodIntersection.create(this,e,this._def)}transform(e){return new ZodEffects({...processCreateParams(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e==="function"?e:()=>e;return new ZodDefault({...processCreateParams(this._def),innerType:this,defaultValue:t,typeName:y.ZodDefault})}brand(){return new ZodBranded({typeName:y.ZodBranded,type:this,...processCreateParams(this._def)})}catch(e){const t=typeof e==="function"?e:()=>e;return new ZodCatch({...processCreateParams(this._def),innerType:this,catchValue:t,typeName:y.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ZodPipeline.create(this,e)}readonly(){return ZodReadonly.create(this)}isOptional(){return this.safeParse(undefined).success}isNullable(){return this.safeParse(null).success}}t.ZodType=ZodType;t.Schema=ZodType;t.ZodSchema=ZodType;const d=/^c[^\s-]{8,}$/i;const u=/^[a-z][a-z0-9]*$/;const c=/[0-9A-HJKMNP-TV-Z]{26}/;const l=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;const p=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;const f=/^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u;const h=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/;const m=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;const datetimeRegex=e=>{if(e.precision){if(e.offset){return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${e.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`)}else{return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${e.precision}}Z$`)}}else if(e.precision===0){if(e.offset){return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`)}else{return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`)}}else{if(e.offset){return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`)}else{return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`)}}};function isValidIP(e,t){if((t==="v4"||!t)&&h.test(e)){return true}if((t==="v6"||!t)&&m.test(e)){return true}return false}class ZodString extends ZodType{constructor(){super(...arguments);this._regex=(e,t,s)=>this.refinement((t=>e.test(t)),{validation:t,code:i.ZodIssueCode.invalid_string,...a.errorUtil.errToObj(s)});this.nonempty=e=>this.min(1,a.errorUtil.errToObj(e));this.trim=()=>new ZodString({...this._def,checks:[...this._def.checks,{kind:"trim"}]});this.toLowerCase=()=>new ZodString({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]});this.toUpperCase=()=>new ZodString({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}_parse(e){if(this._def.coerce){e.data=String(e.data)}const t=this._getType(e);if(t!==o.ZodParsedType.string){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.string,received:t.parsedType});return n.INVALID}const s=new n.ParseStatus;let r=undefined;for(const t of this._def.checks){if(t.kind==="min"){if(e.data.lengtht.value){r=this._getOrReturnCtx(e,r);(0,n.addIssueToContext)(r,{code:i.ZodIssueCode.too_big,maximum:t.value,type:"string",inclusive:true,exact:false,message:t.message});s.dirty()}}else if(t.kind==="length"){const a=e.data.length>t.value;const o=e.data.lengthe.kind==="datetime"))}get isEmail(){return!!this._def.checks.find((e=>e.kind==="email"))}get isURL(){return!!this._def.checks.find((e=>e.kind==="url"))}get isEmoji(){return!!this._def.checks.find((e=>e.kind==="emoji"))}get isUUID(){return!!this._def.checks.find((e=>e.kind==="uuid"))}get isCUID(){return!!this._def.checks.find((e=>e.kind==="cuid"))}get isCUID2(){return!!this._def.checks.find((e=>e.kind==="cuid2"))}get isULID(){return!!this._def.checks.find((e=>e.kind==="ulid"))}get isIP(){return!!this._def.checks.find((e=>e.kind==="ip"))}get minLength(){let e=null;for(const t of this._def.checks){if(t.kind==="min"){if(e===null||t.value>e)e=t.value}}return e}get maxLength(){let e=null;for(const t of this._def.checks){if(t.kind==="max"){if(e===null||t.value{var t;return new ZodString({checks:[],typeName:y.ZodString,coerce:(t=e===null||e===void 0?void 0:e.coerce)!==null&&t!==void 0?t:false,...processCreateParams(e)})};function floatSafeRemainder(e,t){const s=(e.toString().split(".")[1]||"").length;const r=(t.toString().split(".")[1]||"").length;const a=s>r?s:r;const n=parseInt(e.toFixed(a).replace(".",""));const o=parseInt(t.toFixed(a).replace(".",""));return n%o/Math.pow(10,a)}class ZodNumber extends ZodType{constructor(){super(...arguments);this.min=this.gte;this.max=this.lte;this.step=this.multipleOf}_parse(e){if(this._def.coerce){e.data=Number(e.data)}const t=this._getType(e);if(t!==o.ZodParsedType.number){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.number,received:t.parsedType});return n.INVALID}let s=undefined;const r=new n.ParseStatus;for(const t of this._def.checks){if(t.kind==="int"){if(!o.util.isInteger(e.data)){s=this._getOrReturnCtx(e,s);(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.invalid_type,expected:"integer",received:"float",message:t.message});r.dirty()}}else if(t.kind==="min"){const a=t.inclusive?e.datat.value:e.data>=t.value;if(a){s=this._getOrReturnCtx(e,s);(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.too_big,maximum:t.value,type:"number",inclusive:t.inclusive,exact:false,message:t.message});r.dirty()}}else if(t.kind==="multipleOf"){if(floatSafeRemainder(e.data,t.value)!==0){s=this._getOrReturnCtx(e,s);(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.not_multiple_of,multipleOf:t.value,message:t.message});r.dirty()}}else if(t.kind==="finite"){if(!Number.isFinite(e.data)){s=this._getOrReturnCtx(e,s);(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.not_finite,message:t.message});r.dirty()}}else{o.util.assertNever(t)}}return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,true,a.errorUtil.toString(t))}gt(e,t){return this.setLimit("min",e,false,a.errorUtil.toString(t))}lte(e,t){return this.setLimit("max",e,true,a.errorUtil.toString(t))}lt(e,t){return this.setLimit("max",e,false,a.errorUtil.toString(t))}setLimit(e,t,s,r){return new ZodNumber({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:a.errorUtil.toString(r)}]})}_addCheck(e){return new ZodNumber({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:a.errorUtil.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:false,message:a.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:false,message:a.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:true,message:a.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:true,message:a.errorUtil.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:a.errorUtil.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:a.errorUtil.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:true,value:Number.MIN_SAFE_INTEGER,message:a.errorUtil.toString(e)})._addCheck({kind:"max",inclusive:true,value:Number.MAX_SAFE_INTEGER,message:a.errorUtil.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks){if(t.kind==="min"){if(e===null||t.value>e)e=t.value}}return e}get maxValue(){let e=null;for(const t of this._def.checks){if(t.kind==="max"){if(e===null||t.valuee.kind==="int"||e.kind==="multipleOf"&&o.util.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf"){return true}else if(s.kind==="min"){if(t===null||s.value>t)t=s.value}else if(s.kind==="max"){if(e===null||s.valuenew ZodNumber({checks:[],typeName:y.ZodNumber,coerce:(e===null||e===void 0?void 0:e.coerce)||false,...processCreateParams(e)});class ZodBigInt extends ZodType{constructor(){super(...arguments);this.min=this.gte;this.max=this.lte}_parse(e){if(this._def.coerce){e.data=BigInt(e.data)}const t=this._getType(e);if(t!==o.ZodParsedType.bigint){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.bigint,received:t.parsedType});return n.INVALID}let s=undefined;const r=new n.ParseStatus;for(const t of this._def.checks){if(t.kind==="min"){const a=t.inclusive?e.datat.value:e.data>=t.value;if(a){s=this._getOrReturnCtx(e,s);(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.too_big,type:"bigint",maximum:t.value,inclusive:t.inclusive,message:t.message});r.dirty()}}else if(t.kind==="multipleOf"){if(e.data%t.value!==BigInt(0)){s=this._getOrReturnCtx(e,s);(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.not_multiple_of,multipleOf:t.value,message:t.message});r.dirty()}}else{o.util.assertNever(t)}}return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,true,a.errorUtil.toString(t))}gt(e,t){return this.setLimit("min",e,false,a.errorUtil.toString(t))}lte(e,t){return this.setLimit("max",e,true,a.errorUtil.toString(t))}lt(e,t){return this.setLimit("max",e,false,a.errorUtil.toString(t))}setLimit(e,t,s,r){return new ZodBigInt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:a.errorUtil.toString(r)}]})}_addCheck(e){return new ZodBigInt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:false,message:a.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:false,message:a.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:true,message:a.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:true,message:a.errorUtil.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:a.errorUtil.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks){if(t.kind==="min"){if(e===null||t.value>e)e=t.value}}return e}get maxValue(){let e=null;for(const t of this._def.checks){if(t.kind==="max"){if(e===null||t.value{var t;return new ZodBigInt({checks:[],typeName:y.ZodBigInt,coerce:(t=e===null||e===void 0?void 0:e.coerce)!==null&&t!==void 0?t:false,...processCreateParams(e)})};class ZodBoolean extends ZodType{_parse(e){if(this._def.coerce){e.data=Boolean(e.data)}const t=this._getType(e);if(t!==o.ZodParsedType.boolean){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.boolean,received:t.parsedType});return n.INVALID}return(0,n.OK)(e.data)}}t.ZodBoolean=ZodBoolean;ZodBoolean.create=e=>new ZodBoolean({typeName:y.ZodBoolean,coerce:(e===null||e===void 0?void 0:e.coerce)||false,...processCreateParams(e)});class ZodDate extends ZodType{_parse(e){if(this._def.coerce){e.data=new Date(e.data)}const t=this._getType(e);if(t!==o.ZodParsedType.date){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.date,received:t.parsedType});return n.INVALID}if(isNaN(e.data.getTime())){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_date});return n.INVALID}const s=new n.ParseStatus;let r=undefined;for(const t of this._def.checks){if(t.kind==="min"){if(e.data.getTime()t.value){r=this._getOrReturnCtx(e,r);(0,n.addIssueToContext)(r,{code:i.ZodIssueCode.too_big,message:t.message,inclusive:true,exact:false,maximum:t.value,type:"date"});s.dirty()}}else{o.util.assertNever(t)}}return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ZodDate({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:a.errorUtil.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:a.errorUtil.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks){if(t.kind==="min"){if(e===null||t.value>e)e=t.value}}return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks){if(t.kind==="max"){if(e===null||t.valuenew ZodDate({checks:[],coerce:(e===null||e===void 0?void 0:e.coerce)||false,typeName:y.ZodDate,...processCreateParams(e)});class ZodSymbol extends ZodType{_parse(e){const t=this._getType(e);if(t!==o.ZodParsedType.symbol){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.symbol,received:t.parsedType});return n.INVALID}return(0,n.OK)(e.data)}}t.ZodSymbol=ZodSymbol;ZodSymbol.create=e=>new ZodSymbol({typeName:y.ZodSymbol,...processCreateParams(e)});class ZodUndefined extends ZodType{_parse(e){const t=this._getType(e);if(t!==o.ZodParsedType.undefined){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.undefined,received:t.parsedType});return n.INVALID}return(0,n.OK)(e.data)}}t.ZodUndefined=ZodUndefined;ZodUndefined.create=e=>new ZodUndefined({typeName:y.ZodUndefined,...processCreateParams(e)});class ZodNull extends ZodType{_parse(e){const t=this._getType(e);if(t!==o.ZodParsedType.null){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.null,received:t.parsedType});return n.INVALID}return(0,n.OK)(e.data)}}t.ZodNull=ZodNull;ZodNull.create=e=>new ZodNull({typeName:y.ZodNull,...processCreateParams(e)});class ZodAny extends ZodType{constructor(){super(...arguments);this._any=true}_parse(e){return(0,n.OK)(e.data)}}t.ZodAny=ZodAny;ZodAny.create=e=>new ZodAny({typeName:y.ZodAny,...processCreateParams(e)});class ZodUnknown extends ZodType{constructor(){super(...arguments);this._unknown=true}_parse(e){return(0,n.OK)(e.data)}}t.ZodUnknown=ZodUnknown;ZodUnknown.create=e=>new ZodUnknown({typeName:y.ZodUnknown,...processCreateParams(e)});class ZodNever extends ZodType{_parse(e){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.never,received:t.parsedType});return n.INVALID}}t.ZodNever=ZodNever;ZodNever.create=e=>new ZodNever({typeName:y.ZodNever,...processCreateParams(e)});class ZodVoid extends ZodType{_parse(e){const t=this._getType(e);if(t!==o.ZodParsedType.undefined){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.void,received:t.parsedType});return n.INVALID}return(0,n.OK)(e.data)}}t.ZodVoid=ZodVoid;ZodVoid.create=e=>new ZodVoid({typeName:y.ZodVoid,...processCreateParams(e)});class ZodArray extends ZodType{_parse(e){const{ctx:t,status:s}=this._processInputParams(e);const r=this._def;if(t.parsedType!==o.ZodParsedType.array){(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.array,received:t.parsedType});return n.INVALID}if(r.exactLength!==null){const e=t.data.length>r.exactLength.value;const a=t.data.lengthr.maxLength.value){(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.too_big,maximum:r.maxLength.value,type:"array",inclusive:true,exact:false,message:r.maxLength.message});s.dirty()}}if(t.common.async){return Promise.all([...t.data].map(((e,s)=>r.type._parseAsync(new ParseInputLazyPath(t,e,t.path,s))))).then((e=>n.ParseStatus.mergeArray(s,e)))}const a=[...t.data].map(((e,s)=>r.type._parseSync(new ParseInputLazyPath(t,e,t.path,s))));return n.ParseStatus.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new ZodArray({...this._def,minLength:{value:e,message:a.errorUtil.toString(t)}})}max(e,t){return new ZodArray({...this._def,maxLength:{value:e,message:a.errorUtil.toString(t)}})}length(e,t){return new ZodArray({...this._def,exactLength:{value:e,message:a.errorUtil.toString(t)}})}nonempty(e){return this.min(1,e)}}t.ZodArray=ZodArray;ZodArray.create=(e,t)=>new ZodArray({type:e,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...processCreateParams(t)});function deepPartialify(e){if(e instanceof ZodObject){const t={};for(const s in e.shape){const r=e.shape[s];t[s]=ZodOptional.create(deepPartialify(r))}return new ZodObject({...e._def,shape:()=>t})}else if(e instanceof ZodArray){return new ZodArray({...e._def,type:deepPartialify(e.element)})}else if(e instanceof ZodOptional){return ZodOptional.create(deepPartialify(e.unwrap()))}else if(e instanceof ZodNullable){return ZodNullable.create(deepPartialify(e.unwrap()))}else if(e instanceof ZodTuple){return ZodTuple.create(e.items.map((e=>deepPartialify(e))))}else{return e}}class ZodObject extends ZodType{constructor(){super(...arguments);this._cached=null;this.nonstrict=this.passthrough;this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape();const t=o.util.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){const t=this._getType(e);if(t!==o.ZodParsedType.object){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.object,received:t.parsedType});return n.INVALID}const{status:s,ctx:r}=this._processInputParams(e);const{shape:a,keys:d}=this._getCached();const u=[];if(!(this._def.catchall instanceof ZodNever&&this._def.unknownKeys==="strip")){for(const e in r.data){if(!d.includes(e)){u.push(e)}}}const c=[];for(const e of d){const t=a[e];const s=r.data[e];c.push({key:{status:"valid",value:e},value:t._parse(new ParseInputLazyPath(r,s,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof ZodNever){const e=this._def.unknownKeys;if(e==="passthrough"){for(const e of u){c.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}})}}else if(e==="strict"){if(u.length>0){(0,n.addIssueToContext)(r,{code:i.ZodIssueCode.unrecognized_keys,keys:u});s.dirty()}}else if(e==="strip"){}else{throw new Error(`Internal ZodObject error: invalid unknownKeys value.`)}}else{const e=this._def.catchall;for(const t of u){const s=r.data[t];c.push({key:{status:"valid",value:t},value:e._parse(new ParseInputLazyPath(r,s,r.path,t)),alwaysSet:t in r.data})}}if(r.common.async){return Promise.resolve().then((async()=>{const e=[];for(const t of c){const s=await t.key;e.push({key:s,value:await t.value,alwaysSet:t.alwaysSet})}return e})).then((e=>n.ParseStatus.mergeObjectSync(s,e)))}else{return n.ParseStatus.mergeObjectSync(s,c)}}get shape(){return this._def.shape()}strict(e){a.errorUtil.errToObj;return new ZodObject({...this._def,unknownKeys:"strict",...e!==undefined?{errorMap:(t,s)=>{var r,n,o,i;const d=(o=(n=(r=this._def).errorMap)===null||n===void 0?void 0:n.call(r,t,s).message)!==null&&o!==void 0?o:s.defaultError;if(t.code==="unrecognized_keys")return{message:(i=a.errorUtil.errToObj(e).message)!==null&&i!==void 0?i:d};return{message:d}}}:{}})}strip(){return new ZodObject({...this._def,unknownKeys:"strip"})}passthrough(){return new ZodObject({...this._def,unknownKeys:"passthrough"})}extend(e){return new ZodObject({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){const t=new ZodObject({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject});return t}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ZodObject({...this._def,catchall:e})}pick(e){const t={};o.util.objectKeys(e).forEach((s=>{if(e[s]&&this.shape[s]){t[s]=this.shape[s]}}));return new ZodObject({...this._def,shape:()=>t})}omit(e){const t={};o.util.objectKeys(this.shape).forEach((s=>{if(!e[s]){t[s]=this.shape[s]}}));return new ZodObject({...this._def,shape:()=>t})}deepPartial(){return deepPartialify(this)}partial(e){const t={};o.util.objectKeys(this.shape).forEach((s=>{const r=this.shape[s];if(e&&!e[s]){t[s]=r}else{t[s]=r.optional()}}));return new ZodObject({...this._def,shape:()=>t})}required(e){const t={};o.util.objectKeys(this.shape).forEach((s=>{if(e&&!e[s]){t[s]=this.shape[s]}else{const e=this.shape[s];let r=e;while(r instanceof ZodOptional){r=r._def.innerType}t[s]=r}}));return new ZodObject({...this._def,shape:()=>t})}keyof(){return createZodEnum(o.util.objectKeys(this.shape))}}t.ZodObject=ZodObject;ZodObject.create=(e,t)=>new ZodObject({shape:()=>e,unknownKeys:"strip",catchall:ZodNever.create(),typeName:y.ZodObject,...processCreateParams(t)});ZodObject.strictCreate=(e,t)=>new ZodObject({shape:()=>e,unknownKeys:"strict",catchall:ZodNever.create(),typeName:y.ZodObject,...processCreateParams(t)});ZodObject.lazycreate=(e,t)=>new ZodObject({shape:e,unknownKeys:"strip",catchall:ZodNever.create(),typeName:y.ZodObject,...processCreateParams(t)});class ZodUnion extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e);const s=this._def.options;function handleResults(e){for(const t of e){if(t.result.status==="valid"){return t.result}}for(const s of e){if(s.result.status==="dirty"){t.common.issues.push(...s.ctx.common.issues);return s.result}}const s=e.map((e=>new i.ZodError(e.ctx.common.issues)));(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_union,unionErrors:s});return n.INVALID}if(t.common.async){return Promise.all(s.map((async e=>{const s={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}}))).then(handleResults)}else{let e=undefined;const r=[];for(const a of s){const s={...t,common:{...t.common,issues:[]},parent:null};const n=a._parseSync({data:t.data,path:t.path,parent:s});if(n.status==="valid"){return n}else if(n.status==="dirty"&&!e){e={result:n,ctx:s}}if(s.common.issues.length){r.push(s.common.issues)}}if(e){t.common.issues.push(...e.ctx.common.issues);return e.result}const a=r.map((e=>new i.ZodError(e)));(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_union,unionErrors:a});return n.INVALID}}get options(){return this._def.options}}t.ZodUnion=ZodUnion;ZodUnion.create=(e,t)=>new ZodUnion({options:e,typeName:y.ZodUnion,...processCreateParams(t)});const getDiscriminator=e=>{if(e instanceof ZodLazy){return getDiscriminator(e.schema)}else if(e instanceof ZodEffects){return getDiscriminator(e.innerType())}else if(e instanceof ZodLiteral){return[e.value]}else if(e instanceof ZodEnum){return e.options}else if(e instanceof ZodNativeEnum){return Object.keys(e.enum)}else if(e instanceof ZodDefault){return getDiscriminator(e._def.innerType)}else if(e instanceof ZodUndefined){return[undefined]}else if(e instanceof ZodNull){return[null]}else{return null}};class ZodDiscriminatedUnion extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==o.ZodParsedType.object){(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.object,received:t.parsedType});return n.INVALID}const s=this.discriminator;const r=t.data[s];const a=this.optionsMap.get(r);if(!a){(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]});return n.INVALID}if(t.common.async){return a._parseAsync({data:t.data,path:t.path,parent:t})}else{return a._parseSync({data:t.data,path:t.path,parent:t})}}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const r=new Map;for(const s of t){const t=getDiscriminator(s.shape[e]);if(!t){throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`)}for(const a of t){if(r.has(a)){throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`)}r.set(a,s)}}return new ZodDiscriminatedUnion({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...processCreateParams(s)})}}t.ZodDiscriminatedUnion=ZodDiscriminatedUnion;function mergeValues(e,t){const s=(0,o.getParsedType)(e);const r=(0,o.getParsedType)(t);if(e===t){return{valid:true,data:e}}else if(s===o.ZodParsedType.object&&r===o.ZodParsedType.object){const s=o.util.objectKeys(t);const r=o.util.objectKeys(e).filter((e=>s.indexOf(e)!==-1));const a={...e,...t};for(const s of r){const r=mergeValues(e[s],t[s]);if(!r.valid){return{valid:false}}a[s]=r.data}return{valid:true,data:a}}else if(s===o.ZodParsedType.array&&r===o.ZodParsedType.array){if(e.length!==t.length){return{valid:false}}const s=[];for(let r=0;r{if((0,n.isAborted)(e)||(0,n.isAborted)(r)){return n.INVALID}const a=mergeValues(e.value,r.value);if(!a.valid){(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.invalid_intersection_types});return n.INVALID}if((0,n.isDirty)(e)||(0,n.isDirty)(r)){t.dirty()}return{status:t.value,value:a.data}};if(s.common.async){return Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then((([e,t])=>handleParsed(e,t)))}else{return handleParsed(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}}t.ZodIntersection=ZodIntersection;ZodIntersection.create=(e,t,s)=>new ZodIntersection({left:e,right:t,typeName:y.ZodIntersection,...processCreateParams(s)});class ZodTuple extends ZodType{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==o.ZodParsedType.array){(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.array,received:s.parsedType});return n.INVALID}if(s.data.lengththis._def.items.length){(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:true,exact:false,type:"array"});t.dirty()}const a=[...s.data].map(((e,t)=>{const r=this._def.items[t]||this._def.rest;if(!r)return null;return r._parse(new ParseInputLazyPath(s,e,s.path,t))})).filter((e=>!!e));if(s.common.async){return Promise.all(a).then((e=>n.ParseStatus.mergeArray(t,e)))}else{return n.ParseStatus.mergeArray(t,a)}}get items(){return this._def.items}rest(e){return new ZodTuple({...this._def,rest:e})}}t.ZodTuple=ZodTuple;ZodTuple.create=(e,t)=>{if(!Array.isArray(e)){throw new Error("You must pass an array of schemas to z.tuple([ ... ])")}return new ZodTuple({items:e,typeName:y.ZodTuple,rest:null,...processCreateParams(t)})};class ZodRecord extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==o.ZodParsedType.object){(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.object,received:s.parsedType});return n.INVALID}const r=[];const a=this._def.keyType;const d=this._def.valueType;for(const e in s.data){r.push({key:a._parse(new ParseInputLazyPath(s,e,s.path,e)),value:d._parse(new ParseInputLazyPath(s,s.data[e],s.path,e))})}if(s.common.async){return n.ParseStatus.mergeObjectAsync(t,r)}else{return n.ParseStatus.mergeObjectSync(t,r)}}get element(){return this._def.valueType}static create(e,t,s){if(t instanceof ZodType){return new ZodRecord({keyType:e,valueType:t,typeName:y.ZodRecord,...processCreateParams(s)})}return new ZodRecord({keyType:ZodString.create(),valueType:e,typeName:y.ZodRecord,...processCreateParams(t)})}}t.ZodRecord=ZodRecord;class ZodMap extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==o.ZodParsedType.map){(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.map,received:s.parsedType});return n.INVALID}const r=this._def.keyType;const a=this._def.valueType;const d=[...s.data.entries()].map((([e,t],n)=>({key:r._parse(new ParseInputLazyPath(s,e,s.path,[n,"key"])),value:a._parse(new ParseInputLazyPath(s,t,s.path,[n,"value"]))})));if(s.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const s of d){const r=await s.key;const a=await s.value;if(r.status==="aborted"||a.status==="aborted"){return n.INVALID}if(r.status==="dirty"||a.status==="dirty"){t.dirty()}e.set(r.value,a.value)}return{status:t.value,value:e}}))}else{const e=new Map;for(const s of d){const r=s.key;const a=s.value;if(r.status==="aborted"||a.status==="aborted"){return n.INVALID}if(r.status==="dirty"||a.status==="dirty"){t.dirty()}e.set(r.value,a.value)}return{status:t.value,value:e}}}}t.ZodMap=ZodMap;ZodMap.create=(e,t,s)=>new ZodMap({valueType:t,keyType:e,typeName:y.ZodMap,...processCreateParams(s)});class ZodSet extends ZodType{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==o.ZodParsedType.set){(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.set,received:s.parsedType});return n.INVALID}const r=this._def;if(r.minSize!==null){if(s.data.sizer.maxSize.value){(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.too_big,maximum:r.maxSize.value,type:"set",inclusive:true,exact:false,message:r.maxSize.message});t.dirty()}}const a=this._def.valueType;function finalizeSet(e){const s=new Set;for(const r of e){if(r.status==="aborted")return n.INVALID;if(r.status==="dirty")t.dirty();s.add(r.value)}return{status:t.value,value:s}}const d=[...s.data.values()].map(((e,t)=>a._parse(new ParseInputLazyPath(s,e,s.path,t))));if(s.common.async){return Promise.all(d).then((e=>finalizeSet(e)))}else{return finalizeSet(d)}}min(e,t){return new ZodSet({...this._def,minSize:{value:e,message:a.errorUtil.toString(t)}})}max(e,t){return new ZodSet({...this._def,maxSize:{value:e,message:a.errorUtil.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}t.ZodSet=ZodSet;ZodSet.create=(e,t)=>new ZodSet({valueType:e,minSize:null,maxSize:null,typeName:y.ZodSet,...processCreateParams(t)});class ZodFunction extends ZodType{constructor(){super(...arguments);this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==o.ZodParsedType.function){(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.function,received:t.parsedType});return n.INVALID}function makeArgsIssue(e,s){return(0,n.makeIssue)({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,(0,r.getErrorMap)(),r.defaultErrorMap].filter((e=>!!e)),issueData:{code:i.ZodIssueCode.invalid_arguments,argumentsError:s}})}function makeReturnsIssue(e,s){return(0,n.makeIssue)({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,(0,r.getErrorMap)(),r.defaultErrorMap].filter((e=>!!e)),issueData:{code:i.ZodIssueCode.invalid_return_type,returnTypeError:s}})}const s={errorMap:t.common.contextualErrorMap};const a=t.data;if(this._def.returns instanceof ZodPromise){const e=this;return(0,n.OK)((async function(...t){const r=new i.ZodError([]);const n=await e._def.args.parseAsync(t,s).catch((e=>{r.addIssue(makeArgsIssue(t,e));throw r}));const o=await Reflect.apply(a,this,n);const d=await e._def.returns._def.type.parseAsync(o,s).catch((e=>{r.addIssue(makeReturnsIssue(o,e));throw r}));return d}))}else{const e=this;return(0,n.OK)((function(...t){const r=e._def.args.safeParse(t,s);if(!r.success){throw new i.ZodError([makeArgsIssue(t,r.error)])}const n=Reflect.apply(a,this,r.data);const o=e._def.returns.safeParse(n,s);if(!o.success){throw new i.ZodError([makeReturnsIssue(n,o.error)])}return o.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ZodFunction({...this._def,args:ZodTuple.create(e).rest(ZodUnknown.create())})}returns(e){return new ZodFunction({...this._def,returns:e})}implement(e){const t=this.parse(e);return t}strictImplement(e){const t=this.parse(e);return t}static create(e,t,s){return new ZodFunction({args:e?e:ZodTuple.create([]).rest(ZodUnknown.create()),returns:t||ZodUnknown.create(),typeName:y.ZodFunction,...processCreateParams(s)})}}t.ZodFunction=ZodFunction;class ZodLazy extends ZodType{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);const s=this._def.getter();return s._parse({data:t.data,path:t.path,parent:t})}}t.ZodLazy=ZodLazy;ZodLazy.create=(e,t)=>new ZodLazy({getter:e,typeName:y.ZodLazy,...processCreateParams(t)});class ZodLiteral extends ZodType{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{received:t.data,code:i.ZodIssueCode.invalid_literal,expected:this._def.value});return n.INVALID}return{status:"valid",value:e.data}}get value(){return this._def.value}}t.ZodLiteral=ZodLiteral;ZodLiteral.create=(e,t)=>new ZodLiteral({value:e,typeName:y.ZodLiteral,...processCreateParams(t)});function createZodEnum(e,t){return new ZodEnum({values:e,typeName:y.ZodEnum,...processCreateParams(t)})}class ZodEnum extends ZodType{_parse(e){if(typeof e.data!=="string"){const t=this._getOrReturnCtx(e);const s=this._def.values;(0,n.addIssueToContext)(t,{expected:o.util.joinValues(s),received:t.parsedType,code:i.ZodIssueCode.invalid_type});return n.INVALID}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e);const s=this._def.values;(0,n.addIssueToContext)(t,{received:t.data,code:i.ZodIssueCode.invalid_enum_value,options:s});return n.INVALID}return(0,n.OK)(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values){e[t]=t}return e}get Values(){const e={};for(const t of this._def.values){e[t]=t}return e}get Enum(){const e={};for(const t of this._def.values){e[t]=t}return e}extract(e){return ZodEnum.create(e)}exclude(e){return ZodEnum.create(this.options.filter((t=>!e.includes(t))))}}t.ZodEnum=ZodEnum;ZodEnum.create=createZodEnum;class ZodNativeEnum extends ZodType{_parse(e){const t=o.util.getValidEnumValues(this._def.values);const s=this._getOrReturnCtx(e);if(s.parsedType!==o.ZodParsedType.string&&s.parsedType!==o.ZodParsedType.number){const e=o.util.objectValues(t);(0,n.addIssueToContext)(s,{expected:o.util.joinValues(e),received:s.parsedType,code:i.ZodIssueCode.invalid_type});return n.INVALID}if(t.indexOf(e.data)===-1){const e=o.util.objectValues(t);(0,n.addIssueToContext)(s,{received:s.data,code:i.ZodIssueCode.invalid_enum_value,options:e});return n.INVALID}return(0,n.OK)(e.data)}get enum(){return this._def.values}}t.ZodNativeEnum=ZodNativeEnum;ZodNativeEnum.create=(e,t)=>new ZodNativeEnum({values:e,typeName:y.ZodNativeEnum,...processCreateParams(t)});class ZodPromise extends ZodType{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==o.ZodParsedType.promise&&t.common.async===false){(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.promise,received:t.parsedType});return n.INVALID}const s=t.parsedType===o.ZodParsedType.promise?t.data:Promise.resolve(t.data);return(0,n.OK)(s.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}t.ZodPromise=ZodPromise;ZodPromise.create=(e,t)=>new ZodPromise({type:e,typeName:y.ZodPromise,...processCreateParams(t)});class ZodEffects extends ZodType{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);const r=this._def.effect||null;const a={addIssue:e=>{(0,n.addIssueToContext)(s,e);if(e.fatal){t.abort()}else{t.dirty()}},get path(){return s.path}};a.addIssue=a.addIssue.bind(a);if(r.type==="preprocess"){const e=r.transform(s.data,a);if(s.common.issues.length){return{status:"dirty",value:s.data}}if(s.common.async){return Promise.resolve(e).then((e=>this._def.schema._parseAsync({data:e,path:s.path,parent:s})))}else{return this._def.schema._parseSync({data:e,path:s.path,parent:s})}}if(r.type==="refinement"){const executeRefinement=e=>{const t=r.refinement(e,a);if(s.common.async){return Promise.resolve(t)}if(t instanceof Promise){throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.")}return e};if(s.common.async===false){const e=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(e.status==="aborted")return n.INVALID;if(e.status==="dirty")t.dirty();executeRefinement(e.value);return{status:t.value,value:e.value}}else{return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then((e=>{if(e.status==="aborted")return n.INVALID;if(e.status==="dirty")t.dirty();return executeRefinement(e.value).then((()=>({status:t.value,value:e.value})))}))}}if(r.type==="transform"){if(s.common.async===false){const e=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!(0,n.isValid)(e))return e;const o=r.transform(e.value,a);if(o instanceof Promise){throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`)}return{status:t.value,value:o}}else{return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then((e=>{if(!(0,n.isValid)(e))return e;return Promise.resolve(r.transform(e.value,a)).then((e=>({status:t.value,value:e})))}))}}o.util.assertNever(r)}}t.ZodEffects=ZodEffects;t.ZodTransformer=ZodEffects;ZodEffects.create=(e,t,s)=>new ZodEffects({schema:e,typeName:y.ZodEffects,effect:t,...processCreateParams(s)});ZodEffects.createWithPreprocess=(e,t,s)=>new ZodEffects({schema:t,effect:{type:"preprocess",transform:e},typeName:y.ZodEffects,...processCreateParams(s)});class ZodOptional extends ZodType{_parse(e){const t=this._getType(e);if(t===o.ZodParsedType.undefined){return(0,n.OK)(undefined)}return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}t.ZodOptional=ZodOptional;ZodOptional.create=(e,t)=>new ZodOptional({innerType:e,typeName:y.ZodOptional,...processCreateParams(t)});class ZodNullable extends ZodType{_parse(e){const t=this._getType(e);if(t===o.ZodParsedType.null){return(0,n.OK)(null)}return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}t.ZodNullable=ZodNullable;ZodNullable.create=(e,t)=>new ZodNullable({innerType:e,typeName:y.ZodNullable,...processCreateParams(t)});class ZodDefault extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;if(t.parsedType===o.ZodParsedType.undefined){s=this._def.defaultValue()}return this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}t.ZodDefault=ZodDefault;ZodDefault.create=(e,t)=>new ZodDefault({innerType:e,typeName:y.ZodDefault,defaultValue:typeof t.default==="function"?t.default:()=>t.default,...processCreateParams(t)});class ZodCatch extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e);const s={...t,common:{...t.common,issues:[]}};const r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});if((0,n.isAsync)(r)){return r.then((e=>({status:"valid",value:e.status==="valid"?e.value:this._def.catchValue({get error(){return new i.ZodError(s.common.issues)},input:s.data})})))}else{return{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new i.ZodError(s.common.issues)},input:s.data})}}}removeCatch(){return this._def.innerType}}t.ZodCatch=ZodCatch;ZodCatch.create=(e,t)=>new ZodCatch({innerType:e,typeName:y.ZodCatch,catchValue:typeof t.catch==="function"?t.catch:()=>t.catch,...processCreateParams(t)});class ZodNaN extends ZodType{_parse(e){const t=this._getType(e);if(t!==o.ZodParsedType.nan){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.nan,received:t.parsedType});return n.INVALID}return{status:"valid",value:e.data}}}t.ZodNaN=ZodNaN;ZodNaN.create=e=>new ZodNaN({typeName:y.ZodNaN,...processCreateParams(e)});t.BRAND=Symbol("zod_brand");class ZodBranded extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e);const s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}t.ZodBranded=ZodBranded;class ZodPipeline extends ZodType{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async){const handleAsync=async()=>{const e=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});if(e.status==="aborted")return n.INVALID;if(e.status==="dirty"){t.dirty();return(0,n.DIRTY)(e.value)}else{return this._def.out._parseAsync({data:e.value,path:s.path,parent:s})}};return handleAsync()}else{const e=this._def.in._parseSync({data:s.data,path:s.path,parent:s});if(e.status==="aborted")return n.INVALID;if(e.status==="dirty"){t.dirty();return{status:"dirty",value:e.value}}else{return this._def.out._parseSync({data:e.value,path:s.path,parent:s})}}}static create(e,t){return new ZodPipeline({in:e,out:t,typeName:y.ZodPipeline})}}t.ZodPipeline=ZodPipeline;class ZodReadonly extends ZodType{_parse(e){const t=this._def.innerType._parse(e);if((0,n.isValid)(t)){t.value=Object.freeze(t.value)}return t}}t.ZodReadonly=ZodReadonly;ZodReadonly.create=(e,t)=>new ZodReadonly({innerType:e,typeName:y.ZodReadonly,...processCreateParams(t)});const custom=(e,t={},s)=>{if(e)return ZodAny.create().superRefine(((r,a)=>{var n,o;if(!e(r)){const e=typeof t==="function"?t(r):typeof t==="string"?{message:t}:t;const i=(o=(n=e.fatal)!==null&&n!==void 0?n:s)!==null&&o!==void 0?o:true;const d=typeof e==="string"?{message:e}:e;a.addIssue({code:"custom",...d,fatal:i})}}));return ZodAny.create()};t.custom=custom;t.late={object:ZodObject.lazycreate};var y;(function(e){e["ZodString"]="ZodString";e["ZodNumber"]="ZodNumber";e["ZodNaN"]="ZodNaN";e["ZodBigInt"]="ZodBigInt";e["ZodBoolean"]="ZodBoolean";e["ZodDate"]="ZodDate";e["ZodSymbol"]="ZodSymbol";e["ZodUndefined"]="ZodUndefined";e["ZodNull"]="ZodNull";e["ZodAny"]="ZodAny";e["ZodUnknown"]="ZodUnknown";e["ZodNever"]="ZodNever";e["ZodVoid"]="ZodVoid";e["ZodArray"]="ZodArray";e["ZodObject"]="ZodObject";e["ZodUnion"]="ZodUnion";e["ZodDiscriminatedUnion"]="ZodDiscriminatedUnion";e["ZodIntersection"]="ZodIntersection";e["ZodTuple"]="ZodTuple";e["ZodRecord"]="ZodRecord";e["ZodMap"]="ZodMap";e["ZodSet"]="ZodSet";e["ZodFunction"]="ZodFunction";e["ZodLazy"]="ZodLazy";e["ZodLiteral"]="ZodLiteral";e["ZodEnum"]="ZodEnum";e["ZodEffects"]="ZodEffects";e["ZodNativeEnum"]="ZodNativeEnum";e["ZodOptional"]="ZodOptional";e["ZodNullable"]="ZodNullable";e["ZodDefault"]="ZodDefault";e["ZodCatch"]="ZodCatch";e["ZodPromise"]="ZodPromise";e["ZodBranded"]="ZodBranded";e["ZodPipeline"]="ZodPipeline";e["ZodReadonly"]="ZodReadonly"})(y=t.ZodFirstPartyTypeKind||(t.ZodFirstPartyTypeKind={}));class Class{constructor(...e){}}const instanceOfType=(e,s={message:`Input not instance of ${e.name}`})=>(0,t.custom)((t=>t instanceof e),s);t["instanceof"]=instanceOfType;const Z=ZodString.create;t.string=Z;const _=ZodNumber.create;t.number=_;const v=ZodNaN.create;t.nan=v;const g=ZodBigInt.create;t.bigint=g;const I=ZodBoolean.create;t.boolean=I;const T=ZodDate.create;t.date=T;const x=ZodSymbol.create;t.symbol=x;const b=ZodUndefined.create;t.undefined=b;const C=ZodNull.create;t["null"]=C;const P=ZodAny.create;t.any=P;const k=ZodUnknown.create;t.unknown=k;const w=ZodNever.create;t.never=w;const N=ZodVoid.create;t["void"]=N;const O=ZodArray.create;t.array=O;const S=ZodObject.create;t.object=S;const E=ZodObject.strictCreate;t.strictObject=E;const A=ZodUnion.create;t.union=A;const j=ZodDiscriminatedUnion.create;t.discriminatedUnion=j;const L=ZodIntersection.create;t.intersection=L;const U=ZodTuple.create;t.tuple=U;const D=ZodRecord.create;t.record=D;const R=ZodMap.create;t.map=R;const V=ZodSet.create;t.set=V;const M=ZodFunction.create;t["function"]=M;const z=ZodLazy.create;t.lazy=z;const $=ZodLiteral.create;t.literal=$;const B=ZodEnum.create;t["enum"]=B;const K=ZodNativeEnum.create;t.nativeEnum=K;const F=ZodPromise.create;t.promise=F;const q=ZodEffects.create;t.effect=q;t.transformer=q;const W=ZodOptional.create;t.optional=W;const J=ZodNullable.create;t.nullable=J;const Y=ZodEffects.createWithPreprocess;t.preprocess=Y;const H=ZodPipeline.create;t.pipeline=H;const ostring=()=>Z().optional();t.ostring=ostring;const onumber=()=>_().optional();t.onumber=onumber;const oboolean=()=>I().optional();t.oboolean=oboolean;t.coerce={string:e=>ZodString.create({...e,coerce:true}),number:e=>ZodNumber.create({...e,coerce:true}),boolean:e=>ZodBoolean.create({...e,coerce:true}),bigint:e=>ZodBigInt.create({...e,coerce:true}),date:e=>ZodDate.create({...e,coerce:true})};t.NEVER=n.INVALID}};var t={};function __nccwpck_require__(s){var r=t[s];if(r!==undefined){return r.exports}var a=t[s]={exports:{}};var n=true;try{e[s].call(a.exports,a,a.exports,__nccwpck_require__);n=false}finally{if(n)delete t[s]}return a.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var s=__nccwpck_require__(773);module.exports=s})(); \ No newline at end of file diff --git a/packages/next/src/compiled/zod/package.json b/packages/next/src/compiled/zod/package.json new file mode 100644 index 0000000000000..23793495cb366 --- /dev/null +++ b/packages/next/src/compiled/zod/package.json @@ -0,0 +1 @@ +{"name":"zod","main":"index.js","author":"Colin McDonnell ","license":"MIT"} diff --git a/packages/next/src/server/config-schema.ts b/packages/next/src/server/config-schema.ts index 565bfd4d65350..0437a2fb45507 100644 --- a/packages/next/src/server/config-schema.ts +++ b/packages/next/src/server/config-schema.ts @@ -1,481 +1,345 @@ import { NextConfig } from './config' -import type { JSONSchemaType } from 'ajv' import { VALID_LOADERS } from '../shared/lib/image-config' -const configSchema = { - type: 'object', - additionalProperties: false, - properties: { - amp: { - additionalProperties: false, - properties: { - canonicalBase: { - nullable: true, - type: 'string', - }, - }, - type: 'object', - }, - analyticsId: { - type: 'string', - }, - assetPrefix: { - nullable: true, - type: 'string', - }, - basePath: { - type: 'string', - }, - cleanDistDir: { - type: 'boolean', - }, - compiler: { - additionalProperties: false, - properties: { - emotion: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: false, - properties: { - sourceMap: { - type: 'boolean', - }, - autoLabel: { - type: 'string', - enum: ['always', 'dev-only', 'never'], - }, - labelFormat: { - type: 'string', - minLength: 1, - }, - importMap: { - type: 'object', - }, - }, - }, - ] as any, - }, - reactRemoveProperties: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: false, - properties: { - properties: { - type: 'array', - items: { - type: 'string', - }, - }, - }, - }, - ] as any, - }, - relay: { - type: 'object', - }, - removeConsole: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: false, - properties: { - exclude: { - type: 'array', - items: { - type: 'string', - minLength: 1, - }, - }, - }, - }, - ] as any, - }, - styledComponents: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: false, - properties: { - displayName: { - type: 'boolean', - }, - topLevelImportPaths: { - oneOf: [ - { type: 'boolean' }, - { - type: 'array', - items: { - type: 'string', - minLength: 1, - }, - }, - ], - }, - ssr: { - type: 'boolean', - }, - fileName: { - type: 'boolean', - }, - meaninglessFileNames: { - oneOf: [ - { type: 'boolean' }, - { - type: 'array', - items: { - type: 'string', - minLength: 1, - }, - }, - ], - }, - minify: { - type: 'boolean', - }, - transpileTemplateLiterals: { - type: 'boolean', - }, - namespace: { - type: 'string', - minLength: 1, - }, - pure: { - type: 'boolean', - }, - cssProp: { - type: 'boolean', - }, - }, - }, - ] as any, - }, - }, - type: 'object', - }, - compress: { - type: 'boolean', - }, - configOrigin: { - type: 'string', - }, - crossOrigin: { - oneOf: [ - false, - { - enum: ['anonymous', 'use-credentials'], - type: 'string', - }, - ], // automatic typing does not like enum - } as any, - devIndicators: { - additionalProperties: false, - properties: { - buildActivity: { - type: 'boolean', - }, - buildActivityPosition: { - // automatic typing does not like enum - enum: ['bottom-left', 'bottom-right', 'top-left', 'top-right'] as any, - type: 'string', - }, - }, - type: 'object', - }, - distDir: { - minLength: 1, - type: 'string', - nullable: true, - }, - env: { - type: 'object', - }, - eslint: { - additionalProperties: false, - properties: { - dirs: { - items: { - minLength: 1, - type: 'string', - }, - type: 'array', - }, - ignoreDuringBuilds: { - type: 'boolean', - }, - }, - type: 'object', - }, - excludeDefaultMomentLocales: { - type: 'boolean', - }, - experimental: { - additionalProperties: false, - properties: { - appDocumentPreloading: { - type: 'boolean', - }, - adjustFontFallbacks: { - type: 'boolean', - }, - adjustFontFallbacksWithSizeAdjust: { - type: 'boolean', - }, - allowedRevalidateHeaderKeys: { - type: 'array', - }, - amp: { - additionalProperties: false, - properties: { - optimizer: { - type: 'object', - }, - skipValidation: { - type: 'boolean', - }, - validator: { - type: 'string', - }, - }, - type: 'object', - }, - clientRouterFilter: { - type: 'boolean', - }, - clientRouterFilterRedirects: { - type: 'boolean', - }, - clientRouterFilterAllowedRate: { - type: 'number', - }, - cpus: { - type: 'number', - }, - memoryBasedWorkersCount: { - type: 'boolean', - }, - craCompat: { - type: 'boolean', - }, - caseSensitiveRoutes: { - type: 'boolean', - }, - useDeploymentId: { - type: 'boolean', - }, - useDeploymentIdServerActions: { - type: 'boolean', - }, - deploymentId: { - type: 'string', - }, - disableOptimizedLoading: { - type: 'boolean', - }, - disablePostcssPresetEnv: { - type: 'boolean', - }, - esmExternals: { - oneOf: [ - { - type: 'boolean', - }, - { - const: 'loose', - }, - ] as any, - }, - serverActions: { - type: 'boolean', - }, - serverActionsBodySizeLimit: { - oneOf: [ - { - type: 'number', - }, - { - type: 'string', - }, - ] as any, - }, - extensionAlias: { - type: 'object', - }, - externalDir: { - type: 'boolean', - }, - externalMiddlewareRewritesResolve: { - type: 'boolean', - }, - fallbackNodePolyfills: { - type: 'boolean', - }, - fetchCacheKeyPrefix: { - type: 'string', - }, - forceSwcTransforms: { - type: 'boolean', - }, - fullySpecified: { - type: 'boolean', - }, - gzipSize: { - type: 'boolean', - }, - incrementalCacheHandlerPath: { - type: 'string', - }, - isrFlushToDisk: { - type: 'boolean', - }, - isrMemoryCacheSize: { - type: 'number', - }, - largePageDataBytes: { - type: 'number', - }, - manualClientBasePath: { - type: 'boolean', - }, - middlewarePrefetch: { - // automatic typing doesn't like enum - enum: ['strict', 'flexible'] as any, - type: 'string', - }, - nextScriptWorkers: { - type: 'boolean', - }, - optimizeCss: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - }, - ] as any, - }, - optimisticClientCache: { - type: 'boolean', - }, - outputFileTracingRoot: { - nullable: true, - type: 'string', - }, - outputFileTracingExcludes: { - type: 'object', - }, - outputFileTracingIgnores: { - type: 'array', - }, - outputFileTracingIncludes: { - type: 'object', - }, - ppr: { - type: 'boolean', - }, - proxyTimeout: { - minimum: 0, - type: 'number', - }, - serverComponentsExternalPackages: { - items: { - type: 'string', - }, - type: 'array', - }, - scrollRestoration: { - type: 'boolean', - }, - sri: { - properties: { - algorithm: { - enum: ['sha256', 'sha384', 'sha512'] as any, - type: 'string', - }, - }, - type: 'object', - }, - strictNextHead: { - type: 'boolean', - }, - swcMinify: { - type: 'boolean', - }, - swcPlugins: { - type: 'array', - }, - swcTraceProfiling: { - type: 'boolean', - }, - urlImports: { - items: { - type: 'string', - }, - type: 'array', - }, - workerThreads: { - type: 'boolean', - }, - webVitalsAttribution: { - type: 'array', - items: { - type: 'string', - enum: ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'], - } as any, - }, - mdxRs: { - type: 'boolean', - }, - typedRoutes: { - type: 'boolean', - }, - webpackBuildWorker: { - type: 'boolean', - }, - turbo: { - type: 'object', - additionalProperties: false, - properties: { - loaders: { - type: 'object', - }, - rules: { - type: 'object', - }, - resolveAlias: { - type: 'object', - }, - }, - }, - optimizePackageImports: { - type: 'array', - }, - optimizeServerReact: { - type: 'boolean', - }, - instrumentationHook: { - type: 'boolean', - }, - turbotrace: { - type: 'object', - properties: { - logLevel: { - type: 'string', - enum: [ +import { z } from 'next/dist/compiled/zod' +import type zod from 'next/dist/compiled/zod' + +import type { SizeLimit } from '../../types' +import type { ExportPathMap, TurboLoaderItem, TurboRule } from './config-shared' +import type { + Header, + Rewrite, + RouteHas, + Redirect, +} from '../lib/load-custom-routes' + +// A custom zod schema for the SizeLimit type +const zSizeLimit = z.custom((val) => { + if (typeof val === 'number' || typeof val === 'string') { + return true + } + return false +}) + +const zExportMap: zod.ZodType = z.record( + z.string(), + z.object({ + page: z.string(), + query: z.any(), // NextParsedUrlQuery + // private optional properties + _isAppDir: z.boolean().optional(), + _isAppPrefetch: z.boolean().optional(), + _isDynamicError: z.boolean().optional(), + }) +) + +const zRouteHas: zod.ZodType = z.union([ + z.object({ + type: z.enum(['header', 'query', 'cookie']), + key: z.string(), + value: z.string().optional(), + }), + z.object({ + type: z.literal('host'), + key: z.undefined().optional(), + value: z.string(), + }), +]) + +const zRewrite: zod.ZodType = z.object({ + source: z.string(), + destination: z.string(), + basePath: z.literal(false).optional(), + locale: z.literal(false).optional(), + has: z.array(zRouteHas).optional(), + missing: z.array(zRouteHas).optional(), + internal: z.boolean().optional(), +}) + +const zRedirect: zod.ZodType = z + .object({ + source: z.string(), + destination: z.string(), + basePath: z.literal(false).optional(), + locale: z.literal(false).optional(), + has: z.array(zRouteHas).optional(), + missing: z.array(zRouteHas).optional(), + internal: z.boolean().optional(), + }) + .and( + z.union([ + z.object({ + statusCode: z.never().optional(), + permanent: z.boolean(), + }), + z.object({ + statusCode: z.number(), + permanent: z.never().optional(), + }), + ]) + ) + +const zHeader: zod.ZodType
= z.object({ + source: z.string(), + basePath: z.literal(false).optional(), + locale: z.literal(false).optional(), + headers: z.array(z.object({ key: z.string(), value: z.string() })), + has: z.array(zRouteHas).optional(), + missing: z.array(zRouteHas).optional(), + + internal: z.boolean().optional(), +}) + +const zTurboLoaderItem: zod.ZodType = z.union([ + z.string(), + z.object({ + loader: z.string(), + // Any JSON value can be used as turbo loader options, so use z.any() here + options: z.record(z.string(), z.any()), + }), +]) + +const zTurboRule: zod.ZodType = z.union([ + z.array(zTurboLoaderItem), + z.object({ + loaders: z.array(zTurboLoaderItem), + as: z.string(), + }), +]) + +export const configSchema: zod.ZodType = z.lazy(() => + z.strictObject({ + amp: z + .object({ + canonicalBase: z.string().optional(), + }) + .optional(), + analyticsId: z.string().optional(), + assetPrefix: z.string().optional(), + basePath: z.string().optional(), + cleanDistDir: z.boolean().optional(), + compiler: z + .strictObject({ + emotion: z + .union([ + z.boolean(), + z.object({ + sourceMap: z.boolean().optional(), + autoLabel: z + .union([ + z.literal('always'), + z.literal('dev-only'), + z.literal('never'), + ]) + .optional(), + labelFormat: z.string().min(1).optional(), + importMap: z + .record( + z.string(), + z.record( + z.string(), + z.object({ + canonicalImport: z + .tuple([z.string(), z.string()]) + .optional(), + styledBaseImport: z + .tuple([z.string(), z.string()]) + .optional(), + }) + ) + ) + .optional(), + }), + ]) + .optional(), + reactRemoveProperties: z + .union([ + z.boolean().optional(), + z.object({ + properties: z.array(z.string()).optional(), + }), + ]) + .optional(), + relay: z + .object({ + src: z.string(), + artifactDirectory: z.string().optional(), + language: z.enum(['javascript', 'typescript', 'flow']).optional(), + eagerEsModules: z.boolean().optional(), + }) + .optional(), + removeConsole: z + .union([ + z.boolean().optional(), + z.object({ + exclude: z.array(z.string()).min(1).optional(), + }), + ]) + .optional(), + styledComponents: z.union([ + z.boolean().optional(), + z.object({ + displayName: z.boolean().optional(), + topLevelImportPaths: z.array(z.string()).min(1).optional(), + ssr: z.boolean().optional(), + fileName: z.boolean().optional(), + meaninglessFileNames: z.array(z.string()).min(1).optional(), + minify: z.boolean().optional(), + transpileTemplateLiterals: z.boolean().optional(), + namespace: z.string().min(1).optional(), + pure: z.boolean().optional(), + cssProp: z.boolean().optional(), + }), + ]), + }) + .optional(), + compress: z.boolean().optional(), + configOrigin: z.string().optional(), + crossOrigin: z + .union([ + z.literal(false), + z.literal('anonymous'), + z.literal('use-credentials'), + ]) + .optional(), + devIndicators: z + .object({ + buildActivity: z.boolean().optional(), + buildActivityPosition: z + .union([ + z.literal('bottom-left'), + z.literal('bottom-right'), + z.literal('top-left'), + z.literal('top-right'), + ]) + .optional(), + }) + .optional(), + distDir: z.string().min(1).optional(), + env: z.record(z.string(), z.string()).optional(), + eslint: z + .strictObject({ + dirs: z.array(z.string().min(1)).optional(), + ignoreDuringBuilds: z.boolean().optional(), + }) + .optional(), + excludeDefaultMomentLocales: z.boolean().optional(), + experimental: z + .strictObject({ + appDocumentPreloading: z.boolean().optional(), + adjustFontFallbacks: z.boolean().optional(), + adjustFontFallbacksWithSizeAdjust: z.boolean().optional(), + allowedRevalidateHeaderKeys: z.array(z.string()).optional(), + amp: z + .object({ + // AMP optimizer option is unknown, use z.any() here + optimizer: z.any().optional(), + skipValidation: z.boolean().optional(), + validator: z.string().optional(), + }) + .optional(), + clientRouterFilter: z.boolean().optional(), + clientRouterFilterRedirects: z.boolean().optional(), + clientRouterFilterAllowedRate: z.number().optional(), + cpus: z.number().optional(), + memoryBasedWorkersCount: z.boolean().optional(), + craCompat: z.boolean().optional(), + caseSensitiveRoutes: z.boolean().optional(), + useDeploymentId: z.boolean().optional(), + useDeploymentIdServerActions: z.boolean().optional(), + deploymentId: z.string().optional(), + disableOptimizedLoading: z.boolean().optional(), + disablePostcssPresetEnv: z.boolean().optional(), + esmExternals: z.union([z.boolean(), z.literal('loose')]).optional(), + serverActions: z.boolean().optional(), + serverActionsBodySizeLimit: zSizeLimit.optional(), + // The original type was Record + extensionAlias: z.record(z.string(), z.any()).optional(), + externalDir: z.boolean().optional(), + externalMiddlewareRewritesResolve: z.boolean().optional(), + fallbackNodePolyfills: z.literal(false).optional(), + fetchCacheKeyPrefix: z.string().optional(), + forceSwcTransforms: z.boolean().optional(), + fullySpecified: z.boolean().optional(), + gzipSize: z.boolean().optional(), + incrementalCacheHandlerPath: z.string().optional(), + isrFlushToDisk: z.boolean().optional(), + isrMemoryCacheSize: z.number().optional(), + largePageDataBytes: z.number().optional(), + manualClientBasePath: z.boolean().optional(), + middlewarePrefetch: z.enum(['strict', 'flexible']).optional(), + nextScriptWorkers: z.boolean().optional(), + // The critter option is unknown, use z.any() here + optimizeCss: z.union([z.boolean(), z.any()]).optional(), + optimisticClientCache: z.boolean().optional(), + outputFileTracingRoot: z.string().optional(), + outputFileTracingExcludes: z + .record(z.string(), z.array(z.string())) + .optional(), + outputFileTracingIgnores: z.array(z.string()).optional(), + outputFileTracingIncludes: z + .record(z.string(), z.array(z.string())) + .optional(), + ppr: z.boolean().optional(), + proxyTimeout: z.number().gte(0).optional(), + serverComponentsExternalPackages: z.array(z.string()).optional(), + scrollRestoration: z.boolean().optional(), + sri: z + .object({ + algorithm: z.enum(['sha256', 'sha384', 'sha512']).optional(), + }) + .optional(), + strictNextHead: z.boolean().optional(), + swcMinify: z.boolean().optional(), + swcPlugins: z + // The specific swc plugin's option is unknown, use z.any() here + .array(z.tuple([z.string(), z.record(z.string(), z.any())])) + .optional(), + swcTraceProfiling: z.boolean().optional(), + // NonNullable['buildHttp'] + urlImports: z.any().optional(), + workerThreads: z.boolean().optional(), + webVitalsAttribution: z + .array( + z.union([ + z.literal('CLS'), + z.literal('FCP'), + z.literal('FID'), + z.literal('INP'), + z.literal('LCP'), + z.literal('TTFB'), + ]) + ) + .optional(), + mdxRs: z.boolean().optional(), + typedRoutes: z.boolean().optional(), + webpackBuildWorker: z.boolean().optional(), + turbo: z + .object({ + loaders: z.record(z.string(), z.array(zTurboLoaderItem)).optional(), + rules: z.record(z.string(), zTurboRule).optional(), + resolveAlias: z + .record( + z.string(), + z.union([ + z.string(), + z.array(z.string()), + z.record( + z.string(), + z.union([z.string(), z.array(z.string())]) + ), + ]) + ) + .optional(), + }) + .optional(), + optimizePackageImports: z.array(z.string()).optional(), + optimizeServerReact: z.boolean().optional(), + instrumentationHook: z.boolean().optional(), + turbotrace: z + .object({ + logLevel: z + .enum([ 'bug', 'fatal', 'error', @@ -484,341 +348,180 @@ const configSchema = { 'note', 'suggestions', 'info', - ], - } as any, - logAll: { - type: 'boolean', - }, - logDetail: { - type: 'boolean', - }, - contextDirectory: { - type: 'string', - }, - processCwd: { - type: 'string', - }, - memoryLimit: { - type: 'integer', - }, - }, - }, - logging: { - type: 'object', - properties: { - level: { - type: 'string', - }, - fullUrl: { - type: 'boolean', - }, - }, - }, - serverMinification: { - type: 'boolean', - }, - serverSourceMaps: { - type: 'boolean', - }, - bundlePagesExternals: { - type: 'boolean', - }, - }, - type: 'object', - }, - exportPathMap: { - isFunction: true, - errorMessage: 'must be a function that returns a Promise', - } as any, - generateBuildId: { - isFunction: true, - errorMessage: 'must be a function that returns a Promise', - } as any, - generateEtags: { - type: 'boolean', - }, - headers: { - isFunction: true, - errorMessage: 'must be a function that returns a Promise', - } as any, - httpAgentOptions: { - additionalProperties: false, - properties: { - keepAlive: { - type: 'boolean', - }, - }, - type: 'object', - }, - i18n: { - additionalProperties: false, - nullable: true, - properties: { - defaultLocale: { - minLength: 1, - type: 'string', - }, - domains: { - items: { - additionalProperties: false, - properties: { - defaultLocale: { - minLength: 1, - type: 'string', - }, - domain: { - minLength: 1, - type: 'string', - }, - http: { - type: 'boolean', - }, - locales: { - items: { - minLength: 1, - type: 'string', - }, - type: 'array', - }, - }, - type: 'object', - }, - type: 'array', - }, - localeDetection: { - type: 'boolean', - }, - locales: { - items: { - minLength: 1, - type: 'string', - }, - type: 'array', - }, - }, - type: 'object', - }, - images: { - additionalProperties: false, - nullable: true, - properties: { - remotePatterns: { - nullable: true, - items: { - additionalProperties: false, - properties: { - hostname: { - type: 'string', - }, - pathname: { - type: 'string', - }, - port: { - maxLength: 5, - type: 'string', - }, - protocol: { - // automatic typing doesn't like enum - enum: ['http', 'https'] as any, - type: 'string', - }, - }, - required: ['hostname'] as any, - type: 'object', - }, - maxItems: 50, - type: 'array', - }, - unoptimized: { - type: 'boolean', - }, - contentSecurityPolicy: { - type: 'string', - nullable: true, - }, - contentDispositionType: { - enum: ['inline', 'attachment'] as any, // automatic typing does not like enum - type: 'string', - nullable: true, - }, - dangerouslyAllowSVG: { - type: 'boolean', - nullable: true, - }, - deviceSizes: { - items: { - type: 'integer', - minimum: 1, - maximum: 10000, - }, - maxItems: 25, - type: 'array', - nullable: true, - }, - disableStaticImages: { - type: 'boolean', - nullable: true, - }, - domains: { - items: { - type: 'string', - }, - maxItems: 50, - type: 'array', - nullable: true, - }, - formats: { - items: { - enum: ['image/avif', 'image/webp'], // automatic typing does not like enum - type: 'string', - } as any, - maxItems: 4, - type: 'array', - nullable: true, - }, - imageSizes: { - items: { - type: 'integer', - minimum: 1, - maximum: 10000, - }, - minItems: 0, - maxItems: 25, - type: 'array', - nullable: true, - }, - loader: { - // automatic typing does not like enum - enum: VALID_LOADERS as any, - type: 'string', - nullable: true, - }, - loaderFile: { - type: 'string', - nullable: true, - }, - minimumCacheTTL: { - type: 'integer', - minimum: 0, - nullable: true, - }, - path: { - type: 'string', - nullable: true, - }, - }, - type: 'object', - }, - modularizeImports: { - type: 'object', - }, - onDemandEntries: { - additionalProperties: false, - properties: { - maxInactiveAge: { - type: 'number', - }, - pagesBufferLength: { - type: 'number', - }, - }, - type: 'object', - }, - optimizeFonts: { - type: 'boolean', - }, - output: { - // automatic typing doesn't like enum - enum: ['standalone', 'export'] as any, - type: 'string', - }, - outputFileTracing: { - type: 'boolean', - }, - pageExtensions: { - minItems: 1, - type: 'array', - }, - poweredByHeader: { - type: 'boolean', - }, - productionBrowserSourceMaps: { - type: 'boolean', - }, - publicRuntimeConfig: { - type: 'object', - }, - reactProductionProfiling: { - type: 'boolean', - }, - reactStrictMode: { - type: 'boolean', - nullable: true, - }, - redirects: { - isFunction: true, - errorMessage: 'must be a function that returns a Promise', - } as any, - rewrites: { - isFunction: true, - errorMessage: 'must be a function that returns a Promise', - } as any, - sassOptions: { - type: 'object', - }, - serverRuntimeConfig: { - type: 'object', - }, - skipMiddlewareUrlNormalize: { - type: 'boolean', - }, - skipTrailingSlashRedirect: { - type: 'boolean', - }, - staticPageGenerationTimeout: { - type: 'number', - }, - swcMinify: { - type: 'boolean', - }, - target: { - type: 'string', - }, - trailingSlash: { - type: 'boolean', - }, - transpilePackages: { - items: { - type: 'string', - }, - type: 'array', - }, - typescript: { - additionalProperties: false, - properties: { - ignoreBuildErrors: { - type: 'boolean', - }, - tsconfigPath: { - minLength: 1, - type: 'string', - }, - }, - type: 'object', - }, - useFileSystemPublicRoutes: { - type: 'boolean', - }, - webpack: { - isFunction: true, - errorMessage: - 'must be a function that returns a webpack configuration object', - } as any, - }, -} as JSONSchemaType - -// module.exports is used to get around an export bug with TypeScript -// and the Ajv automatic typing -module.exports = { - configSchema, -} + ]) + .optional(), + logAll: z.boolean().optional(), + logDetail: z.boolean().optional(), + contextDirectory: z.string().optional(), + processCwd: z.string().optional(), + memoryLimit: z.number().int().optional(), + }) + .optional(), + logging: z + .object({ + level: z.literal('verbose').optional(), + fullUrl: z.boolean().optional(), + }) + .optional(), + serverMinification: z.boolean().optional(), + serverSourceMaps: z.boolean().optional(), + bundlePagesExternals: z.boolean().optional(), + }) + .optional(), + exportPathMap: z + .function() + .args( + zExportMap, + z.object({ + dev: z.boolean(), + dir: z.string(), + outDir: z.string().nullable(), + distDir: z.string(), + buildId: z.string(), + }) + ) + .returns(z.union([zExportMap, z.promise(zExportMap)])) + .optional(), + generateBuildId: z + .function() + .args() + .returns( + z.union([ + z.string(), + z.null(), + z.promise(z.union([z.string(), z.null()])), + ]) + ) + .optional(), + generateEtags: z.boolean().optional(), + headers: z + .function() + .args() + .returns(z.promise(z.array(zHeader))) + .optional(), + httpAgentOptions: z + .strictObject({ keepAlive: z.boolean().optional() }) + .optional(), + i18n: z + .strictObject({ + defaultLocale: z.string().min(1), + domains: z + .array( + z.strictObject({ + defaultLocale: z.string().min(1), + domain: z.string().min(1), + http: z.literal(true).optional(), + locales: z.array(z.string().min(1)).optional(), + }) + ) + .optional(), + localeDetection: z.literal(false).optional(), + locales: z.array(z.string().min(1)), + }) + .nullable() + .optional(), + images: z + .strictObject({ + remotePatterns: z + .array( + z.strictObject({ + hostname: z.string(), + pathname: z.string().optional(), + port: z.string().max(5).optional(), + protocol: z.enum(['http', 'https']).optional(), + }) + ) + .max(50) + .optional(), + unoptimized: z.boolean().optional(), + contentSecurityPolicy: z.string().optional(), + contentDispositionType: z.enum(['inline', 'attachment']).optional(), + dangerouslyAllowSVG: z.boolean().optional(), + deviceSizes: z + .array(z.number().int().gte(1).lte(10000)) + .max(25) + .optional(), + disableStaticImages: z.boolean().optional(), + domains: z.array(z.string()).max(50).optional(), + formats: z + .array(z.enum(['image/avif', 'image/webp'])) + .max(4) + .optional(), + imageSizes: z + .array(z.number().int().gte(1).lte(10000)) + .min(0) + .max(25) + .optional(), + loader: z.enum(VALID_LOADERS).optional(), + loaderFile: z.string().optional(), + minimumCacheTTL: z.number().int().gte(0).optional(), + path: z.string().optional(), + }) + .optional(), + modularizeImports: z + .record( + z.string(), + z.object({ + transform: z.union([z.string(), z.record(z.string(), z.string())]), + preventFullImport: z.boolean().optional(), + skipDefaultConversion: z.boolean().optional(), + }) + ) + .optional(), + onDemandEntries: z + .strictObject({ + maxInactiveAge: z.number().optional(), + pagesBufferLength: z.number().optional(), + }) + .optional(), + optimizeFonts: z.boolean().optional(), + output: z.enum(['standalone', 'export']).optional(), + outputFileTracing: z.boolean().optional(), + pageExtensions: z.array(z.string()).min(1).optional(), + poweredByHeader: z.boolean().optional(), + productionBrowserSourceMaps: z.boolean().optional(), + publicRuntimeConfig: z.record(z.string(), z.any()).optional(), + reactProductionProfiling: z.boolean().optional(), + reactStrictMode: z.boolean().nullable().optional(), + redirects: z + .function() + .args() + .returns(z.promise(z.array(zRedirect))) + .optional(), + rewrites: z + .function() + .args() + .returns( + z.promise( + z.union([ + z.array(zRewrite), + z.object({ + beforeFiles: z.array(zRewrite), + afterFiles: z.array(zRewrite), + fallback: z.array(zRewrite), + }), + ]) + ) + ) + .optional(), + // saas option is unknown, use z.any() here + sassOptions: z.record(z.string(), z.any()).optional(), + serverRuntimeConfig: z.record(z.string(), z.any()).optional(), + skipMiddlewareUrlNormalize: z.boolean().optional(), + skipTrailingSlashRedirect: z.boolean().optional(), + staticPageGenerationTimeout: z.number().optional(), + swcMinify: z.boolean().optional(), + target: z.string().optional(), + trailingSlash: z.boolean().optional(), + transpilePackages: z.array(z.string()).optional(), + typescript: z + .strictObject({ + ignoreBuildErrors: z.boolean().optional(), + tsconfigPath: z.string().min(1).optional(), + }) + .optional(), + useFileSystemPublicRoutes: z.boolean().optional(), + // The webpack config type is unknown, use z.any() here + webpack: z.any().nullable().optional(), + }) +) diff --git a/packages/next/src/server/config-shared.ts b/packages/next/src/server/config-shared.ts index d8108f4158be6..c03928b177cfb 100644 --- a/packages/next/src/server/config-shared.ts +++ b/packages/next/src/server/config-shared.ts @@ -780,19 +780,3 @@ export async function normalizeConfig(phase: string, config: any) { // Support `new Promise` and `async () =>` as return values of the config export return await config } - -export function validateConfig(userConfig: NextConfig): { - errors?: Array | null -} { - if (process.env.NEXT_MINIMAL) { - return { - errors: [], - } - } else { - const configValidator = require('next/dist/next-config-validate.js') - configValidator(userConfig) - return { - errors: configValidator.errors, - } - } -} diff --git a/packages/next/src/server/config.ts b/packages/next/src/server/config.ts index 3937011f9c925..6d224c57a2d69 100644 --- a/packages/next/src/server/config.ts +++ b/packages/next/src/server/config.ts @@ -9,7 +9,6 @@ import { normalizeConfig, ExperimentalConfig, NextConfigComplete, - validateConfig, NextConfig, TurboLoaderItem, } from './config-shared' @@ -21,8 +20,88 @@ import { findRootDir } from '../lib/find-root' import { setHttpClientAndAgentOptions } from './setup-http-agent-env' import { pathHasPrefix } from '../shared/lib/router/utils/path-has-prefix' +import { ZodParsedType, util as ZodUtil } from 'next/dist/compiled/zod' +import type { ZodError, ZodIssue } from 'next/dist/compiled/zod' + export { DomainLocale, NextConfig, normalizeConfig } from './config-shared' +function processZodErrorMessage(issue: ZodIssue) { + let message = issue.message + + let path = '' + + if (issue.path.length > 0) { + if (issue.path.length === 1) { + const identifier = issue.path[0] + if (typeof identifier === 'number') { + // The first identifier inside path is a number + path = `index ${identifier}` + } else { + path = `"${identifier}"` + } + } else { + // joined path to be shown in the error message + path = `"${issue.path.reduce((acc, cur) => { + if (typeof cur === 'number') { + // array index + return `${acc}[${cur}]` + } + if (cur.includes('"')) { + // escape quotes + return `${acc}["${cur.replaceAll('"', '\\"')}"]` + } + // dot notation + const separator = acc.length === 0 ? '' : '.' + return acc + separator + cur + }, '')}"` + } + } + + if ( + issue.code === 'invalid_type' && + issue.received === ZodParsedType.undefined + ) { + // missing key in object + return `${path} is missing, expected ${issue.expected}` + } + if (issue.code === 'invalid_enum_value') { + // Remove "Invalid enum value" prefix from zod default error message + return `Expected ${ZodUtil.joinValues(issue.options)}, received '${ + issue.received + }' at ${path}` + } + + return message + (path ? ` at ${path}` : '') +} + +function normalizeZodErrors( + error: ZodError +): [errorMessages: string[], shouldExit: boolean] { + let shouldExit = false + return [ + error.issues.flatMap((issue) => { + const messages = [processZodErrorMessage(issue)] + if (issue.path[0] === 'images') { + // We exit the build when encountering an error in the images config + shouldExit = true + } + + if ('unionErrors' in issue) { + issue.unionErrors + .map(normalizeZodErrors) + .forEach(([unionMessages, unionShouldExit]) => { + messages.push(...unionMessages) + // If any of the union results shows exit the build, we exit the build + shouldExit = shouldExit || unionShouldExit + }) + } + + return messages + }), + shouldExit, + ] +} + export function warnOptionHasBeenDeprecated( config: NextConfig, nestedPropertyKey: string, @@ -875,38 +954,36 @@ export default async function loadConfig( userConfigModule.default || userConfigModule ) - const validateResult = validateConfig(userConfig) - - if (validateResult.errors) { - // Only load @segment/ajv-human-errors when invalid config is detected - const { AggregateAjvError } = - require('next/dist/compiled/@segment/ajv-human-errors') as typeof import('next/dist/compiled/@segment/ajv-human-errors') - const aggregatedAjvErrors = new AggregateAjvError(validateResult.errors, { - fieldLabels: 'js', - }) + if (!process.env.NEXT_MINIMAL) { + // We only validate the config against schema in non minimal mode + const { configSchema } = + require('./config-schema') as typeof import('./config-schema') + const state = configSchema.safeParse(userConfig) - let shouldExit = false - const messages = [`Invalid ${configFileName} options detected: `] + if (!state.success) { + // error message header + const messages = [`Invalid ${configFileName} options detected: `] - for (const error of aggregatedAjvErrors) { - messages.push(` ${error.message}`) - if (error.message.startsWith('The value at .images.')) { - shouldExit = true + const [errorMessages, shouldExit] = normalizeZodErrors(state.error) + // ident list item + for (const error of errorMessages) { + messages.push(` ${error}`) } - } - messages.push( - 'See more info here: https://nextjs.org/docs/messages/invalid-next-config' - ) + // error message footer + messages.push( + 'See more info here: https://nextjs.org/docs/messages/invalid-next-config' + ) - if (shouldExit) { - for (const message of messages) { - console.error(message) - } - await flushAndExit(1) - } else { - for (const message of messages) { - curLog.warn(message) + if (shouldExit) { + for (const message of messages) { + console.error(message) + } + await flushAndExit(1) + } else { + for (const message of messages) { + curLog.warn(message) + } } } } diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index dd6858d28958b..63e40bf4e59a3 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -338,55 +338,6 @@ export async function ncc_undici(task, opts) { ) } -// eslint-disable-next-line camelcase -export async function compile_config_schema(task, opts) { - const { configSchema } = require('./dist/server/config-schema') - // eslint-disable-next-line - const Ajv = require('ajv') - // eslint-disable-next-line - const standaloneCode = require('ajv/dist/standalone').default - // eslint-disable-next-line - const ajv = new Ajv({ - code: { source: true }, - allErrors: true, - verbose: true, - }) - - // errorMessage keyword will be consumed by @segment/ajv-human-errors to provide a custom error message - ajv.addKeyword('errorMessage') - - ajv.addKeyword({ - keyword: 'isFunction', - schemaType: 'boolean', - compile() { - return (data) => data == null || data instanceof Function - }, - code(ctx) { - const { data } = ctx - ctx.fail(Ajv._`!(${data} == null || ${data} instanceof Function)`) - }, - metaSchema: { - anyOf: [{ type: 'boolean' }], - }, - }) - - const compiled = ajv.compile(configSchema) - const validateCode = standaloneCode(ajv, compiled) - const preNccFilename = join(__dirname, 'dist', 'next-config-validate.js') - await fs.writeFile(preNccFilename, validateCode) - await task - .source('./dist/next-config-validate.js') - .ncc({}) - .target('dist/next-config-validate') - - await fs.unlink(preNccFilename) - await fs.rename( - join(__dirname, 'dist/next-config-validate/next-config-validate.js'), - join(__dirname, 'dist/next-config-validate.js') - ) - await fs.rmdir(join(__dirname, 'dist/next-config-validate')) -} - // eslint-disable-next-line camelcase externals['acorn'] = 'next/dist/compiled/acorn' export async function ncc_acorn(task, opts) { @@ -1150,16 +1101,6 @@ export async function ncc_async_sema(task, opts) { .ncc({ packageName: 'async-sema', externals }) .target('src/compiled/async-sema') } -// eslint-disable-next-line camelcase -export async function ncc_segment_ajv_human_errors(task, opts) { - await task - .source(relative(__dirname, require.resolve('@segment/ajv-human-errors/'))) - .ncc({ - packageName: '@segment/ajv-human-errors/', - externals, - }) - .target('src/compiled/@segment/ajv-human-errors') -} externals['postcss-plugin-stub-for-cssnano-simple'] = 'next/dist/compiled/postcss-plugin-stub-for-cssnano-simple' @@ -2035,7 +1976,7 @@ export async function ncc_unistore(task, opts) { } // eslint-disable-next-line camelcase -externals['unistore'] = 'next/dist/compiled/superstruct' +externals['superstruct'] = 'next/dist/compiled/superstruct' export async function ncc_superstruct(task, opts) { await task .source(relative(__dirname, require.resolve('superstruct'))) @@ -2043,6 +1984,14 @@ export async function ncc_superstruct(task, opts) { .target('src/compiled/superstruct') } +externals['zod'] = 'next/dist/compiled/zod' +export async function ncc_zod(task, opts) { + await task + .source(relative(__dirname, require.resolve('zod'))) + .ncc({ packageName: 'zod', externals }) + .target('src/compiled/zod') +} + // eslint-disable-next-line camelcase externals['web-vitals'] = 'next/dist/compiled/web-vitals' export async function ncc_web_vitals(task, opts) { @@ -2292,7 +2241,6 @@ export async function ncc(task, opts) { 'ncc_arg', 'ncc_async_retry', 'ncc_async_sema', - 'ncc_segment_ajv_human_errors', 'ncc_postcss_plugin_stub_for_cssnano_simple', 'ncc_assert', 'ncc_browser_zlib', @@ -2366,6 +2314,7 @@ export async function ncc(task, opts) { 'ncc_string_hash', 'ncc_strip_ansi', 'ncc_superstruct', + 'ncc_zod', 'ncc_nft', 'ncc_tar', 'ncc_terser', @@ -2664,10 +2613,7 @@ export async function trace(task, opts) { } export async function build(task, opts) { - await task.serial( - ['precompile', 'compile', 'compile_config_schema', 'generate_types'], - opts - ) + await task.serial(['precompile', 'compile', 'generate_types'], opts) } export async function generate_types(task, opts) { diff --git a/packages/next/types/misc.d.ts b/packages/next/types/misc.d.ts index 00633f5acfc78..e2bf73cc271b0 100644 --- a/packages/next/types/misc.d.ts +++ b/packages/next/types/misc.d.ts @@ -388,11 +388,6 @@ declare module 'next/dist/compiled/@edge-runtime/primitives' { export = m } -declare module 'next/dist/compiled/@segment/ajv-human-errors' { - import * as m from '@segment/ajv-human-errors' - export = m -} - declare module 'next/dist/compiled/react' { import * as m from 'react' export = m @@ -480,3 +475,8 @@ declare module 'next/dist/compiled/@opentelemetry/api' { import * as m from '@opentelemetry/api' export = m } + +declare module 'next/dist/compiled/zod' { + import * as m from 'zod' + export = m +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 22bfb1ffa1aab..5237d8843b00a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -937,9 +937,6 @@ importers: '@playwright/test': specifier: ^1.35.1 version: 1.35.1 - '@segment/ajv-human-errors': - specifier: 2.1.2 - version: 2.1.2(ajv@8.11.0) '@taskr/clear': specifier: 1.1.0 version: 1.1.0 @@ -1066,9 +1063,6 @@ importers: acorn: specifier: 8.5.0 version: 8.5.0 - ajv: - specifier: 8.11.0 - version: 8.11.0 amphtml-validator: specifier: 1.0.35 version: 1.0.35 @@ -1323,7 +1317,7 @@ importers: version: 0.13.4 sass-loader: specifier: 12.4.0 - version: 12.4.0(sass@1.54.0)(webpack@5.86.0) + version: 12.4.0(webpack@5.86.0) schema-utils2: specifier: npm:schema-utils@2.7.1 version: /schema-utils@2.7.1 @@ -1426,6 +1420,9 @@ importers: ws: specifier: 8.2.3 version: 8.2.3 + zod: + specifier: 3.22.3 + version: 3.22.3 packages/next-bundle-analyzer: dependencies: @@ -6716,8 +6713,8 @@ packages: resolution: {integrity: sha512-XQr74QaLeMiqhStEhLn1im9EOMnkypp7MZOwQhGzqp2Weu5eQJbpPxWxixxlYRKWPOmJjsk6qYfYH9kq43yc2w==} dev: true - /@next/react-refresh-utils@13.5.3(react-refresh@0.12.0)(webpack@5.86.0): - resolution: {integrity: sha512-Y4wsqtdX+/QZ6W19N3y/YnuxAt/a79l/zYmRc2mwEplP0rIv6W3MBo3ePFUXOMVfmVesnOhfnZanaGiynZcFOg==} + /@next/react-refresh-utils@13.5.4(react-refresh@0.12.0)(webpack@5.86.0): + resolution: {integrity: sha512-Y2bFd17Gn5Wh1gT/P/xTlApmipdrD0JdTdMwhi8G2wD2qj8p7SZbci1kp7zp+utWVp8PFQD6kHAIBrJS9/iEQQ==} peerDependencies: react-refresh: 0.12.0 webpack: 5.86.0 @@ -7410,14 +7407,6 @@ packages: rxjs: 6.6.2 dev: true - /@segment/ajv-human-errors@2.1.2(ajv@8.11.0): - resolution: {integrity: sha512-d1uQndRFLRO01+xW1y5m+joxDgHf5SLJ70YCY2ArLoo2FJ50o6AoX2mEbuGvnKz/IdwnvDugm9Ti3mZQkW1OoA==} - peerDependencies: - ajv: ^8.0.0 - dependencies: - ajv: 8.11.0 - dev: true - /@shuding/opentype.js@1.4.0-beta.0: resolution: {integrity: sha512-3NgmNyH3l/Hv6EvsWJbsvpcpUba6R8IREQ83nH83cyakCw7uM1arZKNfHwv1Wz6jgqrF/j4x5ELvR6PnK9nTcA==} engines: {node: '>= 8.0.0'} @@ -23494,7 +23483,7 @@ packages: /safer-buffer@2.1.2: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} - /sass-loader@12.4.0(sass@1.54.0)(webpack@5.86.0): + /sass-loader@12.4.0(webpack@5.86.0): resolution: {integrity: sha512-7xN+8khDIzym1oL9XyS6zP6Ges+Bo2B2xbPrjdMHEYyV3AQYhd/wXeru++3ODHF0zMjYmVadblSKrPrjEkL8mg==} engines: {node: '>= 12.13.0'} peerDependencies: @@ -23512,7 +23501,6 @@ packages: dependencies: klona: 2.0.4 neo-async: 2.6.2 - sass: 1.54.0 webpack: 5.86.0(@swc/core@1.3.85) dev: true @@ -26763,6 +26751,10 @@ packages: resolution: {integrity: sha512-N+d4UJSJbt/R3wqY7Coqs5pcV0aUj2j9IaQ3rNj9bVCLld8tTGKRa2USARjnvZJWVx1NDmQev8EknoczaOQDOA==} dev: true + /zod@3.22.3: + resolution: {integrity: sha512-EjIevzuJRiRPbVH4mGc8nApb/lVLKVpmUhAaR5R5doKGfAnGJ6Gr3CViAVjP+4FWSxCsybeWQdcgCtbX+7oZug==} + dev: true + /zwitch@1.0.5: resolution: {integrity: sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==} dev: true @@ -26776,7 +26768,7 @@ packages: name: '@vercel/turbopack-ecmascript-runtime' version: 0.0.0 dependencies: - '@next/react-refresh-utils': 13.5.3(react-refresh@0.12.0)(webpack@5.86.0) + '@next/react-refresh-utils': 13.5.4(react-refresh@0.12.0)(webpack@5.86.0) '@types/node': 20.2.5 transitivePeerDependencies: - react-refresh diff --git a/test/integration/config-validation/test/index.test.ts b/test/integration/config-validation/test/index.test.ts index 6f44afe56168d..74c5b8f738c1d 100644 --- a/test/integration/config-validation/test/index.test.ts +++ b/test/integration/config-validation/test/index.test.ts @@ -19,9 +19,9 @@ describe('next.config.js validation', () => { } `, outputs: [ - 'The value at .images.loader must be one of', - 'The value at .rewrites must be a function that returns a Promise', - 'The value at .swcMinify must be a boolean but it was a string', + `received 'something' at "images.loader"`, + 'Expected function, received boolean at "rewrites"', + 'Expected boolean, received string at "swcMinify"', ], }, { @@ -35,8 +35,8 @@ describe('next.config.js validation', () => { } `, outputs: [ - 'The root value has an unexpected property, nonExistent,', - 'The value at .experimental has an unexpected property, anotherNonExistent', + `Unrecognized key(s) in object: 'nonExistent'`, + `Unrecognized key(s) in object: 'anotherNonExistent' at "experimental"`, ], }, ])( diff --git a/test/integration/dist-dir/test/index.test.js b/test/integration/dist-dir/test/index.test.js index d296bc652e730..9901851d56ffd 100644 --- a/test/integration/dist-dir/test/index.test.js +++ b/test/integration/dist-dir/test/index.test.js @@ -83,11 +83,11 @@ describe('distDir', () => { ) }) - it('should handle null/undefined distDir', async () => { + it('should handle undefined distDir', async () => { const origNextConfig = await fs.readFile(nextConfig, 'utf8') await fs.writeFile( nextConfig, - `module.exports = { distDir: null, eslint: { ignoreDuringBuilds: true } }` + `module.exports = { distDir: undefined, eslint: { ignoreDuringBuilds: true } }` ) const { stderr } = await nextBuild(appDir, [], { stderr: true }) await fs.writeFile(nextConfig, origNextConfig) diff --git a/test/integration/image-optimizer/test/index.test.ts b/test/integration/image-optimizer/test/index.test.ts index b0209037a3135..519247edcf750 100644 --- a/test/integration/image-optimizer/test/index.test.ts +++ b/test/integration/image-optimizer/test/index.test.ts @@ -43,7 +43,7 @@ describe('Image Optimizer', () => { await nextConfig.restore() expect(stderr).toContain( - 'The value at .images.domains must have 50 or fewer items but it has 51.' + 'Array must contain at most 50 element(s) at "images.domains"' ) }) @@ -70,7 +70,7 @@ describe('Image Optimizer', () => { await nextConfig.restore() expect(stderr).toContain( - 'The value at .images.remotePatterns must have 50 or fewer items but it has 51.' + 'Array must contain at most 50 element(s) at "images.remotePatterns"' ) }) @@ -95,7 +95,7 @@ describe('Image Optimizer', () => { await nextConfig.restore() expect(stderr).toContain( - 'The value at .images.remotePatterns[0] has an unexpected property, foo, which is not in the list of allowed properties (hostname, pathname, port, protocol).' + `Unrecognized key(s) in object: 'foo' at "images.remotePatterns[0]"` ) }) @@ -120,7 +120,7 @@ describe('Image Optimizer', () => { await nextConfig.restore() expect(stderr).toContain( - "The value at .images.remotePatterns[0] is missing the required field 'hostname'." + `"images.remotePatterns[0].hostname" is missing, expected string` ) }) @@ -145,7 +145,7 @@ describe('Image Optimizer', () => { await nextConfig.restore() expect(stderr).toContain( - 'The value at .images.deviceSizes must have 25 or fewer items but it has 51.' + `Array must contain at most 25 element(s) at "images.deviceSizes"` ) }) @@ -170,10 +170,10 @@ describe('Image Optimizer', () => { await nextConfig.restore() expect(stderr).toContain( - 'The value at .images.deviceSizes[0] must be equal to or greater than 1.' + 'Number must be greater than or equal to 1 at "images.deviceSizes[0]"' ) expect(stderr).toContain( - 'The value at .images.deviceSizes[1] must be equal to or less than 10000.' + 'Number must be less than or equal to 10000 at "images.deviceSizes[1]"' ) }) @@ -198,10 +198,10 @@ describe('Image Optimizer', () => { await nextConfig.restore() expect(stderr).toContain( - 'The value at .images.imageSizes[0] must be equal to or greater than 1.' + 'Number must be greater than or equal to 1 at "images.imageSizes[0]"' ) expect(stderr).toContain( - 'The value at .images.imageSizes[3] must be equal to or less than 10000.' + 'Number must be less than or equal to 10000 at "images.imageSizes[3]"' ) }) @@ -226,7 +226,7 @@ describe('Image Optimizer', () => { await nextConfig.restore() expect(stderr).toContain( - 'The value at .images.loader must be one of: "default", "imgix", "cloudinary", "akamai", or "custom".' + `Expected 'default' | 'imgix' | 'cloudinary' | 'akamai' | 'custom', received 'notreal' at "images.loader"` ) }) @@ -251,7 +251,7 @@ describe('Image Optimizer', () => { await nextConfig.restore() expect(stderr).toContain( - `The value at .images.formats[1] must be one of: "image/avif" or "image/webp".` + `Expected 'image/avif' | 'image/webp', received 'jpeg' at "images.formats[1]"` ) }) @@ -351,7 +351,7 @@ describe('Image Optimizer', () => { await nextConfig.restore() expect(stderr).toContain( - `The value at .images.dangerouslyAllowSVG must be a boolean but it was a string.` + `Expected boolean, received string at "images.dangerouslyAllowSVG"` ) }) @@ -376,7 +376,7 @@ describe('Image Optimizer', () => { await nextConfig.restore() expect(stderr).toContain( - `The value at .images.contentSecurityPolicy must be a string but it was a number.` + `Expected string, received number at "images.contentSecurityPolicy"` ) }) @@ -401,7 +401,7 @@ describe('Image Optimizer', () => { await nextConfig.restore() expect(stderr).toContain( - `The value at .images.contentDispositionType must be one of: "inline" or "attachment".` + `Expected 'inline' | 'attachment', received 'nope' at "images.contentDispositionType"` ) }) @@ -426,7 +426,7 @@ describe('Image Optimizer', () => { await nextConfig.restore() expect(stderr).toContain( - `The value at .images.minimumCacheTTL must be equal to or greater than 0.` + `Number must be greater than or equal to 0 at "images.minimumCacheTTL"` ) }) @@ -451,7 +451,7 @@ describe('Image Optimizer', () => { await nextConfig.restore() expect(stderr).toContain( - `The value at .images.unoptimized must be a boolean but it was a string.` + `Expected boolean, received string at "images.unoptimized"` ) }) })