UNPKG

docs

Version:

1 lines 82.4 kB
(()=>{var e={2584:e=>{const t=Symbol("arg flag");class ArgError extends Error{constructor(e,t){super(e);this.name="ArgError";this.code=t;Object.setPrototypeOf(this,ArgError.prototype)}}function arg(e,{argv:r=process.argv.slice(2),permissive:n=false,stopAtPositional:a=false}={}){if(!e){throw new ArgError("argument specification object is required","ARG_CONFIG_NO_SPEC")}const i={_:[]};const o={};const s={};for(const r of Object.keys(e)){if(!r){throw new ArgError("argument key cannot be an empty string","ARG_CONFIG_EMPTY_KEY")}if(r[0]!=="-"){throw new ArgError(`argument key must start with '-' but found: '${r}'`,"ARG_CONFIG_NONOPT_KEY")}if(r.length===1){throw new ArgError(`argument key must have a name; singular '-' keys are not allowed: ${r}`,"ARG_CONFIG_NONAME_KEY")}if(typeof e[r]==="string"){o[r]=e[r];continue}let n=e[r];let a=false;if(Array.isArray(n)&&n.length===1&&typeof n[0]==="function"){const[e]=n;n=(t,r,n=[])=>{n.push(e(t,r,n[n.length-1]));return n};a=e===Boolean||e[t]===true}else if(typeof n==="function"){a=n===Boolean||n[t]===true}else{throw new ArgError(`type missing or not a function or valid array type: ${r}`,"ARG_CONFIG_VAD_TYPE")}if(r[1]!=="-"&&r.length>2){throw new ArgError(`short argument keys (with a single hyphen) must have only one character: ${r}`,"ARG_CONFIG_SHORTOPT_TOOLONG")}s[r]=[n,a]}for(let e=0,t=r.length;e<t;e++){const t=r[e];if(a&&i._.length>0){i._=i._.concat(r.slice(e));break}if(t==="--"){i._=i._.concat(r.slice(e+1));break}if(t.length>1&&t[0]==="-"){const a=t[1]==="-"||t.length===2?[t]:t.slice(1).split("").map((e=>`-${e}`));for(let t=0;t<a.length;t++){const c=a[t];const[u,d]=c[1]==="-"?c.split(/=(.*)/,2):[c,undefined];let l=u;while(l in o){l=o[l]}if(!(l in s)){if(n){i._.push(c);continue}else{throw new ArgError(`unknown or unexpected option: ${u}`,"ARG_UNKNOWN_OPTION")}}const[f,p]=s[l];if(!p&&t+1<a.length){throw new ArgError(`option requires argument (but was followed by another short argument): ${u}`,"ARG_MISSING_REQUIRED_SHORTARG")}if(p){i[l]=f(true,l,i[l])}else if(d===undefined){if(r.length<e+2||r[e+1].length>1&&r[e+1][0]==="-"&&!(r[e+1].match(/^-?\d*(\.(?=\d))?\d*$/)&&(f===Number||typeof BigInt!=="undefined"&&f===BigInt))){const e=u===l?"":` (alias for ${l})`;throw new ArgError(`option requires argument: ${u}${e}`,"ARG_MISSING_REQUIRED_LONGARG")}i[l]=f(r[e+1],l,i[l]);++e}else{i[l]=f(d,l,i[l])}}}else{i._.push(t)}}return i}arg.flag=e=>{e[t]=true;return e};arg.COUNT=arg.flag(((e,t,r)=>(r||0)+1));arg.ArgError=ArgError;e.exports=arg},4797:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var a=Object.getOwnPropertyDescriptor(t,r);if(!a||("get"in a?!t.__esModule:a.writable||a.configurable)){a={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,a)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var a=this&&this.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))n(t,e,r)};Object.defineProperty(t,"__esModule",{value:true});a(r(277),t);a(r(6869),t);a(r(677),t);a(r(126),t)},277:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.ServiceInjector=void 0;class ServiceInjector{services;instances=new Map;constructor(e=[]){this.services=e}resolve(e,t,r=[]){if(!e||!this.services.includes(e))return undefined;if(this.instances.has(e))return this.instances.get(e);if(r.includes(e))return undefined;const n=r.concat([e]);const a=new e(...t(e,n));this.instances.set(e,a);return a}}t.ServiceInjector=ServiceInjector},6869:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true})},677:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.run=t.createApp=t.FuncModule=void 0;r(7159);const n=r(6202);const a=r(7713);const FuncModule=e=>t=>{Reflect.defineMetadata(a.metadata.FUNC_MODULE_IDENTIFIER,Object.assign({},e),t)};t.FuncModule=FuncModule;const createApp=(e,t={})=>{const r=resolveModule(e);return new n.Container(r.commands,Object.assign({},t,{services:r.services}))};t.createApp=createApp;const run=async(e,r={})=>{await(0,t.createApp)(e,r).run()};t.run=run;const resolveModule=e=>{const t=isModuleClass(e)?Reflect.getMetadata(a.metadata.FUNC_MODULE_IDENTIFIER,e):e;if(!t){return{commands:[e],services:[]}}const r=(t.imports||[]).map((e=>resolveModule(e)));const n=r.flatMap((e=>e.commands)).concat(t.commands||[]);const i=r.flatMap((e=>e.services)).concat(t.services||[]);return{commands:n,services:i}};const isModuleClass=e=>typeof e==="function"},126:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.Service=void 0;r(7159);const n=r(7713);const Service=()=>e=>{Reflect.defineMetadata(n.metadata.SERVICE_IDENTIFIER,true,e)};t.Service=Service},1112:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.Catch=void 0;r(7159);const n=r(9249);const a=r(7713);const Catch=()=>(e,t)=>{if(typeof e==="function"||typeof t!=="string"){throw(0,n.createSystemError)(n.F_SYSTEM.INVALID_PARAM_TYPE,n.errorTypes.DEFINITION,`Catch "${String(t)}" must decorate an instance method.`,{method:String(t)})}const r=Reflect.getMetadata(a.metadata.METHOD_CATCH_IDENTIFIER,e.constructor)||[];Reflect.defineMetadata(a.metadata.METHOD_CATCH_IDENTIFIER,r.concat([{methodName:t}]),e.constructor)};t.Catch=Catch},5398:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var a=Object.getOwnPropertyDescriptor(t,r);if(!a||("get"in a?!t.__esModule:a.writable||a.configurable)){a={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,a)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var i=this&&this.__importStar||function(){var ownKeys=function(e){ownKeys=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r))t[t.length]=r;return t};return ownKeys(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ownKeys(e),i=0;i<r.length;i++)if(r[i]!=="default")n(t,e,r[i]);a(t,e);return t}}();Object.defineProperty(t,"__esModule",{value:true});t.Command=void 0;r(7159);const o=i(r(8532));const s=r(7713);const commandFactory=e=>t=>{o.commandName(e.name,"name");o.commandAlias(e.alias,"alias");Reflect.defineMetadata(s.metadata.COMMAND_IDENTIFIER,Object.assign({},e),t);Reflect.defineMetadata(s.metadata.HANDLER_IDENTIFIER,s.handlers.COMMAND,t)};const Command=e=>commandFactory(e);t.Command=Command},1189:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.CommandError=t.CatchAll=void 0;r(7159);const n=r(7713);const CatchAll=()=>e=>{Reflect.defineMetadata(n.metadata.HANDLER_IDENTIFIER,n.handlers.ERROR,e)};t.CatchAll=CatchAll;t.CommandError=t.CatchAll},9815:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var a=Object.getOwnPropertyDescriptor(t,r);if(!a||("get"in a?!t.__esModule:a.writable||a.configurable)){a={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,a)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var i=this&&this.__importStar||function(){var ownKeys=function(e){ownKeys=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r))t[t.length]=r;return t};return ownKeys(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ownKeys(e),i=0;i<r.length;i++)if(r[i]!=="default")n(t,e,r[i]);a(t,e);return t}}();Object.defineProperty(t,"__esModule",{value:true});t.Handler=void 0;r(7159);const o=r(9249);const s=i(r(8532));const c=r(7713);const Handler=(e={})=>(t,r)=>{if(typeof t==="function"||typeof r!=="string"){throw(0,o.createSystemError)(o.F_SYSTEM.INVALID_PARAM_TYPE,o.errorTypes.DEFINITION,`Handler "${String(r)}" must decorate an instance method.`,{method:String(r)})}if(e.path&&e.alias){throw(0,o.createSystemError)(o.F_SYSTEM.INVALID_PARAM_VALUE,o.errorTypes.DEFINITION,"Handler path does not support alias.",{alias:e.alias,path:e.path})}if(e.flag&&e.path){throw(0,o.createSystemError)(o.F_SYSTEM.INVALID_PARAM_VALUE,o.errorTypes.DEFINITION,"Handler flag and path cannot be used together.",{flag:e.flag,path:e.path})}if(!e.flag&&e.alias){throw(0,o.createSystemError)(o.F_SYSTEM.MISSING_REQUIRED_PARAM,o.errorTypes.DEFINITION,"Handler alias requires a flag.",{key:"flag",alias:e.alias})}if(e.path){s.mustBeArray(e.path,"path");e.path.forEach((e=>s.commandName(e,"path")))}if(Object.prototype.hasOwnProperty.call(e,"flag")){s.optionName(e.flag||"","flag")}s.optionAlias(e.alias,"alias");const n=Reflect.getMetadata(c.metadata.METHOD_HANDLER_IDENTIFIER,t.constructor)||[];Reflect.defineMetadata(c.metadata.METHOD_HANDLER_IDENTIFIER,n.concat([Object.assign({},e,{methodName:r})]),t.constructor)};t.Handler=Handler},3479:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var a=Object.getOwnPropertyDescriptor(t,r);if(!a||("get"in a?!t.__esModule:a.writable||a.configurable)){a={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,a)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var a=this&&this.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))n(t,e,r)};Object.defineProperty(t,"__esModule",{value:true});a(r(1112),t);a(r(5398),t);a(r(1189),t);a(r(9815),t);a(r(9274),t);a(r(7091),t);a(r(6482),t)},9274:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.CommandMajor=void 0;r(7159);const n=r(7713);const CommandMajor=()=>e=>{Reflect.defineMetadata(n.metadata.HANDLER_IDENTIFIER,n.handlers.MAJOR,e)};t.CommandMajor=CommandMajor},7091:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.CommandMissing=void 0;r(7159);const n=r(7713);const CommandMissing=()=>e=>{Reflect.defineMetadata(n.metadata.HANDLER_IDENTIFIER,n.handlers.MISSING,e)};t.CommandMissing=CommandMissing},6482:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var a=Object.getOwnPropertyDescriptor(t,r);if(!a||("get"in a?!t.__esModule:a.writable||a.configurable)){a={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,a)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var i=this&&this.__importStar||function(){var ownKeys=function(e){ownKeys=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r))t[t.length]=r;return t};return ownKeys(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ownKeys(e),i=0;i<r.length;i++)if(r[i]!=="default")n(t,e,r[i]);a(t,e);return t}}();Object.defineProperty(t,"__esModule",{value:true});t.SubOptions=void 0;r(7159);const o=i(r(8532));const s=r(7713);const SubOptions=(e=[])=>t=>{o.mustBeArray(e,"SubOptions Params");const r=e.map((e=>{o.optionName(e.name,"SubOptions name");o.optionAlias(e.alias,"SubOptions alias");return Object.assign({},{type:Boolean},e)}));Reflect.defineMetadata(s.metadata.SUB_OPTION_IDENTIFIER,r,t)};t.SubOptions=SubOptions},6202:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var a=Object.getOwnPropertyDescriptor(t,r);if(!a||("get"in a?!t.__esModule:a.writable||a.configurable)){a={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,a)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var i=this&&this.__importStar||function(){var ownKeys=function(e){ownKeys=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r))t[t.length]=r;return t};return ownKeys(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ownKeys(e),i=0;i<r.length;i++)if(r[i]!=="default")n(t,e,r[i]);a(t,e);return t}}();var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.Container=void 0;const s=o(r(2584));const c=r(6924);const u=i(r(5246));const d=r(7713);const l=r(9249);const f=r(6403);const p=r(5841);const h=r(7481);const y=r(215);class Container{argv;registry;services;datas;constructor(e,t={}){this.argv=t.argv||process.argv.slice(2);this.registry=new h.HandlerRegistry(e);this.services=t.services||[];this.datas=this.registry.datas;new y.RegistrationValidator(this.registry).validate()}async run(){try{await this.dispatch()}catch(e){this.dispatchError(e)}}async dispatch(){const e=this.scope();if(!e)return;if(e.kind===d.handlers.MISSING&&!this.methodHandlers(e.handler).length){this.dispatchLegacyMissing(e.handler);return}const t=this.optionSpec(e.handler);const r=this.parse(t);this.throwUnknownOptions(r,e.kind===d.handlers.COMMAND);const n=this.nativeOption(t,r);const a=this.commandData(e.handler);const i=e.kind===d.handlers.COMMAND?r._.slice(1):r._;const o=this.selectHandler(e.handler,r,i);const s=new c.Factory({nativeOption:n,args:r,command:a,commands:this.registry.commands(),handler:o.data,inputs:o.inputs,path:o.path,services:this.services});const u=s.getServiceParams(e.handler);const l=new e.handler(...u);try{this.injectFields(e.handler,l,r,n);this.validateFieldValues(e.handler,n);new p.ConstraintValidator(this.fieldOptions(e.handler),r,n).validate();const t=s.getMethodServiceParams(l,o.data.methodName);await Promise.resolve(l[o.data.methodName](...t))}catch(t){const r=await this.dispatchLocalCatch(e.handler,l,t,s);if(r)return;throw t}}scope(){const e=this.findCommand();if(e)return{handler:e,kind:d.handlers.COMMAND};if(this.argv[0]&&!this.argv[0].startsWith("-")){const e=this.registry.missing()[0];if(e)return{handler:e,kind:d.handlers.MISSING};return undefined}const t=this.registry.major();if(t)return{handler:t,kind:d.handlers.MAJOR};if(this.argv.some((e=>e.startsWith("-")&&e!=="-"))){throw(0,l.createRuntimePrintError)(l.F_RUNTIME_PRINT.UNKNOWN_OPTION,l.errorTypes.INPUT,`Unknown option${this.argv.length>1?"s":""}: ${this.argv.join(", ")}.`,{options:this.argv})}return undefined}dispatchLegacyMissing(e){const t={_:this.argv};const r=new c.Factory({nativeOption:{},args:t,commands:this.registry.commands(),inputs:this.argv,services:this.services});const n=r.getServiceParams(e);new e(...n)}parse(e){try{return(0,s.default)(e,{argv:this.argv,permissive:true})}catch(e){throw(0,l.createRuntimePrintError)(l.F_RUNTIME_PRINT.PARSE,l.errorTypes.INPUT,e instanceof Error?e.message:String(e),{error:e},e instanceof Error?e:undefined)}}nativeOption(e,t){return Object.keys(e).reduce(((e,r)=>{if(!r.startsWith("--"))return e;return Object.assign({},e,{[u.removeHyphen(r)]:Object.prototype.hasOwnProperty.call(t,r)?t[r]:undefined})}),{})}injectFields(e,t,r,n){this.fieldOptions(e).forEach((e=>{const a=`--${e.name}`;const i=Object.prototype.hasOwnProperty.call(r,a);const o=i?r[a]:t[e.propertyKey];if(e.required&&o===undefined){throw(0,l.createRuntimePrintError)(l.F_RUNTIME_PRINT.VALIDATION,l.errorTypes.INPUT,`Option "--${e.name}" is required.`,{option:e.name})}t[e.propertyKey]=o;n[e.name]=o}))}validateFieldValues(e,t){const r=Reflect.getMetadata(d.metadata.VALUE_VALIDATOR_IDENTIFIER,e)||{};this.fieldOptions(e).forEach((e=>{const n=r[e.propertyKey]||[];n.forEach((r=>{try{const n=r(t[e.name],t);if(n===false||typeof n==="string"){throw(0,l.createRuntimePrintError)(l.F_RUNTIME_PRINT.VALIDATION,l.errorTypes.INPUT,typeof n==="string"?n:`Option "--${e.name}" is invalid.`,{option:e.name,value:t[e.name]})}}catch(r){if((0,l.isFuncError)(r))throw r;throw(0,l.createRuntimePrintError)(l.F_RUNTIME_PRINT.VALIDATION,l.errorTypes.INPUT,r instanceof Error?r.message:String(r),{option:e.name,value:t[e.name]},r instanceof Error?r:undefined)}}))}))}selectHandler(e,t,r){const n=this.methodHandlers(e);const a=this.selectPathHandler(n,r);if(a)return a;const i=n.filter((e=>{if(!e.flag)return false;return Object.prototype.hasOwnProperty.call(t,`--${e.flag}`)}));if(i.length>1){throw(0,l.createRuntimePrintError)(l.F_RUNTIME_PRINT.MULTIPLE_OPTIONS,l.errorTypes.INPUT,`Only one handler flag can be invoked at a time: ${i.map((e=>`--${e.flag}`)).join(", ")}.`,{options:i.map((e=>e.flag))})}const o=i[0]||n.find((e=>!e.flag));if(o){return{data:o,inputs:r,path:[]}}throw(0,l.createSystemError)(l.F_SYSTEM.MISSING_HANDLER,l.errorTypes.REGISTRATION,`Command "${e.name}" does not have a matching @Handler method.`,{handler:e.name})}optionSpec(e){const t=this.fieldOptions(e);const r=this.methodHandlers(e).filter((e=>e.flag)).map((e=>({name:e.flag||"",alias:e.alias,description:e.description,type:Boolean})));const n=[...t,...r,...this.subOptions(e)];return u.optionsToKeyValue(n)}fieldOptions(e){return Reflect.getMetadata(d.metadata.FIELD_OPTION_IDENTIFIER,e)||[]}commandData(e){return Reflect.getMetadata(d.metadata.COMMAND_IDENTIFIER,e)}methodHandlers(e){return Reflect.getMetadata(d.metadata.METHOD_HANDLER_IDENTIFIER,e)||[]}selectPathHandler(e,t){const r=e.filter((e=>e.path&&e.path.length)).filter((e=>e.path.every(((e,r)=>t[r]===e)))).sort(((e,t)=>t.path.length-e.path.length))[0];if(!r)return undefined;return{data:r,inputs:t.slice(r.path.length),path:r.path||[]}}subOptions(e){return Reflect.getMetadata(d.metadata.SUB_OPTION_IDENTIFIER,e)||[]}findCommand(){const e=this.argv[0];if(!e||e.startsWith("-"))return undefined;return this.registry.findCommand(e)}throwUnknownOptions(e,t){const r=e._.filter(((e,r)=>{if(t&&r===0)return false;return e.startsWith("-")&&e!=="-"}));if(!r.length)return;throw(0,l.createRuntimePrintError)(l.F_RUNTIME_PRINT.UNKNOWN_OPTION,l.errorTypes.INPUT,`Unknown option${r.length>1?"s":""}: ${r.join(", ")}.`,{options:r})}dispatchError(e){const t=(0,l.normalizeRuntimeError)(e);if(t.level===l.errorLevels.SYSTEM){(0,l.handleSystemError)(t)}const r=this.registry.errors();if(!r.length){if(t.level===l.errorLevels.RUNTIME_PRINT){(0,l.handleRuntimePrintError)(t,false);return}throw t}const n=new c.Factory({nativeOption:{},args:{_:[]},commands:this.registry.commands(),services:this.services});const a=new f.FuncException(t);r.forEach((e=>{const t=n.getServiceParams(e,a);new e(...t)}));if(t.level===l.errorLevels.RUNTIME_PRINT){(0,l.handleRuntimePrintError)(t,a.printPrevented)}}async dispatchLocalCatch(e,t,r,n){const a=(0,l.normalizeRuntimeError)(r);if(a.level===l.errorLevels.SYSTEM)return false;const i=Reflect.getMetadata(d.metadata.METHOD_CATCH_IDENTIFIER,e)||[];if(!i.length)return false;await i.reduce((async(e,r)=>{await e;const i=n.getMethodServiceParams(t,r.methodName,new f.FuncException(a));await Promise.resolve(t[r.methodName](...i))}),Promise.resolve());return true}}t.Container=Container},7481:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.HandlerRegistry=void 0;const n=r(7713);class HandlerRegistry{datas={};invalidHandlers=[];constructor(e){e.forEach((e=>{const t=Reflect.getMetadata(n.metadata.HANDLER_IDENTIFIER,e);if(!t){this.invalidHandlers=this.invalidHandlers.concat([e]);return}this.datas[t]=(this.datas[t]||[]).concat([e])}))}commands(){return this.handlers(n.handlers.COMMAND)}errors(){return this.handlers(n.handlers.ERROR)}major(){return this.majors()[0]}majors(){return this.handlers(n.handlers.MAJOR)}missing(){return this.handlers(n.handlers.MISSING)}findCommand(e){if(!e||e.startsWith("-"))return undefined;return this.commands().find((t=>{const r=Reflect.getMetadata(n.metadata.COMMAND_IDENTIFIER,t);if(!r)return false;return r.name===e||r.alias===e}))}handlers(e){return this.datas[e]||[]}}t.HandlerRegistry=HandlerRegistry},215:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.RegistrationValidator=void 0;const n=r(9249);const a=r(7713);class RegistrationValidator{registry;constructor(e){this.registry=e}validate(){this.validateKnownHandlers();this.validateDuplicateTokens(this.registry.commands(),a.metadata.COMMAND_IDENTIFIER,(e=>[{token:e.name,type:n.errorTokenTypes.COMMAND_NAME},{token:e.alias,type:n.errorTokenTypes.COMMAND_ALIAS}]),n.errorScopes.COMMAND);this.validateMajorCount();this.validateMissingCount();this.registry.commands().concat(this.registry.majors()).concat(this.registry.missing().filter((e=>this.methodHandlers(e).length))).forEach((e=>this.validateCommandShape(e)))}validateKnownHandlers(){if(!this.registry.invalidHandlers.length)return;const e=this.registry.invalidHandlers.map((e=>e.name||"<anonymous>"));throw(0,n.createSystemError)(n.F_SYSTEM.UNKNOWN_HANDLER,n.errorTypes.REGISTRATION,`All handlers passed to Container must use a func decorator: ${e.join(", ")}.`,{handlers:e})}validateMajorCount(){const e=this.registry.majors();if(e.length<=1)return;throw(0,n.createSystemError)(n.F_SYSTEM.DUPLICATE_HANDLER,n.errorTypes.REGISTRATION,`Only one major command can be registered: ${e.map((e=>e.name)).join(", ")}.`,{scope:n.errorScopes.COMMAND,handlers:e.map((e=>e.name))})}validateMissingCount(){const e=this.registry.missing();if(e.length<=1)return;throw(0,n.createSystemError)(n.F_SYSTEM.DUPLICATE_HANDLER,n.errorTypes.REGISTRATION,`Only one missing command can be registered: ${e.map((e=>e.name)).join(", ")}.`,{scope:n.errorScopes.COMMAND,handlers:e.map((e=>e.name))})}validateDuplicateTokens(e,t,r,a){const i={};e.forEach((e=>{const o=Reflect.getMetadata(t,e);r(o).forEach((t=>{if(!t.token)return;if(i[t.token]){throw(0,n.createSystemError)(n.F_SYSTEM.DUPLICATE_HANDLER,n.errorTypes.REGISTRATION,`Duplicate ${a} token "${t.token}" found in "${i[t.token]}" and "${e.name}".`,{scope:a,token:t.token,type:t.type,handlers:[i[t.token],e.name]})}i[t.token]=e.name}))}))}validateCommandShape(e){const t=Reflect.getMetadata(a.metadata.FIELD_OPTION_IDENTIFIER,e)||[];const r=Reflect.getMetadata(a.metadata.SUB_OPTION_IDENTIFIER,e)||[];const i=Reflect.getMetadata(a.metadata.METHOD_HANDLER_IDENTIFIER,e)||[];if(!i.length){throw(0,n.createSystemError)(n.F_SYSTEM.MISSING_HANDLER,n.errorTypes.REGISTRATION,`Command "${e.name}" must define at least one @Handler method.`,{handler:e.name})}let o="";const s={};const registerToken=(t,r,a)=>{if(!t)return;if(s[t]){throw(0,n.createSystemError)(n.F_SYSTEM.DUPLICATE_HANDLER,n.errorTypes.REGISTRATION,`Duplicate option token "${t}" found in "${e.name}".`,{handler:e.name,owner:r,scope:n.errorScopes.COMMAND,token:t,type:a})}s[t]=r};t.forEach((t=>{this.validateOptionType(t,e.name);registerToken(`--${t.name}`,t.propertyKey,n.errorTokenTypes.OPTION_NAME);registerToken(t.alias?`-${t.alias}`:undefined,t.propertyKey,n.errorTokenTypes.OPTION_ALIAS)}));r.forEach((t=>{this.validateOptionType(t,e.name);registerToken(`--${t.name}`,`SubOptions.${t.name}`,n.errorTokenTypes.OPTION_NAME);registerToken(t.alias?`-${t.alias}`:undefined,`SubOptions.${t.name}`,n.errorTokenTypes.OPTION_ALIAS)}));i.forEach((t=>{if(t.flag&&t.path){throw(0,n.createSystemError)(n.F_SYSTEM.INVALID_PARAM_VALUE,n.errorTypes.REGISTRATION,`Handler "${t.methodName}" in "${e.name}" cannot define both flag and path.`,{handler:e.name,method:t.methodName})}if(!t.flag){if(t.path&&t.path.length){registerToken(t.path.join(" "),t.methodName,n.errorTokenTypes.COMMAND_NAME);return}if(o){throw(0,n.createSystemError)(n.F_SYSTEM.DUPLICATE_HANDLER,n.errorTypes.REGISTRATION,`Command "${e.name}" must define only one default @Handler method.`,{handler:e.name,methods:[o,t.methodName]})}o=t.methodName;return}registerToken(`--${t.flag}`,t.methodName,n.errorTokenTypes.OPTION_NAME);registerToken(t.alias?`-${t.alias}`:undefined,t.methodName,n.errorTokenTypes.OPTION_ALIAS)}))}validateOptionType(e,t){if(e.type!==Array)return;throw(0,n.createSystemError)(n.F_SYSTEM.UNSUPPORTED_ARRAY_TYPE,n.errorTypes.REGISTRATION,`Option "${e.name}" in "${t}" uses Array. Please use [String] instead.`,{option:e.name,handler:t})}methodHandlers(e){return Reflect.getMetadata(a.metadata.METHOD_HANDLER_IDENTIFIER,e)||[]}}t.RegistrationValidator=RegistrationValidator},6403:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.CommandRegistry=t.FuncException=void 0;class FuncException{_error;defaultPrintPrevented=false;constructor(e){this._error=e}get code(){return this._error.code}get details(){return this._error.details}get error(){return this._error}get level(){return this._error.level}get message(){return this._error.message}get printPrevented(){return this.defaultPrintPrevented}get type(){return this._error.type}preventDefaultPrint(){this.defaultPrintPrevented=true}}t.FuncException=FuncException;class CommandRegistry{_commands;constructor(e=[]){this._commands=e}get commands(){return this._commands}}t.CommandRegistry=CommandRegistry},9249:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.handleEffect=t.handleRuntimePrintError=t.handleSystemError=t.normalizeRuntimeError=t.createRuntimePrintError=t.createRuntimeError=t.createSystemError=t.isFuncError=t.FuncError=t.errorTokenTypes=t.errorScopes=t.errorTypes=t.errorLevels=t.F_EFFECT=t.F_RUNTIME_PRINT=t.F_RUNTIME=t.F_SYSTEM=void 0;t.F_SYSTEM={DUPLICATE_HANDLER:"F_SYSTEM_DUPLICATE_HANDLER",INVALID_PARAM_TYPE:"F_SYSTEM_INVALID_PARAM_TYPE",INVALID_PARAM_VALUE:"F_SYSTEM_INVALID_PARAM_VALUE",MISSING_PROVIDER:"F_SYSTEM_MISSING_PROVIDER",MISSING_HANDLER:"F_SYSTEM_MISSING_HANDLER",MISSING_PARAM_TYPES:"F_SYSTEM_MISSING_PARAM_TYPES",MISSING_REQUIRED_PARAM:"F_SYSTEM_MISSING_REQUIRED_PARAM",UNKNOWN_HANDLER:"F_SYSTEM_UNKNOWN_HANDLER",UNSUPPORTED_ARRAY_TYPE:"F_SYSTEM_UNSUPPORTED_ARRAY_TYPE"};t.F_RUNTIME={HANDLER_ERROR:"F_RUNTIME_HANDLER_ERROR"};t.F_RUNTIME_PRINT={MULTIPLE_OPTIONS:"F_RUNTIME_PRINT_MULTIPLE_OPTIONS",PARSE:"F_RUNTIME_PRINT_PARSE",UNKNOWN_OPTION:"F_RUNTIME_PRINT_UNKNOWN_OPTION",VALIDATION:"F_RUNTIME_PRINT_VALIDATION"};t.F_EFFECT={DEPRECATED_API:"F_EFFECT_DEPRECATED_API"};var r;(function(e){e["EFFECT"]="effect";e["RUNTIME"]="runtime";e["RUNTIME_PRINT"]="runtime-print";e["SYSTEM"]="system"})(r||(t.errorLevels=r={}));var n;(function(e){e["DEFINITION"]="definition";e["DEPRECATION"]="deprecation";e["HANDLER"]="handler";e["INJECTION"]="injection";e["INPUT"]="input";e["REGISTRATION"]="registration"})(n||(t.errorTypes=n={}));var a;(function(e){e["COMMAND"]="command"})(a||(t.errorScopes=a={}));var i;(function(e){e["COMMAND_ALIAS"]="command alias";e["COMMAND_NAME"]="command name";e["OPTION_ALIAS"]="option alias";e["OPTION_NAME"]="option name"})(i||(t.errorTokenTypes=i={}));class FuncError extends Error{cause;code;details;level;type;constructor(e){super(e.message);this.name="FuncError";this.code=e.code;this.details=e.details||{};this.level=e.level;this.type=e.type;this.cause=e.cause}}t.FuncError=FuncError;const isFuncError=e=>e instanceof FuncError;t.isFuncError=isFuncError;const createSystemError=(e,t,n,a={},i)=>new FuncError({code:e,details:a,level:r.SYSTEM,message:n,type:t,cause:i});t.createSystemError=createSystemError;const createRuntimeError=(e,t,n,a={},i)=>new FuncError({code:e,details:a,level:r.RUNTIME,message:n,type:t,cause:i});t.createRuntimeError=createRuntimeError;const createRuntimePrintError=(e,t,n,a={},i)=>new FuncError({code:e,details:a,level:r.RUNTIME_PRINT,message:n,type:t,cause:i});t.createRuntimePrintError=createRuntimePrintError;const normalizeRuntimeError=e=>{if((0,t.isFuncError)(e))return e;const r=e instanceof Error?e:new Error(String(e));return(0,t.createRuntimeError)(t.F_RUNTIME.HANDLER_ERROR,n.HANDLER,r.message,{error:r},r)};t.normalizeRuntimeError=normalizeRuntimeError;const handleSystemError=e=>{throw e};t.handleSystemError=handleSystemError;const handleRuntimePrintError=(e,t)=>{if(t)return;console.error(e.message)};t.handleRuntimePrintError=handleRuntimePrintError;const handleEffect=(e,t,n,a={})=>{const i=new FuncError({code:e,details:a,level:r.EFFECT,message:n,type:t});console.warn(i.message);return i};t.handleEffect=handleEffect},4784:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var a=Object.getOwnPropertyDescriptor(t,r);if(!a||("get"in a?!t.__esModule:a.writable||a.configurable)){a={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,a)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var a=this&&this.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))n(t,e,r)};Object.defineProperty(t,"__esModule",{value:true});t.Container=t.run=t.createApp=t.Service=t.FuncModule=t.ValueValidate=t.Value=t.Required=t.Flag=t.Exclusive=t.Enum=t.DependsOn=t.ArrayValue=t.Regs=t.Exception=t.Args=t.SubOptions=t.Handler=t.CommandMissing=t.CommandMajor=t.CommandError=t.Command=t.CatchAll=t.Catch=void 0;r(7159);var i=r(3479);Object.defineProperty(t,"Catch",{enumerable:true,get:function(){return i.Catch}});Object.defineProperty(t,"CatchAll",{enumerable:true,get:function(){return i.CatchAll}});Object.defineProperty(t,"Command",{enumerable:true,get:function(){return i.Command}});Object.defineProperty(t,"CommandError",{enumerable:true,get:function(){return i.CommandError}});Object.defineProperty(t,"CommandMajor",{enumerable:true,get:function(){return i.CommandMajor}});Object.defineProperty(t,"CommandMissing",{enumerable:true,get:function(){return i.CommandMissing}});Object.defineProperty(t,"Handler",{enumerable:true,get:function(){return i.Handler}});Object.defineProperty(t,"SubOptions",{enumerable:true,get:function(){return i.SubOptions}});var o=r(9861);Object.defineProperty(t,"Args",{enumerable:true,get:function(){return o.Args}});Object.defineProperty(t,"Exception",{enumerable:true,get:function(){return o.Exception}});Object.defineProperty(t,"Regs",{enumerable:true,get:function(){return o.Regs}});var s=r(6141);Object.defineProperty(t,"ArrayValue",{enumerable:true,get:function(){return s.ArrayValue}});Object.defineProperty(t,"DependsOn",{enumerable:true,get:function(){return s.DependsOn}});Object.defineProperty(t,"Enum",{enumerable:true,get:function(){return s.Enum}});Object.defineProperty(t,"Exclusive",{enumerable:true,get:function(){return s.Exclusive}});Object.defineProperty(t,"Flag",{enumerable:true,get:function(){return s.Flag}});Object.defineProperty(t,"Required",{enumerable:true,get:function(){return s.Required}});Object.defineProperty(t,"Value",{enumerable:true,get:function(){return s.Value}});Object.defineProperty(t,"ValueValidate",{enumerable:true,get:function(){return s.ValueValidate}});var c=r(4797);Object.defineProperty(t,"FuncModule",{enumerable:true,get:function(){return c.FuncModule}});Object.defineProperty(t,"Service",{enumerable:true,get:function(){return c.Service}});Object.defineProperty(t,"createApp",{enumerable:true,get:function(){return c.createApp}});Object.defineProperty(t,"run",{enumerable:true,get:function(){return c.run}});var u=r(6202);Object.defineProperty(t,"Container",{enumerable:true,get:function(){return u.Container}});a(r(9249),t);a(r(6403),t)},9861:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.Regs=t.Exception=t.Args=t.injectTokens=void 0;r(7159);const n=r(7713);var a;(function(e){e["ARGS"]="args";e["EXCEPTION"]="exception";e["REGS"]="regs"})(a||(t.injectTokens=a={}));const injectToken=e=>(t,r,a)=>{const i=r?t:t;const o=r?Reflect.getMetadata(n.metadata.PARAM_INJECT_TOKEN_IDENTIFIER,i,r)||{}:Reflect.getMetadata(n.metadata.PARAM_INJECT_TOKEN_IDENTIFIER,i)||{};if(r){Reflect.defineMetadata(n.metadata.PARAM_INJECT_TOKEN_IDENTIFIER,Object.assign({},o,{[a]:e}),i,r);return}Reflect.defineMetadata(n.metadata.PARAM_INJECT_TOKEN_IDENTIFIER,Object.assign({},o,{[a]:e}),i)};const Args=()=>injectToken(a.ARGS);t.Args=Args;const Exception=()=>injectToken(a.EXCEPTION);t.Exception=Exception;const Regs=()=>injectToken(a.REGS);t.Regs=Regs},5841:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.ConstraintValidator=void 0;const n=r(9249);class ConstraintValidator{fieldOptions;args;option;constructor(e,t,r){this.fieldOptions=e;this.args=t;this.option=r}validate(){this.fieldOptions.forEach((e=>{this.validateEnum(e);this.validateDependsOn(e);this.validateExclusive(e)}))}explicitNames(){return new Set(this.fieldOptions.filter((e=>Object.prototype.hasOwnProperty.call(this.args,`--${e.name}`))).map((e=>e.name)))}validateDependsOn(e){if(!e.dependsOn||!e.dependsOn.length)return;const t=this.explicitNames();if(!t.has(e.name))return;const r=e.dependsOn.filter((e=>!t.has(e)));if(!r.length)return;throw(0,n.createRuntimePrintError)(n.F_RUNTIME_PRINT.VALIDATION,n.errorTypes.INPUT,`Option "--${e.name}" depends on: ${r.map((e=>`--${e}`)).join(", ")}.`,{option:e.name,dependsOn:e.dependsOn,missing:r})}validateEnum(e){if(!e.enum||!e.enum.length)return;const t=this.option[e.name];if(t===undefined)return;const r=Array.isArray(t)?t:[t];const a=r.filter((t=>!e.enum.includes(t)));if(!a.length)return;throw(0,n.createRuntimePrintError)(n.F_RUNTIME_PRINT.VALIDATION,n.errorTypes.INPUT,`Option "--${e.name}" must be one of: ${e.enum.join(", ")}.`,{option:e.name,enum:e.enum,invalid:a})}validateExclusive(e){if(!e.exclusive||!e.exclusive.length)return;const t=this.explicitNames();if(!t.has(e.name))return;const r=e.exclusive.filter((e=>t.has(e)));if(!r.length)return;throw(0,n.createRuntimePrintError)(n.F_RUNTIME_PRINT.VALIDATION,n.errorTypes.INPUT,`Option "--${e.name}" cannot be used with: ${r.map((e=>`--${e}`)).join(", ")}.`,{option:e.name,exclusive:e.exclusive,conflicts:r})}}t.ConstraintValidator=ConstraintValidator},6270:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var a=Object.getOwnPropertyDescriptor(t,r);if(!a||("get"in a?!t.__esModule:a.writable||a.configurable)){a={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,a)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var i=this&&this.__importStar||function(){var ownKeys=function(e){ownKeys=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r))t[t.length]=r;return t};return ownKeys(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ownKeys(e),i=0;i<r.length;i++)if(r[i]!=="default")n(t,e,r[i]);a(t,e);return t}}();Object.defineProperty(t,"__esModule",{value:true});t.ArrayValue=t.Value=t.Flag=void 0;r(7159);const o=r(9249);const s=i(r(8532));const c=r(7713);const fieldOptionFactory=(e,t={})=>(r,n)=>{if(typeof r==="function"||typeof n!=="string"){throwInvalidFieldTarget(n)}const a=n;const i=Object.prototype.hasOwnProperty.call(t,"name")?t.name||"":a;s.optionName(i,"name");s.optionAlias(t.alias,"alias");const o=resolveType(e,t,r,a);const u=Reflect.getMetadata(c.metadata.REQUIRED_FIELD_IDENTIFIER,r.constructor)||[];const d=Reflect.getMetadata(c.metadata.FIELD_CONSTRAINT_IDENTIFIER,r.constructor)||{};const l=Object.assign({},{kind:e,name:i,propertyKey:a,required:u.includes(a),type:o},t,d[a]||{});const f=Reflect.getMetadata(c.metadata.FIELD_OPTION_IDENTIFIER,r.constructor)||[];Reflect.defineMetadata(c.metadata.FIELD_OPTION_IDENTIFIER,f.concat([l]),r.constructor)};const resolveType=(e,t,r,n)=>{if(e==="flag")return Boolean;if(e==="array")return[String];const a=t.type;if(a)return a;const i=Reflect.getMetadata(c.metadata.DESIGN_TYPE,r,n);if(i===String||i===Number||i===Boolean)return i;throw(0,o.createSystemError)(o.F_SYSTEM.INVALID_PARAM_TYPE,o.errorTypes.DEFINITION,`Cannot infer value type for "${n}". Please pass type explicitly.`,{property:n,reason:"cannot-infer-value-type"})};const throwInvalidFieldTarget=e=>{throw(0,o.createSystemError)(o.F_SYSTEM.INVALID_PARAM_TYPE,o.errorTypes.DEFINITION,`Field option "${String(e)}" must decorate an instance property.`,{property:String(e)})};const Flag=(e={})=>fieldOptionFactory("flag",e);t.Flag=Flag;const Value=(e={})=>fieldOptionFactory("value",e);t.Value=Value;const ArrayValue=(e={})=>fieldOptionFactory("array",e);t.ArrayValue=ArrayValue},9081:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var a=Object.getOwnPropertyDescriptor(t,r);if(!a||("get"in a?!t.__esModule:a.writable||a.configurable)){a={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,a)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var i=this&&this.__importStar||function(){var ownKeys=function(e){ownKeys=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r))t[t.length]=r;return t};return ownKeys(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ownKeys(e),i=0;i<r.length;i++)if(r[i]!=="default")n(t,e,r[i]);a(t,e);return t}}();Object.defineProperty(t,"__esModule",{value:true});t.ValueValidate=t.Exclusive=t.DependsOn=t.Enum=t.Required=void 0;r(7159);const o=r(9249);const s=r(7713);const c=i(r(8532));const throwInvalidFieldTarget=e=>{throw(0,o.createSystemError)(o.F_SYSTEM.INVALID_PARAM_TYPE,o.errorTypes.DEFINITION,`Field validator "${String(e)}" must decorate an instance property.`,{property:String(e)})};const Required=()=>(e,t)=>{if(typeof e==="function"||typeof t!=="string"){throwInvalidFieldTarget(t)}const r=t;const n=Reflect.getMetadata(s.metadata.REQUIRED_FIELD_IDENTIFIER,e.constructor)||[];Reflect.defineMetadata(s.metadata.REQUIRED_FIELD_IDENTIFIER,n.includes(r)?n:n.concat([r]),e.constructor);const a=Reflect.getMetadata(s.metadata.FIELD_OPTION_IDENTIFIER,e.constructor)||[];Reflect.defineMetadata(s.metadata.FIELD_OPTION_IDENTIFIER,a.map((e=>{if(e.propertyKey!==r)return e;return Object.assign({},e,{required:true})})),e.constructor)};t.Required=Required;const Enum=e=>(t,r)=>{c.mustBeArray(e,"enum");defineFieldConstraint(t,r,{enum:e})};t.Enum=Enum;const DependsOn=e=>(t,r)=>{c.mustBeArray(e,"dependsOn");e.forEach((e=>c.optionName(e,"dependsOn")));defineFieldConstraint(t,r,{dependsOn:e})};t.DependsOn=DependsOn;const Exclusive=e=>(t,r)=>{c.mustBeArray(e,"exclusive");e.forEach((e=>c.optionName(e,"exclusive")));defineFieldConstraint(t,r,{exclusive:e})};t.Exclusive=Exclusive;const ValueValidate=e=>(t,r)=>{if(typeof t==="function"||typeof r!=="string"){throwInvalidFieldTarget(r)}const n=r;const a=Reflect.getMetadata(s.metadata.VALUE_VALIDATOR_IDENTIFIER,t.constructor)||{};Reflect.defineMetadata(s.metadata.VALUE_VALIDATOR_IDENTIFIER,Object.assign({},a,{[n]:(a[n]||[]).concat([e])}),t.constructor)};t.ValueValidate=ValueValidate;const defineFieldConstraint=(e,t,r)=>{if(typeof e==="function"||typeof t!=="string"){throwInvalidFieldTarget(t)}const n=t;const a=Reflect.getMetadata(s.metadata.FIELD_CONSTRAINT_IDENTIFIER,e.constructor)||{};const i=Object.assign({},a[n]||{},r);Reflect.defineMetadata(s.metadata.FIELD_CONSTRAINT_IDENTIFIER,Object.assign({},a,{[n]:i}),e.constructor);const o=Reflect.getMetadata(s.metadata.FIELD_OPTION_IDENTIFIER,e.constructor)||[];Reflect.defineMetadata(s.metadata.FIELD_OPTION_IDENTIFIER,o.map((e=>{if(e.propertyKey!==n)return e;return Object.assign({},e,i)})),e.constructor)}},6141:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var a=Object.getOwnPropertyDescriptor(t,r);if(!a||("get"in a?!t.__esModule:a.writable||a.configurable)){a={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,a)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var a=this&&this.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))n(t,e,r)};Object.defineProperty(t,"__esModule",{value:true});a(r(6270),t);a(r(9081),t)},6924:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var a=Object.getOwnPropertyDescriptor(t,r);if(!a||("get"in a?!t.__esModule:a.writable||a.configurable)){a={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,a)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var i=this&&this.__importStar||function(){var ownKeys=function(e){ownKeys=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r))t[t.length]=r;return t};return ownKeys(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ownKeys(e),i=0;i<r.length;i++)if(r[i]!=="default")n(t,e,r[i]);a(t,e);return t}}();Object.defineProperty(t,"__esModule",{value:true});t.Factory=void 0;const o=i(r(5246));const s=r(7713);const c=r(277);const u=r(9861);const d=r(6403);class Factory{params;injector;constructor(e){this.params=e;this.injector=new c.ServiceInjector(e.services)}getServiceParams(e,t){return this.resolveServiceParams(e,undefined,t,[])}getMethodServiceParams(e,t,r){const n=Object.getPrototypeOf(e);return this.resolveServiceParams(n,t,r,[])}resolveServiceParams(e,t,r,n=[]){const a=this.injectedTokens(e,t);const i=this.paramTypes(e,t);const o=this.params.args;const s=this.params.nativeOption;const c=this.params.inputs||o._;const u=Math.max(i.length,0,...Object.keys(a).map((e=>Number(e)+1)));return Array.from({length:u}).map(((e,t)=>{const u=a[t];if(u)return this.resolveInjectedToken(u,c,s,o,r);return this.resolveService(i[t],r,n)}))}injectedTokens(e,t){if(t){return Reflect.getMetadata(s.metadata.PARAM_INJECT_TOKEN_IDENTIFIER,e,t)||{}}return Reflect.getMetadata(s.metadata.PARAM_INJECT_TOKEN_IDENTIFIER,e)||{}}paramTypes(e,t){if(t){return Reflect.getMetadata(s.metadata.DESIGN_PARAM_TYPES,e,t)||[]}return Reflect.getMetadata(s.metadata.DESIGN_PARAM_TYPES,e)||[]}resolveService(e,t,r=[]){return this.injector.resolve(e,((e,r)=>this.resolveServiceParams(e,undefined,t,r)),r)}resolveInjectedToken(e,t,r,n,a){if(e===u.injectTokens.ARGS){return{command:this.params.command,handler:this.params.handler,inputs:t,native:n,option:r,path:this.params.path||[]}}if(e===u.injectTokens.EXCEPTION){if(a instanceof d.FuncException)return a;return new d.FuncException(a)}if(e===u.injectTokens.REGS){const e=o.commandsToDatas(this.params.commands);return new d.CommandRegistry(e)}return undefined}}t.Factory=Factory},5246:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.removeHyphen=t.optionsToKeyValue=t.commandsToDatas=void 0;const n=r(7713);const commandsToDatas=(e=[])=>e.map((e=>Object.assign({},Reflect.getMetadata(n.metadata.COMMAND_IDENTIFIER,e),{fieldOptions:(Reflect.getMetadata(n.metadata.FIELD_OPTION_IDENTIFIER,e)||[]).map((e=>Object.assign({},e))),handlers:(Reflect.getMetadata(n.metadata.METHOD_HANDLER_IDENTIFIER,e)||[]).map((e=>Object.assign({},e))),subOptions:(Reflect.getMetadata(n.metadata.SUB_OPTION_IDENTIFIER,e)||[]).map((e=>Object.assign({},e)))})));t.commandsToDatas=commandsToDatas;const optionsToKeyValue=(e=[])=>{if(!e||!e.length)return{};return e.reduce(((e,t)=>{const r=`--${t.name}`;const n=t.alias?{[`-${t.alias}`]:r}:{};return Object.assign({},e,{[r]:t.type},n)}),{})};t.optionsToKeyValue=optionsToKeyValue;const removeHyphen=e=>e.replace(/^[-]+/,"");t.removeHyphen=removeHyphen},7713:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.handlers=t.metadata=void 0;var r;(function(e){e["DESIGN_PARAM_TYPES"]="design:paramtypes";e["DESIGN_TYPE"]="design:type";e["HOST_PARAM_TYPES"]="host:paramtypes";e["COMMAND_IDENTIFIER"]="command_ident";e["FIELD_OPTION_IDENTIFIER"]="field_option_ident";e["FIELD_CONSTRAINT_IDENTIFIER"]="field_constraint_ident";e["METHOD_CATCH_IDENTIFIER"]="method_catch_ident";e["METHOD_HANDLER_IDENTIFIER"]="method_handler_ident";e["REQUIRED_FIELD_IDENTIFIER"]="required_field_ident";e["SUB_OPTION_IDENTIFIER"]="sub_o_ident";e["VALUE_VALIDATOR_IDENTIFIER"]="value_validator_ident";e["FUNC_MODULE_IDENTIFIER"]="func_module_ident";e["PARAM_INJECT_TOKEN_IDENTIFIER"]="param_inject_token_ident";e["SERVICE_IDENTIFIER"]="service_ident";e["HANDLER_IDENTIFIER"]="handler_ident";e["INJECT_TOKEN_IDENTIFIER"]="inject_t_ident";e["INJECT_INDEX_IDENTIFIER"]="inject_i_ident"})(r||(t.metadata=r={}));var n;(function(e){e["COMMAND"]="command";e["MISSING"]="missing";e["MAJOR"]="major";e["ERROR"]="error"})(n||(t.handlers=n={}))},8532:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.mustBeArray=t.optionAlias=t.optionName=t.commandAlias=t.commandName=t.requireKey=void 0;const n=r(9249);const requireKey=(e,t)=>{if(!e){throw(0,n.createSystemError)(n.F_SYSTEM.MISSING_REQUIRED_PARAM,n.errorTypes.DEFINITION,`Param \`${t}\` is required.`,{key:t})}};t.requireKey=requireKey;const commandName=(e,r)=>{(0,t.requireKey)(e,r);token(e,r)};t.commandName=commandName;const commandAlias=(e,t)=>{if(!e)return;token(e,t)};t.commandAlias=commandAlias;const optionName=(e,r)=>{(0,t.requireKey)(e,r);token(e,r)};t.optionName=optionName;const optionAlias=(e,t)=>{if(!e)return;token(e,t);if(e.length===1)return;throw(0,n.createSystemError)(n.F_SYSTEM.INVALID_PARAM_VALUE,n.errorTypes.DEFINITION,`Param \`${t}\` must be a single character.`,{key:t,value:e})};t.optionAlias=optionAlias;const mustBeArray=(e,t)=>{if(!Array.isArray(e)){throw(0,n.createSystemError)(n.F_SYSTEM.INVALID_PARAM_TYPE,n.errorTypes.DEFINITION,`Param \`${t}\` must be \`Array\`.`,{key:t,expected:"Array"})}};t.mustBeArray=mustBeArray;const token=(e,t)=>{if(e.trim()===e&&!e.startsWith("-")&&!/\s/.test(e))return;throw(0,n.createSystemError)(n.F_SYSTEM.INVALID_PARAM_VALUE,n.errorTypes.DEFINITION,`Param \`${t}\` cannot be empty, start with "-", or contain whitespace.`,{key:t,value:e})}},5516:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var a=arguments.length,i=a<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,r):n,o;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")i=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)if(o=e[s])i=(a<3?o(i):a>3?o(t,r,i):o(t,r))||i;return a>3&&i&&Object.defineProperty(t,r,i),i};Object.defineProperty(t,"__esModule",{value:true});t.AppModule=void 0;const a=r(4784);const i=r(2426);const o=r(7296);let s=class AppModule{};t.AppModule=s;t.AppModule=s=n([(0,a.FuncModule)({commands:i.commands,services:o.services})],s)},1632:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var a=arguments.length,i=a<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,r):n,o;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")i=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)if(o=e[s])i=(a<3?o(i):a>3?o(t,r,i):o(t,r))||i;return a>3&&i&&Object.defineProperty(t,r,i),i};var a=this&&this.__metadata||function(e,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(e,t)};var i=this&&this.__param||function(e,t){return function(r,n){t(r,n,e)}};Object.defineProperty(t,"__esModule",{value:true});t.ErrorHandler=void 0;const o=r(4784);let s=class ErrorHandler{constructor(e){if(e.level!=="runtime-print")return;console.error(e.message);e.preventDefaultPrint()}};t.ErrorHandler=s;t.ErrorHandler=s=n([(0,o.CatchAll)(),i(0,(0,o.Exception)()),a("design:paramtypes",[Function])],s)},1675:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var a=arguments.length,i=a<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,r):n,o;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")i=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)if(o=e[s])i=(a<3?o(i):a>3?o(t,r,i):o(t,r))||i;return a>3&&i&&Object.defineProperty(t,r,i),i};var a=this&&this.__metadata||function(e,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(e,t)};var i=this&&this.__param||function(e,t){return function(r,n){t(r,n,e)}};Object.defineProperty(t,"__esModule",{value:true});t.Greet=void 0;const o=r(4784);let s=class Greet{name="friend";upper=false;run(e){this.print(`Hello, ${this.name}!`);if(!e.inputs.length)return;this.print(`Extra input: ${e.inputs.join(" ")}`)}shout(){this.print(`HELLO, ${this.name.toUpperCase()}!`)}print(e){console.log(this.upper?e.toUpperCase():e)}};t.Greet=s;n([(0,o.Value)({name:"name",alias:"n",description:"name to greet",type:String}),a("design:type",Object)],s.prototype,"name",void 0);n([(0,o.Flag)({alias:"u",description:"print with uppercase letters"}),a("design:type",Object)],s.prototype,"upper",void 0);n([(0,o.Handler)(),i(0,(0,o.Args)()),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype",void 0)],s.prototype,"run",null);n([(0,o.Handler)({path:["shout"]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",void 0)],s.prototype,"shout",null);t.Greet=s=n([(0,o.Command)({name:"greet",alias:"g",description:"print a greeting"})],s)},2426:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.commands=void 0;const n=r(1632);const a=r(1675);const i=r(659);const o=r(4582);t.commands=[i.Major,a.Greet,o.Missing,n.ErrorHandler]},659:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var a=arguments.length,i=a<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,r):n,o;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")i=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)if(o=e[s])i=(a<3?o(i):a>3?o(t,r,i):o(t,r))||i;return a>3&&i&&Object.defineProperty(t,r,i),i};var a=this&&this.__metadata||function(e,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(e,t)};var i=this&&this.__param||function(e,t){return function(r,n){t