@ooneex/cli 1.8.4 → 1.10.0

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/dist/index.js CHANGED
@@ -1,38 +1,38 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var ma=Object.create;var{getPrototypeOf:pa,defineProperty:Ht,getOwnPropertyNames:ua}=Object;var ha=Object.prototype.hasOwnProperty;function fa(e){return this[e]}var ya,ga,te=(e,t,s)=>{var r=e!=null&&typeof e==="object";if(r){var o=t?ya??=new WeakMap:ga??=new WeakMap,i=o.get(e);if(i)return i}s=e!=null?ma(pa(e)):{};let a=t||!e||!e.__esModule?Ht(s,"default",{value:e,enumerable:!0}):s;for(let n of ua(e))if(!ha.call(a,n))Ht(a,n,{get:fa.bind(e,n),enumerable:!0});if(r)o.set(e,a);return a};var w=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var b=function(e,t,s,r){var o=arguments.length,i=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,s):r,a;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")i=Reflect.decorate(e,t,s,r);else for(var n=e.length-1;n>=0;n--)if(a=e[n])i=(o<3?a(i):o>3?a(t,s,i):a(t,s))||i;return o>3&&i&&Object.defineProperty(t,s,i),i};var be=import.meta.require;var Xt=w((zm,xe)=>{var Sa=typeof process<"u"&&process.env.TERM_PROGRAM==="Hyper",Ta=typeof process<"u"&&process.platform==="win32",zt=typeof process<"u"&&process.platform==="linux",dt={ballotDisabled:"\u2612",ballotOff:"\u2610",ballotOn:"\u2611",bullet:"\u2022",bulletWhite:"\u25E6",fullBlock:"\u2588",heart:"\u2764",identicalTo:"\u2261",line:"\u2500",mark:"\u203B",middot:"\xB7",minus:"\uFF0D",multiplication:"\xD7",obelus:"\xF7",pencilDownRight:"\u270E",pencilRight:"\u270F",pencilUpRight:"\u2710",percent:"%",pilcrow2:"\u2761",pilcrow:"\xB6",plusMinus:"\xB1",question:"?",section:"\xA7",starsOff:"\u2606",starsOn:"\u2605",upDownArrow:"\u2195"},Zt=Object.assign({},dt,{check:"\u221A",cross:"\xD7",ellipsisLarge:"...",ellipsis:"...",info:"i",questionSmall:"?",pointer:">",pointerSmall:"\xBB",radioOff:"( )",radioOn:"(*)",warning:"\u203C"}),Qt=Object.assign({},dt,{ballotCross:"\u2718",check:"\u2714",cross:"\u2716",ellipsisLarge:"\u22EF",ellipsis:"\u2026",info:"\u2139",questionFull:"\uFF1F",questionSmall:"\uFE56",pointer:zt?"\u25B8":"\u276F",pointerSmall:zt?"\u2023":"\u203A",radioOff:"\u25EF",radioOn:"\u25C9",warning:"\u26A0"});xe.exports=Ta&&!Sa?Zt:Qt;Reflect.defineProperty(xe.exports,"common",{enumerable:!1,value:dt});Reflect.defineProperty(xe.exports,"windows",{enumerable:!1,value:Zt});Reflect.defineProperty(xe.exports,"other",{enumerable:!1,value:Qt})});var Me=w((Zm,lt)=>{var Ra=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),Ma=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,Ca=()=>{if(typeof process<"u")return process.env.FORCE_COLOR!=="0";return!1},Jt=()=>{let e={enabled:Ca(),visible:!0,styles:{},keys:{}},t=(i)=>{let a=i.open=`\x1B[${i.codes[0]}m`,n=i.close=`\x1B[${i.codes[1]}m`,d=i.regex=new RegExp(`\\u001b\\[${i.codes[1]}m`,"g");return i.wrap=(l,c)=>{if(l.includes(n))l=l.replace(d,n+a);let u=a+l+n;return c?u.replace(/\r*\n/g,`${n}$&${a}`):u},i},s=(i,a,n)=>{return typeof i==="function"?i(a):i.wrap(a,n)},r=(i,a)=>{if(i===""||i==null)return"";if(e.enabled===!1)return i;if(e.visible===!1)return"";let n=""+i,d=n.includes(`
4
- `),l=a.length;if(l>0&&a.includes("unstyle"))a=[...new Set(["unstyle",...a])].reverse();while(l-- >0)n=s(e.styles[a[l]],n,d);return n},o=(i,a,n)=>{e.styles[i]=t({name:i,codes:a}),(e.keys[n]||(e.keys[n]=[])).push(i),Reflect.defineProperty(e,i,{configurable:!0,enumerable:!0,set(l){e.alias(i,l)},get(){let l=(c)=>r(c,l.stack);return Reflect.setPrototypeOf(l,e),l.stack=this.stack?this.stack.concat(i):[i],l}})};return o("reset",[0,0],"modifier"),o("bold",[1,22],"modifier"),o("dim",[2,22],"modifier"),o("italic",[3,23],"modifier"),o("underline",[4,24],"modifier"),o("inverse",[7,27],"modifier"),o("hidden",[8,28],"modifier"),o("strikethrough",[9,29],"modifier"),o("black",[30,39],"color"),o("red",[31,39],"color"),o("green",[32,39],"color"),o("yellow",[33,39],"color"),o("blue",[34,39],"color"),o("magenta",[35,39],"color"),o("cyan",[36,39],"color"),o("white",[37,39],"color"),o("gray",[90,39],"color"),o("grey",[90,39],"color"),o("bgBlack",[40,49],"bg"),o("bgRed",[41,49],"bg"),o("bgGreen",[42,49],"bg"),o("bgYellow",[43,49],"bg"),o("bgBlue",[44,49],"bg"),o("bgMagenta",[45,49],"bg"),o("bgCyan",[46,49],"bg"),o("bgWhite",[47,49],"bg"),o("blackBright",[90,39],"bright"),o("redBright",[91,39],"bright"),o("greenBright",[92,39],"bright"),o("yellowBright",[93,39],"bright"),o("blueBright",[94,39],"bright"),o("magentaBright",[95,39],"bright"),o("cyanBright",[96,39],"bright"),o("whiteBright",[97,39],"bright"),o("bgBlackBright",[100,49],"bgBright"),o("bgRedBright",[101,49],"bgBright"),o("bgGreenBright",[102,49],"bgBright"),o("bgYellowBright",[103,49],"bgBright"),o("bgBlueBright",[104,49],"bgBright"),o("bgMagentaBright",[105,49],"bgBright"),o("bgCyanBright",[106,49],"bgBright"),o("bgWhiteBright",[107,49],"bgBright"),e.ansiRegex=Ma,e.hasColor=e.hasAnsi=(i)=>{return e.ansiRegex.lastIndex=0,typeof i==="string"&&i!==""&&e.ansiRegex.test(i)},e.alias=(i,a)=>{let n=typeof a==="string"?e[a]:a;if(typeof n!=="function")throw TypeError("Expected alias to be the name of an existing color (string) or a function");if(!n.stack)Reflect.defineProperty(n,"name",{value:i}),e.styles[i]=n,n.stack=[i];Reflect.defineProperty(e,i,{configurable:!0,enumerable:!0,set(d){e.alias(i,d)},get(){let d=(l)=>r(l,d.stack);return Reflect.setPrototypeOf(d,e),d.stack=this.stack?this.stack.concat(n.stack):n.stack,d}})},e.theme=(i)=>{if(!Ra(i))throw TypeError("Expected theme to be an object");for(let a of Object.keys(i))e.alias(a,i[a]);return e},e.alias("unstyle",(i)=>{if(typeof i==="string"&&i!=="")return e.ansiRegex.lastIndex=0,i.replace(e.ansiRegex,"");return""}),e.alias("noop",(i)=>i),e.none=e.clear=e.noop,e.stripColor=e.unstyle,e.symbols=Xt(),e.define=o,e};lt.exports=Jt();lt.exports.create=Jt});var C=w((Ia)=>{var _a=Object.prototype.toString,B=Me(),jt=!1,we=new Set,es={yellow:"blue",cyan:"red",green:"magenta",black:"white",blue:"yellow",red:"cyan",magenta:"green",white:"black"};Ia.longest=(e,t)=>{return e.reduce((s,r)=>Math.max(s,t?r[t].length:r.length),0)};Ia.hasColor=(e)=>!!e&&B.hasColor(e);var Ce=Ia.isObject=(e)=>{return e!==null&&typeof e==="object"&&!Array.isArray(e)};Ia.nativeType=(e)=>{return _a.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")};Ia.isAsyncFn=(e)=>{return Ia.nativeType(e)==="asyncfunction"};Ia.isPrimitive=(e)=>{return e!=null&&typeof e!=="object"&&typeof e!=="function"};Ia.resolve=(e,t,...s)=>{if(typeof t==="function")return t.call(e,...s);return t};Ia.scrollDown=(e=[])=>[...e.slice(1),e[0]];Ia.scrollUp=(e=[])=>[e.pop(),...e];Ia.reorder=(e=[])=>{let t=e.slice();return t.sort((s,r)=>{if(s.index>r.index)return 1;if(s.index<r.index)return-1;return 0}),t};Ia.swap=(e,t,s)=>{let r=e.length,o=s===r?0:s<0?r-1:s,i=e[t];e[t]=e[o],e[o]=i};Ia.width=(e,t=80)=>{let s=e&&e.columns?e.columns:t;if(e&&typeof e.getWindowSize==="function")s=e.getWindowSize()[0];if(process.platform==="win32")return s-1;return s};Ia.height=(e,t=20)=>{let s=e&&e.rows?e.rows:t;if(e&&typeof e.getWindowSize==="function")s=e.getWindowSize()[1];return s};Ia.wordWrap=(e,t={})=>{if(!e)return e;if(typeof t==="number")t={width:t};let{indent:s="",newline:r=`
5
- `+s,width:o=80}=t,i=(r+s).match(/[^\S\n]/g)||[];o-=i.length;let a=`.{1,${o}}([\\s\\u200B]+|$)|[^\\s\\u200B]+?([\\s\\u200B]+|$)`,n=e.trim(),d=new RegExp(a,"g"),l=n.match(d)||[];if(l=l.map((c)=>c.replace(/\n$/,"")),t.padEnd)l=l.map((c)=>c.padEnd(o," "));if(t.padStart)l=l.map((c)=>c.padStart(o," "));return s+l.join(r)};Ia.unmute=(e)=>{let t=e.stack.find((r)=>B.keys.color.includes(r));if(t)return B[t];if(e.stack.find((r)=>r.slice(2)==="bg"))return B[t.slice(2)];return(r)=>r};Ia.pascal=(e)=>e?e[0].toUpperCase()+e.slice(1):"";Ia.inverse=(e)=>{if(!e||!e.stack)return e;let t=e.stack.find((r)=>B.keys.color.includes(r));if(t){let r=B["bg"+Ia.pascal(t)];return r?r.black:e}let s=e.stack.find((r)=>r.slice(0,2)==="bg");if(s)return B[s.slice(2).toLowerCase()]||e;return B.none};Ia.complement=(e)=>{if(!e||!e.stack)return e;let t=e.stack.find((r)=>B.keys.color.includes(r)),s=e.stack.find((r)=>r.slice(0,2)==="bg");if(t&&!s)return B[es[t]||t];if(s){let r=s.slice(2).toLowerCase(),o=es[r];if(!o)return e;return B["bg"+Ia.pascal(o)]||e}return B.none};Ia.meridiem=(e)=>{let t=e.getHours(),s=e.getMinutes(),r=t>=12?"pm":"am";t=t%12;let o=t===0?12:t,i=s<10?"0"+s:s;return o+":"+i+" "+r};Ia.set=(e={},t="",s)=>{return t.split(".").reduce((r,o,i,a)=>{let n=a.length-1>i?r[o]||{}:s;if(!Ia.isObject(n)&&i<a.length-1)n={};return r[o]=n},e)};Ia.get=(e={},t="",s)=>{let r=e[t]==null?t.split(".").reduce((o,i)=>o&&o[i],e):e[t];return r==null?s:r};Ia.mixin=(e,t)=>{if(!Ce(e))return t;if(!Ce(t))return e;for(let s of Object.keys(t)){let r=Object.getOwnPropertyDescriptor(t,s);if(hasOwnProperty.call(r,"value"))if(hasOwnProperty.call(e,s)&&Ce(r.value)){let o=Object.getOwnPropertyDescriptor(e,s);if(Ce(o.value)&&o.value!==r.value)e[s]=Ia.merge({},e[s],t[s]);else Reflect.defineProperty(e,s,r)}else Reflect.defineProperty(e,s,r);else Reflect.defineProperty(e,s,r)}return e};Ia.merge=(...e)=>{let t={};for(let s of e)Ia.mixin(t,s);return t};Ia.mixinEmitter=(e,t)=>{let s=t.constructor.prototype;for(let r of Object.keys(s)){let o=s[r];if(typeof o==="function")Ia.define(e,r,o.bind(t));else Ia.define(e,r,o)}};var _e=(e,t)=>{if(jt)return;if(jt=!0,we.forEach((s)=>s()),e===!0)process.exit(128+t)},ts=_e.bind(null,!0,15),ss=_e.bind(null,!0,2);Ia.onExit=(e)=>{if(we.size===0)process.once("SIGTERM",ts),process.once("SIGINT",ss),process.once("exit",_e);return we.add(e),()=>{if(we.delete(e),we.size===0)process.off("SIGTERM",ts),process.off("SIGINT",ss),process.off("exit",_e)}};Ia.define=(e,t,s)=>{Reflect.defineProperty(e,t,{value:s})};Ia.defineExport=(e,t,s)=>{let r;Reflect.defineProperty(e,t,{enumerable:!0,configurable:!0,set(o){r=o},get(){return r?r():s()}})}});var ns=w((Xm,as)=>{as.exports=({onlyFirst:e=!1}={})=>{let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}});var se=w((Jm,ds)=>{var tn=ns();ds.exports=(e)=>typeof e==="string"?e.replace(tn(),""):e});var ls=w((sn)=>{sn.ctrl={a:"first",b:"backward",c:"cancel",d:"deleteForward",e:"last",f:"forward",g:"reset",i:"tab",k:"cutForward",l:"reset",n:"newItem",m:"cancel",j:"submit",p:"search",r:"remove",s:"save",u:"undo",w:"cutLeft",x:"toggleCursor",v:"paste"};sn.shift={up:"shiftUp",down:"shiftDown",left:"shiftLeft",right:"shiftRight",tab:"prev"};sn.fn={up:"pageUp",down:"pageDown",left:"pageLeft",right:"pageRight",delete:"deleteForward"};sn.option={b:"backward",f:"forward",d:"cutRight",left:"cutLeft",up:"altUp",down:"altDown"};sn.keys={pageup:"pageUp",pagedown:"pageDown",home:"home",end:"end",cancel:"cancel",delete:"deleteForward",backspace:"delete",down:"down",enter:"submit",escape:"cancel",left:"left",space:"space",number:"number",return:"submit",right:"right",tab:"next",up:"up"}});var ms=w((ep,cs)=>{cs.exports=class{_queue=[];_executing=!1;_jobRunner=null;constructor(t){this._jobRunner=t}enqueue=(...t)=>{this._queue.push(t),this._dequeue()};destroy(){this._queue.length=0,this._jobRunner=null}_dequeue(){if(this._executing||!this._queue.length)return;this._executing=!0,this._jobRunner(...this._queue.shift()),setTimeout(()=>{this._executing=!1,this._dequeue()})}}});var mt=w((tp,us)=>{var ps=be("readline"),ln=ls(),cn=ms(),mn=/^(?:\x1b)([a-zA-Z0-9])$/,pn=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,un={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"};function hn(e){return["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(e)}function fn(e){return["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(e)}var Ie=(e="",t={})=>{let s,r={name:t.name,ctrl:!1,meta:!1,shift:!1,option:!1,sequence:e,raw:e,...t};if(Buffer.isBuffer(e))if(e[0]>127&&e[1]===void 0)e[0]-=128,e="\x1B"+String(e);else e=String(e);else if(e!==void 0&&typeof e!=="string")e=String(e);else if(!e)e=r.sequence||"";if(r.sequence=r.sequence||e||r.name,e==="\r")r.raw=void 0,r.name="return";else if(e===`
6
- `)r.name="enter";else if(e==="\t")r.name="tab";else if(e==="\b"||e==="\x7F"||e==="\x1B\x7F"||e==="\x1B\b")r.name="backspace",r.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")r.name="escape",r.meta=e.length===2;else if(e===" "||e==="\x1B ")r.name="space",r.meta=e.length===2;else if(e<="\x1A")r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")r.name="number";else if(e.length===1&&e>="a"&&e<="z")r.name=e;else if(e.length===1&&e>="A"&&e<="Z")r.name=e.toLowerCase(),r.shift=!0;else if(s=mn.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(s[1]);else if(s=pn.exec(e)){let o=[...e];if(o[0]==="\x1B"&&o[1]==="\x1B")r.option=!0;let i=[s[1],s[2],s[4],s[6]].filter(Boolean).join(""),a=(s[3]||s[5]||1)-1;r.ctrl=!!(a&4),r.meta=!!(a&10),r.shift=!!(a&1),r.code=i,r.name=un[i],r.shift=hn(i)||r.shift,r.ctrl=fn(i)||r.ctrl}return r};Ie.listen=(e={},t)=>{let{stdin:s}=e;if(!s||s!==process.stdin&&!s.isTTY)throw Error("Invalid stream passed");let r=ps.createInterface({terminal:!0,input:s});ps.emitKeypressEvents(s,r);let o=new cn((n,d)=>t(n,Ie(n,d),r)),i=s.isRaw;if(s.isTTY)s.setRawMode(!0);return s.on("keypress",o.enqueue),r.resume(),()=>{if(s.isTTY)s.setRawMode(i);s.removeListener("keypress",o.enqueue),o.destroy(),r.pause(),r.close()}};Ie.action=(e,t,s)=>{let r={...ln,...s};if(t.ctrl)return t.action=r.ctrl[t.name],t;if(t.option&&r.option)return t.action=r.option[t.name],t;if(t.shift)return t.action=r.shift[t.name],t;return t.action=r.keys[t.name],t};us.exports=Ie});var fs=w((sp,hs)=>{hs.exports=(e)=>{e.timers=e.timers||{};let t=e.options.timers;if(!t)return;for(let s of Object.keys(t)){let r=t[s];if(typeof r==="number")r={interval:r};yn(e,s,r)}};function yn(e,t,s={}){let r=e.timers[t]={name:t,start:Date.now(),ms:0,tick:0},o=s.interval||120;r.frames=s.frames||[],r.loading=!0;let i=setInterval(()=>{r.ms=Date.now()-r.start,r.tick++,e.render()},o);return r.stop=()=>{r.loading=!1,clearInterval(i)},Reflect.defineProperty(r,"interval",{value:i}),e.once("close",()=>r.stop()),r.stop}});var bs=w((rp,gs)=>{var{define:gn,width:bn}=C();class ys{constructor(e){let t=e.options;gn(this,"_prompt",e),this.type=e.type,this.name=e.name,this.message="",this.header="",this.footer="",this.error="",this.hint="",this.input="",this.cursor=0,this.index=0,this.lines=0,this.tick=0,this.prompt="",this.buffer="",this.width=bn(t.stdout||process.stdout),Object.assign(this,t),this.name=this.name||this.message,this.message=this.message||this.name,this.symbols=e.symbols,this.styles=e.styles,this.required=new Set,this.cancelled=!1,this.submitted=!1}clone(){let e={...this};return e.status=this.status,e.buffer=Buffer.from(e.buffer),delete e.clone,e}set color(e){this._color=e}get color(){let e=this.prompt.styles;if(this.cancelled)return e.cancelled;if(this.submitted)return e.submitted;let t=this._color||e[this.status];return typeof t==="function"?t:e.pending}set loading(e){this._loading=e}get loading(){if(typeof this._loading==="boolean")return this._loading;if(this.loadingChoices)return"choices";return!1}get status(){if(this.cancelled)return"cancelled";if(this.submitted)return"submitted";return"pending"}}gs.exports=ys});var ws=w((op,xs)=>{var pt=C(),M=Me(),ut={default:M.noop,noop:M.noop,set inverse(e){this._inverse=e},get inverse(){return this._inverse||pt.inverse(this.primary)},set complement(e){this._complement=e},get complement(){return this._complement||pt.complement(this.primary)},primary:M.cyan,success:M.green,danger:M.magenta,strong:M.bold,warning:M.yellow,muted:M.dim,disabled:M.gray,dark:M.dim.gray,underline:M.underline,set info(e){this._info=e},get info(){return this._info||this.primary},set em(e){this._em=e},get em(){return this._em||this.primary.underline},set heading(e){this._heading=e},get heading(){return this._heading||this.muted.underline},set pending(e){this._pending=e},get pending(){return this._pending||this.primary},set submitted(e){this._submitted=e},get submitted(){return this._submitted||this.success},set cancelled(e){this._cancelled=e},get cancelled(){return this._cancelled||this.danger},set typing(e){this._typing=e},get typing(){return this._typing||this.dim},set placeholder(e){this._placeholder=e},get placeholder(){return this._placeholder||this.primary.dim},set highlight(e){this._highlight=e},get highlight(){return this._highlight||this.inverse}};ut.merge=(e={})=>{if(e.styles&&typeof e.styles.enabled==="boolean")M.enabled=e.styles.enabled;if(e.styles&&typeof e.styles.visible==="boolean")M.visible=e.styles.visible;let t=pt.merge({},ut,e.styles);delete t.merge;for(let s of Object.keys(M))if(!hasOwnProperty.call(t,s))Reflect.defineProperty(t,s,{get:()=>M[s]});for(let s of Object.keys(M.styles))if(!hasOwnProperty.call(t,s))Reflect.defineProperty(t,s,{get:()=>M[s]});return t};xs.exports=ut});var As=w((ip,Es)=>{var ht=process.platform==="win32",K=Me(),xn=C(),ft={...K.symbols,upDownDoubleArrow:"\u21D5",upDownDoubleArrow2:"\u2B0D",upDownArrow:"\u2195",asterisk:"*",asterism:"\u2042",bulletWhite:"\u25E6",electricArrow:"\u2301",ellipsisLarge:"\u22EF",ellipsisSmall:"\u2026",fullBlock:"\u2588",identicalTo:"\u2261",indicator:K.symbols.check,leftAngle:"\u2039",mark:"\u203B",minus:"\u2212",multiplication:"\xD7",obelus:"\xF7",percent:"%",pilcrow:"\xB6",pilcrow2:"\u2761",pencilUpRight:"\u2710",pencilDownRight:"\u270E",pencilRight:"\u270F",plus:"+",plusMinus:"\xB1",pointRight:"\u261E",rightAngle:"\u203A",section:"\xA7",hexagon:{off:"\u2B21",on:"\u2B22",disabled:"\u2B22"},ballot:{on:"\u2611",off:"\u2610",disabled:"\u2612"},stars:{on:"\u2605",off:"\u2606",disabled:"\u2606"},folder:{on:"\u25BC",off:"\u25B6",disabled:"\u25B6"},prefix:{pending:K.symbols.question,submitted:K.symbols.check,cancelled:K.symbols.cross},separator:{pending:K.symbols.pointerSmall,submitted:K.symbols.middot,cancelled:K.symbols.middot},radio:{off:ht?"( )":"\u25EF",on:ht?"(*)":"\u25C9",disabled:ht?"(|)":"\u24BE"},numbers:["\u24EA","\u2460","\u2461","\u2462","\u2463","\u2464","\u2465","\u2466","\u2467","\u2468","\u2469","\u246A","\u246B","\u246C","\u246D","\u246E","\u246F","\u2470","\u2471","\u2472","\u2473","\u3251","\u3252","\u3253","\u3254","\u3255","\u3256","\u3257","\u3258","\u3259","\u325A","\u325B","\u325C","\u325D","\u325E","\u325F","\u32B1","\u32B2","\u32B3","\u32B4","\u32B5","\u32B6","\u32B7","\u32B8","\u32B9","\u32BA","\u32BB","\u32BC","\u32BD","\u32BE","\u32BF"]};ft.merge=(e)=>{let t=xn.merge({},K.symbols,ft,e.symbols);return delete t.merge,t};Es.exports=ft});var Ns=w((ap,vs)=>{var wn=ws(),En=As(),An=C();vs.exports=(e)=>{e.options=An.merge({},e.options.theme,e.options),e.symbols=En.merge(e.options),e.styles=wn.merge(e.options)}});var Ms=w((Ts,Rs)=>{var Ss=process.env.TERM_PROGRAM==="Apple_Terminal",vn=se(),yt=C(),L=Rs.exports=Ts,gt=!1,re=L.code={bell:"\x07",beep:"\x07",beginning:"\x1B[G",down:"\x1B[J",esc:"\x1B[",getPosition:"\x1B[6n",hide:"\x1B[?25l",line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",restorePosition:"\x1B["+(Ss?"8":"u"),savePosition:"\x1B["+(Ss?"7":"s"),screen:"\x1B[2J",show:"\x1B[?25h",up:"\x1B[1J"},ne=L.cursor={get hidden(){return gt},hide(){return gt=!0,re.hide},show(){return gt=!1,re.show},forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),up:(e=1)=>e?`\x1B[${e}A`:"",down:(e=1)=>e?`\x1B[${e}B`:"",right:(e=1)=>e?`\x1B[${e}C`:"",left:(e=1)=>e?`\x1B[${e}D`:"",to(e,t){return t?`\x1B[${t+1};${e+1}H`:`\x1B[${e+1}G`},move(e=0,t=0){let s="";return s+=e<0?ne.left(-e):e>0?ne.right(e):"",s+=t<0?ne.up(-t):t>0?ne.down(t):"",s},strLen(e){var t=0,s=e.length,r=-1;for(var o=0;o<s;o++)if(r=e.charCodeAt(o),r>=0&&r<=128)t+=1;else t+=2;return t},restore(e={}){let{after:t,cursor:s,initial:r,input:o,prompt:i,size:a,value:n}=e;if(r=yt.isPrimitive(r)?String(r):"",o=yt.isPrimitive(o)?String(o):"",n=yt.isPrimitive(n)?String(n):"",a){let d=L.cursor.up(a)+L.cursor.to(this.strLen(i)),l=o.length-s;if(l>0)d+=L.cursor.left(l);return d}if(n||t){let d=!o&&!!r?-this.strLen(r):-this.strLen(o)+s;if(t)d-=this.strLen(t);if(o===""&&r&&!i.includes(r))d+=this.strLen(r);return L.cursor.move(d)}}},bt=L.erase={screen:re.screen,up:re.up,down:re.down,line:re.line,lineEnd:re.lineEnd,lineStart:re.lineStart,lines(e){let t="";for(let s=0;s<e;s++)t+=L.erase.line+(s<e-1?L.cursor.up(1):"");if(e)t+=L.code.beginning;return t}};L.clear=(e="",t=process.stdout.columns)=>{if(!t)return bt.line+ne.to(0);let s=(i)=>[...vn(i)].length,r=e.split(/\r?\n/),o=0;for(let i of r)o+=1+Math.floor(Math.max(s(i)-1,0)/t);return(bt.line+ne.prevLine()).repeat(o-1)+bt.line+ne.to(0)}});var ue=w((np,_s)=>{var Nn=be("events"),Cs=se(),xt=mt(),Sn=fs(),Tn=bs(),Rn=Ns(),I=C(),de=Ms();class wt extends Nn{constructor(e={}){super();this.name=e.name,this.type=e.type,this.options=e,Rn(this),Sn(this),this.state=new Tn(this),this.initial=[e.initial,e.default].find((t)=>t!=null),this.stdout=e.stdout||process.stdout,this.stdin=e.stdin||process.stdin,this.scale=e.scale||1,this.term=this.options.term||process.env.TERM_PROGRAM,this.margin=Cn(this.options.margin),this.setMaxListeners(0),Mn(this)}async keypress(e,t={}){this.keypressed=!0;let s=xt.action(e,xt(e,t),this.options.actions);this.state.keypress=s,this.emit("keypress",e,s),this.emit("state",this.state.clone());let r=this.options[s.action]||this[s.action]||this.dispatch;if(typeof r==="function")return await r.call(this,e,s);this.alert()}alert(){if(delete this.state.alert,this.options.show===!1)this.emit("alert");else this.stdout.write(de.code.beep)}cursorHide(){this.stdout.write(de.cursor.hide());let e=I.onExit(()=>this.cursorShow());this.on("close",()=>{this.cursorShow(),e()})}cursorShow(){this.stdout.write(de.cursor.show())}write(e){if(!e)return;if(this.stdout&&this.state.show!==!1)this.stdout.write(e);this.state.buffer+=e}clear(e=0){let t=this.state.buffer;if(this.state.buffer="",!t&&!e||this.options.show===!1)return;this.stdout.write(de.cursor.down(e)+de.clear(t,this.width))}restore(){if(this.state.closed||this.options.show===!1)return;let{prompt:e,after:t,rest:s}=this.sections(),{cursor:r,initial:o="",input:i="",value:a=""}=this,n=this.state.size=s.length,d={after:t,cursor:r,initial:o,input:i,prompt:e,size:n,value:a},l=de.cursor.restore(d);if(l)this.stdout.write(l)}sections(){let{buffer:e,input:t,prompt:s}=this.state;s=Cs(s);let r=Cs(e),o=r.indexOf(s),i=r.slice(0,o),n=r.slice(o).split(`
7
- `),d=n[0],l=n[n.length-1],u=(s+(t?" "+t:"")).length,p=u<d.length?d.slice(u+1):"";return{header:i,prompt:d,after:p,rest:n.slice(1),last:l}}async submit(){if(this.state.submitted=!0,this.state.validating=!0,this.options.onSubmit)await this.options.onSubmit.call(this,this.name,this.value,this);let e=this.state.error||await this.validate(this.value,this.state);if(e!==!0){let t=`
3
+ var Sa=Object.create;var{getPrototypeOf:Na,defineProperty:Kt,getOwnPropertyNames:Ra}=Object;var Ca=Object.prototype.hasOwnProperty;function Ma(e){return this[e]}var _a,Ia,te=(e,t,s)=>{var r=e!=null&&typeof e==="object";if(r){var o=t?_a??=new WeakMap:Ia??=new WeakMap,i=o.get(e);if(i)return i}s=e!=null?Sa(Na(e)):{};let a=t||!e||!e.__esModule?Kt(s,"default",{value:e,enumerable:!0}):s;for(let n of Ra(e))if(!Ca.call(a,n))Kt(a,n,{get:Ma.bind(e,n),enumerable:!0});if(r)o.set(e,a);return a};var v=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var b=function(e,t,s,r){var o=arguments.length,i=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,s):r,a;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")i=Reflect.decorate(e,t,s,r);else for(var n=e.length-1;n>=0;n--)if(a=e[n])i=(o<3?a(i):o>3?a(t,s,i):a(t,s))||i;return o>3&&i&&Object.defineProperty(t,s,i),i};var Ee=import.meta.require;var Xt=v((vm,Ae)=>{var Ga=typeof process<"u"&&process.env.TERM_PROGRAM==="Hyper",$a=typeof process<"u"&&process.platform==="win32",Yt=typeof process<"u"&&process.platform==="linux",dt={ballotDisabled:"\u2612",ballotOff:"\u2610",ballotOn:"\u2611",bullet:"\u2022",bulletWhite:"\u25E6",fullBlock:"\u2588",heart:"\u2764",identicalTo:"\u2261",line:"\u2500",mark:"\u203B",middot:"\xB7",minus:"\uFF0D",multiplication:"\xD7",obelus:"\xF7",pencilDownRight:"\u270E",pencilRight:"\u270F",pencilUpRight:"\u2710",percent:"%",pilcrow2:"\u2761",pilcrow:"\xB6",plusMinus:"\xB1",question:"?",section:"\xA7",starsOff:"\u2606",starsOn:"\u2605",upDownArrow:"\u2195"},Qt=Object.assign({},dt,{check:"\u221A",cross:"\xD7",ellipsisLarge:"...",ellipsis:"...",info:"i",questionSmall:"?",pointer:">",pointerSmall:"\xBB",radioOff:"( )",radioOn:"(*)",warning:"\u203C"}),Zt=Object.assign({},dt,{ballotCross:"\u2718",check:"\u2714",cross:"\u2716",ellipsisLarge:"\u22EF",ellipsis:"\u2026",info:"\u2139",questionFull:"\uFF1F",questionSmall:"\uFE56",pointer:Yt?"\u25B8":"\u276F",pointerSmall:Yt?"\u2023":"\u203A",radioOff:"\u25EF",radioOn:"\u25C9",warning:"\u26A0"});Ae.exports=$a&&!Ga?Qt:Zt;Reflect.defineProperty(Ae.exports,"common",{enumerable:!1,value:dt});Reflect.defineProperty(Ae.exports,"windows",{enumerable:!1,value:Qt});Reflect.defineProperty(Ae.exports,"other",{enumerable:!1,value:Zt})});var Be=v((Em,ct)=>{var qa=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),Wa=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,Fa=()=>{if(typeof process<"u")return process.env.FORCE_COLOR!=="0";return!1},Jt=()=>{let e={enabled:Fa(),visible:!0,styles:{},keys:{}},t=(i)=>{let a=i.open=`\x1B[${i.codes[0]}m`,n=i.close=`\x1B[${i.codes[1]}m`,l=i.regex=new RegExp(`\\u001b\\[${i.codes[1]}m`,"g");return i.wrap=(d,c)=>{if(d.includes(n))d=d.replace(l,n+a);let u=a+d+n;return c?u.replace(/\r*\n/g,`${n}$&${a}`):u},i},s=(i,a,n)=>{return typeof i==="function"?i(a):i.wrap(a,n)},r=(i,a)=>{if(i===""||i==null)return"";if(e.enabled===!1)return i;if(e.visible===!1)return"";let n=""+i,l=n.includes(`
4
+ `),d=a.length;if(d>0&&a.includes("unstyle"))a=[...new Set(["unstyle",...a])].reverse();while(d-- >0)n=s(e.styles[a[d]],n,l);return n},o=(i,a,n)=>{e.styles[i]=t({name:i,codes:a}),(e.keys[n]||(e.keys[n]=[])).push(i),Reflect.defineProperty(e,i,{configurable:!0,enumerable:!0,set(d){e.alias(i,d)},get(){let d=(c)=>r(c,d.stack);return Reflect.setPrototypeOf(d,e),d.stack=this.stack?this.stack.concat(i):[i],d}})};return o("reset",[0,0],"modifier"),o("bold",[1,22],"modifier"),o("dim",[2,22],"modifier"),o("italic",[3,23],"modifier"),o("underline",[4,24],"modifier"),o("inverse",[7,27],"modifier"),o("hidden",[8,28],"modifier"),o("strikethrough",[9,29],"modifier"),o("black",[30,39],"color"),o("red",[31,39],"color"),o("green",[32,39],"color"),o("yellow",[33,39],"color"),o("blue",[34,39],"color"),o("magenta",[35,39],"color"),o("cyan",[36,39],"color"),o("white",[37,39],"color"),o("gray",[90,39],"color"),o("grey",[90,39],"color"),o("bgBlack",[40,49],"bg"),o("bgRed",[41,49],"bg"),o("bgGreen",[42,49],"bg"),o("bgYellow",[43,49],"bg"),o("bgBlue",[44,49],"bg"),o("bgMagenta",[45,49],"bg"),o("bgCyan",[46,49],"bg"),o("bgWhite",[47,49],"bg"),o("blackBright",[90,39],"bright"),o("redBright",[91,39],"bright"),o("greenBright",[92,39],"bright"),o("yellowBright",[93,39],"bright"),o("blueBright",[94,39],"bright"),o("magentaBright",[95,39],"bright"),o("cyanBright",[96,39],"bright"),o("whiteBright",[97,39],"bright"),o("bgBlackBright",[100,49],"bgBright"),o("bgRedBright",[101,49],"bgBright"),o("bgGreenBright",[102,49],"bgBright"),o("bgYellowBright",[103,49],"bgBright"),o("bgBlueBright",[104,49],"bgBright"),o("bgMagentaBright",[105,49],"bgBright"),o("bgCyanBright",[106,49],"bgBright"),o("bgWhiteBright",[107,49],"bgBright"),e.ansiRegex=Wa,e.hasColor=e.hasAnsi=(i)=>{return e.ansiRegex.lastIndex=0,typeof i==="string"&&i!==""&&e.ansiRegex.test(i)},e.alias=(i,a)=>{let n=typeof a==="string"?e[a]:a;if(typeof n!=="function")throw TypeError("Expected alias to be the name of an existing color (string) or a function");if(!n.stack)Reflect.defineProperty(n,"name",{value:i}),e.styles[i]=n,n.stack=[i];Reflect.defineProperty(e,i,{configurable:!0,enumerable:!0,set(l){e.alias(i,l)},get(){let l=(d)=>r(d,l.stack);return Reflect.setPrototypeOf(l,e),l.stack=this.stack?this.stack.concat(n.stack):n.stack,l}})},e.theme=(i)=>{if(!qa(i))throw TypeError("Expected theme to be an object");for(let a of Object.keys(i))e.alias(a,i[a]);return e},e.alias("unstyle",(i)=>{if(typeof i==="string"&&i!=="")return e.ansiRegex.lastIndex=0,i.replace(e.ansiRegex,"");return""}),e.alias("noop",(i)=>i),e.none=e.clear=e.noop,e.stripColor=e.unstyle,e.symbols=Xt(),e.define=o,e};ct.exports=Jt();ct.exports.create=Jt});var M=v((Ha)=>{var Ka=Object.prototype.toString,D=Be(),jt=!1,Te=new Set,es={yellow:"blue",cyan:"red",green:"magenta",black:"white",blue:"yellow",red:"cyan",magenta:"green",white:"black"};Ha.longest=(e,t)=>{return e.reduce((s,r)=>Math.max(s,t?r[t].length:r.length),0)};Ha.hasColor=(e)=>!!e&&D.hasColor(e);var Oe=Ha.isObject=(e)=>{return e!==null&&typeof e==="object"&&!Array.isArray(e)};Ha.nativeType=(e)=>{return Ka.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")};Ha.isAsyncFn=(e)=>{return Ha.nativeType(e)==="asyncfunction"};Ha.isPrimitive=(e)=>{return e!=null&&typeof e!=="object"&&typeof e!=="function"};Ha.resolve=(e,t,...s)=>{if(typeof t==="function")return t.call(e,...s);return t};Ha.scrollDown=(e=[])=>[...e.slice(1),e[0]];Ha.scrollUp=(e=[])=>[e.pop(),...e];Ha.reorder=(e=[])=>{let t=e.slice();return t.sort((s,r)=>{if(s.index>r.index)return 1;if(s.index<r.index)return-1;return 0}),t};Ha.swap=(e,t,s)=>{let r=e.length,o=s===r?0:s<0?r-1:s,i=e[t];e[t]=e[o],e[o]=i};Ha.width=(e,t=80)=>{let s=e&&e.columns?e.columns:t;if(e&&typeof e.getWindowSize==="function")s=e.getWindowSize()[0];if(process.platform==="win32")return s-1;return s};Ha.height=(e,t=20)=>{let s=e&&e.rows?e.rows:t;if(e&&typeof e.getWindowSize==="function")s=e.getWindowSize()[1];return s};Ha.wordWrap=(e,t={})=>{if(!e)return e;if(typeof t==="number")t={width:t};let{indent:s="",newline:r=`
5
+ `+s,width:o=80}=t,i=(r+s).match(/[^\S\n]/g)||[];o-=i.length;let a=`.{1,${o}}([\\s\\u200B]+|$)|[^\\s\\u200B]+?([\\s\\u200B]+|$)`,n=e.trim(),l=new RegExp(a,"g"),d=n.match(l)||[];if(d=d.map((c)=>c.replace(/\n$/,"")),t.padEnd)d=d.map((c)=>c.padEnd(o," "));if(t.padStart)d=d.map((c)=>c.padStart(o," "));return s+d.join(r)};Ha.unmute=(e)=>{let t=e.stack.find((r)=>D.keys.color.includes(r));if(t)return D[t];if(e.stack.find((r)=>r.slice(2)==="bg"))return D[t.slice(2)];return(r)=>r};Ha.pascal=(e)=>e?e[0].toUpperCase()+e.slice(1):"";Ha.inverse=(e)=>{if(!e||!e.stack)return e;let t=e.stack.find((r)=>D.keys.color.includes(r));if(t){let r=D["bg"+Ha.pascal(t)];return r?r.black:e}let s=e.stack.find((r)=>r.slice(0,2)==="bg");if(s)return D[s.slice(2).toLowerCase()]||e;return D.none};Ha.complement=(e)=>{if(!e||!e.stack)return e;let t=e.stack.find((r)=>D.keys.color.includes(r)),s=e.stack.find((r)=>r.slice(0,2)==="bg");if(t&&!s)return D[es[t]||t];if(s){let r=s.slice(2).toLowerCase(),o=es[r];if(!o)return e;return D["bg"+Ha.pascal(o)]||e}return D.none};Ha.meridiem=(e)=>{let t=e.getHours(),s=e.getMinutes(),r=t>=12?"pm":"am";t=t%12;let o=t===0?12:t,i=s<10?"0"+s:s;return o+":"+i+" "+r};Ha.set=(e={},t="",s)=>{return t.split(".").reduce((r,o,i,a)=>{let n=a.length-1>i?r[o]||{}:s;if(!Ha.isObject(n)&&i<a.length-1)n={};return r[o]=n},e)};Ha.get=(e={},t="",s)=>{let r=e[t]==null?t.split(".").reduce((o,i)=>o&&o[i],e):e[t];return r==null?s:r};Ha.mixin=(e,t)=>{if(!Oe(e))return t;if(!Oe(t))return e;for(let s of Object.keys(t)){let r=Object.getOwnPropertyDescriptor(t,s);if(hasOwnProperty.call(r,"value"))if(hasOwnProperty.call(e,s)&&Oe(r.value)){let o=Object.getOwnPropertyDescriptor(e,s);if(Oe(o.value)&&o.value!==r.value)e[s]=Ha.merge({},e[s],t[s]);else Reflect.defineProperty(e,s,r)}else Reflect.defineProperty(e,s,r);else Reflect.defineProperty(e,s,r)}return e};Ha.merge=(...e)=>{let t={};for(let s of e)Ha.mixin(t,s);return t};Ha.mixinEmitter=(e,t)=>{let s=t.constructor.prototype;for(let r of Object.keys(s)){let o=s[r];if(typeof o==="function")Ha.define(e,r,o.bind(t));else Ha.define(e,r,o)}};var De=(e,t)=>{if(jt)return;if(jt=!0,Te.forEach((s)=>s()),e===!0)process.exit(128+t)},ts=De.bind(null,!0,15),ss=De.bind(null,!0,2);Ha.onExit=(e)=>{if(Te.size===0)process.once("SIGTERM",ts),process.once("SIGINT",ss),process.once("exit",De);return Te.add(e),()=>{if(Te.delete(e),Te.size===0)process.off("SIGTERM",ts),process.off("SIGINT",ss),process.off("exit",De)}};Ha.define=(e,t,s)=>{Reflect.defineProperty(e,t,{value:s})};Ha.defineExport=(e,t,s)=>{let r;Reflect.defineProperty(e,t,{enumerable:!0,configurable:!0,set(o){r=o},get(){return r?r():s()}})}});var ns=v((Tm,as)=>{as.exports=({onlyFirst:e=!1}={})=>{let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}});var se=v((Sm,ls)=>{var yn=ns();ls.exports=(e)=>typeof e==="string"?e.replace(yn(),""):e});var ds=v((gn)=>{gn.ctrl={a:"first",b:"backward",c:"cancel",d:"deleteForward",e:"last",f:"forward",g:"reset",i:"tab",k:"cutForward",l:"reset",n:"newItem",m:"cancel",j:"submit",p:"search",r:"remove",s:"save",u:"undo",w:"cutLeft",x:"toggleCursor",v:"paste"};gn.shift={up:"shiftUp",down:"shiftDown",left:"shiftLeft",right:"shiftRight",tab:"prev"};gn.fn={up:"pageUp",down:"pageDown",left:"pageLeft",right:"pageRight",delete:"deleteForward"};gn.option={b:"backward",f:"forward",d:"cutRight",left:"cutLeft",up:"altUp",down:"altDown"};gn.keys={pageup:"pageUp",pagedown:"pageDown",home:"home",end:"end",cancel:"cancel",delete:"deleteForward",backspace:"delete",down:"down",enter:"submit",escape:"cancel",left:"left",space:"space",number:"number",return:"submit",right:"right",tab:"next",up:"up"}});var ps=v((Rm,cs)=>{cs.exports=class{_queue=[];_executing=!1;_jobRunner=null;constructor(t){this._jobRunner=t}enqueue=(...t)=>{this._queue.push(t),this._dequeue()};destroy(){this._queue.length=0,this._jobRunner=null}_dequeue(){if(this._executing||!this._queue.length)return;this._executing=!0,this._jobRunner(...this._queue.shift()),setTimeout(()=>{this._executing=!1,this._dequeue()})}}});var mt=v((Cm,us)=>{var ms=Ee("readline"),An=ds(),Tn=ps(),Sn=/^(?:\x1b)([a-zA-Z0-9])$/,Nn=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,Rn={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"};function Cn(e){return["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(e)}function Mn(e){return["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(e)}var Pe=(e="",t={})=>{let s,r={name:t.name,ctrl:!1,meta:!1,shift:!1,option:!1,sequence:e,raw:e,...t};if(Buffer.isBuffer(e))if(e[0]>127&&e[1]===void 0)e[0]-=128,e="\x1B"+String(e);else e=String(e);else if(e!==void 0&&typeof e!=="string")e=String(e);else if(!e)e=r.sequence||"";if(r.sequence=r.sequence||e||r.name,e==="\r")r.raw=void 0,r.name="return";else if(e===`
6
+ `)r.name="enter";else if(e==="\t")r.name="tab";else if(e==="\b"||e==="\x7F"||e==="\x1B\x7F"||e==="\x1B\b")r.name="backspace",r.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")r.name="escape",r.meta=e.length===2;else if(e===" "||e==="\x1B ")r.name="space",r.meta=e.length===2;else if(e<="\x1A")r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")r.name="number";else if(e.length===1&&e>="a"&&e<="z")r.name=e;else if(e.length===1&&e>="A"&&e<="Z")r.name=e.toLowerCase(),r.shift=!0;else if(s=Sn.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(s[1]);else if(s=Nn.exec(e)){let o=[...e];if(o[0]==="\x1B"&&o[1]==="\x1B")r.option=!0;let i=[s[1],s[2],s[4],s[6]].filter(Boolean).join(""),a=(s[3]||s[5]||1)-1;r.ctrl=!!(a&4),r.meta=!!(a&10),r.shift=!!(a&1),r.code=i,r.name=Rn[i],r.shift=Cn(i)||r.shift,r.ctrl=Mn(i)||r.ctrl}return r};Pe.listen=(e={},t)=>{let{stdin:s}=e;if(!s||s!==process.stdin&&!s.isTTY)throw Error("Invalid stream passed");let r=ms.createInterface({terminal:!0,input:s});ms.emitKeypressEvents(s,r);let o=new Tn((n,l)=>t(n,Pe(n,l),r)),i=s.isRaw;if(s.isTTY)s.setRawMode(!0);return s.on("keypress",o.enqueue),r.resume(),()=>{if(s.isTTY)s.setRawMode(i);s.removeListener("keypress",o.enqueue),o.destroy(),r.pause(),r.close()}};Pe.action=(e,t,s)=>{let r={...An,...s};if(t.ctrl)return t.action=r.ctrl[t.name],t;if(t.option&&r.option)return t.action=r.option[t.name],t;if(t.shift)return t.action=r.shift[t.name],t;return t.action=r.keys[t.name],t};us.exports=Pe});var fs=v((Mm,hs)=>{hs.exports=(e)=>{e.timers=e.timers||{};let t=e.options.timers;if(!t)return;for(let s of Object.keys(t)){let r=t[s];if(typeof r==="number")r={interval:r};_n(e,s,r)}};function _n(e,t,s={}){let r=e.timers[t]={name:t,start:Date.now(),ms:0,tick:0},o=s.interval||120;r.frames=s.frames||[],r.loading=!0;let i=setInterval(()=>{r.ms=Date.now()-r.start,r.tick++,e.render()},o);return r.stop=()=>{r.loading=!1,clearInterval(i)},Reflect.defineProperty(r,"interval",{value:i}),e.once("close",()=>r.stop()),r.stop}});var bs=v((_m,gs)=>{var{define:In,width:Bn}=M();class ys{constructor(e){let t=e.options;In(this,"_prompt",e),this.type=e.type,this.name=e.name,this.message="",this.header="",this.footer="",this.error="",this.hint="",this.input="",this.cursor=0,this.index=0,this.lines=0,this.tick=0,this.prompt="",this.buffer="",this.width=Bn(t.stdout||process.stdout),Object.assign(this,t),this.name=this.name||this.message,this.message=this.message||this.name,this.symbols=e.symbols,this.styles=e.styles,this.required=new Set,this.cancelled=!1,this.submitted=!1}clone(){let e={...this};return e.status=this.status,e.buffer=Buffer.from(e.buffer),delete e.clone,e}set color(e){this._color=e}get color(){let e=this.prompt.styles;if(this.cancelled)return e.cancelled;if(this.submitted)return e.submitted;let t=this._color||e[this.status];return typeof t==="function"?t:e.pending}set loading(e){this._loading=e}get loading(){if(typeof this._loading==="boolean")return this._loading;if(this.loadingChoices)return"choices";return!1}get status(){if(this.cancelled)return"cancelled";if(this.submitted)return"submitted";return"pending"}}gs.exports=ys});var ws=v((Im,xs)=>{var ut=M(),R=Be(),ht={default:R.noop,noop:R.noop,set inverse(e){this._inverse=e},get inverse(){return this._inverse||ut.inverse(this.primary)},set complement(e){this._complement=e},get complement(){return this._complement||ut.complement(this.primary)},primary:R.cyan,success:R.green,danger:R.magenta,strong:R.bold,warning:R.yellow,muted:R.dim,disabled:R.gray,dark:R.dim.gray,underline:R.underline,set info(e){this._info=e},get info(){return this._info||this.primary},set em(e){this._em=e},get em(){return this._em||this.primary.underline},set heading(e){this._heading=e},get heading(){return this._heading||this.muted.underline},set pending(e){this._pending=e},get pending(){return this._pending||this.primary},set submitted(e){this._submitted=e},get submitted(){return this._submitted||this.success},set cancelled(e){this._cancelled=e},get cancelled(){return this._cancelled||this.danger},set typing(e){this._typing=e},get typing(){return this._typing||this.dim},set placeholder(e){this._placeholder=e},get placeholder(){return this._placeholder||this.primary.dim},set highlight(e){this._highlight=e},get highlight(){return this._highlight||this.inverse}};ht.merge=(e={})=>{if(e.styles&&typeof e.styles.enabled==="boolean")R.enabled=e.styles.enabled;if(e.styles&&typeof e.styles.visible==="boolean")R.visible=e.styles.visible;let t=ut.merge({},ht,e.styles);delete t.merge;for(let s of Object.keys(R))if(!hasOwnProperty.call(t,s))Reflect.defineProperty(t,s,{get:()=>R[s]});for(let s of Object.keys(R.styles))if(!hasOwnProperty.call(t,s))Reflect.defineProperty(t,s,{get:()=>R[s]});return t};xs.exports=ht});var Es=v((Bm,vs)=>{var ft=process.platform==="win32",K=Be(),On=M(),yt={...K.symbols,upDownDoubleArrow:"\u21D5",upDownDoubleArrow2:"\u2B0D",upDownArrow:"\u2195",asterisk:"*",asterism:"\u2042",bulletWhite:"\u25E6",electricArrow:"\u2301",ellipsisLarge:"\u22EF",ellipsisSmall:"\u2026",fullBlock:"\u2588",identicalTo:"\u2261",indicator:K.symbols.check,leftAngle:"\u2039",mark:"\u203B",minus:"\u2212",multiplication:"\xD7",obelus:"\xF7",percent:"%",pilcrow:"\xB6",pilcrow2:"\u2761",pencilUpRight:"\u2710",pencilDownRight:"\u270E",pencilRight:"\u270F",plus:"+",plusMinus:"\xB1",pointRight:"\u261E",rightAngle:"\u203A",section:"\xA7",hexagon:{off:"\u2B21",on:"\u2B22",disabled:"\u2B22"},ballot:{on:"\u2611",off:"\u2610",disabled:"\u2612"},stars:{on:"\u2605",off:"\u2606",disabled:"\u2606"},folder:{on:"\u25BC",off:"\u25B6",disabled:"\u25B6"},prefix:{pending:K.symbols.question,submitted:K.symbols.check,cancelled:K.symbols.cross},separator:{pending:K.symbols.pointerSmall,submitted:K.symbols.middot,cancelled:K.symbols.middot},radio:{off:ft?"( )":"\u25EF",on:ft?"(*)":"\u25C9",disabled:ft?"(|)":"\u24BE"},numbers:["\u24EA","\u2460","\u2461","\u2462","\u2463","\u2464","\u2465","\u2466","\u2467","\u2468","\u2469","\u246A","\u246B","\u246C","\u246D","\u246E","\u246F","\u2470","\u2471","\u2472","\u2473","\u3251","\u3252","\u3253","\u3254","\u3255","\u3256","\u3257","\u3258","\u3259","\u325A","\u325B","\u325C","\u325D","\u325E","\u325F","\u32B1","\u32B2","\u32B3","\u32B4","\u32B5","\u32B6","\u32B7","\u32B8","\u32B9","\u32BA","\u32BB","\u32BC","\u32BD","\u32BE","\u32BF"]};yt.merge=(e)=>{let t=On.merge({},K.symbols,yt,e.symbols);return delete t.merge,t};vs.exports=yt});var Ts=v((Om,As)=>{var Dn=ws(),Pn=Es(),Ln=M();As.exports=(e)=>{e.options=Ln.merge({},e.options.theme,e.options),e.symbols=Pn.merge(e.options),e.styles=Dn.merge(e.options)}});var Cs=v((Ns,Rs)=>{var Ss=process.env.TERM_PROGRAM==="Apple_Terminal",kn=se(),gt=M(),L=Rs.exports=Ns,bt=!1,re=L.code={bell:"\x07",beep:"\x07",beginning:"\x1B[G",down:"\x1B[J",esc:"\x1B[",getPosition:"\x1B[6n",hide:"\x1B[?25l",line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",restorePosition:"\x1B["+(Ss?"8":"u"),savePosition:"\x1B["+(Ss?"7":"s"),screen:"\x1B[2J",show:"\x1B[?25h",up:"\x1B[1J"},le=L.cursor={get hidden(){return bt},hide(){return bt=!0,re.hide},show(){return bt=!1,re.show},forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),up:(e=1)=>e?`\x1B[${e}A`:"",down:(e=1)=>e?`\x1B[${e}B`:"",right:(e=1)=>e?`\x1B[${e}C`:"",left:(e=1)=>e?`\x1B[${e}D`:"",to(e,t){return t?`\x1B[${t+1};${e+1}H`:`\x1B[${e+1}G`},move(e=0,t=0){let s="";return s+=e<0?le.left(-e):e>0?le.right(e):"",s+=t<0?le.up(-t):t>0?le.down(t):"",s},strLen(e){var t=0,s=e.length,r=-1;for(var o=0;o<s;o++)if(r=e.charCodeAt(o),r>=0&&r<=128)t+=1;else t+=2;return t},restore(e={}){let{after:t,cursor:s,initial:r,input:o,prompt:i,size:a,value:n}=e;if(r=gt.isPrimitive(r)?String(r):"",o=gt.isPrimitive(o)?String(o):"",n=gt.isPrimitive(n)?String(n):"",a){let l=L.cursor.up(a)+L.cursor.to(this.strLen(i)),d=o.length-s;if(d>0)l+=L.cursor.left(d);return l}if(n||t){let l=!o&&!!r?-this.strLen(r):-this.strLen(o)+s;if(t)l-=this.strLen(t);if(o===""&&r&&!i.includes(r))l+=this.strLen(r);return L.cursor.move(l)}}},xt=L.erase={screen:re.screen,up:re.up,down:re.down,line:re.line,lineEnd:re.lineEnd,lineStart:re.lineStart,lines(e){let t="";for(let s=0;s<e;s++)t+=L.erase.line+(s<e-1?L.cursor.up(1):"");if(e)t+=L.code.beginning;return t}};L.clear=(e="",t=process.stdout.columns)=>{if(!t)return xt.line+le.to(0);let s=(i)=>[...kn(i)].length,r=e.split(/\r?\n/),o=0;for(let i of r)o+=1+Math.floor(Math.max(s(i)-1,0)/t);return(xt.line+le.prevLine()).repeat(o-1)+xt.line+le.to(0)}});var he=v((Dm,_s)=>{var Un=Ee("events"),Ms=se(),wt=mt(),Gn=fs(),$n=bs(),qn=Ts(),I=M(),de=Cs();class vt extends Un{constructor(e={}){super();this.name=e.name,this.type=e.type,this.options=e,qn(this),Gn(this),this.state=new $n(this),this.initial=[e.initial,e.default].find((t)=>t!=null),this.stdout=e.stdout||process.stdout,this.stdin=e.stdin||process.stdin,this.scale=e.scale||1,this.term=this.options.term||process.env.TERM_PROGRAM,this.margin=Fn(this.options.margin),this.setMaxListeners(0),Wn(this)}async keypress(e,t={}){this.keypressed=!0;let s=wt.action(e,wt(e,t),this.options.actions);this.state.keypress=s,this.emit("keypress",e,s),this.emit("state",this.state.clone());let r=this.options[s.action]||this[s.action]||this.dispatch;if(typeof r==="function")return await r.call(this,e,s);this.alert()}alert(){if(delete this.state.alert,this.options.show===!1)this.emit("alert");else this.stdout.write(de.code.beep)}cursorHide(){this.stdout.write(de.cursor.hide());let e=I.onExit(()=>this.cursorShow());this.on("close",()=>{this.cursorShow(),e()})}cursorShow(){this.stdout.write(de.cursor.show())}write(e){if(!e)return;if(this.stdout&&this.state.show!==!1)this.stdout.write(e);this.state.buffer+=e}clear(e=0){let t=this.state.buffer;if(this.state.buffer="",!t&&!e||this.options.show===!1)return;this.stdout.write(de.cursor.down(e)+de.clear(t,this.width))}restore(){if(this.state.closed||this.options.show===!1)return;let{prompt:e,after:t,rest:s}=this.sections(),{cursor:r,initial:o="",input:i="",value:a=""}=this,n=this.state.size=s.length,l={after:t,cursor:r,initial:o,input:i,prompt:e,size:n,value:a},d=de.cursor.restore(l);if(d)this.stdout.write(d)}sections(){let{buffer:e,input:t,prompt:s}=this.state;s=Ms(s);let r=Ms(e),o=r.indexOf(s),i=r.slice(0,o),n=r.slice(o).split(`
7
+ `),l=n[0],d=n[n.length-1],u=(s+(t?" "+t:"")).length,m=u<l.length?l.slice(u+1):"";return{header:i,prompt:l,after:m,rest:n.slice(1),last:d}}async submit(){if(this.state.submitted=!0,this.state.validating=!0,this.options.onSubmit)await this.options.onSubmit.call(this,this.name,this.value,this);let e=this.state.error||await this.validate(this.value,this.state);if(e!==!0){let t=`
8
8
  `+this.symbols.pointer+" ";if(typeof e==="string")t+=e.trim();else t+="Invalid input";this.state.error=`
9
9
  `+this.styles.danger(t),this.state.submitted=!1,await this.render(),await this.alert(),this.state.validating=!1,this.state.error=void 0;return}this.state.validating=!1,await this.render(),await this.close(),this.value=await this.result(this.value),this.emit("submit",this.value)}async cancel(e){if(this.state.cancelled=this.state.submitted=!0,await this.render(),await this.close(),typeof this.options.onCancel==="function")await this.options.onCancel.call(this,this.name,this.value,this);this.emit("cancel",await this.error(e))}async close(){this.state.closed=!0;try{let e=this.sections(),t=Math.ceil(e.prompt.length/this.width);if(e.rest)this.write(de.cursor.down(e.rest.length));this.write(`
10
- `.repeat(t))}catch(e){}this.emit("close")}start(){if(!this.stop&&this.options.show!==!1)this.stop=xt.listen(this,this.keypress.bind(this)),this.once("close",this.stop),this.emit("start",this)}async skip(){if(this.skipped=this.options.skip===!0,typeof this.options.skip==="function")this.skipped=await this.options.skip.call(this,this.name,this.value);return this.skipped}async initialize(){let{format:e,options:t,result:s}=this;if(this.format=()=>e.call(this,this.value),this.result=()=>s.call(this,this.value),typeof t.initial==="function")this.initial=await t.initial.call(this,this);if(typeof t.onRun==="function")await t.onRun.call(this,this);if(typeof t.onSubmit==="function"){let r=t.onSubmit.bind(this),o=this.submit.bind(this);delete this.options.onSubmit,this.submit=async()=>{return await r(this.name,this.value,this),o()}}await this.start(),await this.render()}render(){throw Error("expected prompt to have a custom render method")}run(){return new Promise(async(e,t)=>{if(this.once("submit",e),this.once("cancel",t),await this.skip())return this.render=()=>{},this.submit();await this.initialize(),this.emit("run")})}async element(e,t,s){let{options:r,state:o,symbols:i,timers:a}=this,n=a&&a[e];o.timer=n;let d=r[e]||o[e]||i[e],l=t&&t[e]!=null?t[e]:await d;if(l==="")return l;let c=await this.resolve(l,o,t,s);if(!c&&t&&t[e])return this.resolve(d,o,t,s);return c}async prefix(){let e=await this.element("prefix")||this.symbols,t=this.timers&&this.timers.prefix,s=this.state;if(s.timer=t,I.isObject(e))e=e[s.status]||e.pending;if(!I.hasColor(e))return(this.styles[s.status]||this.styles.pending)(e);return e}async message(){let e=await this.element("message");if(!I.hasColor(e))return this.styles.strong(e);return e}async separator(){let e=await this.element("separator")||this.symbols,t=this.timers&&this.timers.separator,s=this.state;s.timer=t;let r=e[s.status]||e.pending||s.separator,o=await this.resolve(r,s);if(I.isObject(o))o=o[s.status]||o.pending;if(!I.hasColor(o))return this.styles.muted(o);return o}async pointer(e,t){let s=await this.element("pointer",e,t);if(typeof s==="string"&&I.hasColor(s))return s;if(s){let r=this.styles,o=this.index===t,i=o?r.primary:(d)=>d,a=await this.resolve(s[o?"on":"off"]||s,this.state),n=!I.hasColor(a)?i(a):a;return o?n:" ".repeat(a.length)}}async indicator(e,t){let s=await this.element("indicator",e,t);if(typeof s==="string"&&I.hasColor(s))return s;if(s){let r=this.styles,o=e.enabled===!0,i=o?r.success:r.dark,a=s[o?"on":"off"]||s;return!I.hasColor(a)?i(a):a}return""}body(){return null}footer(){if(this.state.status==="pending")return this.element("footer")}header(){if(this.state.status==="pending")return this.element("header")}async hint(){if(this.state.status==="pending"&&!this.isValue(this.state.input)){let e=await this.element("hint");if(!I.hasColor(e))return this.styles.muted(e);return e}}error(e){return!this.state.submitted?e||this.state.error:""}format(e){return e}result(e){return e}validate(e){if(this.options.required===!0)return this.isValue(e);return!0}isValue(e){return e!=null&&e!==""}resolve(e,...t){return I.resolve(this,e,...t)}get base(){return wt.prototype}get style(){return this.styles[this.state.status]}get height(){return this.options.rows||I.height(this.stdout,25)}get width(){return this.options.columns||I.width(this.stdout,80)}get size(){return{width:this.width,height:this.height}}set cursor(e){this.state.cursor=e}get cursor(){return this.state.cursor}set input(e){this.state.input=e}get input(){return this.state.input}set value(e){this.state.value=e}get value(){let{input:e,value:t}=this.state,s=[t,e].find(this.isValue.bind(this));return this.isValue(s)?s:this.initial}static get prompt(){return(e)=>new this(e).run()}}function Mn(e){let t=(o)=>{return e[o]===void 0||typeof e[o]==="function"},s=["actions","choices","initial","margin","roles","styles","symbols","theme","timers","value"],r=["body","footer","error","header","hint","indicator","message","prefix","separator","skip"];for(let o of Object.keys(e.options)){if(s.includes(o))continue;if(/^on[A-Z]/.test(o))continue;let i=e.options[o];if(typeof i==="function"&&t(o)){if(!r.includes(o))e[o]=i.bind(e)}else if(typeof e[o]!=="function")e[o]=i}}function Cn(e){if(typeof e==="number")e=[e,e,e,e];let t=[].concat(e||[]),s=(o)=>o%2===0?`
11
- `:" ",r=[];for(let o=0;o<4;o++){let i=s(o);if(t[o])r.push(i.repeat(t[o]));else r.push("")}return r}_s.exports=wt});var Ds=w((dp,Os)=>{var _n=C(),Is={default(e,t){return t},checkbox(e,t){throw Error("checkbox role is not implemented yet")},editable(e,t){throw Error("editable role is not implemented yet")},expandable(e,t){throw Error("expandable role is not implemented yet")},heading(e,t){return t.disabled="",t.indicator=[t.indicator," "].find((s)=>s!=null),t.message=t.message||"",t},input(e,t){throw Error("input role is not implemented yet")},option(e,t){return Is.default(e,t)},radio(e,t){throw Error("radio role is not implemented yet")},separator(e,t){return t.disabled="",t.indicator=[t.indicator," "].find((s)=>s!=null),t.message=t.message||e.symbols.line.repeat(5),t},spacer(e,t){return t}};Os.exports=(e,t={})=>{let s=_n.merge({},Is,t.roles);return s[e]||s.default}});var Ee=w((lp,Us)=>{var In=se(),On=ue(),Dn=Ds(),Oe=C(),{reorder:Et,scrollUp:Bn,scrollDown:Pn,isObject:Bs,swap:Ln}=Oe;class Ls extends On{constructor(e){super(e);this.cursorHide(),this.maxSelected=e.maxSelected||1/0,this.multiple=e.multiple||!1,this.initial=e.initial||0,this.delay=e.delay||0,this.longest=0,this.num=""}async initialize(){if(typeof this.options.initial==="function")this.initial=await this.options.initial.call(this);await this.reset(!0),await super.initialize()}async reset(){let{choices:e,initial:t,autofocus:s,suggest:r}=this.options;if(this.state._choices=[],this.state.choices=[],this.choices=await Promise.all(await this.toChoices(e)),this.choices.forEach((o)=>o.enabled=!1),typeof r!=="function"&&this.selectable.length===0)throw Error("At least one choice must be selectable");if(Bs(t))t=Object.keys(t);if(Array.isArray(t)){if(s!=null)this.index=this.findIndex(s);t.forEach((o)=>this.enable(this.find(o))),await this.render()}else{if(s!=null)t=s;if(typeof t==="string")t=this.findIndex(t);if(typeof t==="number"&&t>-1)this.index=Math.max(0,Math.min(t,this.choices.length)),this.enable(this.find(this.index))}if(this.isDisabled(this.focused))await this.down()}async toChoices(e,t){this.state.loadingChoices=!0;let s=[],r=0,o=async(i,a)=>{if(typeof i==="function")i=await i.call(this);if(i instanceof Promise)i=await i;for(let n=0;n<i.length;n++){let d=i[n]=await this.toChoice(i[n],r++,a);if(s.push(d),d.choices)await o(d.choices,d)}return s};return o(e,t).then((i)=>{return this.state.loadingChoices=!1,i})}async toChoice(e,t,s){if(typeof e==="function")e=await e.call(this,this);if(e instanceof Promise)e=await e;if(typeof e==="string")e={name:e};if(e.normalized)return e;e.normalized=!0;let r=e.value;if(e=Dn(e.role,this.options)(this,e),typeof e.disabled==="string"&&!e.hint)e.hint=e.disabled,e.disabled=!0;if(e.disabled===!0&&e.hint==null)e.hint="(disabled)";if(e.index!=null)return e;if(e.name=e.name||e.key||e.title||e.value||e.message,e.message=e.message||e.name||"",e.value=[e.value,e.name].find(this.isValue.bind(this)),e.input="",e.index=t,e.cursor=0,Oe.define(e,"parent",s),e.level=s?s.level+1:1,e.indent==null)e.indent=s?s.indent+" ":e.indent||"";if(e.path=s?s.path+"."+e.name:e.name,e.enabled=!!(this.multiple&&!this.isDisabled(e)&&(e.enabled||this.isSelected(e))),!this.isDisabled(e))this.longest=Math.max(this.longest,In(e.message).length);let i={...e};if(e.reset=(a=i.input,n=i.value)=>{for(let d of Object.keys(i))e[d]=i[d];e.input=a,e.value=n},r==null&&typeof e.initial==="function")e.input=await e.initial.call(this,this.state,e,t);return e}async onChoice(e,t){if(this.emit("choice",e,t,this),typeof e.onChoice==="function")await e.onChoice.call(this,this.state,e,t)}async addChoice(e,t,s){let r=await this.toChoice(e,t,s);return this.choices.push(r),this.index=this.choices.length-1,this.limit=this.choices.length,r}async newItem(e,t,s){let r={name:"New choice name?",editable:!0,newChoice:!0,...e},o=await this.addChoice(r,t,s);return o.updateChoice=()=>{delete o.newChoice,o.name=o.message=o.input,o.input="",o.cursor=0},this.render()}indent(e){if(e.indent==null)return e.level>1?" ".repeat(e.level-1):"";return e.indent}dispatch(e,t){if(this.multiple&&this[t.name])return this[t.name]();this.alert()}focus(e,t){if(typeof t!=="boolean")t=e.enabled;if(t&&!e.enabled&&this.selected.length>=this.maxSelected)return this.alert();return this.index=e.index,e.enabled=t&&!this.isDisabled(e),e}space(){if(!this.multiple)return this.alert();if(!this.focused)return;return this.toggle(this.focused),this.render()}a(){if(this.maxSelected<this.choices.length)return this.alert();let e=this.selectable.every((t)=>t.enabled);return this.choices.forEach((t)=>t.enabled=!e),this.render()}i(){if(this.choices.length-this.selected.length>this.maxSelected)return this.alert();return this.choices.forEach((e)=>e.enabled=!e.enabled),this.render()}g(){if(!this.choices.some((t)=>!!t.parent))return this.a();let e=this.focused;return this.toggle(e.parent&&!e.choices?e.parent:e),this.render()}toggle(e,t){if(!e.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(typeof t!=="boolean")t=!e.enabled;if(e.enabled=t,e.choices)e.choices.forEach((r)=>this.toggle(r,t));let s=e.parent;while(s){let r=s.choices.filter((o)=>this.isDisabled(o));s.enabled=r.every((o)=>o.enabled===!0),s=s.parent}return Ps(this,this.choices),this.emit("toggle",e,this),e}enable(e){if(this.selected.length>=this.maxSelected)return this.alert();return e.enabled=!this.isDisabled(e),e.choices&&e.choices.forEach(this.enable.bind(this)),e}disable(e){return e.enabled=!1,e.choices&&e.choices.forEach(this.disable.bind(this)),e}number(e){this.num+=e;let t=(s)=>{let r=Number(s);if(r>this.choices.length-1)return this.alert();let o=this.focused,i=this.choices.find((a)=>r===a.index);if(!i.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(this.visible.indexOf(i)===-1){let a=Et(this.choices),n=a.indexOf(i);if(o.index>n){let d=a.slice(n,n+this.limit),l=a.filter((c)=>!d.includes(c));this.choices=d.concat(l)}else{let d=n-this.limit+1;this.choices=a.slice(d).concat(a.slice(0,d))}}return this.index=this.choices.indexOf(i),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise((s)=>{let r=this.choices.length,o=this.num,i=(a=!1,n)=>{if(clearTimeout(this.numberTimeout),a)n=t(o);this.num="",s(n)};if(o==="0"||o.length===1&&Number(o+"0")>r)return i(!0);if(Number(o)>r)return i(!1,this.alert());this.numberTimeout=setTimeout(()=>i(!0),this.delay)})}home(){return this.choices=Et(this.choices),this.index=0,this.render()}end(){let e=this.choices.length-this.limit,t=Et(this.choices);return this.choices=t.slice(e).concat(t.slice(0,e)),this.index=this.limit-1,this.render()}first(){return this.index=0,this.render()}last(){return this.index=this.visible.length-1,this.render()}prev(){if(this.visible.length<=1)return this.alert();return this.up()}next(){if(this.visible.length<=1)return this.alert();return this.down()}right(){if(this.cursor>=this.input.length)return this.alert();return this.cursor++,this.render()}left(){if(this.cursor<=0)return this.alert();return this.cursor--,this.render()}up(){let e=this.choices.length,t=this.visible.length,s=this.index;if(this.options.scroll===!1&&s===0)return this.alert();if(e>t&&s===0)return this.scrollUp();if(this.index=(s-1%e+e)%e,this.isDisabled()&&!this.allChoicesAreDisabled())return this.up();return this.render()}down(){let e=this.choices.length,t=this.visible.length,s=this.index;if(this.options.scroll===!1&&s===t-1)return this.alert();if(e>t&&s===t-1)return this.scrollDown();if(this.index=(s+1)%e,this.isDisabled()&&!this.allChoicesAreDisabled())return this.down();return this.render()}scrollUp(e=0){if(this.choices=Bn(this.choices),this.index=e,this.isDisabled())return this.up();return this.render()}scrollDown(e=this.visible.length-1){if(this.choices=Pn(this.choices),this.index=e,this.isDisabled())return this.down();return this.render()}async shiftUp(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index-1),await this.up(),this.sorting=!1;return}return this.scrollUp(this.index)}async shiftDown(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index+1),await this.down(),this.sorting=!1;return}return this.scrollDown(this.index)}pageUp(){if(this.visible.length<=1)return this.alert();if(this.limit=Math.max(this.limit-1,0),this.index=Math.min(this.limit-1,this.index),this._limit=this.limit,this.isDisabled())return this.up();return this.render()}pageDown(){if(this.visible.length>=this.choices.length)return this.alert();if(this.index=Math.max(0,this.index),this.limit=Math.min(this.limit+1,this.choices.length),this._limit=this.limit,this.isDisabled())return this.down();return this.render()}swap(e){Ln(this.choices,this.index,e)}allChoicesAreDisabled(e=this.choices){return e.every((t)=>this.isDisabled(t))}isDisabled(e=this.focused){if(e&&["disabled","collapsed","hidden","completing","readonly"].some((s)=>e[s]===!0))return!0;return e&&e.role==="heading"}isEnabled(e=this.focused){if(Array.isArray(e))return e.every((t)=>this.isEnabled(t));if(e.choices){let t=e.choices.filter((s)=>!this.isDisabled(s));return e.enabled&&t.every((s)=>this.isEnabled(s))}return e.enabled&&!this.isDisabled(e)}isChoice(e,t){return e.name===t||e.index===Number(t)}isSelected(e){if(Array.isArray(this.initial))return this.initial.some((t)=>this.isChoice(e,t));return this.isChoice(e,this.initial)}map(e=[],t="value"){return[].concat(e||[]).reduce((s,r)=>{return s[r]=this.find(r,t),s},{})}filter(e,t){let r=typeof e==="function"?e:(a,n)=>[a.name,n].includes(e),i=(this.options.multiple?this.state._choices:this.choices).filter(r);if(t)return i.map((a)=>a[t]);return i}find(e,t){if(Bs(e))return t?e[t]:e;let r=typeof e==="function"?e:(i,a)=>[i.name,a].includes(e),o=this.choices.find(r);if(o)return t?o[t]:o}findIndex(e){return this.choices.indexOf(this.find(e))}async submit(){let e=this.focused;if(!e)return this.alert();if(e.newChoice){if(!e.input)return this.alert();return e.updateChoice(),this.render()}if(this.choices.some((i)=>i.newChoice))return this.alert();let{reorder:t,sort:s}=this.options,r=this.multiple===!0,o=this.selected;if(o===void 0)return this.alert();if(Array.isArray(o)&&t!==!1&&s!==!0)o=Oe.reorder(o);return this.value=r?o.map((i)=>i.name):o.name,super.submit()}set choices(e=[]){this.state._choices=this.state._choices||[],this.state.choices=e;for(let t of e)if(!this.state._choices.some((s)=>s.name===t.name))this.state._choices.push(t);if(!this._initial&&this.options.initial){this._initial=!0;let t=this.initial;if(typeof t==="string"||typeof t==="number"){let s=this.find(t);if(s)this.initial=s.index,this.focus(s,!0)}}}get choices(){return Ps(this,this.state.choices||[])}set visible(e){this.state.visible=e}get visible(){return(this.state.visible||this.choices).slice(0,this.limit)}set limit(e){this.state.limit=e}get limit(){let{state:e,options:t,choices:s}=this,r=e.limit||this._limit||t.limit||s.length;return Math.min(r,this.height)}set value(e){super.value=e}get value(){if(typeof super.value!=="string"&&super.value===this.initial)return this.input;return super.value}set index(e){this.state.index=e}get index(){return Math.max(0,this.state?this.state.index:0)}get enabled(){return this.filter(this.isEnabled.bind(this))}get focused(){let e=this.choices[this.index];if(e&&this.state.submitted&&this.multiple!==!0)e.enabled=!0;return e}get selectable(){return this.choices.filter((e)=>!this.isDisabled(e))}get selected(){return this.multiple?this.enabled:this.focused}}function Ps(e,t){if(t instanceof Promise)return t;if(typeof t==="function"){if(Oe.isAsyncFn(t))return t;t=t.call(e,e)}for(let s of t){if(Array.isArray(s.choices)){let r=s.choices.filter((o)=>!e.isDisabled(o));s.enabled=r.every((o)=>o.enabled===!0)}if(e.isDisabled(s)===!0)delete s.enabled}return t}Us.exports=Ls});var oe=w((cp,ks)=>{var Un=Ee(),At=C();class Gs extends Un{constructor(e){super(e);this.emptyError=this.options.emptyError||"No items were selected"}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}separator(){if(this.options.separator)return super.separator();let e=this.styles.muted(this.symbols.ellipsis);return this.state.submitted?super.separator():e}pointer(e,t){return!this.multiple||this.options.pointer?super.pointer(e,t):""}indicator(e,t){return this.multiple?super.indicator(e,t):""}choiceMessage(e,t){let s=this.resolve(e.message,this.state,e,t);if(e.role==="heading"&&!At.hasColor(s))s=this.styles.strong(s);return this.resolve(s,this.state,e,t)}choiceSeparator(){return":"}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=await this.pointer(e,t),o=await this.indicator(e,t)+(e.pad||""),i=await this.resolve(e.hint,this.state,e,t);if(i&&!At.hasColor(i))i=this.styles.muted(i);let a=this.indent(e),n=await this.choiceMessage(e,t),d=()=>[this.margin[3],a+r+o,n,this.margin[1],i].filter(Boolean).join(" ");if(e.role==="heading")return d();if(e.disabled){if(!At.hasColor(n))n=this.styles.disabled(n);return d()}if(s)n=this.styles.em(n);return d()}async renderChoices(){if(this.state.loading==="choices")return this.styles.warning("Loading choices");if(this.state.submitted)return"";let e=this.visible.map(async(o,i)=>await this.renderChoice(o,i)),t=await Promise.all(e);if(!t.length)t.push(this.styles.danger("No matching choices"));let s=this.margin[0]+t.join(`
10
+ `.repeat(t))}catch(e){}this.emit("close")}start(){if(!this.stop&&this.options.show!==!1)this.stop=wt.listen(this,this.keypress.bind(this)),this.once("close",this.stop),this.emit("start",this)}async skip(){if(this.skipped=this.options.skip===!0,typeof this.options.skip==="function")this.skipped=await this.options.skip.call(this,this.name,this.value);return this.skipped}async initialize(){let{format:e,options:t,result:s}=this;if(this.format=()=>e.call(this,this.value),this.result=()=>s.call(this,this.value),typeof t.initial==="function")this.initial=await t.initial.call(this,this);if(typeof t.onRun==="function")await t.onRun.call(this,this);if(typeof t.onSubmit==="function"){let r=t.onSubmit.bind(this),o=this.submit.bind(this);delete this.options.onSubmit,this.submit=async()=>{return await r(this.name,this.value,this),o()}}await this.start(),await this.render()}render(){throw Error("expected prompt to have a custom render method")}run(){return new Promise(async(e,t)=>{if(this.once("submit",e),this.once("cancel",t),await this.skip())return this.render=()=>{},this.submit();await this.initialize(),this.emit("run")})}async element(e,t,s){let{options:r,state:o,symbols:i,timers:a}=this,n=a&&a[e];o.timer=n;let l=r[e]||o[e]||i[e],d=t&&t[e]!=null?t[e]:await l;if(d==="")return d;let c=await this.resolve(d,o,t,s);if(!c&&t&&t[e])return this.resolve(l,o,t,s);return c}async prefix(){let e=await this.element("prefix")||this.symbols,t=this.timers&&this.timers.prefix,s=this.state;if(s.timer=t,I.isObject(e))e=e[s.status]||e.pending;if(!I.hasColor(e))return(this.styles[s.status]||this.styles.pending)(e);return e}async message(){let e=await this.element("message");if(!I.hasColor(e))return this.styles.strong(e);return e}async separator(){let e=await this.element("separator")||this.symbols,t=this.timers&&this.timers.separator,s=this.state;s.timer=t;let r=e[s.status]||e.pending||s.separator,o=await this.resolve(r,s);if(I.isObject(o))o=o[s.status]||o.pending;if(!I.hasColor(o))return this.styles.muted(o);return o}async pointer(e,t){let s=await this.element("pointer",e,t);if(typeof s==="string"&&I.hasColor(s))return s;if(s){let r=this.styles,o=this.index===t,i=o?r.primary:(l)=>l,a=await this.resolve(s[o?"on":"off"]||s,this.state),n=!I.hasColor(a)?i(a):a;return o?n:" ".repeat(a.length)}}async indicator(e,t){let s=await this.element("indicator",e,t);if(typeof s==="string"&&I.hasColor(s))return s;if(s){let r=this.styles,o=e.enabled===!0,i=o?r.success:r.dark,a=s[o?"on":"off"]||s;return!I.hasColor(a)?i(a):a}return""}body(){return null}footer(){if(this.state.status==="pending")return this.element("footer")}header(){if(this.state.status==="pending")return this.element("header")}async hint(){if(this.state.status==="pending"&&!this.isValue(this.state.input)){let e=await this.element("hint");if(!I.hasColor(e))return this.styles.muted(e);return e}}error(e){return!this.state.submitted?e||this.state.error:""}format(e){return e}result(e){return e}validate(e){if(this.options.required===!0)return this.isValue(e);return!0}isValue(e){return e!=null&&e!==""}resolve(e,...t){return I.resolve(this,e,...t)}get base(){return vt.prototype}get style(){return this.styles[this.state.status]}get height(){return this.options.rows||I.height(this.stdout,25)}get width(){return this.options.columns||I.width(this.stdout,80)}get size(){return{width:this.width,height:this.height}}set cursor(e){this.state.cursor=e}get cursor(){return this.state.cursor}set input(e){this.state.input=e}get input(){return this.state.input}set value(e){this.state.value=e}get value(){let{input:e,value:t}=this.state,s=[t,e].find(this.isValue.bind(this));return this.isValue(s)?s:this.initial}static get prompt(){return(e)=>new this(e).run()}}function Wn(e){let t=(o)=>{return e[o]===void 0||typeof e[o]==="function"},s=["actions","choices","initial","margin","roles","styles","symbols","theme","timers","value"],r=["body","footer","error","header","hint","indicator","message","prefix","separator","skip"];for(let o of Object.keys(e.options)){if(s.includes(o))continue;if(/^on[A-Z]/.test(o))continue;let i=e.options[o];if(typeof i==="function"&&t(o)){if(!r.includes(o))e[o]=i.bind(e)}else if(typeof e[o]!=="function")e[o]=i}}function Fn(e){if(typeof e==="number")e=[e,e,e,e];let t=[].concat(e||[]),s=(o)=>o%2===0?`
11
+ `:" ",r=[];for(let o=0;o<4;o++){let i=s(o);if(t[o])r.push(i.repeat(t[o]));else r.push("")}return r}_s.exports=vt});var Os=v((Pm,Bs)=>{var Kn=M(),Is={default(e,t){return t},checkbox(e,t){throw Error("checkbox role is not implemented yet")},editable(e,t){throw Error("editable role is not implemented yet")},expandable(e,t){throw Error("expandable role is not implemented yet")},heading(e,t){return t.disabled="",t.indicator=[t.indicator," "].find((s)=>s!=null),t.message=t.message||"",t},input(e,t){throw Error("input role is not implemented yet")},option(e,t){return Is.default(e,t)},radio(e,t){throw Error("radio role is not implemented yet")},separator(e,t){return t.disabled="",t.indicator=[t.indicator," "].find((s)=>s!=null),t.message=t.message||e.symbols.line.repeat(5),t},spacer(e,t){return t}};Bs.exports=(e,t={})=>{let s=Kn.merge({},Is,t.roles);return s[e]||s.default}});var Se=v((Lm,ks)=>{var Hn=se(),Vn=he(),zn=Os(),Le=M(),{reorder:Et,scrollUp:Yn,scrollDown:Qn,isObject:Ds,swap:Zn}=Le;class Ls extends Vn{constructor(e){super(e);this.cursorHide(),this.maxSelected=e.maxSelected||1/0,this.multiple=e.multiple||!1,this.initial=e.initial||0,this.delay=e.delay||0,this.longest=0,this.num=""}async initialize(){if(typeof this.options.initial==="function")this.initial=await this.options.initial.call(this);await this.reset(!0),await super.initialize()}async reset(){let{choices:e,initial:t,autofocus:s,suggest:r}=this.options;if(this.state._choices=[],this.state.choices=[],this.choices=await Promise.all(await this.toChoices(e)),this.choices.forEach((o)=>o.enabled=!1),typeof r!=="function"&&this.selectable.length===0)throw Error("At least one choice must be selectable");if(Ds(t))t=Object.keys(t);if(Array.isArray(t)){if(s!=null)this.index=this.findIndex(s);t.forEach((o)=>this.enable(this.find(o))),await this.render()}else{if(s!=null)t=s;if(typeof t==="string")t=this.findIndex(t);if(typeof t==="number"&&t>-1)this.index=Math.max(0,Math.min(t,this.choices.length)),this.enable(this.find(this.index))}if(this.isDisabled(this.focused))await this.down()}async toChoices(e,t){this.state.loadingChoices=!0;let s=[],r=0,o=async(i,a)=>{if(typeof i==="function")i=await i.call(this);if(i instanceof Promise)i=await i;for(let n=0;n<i.length;n++){let l=i[n]=await this.toChoice(i[n],r++,a);if(s.push(l),l.choices)await o(l.choices,l)}return s};return o(e,t).then((i)=>{return this.state.loadingChoices=!1,i})}async toChoice(e,t,s){if(typeof e==="function")e=await e.call(this,this);if(e instanceof Promise)e=await e;if(typeof e==="string")e={name:e};if(e.normalized)return e;e.normalized=!0;let r=e.value;if(e=zn(e.role,this.options)(this,e),typeof e.disabled==="string"&&!e.hint)e.hint=e.disabled,e.disabled=!0;if(e.disabled===!0&&e.hint==null)e.hint="(disabled)";if(e.index!=null)return e;if(e.name=e.name||e.key||e.title||e.value||e.message,e.message=e.message||e.name||"",e.value=[e.value,e.name].find(this.isValue.bind(this)),e.input="",e.index=t,e.cursor=0,Le.define(e,"parent",s),e.level=s?s.level+1:1,e.indent==null)e.indent=s?s.indent+" ":e.indent||"";if(e.path=s?s.path+"."+e.name:e.name,e.enabled=!!(this.multiple&&!this.isDisabled(e)&&(e.enabled||this.isSelected(e))),!this.isDisabled(e))this.longest=Math.max(this.longest,Hn(e.message).length);let i={...e};if(e.reset=(a=i.input,n=i.value)=>{for(let l of Object.keys(i))e[l]=i[l];e.input=a,e.value=n},r==null&&typeof e.initial==="function")e.input=await e.initial.call(this,this.state,e,t);return e}async onChoice(e,t){if(this.emit("choice",e,t,this),typeof e.onChoice==="function")await e.onChoice.call(this,this.state,e,t)}async addChoice(e,t,s){let r=await this.toChoice(e,t,s);return this.choices.push(r),this.index=this.choices.length-1,this.limit=this.choices.length,r}async newItem(e,t,s){let r={name:"New choice name?",editable:!0,newChoice:!0,...e},o=await this.addChoice(r,t,s);return o.updateChoice=()=>{delete o.newChoice,o.name=o.message=o.input,o.input="",o.cursor=0},this.render()}indent(e){if(e.indent==null)return e.level>1?" ".repeat(e.level-1):"";return e.indent}dispatch(e,t){if(this.multiple&&this[t.name])return this[t.name]();this.alert()}focus(e,t){if(typeof t!=="boolean")t=e.enabled;if(t&&!e.enabled&&this.selected.length>=this.maxSelected)return this.alert();return this.index=e.index,e.enabled=t&&!this.isDisabled(e),e}space(){if(!this.multiple)return this.alert();if(!this.focused)return;return this.toggle(this.focused),this.render()}a(){if(this.maxSelected<this.choices.length)return this.alert();let e=this.selectable.every((t)=>t.enabled);return this.choices.forEach((t)=>t.enabled=!e),this.render()}i(){if(this.choices.length-this.selected.length>this.maxSelected)return this.alert();return this.choices.forEach((e)=>e.enabled=!e.enabled),this.render()}g(){if(!this.choices.some((t)=>!!t.parent))return this.a();let e=this.focused;return this.toggle(e.parent&&!e.choices?e.parent:e),this.render()}toggle(e,t){if(!e.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(typeof t!=="boolean")t=!e.enabled;if(e.enabled=t,e.choices)e.choices.forEach((r)=>this.toggle(r,t));let s=e.parent;while(s){let r=s.choices.filter((o)=>this.isDisabled(o));s.enabled=r.every((o)=>o.enabled===!0),s=s.parent}return Ps(this,this.choices),this.emit("toggle",e,this),e}enable(e){if(this.selected.length>=this.maxSelected)return this.alert();return e.enabled=!this.isDisabled(e),e.choices&&e.choices.forEach(this.enable.bind(this)),e}disable(e){return e.enabled=!1,e.choices&&e.choices.forEach(this.disable.bind(this)),e}number(e){this.num+=e;let t=(s)=>{let r=Number(s);if(r>this.choices.length-1)return this.alert();let o=this.focused,i=this.choices.find((a)=>r===a.index);if(!i.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(this.visible.indexOf(i)===-1){let a=Et(this.choices),n=a.indexOf(i);if(o.index>n){let l=a.slice(n,n+this.limit),d=a.filter((c)=>!l.includes(c));this.choices=l.concat(d)}else{let l=n-this.limit+1;this.choices=a.slice(l).concat(a.slice(0,l))}}return this.index=this.choices.indexOf(i),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise((s)=>{let r=this.choices.length,o=this.num,i=(a=!1,n)=>{if(clearTimeout(this.numberTimeout),a)n=t(o);this.num="",s(n)};if(o==="0"||o.length===1&&Number(o+"0")>r)return i(!0);if(Number(o)>r)return i(!1,this.alert());this.numberTimeout=setTimeout(()=>i(!0),this.delay)})}home(){return this.choices=Et(this.choices),this.index=0,this.render()}end(){let e=this.choices.length-this.limit,t=Et(this.choices);return this.choices=t.slice(e).concat(t.slice(0,e)),this.index=this.limit-1,this.render()}first(){return this.index=0,this.render()}last(){return this.index=this.visible.length-1,this.render()}prev(){if(this.visible.length<=1)return this.alert();return this.up()}next(){if(this.visible.length<=1)return this.alert();return this.down()}right(){if(this.cursor>=this.input.length)return this.alert();return this.cursor++,this.render()}left(){if(this.cursor<=0)return this.alert();return this.cursor--,this.render()}up(){let e=this.choices.length,t=this.visible.length,s=this.index;if(this.options.scroll===!1&&s===0)return this.alert();if(e>t&&s===0)return this.scrollUp();if(this.index=(s-1%e+e)%e,this.isDisabled()&&!this.allChoicesAreDisabled())return this.up();return this.render()}down(){let e=this.choices.length,t=this.visible.length,s=this.index;if(this.options.scroll===!1&&s===t-1)return this.alert();if(e>t&&s===t-1)return this.scrollDown();if(this.index=(s+1)%e,this.isDisabled()&&!this.allChoicesAreDisabled())return this.down();return this.render()}scrollUp(e=0){if(this.choices=Yn(this.choices),this.index=e,this.isDisabled())return this.up();return this.render()}scrollDown(e=this.visible.length-1){if(this.choices=Qn(this.choices),this.index=e,this.isDisabled())return this.down();return this.render()}async shiftUp(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index-1),await this.up(),this.sorting=!1;return}return this.scrollUp(this.index)}async shiftDown(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index+1),await this.down(),this.sorting=!1;return}return this.scrollDown(this.index)}pageUp(){if(this.visible.length<=1)return this.alert();if(this.limit=Math.max(this.limit-1,0),this.index=Math.min(this.limit-1,this.index),this._limit=this.limit,this.isDisabled())return this.up();return this.render()}pageDown(){if(this.visible.length>=this.choices.length)return this.alert();if(this.index=Math.max(0,this.index),this.limit=Math.min(this.limit+1,this.choices.length),this._limit=this.limit,this.isDisabled())return this.down();return this.render()}swap(e){Zn(this.choices,this.index,e)}allChoicesAreDisabled(e=this.choices){return e.every((t)=>this.isDisabled(t))}isDisabled(e=this.focused){if(e&&["disabled","collapsed","hidden","completing","readonly"].some((s)=>e[s]===!0))return!0;return e&&e.role==="heading"}isEnabled(e=this.focused){if(Array.isArray(e))return e.every((t)=>this.isEnabled(t));if(e.choices){let t=e.choices.filter((s)=>!this.isDisabled(s));return e.enabled&&t.every((s)=>this.isEnabled(s))}return e.enabled&&!this.isDisabled(e)}isChoice(e,t){return e.name===t||e.index===Number(t)}isSelected(e){if(Array.isArray(this.initial))return this.initial.some((t)=>this.isChoice(e,t));return this.isChoice(e,this.initial)}map(e=[],t="value"){return[].concat(e||[]).reduce((s,r)=>{return s[r]=this.find(r,t),s},{})}filter(e,t){let r=typeof e==="function"?e:(a,n)=>[a.name,n].includes(e),i=(this.options.multiple?this.state._choices:this.choices).filter(r);if(t)return i.map((a)=>a[t]);return i}find(e,t){if(Ds(e))return t?e[t]:e;let r=typeof e==="function"?e:(i,a)=>[i.name,a].includes(e),o=this.choices.find(r);if(o)return t?o[t]:o}findIndex(e){return this.choices.indexOf(this.find(e))}async submit(){let e=this.focused;if(!e)return this.alert();if(e.newChoice){if(!e.input)return this.alert();return e.updateChoice(),this.render()}if(this.choices.some((i)=>i.newChoice))return this.alert();let{reorder:t,sort:s}=this.options,r=this.multiple===!0,o=this.selected;if(o===void 0)return this.alert();if(Array.isArray(o)&&t!==!1&&s!==!0)o=Le.reorder(o);return this.value=r?o.map((i)=>i.name):o.name,super.submit()}set choices(e=[]){this.state._choices=this.state._choices||[],this.state.choices=e;for(let t of e)if(!this.state._choices.some((s)=>s.name===t.name))this.state._choices.push(t);if(!this._initial&&this.options.initial){this._initial=!0;let t=this.initial;if(typeof t==="string"||typeof t==="number"){let s=this.find(t);if(s)this.initial=s.index,this.focus(s,!0)}}}get choices(){return Ps(this,this.state.choices||[])}set visible(e){this.state.visible=e}get visible(){return(this.state.visible||this.choices).slice(0,this.limit)}set limit(e){this.state.limit=e}get limit(){let{state:e,options:t,choices:s}=this,r=e.limit||this._limit||t.limit||s.length;return Math.min(r,this.height)}set value(e){super.value=e}get value(){if(typeof super.value!=="string"&&super.value===this.initial)return this.input;return super.value}set index(e){this.state.index=e}get index(){return Math.max(0,this.state?this.state.index:0)}get enabled(){return this.filter(this.isEnabled.bind(this))}get focused(){let e=this.choices[this.index];if(e&&this.state.submitted&&this.multiple!==!0)e.enabled=!0;return e}get selectable(){return this.choices.filter((e)=>!this.isDisabled(e))}get selected(){return this.multiple?this.enabled:this.focused}}function Ps(e,t){if(t instanceof Promise)return t;if(typeof t==="function"){if(Le.isAsyncFn(t))return t;t=t.call(e,e)}for(let s of t){if(Array.isArray(s.choices)){let r=s.choices.filter((o)=>!e.isDisabled(o));s.enabled=r.every((o)=>o.enabled===!0)}if(e.isDisabled(s)===!0)delete s.enabled}return t}ks.exports=Ls});var oe=v((km,Gs)=>{var Xn=Se(),At=M();class Us extends Xn{constructor(e){super(e);this.emptyError=this.options.emptyError||"No items were selected"}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}separator(){if(this.options.separator)return super.separator();let e=this.styles.muted(this.symbols.ellipsis);return this.state.submitted?super.separator():e}pointer(e,t){return!this.multiple||this.options.pointer?super.pointer(e,t):""}indicator(e,t){return this.multiple?super.indicator(e,t):""}choiceMessage(e,t){let s=this.resolve(e.message,this.state,e,t);if(e.role==="heading"&&!At.hasColor(s))s=this.styles.strong(s);return this.resolve(s,this.state,e,t)}choiceSeparator(){return":"}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=await this.pointer(e,t),o=await this.indicator(e,t)+(e.pad||""),i=await this.resolve(e.hint,this.state,e,t);if(i&&!At.hasColor(i))i=this.styles.muted(i);let a=this.indent(e),n=await this.choiceMessage(e,t),l=()=>[this.margin[3],a+r+o,n,this.margin[1],i].filter(Boolean).join(" ");if(e.role==="heading")return l();if(e.disabled){if(!At.hasColor(n))n=this.styles.disabled(n);return l()}if(s)n=this.styles.em(n);return l()}async renderChoices(){if(this.state.loading==="choices")return this.styles.warning("Loading choices");if(this.state.submitted)return"";let e=this.visible.map(async(o,i)=>await this.renderChoice(o,i)),t=await Promise.all(e);if(!t.length)t.push(this.styles.danger("No matching choices"));let s=this.margin[0]+t.join(`
12
12
  `),r;if(this.options.choicesHeader)r=await this.resolve(this.options.choicesHeader,this.state);return[r,s].filter(Boolean).join(`
13
- `)}format(){if(!this.state.submitted||this.state.cancelled)return"";if(Array.isArray(this.selected))return this.selected.map((e)=>this.styles.primary(e.name)).join(", ");return this.styles.primary(this.selected.name)}async render(){let{submitted:e,size:t}=this.state,s="",r=await this.header(),o=await this.prefix(),i=await this.separator(),a=await this.message();if(this.options.promptLine!==!1)s=[o,a,i,""].join(" "),this.state.prompt=s;let n=await this.format(),d=await this.error()||await this.hint(),l=await this.renderChoices(),c=await this.footer();if(n)s+=n;if(d&&!s.includes(d))s+=" "+d;if(e&&!n&&!l.trim()&&this.multiple&&this.emptyError!=null)s+=this.styles.danger(this.emptyError);this.clear(t),this.write([r,s,l,c].filter(Boolean).join(`
14
- `)),this.write(this.margin[2]),this.restore()}}ks.exports=Gs});var qs=w((mp,Ws)=>{var Gn=oe(),kn=(e,t)=>{let s=e?new RegExp(e,"ig"):/$^/;return(r)=>{return e?r.replace(s,(o)=>t(o)):r}};class $s extends Gn{constructor(e){super(e);this.cursorShow()}moveCursor(e){this.state.cursor+=e}dispatch(e){return this.append(e)}space(e){return this.options.multiple?super.space(e):this.append(e)}append(e){let{cursor:t,input:s}=this.state;return this.input=s.slice(0,t)+e+s.slice(t),this.moveCursor(1),this.complete()}delete(){let{cursor:e,input:t}=this.state;if(!t)return this.alert();return this.input=t.slice(0,e-1)+t.slice(e),this.moveCursor(-1),this.complete()}deleteForward(){let{cursor:e,input:t}=this.state;if(t[e]===void 0)return this.alert();return this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.complete()}number(e){return this.append(e)}async complete(){this.completing=!0,this.choices=await this.suggest(this.input,this.state._choices),this.state.limit=void 0,this.index=Math.min(Math.max(this.visible.length-1,0),this.index),await this.render(),this.completing=!1}suggest(e=this.input,t=this.state._choices){if(typeof this.options.suggest==="function")return this.options.suggest.call(this,e,t);let s=e.toLowerCase();return t.filter((r)=>r.message.toLowerCase().includes(s))}pointer(){return""}format(){if(!this.focused)return this.input;if(this.options.multiple&&this.state.submitted)return this.selected.map((e)=>this.styles.primary(e.message)).join(", ");if(this.state.submitted){let e=this.value=this.input=this.focused.value;return this.styles.primary(e)}return this.input}async render(){if(this.state.status!=="pending")return super.render();let e=this.options.highlight||this.styles.complement,t=(o,i)=>{if(!o)return o;if(e.stack)return e(o);return e.call(this,o)},s=kn(this.input,t),r=this.choices;this.choices=r.map((o)=>({...o,message:s(o.message)})),await super.render(),this.choices=r}submit(){if(this.options.multiple)this.value=this.selected.map((e)=>e.name);return super.submit()}}Ws.exports=$s});var Nt=w((pp,Ks)=>{var vt=C();Ks.exports=(e,t={})=>{e.cursorHide();let{input:s="",initial:r="",pos:o,showCursor:i=!0,color:a}=t,n=a||e.styles.placeholder,d=vt.inverse(e.styles.primary),l=(f)=>d(e.styles.black(f)),c=s,u=" ",p=l(u);if(e.blink&&e.blink.off===!0)l=(f)=>f,p="";if(i&&o===0&&r===""&&s==="")return l(u);if(i&&o===0&&(s===r||s===""))return l(r[0])+n(r.slice(1));r=vt.isPrimitive(r)?`${r}`:"",s=vt.isPrimitive(s)?`${s}`:"";let m=r&&r.startsWith(s)&&r!==s,h=m?l(r[s.length]):p;if(o!==s.length&&i===!0)c=s.slice(0,o)+l(s[o])+s.slice(o+1),h="";if(i===!1)h="";if(m){let f=e.styles.unstyle(c+h);return c+h+n(r.slice(f.length))}return c+h}});var De=w((up,Fs)=>{var $n=se(),Wn=oe(),qn=Nt();class Hs extends Wn{constructor(e){super({...e,multiple:!0});this.type="form",this.initial=this.options.initial,this.align=[this.options.align,"right"].find((t)=>t!=null),this.emptyError="",this.values={}}async reset(e){if(await super.reset(),e===!0)this._index=this.index;return this.index=this._index,this.values={},this.choices.forEach((t)=>t.reset&&t.reset()),this.render()}dispatch(e){return!!e&&this.append(e)}append(e){let t=this.focused;if(!t)return this.alert();let{cursor:s,input:r}=t;return t.value=t.input=r.slice(0,s)+e+r.slice(s),t.cursor++,this.render()}delete(){let e=this.focused;if(!e||e.cursor<=0)return this.alert();let{cursor:t,input:s}=e;return e.value=e.input=s.slice(0,t-1)+s.slice(t),e.cursor--,this.render()}deleteForward(){let e=this.focused;if(!e)return this.alert();let{cursor:t,input:s}=e;if(s[t]===void 0)return this.alert();let r=`${s}`.slice(0,t)+`${s}`.slice(t+1);return e.value=e.input=r,this.render()}right(){let e=this.focused;if(!e)return this.alert();if(e.cursor>=e.input.length)return this.alert();return e.cursor++,this.render()}left(){let e=this.focused;if(!e)return this.alert();if(e.cursor<=0)return this.alert();return e.cursor--,this.render()}space(e,t){return this.dispatch(e,t)}number(e,t){return this.dispatch(e,t)}next(){let e=this.focused;if(!e)return this.alert();let{initial:t,input:s}=e;if(t&&t.startsWith(s)&&s!==t)return e.value=e.input=t,e.cursor=e.value.length,this.render();return super.next()}prev(){let e=this.focused;if(!e)return this.alert();if(e.cursor===0)return super.prev();return e.value=e.input="",e.cursor=0,this.render()}separator(){return""}format(e){return!this.state.submitted?super.format(e):""}pointer(){return""}indicator(e){return e.input?"\u29BF":"\u2299"}async choiceSeparator(e,t){let s=await this.resolve(e.separator,this.state,e,t)||":";return s?" "+this.styles.disabled(s):""}async renderChoice(e,t){await this.onChoice(e,t);let{state:s,styles:r}=this,{cursor:o,initial:i="",name:a,input:n=""}=e,{muted:d,submitted:l,primary:c,danger:u}=r,p=this.index===t,m=e.validate||(()=>!0),h=await this.choiceSeparator(e,t),f=e.message;if(this.align==="right")f=f.padStart(this.longest+1," ");if(this.align==="left")f=f.padEnd(this.longest+1," ");let g=this.values[a]=n||i,y=n?"success":"dark";if(await m.call(e,g,this.state)!==!0)y="danger";let E=r[y],A=E(await this.indicator(e,t))+(e.pad||""),N=this.indent(e),R=()=>[N,A,f+h,n].filter(Boolean).join(" ");if(s.submitted)return f=$n(f),n=l(n),R();if(e.format)n=await e.format.call(this,n,e,t);else{let _=this.styles.muted;n=qn(this,{input:n,initial:i,pos:o,showCursor:p,color:_})}if(!this.isValue(n))n=this.styles.muted(this.symbols.ellipsis);if(e.result)this.values[a]=await e.result.call(this,g,e,t);if(p)f=c(f);if(e.error)n+=(n?" ":"")+u(e.error.trim());else if(e.hint)n+=(n?" ":"")+d(e.hint.trim());return R()}async submit(){return this.value=this.values,super.base.submit.call(this)}}Fs.exports=Hs});var St=w((hp,Ys)=>{var Kn=De(),Hn=()=>{throw Error("expected prompt to have a custom authenticate method")},Vs=(e=Hn)=>{class t extends Kn{constructor(s){super(s)}async submit(){this.value=await e.call(this,this.values,this.state),super.base.submit.call(this)}static create(s){return Vs(s)}}return t};Ys.exports=Vs()});var Qs=w((fp,Zs)=>{var Fn=St();function Vn(e,t){if(e.username===this.options.username&&e.password===this.options.password)return!0;return!1}var zs=(e=Vn)=>{let t=[{name:"username",message:"username"},{name:"password",message:"password",format(r){if(this.options.showPassword)return r;return(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(r.length))}}];class s extends Fn.create(e){constructor(r){super({...r,choices:t})}static create(r){return zs(r)}}return s};Zs.exports=zs()});var Be=w((yp,Js)=>{var Yn=ue(),{isPrimitive:zn,hasColor:Zn}=C();class Xs extends Yn{constructor(e){super(e);this.cursorHide()}async initialize(){let e=await this.resolve(this.initial,this.state);this.input=await this.cast(e),await super.initialize()}dispatch(e){if(!this.isValue(e))return this.alert();return this.input=e,this.submit()}format(e){let{styles:t,state:s}=this;return!s.submitted?t.primary(e):t.success(e)}cast(e){return this.isTrue(e)}isTrue(e){return/^[ty1]/i.test(e)}isFalse(e){return/^[fn0]/i.test(e)}isValue(e){return zn(e)&&(this.isTrue(e)||this.isFalse(e))}async hint(){if(this.state.status==="pending"){let e=await this.element("hint");if(!Zn(e))return this.styles.muted(e);return e}}async render(){let{input:e,size:t}=this.state,s=await this.prefix(),r=await this.separator(),o=await this.message(),i=this.styles.muted(this.default),a=[s,o,i,r].filter(Boolean).join(" ");this.state.prompt=a;let n=await this.header(),d=this.value=this.cast(e),l=await this.format(d),c=await this.error()||await this.hint(),u=await this.footer();if(c&&!a.includes(c))l+=" "+c;a+=" "+l,this.clear(t),this.write([n,a,u].filter(Boolean).join(`
15
- `)),this.restore()}set value(e){super.value=e}get value(){return this.cast(super.value)}}Js.exports=Xs});var tr=w((gp,er)=>{var Qn=Be();class js extends Qn{constructor(e){super(e);this.default=this.options.default||(this.initial?"(Y/n)":"(y/N)")}}er.exports=js});var or=w((bp,rr)=>{var Xn=oe(),Jn=De(),he=Jn.prototype;class sr extends Xn{constructor(e){super({...e,multiple:!0});this.align=[this.options.align,"left"].find((t)=>t!=null),this.emptyError="",this.values={}}dispatch(e,t){let s=this.focused,r=s.parent||{};if(!s.editable&&!r.editable){if(e==="a"||e==="i")return super[e]()}return he.dispatch.call(this,e,t)}append(e,t){return he.append.call(this,e,t)}delete(e,t){return he.delete.call(this,e,t)}space(e){return this.focused.editable?this.append(e):super.space()}number(e){return this.focused.editable?this.append(e):super.number(e)}next(){return this.focused.editable?he.next.call(this):super.next()}prev(){return this.focused.editable?he.prev.call(this):super.prev()}async indicator(e,t){let s=e.indicator||"",r=e.editable?s:super.indicator(e,t);return await this.resolve(r,this.state,e,t)||""}indent(e){return e.role==="heading"?"":e.editable?" ":" "}async renderChoice(e,t){if(e.indent="",e.editable)return he.renderChoice.call(this,e,t);return super.renderChoice(e,t)}error(){return""}footer(){return this.state.error}async validate(){let e=!0;for(let t of this.choices){if(typeof t.validate!=="function")continue;if(t.role==="heading")continue;let s=t.parent?this.value[t.parent.name]:this.value;if(t.editable)s=t.value===t.name?t.initial||"":t.value;else if(!this.isDisabled(t))s=t.enabled===!0;if(e=await t.validate(s,this.state),e!==!0)break}if(e!==!0)this.state.error=typeof e==="string"?e:"Invalid Input";return e}submit(){if(this.focused.newChoice===!0)return super.submit();if(this.choices.some((e)=>e.newChoice))return this.alert();this.value={};for(let e of this.choices){let t=e.parent?this.value[e.parent.name]:this.value;if(e.role==="heading"){this.value[e.name]={};continue}if(e.editable)t[e.name]=e.value===e.name?e.initial||"":e.value;else if(!this.isDisabled(e))t[e.name]=e.enabled===!0}return this.base.submit.call(this)}}rr.exports=sr});var le=w((xp,ar)=>{var jn=ue(),ed=mt(),td=Nt(),{isPrimitive:sd}=C();class ir extends jn{constructor(e){super(e);if(this.initial=sd(this.initial)?String(this.initial):"",this.initial)this.cursorHide();this.state.prevCursor=0,this.state.clipboard=[],this.keypressTimeout=this.options.keypressTimeout!==void 0?this.options.keypressTimeout:null}async keypress(e,t=e?ed(e,{}):{}){let s=Date.now(),r=s-this.lastKeypress;this.lastKeypress=s;let o=t.name==="return"||t.name==="enter",i=this.state.prevKeypress,a;if(this.state.prevKeypress=t,this.keypressTimeout!=null&&o){if(r<this.keypressTimeout)return this.submit();this.state.multilineBuffer=this.state.multilineBuffer||"",this.state.multilineBuffer+=e,a=!0,i=null}if(a||this.options.multiline&&o){if(!i||i.name!=="return")return this.append(`
16
- `,t)}return super.keypress(e,t)}moveCursor(e){this.cursor+=e}reset(){return this.input=this.value="",this.cursor=0,this.render()}dispatch(e,t){if(!e||t.ctrl||t.code)return this.alert();this.append(e)}append(e){let{cursor:t,input:s}=this.state;this.input=`${s}`.slice(0,t)+e+`${s}`.slice(t),this.moveCursor(String(e).length),this.render()}insert(e){this.append(e)}delete(){let{cursor:e,input:t}=this.state;if(e<=0)return this.alert();this.input=`${t}`.slice(0,e-1)+`${t}`.slice(e),this.moveCursor(-1),this.render()}deleteForward(){let{cursor:e,input:t}=this.state;if(t[e]===void 0)return this.alert();this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.render()}cutForward(){let e=this.cursor;if(this.input.length<=e)return this.alert();this.state.clipboard.push(this.input.slice(e)),this.input=this.input.slice(0,e),this.render()}cutLeft(){let e=this.cursor;if(e===0)return this.alert();let t=this.input.slice(0,e),s=this.input.slice(e),r=t.split(" ");this.state.clipboard.push(r.pop()),this.input=r.join(" "),this.cursor=this.input.length,this.input+=s,this.render()}paste(){if(!this.state.clipboard.length)return this.alert();this.insert(this.state.clipboard.pop()),this.render()}toggleCursor(){if(this.state.prevCursor)this.cursor=this.state.prevCursor,this.state.prevCursor=0;else this.state.prevCursor=this.cursor,this.cursor=0;this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.input.length-1,this.render()}next(){let e=this.initial!=null?String(this.initial):"";if(!e||!e.startsWith(this.input))return this.alert();this.input=this.initial,this.cursor=this.initial.length,this.render()}prev(){if(!this.input)return this.alert();this.reset()}backward(){return this.left()}forward(){return this.right()}right(){if(this.cursor>=this.input.length)return this.alert();return this.moveCursor(1),this.render()}left(){if(this.cursor<=0)return this.alert();return this.moveCursor(-1),this.render()}isValue(e){return!!e}async format(e=this.value){let t=await this.resolve(this.initial,this.state);if(!this.state.submitted)return td(this,{input:e,initial:t,pos:this.cursor});return this.styles.submitted(e||t)}async render(){let e=this.state.size,t=await this.prefix(),s=await this.separator(),r=await this.message(),o=[t,r,s].filter(Boolean).join(" ");this.state.prompt=o;let i=await this.header(),a=await this.format(),n=await this.error()||await this.hint(),d=await this.footer();if(n&&!a.includes(n))a+=" "+n;o+=" "+a,this.clear(e),this.write([i,o,d].filter(Boolean).join(`
17
- `)),this.restore()}}ar.exports=ir});var dr=w((wp,nr)=>{var rd=(e)=>e.filter((t,s)=>e.lastIndexOf(t)===s),Pe=(e)=>rd(e).filter(Boolean);nr.exports=(e,t={},s="")=>{let{past:r=[],present:o=""}=t,i,a;switch(e){case"prev":case"undo":return i=r.slice(0,r.length-1),a=r[r.length-1]||"",{past:Pe([s,...i]),present:a};case"next":case"redo":return i=r.slice(1),a=r[0]||"",{past:Pe([...i,s]),present:a};case"save":return{past:Pe([...r,s]),present:""};case"remove":if(a=Pe(r.filter((n)=>n!==s)),o="",a.length)o=a.pop();return{past:a,present:o};default:throw Error(`Invalid action: "${e}"`)}}});var Tt=w((Ep,mr)=>{var od=le(),lr=dr();class cr extends od{constructor(e){super(e);let t=this.options.history;if(t&&t.store){let s=t.values||this.initial;this.autosave=!!t.autosave,this.store=t.store,this.data=this.store.get("values")||{past:[],present:s},this.initial=this.data.present||this.data.past[this.data.past.length-1]}}completion(e){if(!this.store)return this.alert();if(this.data=lr(e,this.data,this.input),!this.data.present)return this.alert();return this.input=this.data.present,this.cursor=this.input.length,this.render()}altUp(){return this.completion("prev")}altDown(){return this.completion("next")}prev(){return this.save(),super.prev()}save(){if(!this.store)return;this.data=lr("save",this.data,this.input),this.store.set("values",this.data)}submit(){if(this.store&&this.autosave===!0)this.save();return super.submit()}}mr.exports=cr});var hr=w((Ap,ur)=>{var id=le();class pr extends id{format(){return""}}ur.exports=pr});var gr=w((vp,yr)=>{var ad=le();class fr extends ad{constructor(e={}){super(e);this.sep=this.options.separator||/, */,this.initial=e.initial||""}split(e=this.value){return e?String(e).split(this.sep):[]}format(){let e=this.state.submitted?this.styles.primary:(t)=>t;return this.list.map(e).join(", ")}async submit(e){let t=this.state.error||await this.validate(this.list,this.state);if(t!==!0)return this.state.error=t,super.submit();return this.value=this.list,super.submit()}get list(){return this.split()}}yr.exports=fr});var wr=w((Np,xr)=>{var nd=oe();class br extends nd{constructor(e){super({...e,multiple:!0})}}xr.exports=br});var Rt=w((Sp,Ar)=>{var dd=le();class Er extends dd{constructor(e={}){super({style:"number",...e});this.min=this.isValue(e.min)?this.toNumber(e.min):-1/0,this.max=this.isValue(e.max)?this.toNumber(e.max):1/0,this.delay=e.delay!=null?e.delay:1000,this.float=e.float!==!1,this.round=e.round===!0||e.float===!1,this.major=e.major||10,this.minor=e.minor||1,this.initial=e.initial!=null?e.initial:"",this.input=String(this.initial),this.cursor=this.input.length,this.cursorShow()}append(e){if(!/[-+.]/.test(e)||e==="."&&this.input.includes("."))return this.alert("invalid number");return super.append(e)}number(e){return super.append(e)}next(){if(this.input&&this.input!==this.initial)return this.alert();if(!this.isValue(this.initial))return this.alert();return this.input=this.initial,this.cursor=String(this.initial).length,this.render()}up(e){let t=e||this.minor,s=this.toNumber(this.input);if(s>this.max+t)return this.alert();return this.input=`${s+t}`,this.render()}down(e){let t=e||this.minor,s=this.toNumber(this.input);if(s<this.min-t)return this.alert();return this.input=`${s-t}`,this.render()}shiftDown(){return this.down(this.major)}shiftUp(){return this.up(this.major)}format(e=this.input){if(typeof this.options.format==="function")return this.options.format.call(this,e);return this.styles.info(e)}toNumber(e=""){return this.float?+e:Math.round(+e)}isValue(e){return/^[-+]?[0-9]+((\.)|(\.[0-9]+))?$/.test(e)}submit(){let e=[this.input,this.initial].find((t)=>this.isValue(t));return this.value=this.toNumber(e||0),super.submit()}}Ar.exports=Er});var Sr=w((Tp,Nr)=>{var ld=le();class vr extends ld{constructor(e){super(e);this.cursorShow()}format(e=this.input){if(!this.keypressed)return"";return(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(e.length))}}Nr.exports=vr});var Cr=w((Rp,Mr)=>{var cd=se(),md=Ee(),Tr=C();class Rr extends md{constructor(e={}){super(e);this.widths=[].concat(e.messageWidth||50),this.align=[].concat(e.align||"left"),this.linebreak=e.linebreak||!1,this.edgeLength=e.edgeLength||3,this.newline=e.newline||`
13
+ `)}format(){if(!this.state.submitted||this.state.cancelled)return"";if(Array.isArray(this.selected))return this.selected.map((e)=>this.styles.primary(e.name)).join(", ");return this.styles.primary(this.selected.name)}async render(){let{submitted:e,size:t}=this.state,s="",r=await this.header(),o=await this.prefix(),i=await this.separator(),a=await this.message();if(this.options.promptLine!==!1)s=[o,a,i,""].join(" "),this.state.prompt=s;let n=await this.format(),l=await this.error()||await this.hint(),d=await this.renderChoices(),c=await this.footer();if(n)s+=n;if(l&&!s.includes(l))s+=" "+l;if(e&&!n&&!d.trim()&&this.multiple&&this.emptyError!=null)s+=this.styles.danger(this.emptyError);this.clear(t),this.write([r,s,d,c].filter(Boolean).join(`
14
+ `)),this.write(this.margin[2]),this.restore()}}Gs.exports=Us});var Ws=v((Um,qs)=>{var Jn=oe(),jn=(e,t)=>{let s=e?new RegExp(e,"ig"):/$^/;return(r)=>{return e?r.replace(s,(o)=>t(o)):r}};class $s extends Jn{constructor(e){super(e);this.cursorShow()}moveCursor(e){this.state.cursor+=e}dispatch(e){return this.append(e)}space(e){return this.options.multiple?super.space(e):this.append(e)}append(e){let{cursor:t,input:s}=this.state;return this.input=s.slice(0,t)+e+s.slice(t),this.moveCursor(1),this.complete()}delete(){let{cursor:e,input:t}=this.state;if(!t)return this.alert();return this.input=t.slice(0,e-1)+t.slice(e),this.moveCursor(-1),this.complete()}deleteForward(){let{cursor:e,input:t}=this.state;if(t[e]===void 0)return this.alert();return this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.complete()}number(e){return this.append(e)}async complete(){this.completing=!0,this.choices=await this.suggest(this.input,this.state._choices),this.state.limit=void 0,this.index=Math.min(Math.max(this.visible.length-1,0),this.index),await this.render(),this.completing=!1}suggest(e=this.input,t=this.state._choices){if(typeof this.options.suggest==="function")return this.options.suggest.call(this,e,t);let s=e.toLowerCase();return t.filter((r)=>r.message.toLowerCase().includes(s))}pointer(){return""}format(){if(!this.focused)return this.input;if(this.options.multiple&&this.state.submitted)return this.selected.map((e)=>this.styles.primary(e.message)).join(", ");if(this.state.submitted){let e=this.value=this.input=this.focused.value;return this.styles.primary(e)}return this.input}async render(){if(this.state.status!=="pending")return super.render();let e=this.options.highlight||this.styles.complement,t=(o,i)=>{if(!o)return o;if(e.stack)return e(o);return e.call(this,o)},s=jn(this.input,t),r=this.choices;this.choices=r.map((o)=>({...o,message:s(o.message)})),await super.render(),this.choices=r}submit(){if(this.options.multiple)this.value=this.selected.map((e)=>e.name);return super.submit()}}qs.exports=$s});var St=v((Gm,Fs)=>{var Tt=M();Fs.exports=(e,t={})=>{e.cursorHide();let{input:s="",initial:r="",pos:o,showCursor:i=!0,color:a}=t,n=a||e.styles.placeholder,l=Tt.inverse(e.styles.primary),d=(f)=>l(e.styles.black(f)),c=s,u=" ",m=d(u);if(e.blink&&e.blink.off===!0)d=(f)=>f,m="";if(i&&o===0&&r===""&&s==="")return d(u);if(i&&o===0&&(s===r||s===""))return d(r[0])+n(r.slice(1));r=Tt.isPrimitive(r)?`${r}`:"",s=Tt.isPrimitive(s)?`${s}`:"";let p=r&&r.startsWith(s)&&r!==s,h=p?d(r[s.length]):m;if(o!==s.length&&i===!0)c=s.slice(0,o)+d(s[o])+s.slice(o+1),h="";if(i===!1)h="";if(p){let f=e.styles.unstyle(c+h);return c+h+n(r.slice(f.length))}return c+h}});var ke=v(($m,Hs)=>{var el=se(),tl=oe(),sl=St();class Ks extends tl{constructor(e){super({...e,multiple:!0});this.type="form",this.initial=this.options.initial,this.align=[this.options.align,"right"].find((t)=>t!=null),this.emptyError="",this.values={}}async reset(e){if(await super.reset(),e===!0)this._index=this.index;return this.index=this._index,this.values={},this.choices.forEach((t)=>t.reset&&t.reset()),this.render()}dispatch(e){return!!e&&this.append(e)}append(e){let t=this.focused;if(!t)return this.alert();let{cursor:s,input:r}=t;return t.value=t.input=r.slice(0,s)+e+r.slice(s),t.cursor++,this.render()}delete(){let e=this.focused;if(!e||e.cursor<=0)return this.alert();let{cursor:t,input:s}=e;return e.value=e.input=s.slice(0,t-1)+s.slice(t),e.cursor--,this.render()}deleteForward(){let e=this.focused;if(!e)return this.alert();let{cursor:t,input:s}=e;if(s[t]===void 0)return this.alert();let r=`${s}`.slice(0,t)+`${s}`.slice(t+1);return e.value=e.input=r,this.render()}right(){let e=this.focused;if(!e)return this.alert();if(e.cursor>=e.input.length)return this.alert();return e.cursor++,this.render()}left(){let e=this.focused;if(!e)return this.alert();if(e.cursor<=0)return this.alert();return e.cursor--,this.render()}space(e,t){return this.dispatch(e,t)}number(e,t){return this.dispatch(e,t)}next(){let e=this.focused;if(!e)return this.alert();let{initial:t,input:s}=e;if(t&&t.startsWith(s)&&s!==t)return e.value=e.input=t,e.cursor=e.value.length,this.render();return super.next()}prev(){let e=this.focused;if(!e)return this.alert();if(e.cursor===0)return super.prev();return e.value=e.input="",e.cursor=0,this.render()}separator(){return""}format(e){return!this.state.submitted?super.format(e):""}pointer(){return""}indicator(e){return e.input?"\u29BF":"\u2299"}async choiceSeparator(e,t){let s=await this.resolve(e.separator,this.state,e,t)||":";return s?" "+this.styles.disabled(s):""}async renderChoice(e,t){await this.onChoice(e,t);let{state:s,styles:r}=this,{cursor:o,initial:i="",name:a,input:n=""}=e,{muted:l,submitted:d,primary:c,danger:u}=r,m=this.index===t,p=e.validate||(()=>!0),h=await this.choiceSeparator(e,t),f=e.message;if(this.align==="right")f=f.padStart(this.longest+1," ");if(this.align==="left")f=f.padEnd(this.longest+1," ");let g=this.values[a]=n||i,y=n?"success":"dark";if(await p.call(e,g,this.state)!==!0)y="danger";let w=r[y],E=w(await this.indicator(e,t))+(e.pad||""),T=this.indent(e),_=()=>[T,E,f+h,n].filter(Boolean).join(" ");if(s.submitted)return f=el(f),n=d(n),_();if(e.format)n=await e.format.call(this,n,e,t);else{let O=this.styles.muted;n=sl(this,{input:n,initial:i,pos:o,showCursor:m,color:O})}if(!this.isValue(n))n=this.styles.muted(this.symbols.ellipsis);if(e.result)this.values[a]=await e.result.call(this,g,e,t);if(m)f=c(f);if(e.error)n+=(n?" ":"")+u(e.error.trim());else if(e.hint)n+=(n?" ":"")+l(e.hint.trim());return _()}async submit(){return this.value=this.values,super.base.submit.call(this)}}Hs.exports=Ks});var Nt=v((qm,zs)=>{var rl=ke(),ol=()=>{throw Error("expected prompt to have a custom authenticate method")},Vs=(e=ol)=>{class t extends rl{constructor(s){super(s)}async submit(){this.value=await e.call(this,this.values,this.state),super.base.submit.call(this)}static create(s){return Vs(s)}}return t};zs.exports=Vs()});var Zs=v((Wm,Qs)=>{var il=Nt();function al(e,t){if(e.username===this.options.username&&e.password===this.options.password)return!0;return!1}var Ys=(e=al)=>{let t=[{name:"username",message:"username"},{name:"password",message:"password",format(r){if(this.options.showPassword)return r;return(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(r.length))}}];class s extends il.create(e){constructor(r){super({...r,choices:t})}static create(r){return Ys(r)}}return s};Qs.exports=Ys()});var Ue=v((Fm,Js)=>{var nl=he(),{isPrimitive:ll,hasColor:dl}=M();class Xs extends nl{constructor(e){super(e);this.cursorHide()}async initialize(){let e=await this.resolve(this.initial,this.state);this.input=await this.cast(e),await super.initialize()}dispatch(e){if(!this.isValue(e))return this.alert();return this.input=e,this.submit()}format(e){let{styles:t,state:s}=this;return!s.submitted?t.primary(e):t.success(e)}cast(e){return this.isTrue(e)}isTrue(e){return/^[ty1]/i.test(e)}isFalse(e){return/^[fn0]/i.test(e)}isValue(e){return ll(e)&&(this.isTrue(e)||this.isFalse(e))}async hint(){if(this.state.status==="pending"){let e=await this.element("hint");if(!dl(e))return this.styles.muted(e);return e}}async render(){let{input:e,size:t}=this.state,s=await this.prefix(),r=await this.separator(),o=await this.message(),i=this.styles.muted(this.default),a=[s,o,i,r].filter(Boolean).join(" ");this.state.prompt=a;let n=await this.header(),l=this.value=this.cast(e),d=await this.format(l),c=await this.error()||await this.hint(),u=await this.footer();if(c&&!a.includes(c))d+=" "+c;a+=" "+d,this.clear(t),this.write([n,a,u].filter(Boolean).join(`
15
+ `)),this.restore()}set value(e){super.value=e}get value(){return this.cast(super.value)}}Js.exports=Xs});var tr=v((Km,er)=>{var cl=Ue();class js extends cl{constructor(e){super(e);this.default=this.options.default||(this.initial?"(Y/n)":"(y/N)")}}er.exports=js});var or=v((Hm,rr)=>{var pl=oe(),ml=ke(),fe=ml.prototype;class sr extends pl{constructor(e){super({...e,multiple:!0});this.align=[this.options.align,"left"].find((t)=>t!=null),this.emptyError="",this.values={}}dispatch(e,t){let s=this.focused,r=s.parent||{};if(!s.editable&&!r.editable){if(e==="a"||e==="i")return super[e]()}return fe.dispatch.call(this,e,t)}append(e,t){return fe.append.call(this,e,t)}delete(e,t){return fe.delete.call(this,e,t)}space(e){return this.focused.editable?this.append(e):super.space()}number(e){return this.focused.editable?this.append(e):super.number(e)}next(){return this.focused.editable?fe.next.call(this):super.next()}prev(){return this.focused.editable?fe.prev.call(this):super.prev()}async indicator(e,t){let s=e.indicator||"",r=e.editable?s:super.indicator(e,t);return await this.resolve(r,this.state,e,t)||""}indent(e){return e.role==="heading"?"":e.editable?" ":" "}async renderChoice(e,t){if(e.indent="",e.editable)return fe.renderChoice.call(this,e,t);return super.renderChoice(e,t)}error(){return""}footer(){return this.state.error}async validate(){let e=!0;for(let t of this.choices){if(typeof t.validate!=="function")continue;if(t.role==="heading")continue;let s=t.parent?this.value[t.parent.name]:this.value;if(t.editable)s=t.value===t.name?t.initial||"":t.value;else if(!this.isDisabled(t))s=t.enabled===!0;if(e=await t.validate(s,this.state),e!==!0)break}if(e!==!0)this.state.error=typeof e==="string"?e:"Invalid Input";return e}submit(){if(this.focused.newChoice===!0)return super.submit();if(this.choices.some((e)=>e.newChoice))return this.alert();this.value={};for(let e of this.choices){let t=e.parent?this.value[e.parent.name]:this.value;if(e.role==="heading"){this.value[e.name]={};continue}if(e.editable)t[e.name]=e.value===e.name?e.initial||"":e.value;else if(!this.isDisabled(e))t[e.name]=e.enabled===!0}return this.base.submit.call(this)}}rr.exports=sr});var ce=v((Vm,ar)=>{var ul=he(),hl=mt(),fl=St(),{isPrimitive:yl}=M();class ir extends ul{constructor(e){super(e);if(this.initial=yl(this.initial)?String(this.initial):"",this.initial)this.cursorHide();this.state.prevCursor=0,this.state.clipboard=[],this.keypressTimeout=this.options.keypressTimeout!==void 0?this.options.keypressTimeout:null}async keypress(e,t=e?hl(e,{}):{}){let s=Date.now(),r=s-this.lastKeypress;this.lastKeypress=s;let o=t.name==="return"||t.name==="enter",i=this.state.prevKeypress,a;if(this.state.prevKeypress=t,this.keypressTimeout!=null&&o){if(r<this.keypressTimeout)return this.submit();this.state.multilineBuffer=this.state.multilineBuffer||"",this.state.multilineBuffer+=e,a=!0,i=null}if(a||this.options.multiline&&o){if(!i||i.name!=="return")return this.append(`
16
+ `,t)}return super.keypress(e,t)}moveCursor(e){this.cursor+=e}reset(){return this.input=this.value="",this.cursor=0,this.render()}dispatch(e,t){if(!e||t.ctrl||t.code)return this.alert();this.append(e)}append(e){let{cursor:t,input:s}=this.state;this.input=`${s}`.slice(0,t)+e+`${s}`.slice(t),this.moveCursor(String(e).length),this.render()}insert(e){this.append(e)}delete(){let{cursor:e,input:t}=this.state;if(e<=0)return this.alert();this.input=`${t}`.slice(0,e-1)+`${t}`.slice(e),this.moveCursor(-1),this.render()}deleteForward(){let{cursor:e,input:t}=this.state;if(t[e]===void 0)return this.alert();this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.render()}cutForward(){let e=this.cursor;if(this.input.length<=e)return this.alert();this.state.clipboard.push(this.input.slice(e)),this.input=this.input.slice(0,e),this.render()}cutLeft(){let e=this.cursor;if(e===0)return this.alert();let t=this.input.slice(0,e),s=this.input.slice(e),r=t.split(" ");this.state.clipboard.push(r.pop()),this.input=r.join(" "),this.cursor=this.input.length,this.input+=s,this.render()}paste(){if(!this.state.clipboard.length)return this.alert();this.insert(this.state.clipboard.pop()),this.render()}toggleCursor(){if(this.state.prevCursor)this.cursor=this.state.prevCursor,this.state.prevCursor=0;else this.state.prevCursor=this.cursor,this.cursor=0;this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.input.length-1,this.render()}next(){let e=this.initial!=null?String(this.initial):"";if(!e||!e.startsWith(this.input))return this.alert();this.input=this.initial,this.cursor=this.initial.length,this.render()}prev(){if(!this.input)return this.alert();this.reset()}backward(){return this.left()}forward(){return this.right()}right(){if(this.cursor>=this.input.length)return this.alert();return this.moveCursor(1),this.render()}left(){if(this.cursor<=0)return this.alert();return this.moveCursor(-1),this.render()}isValue(e){return!!e}async format(e=this.value){let t=await this.resolve(this.initial,this.state);if(!this.state.submitted)return fl(this,{input:e,initial:t,pos:this.cursor});return this.styles.submitted(e||t)}async render(){let e=this.state.size,t=await this.prefix(),s=await this.separator(),r=await this.message(),o=[t,r,s].filter(Boolean).join(" ");this.state.prompt=o;let i=await this.header(),a=await this.format(),n=await this.error()||await this.hint(),l=await this.footer();if(n&&!a.includes(n))a+=" "+n;o+=" "+a,this.clear(e),this.write([i,o,l].filter(Boolean).join(`
17
+ `)),this.restore()}}ar.exports=ir});var lr=v((zm,nr)=>{var gl=(e)=>e.filter((t,s)=>e.lastIndexOf(t)===s),Ge=(e)=>gl(e).filter(Boolean);nr.exports=(e,t={},s="")=>{let{past:r=[],present:o=""}=t,i,a;switch(e){case"prev":case"undo":return i=r.slice(0,r.length-1),a=r[r.length-1]||"",{past:Ge([s,...i]),present:a};case"next":case"redo":return i=r.slice(1),a=r[0]||"",{past:Ge([...i,s]),present:a};case"save":return{past:Ge([...r,s]),present:""};case"remove":if(a=Ge(r.filter((n)=>n!==s)),o="",a.length)o=a.pop();return{past:a,present:o};default:throw Error(`Invalid action: "${e}"`)}}});var Rt=v((Ym,pr)=>{var bl=ce(),dr=lr();class cr extends bl{constructor(e){super(e);let t=this.options.history;if(t&&t.store){let s=t.values||this.initial;this.autosave=!!t.autosave,this.store=t.store,this.data=this.store.get("values")||{past:[],present:s},this.initial=this.data.present||this.data.past[this.data.past.length-1]}}completion(e){if(!this.store)return this.alert();if(this.data=dr(e,this.data,this.input),!this.data.present)return this.alert();return this.input=this.data.present,this.cursor=this.input.length,this.render()}altUp(){return this.completion("prev")}altDown(){return this.completion("next")}prev(){return this.save(),super.prev()}save(){if(!this.store)return;this.data=dr("save",this.data,this.input),this.store.set("values",this.data)}submit(){if(this.store&&this.autosave===!0)this.save();return super.submit()}}pr.exports=cr});var hr=v((Qm,ur)=>{var xl=ce();class mr extends xl{format(){return""}}ur.exports=mr});var gr=v((Zm,yr)=>{var wl=ce();class fr extends wl{constructor(e={}){super(e);this.sep=this.options.separator||/, */,this.initial=e.initial||""}split(e=this.value){return e?String(e).split(this.sep):[]}format(){let e=this.state.submitted?this.styles.primary:(t)=>t;return this.list.map(e).join(", ")}async submit(e){let t=this.state.error||await this.validate(this.list,this.state);if(t!==!0)return this.state.error=t,super.submit();return this.value=this.list,super.submit()}get list(){return this.split()}}yr.exports=fr});var wr=v((Xm,xr)=>{var vl=oe();class br extends vl{constructor(e){super({...e,multiple:!0})}}xr.exports=br});var Ct=v((Jm,Er)=>{var El=ce();class vr extends El{constructor(e={}){super({style:"number",...e});this.min=this.isValue(e.min)?this.toNumber(e.min):-1/0,this.max=this.isValue(e.max)?this.toNumber(e.max):1/0,this.delay=e.delay!=null?e.delay:1000,this.float=e.float!==!1,this.round=e.round===!0||e.float===!1,this.major=e.major||10,this.minor=e.minor||1,this.initial=e.initial!=null?e.initial:"",this.input=String(this.initial),this.cursor=this.input.length,this.cursorShow()}append(e){if(!/[-+.]/.test(e)||e==="."&&this.input.includes("."))return this.alert("invalid number");return super.append(e)}number(e){return super.append(e)}next(){if(this.input&&this.input!==this.initial)return this.alert();if(!this.isValue(this.initial))return this.alert();return this.input=this.initial,this.cursor=String(this.initial).length,this.render()}up(e){let t=e||this.minor,s=this.toNumber(this.input);if(s>this.max+t)return this.alert();return this.input=`${s+t}`,this.render()}down(e){let t=e||this.minor,s=this.toNumber(this.input);if(s<this.min-t)return this.alert();return this.input=`${s-t}`,this.render()}shiftDown(){return this.down(this.major)}shiftUp(){return this.up(this.major)}format(e=this.input){if(typeof this.options.format==="function")return this.options.format.call(this,e);return this.styles.info(e)}toNumber(e=""){return this.float?+e:Math.round(+e)}isValue(e){return/^[-+]?[0-9]+((\.)|(\.[0-9]+))?$/.test(e)}submit(){let e=[this.input,this.initial].find((t)=>this.isValue(t));return this.value=this.toNumber(e||0),super.submit()}}Er.exports=vr});var Sr=v((jm,Tr)=>{var Al=ce();class Ar extends Al{constructor(e){super(e);this.cursorShow()}format(e=this.input){if(!this.keypressed)return"";return(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(e.length))}}Tr.exports=Ar});var Mr=v((eu,Cr)=>{var Tl=se(),Sl=Se(),Nr=M();class Rr extends Sl{constructor(e={}){super(e);this.widths=[].concat(e.messageWidth||50),this.align=[].concat(e.align||"left"),this.linebreak=e.linebreak||!1,this.edgeLength=e.edgeLength||3,this.newline=e.newline||`
18
18
  `;let t=e.startNumber||1;if(typeof this.scale==="number")this.scaleKey=!1,this.scale=Array(this.scale).fill(0).map((s,r)=>({name:r+t}))}async reset(){return this.tableized=!1,await super.reset(),this.render()}tableize(){if(this.tableized===!0)return;this.tableized=!0;let e=0;for(let t of this.choices){e=Math.max(e,t.message.length),t.scaleIndex=t.initial||2,t.scale=[];for(let s=0;s<this.scale.length;s++)t.scale.push({index:s})}this.widths[0]=Math.min(this.widths[0],e+3)}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}heading(e,t,s){return this.styles.strong(e)}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let e=this.focused;if(e.scaleIndex>=this.scale.length-1)return this.alert();return e.scaleIndex++,this.render()}left(){let e=this.focused;if(e.scaleIndex<=0)return this.alert();return e.scaleIndex--,this.render()}indent(){return""}format(){if(this.state.submitted)return this.choices.map((t)=>this.styles.info(t.index)).join(", ");return""}pointer(){return""}renderScaleKey(){if(this.scaleKey===!1)return"";if(this.state.submitted)return"";return["",...this.scale.map((s)=>` ${s.name} - ${s.message}`)].map((s)=>this.styles.muted(s)).join(`
19
- `)}renderScaleHeading(e){let t=this.scale.map((n)=>n.name);if(typeof this.options.renderScaleHeading==="function")t=this.options.renderScaleHeading.call(this,e);let s=this.scaleLength-t.join("").length,r=Math.round(s/(t.length-1)),i=t.map((n)=>this.styles.strong(n)).join(" ".repeat(r)),a=" ".repeat(this.widths[0]);return this.margin[3]+a+this.margin[1]+i}scaleIndicator(e,t,s){if(typeof this.options.scaleIndicator==="function")return this.options.scaleIndicator.call(this,e,t,s);let r=e.scaleIndex===t.index;if(t.disabled)return this.styles.hint(this.symbols.radio.disabled);if(r)return this.styles.success(this.symbols.radio.on);return this.symbols.radio.off}renderScale(e,t){let s=e.scale.map((o)=>this.scaleIndicator(e,o,t)),r=this.term==="Hyper"?"":" ";return s.join(r+this.symbols.line.repeat(this.edgeLength))}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=await this.pointer(e,t),o=await e.hint;if(o&&!Tr.hasColor(o))o=this.styles.muted(o);let i=(m)=>this.margin[3]+m.replace(/\s+$/,"").padEnd(this.widths[0]," "),a=this.newline,n=this.indent(e),d=await this.resolve(e.message,this.state,e,t),l=await this.renderScale(e,t),c=this.margin[1]+this.margin[3];this.scaleLength=cd(l).length,this.widths[0]=Math.min(this.widths[0],this.width-this.scaleLength-c.length);let p=Tr.wordWrap(d,{width:this.widths[0],newline:a}).split(`
20
- `).map((m)=>i(m)+this.margin[1]);if(s)l=this.styles.info(l),p=p.map((m)=>this.styles.info(m));if(p[0]+=l,this.linebreak)p.push("");return[n+r,p.join(`
19
+ `)}renderScaleHeading(e){let t=this.scale.map((n)=>n.name);if(typeof this.options.renderScaleHeading==="function")t=this.options.renderScaleHeading.call(this,e);let s=this.scaleLength-t.join("").length,r=Math.round(s/(t.length-1)),i=t.map((n)=>this.styles.strong(n)).join(" ".repeat(r)),a=" ".repeat(this.widths[0]);return this.margin[3]+a+this.margin[1]+i}scaleIndicator(e,t,s){if(typeof this.options.scaleIndicator==="function")return this.options.scaleIndicator.call(this,e,t,s);let r=e.scaleIndex===t.index;if(t.disabled)return this.styles.hint(this.symbols.radio.disabled);if(r)return this.styles.success(this.symbols.radio.on);return this.symbols.radio.off}renderScale(e,t){let s=e.scale.map((o)=>this.scaleIndicator(e,o,t)),r=this.term==="Hyper"?"":" ";return s.join(r+this.symbols.line.repeat(this.edgeLength))}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=await this.pointer(e,t),o=await e.hint;if(o&&!Nr.hasColor(o))o=this.styles.muted(o);let i=(p)=>this.margin[3]+p.replace(/\s+$/,"").padEnd(this.widths[0]," "),a=this.newline,n=this.indent(e),l=await this.resolve(e.message,this.state,e,t),d=await this.renderScale(e,t),c=this.margin[1]+this.margin[3];this.scaleLength=Tl(d).length,this.widths[0]=Math.min(this.widths[0],this.width-this.scaleLength-c.length);let m=Nr.wordWrap(l,{width:this.widths[0],newline:a}).split(`
20
+ `).map((p)=>i(p)+this.margin[1]);if(s)d=this.styles.info(d),m=m.map((p)=>this.styles.info(p));if(m[0]+=d,this.linebreak)m.push("");return[n+r,m.join(`
21
21
  `)].filter(Boolean)}async renderChoices(){if(this.state.submitted)return"";this.tableize();let e=this.visible.map(async(r,o)=>await this.renderChoice(r,o)),t=await Promise.all(e),s=await this.renderScaleHeading();return this.margin[0]+[s,...t.map((r)=>r.join(" "))].join(`
22
- `)}async render(){let{submitted:e,size:t}=this.state,s=await this.prefix(),r=await this.separator(),o=await this.message(),i="";if(this.options.promptLine!==!1)i=[s,o,r,""].join(" "),this.state.prompt=i;let a=await this.header(),n=await this.format(),d=await this.renderScaleKey(),l=await this.error()||await this.hint(),c=await this.renderChoices(),u=await this.footer(),p=this.emptyError;if(n)i+=n;if(l&&!i.includes(l))i+=" "+l;if(e&&!n&&!c.trim()&&this.multiple&&p!=null)i+=this.styles.danger(p);if(this.clear(t),this.write([a,i,d,c,u].filter(Boolean).join(`
23
- `)),!this.state.submitted)this.write(this.margin[2]);this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIndex;return this.base.submit.call(this)}}Mr.exports=Rr});var Dr=w((Mp,Or)=>{var _r=se(),pd=(e="")=>{return typeof e==="string"?e.replace(/^['"]|['"]$/g,""):""};class Ir{constructor(e){this.name=e.key,this.field=e.field||{},this.value=pd(e.initial||this.field.initial||""),this.message=e.message||this.name,this.cursor=0,this.input="",this.lines=[]}}var ud=async(e={},t={},s=(r)=>r)=>{let r=new Set,o=e.fields||[],i=e.template,a=[],n=[],d=[],l=1;if(typeof i==="function")i=await i();let c=-1,u=()=>i[++c],p=()=>i[c+1],m=(h)=>{h.line=l,a.push(h)};m({type:"bos",value:""});while(c<i.length-1){let h=u();if(/^[^\S\n ]$/.test(h)){m({type:"text",value:h});continue}if(h===`
24
- `){m({type:"newline",value:h}),l++;continue}if(h==="\\"){h+=u(),m({type:"text",value:h});continue}if((h==="$"||h==="#"||h==="{")&&p()==="{"){let g=u();h+=g;let y={type:"template",open:h,inner:"",close:"",value:h},E;while(E=u()){if(E==="}"){if(p()==="}")E+=u();y.value+=E,y.close=E;break}if(E===":")y.initial="",y.key=y.inner;else if(y.initial!==void 0)y.initial+=E;y.value+=E,y.inner+=E}if(y.template=y.open+(y.initial||y.inner)+y.close,y.key=y.key||y.inner,hasOwnProperty.call(t,y.key))y.initial=t[y.key];y=s(y),m(y),d.push(y.key),r.add(y.key);let A=n.find((N)=>N.name===y.key);if(y.field=o.find((N)=>N.name===y.key),!A)A=new Ir(y),n.push(A);A.lines.push(y.line-1);continue}let f=a[a.length-1];if(f.type==="text"&&f.line===l)f.value+=h;else m({type:"text",value:h})}return m({type:"eos",value:""}),{input:i,tabstops:a,unique:r,keys:d,items:n}};Or.exports=async(e)=>{let t=e.options,s=new Set(t.required===!0?[]:t.required||[]),r={...t.values,...t.initial},{tabstops:o,items:i,keys:a}=await ud(t,r),n=Mt("result",e,t),d=Mt("format",e,t),l=Mt("validate",e,t,!0),c=e.isValue.bind(e);return async(u={},p=!1)=>{let m=0;u.required=s,u.items=i,u.keys=a,u.output="";let h=async(E,A,N,R)=>{let _=await l(E,A,N,R);if(_===!1)return"Invalid field "+N.name;return _};for(let E of o){let{value:A,key:N}=E;if(E.type!=="template"){if(A)u.output+=A;continue}if(E.type==="template"){let R=i.find((pe)=>pe.name===N);if(t.required===!0)u.required.add(R.name);let _=[R.input,u.values[R.value],R.value,A].find(c),ee=(R.field||{}).message||E.inner;if(p){let pe=await h(u.values[N],u,R,m);if(pe&&typeof pe==="string"||pe===!1){u.invalid.set(N,pe);continue}u.invalid.delete(N);let ca=await n(u.values[N],u,R,m);u.output+=_r(ca);continue}R.placeholder=!1;let Kt=A;if(A=await d(A,u,R,m),_!==A)u.values[N]=_,A=e.styles.typing(_),u.missing.delete(ee);else if(u.values[N]=void 0,_=`<${ee}>`,A=e.styles.primary(_),R.placeholder=!0,u.required.has(N))u.missing.add(ee);if(u.missing.has(ee)&&u.validating)A=e.styles.warning(_);if(u.invalid.has(N)&&u.validating)A=e.styles.danger(_);if(m===u.index)if(Kt!==A)A=e.styles.underline(A);else A=e.styles.heading(_r(A));m++}if(A)u.output+=A}let f=u.output.split(`
25
- `).map((E)=>" "+E),g=i.length,y=0;for(let E of i){if(u.invalid.has(E.name))E.lines.forEach((A)=>{if(f[A][0]!==" ")return;f[A]=u.styles.danger(u.symbols.bullet)+f[A].slice(1)});if(e.isValue(u.values[E.name]))y++}return u.completed=(y/g*100).toFixed(0),u.output=f.join(`
26
- `),u.output}};function Mt(e,t,s,r){return(o,i,a,n)=>{if(typeof a.field[e]==="function")return a.field[e].call(t,o,i,a,n);return[r,o].find((d)=>t.isValue(d))}}});var Lr=w((Cp,Pr)=>{var hd=se(),fd=Dr(),yd=ue();class Br extends yd{constructor(e){super(e);this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await fd(this),await super.initialize()}async reset(e){if(this.state.keys=[],this.state.invalid=new Map,this.state.missing=new Set,this.state.completed=0,this.state.values={},e!==!0)await this.initialize(),await this.render()}moveCursor(e){let t=this.getItem();this.cursor+=e,t.cursor+=e}dispatch(e,t){if(!t.code&&!t.ctrl&&e!=null&&this.getItem()){this.append(e,t);return}this.alert()}append(e,t){let s=this.getItem(),r=s.input.slice(0,this.cursor),o=s.input.slice(this.cursor);this.input=s.input=`${r}${e}${o}`,this.moveCursor(1),this.render()}delete(){let e=this.getItem();if(this.cursor<=0||!e.input)return this.alert();let t=e.input.slice(this.cursor),s=e.input.slice(0,this.cursor-1);this.input=e.input=`${s}${t}`,this.moveCursor(-1),this.render()}increment(e){return e>=this.state.keys.length-1?0:e+1}decrement(e){return e<=0?this.state.keys.length-1:e-1}first(){this.state.index=0,this.render()}last(){this.state.index=this.state.keys.length-1,this.render()}right(){if(this.cursor>=this.input.length)return this.alert();this.moveCursor(1),this.render()}left(){if(this.cursor<=0)return this.alert();this.moveCursor(-1),this.render()}prev(){this.state.index=this.decrement(this.state.index),this.getItem(),this.render()}next(){this.state.index=this.increment(this.state.index),this.getItem(),this.render()}up(){this.prev()}down(){this.next()}format(e){let t=this.state.completed<100?this.styles.warning:this.styles.success;if(this.state.submitted===!0&&this.state.completed!==100)t=this.styles.danger;return t(`${this.state.completed}% completed`)}async render(){let{index:e,keys:t=[],submitted:s,size:r}=this.state,o=[this.options.newline,`
27
- `].find((y)=>y!=null),i=await this.prefix(),a=await this.separator(),n=await this.message(),d=[i,n,a].filter(Boolean).join(" ");this.state.prompt=d;let l=await this.header(),c=await this.error()||"",u=await this.hint()||"",p=s?"":await this.interpolate(this.state),m=this.state.key=t[e]||"",h=await this.format(m),f=await this.footer();if(h)d+=" "+h;if(u&&!h&&this.state.completed===0)d+=" "+u;this.clear(r);let g=[l,d,p,f,c.trim()];this.write(g.filter(Boolean).join(o)),this.restore()}getItem(e){let{items:t,keys:s,index:r}=this.state,o=t.find((i)=>i.name===s[r]);if(o&&o.input!=null)this.input=o.input,this.cursor=o.cursor;return o}async submit(){if(typeof this.interpolate!=="function")await this.initialize();await this.interpolate(this.state,!0);let{invalid:e,missing:t,output:s,values:r}=this.state;if(e.size){let a="";for(let[n,d]of e)a+=`Invalid ${n}: ${d}
28
- `;return this.state.error=a,super.submit()}if(t.size)return this.state.error="Required: "+[...t.keys()].join(", "),super.submit();let i=hd(s).split(`
22
+ `)}async render(){let{submitted:e,size:t}=this.state,s=await this.prefix(),r=await this.separator(),o=await this.message(),i="";if(this.options.promptLine!==!1)i=[s,o,r,""].join(" "),this.state.prompt=i;let a=await this.header(),n=await this.format(),l=await this.renderScaleKey(),d=await this.error()||await this.hint(),c=await this.renderChoices(),u=await this.footer(),m=this.emptyError;if(n)i+=n;if(d&&!i.includes(d))i+=" "+d;if(e&&!n&&!c.trim()&&this.multiple&&m!=null)i+=this.styles.danger(m);if(this.clear(t),this.write([a,i,l,c,u].filter(Boolean).join(`
23
+ `)),!this.state.submitted)this.write(this.margin[2]);this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIndex;return this.base.submit.call(this)}}Cr.exports=Rr});var Or=v((tu,Br)=>{var _r=se(),Nl=(e="")=>{return typeof e==="string"?e.replace(/^['"]|['"]$/g,""):""};class Ir{constructor(e){this.name=e.key,this.field=e.field||{},this.value=Nl(e.initial||this.field.initial||""),this.message=e.message||this.name,this.cursor=0,this.input="",this.lines=[]}}var Rl=async(e={},t={},s=(r)=>r)=>{let r=new Set,o=e.fields||[],i=e.template,a=[],n=[],l=[],d=1;if(typeof i==="function")i=await i();let c=-1,u=()=>i[++c],m=()=>i[c+1],p=(h)=>{h.line=d,a.push(h)};p({type:"bos",value:""});while(c<i.length-1){let h=u();if(/^[^\S\n ]$/.test(h)){p({type:"text",value:h});continue}if(h===`
24
+ `){p({type:"newline",value:h}),d++;continue}if(h==="\\"){h+=u(),p({type:"text",value:h});continue}if((h==="$"||h==="#"||h==="{")&&m()==="{"){let g=u();h+=g;let y={type:"template",open:h,inner:"",close:"",value:h},w;while(w=u()){if(w==="}"){if(m()==="}")w+=u();y.value+=w,y.close=w;break}if(w===":")y.initial="",y.key=y.inner;else if(y.initial!==void 0)y.initial+=w;y.value+=w,y.inner+=w}if(y.template=y.open+(y.initial||y.inner)+y.close,y.key=y.key||y.inner,hasOwnProperty.call(t,y.key))y.initial=t[y.key];y=s(y),p(y),l.push(y.key),r.add(y.key);let E=n.find((T)=>T.name===y.key);if(y.field=o.find((T)=>T.name===y.key),!E)E=new Ir(y),n.push(E);E.lines.push(y.line-1);continue}let f=a[a.length-1];if(f.type==="text"&&f.line===d)f.value+=h;else p({type:"text",value:h})}return p({type:"eos",value:""}),{input:i,tabstops:a,unique:r,keys:l,items:n}};Br.exports=async(e)=>{let t=e.options,s=new Set(t.required===!0?[]:t.required||[]),r={...t.values,...t.initial},{tabstops:o,items:i,keys:a}=await Rl(t,r),n=Mt("result",e,t),l=Mt("format",e,t),d=Mt("validate",e,t,!0),c=e.isValue.bind(e);return async(u={},m=!1)=>{let p=0;u.required=s,u.items=i,u.keys=a,u.output="";let h=async(w,E,T,_)=>{let O=await d(w,E,T,_);if(O===!1)return"Invalid field "+T.name;return O};for(let w of o){let{value:E,key:T}=w;if(w.type!=="template"){if(E)u.output+=E;continue}if(w.type==="template"){let _=i.find((ue)=>ue.name===T);if(t.required===!0)u.required.add(_.name);let O=[_.input,u.values[_.value],_.value,E].find(c),Me=(_.field||{}).message||w.inner;if(m){let ue=await h(u.values[T],u,_,p);if(ue&&typeof ue==="string"||ue===!1){u.invalid.set(T,ue);continue}u.invalid.delete(T);let Ta=await n(u.values[T],u,_,p);u.output+=_r(Ta);continue}_.placeholder=!1;let Aa=E;if(E=await l(E,u,_,p),O!==E)u.values[T]=O,E=e.styles.typing(O),u.missing.delete(Me);else if(u.values[T]=void 0,O=`<${Me}>`,E=e.styles.primary(O),_.placeholder=!0,u.required.has(T))u.missing.add(Me);if(u.missing.has(Me)&&u.validating)E=e.styles.warning(O);if(u.invalid.has(T)&&u.validating)E=e.styles.danger(O);if(p===u.index)if(Aa!==E)E=e.styles.underline(E);else E=e.styles.heading(_r(E));p++}if(E)u.output+=E}let f=u.output.split(`
25
+ `).map((w)=>" "+w),g=i.length,y=0;for(let w of i){if(u.invalid.has(w.name))w.lines.forEach((E)=>{if(f[E][0]!==" ")return;f[E]=u.styles.danger(u.symbols.bullet)+f[E].slice(1)});if(e.isValue(u.values[w.name]))y++}return u.completed=(y/g*100).toFixed(0),u.output=f.join(`
26
+ `),u.output}};function Mt(e,t,s,r){return(o,i,a,n)=>{if(typeof a.field[e]==="function")return a.field[e].call(t,o,i,a,n);return[r,o].find((l)=>t.isValue(l))}}});var Lr=v((su,Pr)=>{var Cl=se(),Ml=Or(),_l=he();class Dr extends _l{constructor(e){super(e);this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await Ml(this),await super.initialize()}async reset(e){if(this.state.keys=[],this.state.invalid=new Map,this.state.missing=new Set,this.state.completed=0,this.state.values={},e!==!0)await this.initialize(),await this.render()}moveCursor(e){let t=this.getItem();this.cursor+=e,t.cursor+=e}dispatch(e,t){if(!t.code&&!t.ctrl&&e!=null&&this.getItem()){this.append(e,t);return}this.alert()}append(e,t){let s=this.getItem(),r=s.input.slice(0,this.cursor),o=s.input.slice(this.cursor);this.input=s.input=`${r}${e}${o}`,this.moveCursor(1),this.render()}delete(){let e=this.getItem();if(this.cursor<=0||!e.input)return this.alert();let t=e.input.slice(this.cursor),s=e.input.slice(0,this.cursor-1);this.input=e.input=`${s}${t}`,this.moveCursor(-1),this.render()}increment(e){return e>=this.state.keys.length-1?0:e+1}decrement(e){return e<=0?this.state.keys.length-1:e-1}first(){this.state.index=0,this.render()}last(){this.state.index=this.state.keys.length-1,this.render()}right(){if(this.cursor>=this.input.length)return this.alert();this.moveCursor(1),this.render()}left(){if(this.cursor<=0)return this.alert();this.moveCursor(-1),this.render()}prev(){this.state.index=this.decrement(this.state.index),this.getItem(),this.render()}next(){this.state.index=this.increment(this.state.index),this.getItem(),this.render()}up(){this.prev()}down(){this.next()}format(e){let t=this.state.completed<100?this.styles.warning:this.styles.success;if(this.state.submitted===!0&&this.state.completed!==100)t=this.styles.danger;return t(`${this.state.completed}% completed`)}async render(){let{index:e,keys:t=[],submitted:s,size:r}=this.state,o=[this.options.newline,`
27
+ `].find((y)=>y!=null),i=await this.prefix(),a=await this.separator(),n=await this.message(),l=[i,n,a].filter(Boolean).join(" ");this.state.prompt=l;let d=await this.header(),c=await this.error()||"",u=await this.hint()||"",m=s?"":await this.interpolate(this.state),p=this.state.key=t[e]||"",h=await this.format(p),f=await this.footer();if(h)l+=" "+h;if(u&&!h&&this.state.completed===0)l+=" "+u;this.clear(r);let g=[d,l,m,f,c.trim()];this.write(g.filter(Boolean).join(o)),this.restore()}getItem(e){let{items:t,keys:s,index:r}=this.state,o=t.find((i)=>i.name===s[r]);if(o&&o.input!=null)this.input=o.input,this.cursor=o.cursor;return o}async submit(){if(typeof this.interpolate!=="function")await this.initialize();await this.interpolate(this.state,!0);let{invalid:e,missing:t,output:s,values:r}=this.state;if(e.size){let a="";for(let[n,l]of e)a+=`Invalid ${n}: ${l}
28
+ `;return this.state.error=a,super.submit()}if(t.size)return this.state.error="Required: "+[...t.keys()].join(", "),super.submit();let i=Cl(s).split(`
29
29
  `).map((a)=>a.slice(1)).join(`
30
- `);return this.value={values:r,result:i},super.submit()}}Pr.exports=Br});var kr=w((_p,Gr)=>{var gd=oe();class Ur extends gd{constructor(e){super({...e,reorder:!1,sort:!0,multiple:!0});this.state.hint=[this.options.hint,"(Use <shift>+<up/down> to sort)"].find(this.isValue.bind(this))}indicator(){return""}async renderChoice(e,t){let s=await super.renderChoice(e,t),r=this.symbols.identicalTo+" ",o=this.index===t&&this.sorting?this.styles.muted(r):" ";if(this.options.drag===!1)o="";if(this.options.numbered===!0)return o+`${t+1} - `+s;return o+s}get selected(){return this.choices}submit(){return this.value=this.choices.map((e)=>e.value),super.submit()}}Gr.exports=Ur});var qr=w((Ip,Wr)=>{var bd=Ee();class $r extends bd{constructor(e={}){super(e);if(this.emptyError=e.emptyError||"No items were selected",this.term=process.env.TERM_PROGRAM,!this.options.header){let t=["","4 - Strongly Agree","3 - Agree","2 - Neutral","1 - Disagree","0 - Strongly Disagree",""];t=t.map((s)=>this.styles.muted(s)),this.state.header=t.join(`
31
- `)}}async toChoices(...e){if(this.createdScales)return!1;this.createdScales=!0;let t=await super.toChoices(...e);for(let s of t)s.scale=xd(5,this.options),s.scaleIdx=2;return t}dispatch(){this.alert()}space(){let e=this.focused,t=e.scale[e.scaleIdx],s=t.selected;return e.scale.forEach((r)=>r.selected=!1),t.selected=!s,this.render()}indicator(){return""}pointer(){return""}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let e=this.focused;if(e.scaleIdx>=e.scale.length-1)return this.alert();return e.scaleIdx++,this.render()}left(){let e=this.focused;if(e.scaleIdx<=0)return this.alert();return e.scaleIdx--,this.render()}indent(){return" "}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=this.term==="Hyper",o=!r?8:9,i=!r?" ":"",a=this.symbols.line.repeat(o),n=" ".repeat(o+(r?0:1)),d=(E)=>(E?this.styles.success("\u25C9"):"\u25EF")+i,l=t+1+".",c=s?this.styles.heading:this.styles.noop,u=await this.resolve(e.message,this.state,e,t),p=this.indent(e),m=p+e.scale.map((E,A)=>d(A===e.scaleIdx)).join(a),h=(E)=>E===e.scaleIdx?c(E):E,f=p+e.scale.map((E,A)=>h(A)).join(n),g=()=>[l,u].filter(Boolean).join(" "),y=()=>[g(),m,f," "].filter(Boolean).join(`
32
- `);if(s)m=this.styles.cyan(m),f=this.styles.cyan(f);return y()}async renderChoices(){if(this.state.submitted)return"";let e=this.visible.map(async(s,r)=>await this.renderChoice(s,r)),t=await Promise.all(e);if(!t.length)t.push(this.styles.danger("No matching choices"));return t.join(`
33
- `)}format(){if(this.state.submitted)return this.choices.map((t)=>this.styles.info(t.scaleIdx)).join(", ");return""}async render(){let{submitted:e,size:t}=this.state,s=await this.prefix(),r=await this.separator(),o=await this.message(),i=[s,o,r].filter(Boolean).join(" ");this.state.prompt=i;let a=await this.header(),n=await this.format(),d=await this.error()||await this.hint(),l=await this.renderChoices(),c=await this.footer();if(n||!d)i+=" "+n;if(d&&!i.includes(d))i+=" "+d;if(e&&!n&&!l&&this.multiple&&this.type!=="form")i+=this.styles.danger(this.emptyError);this.clear(t),this.write([i,a,l,c].filter(Boolean).join(`
34
- `)),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIdx;return this.base.submit.call(this)}}function xd(e,t={}){if(Array.isArray(t.scale))return t.scale.map((r)=>({...r}));let s=[];for(let r=1;r<e+1;r++)s.push({i:r,selected:!1});return s}Wr.exports=$r});var Fr=w((Op,Hr)=>{var wd=Be();class Kr extends wd{async initialize(){await super.initialize(),this.value=this.initial=this.resolve(this.options.initial),this.disabled=this.options.disabled||"no",this.enabled=this.options.enabled||"yes",await this.render()}reset(){this.value=this.initial,this.render()}delete(){this.alert()}toggle(){this.value=!this.value,this.render()}enable(){if(this.value===!0)return this.alert();this.value=!0,this.render()}disable(){if(this.value===!1)return this.alert();this.value=!1,this.render()}up(){this.toggle()}down(){this.toggle()}right(){this.toggle()}left(){this.toggle()}next(){this.toggle()}prev(){this.toggle()}dispatch(e="",t){switch(e.toLowerCase()){case" ":return this.toggle();case"1":case"y":case"t":return this.enable();case"0":case"n":case"f":return this.disable();default:return this.alert()}}format(){let e=(s)=>this.styles.primary.underline(s);return[this.value?this.disabled:e(this.disabled),this.value?e(this.enabled):this.enabled].join(this.styles.muted(" / "))}async render(){let{size:e}=this.state,t=await this.header(),s=await this.prefix(),r=await this.separator(),o=await this.message(),i=await this.format(),a=await this.error()||await this.hint(),n=await this.footer(),d=[s,o,r,i].join(" ");if(this.state.prompt=d,a&&!d.includes(a))d+=" "+a;this.clear(e),this.write([t,d,n].filter(Boolean).join(`
35
- `)),this.write(this.margin[2]),this.restore()}}Hr.exports=Kr});var zr=w((Dp,Yr)=>{var Ed=oe();class Vr extends Ed{constructor(e){super(e);if(typeof this.options.correctChoice!=="number"||this.options.correctChoice<0)throw Error("Please specify the index of the correct answer from the list of choices")}async toChoices(e,t){let s=await super.toChoices(e,t);if(s.length<2)throw Error("Please give at least two choices to the user");if(this.options.correctChoice>s.length)throw Error("Please specify the index of the correct answer from the list of choices");return s}check(e){return e.index===this.options.correctChoice}async result(e){return{selectedAnswer:e,correctAnswer:this.options.choices[this.options.correctChoice].value,correct:await this.check(this.state)}}}Yr.exports=Vr});var Qr=w((Ct)=>{var Zr=C(),S=(e,t)=>{Zr.defineExport(Ct,e,t),Zr.defineExport(Ct,e.toLowerCase(),t)};S("AutoComplete",()=>qs());S("BasicAuth",()=>Qs());S("Confirm",()=>tr());S("Editable",()=>or());S("Form",()=>De());S("Input",()=>Tt());S("Invisible",()=>hr());S("List",()=>gr());S("MultiSelect",()=>wr());S("Numeral",()=>Rt());S("Password",()=>Sr());S("Scale",()=>Cr());S("Select",()=>oe());S("Snippet",()=>Lr());S("Sort",()=>kr());S("Survey",()=>qr());S("Text",()=>Tt());S("Toggle",()=>Fr());S("Quiz",()=>zr())});var Jr=w((Pp,Xr)=>{Xr.exports={ArrayPrompt:Ee(),AuthPrompt:St(),BooleanPrompt:Be(),NumberPrompt:Rt(),StringPrompt:le()}});var ae=w((Lp,eo)=>{var jr=be("assert"),It=be("events"),ie=C();class U extends It{constructor(e,t){super();this.options=ie.merge({},e),this.answers={...t}}register(e,t){if(ie.isObject(e)){for(let r of Object.keys(e))this.register(r,e[r]);return this}jr.equal(typeof t,"function","expected a function");let s=e.toLowerCase();if(t.prototype instanceof this.Prompt)this.prompts[s]=t;else this.prompts[s]=t(this.Prompt,this);return this}async prompt(e=[]){for(let t of[].concat(e))try{if(typeof t==="function")t=await t.call(this);await this.ask(ie.merge({},this.options,t))}catch(s){return Promise.reject(s)}return this.answers}async ask(e){if(typeof e==="function")e=await e.call(this);let t=ie.merge({},this.options,e),{type:s,name:r}=e,{set:o,get:i}=ie;if(typeof s==="function")s=await s.call(this,e,this.answers);if(!s)return this.answers[r];if(s==="number")s="numeral";jr(this.prompts[s],`Prompt "${s}" is not registered`);let a=new this.prompts[s](t),n=i(this.answers,r);if(a.state.answers=this.answers,a.enquirer=this,r)a.on("submit",(l)=>{this.emit("answer",r,l,a),o(this.answers,r,l)});let d=a.emit.bind(a);if(a.emit=(...l)=>{return this.emit.call(this,...l),d(...l)},this.emit("prompt",a,this),t.autofill&&n!=null){if(a.value=a.input=n,t.autofill==="show")await a.submit()}else n=a.value=await a.run();return n}use(e){return e.call(this,this),this}set Prompt(e){this._Prompt=e}get Prompt(){return this._Prompt||this.constructor.Prompt}get prompts(){return this.constructor.prompts}static set Prompt(e){this._Prompt=e}static get Prompt(){return this._Prompt||ue()}static get prompts(){return Qr()}static get types(){return Jr()}static get prompt(){let e=(t,...s)=>{let r=new this(...s),o=r.emit.bind(r);return r.emit=(...i)=>{return e.emit(...i),o(...i)},r.prompt(t)};return ie.mixinEmitter(e,new It),e}}ie.mixinEmitter(U,new It);var _t=U.prompts;for(let e of Object.keys(_t)){let t=e.toLowerCase(),s=(r)=>new _t[e](r).run();if(U.prompt[t]=s,U[t]=s,!U[e])Reflect.defineProperty(U,e,{get:()=>_t[e]})}var Ae=(e)=>{ie.defineExport(U,e,()=>U.types[e])};Ae("ArrayPrompt");Ae("AuthPrompt");Ae("BooleanPrompt");Ae("NumberPrompt");Ae("StringPrompt");eo.exports=U});var Bi=w((Ut,Gt)=>{(function(e,t){if(typeof Ut==="object"&&typeof Gt==="object")Gt.exports=t();else if(typeof define==="function"&&define.amd)define(function(){return t()});else e.pluralize=t()})(Ut,function(){var e=[],t=[],s={},r={},o={};function i(m){if(typeof m==="string")return new RegExp("^"+m+"$","i");return m}function a(m,h){if(m===h)return h;if(m===m.toLowerCase())return h.toLowerCase();if(m===m.toUpperCase())return h.toUpperCase();if(m[0]===m[0].toUpperCase())return h.charAt(0).toUpperCase()+h.substr(1).toLowerCase();return h.toLowerCase()}function n(m,h){return m.replace(/\$(\d{1,2})/g,function(f,g){return h[g]||""})}function d(m,h){return m.replace(h[0],function(f,g){var y=n(h[1],arguments);if(f==="")return a(m[g-1],y);return a(f,y)})}function l(m,h,f){if(!m.length||s.hasOwnProperty(m))return h;var g=f.length;while(g--){var y=f[g];if(y[0].test(h))return d(h,y)}return h}function c(m,h,f){return function(g){var y=g.toLowerCase();if(h.hasOwnProperty(y))return a(g,y);if(m.hasOwnProperty(y))return a(g,m[y]);return l(y,g,f)}}function u(m,h,f,g){return function(y){var E=y.toLowerCase();if(h.hasOwnProperty(E))return!0;if(m.hasOwnProperty(E))return!1;return l(E,E,f)===E}}function p(m,h,f){var g=h===1?p.singular(m):p.plural(m);return(f?h+" ":"")+g}return p.plural=c(o,r,e),p.isPlural=u(o,r,e),p.singular=c(r,o,t),p.isSingular=u(r,o,t),p.addPluralRule=function(m,h){e.push([i(m),h])},p.addSingularRule=function(m,h){t.push([i(m),h])},p.addUncountableRule=function(m){if(typeof m==="string"){s[m.toLowerCase()]=!0;return}p.addPluralRule(m,"$0"),p.addSingularRule(m,"$0")},p.addIrregularRule=function(m,h){h=h.toLowerCase(),m=m.toLowerCase(),o[m]=h,r[h]=m},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["passerby","passersby"]].forEach(function(m){return p.addIrregularRule(m[0],m[1])}),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach(function(m){return p.addPluralRule(m[0],m[1])}),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/\b((?:tit)?m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,"$1"],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach(function(m){return p.addSingularRule(m[0],m[1])}),["adulthood","advice","agenda","aid","aircraft","alcohol","ammo","analytics","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","firmware","flounder","fun","gallows","garbage","graffiti","hardware","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","mud","manga","news","only","personnel","pike","plankton","pliers","police","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","software","species","staff","swine","tennis","traffic","transportation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pok[e\u00E9]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(p.addUncountableRule),p})});import{parseArgs as Tm}from"util";import{Exception as na}from"@ooneex/exception";import{TerminalLogger as Rm}from"@ooneex/logger";import{container as ba}from"@ooneex/container";var Te=[];var Ft=(e)=>{let t=null;return Te.find((s)=>{return t=ba.get(s),t.getName()===e}),t};import{homedir as va}from"os";import{join as nt}from"path";import{TerminalLogger as Na}from"@ooneex/logger";import{container as xa,EContainerScope as wa}from"@ooneex/container";var x={command:(e=wa.Singleton)=>{return(t)=>{xa.add(t,e),Te.push(t)}}};var Vt=`#compdef oo ooneex
30
+ `);return this.value={values:r,result:i},super.submit()}}Pr.exports=Dr});var Gr=v((ru,Ur)=>{var Il=oe();class kr extends Il{constructor(e){super({...e,reorder:!1,sort:!0,multiple:!0});this.state.hint=[this.options.hint,"(Use <shift>+<up/down> to sort)"].find(this.isValue.bind(this))}indicator(){return""}async renderChoice(e,t){let s=await super.renderChoice(e,t),r=this.symbols.identicalTo+" ",o=this.index===t&&this.sorting?this.styles.muted(r):" ";if(this.options.drag===!1)o="";if(this.options.numbered===!0)return o+`${t+1} - `+s;return o+s}get selected(){return this.choices}submit(){return this.value=this.choices.map((e)=>e.value),super.submit()}}Ur.exports=kr});var Wr=v((ou,qr)=>{var Bl=Se();class $r extends Bl{constructor(e={}){super(e);if(this.emptyError=e.emptyError||"No items were selected",this.term=process.env.TERM_PROGRAM,!this.options.header){let t=["","4 - Strongly Agree","3 - Agree","2 - Neutral","1 - Disagree","0 - Strongly Disagree",""];t=t.map((s)=>this.styles.muted(s)),this.state.header=t.join(`
31
+ `)}}async toChoices(...e){if(this.createdScales)return!1;this.createdScales=!0;let t=await super.toChoices(...e);for(let s of t)s.scale=Ol(5,this.options),s.scaleIdx=2;return t}dispatch(){this.alert()}space(){let e=this.focused,t=e.scale[e.scaleIdx],s=t.selected;return e.scale.forEach((r)=>r.selected=!1),t.selected=!s,this.render()}indicator(){return""}pointer(){return""}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let e=this.focused;if(e.scaleIdx>=e.scale.length-1)return this.alert();return e.scaleIdx++,this.render()}left(){let e=this.focused;if(e.scaleIdx<=0)return this.alert();return e.scaleIdx--,this.render()}indent(){return" "}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=this.term==="Hyper",o=!r?8:9,i=!r?" ":"",a=this.symbols.line.repeat(o),n=" ".repeat(o+(r?0:1)),l=(w)=>(w?this.styles.success("\u25C9"):"\u25EF")+i,d=t+1+".",c=s?this.styles.heading:this.styles.noop,u=await this.resolve(e.message,this.state,e,t),m=this.indent(e),p=m+e.scale.map((w,E)=>l(E===e.scaleIdx)).join(a),h=(w)=>w===e.scaleIdx?c(w):w,f=m+e.scale.map((w,E)=>h(E)).join(n),g=()=>[d,u].filter(Boolean).join(" "),y=()=>[g(),p,f," "].filter(Boolean).join(`
32
+ `);if(s)p=this.styles.cyan(p),f=this.styles.cyan(f);return y()}async renderChoices(){if(this.state.submitted)return"";let e=this.visible.map(async(s,r)=>await this.renderChoice(s,r)),t=await Promise.all(e);if(!t.length)t.push(this.styles.danger("No matching choices"));return t.join(`
33
+ `)}format(){if(this.state.submitted)return this.choices.map((t)=>this.styles.info(t.scaleIdx)).join(", ");return""}async render(){let{submitted:e,size:t}=this.state,s=await this.prefix(),r=await this.separator(),o=await this.message(),i=[s,o,r].filter(Boolean).join(" ");this.state.prompt=i;let a=await this.header(),n=await this.format(),l=await this.error()||await this.hint(),d=await this.renderChoices(),c=await this.footer();if(n||!l)i+=" "+n;if(l&&!i.includes(l))i+=" "+l;if(e&&!n&&!d&&this.multiple&&this.type!=="form")i+=this.styles.danger(this.emptyError);this.clear(t),this.write([i,a,d,c].filter(Boolean).join(`
34
+ `)),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIdx;return this.base.submit.call(this)}}function Ol(e,t={}){if(Array.isArray(t.scale))return t.scale.map((r)=>({...r}));let s=[];for(let r=1;r<e+1;r++)s.push({i:r,selected:!1});return s}qr.exports=$r});var Hr=v((iu,Kr)=>{var Dl=Ue();class Fr extends Dl{async initialize(){await super.initialize(),this.value=this.initial=this.resolve(this.options.initial),this.disabled=this.options.disabled||"no",this.enabled=this.options.enabled||"yes",await this.render()}reset(){this.value=this.initial,this.render()}delete(){this.alert()}toggle(){this.value=!this.value,this.render()}enable(){if(this.value===!0)return this.alert();this.value=!0,this.render()}disable(){if(this.value===!1)return this.alert();this.value=!1,this.render()}up(){this.toggle()}down(){this.toggle()}right(){this.toggle()}left(){this.toggle()}next(){this.toggle()}prev(){this.toggle()}dispatch(e="",t){switch(e.toLowerCase()){case" ":return this.toggle();case"1":case"y":case"t":return this.enable();case"0":case"n":case"f":return this.disable();default:return this.alert()}}format(){let e=(s)=>this.styles.primary.underline(s);return[this.value?this.disabled:e(this.disabled),this.value?e(this.enabled):this.enabled].join(this.styles.muted(" / "))}async render(){let{size:e}=this.state,t=await this.header(),s=await this.prefix(),r=await this.separator(),o=await this.message(),i=await this.format(),a=await this.error()||await this.hint(),n=await this.footer(),l=[s,o,r,i].join(" ");if(this.state.prompt=l,a&&!l.includes(a))l+=" "+a;this.clear(e),this.write([t,l,n].filter(Boolean).join(`
35
+ `)),this.write(this.margin[2]),this.restore()}}Kr.exports=Fr});var Yr=v((au,zr)=>{var Pl=oe();class Vr extends Pl{constructor(e){super(e);if(typeof this.options.correctChoice!=="number"||this.options.correctChoice<0)throw Error("Please specify the index of the correct answer from the list of choices")}async toChoices(e,t){let s=await super.toChoices(e,t);if(s.length<2)throw Error("Please give at least two choices to the user");if(this.options.correctChoice>s.length)throw Error("Please specify the index of the correct answer from the list of choices");return s}check(e){return e.index===this.options.correctChoice}async result(e){return{selectedAnswer:e,correctAnswer:this.options.choices[this.options.correctChoice].value,correct:await this.check(this.state)}}}zr.exports=Vr});var Zr=v((_t)=>{var Qr=M(),S=(e,t)=>{Qr.defineExport(_t,e,t),Qr.defineExport(_t,e.toLowerCase(),t)};S("AutoComplete",()=>Ws());S("BasicAuth",()=>Zs());S("Confirm",()=>tr());S("Editable",()=>or());S("Form",()=>ke());S("Input",()=>Rt());S("Invisible",()=>hr());S("List",()=>gr());S("MultiSelect",()=>wr());S("Numeral",()=>Ct());S("Password",()=>Sr());S("Scale",()=>Mr());S("Select",()=>oe());S("Snippet",()=>Lr());S("Sort",()=>Gr());S("Survey",()=>Wr());S("Text",()=>Rt());S("Toggle",()=>Hr());S("Quiz",()=>Yr())});var Jr=v((lu,Xr)=>{Xr.exports={ArrayPrompt:Se(),AuthPrompt:Nt(),BooleanPrompt:Ue(),NumberPrompt:Ct(),StringPrompt:ce()}});var ae=v((du,eo)=>{var jr=Ee("assert"),Bt=Ee("events"),ie=M();class k extends Bt{constructor(e,t){super();this.options=ie.merge({},e),this.answers={...t}}register(e,t){if(ie.isObject(e)){for(let r of Object.keys(e))this.register(r,e[r]);return this}jr.equal(typeof t,"function","expected a function");let s=e.toLowerCase();if(t.prototype instanceof this.Prompt)this.prompts[s]=t;else this.prompts[s]=t(this.Prompt,this);return this}async prompt(e=[]){for(let t of[].concat(e))try{if(typeof t==="function")t=await t.call(this);await this.ask(ie.merge({},this.options,t))}catch(s){return Promise.reject(s)}return this.answers}async ask(e){if(typeof e==="function")e=await e.call(this);let t=ie.merge({},this.options,e),{type:s,name:r}=e,{set:o,get:i}=ie;if(typeof s==="function")s=await s.call(this,e,this.answers);if(!s)return this.answers[r];if(s==="number")s="numeral";jr(this.prompts[s],`Prompt "${s}" is not registered`);let a=new this.prompts[s](t),n=i(this.answers,r);if(a.state.answers=this.answers,a.enquirer=this,r)a.on("submit",(d)=>{this.emit("answer",r,d,a),o(this.answers,r,d)});let l=a.emit.bind(a);if(a.emit=(...d)=>{return this.emit.call(this,...d),l(...d)},this.emit("prompt",a,this),t.autofill&&n!=null){if(a.value=a.input=n,t.autofill==="show")await a.submit()}else n=a.value=await a.run();return n}use(e){return e.call(this,this),this}set Prompt(e){this._Prompt=e}get Prompt(){return this._Prompt||this.constructor.Prompt}get prompts(){return this.constructor.prompts}static set Prompt(e){this._Prompt=e}static get Prompt(){return this._Prompt||he()}static get prompts(){return Zr()}static get types(){return Jr()}static get prompt(){let e=(t,...s)=>{let r=new this(...s),o=r.emit.bind(r);return r.emit=(...i)=>{return e.emit(...i),o(...i)},r.prompt(t)};return ie.mixinEmitter(e,new Bt),e}}ie.mixinEmitter(k,new Bt);var It=k.prompts;for(let e of Object.keys(It)){let t=e.toLowerCase(),s=(r)=>new It[e](r).run();if(k.prompt[t]=s,k[t]=s,!k[e])Reflect.defineProperty(k,e,{get:()=>It[e]})}var Ne=(e)=>{ie.defineExport(k,e,()=>k.types[e])};Ne("ArrayPrompt");Ne("AuthPrompt");Ne("BooleanPrompt");Ne("NumberPrompt");Ne("StringPrompt");eo.exports=k});var Oi=v((Ut,Gt)=>{(function(e,t){if(typeof Ut==="object"&&typeof Gt==="object")Gt.exports=t();else if(typeof define==="function"&&define.amd)define(function(){return t()});else e.pluralize=t()})(Ut,function(){var e=[],t=[],s={},r={},o={};function i(p){if(typeof p==="string")return new RegExp("^"+p+"$","i");return p}function a(p,h){if(p===h)return h;if(p===p.toLowerCase())return h.toLowerCase();if(p===p.toUpperCase())return h.toUpperCase();if(p[0]===p[0].toUpperCase())return h.charAt(0).toUpperCase()+h.substr(1).toLowerCase();return h.toLowerCase()}function n(p,h){return p.replace(/\$(\d{1,2})/g,function(f,g){return h[g]||""})}function l(p,h){return p.replace(h[0],function(f,g){var y=n(h[1],arguments);if(f==="")return a(p[g-1],y);return a(f,y)})}function d(p,h,f){if(!p.length||s.hasOwnProperty(p))return h;var g=f.length;while(g--){var y=f[g];if(y[0].test(h))return l(h,y)}return h}function c(p,h,f){return function(g){var y=g.toLowerCase();if(h.hasOwnProperty(y))return a(g,y);if(p.hasOwnProperty(y))return a(g,p[y]);return d(y,g,f)}}function u(p,h,f,g){return function(y){var w=y.toLowerCase();if(h.hasOwnProperty(w))return!0;if(p.hasOwnProperty(w))return!1;return d(w,w,f)===w}}function m(p,h,f){var g=h===1?m.singular(p):m.plural(p);return(f?h+" ":"")+g}return m.plural=c(o,r,e),m.isPlural=u(o,r,e),m.singular=c(r,o,t),m.isSingular=u(r,o,t),m.addPluralRule=function(p,h){e.push([i(p),h])},m.addSingularRule=function(p,h){t.push([i(p),h])},m.addUncountableRule=function(p){if(typeof p==="string"){s[p.toLowerCase()]=!0;return}m.addPluralRule(p,"$0"),m.addSingularRule(p,"$0")},m.addIrregularRule=function(p,h){h=h.toLowerCase(),p=p.toLowerCase(),o[p]=h,r[h]=p},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["passerby","passersby"]].forEach(function(p){return m.addIrregularRule(p[0],p[1])}),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach(function(p){return m.addPluralRule(p[0],p[1])}),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/\b((?:tit)?m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,"$1"],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach(function(p){return m.addSingularRule(p[0],p[1])}),["adulthood","advice","agenda","aid","aircraft","alcohol","ammo","analytics","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","firmware","flounder","fun","gallows","garbage","graffiti","hardware","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","mud","manga","news","only","personnel","pike","plankton","pliers","police","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","software","species","staff","swine","tennis","traffic","transportation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pok[e\u00E9]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(m.addUncountableRule),m})});import{parseArgs as jp}from"util";import{Exception as xa}from"@ooneex/exception";import{TerminalLogger as em}from"@ooneex/logger";import{container as Ba}from"@ooneex/container";var _e=[];var Ht=(e)=>{let t=null;return _e.find((s)=>{return t=Ba.get(s),t.getName()===e}),t};import{homedir as ka}from"os";import{join as lt}from"path";import{TerminalLogger as Ua}from"@ooneex/logger";import{container as Oa,EContainerScope as Da}from"@ooneex/container";var x={command:(e=Da.Singleton)=>{return(t)=>{Oa.add(t,e),_e.push(t)}}};var Vt=`#compdef oo ooneex
36
36
 
37
37
  _oo_modules() {
38
38
  local -a modules
@@ -65,6 +65,7 @@ _oo() {
65
65
  'make\\:pubsub:Generate a new PubSub event class'
66
66
  'make\\:release:Release packages with version bump, changelog, and git tag'
67
67
  'make\\:repository:Generate a new repository class'
68
+ 'make\\:resource\\:book:Generate book resource (entity, migration, repository)'
68
69
  'make\\:seed:Generate a new seed file'
69
70
  'make\\:service:Generate a new service class'
70
71
  'make\\:storage:Generate a new storage class'
@@ -137,7 +138,7 @@ _oo() {
137
138
  '--name=[Name of the resource]:name' \\
138
139
  '--module=[Module name]:module:_oo_modules'
139
140
  ;;
140
- make:release|make:claude:skill|completion:zsh)
141
+ make:release|make:resource:book|make:claude:skill|completion:zsh)
141
142
  ;;
142
143
  esac
143
144
  ;;
@@ -145,7 +146,7 @@ _oo() {
145
146
  }
146
147
 
147
148
  _oo "$@"
148
- `;var Yt=`#compdef oo ooneex
149
+ `;var zt=`#compdef oo ooneex
149
150
 
150
151
  _ooneex_modules() {
151
152
  local -a modules
@@ -178,6 +179,7 @@ _ooneex() {
178
179
  'make\\:pubsub:Generate a new PubSub event class'
179
180
  'make\\:release:Release packages with version bump, changelog, and git tag'
180
181
  'make\\:repository:Generate a new repository class'
182
+ 'make\\:resource\\:book:Generate book resource (entity, migration, repository)'
181
183
  'make\\:seed:Generate a new seed file'
182
184
  'make\\:service:Generate a new service class'
183
185
  'make\\:storage:Generate a new storage class'
@@ -250,7 +252,7 @@ _ooneex() {
250
252
  '--name=[Name of the resource]:name' \\
251
253
  '--module=[Module name]:module:_ooneex_modules'
252
254
  ;;
253
- make:release|make:claude:skill|completion:zsh)
255
+ make:release|make:resource:book|make:claude:skill|completion:zsh)
254
256
  ;;
255
257
  esac
256
258
  ;;
@@ -258,9 +260,9 @@ _ooneex() {
258
260
  }
259
261
 
260
262
  _ooneex "$@"
261
- `;class Re{getName(){return"completion:zsh"}getDescription(){return"Install Zsh completion for oo command"}async run(){let e=nt(va(),".zsh"),t=nt(e,"_oo");await Bun.write(t,Vt);let s=nt(e,"_ooneex");await Bun.write(s,Yt);let r=new Na;r.success(`${t} created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),r.success(`${s} created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),r.info(`Add the following to your .zshrc if not already present:
263
+ `;class Ie{getName(){return"completion:zsh"}getDescription(){return"Install Zsh completion for oo command"}async run(){let e=lt(ka(),".zsh"),t=lt(e,"_oo");await Bun.write(t,Vt);let s=lt(e,"_ooneex");await Bun.write(s,zt);let r=new Ua;r.success(`${t} created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),r.success(`${s} created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),r.info(`Add the following to your .zshrc if not already present:
262
264
  fpath=(~/.zsh $fpath)
263
- autoload -Uz compinit && compinit`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}Re=b([x.command()],Re);import{join as H}from"path";import{TerminalLogger as Md}from"@ooneex/logger";import{toPascalCase as Cd}from"@ooneex/utils";var to=te(ae(),1);import{Assert as Ad,Validation as vd}from"@ooneex/validation";var Nd=1,Sd=/^[a-zA-Z][a-zA-Z0-9-]*$/;class ve extends vd{getConstraint(){return Ad(`string >= ${Nd}`)}getErrorMessage(){return"Name must start with a letter and contain only letters, numbers, and hyphens"}validate(e,t){let s=super.validate(e,t);if(!s.isValid)return s;let r=e;if(!Sd.test(r))return{isValid:!1,message:this.getErrorMessage()||"Invalid name format"};return{isValid:!0}}}var v=async(e)=>{return(await to.prompt({type:"input",name:"name",message:e.message,validate:(s)=>{let o=new ve().validate(s);if(!o.isValid)return o.message||"Controller name is invalid";return!0}})).name};var so=`import { describe, expect, test } from "bun:test";
265
+ autoload -Uz compinit && compinit`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}Ie=b([x.command()],Ie);import{join as H}from"path";import{TerminalLogger as Wl}from"@ooneex/logger";import{toPascalCase as Fl}from"@ooneex/utils";var to=te(ae(),1);import{Assert as Ll,Validation as kl}from"@ooneex/validation";var Ul=1,Gl=/^[a-zA-Z][a-zA-Z0-9-]*$/;class Re extends kl{getConstraint(){return Ll(`string >= ${Ul}`)}getErrorMessage(){return"Name must start with a letter and contain only letters, numbers, and hyphens"}validate(e,t){let s=super.validate(e,t);if(!s.isValid)return s;let r=e;if(!Gl.test(r))return{isValid:!1,message:this.getErrorMessage()||"Invalid name format"};return{isValid:!0}}}var A=async(e)=>{return(await to.prompt({type:"input",name:"name",message:e.message,validate:(s)=>{let o=new Re().validate(s);if(!o.isValid)return o.message||"Controller name is invalid";return!0}})).name};var so=`import { describe, expect, test } from "bun:test";
264
266
  import { {{NAME}}Ai } from "@/ai/{{NAME}}Ai";
265
267
 
266
268
  describe("{{NAME}}Ai", () => {
@@ -296,7 +298,7 @@ export class {{NAME}}Ai implements IAiChat<OpenAiConfigType> {
296
298
  yield* this.ai.runStream(prompt || "My prompt", config);
297
299
  }
298
300
  }
299
- `;class Le{getName(){return"make:ai"}getDescription(){return"Generate a new AI class"}async run(e){let{name:t,module:s}=e;if(!t)t=await v({message:"Enter name"});t=Cd(t).replace(/Ai$/,"");let r=ro.replace(/{{NAME}}/g,t),o=s?H("modules",s):".",i=H(o,"src","ai"),a=H(process.cwd(),i),n=H(a,`${t}Ai.ts`);await Bun.write(n,r);let d=so.replace(/{{NAME}}/g,t),l=H(o,"tests","ai"),c=H(process.cwd(),l),u=H(c,`${t}Ai.spec.ts`);await Bun.write(u,d);let p=new Md;p.success(`${H(i,t)}Ai.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),p.success(`${H(l,t)}Ai.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/ai"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}Le=b([x.command()],Le);import{join as F}from"path";import{TerminalLogger as Od}from"@ooneex/logger";import{toPascalCase as Dd}from"@ooneex/utils";var oo=`import { describe, expect, test } from "bun:test";
301
+ `;class $e{getName(){return"make:ai"}getDescription(){return"Generate a new AI class"}async run(e){let{name:t,module:s}=e;if(!t)t=await A({message:"Enter name"});t=Fl(t).replace(/Ai$/,"");let r=ro.replace(/{{NAME}}/g,t),o=s?H("modules",s):".",i=H(o,"src","ai"),a=H(process.cwd(),i),n=H(a,`${t}Ai.ts`);await Bun.write(n,r);let l=so.replace(/{{NAME}}/g,t),d=H(o,"tests","ai"),c=H(process.cwd(),d),u=H(c,`${t}Ai.spec.ts`);await Bun.write(u,l);let m=new Wl;m.success(`${H(i,t)}Ai.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),m.success(`${H(d,t)}Ai.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/ai"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}$e=b([x.command()],$e);import{join as V}from"path";import{TerminalLogger as Vl}from"@ooneex/logger";import{toPascalCase as zl}from"@ooneex/utils";var oo=`import { describe, expect, test } from "bun:test";
300
302
  import { {{NAME}}Analytics } from "@/analytics/{{NAME}}Analytics";
301
303
 
302
304
  describe("{{NAME}}Analytics", () => {
@@ -320,7 +322,7 @@ export class {{NAME}}Analytics<T extends CaptureOptionsType = CaptureOptionsType
320
322
  // console.log("Analytics captured:", options);
321
323
  }
322
324
  }
323
- `;class Ue{getName(){return"make:analytics"}getDescription(){return"Generate a new analytics class"}async run(e){let{name:t,module:s}=e;if(!t)t=await v({message:"Enter analytics name"});t=Dd(t).replace(/Analytics$/,"");let r=io.replace(/{{NAME}}/g,t),o=s?F("modules",s):".",i=F(o,"src","analytics"),a=F(process.cwd(),i),n=F(a,`${t}Analytics.ts`);await Bun.write(n,r);let d=oo.replace(/{{NAME}}/g,t),l=F(o,"tests","analytics"),c=F(process.cwd(),l),u=F(c,`${t}Analytics.spec.ts`);await Bun.write(u,d);let p=new Od;p.success(`${F(i,t)}Analytics.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),p.success(`${F(l,t)}Analytics.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/analytics"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}Ue=b([x.command()],Ue);import{join as T}from"path";import{TerminalLogger as wl}from"@ooneex/logger";import{toKebabCase as El,toSnakeCase as Al}from"@ooneex/utils";var ao=te(ae(),1);var no=async(e)=>{let t=new ve;return(await ao.prompt({type:"input",name:"destination",message:e.message,initial:e.initial||".",validate:(r)=>{let o=t.validate(r);if(!o.isValid)return o.message||"Invalid destination";return!0}})).destination};var lo=`import { RuleConfigSeverity, type UserConfig } from "@commitlint/types";
325
+ `;class qe{getName(){return"make:analytics"}getDescription(){return"Generate a new analytics class"}async run(e){let{name:t,module:s}=e;if(!t)t=await A({message:"Enter analytics name"});t=zl(t).replace(/Analytics$/,"");let r=io.replace(/{{NAME}}/g,t),o=s?V("modules",s):".",i=V(o,"src","analytics"),a=V(process.cwd(),i),n=V(a,`${t}Analytics.ts`);await Bun.write(n,r);let l=oo.replace(/{{NAME}}/g,t),d=V(o,"tests","analytics"),c=V(process.cwd(),d),u=V(c,`${t}Analytics.spec.ts`);await Bun.write(u,l);let m=new Vl;m.success(`${V(i,t)}Analytics.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),m.success(`${V(d,t)}Analytics.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/analytics"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}qe=b([x.command()],qe);import{join as N}from"path";import{TerminalLogger as Od}from"@ooneex/logger";import{toKebabCase as Dd,toSnakeCase as Pd}from"@ooneex/utils";var ao=te(ae(),1);var no=async(e)=>{let t=new Re;return(await ao.prompt({type:"input",name:"destination",message:e.message,initial:e.initial||".",validate:(r)=>{let o=t.validate(r);if(!o.isValid)return o.message||"Invalid destination";return!0}})).destination};var lo=`import { RuleConfigSeverity, type UserConfig } from "@commitlint/types";
324
326
 
325
327
  const Configuration: UserConfig = {
326
328
  extends: ["@commitlint/config-conventional"],
@@ -610,7 +612,7 @@ vite.config.ts.timestamp-*
610
612
 
611
613
  # Application
612
614
  var/
613
- `;var mo=`import { inject } from "@ooneex/container";
615
+ `;var po=`import { inject } from "@ooneex/container";
614
616
  import { AppEnv } from "@ooneex/app-env";
615
617
  import { DataSource } from "typeorm";
616
618
  import { TypeormDatabase, DatabaseException, decorator } from "@ooneex/database";
@@ -644,7 +646,7 @@ export class AppDatabase extends TypeormDatabase {
644
646
  return this.source;
645
647
  }
646
648
  }
647
- `;var po=`{
649
+ `;var mo=`{
648
650
  "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
649
651
  "vcs": {
650
652
  "enabled": true,
@@ -1303,7 +1305,7 @@ Proprietary - All rights reserved.
1303
1305
  },
1304
1306
  "exclude": ["node_modules", ".github", ".husky", ".nx", ".zed", ".vscode"]
1305
1307
  }
1306
- `;var Eo=`{
1308
+ `;var vo=`{
1307
1309
  "formatter": "language_server",
1308
1310
  "format_on_save": "on",
1309
1311
  "languages": {
@@ -1405,11 +1407,25 @@ Proprietary - All rights reserved.
1405
1407
  }
1406
1408
  }
1407
1409
  }
1408
- `;import{basename as ll,join as O}from"path";import{TerminalLogger as cl}from"@ooneex/logger";import{toKebabCase as ml,toPascalCase as Ge,trim as pl}from"@ooneex/utils";var Ao=te(ae(),1),fe=async(e)=>{return(await Ao.prompt({type:"confirm",name:"confirm",message:e.message})).confirm};var Ne=["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD"];var vo=te(ae(),1);import{Assert as zd,Validation as Zd}from"@ooneex/validation";class Dt extends Zd{getConstraint(){return zd("string >= 3")}getErrorMessage(){return`Route method must be one of: ${Ne.join(", ")}`}validate(e,t){let s=super.validate(e,t);if(!s.isValid)return s;let r=e;if(r.trim()!==r)return{isValid:!1,message:this.getErrorMessage()||"Invalid route method format"};let o=r.toUpperCase();if(!Ne.includes(o))return{isValid:!1,message:this.getErrorMessage()||"Invalid route method"};return{isValid:!0}}}var No=async(e)=>{return(await vo.prompt({type:"select",name:"method",message:e.message,initial:e.initial??0,choices:Ne.map((s)=>s),validate:(s)=>{let o=new Dt().validate(s);if(!o.isValid)return o.message||"Route method is invalid";return!0}})).method};var So=te(ae(),1);import{Assert as Qd,Validation as Xd}from"@ooneex/validation";var Jd=/^[a-zA-Z0-9]+\.[a-zA-Z0-9]+\.[a-zA-Z0-9]+$/;class Bt extends Xd{getConstraint(){return Qd("string >= 7")}getErrorMessage(){return"Route name must follow format: namespace.resource.action (e.g., 'api.users.list')"}validate(e,t){let s=super.validate(e,t);if(!s.isValid)return s;let r=e;if(r.trim()!==r)return{isValid:!1,message:this.getErrorMessage()||"Invalid route name format"};if(!Jd.test(r))return{isValid:!1,message:this.getErrorMessage()||"Invalid route name format"};let o=r.split(".");if(o.length!==3)return{isValid:!1,message:this.getErrorMessage()||"Invalid route name format"};let[i,a,n]=o;if(!i||!a||!n)return{isValid:!1,message:this.getErrorMessage()||"Invalid route name format"};return{isValid:!0}}}var To=async(e)=>{return(await So.prompt({type:"input",name:"routeName",message:e.message,validate:(s)=>{let o=new Bt().validate(s);if(!o.isValid)return o.message||"Route name is invalid";return!0}})).routeName};var Ro=te(ae(),1);import{Assert as jd,Validation as el}from"@ooneex/validation";var tl=1,sl=/^\/[\w\-/:]*$/,rl=/^[a-zA-Z0-9\-_]+$/,ol=/^:[a-zA-Z][a-zA-Z0-9]*$/;class Pt extends el{getConstraint(){return jd(`string >= ${tl}`)}getErrorMessage(){return"Route path must start with '/' and contain only valid segments (e.g., '/users', '/api/users/:id')"}validate(e,t){let s=super.validate(e,t);if(!s.isValid)return s;let r=e;if(r.trim()!==r)return{isValid:!1,message:this.getErrorMessage()||"Invalid route path format"};if(!r.startsWith("/"))return{isValid:!1,message:"Route path must start with '/'"};if(r.length>1&&r.endsWith("/"))return{isValid:!1,message:"Route path cannot end with '/' (except for root path)"};if(!sl.test(r))return{isValid:!1,message:this.getErrorMessage()||"Invalid route path format"};if(r==="/")return{isValid:!0};let o=r.slice(1).split("/");for(let i of o){if(!i)return{isValid:!1,message:"Route path cannot contain empty segments (double slashes)"};if(i.startsWith(":")){if(!ol.test(i))return{isValid:!1,message:`Invalid parameter segment '${i}'. Parameters must follow format ':paramName' with alphanumeric characters only`}}else if(!rl.test(i))return{isValid:!1,message:`Invalid path segment '${i}'. Segments must contain only letters, numbers, hyphens, and underscores`}}return{isValid:!0}}}var Mo=async(e)=>{return(await Ro.prompt({type:"input",name:"path",message:e.message,initial:e.initial??"/",validate:(s)=>{let o=new Pt().validate(s);if(!o.isValid)return o.message||"Route path is invalid";return!0}})).path};var Co=`import type { ContextType } from "@ooneex/socket";
1410
+ `;import{basename as Ed,join as U}from"path";import{TerminalLogger as Ad}from"@ooneex/logger";import{toKebabCase as Td,toPascalCase as We,trim as Sd}from"@ooneex/utils";var Eo=te(ae(),1),ye=async(e)=>{return(await Eo.prompt({type:"confirm",name:"confirm",message:e.message})).confirm};var Ce=["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD"];var Ao=te(ae(),1);import{Assert as ld,Validation as dd}from"@ooneex/validation";class Dt extends dd{getConstraint(){return ld("string >= 3")}getErrorMessage(){return`Route method must be one of: ${Ce.join(", ")}`}validate(e,t){let s=super.validate(e,t);if(!s.isValid)return s;let r=e;if(r.trim()!==r)return{isValid:!1,message:this.getErrorMessage()||"Invalid route method format"};let o=r.toUpperCase();if(!Ce.includes(o))return{isValid:!1,message:this.getErrorMessage()||"Invalid route method"};return{isValid:!0}}}var To=async(e)=>{return(await Ao.prompt({type:"select",name:"method",message:e.message,initial:e.initial??0,choices:Ce.map((s)=>s),validate:(s)=>{let o=new Dt().validate(s);if(!o.isValid)return o.message||"Route method is invalid";return!0}})).method};var So=te(ae(),1);import{Assert as cd,Validation as pd}from"@ooneex/validation";var md=/^[a-zA-Z0-9]+\.[a-zA-Z0-9]+\.[a-zA-Z0-9]+$/;class Pt extends pd{getConstraint(){return cd("string >= 7")}getErrorMessage(){return"Route name must follow format: namespace.resource.action (e.g., 'api.users.list')"}validate(e,t){let s=super.validate(e,t);if(!s.isValid)return s;let r=e;if(r.trim()!==r)return{isValid:!1,message:this.getErrorMessage()||"Invalid route name format"};if(!md.test(r))return{isValid:!1,message:this.getErrorMessage()||"Invalid route name format"};let o=r.split(".");if(o.length!==3)return{isValid:!1,message:this.getErrorMessage()||"Invalid route name format"};let[i,a,n]=o;if(!i||!a||!n)return{isValid:!1,message:this.getErrorMessage()||"Invalid route name format"};return{isValid:!0}}}var No=async(e)=>{return(await So.prompt({type:"input",name:"routeName",message:e.message,validate:(s)=>{let o=new Pt().validate(s);if(!o.isValid)return o.message||"Route name is invalid";return!0}})).routeName};var Ro=te(ae(),1);import{Assert as ud,Validation as hd}from"@ooneex/validation";var fd=1,yd=/^\/[\w\-/:]*$/,gd=/^[a-zA-Z0-9\-_]+$/,bd=/^:[a-zA-Z][a-zA-Z0-9]*$/;class Lt extends hd{getConstraint(){return ud(`string >= ${fd}`)}getErrorMessage(){return"Route path must start with '/' and contain only valid segments (e.g., '/users', '/api/users/:id')"}validate(e,t){let s=super.validate(e,t);if(!s.isValid)return s;let r=e;if(r.trim()!==r)return{isValid:!1,message:this.getErrorMessage()||"Invalid route path format"};if(!r.startsWith("/"))return{isValid:!1,message:"Route path must start with '/'"};if(r.length>1&&r.endsWith("/"))return{isValid:!1,message:"Route path cannot end with '/' (except for root path)"};if(!yd.test(r))return{isValid:!1,message:this.getErrorMessage()||"Invalid route path format"};if(r==="/")return{isValid:!0};let o=r.slice(1).split("/");for(let i of o){if(!i)return{isValid:!1,message:"Route path cannot contain empty segments (double slashes)"};if(i.startsWith(":")){if(!bd.test(i))return{isValid:!1,message:`Invalid parameter segment '${i}'. Parameters must follow format ':paramName' with alphanumeric characters only`}}else if(!gd.test(i))return{isValid:!1,message:`Invalid path segment '${i}'. Segments must contain only letters, numbers, hyphens, and underscores`}}return{isValid:!0}}}var Co=async(e)=>{return(await Ro.prompt({type:"input",name:"path",message:e.message,initial:e.initial??"/",validate:(s)=>{let o=new Lt().validate(s);if(!o.isValid)return o.message||"Route path is invalid";return!0}})).path};var Mo=`import type { ContextType } from "@ooneex/socket";
1409
1411
  import { ERole } from "@ooneex/role";
1410
1412
  import { Route } from "@ooneex/routing";
1411
1413
  import { Assert } from "@ooneex/validation";
1412
- import type { {{TYPE_NAME}}RouteType } from "../types/routes/{{TYPE_NAME_FILE}}";
1414
+
1415
+ export type {{TYPE_NAME}}RouteType = {
1416
+ params: {
1417
+
1418
+ },
1419
+ payload: {
1420
+
1421
+ },
1422
+ queries: {
1423
+
1424
+ },
1425
+ response: {
1426
+
1427
+ },
1428
+ };
1413
1429
 
1414
1430
  @Route.socket("{{ROUTE_PATH}}", {
1415
1431
  name: "{{ROUTE_NAME}}",
@@ -1455,7 +1471,21 @@ describe("{{NAME}}Controller", () => {
1455
1471
  import { ERole } from "@ooneex/role";
1456
1472
  import { Route } from "@ooneex/routing";
1457
1473
  import { Assert } from "@ooneex/validation";
1458
- import type { {{TYPE_NAME}}RouteType } from "@/types/routes/{{TYPE_NAME_FILE}}";
1474
+
1475
+ export type {{TYPE_NAME}}RouteType = {
1476
+ params: {
1477
+
1478
+ },
1479
+ payload: {
1480
+
1481
+ },
1482
+ queries: {
1483
+
1484
+ },
1485
+ response: {
1486
+
1487
+ },
1488
+ };
1459
1489
 
1460
1490
  @Route.{{ROUTE_METHOD}}("{{ROUTE_PATH}}", {
1461
1491
  name: "{{ROUTE_NAME}}",
@@ -1484,23 +1514,9 @@ export class {{NAME}}Controller {
1484
1514
  });
1485
1515
  }
1486
1516
  }
1487
- `;var Oo=`export type {{TYPE_NAME}}RouteType = {
1488
- params: {
1489
-
1490
- },
1491
- payload: {
1492
-
1493
- },
1494
- queries: {
1495
-
1496
- },
1497
- response: {
1498
-
1499
- },
1500
- };
1501
- `;class ye{getName(){return"make:controller"}getDescription(){return"Generate a new controller class"}async addToModule(e,t){let s=await Bun.file(e).text(),r=`${t}Controller`,o=`import { ${r} } from "./controllers/${r}";
1517
+ `;class ne{getName(){return"make:controller"}getDescription(){return"Generate a new controller class"}async addToModule(e,t){let s=await Bun.file(e).text(),r=`${t}Controller`,o=`import { ${r} } from "./controllers/${r}";
1502
1518
  `,i=s.lastIndexOf("import "),a=s.indexOf(`
1503
- `,i);s=`${s.slice(0,a+1)}${o}${s.slice(a+1)}`;let n=/(controllers:\s*\[)([^\]]*)/s,d=s.match(n);if(d){let l=d[2]?.trim(),c=l?`${l}, ${r}`:r;s=s.replace(n,`$1${c}`)}await Bun.write(e,s)}async run(e){let{name:t,module:s,isSocket:r}=e;if(!t)t=await v({message:"Enter controller name"});if(r===void 0)r=await fe({message:"Is this a socket controller?"});t=Ge(t).replace(/Controller$/,"");let{route:o={}}=e,a=(r?Co:Io).replaceAll("{{NAME}}",t),n="",d="";if(!o.name)o.name=await To({message:"Enter route name (e.g., api.user.create)"});if(n=Ge(o.name),d=o.name,a=a.replaceAll("{{ROUTE_NAME}}",o.name).replaceAll("{{TYPE_NAME}}",n).replaceAll("{{TYPE_NAME_FILE}}",d),!o.path)o.path=await Mo({message:"Enter route path",initial:"/"});let l=`/${ml(pl(o.path,"/"))}`;if(a=a.replaceAll("{{ROUTE_PATH}}",l),!r&&!o.method)o.method=await No({message:"Enter route method"});if(!r&&o.method)a=a.replaceAll("{{ROUTE_METHOD}}",o.method.toLowerCase());let c=s?O("modules",s):".",u=O(c,"src","controllers"),p=O(process.cwd(),u),m=O(p,`${t}Controller.ts`);await Bun.write(m,a);let h=O(c,"src","types","routes"),f=O(process.cwd(),h),g=O(f,`${d}.ts`),y=Oo.replaceAll("{{TYPE_NAME}}",n);await Bun.write(g,y);let E=_o.replace(/{{NAME}}/g,t),A=O(c,"tests","controllers"),N=O(process.cwd(),A),R=O(N,`${t}Controller.spec.ts`);await Bun.write(R,E);let _=s?Ge(s):Ge(ll(process.cwd())),Se=O(process.cwd(),c,"src",`${_}Module.ts`);if(await Bun.file(Se).exists())await this.addToModule(Se,t);let ee=new cl;ee.success(`${O(u,t)}Controller.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),ee.success(`${O(h,d)}.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),ee.success(`${O(A,t)}Controller.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/controller"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}ye=b([x.command()],ye);import{join as P}from"path";import{TerminalLogger as gl}from"@ooneex/logger";import{toKebabCase as bl,toPascalCase as xl}from"@ooneex/utils";var Do=`import type { ModuleType } from "@ooneex/module";
1519
+ `,i);s=`${s.slice(0,a+1)}${o}${s.slice(a+1)}`;let n=/(controllers:\s*\[)([^\]]*)/s,l=s.match(n);if(l){let d=l[2]?.trim(),c=d?`${d}, ${r}`:r;s=s.replace(n,`$1${c}`)}await Bun.write(e,s)}async run(e){let{name:t,module:s,isSocket:r}=e;if(!t)t=await A({message:"Enter controller name"});if(r===void 0)r=await ye({message:"Is this a socket controller?"});t=We(t).replace(/Controller$/,"");let{route:o={}}=e,a=(r?Mo:Io).replaceAll("{{NAME}}",t);if(!o.name)o.name=await No({message:"Enter route name (e.g., api.user.create)"});let n=We(o.name);if(a=a.replaceAll("{{ROUTE_NAME}}",o.name).replaceAll("{{TYPE_NAME}}",n),!o.path)o.path=await Co({message:"Enter route path",initial:"/"});let l=`/${Td(Sd(o.path,"/"))}`;if(a=a.replaceAll("{{ROUTE_PATH}}",l),!r&&!o.method)o.method=await To({message:"Enter route method"});if(!r&&o.method)a=a.replaceAll("{{ROUTE_METHOD}}",o.method.toLowerCase());let d=s?U("modules",s):".",c=U(d,"src","controllers"),u=U(process.cwd(),c),m=U(u,`${t}Controller.ts`);await Bun.write(m,a);let p=_o.replace(/{{NAME}}/g,t),h=U(d,"tests","controllers"),f=U(process.cwd(),h),g=U(f,`${t}Controller.spec.ts`);await Bun.write(g,p);let y=s?We(s):We(Ed(process.cwd())),w=U(process.cwd(),d,"src",`${y}Module.ts`);if(await Bun.file(w).exists())await this.addToModule(w,t);let E=new Ad;E.success(`${U(c,t)}Controller.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),E.success(`${U(h,t)}Controller.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/controller"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}ne=b([x.command()],ne);import{join as P}from"path";import{TerminalLogger as _d}from"@ooneex/logger";import{toKebabCase as Id,toPascalCase as Bd}from"@ooneex/utils";var Bo=`import type { ModuleType } from "@ooneex/module";
1504
1520
 
1505
1521
  export const {{NAME}}Module: ModuleType = {
1506
1522
  controllers: [],
@@ -1509,7 +1525,7 @@ export const {{NAME}}Module: ModuleType = {
1509
1525
  cronJobs: [],
1510
1526
  events: [],
1511
1527
  };
1512
- `;var Bo=`{
1528
+ `;var Oo=`{
1513
1529
  "name": "@module/{{NAME}}",
1514
1530
  "description": "",
1515
1531
  "version": "0.0.1",
@@ -1518,7 +1534,7 @@ export const {{NAME}}Module: ModuleType = {
1518
1534
  "lint": "tsgo --noEmit && bunx biome lint"
1519
1535
  }
1520
1536
  }
1521
- `;var Po=`import { describe, expect, test } from "bun:test";
1537
+ `;var Do=`import { describe, expect, test } from "bun:test";
1522
1538
  import { {{NAME}}Module } from "@/{{NAME}}Module";
1523
1539
 
1524
1540
  describe("{{NAME}}Module", () => {
@@ -1542,7 +1558,7 @@ describe("{{NAME}}Module", () => {
1542
1558
  expect(Array.isArray({{NAME}}Module.events)).toBe(true);
1543
1559
  });
1544
1560
  });
1545
- `;var Lo=`{
1561
+ `;var Po=`{
1546
1562
  "extends": "../../tsconfig.json",
1547
1563
  "compilerOptions": {
1548
1564
  "types": ["@types/bun"],
@@ -1554,12 +1570,12 @@ describe("{{NAME}}Module", () => {
1554
1570
  "exclude": ["node_modules", "dist"]
1555
1571
  }
1556
1572
  `;class ge{getName(){return"make:module"}getDescription(){return"Generate a new module"}async addToAppModule(e,t,s){let r=await Bun.file(e).text(),o=`${t}Module`,i=`@${s}/${o}`,a=`import { ${o} } from "${i}";
1557
- `,n=r.lastIndexOf("import "),d=r.indexOf(`
1558
- `,n);r=`${r.slice(0,d+1)}${a}${r.slice(d+1)}`;let l=["controllers","entities","middlewares","cronJobs","events"];for(let c of l){let u=new RegExp(`(${c}:\\s*\\[)([^\\]]*)`,"s"),p=r.match(u);if(p){let m=p[2]?.trim(),h=`...${o}.${c}`,f=m?`${m}, ${h}`:h;r=r.replace(u,`$1${f}`)}}await Bun.write(e,r)}async addModuleScope(e,t){let s=await Bun.file(e).text(),r=/("scope-enum":\s*\[\s*RuleConfigSeverity\.Error,\s*"always",\s*\[)([\s\S]*?)(\])/,o=s.match(r);if(o){let i=o[2]?.trim()??"",a=`"${t}"`;if(!i.includes(a)){let n=i?`${i}
1573
+ `,n=r.lastIndexOf("import "),l=r.indexOf(`
1574
+ `,n);r=`${r.slice(0,l+1)}${a}${r.slice(l+1)}`;let d=["controllers","entities","middlewares","cronJobs","events"];for(let c of d){let u=new RegExp(`(${c}:\\s*\\[)([^\\]]*)`,"s"),m=r.match(u);if(m){let p=m[2]?.trim(),h=`...${o}.${c}`,f=p?`${p}, ${h}`:h;r=r.replace(u,`$1${f}`)}}await Bun.write(e,r)}async addModuleScope(e,t){let s=await Bun.file(e).text(),r=/("scope-enum":\s*\[\s*RuleConfigSeverity\.Error,\s*"always",\s*\[)([\s\S]*?)(\])/,o=s.match(r);if(o){let i=o[2]?.trim()??"",a=`"${t}"`;if(!i.includes(a)){let n=i?`${i}
1559
1575
  ${a},`:`
1560
1576
  ${a},`;s=s.replace(r,`$1${n}
1561
1577
  $3`),await Bun.write(e,s)}}}async addPathAlias(e,t){let s=await Bun.file(e).text(),r=JSON.parse(s);r.compilerOptions??={},r.compilerOptions.paths??={},r.compilerOptions.paths[`@${t}/*`]=[`../${t}/src/*`],await Bun.write(e,`${JSON.stringify(r,null,2)}
1562
- `)}async run(e){let{cwd:t=process.cwd(),silent:s=!1,skipMigrations:r=!1,skipSeeds:o=!1}=e,{name:i}=e;if(!i)i=await v({message:"Enter module name"});let a=xl(i).replace(/Module$/,""),n=bl(a),d=P(t,"modules",n),l=P(d,"src"),c=P(d,"tests"),u=Do.replace(/{{NAME}}/g,a),p=Bo.replace(/{{NAME}}/g,n),m=Po.replace(/{{NAME}}/g,a);if(await Bun.write(P(l,`${a}Module.ts`),u),!r)await Bun.write(P(l,"migrations","migrations.ts"),"");if(!o)await Bun.write(P(l,"seeds","seeds.ts"),"");if(await Bun.write(P(d,"package.json"),p),await Bun.write(P(d,"tsconfig.json"),Lo),await Bun.write(P(c,`${a}Module.spec.ts`),m),n!=="app"){let g=P(t,"modules","app","src","AppModule.ts");if(await Bun.file(g).exists())await this.addToAppModule(g,a,n);let y=P(t,"modules","app","tsconfig.json");if(await Bun.file(y).exists())await this.addPathAlias(y,n)}let h=P(t,".commitlintrc.ts");if(await Bun.file(h).exists())await this.addModuleScope(h,n);if(!s)new gl().success(`modules/${n} created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0});await Bun.spawn(["bun","add","@ooneex/module"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}ge=b([x.command()],ge);class ke{getName(){return"make:app"}getDescription(){return"Generate a new application"}async run(e){let{name:t,destination:s}=e;if(!t)t=await v({message:"Enter application name"});let r=El(t);if(!s)s=await no({message:"Enter destination path",initial:r});let o=bo.replace(/{{NAME}}/g,r);await Bun.write(T(s,".commitlintrc.ts"),lo),await Bun.write(T(s,".gitignore"),co),await Bun.write(T(s,"biome.jsonc"),po),await Bun.write(T(s,"bunfig.toml"),uo),await Bun.write(T(s,"nx.json"),go),await Bun.write(T(s,"package.json"),o),await Bun.write(T(s,"README.md"),xo.replace(/{{NAME}}/g,r)),await Bun.write(T(s,"tsconfig.json"),wo),await Bun.write(T(s,".zed","settings.json"),Eo),await new ge().run({name:"app",cwd:s,silent:!0,skipMigrations:!0,skipSeeds:!0});let a=T(s,"modules","app","package.json"),n=await Bun.file(a).json();n.scripts.dev="docker compose up -d && bun --hot run ./src/index.ts",n.scripts.build="bun build ./src/index.ts --outdir ./dist --target bun",await Bun.write(a,JSON.stringify(n,null,2));let d=Ot.replace(/^DATABASE_URL=/m,'DATABASE_URL="postgresql://ooneex:ooneex@localhost:5432/ooneex"').replace(/^CACHE_REDIS_URL=/m,'CACHE_REDIS_URL="redis://localhost:6379"').replace(/^PUBSUB_REDIS_URL=/m,'PUBSUB_REDIS_URL="redis://localhost:6379"').replace(/^RATE_LIMIT_REDIS_URL=/m,'RATE_LIMIT_REDIS_URL="redis://localhost:6379"').replace(/^DATABASE_REDIS_URL=/m,'DATABASE_REDIS_URL="redis://localhost:6379"');await Bun.write(T(s,"modules","app",".env"),d),await Bun.write(T(s,"modules","app",".env.example"),Ot),await Bun.write(T(s,"modules","app","src","databases","AppDatabase.ts"),mo),await Bun.write(T(s,"modules","app","src","index.ts"),yo);let l=Al(t),c=fo.replace(/{{NAME}}/g,l);await Bun.write(T(s,"modules","app","docker-compose.yml"),c);let u=ho.replace(/{{NAME}}/g,l);await Bun.write(T(s,"modules","app","Dockerfile"),u),await Bun.write(T(s,"modules","app","var",".gitkeep"),""),await new ye().run({name:"HealthCheck",isSocket:!1,module:"app",route:{name:"api.health.check",path:"/healthcheck",method:"GET"}}),await Bun.spawn(["git","init"],{cwd:s,stdout:"ignore",stderr:"inherit"}).exited,await Bun.spawn(["bun","add","@ooneex/analytics","@ooneex/app","@ooneex/app-env","@ooneex/auth","@ooneex/cache","@ooneex/container","@ooneex/database","@ooneex/logger","@ooneex/mailer","@ooneex/middleware","@ooneex/module","@ooneex/rate-limit","@ooneex/role","@ooneex/routing","@ooneex/storage","@ooneex/translation","@ooneex/types","@ooneex/user","@ooneex/utils","@ooneex/validation","@ooneex/controller","pg","apache-arrow","reflect-metadata","typeorm"],{cwd:s,stdout:"ignore",stderr:"inherit"}).exited,await Bun.spawn(["bun","add","-D","@biomejs/biome","@commitlint/cli","@commitlint/config-conventional","@commitlint/prompt-cli","@commitlint/types","@nx/js","@nx/workspace","@swc-node/register","@swc/core","@swc/helpers","@types/bun","@types/node","@typescript/native-preview","husky","lint-staged","nx","typescript","undici-types"],{cwd:s,stdout:"ignore",stderr:"inherit"}).exited,await Bun.spawn(["bunx","husky","init"],{cwd:s,stdout:"ignore",stderr:"inherit"}).exited,await Bun.write(T(s,".husky","pre-commit"),"lint-staged"),await Bun.write(T(s,".husky","commit-msg"),'bunx commitlint --edit "$1"'),new wl().success(`${r} created successfully at ${s}`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}ke=b([x.command()],ke);import{join as V}from"path";import{TerminalLogger as Sl}from"@ooneex/logger";import{toPascalCase as Tl}from"@ooneex/utils";var Uo=`import { describe, expect, test } from "bun:test";
1578
+ `)}async run(e){let{cwd:t=process.cwd(),silent:s=!1,skipMigrations:r=!1,skipSeeds:o=!1}=e,{name:i}=e;if(!i)i=await A({message:"Enter module name"});let a=Bd(i).replace(/Module$/,""),n=Id(a),l=P(t,"modules",n),d=P(l,"src"),c=P(l,"tests"),u=Bo.replace(/{{NAME}}/g,a),m=Oo.replace(/{{NAME}}/g,n),p=Do.replace(/{{NAME}}/g,a);if(await Bun.write(P(d,`${a}Module.ts`),u),!r)await Bun.write(P(d,"migrations","migrations.ts"),"");if(!o)await Bun.write(P(d,"seeds","seeds.ts"),"");if(await Bun.write(P(l,"package.json"),m),await Bun.write(P(l,"tsconfig.json"),Po),await Bun.write(P(c,`${a}Module.spec.ts`),p),n!=="app"){let g=P(t,"modules","app","src","AppModule.ts");if(await Bun.file(g).exists())await this.addToAppModule(g,a,n);let y=P(t,"modules","app","tsconfig.json");if(await Bun.file(y).exists())await this.addPathAlias(y,n)}let h=P(t,".commitlintrc.ts");if(await Bun.file(h).exists())await this.addModuleScope(h,n);if(!s)new _d().success(`modules/${n} created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0});await Bun.spawn(["bun","add","@ooneex/module"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}ge=b([x.command()],ge);class Fe{getName(){return"make:app"}getDescription(){return"Generate a new application"}async run(e){let{name:t,destination:s}=e;if(!t)t=await A({message:"Enter application name"});let r=Dd(t);if(!s)s=await no({message:"Enter destination path",initial:r});let o=bo.replace(/{{NAME}}/g,r);await Bun.write(N(s,".commitlintrc.ts"),lo),await Bun.write(N(s,".gitignore"),co),await Bun.write(N(s,"biome.jsonc"),mo),await Bun.write(N(s,"bunfig.toml"),uo),await Bun.write(N(s,"nx.json"),go),await Bun.write(N(s,"package.json"),o),await Bun.write(N(s,"README.md"),xo.replace(/{{NAME}}/g,r)),await Bun.write(N(s,"tsconfig.json"),wo),await Bun.write(N(s,".zed","settings.json"),vo),await new ge().run({name:"app",cwd:s,silent:!0,skipMigrations:!0,skipSeeds:!0});let a=N(s,"modules","app","package.json"),n=await Bun.file(a).json();n.scripts.dev="docker compose up -d && bun --hot run ./src/index.ts",n.scripts.build="bun build ./src/index.ts --outdir ./dist --target bun",await Bun.write(a,JSON.stringify(n,null,2));let l=Ot.replace(/^DATABASE_URL=/m,'DATABASE_URL="postgresql://ooneex:ooneex@localhost:5432/ooneex"').replace(/^CACHE_REDIS_URL=/m,'CACHE_REDIS_URL="redis://localhost:6379"').replace(/^PUBSUB_REDIS_URL=/m,'PUBSUB_REDIS_URL="redis://localhost:6379"').replace(/^RATE_LIMIT_REDIS_URL=/m,'RATE_LIMIT_REDIS_URL="redis://localhost:6379"').replace(/^DATABASE_REDIS_URL=/m,'DATABASE_REDIS_URL="redis://localhost:6379"');await Bun.write(N(s,"modules","app",".env"),l),await Bun.write(N(s,"modules","app",".env.example"),Ot),await Bun.write(N(s,"modules","app","src","databases","AppDatabase.ts"),po),await Bun.write(N(s,"modules","app","src","index.ts"),yo);let d=Pd(t),c=fo.replace(/{{NAME}}/g,d);await Bun.write(N(s,"modules","app","docker-compose.yml"),c);let u=ho.replace(/{{NAME}}/g,d);await Bun.write(N(s,"modules","app","Dockerfile"),u),await Bun.write(N(s,"modules","app","var",".gitkeep"),""),await new ne().run({name:"HealthCheck",isSocket:!1,module:"app",route:{name:"api.health.check",path:"/healthcheck",method:"GET"}}),await Bun.spawn(["git","init"],{cwd:s,stdout:"ignore",stderr:"inherit"}).exited,await Bun.spawn(["bun","add","@ooneex/analytics","@ooneex/app","@ooneex/app-env","@ooneex/auth","@ooneex/cache","@ooneex/container","@ooneex/database","@ooneex/logger","@ooneex/mailer","@ooneex/middleware","@ooneex/module","@ooneex/rate-limit","@ooneex/role","@ooneex/routing","@ooneex/storage","@ooneex/translation","@ooneex/types","@ooneex/user","@ooneex/utils","@ooneex/validation","@ooneex/controller","pg","apache-arrow","reflect-metadata","typeorm"],{cwd:s,stdout:"ignore",stderr:"inherit"}).exited,await Bun.spawn(["bun","add","-D","@biomejs/biome","@commitlint/cli","@commitlint/config-conventional","@commitlint/prompt-cli","@commitlint/types","@nx/js","@nx/workspace","@swc-node/register","@swc/core","@swc/helpers","@types/bun","@types/node","@typescript/native-preview","husky","lint-staged","nx","typescript","undici-types"],{cwd:s,stdout:"ignore",stderr:"inherit"}).exited,await Bun.spawn(["bunx","husky","init"],{cwd:s,stdout:"ignore",stderr:"inherit"}).exited,await Bun.write(N(s,".husky","pre-commit"),"lint-staged"),await Bun.write(N(s,".husky","commit-msg"),'bunx commitlint --edit "$1"'),new Od().success(`${r} created successfully at ${s}`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}Fe=b([x.command()],Fe);import{join as z}from"path";import{TerminalLogger as Ud}from"@ooneex/logger";import{toPascalCase as Gd}from"@ooneex/utils";var Lo=`import { describe, expect, test } from "bun:test";
1563
1579
  import { {{NAME}}Cache } from "@/cache/{{NAME}}Cache";
1564
1580
 
1565
1581
  describe("{{NAME}}Cache", () => {
@@ -1587,7 +1603,7 @@ describe("{{NAME}}Cache", () => {
1587
1603
  expect(typeof {{NAME}}Cache.prototype.has).toBe("function");
1588
1604
  });
1589
1605
  });
1590
- `;var Go=`import { CacheException, decorator } from "@ooneex/cache";
1606
+ `;var ko=`import { CacheException, decorator } from "@ooneex/cache";
1591
1607
  import type { ICache } from "@ooneex/cache";
1592
1608
 
1593
1609
  @decorator.cache()
@@ -1608,7 +1624,7 @@ export class {{NAME}}Cache implements ICache {
1608
1624
  throw new CacheException(\`Failed to check if key "\${key}" exists: Not implemented\`);
1609
1625
  }
1610
1626
  }
1611
- `;class $e{getName(){return"make:cache"}getDescription(){return"Generate a new cache class"}async run(e){let{name:t,module:s}=e;if(!t)t=await v({message:"Enter cache name"});t=Tl(t).replace(/Cache$/,"");let r=Go.replace(/{{NAME}}/g,t),o=s?V("modules",s):".",i=V(o,"src","cache"),a=V(process.cwd(),i),n=V(a,`${t}Cache.ts`);await Bun.write(n,r);let d=Uo.replace(/{{NAME}}/g,t),l=V(o,"tests","cache"),c=V(process.cwd(),l),u=V(c,`${t}Cache.spec.ts`);await Bun.write(u,d);let p=new Sl;p.success(`${V(i,t)}Cache.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),p.success(`${V(l,t)}Cache.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/cache"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}$e=b([x.command()],$e);import{join as We}from"path";import{TerminalLogger as Yl}from"@ooneex/logger";var ko=`---
1627
+ `;class Ke{getName(){return"make:cache"}getDescription(){return"Generate a new cache class"}async run(e){let{name:t,module:s}=e;if(!t)t=await A({message:"Enter cache name"});t=Gd(t).replace(/Cache$/,"");let r=ko.replace(/{{NAME}}/g,t),o=s?z("modules",s):".",i=z(o,"src","cache"),a=z(process.cwd(),i),n=z(a,`${t}Cache.ts`);await Bun.write(n,r);let l=Lo.replace(/{{NAME}}/g,t),d=z(o,"tests","cache"),c=z(process.cwd(),d),u=z(c,`${t}Cache.spec.ts`);await Bun.write(u,l);let m=new Ud;m.success(`${z(i,t)}Cache.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),m.success(`${z(d,t)}Cache.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/cache"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}Ke=b([x.command()],Ke);import{join as He}from"path";import{TerminalLogger as ac}from"@ooneex/logger";var Uo=`---
1612
1628
  name: commit
1613
1629
  description: Create commit messages grouped by module. Analyzes git changes, groups files under modules/ by module name, and creates separate commits following commitlint conventions. Uses common scope for non-module changes.
1614
1630
  ---
@@ -1778,6 +1794,7 @@ Before committing, verify:
1778
1794
  2. Tests pass for modified modules
1779
1795
  3. No debug code or console.logs left in
1780
1796
  4. Commit message follows the format exactly
1797
+ 5. For Entity class, if property is optional, add \`null\` to its type.
1781
1798
 
1782
1799
  ## Handling Special Cases
1783
1800
 
@@ -1800,101 +1817,7 @@ Use \`refactor\` for file reorganization:
1800
1817
  git add modules/product/
1801
1818
  git commit -m "refactor(product): Reorganize service file structure"
1802
1819
  \`\`\`
1803
- `;var $o="---\nname: make:ai\ndescription: Generate a new AI class with its test file, then complete the generated code. Use when creating a new AI chat class that uses OpenAI via the @ooneex/ai package.\n---\n\n# Make AI Class\n\nGenerate a new AI class and its test file using the `make:ai` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the AI class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:ai --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/ai/<Name>Ai.ts` - The AI class file (or `modules/<module>/src/ai/<Name>Ai.ts` with `--module`)\n- `tests/ai/<Name>Ai.spec.ts` - The test file (or `modules/<module>/tests/ai/<Name>Ai.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the AI class\n\nEdit `src/ai/<Name>Ai.ts` to complete the implementation:\n\n- Update the prompt in the `run` method from `\"My prompt\"` to a meaningful prompt based on the class purpose\n- Update the prompt in the `runStream` method from `\"My prompt\"` to a meaningful prompt based on the class purpose\n- Add any additional configuration or methods relevant to the AI class purpose\n- Ensure proper typing for the `run<T>()` generic return type\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { decorator, type IAiChat, OpenAi, type OpenAiConfigType } from \"@ooneex/ai\";\nimport { inject } from \"@ooneex/container\";\n\n@decorator.ai()\nexport class <Name>Ai implements IAiChat<OpenAiConfigType> {\n constructor(@inject(OpenAi) private readonly ai: OpenAi) {}\n\n public async run<T>(prompt?: string, config?: Omit<OpenAiConfigType, \"prompt\">): Promise<T> {\n return this.ai.run<T>(prompt || \"My prompt\", config);\n }\n\n public async *runStream(\n prompt?: string,\n config?: Omit<OpenAiConfigType, \"prompt\" | \"output\">,\n ): AsyncGenerator<string, void, unknown> {\n yield* this.ai.runStream(prompt || \"My prompt\", config);\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/ai/<Name>Ai.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, run method, runStream method)\n- Add tests relevant to the specific AI class behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Ai } from \"@/ai/<Name>Ai\";\n\ndescribe(\"<Name>Ai\", () => {\n test(\"should have class name ending with 'Ai'\", () => {\n expect(<Name>Ai.name.endsWith(\"Ai\")).toBe(true);\n });\n\n test(\"should have 'run' method\", () => {\n expect(<Name>Ai.prototype.run).toBeDefined();\n expect(typeof <Name>Ai.prototype.run).toBe(\"function\");\n });\n\n test(\"should have 'runStream' method\", () => {\n expect(<Name>Ai.prototype.runStream).toBeDefined();\n expect(typeof <Name>Ai.prototype.runStream).toBe(\"function\");\n });\n});\n```\n\n### 5. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/ai/<Name>Ai.ts tests/ai/<Name>Ai.spec.ts\n```\n";var Wo="---\nname: make:analytics\ndescription: Generate a new analytics class with its test file, then complete the generated code. Use when creating a new analytics tracking class that uses the @ooneex/analytics package.\n---\n\n# Make Analytics Class\n\nGenerate a new analytics class and its test file using the `make:analytics` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the analytics class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:analytics --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/analytics/<Name>Analytics.ts` - The analytics class file (or `modules/<module>/src/analytics/<Name>Analytics.ts` with `--module`)\n- `tests/analytics/<Name>Analytics.spec.ts` - The test file (or `modules/<module>/tests/analytics/<Name>Analytics.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the analytics class\n\nEdit `src/analytics/<Name>Analytics.ts` to complete the implementation:\n\n- Implement the `capture` method with actual analytics tracking logic\n- Define a proper type for `CaptureOptionsType` instead of `Record<string, unknown>` based on the analytics purpose\n- Add any additional methods or properties relevant to the analytics class purpose\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { decorator } from \"@ooneex/analytics\";\nimport type { IAnalytics } from \"@ooneex/analytics\";\n\ntype CaptureOptionsType = Record<string, unknown>;\n\n@decorator.analytics()\nexport class <Name>Analytics<T extends CaptureOptionsType = CaptureOptionsType> implements IAnalytics<T> {\n public capture(options: T): void {\n // console.log(\"Analytics captured:\", options);\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/analytics/<Name>Analytics.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, capture method)\n- Add tests relevant to the specific analytics class behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Analytics } from \"@/analytics/<Name>Analytics\";\n\ndescribe(\"<Name>Analytics\", () => {\n test(\"should have class name ending with 'Analytics'\", () => {\n expect(<Name>Analytics.name.endsWith(\"Analytics\")).toBe(true);\n });\n\n test(\"should have 'capture' method\", () => {\n expect(<Name>Analytics.prototype.capture).toBeDefined();\n expect(typeof <Name>Analytics.prototype.capture).toBe(\"function\");\n });\n});\n```\n\n### 5. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/analytics/<Name>Analytics.ts tests/analytics/<Name>Analytics.spec.ts\n```\n";var qo="---\nname: make:cache\ndescription: Generate a new cache adapter class with its test file, then complete the generated code. Use when creating a new cache adapter that implements the ICache interface from @ooneex/cache.\n---\n\n# Make Cache Class\n\nGenerate a new cache class and its test file using the `make:cache` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the cache class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:cache --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/cache/<Name>Cache.ts` - The cache class file (or `modules/<module>/src/cache/<Name>Cache.ts` with `--module`)\n- `tests/cache/<Name>Cache.spec.ts` - The test file (or `modules/<module>/tests/cache/<Name>Cache.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the cache class\n\nEdit `src/cache/<Name>Cache.ts` to complete the implementation:\n\n- Implement the `get` method to retrieve cached values by key\n- Implement the `set` method to store values with optional TTL\n- Implement the `delete` method to remove cached entries\n- Implement the `has` method to check key existence\n- Replace the `CacheException` throws with actual cache logic\n- Inject any required dependencies (e.g., Redis client) via the constructor\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { CacheException, decorator } from \"@ooneex/cache\";\nimport type { ICache } from \"@ooneex/cache\";\n\n@decorator.cache()\nexport class <Name>Cache implements ICache {\n public async get<T = unknown>(key: string): Promise<T | undefined> {\n throw new CacheException(`Failed to get key \"${key}\": Not implemented`);\n }\n\n public async set<T = unknown>(key: string, value: T, ttl?: number): Promise<void> {\n throw new CacheException(`Failed to set key \"${key}\": Not implemented`);\n }\n\n public async delete(key: string): Promise<boolean> {\n throw new CacheException(`Failed to delete key \"${key}\": Not implemented`);\n }\n\n public async has(key: string): Promise<boolean> {\n throw new CacheException(`Failed to check if key \"${key}\" exists: Not implemented`);\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/cache/<Name>Cache.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, get, set, delete, has methods)\n- Add tests relevant to the specific cache class behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Cache } from \"@/cache/<Name>Cache\";\n\ndescribe(\"<Name>Cache\", () => {\n test(\"should have class name ending with 'Cache'\", () => {\n expect(<Name>Cache.name.endsWith(\"Cache\")).toBe(true);\n });\n\n test(\"should have 'get' method\", () => {\n expect(<Name>Cache.prototype.get).toBeDefined();\n expect(typeof <Name>Cache.prototype.get).toBe(\"function\");\n });\n\n test(\"should have 'set' method\", () => {\n expect(<Name>Cache.prototype.set).toBeDefined();\n expect(typeof <Name>Cache.prototype.set).toBe(\"function\");\n });\n\n test(\"should have 'delete' method\", () => {\n expect(<Name>Cache.prototype.delete).toBeDefined();\n expect(typeof <Name>Cache.prototype.delete).toBe(\"function\");\n });\n\n test(\"should have 'has' method\", () => {\n expect(<Name>Cache.prototype.has).toBeDefined();\n expect(typeof <Name>Cache.prototype.has).toBe(\"function\");\n });\n});\n```\n\n### 5. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/cache/<Name>Cache.ts tests/cache/<Name>Cache.spec.ts\n```\n";var Ko="---\nname: make:controller\ndescription: Generate a new controller class with route type and test file, then complete the generated code. Use when creating a new HTTP or WebSocket controller with routing, validation, and role-based access.\n---\n\n# Make Controller Class\n\nGenerate a new controller class, its route type, and test file using the `make:controller` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the controller class and related files:\n\n```bash\nbunx @ooneex/cli@latest make:controller --name <name> --module <module> --is-socket <true|false> --route.name <route.name> --route.path <route.path> --route.method <route.method>\n```\n\nWhere:\n- `<name>` is the controller name provided by the user\n- `--module` is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root\n- `--is-socket` determines HTTP vs WebSocket controller (defaults to `false`)\n- `--route.name` is the route name using dot notation: `<resource>.<action>` (e.g., `user.create`, `book.list`, `flashcard.delete`)\n- `--route.path` is the route path (e.g., `/api/users`)\n- `--route.method` is the HTTP method (e.g., `get`, `post`, `put`, `patch`, `delete`) \u2014 only for HTTP controllers\n\nThe command will generate (paths prefixed with `modules/<module>/` when `--module` is provided):\n- `src/controllers/<Name>Controller.ts` - The controller class file\n- `src/types/routes/<route.name>.ts` - The route type file\n- `tests/controllers/<Name>Controller.spec.ts` - The test file\n\n### 2. Read the generated files\n\nRead all three generated files to understand the scaffolded code.\n\n### 3. Complete the route type\n\nEdit `src/types/routes/<route.name>.ts` to define the route's type contract.\n\n**Add or remove `params`, `payload`, and `queries` based on context:**\n\n- **`params`** \u2014 Include only when the route path contains dynamic segments (e.g., `/api/users/:id`). Remove entirely for routes with no URL parameters (e.g., `/api/users`).\n- **`payload`** \u2014 Include only for methods that accept a request body (`post`, `put`, `patch`). Remove entirely for `get` and `delete` routes.\n- **`queries`** \u2014 Include only when the route supports query string filtering, pagination, or sorting (e.g., list/search endpoints). Remove entirely when not needed.\n- **`response`** \u2014 Always include.\n\nThe generated route type structure follows this pattern (remove unused sections):\n\n```typescript\n// Example: GET /api/users (list) \u2014 no params, no payload, has queries\nexport type <TypeName>RouteType = {\n queries: {\n\n },\n response: {\n\n },\n};\n\n// Example: POST /api/users (create) \u2014 no params, has payload, no queries\nexport type <TypeName>RouteType = {\n payload: {\n\n },\n response: {\n\n },\n};\n\n// Example: GET /api/users/:id (detail) \u2014 has params, no payload, no queries\nexport type <TypeName>RouteType = {\n params: {\n\n },\n response: {\n\n },\n};\n\n// Example: PUT /api/users/:id (update) \u2014 has params, has payload, no queries\nexport type <TypeName>RouteType = {\n params: {\n\n },\n payload: {\n\n },\n response: {\n\n },\n};\n```\n\n### 4. Complete the controller class\n\nEdit `src/controllers/<Name>Controller.ts` to complete the implementation:\n\n- Set appropriate `roles` for access control\n- Add a meaningful `description` for the route that explains what the endpoint does (e.g., `\"Create a new user account\"`, `\"List all books with pagination\"`)\n- Implement the `index` method with actual controller logic\n- Inject any required dependencies (repositories, services) via the constructor\n\n**Add or remove `params`, `payload`, and `queries` in the `@Route` decorator to match the route type (step 3):**\n\n- **`params`** \u2014 Include with `Assert()` validators only when the route has URL parameters. Remove the `params` key entirely otherwise.\n- **`payload`** \u2014 Include with `Assert({...})` only for `post`, `put`, `patch` methods. Remove the `payload` key entirely for `get` and `delete`.\n- **`queries`** \u2014 Include with `Assert({...})` only when query parameters are expected. Remove the `queries` key entirely otherwise.\n- **`response`** \u2014 Always include with `Assert({...})`.\n\n**HTTP controller** generated structure (remove `params`, `payload`, `queries` as needed \u2014 see rules above):\n\n```typescript\nimport type { ContextType } from \"@ooneex/controller\";\nimport { ERole } from \"@ooneex/role\";\nimport { Route } from \"@ooneex/routing\";\nimport { Assert } from \"@ooneex/validation\";\nimport type { <TypeName>RouteType } from \"../types/routes/<route.name>\";\n\n@Route.<method>(\"<route.path>\", {\n name: \"<route.name>\",\n version: 1,\n description: \"\",\n params: {\n // id: Assert(\"string\"),\n },\n payload: Assert({\n\n }),\n queries: Assert({\n\n }),\n response: Assert({\n\n }),\n roles: [ERole.USER],\n})\nexport class <Name>Controller {\n public async index(context: ContextType<<TypeName>RouteType>) {\n // const { id } = context.params;\n\n return context.response.json({\n\n });\n }\n}\n```\n\n**Socket controller** generated structure (remove `params`, `payload`, `queries` as needed \u2014 see rules above):\n\n```typescript\nimport type { ContextType } from \"@ooneex/socket\";\nimport { ERole } from \"@ooneex/role\";\nimport { Route } from \"@ooneex/routing\";\nimport { Assert } from \"@ooneex/validation\";\nimport type { <TypeName>RouteType } from \"../types/routes/<route.name>\";\n\n@Route.socket(\"<route.path>\", {\n name: \"<route.name>\",\n version: 1,\n description: \"\",\n params: {\n // id: Assert(\"string\"),\n },\n payload: Assert({\n\n }),\n queries: Assert({\n\n }),\n response: Assert({\n\n }),\n roles: [ERole.USER],\n})\nexport class <Name>Controller {\n public async index(context: ContextType<<TypeName>RouteType>) {\n // const { id } = context.params;\n\n return context.response.json({\n\n });\n }\n}\n```\n\n### 5. Complete the test file\n\nEdit `tests/controllers/<Name>Controller.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, index method)\n- Add tests relevant to the specific controller behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Controller } from \"@/controllers/<Name>Controller\";\n\ndescribe(\"<Name>Controller\", () => {\n test(\"should have class name ending with 'Controller'\", () => {\n expect(<Name>Controller.name.endsWith(\"Controller\")).toBe(true);\n });\n\n test(\"should have 'index' method\", () => {\n expect(<Name>Controller.prototype.index).toBeDefined();\n expect(typeof <Name>Controller.prototype.index).toBe(\"function\");\n });\n});\n```\n\n### 6. Register the controller in the module\n\nAdd the new controller to the module's `controllers` array in `src/<PascalModuleName>Module.ts` (e.g., `src/BookModule.ts` for the `book` module):\n\n```typescript\nimport type { ModuleType } from \"@ooneex/module\";\nimport { <Name>Controller } from \"./controllers/<Name>Controller\";\n\nexport const <PascalModuleName>Module: ModuleType = {\n controllers: [<Name>Controller],\n entities: [],\n permissions: [],\n middlewares: [],\n cronJobs: [],\n events: [],\n};\n```\n\nThe module file uses PascalCase naming: `<PascalModuleName>Module.ts` with export `<PascalModuleName>Module`.\n\nIf the module already has other controllers registered, append the new controller to the existing `controllers` array and add the import alongside existing imports.\n\n### 7. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/controllers/<Name>Controller.ts src/types/routes/<route.name>.ts tests/controllers/<Name>Controller.spec.ts\n```\n\n### 8. Create the service\n\nAfter the controller is created, generate a service class for the controller's business logic using the `make:service` skill:\n\n```\n/make:service --name <Name>\n```\n\nWhere `<Name>` matches the controller name (e.g., if the controller is `CreateUserController`, the service is `CreateUserService`).\n\n### 9. Create the pubsub event\n\nAfter the service is created, generate a pubsub event class for the controller's domain events using the `make:pubsub` skill:\n\n```\n/make:pubsub --name <Name> --channel <resource>.<action>\n```\n\nWhere:\n- `<Name>` matches the controller name (e.g., if the controller is `CreateUserController`, the event is `CreateUserEvent`)\n- `<resource>.<action>` follows the same dot notation as the route name (e.g., `user.create`, `book.delete`)\n\nOnce the event is created:\n- Inject the **service** into the **event** via the constructor, and call the service's `execute` method from the event's `handler` method.\n- Inject the **event** into the **controller** via the constructor, and publish the event from the controller's `index` method.\n";var Ho="---\nname: make:cron\ndescription: Generate a new cron job class with its test file, then complete the generated code. Use when creating a new scheduled task that extends the Cron base class from @ooneex/cron.\n---\n\n# Make Cron Class\n\nGenerate a new cron class and its test file using the `make:cron` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the cron class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:cron --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/cron/<Name>Cron.ts` - The cron class file (or `modules/<module>/src/cron/<Name>Cron.ts` with `--module`)\n- `tests/cron/<Name>Cron.spec.ts` - The test file (or `modules/<module>/tests/cron/<Name>Cron.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the cron class\n\nEdit `src/cron/<Name>Cron.ts` to complete the implementation:\n\n- Set the appropriate cron schedule in `getTime()` (e.g., `\"every 5 minutes\"`, `\"every 1 hours\"`, `\"every 30 seconds\"`)\n- Set the timezone in `getTimeZone()` if needed, or keep `null` for server timezone\n- Implement the `handler()` method with the actual cron job logic\n- Inject any required dependencies via the constructor\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport type { TimeZoneType } from \"@ooneex/country\";\nimport type { CronTimeType } from \"@ooneex/cron\";\nimport { Cron, decorator } from \"@ooneex/cron\";\n\n@decorator.cron()\nexport class <Name>Cron extends Cron {\n public getTime(): CronTimeType {\n // Examples: \"every 5 minutes\", \"every 1 hours\", \"every 30 seconds\"\n return \"every 1 hours\";\n }\n\n public getTimeZone(): TimeZoneType | null {\n // Return null to use server timezone, or specify a timezone like \"Europe/Paris\"\n return null;\n }\n\n public async handler(): Promise<void> {\n // Implement your cron handler logic here\n // console.log(\"<Name>Cron handler executed\");\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/cron/<Name>Cron.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, getTime, getTimeZone, handler methods)\n- Add tests relevant to the specific cron class behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Cron } from \"@/cron/<Name>Cron\";\n\ndescribe(\"<Name>Cron\", () => {\n test(\"should have class name ending with 'Cron'\", () => {\n expect(<Name>Cron.name.endsWith(\"Cron\")).toBe(true);\n });\n\n test(\"should have 'getTime' method\", () => {\n expect(<Name>Cron.prototype.getTime).toBeDefined();\n expect(typeof <Name>Cron.prototype.getTime).toBe(\"function\");\n });\n\n test(\"should have 'getTimeZone' method\", () => {\n expect(<Name>Cron.prototype.getTimeZone).toBeDefined();\n expect(typeof <Name>Cron.prototype.getTimeZone).toBe(\"function\");\n });\n\n test(\"should have 'handler' method\", () => {\n expect(<Name>Cron.prototype.handler).toBeDefined();\n expect(typeof <Name>Cron.prototype.handler).toBe(\"function\");\n });\n});\n```\n\n### 5. Register the cron job in the module\n\nAdd the new cron job to the module's `cronJobs` array in `src/<PascalModuleName>Module.ts` (e.g., `src/BookModule.ts` for the `book` module):\n\n```typescript\nimport type { ModuleType } from \"@ooneex/module\";\nimport { <Name>Cron } from \"./cron/<Name>Cron\";\n\nexport const <PascalModuleName>Module: ModuleType = {\n controllers: [],\n entities: [],\n permissions: [],\n middlewares: [],\n cronJobs: [<Name>Cron],\n events: [],\n};\n```\n\nThe module file uses PascalCase naming: `<PascalModuleName>Module.ts` with export `<PascalModuleName>Module`.\n\nIf the module already has other cron jobs registered, append the new cron job to the existing `cronJobs` array and add the import alongside existing imports.\n\n### 6. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/cron/<Name>Cron.ts tests/cron/<Name>Cron.spec.ts\n```\n";var Fo="---\nname: make:database\ndescription: Generate a new database class with its test file, then complete the generated code. Use when creating a new database adapter that extends TypeormDatabase from @ooneex/database.\n---\n\n# Make Database Class\n\nGenerate a new database class and its test file using the `make:database` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the database class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:database --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/databases/<Name>Database.ts` - The database class file (or `modules/<module>/src/databases/<Name>Database.ts` with `--module`)\n- `tests/databases/<Name>Database.spec.ts` - The test file (or `modules/<module>/tests/databases/<Name>Database.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the database class\n\nEdit `src/databases/<Name>Database.ts` to complete the implementation:\n\n- Add entity imports and register them in the `entities` array\n- Adjust the database path if needed (default is `\"var/db\"`)\n- Configure DataSource options as appropriate (type, synchronize, etc.)\n- Inject any required dependencies via the constructor\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { DataSource } from \"typeorm\";\nimport { TypeormDatabase, DatabaseException, decorator } from \"@ooneex/database\";\n\n@decorator.database()\nexport class <Name>Database extends TypeormDatabase {\n public getSource(database?: string): DataSource {\n database = database || \"var/db\";\n\n this.source = new DataSource({\n synchronize: false,\n entities: [\n // TODO: Load your entities here\n ],\n enableWAL: true,\n busyErrorRetry: 2000,\n busyTimeout: 30_000,\n database,\n type: \"sqlite\",\n });\n\n return this.source;\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/databases/<Name>Database.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, getSource method)\n- Add tests relevant to the specific database class behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Database } from \"@/databases/<Name>Database\";\n\ndescribe(\"<Name>Database\", () => {\n test(\"should have class name ending with 'Database'\", () => {\n expect(<Name>Database.name.endsWith(\"Database\")).toBe(true);\n });\n\n test(\"should have 'getSource' method\", () => {\n expect(<Name>Database.prototype.getSource).toBeDefined();\n expect(typeof <Name>Database.prototype.getSource).toBe(\"function\");\n });\n});\n```\n\n### 5. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/databases/<Name>Database.ts tests/databases/<Name>Database.spec.ts\n```\n";var Vo="---\nname: make:entity\ndescription: Generate a new TypeORM entity class with its test file, then complete the generated code. Use when creating a new database entity with columns, relations, and table mapping.\n---\n\n# Make Entity Class\n\nGenerate a new entity class and its test file using the `make:entity` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the entity class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:entity --name <name> --module <module> --table-name <table_name>\n```\n\nWhere `<name>` is the name provided by the user. The `--table-name` option is optional \u2014 if omitted, it defaults to the snake_case pluralized form of the name (e.g., `UserProfile` becomes `user_profiles`). The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/entities/<Name>Entity.ts` - The entity class file (or `modules/<module>/src/entities/<Name>Entity.ts` with `--module`)\n- `tests/entities/<Name>Entity.spec.ts` - The test file (or `modules/<module>/tests/entities/<Name>Entity.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the entity class\n\nEdit `src/entities/<Name>Entity.ts` to complete the implementation:\n\n- Add entity-specific columns with appropriate TypeORM decorators (`@Column`)\n- Add relations if needed (`@ManyToOne`, `@OneToMany`, `@ManyToMany`, etc.)\n- Remove any scaffolded columns that are not relevant to the entity\n- Adjust column types, lengths, and constraints as needed\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport type { LocaleType } from \"@ooneex/translation\";\nimport { random } from \"@ooneex/utils\";\nimport { Column, CreateDateColumn, DeleteDateColumn, PrimaryColumn, UpdateDateColumn } from \"typeorm\";\n\n@Entity({\n name: \"<table_name>\",\n})\nexport class <Name>Entity extends BaseEntity {\n @PrimaryColumn({ name: \"id\", type: \"varchar\", length: 25 })\n id: string = random.nanoid(25);\n\n @Column({\n name: \"is_locked\",\n type: \"boolean\",\n default: false,\n nullable: true,\n })\n isLocked?: boolean;\n\n @Column({ name: \"locked_at\", type: \"timestamptz\", nullable: true })\n lockedAt?: Date;\n\n @Column({\n name: \"is_blocked\",\n type: \"boolean\",\n default: false,\n nullable: true,\n })\n isBlocked?: boolean;\n\n @Column({ name: \"blocked_at\", type: \"timestamptz\", nullable: true })\n blockedAt?: Date;\n\n @Column({ name: \"block_reason\", type: \"text\", nullable: true })\n blockReason?: string;\n\n @Column({ name: \"is_public\", type: \"boolean\", default: true, nullable: true })\n isPublic?: boolean;\n\n @Column({ name: \"lang\", type: \"varchar\", length: 10, nullable: true })\n lang?: LocaleType;\n\n @CreateDateColumn({ name: \"created_at\" })\n createdAt?: Date;\n\n @UpdateDateColumn({ name: \"updated_at\" })\n updatedAt?: Date;\n\n @DeleteDateColumn({ name: \"deleted_at\" })\n deletedAt?: Date;\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/entities/<Name>Entity.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, id, default columns)\n- Add tests for any new entity-specific columns and relations\n- Update tests if scaffolded columns were removed\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Entity } from \"@/entities/<Name>Entity\";\n\ndescribe(\"<Name>Entity\", () => {\n test(\"should have class name ending with 'Entity'\", () => {\n expect(<Name>Entity.name.endsWith(\"Entity\")).toBe(true);\n });\n\n test(\"should have 'id' property with default nanoid\", () => {\n const entity = new <Name>Entity();\n expect(entity.id).toBeDefined();\n expect(typeof entity.id).toBe(\"string\");\n expect(entity.id.length).toBe(25);\n });\n\n test(\"should have 'isLocked' property\", () => {\n const entity = new <Name>Entity();\n expect(\"isLocked\" in entity).toBe(true);\n });\n\n // ... additional property tests\n});\n```\n\n### 5. Register the entity in the module\n\nAdd the new entity to the module's `entities` array in `src/<PascalModuleName>Module.ts` (e.g., `src/BookModule.ts` for the `book` module):\n\n```typescript\nimport type { ModuleType } from \"@ooneex/module\";\nimport { <Name>Entity } from \"./entities/<Name>Entity\";\n\nexport const <PascalModuleName>Module: ModuleType = {\n controllers: [],\n entities: [<Name>Entity],\n permissions: [],\n middlewares: [],\n cronJobs: [],\n events: [],\n};\n```\n\nThe module file uses PascalCase naming: `<PascalModuleName>Module.ts` with export `<PascalModuleName>Module`.\n\nIf the module already has other entities registered, append the new entity to the existing `entities` array and add the import alongside existing imports.\n\n### 6. Create a migration for the entity\n\nAfter creating or updating an entity, generate a migration to apply the corresponding schema changes to the database.\n\nRun the generator:\n\n```bash\nbunx @ooneex/cli@latest make:migration\n```\n\nThen read the generated migration file in `src/migrations/` and complete it:\n\n- In the `up` method, write the SQL to create the table (or alter it if updating an existing entity). Include all columns, types, constraints, defaults, and indexes matching the entity definition.\n- In the `down` method, write the reverse SQL to undo the changes (e.g., `DROP TABLE` or `ALTER TABLE DROP COLUMN`).\n- If the migration depends on another migration (e.g., a foreign key referencing another table), add that migration class to the `getDependencies()` return array.\n\nExample `up` method for a new entity:\n\n```typescript\npublic async up(tx: TransactionSQL): Promise<void> {\n await tx`\n CREATE TABLE IF NOT EXISTS <table_name> (\n id VARCHAR(25) PRIMARY KEY,\n is_locked BOOLEAN DEFAULT false,\n locked_at TIMESTAMPTZ,\n is_blocked BOOLEAN DEFAULT false,\n blocked_at TIMESTAMPTZ,\n block_reason TEXT,\n is_public BOOLEAN DEFAULT true,\n lang VARCHAR(10),\n created_at TIMESTAMPTZ DEFAULT NOW(),\n updated_at TIMESTAMPTZ DEFAULT NOW(),\n deleted_at TIMESTAMPTZ\n )\n `;\n}\n```\n\n### 7. Create a repository for the entity\n\nAfter creating the entity, generate a repository to handle database operations for it.\n\nRun the generator:\n\n```bash\nbunx @ooneex/cli@latest make:repository --name <name>\n```\n\nWhere `<name>` is the same name used for the entity. The command will generate:\n- `src/repositories/<Name>Repository.ts` - The repository class\n- `tests/repositories/<Name>Repository.spec.ts` - The test file\n\nThen read the generated files and complete the repository implementation:\n\n- Adjust search fields in the `find()` method to match the entity's searchable columns\n- Customize relations loading in `findOne`/`findOneBy` if the entity has relations\n- Add any domain-specific methods relevant to the entity\n- Remove methods that don't apply to the entity\n- Update tests to match the final repository methods\n\n### 8. Lint and format\n\nRun linting and formatting on all generated files:\n\n```bash\nbunx biome check --fix src/entities/<Name>Entity.ts tests/entities/<Name>Entity.spec.ts src/repositories/<Name>Repository.ts tests/repositories/<Name>Repository.spec.ts src/migrations/\n```\n";var Yo="---\nname: make:logger\ndescription: Generate a new logger class with its test file, then complete the generated code. Use when creating a new logger that implements the ILogger interface from @ooneex/logger.\n---\n\n# Make Logger Class\n\nGenerate a new logger class and its test file using the `make:logger` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the logger class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:logger --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/loggers/<Name>Logger.ts` - The logger class file (or `modules/<module>/src/loggers/<Name>Logger.ts` with `--module`)\n- `tests/loggers/<Name>Logger.spec.ts` - The test file (or `modules/<module>/tests/loggers/<Name>Logger.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the logger class\n\nEdit `src/loggers/<Name>Logger.ts` to complete the implementation:\n\n- Implement the `init()` method to set up the logger (e.g., open file handles, configure transports)\n- Implement `log`, `debug`, `info`, `success`, `warn`, and `error` methods with actual logging logic\n- Inject any required dependencies via the constructor\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport type { IException } from \"@ooneex/exception\";\nimport type { ILogger } from \"@ooneex/logger\";\nimport type { ScalarType } from \"@ooneex/types\";\nimport { decorator } from \"@ooneex/logger\";\n\n@decorator.logger()\nexport class <Name>Logger implements ILogger {\n public async init(): Promise<void> {\n // Initialize your logger here\n }\n\n public log(message: string, data?: Record<string, ScalarType>): void {\n // Handle general logging\n }\n\n public debug(message: string, data?: Record<string, ScalarType>): void {\n // Handle debug logging\n }\n\n public info(message: string, data?: Record<string, ScalarType>): void {\n // Handle info logging\n }\n\n public success(message: string, data?: Record<string, ScalarType>): void {\n // Handle success logging\n }\n\n public warn(message: string, data?: Record<string, ScalarType>): void {\n // Handle warning logging\n }\n\n public error(message: string | IException, data?: Record<string, ScalarType>): void {\n // Handle error logging\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/loggers/<Name>Logger.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, init, log, debug, info, success, warn, error methods)\n- Add tests relevant to the specific logger class behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Logger } from \"@/loggers/<Name>Logger\";\n\ndescribe(\"<Name>Logger\", () => {\n test(\"should have class name ending with 'Logger'\", () => {\n expect(<Name>Logger.name.endsWith(\"Logger\")).toBe(true);\n });\n\n test(\"should have 'init' method\", () => {\n expect(<Name>Logger.prototype.init).toBeDefined();\n expect(typeof <Name>Logger.prototype.init).toBe(\"function\");\n });\n\n test(\"should have 'log' method\", () => {\n expect(<Name>Logger.prototype.log).toBeDefined();\n expect(typeof <Name>Logger.prototype.log).toBe(\"function\");\n });\n\n test(\"should have 'debug' method\", () => {\n expect(<Name>Logger.prototype.debug).toBeDefined();\n expect(typeof <Name>Logger.prototype.debug).toBe(\"function\");\n });\n\n test(\"should have 'info' method\", () => {\n expect(<Name>Logger.prototype.info).toBeDefined();\n expect(typeof <Name>Logger.prototype.info).toBe(\"function\");\n });\n\n test(\"should have 'success' method\", () => {\n expect(<Name>Logger.prototype.success).toBeDefined();\n expect(typeof <Name>Logger.prototype.success).toBe(\"function\");\n });\n\n test(\"should have 'warn' method\", () => {\n expect(<Name>Logger.prototype.warn).toBeDefined();\n expect(typeof <Name>Logger.prototype.warn).toBe(\"function\");\n });\n\n test(\"should have 'error' method\", () => {\n expect(<Name>Logger.prototype.error).toBeDefined();\n expect(typeof <Name>Logger.prototype.error).toBe(\"function\");\n });\n});\n```\n\n### 5. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/loggers/<Name>Logger.ts tests/loggers/<Name>Logger.spec.ts\n```\n";var zo="---\nname: make:mailer\ndescription: Generate a new mailer class with its template and test files, then complete the generated code. Use when creating a new email sender with JSX template using @ooneex/mailer.\n---\n\n# Make Mailer Class\n\nGenerate a new mailer class, its JSX template, and test files using the `make:mailer` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the mailer class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:mailer --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate (paths prefixed with `modules/<module>/` when `--module` is provided):\n- `src/mailers/<Name>Mailer.ts` - The mailer class file\n- `src/mailers/<Name>MailerTemplate.tsx` - The JSX email template\n- `tests/mailers/<Name>Mailer.spec.ts` - The mailer test file\n- `tests/mailers/<Name>MailerTemplate.spec.ts` - The template test file\n\n### 2. Read the generated files\n\nRead all four generated files to understand the scaffolded code.\n\n### 3. Complete the mailer class\n\nEdit `src/mailers/<Name>Mailer.ts` to complete the implementation:\n\n- Adjust the `send` method config type if additional parameters are needed\n- Add any pre-send logic (validation, data transformation, etc.)\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { inject } from \"@ooneex/container\";\nimport type { IMailer } from \"@ooneex/mailer\";\nimport { type <Name>MailerPropsType, <Name>MailerTemplate } from \"./<Name>MailerTemplate\";\n\nexport class <Name>Mailer implements IMailer {\n constructor(\n @inject(\"mailer\")\n private readonly mailer: IMailer,\n ) {}\n\n public send = async (config: {\n to: string[];\n subject: string;\n from?: { name: string; address: string };\n data?: <Name>MailerPropsType;\n }): Promise<void> => {\n const { data, ...rest } = config;\n\n await this.mailer.send({\n ...rest,\n content: <Name>MailerTemplate(data),\n });\n };\n}\n```\n\n### 4. Complete the mailer template\n\nEdit `src/mailers/<Name>MailerTemplate.tsx` to complete the implementation:\n\n- Update `<Name>MailerPropsType` with the actual props needed for the email\n- Build the email body using `MailerLayout` components (Header, Body, Footer)\n- Add email content, styling, and dynamic data rendering\n\nThe generated template structure follows this pattern:\n\n```tsx\nimport { MailerLayout } from \"@ooneex/mailer\";\n\nexport type <Name>MailerPropsType = {\n link: string;\n};\n\nexport const <Name>MailerTemplate = (props?: <Name>MailerPropsType) => (\n <MailerLayout>\n <MailerLayout.Header />\n <MailerLayout.Body>\n <a href={props?.link}>Login</a>\n </MailerLayout.Body>\n <MailerLayout.Footer />\n </MailerLayout>\n);\n```\n\n### 5. Complete the test files\n\nEdit `tests/mailers/<Name>Mailer.spec.ts` and `tests/mailers/<Name>MailerTemplate.spec.ts` to add meaningful tests beyond the scaffolded ones.\n\n### 6. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/mailers/<Name>Mailer.ts src/mailers/<Name>MailerTemplate.tsx tests/mailers/<Name>Mailer.spec.ts tests/mailers/<Name>MailerTemplate.spec.ts\n```\n";var Zo="---\nname: make:middleware\ndescription: Generate a new middleware class with its test file, then complete the generated code. Use when creating a new HTTP or WebSocket middleware that implements IMiddleware from @ooneex/middleware.\n---\n\n# Make Middleware Class\n\nGenerate a new middleware class and its test file using the `make:middleware` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the middleware class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:middleware --name <name> --module <module> --is-socket <true|false>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The `--is-socket` option determines whether to generate an HTTP middleware or a WebSocket middleware (defaults to `false` if omitted). The command will generate:\n- `src/middlewares/<Name>Middleware.ts` - The middleware class file (or `modules/<module>/src/middlewares/<Name>Middleware.ts` with `--module`)\n- `tests/middlewares/<Name>Middleware.spec.ts` - The test file (or `modules/<module>/tests/middlewares/<Name>Middleware.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the middleware class\n\nEdit `src/middlewares/<Name>Middleware.ts` to complete the implementation:\n\n- Implement the `handler` method with actual middleware logic\n- Add request/response transformations, authentication checks, logging, etc.\n- Inject any required dependencies via the constructor\n\n**HTTP middleware** generated structure:\n\n```typescript\nimport type { ContextType } from \"@ooneex/controller\";\nimport { decorator, type IMiddleware } from \"@ooneex/middleware\";\n\n@decorator.middleware()\nexport class <Name>Middleware implements IMiddleware {\n public async handler(context: ContextType): Promise<ContextType> {\n // Example: Add custom header\n // context.response.header(\"X-Custom-Header\", \"value\");\n\n return context\n }\n}\n```\n\n**Socket middleware** generated structure:\n\n```typescript\nimport type { ContextType } from \"@ooneex/socket\";\nimport { decorator, type IMiddleware } from \"@ooneex/middleware\";\n\n@decorator.middleware()\nexport class <Name>Middleware implements IMiddleware {\n public async handler(context: ContextType): Promise<ContextType> {\n // Example: Add custom header\n // context.response.header(\"X-Custom-Header\", \"value\");\n\n return context\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/middlewares/<Name>Middleware.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, handler method)\n- Add tests relevant to the specific middleware behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Middleware } from \"@/middlewares/<Name>Middleware\";\n\ndescribe(\"<Name>Middleware\", () => {\n test(\"should have class name ending with 'Middleware'\", () => {\n expect(<Name>Middleware.name.endsWith(\"Middleware\")).toBe(true);\n });\n\n test(\"should have 'handler' method\", () => {\n expect(<Name>Middleware.prototype.handler).toBeDefined();\n expect(typeof <Name>Middleware.prototype.handler).toBe(\"function\");\n });\n});\n```\n\n### 5. Register the middleware in the module\n\nAdd the new middleware to the module's `middlewares` array in `src/<PascalModuleName>Module.ts` (e.g., `src/BookModule.ts` for the `book` module):\n\n```typescript\nimport type { ModuleType } from \"@ooneex/module\";\nimport { <Name>Middleware } from \"./middlewares/<Name>Middleware\";\n\nexport const <PascalModuleName>Module: ModuleType = {\n controllers: [],\n entities: [],\n permissions: [],\n middlewares: [<Name>Middleware],\n cronJobs: [],\n events: [],\n};\n```\n\nThe module file uses PascalCase naming: `<PascalModuleName>Module.ts` with export `<PascalModuleName>Module`.\n\nIf the module already has other middlewares registered, append the new middleware to the existing `middlewares` array and add the import alongside existing imports.\n\n### 6. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/middlewares/<Name>Middleware.ts tests/middlewares/<Name>Middleware.spec.ts\n```\n";var Qo="---\nname: make:migration\ndescription: Generate a new database migration file, then complete the generated code. Use when creating a new database migration for schema changes using @ooneex/migrations.\n---\n\n# Make Migration\n\nGenerate a new migration file using the `make:migration` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the migration file:\n\n```bash\nbunx @ooneex/cli@latest make:migration --module <module>\n```\n\nThe `--module` option is optional \u2014 if provided, the migration file is generated under `modules/<module>/src/migrations/` instead of `src/migrations/`. The command will:\n- Generate a timestamped migration file in `src/migrations/` (or `modules/<module>/src/migrations/` with `--module`)\n- Add a `migration:up` script to `package.json` if not already present\n\n### 2. Read the generated file\n\nRead the generated migration file in `src/migrations/` to understand the scaffolded code.\n\n### 3. Complete the migration\n\nEdit the generated migration file to implement:\n\n- The `up` method with the schema changes (create tables, add columns, create indexes, etc.)\n- The `down` method with the reverse operations to undo the migration\n\n### 4. Lint and format\n\nRun linting and formatting on the generated file:\n\n```bash\nbunx biome check --fix src/migrations/\n```\n";var Xo="---\nname: make:permission\ndescription: Generate a new permission class with its test file, then complete the generated code. Use when creating a new permission that extends Permission from @ooneex/permission.\n---\n\n# Make Permission Class\n\nGenerate a new permission class and its test file using the `make:permission` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the permission class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:permission --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/permissions/<Name>Permission.ts` - The permission class file (or `modules/<module>/src/permissions/<Name>Permission.ts` with `--module`)\n- `tests/permissions/<Name>Permission.spec.ts` - The test file (or `modules/<module>/tests/permissions/<Name>Permission.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the permission class\n\nEdit `src/permissions/<Name>Permission.ts` to complete the implementation:\n\n- Implement the `allow()` method with permission rules using `this.ability.can()`\n- Implement the `setUserPermissions()` method with role-based permission logic\n- Define which actions (read, create, update, delete, manage) are allowed on which entities\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { decorator, Permission } from \"@ooneex/permission\";\nimport type { IUser } from \"@ooneex/user\";\n\n@decorator.permission()\nexport class <Name>Permission extends Permission {\n public allow(): this {\n // Example: Add permissions using this.ability.can()\n // this.ability.can(\"read\", \"YourEntity\");\n // this.ability.can([\"read\", \"update\"], \"YourEntity\", { userId: user.id });\n\n return this;\n }\n\n public setUserPermissions(user: IUser | null): this {\n if (!user) {\n return this;\n }\n\n // Example: Grant full access to admins\n // const { roles } = user;\n // if (roles.includes(ERole.ADMIN)) {\n // this.ability.can(\"manage\", \"all\");\n // return this;\n // }\n\n // Example: Grant specific permissions based on roles\n // for (const role of roles) {\n // if (role === ERole.USER) {\n // this.ability.can([\"read\", \"update\"], \"YourEntity\", { userId: user.id });\n // }\n //\n // if (role === ERole.GUEST) {\n // this.ability.can(\"read\", \"YourEntity\", { public: true });\n // }\n // }\n\n return this;\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/permissions/<Name>Permission.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, extends Permission, allow, setUserPermissions methods)\n- Add tests relevant to the specific permission rules\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { Permission } from \"@ooneex/permission\";\nimport { <Name>Permission } from \"@/permissions/<Name>Permission\";\n\ndescribe(\"<Name>Permission\", () => {\n test(\"should have class name ending with 'Permission'\", () => {\n expect(<Name>Permission.name.endsWith(\"Permission\")).toBe(true);\n });\n\n test(\"should extend Permission\", () => {\n const permission = new <Name>Permission();\n expect(permission).toBeInstanceOf(Permission);\n });\n\n test(\"should have 'allow' method\", () => {\n expect(<Name>Permission.prototype.allow).toBeDefined();\n expect(typeof <Name>Permission.prototype.allow).toBe(\"function\");\n });\n\n test(\"should have 'setUserPermissions' method\", () => {\n expect(<Name>Permission.prototype.setUserPermissions).toBeDefined();\n expect(typeof <Name>Permission.prototype.setUserPermissions).toBe(\"function\");\n });\n});\n```\n\n### 5. Register the permission in the module\n\nAdd the new permission to the module's `permissions` array in `src/<PascalModuleName>Module.ts` (e.g., `src/BookModule.ts` for the `book` module):\n\n```typescript\nimport type { ModuleType } from \"@ooneex/module\";\nimport { <Name>Permission } from \"./permissions/<Name>Permission\";\n\nexport const <PascalModuleName>Module: ModuleType = {\n controllers: [],\n entities: [],\n permissions: [<Name>Permission],\n middlewares: [],\n cronJobs: [],\n events: [],\n};\n```\n\nThe module file uses PascalCase naming: `<PascalModuleName>Module.ts` with export `<PascalModuleName>Module`.\n\nIf the module already has other permissions registered, append the new permission to the existing `permissions` array and add the import alongside existing imports.\n\n### 6. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/permissions/<Name>Permission.ts tests/permissions/<Name>Permission.spec.ts\n```\n";var Jo="---\nname: make:pubsub\ndescription: Generate a new PubSub event class with its test file, then complete the generated code. Use when creating a new publish/subscribe event that extends PubSub from @ooneex/pub-sub.\n---\n\n# Make PubSub Event Class\n\nGenerate a new PubSub event class and its test file using the `make:pubsub` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the PubSub event class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:pubsub --name <name> --module <module> --channel <channel>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The `--channel` option is optional \u2014 if omitted, it defaults to the kebab-case form of the name (e.g., `UserCreated` becomes `user-created`). The command will generate:\n- `src/events/<Name>Event.ts` - The event class file (or `modules/<module>/src/events/<Name>Event.ts` with `--module`)\n- `tests/events/<Name>Event.spec.ts` - The test file (or `modules/<module>/tests/events/<Name>Event.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the PubSub event class\n\nEdit `src/events/<Name>Event.ts` to complete the implementation:\n\n- Define a proper data type instead of `Record<string, ScalarType>` for the event payload\n- Implement the `handler()` method with actual event handling logic\n- Set the appropriate channel name in `getChannel()`\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { inject } from \"@ooneex/container\";\nimport type { ScalarType } from \"@ooneex/types\";\nimport { decorator, PubSub, RedisPubSub } from \"@ooneex/pub-sub\";\n\n@decorator.pubSub()\nexport class <Name>Event<Data extends Record<string, ScalarType> = Record<string, ScalarType>> extends PubSub<Data> {\n constructor(\n @inject(RedisPubSub)\n client: RedisPubSub<Data>,\n ) {\n super(client);\n }\n\n public getChannel(): string {\n return \"<channel>\";\n }\n\n public async handler(context: { data: Data; channel: string }): Promise<void> {\n console.log(context);\n // TODO: Implement handler logic here\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/events/<Name>Event.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, getChannel, handler, publish, subscribe, unsubscribe, unsubscribeAll methods)\n- Add tests relevant to the specific event behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>PubSub } from \"@/pubsub/<Name>PubSub\";\n\ndescribe(\"<Name>PubSub\", () => {\n test(\"should have class name ending with 'PubSub'\", () => {\n expect(<Name>PubSub.name.endsWith(\"PubSub\")).toBe(true);\n });\n\n test(\"should have 'getChannel' method\", () => {\n expect(<Name>PubSub.prototype.getChannel).toBeDefined();\n expect(typeof <Name>PubSub.prototype.getChannel).toBe(\"function\");\n });\n\n test(\"should have 'handler' method\", () => {\n expect(<Name>PubSub.prototype.handler).toBeDefined();\n expect(typeof <Name>PubSub.prototype.handler).toBe(\"function\");\n });\n\n test(\"should have 'publish' method\", () => {\n expect(<Name>PubSub.prototype.publish).toBeDefined();\n expect(typeof <Name>PubSub.prototype.publish).toBe(\"function\");\n });\n\n test(\"should have 'subscribe' method\", () => {\n expect(<Name>PubSub.prototype.subscribe).toBeDefined();\n expect(typeof <Name>PubSub.prototype.subscribe).toBe(\"function\");\n });\n\n test(\"should have 'unsubscribe' method\", () => {\n expect(<Name>PubSub.prototype.unsubscribe).toBeDefined();\n expect(typeof <Name>PubSub.prototype.unsubscribe).toBe(\"function\");\n });\n\n test(\"should have 'unsubscribeAll' method\", () => {\n expect(<Name>PubSub.prototype.unsubscribeAll).toBeDefined();\n expect(typeof <Name>PubSub.prototype.unsubscribeAll).toBe(\"function\");\n });\n});\n```\n\n### 5. Register the event in the module\n\nAdd the new event to the module's `events` array in `src/<PascalModuleName>Module.ts` (e.g., `src/BookModule.ts` for the `book` module):\n\n```typescript\nimport type { ModuleType } from \"@ooneex/module\";\nimport { <Name>Event } from \"./events/<Name>Event\";\n\nexport const <PascalModuleName>Module: ModuleType = {\n controllers: [],\n entities: [],\n permissions: [],\n middlewares: [],\n cronJobs: [],\n events: [<Name>Event],\n};\n```\n\nThe module file uses PascalCase naming: `<PascalModuleName>Module.ts` with export `<PascalModuleName>Module`.\n\nIf the module already has other events registered, append the new event to the existing `events` array and add the import alongside existing imports.\n\n### 6. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/events/<Name>Event.ts tests/events/<Name>Event.spec.ts\n```\n";var jo="---\nname: make:repository\ndescription: Generate a new repository class with its test file, then complete the generated code. Use when creating a new TypeORM repository for database operations on an entity.\n---\n\n# Make Repository Class\n\nGenerate a new repository class and its test file using the `make:repository` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the repository class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:repository --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/repositories/<Name>Repository.ts` - The repository class file (or `modules/<module>/src/repositories/<Name>Repository.ts` with `--module`)\n- `tests/repositories/<Name>Repository.spec.ts` - The test file (or `modules/<module>/tests/repositories/<Name>Repository.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the repository class\n\nEdit `src/repositories/<Name>Repository.ts` to complete the implementation:\n\n- Verify the entity import path matches the actual entity location\n- Adjust the `find` method's search fields (default searches `name` with `ILike`)\n- Customize relations loading in `findOne`/`findOneBy` if needed\n\n#### Adding methods\n\nLook at the entity's fields, relations, and business context to determine if custom domain-specific methods are needed. For example:\n- A `SessionRepository` might need `revokeSession(sessionId: string)` and `revokeAllUserSessions(userId: string)`\n- A `NotificationRepository` might need `markAsRead(id: string)` and `markAllAsRead(userId: string)`\n- Entities with status fields may need methods like `archive(id: string)` or `activate(id: string)`\n\nRead related entities, services, or actions in the module to understand what operations the repository should support, then add the appropriate methods.\n\n#### Removing methods\n\nRemove scaffolded methods that don't make sense for the entity's context:\n- Remove `createMany`/`updateMany` if the entity is always managed individually (e.g., user profiles, settings)\n- Remove `delete` if the entity uses soft deletes only (use a custom `softDelete` or `archive` method instead)\n- Remove `find` if the entity is only ever accessed by ID or specific criteria (e.g., singleton config entities)\n- Remove `count` if there's no use case for counting records of this entity\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { inject } from \"@ooneex/container\";\nimport type { ITypeormDatabase } from \"@ooneex/database\";\nimport { decorator } from \"@ooneex/repository\";\nimport type { FilterResultType } from \"@ooneex/types\";\nimport type { FindManyOptions, FindOptionsWhere, Repository, SaveOptions, UpdateResult } from \"typeorm\";\nimport { ILike } from \"typeorm\";\nimport { <Name>Entity } from \"../entities/<Name>Entity\";\n\n@decorator.repository()\nexport class <Name>Repository {\n constructor(\n @inject(\"database\")\n private readonly database: ITypeormDatabase,\n ) {}\n\n public async open(): Promise<Repository<<Name>Entity>> {\n return await this.database.open(<Name>Entity);\n }\n\n public async close(): Promise<void> {\n await this.database.close();\n }\n\n public async find(\n criteria: FindManyOptions<<Name>Entity> & { page?: number; limit?: number; q?: string },\n ): Promise<FilterResultType<<Name>Entity>> {\n // ... pagination and search logic\n }\n\n public async findOne(id: string): Promise<<Name>Entity | null> { ... }\n public async findOneBy(criteria: FindOptionsWhere<<Name>Entity>): Promise<<Name>Entity | null> { ... }\n public async create(entity: <Name>Entity, options?: SaveOptions): Promise<<Name>Entity> { ... }\n public async createMany(entities: <Name>Entity[], options?: SaveOptions): Promise<<Name>Entity[]> { ... }\n public async update(entity: <Name>Entity, options?: SaveOptions): Promise<<Name>Entity> { ... }\n public async updateMany(entities: <Name>Entity[], options?: SaveOptions): Promise<<Name>Entity[]> { ... }\n public async delete(criteria: FindOptionsWhere<<Name>Entity> | FindOptionsWhere<<Name>Entity>[]): Promise<UpdateResult> { ... }\n public async count(criteria?: FindOptionsWhere<<Name>Entity> | FindOptionsWhere<<Name>Entity>[]): Promise<number> { ... }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/repositories/<Name>Repository.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep scaffolded tests for methods that remain in the repository (remove tests for methods that were removed)\n- Add tests for any custom domain-specific methods added to the repository\n- Add tests relevant to the specific repository behavior\n\n### 5. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/repositories/<Name>Repository.ts tests/repositories/<Name>Repository.spec.ts\n```\n";var ei="---\nname: make:seed\ndescription: Generate a new database seed file, then complete the generated code. Use when creating seed data for populating the database using @ooneex/seeds.\n---\n\n# Make Seed\n\nGenerate a new seed file using the `make:seed` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the seed file:\n\n```bash\nbunx @ooneex/cli@latest make:seed --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, the seed file is generated under `modules/<module>/src/seeds/` instead of `src/seeds/`. The command will:\n- Generate a seed file in `src/seeds/` (or `modules/<module>/src/seeds/` with `--module`)\n- Add a `seed:run` script to `package.json` if not already present\n\n### 2. Read the generated file\n\nRead the generated seed file in `src/seeds/` to understand the scaffolded code.\n\n### 3. Complete the seed\n\nEdit the generated seed file to implement:\n\n- Import the relevant entity classes\n- Create seed data with hardcoded nanoid values for `id` fields (generate via `bun -e \"import { random } from '@ooneex/utils'; console.log(random.nanoid())\"`)\n- Do NOT use sequential IDs like `\"item-1\"`, `\"item-2\"`\n- Ensure the same entity uses the same ID everywhere it appears\n\n### 4. Lint and format\n\nRun linting and formatting on the generated file:\n\n```bash\nbunx biome check --fix src/seeds/\n```\n";var ti="---\nname: make:service\ndescription: Generate a new service class with its test file, then complete the generated code. Use when creating a new business logic service that implements IService from @ooneex/service.\n---\n\n# Make Service Class\n\nGenerate a new service class and its test file using the `make:service` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the service class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:service --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/services/<Name>Service.ts` - The service class file (or `modules/<module>/src/services/<Name>Service.ts` with `--module`)\n- `tests/services/<Name>Service.spec.ts` - The test file (or `modules/<module>/tests/services/<Name>Service.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the service class\n\nEdit `src/services/<Name>Service.ts` to complete the implementation:\n\n- Define a proper type for `ServiceDataType` instead of `Record<string, unknown>`\n- Implement the `execute()` method with actual business logic\n- Inject any required dependencies (repositories, other services, etc.) via the constructor\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { decorator } from \"@ooneex/service\";\nimport type { IService } from \"@ooneex/service\";\n\ntype ServiceDataType = Record<string, unknown>;\n\n@decorator.service()\nexport class <Name>Service<T extends ServiceDataType = ServiceDataType> implements IService<T> {\n public async execute(data?: T): Promise<void> {\n // TODO: Implement service logic\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/services/<Name>Service.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, execute method)\n- Add tests relevant to the specific service behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Service } from \"@/services/<Name>Service\";\n\ndescribe(\"<Name>Service\", () => {\n test(\"should have class name ending with 'Service'\", () => {\n expect(<Name>Service.name.endsWith(\"Service\")).toBe(true);\n });\n\n test(\"should have 'execute' method\", () => {\n expect(<Name>Service.prototype.execute).toBeDefined();\n expect(typeof <Name>Service.prototype.execute).toBe(\"function\");\n });\n});\n```\n\n### 5. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/services/<Name>Service.ts tests/services/<Name>Service.spec.ts\n```\n";var si="---\nname: make:storage\ndescription: Generate a new storage class with its test file, then complete the generated code. Use when creating a new S3-compatible storage adapter that extends Storage from @ooneex/storage.\n---\n\n# Make Storage Class\n\nGenerate a new storage class and its test file using the `make:storage` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the storage class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:storage --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/storage/<Name>Storage.ts` - The storage class file (or `modules/<module>/src/storage/<Name>Storage.ts` with `--module`)\n- `tests/storage/<Name>Storage.spec.ts` - The test file (or `modules/<module>/tests/storage/<Name>Storage.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the storage class\n\nEdit `src/storage/<Name>Storage.ts` to complete the implementation:\n\n- Set the `bucket` property to the appropriate bucket name\n- Verify the environment variable names match the project configuration (`STORAGE_<NAME_UPPER>_ACCESS_KEY`, `STORAGE_<NAME_UPPER>_SECRET_KEY`, `STORAGE_<NAME_UPPER>_ENDPOINT`, `STORAGE_<NAME_UPPER>_REGION`)\n- Add any additional storage-specific methods if needed\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { Storage, decorator, StorageException } from \"@ooneex/storage\";\nimport type { S3Options } from \"bun\";\n\n@decorator.storage()\nexport class <Name>Storage extends Storage {\n protected bucket: string;\n private readonly accessKey: string;\n private readonly secretKey: string;\n private readonly endpoint: string;\n private readonly region: string;\n\n constructor(options?: {\n accessKey?: string;\n secretKey?: string;\n endpoint?: string;\n region?: string;\n }) {\n super();\n\n const accessKey = options?.accessKey || Bun.env.STORAGE_<NAME_UPPER>_ACCESS_KEY;\n const secretKey = options?.secretKey || Bun.env.STORAGE_<NAME_UPPER>_SECRET_KEY;\n const endpoint = options?.endpoint || Bun.env.STORAGE_<NAME_UPPER>_ENDPOINT;\n\n // ... validation throws StorageException if missing ...\n\n this.accessKey = accessKey;\n this.secretKey = secretKey;\n this.endpoint = endpoint;\n this.region = options?.region || Bun.env.STORAGE_<NAME_UPPER>_REGION || \"auto\";\n }\n\n public getOptions(): S3Options {\n return {\n accessKeyId: this.accessKey,\n secretAccessKey: this.secretKey,\n endpoint: this.endpoint,\n bucket: this.bucket,\n region: this.region,\n };\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/storage/<Name>Storage.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, bucket field, getOptions method)\n- Add tests relevant to the specific storage class behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>StorageAdapter } from \"@/storage/<Name>StorageAdapter\";\n\ndescribe(\"<Name>StorageAdapter\", () => {\n test(\"should have class name ending with 'StorageAdapter'\", () => {\n expect(<Name>StorageAdapter.name.endsWith(\"StorageAdapter\")).toBe(true);\n });\n\n test(\"should have 'bucket' field\", () => {\n expect(\"bucket\" in <Name>StorageAdapter.prototype || \"bucket\" in Object.getOwnPropertyNames(<Name>StorageAdapter.prototype)).toBe(true);\n });\n\n test(\"should have 'getOptions' method\", () => {\n expect(<Name>StorageAdapter.prototype.getOptions).toBeDefined();\n expect(typeof <Name>StorageAdapter.prototype.getOptions).toBe(\"function\");\n });\n});\n```\n\n### 5. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/storage/<Name>Storage.ts tests/storage/<Name>Storage.spec.ts\n```\n";var ri="---\nname: make:vector-database\ndescription: Generate a new vector database class with its test file, then complete the generated code. Use when creating a new vector database that extends VectorDatabase from @ooneex/rag.\n---\n\n# Make Vector Database Class\n\nGenerate a new vector database class and its test file using the `make:vector-database` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the vector database class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:vector-database --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/databases/<Name>VectorDatabase.ts` - The vector database class file (or `modules/<module>/src/databases/<Name>VectorDatabase.ts` with `--module`)\n- `tests/databases/<Name>VectorDatabase.spec.ts` - The test file (or `modules/<module>/tests/databases/<Name>VectorDatabase.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the vector database class\n\nEdit `src/databases/<Name>VectorDatabase.ts` to complete the implementation:\n\n- Set the `getDatabaseUri()` return value to the actual LanceDB database path\n- Configure the embedding provider and model in `getEmbeddingModel()`\n- Define the custom data fields in `DataType` and map them in `getSchema()`\n- Import the appropriate Apache Arrow types for your schema fields\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { VectorDatabase, decorator } from \"@ooneex/rag\";\nimport type { EmbeddingModelType, EmbeddingProviderType, FieldValueType } from \"@ooneex/rag\";\nimport { Utf8 } from \"apache-arrow\";\n\ntype DataType = {\n name: string;\n};\n\n@decorator.vectorDatabase()\nexport class <Name>VectorDatabase extends VectorDatabase<DataType> {\n public getDatabaseUri(): string {\n return \"\";\n }\n\n public getEmbeddingModel(): { provider: EmbeddingProviderType; model: EmbeddingModelType[\"model\"] } {\n return { provider: \"openai\", model: \"text-embedding-ada-002\" };\n }\n\n public getSchema(): { [K in keyof DataType]: FieldValueType } {\n return {\n name: new Utf8(),\n };\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/databases/<Name>VectorDatabase.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, getDatabaseUri, getEmbeddingModel, getSchema methods)\n- Add tests relevant to the specific vector database class behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>VectorDatabase } from \"@/databases/<Name>VectorDatabase\";\n\ndescribe(\"<Name>VectorDatabase\", () => {\n test(\"should have class name ending with 'VectorDatabase'\", () => {\n expect(<Name>VectorDatabase.name.endsWith(\"VectorDatabase\")).toBe(true);\n });\n\n test(\"should have 'getDatabaseUri' method\", () => {\n expect(<Name>VectorDatabase.prototype.getDatabaseUri).toBeDefined();\n expect(typeof <Name>VectorDatabase.prototype.getDatabaseUri).toBe(\"function\");\n });\n\n test(\"should have 'getEmbeddingModel' method\", () => {\n expect(<Name>VectorDatabase.prototype.getEmbeddingModel).toBeDefined();\n expect(typeof <Name>VectorDatabase.prototype.getEmbeddingModel).toBe(\"function\");\n });\n\n test(\"should have 'getSchema' method\", () => {\n expect(<Name>VectorDatabase.prototype.getSchema).toBeDefined();\n expect(typeof <Name>VectorDatabase.prototype.getSchema).toBe(\"function\");\n });\n});\n```\n\n### 5. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/databases/<Name>VectorDatabase.ts tests/databases/<Name>VectorDatabase.spec.ts\n```\n";var oi=`---
1804
- name: optimize
1805
- description: Optimize a module's codebase for quality, performance, and clean conventions. Enforces arrow functions (except class methods), type/interface naming, removes duplication, and ensures only important tests remain.
1806
- ---
1807
-
1808
- # Optimize Codebase
1809
-
1810
- Optimize a module's codebase for quality, performance, and clean conventions.
1811
-
1812
- ## Coding Conventions
1813
-
1814
- Apply these conventions across all files in the target module:
1815
-
1816
- - **Arrow functions everywhere** \u2014 use arrow functions for all function expressions, callbacks, standalone functions, and variable declarations. The ONLY exception is class methods, which must use regular method syntax.
1817
- - **Type naming** \u2014 all type aliases must end with the \`Type\` suffix (e.g., \`UserDataType\`, \`ConfigOptionsType\`). Rename any that don't comply.
1818
- - **Interface naming** \u2014 all interface names must start with the \`I\` prefix (e.g., \`IUser\`, \`IService\`, \`IRepository\`). Rename any that don't comply.
1819
- - Always explicitly show visibility on class methods and properties (\`private\`, \`public\`, \`protected\`).
1820
-
1821
- ## Steps
1822
-
1823
- ### 1. Identify the target
1824
-
1825
- Determine the module to optimize. If the user specifies a module name, work in \`modules/<module>/\`. If no module is specified, ask the user which module to optimize.
1826
-
1827
- ### 2. Read and analyze the module
1828
-
1829
- Read all source files (\`src/**/*.ts\`) and test files (\`tests/**/*.ts\`) in the target module. Build a full picture of:
1830
-
1831
- - All types, interfaces, classes, and functions
1832
- - Dependencies between files
1833
- - Existing test coverage
1834
-
1835
- ### 3. Enforce naming conventions
1836
-
1837
- Scan every file and fix:
1838
-
1839
- - **Types not ending with \`Type\`** \u2014 rename the type and update all references across the module
1840
- - **Interfaces not starting with \`I\`** \u2014 rename the interface and update all references across the module
1841
- - **Non-arrow functions** \u2014 convert all function expressions, callbacks, and standalone functions to arrow functions. Do NOT convert class methods.
1842
- - **Missing visibility modifiers** \u2014 add explicit \`public\`, \`private\`, or \`protected\` to all class methods and properties
1843
-
1844
- ### 4. Remove code duplication
1845
-
1846
- Identify duplicated or near-duplicated code within the module:
1847
-
1848
- - Extract shared logic into well-named helper arrow functions or base classes
1849
- - Consolidate repeated type definitions
1850
- - Merge similar utility functions
1851
- - Remove dead code (unused imports, unreachable branches, unused variables)
1852
-
1853
- ### 5. Optimize for performance
1854
-
1855
- Review and improve:
1856
-
1857
- - Replace inefficient loops or repeated iterations with single-pass approaches where possible
1858
- - Use \`Map\`/\`Set\` instead of arrays for lookups when appropriate
1859
- - Avoid unnecessary object spreads or deep clones
1860
- - Prefer early returns to reduce nesting
1861
- - Remove unnecessary \`async\`/\`await\` where a direct return suffices
1862
- - Eliminate redundant null/undefined checks when the type system already guarantees the value
1863
-
1864
- ### 6. Optimize tests
1865
-
1866
- Review all test files and restructure:
1867
-
1868
- - **Remove trivial tests** \u2014 delete tests that only check obvious things (e.g., "class name ends with X", "method exists") unless they serve as smoke tests for generated code
1869
- - **Keep and improve important tests** \u2014 focus on tests that verify actual business logic, edge cases, error handling, and integration behavior
1870
- - **Write fewer but more meaningful tests** \u2014 each test should validate a real scenario or invariant, not just existence checks
1871
- - **Consolidate redundant test cases** \u2014 merge tests that cover the same code path with slightly different inputs into parameterized patterns
1872
- - **Ensure critical paths are covered** \u2014 every public method with logic should have at least one test covering its happy path and one covering its error/edge case
1873
-
1874
- ### 7. Final cleanup
1875
-
1876
- - Remove all unused imports
1877
- - Remove empty files or files with no exports
1878
- - Ensure consistent formatting
1879
-
1880
- ### 8. Lint and format
1881
-
1882
- Run linting and formatting on all modified files:
1883
-
1884
- \`\`\`bash
1885
- bunx biome check --fix <list of modified files>
1886
- \`\`\`
1887
-
1888
- ### 9. Run tests
1889
-
1890
- Run the module's tests to verify nothing is broken:
1891
-
1892
- \`\`\`bash
1893
- bun test <module test directory>
1894
- \`\`\`
1895
-
1896
- If any test fails, fix the issue and re-run until all tests pass.
1897
- `;var zl={"make.ai":$o,"make.analytics":Wo,"make.cache":qo,"make.controller":Ko,"make.cron":Ho,"make.database":Fo,"make.entity":Vo,"make.logger":Yo,"make.mailer":zo,"make.middleware":Zo,"make.migration":Qo,"make.permission":Xo,"make.pubsub":Jo,"make.repository":jo,"make.seed":ei,"make.service":ti,"make.storage":si,"make.vector-database":ri,commit:ko,optimize:oi};class qe{getName(){return"make:claude:skill"}getDescription(){return"Generate Claude skills from templates"}async run(){let e=We(".claude","skills"),t=We(process.cwd(),e),s=new Yl;for(let[r,o]of Object.entries(zl)){let i=r.replace(/\./g,"-"),a=We(t,i,"SKILL.md");await Bun.write(a,o),s.success(`${We(e,i,"SKILL.md")} created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}}qe=b([x.command()],qe);import{basename as Xl,join as G}from"path";import{TerminalLogger as Jl}from"@ooneex/logger";import{toPascalCase as Lt}from"@ooneex/utils";var ii=`import { describe, expect, test } from "bun:test";
1820
+ `;var Go="---\nname: make:ai\ndescription: Generate a new AI class with its test file, then complete the generated code. Use when creating a new AI chat class that uses OpenAI via the @ooneex/ai package.\n---\n\n# Make AI Class\n\nGenerate a new AI class and its test file using the `make:ai` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the AI class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:ai --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/ai/<Name>Ai.ts` - The AI class file (or `modules/<module>/src/ai/<Name>Ai.ts` with `--module`)\n- `tests/ai/<Name>Ai.spec.ts` - The test file (or `modules/<module>/tests/ai/<Name>Ai.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the AI class\n\nEdit `src/ai/<Name>Ai.ts` to complete the implementation:\n\n- Update the prompt in the `run` method from `\"My prompt\"` to a meaningful prompt based on the class purpose\n- Update the prompt in the `runStream` method from `\"My prompt\"` to a meaningful prompt based on the class purpose\n- Add any additional configuration or methods relevant to the AI class purpose\n- Ensure proper typing for the `run<T>()` generic return type\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { decorator, type IAiChat, OpenAi, type OpenAiConfigType } from \"@ooneex/ai\";\nimport { inject } from \"@ooneex/container\";\n\n@decorator.ai()\nexport class <Name>Ai implements IAiChat<OpenAiConfigType> {\n constructor(@inject(OpenAi) private readonly ai: OpenAi) {}\n\n public async run<T>(prompt?: string, config?: Omit<OpenAiConfigType, \"prompt\">): Promise<T> {\n return this.ai.run<T>(prompt || \"My prompt\", config);\n }\n\n public async *runStream(\n prompt?: string,\n config?: Omit<OpenAiConfigType, \"prompt\" | \"output\">,\n ): AsyncGenerator<string, void, unknown> {\n yield* this.ai.runStream(prompt || \"My prompt\", config);\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/ai/<Name>Ai.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, run method, runStream method)\n- Add tests relevant to the specific AI class behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Ai } from \"@/ai/<Name>Ai\";\n\ndescribe(\"<Name>Ai\", () => {\n test(\"should have class name ending with 'Ai'\", () => {\n expect(<Name>Ai.name.endsWith(\"Ai\")).toBe(true);\n });\n\n test(\"should have 'run' method\", () => {\n expect(<Name>Ai.prototype.run).toBeDefined();\n expect(typeof <Name>Ai.prototype.run).toBe(\"function\");\n });\n\n test(\"should have 'runStream' method\", () => {\n expect(<Name>Ai.prototype.runStream).toBeDefined();\n expect(typeof <Name>Ai.prototype.runStream).toBe(\"function\");\n });\n});\n```\n\n### 5. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/ai/<Name>Ai.ts tests/ai/<Name>Ai.spec.ts\n```\n";var $o="---\nname: make:analytics\ndescription: Generate a new analytics class with its test file, then complete the generated code. Use when creating a new analytics tracking class that uses the @ooneex/analytics package.\n---\n\n# Make Analytics Class\n\nGenerate a new analytics class and its test file using the `make:analytics` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the analytics class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:analytics --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/analytics/<Name>Analytics.ts` - The analytics class file (or `modules/<module>/src/analytics/<Name>Analytics.ts` with `--module`)\n- `tests/analytics/<Name>Analytics.spec.ts` - The test file (or `modules/<module>/tests/analytics/<Name>Analytics.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the analytics class\n\nEdit `src/analytics/<Name>Analytics.ts` to complete the implementation:\n\n- Implement the `capture` method with actual analytics tracking logic\n- Define a proper type for `CaptureOptionsType` instead of `Record<string, unknown>` based on the analytics purpose\n- Add any additional methods or properties relevant to the analytics class purpose\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { decorator } from \"@ooneex/analytics\";\nimport type { IAnalytics } from \"@ooneex/analytics\";\n\ntype CaptureOptionsType = Record<string, unknown>;\n\n@decorator.analytics()\nexport class <Name>Analytics<T extends CaptureOptionsType = CaptureOptionsType> implements IAnalytics<T> {\n public capture(options: T): void {\n // console.log(\"Analytics captured:\", options);\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/analytics/<Name>Analytics.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, capture method)\n- Add tests relevant to the specific analytics class behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Analytics } from \"@/analytics/<Name>Analytics\";\n\ndescribe(\"<Name>Analytics\", () => {\n test(\"should have class name ending with 'Analytics'\", () => {\n expect(<Name>Analytics.name.endsWith(\"Analytics\")).toBe(true);\n });\n\n test(\"should have 'capture' method\", () => {\n expect(<Name>Analytics.prototype.capture).toBeDefined();\n expect(typeof <Name>Analytics.prototype.capture).toBe(\"function\");\n });\n});\n```\n\n### 5. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/analytics/<Name>Analytics.ts tests/analytics/<Name>Analytics.spec.ts\n```\n";var qo="---\nname: make:cache\ndescription: Generate a new cache adapter class with its test file, then complete the generated code. Use when creating a new cache adapter that implements the ICache interface from @ooneex/cache.\n---\n\n# Make Cache Class\n\nGenerate a new cache class and its test file using the `make:cache` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the cache class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:cache --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/cache/<Name>Cache.ts` - The cache class file (or `modules/<module>/src/cache/<Name>Cache.ts` with `--module`)\n- `tests/cache/<Name>Cache.spec.ts` - The test file (or `modules/<module>/tests/cache/<Name>Cache.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the cache class\n\nEdit `src/cache/<Name>Cache.ts` to complete the implementation:\n\n- Implement the `get` method to retrieve cached values by key\n- Implement the `set` method to store values with optional TTL\n- Implement the `delete` method to remove cached entries\n- Implement the `has` method to check key existence\n- Replace the `CacheException` throws with actual cache logic\n- Inject any required dependencies (e.g., Redis client) via the constructor\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { CacheException, decorator } from \"@ooneex/cache\";\nimport type { ICache } from \"@ooneex/cache\";\n\n@decorator.cache()\nexport class <Name>Cache implements ICache {\n public async get<T = unknown>(key: string): Promise<T | undefined> {\n throw new CacheException(`Failed to get key \"${key}\": Not implemented`);\n }\n\n public async set<T = unknown>(key: string, value: T, ttl?: number): Promise<void> {\n throw new CacheException(`Failed to set key \"${key}\": Not implemented`);\n }\n\n public async delete(key: string): Promise<boolean> {\n throw new CacheException(`Failed to delete key \"${key}\": Not implemented`);\n }\n\n public async has(key: string): Promise<boolean> {\n throw new CacheException(`Failed to check if key \"${key}\" exists: Not implemented`);\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/cache/<Name>Cache.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, get, set, delete, has methods)\n- Add tests relevant to the specific cache class behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Cache } from \"@/cache/<Name>Cache\";\n\ndescribe(\"<Name>Cache\", () => {\n test(\"should have class name ending with 'Cache'\", () => {\n expect(<Name>Cache.name.endsWith(\"Cache\")).toBe(true);\n });\n\n test(\"should have 'get' method\", () => {\n expect(<Name>Cache.prototype.get).toBeDefined();\n expect(typeof <Name>Cache.prototype.get).toBe(\"function\");\n });\n\n test(\"should have 'set' method\", () => {\n expect(<Name>Cache.prototype.set).toBeDefined();\n expect(typeof <Name>Cache.prototype.set).toBe(\"function\");\n });\n\n test(\"should have 'delete' method\", () => {\n expect(<Name>Cache.prototype.delete).toBeDefined();\n expect(typeof <Name>Cache.prototype.delete).toBe(\"function\");\n });\n\n test(\"should have 'has' method\", () => {\n expect(<Name>Cache.prototype.has).toBeDefined();\n expect(typeof <Name>Cache.prototype.has).toBe(\"function\");\n });\n});\n```\n\n### 5. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/cache/<Name>Cache.ts tests/cache/<Name>Cache.spec.ts\n```\n";var Wo="---\nname: make:controller\ndescription: Generate a new controller class with route type and test file, then complete the generated code. Use when creating a new HTTP or WebSocket controller with routing, validation, and role-based access.\n---\n\n# Make Controller Class\n\nGenerate a new controller class, its route type, and test file using the `make:controller` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the controller class and related files:\n\n```bash\nbunx @ooneex/cli@latest make:controller --name <name> --module <module> --is-socket <true|false> --route.name <route.name> --route.path <route.path> --route.method <route.method>\n```\n\nWhere:\n- `<name>` is the controller name provided by the user\n- `--module` is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root\n- `--is-socket` determines HTTP vs WebSocket controller (defaults to `false`)\n- `--route.name` is the route name using dot notation: `<resource>.<action>` (e.g., `user.create`, `book.list`, `flashcard.delete`)\n- `--route.path` is the route path (e.g., `/api/users`)\n- `--route.method` is the HTTP method (e.g., `get`, `post`, `put`, `patch`, `delete`) \u2014 only for HTTP controllers\n\nThe command will generate (paths prefixed with `modules/<module>/` when `--module` is provided):\n- `src/controllers/<Name>Controller.ts` - The controller class file\n- `src/types/routes/<route.name>.ts` - The route type file (will be moved into the controller file \u2014 see step 3)\n- `tests/controllers/<Name>Controller.spec.ts` - The test file\n\n### 2. Read the generated files\n\nRead all three generated files to understand the scaffolded code.\n\n### 3. Complete the route type\n\n**IMPORTANT: Keep the route type inside the controller file**, not in a separate type file. Define the type directly in `src/controllers/<Name>Controller.ts` above the class definition. Delete the generated `src/types/routes/<route.name>.ts` file if it was created.\n\n**Remove unnecessary `params`, `payload`, and `queries` \u2014 only include what the route actually needs:**\n\n- **`params`** \u2014 Include only when the route path contains dynamic segments (e.g., `/api/users/:id`). Remove entirely for routes with no URL parameters (e.g., `/api/users`).\n- **`payload`** \u2014 Include only for methods that accept a request body (`post`, `put`, `patch`). Remove entirely for `get` and `delete` routes.\n- **`queries`** \u2014 Include only when the route supports query string filtering, pagination, or sorting (e.g., list/search endpoints). Remove entirely when not needed.\n- **`response`** \u2014 Always include.\n\nThe route type structure follows this pattern (remove unused sections):\n\n```typescript\n// Example: GET /api/users (list) \u2014 no params, no payload, has queries\ntype <TypeName>RouteType = {\n queries: {\n\n },\n response: {\n\n },\n};\n\n// Example: POST /api/users (create) \u2014 no params, has payload, no queries\ntype <TypeName>RouteType = {\n payload: {\n\n },\n response: {\n\n },\n};\n\n// Example: GET /api/users/:id (detail) \u2014 has params, no payload, no queries\ntype <TypeName>RouteType = {\n params: {\n\n },\n response: {\n\n },\n};\n\n// Example: PUT /api/users/:id (update) \u2014 has params, has payload, no queries\ntype <TypeName>RouteType = {\n params: {\n\n },\n payload: {\n\n },\n response: {\n\n },\n};\n```\n\n### 4. Complete the controller class\n\nEdit `src/controllers/<Name>Controller.ts` to complete the implementation:\n\n- Set appropriate `roles` for access control\n- Add a meaningful `description` for the route that explains what the endpoint does (e.g., `\"Create a new user account\"`, `\"List all books with pagination\"`)\n- **Keep the controller thin** \u2014 do NOT put business logic in the controller. Put all logic in the corresponding service and inject the service into the controller via the constructor. The controller's `index` method should only delegate to the service.\n- **Remove unnecessary `params`, `payload`, and `queries`** from both the route type and the `@Route` decorator \u2014 only include what the route actually needs (see step 3 rules).\n\n**Add or remove `params`, `payload`, and `queries` in the `@Route` decorator to match the route type (step 3):**\n\n- **`params`** \u2014 Include with `Assert()` validators only when the route has URL parameters. Remove the `params` key entirely otherwise.\n- **`payload`** \u2014 Include with `Assert({...})` only for `post`, `put`, `patch` methods. Remove the `payload` key entirely for `get` and `delete`.\n- **`queries`** \u2014 Include with `Assert({...})` only when query parameters are expected. Remove the `queries` key entirely otherwise.\n- **`response`** \u2014 Always include with `Assert({...})`.\n\n**HTTP controller** generated structure (remove `params`, `payload`, `queries` as needed \u2014 see rules above):\n\n```typescript\nimport type { ContextType } from \"@ooneex/controller\";\nimport { ERole } from \"@ooneex/role\";\nimport { Route } from \"@ooneex/routing\";\nimport { Assert } from \"@ooneex/validation\";\n\ntype <TypeName>RouteType = {\n // Only include params, payload, queries as needed (see step 3)\n response: {\n\n },\n};\n\n@Route.<method>(\"<route.path>\", {\n name: \"<route.name>\",\n version: 1,\n description: \"\",\n // Only include params, payload, queries as needed (see step 3)\n response: Assert({\n\n }),\n roles: [ERole.USER],\n})\nexport class <Name>Controller {\n public async index(context: ContextType<<TypeName>RouteType>) {\n return context.response.json({\n\n });\n }\n}\n```\n\n**Socket controller** generated structure (remove `params`, `payload`, `queries` as needed \u2014 see rules above):\n\n```typescript\nimport type { ContextType } from \"@ooneex/socket\";\nimport { ERole } from \"@ooneex/role\";\nimport { Route } from \"@ooneex/routing\";\nimport { Assert } from \"@ooneex/validation\";\n\ntype <TypeName>RouteType = {\n // Only include params, payload, queries as needed (see step 3)\n response: {\n\n },\n};\n\n@Route.socket(\"<route.path>\", {\n name: \"<route.name>\",\n version: 1,\n description: \"\",\n // Only include params, payload, queries as needed (see step 3)\n response: Assert({\n\n }),\n roles: [ERole.USER],\n})\nexport class <Name>Controller {\n public async index(context: ContextType<<TypeName>RouteType>) {\n return context.response.json({\n\n });\n }\n}\n```\n\n### 5. Complete the test file\n\nEdit `tests/controllers/<Name>Controller.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, index method)\n- Add tests relevant to the specific controller behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Controller } from \"@/controllers/<Name>Controller\";\n\ndescribe(\"<Name>Controller\", () => {\n test(\"should have class name ending with 'Controller'\", () => {\n expect(<Name>Controller.name.endsWith(\"Controller\")).toBe(true);\n });\n\n test(\"should have 'index' method\", () => {\n expect(<Name>Controller.prototype.index).toBeDefined();\n expect(typeof <Name>Controller.prototype.index).toBe(\"function\");\n });\n});\n```\n\n### 6. Register the controller in the module\n\nAdd the new controller to the module's `controllers` array in `src/<PascalModuleName>Module.ts` (e.g., `src/BookModule.ts` for the `book` module):\n\n```typescript\nimport type { ModuleType } from \"@ooneex/module\";\nimport { <Name>Controller } from \"./controllers/<Name>Controller\";\n\nexport const <PascalModuleName>Module: ModuleType = {\n controllers: [<Name>Controller],\n entities: [],\n permissions: [],\n middlewares: [],\n cronJobs: [],\n events: [],\n};\n```\n\nThe module file uses PascalCase naming: `<PascalModuleName>Module.ts` with export `<PascalModuleName>Module`.\n\nIf the module already has other controllers registered, append the new controller to the existing `controllers` array and add the import alongside existing imports.\n\n### 7. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/controllers/<Name>Controller.ts tests/controllers/<Name>Controller.spec.ts\n```\n\n### 8. Create the service\n\nAfter the controller is created, generate a service class for the controller's business logic using the `make:service` skill:\n\n```\n/make:service --name <Name>\n```\n\nWhere `<Name>` matches the controller name (e.g., if the controller is `CreateUserController`, the service is `CreateUserService`).\n\n### 9. Create the pubsub event\n\nAfter the service is created, generate a pubsub event class for the controller's domain events using the `make:pubsub` skill:\n\n```\n/make:pubsub --name <Name> --channel <resource>.<action>\n```\n\nWhere:\n- `<Name>` matches the controller name (e.g., if the controller is `CreateUserController`, the event is `CreateUserEvent`)\n- `<resource>.<action>` follows the same dot notation as the route name (e.g., `user.create`, `book.delete`)\n\nOnce the event is created:\n- Inject the **service** into the **event** via the constructor, and call the service's `execute` method from the event's `handler` method.\n- Inject the **event** into the **controller** via the constructor, and publish the event from the controller's `index` method.\n";var Fo="---\nname: make:cron\ndescription: Generate a new cron job class with its test file, then complete the generated code. Use when creating a new scheduled task that extends the Cron base class from @ooneex/cron.\n---\n\n# Make Cron Class\n\nGenerate a new cron class and its test file using the `make:cron` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the cron class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:cron --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/cron/<Name>Cron.ts` - The cron class file (or `modules/<module>/src/cron/<Name>Cron.ts` with `--module`)\n- `tests/cron/<Name>Cron.spec.ts` - The test file (or `modules/<module>/tests/cron/<Name>Cron.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the cron class\n\nEdit `src/cron/<Name>Cron.ts` to complete the implementation:\n\n- Set the appropriate cron schedule in `getTime()` (e.g., `\"every 5 minutes\"`, `\"every 1 hours\"`, `\"every 30 seconds\"`)\n- Set the timezone in `getTimeZone()` if needed, or keep `null` for server timezone\n- Implement the `handler()` method with the actual cron job logic\n- Inject any required dependencies via the constructor\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport type { TimeZoneType } from \"@ooneex/country\";\nimport type { CronTimeType } from \"@ooneex/cron\";\nimport { Cron, decorator } from \"@ooneex/cron\";\n\n@decorator.cron()\nexport class <Name>Cron extends Cron {\n public getTime(): CronTimeType {\n // Examples: \"every 5 minutes\", \"every 1 hours\", \"every 30 seconds\"\n return \"every 1 hours\";\n }\n\n public getTimeZone(): TimeZoneType | null {\n // Return null to use server timezone, or specify a timezone like \"Europe/Paris\"\n return null;\n }\n\n public async handler(): Promise<void> {\n // Implement your cron handler logic here\n // console.log(\"<Name>Cron handler executed\");\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/cron/<Name>Cron.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, getTime, getTimeZone, handler methods)\n- Add tests relevant to the specific cron class behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Cron } from \"@/cron/<Name>Cron\";\n\ndescribe(\"<Name>Cron\", () => {\n test(\"should have class name ending with 'Cron'\", () => {\n expect(<Name>Cron.name.endsWith(\"Cron\")).toBe(true);\n });\n\n test(\"should have 'getTime' method\", () => {\n expect(<Name>Cron.prototype.getTime).toBeDefined();\n expect(typeof <Name>Cron.prototype.getTime).toBe(\"function\");\n });\n\n test(\"should have 'getTimeZone' method\", () => {\n expect(<Name>Cron.prototype.getTimeZone).toBeDefined();\n expect(typeof <Name>Cron.prototype.getTimeZone).toBe(\"function\");\n });\n\n test(\"should have 'handler' method\", () => {\n expect(<Name>Cron.prototype.handler).toBeDefined();\n expect(typeof <Name>Cron.prototype.handler).toBe(\"function\");\n });\n});\n```\n\n### 5. Register the cron job in the module\n\nAdd the new cron job to the module's `cronJobs` array in `src/<PascalModuleName>Module.ts` (e.g., `src/BookModule.ts` for the `book` module):\n\n```typescript\nimport type { ModuleType } from \"@ooneex/module\";\nimport { <Name>Cron } from \"./cron/<Name>Cron\";\n\nexport const <PascalModuleName>Module: ModuleType = {\n controllers: [],\n entities: [],\n permissions: [],\n middlewares: [],\n cronJobs: [<Name>Cron],\n events: [],\n};\n```\n\nThe module file uses PascalCase naming: `<PascalModuleName>Module.ts` with export `<PascalModuleName>Module`.\n\nIf the module already has other cron jobs registered, append the new cron job to the existing `cronJobs` array and add the import alongside existing imports.\n\n### 6. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/cron/<Name>Cron.ts tests/cron/<Name>Cron.spec.ts\n```\n";var Ko="---\nname: make:database\ndescription: Generate a new database class with its test file, then complete the generated code. Use when creating a new database adapter that extends TypeormDatabase from @ooneex/database.\n---\n\n# Make Database Class\n\nGenerate a new database class and its test file using the `make:database` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the database class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:database --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/databases/<Name>Database.ts` - The database class file (or `modules/<module>/src/databases/<Name>Database.ts` with `--module`)\n- `tests/databases/<Name>Database.spec.ts` - The test file (or `modules/<module>/tests/databases/<Name>Database.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the database class\n\nEdit `src/databases/<Name>Database.ts` to complete the implementation:\n\n- Add entity imports and register them in the `entities` array\n- Adjust the database path if needed (default is `\"var/db\"`)\n- Configure DataSource options as appropriate (type, synchronize, etc.)\n- Inject any required dependencies via the constructor\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { DataSource } from \"typeorm\";\nimport { TypeormDatabase, DatabaseException, decorator } from \"@ooneex/database\";\n\n@decorator.database()\nexport class <Name>Database extends TypeormDatabase {\n public getSource(database?: string): DataSource {\n database = database || \"var/db\";\n\n this.source = new DataSource({\n synchronize: false,\n entities: [\n // TODO: Load your entities here\n ],\n enableWAL: true,\n busyErrorRetry: 2000,\n busyTimeout: 30_000,\n database,\n type: \"sqlite\",\n });\n\n return this.source;\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/databases/<Name>Database.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, getSource method)\n- Add tests relevant to the specific database class behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Database } from \"@/databases/<Name>Database\";\n\ndescribe(\"<Name>Database\", () => {\n test(\"should have class name ending with 'Database'\", () => {\n expect(<Name>Database.name.endsWith(\"Database\")).toBe(true);\n });\n\n test(\"should have 'getSource' method\", () => {\n expect(<Name>Database.prototype.getSource).toBeDefined();\n expect(typeof <Name>Database.prototype.getSource).toBe(\"function\");\n });\n});\n```\n\n### 5. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/databases/<Name>Database.ts tests/databases/<Name>Database.spec.ts\n```\n";var Ho="---\nname: make:entity\ndescription: Generate a new TypeORM entity class with its test file, then complete the generated code. Use when creating a new database entity with columns, relations, and table mapping.\n---\n\n# Make Entity Class\n\nGenerate a new entity class and its test file using the `make:entity` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the entity class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:entity --name <name> --module <module> --table-name <table_name>\n```\n\nWhere `<name>` is the name provided by the user. The `--table-name` option is optional \u2014 if omitted, it defaults to the snake_case pluralized form of the name (e.g., `UserProfile` becomes `user_profiles`). The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/entities/<Name>Entity.ts` - The entity class file (or `modules/<module>/src/entities/<Name>Entity.ts` with `--module`)\n- `tests/entities/<Name>Entity.spec.ts` - The test file (or `modules/<module>/tests/entities/<Name>Entity.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the entity class\n\nEdit `src/entities/<Name>Entity.ts` to complete the implementation:\n\n- Add entity-specific columns with appropriate TypeORM decorators (`@Column`)\n- Add relations if needed (`@ManyToOne`, `@OneToMany`, `@ManyToMany`, etc.)\n- Remove any scaffolded columns that are not relevant to the entity\n- Adjust column types, lengths, and constraints as needed\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport type { LocaleType } from \"@ooneex/translation\";\nimport { random } from \"@ooneex/utils\";\nimport { Column, CreateDateColumn, DeleteDateColumn, PrimaryColumn, UpdateDateColumn } from \"typeorm\";\n\n@Entity({\n name: \"<table_name>\",\n})\nexport class <Name>Entity extends BaseEntity {\n @PrimaryColumn({ name: \"id\", type: \"varchar\", length: 25 })\n id: string = random.nanoid(25);\n\n @Column({\n name: \"is_locked\",\n type: \"boolean\",\n default: false,\n nullable: true,\n })\n isLocked?: boolean;\n\n @Column({ name: \"locked_at\", type: \"timestamptz\", nullable: true })\n lockedAt?: Date;\n\n @Column({\n name: \"is_blocked\",\n type: \"boolean\",\n default: false,\n nullable: true,\n })\n isBlocked?: boolean;\n\n @Column({ name: \"blocked_at\", type: \"timestamptz\", nullable: true })\n blockedAt?: Date;\n\n @Column({ name: \"block_reason\", type: \"text\", nullable: true })\n blockReason?: string;\n\n @Column({ name: \"is_public\", type: \"boolean\", default: true, nullable: true })\n isPublic?: boolean;\n\n @Column({ name: \"lang\", type: \"varchar\", length: 10, nullable: true })\n lang?: LocaleType;\n\n @CreateDateColumn({ name: \"created_at\" })\n createdAt?: Date;\n\n @UpdateDateColumn({ name: \"updated_at\" })\n updatedAt?: Date;\n\n @DeleteDateColumn({ name: \"deleted_at\" })\n deletedAt?: Date;\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/entities/<Name>Entity.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, id, default columns)\n- Add tests for any new entity-specific columns and relations\n- Update tests if scaffolded columns were removed\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Entity } from \"@/entities/<Name>Entity\";\n\ndescribe(\"<Name>Entity\", () => {\n test(\"should have class name ending with 'Entity'\", () => {\n expect(<Name>Entity.name.endsWith(\"Entity\")).toBe(true);\n });\n\n test(\"should have 'id' property with default nanoid\", () => {\n const entity = new <Name>Entity();\n expect(entity.id).toBeDefined();\n expect(typeof entity.id).toBe(\"string\");\n expect(entity.id.length).toBe(25);\n });\n\n test(\"should have 'isLocked' property\", () => {\n const entity = new <Name>Entity();\n expect(\"isLocked\" in entity).toBe(true);\n });\n\n // ... additional property tests\n});\n```\n\n### 5. Register the entity in the module\n\nAdd the new entity to the module's `entities` array in `src/<PascalModuleName>Module.ts` (e.g., `src/BookModule.ts` for the `book` module):\n\n```typescript\nimport type { ModuleType } from \"@ooneex/module\";\nimport { <Name>Entity } from \"./entities/<Name>Entity\";\n\nexport const <PascalModuleName>Module: ModuleType = {\n controllers: [],\n entities: [<Name>Entity],\n permissions: [],\n middlewares: [],\n cronJobs: [],\n events: [],\n};\n```\n\nThe module file uses PascalCase naming: `<PascalModuleName>Module.ts` with export `<PascalModuleName>Module`.\n\nIf the module already has other entities registered, append the new entity to the existing `entities` array and add the import alongside existing imports.\n\n### 6. Create a migration for the entity\n\nAfter creating or updating an entity, generate a migration to apply the corresponding schema changes to the database.\n\nRun the generator:\n\n```bash\nbunx @ooneex/cli@latest make:migration\n```\n\nThen read the generated migration file in `src/migrations/` and complete it:\n\n- In the `up` method, write the SQL to create the table (or alter it if updating an existing entity). Include all columns, types, constraints, defaults, and indexes matching the entity definition.\n- In the `down` method, write the reverse SQL to undo the changes (e.g., `DROP TABLE` or `ALTER TABLE DROP COLUMN`).\n- If the migration depends on another migration (e.g., a foreign key referencing another table), add that migration class to the `getDependencies()` return array.\n\nExample `up` method for a new entity:\n\n```typescript\npublic async up(tx: TransactionSQL): Promise<void> {\n await tx`\n CREATE TABLE IF NOT EXISTS <table_name> (\n id VARCHAR(25) PRIMARY KEY,\n is_locked BOOLEAN DEFAULT false,\n locked_at TIMESTAMPTZ,\n is_blocked BOOLEAN DEFAULT false,\n blocked_at TIMESTAMPTZ,\n block_reason TEXT,\n is_public BOOLEAN DEFAULT true,\n lang VARCHAR(10),\n created_at TIMESTAMPTZ DEFAULT NOW(),\n updated_at TIMESTAMPTZ DEFAULT NOW(),\n deleted_at TIMESTAMPTZ\n )\n `;\n}\n```\n\n### 7. Create a repository for the entity\n\nAfter creating the entity, generate a repository to handle database operations for it.\n\nRun the generator:\n\n```bash\nbunx @ooneex/cli@latest make:repository --name <name>\n```\n\nWhere `<name>` is the same name used for the entity. The command will generate:\n- `src/repositories/<Name>Repository.ts` - The repository class\n- `tests/repositories/<Name>Repository.spec.ts` - The test file\n\nThen read the generated files and complete the repository implementation:\n\n- Adjust search fields in the `find()` method to match the entity's searchable columns\n- Customize relations loading in `findOne`/`findOneBy` if the entity has relations\n- Add any domain-specific methods relevant to the entity\n- Remove methods that don't apply to the entity\n- Update tests to match the final repository methods\n\n### 8. Lint and format\n\nRun linting and formatting on all generated files:\n\n```bash\nbunx biome check --fix src/entities/<Name>Entity.ts tests/entities/<Name>Entity.spec.ts src/repositories/<Name>Repository.ts tests/repositories/<Name>Repository.spec.ts src/migrations/\n```\n";var Vo="---\nname: make:logger\ndescription: Generate a new logger class with its test file, then complete the generated code. Use when creating a new logger that implements the ILogger interface from @ooneex/logger.\n---\n\n# Make Logger Class\n\nGenerate a new logger class and its test file using the `make:logger` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the logger class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:logger --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/loggers/<Name>Logger.ts` - The logger class file (or `modules/<module>/src/loggers/<Name>Logger.ts` with `--module`)\n- `tests/loggers/<Name>Logger.spec.ts` - The test file (or `modules/<module>/tests/loggers/<Name>Logger.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the logger class\n\nEdit `src/loggers/<Name>Logger.ts` to complete the implementation:\n\n- Implement the `init()` method to set up the logger (e.g., open file handles, configure transports)\n- Implement `log`, `debug`, `info`, `success`, `warn`, and `error` methods with actual logging logic\n- Inject any required dependencies via the constructor\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport type { IException } from \"@ooneex/exception\";\nimport type { ILogger } from \"@ooneex/logger\";\nimport type { ScalarType } from \"@ooneex/types\";\nimport { decorator } from \"@ooneex/logger\";\n\n@decorator.logger()\nexport class <Name>Logger implements ILogger {\n public async init(): Promise<void> {\n // Initialize your logger here\n }\n\n public log(message: string, data?: Record<string, ScalarType>): void {\n // Handle general logging\n }\n\n public debug(message: string, data?: Record<string, ScalarType>): void {\n // Handle debug logging\n }\n\n public info(message: string, data?: Record<string, ScalarType>): void {\n // Handle info logging\n }\n\n public success(message: string, data?: Record<string, ScalarType>): void {\n // Handle success logging\n }\n\n public warn(message: string, data?: Record<string, ScalarType>): void {\n // Handle warning logging\n }\n\n public error(message: string | IException, data?: Record<string, ScalarType>): void {\n // Handle error logging\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/loggers/<Name>Logger.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, init, log, debug, info, success, warn, error methods)\n- Add tests relevant to the specific logger class behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Logger } from \"@/loggers/<Name>Logger\";\n\ndescribe(\"<Name>Logger\", () => {\n test(\"should have class name ending with 'Logger'\", () => {\n expect(<Name>Logger.name.endsWith(\"Logger\")).toBe(true);\n });\n\n test(\"should have 'init' method\", () => {\n expect(<Name>Logger.prototype.init).toBeDefined();\n expect(typeof <Name>Logger.prototype.init).toBe(\"function\");\n });\n\n test(\"should have 'log' method\", () => {\n expect(<Name>Logger.prototype.log).toBeDefined();\n expect(typeof <Name>Logger.prototype.log).toBe(\"function\");\n });\n\n test(\"should have 'debug' method\", () => {\n expect(<Name>Logger.prototype.debug).toBeDefined();\n expect(typeof <Name>Logger.prototype.debug).toBe(\"function\");\n });\n\n test(\"should have 'info' method\", () => {\n expect(<Name>Logger.prototype.info).toBeDefined();\n expect(typeof <Name>Logger.prototype.info).toBe(\"function\");\n });\n\n test(\"should have 'success' method\", () => {\n expect(<Name>Logger.prototype.success).toBeDefined();\n expect(typeof <Name>Logger.prototype.success).toBe(\"function\");\n });\n\n test(\"should have 'warn' method\", () => {\n expect(<Name>Logger.prototype.warn).toBeDefined();\n expect(typeof <Name>Logger.prototype.warn).toBe(\"function\");\n });\n\n test(\"should have 'error' method\", () => {\n expect(<Name>Logger.prototype.error).toBeDefined();\n expect(typeof <Name>Logger.prototype.error).toBe(\"function\");\n });\n});\n```\n\n### 5. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/loggers/<Name>Logger.ts tests/loggers/<Name>Logger.spec.ts\n```\n";var zo="---\nname: make:mailer\ndescription: Generate a new mailer class with its template and test files, then complete the generated code. Use when creating a new email sender with JSX template using @ooneex/mailer.\n---\n\n# Make Mailer Class\n\nGenerate a new mailer class, its JSX template, and test files using the `make:mailer` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the mailer class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:mailer --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate (paths prefixed with `modules/<module>/` when `--module` is provided):\n- `src/mailers/<Name>Mailer.ts` - The mailer class file\n- `src/mailers/<Name>MailerTemplate.tsx` - The JSX email template\n- `tests/mailers/<Name>Mailer.spec.ts` - The mailer test file\n- `tests/mailers/<Name>MailerTemplate.spec.ts` - The template test file\n\n### 2. Read the generated files\n\nRead all four generated files to understand the scaffolded code.\n\n### 3. Complete the mailer class\n\nEdit `src/mailers/<Name>Mailer.ts` to complete the implementation:\n\n- Adjust the `send` method config type if additional parameters are needed\n- Add any pre-send logic (validation, data transformation, etc.)\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { inject } from \"@ooneex/container\";\nimport type { IMailer } from \"@ooneex/mailer\";\nimport { type <Name>MailerPropsType, <Name>MailerTemplate } from \"./<Name>MailerTemplate\";\n\nexport class <Name>Mailer implements IMailer {\n constructor(\n @inject(\"mailer\")\n private readonly mailer: IMailer,\n ) {}\n\n public send = async (config: {\n to: string[];\n subject: string;\n from?: { name: string; address: string };\n data?: <Name>MailerPropsType;\n }): Promise<void> => {\n const { data, ...rest } = config;\n\n await this.mailer.send({\n ...rest,\n content: <Name>MailerTemplate(data),\n });\n };\n}\n```\n\n### 4. Complete the mailer template\n\nEdit `src/mailers/<Name>MailerTemplate.tsx` to complete the implementation:\n\n- Update `<Name>MailerPropsType` with the actual props needed for the email\n- Build the email body using `MailerLayout` components (Header, Body, Footer)\n- Add email content, styling, and dynamic data rendering\n\nThe generated template structure follows this pattern:\n\n```tsx\nimport { MailerLayout } from \"@ooneex/mailer\";\n\nexport type <Name>MailerPropsType = {\n link: string;\n};\n\nexport const <Name>MailerTemplate = (props?: <Name>MailerPropsType) => (\n <MailerLayout>\n <MailerLayout.Header />\n <MailerLayout.Body>\n <a href={props?.link}>Login</a>\n </MailerLayout.Body>\n <MailerLayout.Footer />\n </MailerLayout>\n);\n```\n\n### 5. Complete the test files\n\nEdit `tests/mailers/<Name>Mailer.spec.ts` and `tests/mailers/<Name>MailerTemplate.spec.ts` to add meaningful tests beyond the scaffolded ones.\n\n### 6. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/mailers/<Name>Mailer.ts src/mailers/<Name>MailerTemplate.tsx tests/mailers/<Name>Mailer.spec.ts tests/mailers/<Name>MailerTemplate.spec.ts\n```\n";var Yo="---\nname: make:middleware\ndescription: Generate a new middleware class with its test file, then complete the generated code. Use when creating a new HTTP or WebSocket middleware that implements IMiddleware from @ooneex/middleware.\n---\n\n# Make Middleware Class\n\nGenerate a new middleware class and its test file using the `make:middleware` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the middleware class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:middleware --name <name> --module <module> --is-socket <true|false>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The `--is-socket` option determines whether to generate an HTTP middleware or a WebSocket middleware (defaults to `false` if omitted). The command will generate:\n- `src/middlewares/<Name>Middleware.ts` - The middleware class file (or `modules/<module>/src/middlewares/<Name>Middleware.ts` with `--module`)\n- `tests/middlewares/<Name>Middleware.spec.ts` - The test file (or `modules/<module>/tests/middlewares/<Name>Middleware.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the middleware class\n\nEdit `src/middlewares/<Name>Middleware.ts` to complete the implementation:\n\n- Implement the `handler` method with actual middleware logic\n- Add request/response transformations, authentication checks, logging, etc.\n- Inject any required dependencies via the constructor\n\n**HTTP middleware** generated structure:\n\n```typescript\nimport type { ContextType } from \"@ooneex/controller\";\nimport { decorator, type IMiddleware } from \"@ooneex/middleware\";\n\n@decorator.middleware()\nexport class <Name>Middleware implements IMiddleware {\n public async handler(context: ContextType): Promise<ContextType> {\n // Example: Add custom header\n // context.response.header(\"X-Custom-Header\", \"value\");\n\n return context\n }\n}\n```\n\n**Socket middleware** generated structure:\n\n```typescript\nimport type { ContextType } from \"@ooneex/socket\";\nimport { decorator, type IMiddleware } from \"@ooneex/middleware\";\n\n@decorator.middleware()\nexport class <Name>Middleware implements IMiddleware {\n public async handler(context: ContextType): Promise<ContextType> {\n // Example: Add custom header\n // context.response.header(\"X-Custom-Header\", \"value\");\n\n return context\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/middlewares/<Name>Middleware.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, handler method)\n- Add tests relevant to the specific middleware behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Middleware } from \"@/middlewares/<Name>Middleware\";\n\ndescribe(\"<Name>Middleware\", () => {\n test(\"should have class name ending with 'Middleware'\", () => {\n expect(<Name>Middleware.name.endsWith(\"Middleware\")).toBe(true);\n });\n\n test(\"should have 'handler' method\", () => {\n expect(<Name>Middleware.prototype.handler).toBeDefined();\n expect(typeof <Name>Middleware.prototype.handler).toBe(\"function\");\n });\n});\n```\n\n### 5. Register the middleware in the module\n\nAdd the new middleware to the module's `middlewares` array in `src/<PascalModuleName>Module.ts` (e.g., `src/BookModule.ts` for the `book` module):\n\n```typescript\nimport type { ModuleType } from \"@ooneex/module\";\nimport { <Name>Middleware } from \"./middlewares/<Name>Middleware\";\n\nexport const <PascalModuleName>Module: ModuleType = {\n controllers: [],\n entities: [],\n permissions: [],\n middlewares: [<Name>Middleware],\n cronJobs: [],\n events: [],\n};\n```\n\nThe module file uses PascalCase naming: `<PascalModuleName>Module.ts` with export `<PascalModuleName>Module`.\n\nIf the module already has other middlewares registered, append the new middleware to the existing `middlewares` array and add the import alongside existing imports.\n\n### 6. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/middlewares/<Name>Middleware.ts tests/middlewares/<Name>Middleware.spec.ts\n```\n";var Qo="---\nname: make:migration\ndescription: Generate a new database migration file, then complete the generated code. Use when creating a new database migration for schema changes using @ooneex/migrations.\n---\n\n# Make Migration\n\nGenerate a new migration file using the `make:migration` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the migration file:\n\n```bash\nbunx @ooneex/cli@latest make:migration --module <module>\n```\n\nThe `--module` option is optional \u2014 if provided, the migration file is generated under `modules/<module>/src/migrations/` instead of `src/migrations/`. The command will:\n- Generate a timestamped migration file in `src/migrations/` (or `modules/<module>/src/migrations/` with `--module`)\n- Add a `migration:up` script to `package.json` if not already present\n\n### 2. Read the generated file\n\nRead the generated migration file in `src/migrations/` to understand the scaffolded code.\n\n### 3. Complete the migration\n\nEdit the generated migration file to implement:\n\n- The `up` method with the schema changes (create tables, add columns, create indexes, etc.)\n- The `down` method with the reverse operations to undo the migration\n\n### 4. Lint and format\n\nRun linting and formatting on the generated file:\n\n```bash\nbunx biome check --fix src/migrations/\n```\n";var Zo="---\nname: make:permission\ndescription: Generate a new permission class with its test file, then complete the generated code. Use when creating a new permission that extends Permission from @ooneex/permission.\n---\n\n# Make Permission Class\n\nGenerate a new permission class and its test file using the `make:permission` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the permission class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:permission --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/permissions/<Name>Permission.ts` - The permission class file (or `modules/<module>/src/permissions/<Name>Permission.ts` with `--module`)\n- `tests/permissions/<Name>Permission.spec.ts` - The test file (or `modules/<module>/tests/permissions/<Name>Permission.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the permission class\n\nEdit `src/permissions/<Name>Permission.ts` to complete the implementation:\n\n- Implement the `allow()` method with permission rules using `this.ability.can()`\n- Implement the `setUserPermissions()` method with role-based permission logic\n- Define which actions (read, create, update, delete, manage) are allowed on which entities\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { decorator, Permission } from \"@ooneex/permission\";\nimport type { IUser } from \"@ooneex/user\";\n\n@decorator.permission()\nexport class <Name>Permission extends Permission {\n public allow(): this {\n // Example: Add permissions using this.ability.can()\n // this.ability.can(\"read\", \"YourEntity\");\n // this.ability.can([\"read\", \"update\"], \"YourEntity\", { userId: user.id });\n\n return this;\n }\n\n public setUserPermissions(user: IUser | null): this {\n if (!user) {\n return this;\n }\n\n // Example: Grant full access to admins\n // const { roles } = user;\n // if (roles.includes(ERole.ADMIN)) {\n // this.ability.can(\"manage\", \"all\");\n // return this;\n // }\n\n // Example: Grant specific permissions based on roles\n // for (const role of roles) {\n // if (role === ERole.USER) {\n // this.ability.can([\"read\", \"update\"], \"YourEntity\", { userId: user.id });\n // }\n //\n // if (role === ERole.GUEST) {\n // this.ability.can(\"read\", \"YourEntity\", { public: true });\n // }\n // }\n\n return this;\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/permissions/<Name>Permission.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, extends Permission, allow, setUserPermissions methods)\n- Add tests relevant to the specific permission rules\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { Permission } from \"@ooneex/permission\";\nimport { <Name>Permission } from \"@/permissions/<Name>Permission\";\n\ndescribe(\"<Name>Permission\", () => {\n test(\"should have class name ending with 'Permission'\", () => {\n expect(<Name>Permission.name.endsWith(\"Permission\")).toBe(true);\n });\n\n test(\"should extend Permission\", () => {\n const permission = new <Name>Permission();\n expect(permission).toBeInstanceOf(Permission);\n });\n\n test(\"should have 'allow' method\", () => {\n expect(<Name>Permission.prototype.allow).toBeDefined();\n expect(typeof <Name>Permission.prototype.allow).toBe(\"function\");\n });\n\n test(\"should have 'setUserPermissions' method\", () => {\n expect(<Name>Permission.prototype.setUserPermissions).toBeDefined();\n expect(typeof <Name>Permission.prototype.setUserPermissions).toBe(\"function\");\n });\n});\n```\n\n### 5. Register the permission in the module\n\nAdd the new permission to the module's `permissions` array in `src/<PascalModuleName>Module.ts` (e.g., `src/BookModule.ts` for the `book` module):\n\n```typescript\nimport type { ModuleType } from \"@ooneex/module\";\nimport { <Name>Permission } from \"./permissions/<Name>Permission\";\n\nexport const <PascalModuleName>Module: ModuleType = {\n controllers: [],\n entities: [],\n permissions: [<Name>Permission],\n middlewares: [],\n cronJobs: [],\n events: [],\n};\n```\n\nThe module file uses PascalCase naming: `<PascalModuleName>Module.ts` with export `<PascalModuleName>Module`.\n\nIf the module already has other permissions registered, append the new permission to the existing `permissions` array and add the import alongside existing imports.\n\n### 6. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/permissions/<Name>Permission.ts tests/permissions/<Name>Permission.spec.ts\n```\n";var Xo="---\nname: make:pubsub\ndescription: Generate a new PubSub event class with its test file, then complete the generated code. Use when creating a new publish/subscribe event that extends PubSub from @ooneex/pub-sub.\n---\n\n# Make PubSub Event Class\n\nGenerate a new PubSub event class and its test file using the `make:pubsub` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the PubSub event class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:pubsub --name <name> --module <module> --channel <channel>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The `--channel` option is optional \u2014 if omitted, it defaults to the kebab-case form of the name (e.g., `UserCreated` becomes `user-created`). The command will generate:\n- `src/events/<Name>Event.ts` - The event class file (or `modules/<module>/src/events/<Name>Event.ts` with `--module`)\n- `tests/events/<Name>Event.spec.ts` - The test file (or `modules/<module>/tests/events/<Name>Event.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the PubSub event class\n\nEdit `src/events/<Name>Event.ts` to complete the implementation:\n\n- Define a proper data type instead of `Record<string, ScalarType>` for the event payload\n- Implement the `handler()` method with actual event handling logic\n- Set the appropriate channel name in `getChannel()`\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { inject } from \"@ooneex/container\";\nimport type { ScalarType } from \"@ooneex/types\";\nimport { decorator, PubSub, RedisPubSub } from \"@ooneex/pub-sub\";\n\n@decorator.pubSub()\nexport class <Name>Event<Data extends Record<string, ScalarType> = Record<string, ScalarType>> extends PubSub<Data> {\n constructor(\n @inject(RedisPubSub)\n client: RedisPubSub<Data>,\n ) {\n super(client);\n }\n\n public getChannel(): string {\n return \"<channel>\";\n }\n\n public async handler(context: { data: Data; channel: string }): Promise<void> {\n console.log(context);\n // TODO: Implement handler logic here\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/events/<Name>Event.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, getChannel, handler, publish, subscribe, unsubscribe, unsubscribeAll methods)\n- Add tests relevant to the specific event behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>PubSub } from \"@/pubsub/<Name>PubSub\";\n\ndescribe(\"<Name>PubSub\", () => {\n test(\"should have class name ending with 'PubSub'\", () => {\n expect(<Name>PubSub.name.endsWith(\"PubSub\")).toBe(true);\n });\n\n test(\"should have 'getChannel' method\", () => {\n expect(<Name>PubSub.prototype.getChannel).toBeDefined();\n expect(typeof <Name>PubSub.prototype.getChannel).toBe(\"function\");\n });\n\n test(\"should have 'handler' method\", () => {\n expect(<Name>PubSub.prototype.handler).toBeDefined();\n expect(typeof <Name>PubSub.prototype.handler).toBe(\"function\");\n });\n\n test(\"should have 'publish' method\", () => {\n expect(<Name>PubSub.prototype.publish).toBeDefined();\n expect(typeof <Name>PubSub.prototype.publish).toBe(\"function\");\n });\n\n test(\"should have 'subscribe' method\", () => {\n expect(<Name>PubSub.prototype.subscribe).toBeDefined();\n expect(typeof <Name>PubSub.prototype.subscribe).toBe(\"function\");\n });\n\n test(\"should have 'unsubscribe' method\", () => {\n expect(<Name>PubSub.prototype.unsubscribe).toBeDefined();\n expect(typeof <Name>PubSub.prototype.unsubscribe).toBe(\"function\");\n });\n\n test(\"should have 'unsubscribeAll' method\", () => {\n expect(<Name>PubSub.prototype.unsubscribeAll).toBeDefined();\n expect(typeof <Name>PubSub.prototype.unsubscribeAll).toBe(\"function\");\n });\n});\n```\n\n### 5. Register the event in the module\n\nAdd the new event to the module's `events` array in `src/<PascalModuleName>Module.ts` (e.g., `src/BookModule.ts` for the `book` module):\n\n```typescript\nimport type { ModuleType } from \"@ooneex/module\";\nimport { <Name>Event } from \"./events/<Name>Event\";\n\nexport const <PascalModuleName>Module: ModuleType = {\n controllers: [],\n entities: [],\n permissions: [],\n middlewares: [],\n cronJobs: [],\n events: [<Name>Event],\n};\n```\n\nThe module file uses PascalCase naming: `<PascalModuleName>Module.ts` with export `<PascalModuleName>Module`.\n\nIf the module already has other events registered, append the new event to the existing `events` array and add the import alongside existing imports.\n\n### 6. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/events/<Name>Event.ts tests/events/<Name>Event.spec.ts\n```\n";var Jo="---\nname: make:repository\ndescription: Generate a new repository class with its test file, then complete the generated code. Use when creating a new TypeORM repository for database operations on an entity.\n---\n\n# Make Repository Class\n\nGenerate a new repository class and its test file using the `make:repository` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the repository class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:repository --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/repositories/<Name>Repository.ts` - The repository class file (or `modules/<module>/src/repositories/<Name>Repository.ts` with `--module`)\n- `tests/repositories/<Name>Repository.spec.ts` - The test file (or `modules/<module>/tests/repositories/<Name>Repository.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the repository class\n\nEdit `src/repositories/<Name>Repository.ts` to complete the implementation:\n\n- Verify the entity import path matches the actual entity location\n- Adjust the `find` method's search fields (default searches `name` with `ILike`)\n- Customize relations loading in `findOne`/`findOneBy` if needed\n\n#### Adding methods\n\nLook at the entity's fields, relations, and business context to determine if custom domain-specific methods are needed. For example:\n- A `SessionRepository` might need `revokeSession(sessionId: string)` and `revokeAllUserSessions(userId: string)`\n- A `NotificationRepository` might need `markAsRead(id: string)` and `markAllAsRead(userId: string)`\n- Entities with status fields may need methods like `archive(id: string)` or `activate(id: string)`\n\nRead related entities, services, or actions in the module to understand what operations the repository should support, then add the appropriate methods.\n\n#### Removing methods\n\nRemove scaffolded methods that don't make sense for the entity's context:\n- Remove `createMany`/`updateMany` if the entity is always managed individually (e.g., user profiles, settings)\n- Remove `delete` if the entity uses soft deletes only (use a custom `softDelete` or `archive` method instead)\n- Remove `find` if the entity is only ever accessed by ID or specific criteria (e.g., singleton config entities)\n- Remove `count` if there's no use case for counting records of this entity\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { inject } from \"@ooneex/container\";\nimport type { ITypeormDatabase } from \"@ooneex/database\";\nimport { decorator } from \"@ooneex/repository\";\nimport type { FilterResultType } from \"@ooneex/types\";\nimport type { FindManyOptions, FindOptionsWhere, Repository, SaveOptions, UpdateResult } from \"typeorm\";\nimport { ILike } from \"typeorm\";\nimport { <Name>Entity } from \"../entities/<Name>Entity\";\n\n@decorator.repository()\nexport class <Name>Repository {\n constructor(\n @inject(\"database\")\n private readonly database: ITypeormDatabase,\n ) {}\n\n public async open(): Promise<Repository<<Name>Entity>> {\n return await this.database.open(<Name>Entity);\n }\n\n public async close(): Promise<void> {\n await this.database.close();\n }\n\n public async find(\n criteria: FindManyOptions<<Name>Entity> & { page?: number; limit?: number; q?: string },\n ): Promise<FilterResultType<<Name>Entity>> {\n // ... pagination and search logic\n }\n\n public async findOne(id: string): Promise<<Name>Entity | null> { ... }\n public async findOneBy(criteria: FindOptionsWhere<<Name>Entity>): Promise<<Name>Entity | null> { ... }\n public async create(entity: <Name>Entity, options?: SaveOptions): Promise<<Name>Entity> { ... }\n public async createMany(entities: <Name>Entity[], options?: SaveOptions): Promise<<Name>Entity[]> { ... }\n public async update(entity: <Name>Entity, options?: SaveOptions): Promise<<Name>Entity> { ... }\n public async updateMany(entities: <Name>Entity[], options?: SaveOptions): Promise<<Name>Entity[]> { ... }\n public async delete(criteria: FindOptionsWhere<<Name>Entity> | FindOptionsWhere<<Name>Entity>[]): Promise<UpdateResult> { ... }\n public async count(criteria?: FindOptionsWhere<<Name>Entity> | FindOptionsWhere<<Name>Entity>[]): Promise<number> { ... }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/repositories/<Name>Repository.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep scaffolded tests for methods that remain in the repository (remove tests for methods that were removed)\n- Add tests for any custom domain-specific methods added to the repository\n- Add tests relevant to the specific repository behavior\n\n### 5. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/repositories/<Name>Repository.ts tests/repositories/<Name>Repository.spec.ts\n```\n";var jo="---\nname: make:seed\ndescription: Generate a new database seed file, then complete the generated code. Use when creating seed data for populating the database using @ooneex/seeds.\n---\n\n# Make Seed\n\nGenerate a new seed file using the `make:seed` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the seed file:\n\n```bash\nbunx @ooneex/cli@latest make:seed --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, the seed file is generated under `modules/<module>/src/seeds/` instead of `src/seeds/`. The command will:\n- Generate a seed file in `src/seeds/` (or `modules/<module>/src/seeds/` with `--module`)\n- Add a `seed:run` script to `package.json` if not already present\n\n### 2. Read the generated file\n\nRead the generated seed file in `src/seeds/` to understand the scaffolded code.\n\n### 3. Complete the seed\n\nEdit the generated seed file to implement:\n\n- Import the relevant entity classes\n- Create seed data with hardcoded nanoid values for `id` fields (generate via `bun -e \"import { random } from '@ooneex/utils'; console.log(random.nanoid())\"`)\n- Do NOT use sequential IDs like `\"item-1\"`, `\"item-2\"`\n- Ensure the same entity uses the same ID everywhere it appears\n\n### 4. Lint and format\n\nRun linting and formatting on the generated file:\n\n```bash\nbunx biome check --fix src/seeds/\n```\n";var ei="---\nname: make:service\ndescription: Generate a new service class with its test file, then complete the generated code. Use when creating a new business logic service that implements IService from @ooneex/service.\n---\n\n# Make Service Class\n\nGenerate a new service class and its test file using the `make:service` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the service class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:service --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/services/<Name>Service.ts` - The service class file (or `modules/<module>/src/services/<Name>Service.ts` with `--module`)\n- `tests/services/<Name>Service.spec.ts` - The test file (or `modules/<module>/tests/services/<Name>Service.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the service class\n\nEdit `src/services/<Name>Service.ts` to complete the implementation:\n\n- Define a proper type for `ServiceDataType` instead of `Record<string, unknown>`\n- Implement the `execute()` method with actual business logic\n- Inject any required dependencies (repositories, other services, etc.) via the constructor\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { decorator } from \"@ooneex/service\";\nimport type { IService } from \"@ooneex/service\";\n\ntype ServiceDataType = Record<string, unknown>;\n\n@decorator.service()\nexport class <Name>Service<T extends ServiceDataType = ServiceDataType> implements IService<T> {\n public async execute(data?: T): Promise<void> {\n // TODO: Implement service logic\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/services/<Name>Service.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, execute method)\n- Add tests relevant to the specific service behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>Service } from \"@/services/<Name>Service\";\n\ndescribe(\"<Name>Service\", () => {\n test(\"should have class name ending with 'Service'\", () => {\n expect(<Name>Service.name.endsWith(\"Service\")).toBe(true);\n });\n\n test(\"should have 'execute' method\", () => {\n expect(<Name>Service.prototype.execute).toBeDefined();\n expect(typeof <Name>Service.prototype.execute).toBe(\"function\");\n });\n});\n```\n\n### 5. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/services/<Name>Service.ts tests/services/<Name>Service.spec.ts\n```\n";var ti="---\nname: make:storage\ndescription: Generate a new storage class with its test file, then complete the generated code. Use when creating a new S3-compatible storage adapter that extends Storage from @ooneex/storage.\n---\n\n# Make Storage Class\n\nGenerate a new storage class and its test file using the `make:storage` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the storage class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:storage --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/storage/<Name>Storage.ts` - The storage class file (or `modules/<module>/src/storage/<Name>Storage.ts` with `--module`)\n- `tests/storage/<Name>Storage.spec.ts` - The test file (or `modules/<module>/tests/storage/<Name>Storage.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the storage class\n\nEdit `src/storage/<Name>Storage.ts` to complete the implementation:\n\n- Set the `bucket` property to the appropriate bucket name\n- Verify the environment variable names match the project configuration (`STORAGE_<NAME_UPPER>_ACCESS_KEY`, `STORAGE_<NAME_UPPER>_SECRET_KEY`, `STORAGE_<NAME_UPPER>_ENDPOINT`, `STORAGE_<NAME_UPPER>_REGION`)\n- Add any additional storage-specific methods if needed\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { Storage, decorator, StorageException } from \"@ooneex/storage\";\nimport type { S3Options } from \"bun\";\n\n@decorator.storage()\nexport class <Name>Storage extends Storage {\n protected bucket: string;\n private readonly accessKey: string;\n private readonly secretKey: string;\n private readonly endpoint: string;\n private readonly region: string;\n\n constructor(options?: {\n accessKey?: string;\n secretKey?: string;\n endpoint?: string;\n region?: string;\n }) {\n super();\n\n const accessKey = options?.accessKey || Bun.env.STORAGE_<NAME_UPPER>_ACCESS_KEY;\n const secretKey = options?.secretKey || Bun.env.STORAGE_<NAME_UPPER>_SECRET_KEY;\n const endpoint = options?.endpoint || Bun.env.STORAGE_<NAME_UPPER>_ENDPOINT;\n\n // ... validation throws StorageException if missing ...\n\n this.accessKey = accessKey;\n this.secretKey = secretKey;\n this.endpoint = endpoint;\n this.region = options?.region || Bun.env.STORAGE_<NAME_UPPER>_REGION || \"auto\";\n }\n\n public getOptions(): S3Options {\n return {\n accessKeyId: this.accessKey,\n secretAccessKey: this.secretKey,\n endpoint: this.endpoint,\n bucket: this.bucket,\n region: this.region,\n };\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/storage/<Name>Storage.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, bucket field, getOptions method)\n- Add tests relevant to the specific storage class behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>StorageAdapter } from \"@/storage/<Name>StorageAdapter\";\n\ndescribe(\"<Name>StorageAdapter\", () => {\n test(\"should have class name ending with 'StorageAdapter'\", () => {\n expect(<Name>StorageAdapter.name.endsWith(\"StorageAdapter\")).toBe(true);\n });\n\n test(\"should have 'bucket' field\", () => {\n expect(\"bucket\" in <Name>StorageAdapter.prototype || \"bucket\" in Object.getOwnPropertyNames(<Name>StorageAdapter.prototype)).toBe(true);\n });\n\n test(\"should have 'getOptions' method\", () => {\n expect(<Name>StorageAdapter.prototype.getOptions).toBeDefined();\n expect(typeof <Name>StorageAdapter.prototype.getOptions).toBe(\"function\");\n });\n});\n```\n\n### 5. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/storage/<Name>Storage.ts tests/storage/<Name>Storage.spec.ts\n```\n";var si="---\nname: make:vector-database\ndescription: Generate a new vector database class with its test file, then complete the generated code. Use when creating a new vector database that extends VectorDatabase from @ooneex/rag.\n---\n\n# Make Vector Database Class\n\nGenerate a new vector database class and its test file using the `make:vector-database` CLI command, then complete the generated code with proper implementation.\n\n## Coding Conventions\n\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`)\n- Always use arrow functions when possible, but NOT for class methods (class methods use regular method syntax)\n- End type names with the `Type` suffix (e.g., `ExceptionStackFrameType`, `ServiceDataType`)\n- Start interface names with the `I` prefix (e.g., `IException`, `IService`, `IAiChat`)\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Run the generator\n\nRun the following command to scaffold the vector database class and test files:\n\n```bash\nbunx @ooneex/cli@latest make:vector-database --name <name> --module <module>\n```\n\nWhere `<name>` is the name provided by the user. The `--module` option is optional \u2014 if provided, files are generated under `modules/<module>/` instead of the project root. The command will generate:\n- `src/databases/<Name>VectorDatabase.ts` - The vector database class file (or `modules/<module>/src/databases/<Name>VectorDatabase.ts` with `--module`)\n- `tests/databases/<Name>VectorDatabase.spec.ts` - The test file (or `modules/<module>/tests/databases/<Name>VectorDatabase.spec.ts` with `--module`)\n\n### 2. Read the generated files\n\nRead both generated files to understand the scaffolded code.\n\n### 3. Complete the vector database class\n\nEdit `src/databases/<Name>VectorDatabase.ts` to complete the implementation:\n\n- Set the `getDatabaseUri()` return value to the actual LanceDB database path\n- Configure the embedding provider and model in `getEmbeddingModel()`\n- Define the custom data fields in `DataType` and map them in `getSchema()`\n- Import the appropriate Apache Arrow types for your schema fields\n\nThe generated class structure follows this pattern:\n\n```typescript\nimport { VectorDatabase, decorator } from \"@ooneex/rag\";\nimport type { EmbeddingModelType, EmbeddingProviderType, FieldValueType } from \"@ooneex/rag\";\nimport { Utf8 } from \"apache-arrow\";\n\ntype DataType = {\n name: string;\n};\n\n@decorator.vectorDatabase()\nexport class <Name>VectorDatabase extends VectorDatabase<DataType> {\n public getDatabaseUri(): string {\n return \"\";\n }\n\n public getEmbeddingModel(): { provider: EmbeddingProviderType; model: EmbeddingModelType[\"model\"] } {\n return { provider: \"openai\", model: \"text-embedding-ada-002\" };\n }\n\n public getSchema(): { [K in keyof DataType]: FieldValueType } {\n return {\n name: new Utf8(),\n };\n }\n}\n```\n\n### 4. Complete the test file\n\nEdit `tests/databases/<Name>VectorDatabase.spec.ts` to add meaningful tests beyond the scaffolded ones:\n\n- Keep the existing scaffolded tests (class name, getDatabaseUri, getEmbeddingModel, getSchema methods)\n- Add tests relevant to the specific vector database class behavior\n\nThe generated test structure follows this pattern:\n\n```typescript\nimport { describe, expect, test } from \"bun:test\";\nimport { <Name>VectorDatabase } from \"@/databases/<Name>VectorDatabase\";\n\ndescribe(\"<Name>VectorDatabase\", () => {\n test(\"should have class name ending with 'VectorDatabase'\", () => {\n expect(<Name>VectorDatabase.name.endsWith(\"VectorDatabase\")).toBe(true);\n });\n\n test(\"should have 'getDatabaseUri' method\", () => {\n expect(<Name>VectorDatabase.prototype.getDatabaseUri).toBeDefined();\n expect(typeof <Name>VectorDatabase.prototype.getDatabaseUri).toBe(\"function\");\n });\n\n test(\"should have 'getEmbeddingModel' method\", () => {\n expect(<Name>VectorDatabase.prototype.getEmbeddingModel).toBeDefined();\n expect(typeof <Name>VectorDatabase.prototype.getEmbeddingModel).toBe(\"function\");\n });\n\n test(\"should have 'getSchema' method\", () => {\n expect(<Name>VectorDatabase.prototype.getSchema).toBeDefined();\n expect(typeof <Name>VectorDatabase.prototype.getSchema).toBe(\"function\");\n });\n});\n```\n\n### 5. Lint and format\n\nRun linting and formatting on the generated files:\n\n```bash\nbunx biome check --fix src/databases/<Name>VectorDatabase.ts tests/databases/<Name>VectorDatabase.spec.ts\n```\n";var ri="---\nname: optimize\ndescription: Optimize a module's codebase for quality, performance, and clean conventions. Enforces arrow functions (except class methods), type/interface naming, removes duplication, and ensures only important tests remain.\n---\n\n# Optimize Codebase\n\nOptimize a module's codebase for quality, performance, and clean conventions.\n\n## Coding Conventions\n\nApply these conventions across all files in the target module:\n\n- **Arrow functions everywhere** \u2014 use arrow functions for all function expressions, callbacks, standalone functions, and variable declarations. The ONLY exception is class methods, which must use regular method syntax.\n- **Type naming** \u2014 all type aliases must end with the `Type` suffix (e.g., `UserDataType`, `ConfigOptionsType`). Rename any that don't comply.\n- **Interface naming** \u2014 all interface names must start with the `I` prefix (e.g., `IUser`, `IService`, `IRepository`). Rename any that don't comply.\n- **No definite assignment assertions** \u2014 never use `!` on class properties (e.g., `email!: string`). Use a default value or make the property optional (`?`) instead.\n- Always explicitly show visibility on class methods and properties (`private`, `public`, `protected`).\n- For Entity class, if property is optional, add `null` to its type.\n\n## Steps\n\n### 1. Identify the target\n\nDetermine the module to optimize. If the user specifies a module name, work in `modules/<module>/`. If no module is specified, ask the user which module to optimize.\n\n### 2. Read and analyze the module\n\nRead all source files (`src/**/*.ts`) and test files (`tests/**/*.ts`) in the target module. Build a full picture of:\n\n- All types, interfaces, classes, and functions\n- Dependencies between files\n- Existing test coverage\n\n### 3. Enforce naming conventions\n\nScan every file and fix:\n\n- **Types not ending with `Type`** \u2014 rename the type and update all references across the module\n- **Interfaces not starting with `I`** \u2014 rename the interface and update all references across the module\n- **Non-arrow functions** \u2014 convert all function expressions, callbacks, and standalone functions to arrow functions. Do NOT convert class methods.\n- **Missing visibility modifiers** \u2014 add explicit `public`, `private`, or `protected` to all class methods and properties\n\n### 4. Remove code duplication\n\nIdentify duplicated or near-duplicated code within the module:\n\n- Extract shared logic into well-named helper arrow functions or base classes\n- Consolidate repeated type definitions\n- Merge similar utility functions\n- Remove dead code (unused imports, unreachable branches, unused variables)\n\n### 5. Optimize for performance\n\nReview and improve:\n\n- Replace inefficient loops or repeated iterations with single-pass approaches where possible\n- Use `Map`/`Set` instead of arrays for lookups when appropriate\n- Avoid unnecessary object spreads or deep clones\n- Prefer early returns to reduce nesting\n- Remove unnecessary `async`/`await` where a direct return suffices\n- Eliminate redundant null/undefined checks when the type system already guarantees the value\n\n### 6. Optimize tests\n\nReview all test files and restructure:\n\n- **Remove trivial tests** \u2014 delete tests that only check obvious things (e.g., \"class name ends with X\", \"method exists\") unless they serve as smoke tests for generated code\n- **Keep and improve important tests** \u2014 focus on tests that verify actual business logic, edge cases, error handling, and integration behavior\n- **Write fewer but more meaningful tests** \u2014 each test should validate a real scenario or invariant, not just existence checks\n- **Consolidate redundant test cases** \u2014 merge tests that cover the same code path with slightly different inputs into parameterized patterns\n- **Ensure critical paths are covered** \u2014 every public method with logic should have at least one test covering its happy path and one covering its error/edge case\n\n### 7. Final cleanup\n\n- Remove all unused imports\n- Remove empty files or files with no exports\n- Ensure consistent formatting\n\n### 8. Lint and format\n\nRun linting and formatting on all modified files:\n\n```bash\nbunx biome check --fix <list of modified files>\n```\n\n### 9. Run tests\n\nRun the module's tests to verify nothing is broken:\n\n```bash\nbun test <module test directory>\n```\n\nIf any test fails, fix the issue and re-run until all tests pass.\n";var nc={"make.ai":Go,"make.analytics":$o,"make.cache":qo,"make.controller":Wo,"make.cron":Fo,"make.database":Ko,"make.entity":Ho,"make.logger":Vo,"make.mailer":zo,"make.middleware":Yo,"make.migration":Qo,"make.permission":Zo,"make.pubsub":Xo,"make.repository":Jo,"make.seed":jo,"make.service":ei,"make.storage":ti,"make.vector-database":si,commit:Uo,optimize:ri};class Ve{getName(){return"make:claude:skill"}getDescription(){return"Generate Claude skills from templates"}async run(){let e=He(".claude","skills"),t=He(process.cwd(),e),s=new ac;for(let[r,o]of Object.entries(nc)){let i=r.replace(/\./g,"-"),a=He(t,i,"SKILL.md");await Bun.write(a,o),s.success(`${He(e,i,"SKILL.md")} created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}}Ve=b([x.command()],Ve);import{basename as cc,join as G}from"path";import{TerminalLogger as pc}from"@ooneex/logger";import{toPascalCase as kt}from"@ooneex/utils";var oi=`import { describe, expect, test } from "bun:test";
1898
1821
  import { {{NAME}}Cron } from "@/cron/{{NAME}}Cron";
1899
1822
 
1900
1823
  describe("{{NAME}}Cron", () => {
@@ -1917,7 +1840,7 @@ describe("{{NAME}}Cron", () => {
1917
1840
  expect(typeof {{NAME}}Cron.prototype.handler).toBe("function");
1918
1841
  });
1919
1842
  });
1920
- `;var ai=`import type { TimeZoneType } from "@ooneex/country";
1843
+ `;var ii=`import type { TimeZoneType } from "@ooneex/country";
1921
1844
  import type { CronTimeType } from "@ooneex/cron";
1922
1845
  import { Cron, decorator } from "@ooneex/cron";
1923
1846
 
@@ -1938,9 +1861,9 @@ export class {{NAME}}Cron extends Cron {
1938
1861
  // console.log("{{NAME}}Cron handler executed");
1939
1862
  }
1940
1863
  }
1941
- `;class Ke{getName(){return"make:cron"}getDescription(){return"Generate a new cron class"}async addToModule(e,t){let s=await Bun.file(e).text(),r=`${t}Cron`,o=`import { ${r} } from "./cron/${r}";
1864
+ `;class ze{getName(){return"make:cron"}getDescription(){return"Generate a new cron class"}async addToModule(e,t){let s=await Bun.file(e).text(),r=`${t}Cron`,o=`import { ${r} } from "./cron/${r}";
1942
1865
  `,i=s.lastIndexOf("import "),a=s.indexOf(`
1943
- `,i);s=`${s.slice(0,a+1)}${o}${s.slice(a+1)}`;let n=/(cronJobs:\s*\[)([^\]]*)/s,d=s.match(n);if(d){let l=d[2]?.trim(),c=l?`${l}, ${r}`:r;s=s.replace(n,`$1${c}`)}await Bun.write(e,s)}async run(e){let{name:t,module:s}=e;if(!t)t=await v({message:"Enter cron name"});t=Lt(t).replace(/Cron$/,"");let r=ai.replace(/{{NAME}}/g,t),o=s?G("modules",s):".",i=G(o,"src","cron"),a=G(process.cwd(),i),n=G(a,`${t}Cron.ts`);await Bun.write(n,r);let d=ii.replace(/{{NAME}}/g,t),l=G(o,"tests","cron"),c=G(process.cwd(),l),u=G(c,`${t}Cron.spec.ts`);await Bun.write(u,d);let p=s?Lt(s):Lt(Xl(process.cwd())),m=G(process.cwd(),o,"src",`${p}Module.ts`);if(await Bun.file(m).exists())await this.addToModule(m,t);let h=new Jl;h.success(`${G(i,t)}Cron.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),h.success(`${G(l,t)}Cron.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/cron"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}Ke=b([x.command()],Ke);import{join as Y}from"path";import{TerminalLogger as tc}from"@ooneex/logger";import{toPascalCase as sc}from"@ooneex/utils";var ni=`import { describe, expect, test } from "bun:test";
1866
+ `,i);s=`${s.slice(0,a+1)}${o}${s.slice(a+1)}`;let n=/(cronJobs:\s*\[)([^\]]*)/s,l=s.match(n);if(l){let d=l[2]?.trim(),c=d?`${d}, ${r}`:r;s=s.replace(n,`$1${c}`)}await Bun.write(e,s)}async run(e){let{name:t,module:s}=e;if(!t)t=await A({message:"Enter cron name"});t=kt(t).replace(/Cron$/,"");let r=ii.replace(/{{NAME}}/g,t),o=s?G("modules",s):".",i=G(o,"src","cron"),a=G(process.cwd(),i),n=G(a,`${t}Cron.ts`);await Bun.write(n,r);let l=oi.replace(/{{NAME}}/g,t),d=G(o,"tests","cron"),c=G(process.cwd(),d),u=G(c,`${t}Cron.spec.ts`);await Bun.write(u,l);let m=s?kt(s):kt(cc(process.cwd())),p=G(process.cwd(),o,"src",`${m}Module.ts`);if(await Bun.file(p).exists())await this.addToModule(p,t);let h=new pc;h.success(`${G(i,t)}Cron.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),h.success(`${G(d,t)}Cron.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/cron"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}ze=b([x.command()],ze);import{join as Y}from"path";import{TerminalLogger as hc}from"@ooneex/logger";import{toPascalCase as fc}from"@ooneex/utils";var ai=`import { describe, expect, test } from "bun:test";
1944
1867
  import { {{NAME}}Database } from "@/databases/{{NAME}}Database";
1945
1868
 
1946
1869
  describe("{{NAME}}Database", () => {
@@ -1953,7 +1876,7 @@ describe("{{NAME}}Database", () => {
1953
1876
  expect(typeof {{NAME}}Database.prototype.getSource).toBe("function");
1954
1877
  });
1955
1878
  });
1956
- `;var di=`import { DataSource } from "typeorm";
1879
+ `;var ni=`import { DataSource } from "typeorm";
1957
1880
  import { TypeormDatabase, DatabaseException, decorator } from "@ooneex/database";
1958
1881
 
1959
1882
  @decorator.database()
@@ -1976,7 +1899,7 @@ export class {{NAME}}Database extends TypeormDatabase {
1976
1899
  return this.source;
1977
1900
  }
1978
1901
  }
1979
- `;class He{getName(){return"make:database"}getDescription(){return"Generate a new database class"}async run(e){let{name:t,module:s}=e;if(!t)t=await v({message:"Enter database name"});t=sc(t).replace(/DatabaseAdapter$/,"").replace(/Database$/,"");let r=di.replace(/{{NAME}}/g,t),o=s?Y("modules",s):".",i=Y(o,"src","databases"),a=Y(process.cwd(),i),n=Y(a,`${t}Database.ts`);await Bun.write(n,r);let d=ni.replace(/{{NAME}}/g,t),l=Y(o,"tests","databases"),c=Y(process.cwd(),l),u=Y(c,`${t}Database.spec.ts`);await Bun.write(u,d);let p=new tc;p.success(`${Y(i,t)}Database.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),p.success(`${Y(l,t)}Database.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/database"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}He=b([x.command()],He);import{join as Oi}from"path";import{TerminalLogger as Ac}from"@ooneex/logger";var{YAML:Di}=globalThis.Bun;var ci=te(ae(),1),li=["clickhouse","elasticsearch","grafana","jaeger","keycloak","libretranslate","maildev","memcached","minio","mongodb","mysql","nats","postgres","prometheus","rabbitmq","redis","temporal","vault"],mi=async(e)=>{return(await ci.prompt({type:"autocomplete",name:"service",message:e.message,initial:e.initial,choices:li.map((s)=>s),validate:(s)=>{if(!li.includes(s))return"Docker service is invalid";return!0}})).service};var pi=`services:
1902
+ `;class Ye{getName(){return"make:database"}getDescription(){return"Generate a new database class"}async run(e){let{name:t,module:s}=e;if(!t)t=await A({message:"Enter database name"});t=fc(t).replace(/DatabaseAdapter$/,"").replace(/Database$/,"");let r=ni.replace(/{{NAME}}/g,t),o=s?Y("modules",s):".",i=Y(o,"src","databases"),a=Y(process.cwd(),i),n=Y(a,`${t}Database.ts`);await Bun.write(n,r);let l=ai.replace(/{{NAME}}/g,t),d=Y(o,"tests","databases"),c=Y(process.cwd(),d),u=Y(c,`${t}Database.spec.ts`);await Bun.write(u,l);let m=new hc;m.success(`${Y(i,t)}Database.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),m.success(`${Y(d,t)}Database.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/database"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}Ye=b([x.command()],Ye);import{join as Ii}from"path";import{TerminalLogger as Pc}from"@ooneex/logger";var{YAML:Bi}=globalThis.Bun;var di=te(ae(),1),li=["clickhouse","elasticsearch","grafana","jaeger","keycloak","libretranslate","maildev","memcached","minio","mongodb","mysql","nats","postgres","prometheus","rabbitmq","redis","temporal","vault"],ci=async(e)=>{return(await di.prompt({type:"autocomplete",name:"service",message:e.message,initial:e.initial,choices:li.map((s)=>s),validate:(s)=>{if(!li.includes(s))return"Docker service is invalid";return!0}})).service};var pi=`services:
1980
1903
  # ClickHouse - Column-oriented OLAP database for analytics
1981
1904
  # Docs: https://clickhouse.com/docs
1982
1905
  # HTTP API: http://localhost:8123
@@ -1997,7 +1920,7 @@ export class {{NAME}}Database extends TypeormDatabase {
1997
1920
 
1998
1921
  volumes:
1999
1922
  clickhouse_data:
2000
- `;var ui=`services:
1923
+ `;var mi=`services:
2001
1924
  # Elasticsearch - Full-text search and analytics engine
2002
1925
  # Docs: https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
2003
1926
  # HTTP API: http://localhost:9200
@@ -2018,7 +1941,7 @@ volumes:
2018
1941
 
2019
1942
  volumes:
2020
1943
  elasticsearch_data:
2021
- `;var hi=`services:
1944
+ `;var ui=`services:
2022
1945
  # Grafana - Metrics visualization and dashboards
2023
1946
  # Docs: https://grafana.com/docs/grafana/latest/
2024
1947
  # Web UI: http://localhost:3000 (ooneex/ooneex)
@@ -2036,7 +1959,7 @@ volumes:
2036
1959
 
2037
1960
  volumes:
2038
1961
  grafana_data:
2039
- `;var fi=`services:
1962
+ `;var hi=`services:
2040
1963
  # Jaeger - Distributed tracing system
2041
1964
  # Docs: https://www.jaegertracing.io/docs/
2042
1965
  # Web UI: http://localhost:16686
@@ -2050,7 +1973,7 @@ volumes:
2050
1973
  - "16686:16686"
2051
1974
  - "6831:6831/udp"
2052
1975
  - "14268:14268"
2053
- `;var yi=`services:
1976
+ `;var fi=`services:
2054
1977
  # Keycloak - Identity and access management
2055
1978
  # Docs: https://www.keycloak.org/documentation
2056
1979
  # Admin Console: http://localhost:8080 (ooneex/ooneex)
@@ -2064,7 +1987,7 @@ volumes:
2064
1987
  - KEYCLOAK_ADMIN=ooneex
2065
1988
  - KEYCLOAK_ADMIN_PASSWORD=ooneex
2066
1989
  command: start-dev
2067
- `;var gi=`services:
1990
+ `;var yi=`services:
2068
1991
  # LibreTranslate - Self-hosted machine translation API
2069
1992
  # Docs: https://libretranslate.com/docs/
2070
1993
  # API: http://localhost:4000
@@ -2091,7 +2014,7 @@ volumes:
2091
2014
 
2092
2015
  volumes:
2093
2016
  libretranslate_models:
2094
- `;var bi=`services:
2017
+ `;var gi=`services:
2095
2018
  # MailDev - Email testing tool with web UI
2096
2019
  # Docs: https://github.com/maildev/maildev
2097
2020
  # Web UI: http://localhost:1080
@@ -2102,7 +2025,7 @@ volumes:
2102
2025
  ports:
2103
2026
  - "1080:1080"
2104
2027
  - "1025:1025"
2105
- `;var xi=`services:
2028
+ `;var bi=`services:
2106
2029
  # Memcached - Distributed memory caching system
2107
2030
  # Docs: https://memcached.org/
2108
2031
  # Connection: localhost:11211
@@ -2112,7 +2035,7 @@ volumes:
2112
2035
  restart: "on-failure"
2113
2036
  ports:
2114
2037
  - "11211:11211"
2115
- `;var wi=`services:
2038
+ `;var xi=`services:
2116
2039
  # MinIO - S3-compatible object storage
2117
2040
  # Docs: https://min.io/docs/minio/container/index.html
2118
2041
  # API: http://localhost:9000
@@ -2133,7 +2056,7 @@ volumes:
2133
2056
 
2134
2057
  volumes:
2135
2058
  minio_data:
2136
- `;var Ei=`services:
2059
+ `;var wi=`services:
2137
2060
  # MongoDB - NoSQL document database
2138
2061
  # Docs: https://www.mongodb.com/docs/
2139
2062
  # Connection: mongodb://ooneex:ooneex@localhost:27017/ooneex
@@ -2152,7 +2075,7 @@ volumes:
2152
2075
 
2153
2076
  volumes:
2154
2077
  mongodb_data:
2155
- `;var Ai=`services:
2078
+ `;var vi=`services:
2156
2079
  # MySQL - Alternative relational database
2157
2080
  # Docs: https://dev.mysql.com/doc/
2158
2081
  # Connection: mysql://ooneex:ooneex@localhost:3306/ooneex
@@ -2172,7 +2095,7 @@ volumes:
2172
2095
 
2173
2096
  volumes:
2174
2097
  mysql_db:
2175
- `;var vi=`services:
2098
+ `;var Ei=`services:
2176
2099
  # NATS - High-performance messaging system with JetStream
2177
2100
  # Docs: https://docs.nats.io/
2178
2101
  # Client: localhost:4222
@@ -2185,7 +2108,7 @@ volumes:
2185
2108
  - "4222:4222"
2186
2109
  - "8222:8222"
2187
2110
  command: "--jetstream --http_port 8222"
2188
- `;var Ni=`services:
2111
+ `;var Ai=`services:
2189
2112
  # Jade - FastAPI REST API to fetch YouTube metadata and download videos or audio via Dockerized microservice.
2190
2113
  # API: http://localhost:8000
2191
2114
  # Docs: http://localhost:8000/docs
@@ -2203,7 +2126,7 @@ volumes:
2203
2126
 
2204
2127
  volumes:
2205
2128
  jade_data:
2206
- `;var Si=`services:
2129
+ `;var Ti=`services:
2207
2130
  # PostgreSQL - Primary relational database
2208
2131
  # Docs: https://www.postgresql.org/docs/
2209
2132
  # Connection: postgresql://ooneex:ooneex@localhost:5432/ooneex
@@ -2224,7 +2147,7 @@ volumes:
2224
2147
 
2225
2148
  volumes:
2226
2149
  postgres_db:
2227
- `;var Ti=`services:
2150
+ `;var Si=`services:
2228
2151
  # Prometheus - Metrics collection and monitoring
2229
2152
  # Docs: https://prometheus.io/docs/
2230
2153
  # Web UI: http://localhost:9090
@@ -2239,7 +2162,7 @@ volumes:
2239
2162
 
2240
2163
  volumes:
2241
2164
  prometheus_data:
2242
- `;var Ri=`services:
2165
+ `;var Ni=`services:
2243
2166
  # RabbitMQ - Message broker for async processing
2244
2167
  # Docs: https://www.rabbitmq.com/docs
2245
2168
  # AMQP: amqp://ooneex:ooneex@localhost:5672/ooneex
@@ -2261,7 +2184,7 @@ volumes:
2261
2184
 
2262
2185
  volumes:
2263
2186
  rabbitmq_data:
2264
- `;var Mi=`services:
2187
+ `;var Ri=`services:
2265
2188
  # Redis - In-memory data store for caching and sessions
2266
2189
  # Docs: https://redis.io/docs/
2267
2190
  # Connection: redis://localhost:6379
@@ -2293,7 +2216,7 @@ volumes:
2293
2216
  - POSTGRES_USER=ooneex
2294
2217
  - POSTGRES_PWD=ooneex
2295
2218
  - POSTGRES_SEEDS=postgres
2296
- `;var _i=`services:
2219
+ `;var Mi=`services:
2297
2220
  # Vault - Secrets management and encryption
2298
2221
  # Docs: https://developer.hashicorp.com/vault/docs
2299
2222
  # Web UI: http://localhost:8200 (token: ooneex)
@@ -2308,20 +2231,20 @@ volumes:
2308
2231
  - VAULT_DEV_LISTEN_ADDRESS=0.0.0.0:8200
2309
2232
  cap_add:
2310
2233
  - IPC_LOCK
2311
- `;var Ii={clickhouse:pi,elasticsearch:ui,grafana:hi,"ooneex-jade":Ni,jaeger:fi,keycloak:yi,libretranslate:gi,maildev:bi,memcached:xi,minio:wi,mongodb:Ei,mysql:Ai,nats:vi,postgres:Si,prometheus:Ti,rabbitmq:Ri,redis:Mi,temporal:Ci,vault:_i};function vc(e){let t=e.split(`
2234
+ `;var _i={clickhouse:pi,elasticsearch:mi,grafana:ui,"ooneex-jade":Ai,jaeger:hi,keycloak:fi,libretranslate:yi,maildev:gi,memcached:bi,minio:xi,mongodb:wi,mysql:vi,nats:Ei,postgres:Ti,prometheus:Si,rabbitmq:Ni,redis:Ri,temporal:Ci,vault:Mi};function Lc(e){let t=e.split(`
2312
2235
  `),s=[],r=!1;for(let o of t){if(o.startsWith("services:")){r=!0;continue}if(r){if(o.startsWith("volumes:")||o.startsWith("networks:"))break;s.push(o)}}return s.join(`
2313
- `)}function Nc(e){let t=Di.parse(e);return t.volumes?Object.keys(t.volumes):[]}class Fe{getName(){return"make:docker"}getDescription(){return"Add a docker service to docker-compose.yml"}async run(e){let{name:t}=e;if(!t)t=await mi({message:"Select docker service"});let s=Ii[t],r=Oi(process.cwd(),"docker-compose.yml"),o=new Ac,i=Bun.file(r);if(await i.exists()){let d=await i.text(),l=Di.parse(d);if(l.services&&t in l.services){o.warn(`Service "${t}" already exists in docker-compose.yml`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0});return}let c=vc(s),u=Nc(s),p=d,m=p.indexOf(`
2314
- volumes:`),h=p.indexOf(`
2315
- networks:`),f=-1;if(m!==-1&&h!==-1)f=Math.min(m,h);else if(m!==-1)f=m;else if(h!==-1)f=h;if(f!==-1)p=`${p.slice(0,f)}
2316
- ${c}${p.slice(f)}`;else p=`${p.trimEnd()}
2317
- ${c}`;for(let g of u)if(!p.includes(` ${g}:`))if(p.includes(`
2318
- volumes:`)){let y=p.indexOf(`
2319
- volumes:`),E=p.slice(y+9);p=`${p.slice(0,y+9)}
2320
- ${g}:${E}`}else p=`${p.trimEnd()}
2236
+ `)}function kc(e){let t=Bi.parse(e);return t.volumes?Object.keys(t.volumes):[]}class Qe{getName(){return"make:docker"}getDescription(){return"Add a docker service to docker-compose.yml"}async run(e){let{name:t}=e;if(!t)t=await ci({message:"Select docker service"});let s=_i[t],r=Ii(process.cwd(),"docker-compose.yml"),o=new Pc,i=Bun.file(r);if(await i.exists()){let l=await i.text(),d=Bi.parse(l);if(d.services&&t in d.services){o.warn(`Service "${t}" already exists in docker-compose.yml`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0});return}let c=Lc(s),u=kc(s),m=l,p=m.indexOf(`
2237
+ volumes:`),h=m.indexOf(`
2238
+ networks:`),f=-1;if(p!==-1&&h!==-1)f=Math.min(p,h);else if(p!==-1)f=p;else if(h!==-1)f=h;if(f!==-1)m=`${m.slice(0,f)}
2239
+ ${c}${m.slice(f)}`;else m=`${m.trimEnd()}
2240
+ ${c}`;for(let g of u)if(!m.includes(` ${g}:`))if(m.includes(`
2241
+ volumes:`)){let y=m.indexOf(`
2242
+ volumes:`),w=m.slice(y+9);m=`${m.slice(0,y+9)}
2243
+ ${g}:${w}`}else m=`${m.trimEnd()}
2321
2244
 
2322
2245
  volumes:
2323
2246
  ${g}:
2324
- `;await Bun.write(r,p)}else await Bun.write(r,s);let a=Oi(process.cwd(),"package.json"),n=Bun.file(a);if(await n.exists()){let d=await n.json();d.scripts=d.scripts||{},d.scripts.docker="docker compose up -d",await Bun.write(a,JSON.stringify(d,null,2))}o.success(`Service "${t}" added to docker-compose.yml`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),o.info("Run 'bun run docker' to start docker containers",void 0,{showTimestamp:!1,showArrow:!0,showLevel:!1})}}Fe=b([x.command()],Fe);var Ui=te(Bi(),1);import{basename as Rc,join as k}from"path";import{TerminalLogger as Mc}from"@ooneex/logger";import{toPascalCase as kt,toSnakeCase as Cc}from"@ooneex/utils";var Pi=`import { describe, expect, test } from "bun:test";
2247
+ `;await Bun.write(r,m)}else await Bun.write(r,s);let a=Ii(process.cwd(),"package.json"),n=Bun.file(a);if(await n.exists()){let l=await n.json();l.scripts=l.scripts||{},l.scripts.docker="docker compose up -d",await Bun.write(a,JSON.stringify(l,null,2))}o.success(`Service "${t}" added to docker-compose.yml`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),o.info("Run 'bun run docker' to start docker containers",void 0,{showTimestamp:!1,showArrow:!0,showLevel:!1})}}Qe=b([x.command()],Qe);var Li=te(Oi(),1);import{basename as $c,join as $}from"path";import{TerminalLogger as qc}from"@ooneex/logger";import{toPascalCase as $t,toSnakeCase as Wc}from"@ooneex/utils";var Di=`import { describe, expect, test } from "bun:test";
2325
2248
  import { {{NAME}}Entity } from "@/entities/{{NAME}}Entity";
2326
2249
 
2327
2250
  describe("{{NAME}}Entity", () => {
@@ -2386,16 +2309,16 @@ describe("{{NAME}}Entity", () => {
2386
2309
  expect("deletedAt" in entity).toBe(true);
2387
2310
  });
2388
2311
  });
2389
- `;var Li=`import type { LocaleType } from "@ooneex/translation";
2312
+ `;var Pi=`import type { LocaleType } from "@ooneex/translation";
2390
2313
  import { random } from "@ooneex/utils";
2391
- import { Column, CreateDateColumn, DeleteDateColumn, PrimaryColumn, UpdateDateColumn } from "typeorm";
2314
+ import { Column, CreateDateColumn, DeleteDateColumn, Entity, PrimaryColumn, UpdateDateColumn } from "typeorm";
2392
2315
 
2393
2316
  @Entity({
2394
2317
  name: "{{TABLE_NAME}}",
2395
2318
  })
2396
- export class {{NAME}}Entity extends BaseEntity {
2397
- @PrimaryColumn({ name: "id", type: "varchar", length: 25 })
2398
- id: string = random.nanoid(25);
2319
+ export class {{NAME}}Entity {
2320
+ @PrimaryColumn({ name: "id", type: "varchar", length: 20 })
2321
+ id: string = random.id();
2399
2322
 
2400
2323
  @Column({
2401
2324
  name: "is_locked",
@@ -2437,9 +2360,9 @@ export class {{NAME}}Entity extends BaseEntity {
2437
2360
  @DeleteDateColumn({ name: "deleted_at" })
2438
2361
  deletedAt?: Date;
2439
2362
  }
2440
- `;class Ve{getName(){return"make:entity"}getDescription(){return"Generate a new entity class"}async addToModule(e,t){let s=await Bun.file(e).text(),r=`${t}Entity`,o=`import { ${r} } from "./entities/${r}";
2363
+ `;class be{getName(){return"make:entity"}getDescription(){return"Generate a new entity class"}async addToModule(e,t){let s=await Bun.file(e).text(),r=`${t}Entity`,o=`import { ${r} } from "./entities/${r}";
2441
2364
  `,i=s.lastIndexOf("import "),a=s.indexOf(`
2442
- `,i);s=`${s.slice(0,a+1)}${o}${s.slice(a+1)}`;let n=/(entities:\s*\[)([^\]]*)/s,d=s.match(n);if(d){let l=d[2]?.trim(),c=l?`${l}, ${r}`:r;s=s.replace(n,`$1${c}`)}await Bun.write(e,s)}async run(e){let{name:t,module:s,tableName:r}=e;if(!t)t=await v({message:"Enter entity name"});if(t=kt(t).replace(/Entity$/,""),!r)r=Cc(Ui.default(t));let o=Li.replace(/{{NAME}}/g,t).replace(/{{TABLE_NAME}}/g,r),i=s?k("modules",s):".",a=k(i,"src","entities"),n=k(process.cwd(),a),d=k(n,`${t}Entity.ts`);await Bun.write(d,o);let l=Pi.replace(/{{NAME}}/g,t),c=k(i,"tests","entities"),u=k(process.cwd(),c),p=k(u,`${t}Entity.spec.ts`);await Bun.write(p,l);let m=s?kt(s):kt(Rc(process.cwd())),h=k(process.cwd(),i,"src",`${m}Module.ts`);if(await Bun.file(h).exists())await this.addToModule(h,t);let f=new Mc;f.success(`${k(a,t)}Entity.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),f.success(`${k(c,t)}Entity.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}Ve=b([x.command()],Ve);import{join as z}from"path";import{TerminalLogger as Oc}from"@ooneex/logger";import{toPascalCase as Dc}from"@ooneex/utils";var Gi=`import { describe, expect, test } from "bun:test";
2365
+ `,i);s=`${s.slice(0,a+1)}${o}${s.slice(a+1)}`;let n=/(entities:\s*\[)([^\]]*)/s,l=s.match(n);if(l){let d=l[2]?.trim(),c=d?`${d}, ${r}`:r;s=s.replace(n,`$1${c}`)}await Bun.write(e,s)}async run(e){let{name:t,module:s,tableName:r}=e;if(!t)t=await A({message:"Enter entity name"});if(t=$t(t).replace(/Entity$/,""),!r)r=Wc(Li.default(t));let o=Pi.replace(/{{NAME}}/g,t).replace(/{{TABLE_NAME}}/g,r),i=s?$("modules",s):".",a=$(i,"src","entities"),n=$(process.cwd(),a),l=$(n,`${t}Entity.ts`);await Bun.write(l,o);let d=Di.replace(/{{NAME}}/g,t),c=$(i,"tests","entities"),u=$(process.cwd(),c),m=$(u,`${t}Entity.spec.ts`);await Bun.write(m,d);let p=s?$t(s):$t($c(process.cwd())),h=$(process.cwd(),i,"src",`${p}Module.ts`);if(await Bun.file(h).exists())await this.addToModule(h,t);let f=new qc;f.success(`${$(a,t)}Entity.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),f.success(`${$(c,t)}Entity.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}be=b([x.command()],be);import{join as Q}from"path";import{TerminalLogger as Hc}from"@ooneex/logger";import{toPascalCase as Vc}from"@ooneex/utils";var ki=`import { describe, expect, test } from "bun:test";
2443
2366
  import { {{NAME}}Logger } from "@/loggers/{{NAME}}Logger";
2444
2367
 
2445
2368
  describe("{{NAME}}Logger", () => {
@@ -2482,7 +2405,7 @@ describe("{{NAME}}Logger", () => {
2482
2405
  expect(typeof {{NAME}}Logger.prototype.error).toBe("function");
2483
2406
  });
2484
2407
  });
2485
- `;var ki=`import type { IException } from "@ooneex/exception";
2408
+ `;var Ui=`import type { IException } from "@ooneex/exception";
2486
2409
  import type { ILogger } from "@ooneex/logger";
2487
2410
  import type { ScalarType } from "@ooneex/types";
2488
2411
  import { decorator } from "@ooneex/logger";
@@ -2517,7 +2440,7 @@ export class {{NAME}}Logger implements ILogger {
2517
2440
  // Handle error logging
2518
2441
  }
2519
2442
  }
2520
- `;class Ye{getName(){return"make:logger"}getDescription(){return"Generate a new logger class"}async run(e){let{name:t,module:s}=e;if(!t)t=await v({message:"Enter logger name"});t=Dc(t).replace(/Logger$/,"");let r=ki.replace(/{{NAME}}/g,t),o=s?z("modules",s):".",i=z(o,"src","loggers"),a=z(process.cwd(),i),n=z(a,`${t}Logger.ts`);await Bun.write(n,r);let d=Gi.replace(/{{NAME}}/g,t),l=z(o,"tests","loggers"),c=z(process.cwd(),l),u=z(c,`${t}Logger.spec.ts`);await Bun.write(u,d);let p=new Oc;p.success(`${z(i,t)}Logger.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),p.success(`${z(l,t)}Logger.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/logger"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}Ye=b([x.command()],Ye);import{join as D}from"path";import{TerminalLogger as Gc}from"@ooneex/logger";import{toPascalCase as kc}from"@ooneex/utils";var $i=`import { describe, expect, test } from "bun:test";
2443
+ `;class Ze{getName(){return"make:logger"}getDescription(){return"Generate a new logger class"}async run(e){let{name:t,module:s}=e;if(!t)t=await A({message:"Enter logger name"});t=Vc(t).replace(/Logger$/,"");let r=Ui.replace(/{{NAME}}/g,t),o=s?Q("modules",s):".",i=Q(o,"src","loggers"),a=Q(process.cwd(),i),n=Q(a,`${t}Logger.ts`);await Bun.write(n,r);let l=ki.replace(/{{NAME}}/g,t),d=Q(o,"tests","loggers"),c=Q(process.cwd(),d),u=Q(c,`${t}Logger.spec.ts`);await Bun.write(u,l);let m=new Hc;m.success(`${Q(i,t)}Logger.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),m.success(`${Q(d,t)}Logger.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/logger"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}Ze=b([x.command()],Ze);import{join as B}from"path";import{TerminalLogger as Xc}from"@ooneex/logger";import{toPascalCase as Jc}from"@ooneex/utils";var Gi=`import { describe, expect, test } from "bun:test";
2521
2444
  import { {{NAME}}Mailer } from "@/mailers/{{NAME}}Mailer";
2522
2445
 
2523
2446
  describe("{{NAME}}Mailer", () => {
@@ -2530,7 +2453,7 @@ describe("{{NAME}}Mailer", () => {
2530
2453
  expect(typeof {{NAME}}Mailer.prototype.send).toBe("function");
2531
2454
  });
2532
2455
  });
2533
- `;var Wi=`import { inject } from "@ooneex/container";
2456
+ `;var $i=`import { inject } from "@ooneex/container";
2534
2457
  import type { IMailer } from "@ooneex/mailer";
2535
2458
  import { type {{NAME}}MailerPropsType, {{NAME}}MailerTemplate } from "./{{NAME}}MailerTemplate";
2536
2459
 
@@ -2566,7 +2489,7 @@ describe("{{NAME}}MailerTemplate", () => {
2566
2489
  expect(typeof {{NAME}}MailerTemplate).toBe("function");
2567
2490
  });
2568
2491
  });
2569
- `;var Ki=`import { MailerLayout } from "@ooneex/mailer";
2492
+ `;var Wi=`import { MailerLayout } from "@ooneex/mailer";
2570
2493
 
2571
2494
  export type {{NAME}}MailerPropsType = {
2572
2495
  link: string;
@@ -2581,7 +2504,7 @@ export const {{NAME}}MailerTemplate = (props?: {{NAME}}MailerPropsType) => (
2581
2504
  <MailerLayout.Footer />
2582
2505
  </MailerLayout>
2583
2506
  );
2584
- `;class ze{getName(){return"make:mailer"}getDescription(){return"Generate a new mailer class"}async run(e){let{name:t,module:s}=e;if(!t)t=await v({message:"Enter mailer name"});t=kc(t).replace(/Mailer$/,"");let r=Wi.replace(/{{NAME}}/g,t),o=Ki.replace(/{{NAME}}/g,t),i=s?D("modules",s):".",a=D(i,"src","mailers"),n=D(process.cwd(),a),d=D(n,`${t}Mailer.ts`),l=D(n,`${t}MailerTemplate.tsx`);await Bun.write(d,r),await Bun.write(l,o);let c=$i.replace(/{{NAME}}/g,t),u=qi.replace(/{{NAME}}/g,t),p=D(i,"tests","mailers"),m=D(process.cwd(),p),h=D(m,`${t}Mailer.spec.ts`),f=D(m,`${t}MailerTemplate.spec.ts`);await Bun.write(h,c),await Bun.write(f,u);let g=new Gc;g.success(`${D(a,t)}Mailer.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),g.success(`${D(a,t)}MailerTemplate.tsx created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),g.success(`${D(p,t)}Mailer.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),g.success(`${D(p,t)}MailerTemplate.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/mailer"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}ze=b([x.command()],ze);import{basename as Kc,join as $}from"path";import{TerminalLogger as Hc}from"@ooneex/logger";import{toPascalCase as $t}from"@ooneex/utils";var Hi=`import type { ContextType } from "@ooneex/socket";
2507
+ `;class Xe{getName(){return"make:mailer"}getDescription(){return"Generate a new mailer class"}async run(e){let{name:t,module:s}=e;if(!t)t=await A({message:"Enter mailer name"});t=Jc(t).replace(/Mailer$/,"");let r=$i.replace(/{{NAME}}/g,t),o=Wi.replace(/{{NAME}}/g,t),i=s?B("modules",s):".",a=B(i,"src","mailers"),n=B(process.cwd(),a),l=B(n,`${t}Mailer.ts`),d=B(n,`${t}MailerTemplate.tsx`);await Bun.write(l,r),await Bun.write(d,o);let c=Gi.replace(/{{NAME}}/g,t),u=qi.replace(/{{NAME}}/g,t),m=B(i,"tests","mailers"),p=B(process.cwd(),m),h=B(p,`${t}Mailer.spec.ts`),f=B(p,`${t}MailerTemplate.spec.ts`);await Bun.write(h,c),await Bun.write(f,u);let g=new Xc;g.success(`${B(a,t)}Mailer.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),g.success(`${B(a,t)}MailerTemplate.tsx created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),g.success(`${B(m,t)}Mailer.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),g.success(`${B(m,t)}MailerTemplate.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/mailer"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}Xe=b([x.command()],Xe);import{basename as sp,join as q}from"path";import{TerminalLogger as rp}from"@ooneex/logger";import{toPascalCase as qt}from"@ooneex/utils";var Fi=`import type { ContextType } from "@ooneex/socket";
2585
2508
  import { decorator, type IMiddleware } from "@ooneex/middleware";
2586
2509
 
2587
2510
  @decorator.middleware()
@@ -2593,7 +2516,7 @@ export class {{NAME}}Middleware implements IMiddleware {
2593
2516
  return context
2594
2517
  }
2595
2518
  }
2596
- `;var Fi=`import { describe, expect, test } from "bun:test";
2519
+ `;var Ki=`import { describe, expect, test } from "bun:test";
2597
2520
  import { {{NAME}}Middleware } from "@/middlewares/{{NAME}}Middleware";
2598
2521
 
2599
2522
  describe("{{NAME}}Middleware", () => {
@@ -2606,7 +2529,7 @@ describe("{{NAME}}Middleware", () => {
2606
2529
  expect(typeof {{NAME}}Middleware.prototype.handler).toBe("function");
2607
2530
  });
2608
2531
  });
2609
- `;var Vi=`import type { ContextType } from "@ooneex/controller";
2532
+ `;var Hi=`import type { ContextType } from "@ooneex/controller";
2610
2533
  import { decorator, type IMiddleware } from "@ooneex/middleware";
2611
2534
 
2612
2535
  @decorator.middleware()
@@ -2618,9 +2541,9 @@ export class {{NAME}}Middleware implements IMiddleware {
2618
2541
  return context
2619
2542
  }
2620
2543
  }
2621
- `;class Ze{getName(){return"make:middleware"}getDescription(){return"Generate a new middleware class"}async addToModule(e,t){let s=await Bun.file(e).text(),r=`${t}Middleware`,o=`import { ${r} } from "./middlewares/${r}";
2544
+ `;class Je{getName(){return"make:middleware"}getDescription(){return"Generate a new middleware class"}async addToModule(e,t){let s=await Bun.file(e).text(),r=`${t}Middleware`,o=`import { ${r} } from "./middlewares/${r}";
2622
2545
  `,i=s.lastIndexOf("import "),a=s.indexOf(`
2623
- `,i);s=`${s.slice(0,a+1)}${o}${s.slice(a+1)}`;let n=/(middlewares:\s*\[)([^\]]*)/s,d=s.match(n);if(d){let l=d[2]?.trim(),c=l?`${l}, ${r}`:r;s=s.replace(n,`$1${c}`)}await Bun.write(e,s)}async run(e){let{name:t,module:s,isSocket:r}=e;if(!t)t=await v({message:"Enter middleware name"});if(r===void 0)r=await fe({message:"Is this a socket middleware?"});t=$t(t).replace(/Middleware$/,"");let i=(r?Hi:Vi).replace(/{{NAME}}/g,t),a=s?$("modules",s):".",n=$(a,"src","middlewares"),d=$(process.cwd(),n),l=$(d,`${t}Middleware.ts`);await Bun.write(l,i);let c=Fi.replace(/{{NAME}}/g,t),u=$(a,"tests","middlewares"),p=$(process.cwd(),u),m=$(p,`${t}Middleware.spec.ts`);await Bun.write(m,c);let h=s?$t(s):$t(Kc(process.cwd())),f=$(process.cwd(),a,"src",`${h}Module.ts`);if(await Bun.file(f).exists())await this.addToModule(f,t);let g=new Hc;g.success(`${$(n,t)}Middleware.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),g.success(`${$(u,t)}Middleware.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/middleware"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}Ze=b([x.command()],Ze);import{join as Qe}from"path";import{TerminalLogger as Vc}from"@ooneex/logger";import{migrationCreate as Yc}from"@ooneex/migrations";var Yi=`#!/usr/bin/env bun
2546
+ `,i);s=`${s.slice(0,a+1)}${o}${s.slice(a+1)}`;let n=/(middlewares:\s*\[)([^\]]*)/s,l=s.match(n);if(l){let d=l[2]?.trim(),c=d?`${d}, ${r}`:r;s=s.replace(n,`$1${c}`)}await Bun.write(e,s)}async run(e){let{name:t,module:s,isSocket:r}=e;if(!t)t=await A({message:"Enter middleware name"});if(r===void 0)r=await ye({message:"Is this a socket middleware?"});t=qt(t).replace(/Middleware$/,"");let i=(r?Fi:Hi).replace(/{{NAME}}/g,t),a=s?q("modules",s):".",n=q(a,"src","middlewares"),l=q(process.cwd(),n),d=q(l,`${t}Middleware.ts`);await Bun.write(d,i);let c=Ki.replace(/{{NAME}}/g,t),u=q(a,"tests","middlewares"),m=q(process.cwd(),u),p=q(m,`${t}Middleware.spec.ts`);await Bun.write(p,c);let h=s?qt(s):qt(sp(process.cwd())),f=q(process.cwd(),a,"src",`${h}Module.ts`);if(await Bun.file(f).exists())await this.addToModule(f,t);let g=new rp;g.success(`${q(n,t)}Middleware.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),g.success(`${q(u,t)}Middleware.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/middleware"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}Je=b([x.command()],Je);import{join as je}from"path";import{TerminalLogger as ip}from"@ooneex/logger";import{migrationCreate as ap}from"@ooneex/migrations";var Vi=`#!/usr/bin/env bun
2624
2547
 
2625
2548
  import { migrationUp } from "@ooneex/migrations";
2626
2549
  import "@/migrations/migrations";
@@ -2629,7 +2552,7 @@ await migrationUp({
2629
2552
  databaseUrl: Bun.env.DATABASE_URL || ":memory:",
2630
2553
  tableName: "migrations",
2631
2554
  });
2632
- `;class Xe{getName(){return"make:migration"}getDescription(){return"Generate a new migration file"}async run(e){let{module:t}=e,s=t?Qe("modules",t):".",r=await Yc({dir:Qe(s,"src/migrations")}),o=Qe(process.cwd(),s,"bin","migration","up.ts");if(!await Bun.file(o).exists())await Bun.write(o,Yi);let a=Qe(process.cwd(),"package.json"),n=Bun.file(a);if(await n.exists()){let c=await n.json();c.scripts=c.scripts||{},c.scripts["migration:up"]="bun ./bin/migration/up.ts",await Bun.write(a,JSON.stringify(c,null,2))}let d=new Vc;d.success(`${r} created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),d.info("Run 'bun run migration:up' to execute migrations",void 0,{showTimestamp:!1,showArrow:!0,showLevel:!1}),await Bun.spawn(["bun","add","--dev","@ooneex/migrations"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}Xe=b([x.command()],Xe);import{join as Z}from"path";import{TerminalLogger as Qc}from"@ooneex/logger";import{toPascalCase as Xc}from"@ooneex/utils";var zi=`import { describe, expect, test } from "bun:test";
2555
+ `;class xe{getName(){return"make:migration"}getDescription(){return"Generate a new migration file"}async run(e){let{module:t}=e,s=t?je("modules",t):".",r=await ap({dir:je(s,"src/migrations")}),o=je(process.cwd(),s,"bin","migration","up.ts");if(!await Bun.file(o).exists())await Bun.write(o,Vi);let a=je(process.cwd(),"package.json"),n=Bun.file(a);if(await n.exists()){let c=await n.json();c.scripts=c.scripts||{},c.scripts["migration:up"]="bun ./bin/migration/up.ts",await Bun.write(a,JSON.stringify(c,null,2))}let l=new ip;l.success(`${r} created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),l.info("Run 'bun run migration:up' to execute migrations",void 0,{showTimestamp:!1,showArrow:!0,showLevel:!1}),await Bun.spawn(["bun","add","--dev","@ooneex/migrations"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}xe=b([x.command()],xe);import{join as Z}from"path";import{TerminalLogger as dp}from"@ooneex/logger";import{toPascalCase as cp}from"@ooneex/utils";var zi=`import { describe, expect, test } from "bun:test";
2633
2556
  import { Permission } from "@ooneex/permission";
2634
2557
  import { {{NAME}}Permission } from "@/permissions/{{NAME}}Permission";
2635
2558
 
@@ -2654,7 +2577,7 @@ describe("{{NAME}}Permission", () => {
2654
2577
  });
2655
2578
 
2656
2579
  });
2657
- `;var Zi=`import { decorator, Permission } from "@ooneex/permission";
2580
+ `;var Yi=`import { decorator, Permission } from "@ooneex/permission";
2658
2581
  import type { IUser } from "@ooneex/user";
2659
2582
 
2660
2583
  @decorator.permission()
@@ -2693,7 +2616,7 @@ export class {{NAME}}Permission extends Permission {
2693
2616
  return this;
2694
2617
  }
2695
2618
  }
2696
- `;class Je{getName(){return"make:permission"}getDescription(){return"Generate a new permission class"}async run(e){let{name:t,module:s}=e;if(!t)t=await v({message:"Enter permission name"});t=Xc(t).replace(/Permission$/,"");let r=Zi.replace(/{{NAME}}/g,t),o=s?Z("modules",s):".",i=Z(o,"src","permissions"),a=Z(process.cwd(),i),n=Z(a,`${t}Permission.ts`);await Bun.write(n,r);let d=zi.replace(/{{NAME}}/g,t),l=Z(o,"tests","permissions"),c=Z(process.cwd(),l),u=Z(c,`${t}Permission.spec.ts`);await Bun.write(u,d);let p=new Qc;p.success(`${Z(i,t)}Permission.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),p.success(`${Z(l,t)}Permission.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/permission"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}Je=b([x.command()],Je);import{basename as em,join as W}from"path";import{TerminalLogger as tm}from"@ooneex/logger";import{toKebabCase as sm,toPascalCase as Wt}from"@ooneex/utils";var Qi=`import { describe, expect, test } from "bun:test";
2619
+ `;class et{getName(){return"make:permission"}getDescription(){return"Generate a new permission class"}async run(e){let{name:t,module:s}=e;if(!t)t=await A({message:"Enter permission name"});t=cp(t).replace(/Permission$/,"");let r=Yi.replace(/{{NAME}}/g,t),o=s?Z("modules",s):".",i=Z(o,"src","permissions"),a=Z(process.cwd(),i),n=Z(a,`${t}Permission.ts`);await Bun.write(n,r);let l=zi.replace(/{{NAME}}/g,t),d=Z(o,"tests","permissions"),c=Z(process.cwd(),d),u=Z(c,`${t}Permission.spec.ts`);await Bun.write(u,l);let m=new dp;m.success(`${Z(i,t)}Permission.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),m.success(`${Z(d,t)}Permission.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/permission"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}et=b([x.command()],et);import{basename as up,join as W}from"path";import{TerminalLogger as hp}from"@ooneex/logger";import{toKebabCase as fp,toPascalCase as Wt}from"@ooneex/utils";var Qi=`import { describe, expect, test } from "bun:test";
2697
2620
  import { {{NAME}}PubSub } from "@/pubsub/{{NAME}}PubSub";
2698
2621
 
2699
2622
  describe("{{NAME}}PubSub", () => {
@@ -2731,7 +2654,7 @@ describe("{{NAME}}PubSub", () => {
2731
2654
  expect(typeof {{NAME}}PubSub.prototype.unsubscribeAll).toBe("function");
2732
2655
  });
2733
2656
  });
2734
- `;var Xi=`import { inject } from "@ooneex/container";
2657
+ `;var Zi=`import { inject } from "@ooneex/container";
2735
2658
  import type { ScalarType } from "@ooneex/types";
2736
2659
  import { decorator, PubSub, RedisPubSub } from "@ooneex/pub-sub";
2737
2660
 
@@ -2753,27 +2676,27 @@ export class {{NAME}}Event<Data extends Record<string, ScalarType> = Record<stri
2753
2676
  // TODO: Implement handler logic here
2754
2677
  }
2755
2678
  }
2756
- `;class je{getName(){return"make:pubsub"}getDescription(){return"Generate a new PubSub event class"}async addToModule(e,t){let s=await Bun.file(e).text(),r=`${t}Event`,o=`import { ${r} } from "./events/${r}";
2679
+ `;class tt{getName(){return"make:pubsub"}getDescription(){return"Generate a new PubSub event class"}async addToModule(e,t){let s=await Bun.file(e).text(),r=`${t}Event`,o=`import { ${r} } from "./events/${r}";
2757
2680
  `,i=s.lastIndexOf("import "),a=s.indexOf(`
2758
- `,i);s=`${s.slice(0,a+1)}${o}${s.slice(a+1)}`;let n=/(events:\s*\[)([^\]]*)/s,d=s.match(n);if(d){let l=d[2]?.trim(),c=l?`${l}, ${r}`:r;s=s.replace(n,`$1${c}`)}await Bun.write(e,s)}async run(e){let{name:t,module:s,channel:r}=e;if(!t)t=await v({message:"Enter name"});if(t=Wt(t).replace(/PubSub$/,""),!r)r=sm(t);let o=Xi.replace(/{{NAME}}/g,t).replace(/{{CHANNEL}}/g,r),i=s?W("modules",s):".",a=W(i,"src","events"),n=W(process.cwd(),a),d=W(n,`${t}Event.ts`);await Bun.write(d,o);let l=Qi.replace(/{{NAME}}/g,t),c=W(i,"tests","events"),u=W(process.cwd(),c),p=W(u,`${t}Event.spec.ts`);await Bun.write(p,l);let m=s?Wt(s):Wt(em(process.cwd())),h=W(process.cwd(),i,"src",`${m}Module.ts`);if(await Bun.file(h).exists())await this.addToModule(h,t);let f=new tm;f.success(`${W(a,t)}Event.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),f.success(`${W(c,t)}Event.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/pub-sub"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}je=b([x.command()],je);import{readdir as rm}from"fs/promises";import{join as ce}from"path";import{TerminalLogger as om}from"@ooneex/logger";var{$:me}=globalThis.Bun;var im={feat:"Added",fix:"Fixed",refactor:"Changed",perf:"Changed",style:"Changed",docs:"Changed",build:"Changed",ci:"Changed",chore:"Changed",revert:"Removed"};class et{getName(){return"make:release"}getDescription(){return"Release packages with version bump, changelog, and git tag"}async run(){let e=new om,t=process.cwd(),s=[];for(let{name:a,type:n}of[{name:"packages",type:"package"},{name:"modules",type:"module"}])try{let d=await rm(ce(t,a),{withFileTypes:!0});s.push(...d.filter((l)=>l.isDirectory()).map((l)=>({base:ce(a,l.name),type:n})))}catch{}let r={showTimestamp:!1,showArrow:!1,useSymbol:!0};if(s.length===0){e.error("No packages or modules found",void 0,r);return}let o=0;for(let a of s){let n=ce(t,a.base),d=ce(n,"package.json"),l=Bun.file(d);if(!await l.exists())continue;let c=await l.json(),u=await this.getLastTag(c.name),p=await this.getCommitsSinceTag(u,a.base);if(p.length===0)continue;let m=this.determineBumpType(p),h=this.bumpVersion(c.version,m);c.version=h;let f=`${c.name}@${h}`;await Bun.write(d,`${JSON.stringify(c,null,2)}
2759
- `),await this.updateChangelog(n,h,f,p),await this.gitAdd(ce(a.base,"package.json"),ce(a.base,"CHANGELOG.md")),await this.gitCommit(`chore(release): ${c.name}@${h}`),await this.gitTag(f,`chore(release): ${c.name}@${h}`),e.success(`${c.name}@${h} released (${m} bump, ${p.length} commit(s))`,void 0,r),o++}if(o===0){e.info(`No packages have unreleased commits
2760
- `,void 0,{showArrow:!1,showTimestamp:!1,showLevel:!1,useSymbol:!1});return}if(e.success(`${o} package(s) released`,void 0,r),await fe({message:"Push commits and tags to remote?"}))try{await me`git push && git push --tags`,e.success("Pushed commits and tags to remote",void 0,r)}catch{e.error("Failed to push to remote",void 0,r)}}async getLastTag(e){try{let s=(await me`git --no-pager tag --list "${e}@*" --sort=-v:refname`.quiet()).text().trim();if(!s)return null;return s.split(`
2761
- `)[0]??null}catch{return null}}async getCommitsSinceTag(e,t){let s=e?`${e}..HEAD`:"HEAD",r="%H|%an|%s";try{let i=(await me`git --no-pager log ${s} --format=${"%H|%an|%s"} -- ${t}`.quiet()).text().trim();if(!i)return[];let a=[],n=/^([a-z]+)\(([^)]+)\):\s*(.+)$/;for(let d of i.split(`
2762
- `)){let[l,c,...u]=d.split("|"),p=u.join("|");if(!l||!c||!p)continue;let m=p.match(n);if(m){let[,h,f,g]=m;if(h&&f&&g)a.push({hash:l.substring(0,8),type:h,scope:f,subject:g,author:c})}}return a}catch{return[]}}determineBumpType(e){for(let t of e)if(t.type==="feat")return"minor";return"patch"}bumpVersion(e,t){let s=e.split(".").map(Number),[r=0,o=0,i=0]=s;if(t==="minor")return`${r}.${o+1}.0`;return`${r}.${o}.${i+1}`}async getRepoUrl(){try{return(await me`git --no-pager remote get-url origin`.quiet()).text().trim().replace(/\.git$/,"").replace(/^git@([^:]+):/,"https://$1/")}catch{return null}}async updateChangelog(e,t,s,r){let o=ce(e,"CHANGELOG.md"),i=new Date().toISOString().split("T")[0],a=await this.getRepoUrl(),n=new Map;for(let h of r){let f=im[h.type]??"Changed",g=n.get(f)??[];g.push(h),n.set(f,g)}let d=["Added","Changed","Deprecated","Removed","Fixed","Security"],c=`## ${a?`[${t}](${a}/releases/tag/${s})`:`[${t}]`} - ${i}
2763
- `;for(let h of d){let f=n.get(h);if(!f||f.length===0)continue;c+=`
2681
+ `,i);s=`${s.slice(0,a+1)}${o}${s.slice(a+1)}`;let n=/(events:\s*\[)([^\]]*)/s,l=s.match(n);if(l){let d=l[2]?.trim(),c=d?`${d}, ${r}`:r;s=s.replace(n,`$1${c}`)}await Bun.write(e,s)}async run(e){let{name:t,module:s,channel:r}=e;if(!t)t=await A({message:"Enter name"});if(t=Wt(t).replace(/PubSub$/,""),!r)r=fp(t);let o=Zi.replace(/{{NAME}}/g,t).replace(/{{CHANNEL}}/g,r),i=s?W("modules",s):".",a=W(i,"src","events"),n=W(process.cwd(),a),l=W(n,`${t}Event.ts`);await Bun.write(l,o);let d=Qi.replace(/{{NAME}}/g,t),c=W(i,"tests","events"),u=W(process.cwd(),c),m=W(u,`${t}Event.spec.ts`);await Bun.write(m,d);let p=s?Wt(s):Wt(up(process.cwd())),h=W(process.cwd(),i,"src",`${p}Module.ts`);if(await Bun.file(h).exists())await this.addToModule(h,t);let f=new hp;f.success(`${W(a,t)}Event.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),f.success(`${W(c,t)}Event.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/pub-sub"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}tt=b([x.command()],tt);import{readdir as yp}from"fs/promises";import{join as pe}from"path";import{TerminalLogger as gp}from"@ooneex/logger";var{$:me}=globalThis.Bun;var bp={feat:"Added",fix:"Fixed",refactor:"Changed",perf:"Changed",style:"Changed",docs:"Changed",build:"Changed",ci:"Changed",chore:"Changed",revert:"Removed"};class st{getName(){return"make:release"}getDescription(){return"Release packages with version bump, changelog, and git tag"}async run(){let e=new gp,t=process.cwd(),s=[];for(let{name:a,type:n}of[{name:"packages",type:"package"},{name:"modules",type:"module"}])try{let l=await yp(pe(t,a),{withFileTypes:!0});s.push(...l.filter((d)=>d.isDirectory()).map((d)=>({base:pe(a,d.name),type:n})))}catch{}let r={showTimestamp:!1,showArrow:!1,useSymbol:!0};if(s.length===0){e.error("No packages or modules found",void 0,r);return}let o=0;for(let a of s){let n=pe(t,a.base),l=pe(n,"package.json"),d=Bun.file(l);if(!await d.exists())continue;let c=await d.json(),u=await this.getLastTag(c.name),m=await this.getCommitsSinceTag(u,a.base);if(m.length===0)continue;let p=this.determineBumpType(m),h=this.bumpVersion(c.version,p);c.version=h;let f=`${c.name}@${h}`;await Bun.write(l,`${JSON.stringify(c,null,2)}
2682
+ `),await this.updateChangelog(n,h,f,m),await this.gitAdd(pe(a.base,"package.json"),pe(a.base,"CHANGELOG.md")),await this.gitCommit(`chore(release): ${c.name}@${h}`),await this.gitTag(f,`chore(release): ${c.name}@${h}`),e.success(`${c.name}@${h} released (${p} bump, ${m.length} commit(s))`,void 0,r),o++}if(o===0){e.info(`No packages have unreleased commits
2683
+ `,void 0,{showArrow:!1,showTimestamp:!1,showLevel:!1,useSymbol:!1});return}if(e.success(`${o} package(s) released`,void 0,r),await ye({message:"Push commits and tags to remote?"}))try{await me`git push && git push --tags`,e.success("Pushed commits and tags to remote",void 0,r)}catch{e.error("Failed to push to remote",void 0,r)}}async getLastTag(e){try{let s=(await me`git --no-pager tag --list "${e}@*" --sort=-v:refname`.quiet()).text().trim();if(!s)return null;return s.split(`
2684
+ `)[0]??null}catch{return null}}async getCommitsSinceTag(e,t){let s=e?`${e}..HEAD`:"HEAD",r="%H|%an|%s";try{let i=(await me`git --no-pager log ${s} --format=${"%H|%an|%s"} -- ${t}`.quiet()).text().trim();if(!i)return[];let a=[],n=/^([a-z]+)\(([^)]+)\):\s*(.+)$/;for(let l of i.split(`
2685
+ `)){let[d,c,...u]=l.split("|"),m=u.join("|");if(!d||!c||!m)continue;let p=m.match(n);if(p){let[,h,f,g]=p;if(h&&f&&g)a.push({hash:d.substring(0,8),type:h,scope:f,subject:g,author:c})}}return a}catch{return[]}}determineBumpType(e){for(let t of e)if(t.type==="feat")return"minor";return"patch"}bumpVersion(e,t){let s=e.split(".").map(Number),[r=0,o=0,i=0]=s;if(t==="minor")return`${r}.${o+1}.0`;return`${r}.${o}.${i+1}`}async getRepoUrl(){try{return(await me`git --no-pager remote get-url origin`.quiet()).text().trim().replace(/\.git$/,"").replace(/^git@([^:]+):/,"https://$1/")}catch{return null}}async updateChangelog(e,t,s,r){let o=pe(e,"CHANGELOG.md"),i=new Date().toISOString().split("T")[0],a=await this.getRepoUrl(),n=new Map;for(let h of r){let f=bp[h.type]??"Changed",g=n.get(f)??[];g.push(h),n.set(f,g)}let l=["Added","Changed","Deprecated","Removed","Fixed","Security"],c=`## ${a?`[${t}](${a}/releases/tag/${s})`:`[${t}]`} - ${i}
2686
+ `;for(let h of l){let f=n.get(h);if(!f||f.length===0)continue;c+=`
2764
2687
  ### ${h}
2765
2688
 
2766
2689
  `;for(let g of f){let y=a?` ([${g.hash}](${a}/commit/${g.hash}))`:"";c+=`- ${g.subject} \u2014 ${g.author}${y}
2767
- `}}let u=Bun.file(o),p="";if(await u.exists())p=await u.text();let m;if(p){let h=p.match(/## \[Unreleased\][^\n]*\n/),f=p.match(/## \[\d+\.\d+\.\d+\]/);if(h){let g=(h.index??0)+h[0].length;m=`${p.slice(0,g)}
2690
+ `}}let u=Bun.file(o),m="";if(await u.exists())m=await u.text();let p;if(m){let h=m.match(/## \[Unreleased\][^\n]*\n/),f=m.match(/## \[\d+\.\d+\.\d+\]/);if(h){let g=(h.index??0)+h[0].length;p=`${m.slice(0,g)}
2768
2691
  ${c}
2769
- ${p.slice(g)}`}else if(f&&f.index!==void 0)m=`${p.slice(0,f.index)}${c}
2770
- ${p.slice(f.index)}`;else m=`${p.trimEnd()}
2692
+ ${m.slice(g)}`}else if(f&&f.index!==void 0)p=`${m.slice(0,f.index)}${c}
2693
+ ${m.slice(f.index)}`;else p=`${m.trimEnd()}
2771
2694
 
2772
2695
  ${c}
2773
- `}else m=`# Changelog
2696
+ `}else p=`# Changelog
2774
2697
 
2775
2698
  ${c}
2776
- `;await Bun.write(o,m)}async gitAdd(...e){await me`git add ${e}`}async gitCommit(e){await me`git commit --no-verify -m ${e}`}async gitTag(e,t){await me`git tag -a ${e} -m ${t}`}}et=b([x.command()],et);import{join as Q}from"path";import{TerminalLogger as dm}from"@ooneex/logger";import{toPascalCase as lm}from"@ooneex/utils";var Ji=`import { describe, expect, test } from "bun:test";
2699
+ `;await Bun.write(o,p)}async gitAdd(...e){await me`git add ${e}`}async gitCommit(e){await me`git commit --no-verify -m ${e}`}async gitTag(e,t){await me`git tag -a ${e} -m ${t}`}}st=b([x.command()],st);import{join as X}from"path";import{TerminalLogger as vp}from"@ooneex/logger";import{toPascalCase as Ep}from"@ooneex/utils";var Xi=`import { describe, expect, test } from "bun:test";
2777
2700
  import { {{NAME}}Repository } from "@/repositories/{{NAME}}Repository";
2778
2701
 
2779
2702
  describe("{{NAME}}Repository", () => {
@@ -2836,12 +2759,11 @@ describe("{{NAME}}Repository", () => {
2836
2759
  expect(typeof {{NAME}}Repository.prototype.count).toBe("function");
2837
2760
  });
2838
2761
  });
2839
- `;var ji=`import { inject } from "@ooneex/container";
2762
+ `;var Ji=`import { inject } from "@ooneex/container";
2840
2763
  import type { ITypeormDatabase } from "@ooneex/database";
2841
2764
  import { decorator } from "@ooneex/repository";
2842
2765
  import type { FilterResultType } from "@ooneex/types";
2843
2766
  import type { FindManyOptions, FindOptionsWhere, Repository, SaveOptions, UpdateResult } from "typeorm";
2844
- import { ILike } from "typeorm";
2845
2767
  import { {{NAME}}Entity } from "../entities/{{NAME}}Entity";
2846
2768
 
2847
2769
  @decorator.repository()
@@ -2873,14 +2795,13 @@ export class {{NAME}}Repository {
2873
2795
  skip = (page - 1) * take;
2874
2796
  }
2875
2797
 
2876
- // Apply name search if q parameter is provided
2877
2798
  let findOptions = { ...rest, take, ...(skip !== undefined && { skip }) };
2878
2799
  if (q) {
2879
2800
  findOptions = {
2880
2801
  ...findOptions,
2881
2802
  where: {
2882
2803
  ...rest.where,
2883
- name: ILike(\`%\${q}%\`),
2804
+ // name: ILike(\`%\${q}%\`),
2884
2805
  },
2885
2806
  };
2886
2807
  }
@@ -2892,7 +2813,7 @@ export class {{NAME}}Repository {
2892
2813
  if (q) {
2893
2814
  countWhere = {
2894
2815
  ...rest.where,
2895
- name: ILike(\`%\${q}%\`),
2816
+ // name: ILike(\`%\${q}%\`),
2896
2817
  };
2897
2818
  }
2898
2819
 
@@ -2936,12 +2857,16 @@ export class {{NAME}}Repository {
2936
2857
  return await repository.save(entities, options);
2937
2858
  }
2938
2859
 
2939
- public async update(entity: {{NAME}}Entity, options?: SaveOptions): Promise<{{NAME}}Entity> {
2940
- return await this.create(entity, options);
2860
+ public async update(entity: Partial<{{NAME}}Entity> & { id: string }): Promise<UpdateResult> {
2861
+ const repository = await this.open();
2862
+
2863
+ return await repository.update(entity.id, entity);
2941
2864
  }
2942
2865
 
2943
- public async updateMany(entities: {{NAME}}Entity[], options?: SaveOptions): Promise<{{NAME}}Entity[]> {
2944
- return await this.createMany(entities, options);
2866
+ public async updateMany(entities: (Partial<{{NAME}}Entity> & { id: string })[]): Promise<UpdateResult[]> {
2867
+ const repository = await this.open();
2868
+
2869
+ return await Promise.all(entities.map((entity) => repository.update(entity.id, entity)));
2945
2870
  }
2946
2871
 
2947
2872
  public async delete(
@@ -2958,13 +2883,715 @@ export class {{NAME}}Repository {
2958
2883
  return await repository.count(criteria ? { where: criteria } : {});
2959
2884
  }
2960
2885
  }
2961
- `;class tt{getName(){return"make:repository"}getDescription(){return"Generate a new repository class"}async run(e){let{name:t,module:s}=e;if(!t)t=await v({message:"Enter repository name"});t=lm(t).replace(/Repository$/,"");let r=ji.replace(/{{NAME}}/g,t),o=s?Q("modules",s):".",i=Q(o,"src","repositories"),a=Q(process.cwd(),i),n=Q(a,`${t}Repository.ts`);await Bun.write(n,r);let d=Ji.replace(/{{NAME}}/g,t),l=Q(o,"tests","repositories"),c=Q(process.cwd(),l),u=Q(c,`${t}Repository.spec.ts`);await Bun.write(u,d);let p=new dm;p.success(`${Q(i,t)}Repository.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),p.success(`${Q(l,t)}Repository.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/repository"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}tt=b([x.command()],tt);import{join as st}from"path";import{TerminalLogger as mm}from"@ooneex/logger";import{seedCreate as pm}from"@ooneex/seeds";var ea=`#!/usr/bin/env bun
2886
+ `;class we{getName(){return"make:repository"}getDescription(){return"Generate a new repository class"}async run(e){let{name:t,module:s}=e;if(!t)t=await A({message:"Enter repository name"});t=Ep(t).replace(/Repository$/,"");let r=Ji.replace(/{{NAME}}/g,t),o=s?X("modules",s):".",i=X(o,"src","repositories"),a=X(process.cwd(),i),n=X(a,`${t}Repository.ts`);await Bun.write(n,r);let l=Xi.replace(/{{NAME}}/g,t),d=X(o,"tests","repositories"),c=X(process.cwd(),d),u=X(c,`${t}Repository.spec.ts`);await Bun.write(u,l);let m=new vp;m.success(`${X(i,t)}Repository.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),m.success(`${X(d,t)}Repository.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/repository"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}we=b([x.command()],we);import{join as C}from"path";var{Glob:$p}=globalThis.Bun;var ji=`import type { IBook } from "@ooneex/book";
2887
+ import type { LocaleType } from "@ooneex/translation";
2888
+ import { random } from "@ooneex/utils";
2889
+ import {
2890
+ Column,
2891
+ CreateDateColumn,
2892
+ Entity,
2893
+ PrimaryColumn,
2894
+ UpdateDateColumn,
2895
+ } from "typeorm";
2962
2896
 
2963
- import { seedRun } from "@ooneex/seeds";
2964
- import "@/seeds/seeds";
2897
+ @Entity({
2898
+ name: "books",
2899
+ })
2900
+ export class BookEntity implements IBook {
2901
+ @PrimaryColumn({ name: "id", type: "varchar", length: 25 })
2902
+ id: string = random.id();
2965
2903
 
2966
- await seedRun();
2967
- `;class rt{getName(){return"make:seed"}getDescription(){return"Generate a new seed file"}async run(e){let{name:t,module:s}=e;if(!t)t=await v({message:"Enter seed name"});let r=s?st("modules",s):".",o=await pm({name:t,dir:st(r,"src/seeds")}),i=st(process.cwd(),r,"bin","seed","run.ts");if(!await Bun.file(i).exists())await Bun.write(i,ea);let n=st(process.cwd(),"package.json"),d=Bun.file(n);if(await d.exists()){let u=await d.json();u.scripts=u.scripts||{},u.scripts["seed:run"]="bun ./bin/seed/run.ts",await Bun.write(n,JSON.stringify(u,null,2))}let l=new mm;l.success(`${o} created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),l.info("Run 'bun run seed:run' to execute seeds",void 0,{showTimestamp:!1,showArrow:!0,showLevel:!1}),await Bun.spawn(["bun","add","--dev","@ooneex/seeds"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}rt=b([x.command()],rt);import{join as X}from"path";import{TerminalLogger as fm}from"@ooneex/logger";import{toPascalCase as ym}from"@ooneex/utils";var ta=`import { describe, expect, test } from "bun:test";
2904
+ @Column({ name: "title", type: "varchar", length: 255 })
2905
+ title: string;
2906
+
2907
+ @Column({ name: "color", type: "varchar", length: 50, nullable: true })
2908
+ color?: string | null;
2909
+
2910
+ @Column({ name: "description", type: "text", nullable: true })
2911
+ description?: string | null;
2912
+
2913
+ @Column({ name: "summarize", type: "text", nullable: true })
2914
+ summarize?: string | null;
2915
+
2916
+ @Column({ name: "page_count", type: "int", nullable: true })
2917
+ pageCount?: number | null;
2918
+
2919
+ @Column({ name: "src", type: "varchar", length: 255 })
2920
+ src: string;
2921
+
2922
+ @Column({ name: "cover_image", type: "varchar", length: 255, nullable: true })
2923
+ coverImage?: string | null;
2924
+
2925
+ @Column({ name: "tags", type: "text", array: true, nullable: true })
2926
+ tags?: string[] | null;
2927
+
2928
+ @Column({ name: "topics", type: "text", array: true, nullable: true })
2929
+ topics?: string[] | null;
2930
+
2931
+ @Column({ name: "categories", type: "text", array: true, nullable: true })
2932
+ categories?: string[] | null;
2933
+
2934
+ @Column({ name: "lang", type: "varchar", length: 10, nullable: true })
2935
+ lang?: LocaleType | null;
2936
+
2937
+ @Column({ name: "status", type: "varchar", length: 50, nullable: true })
2938
+ status?: string | null;
2939
+
2940
+ @CreateDateColumn({ name: "created_at" })
2941
+ createdAt?: Date | null;
2942
+
2943
+ @UpdateDateColumn({ name: "updated_at" })
2944
+ updatedAt?: Date | null;
2945
+ }
2946
+ `;var ea=`import { decorator, type IMigration, type MigrationClassType } from '@ooneex/migrations';
2947
+ import type { TransactionSQL } from 'bun';
2948
+
2949
+ @decorator.migration()
2950
+ export class {{ name }} implements IMigration {
2951
+ public async up(tx: TransactionSQL): Promise<void> {
2952
+ await tx\`
2953
+ CREATE TABLE IF NOT EXISTS books (
2954
+ id VARCHAR(25) PRIMARY KEY,
2955
+ title VARCHAR(255) NOT NULL,
2956
+ color VARCHAR(50),
2957
+ description TEXT,
2958
+ summarize TEXT,
2959
+ page_count INT,
2960
+ src VARCHAR(255) NOT NULL,
2961
+ cover_image VARCHAR(255),
2962
+ tags TEXT[],
2963
+ topics TEXT[],
2964
+ categories TEXT[],
2965
+ lang VARCHAR(10),
2966
+ status VARCHAR(50),
2967
+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
2968
+ updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
2969
+ )
2970
+ \`;
2971
+
2972
+ await tx\`
2973
+ CREATE INDEX IF NOT EXISTS idx_books_title ON books (title)
2974
+ \`;
2975
+ }
2976
+
2977
+ public async down(tx: TransactionSQL): Promise<void> {
2978
+ await tx\`DROP TABLE IF EXISTS books\`;
2979
+ }
2980
+
2981
+ public getVersion(): string {
2982
+ return '{{ version }}';
2983
+ }
2984
+
2985
+ public getDependencies(): MigrationClassType[] {
2986
+ return [];
2987
+ }
2988
+ }
2989
+ `;var ta=`import { inject } from "@ooneex/container";
2990
+ import type { ITypeormDatabase } from "@ooneex/database";
2991
+ import { decorator } from "@ooneex/repository";
2992
+ import type { FilterResultType } from "@ooneex/types";
2993
+ import type { FindManyOptions, FindOptionsWhere, Repository, SaveOptions, UpdateResult } from "typeorm";
2994
+ import { ILike } from "typeorm";
2995
+ import { BookEntity } from "../entities/BookEntity";
2996
+
2997
+ @decorator.repository()
2998
+ export class BookRepository {
2999
+ constructor(
3000
+ @inject("database")
3001
+ private readonly database: ITypeormDatabase,
3002
+ ) {}
3003
+
3004
+ public async open(): Promise<Repository<BookEntity>> {
3005
+ return await this.database.open(BookEntity);
3006
+ }
3007
+
3008
+ public async close(): Promise<void> {
3009
+ await this.database.close();
3010
+ }
3011
+
3012
+ public async find(
3013
+ criteria: FindManyOptions<BookEntity> & { page?: number; limit?: number; q?: string },
3014
+ ): Promise<FilterResultType<BookEntity>> {
3015
+ const repository = await this.open();
3016
+
3017
+ const { page = 1, limit = 100, q, ...rest } = criteria;
3018
+
3019
+ let skip: number | undefined;
3020
+ const take = limit === 0 ? 100 : limit;
3021
+
3022
+ if (page && page > 0 && limit && limit > 0) {
3023
+ skip = (page - 1) * take;
3024
+ }
3025
+
3026
+ let findOptions = { ...rest, take, ...(skip !== undefined && { skip }) };
3027
+ if (q) {
3028
+ findOptions = {
3029
+ ...findOptions,
3030
+ where: {
3031
+ ...rest.where,
3032
+ title: ILike(\`%\${q}%\`),
3033
+ },
3034
+ };
3035
+ }
3036
+
3037
+ const result = await repository.find(findOptions);
3038
+
3039
+ let countWhere = rest.where;
3040
+ if (q) {
3041
+ countWhere = {
3042
+ ...rest.where,
3043
+ title: ILike(\`%\${q}%\`),
3044
+ };
3045
+ }
3046
+
3047
+ const total = await this.count(countWhere);
3048
+ const totalPages = Math.ceil(total / limit);
3049
+
3050
+ return {
3051
+ resources: result,
3052
+ total,
3053
+ totalPages,
3054
+ page,
3055
+ limit,
3056
+ };
3057
+ }
3058
+
3059
+ public async findOne(id: string): Promise<BookEntity | null> {
3060
+ const repository = await this.open();
3061
+
3062
+ return await repository.findOne({
3063
+ where: { id },
3064
+ });
3065
+ }
3066
+
3067
+ public async findOneBy(criteria: FindOptionsWhere<BookEntity>): Promise<BookEntity | null> {
3068
+ const repository = await this.open();
3069
+
3070
+ return await repository.findOne({
3071
+ where: criteria,
3072
+ });
3073
+ }
3074
+
3075
+ public async create(entity: BookEntity, options?: SaveOptions): Promise<BookEntity> {
3076
+ const repository = await this.open();
3077
+
3078
+ return await repository.save(entity, options);
3079
+ }
3080
+
3081
+ public async createMany(entities: BookEntity[], options?: SaveOptions): Promise<BookEntity[]> {
3082
+ const repository = await this.open();
3083
+
3084
+ return await repository.save(entities, options);
3085
+ }
3086
+
3087
+ public async update(entity: Partial<BookEntity> & { id: string }): Promise<UpdateResult> {
3088
+ const repository = await this.open();
3089
+
3090
+ return await repository.update(entity.id, entity);
3091
+ }
3092
+
3093
+ public async updateMany(entities: (Partial<BookEntity> & { id: string })[]): Promise<UpdateResult[]> {
3094
+ const repository = await this.open();
3095
+
3096
+ return await Promise.all(entities.map((entity) => repository.update(entity.id, entity)));
3097
+ }
3098
+
3099
+ public async delete(
3100
+ criteria: FindOptionsWhere<BookEntity> | FindOptionsWhere<BookEntity>[],
3101
+ ): Promise<UpdateResult> {
3102
+ const repository = await this.open();
3103
+
3104
+ return await repository.softDelete(criteria);
3105
+ }
3106
+
3107
+ public async count(criteria?: FindOptionsWhere<BookEntity> | FindOptionsWhere<BookEntity>[]): Promise<number> {
3108
+ const repository = await this.open();
3109
+
3110
+ return await repository.count(criteria ? { where: criteria } : {});
3111
+ }
3112
+ }
3113
+ `;var sa=`import type { ContextType } from "@ooneex/controller";
3114
+ import { inject } from "@ooneex/container";
3115
+ import { ERole } from "@ooneex/role";
3116
+ import { Route } from "@ooneex/routing";
3117
+ import type { LocaleType } from "@ooneex/translation";
3118
+ import { Assert } from "@ooneex/validation";
3119
+ import { CreateBookService } from "../services/CreateBookService";
3120
+
3121
+ type CreateBookRouteType = {
3122
+ payload: {
3123
+ title: string;
3124
+ color?: string;
3125
+ description?: string;
3126
+ summarize?: string;
3127
+ pageCount?: number;
3128
+ src: string;
3129
+ coverImage?: string;
3130
+ tags?: string[];
3131
+ topics?: string[];
3132
+ categories?: string[];
3133
+ lang?: LocaleType;
3134
+ status?: string;
3135
+ };
3136
+ response: {
3137
+ id: string;
3138
+ title: string;
3139
+ color?: string;
3140
+ description?: string;
3141
+ summarize?: string;
3142
+ pageCount?: number;
3143
+ src: string;
3144
+ coverImage?: string;
3145
+ tags?: string[];
3146
+ topics?: string[];
3147
+ categories?: string[];
3148
+ lang?: LocaleType;
3149
+ status?: string;
3150
+ };
3151
+ };
3152
+
3153
+ @Route.Post("/books", {
3154
+ name: "book.create",
3155
+ version: 1,
3156
+ description: "Create a new book",
3157
+ payload: Assert({
3158
+ title: "string",
3159
+ color: "string?",
3160
+ description: "string?",
3161
+ summarize: "string?",
3162
+ pageCount: "number?",
3163
+ src: "string",
3164
+ coverImage: "string?",
3165
+ tags: "string[]?",
3166
+ topics: "string[]?",
3167
+ categories: "string[]?",
3168
+ lang: "string?",
3169
+ status: "string?",
3170
+ }),
3171
+ response: Assert({
3172
+ id: "string",
3173
+ title: "string",
3174
+ color: "string?",
3175
+ description: "string?",
3176
+ summarize: "string?",
3177
+ pageCount: "number?",
3178
+ src: "string",
3179
+ coverImage: "string?",
3180
+ tags: "string[]?",
3181
+ topics: "string[]?",
3182
+ categories: "string[]?",
3183
+ lang: "string?",
3184
+ status: "string?",
3185
+ }),
3186
+ roles: [ERole.USER],
3187
+ })
3188
+ export class CreateBookController {
3189
+ constructor(
3190
+ @inject(CreateBookService) private readonly service: CreateBookService,
3191
+ ) {}
3192
+
3193
+ public async index(context: ContextType<CreateBookRouteType>) {
3194
+ const { title, color, description, summarize, pageCount, src, coverImage, tags, topics, categories, lang, status } = context.payload;
3195
+
3196
+ const book = await this.service.execute({ title, color, description, summarize, pageCount, src, coverImage, tags, topics, categories, lang, status });
3197
+
3198
+ return context.response.json(book);
3199
+ }
3200
+ }
3201
+ `;var ra=`import type { ContextType } from "@ooneex/controller";
3202
+ import { inject } from "@ooneex/container";
3203
+ import { ERole } from "@ooneex/role";
3204
+ import { Route } from "@ooneex/routing";
3205
+ import { Assert } from "@ooneex/validation";
3206
+ import { DeleteBookService } from "../services/DeleteBookService";
3207
+
3208
+ type DeleteBookRouteType = {
3209
+ params: { id: string };
3210
+ response: { id: string };
3211
+ };
3212
+
3213
+ @Route.Delete("/books/:id", {
3214
+ name: "book.delete",
3215
+ version: 1,
3216
+ description: "Delete a book",
3217
+ params: {
3218
+ id: Assert("string"),
3219
+ },
3220
+ response: Assert({
3221
+ id: "string",
3222
+ }),
3223
+ roles: [ERole.USER],
3224
+ })
3225
+ export class DeleteBookController {
3226
+ constructor(
3227
+ @inject(DeleteBookService) private readonly service: DeleteBookService,
3228
+ ) {}
3229
+
3230
+ public async index(context: ContextType<DeleteBookRouteType>) {
3231
+ const { id } = context.params;
3232
+
3233
+ await this.service.execute({ id });
3234
+
3235
+ return context.response.json({ id });
3236
+ }
3237
+ }
3238
+ `;var oa=`import type { ContextType } from "@ooneex/controller";
3239
+ import { inject } from "@ooneex/container";
3240
+ import type { LocaleType } from "@ooneex/translation";
3241
+ import { ERole } from "@ooneex/role";
3242
+ import { Route } from "@ooneex/routing";
3243
+ import { Assert } from "@ooneex/validation";
3244
+ import { GetBookService } from "../services/GetBookService";
3245
+
3246
+ type GetBookRouteType = {
3247
+ params: { id: string };
3248
+ response: {
3249
+ id: string;
3250
+ title: string;
3251
+ color?: string;
3252
+ description?: string;
3253
+ summarize?: string;
3254
+ pageCount?: number;
3255
+ src: string;
3256
+ coverImage?: string;
3257
+ tags?: string[];
3258
+ topics?: string[];
3259
+ categories?: string[];
3260
+ lang?: LocaleType;
3261
+ status?: string;
3262
+ };
3263
+ };
3264
+
3265
+ @Route.Get("/books/:id", {
3266
+ name: "book.get",
3267
+ version: 1,
3268
+ description: "Get a book by id",
3269
+ params: {
3270
+ id: Assert("string"),
3271
+ },
3272
+ roles: [ERole.USER],
3273
+ })
3274
+ export class GetBookController {
3275
+ constructor(
3276
+ @inject(GetBookService) private readonly service: GetBookService,
3277
+ ) {}
3278
+
3279
+ public async index(context: ContextType<GetBookRouteType>) {
3280
+ const { id } = context.params;
3281
+
3282
+ const book = await this.service.execute({ id });
3283
+
3284
+ return context.response.json(book);
3285
+ }
3286
+ }
3287
+ `;var ia=`import type { ContextType } from "@ooneex/controller";
3288
+ import { inject } from "@ooneex/container";
3289
+ import type { LocaleType } from "@ooneex/translation";
3290
+ import { ERole } from "@ooneex/role";
3291
+ import { Route } from "@ooneex/routing";
3292
+ import { Assert } from "@ooneex/validation";
3293
+ import { ListBooksService } from "../services/ListBooksService";
3294
+
3295
+ type ListBooksRouteType = {
3296
+ query: { page?: number; limit?: number; q?: string };
3297
+ response: {
3298
+ resources: {
3299
+ id: string;
3300
+ title: string;
3301
+ color?: string;
3302
+ description?: string;
3303
+ summarize?: string;
3304
+ pageCount?: number;
3305
+ src: string;
3306
+ coverImage?: string;
3307
+ tags?: string[];
3308
+ topics?: string[];
3309
+ categories?: string[];
3310
+ lang?: LocaleType;
3311
+ status?: string;
3312
+ }[];
3313
+ total: number;
3314
+ totalPages: number;
3315
+ page: number;
3316
+ limit: number;
3317
+ };
3318
+ };
3319
+
3320
+ @Route.Get("/books", {
3321
+ name: "book.list",
3322
+ version: 1,
3323
+ description: "List all books",
3324
+ query: Assert({
3325
+ page: "number?",
3326
+ limit: "number?",
3327
+ q: "string?",
3328
+ }),
3329
+ roles: [ERole.USER],
3330
+ })
3331
+ export class ListBooksController {
3332
+ constructor(
3333
+ @inject(ListBooksService) private readonly service: ListBooksService,
3334
+ ) {}
3335
+
3336
+ public async index(context: ContextType<ListBooksRouteType>) {
3337
+ const { page, limit, q } = context.query;
3338
+
3339
+ const result = await this.service.execute({ page, limit, q });
3340
+
3341
+ return context.response.json(result);
3342
+ }
3343
+ }
3344
+ `;var aa=`import type { ContextType } from "@ooneex/controller";
3345
+ import { inject } from "@ooneex/container";
3346
+ import { ERole } from "@ooneex/role";
3347
+ import { Route } from "@ooneex/routing";
3348
+ import type { LocaleType } from "@ooneex/translation";
3349
+ import { Assert } from "@ooneex/validation";
3350
+ import { UpdateBookService } from "../services/UpdateBookService";
3351
+
3352
+ type UpdateBookRouteType = {
3353
+ params: { id: string };
3354
+ payload: {
3355
+ title?: string;
3356
+ color?: string;
3357
+ description?: string;
3358
+ summarize?: string;
3359
+ pageCount?: number;
3360
+ src?: string;
3361
+ coverImage?: string;
3362
+ tags?: string[];
3363
+ topics?: string[];
3364
+ categories?: string[];
3365
+ lang?: LocaleType;
3366
+ status?: string;
3367
+ };
3368
+ response: {
3369
+ id: string;
3370
+ title: string;
3371
+ color?: string;
3372
+ description?: string;
3373
+ summarize?: string;
3374
+ pageCount?: number;
3375
+ src: string;
3376
+ coverImage?: string;
3377
+ tags?: string[];
3378
+ topics?: string[];
3379
+ categories?: string[];
3380
+ lang?: LocaleType;
3381
+ status?: string;
3382
+ };
3383
+ };
3384
+
3385
+ @Route.Patch("/books/:id", {
3386
+ name: "book.update",
3387
+ version: 1,
3388
+ description: "Update a book",
3389
+ params: {
3390
+ id: Assert("string"),
3391
+ },
3392
+ payload: Assert({
3393
+ title: "string?",
3394
+ color: "string?",
3395
+ description: "string?",
3396
+ summarize: "string?",
3397
+ pageCount: "number?",
3398
+ src: "string?",
3399
+ coverImage: "string?",
3400
+ tags: "string[]?",
3401
+ topics: "string[]?",
3402
+ categories: "string[]?",
3403
+ lang: "string?",
3404
+ status: "string?",
3405
+ }),
3406
+ response: Assert({
3407
+ id: "string",
3408
+ title: "string",
3409
+ color: "string?",
3410
+ description: "string?",
3411
+ summarize: "string?",
3412
+ pageCount: "number?",
3413
+ src: "string",
3414
+ coverImage: "string?",
3415
+ tags: "string[]?",
3416
+ topics: "string[]?",
3417
+ categories: "string[]?",
3418
+ lang: "string?",
3419
+ status: "string?",
3420
+ }),
3421
+ roles: [ERole.USER],
3422
+ })
3423
+ export class UpdateBookController {
3424
+ constructor(
3425
+ @inject(UpdateBookService) private readonly service: UpdateBookService,
3426
+ ) {}
3427
+
3428
+ public async index(context: ContextType<UpdateBookRouteType>) {
3429
+ const { id } = context.params;
3430
+ const { title, color, description, summarize, pageCount, src, coverImage, tags, topics, categories, lang, status } = context.payload;
3431
+
3432
+ const book = await this.service.execute({ id, title, color, description, summarize, pageCount, src, coverImage, tags, topics, categories, lang, status });
3433
+
3434
+ return context.response.json(book);
3435
+ }
3436
+ }
3437
+ `;var na=`import { inject } from "@ooneex/container";
3438
+ import { decorator } from "@ooneex/service";
3439
+ import type { IService } from "@ooneex/service";
3440
+ import type { LocaleType } from "@ooneex/translation";
3441
+ import { BookEntity } from "../entities/BookEntity";
3442
+ import { BookRepository } from "../repositories/BookRepository";
3443
+
3444
+ type ServiceDataType = {
3445
+ title: string;
3446
+ color?: string;
3447
+ description?: string;
3448
+ summarize?: string;
3449
+ pageCount?: number;
3450
+ src: string;
3451
+ coverImage?: string;
3452
+ tags?: string[];
3453
+ topics?: string[];
3454
+ categories?: string[];
3455
+ lang?: LocaleType;
3456
+ status?: string;
3457
+ };
3458
+
3459
+ @decorator.service()
3460
+ export class CreateBookService<T extends ServiceDataType = ServiceDataType> implements IService<T> {
3461
+ constructor(
3462
+ @inject(BookRepository) private readonly repository: BookRepository,
3463
+ ) {}
3464
+
3465
+ public async execute(data?: T): Promise<BookEntity | null> {
3466
+ if (!data) return null;
3467
+
3468
+ const book = new BookEntity();
3469
+ book.title = data.title;
3470
+ book.color = data.color;
3471
+ book.description = data.description;
3472
+ book.summarize = data.summarize;
3473
+ book.pageCount = data.pageCount;
3474
+ book.src = data.src;
3475
+ book.coverImage = data.coverImage;
3476
+ book.tags = data.tags;
3477
+ book.topics = data.topics;
3478
+ book.categories = data.categories;
3479
+ book.lang = data.lang;
3480
+ book.status = data.status;
3481
+
3482
+ return await this.repository.create(book);
3483
+ }
3484
+ }
3485
+ `;var la=`import { inject } from "@ooneex/container";
3486
+ import { decorator } from "@ooneex/service";
3487
+ import type { IService } from "@ooneex/service";
3488
+ import { BookRepository } from "../repositories/BookRepository";
3489
+
3490
+ type ServiceDataType = {
3491
+ id: string;
3492
+ };
3493
+
3494
+ @decorator.service()
3495
+ export class DeleteBookService<T extends ServiceDataType = ServiceDataType> implements IService<T> {
3496
+ constructor(
3497
+ @inject(BookRepository) private readonly repository: BookRepository,
3498
+ ) {}
3499
+
3500
+ public async execute(data?: T): Promise<void> {
3501
+ if (!data) return;
3502
+
3503
+ await this.repository.delete({ id: data.id });
3504
+ }
3505
+ }
3506
+ `;var da=`import { inject } from "@ooneex/container";
3507
+ import { decorator } from "@ooneex/service";
3508
+ import type { IService } from "@ooneex/service";
3509
+ import { BookEntity } from "../entities/BookEntity";
3510
+ import { BookRepository } from "../repositories/BookRepository";
3511
+
3512
+ type ServiceDataType = {
3513
+ id: string;
3514
+ };
3515
+
3516
+ @decorator.service()
3517
+ export class GetBookService<T extends ServiceDataType = ServiceDataType> implements IService<T> {
3518
+ constructor(
3519
+ @inject(BookRepository) private readonly repository: BookRepository,
3520
+ ) {}
3521
+
3522
+ public async execute(data?: T): Promise<BookEntity | null> {
3523
+ if (!data) return null;
3524
+
3525
+ return await this.repository.findOne(data.id);
3526
+ }
3527
+ }
3528
+ `;var ca=`import { inject } from "@ooneex/container";
3529
+ import { decorator } from "@ooneex/service";
3530
+ import type { IService } from "@ooneex/service";
3531
+ import type { FilterResultType } from "@ooneex/types";
3532
+ import { BookEntity } from "../entities/BookEntity";
3533
+ import { BookRepository } from "../repositories/BookRepository";
3534
+
3535
+ type ServiceDataType = {
3536
+ page?: number;
3537
+ limit?: number;
3538
+ q?: string;
3539
+ };
3540
+
3541
+ @decorator.service()
3542
+ export class ListBooksService<T extends ServiceDataType = ServiceDataType> implements IService<T> {
3543
+ constructor(
3544
+ @inject(BookRepository) private readonly repository: BookRepository,
3545
+ ) {}
3546
+
3547
+ public async execute(data?: T): Promise<FilterResultType<BookEntity>> {
3548
+ return await this.repository.find({
3549
+ page: data?.page,
3550
+ limit: data?.limit,
3551
+ q: data?.q,
3552
+ });
3553
+ }
3554
+ }
3555
+ `;var pa=`import { inject } from "@ooneex/container";
3556
+ import { decorator } from "@ooneex/service";
3557
+ import type { IService } from "@ooneex/service";
3558
+ import type { LocaleType } from "@ooneex/translation";
3559
+ import { BookEntity } from "../entities/BookEntity";
3560
+ import { BookRepository } from "../repositories/BookRepository";
3561
+
3562
+ type ServiceDataType = {
3563
+ id: string;
3564
+ title?: string;
3565
+ color?: string;
3566
+ description?: string;
3567
+ summarize?: string;
3568
+ pageCount?: number;
3569
+ src?: string;
3570
+ coverImage?: string;
3571
+ tags?: string[];
3572
+ topics?: string[];
3573
+ categories?: string[];
3574
+ lang?: LocaleType;
3575
+ status?: string;
3576
+ };
3577
+
3578
+ @decorator.service()
3579
+ export class UpdateBookService<T extends ServiceDataType = ServiceDataType> implements IService<T> {
3580
+ constructor(
3581
+ @inject(BookRepository) private readonly repository: BookRepository,
3582
+ ) {}
3583
+
3584
+ public async execute(data?: T): Promise<BookEntity | null> {
3585
+ if (!data) return null;
3586
+
3587
+ const { id, ...fields } = data;
3588
+
3589
+ await this.repository.update({ id, ...fields });
3590
+
3591
+ return await this.repository.findOne(id);
3592
+ }
3593
+ }
3594
+ `;import{join as J}from"path";import{TerminalLogger as Up}from"@ooneex/logger";import{toPascalCase as Gp}from"@ooneex/utils";var ma=`import { describe, expect, test } from "bun:test";
2968
3595
  import { {{NAME}}Service } from "@/services/{{NAME}}Service";
2969
3596
 
2970
3597
  describe("{{NAME}}Service", () => {
@@ -2977,7 +3604,7 @@ describe("{{NAME}}Service", () => {
2977
3604
  expect(typeof {{NAME}}Service.prototype.execute).toBe("function");
2978
3605
  });
2979
3606
  });
2980
- `;var sa=`import { decorator } from "@ooneex/service";
3607
+ `;var ua=`import { decorator } from "@ooneex/service";
2981
3608
  import type { IService } from "@ooneex/service";
2982
3609
 
2983
3610
  type ServiceDataType = Record<string, unknown>;
@@ -2988,7 +3615,13 @@ export class {{NAME}}Service<T extends ServiceDataType = ServiceDataType> implem
2988
3615
  // TODO: Implement service logic
2989
3616
  }
2990
3617
  }
2991
- `;class ot{getName(){return"make:service"}getDescription(){return"Generate a new service class"}async run(e){let{name:t,module:s}=e;if(!t)t=await v({message:"Enter service name"});t=ym(t).replace(/Service$/,"");let r=sa.replace(/{{NAME}}/g,t),o=s?X("modules",s):".",i=X(o,"src","services"),a=X(process.cwd(),i),n=X(a,`${t}Service.ts`);await Bun.write(n,r);let d=ta.replace(/{{NAME}}/g,t),l=X(o,"tests","services"),c=X(process.cwd(),l),u=X(c,`${t}Service.spec.ts`);await Bun.write(u,d);let p=new fm;p.success(`${X(i,t)}Service.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),p.success(`${X(l,t)}Service.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/service"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}ot=b([x.command()],ot);import{join as J}from"path";import{TerminalLogger as xm}from"@ooneex/logger";import{toPascalCase as wm,toSnakeCase as Em}from"@ooneex/utils";var ra=`import { describe, expect, test } from "bun:test";
3618
+ `;class ve{getName(){return"make:service"}getDescription(){return"Generate a new service class"}async run(e){let{name:t,module:s}=e;if(!t)t=await A({message:"Enter service name"});t=Gp(t).replace(/Service$/,"");let r=ua.replace(/{{NAME}}/g,t),o=s?J("modules",s):".",i=J(o,"src","services"),a=J(process.cwd(),i),n=J(a,`${t}Service.ts`);await Bun.write(n,r);let l=ma.replace(/{{NAME}}/g,t),d=J(o,"tests","services"),c=J(process.cwd(),d),u=J(c,`${t}Service.spec.ts`);await Bun.write(u,l);let m=new Up;m.success(`${J(i,t)}Service.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),m.success(`${J(d,t)}Service.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/service"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}ve=b([x.command()],ve);class rt{getName(){return"make:resource:book"}getDescription(){return"Generate book resource (entity, migration, repository)"}async run(){let t=C("modules","book");await new be().run({name:"Book",module:"book",tableName:"books"}),await new xe().run({module:"book"}),await new we().run({name:"Book",module:"book"});let i=new ne,a=[{name:"CreateBook",route:{name:"book.create",path:"/books",method:"POST"}},{name:"GetBook",route:{name:"book.get",path:"/books/:id",method:"GET"}},{name:"ListBooks",route:{name:"book.list",path:"/books",method:"GET"}},{name:"UpdateBook",route:{name:"book.update",path:"/books/:id",method:"PATCH"}},{name:"DeleteBook",route:{name:"book.delete",path:"/books/:id",method:"DELETE"}}];for(let f of a)await i.run({...f,module:"book",isSocket:!1});let n=C(process.cwd(),t,"src","controllers");await Bun.write(C(n,"CreateBookController.ts"),sa),await Bun.write(C(n,"GetBookController.ts"),oa),await Bun.write(C(n,"ListBooksController.ts"),ia),await Bun.write(C(n,"UpdateBookController.ts"),aa),await Bun.write(C(n,"DeleteBookController.ts"),ra);let l=new ve,d=["CreateBook","GetBook","ListBooks","UpdateBook","DeleteBook"];for(let f of d)await l.run({name:f,module:"book"});let c=C(process.cwd(),t,"src","services");await Bun.write(C(c,"CreateBookService.ts"),na),await Bun.write(C(c,"GetBookService.ts"),da),await Bun.write(C(c,"ListBooksService.ts"),ca),await Bun.write(C(c,"UpdateBookService.ts"),pa),await Bun.write(C(c,"DeleteBookService.ts"),la);let u=C(process.cwd(),t,"src","entities","BookEntity.ts");await Bun.write(u,ji);let m=C(process.cwd(),t,"src","migrations"),p=new $p("Migration*.ts");for await(let f of p.scan(m)){if(f==="migrations.ts")continue;let g=f.replace(/\.ts$/,""),y=g.replace("Migration",""),w=ea.replaceAll("{{ name }}",g).replaceAll("{{ version }}",y);await Bun.write(C(m,f),w)}let h=C(process.cwd(),t,"src","repositories","BookRepository.ts");await Bun.write(h,ta)}}rt=b([x.command()],rt);import{join as ot}from"path";import{TerminalLogger as Wp}from"@ooneex/logger";import{seedCreate as Fp}from"@ooneex/seeds";var ha=`#!/usr/bin/env bun
3619
+
3620
+ import { seedRun } from "@ooneex/seeds";
3621
+ import "@/seeds/seeds";
3622
+
3623
+ await seedRun();
3624
+ `;class it{getName(){return"make:seed"}getDescription(){return"Generate a new seed file"}async run(e){let{name:t,module:s}=e;if(!t)t=await A({message:"Enter seed name"});let r=s?ot("modules",s):".",o=await Fp({name:t,dir:ot(r,"src/seeds")}),i=ot(process.cwd(),r,"bin","seed","run.ts");if(!await Bun.file(i).exists())await Bun.write(i,ha);let n=ot(process.cwd(),"package.json"),l=Bun.file(n);if(await l.exists()){let u=await l.json();u.scripts=u.scripts||{},u.scripts["seed:run"]="bun ./bin/seed/run.ts",await Bun.write(n,JSON.stringify(u,null,2))}let d=new Wp;d.success(`${o} created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),d.info("Run 'bun run seed:run' to execute seeds",void 0,{showTimestamp:!1,showArrow:!0,showLevel:!1}),await Bun.spawn(["bun","add","--dev","@ooneex/seeds"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}it=b([x.command()],it);import{join as j}from"path";import{TerminalLogger as Vp}from"@ooneex/logger";import{toPascalCase as zp,toSnakeCase as Yp}from"@ooneex/utils";var fa=`import { describe, expect, test } from "bun:test";
2992
3625
  import { {{NAME}}StorageAdapter } from "@/storage/{{NAME}}StorageAdapter";
2993
3626
 
2994
3627
  describe("{{NAME}}StorageAdapter", () => {
@@ -3005,7 +3638,7 @@ describe("{{NAME}}StorageAdapter", () => {
3005
3638
  expect(typeof {{NAME}}StorageAdapter.prototype.getOptions).toBe("function");
3006
3639
  });
3007
3640
  });
3008
- `;var oa=`import { Storage, decorator, StorageException } from "@ooneex/storage";
3641
+ `;var ya=`import { Storage, decorator, StorageException } from "@ooneex/storage";
3009
3642
  import type { S3Options } from "bun";
3010
3643
 
3011
3644
  @decorator.storage()
@@ -3060,7 +3693,7 @@ export class {{NAME}}Storage extends Storage {
3060
3693
  };
3061
3694
  }
3062
3695
  }
3063
- `;class it{getName(){return"make:storage"}getDescription(){return"Generate a new storage class"}async run(e){let{name:t,module:s}=e;if(!t)t=await v({message:"Enter storage name"});t=wm(t).replace(/Storage$/,"");let r=Em(t).toUpperCase(),o=oa.replace(/{{NAME}}/g,t).replace(/{{NAME_UPPER}}/g,r),i=s?J("modules",s):".",a=J(i,"src","storage"),n=J(process.cwd(),a),d=J(n,`${t}Storage.ts`);await Bun.write(d,o);let l=ra.replace(/{{NAME}}/g,t),c=J(i,"tests","storage"),u=J(process.cwd(),c),p=J(u,`${t}Storage.spec.ts`);await Bun.write(p,l);let m=new xm;m.success(`${J(a,t)}Storage.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),m.success(`${J(c,t)}Storage.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/storage"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}it=b([x.command()],it);import{join as j}from"path";import{TerminalLogger as Nm}from"@ooneex/logger";import{toPascalCase as Sm}from"@ooneex/utils";var ia=`import { describe, expect, test } from "bun:test";
3696
+ `;class at{getName(){return"make:storage"}getDescription(){return"Generate a new storage class"}async run(e){let{name:t,module:s}=e;if(!t)t=await A({message:"Enter storage name"});t=zp(t).replace(/Storage$/,"");let r=Yp(t).toUpperCase(),o=ya.replace(/{{NAME}}/g,t).replace(/{{NAME_UPPER}}/g,r),i=s?j("modules",s):".",a=j(i,"src","storage"),n=j(process.cwd(),a),l=j(n,`${t}Storage.ts`);await Bun.write(l,o);let d=fa.replace(/{{NAME}}/g,t),c=j(i,"tests","storage"),u=j(process.cwd(),c),m=j(u,`${t}Storage.spec.ts`);await Bun.write(m,d);let p=new Vp;p.success(`${j(a,t)}Storage.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),p.success(`${j(c,t)}Storage.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/storage"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}at=b([x.command()],at);import{join as ee}from"path";import{TerminalLogger as Xp}from"@ooneex/logger";import{toPascalCase as Jp}from"@ooneex/utils";var ga=`import { describe, expect, test } from "bun:test";
3064
3697
  import { {{NAME}}VectorDatabase } from "@/databases/{{NAME}}VectorDatabase";
3065
3698
 
3066
3699
  describe("{{NAME}}VectorDatabase", () => {
@@ -3083,7 +3716,7 @@ describe("{{NAME}}VectorDatabase", () => {
3083
3716
  expect(typeof {{NAME}}VectorDatabase.prototype.getSchema).toBe("function");
3084
3717
  });
3085
3718
  });
3086
- `;var aa=`import { VectorDatabase, decorator } from "@ooneex/rag";
3719
+ `;var ba=`import { VectorDatabase, decorator } from "@ooneex/rag";
3087
3720
  import type { EmbeddingModelType, EmbeddingProviderType, FieldValueType } from "@ooneex/rag";
3088
3721
  import { Utf8 } from "apache-arrow";
3089
3722
 
@@ -3107,8 +3740,8 @@ export class {{NAME}}VectorDatabase extends VectorDatabase<DataType> {
3107
3740
  };
3108
3741
  }
3109
3742
  }
3110
- `;class at{getName(){return"make:vector-database"}getDescription(){return"Generate a new vector database class"}async run(e){let{name:t,module:s}=e;if(!t)t=await v({message:"Enter vector database name"});t=Sm(t).replace(/VectorDatabase$/,"").replace(/Database$/,"");let r=aa.replace(/{{NAME}}/g,t),o=s?j("modules",s):".",i=j(o,"src","databases"),a=j(process.cwd(),i),n=j(a,`${t}VectorDatabase.ts`);await Bun.write(n,r);let d=ia.replace(/{{NAME}}/g,t),l=j(o,"tests","databases"),c=j(process.cwd(),l),u=j(c,`${t}VectorDatabase.spec.ts`);await Bun.write(u,d);let p=new Nm;p.success(`${j(i,t)}VectorDatabase.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),p.success(`${j(l,t)}VectorDatabase.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/rag"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}at=b([x.command()],at);var{values:q,positionals:Mm}=Tm({args:Bun.argv,options:{name:{type:"string"},"route-name":{type:"string"},"route-path":{type:"string"},"route-method":{type:"string"},"is-socket":{type:"boolean"},dir:{type:"string"},channel:{type:"string"},"table-name":{type:"string"},module:{type:"string"},destination:{type:"string"}},strict:!1,allowPositionals:!0}),qt=new Rm,da=Mm[2];if(!da)qt.error(`Command name is required
3111
- `),process.exit(1);var la=Ft(da);if(!la)qt.info(`No commands found
3112
- `),process.exit(1);var Cm={name:q.name,dir:q.dir,channel:q.channel,isSocket:q["is-socket"],tableName:q["table-name"],module:q.module,destination:q.destination,route:{name:q["route-name"],path:q["route-path"],method:q["route-method"]}};try{await la.run(Cm)}catch(e){let t=e instanceof na?e:new na(e instanceof Error?e:String(e));qt.error(t,void 0,{showArrow:!1,showTimestamp:!1,showLevel:!1}),process.exit(1)}
3743
+ `;class nt{getName(){return"make:vector-database"}getDescription(){return"Generate a new vector database class"}async run(e){let{name:t,module:s}=e;if(!t)t=await A({message:"Enter vector database name"});t=Jp(t).replace(/VectorDatabase$/,"").replace(/Database$/,"");let r=ba.replace(/{{NAME}}/g,t),o=s?ee("modules",s):".",i=ee(o,"src","databases"),a=ee(process.cwd(),i),n=ee(a,`${t}VectorDatabase.ts`);await Bun.write(n,r);let l=ga.replace(/{{NAME}}/g,t),d=ee(o,"tests","databases"),c=ee(process.cwd(),d),u=ee(c,`${t}VectorDatabase.spec.ts`);await Bun.write(u,l);let m=new Xp;m.success(`${ee(i,t)}VectorDatabase.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),m.success(`${ee(d,t)}VectorDatabase.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),await Bun.spawn(["bun","add","@ooneex/rag"],{cwd:process.cwd(),stdout:"ignore",stderr:"inherit"}).exited}}nt=b([x.command()],nt);var{values:F,positionals:tm}=jp({args:Bun.argv,options:{name:{type:"string"},"route-name":{type:"string"},"route-path":{type:"string"},"route-method":{type:"string"},"is-socket":{type:"boolean"},dir:{type:"string"},channel:{type:"string"},"table-name":{type:"string"},module:{type:"string"},destination:{type:"string"}},strict:!1,allowPositionals:!0}),Ft=new em,wa=tm[2];if(!wa)Ft.error(`Command name is required
3744
+ `),process.exit(1);var va=Ht(wa);if(!va)Ft.info(`No commands found
3745
+ `),process.exit(1);var sm={name:F.name,dir:F.dir,channel:F.channel,isSocket:F["is-socket"],tableName:F["table-name"],module:F.module,destination:F.destination,route:{name:F["route-name"],path:F["route-path"],method:F["route-method"]}};try{await va.run(sm)}catch(e){let t=e instanceof xa?e:new xa(e instanceof Error?e:String(e));Ft.error(t,void 0,{showArrow:!1,showTimestamp:!1,showLevel:!1}),process.exit(1)}
3113
3746
 
3114
- //# debugId=5702C0E87621042464756E2164756E21
3747
+ //# debugId=674E9917123F006A64756E2164756E21