@point-hub/papi 0.1.2 → 0.1.4
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/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ declare function skip(currentPage: string | number, pageSize: string | number):
|
|
|
28
28
|
declare function filter(filter: never): never;
|
|
29
29
|
declare function fields(fields?: string, excludeFields?: string[]): IFieldsObject;
|
|
30
30
|
declare function convertStringToArray(fields: string): string[];
|
|
31
|
-
declare function convertArrayToObject(array: string[]): IFieldsObject;
|
|
31
|
+
declare function convertArrayToObject(array: string[], value?: number): IFieldsObject;
|
|
32
32
|
declare function filterExludeFields(obj: IFieldsObject, excludeFields: string[]): IFieldsObject;
|
|
33
33
|
declare function sort(fields: string): ISortObject;
|
|
34
34
|
declare const _default: {
|
package/lib/index.js
CHANGED
|
@@ -13,4 +13,4 @@ Instructions:
|
|
|
13
13
|
[a,b,c]/delete: Filter choices
|
|
14
14
|
enter/return: Complete answer
|
|
15
15
|
`}return""}renderCurrentInput(){return`
|
|
16
|
-
Filtered results for: ${this.inputValue?this.inputValue:Q0.gray("Enter something to filter")}\n`}renderOption(U,Z,J){let Q;if(Z.disabled)Q=U===J?Q0.gray().underline(Z.title):Q0.strikethrough().gray(Z.title);else Q=U===J?Q0.cyan().underline(Z.title):Z.title;return(Z.selected?Q0.green(T0.radioOn):T0.radioOff)+" "+Q}renderDoneOrInstructions(){if(this.done)return this.value.filter((Z)=>Z.selected).map((Z)=>Z.title).join(", ");const U=[Q0.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];if(this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled)U.push(Q0.yellow(this.warn));return U.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(wQ.hide);super.render();let U=[GU.symbol(this.done,this.aborted),Q0.bold(this.msg),GU.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)U+=Q0.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;U+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+U),this.clear=zU(U,this.out.columns)}}HU.exports=EU});var $U=E((IY,WU)=>{var BU=A(),kQ=Z0(),{style:MU,clear:bQ}=g(),{erase:hQ,cursor:FU}=P();class RU extends kQ{constructor(U={}){super(U);this.msg=U.message,this.value=U.initial,this.initialValue=!!U.initial,this.yesMsg=U.yes||"yes",this.yesOption=U.yesOption||"(Y/n)",this.noMsg=U.no||"no",this.noOption=U.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}_(U,Z){if(U.toLowerCase()==="y")return this.value=!0,this.submit();if(U.toLowerCase()==="n")return this.value=!1,this.submit();return this.bell()}render(){if(this.closed)return;if(this.firstRender)this.out.write(FU.hide);else this.out.write(bQ(this.outputText,this.out.columns));super.render(),this.outputText=[MU.symbol(this.done,this.aborted),BU.bold(this.msg),MU.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:BU.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(hQ.line+FU.to(0)+this.outputText)}}WU.exports=RU});var OU=E((TY,NU)=>{NU.exports={TextPrompt:Z4(),SelectPrompt:Y4(),TogglePrompt:H4(),DatePrompt:a4(),NumberPrompt:o4(),MultiselectPrompt:r1(),AutocompletePrompt:DU(),AutocompleteMultiselectPrompt:VU(),ConfirmPrompt:$U()}});var TU=E((IU)=>{var a=function(U,Z,J={}){return new Promise((Q,K)=>{const X=new vQ[U](Z),Y=J.onAbort||H1,z=J.onSubmit||H1,G=J.onExit||H1;X.on("state",Z.onState||H1),X.on("submit",(D)=>Q(z(D))),X.on("exit",(D)=>Q(G(D))),X.on("abort",(D)=>K(Y(D)))})},b=IU,vQ=OU(),H1=(U)=>U;b.text=(U)=>a("TextPrompt",U);b.password=(U)=>{return U.style="password",b.text(U)};b.invisible=(U)=>{return U.style="invisible",b.text(U)};b.number=(U)=>a("NumberPrompt",U);b.date=(U)=>a("DatePrompt",U);b.confirm=(U)=>a("ConfirmPrompt",U);b.list=(U)=>{const Z=U.separator||",";return a("TextPrompt",U,{onSubmit:(J)=>J.split(Z).map((Q)=>Q.trim())})};b.toggle=(U)=>a("TogglePrompt",U);b.select=(U)=>a("SelectPrompt",U);b.multiselect=(U)=>{U.choices=[].concat(U.choices||[]);const Z=(J)=>J.filter((Q)=>Q.selected).map((Q)=>Q.value);return a("MultiselectPrompt",U,{onAbort:Z,onSubmit:Z})};b.autocompleteMultiselect=(U)=>{U.choices=[].concat(U.choices||[]);const Z=(J)=>J.filter((Q)=>Q.selected).map((Q)=>Q.value);return a("AutocompleteMultiselectPrompt",U,{onAbort:Z,onSubmit:Z})};var xQ=(U,Z)=>Promise.resolve(Z.filter((J)=>J.title.slice(0,U.length).toLowerCase()===U.toLowerCase()));b.autocomplete=(U)=>{return U.suggest=U.suggest||xQ,U.choices=[].concat(U.choices||[]),a("AutocompletePrompt",U)}});var AU=E((SY,SU)=>{async function z0(U=[],{onSubmit:Z=LU,onCancel:J=LU}={}){const Q={},K=z0._override||{};U=[].concat(U);let X,Y,z,G,D,F;const I=async(N,H,V=!1)=>{if(!V&&N.validate&&N.validate(H)!==!0)return;return N.format?await N.format(H,Q):H};for(Y of U){if({name:G,type:D}=Y,typeof D==="function")D=await D(X,{...Q},Y),Y.type=D;if(!D)continue;for(let N in Y){if(yQ.includes(N))continue;let H=Y[N];Y[N]=typeof H==="function"?await H(X,{...Q},F):H}if(F=Y,typeof Y.message!=="string")throw new Error("prompt message is required");if({name:G,type:D}=Y,e1[D]===void 0)throw new Error(`prompt type (${D}) is not defined`);if(K[Y.name]!==void 0){if(X=await I(Y,K[Y.name]),X!==void 0){Q[G]=X;continue}}try{X=z0._injected?gQ(z0._injected,Y.initial):await e1[D](Y),Q[G]=X=await I(Y,X,!0),z=await Z(Y,X,Q)}catch(N){z=!await J(Y,Q)}if(z)return Q}return Q}var gQ=function(U,Z){const J=U.shift();if(J instanceof Error)throw J;return J===void 0?Z:J},mQ=function(U){z0._injected=(z0._injected||[]).concat(U)},uQ=function(U){z0._override=Object.assign({},U)},e1=TU(),yQ=["suggest","format","onState","validate","onRender","type"],LU=()=>{};SU.exports=Object.assign(z0,{prompt:z0,prompts:e1,inject:mQ,override:uQ})});var PU=E((AY,qU)=>{var dQ=function(U){U=(Array.isArray(U)?U:U.split(".")).map(Number);let Z=0,J=process.versions.node.split(".").map(Number);for(;Z<U.length;Z++){if(J[Z]>U[Z])return!1;if(U[Z]>J[Z])return!0}return!1};qU.exports=dQ("8.6.0")?k7():AU()});import{createRequire as wY} from"module";var pU=u0(R1(),1);class R0{constructor(U){var Z;this.opts={},this.args={},this.name=U.name,this.alias=(Z=U.alias)!==null&&Z!==void 0?Z:[],this.description=U.description,this.summary=U.summary,this.arguments=U.arguments,this.options=U.options}}import*as d0 from"tty";var{env:K0={},argv:K6=[],platform:nU=""}=typeof process==="undefined"?{}:process,aU="NO_COLOR"in K0||K6.includes("--no-color"),lU="FORCE_COLOR"in K0||K6.includes("--color"),iU=nU==="win32",X6=K0.TERM==="dumb",sU=d0&&d0.isatty&&d0.isatty(1)&&K0.TERM&&!X6,rU="CI"in K0&&(("GITHUB_ACTIONS"in K0)||("GITLAB_CI"in K0)||("CIRCLECI"in K0)),oU=!aU&&(lU||iU&&!X6||sU||rU),Y6=(U,Z,J,Q,K=Z.substring(0,U)+Q,X=Z.substring(U+J.length),Y=X.indexOf(J))=>K+(Y<0?X:Y6(Y,X,J,Q)),tU=(U,Z,J,Q,K)=>U<0?J+Z+Q:J+Y6(U,Z,Q,K)+Q,eU=(U,Z,J=U,Q=U.length+1)=>(K)=>K||!(K===""||K===void 0)?tU((""+K).indexOf(Z,Q),K,U,Z,J):"",$=(U,Z,J)=>eU(`\x1B[${U}m`,`\x1B[${Z}m`,J),Q6={reset:$(0,0),bold:$(1,22,"\x1B[22m\x1B[1m"),dim:$(2,22,"\x1B[22m\x1B[2m"),italic:$(3,23),underline:$(4,24),inverse:$(7,27),hidden:$(8,28),strikethrough:$(9,29),black:$(30,39),red:$(31,39),green:$(32,39),yellow:$(33,39),blue:$(34,39),magenta:$(35,39),cyan:$(36,39),white:$(37,39),gray:$(90,39),bgBlack:$(40,49),bgRed:$(41,49),bgGreen:$(42,49),bgYellow:$(43,49),bgBlue:$(44,49),bgMagenta:$(45,49),bgCyan:$(46,49),bgWhite:$(47,49),blackBright:$(90,39),redBright:$(91,39),greenBright:$(92,39),yellowBright:$(93,39),blueBright:$(94,39),magentaBright:$(95,39),cyanBright:$(96,39),whiteBright:$(97,39),bgBlackBright:$(100,49),bgRedBright:$(101,49),bgGreenBright:$(102,49),bgYellowBright:$(103,49),bgBlueBright:$(104,49),bgMagentaBright:$(105,49),bgCyanBright:$(106,49),bgWhiteBright:$(107,49)},UZ=({useColor:U=oU}={})=>U?Q6:Object.keys(Q6).reduce((Z,J)=>({...Z,[J]:String}),{}),{reset:QK,bold:KK,dim:XK,italic:YK,underline:DK,inverse:zK,hidden:GK,strikethrough:EK,black:HK,red:D6,green:z6,yellow:G6,blue:E6,magenta:VK,cyan:BK,white:MK,gray:H6,bgBlack:FK,bgRed:V6,bgGreen:B6,bgYellow:M6,bgBlue:F6,bgMagenta:RK,bgCyan:WK,bgWhite:$K,blackBright:NK,redBright:OK,greenBright:IK,yellowBright:TK,blueBright:LK,magentaBright:SK,cyanBright:AK,whiteBright:qK,bgBlackBright:PK,bgRedBright:jK,bgGreenBright:CK,bgYellowBright:_K,bgBlueBright:wK,bgMagentaBright:fK,bgCyanBright:kK,bgWhiteBright:bK}=UZ();class L{static red(U){return D6(U)}static green(U){return z6(U)}static blue(U){return E6(U)}static gray(U){return H6(U)}static yellow(U){return G6(U)}static bgRed(U){return V6(U)}static bgGreen(U){return B6(U)}static bgBlue(U){return F6(U)}static bgYellow(U){return M6(U)}}var F9=u0(M9(),1);class P1 extends F9.default{constructor(U){super(U)}static termsWidth(...U){return Math.max(...U)}}class s extends P1{constructor(U=30){super({colWidths:[U,process.stdout.columns-U],wordWrap:!0,chars:{top:"","top-mid":"","top-left":"","top-right":"",bottom:"","bottom-mid":"","bottom-left":"","bottom-right":"",left:"","left-mid":"",mid:"","mid-mid":"",right:"","right-mid":"",middle:""}})}}class r{static rootHelp(U,Z){this.outputRoot+=L.yellow("USAGE"),this.outputRoot+=this.br(),this.outputRoot+=` ${U.name} [options] <command>`,this.outputRoot+=this.br(),this.outputRoot+=this.br(),this.outputRoot+=L.yellow("COMMANDS"),this.outputRoot+=this.br();const J=s.termsWidth(r.commandTermLength(U.getCommands()),r.optionTermLength(Z)),Q=new s(J+this.separatorLength+Math.round(J/2));U.getCommands().forEach((X)=>{Q.push([L.green(X.name),L.gray(X.summary)])}),this.outputRoot+=Q.toString(),this.outputRoot+=this.br();const K=new s(J+this.separatorLength+Math.round(J/2));this.outputRoot+=this.br(),this.outputRoot+=L.yellow("OPTIONS"),this.outputRoot+=this.br(),Z.forEach((X)=>{let Y=L.green(X.flag);if(X.type==="boolean"&&X.shorthand)Y+=`, ${L.green(X.shorthand)}`;if(X.type==="boolean")K.push([Y,L.gray(X.description)])}),this.outputRoot+=K.toString(),this.outputRoot+=this.br(),console.log(this.outputRoot)}static commandHelp(U,Z){if(this.output+=L.yellow("USAGE"),this.output+=this.br(),this.output+=` ${U.name} ${Z.name}`,Z.options.length)this.output+=" [options]";Z.arguments.forEach((X)=>{this.output+=` <${X.name}>`}),this.output+=this.br(),this.output+=this.br(),this.output+=L.yellow("ARGUMENTS"),this.output+=this.br();const J=s.termsWidth(r.argumentTermLength(Z.arguments),r.optionTermLength(Z.options)),Q=new s(J+this.separatorLength+Math.round(J/2));Z.arguments.forEach((X)=>{Q.push([L.green(X.name),L.gray(X.description)])}),this.output+=Q.toString(),this.output+=this.br(),this.output+=this.br(),this.output+=L.yellow("OPTIONS"),this.output+=this.br();const K=new s(J+this.separatorLength+Math.round(J/2));if(Z.options.forEach((X)=>{let Y=L.green(X.flag);if(X.type==="boolean"&&X.shorthand)Y+=`, ${L.green(X.shorthand)}`;if(X.type==="boolean")K.push([Y,L.gray(X.description)])}),this.output+=K.toString(),this.output+=this.br(),Z.alias.length)this.output+=this.br(),this.output+=L.yellow("ALIAS"),this.output+=this.br(),this.output+=` ${L.green(Z.alias.join(","))}`;console.log(this.output)}static br(U=1){let Z="";for(let J=0;J<U;J++)Z+="\n";return Z}static commandTermLength(U){return U.reduce((Z,J)=>{return Math.max(Z,J.name.length)},0)}static optionTermLength(U){return U.reduce((Z,J)=>{return Math.max(Z,J.flag.length)},0)}static argumentTermLength(U){return U.reduce((Z,J)=>{return Math.max(Z,J.name.length)},0)}}r.separatorLength=10;r.outputRoot="";r.output="";var gZ=u0(R1(),1);var cQ=u0(PU(),1);import cY from"fs";import nY from"path";import iY from"fs";import rY from"path";import eY from"fs";var U6=(U)=>U[0].toUpperCase()+U.slice(1);var m0=(U)=>{return U.replace(/(?:^\w|[A-Z]|\b\w)/g,function(Z,J){return J===0?Z.toLowerCase():Z.toUpperCase()}).replace(/[^0-9a-zA-Z]/g,"")};var M0=(U)=>U6(m0(U));var j=(U)=>U.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase();import L0 from"fs";import CU from"path";class V1 extends R0{constructor(){super({name:"make:command",description:"Make a new console command",summary:"Make a new console command",arguments:[{name:"name",description:"Name of console command"}],options:[]})}async handle(){if(L0.existsSync(`${process.cwd()}/src/console/commands/${j(this.args.name)}`)){console.error(L.red("Command directory is exists"));return}L0.mkdirSync(`${process.cwd()}/src/console/commands/${j(this.args.name)}`,{recursive:!0});const U=L0.readFileSync(CU.resolve(E0,"./command/index.command.ts")).toString().replace("[name]",j(this.args.name)).replace("NewCommand",`${M0(this.args.name)}Command`);L0.writeFileSync(`${process.cwd()}/src/console/commands/${j(this.args.name)}/index.command.ts`,U);const Z=L0.readFileSync(CU.resolve(E0,"./command/index.spec.ts")).toString().replace(/NewCommand/g,`${M0(this.args.name)}Command`).replace(/newCommand/g,`${m0(this.args.name)}Command`);L0.writeFileSync(`${process.cwd()}/src/console/commands/${j(this.args.name)}/index.spec.ts`,Z),console.info(`src/console/commands/${j(this.args.name)}/index.command.ts`,"has been created"),console.info(`src/console/commands/${j(this.args.name)}/index.spec.ts`,"has been created")}}import l from"fs";import B1 from"path";class M1 extends R0{constructor(){super({name:"make:middleware",description:"Make a new middleware",summary:"Make a new middleware",arguments:[{name:"name",description:"Name of middleware"}],options:[{type:"boolean",flag:"--configurable",shorthand:"-c",description:"Export a function which accepts an options"}]})}async handle(){if(l.existsSync(`${process.cwd()}/src/middleware/${j(this.args.name)}`)){console.error(L.red("Middleware directory is exists"));return}if(l.mkdirSync(`${process.cwd()}/src/middleware/${j(this.args.name)}`,{recursive:!0}),this.opts["--configurable"])this.copyConfigureableMiddleware();else this.copyMiddleware()}copyMiddleware(){const U=l.readFileSync(B1.resolve(E0,"./middleware/new.middleware.ts")).toString().replace("NewMiddleware",`${M0(this.args.name)}Middleware`);l.writeFileSync(`${process.cwd()}/src/middleware/${j(this.args.name)}/index.middleware.ts`,U);const Z=l.readFileSync(B1.resolve(E0,"./middleware/new.spec.ts")).toString().replace("new.middleware.ts","index.middleware.ts");l.writeFileSync(`${process.cwd()}/src/middleware/${j(this.args.name)}/index.spec.ts`,Z),console.info(`src/middleware/${j(this.args.name)}/index.middleware.ts`,"has been created"),console.info(`src/middleware/${j(this.args.name)}/index.spec.ts`,"has been created")}copyConfigureableMiddleware(){const U=l.readFileSync(B1.resolve(E0,"./middleware/configurable.middleware.ts")).toString().replace("NewMiddleware",`${M0(this.args.name)}Middleware`);l.writeFileSync(`${process.cwd()}/src/middleware/${j(this.args.name)}/index.middleware.ts`,U);const Z=l.readFileSync(B1.resolve(E0,"./middleware/configurable.spec.ts")).toString().replace("configurable.middleware.ts","index.middleware.ts");l.writeFileSync(`${process.cwd()}/src/middleware/${j(this.args.name)}/index.spec.ts`,Z),console.info(`src/middleware/${j(this.args.name)}/index.middleware.ts`,"has been created"),console.info(`src/middleware/${j(this.args.name)}/index.spec.ts`,"has been created")}}class _U{command;constructor(U){this.command=U}async register(){this.command.register(new V1),this.command.register(new M1)}}function wU(U=1){if(typeof U==="string")return parseInt(U);return U}function fU(U=10){if(typeof U==="string")return parseInt(U);return U}function iQ(U,Z){return(wU(U)-1)*fU(Z)}function sQ(U){return U}function rQ(U="",Z=[]){const J=bU(kU(U));return hU(J,Z)}function kU(U){return U.split(" ").join().split(",").filter((Z)=>Z)}function bU(U){const Z={};for(let J=0;J<U.length;J++)Z[`${U[J].trim()}`]=1;return Z}function hU(U,Z){for(let J=0;J<Z.length;J++)U[`${Z[J]}`]=0;return U}function oQ(U){const Z={};if(U)U.split(",").forEach(function(J){if(J.charAt(0)==="-")J=J.substring(1),Z[J.trim()]=-1;else Z[J.trim()]=1});return Z}var tQ={page:wU,limit:fU,skip:iQ,sort:oQ,fields:rQ,filter:sQ,filterExludeFields:hU,convertStringToArray:kU,convertArrayToObject:bU};class vU{app;server=null;constructor(U){this.app=U}listen(U,Z){return new Promise((J,Q)=>{if(Z)this.server=this.app.listen(U,Z).once("listening",J).once("error",Q);else this.server=this.app.listen(U).once("listening",J).once("error",Q)})}async start(U,Z){await this.listen(U,Z)}stop(){this.server?.close(),this.server=null}get host(){const U=this.server?.address();if(U?.address==="0.0.0.0"||U?.address==="::")return"localhost";else return U?.address}get port(){return this.server?.address()?.port}get url(){return`http://${this.host}${this.port!==80?`:${this.port}`:""}`}}var E0=import.meta.path.replace("/index.ts","/../stub").replace("/index.js","/../stub");export{E0 as stubDir,tQ as Querystring,_U as ConsoleKernel,vU as BaseServer};
|
|
16
|
+
Filtered results for: ${this.inputValue?this.inputValue:Q0.gray("Enter something to filter")}\n`}renderOption(U,Z,J){let Q;if(Z.disabled)Q=U===J?Q0.gray().underline(Z.title):Q0.strikethrough().gray(Z.title);else Q=U===J?Q0.cyan().underline(Z.title):Z.title;return(Z.selected?Q0.green(T0.radioOn):T0.radioOff)+" "+Q}renderDoneOrInstructions(){if(this.done)return this.value.filter((Z)=>Z.selected).map((Z)=>Z.title).join(", ");const U=[Q0.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];if(this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled)U.push(Q0.yellow(this.warn));return U.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(wQ.hide);super.render();let U=[GU.symbol(this.done,this.aborted),Q0.bold(this.msg),GU.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)U+=Q0.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;U+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+U),this.clear=zU(U,this.out.columns)}}HU.exports=EU});var $U=E((IY,WU)=>{var BU=A(),kQ=Z0(),{style:MU,clear:bQ}=g(),{erase:hQ,cursor:FU}=P();class RU extends kQ{constructor(U={}){super(U);this.msg=U.message,this.value=U.initial,this.initialValue=!!U.initial,this.yesMsg=U.yes||"yes",this.yesOption=U.yesOption||"(Y/n)",this.noMsg=U.no||"no",this.noOption=U.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write("\n"),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write("\n"),this.close()}_(U,Z){if(U.toLowerCase()==="y")return this.value=!0,this.submit();if(U.toLowerCase()==="n")return this.value=!1,this.submit();return this.bell()}render(){if(this.closed)return;if(this.firstRender)this.out.write(FU.hide);else this.out.write(bQ(this.outputText,this.out.columns));super.render(),this.outputText=[MU.symbol(this.done,this.aborted),BU.bold(this.msg),MU.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:BU.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(hQ.line+FU.to(0)+this.outputText)}}WU.exports=RU});var OU=E((TY,NU)=>{NU.exports={TextPrompt:Z4(),SelectPrompt:Y4(),TogglePrompt:H4(),DatePrompt:a4(),NumberPrompt:o4(),MultiselectPrompt:r1(),AutocompletePrompt:DU(),AutocompleteMultiselectPrompt:VU(),ConfirmPrompt:$U()}});var TU=E((IU)=>{var a=function(U,Z,J={}){return new Promise((Q,K)=>{const X=new vQ[U](Z),Y=J.onAbort||H1,z=J.onSubmit||H1,G=J.onExit||H1;X.on("state",Z.onState||H1),X.on("submit",(D)=>Q(z(D))),X.on("exit",(D)=>Q(G(D))),X.on("abort",(D)=>K(Y(D)))})},b=IU,vQ=OU(),H1=(U)=>U;b.text=(U)=>a("TextPrompt",U);b.password=(U)=>{return U.style="password",b.text(U)};b.invisible=(U)=>{return U.style="invisible",b.text(U)};b.number=(U)=>a("NumberPrompt",U);b.date=(U)=>a("DatePrompt",U);b.confirm=(U)=>a("ConfirmPrompt",U);b.list=(U)=>{const Z=U.separator||",";return a("TextPrompt",U,{onSubmit:(J)=>J.split(Z).map((Q)=>Q.trim())})};b.toggle=(U)=>a("TogglePrompt",U);b.select=(U)=>a("SelectPrompt",U);b.multiselect=(U)=>{U.choices=[].concat(U.choices||[]);const Z=(J)=>J.filter((Q)=>Q.selected).map((Q)=>Q.value);return a("MultiselectPrompt",U,{onAbort:Z,onSubmit:Z})};b.autocompleteMultiselect=(U)=>{U.choices=[].concat(U.choices||[]);const Z=(J)=>J.filter((Q)=>Q.selected).map((Q)=>Q.value);return a("AutocompleteMultiselectPrompt",U,{onAbort:Z,onSubmit:Z})};var xQ=(U,Z)=>Promise.resolve(Z.filter((J)=>J.title.slice(0,U.length).toLowerCase()===U.toLowerCase()));b.autocomplete=(U)=>{return U.suggest=U.suggest||xQ,U.choices=[].concat(U.choices||[]),a("AutocompletePrompt",U)}});var AU=E((SY,SU)=>{async function z0(U=[],{onSubmit:Z=LU,onCancel:J=LU}={}){const Q={},K=z0._override||{};U=[].concat(U);let X,Y,z,G,D,F;const I=async(N,H,V=!1)=>{if(!V&&N.validate&&N.validate(H)!==!0)return;return N.format?await N.format(H,Q):H};for(Y of U){if({name:G,type:D}=Y,typeof D==="function")D=await D(X,{...Q},Y),Y.type=D;if(!D)continue;for(let N in Y){if(yQ.includes(N))continue;let H=Y[N];Y[N]=typeof H==="function"?await H(X,{...Q},F):H}if(F=Y,typeof Y.message!=="string")throw new Error("prompt message is required");if({name:G,type:D}=Y,e1[D]===void 0)throw new Error(`prompt type (${D}) is not defined`);if(K[Y.name]!==void 0){if(X=await I(Y,K[Y.name]),X!==void 0){Q[G]=X;continue}}try{X=z0._injected?gQ(z0._injected,Y.initial):await e1[D](Y),Q[G]=X=await I(Y,X,!0),z=await Z(Y,X,Q)}catch(N){z=!await J(Y,Q)}if(z)return Q}return Q}var gQ=function(U,Z){const J=U.shift();if(J instanceof Error)throw J;return J===void 0?Z:J},mQ=function(U){z0._injected=(z0._injected||[]).concat(U)},uQ=function(U){z0._override=Object.assign({},U)},e1=TU(),yQ=["suggest","format","onState","validate","onRender","type"],LU=()=>{};SU.exports=Object.assign(z0,{prompt:z0,prompts:e1,inject:mQ,override:uQ})});var PU=E((AY,qU)=>{var dQ=function(U){U=(Array.isArray(U)?U:U.split(".")).map(Number);let Z=0,J=process.versions.node.split(".").map(Number);for(;Z<U.length;Z++){if(J[Z]>U[Z])return!1;if(U[Z]>J[Z])return!0}return!1};qU.exports=dQ("8.6.0")?k7():AU()});import{createRequire as wY} from"module";var pU=u0(R1(),1);class R0{constructor(U){var Z;this.opts={},this.args={},this.name=U.name,this.alias=(Z=U.alias)!==null&&Z!==void 0?Z:[],this.description=U.description,this.summary=U.summary,this.arguments=U.arguments,this.options=U.options}}import*as d0 from"tty";var{env:K0={},argv:K6=[],platform:nU=""}=typeof process==="undefined"?{}:process,aU="NO_COLOR"in K0||K6.includes("--no-color"),lU="FORCE_COLOR"in K0||K6.includes("--color"),iU=nU==="win32",X6=K0.TERM==="dumb",sU=d0&&d0.isatty&&d0.isatty(1)&&K0.TERM&&!X6,rU="CI"in K0&&(("GITHUB_ACTIONS"in K0)||("GITLAB_CI"in K0)||("CIRCLECI"in K0)),oU=!aU&&(lU||iU&&!X6||sU||rU),Y6=(U,Z,J,Q,K=Z.substring(0,U)+Q,X=Z.substring(U+J.length),Y=X.indexOf(J))=>K+(Y<0?X:Y6(Y,X,J,Q)),tU=(U,Z,J,Q,K)=>U<0?J+Z+Q:J+Y6(U,Z,Q,K)+Q,eU=(U,Z,J=U,Q=U.length+1)=>(K)=>K||!(K===""||K===void 0)?tU((""+K).indexOf(Z,Q),K,U,Z,J):"",$=(U,Z,J)=>eU(`\x1B[${U}m`,`\x1B[${Z}m`,J),Q6={reset:$(0,0),bold:$(1,22,"\x1B[22m\x1B[1m"),dim:$(2,22,"\x1B[22m\x1B[2m"),italic:$(3,23),underline:$(4,24),inverse:$(7,27),hidden:$(8,28),strikethrough:$(9,29),black:$(30,39),red:$(31,39),green:$(32,39),yellow:$(33,39),blue:$(34,39),magenta:$(35,39),cyan:$(36,39),white:$(37,39),gray:$(90,39),bgBlack:$(40,49),bgRed:$(41,49),bgGreen:$(42,49),bgYellow:$(43,49),bgBlue:$(44,49),bgMagenta:$(45,49),bgCyan:$(46,49),bgWhite:$(47,49),blackBright:$(90,39),redBright:$(91,39),greenBright:$(92,39),yellowBright:$(93,39),blueBright:$(94,39),magentaBright:$(95,39),cyanBright:$(96,39),whiteBright:$(97,39),bgBlackBright:$(100,49),bgRedBright:$(101,49),bgGreenBright:$(102,49),bgYellowBright:$(103,49),bgBlueBright:$(104,49),bgMagentaBright:$(105,49),bgCyanBright:$(106,49),bgWhiteBright:$(107,49)},UZ=({useColor:U=oU}={})=>U?Q6:Object.keys(Q6).reduce((Z,J)=>({...Z,[J]:String}),{}),{reset:QK,bold:KK,dim:XK,italic:YK,underline:DK,inverse:zK,hidden:GK,strikethrough:EK,black:HK,red:D6,green:z6,yellow:G6,blue:E6,magenta:VK,cyan:BK,white:MK,gray:H6,bgBlack:FK,bgRed:V6,bgGreen:B6,bgYellow:M6,bgBlue:F6,bgMagenta:RK,bgCyan:WK,bgWhite:$K,blackBright:NK,redBright:OK,greenBright:IK,yellowBright:TK,blueBright:LK,magentaBright:SK,cyanBright:AK,whiteBright:qK,bgBlackBright:PK,bgRedBright:jK,bgGreenBright:CK,bgYellowBright:_K,bgBlueBright:wK,bgMagentaBright:fK,bgCyanBright:kK,bgWhiteBright:bK}=UZ();class L{static red(U){return D6(U)}static green(U){return z6(U)}static blue(U){return E6(U)}static gray(U){return H6(U)}static yellow(U){return G6(U)}static bgRed(U){return V6(U)}static bgGreen(U){return B6(U)}static bgBlue(U){return F6(U)}static bgYellow(U){return M6(U)}}var F9=u0(M9(),1);class P1 extends F9.default{constructor(U){super(U)}static termsWidth(...U){return Math.max(...U)}}class s extends P1{constructor(U=30){super({colWidths:[U,process.stdout.columns-U],wordWrap:!0,chars:{top:"","top-mid":"","top-left":"","top-right":"",bottom:"","bottom-mid":"","bottom-left":"","bottom-right":"",left:"","left-mid":"",mid:"","mid-mid":"",right:"","right-mid":"",middle:""}})}}class r{static rootHelp(U,Z){this.outputRoot+=L.yellow("USAGE"),this.outputRoot+=this.br(),this.outputRoot+=` ${U.name} [options] <command>`,this.outputRoot+=this.br(),this.outputRoot+=this.br(),this.outputRoot+=L.yellow("COMMANDS"),this.outputRoot+=this.br();const J=s.termsWidth(r.commandTermLength(U.getCommands()),r.optionTermLength(Z)),Q=new s(J+this.separatorLength+Math.round(J/2));U.getCommands().forEach((X)=>{Q.push([L.green(X.name),L.gray(X.summary)])}),this.outputRoot+=Q.toString(),this.outputRoot+=this.br();const K=new s(J+this.separatorLength+Math.round(J/2));this.outputRoot+=this.br(),this.outputRoot+=L.yellow("OPTIONS"),this.outputRoot+=this.br(),Z.forEach((X)=>{let Y=L.green(X.flag);if(X.type==="boolean"&&X.shorthand)Y+=`, ${L.green(X.shorthand)}`;if(X.type==="boolean")K.push([Y,L.gray(X.description)])}),this.outputRoot+=K.toString(),this.outputRoot+=this.br(),console.log(this.outputRoot)}static commandHelp(U,Z){if(this.output+=L.yellow("USAGE"),this.output+=this.br(),this.output+=` ${U.name} ${Z.name}`,Z.options.length)this.output+=" [options]";Z.arguments.forEach((X)=>{this.output+=` <${X.name}>`}),this.output+=this.br(),this.output+=this.br(),this.output+=L.yellow("ARGUMENTS"),this.output+=this.br();const J=s.termsWidth(r.argumentTermLength(Z.arguments),r.optionTermLength(Z.options)),Q=new s(J+this.separatorLength+Math.round(J/2));Z.arguments.forEach((X)=>{Q.push([L.green(X.name),L.gray(X.description)])}),this.output+=Q.toString(),this.output+=this.br(),this.output+=this.br(),this.output+=L.yellow("OPTIONS"),this.output+=this.br();const K=new s(J+this.separatorLength+Math.round(J/2));if(Z.options.forEach((X)=>{let Y=L.green(X.flag);if(X.type==="boolean"&&X.shorthand)Y+=`, ${L.green(X.shorthand)}`;if(X.type==="boolean")K.push([Y,L.gray(X.description)])}),this.output+=K.toString(),this.output+=this.br(),Z.alias.length)this.output+=this.br(),this.output+=L.yellow("ALIAS"),this.output+=this.br(),this.output+=` ${L.green(Z.alias.join(","))}`;console.log(this.output)}static br(U=1){let Z="";for(let J=0;J<U;J++)Z+="\n";return Z}static commandTermLength(U){return U.reduce((Z,J)=>{return Math.max(Z,J.name.length)},0)}static optionTermLength(U){return U.reduce((Z,J)=>{return Math.max(Z,J.flag.length)},0)}static argumentTermLength(U){return U.reduce((Z,J)=>{return Math.max(Z,J.name.length)},0)}}r.separatorLength=10;r.outputRoot="";r.output="";var gZ=u0(R1(),1);var cQ=u0(PU(),1);import cY from"fs";import nY from"path";import iY from"fs";import rY from"path";import eY from"fs";var U6=(U)=>U[0].toUpperCase()+U.slice(1);var m0=(U)=>{return U.replace(/(?:^\w|[A-Z]|\b\w)/g,function(Z,J){return J===0?Z.toLowerCase():Z.toUpperCase()}).replace(/[^0-9a-zA-Z]/g,"")};var M0=(U)=>U6(m0(U));var j=(U)=>U.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase();import L0 from"fs";import CU from"path";class V1 extends R0{constructor(){super({name:"make:command",description:"Make a new console command",summary:"Make a new console command",arguments:[{name:"name",description:"Name of console command"}],options:[]})}async handle(){if(L0.existsSync(`${process.cwd()}/src/console/commands/${j(this.args.name)}`)){console.error(L.red("Command directory is exists"));return}L0.mkdirSync(`${process.cwd()}/src/console/commands/${j(this.args.name)}`,{recursive:!0});const U=L0.readFileSync(CU.resolve(E0,"./command/index.command.ts")).toString().replace("[name]",j(this.args.name)).replace("NewCommand",`${M0(this.args.name)}Command`);L0.writeFileSync(`${process.cwd()}/src/console/commands/${j(this.args.name)}/index.command.ts`,U);const Z=L0.readFileSync(CU.resolve(E0,"./command/index.spec.ts")).toString().replace(/NewCommand/g,`${M0(this.args.name)}Command`).replace(/newCommand/g,`${m0(this.args.name)}Command`);L0.writeFileSync(`${process.cwd()}/src/console/commands/${j(this.args.name)}/index.spec.ts`,Z),console.info(`src/console/commands/${j(this.args.name)}/index.command.ts`,"has been created"),console.info(`src/console/commands/${j(this.args.name)}/index.spec.ts`,"has been created")}}import l from"fs";import B1 from"path";class M1 extends R0{constructor(){super({name:"make:middleware",description:"Make a new middleware",summary:"Make a new middleware",arguments:[{name:"name",description:"Name of middleware"}],options:[{type:"boolean",flag:"--configurable",shorthand:"-c",description:"Export a function which accepts an options"}]})}async handle(){if(l.existsSync(`${process.cwd()}/src/middleware/${j(this.args.name)}`)){console.error(L.red("Middleware directory is exists"));return}if(l.mkdirSync(`${process.cwd()}/src/middleware/${j(this.args.name)}`,{recursive:!0}),this.opts["--configurable"])this.copyConfigureableMiddleware();else this.copyMiddleware()}copyMiddleware(){const U=l.readFileSync(B1.resolve(E0,"./middleware/new.middleware.ts")).toString().replace("NewMiddleware",`${M0(this.args.name)}Middleware`);l.writeFileSync(`${process.cwd()}/src/middleware/${j(this.args.name)}/index.middleware.ts`,U);const Z=l.readFileSync(B1.resolve(E0,"./middleware/new.spec.ts")).toString().replace("new.middleware.ts","index.middleware.ts");l.writeFileSync(`${process.cwd()}/src/middleware/${j(this.args.name)}/index.spec.ts`,Z),console.info(`src/middleware/${j(this.args.name)}/index.middleware.ts`,"has been created"),console.info(`src/middleware/${j(this.args.name)}/index.spec.ts`,"has been created")}copyConfigureableMiddleware(){const U=l.readFileSync(B1.resolve(E0,"./middleware/configurable.middleware.ts")).toString().replace("NewMiddleware",`${M0(this.args.name)}Middleware`);l.writeFileSync(`${process.cwd()}/src/middleware/${j(this.args.name)}/index.middleware.ts`,U);const Z=l.readFileSync(B1.resolve(E0,"./middleware/configurable.spec.ts")).toString().replace("configurable.middleware.ts","index.middleware.ts");l.writeFileSync(`${process.cwd()}/src/middleware/${j(this.args.name)}/index.spec.ts`,Z),console.info(`src/middleware/${j(this.args.name)}/index.middleware.ts`,"has been created"),console.info(`src/middleware/${j(this.args.name)}/index.spec.ts`,"has been created")}}class _U{command;constructor(U){this.command=U}async register(){this.command.register(new V1),this.command.register(new M1)}}function wU(U=1){if(typeof U==="string")return parseInt(U);return U}function fU(U=10){if(typeof U==="string")return parseInt(U);return U}function iQ(U,Z){return(wU(U)-1)*fU(Z)}function sQ(U){return U}function rQ(U="",Z=[]){const J=bU(kU(U));return hU(J,Z)}function kU(U){return U.split(" ").join().split(",").filter((Z)=>Z)}function bU(U,Z=1){const J={};for(let Q=0;Q<U.length;Q++)J[`${U[Q].trim()}`]=Z;return J}function hU(U,Z){for(let J=0;J<Z.length;J++)U[`${Z[J]}`]=0;return U}function oQ(U){const Z={};if(U)U.split(",").forEach(function(J){if(J.charAt(0)==="-")J=J.substring(1),Z[J.trim()]=-1;else Z[J.trim()]=1});return Z}var tQ={page:wU,limit:fU,skip:iQ,sort:oQ,fields:rQ,filter:sQ,filterExludeFields:hU,convertStringToArray:kU,convertArrayToObject:bU};class vU{app;server=null;constructor(U){this.app=U}listen(U,Z){return new Promise((J,Q)=>{if(Z)this.server=this.app.listen(U,Z).once("listening",J).once("error",Q);else this.server=this.app.listen(U).once("listening",J).once("error",Q)})}async start(U,Z){await this.listen(U,Z)}stop(){this.server?.close(),this.server=null}get host(){const U=this.server?.address();if(U?.address==="0.0.0.0"||U?.address==="::")return"localhost";else return U?.address}get port(){return this.server?.address()?.port}get url(){return`http://${this.host}${this.port!==80?`:${this.port}`:""}`}}var E0=import.meta.path.replace("/index.ts","/../stub").replace("/index.js","/../stub");export{E0 as stubDir,tQ as Querystring,_U as ConsoleKernel,vU as BaseServer};
|