@visulima/api-platform 2.0.28 → 2.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## @visulima/api-platform [2.0.29](https://github.com/visulima/visulima/compare/@visulima/api-platform@2.0.28...@visulima/api-platform@2.0.29) (2024-03-11)
2
+
3
+
4
+
5
+ ### Dependencies
6
+
7
+ * **@visulima/jsdoc-open-api:** upgraded to 2.0.21
8
+ * **@visulima/fs:** upgraded to 1.3.1
9
+
1
10
  ## @visulima/api-platform [2.0.28](https://github.com/visulima/visulima/compare/@visulima/api-platform@2.0.27...@visulima/api-platform@2.0.28) (2024-03-11)
2
11
 
3
12
 
@@ -7,12 +7,12 @@ import { parseFile, jsDocumentCommentsToOpenApi, swaggerJsDocumentCommentsToOpen
7
7
  import { readdir, realpath, stat } from 'node:fs/promises';
8
8
  import { fileURLToPath } from 'node:url';
9
9
 
10
- var re=(e,r)=>{if(r.length===0)throw new Error("must include at least one key to map");let t=e.toString();return r.forEach(o=>{t=o.optional?t.replace("(?:\\/([^\\/]+?))?\\",`/:${o.name}?`):t.replace("(?:([^\\/]+?))",`:${o.name}`);}),t.replace("/?(?=\\/|$)/i","").replace("/^","").replaceAll("\\","").replaceAll(/\/{2,}/gu,"/")},D=re;var oe=(e,r)=>{if(typeof e=="string")return e;if(e.fast_slash)return "";if(e.fast_star)return "*";let t="";r.length>0&&(t=D(e,r));let o=/^\/\^((?:\\[$()*+./?[\\\]^{|}]|[^$()*+./?[\\\]^{|}])*)\$\//u.exec(e.toString().replace("\\/?","").replace("(?=\\/|$)","$"));return Array.isArray(o)&&o.length>1?o[1].replaceAll(/\\(.)/gu,"$1").slice(1):t?t.slice(1):e.toString()},P=oe;var ie=(e,r,t)=>{let o=e.route.stack.at(-1),i=r.map(a=>({in:"path",name:a.name,required:!a.optional})),n=e.route.stack.filter(a=>a.handle.metadata);if(n.length>1)throw new Error("Only one metadata middleware is allowed per route");let s=(t+e.route.path).replaceAll(/\/{2,}/gu,"/");return n.length===0?{method:o.method,path:s,pathParams:i}:{metadata:n[0].handle.metadata,method:o.method,path:s,pathParams:i}},$=(e,r,t,o)=>{o=[...o,...t.keys],t.name==="router"&&t.handle&&t.handle.stack.forEach(i=>{r=r||"",$(e,`${r}/${P(t.regexp,t.keys)}`,i,o);}),!(!t.route||t.route.stack.length===0)&&e.push(ie(t,o,r));},ne=e=>{let r=e._router||e.router,t=[];return r.stack.forEach(o=>{$(t,"",o,[]);}),t},F=ne;var se=e=>{let r=[];return F(e).forEach(t=>{r.push({file:"unknown",method:t.method.toUpperCase(),path:t.path,tags:[]});}),r},T=se;var L=e=>e.replaceAll(/ \(.*\)/gu,"").trim(),j=e=>e.trim().split(" ")[1].slice(1,-1),ae=e=>{let t=e.printRoutes().replaceAll(/[─│└├]/gu," ").trimEnd().split(`
11
- `),o=t.reduce((n,s,a)=>{let l=L(s);if(L(t[a-1]??"")===l){let te=n.filter(A=>A.index<a&&A.segment===l),{methods:R}=te.at(-1);return R!==null&&R.push(j(s)),n}let p=s.replaceAll(/ \(.*\)/gu,"").match(/ /gu);if(p===null)throw new Error("Invalid spaces");let c=p.length/4,d=s.includes("("),S=d?[j(s)]:null;return n.push({depth:c,index:a,isRoute:d,methods:S,segment:l}),n},[]),i=[];return o.filter(n=>n.isRoute).forEach(n=>{let a=[...o.filter(l=>l.index<n.index&&l.depth<n.depth).filter((l,f,p)=>!p.find(c=>c.depth===l.depth&&c.index>l.index)).map(l=>l.segment),n.segment].join("");if(n.methods===null)throw new Error("Invalid methods");n.methods.forEach(l=>{i.push({file:"unknown",method:l.toUpperCase(),path:a,tags:[]});});}),i},O=ae;var ce=e=>{let t=e._core.router.routes,o=[];return [...t.keys()].forEach(i=>{t.get(i).routes.forEach(n=>{o.push({file:"unknown",method:n.route.method.toUpperCase(),path:n.path,tags:[]});});}),o},N=ce;var le=e=>{let r=[];return e.middleware.filter(t=>t.router).flatMap(t=>t.router.stack).forEach(t=>{r.push({file:"unknown",method:t.methods.join("|").toUpperCase(),path:t.path,tags:[]});}),r},I=le;var C=/\.(js|ts|mjs|cjs)$/u,me=(e,r,t=!1)=>{let o=[],i=parseFile(e,jsDocumentCommentsToOpenApi,t);o=[...o,...i.map(a=>a.spec)];let n=parseFile(e,swaggerJsDocumentCommentsToOpenApi,t);o=[...o,...n.map(a=>a.spec)];let s=[];return o.length===0?(readFileSync(e,"utf8").split(/\r?\n/u).forEach(l=>{let f=/[=aces|]+\s["'|](GET|POST|PUT|PATCH|HEAD|DELETE|OPTIONS)["'|]/u.exec(l);if(f){let[,p]=f;p==="GET"&&(p="GET|HEAD"),s.push({file:e.replace(`${h.cwd()}${h.platform==="win32"?"\\":"/"}`,""),method:p,path:e.replace(r,"").replace(C,"").replaceAll("\\","/"),tags:[]});}}),s.length===0&&s.push({file:e.replace(`${h.cwd()}${h.platform==="win32"?"\\":"/"}`,""),method:"GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS",path:e.replace(r,"").replace(C,"").replaceAll("\\","/"),tags:[]}),s):(o.forEach(a=>{Object.entries(a?.paths??{}).forEach(([f,p])=>{Object.entries(p).forEach(([d,S])=>{s.push({file:e.replace(`${h.cwd()}${h.platform==="win32"?"\\":"/"}`,""),method:d.toUpperCase(),path:f.replaceAll("\\","/"),tags:S.tags});});});}),s)},U=me;var de=class extends Error{root;constructor(e,r){super(`${e instanceof Error?e.message:e} for path "${r}"`),this.cause=e,this.name="WalkError",this.root=r;}},x=de;var ke=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},be=ke,Re=e=>{let r=e.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${r}$`)},B=Re,Ae=e=>e instanceof URL?fileURLToPath(e):e,De=Ae,Pe=(e,r,t,o)=>r&&!r.some(i=>e.endsWith(i))||t&&!t.some(i=>i.test(e))?!1:!(o&&o.some(i=>i.test(e))),w=Pe,$e=async e=>{let r=normalize(e),t=basename(r),o=await stat(r);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:t,path:r}};async function*H(e,{extensions:r,followSymlinks:t=!1,includeDirs:o=!0,includeFiles:i=!0,includeSymlinks:n=!0,match:s,maxDepth:a=Number.POSITIVE_INFINITY,skip:l}={}){if(be(e),a<0)return;let f=s?s.map(c=>typeof c=="string"?B(c):c):void 0,p=l?l.map(c=>typeof c=="string"?B(c):c):void 0;if(e=resolve(De(e)),o&&w(e,r,f,p)&&(yield await $e(e)),!(a<1||!w(e,void 0,void 0,p)))try{for await(let c of await readdir(e,{withFileTypes:!0})){let d=join(e,c.name);if(c.isSymbolicLink())if(t)d=await realpath(d);else if(n&&w(d,r,f,p))yield {isDirectory:c.isDirectory,isFile:c.isFile,isSymbolicLink:c.isSymbolicLink,name:c.name,path:d};else continue;c.isSymbolicLink()||c.isDirectory()?yield*H(d,{extensions:r,followSymlinks:t,includeDirs:o,includeFiles:i,includeSymlinks:n,match:f,maxDepth:a-1,skip:p}):c.isFile()&&i&&w(d,r,f,p)&&(yield {isDirectory:c.isDirectory,isFile:c.isFile,isSymbolicLink:c.isSymbolicLink,name:c.name,path:d});}}catch(c){throw c instanceof x?c:new x(c,e)}}var Fe=async(e,r={})=>{let t={extensions:["js","mjs","cjs","ts"],...r},o=[];for await(let i of H(e,t))o.push(i.path);return o},J=Fe;new TextEncoder;var E=[".js",".ts",".mjs",".cjs"],_=e=>{let r=parse(e);for(;r.base&&r.root!==r.dir;){if(readdirSync(r.dir).find(i=>i==="package.json"))return r.dir;r=parse(r.dir);}return null},G=e=>{let r=`${e}/package.json`,{dependencies:t}=JSON.parse(readFileSync(r).toString());return t?.express?"express":t?.koa&&(t["@koa/router"]||t["koa-router"])?"koa":t?.next?"next":t?.["@hapi/hapi"]?"hapi":t?.fastify?"fastify":null},W=(e,r)=>Object.keys(e).length===0?null:r==="hapi"?typeof e.app.app=="string"?e.app:e:e.app??e;var Y=e=>{try{return statSync(e).isDirectory()}catch{return !1}},Oe=async(e="")=>{let r=join(e,"pages/api");return !Y(r)&&(r=join(e,"src/pages/api"),!Y(r))?[]:J(r,{extensions:E,includeDirs:!1})},V=Oe;var v=async(e,r,t)=>{if(r==="express")return T(e);if(r==="koa")return I(e);if(r==="hapi")return N(e);if(r==="fastify")return O(e);if(r==="next"){let o=await V(e);if(o.length===0)throw new Error(`No API routes found, in "${e}".`);return o.flatMap(i=>U(i,e,t))}return null};var Ne=(e,r)=>{let t=new Map;return e.forEach(o=>{let i=r(o),n=t.get(i);n?n.push(o):t.set(i,[o]);}),t},q=Ne;var Ie=(e,r)=>{let t={ANY:y.redBright,DELETE:y.redBright,GET:y.blue,HEAD:y.hex("#6C7280"),OPTIONS:y.hex("#6C7280"),PATCH:y.yellow,POST:y.yellow,PUT:y.yellow},o;if(e==="GET|HEAD")o=`${y.blue("GET")}${y.grey("|HEAD")}`;else {let f=t[e](e);o=e==="GET"?`${f}${y.grey("|HEAD")}`:f;}let i=e==="GET"?6:14-e.length,n=Array.from({length:i}).fill(" ").join(""),s=process.stdout.columns-16-r.length-4,a=s>0?Array.from({length:s}).fill(".").join(""):"",l=r.split("/").map(f=>[":","["].includes(f[0]??"")?y.yellowBright(f):f).join("/");return ` ${o}${n}${l}${y.grey(a)}`},Me=(e,r={})=>e.map(t=>{if(!(Array.isArray(r.methods)&&r.methods.includes(t.method)))return t.method==="GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS"&&(t.method="ANY"),Ie(t.method,t.path.replace("/pages",""))}).filter(Boolean),k=Me;var Be=async(e,r,t={})=>{let o=join(h.cwd(),r);if(!existsSync(o))throw new Error("No such file, invalid path provided.");let i=_(o);if(!i)throw new Error("Please initialize local package.json.");if(e===void 0){let s=G(i);if(!s)throw new Error("Couldn't detect supported back-end framework.");e=s;}let n=null;if(e==="next")n=await v(o,"next",t.verbose??!1);else {if(!statSync(o).isFile())throw new Error(`${o} is directory, but file expected.`);if(!E.includes(extname(o)))throw new Error("Please specify application .ts/.js/.mjs/.cjs file.");let s=`${i}/.env`;existsSync(s)&&(await import(`${i}/node_modules/dotenv/lib/main.js`)).config({path:s});let a=extname(o)===".ts",l=join(i,"node_modules/.bin/tsc");if(a&&!existsSync(l))throw new Error(`Please install typescript in ${i}`);try{if(a)try{execSync(`${l} --outDir framework-list >&2`,{cwd:i});}catch(c){console.log(`TSC compilation failed. Please resolve issues in your project.
10
+ var re=(e,r)=>{if(r.length===0)throw new Error("must include at least one key to map");let t=e.toString();return r.forEach(o=>{t=o.optional?t.replace("(?:\\/([^\\/]+?))?\\",`/:${o.name}?`):t.replace("(?:([^\\/]+?))",`:${o.name}`);}),t.replace("/?(?=\\/|$)/i","").replace("/^","").replaceAll("\\","").replaceAll(/\/{2,}/gu,"/")},D=re;var oe=(e,r)=>{if(typeof e=="string")return e;if(e.fast_slash)return "";if(e.fast_star)return "*";let t="";r.length>0&&(t=D(e,r));let o=/^\/\^((?:\\[$()*+./?[\\\]^{|}]|[^$()*+./?[\\\]^{|}])*)\$\//u.exec(e.toString().replace("\\/?","").replace("(?=\\/|$)","$"));return Array.isArray(o)&&o.length>1?o[1].replaceAll(/\\(.)/gu,"$1").slice(1):t?t.slice(1):e.toString()},P=oe;var ie=(e,r,t)=>{let o=e.route.stack.at(-1),i=r.map(a=>({in:"path",name:a.name,required:!a.optional})),n=e.route.stack.filter(a=>a.handle.metadata);if(n.length>1)throw new Error("Only one metadata middleware is allowed per route");let s=(t+e.route.path).replaceAll(/\/{2,}/gu,"/");return n.length===0?{method:o.method,path:s,pathParams:i}:{metadata:n[0].handle.metadata,method:o.method,path:s,pathParams:i}},$=(e,r,t,o)=>{o=[...o,...t.keys],t.name==="router"&&t.handle&&t.handle.stack.forEach(i=>{r=r||"",$(e,`${r}/${P(t.regexp,t.keys)}`,i,o);}),!(!t.route||t.route.stack.length===0)&&e.push(ie(t,o,r));},ne=e=>{let r=e._router||e.router,t=[];return r.stack.forEach(o=>{$(t,"",o,[]);}),t},T=ne;var se=e=>{let r=[];return T(e).forEach(t=>{r.push({file:"unknown",method:t.method.toUpperCase(),path:t.path,tags:[]});}),r},F=se;var L=e=>e.replaceAll(/ \(.*\)/gu,"").trim(),j=e=>e.trim().split(" ")[1].slice(1,-1),ae=e=>{let t=e.printRoutes().replaceAll(/[─│└├]/gu," ").trimEnd().split(`
11
+ `),o=t.reduce((n,s,a)=>{let l=L(s);if(L(t[a-1]??"")===l){let te=n.filter(A=>A.index<a&&A.segment===l),{methods:R}=te.at(-1);return R!==null&&R.push(j(s)),n}let p=s.replaceAll(/ \(.*\)/gu,"").match(/ /gu);if(p===null)throw new Error("Invalid spaces");let c=p.length/4,d=s.includes("("),S=d?[j(s)]:null;return n.push({depth:c,index:a,isRoute:d,methods:S,segment:l}),n},[]),i=[];return o.filter(n=>n.isRoute).forEach(n=>{let a=[...o.filter(l=>l.index<n.index&&l.depth<n.depth).filter((l,f,p)=>!p.find(c=>c.depth===l.depth&&c.index>l.index)).map(l=>l.segment),n.segment].join("");if(n.methods===null)throw new Error("Invalid methods");n.methods.forEach(l=>{i.push({file:"unknown",method:l.toUpperCase(),path:a,tags:[]});});}),i},O=ae;var ce=e=>{let t=e._core.router.routes,o=[];return [...t.keys()].forEach(i=>{t.get(i).routes.forEach(n=>{o.push({file:"unknown",method:n.route.method.toUpperCase(),path:n.path,tags:[]});});}),o},N=ce;var le=e=>{let r=[];return e.middleware.filter(t=>t.router).flatMap(t=>t.router.stack).forEach(t=>{r.push({file:"unknown",method:t.methods.join("|").toUpperCase(),path:t.path,tags:[]});}),r},I=le;var C=/\.(js|ts|mjs|cjs)$/u,me=(e,r,t=!1)=>{let o=[],i=parseFile(e,jsDocumentCommentsToOpenApi,t);o=[...o,...i.map(a=>a.spec)];let n=parseFile(e,swaggerJsDocumentCommentsToOpenApi,t);o=[...o,...n.map(a=>a.spec)];let s=[];return o.length===0?(readFileSync(e,"utf8").split(/\r?\n/u).forEach(l=>{let f=/[=aces|]+\s["'|](GET|POST|PUT|PATCH|HEAD|DELETE|OPTIONS)["'|]/u.exec(l);if(f){let[,p]=f;p==="GET"&&(p="GET|HEAD"),s.push({file:e.replace(`${h.cwd()}${h.platform==="win32"?"\\":"/"}`,""),method:p,path:e.replace(r,"").replace(C,"").replaceAll("\\","/"),tags:[]});}}),s.length===0&&s.push({file:e.replace(`${h.cwd()}${h.platform==="win32"?"\\":"/"}`,""),method:"GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS",path:e.replace(r,"").replace(C,"").replaceAll("\\","/"),tags:[]}),s):(o.forEach(a=>{Object.entries(a?.paths??{}).forEach(([f,p])=>{Object.entries(p).forEach(([d,S])=>{s.push({file:e.replace(`${h.cwd()}${h.platform==="win32"?"\\":"/"}`,""),method:d.toUpperCase(),path:f.replaceAll("\\","/"),tags:S.tags});});});}),s)},U=me;var de=class extends Error{root;constructor(e,r){super(`${e instanceof Error?e.message:e} for path "${r}"`),this.cause=e,this.name="WalkError",this.root=r;}},x=de;var ke=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},be=ke,Re=e=>{let r=e.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${r}$`)},B=Re,Ae=e=>e instanceof URL?fileURLToPath(e):e,De=Ae,Pe=(e,r,t,o)=>r&&!r.some(i=>e.endsWith(i))||t&&!t.some(i=>i.test(e))?!1:!(o&&o.some(i=>i.test(e))),w=Pe,$e=async e=>{let r=normalize(e),t=basename(r),o=await stat(r);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:t,path:r}};async function*H(e,{extensions:r,followSymlinks:t=!1,includeDirs:o=!0,includeFiles:i=!0,includeSymlinks:n=!0,match:s,maxDepth:a=Number.POSITIVE_INFINITY,skip:l}={}){if(be(e),a<0)return;let f=s?s.map(c=>typeof c=="string"?B(c):c):void 0,p=l?l.map(c=>typeof c=="string"?B(c):c):void 0;if(e=resolve(De(e)),o&&w(e,r,f,p)&&(yield await $e(e)),!(a<1||!w(e,void 0,void 0,p)))try{for await(let c of await readdir(e,{withFileTypes:!0})){let d=join(e,c.name);if(c.isSymbolicLink())if(t)d=await realpath(d);else if(n&&w(d,r,f,p))yield {isDirectory:c.isDirectory,isFile:c.isFile,isSymbolicLink:c.isSymbolicLink,name:c.name,path:d};else continue;c.isSymbolicLink()||c.isDirectory()?yield*H(d,{extensions:r,followSymlinks:t,includeDirs:o,includeFiles:i,includeSymlinks:n,match:f,maxDepth:a-1,skip:p}):c.isFile()&&i&&w(d,r,f,p)&&(yield {isDirectory:c.isDirectory,isFile:c.isFile,isSymbolicLink:c.isSymbolicLink,name:c.name,path:d});}}catch(c){throw c instanceof x?c:new x(c,e)}}var Te=async(e,r={})=>{let t={extensions:["js","mjs","cjs","ts"],...r},o=[];for await(let i of H(e,t))o.push(i.path);return o},J=Te;new TextEncoder;var E=[".js",".ts",".mjs",".cjs"],_=e=>{let r=parse(e);for(;r.base&&r.root!==r.dir;){if(readdirSync(r.dir).find(i=>i==="package.json"))return r.dir;r=parse(r.dir);}return null},G=e=>{let r=`${e}/package.json`,{dependencies:t}=JSON.parse(readFileSync(r).toString());return t?.express?"express":t?.koa&&(t["@koa/router"]||t["koa-router"])?"koa":t?.next?"next":t?.["@hapi/hapi"]?"hapi":t?.fastify?"fastify":null},W=(e,r)=>Object.keys(e).length===0?null:r==="hapi"?typeof e.app.app=="string"?e.app:e:e.app??e;var Y=e=>{try{return statSync(e).isDirectory()}catch{return !1}},Oe=async(e="")=>{let r=join(e,"pages/api");return !Y(r)&&(r=join(e,"src/pages/api"),!Y(r))?[]:J(r,{extensions:E,includeDirs:!1})},V=Oe;var v=async(e,r,t)=>{if(r==="express")return F(e);if(r==="koa")return I(e);if(r==="hapi")return N(e);if(r==="fastify")return O(e);if(r==="next"){let o=await V(e);if(o.length===0)throw new Error(`No API routes found, in "${e}".`);return o.flatMap(i=>U(i,e,t))}return null};var Ne=(e,r)=>{let t=new Map;return e.forEach(o=>{let i=r(o),n=t.get(i);n?n.push(o):t.set(i,[o]);}),t},q=Ne;var Ie=(e,r)=>{let t={ANY:y.redBright,DELETE:y.redBright,GET:y.blue,HEAD:y.hex("#6C7280"),OPTIONS:y.hex("#6C7280"),PATCH:y.yellow,POST:y.yellow,PUT:y.yellow},o;if(e==="GET|HEAD")o=`${y.blue("GET")}${y.grey("|HEAD")}`;else {let f=t[e](e);o=e==="GET"?`${f}${y.grey("|HEAD")}`:f;}let i=e==="GET"?6:14-e.length,n=Array.from({length:i}).fill(" ").join(""),s=process.stdout.columns-16-r.length-4,a=s>0?Array.from({length:s}).fill(".").join(""):"",l=r.split("/").map(f=>[":","["].includes(f[0]??"")?y.yellowBright(f):f).join("/");return ` ${o}${n}${l}${y.grey(a)}`},Me=(e,r={})=>e.map(t=>{if(!(Array.isArray(r.methods)&&r.methods.includes(t.method)))return t.method==="GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS"&&(t.method="ANY"),Ie(t.method,t.path.replace("/pages",""))}).filter(Boolean),k=Me;var Be=async(e,r,t={})=>{let o=join(h.cwd(),r);if(!existsSync(o))throw new Error("No such file, invalid path provided.");let i=_(o);if(!i)throw new Error("Please initialize local package.json.");if(e===void 0){let s=G(i);if(!s)throw new Error("Couldn't detect supported back-end framework.");e=s;}let n=null;if(e==="next")n=await v(o,"next",t.verbose??!1);else {if(!statSync(o).isFile())throw new Error(`${o} is directory, but file expected.`);if(!E.includes(extname(o)))throw new Error("Please specify application .ts/.js/.mjs/.cjs file.");let s=`${i}/.env`;existsSync(s)&&(await import(`${i}/node_modules/dotenv/lib/main.js`)).config({path:s});let a=extname(o)===".ts",l=join(i,"node_modules/.bin/tsc");if(a&&!existsSync(l))throw new Error(`Please install typescript in ${i}`);try{if(a)try{execSync(`${l} --outDir framework-list >&2`,{cwd:i});}catch(c){console.log(`TSC compilation failed. Please resolve issues in your project.
12
12
  `),console.log(c),rmSync(join(i,"framework-list"),{recursive:!0});}let f=a?join(i,"framework-list",o.replace(i,"").replace(".ts",".js")):o,{default:p}=await import(f);n=await v(["AsyncFunction","Function"].includes(p.constructor.name)?await p():W(p,e),e,t.verbose??!1);}finally{a&&rmSync(join(i,"framework-list"),{recursive:!0});}}if(n===null)throw new Error(`Framework "${e}" is not supported.`);if(Array.isArray(t.includePaths)&&t.includePaths.length>0&&(n=t.includePaths.flatMap(s=>n.filter(a=>a.path.startsWith(s)))),Array.isArray(t.excludePaths)&&t.excludePaths.length>0&&(n=t.excludePaths.flatMap(s=>n.filter(a=>!a.path.startsWith(s)))),typeof t.group=="string"&&t.group!==""){console.log();let s=q(n,l=>t.group==="path"?l.path.replace("/pages","").split("/")[1]:l.tags[0]??"unsorted"),a=0;s.forEach((l,f)=>{a>0&&console.log();let p=(h.stdout.columns-16-f.length)/2,c=p>0?Array.from({length:p}).fill(" ").join(""):"";console.log(c+y.bold.underline(f)),k(l,t).forEach(d=>{console.log(d);}),a+=1;});}else console.log(),k(n,t).forEach(s=>{console.log(s);});console.log(`
13
13
  Listed ${y.greenBright(String(n.length))} HTTP ${n.length===1?"route":"routes"}.
14
14
  `);},lr=Be;
15
15
 
16
16
  export { lr as a };
17
17
  //# sourceMappingURL=out.js.map
18
- //# sourceMappingURL=chunk-JGK44A4N.mjs.map
18
+ //# sourceMappingURL=chunk-BH3TIAIJ.mjs.map
@@ -15,12 +15,12 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
15
  var y__default = /*#__PURE__*/_interopDefault(y);
16
16
  var d__default = /*#__PURE__*/_interopDefault(d);
17
17
 
18
- var te=(e,r)=>{if(r.length===0)throw new Error("must include at least one key to map");let t=e.toString();return r.forEach(o=>{t=o.optional?t.replace("(?:\\/([^\\/]+?))?\\",`/:${o.name}?`):t.replace("(?:([^\\/]+?))",`:${o.name}`);}),t.replace("/?(?=\\/|$)/i","").replace("/^","").replaceAll("\\","").replaceAll(/\/{2,}/gu,"/")},A=te;var re=(e,r)=>{if(typeof e=="string")return e;if(e.fast_slash)return "";if(e.fast_star)return "*";let t="";r.length>0&&(t=A(e,r));let o=/^\/\^((?:\\[$()*+./?[\\\]^{|}]|[^$()*+./?[\\\]^{|}])*)\$\//u.exec(e.toString().replace("\\/?","").replace("(?=\\/|$)","$"));return Array.isArray(o)&&o.length>1?o[1].replaceAll(/\\(.)/gu,"$1").slice(1):t?t.slice(1):e.toString()},D=re;var oe=(e,r,t)=>{let o=e.route.stack.at(-1),i=r.map(a=>({in:"path",name:a.name,required:!a.optional})),n=e.route.stack.filter(a=>a.handle.metadata);if(n.length>1)throw new Error("Only one metadata middleware is allowed per route");let s=(t+e.route.path).replaceAll(/\/{2,}/gu,"/");return n.length===0?{method:o.method,path:s,pathParams:i}:{metadata:n[0].handle.metadata,method:o.method,path:s,pathParams:i}},P=(e,r,t,o)=>{o=[...o,...t.keys],t.name==="router"&&t.handle&&t.handle.stack.forEach(i=>{r=r||"",P(e,`${r}/${D(t.regexp,t.keys)}`,i,o);}),!(!t.route||t.route.stack.length===0)&&e.push(oe(t,o,r));},ie=e=>{let r=e._router||e.router,t=[];return r.stack.forEach(o=>{P(t,"",o,[]);}),t},$=ie;var ne=e=>{let r=[];return $(e).forEach(t=>{r.push({file:"unknown",method:t.method.toUpperCase(),path:t.path,tags:[]});}),r},F=ne;var T=e=>e.replaceAll(/ \(.*\)/gu,"").trim(),L=e=>e.trim().split(" ")[1].slice(1,-1),se=e=>{let t=e.printRoutes().replaceAll(/[─│└├]/gu," ").trimEnd().split(`
19
- `),o=t.reduce((n,s,a)=>{let l=T(s);if(T(t[a-1]??"")===l){let ee=n.filter(R=>R.index<a&&R.segment===l),{methods:b}=ee.at(-1);return b!==null&&b.push(L(s)),n}let p=s.replaceAll(/ \(.*\)/gu,"").match(/ /gu);if(p===null)throw new Error("Invalid spaces");let c=p.length/4,m=s.includes("("),E=m?[L(s)]:null;return n.push({depth:c,index:a,isRoute:m,methods:E,segment:l}),n},[]),i=[];return o.filter(n=>n.isRoute).forEach(n=>{let a=[...o.filter(l=>l.index<n.index&&l.depth<n.depth).filter((l,f,p)=>!p.find(c=>c.depth===l.depth&&c.index>l.index)).map(l=>l.segment),n.segment].join("");if(n.methods===null)throw new Error("Invalid methods");n.methods.forEach(l=>{i.push({file:"unknown",method:l.toUpperCase(),path:a,tags:[]});});}),i},j=se;var ae=e=>{let t=e._core.router.routes,o=[];return [...t.keys()].forEach(i=>{t.get(i).routes.forEach(n=>{o.push({file:"unknown",method:n.route.method.toUpperCase(),path:n.path,tags:[]});});}),o},O=ae;var ce=e=>{let r=[];return e.middleware.filter(t=>t.router).flatMap(t=>t.router.stack).forEach(t=>{r.push({file:"unknown",method:t.methods.join("|").toUpperCase(),path:t.path,tags:[]});}),r},N=ce;var M=/\.(js|ts|mjs|cjs)$/u,ue=(e,r,t=!1)=>{let o=[],i=jsdocOpenApi.parseFile(e,jsdocOpenApi.jsDocumentCommentsToOpenApi,t);o=[...o,...i.map(a=>a.spec)];let n=jsdocOpenApi.parseFile(e,jsdocOpenApi.swaggerJsDocumentCommentsToOpenApi,t);o=[...o,...n.map(a=>a.spec)];let s=[];return o.length===0?(fs.readFileSync(e,"utf8").split(/\r?\n/u).forEach(l=>{let f=/[=aces|]+\s["'|](GET|POST|PUT|PATCH|HEAD|DELETE|OPTIONS)["'|]/u.exec(l);if(f){let[,p]=f;p==="GET"&&(p="GET|HEAD"),s.push({file:e.replace(`${y__default.default.cwd()}${y__default.default.platform==="win32"?"\\":"/"}`,""),method:p,path:e.replace(r,"").replace(M,"").replaceAll("\\","/"),tags:[]});}}),s.length===0&&s.push({file:e.replace(`${y__default.default.cwd()}${y__default.default.platform==="win32"?"\\":"/"}`,""),method:"GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS",path:e.replace(r,"").replace(M,"").replaceAll("\\","/"),tags:[]}),s):(o.forEach(a=>{Object.entries(a?.paths??{}).forEach(([f,p])=>{Object.entries(p).forEach(([m,E])=>{s.push({file:e.replace(`${y__default.default.cwd()}${y__default.default.platform==="win32"?"\\":"/"}`,""),method:m.toUpperCase(),path:f.replaceAll("\\","/"),tags:E.tags});});});}),s)},C=ue;var me=class extends Error{root;constructor(e,r){super(`${e instanceof Error?e.message:e} for path "${r}"`),this.cause=e,this.name="WalkError",this.root=r;}},S=me;var ve=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},ke=ve,be=e=>{let r=e.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${r}$`)},U=be,Re=e=>e instanceof URL?url.fileURLToPath(e):e,Ae=Re,De=(e,r,t,o)=>r&&!r.some(i=>e.endsWith(i))||t&&!t.some(i=>i.test(e))?!1:!(o&&o.some(i=>i.test(e))),g=De,Pe=async e=>{let r=path.normalize(e),t=path.basename(r),o=await promises.stat(r);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:t,path:r}};async function*B(e,{extensions:r,followSymlinks:t=!1,includeDirs:o=!0,includeFiles:i=!0,includeSymlinks:n=!0,match:s,maxDepth:a=Number.POSITIVE_INFINITY,skip:l}={}){if(ke(e),a<0)return;let f=s?s.map(c=>typeof c=="string"?U(c):c):void 0,p=l?l.map(c=>typeof c=="string"?U(c):c):void 0;if(e=path.resolve(Ae(e)),o&&g(e,r,f,p)&&(yield await Pe(e)),!(a<1||!g(e,void 0,void 0,p)))try{for await(let c of await promises.readdir(e,{withFileTypes:!0})){let m=path.join(e,c.name);if(c.isSymbolicLink())if(t)m=await promises.realpath(m);else if(n&&g(m,r,f,p))yield {isDirectory:c.isDirectory,isFile:c.isFile,isSymbolicLink:c.isSymbolicLink,name:c.name,path:m};else continue;c.isSymbolicLink()||c.isDirectory()?yield*B(m,{extensions:r,followSymlinks:t,includeDirs:o,includeFiles:i,includeSymlinks:n,match:f,maxDepth:a-1,skip:p}):c.isFile()&&i&&g(m,r,f,p)&&(yield {isDirectory:c.isDirectory,isFile:c.isFile,isSymbolicLink:c.isSymbolicLink,name:c.name,path:m});}}catch(c){throw c instanceof S?c:new S(c,e)}}var $e=async(e,r={})=>{let t={extensions:["js","mjs","cjs","ts"],...r},o=[];for await(let i of B(e,t))o.push(i.path);return o},H=$e;new TextEncoder;var w=[".js",".ts",".mjs",".cjs"],K=e=>{let r=path.parse(e);for(;r.base&&r.root!==r.dir;){if(fs.readdirSync(r.dir).find(i=>i==="package.json"))return r.dir;r=path.parse(r.dir);}return null},_=e=>{let r=`${e}/package.json`,{dependencies:t}=JSON.parse(fs.readFileSync(r).toString());return t?.express?"express":t?.koa&&(t["@koa/router"]||t["koa-router"])?"koa":t?.next?"next":t?.["@hapi/hapi"]?"hapi":t?.fastify?"fastify":null},G=(e,r)=>Object.keys(e).length===0?null:r==="hapi"?typeof e.app.app=="string"?e.app:e:e.app??e;var z=e=>{try{return fs.statSync(e).isDirectory()}catch{return !1}},je=async(e="")=>{let r=path.join(e,"pages/api");return !z(r)&&(r=path.join(e,"src/pages/api"),!z(r))?[]:H(r,{extensions:w,includeDirs:!1})},Y=je;var x=async(e,r,t)=>{if(r==="express")return F(e);if(r==="koa")return N(e);if(r==="hapi")return O(e);if(r==="fastify")return j(e);if(r==="next"){let o=await Y(e);if(o.length===0)throw new Error(`No API routes found, in "${e}".`);return o.flatMap(i=>C(i,e,t))}return null};var Oe=(e,r)=>{let t=new Map;return e.forEach(o=>{let i=r(o),n=t.get(i);n?n.push(o):t.set(i,[o]);}),t},V=Oe;var Ne=(e,r)=>{let t={ANY:d__default.default.redBright,DELETE:d__default.default.redBright,GET:d__default.default.blue,HEAD:d__default.default.hex("#6C7280"),OPTIONS:d__default.default.hex("#6C7280"),PATCH:d__default.default.yellow,POST:d__default.default.yellow,PUT:d__default.default.yellow},o;if(e==="GET|HEAD")o=`${d__default.default.blue("GET")}${d__default.default.grey("|HEAD")}`;else {let f=t[e](e);o=e==="GET"?`${f}${d__default.default.grey("|HEAD")}`:f;}let i=e==="GET"?6:14-e.length,n=Array.from({length:i}).fill(" ").join(""),s=process.stdout.columns-16-r.length-4,a=s>0?Array.from({length:s}).fill(".").join(""):"",l=r.split("/").map(f=>[":","["].includes(f[0]??"")?d__default.default.yellowBright(f):f).join("/");return ` ${o}${n}${l}${d__default.default.grey(a)}`},Ie=(e,r={})=>e.map(t=>{if(!(Array.isArray(r.methods)&&r.methods.includes(t.method)))return t.method==="GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS"&&(t.method="ANY"),Ne(t.method,t.path.replace("/pages",""))}).filter(Boolean),v=Ie;var Ue=async(e,r,t={})=>{let o=path.join(y__default.default.cwd(),r);if(!fs.existsSync(o))throw new Error("No such file, invalid path provided.");let i=K(o);if(!i)throw new Error("Please initialize local package.json.");if(e===void 0){let s=_(i);if(!s)throw new Error("Couldn't detect supported back-end framework.");e=s;}let n=null;if(e==="next")n=await x(o,"next",t.verbose??!1);else {if(!fs.statSync(o).isFile())throw new Error(`${o} is directory, but file expected.`);if(!w.includes(path.extname(o)))throw new Error("Please specify application .ts/.js/.mjs/.cjs file.");let s=`${i}/.env`;fs.existsSync(s)&&(await import(`${i}/node_modules/dotenv/lib/main.js`)).config({path:s});let a=path.extname(o)===".ts",l=path.join(i,"node_modules/.bin/tsc");if(a&&!fs.existsSync(l))throw new Error(`Please install typescript in ${i}`);try{if(a)try{child_process.execSync(`${l} --outDir framework-list >&2`,{cwd:i});}catch(c){console.log(`TSC compilation failed. Please resolve issues in your project.
18
+ var te=(e,r)=>{if(r.length===0)throw new Error("must include at least one key to map");let t=e.toString();return r.forEach(o=>{t=o.optional?t.replace("(?:\\/([^\\/]+?))?\\",`/:${o.name}?`):t.replace("(?:([^\\/]+?))",`:${o.name}`);}),t.replace("/?(?=\\/|$)/i","").replace("/^","").replaceAll("\\","").replaceAll(/\/{2,}/gu,"/")},A=te;var re=(e,r)=>{if(typeof e=="string")return e;if(e.fast_slash)return "";if(e.fast_star)return "*";let t="";r.length>0&&(t=A(e,r));let o=/^\/\^((?:\\[$()*+./?[\\\]^{|}]|[^$()*+./?[\\\]^{|}])*)\$\//u.exec(e.toString().replace("\\/?","").replace("(?=\\/|$)","$"));return Array.isArray(o)&&o.length>1?o[1].replaceAll(/\\(.)/gu,"$1").slice(1):t?t.slice(1):e.toString()},D=re;var oe=(e,r,t)=>{let o=e.route.stack.at(-1),i=r.map(a=>({in:"path",name:a.name,required:!a.optional})),n=e.route.stack.filter(a=>a.handle.metadata);if(n.length>1)throw new Error("Only one metadata middleware is allowed per route");let s=(t+e.route.path).replaceAll(/\/{2,}/gu,"/");return n.length===0?{method:o.method,path:s,pathParams:i}:{metadata:n[0].handle.metadata,method:o.method,path:s,pathParams:i}},P=(e,r,t,o)=>{o=[...o,...t.keys],t.name==="router"&&t.handle&&t.handle.stack.forEach(i=>{r=r||"",P(e,`${r}/${D(t.regexp,t.keys)}`,i,o);}),!(!t.route||t.route.stack.length===0)&&e.push(oe(t,o,r));},ie=e=>{let r=e._router||e.router,t=[];return r.stack.forEach(o=>{P(t,"",o,[]);}),t},$=ie;var ne=e=>{let r=[];return $(e).forEach(t=>{r.push({file:"unknown",method:t.method.toUpperCase(),path:t.path,tags:[]});}),r},T=ne;var F=e=>e.replaceAll(/ \(.*\)/gu,"").trim(),L=e=>e.trim().split(" ")[1].slice(1,-1),se=e=>{let t=e.printRoutes().replaceAll(/[─│└├]/gu," ").trimEnd().split(`
19
+ `),o=t.reduce((n,s,a)=>{let l=F(s);if(F(t[a-1]??"")===l){let ee=n.filter(R=>R.index<a&&R.segment===l),{methods:b}=ee.at(-1);return b!==null&&b.push(L(s)),n}let p=s.replaceAll(/ \(.*\)/gu,"").match(/ /gu);if(p===null)throw new Error("Invalid spaces");let c=p.length/4,m=s.includes("("),E=m?[L(s)]:null;return n.push({depth:c,index:a,isRoute:m,methods:E,segment:l}),n},[]),i=[];return o.filter(n=>n.isRoute).forEach(n=>{let a=[...o.filter(l=>l.index<n.index&&l.depth<n.depth).filter((l,f,p)=>!p.find(c=>c.depth===l.depth&&c.index>l.index)).map(l=>l.segment),n.segment].join("");if(n.methods===null)throw new Error("Invalid methods");n.methods.forEach(l=>{i.push({file:"unknown",method:l.toUpperCase(),path:a,tags:[]});});}),i},j=se;var ae=e=>{let t=e._core.router.routes,o=[];return [...t.keys()].forEach(i=>{t.get(i).routes.forEach(n=>{o.push({file:"unknown",method:n.route.method.toUpperCase(),path:n.path,tags:[]});});}),o},O=ae;var ce=e=>{let r=[];return e.middleware.filter(t=>t.router).flatMap(t=>t.router.stack).forEach(t=>{r.push({file:"unknown",method:t.methods.join("|").toUpperCase(),path:t.path,tags:[]});}),r},N=ce;var M=/\.(js|ts|mjs|cjs)$/u,ue=(e,r,t=!1)=>{let o=[],i=jsdocOpenApi.parseFile(e,jsdocOpenApi.jsDocumentCommentsToOpenApi,t);o=[...o,...i.map(a=>a.spec)];let n=jsdocOpenApi.parseFile(e,jsdocOpenApi.swaggerJsDocumentCommentsToOpenApi,t);o=[...o,...n.map(a=>a.spec)];let s=[];return o.length===0?(fs.readFileSync(e,"utf8").split(/\r?\n/u).forEach(l=>{let f=/[=aces|]+\s["'|](GET|POST|PUT|PATCH|HEAD|DELETE|OPTIONS)["'|]/u.exec(l);if(f){let[,p]=f;p==="GET"&&(p="GET|HEAD"),s.push({file:e.replace(`${y__default.default.cwd()}${y__default.default.platform==="win32"?"\\":"/"}`,""),method:p,path:e.replace(r,"").replace(M,"").replaceAll("\\","/"),tags:[]});}}),s.length===0&&s.push({file:e.replace(`${y__default.default.cwd()}${y__default.default.platform==="win32"?"\\":"/"}`,""),method:"GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS",path:e.replace(r,"").replace(M,"").replaceAll("\\","/"),tags:[]}),s):(o.forEach(a=>{Object.entries(a?.paths??{}).forEach(([f,p])=>{Object.entries(p).forEach(([m,E])=>{s.push({file:e.replace(`${y__default.default.cwd()}${y__default.default.platform==="win32"?"\\":"/"}`,""),method:m.toUpperCase(),path:f.replaceAll("\\","/"),tags:E.tags});});});}),s)},C=ue;var me=class extends Error{root;constructor(e,r){super(`${e instanceof Error?e.message:e} for path "${r}"`),this.cause=e,this.name="WalkError",this.root=r;}},S=me;var ve=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},ke=ve,be=e=>{let r=e.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${r}$`)},U=be,Re=e=>e instanceof URL?url.fileURLToPath(e):e,Ae=Re,De=(e,r,t,o)=>r&&!r.some(i=>e.endsWith(i))||t&&!t.some(i=>i.test(e))?!1:!(o&&o.some(i=>i.test(e))),g=De,Pe=async e=>{let r=path.normalize(e),t=path.basename(r),o=await promises.stat(r);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:t,path:r}};async function*B(e,{extensions:r,followSymlinks:t=!1,includeDirs:o=!0,includeFiles:i=!0,includeSymlinks:n=!0,match:s,maxDepth:a=Number.POSITIVE_INFINITY,skip:l}={}){if(ke(e),a<0)return;let f=s?s.map(c=>typeof c=="string"?U(c):c):void 0,p=l?l.map(c=>typeof c=="string"?U(c):c):void 0;if(e=path.resolve(Ae(e)),o&&g(e,r,f,p)&&(yield await Pe(e)),!(a<1||!g(e,void 0,void 0,p)))try{for await(let c of await promises.readdir(e,{withFileTypes:!0})){let m=path.join(e,c.name);if(c.isSymbolicLink())if(t)m=await promises.realpath(m);else if(n&&g(m,r,f,p))yield {isDirectory:c.isDirectory,isFile:c.isFile,isSymbolicLink:c.isSymbolicLink,name:c.name,path:m};else continue;c.isSymbolicLink()||c.isDirectory()?yield*B(m,{extensions:r,followSymlinks:t,includeDirs:o,includeFiles:i,includeSymlinks:n,match:f,maxDepth:a-1,skip:p}):c.isFile()&&i&&g(m,r,f,p)&&(yield {isDirectory:c.isDirectory,isFile:c.isFile,isSymbolicLink:c.isSymbolicLink,name:c.name,path:m});}}catch(c){throw c instanceof S?c:new S(c,e)}}var $e=async(e,r={})=>{let t={extensions:["js","mjs","cjs","ts"],...r},o=[];for await(let i of B(e,t))o.push(i.path);return o},H=$e;new TextEncoder;var w=[".js",".ts",".mjs",".cjs"],K=e=>{let r=path.parse(e);for(;r.base&&r.root!==r.dir;){if(fs.readdirSync(r.dir).find(i=>i==="package.json"))return r.dir;r=path.parse(r.dir);}return null},_=e=>{let r=`${e}/package.json`,{dependencies:t}=JSON.parse(fs.readFileSync(r).toString());return t?.express?"express":t?.koa&&(t["@koa/router"]||t["koa-router"])?"koa":t?.next?"next":t?.["@hapi/hapi"]?"hapi":t?.fastify?"fastify":null},G=(e,r)=>Object.keys(e).length===0?null:r==="hapi"?typeof e.app.app=="string"?e.app:e:e.app??e;var z=e=>{try{return fs.statSync(e).isDirectory()}catch{return !1}},je=async(e="")=>{let r=path.join(e,"pages/api");return !z(r)&&(r=path.join(e,"src/pages/api"),!z(r))?[]:H(r,{extensions:w,includeDirs:!1})},Y=je;var x=async(e,r,t)=>{if(r==="express")return T(e);if(r==="koa")return N(e);if(r==="hapi")return O(e);if(r==="fastify")return j(e);if(r==="next"){let o=await Y(e);if(o.length===0)throw new Error(`No API routes found, in "${e}".`);return o.flatMap(i=>C(i,e,t))}return null};var Oe=(e,r)=>{let t=new Map;return e.forEach(o=>{let i=r(o),n=t.get(i);n?n.push(o):t.set(i,[o]);}),t},V=Oe;var Ne=(e,r)=>{let t={ANY:d__default.default.redBright,DELETE:d__default.default.redBright,GET:d__default.default.blue,HEAD:d__default.default.hex("#6C7280"),OPTIONS:d__default.default.hex("#6C7280"),PATCH:d__default.default.yellow,POST:d__default.default.yellow,PUT:d__default.default.yellow},o;if(e==="GET|HEAD")o=`${d__default.default.blue("GET")}${d__default.default.grey("|HEAD")}`;else {let f=t[e](e);o=e==="GET"?`${f}${d__default.default.grey("|HEAD")}`:f;}let i=e==="GET"?6:14-e.length,n=Array.from({length:i}).fill(" ").join(""),s=process.stdout.columns-16-r.length-4,a=s>0?Array.from({length:s}).fill(".").join(""):"",l=r.split("/").map(f=>[":","["].includes(f[0]??"")?d__default.default.yellowBright(f):f).join("/");return ` ${o}${n}${l}${d__default.default.grey(a)}`},Ie=(e,r={})=>e.map(t=>{if(!(Array.isArray(r.methods)&&r.methods.includes(t.method)))return t.method==="GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS"&&(t.method="ANY"),Ne(t.method,t.path.replace("/pages",""))}).filter(Boolean),v=Ie;var Ue=async(e,r,t={})=>{let o=path.join(y__default.default.cwd(),r);if(!fs.existsSync(o))throw new Error("No such file, invalid path provided.");let i=K(o);if(!i)throw new Error("Please initialize local package.json.");if(e===void 0){let s=_(i);if(!s)throw new Error("Couldn't detect supported back-end framework.");e=s;}let n=null;if(e==="next")n=await x(o,"next",t.verbose??!1);else {if(!fs.statSync(o).isFile())throw new Error(`${o} is directory, but file expected.`);if(!w.includes(path.extname(o)))throw new Error("Please specify application .ts/.js/.mjs/.cjs file.");let s=`${i}/.env`;fs.existsSync(s)&&(await import(`${i}/node_modules/dotenv/lib/main.js`)).config({path:s});let a=path.extname(o)===".ts",l=path.join(i,"node_modules/.bin/tsc");if(a&&!fs.existsSync(l))throw new Error(`Please install typescript in ${i}`);try{if(a)try{child_process.execSync(`${l} --outDir framework-list >&2`,{cwd:i});}catch(c){console.log(`TSC compilation failed. Please resolve issues in your project.
20
20
  `),console.log(c),fs.rmSync(path.join(i,"framework-list"),{recursive:!0});}let f=a?path.join(i,"framework-list",o.replace(i,"").replace(".ts",".js")):o,{default:p}=await import(f);n=await x(["AsyncFunction","Function"].includes(p.constructor.name)?await p():G(p,e),e,t.verbose??!1);}finally{a&&fs.rmSync(path.join(i,"framework-list"),{recursive:!0});}}if(n===null)throw new Error(`Framework "${e}" is not supported.`);if(Array.isArray(t.includePaths)&&t.includePaths.length>0&&(n=t.includePaths.flatMap(s=>n.filter(a=>a.path.startsWith(s)))),Array.isArray(t.excludePaths)&&t.excludePaths.length>0&&(n=t.excludePaths.flatMap(s=>n.filter(a=>!a.path.startsWith(s)))),typeof t.group=="string"&&t.group!==""){console.log();let s=V(n,l=>t.group==="path"?l.path.replace("/pages","").split("/")[1]:l.tags[0]??"unsorted"),a=0;s.forEach((l,f)=>{a>0&&console.log();let p=(y__default.default.stdout.columns-16-f.length)/2,c=p>0?Array.from({length:p}).fill(" ").join(""):"";console.log(c+d__default.default.bold.underline(f)),v(l,t).forEach(m=>{console.log(m);}),a+=1;});}else console.log(),v(n,t).forEach(s=>{console.log(s);});console.log(`
21
21
  Listed ${d__default.default.greenBright(String(n.length))} HTTP ${n.length===1?"route":"routes"}.
22
22
  `);},Rr=Ue;
23
23
 
24
24
  exports.a = Rr;
25
25
  //# sourceMappingURL=out.js.map
26
- //# sourceMappingURL=chunk-6BXAS5PQ.js.map
26
+ //# sourceMappingURL=chunk-O2ZQIAT5.js.map
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunk6BXAS5PQ_js = require('../../../chunk-6BXAS5PQ.js');
3
+ var chunkO2ZQIAT5_js = require('../../../chunk-O2ZQIAT5.js');
4
4
  require('../../../chunk-3XT5P2HO.js');
5
5
  var process = require('process');
6
6
 
7
- var i=(o,t="list",r="List all available API routes; Supported frameworks are next, express, koa, hapi and fastify")=>{o.command(t).description(r).option("--framework <framework>","Framework to use, choose from next, express, koa, hapi and fastify").option("-p, --path [path]","...").option("--group [type]","Groups routes. Supported: path, tag").option("--include-path [path]","Includes only routes which contain a given path element. (comma-separated values)",[]).option("--exclude-path [path]","Excludes routes which contain a given path element. (comma-separated values)",[]).option("-v, --verbose","Verbose output.",!1).action(async e=>{try{await chunk6BXAS5PQ_js.a(e.framework,e.path,{excludePaths:e.excludePaths??[],group:e.group,includePaths:e.includePath??[],verbose:e.verbose});}catch(s){console.log(),console.error(s),process.exit(1);}});},m=i;
7
+ var i=(o,t="list",r="List all available API routes; Supported frameworks are next, express, koa, hapi and fastify")=>{o.command(t).description(r).option("--framework <framework>","Framework to use, choose from next, express, koa, hapi and fastify").option("-p, --path [path]","...").option("--group [type]","Groups routes. Supported: path, tag").option("--include-path [path]","Includes only routes which contain a given path element. (comma-separated values)",[]).option("--exclude-path [path]","Excludes routes which contain a given path element. (comma-separated values)",[]).option("-v, --verbose","Verbose output.",!1).action(async e=>{try{await chunkO2ZQIAT5_js.a(e.framework,e.path,{excludePaths:e.excludePaths??[],group:e.group,includePaths:e.includePath??[],verbose:e.verbose});}catch(s){console.log(),console.error(s),process.exit(1);}});},m=i;
8
8
 
9
9
  exports.listCommand = m;
10
10
  //# sourceMappingURL=out.js.map
@@ -1,4 +1,4 @@
1
- import { a } from '../../../chunk-JGK44A4N.mjs';
1
+ import { a } from '../../../chunk-BH3TIAIJ.mjs';
2
2
  import '../../../chunk-HTAA47WA.mjs';
3
3
  import { exit } from 'node:process';
4
4
 
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunk6BXAS5PQ_js = require('../../chunk-6BXAS5PQ.js');
3
+ var chunkO2ZQIAT5_js = require('../../chunk-O2ZQIAT5.js');
4
4
  require('../../chunk-3XT5P2HO.js');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, 'listCommand', {
9
9
  enumerable: true,
10
- get: function () { return chunk6BXAS5PQ_js.a; }
10
+ get: function () { return chunkO2ZQIAT5_js.a; }
11
11
  });
12
12
  //# sourceMappingURL=out.js.map
13
13
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- export { a as listCommand } from '../../chunk-JGK44A4N.mjs';
1
+ export { a as listCommand } from '../../chunk-BH3TIAIJ.mjs';
2
2
  import '../../chunk-HTAA47WA.mjs';
3
3
  //# sourceMappingURL=out.js.map
4
4
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/api-platform",
3
- "version": "2.0.28",
3
+ "version": "2.0.29",
4
4
  "description": "Visulima API platform is a set of tools to build and consume web APIs",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -142,7 +142,7 @@
142
142
  },
143
143
  "dependencies": {
144
144
  "@visulima/connect": "3.0.2",
145
- "@visulima/jsdoc-open-api": "2.0.20",
145
+ "@visulima/jsdoc-open-api": "2.0.21",
146
146
  "accepts": "^1.3.8",
147
147
  "debug": "^4.3.4",
148
148
  "http-errors": "^2.0.0",
@@ -182,7 +182,7 @@
182
182
  "@types/swagger-ui-react": "^4.18.3",
183
183
  "@types/webpack": "^5.28.5",
184
184
  "@visulima/crud": "2.0.16",
185
- "@visulima/fs": "1.3.0",
185
+ "@visulima/fs": "1.3.1",
186
186
  "@vitest/coverage-v8": "^1.3.1",
187
187
  "@vitest/ui": "^1.3.1",
188
188
  "chalk": "5.3.0",