@adaas/a-utils 0.1.28 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var aConcept=require('@adaas/a-concept');var nt=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var i=(B,t)=>nt(B,"name",{value:t,configurable:true});var a=(B,t,e,r)=>{for(var o=r>1?void 0:r?ut(t,e):t,n=B.length-1,s;n>=0;n--)(s=B[n])&&(o=(r?s(t,e,o):s(o))||o);return r&&o&&nt(t,e,o),o},p=(B,t)=>(e,r)=>t(e,r,B);var we=class we extends aConcept.A_Fragment{constructor(t,e){super({name:t}),this._meta=new aConcept.A_Meta;for(let r in e)this._meta.set(r,e[r]);}[Symbol.iterator](){return this._meta[Symbol.iterator]()}get meta(){return this._meta}get(t){return this._meta.get(t)}set(t,e){this._meta.set(t,e);}has(t){return this._meta.has(t)}drop(t){this._meta.delete(t);}clear(){this._meta.clear();}toRaw(){return this._meta.toJSON()}toJSON(){return {name:this.name,...this.meta.toJSON()}}};i(we,"A_ExecutionContext");var v=we;var Re=class Re extends v{constructor(t,e){super("operation-context"),this.meta.set("name",t),this.meta.set("params",e||{});}get name(){return this._meta.get("name")||this._name}get result(){return this._meta.get("result")}get error(){return this._meta.get("error")}get params(){return this._meta.get("params")||{}}fail(t){this._meta.set("error",t);}succeed(t){this._meta.set("result",t);}toJSON(){return {name:this.name,params:this.params,result:this.result||{},error:this.error?.toJSON()}}};i(Re,"A_OperationContext");var _=Re;var pe=class pe extends aConcept.A_Error{constructor(t,e){aConcept.A_TypeGuards.isString(e)?super(t,e):super(t),e instanceof _&&(this._context=e);}get context(){return this._context}};i(pe,"A_ChannelError"),pe.MethodNotImplemented="A-Channel Method Not Implemented";var Y=pe;var xt=(x=>(x.onTimeout="_A_Channel_onTimeout",x.onRetry="_A_Channel_onRetry",x.onCircuitBreakerOpen="_A_Channel_onCircuitBreakerOpen",x.onCache="_A_Channel_onCache",x.onConnect="_A_Channel_onConnect",x.onDisconnect="_A_Channel_onDisconnect",x.onBeforeRequest="_A_Channel_onBeforeRequest",x.onRequest="_A_Channel_onRequest",x.onAfterRequest="_A_Channel_onAfterRequest",x.onError="_A_Channel_onError",x.onSend="_A_Channel_onSend",x.onConsume="_A_Channel_onConsume",x))(xt||{}),Ct=(r=>(r.PENDING="PENDING",r.SUCCESS="SUCCESS",r.FAILED="FAILED",r))(Ct||{});var Le=class Le extends _{constructor(t){super("request",t);}get status(){return this.result?.status}get data(){return this.result?.data}succeed(t){let e=this.result;super.succeed({...e,data:t,status:"SUCCESS"});}};i(Le,"A_ChannelRequest");var te=Le;var I=class I extends aConcept.A_Component{constructor(){super();this._processing=false;this._cache=new Map;}get processing(){return this._processing}get initialize(){return this._initialized||(this._initialized=this.connect()),this._initialized}async onConnect(...e){}async onDisconnect(...e){}async onBeforeRequest(...e){}async onRequest(...e){}async onAfterRequest(...e){}async onError(...e){}async onSend(...e){}async connect(){await this.call("_A_Channel_onConnect");}async disconnect(){await this.call("_A_Channel_onDisconnect");}async request(e){await this.initialize,this._processing=true;let r=new aConcept.A_Scope({name:`a-channel@scope:request:${aConcept.A_IdentityHelper.generateTimeId()}`}).inherit(aConcept.A_Context.scope(this)),o=new te(e);try{return r.register(o),await this.call("_A_Channel_onBeforeRequest",r),await this.call("_A_Channel_onRequest",r),await this.call("_A_Channel_onAfterRequest",r),this._processing=!1,o}catch(n){this._processing=false;let s=new Y(n);throw o.fail(s),r.register(s),await this.call("_A_Channel_onError",r),r.destroy(),s}}async send(e){await this.initialize,this._processing=true;let r=new aConcept.A_Scope({name:`a-channel@scope:send:${aConcept.A_IdentityHelper.generateTimeId()}`}).inherit(aConcept.A_Context.scope(this)),o=new _("send",e);try{r.inherit(aConcept.A_Context.scope(this)),r.register(o),await this.call("_A_Channel_onSend",r),this._processing=!1;}catch(n){this._processing=false;let s=new Y(n);r.register(s),o.fail(s),await this.call("_A_Channel_onError",r),r.destroy();}}async consume(){await this.initialize,this._processing=true;let e=new aConcept.A_Scope({name:`a-channel@scope:consume:${aConcept.A_IdentityHelper.generateTimeId()}`}).inherit(aConcept.A_Context.scope(this)),r=new _("consume",{});try{return e.inherit(aConcept.A_Context.scope(this)),e.register(r),await this.call("_A_Channel_onConsume",e),this._processing=!1,r}catch(o){this._processing=false;let n=new Y(o);return r.fail(n),await this.call("_A_Channel_onError",e),r}}};i(I,"A_Channel"),a([aConcept.A_Feature.Extend({name:"_A_Channel_onConnect"})],I.prototype,"onConnect",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onDisconnect"})],I.prototype,"onDisconnect",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onBeforeRequest"})],I.prototype,"onBeforeRequest",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onRequest"})],I.prototype,"onRequest",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onAfterRequest"})],I.prototype,"onAfterRequest",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onError"})],I.prototype,"onError",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onSend"})],I.prototype,"onSend",1);var Oe=I;var Rt=(s=>(s.CREATED="CREATED",s.INITIALIZED="INITIALIZED",s.COMPILED="COMPILED",s.EXECUTING="EXECUTING",s.COMPLETED="COMPLETED",s.FAILED="FAILED",s))(Rt||{}),Lt=(o=>(o.CREATED_TO_INITIALIZED="created_initialized",o.INITIALIZED_TO_EXECUTING="initialized_executing",o.EXECUTING_TO_COMPLETED="executing_completed",o.EXECUTING_TO_FAILED="executing_failed",o))(Lt||{}),vt=(c=>(c.onInit="_A_Command_onInit",c.onBeforeExecute="_A_Command_onBeforeExecute",c.onExecute="_A_Command_onExecute",c.onAfterExecute="_A_Command_onAfterExecute",c.onComplete="_A_Command_onComplete",c.onFail="_A_Command_onFail",c.onError="_A_Command_onError",c))(vt||{}),Pt=(c=>(c.onInit="onInit",c.onBeforeExecute="onBeforeExecute",c.onExecute="onExecute",c.onAfterExecute="onAfterExecute",c.onComplete="onComplete",c.onFail="onFail",c.onError="onError",c))(Pt||{});var q=class q extends aConcept.A_Error{};i(q,"A_CommandError"),q.CommandScopeBindingError="A-Command Scope Binding Error",q.ExecutionError="A-Command Execution Error",q.ResultProcessingError="A-Command Result Processing Error",q.CommandInterruptedError="A-Command Interrupted Error";var D=q;var oe=class oe extends aConcept.A_Error{};i(oe,"A_StateMachineError"),oe.InitializationError="A-StateMachine Initialization Error",oe.TransitionError="A-StateMachine Transition Error";var K=oe;var bt=(o=>(o.onError="_A_StateMachine_onError",o.onInitialize="_A_StateMachine_onInitialize",o.onBeforeTransition="_A_StateMachine_onBeforeTransition",o.onAfterTransition="_A_StateMachine_onAfterTransition",o))(bt||{});var Ie=class Ie extends _{constructor(t){super("a-state-machine-transition",t),this._meta.set("from",t.from),this._meta.set("to",t.to);}get from(){return this._meta.get("from")}get to(){return this._meta.get("to")}};i(Ie,"A_StateMachineTransition");var P=Ie;var Dt,Mt,Gt,$t,j=class j extends aConcept.A_Component{get ready(){return this._initialized||(this._initialized=this.call("_A_StateMachine_onInitialize")),this._initialized}async[$t="_A_StateMachine_onInitialize"](...t){}async[Gt="_A_StateMachine_onBeforeTransition"](...t){}async[Mt="_A_StateMachine_onAfterTransition"](...t){}async[Dt="_A_StateMachine_onError"](...t){}async transition(t,e,r){await this.ready;let o=`${aConcept.A_FormatterHelper.toCamelCase(String(t))}_${aConcept.A_FormatterHelper.toCamelCase(String(e))}`,n=new P({from:String(t),to:String(e),props:r}),s=new aConcept.A_Scope({name:`A-StateMachine-Transition-Scope-${o}`,fragments:[n]});try{return await this.call("_A_StateMachine_onBeforeTransition",s),await this.call(o,s),await this.call("_A_StateMachine_onAfterTransition",s),s.destroy(),n.result}catch(c){let f=new K({title:K.TransitionError,description:`An error occurred while transitioning to "${o}"`,originalError:c});throw s.register(f),await this.call("_A_StateMachine_onError",s),s.destroy(),f}}};i(j,"A_StateMachine"),a([aConcept.A_Feature.Extend()],j.prototype,$t,1),a([aConcept.A_Feature.Extend()],j.prototype,Gt,1),a([aConcept.A_Feature.Extend()],j.prototype,Mt,1),a([aConcept.A_Feature.Extend()],j.prototype,Dt,1);var b=j;var Jo={},X=[];var _e=class _e extends aConcept.A_Error{};i(_e,"A_ConfigError"),_e.InitializationError="A-Config Initialization Error";var N=_e;var Ne=class Ne extends v{constructor(e){super("a-config");this.DEFAULT_ALLOWED_TO_READ_PROPERTIES=[...aConcept.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...X];this._strict=e.strict??false,this._configProperties=e.variables??[];for(let r in e.defaults)this.set(aConcept.A_FormatterHelper.toUpperSnakeCase(r),e.defaults[r]);}get strict(){return this._strict}get(e){if(this._configProperties.includes(e)||this.DEFAULT_ALLOWED_TO_READ_PROPERTIES.includes(e)||!this._strict)return super.get(aConcept.A_FormatterHelper.toUpperSnakeCase(e));throw new N("Property not exists or not allowed to read")}set(e,r){let o=Array.isArray(e)?e:typeof e=="string"?[{property:e,value:r}]:Object.keys(e).map(n=>({property:n,value:e[n]}));for(let{property:n,value:s}of o)super.set(aConcept.A_FormatterHelper.toUpperSnakeCase(n),s);}};i(Ne,"A_Config");var g=Ne;var at=20,ci="all",ct={red:"31",yellow:"33",green:"32",blue:"34",cyan:"36",magenta:"35",gray:"90",brightBlue:"94",brightCyan:"96",brightMagenta:"95",darkGray:"30",lightGray:"37",indigo:"38;5;54",violet:"38;5;93",purple:"38;5;129",lavender:"38;5;183",skyBlue:"38;5;117",steelBlue:"38;5;67",slateBlue:"38;5;62",deepBlue:"38;5;18",lightBlue:"38;5;153",periwinkle:"38;5;111",cornflower:"38;5;69",powder:"38;5;152",charcoal:"38;5;236",silver:"38;5;250",smoke:"38;5;244",slate:"38;5;240"},pt=["blue","cyan","magenta","gray","brightBlue","brightCyan","brightMagenta","darkGray","lightGray","indigo","violet","purple","lavender","skyBlue","steelBlue","slateBlue","deepBlue","lightBlue","periwinkle","cornflower","powder","charcoal","silver","smoke","slate"],z={RESET:"\x1B[0m",PREFIX:"\x1B[",SUFFIX:"m"},J={MINUTES_PAD:2,SECONDS_PAD:2,MILLISECONDS_PAD:3,SEPARATOR:":"},C={SCOPE_OPEN:"[",SCOPE_CLOSE:"]",TIME_OPEN:"|",TIME_CLOSE:"|",SEPARATOR:"-------------------------------",INDENT_BASE:3,PIPE:"| "},ie={LOG_LEVEL:"A_LOGGER_LEVEL",DEFAULT_SCOPE_LENGTH:"A_LOGGER_DEFAULT_SCOPE_LENGTH",DEFAULT_SCOPE_COLOR:"A_LOGGER_DEFAULT_SCOPE_COLOR",DEFAULT_LOG_COLOR:"A_LOGGER_DEFAULT_LOG_COLOR"};exports.A_Logger=class T extends aConcept.A_Component{constructor(e,r){super();this.scope=e;this.config=r;this.COLORS=ct,this.STANDARD_SCOPE_LENGTH=r?.get(ie.DEFAULT_SCOPE_LENGTH)||20;let o=r?.get(ie.DEFAULT_SCOPE_COLOR),n=r?.get(ie.DEFAULT_LOG_COLOR);if(o||n)this.DEFAULT_SCOPE_COLOR=o||this.generateColorFromScopeName(this.scope.name),this.DEFAULT_LOG_COLOR=n||this.generateColorFromScopeName(this.scope.name);else {let s=this.generateComplementaryColorsFromScope(this.scope.name);this.DEFAULT_SCOPE_COLOR=s.scopeColor,this.DEFAULT_LOG_COLOR=s.logColor;}}simpleHash(e){let r=0;for(let o=0;o<e.length;o++){let n=e.charCodeAt(o);r=(r<<5)-r+n,r=r&r;}return Math.abs(r)}generateColorFromScopeName(e){let r=pt,n=this.simpleHash(e)%r.length;return r[n]}generateComplementaryColorsFromScope(e){let r=[{scopeColor:"indigo",logColor:"lightBlue"},{scopeColor:"deepBlue",logColor:"cyan"},{scopeColor:"purple",logColor:"lavender"},{scopeColor:"steelBlue",logColor:"skyBlue"},{scopeColor:"slateBlue",logColor:"periwinkle"},{scopeColor:"charcoal",logColor:"silver"},{scopeColor:"violet",logColor:"brightMagenta"},{scopeColor:"darkGray",logColor:"lightGray"},{scopeColor:"cornflower",logColor:"powder"},{scopeColor:"slate",logColor:"smoke"}],n=this.simpleHash(e)%r.length;return r[n]}get scopeLength(){return Math.max(this.scope.name.length,this.STANDARD_SCOPE_LENGTH)}get formattedScope(){let e=this.scope.name,r=this.STANDARD_SCOPE_LENGTH;if(e.length>=r)return e.substring(0,r);let o=r-e.length,n=Math.floor(o/2),s=o-n;return " ".repeat(n)+e+" ".repeat(s)}compile(e,...r){let o=this.getTime(),n=" ".repeat(this.scopeLength+3),s=r.length>1;return [`${z.PREFIX}${this.COLORS[this.DEFAULT_SCOPE_COLOR]}${z.SUFFIX}${C.SCOPE_OPEN}${this.formattedScope}${C.SCOPE_CLOSE}${z.RESET} ${z.PREFIX}${this.COLORS[e]}${z.SUFFIX}${C.TIME_OPEN}${o}${C.TIME_CLOSE}`,s?`
|
|
1
|
+
'use strict';var aConcept=require('@adaas/a-concept');var nt=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var i=(B,t)=>nt(B,"name",{value:t,configurable:true});var a=(B,t,e,r)=>{for(var o=r>1?void 0:r?ut(t,e):t,n=B.length-1,s;n>=0;n--)(s=B[n])&&(o=(r?s(t,e,o):s(o))||o);return r&&o&&nt(t,e,o),o},p=(B,t)=>(e,r)=>t(e,r,B);var we=class we extends aConcept.A_Fragment{constructor(t,e){super({name:t}),this._meta=new aConcept.A_Meta;for(let r in e)this._meta.set(r,e[r]);}[Symbol.iterator](){return this._meta[Symbol.iterator]()}get meta(){return this._meta}get(t){return this._meta.get(t)}set(t,e){this._meta.set(t,e);}has(t){return this._meta.has(t)}drop(t){this._meta.delete(t);}clear(){this._meta.clear();}toRaw(){return this._meta.toJSON()}toJSON(){return {name:this.name,...this.meta.toJSON()}}};i(we,"A_ExecutionContext");var v=we;var Re=class Re extends v{constructor(t,e){super("operation-context"),this.meta.set("name",t),this.meta.set("params",e||{});}get name(){return this._meta.get("name")||this._name}get result(){return this._meta.get("result")}get error(){return this._meta.get("error")}get params(){return this._meta.get("params")||{}}fail(t){this._meta.set("error",t);}succeed(t){this._meta.set("result",t);}toJSON(){return {name:this.name,params:this.params,result:this.result||{},error:this.error?.toJSON()}}};i(Re,"A_OperationContext");var _=Re;var pe=class pe extends aConcept.A_Error{constructor(t,e){aConcept.A_TypeGuards.isString(e)?super(t,e):super(t),e instanceof _&&(this._context=e);}get context(){return this._context}};i(pe,"A_ChannelError"),pe.MethodNotImplemented="A-Channel Method Not Implemented";var Y=pe;var xt=(x=>(x.onTimeout="_A_Channel_onTimeout",x.onRetry="_A_Channel_onRetry",x.onCircuitBreakerOpen="_A_Channel_onCircuitBreakerOpen",x.onCache="_A_Channel_onCache",x.onConnect="_A_Channel_onConnect",x.onDisconnect="_A_Channel_onDisconnect",x.onBeforeRequest="_A_Channel_onBeforeRequest",x.onRequest="_A_Channel_onRequest",x.onAfterRequest="_A_Channel_onAfterRequest",x.onError="_A_Channel_onError",x.onSend="_A_Channel_onSend",x.onConsume="_A_Channel_onConsume",x))(xt||{}),Ct=(r=>(r.PENDING="PENDING",r.SUCCESS="SUCCESS",r.FAILED="FAILED",r))(Ct||{});var Le=class Le extends _{constructor(t){super("request",t);}get status(){return this.result?.status}get data(){return this.result?.data}succeed(t){let e=this.result;super.succeed({...e,data:t,status:"SUCCESS"});}};i(Le,"A_ChannelRequest");var te=Le;var I=class I extends aConcept.A_Component{constructor(){super();this._processing=false;this._cache=new Map;}get processing(){return this._processing}get initialize(){return this._initialized||(this._initialized=this.connect()),this._initialized}async onConnect(...e){}async onDisconnect(...e){}async onBeforeRequest(...e){}async onRequest(...e){}async onAfterRequest(...e){}async onError(...e){}async onSend(...e){}async connect(){await this.call("_A_Channel_onConnect");}async disconnect(){await this.call("_A_Channel_onDisconnect");}async request(e){await this.initialize,this._processing=true;let r=new aConcept.A_Scope({name:`a-channel@scope:request:${aConcept.A_IdentityHelper.generateTimeId()}`}).inherit(aConcept.A_Context.scope(this)),o=new te(e);try{return r.register(o),await this.call("_A_Channel_onBeforeRequest",r),await this.call("_A_Channel_onRequest",r),await this.call("_A_Channel_onAfterRequest",r),this._processing=!1,o}catch(n){this._processing=false;let s=new Y(n);throw o.fail(s),r.register(s),await this.call("_A_Channel_onError",r),r.destroy(),s}}async send(e){await this.initialize,this._processing=true;let r=new aConcept.A_Scope({name:`a-channel@scope:send:${aConcept.A_IdentityHelper.generateTimeId()}`}).inherit(aConcept.A_Context.scope(this)),o=new _("send",e);try{r.inherit(aConcept.A_Context.scope(this)),r.register(o),await this.call("_A_Channel_onSend",r),this._processing=!1;}catch(n){this._processing=false;let s=new Y(n);r.register(s),o.fail(s),await this.call("_A_Channel_onError",r),r.destroy();}}async consume(){await this.initialize,this._processing=true;let e=new aConcept.A_Scope({name:`a-channel@scope:consume:${aConcept.A_IdentityHelper.generateTimeId()}`}).inherit(aConcept.A_Context.scope(this)),r=new _("consume",{});try{return e.inherit(aConcept.A_Context.scope(this)),e.register(r),await this.call("_A_Channel_onConsume",e),this._processing=!1,r}catch(o){this._processing=false;let n=new Y(o);return r.fail(n),await this.call("_A_Channel_onError",e),r}}};i(I,"A_Channel"),a([aConcept.A_Feature.Extend({name:"_A_Channel_onConnect"})],I.prototype,"onConnect",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onDisconnect"})],I.prototype,"onDisconnect",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onBeforeRequest"})],I.prototype,"onBeforeRequest",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onRequest"})],I.prototype,"onRequest",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onAfterRequest"})],I.prototype,"onAfterRequest",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onError"})],I.prototype,"onError",1),a([aConcept.A_Feature.Extend({name:"_A_Channel_onSend"})],I.prototype,"onSend",1);var Oe=I;var Rt=(s=>(s.CREATED="CREATED",s.INITIALIZED="INITIALIZED",s.COMPILED="COMPILED",s.EXECUTING="EXECUTING",s.COMPLETED="COMPLETED",s.FAILED="FAILED",s))(Rt||{}),Lt=(o=>(o.CREATED_TO_INITIALIZED="created_initialized",o.INITIALIZED_TO_EXECUTING="initialized_executing",o.EXECUTING_TO_COMPLETED="executing_completed",o.EXECUTING_TO_FAILED="executing_failed",o))(Lt||{}),vt=(c=>(c.onInit="_A_Command_onInit",c.onBeforeExecute="_A_Command_onBeforeExecute",c.onExecute="_A_Command_onExecute",c.onAfterExecute="_A_Command_onAfterExecute",c.onComplete="_A_Command_onComplete",c.onFail="_A_Command_onFail",c.onError="_A_Command_onError",c))(vt||{}),Pt=(c=>(c.onInit="onInit",c.onBeforeExecute="onBeforeExecute",c.onExecute="onExecute",c.onAfterExecute="onAfterExecute",c.onComplete="onComplete",c.onFail="onFail",c.onError="onError",c))(Pt||{});var q=class q extends aConcept.A_Error{};i(q,"A_CommandError"),q.CommandScopeBindingError="A-Command Scope Binding Error",q.ExecutionError="A-Command Execution Error",q.ResultProcessingError="A-Command Result Processing Error",q.CommandInterruptedError="A-Command Interrupted Error";var D=q;var oe=class oe extends aConcept.A_Error{};i(oe,"A_StateMachineError"),oe.InitializationError="A-StateMachine Initialization Error",oe.TransitionError="A-StateMachine Transition Error";var K=oe;var bt=(o=>(o.onError="_A_StateMachine_onError",o.onInitialize="_A_StateMachine_onInitialize",o.onBeforeTransition="_A_StateMachine_onBeforeTransition",o.onAfterTransition="_A_StateMachine_onAfterTransition",o))(bt||{});var Ie=class Ie extends _{constructor(t){super("a-state-machine-transition",t),this._meta.set("from",t.from),this._meta.set("to",t.to);}get from(){return this._meta.get("from")}get to(){return this._meta.get("to")}};i(Ie,"A_StateMachineTransition");var P=Ie;var Mt,Gt,$t,Ut,j=class j extends aConcept.A_Component{get ready(){return this._initialized||(this._initialized=this.call("_A_StateMachine_onInitialize")),this._initialized}async[Ut="_A_StateMachine_onInitialize"](...t){}async[$t="_A_StateMachine_onBeforeTransition"](...t){}async[Gt="_A_StateMachine_onAfterTransition"](...t){}async[Mt="_A_StateMachine_onError"](...t){}async transition(t,e,r){await this.ready;let o=`${aConcept.A_FormatterHelper.toCamelCase(String(t))}_${aConcept.A_FormatterHelper.toCamelCase(String(e))}`,n=new P({from:String(t),to:String(e),props:r}),s=new aConcept.A_Scope({name:`A-StateMachine-Transition-Scope-${o}`,fragments:[n]}).inherit(aConcept.A_Context.scope(this));try{return await this.call("_A_StateMachine_onBeforeTransition",s),await this.call(o,s),await this.call("_A_StateMachine_onAfterTransition",s),s.destroy(),n.result}catch(c){let f=new K({title:K.TransitionError,description:`An error occurred while transitioning to "${o}"`,originalError:c});throw s.register(f),await this.call("_A_StateMachine_onError",s),s.destroy(),f}}};i(j,"A_StateMachine"),a([aConcept.A_Feature.Extend()],j.prototype,Ut,1),a([aConcept.A_Feature.Extend()],j.prototype,$t,1),a([aConcept.A_Feature.Extend()],j.prototype,Gt,1),a([aConcept.A_Feature.Extend()],j.prototype,Mt,1);var b=j;var Jo={},X=[];var _e=class _e extends aConcept.A_Error{};i(_e,"A_ConfigError"),_e.InitializationError="A-Config Initialization Error";var N=_e;var Ne=class Ne extends v{constructor(e){super("a-config");this.DEFAULT_ALLOWED_TO_READ_PROPERTIES=[...aConcept.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...X];this._strict=e.strict??false,this._configProperties=e.variables??[];for(let r in e.defaults)this.set(aConcept.A_FormatterHelper.toUpperSnakeCase(r),e.defaults[r]);}get strict(){return this._strict}get(e){if(this._configProperties.includes(e)||this.DEFAULT_ALLOWED_TO_READ_PROPERTIES.includes(e)||!this._strict)return super.get(aConcept.A_FormatterHelper.toUpperSnakeCase(e));throw new N("Property not exists or not allowed to read")}set(e,r){let o=Array.isArray(e)?e:typeof e=="string"?[{property:e,value:r}]:Object.keys(e).map(n=>({property:n,value:e[n]}));for(let{property:n,value:s}of o)super.set(aConcept.A_FormatterHelper.toUpperSnakeCase(n),s);}};i(Ne,"A_Config");var g=Ne;var at=20,ci="all",ct={red:"31",yellow:"33",green:"32",blue:"34",cyan:"36",magenta:"35",gray:"90",brightBlue:"94",brightCyan:"96",brightMagenta:"95",darkGray:"30",lightGray:"37",indigo:"38;5;54",violet:"38;5;93",purple:"38;5;129",lavender:"38;5;183",skyBlue:"38;5;117",steelBlue:"38;5;67",slateBlue:"38;5;62",deepBlue:"38;5;18",lightBlue:"38;5;153",periwinkle:"38;5;111",cornflower:"38;5;69",powder:"38;5;152",charcoal:"38;5;236",silver:"38;5;250",smoke:"38;5;244",slate:"38;5;240"},pt=["blue","cyan","magenta","gray","brightBlue","brightCyan","brightMagenta","darkGray","lightGray","indigo","violet","purple","lavender","skyBlue","steelBlue","slateBlue","deepBlue","lightBlue","periwinkle","cornflower","powder","charcoal","silver","smoke","slate"],z={RESET:"\x1B[0m",PREFIX:"\x1B[",SUFFIX:"m"},J={MINUTES_PAD:2,SECONDS_PAD:2,MILLISECONDS_PAD:3,SEPARATOR:":"},C={SCOPE_OPEN:"[",SCOPE_CLOSE:"]",TIME_OPEN:"|",TIME_CLOSE:"|",SEPARATOR:"-------------------------------",INDENT_BASE:3,PIPE:"| "},ie={LOG_LEVEL:"A_LOGGER_LEVEL",DEFAULT_SCOPE_LENGTH:"A_LOGGER_DEFAULT_SCOPE_LENGTH",DEFAULT_SCOPE_COLOR:"A_LOGGER_DEFAULT_SCOPE_COLOR",DEFAULT_LOG_COLOR:"A_LOGGER_DEFAULT_LOG_COLOR"};exports.A_Logger=class T extends aConcept.A_Component{constructor(e,r){super();this.scope=e;this.config=r;this.COLORS=ct,this.STANDARD_SCOPE_LENGTH=r?.get(ie.DEFAULT_SCOPE_LENGTH)||20;let o=r?.get(ie.DEFAULT_SCOPE_COLOR),n=r?.get(ie.DEFAULT_LOG_COLOR);if(o||n)this.DEFAULT_SCOPE_COLOR=o||this.generateColorFromScopeName(this.scope.name),this.DEFAULT_LOG_COLOR=n||this.generateColorFromScopeName(this.scope.name);else {let s=this.generateComplementaryColorsFromScope(this.scope.name);this.DEFAULT_SCOPE_COLOR=s.scopeColor,this.DEFAULT_LOG_COLOR=s.logColor;}}simpleHash(e){let r=0;for(let o=0;o<e.length;o++){let n=e.charCodeAt(o);r=(r<<5)-r+n,r=r&r;}return Math.abs(r)}generateColorFromScopeName(e){let r=pt,n=this.simpleHash(e)%r.length;return r[n]}generateComplementaryColorsFromScope(e){let r=[{scopeColor:"indigo",logColor:"lightBlue"},{scopeColor:"deepBlue",logColor:"cyan"},{scopeColor:"purple",logColor:"lavender"},{scopeColor:"steelBlue",logColor:"skyBlue"},{scopeColor:"slateBlue",logColor:"periwinkle"},{scopeColor:"charcoal",logColor:"silver"},{scopeColor:"violet",logColor:"brightMagenta"},{scopeColor:"darkGray",logColor:"lightGray"},{scopeColor:"cornflower",logColor:"powder"},{scopeColor:"slate",logColor:"smoke"}],n=this.simpleHash(e)%r.length;return r[n]}get scopeLength(){return Math.max(this.scope.name.length,this.STANDARD_SCOPE_LENGTH)}get formattedScope(){let e=this.scope.name,r=this.STANDARD_SCOPE_LENGTH;if(e.length>=r)return e.substring(0,r);let o=r-e.length,n=Math.floor(o/2),s=o-n;return " ".repeat(n)+e+" ".repeat(s)}compile(e,...r){let o=this.getTime(),n=" ".repeat(this.scopeLength+3),s=r.length>1;return [`${z.PREFIX}${this.COLORS[this.DEFAULT_SCOPE_COLOR]}${z.SUFFIX}${C.SCOPE_OPEN}${this.formattedScope}${C.SCOPE_CLOSE}${z.RESET} ${z.PREFIX}${this.COLORS[e]}${z.SUFFIX}${C.TIME_OPEN}${o}${C.TIME_CLOSE}`,s?`
|
|
2
2
|
${n}${C.TIME_OPEN}${C.SEPARATOR}`:"",...r.map((c,f)=>{let U=f>0||s;switch(true){case c instanceof aConcept.A_Error:return this.compile_A_Error(c);case c instanceof Error:return this.compile_Error(c);case(typeof c=="object"&&c!==null):return this.formatObject(c,U,n);default:return this.formatString(String(c),U,n)}}),s?`
|
|
3
3
|
${n}${C.TIME_OPEN}${C.SEPARATOR}${z.RESET}`:z.RESET]}formatObject(e,r,o){if(aConcept.A_Context.environment==="browser")return e;let n;try{n=JSON.stringify(e,null,2);}catch{let f=new WeakSet;n=JSON.stringify(e,(U,l)=>{if(typeof l=="object"&&l!==null){if(f.has(l))return "[Circular Reference]";f.add(l);}return l},2);}let s=n.replace(/\n/g,`
|
|
4
4
|
${o}${C.PIPE}`);return r?`
|
|
@@ -40,6 +40,6 @@ ${r}|-------------------------------`:"")}compile_Error(e){let r=" ".repeat(this
|
|
|
40
40
|
`).map((o,n)=>n===0?o:`${r}| ${o}`).join(`
|
|
41
41
|
`)},null,2).replace(/\n/g,`
|
|
42
42
|
${r}| `).replace(/\\n/g,`
|
|
43
|
-
`)}getTime(){let e=new Date,r=String(e.getMinutes()).padStart(J.MINUTES_PAD,"0"),o=String(e.getSeconds()).padStart(J.SECONDS_PAD,"0"),n=String(e.getMilliseconds()).padStart(J.MILLISECONDS_PAD,"0");return `${r}${J.SEPARATOR}${o}${J.SEPARATOR}${n}`}};i(exports.A_Logger,"A_Logger"),exports.A_Logger=a([p(0,aConcept.A_Inject(aConcept.A_Scope)),p(1,aConcept.A_Inject(g))],exports.A_Logger);var jt,Ht,Kt,Xt,Jt,Wt,Zt,Qt,er,tr,rr,E=class E extends aConcept.A_Entity{constructor(e){super(e);this._listeners=new Map;}static get code(){return super.entity}get duration(){return this._endTime&&this._startTime?this._endTime.getTime()-this._startTime.getTime():this._startTime?new Date().getTime()-this._startTime.getTime():void 0}get idleTime(){return this._startTime&&this._createdAt?this._startTime.getTime()-this._createdAt.getTime():void 0}get scope(){return this._executionScope}get context(){return this.scope.resolve(v)}get code(){return this.constructor.code}get status(){return this._status}get createdAt(){return this._createdAt}get startedAt(){return this._startTime}get endedAt(){return this._endTime}get result(){return this._result}get error(){return this._error}get params(){return this._params}get isProcessed(){return this._status==="COMPLETED"||this._status==="FAILED"}async[rr="_A_StateMachine_onBeforeTransition"](e,r,...o){this.checkScopeInheritance(),r?.debug("yellow",`Command ${this.aseid.toString()} transitioning from ${e.from} to ${e.to}`);}async[tr="created_initialized"](e,...r){this._status==="CREATED"&&(this._createdAt=new Date,this._status="INITIALIZED",this.emit("onInit"));}async[er="initialized_executing"](e,...r){this._status!=="INITIALIZED"&&this._status!=="CREATED"||(this._startTime=new Date,this._status="EXECUTING",this.emit("onExecute"));}async[Qt="executing_completed"](e,...r){this._endTime=new Date,this._status="COMPLETED",this.emit("onComplete");}async[Zt="executing_failed"](e,r,...o){this._endTime=new Date,this._status="FAILED",this.emit("onFail");}async[Wt="_A_Command_onInit"](e,...r){await e.transition("CREATED","INITIALIZED");}async[Jt="_A_Command_onBeforeExecute"](e,...r){await e.transition("INITIALIZED","EXECUTING");}async[Xt="_A_Command_onExecute"](...e){}async[Kt="_A_Command_onAfterExecute"](...e){}async[Ht="_A_Command_onComplete"](e,...r){await e.transition("EXECUTING","COMPLETED");}async[jt="_A_Command_onFail"](e,r,...o){await e.transition("EXECUTING","FAILED");}async init(){await this.call("_A_Command_onInit",this.scope);}async execute(){if(!this.isProcessed)try{this.checkScopeInheritance();let e=new v("execute-command");this.scope.register(e),await new Promise(async(r,o)=>{try{let n=new aConcept.A_Feature({name:"_A_Command_onBeforeExecute",component:this,scope:this.scope}),s=new aConcept.A_Feature({name:"_A_Command_onExecute",component:this,scope:this.scope}),c=new aConcept.A_Feature({name:"_A_Command_onAfterExecute",component:this,scope:this.scope});this.on("onComplete",()=>{n.interrupt(),s.interrupt(),c.interrupt(),r();}),this.on("onFail",()=>{n.interrupt(),s.interrupt(),c.interrupt(),o(this.error);}),await n.process(this.scope),await s.process(this.scope),await c.process(this.scope),this._origin==="invoked"&&await this.complete(),r();}catch(n){o(n);}});}catch(e){let r=e instanceof aConcept.A_Error?e:new D({title:D.ExecutionError,description:`An error occurred while executing command "${this.aseid.toString()}".`,originalError:e});await this.fail(r);}}async complete(e){this.isProcessed||(this._status="COMPLETED",this._result=e,await this.call("_A_Command_onComplete",this.scope),this.scope.destroy());}async fail(e){this.isProcessed||(this._status="FAILED",e&&(this._error=e,this.scope.register(e)),await this.call("_A_Command_onFail",this.scope),this.scope.destroy());}on(e,r){this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(r);}off(e,r){this._listeners.get(e)?.delete(r);}emit(e){this._listeners.get(e)?.forEach(async r=>{r(this);});}fromNew(e){super.fromNew(e),this._origin="invoked",this._executionScope=new aConcept.A_Scope({name:`A-Command-Execution-Scope-${this.aseid.toString()}`,components:[b]}),this._createdAt=new Date,this._params=e,this._status="CREATED";}fromJSON(e){super.fromJSON(e),this._origin="serialized",this._executionScope=new aConcept.A_Scope({name:`A-Command-Execution-Scope-${this.aseid.toString()}`,components:[b]}),e.createdAt&&(this._createdAt=new Date(e.createdAt)),e.startedAt&&(this._startTime=new Date(e.startedAt)),e.endedAt&&(this._endTime=new Date(e.endedAt)),this._params=e.params,this._status=e.status,e.error&&(this._error=new D(e.error)),e.result&&(this._result=e.result);}toJSON(){return {...super.toJSON(),code:this.code,status:this._status,params:this._params,createdAt:this._createdAt.toISOString(),startedAt:this._startTime?this._startTime.toISOString():void 0,endedAt:this._endTime?this._endTime.toISOString():void 0,duration:this.duration,idleTime:this.idleTime,result:this.result,error:this.error?this.error.toJSON():void 0}}checkScopeInheritance(){let e;try{e=aConcept.A_Context.scope(this);}catch(r){throw new D({title:D.CommandScopeBindingError,description:`Command ${this.aseid.toString()} is not bound to any context scope. Ensure the command is properly registered within a context before execution.`,originalError:r})}this.scope.isInheritedFrom(aConcept.A_Context.scope(this))||this.scope.inherit(aConcept.A_Context.scope(this));}};i(E,"A_Command"),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Inject(P)),p(1,aConcept.A_Inject(exports.A_Logger))],E.prototype,rr,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Inject(P))],E.prototype,tr,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Inject(P))],E.prototype,er,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Inject(P))],E.prototype,Qt,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Inject(P)),p(1,aConcept.A_Inject(aConcept.A_Error))],E.prototype,Zt,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Inject(b))],E.prototype,Wt,1),a([aConcept.A_Feature.Extend({after:/.*/}),p(0,aConcept.A_Dependency.Required()),p(0,aConcept.A_Inject(b))],E.prototype,Jt,1),a([aConcept.A_Feature.Extend()],E.prototype,Xt,1),a([aConcept.A_Feature.Extend()],E.prototype,Kt,1),a([aConcept.A_Feature.Extend({after:/.*/}),p(0,aConcept.A_Inject(b))],E.prototype,Ht,1),a([aConcept.A_Feature.Extend({after:/.*/}),p(0,aConcept.A_Dependency.Required()),p(0,aConcept.A_Inject(b)),p(1,aConcept.A_Inject(v))],E.prototype,jt,1);var De=E;var Me=class Me{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._fs}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){this._fs=await import('fs');}initBrowser(){this._fs={readFileSync:i((t,e)=>(this.logger.warning("fs.readFileSync not available in browser environment"),""),"readFileSync"),existsSync:i(t=>(this.logger.warning("fs.existsSync not available in browser environment"),false),"existsSync"),createReadStream:i(t=>(this.logger.warning("fs.createReadStream not available in browser environment"),null),"createReadStream")};}};i(Me,"A_FSPolyfillClass");var de=Me;var Ge=class Ge{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(t){return this._initialized||(this._fsPolyfill=t,await this.init()),this._crypto}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('crypto');this._crypto={createTextHash:i((e,r="sha384")=>Promise.resolve(`${r}-${t.createHash(r).update(e).digest("base64")}`),"createTextHash"),createFileHash:i((e,r="sha384")=>new Promise(async(o,n)=>{try{if(!this._fsPolyfill)throw new Error("FS polyfill is required for file hashing");let s=t.createHash(r),c=this._fsPolyfill.createReadStream(e);c.on("data",f=>s.update(f)),c.on("end",()=>o(`${r}-${s.digest("base64")}`)),c.on("error",f=>n(f));}catch(s){n(s);}}),"createFileHash")};}initBrowser(){this._crypto={createFileHash:i(()=>(this.logger.warning("File hash not available in browser environment"),Promise.resolve("")),"createFileHash"),createTextHash:i((t,e="SHA-384")=>new Promise(async(r,o)=>{try{if(!crypto.subtle)throw new Error("SubtleCrypto not available");let s=new TextEncoder().encode(t),c=await crypto.subtle.digest(e,s),f=Array.from(new Uint8Array(c)),U=btoa(String.fromCharCode(...f));r(`${e}-${U}`);}catch(n){o(n);}}),"createTextHash")};}};i(Ge,"A_CryptoPolyfillClass");var me=Ge;var $e=class $e{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._http}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('http');this._http={request:t.request,get:t.get,createServer:t.createServer};}initBrowser(){this._http={request:i((t,e)=>(this.logger.warning("http.request not available in browser/test environment, use fetch instead"),this.createMockRequest(t,e,false)),"request"),get:i((t,e)=>(this.logger.warning("http.get not available in browser/test environment, use fetch instead"),this.createMockRequest(typeof t=="string"?{hostname:t}:t,e,false)),"get"),createServer:i(()=>(this.logger.error("http.createServer not available in browser/test environment"),null),"createServer")};}createMockRequest(t,e,r=false){return {end:i(()=>{if(e){let n={statusCode:200,headers:{},on:i((s,c)=>{s==="data"?setTimeout(()=>c("mock data"),0):s==="end"&&setTimeout(()=>c(),0);},"on"),pipe:i(s=>{s.write&&s.write("mock data"),s.end&&s.end();},"pipe")};setTimeout(()=>e(n),0);}},"end"),write:i(n=>{},"write"),on:i((n,s)=>{},"on")}}};i($e,"A_HttpPolyfillClass");var he=$e;var Ue=class Ue{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._https}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('https');this._https={request:t.request,get:t.get,createServer:t.createServer};}initBrowser(){this._https={request:i((t,e)=>(this.logger.warning("https.request not available in browser/test environment, use fetch instead"),this.createMockRequest(t,e,true)),"request"),get:i((t,e)=>(this.logger.warning("https.get not available in browser/test environment, use fetch instead"),this.createMockRequest(typeof t=="string"?{hostname:t}:t,e,true)),"get"),createServer:i(()=>(this.logger.error("https.createServer not available in browser/test environment"),null),"createServer")};}createMockRequest(t,e,r=true){return {end:i(()=>{if(e){let n={statusCode:200,headers:{},on:i((s,c)=>{s==="data"?setTimeout(()=>c("mock data"),0):s==="end"&&setTimeout(()=>c(),0);},"on"),pipe:i(s=>{s.write&&s.write("mock data"),s.end&&s.end();},"pipe")};setTimeout(()=>e(n),0);}},"end"),write:i(n=>{},"write"),on:i((n,s)=>{},"on")}}};i(Ue,"A_HttpsPolyfillClass");var fe=Ue;var ze=class ze{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._path}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){this._path=await import('path');}initBrowser(){this._path={join:i((...t)=>t.join("/").replace(/\/+/g,"/"),"join"),resolve:i((...t)=>{let e="";for(let r of t)r.startsWith("/")?e=r:e=this._path.join(e,r);return e||"/"},"resolve"),dirname:i(t=>t.split("/").slice(0,-1).join("/")||"/","dirname"),basename:i((t,e)=>{let r=t.split("/").pop()||"";return e&&r.endsWith(e)?r.slice(0,-e.length):r},"basename"),extname:i(t=>{let e=t.split(".");return e.length>1?"."+e.pop():""},"extname"),relative:i((t,e)=>e.replace(t,"").replace(/^\//,""),"relative"),normalize:i(t=>t.replace(/\/+/g,"/").replace(/\/$/,"")||"/","normalize"),isAbsolute:i(t=>t.startsWith("/")||/^[a-zA-Z]:/.test(t),"isAbsolute"),parse:i(t=>{let e=this._path.extname(t),r=this._path.basename(t),o=this._path.basename(t,e);return {root:"/",dir:this._path.dirname(t),base:r,ext:e,name:o}},"parse"),format:i(t=>this._path.join(t.dir||"",t.base||""),"format"),sep:"/",delimiter:":"};}};i(ze,"A_PathPolyfillClass");var ye=ze;var Fe=class Fe{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._url}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('url');this._url={parse:t.parse,format:t.format,resolve:t.resolve,URL:t.URL||globalThis.URL,URLSearchParams:t.URLSearchParams||globalThis.URLSearchParams};}initBrowser(){this._url={parse:i(t=>{try{let e=new URL(t);return {protocol:e.protocol,hostname:e.hostname,port:e.port,pathname:e.pathname,search:e.search,hash:e.hash,host:e.host,href:e.href}}catch{return {}}},"parse"),format:i(t=>{try{return new URL("",t.href||`${t.protocol}//${t.host}${t.pathname}${t.search}${t.hash}`).href}catch{return ""}},"format"),resolve:i((t,e)=>{try{return new URL(e,t).href}catch{return e}},"resolve"),URL:globalThis.URL,URLSearchParams:globalThis.URLSearchParams};}};i(Fe,"A_UrlPolyfillClass");var ge=Fe;var Be=class Be{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._buffer}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('buffer');this._buffer={from:t.Buffer.from,alloc:t.Buffer.alloc,allocUnsafe:t.Buffer.allocUnsafe,isBuffer:t.Buffer.isBuffer,concat:t.Buffer.concat};}initBrowser(){this._buffer={from:i((t,e)=>typeof t=="string"?new TextEncoder().encode(t):new Uint8Array(t),"from"),alloc:i((t,e)=>{let r=new Uint8Array(t);return e!==void 0&&r.fill(e),r},"alloc"),allocUnsafe:i(t=>new Uint8Array(t),"allocUnsafe"),isBuffer:i(t=>t instanceof Uint8Array||t instanceof ArrayBuffer,"isBuffer"),concat:i((t,e)=>{let r=e||t.reduce((s,c)=>s+c.length,0),o=new Uint8Array(r),n=0;for(let s of t)o.set(s,n),n+=s.length;return o},"concat")};}};i(Be,"A_BufferPolyfillClass");var ue=Be;var Ye=class Ye{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._process}async init(){try{aConcept.A_Context.environment==="server"?this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}initServer(){this._process={env:process.env,argv:process.argv,platform:process.platform,version:process.version,versions:process.versions,cwd:process.cwd,exit:process.exit,nextTick:process.nextTick};}initBrowser(){this._process={env:{NODE_ENV:"browser",...globalThis.process?.env||{}},argv:["browser"],platform:"browser",version:"browser",versions:{node:"browser"},cwd:i(()=>"/","cwd"),exit:i(t=>{throw this.logger.warning("process.exit not available in browser"),new Error(`Process exit with code ${t}`)},"exit"),nextTick:i((t,...e)=>{setTimeout(()=>t(...e),0);},"nextTick")};}};i(Ye,"A_ProcessPolyfillClass");var Ee=Ye;exports.A_Polyfill=class m extends aConcept.A_Component{constructor(e){super();this.logger=e;this._initializing=null;}get ready(){return this._initialized||(this._initialized=this._loadInternal()),this._initialized}async load(){await this.ready;}async attachToWindow(){aConcept.A_Context.environment==="browser"&&(globalThis.A_Polyfill=this,globalThis.process={env:{NODE_ENV:"production"},cwd:i(()=>"/","cwd")},globalThis.__dirname="/");}async _loadInternal(){this._fsPolyfill=new de(this.logger),this._cryptoPolyfill=new me(this.logger),this._httpPolyfill=new he(this.logger),this._httpsPolyfill=new fe(this.logger),this._pathPolyfill=new ye(this.logger),this._urlPolyfill=new ge(this.logger),this._bufferPolyfill=new ue(this.logger),this._processPolyfill=new Ee(this.logger),await this._fsPolyfill.get(),await this._cryptoPolyfill.get(await this._fsPolyfill.get()),await this._httpPolyfill.get(),await this._httpsPolyfill.get(),await this._pathPolyfill.get(),await this._urlPolyfill.get(),await this._bufferPolyfill.get(),await this._processPolyfill.get();}async fs(){return await this.ready,await this._fsPolyfill.get()}async crypto(){return await this.ready,await this._cryptoPolyfill.get()}async http(){return await this.ready,await this._httpPolyfill.get()}async https(){return await this.ready,await this._httpsPolyfill.get()}async path(){return await this.ready,await this._pathPolyfill.get()}async url(){return await this.ready,await this._urlPolyfill.get()}async buffer(){return await this.ready,await this._bufferPolyfill.get()}async process(){return await this.ready,await this._processPolyfill.get()}};i(exports.A_Polyfill,"A_Polyfill"),a([aConcept.A_Concept.Load()],exports.A_Polyfill.prototype,"load",1),a([aConcept.A_Concept.Load()],exports.A_Polyfill.prototype,"attachToWindow",1),exports.A_Polyfill=a([p(0,aConcept.A_Inject(exports.A_Logger))],exports.A_Polyfill);exports.ConfigReader=class A extends aConcept.A_Component{constructor(e){super();this.polyfill=e;this.DEFAULT_ALLOWED_TO_READ_PROPERTIES=[...aConcept.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...X];}async attachContext(e,r,o){o||(o=new g({defaults:{}}),e.scope.register(o));let n=await this.getProjectRoot();o.set("A_CONCEPT_ROOT_FOLDER",n);}async initialize(e){let r=await this.read();for(let o in r)e.set(o,r[o]);}resolve(e){return e}async read(e=[]){return {}}async getProjectRoot(e=__dirname){return (await this.polyfill.process()).cwd()}};i(exports.ConfigReader,"ConfigReader"),a([aConcept.A_Concept.Load(),p(0,aConcept.A_Inject(aConcept.A_Container)),p(1,aConcept.A_Inject(aConcept.A_Scope)),p(2,aConcept.A_Inject(g))],exports.ConfigReader.prototype,"attachContext",1),a([aConcept.A_Concept.Load(),p(0,aConcept.A_Dependency.Required()),p(0,aConcept.A_Inject(g))],exports.ConfigReader.prototype,"initialize",1),exports.ConfigReader=a([p(0,aConcept.A_Dependency.Required()),p(0,aConcept.A_Inject(exports.A_Polyfill))],exports.ConfigReader);var Ve=class Ve extends exports.ConfigReader{constructor(){super(...arguments);this.FileData=new Map;}getConfigurationProperty_File_Alias(e){return aConcept.A_FormatterHelper.toCamelCase(e)}resolve(e){return this.FileData.get(this.getConfigurationProperty_File_Alias(e))}async read(e){let r=await this.polyfill.fs();try{let o=r.readFileSync(`${aConcept.A_Context.concept}.conf.json`,"utf8"),n=JSON.parse(o);return this.FileData=new Map(Object.entries(n)),n}catch{return {}}}};i(Ve,"FileConfigReader");var se=Ve;var Te=class Te extends exports.ConfigReader{async readEnvFile(t,e,r){let o=await e.fs();o.existsSync(".env")&&o.readFileSync(`${t.get("A_CONCEPT_ROOT_FOLDER")}/.env`,"utf-8").split(`
|
|
44
|
-
`).forEach(n=>{let[s,c]=n.split("=");s&&c&&(process.env[s.trim()]=c.trim());});}getConfigurationProperty_ENV_Alias(t){return aConcept.A_FormatterHelper.toUpperSnakeCase(t)}resolve(t){return process.env[this.getConfigurationProperty_ENV_Alias(t)]}async read(t=[]){let e=[...t,...Object.keys(process.env)],r={};return e.forEach(o=>{r[o]=this.resolve(o);}),r}};i(Te,"ENVConfigReader"),a([aConcept.A_Concept.Load({before:["ENVConfigReader.initialize"]}),p(0,aConcept.A_Inject(g)),p(1,aConcept.A_Inject(exports.A_Polyfill)),p(2,aConcept.A_Inject(aConcept.A_Feature))],Te.prototype,"readEnvFile",1);var W=Te;var Ae=class Ae extends aConcept.A_Container{async prepare(t){if(!this.scope.has(g)){let r=new g({variables:[...aConcept.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...X],defaults:{}});this.scope.register(r);}let e=await t.fs();try{switch(!0){case(aConcept.A_Context.environment==="server"&&!!e.existsSync(`${aConcept.A_Context.concept}.conf.json`)):this.reader=this.scope.resolve(se);break;case(aConcept.A_Context.environment==="server"&&!e.existsSync(`${aConcept.A_Context.concept}.conf.json`)):this.reader=this.scope.resolve(W);break;case aConcept.A_Context.environment==="browser":this.reader=this.scope.resolve(W);break;default:throw new N(N.InitializationError,`Environment ${aConcept.A_Context.environment} is not supported`)}}catch(r){if(r instanceof aConcept.A_ScopeError)throw new N({title:N.InitializationError,description:`Failed to initialize A_ConfigLoader. Reader not found for environment ${aConcept.A_Context.environment}`,originalError:r})}}};i(Ae,"A_ConfigLoader"),a([aConcept.A_Concept.Load({before:/.*/}),p(0,aConcept.A_Inject(exports.A_Polyfill))],Ae.prototype,"prepare",1);var je=Ae;var vr=(B=>B)(vr||{});var Se={A_LOGGER_LEVEL:"A_LOGGER_LEVEL",A_LOGGER_DEFAULT_SCOPE_LENGTH:"A_LOGGER_DEFAULT_SCOPE_LENGTH",A_LOGGER_DEFAULT_SCOPE_COLOR:"A_LOGGER_DEFAULT_SCOPE_COLOR",A_LOGGER_DEFAULT_LOG_COLOR:"A_LOGGER_DEFAULT_LOG_COLOR"},$n=[Se.A_LOGGER_LEVEL,Se.A_LOGGER_DEFAULT_SCOPE_LENGTH,Se.A_LOGGER_DEFAULT_SCOPE_COLOR,Se.A_LOGGER_DEFAULT_LOG_COLOR];var xe=class xe extends aConcept.A_Error{};i(xe,"A_ManifestError"),xe.ManifestInitializationError="A-Manifest Initialization Error";var F=xe;var He=class He{constructor(t,e,r,o=false){this.manifest=t;this.component=e;this.method=r;this.checkExclusion=o;}for(t){let e=this.manifest.internal_checkAccess({component:this.component,method:this.method,target:t});return this.checkExclusion?!e:e}};i(He,"A_ManifestChecker");var Z=He;var Xe=class Xe extends aConcept.A_Fragment{constructor(e=[]){super({name:"A-Manifest"});this.rules=[];this.prepare(e);}prepare(e){if(!aConcept.A_TypeGuards.isArray(e))throw new F(F.ManifestInitializationError,"A-Manifest configuration should be an array of configurations");for(let r of e)this.processConfigItem(r);}processConfigItem(e){if(!aConcept.A_TypeGuards.isComponentConstructor(e.component))throw new F(F.ManifestInitializationError,"A-Manifest configuration item should be a A-Component constructor");let r=this.constructorToRegex(e.component);if(e.apply||e.exclude){let o=/.*/;this.rules.push({componentRegex:r,methodRegex:o,applyRegex:e.apply?this.allowedComponentsToRegex(e.apply):void 0,excludeRegex:e.exclude?this.allowedComponentsToRegex(e.exclude):void 0});}if(e.methods&&e.methods.length>0)for(let o of e.methods){let n=this.methodToRegex(o.method);this.rules.push({componentRegex:r,methodRegex:n,applyRegex:o.apply?this.allowedComponentsToRegex(o.apply):void 0,excludeRegex:o.exclude?this.allowedComponentsToRegex(o.exclude):void 0});}}constructorToRegex(e){return new RegExp(`^${this.escapeRegex(e.name)}$`)}methodToRegex(e){return e instanceof RegExp?e:new RegExp(`^${this.escapeRegex(e)}$`)}allowedComponentsToRegex(e){if(e instanceof RegExp)return e;let r=e.map(o=>this.escapeRegex(o.name));return new RegExp(`^(${r.join("|")})$`)}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}configItemToRegexp(e){return this.constructorToRegex(e)}ID(e,r){return `${e.name}.${r}`}isAllowed(e,r){let o=typeof e=="function"?e:e.constructor;return new Z(this,o,r)}internal_checkAccess(e){let r=e.component.name,o=e.method,n=e.target.name,s=this.rules.filter(c=>c.componentRegex.test(r)&&c.methodRegex.test(o)).sort((c,f)=>{let U=c.methodRegex.source===".*",l=f.methodRegex.source===".*";return U&&!l?1:!U&&l?-1:0});if(s.length===0)return true;for(let c of s){if(c.excludeRegex&&c.excludeRegex.test(n))return false;if(c.applyRegex)return c.applyRegex.test(n)}return true}isExcluded(e,r){let o=typeof e=="function"?e:e.constructor;return new Z(this,o,r,true)}};i(Xe,"A_Manifest");var Ke=Xe;var Ir=(l=>(l.onInit="_A_Memory_onInit",l.onDestroy="_A_Memory_onDestroy",l.onExpire="_A_Memory_onExpire",l.onError="_A_Memory_onError",l.onSerialize="_A_Memory_onSerialize",l.onSet="_A_Memory_onSet",l.onGet="_A_Memory_onGet",l.onDrop="_A_Memory_onDrop",l.onClear="_A_Memory_onClear",l.onHas="_A_Memory_onHas",l))(Ir||{});var Je=class Je extends aConcept.A_Fragment{constructor(){super(...arguments);this._storage=new Map;}set(e,r){this._storage.set(e,r);}get(e){return this._storage.get(e)}delete(e){this._storage.delete(e);}has(e){return this._storage.has(e)}clear(){this._storage.clear();}};i(Je,"A_MemoryContext");var R=Je;var O=class O extends aConcept.A_Error{};i(O,"A_MemoryError"),O.MemoryInitializationError="Memory initialization error",O.MemoryDestructionError="Memory destruction error",O.MemoryGetError="Memory GET operation failed",O.MemorySetError="Memory SET operation failed",O.MemoryDropError="Memory DROP operation failed",O.MemoryClearError="Memory CLEAR operation failed",O.MemoryHasError="Memory HAS operation failed",O.MemorySerializeError="Memory toJSON operation failed";var d=O;var Dr,Mr,Gr,$r,Ur,zr,Fr,Br,Yr,L=class L extends aConcept.A_Component{get ready(){return this._ready||(this._ready=this.init()),this._ready}async[Yr="_A_Memory_onError"](...t){}async[Br="_A_Memory_onExpire"](...t){}async[Fr="_A_Memory_onInit"](t,...e){t||(t=new R,aConcept.A_Context.scope(this).register(t));}async[zr="_A_Memory_onDestroy"](t,...e){t.clear();}async[Ur="_A_Memory_onGet"](t,e,...r){t.succeed(e.get(t.params.key));}async[$r="_A_Memory_onHas"](t,e,...r){t.succeed(e.has(t.params.key));}async[Gr="_A_Memory_onSet"](t,e,r,...o){console.log("A_Memory onSet called with key:",r.name),console.log("A_Memory onSet called with key:",r.parent?.name),e.set(t.params.key,t.params.value);}async[Mr="_A_Memory_onDrop"](t,e,...r){e.delete(t.params.key);}async[Dr="_A_Memory_onClear"](t,e,...r){e.clear();}async init(){if(this._ready)return this._ready;let t=new aConcept.A_Scope({name:"A-Memory-Init-Scope"}).inherit(aConcept.A_Context.scope(this));try{await this.call("_A_Memory_onInit",t);}catch(e){let r=new d({title:d.MemoryInitializationError,description:"An error occurred during memory initialization",originalError:e});throw t.register(r),await this.call("_A_Memory_onError",t),t.destroy(),r}}async destroy(){let t=new aConcept.A_Scope({name:"A-Memory-Destroy-Scope"}).inherit(aConcept.A_Context.scope(this));try{this._ready=void 0,await this.call("_A_Memory_onDestroy",t);}catch(e){let r=new d({title:d.MemoryDestructionError,description:"An error occurred during memory destruction",originalError:e});throw t.register(r),await this.call("_A_Memory_onError",t),t.destroy(),r}}async get(t){let e=new _("get",{key:t}),r=new aConcept.A_Scope({name:"A-Memory-Get-Operation-Scope",fragments:[e]}).inherit(aConcept.A_Context.scope(this));try{return await this.call("_A_Memory_onGet",r),r.destroy(),e.result}catch(o){let n=new d({title:d.MemoryGetError,description:`An error occurred while getting the value for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("_A_Memory_onError",r),r.destroy(),n}}async has(t){let e=new _("has",{key:t}),r=new aConcept.A_Scope({name:"A-Memory-Has-Operation-Scope",fragments:[e]}).inherit(aConcept.A_Context.scope(this));try{return await this.call("_A_Memory_onHas",r),r.destroy(),e.result}catch(o){let n=new d({title:d.MemoryHasError,description:`An error occurred while checking existence for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("_A_Memory_onError",r),r.destroy(),n}}async set(t,e){let r=new _("set",{key:t,value:e}),o=new aConcept.A_Scope({name:"A-Memory-Set-Operation-Scope",fragments:[r]}).inherit(aConcept.A_Context.scope(this));try{await this.call("_A_Memory_onSet",o);}catch(n){let s=new d({title:d.MemorySetError,description:`An error occurred while setting the value for key "${String(t)}"`,originalError:n});throw o.register(s),await this.call("_A_Memory_onError",o),o.destroy(),s}}async drop(t){let e=new _("drop",{key:t}),r=new aConcept.A_Scope({name:"A-Memory-Drop-Operation-Scope",fragments:[e]}).inherit(aConcept.A_Context.scope(this));try{await this.call("_A_Memory_onDrop",r);}catch(o){let n=new d({title:d.MemoryDropError,description:`An error occurred while dropping the value for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("_A_Memory_onError",r),r.destroy(),n}}async clear(){let t=new _("clear"),e=new aConcept.A_Scope({name:"A-Memory-Clear-Operation-Scope",fragments:[t]}).inherit(aConcept.A_Context.scope(this));try{await this.call("_A_Memory_onClear",e);}catch(r){let o=new d({title:d.MemoryClearError,description:"An error occurred while clearing the memory",originalError:r});throw e.register(o),await this.call("_A_Memory_onError",e),e.destroy(),o}}async toJSON(){let t=new _("serialize"),e=new aConcept.A_Scope({name:"A-Memory-Serialize-Operation-Scope",fragments:[t]}).inherit(aConcept.A_Context.scope(this));try{return await this.call("_A_Memory_onSerialize",e),t.result}catch(r){let o=new d({title:d.MemorySerializeError,description:"An error occurred while serializing the memory",originalError:r});throw e.register(o),await this.call("_A_Memory_onError",e),e.destroy(),o}}};i(L,"A_Memory"),a([aConcept.A_Feature.Extend()],L.prototype,Yr,1),a([aConcept.A_Feature.Extend()],L.prototype,Br,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Inject(R))],L.prototype,Fr,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Inject(R))],L.prototype,zr,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Dependency.Required()),p(0,aConcept.A_Inject(_)),p(1,aConcept.A_Inject(R))],L.prototype,Ur,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Dependency.Required()),p(0,aConcept.A_Inject(_)),p(1,aConcept.A_Inject(R))],L.prototype,$r,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Dependency.Required()),p(0,aConcept.A_Inject(_)),p(1,aConcept.A_Inject(R)),p(2,aConcept.A_Inject(aConcept.A_Scope))],L.prototype,Gr,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Dependency.Required()),p(0,aConcept.A_Inject(_)),p(1,aConcept.A_Inject(R))],L.prototype,Mr,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Dependency.Required()),p(0,aConcept.A_Inject(_)),p(1,aConcept.A_Inject(R))],L.prototype,Dr,1);var We=L;var Vr=(l=>(l.onBeforeLoad="_A_Service_onBeforeLoad",l.onLoad="_A_Service_onLoad",l.onAfterLoad="_A_Service_onAfterLoad",l.onBeforeStart="_A_Service_onBeforeStart",l.onStart="_A_Service_onStart",l.onAfterStart="_A_Service_onAfterStart",l.onBeforeStop="_A_Service_onBeforeStop",l.onStop="_A_Service_onStop",l.onAfterStop="_A_Service_onAfterStop",l.onError="_A_Service_onError",l))(Vr||{});var Q=class Q extends aConcept.A_Error{};i(Q,"A_Service_Error"),Q.ServiceLoadError="Service load error",Q.ServiceStartError="Service start error",Q.ServiceStopError="Service stop error";var y=Q;var Hr,Kr,Xr,Jr,Wr,Zr,Qr,eo,to,ro,h=class h extends aConcept.A_Container{async load(){try{await this.call("_A_Service_onBeforeLoad"),await this.call("_A_Service_onLoad"),await this.call("_A_Service_onAfterLoad");}catch(t){let e;switch(true){case t instanceof y:e=t;break;case(t instanceof aConcept.A_Error&&t.originalError instanceof y):e=t.originalError;break;default:e=new y({title:y.ServiceLoadError,description:"An error occurred while processing the request.",originalError:t});break}this.scope.register(e),await this.call("_A_Service_onError");}}async start(){try{await this.call("_A_Service_onBeforeStart"),await this.call("_A_Service_onStart"),await this.call("_A_Service_onAfterStart");}catch(t){let e;switch(true){case t instanceof y:e=t;break;case(t instanceof aConcept.A_Error&&t.originalError instanceof y):e=t.originalError;break;default:e=new y({title:y.ServiceStartError,description:"An error occurred while processing the request.",originalError:t});break}this.scope.register(e),await this.call("_A_Service_onError");}}async stop(){try{await this.call("_A_Service_onBeforeStop"),await this.call("_A_Service_onStop"),await this.call("_A_Service_onAfterStop");}catch(t){let e;switch(true){case t instanceof y:e=t;break;case(t instanceof aConcept.A_Error&&t.originalError instanceof y):e=t.originalError;break;default:e=new y({title:y.ServiceStopError,description:"An error occurred while processing the request.",originalError:t});break}this.scope.register(e),await this.call("_A_Service_onError");}}async[ro="_A_Service_onBeforeLoad"](t,...e){t||(this.scope.register(exports.A_Polyfill),t=this.scope.resolve(exports.A_Polyfill));}async[to="_A_Service_onLoad"](...t){}async[eo="_A_Service_onAfterLoad"](...t){}async[Qr="_A_Service_onBeforeStart"](...t){}async[Zr="_A_Service_onStart"](...t){}async[Wr="_A_Service_onAfterStart"](...t){}async[Jr="_A_Service_onBeforeStop"](...t){}async[Xr="_A_Service_onStop"](...t){}async[Kr="_A_Service_onAfterStop"](...t){}async[Hr="_A_Service_onError"](t,e,...r){e?.error(t);}};i(h,"A_Service"),a([aConcept.A_Concept.Load()],h.prototype,"load",1),a([aConcept.A_Concept.Start()],h.prototype,"start",1),a([aConcept.A_Concept.Stop()],h.prototype,"stop",1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Inject(exports.A_Polyfill))],h.prototype,ro,1),a([aConcept.A_Feature.Extend()],h.prototype,to,1),a([aConcept.A_Feature.Extend()],h.prototype,eo,1),a([aConcept.A_Feature.Extend()],h.prototype,Qr,1),a([aConcept.A_Feature.Extend()],h.prototype,Zr,1),a([aConcept.A_Feature.Extend()],h.prototype,Wr,1),a([aConcept.A_Feature.Extend()],h.prototype,Jr,1),a([aConcept.A_Feature.Extend()],h.prototype,Xr,1),a([aConcept.A_Feature.Extend()],h.prototype,Kr,1),a([aConcept.A_Feature.Extend({before:/.*/}),p(0,aConcept.A_Inject(aConcept.A_Error)),p(1,aConcept.A_Inject(exports.A_Logger))],h.prototype,Hr,1);var et=h;var tt=class tt{constructor(){this.promise=new Promise((t,e)=>{this.resolveFn=t,this.rejectFn=e;});}resolve(t){this.resolveFn(t);}reject(t){this.rejectFn(t);}};i(tt,"A_Deferred");var ce=tt;var rt=class rt{constructor(t,e,r){this.config={resolveOnClear:false};r&&(this.config={...this.config,...r}),this.deferred=new ce,this.timeout=setTimeout(()=>e().then((...o)=>this.deferred.resolve(...o)).catch((...o)=>this.deferred.reject(...o)),t);}get promise(){return this.deferred.promise}clear(){this.timeout&&(clearTimeout(this.timeout),this.config.resolveOnClear?this.deferred.resolve(void 0):this.deferred.reject(new aConcept.A_Error("Timeout Cleared")));}};i(rt,"A_ScheduleObject");var ee=rt;var it=class it extends aConcept.A_Component{async schedule(t,e,r){let o=aConcept.A_TypeGuards.isString(t)?new Date(t).getTime():t;return new ee(o-Date.now(),e,r)}async delay(t,e,r){return new ee(t,e,r)}};i(it,"A_Schedule");var ot=it;exports.A_CONSTANTS__CONFIG_ENV_VARIABLES=Jo;exports.A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY=X;exports.A_Channel=Oe;exports.A_ChannelError=Y;exports.A_ChannelFeatures=xt;exports.A_ChannelRequest=te;exports.A_ChannelRequestStatuses=Ct;exports.A_Command=De;exports.A_CommandError=D;exports.A_CommandEvent=Pt;exports.A_CommandFeatures=vt;exports.A_CommandTransitions=Lt;exports.A_Command_Status=Rt;exports.A_Config=g;exports.A_ConfigError=N;exports.A_ConfigLoader=je;exports.A_Deferred=ce;exports.A_ExecutionContext=v;exports.A_LOGGER_ANSI=z;exports.A_LOGGER_COLORS=ct;exports.A_LOGGER_DEFAULT_LEVEL=ci;exports.A_LOGGER_DEFAULT_SCOPE_LENGTH=at;exports.A_LOGGER_ENV_KEYS=ie;exports.A_LOGGER_FORMAT=C;exports.A_LOGGER_SAFE_RANDOM_COLORS=pt;exports.A_LOGGER_TIME_FORMAT=J;exports.A_LoggerEnvVariables=Se;exports.A_LoggerEnvVariablesArray=$n;exports.A_Manifest=Ke;exports.A_ManifestChecker=Z;exports.A_ManifestError=F;exports.A_Memory=We;exports.A_MemoryContext=R;exports.A_MemoryError=d;exports.A_MemoryFeatures=Ir;exports.A_OperationContext=_;exports.A_Schedule=ot;exports.A_ScheduleObject=ee;exports.A_Service=et;exports.A_ServiceFeatures=Vr;exports.A_StateMachine=b;exports.A_StateMachineError=K;exports.A_StateMachineFeatures=bt;exports.A_StateMachineTransition=P;exports.A_TYPES__ConfigFeature=vr;exports.ENVConfigReader=W;exports.FileConfigReader=se;//# sourceMappingURL=index.cjs.map
|
|
43
|
+
`)}getTime(){let e=new Date,r=String(e.getMinutes()).padStart(J.MINUTES_PAD,"0"),o=String(e.getSeconds()).padStart(J.SECONDS_PAD,"0"),n=String(e.getMilliseconds()).padStart(J.MILLISECONDS_PAD,"0");return `${r}${J.SEPARATOR}${o}${J.SEPARATOR}${n}`}};i(exports.A_Logger,"A_Logger"),exports.A_Logger=a([p(0,aConcept.A_Inject(aConcept.A_Scope)),p(1,aConcept.A_Inject(g))],exports.A_Logger);var Ht,Kt,Xt,Jt,Wt,Zt,Qt,er,tr,rr,or,E=class E extends aConcept.A_Entity{constructor(e){super(e);this._listeners=new Map;}static get code(){return super.entity}get duration(){return this._endTime&&this._startTime?this._endTime.getTime()-this._startTime.getTime():this._startTime?new Date().getTime()-this._startTime.getTime():void 0}get idleTime(){return this._startTime&&this._createdAt?this._startTime.getTime()-this._createdAt.getTime():void 0}get scope(){return this._executionScope}get context(){return this.scope.resolve(v)}get code(){return this.constructor.code}get status(){return this._status}get createdAt(){return this._createdAt}get startedAt(){return this._startTime}get endedAt(){return this._endTime}get result(){return this._result}get error(){return this._error}get params(){return this._params}get isProcessed(){return this._status==="COMPLETED"||this._status==="FAILED"}async[or="_A_StateMachine_onBeforeTransition"](e,r,...o){this.checkScopeInheritance(),r?.debug("yellow",`Command ${this.aseid.toString()} transitioning from ${e.from} to ${e.to}`);}async[rr="created_initialized"](e,...r){this._status==="CREATED"&&(this._createdAt=new Date,this._status="INITIALIZED",this.emit("onInit"));}async[tr="initialized_executing"](e,...r){this._status!=="INITIALIZED"&&this._status!=="CREATED"||(this._startTime=new Date,this._status="EXECUTING",this.emit("onExecute"));}async[er="executing_completed"](e,...r){this._endTime=new Date,this._status="COMPLETED",this.emit("onComplete");}async[Qt="executing_failed"](e,r,...o){this._endTime=new Date,this._status="FAILED",this.emit("onFail");}async[Zt="_A_Command_onInit"](e,...r){await e.transition("CREATED","INITIALIZED");}async[Wt="_A_Command_onBeforeExecute"](e,...r){await e.transition("INITIALIZED","EXECUTING");}async[Jt="_A_Command_onExecute"](...e){}async[Xt="_A_Command_onAfterExecute"](...e){}async[Kt="_A_Command_onComplete"](e,...r){await e.transition("EXECUTING","COMPLETED");}async[Ht="_A_Command_onFail"](e,r,...o){await e.transition("EXECUTING","FAILED");}async init(){await this.call("_A_Command_onInit",this.scope);}async execute(){if(!this.isProcessed)try{this.checkScopeInheritance();let e=new v("execute-command");this.scope.register(e),await new Promise(async(r,o)=>{try{let n=new aConcept.A_Feature({name:"_A_Command_onBeforeExecute",component:this,scope:this.scope}),s=new aConcept.A_Feature({name:"_A_Command_onExecute",component:this,scope:this.scope}),c=new aConcept.A_Feature({name:"_A_Command_onAfterExecute",component:this,scope:this.scope});this.on("onComplete",()=>{n.interrupt(),s.interrupt(),c.interrupt(),r();}),this.on("onFail",()=>{n.interrupt(),s.interrupt(),c.interrupt(),o(this.error);}),await n.process(this.scope),await s.process(this.scope),await c.process(this.scope),this._origin==="invoked"&&await this.complete(),r();}catch(n){o(n);}});}catch(e){let r=e instanceof aConcept.A_Error?e:new D({title:D.ExecutionError,description:`An error occurred while executing command "${this.aseid.toString()}".`,originalError:e});await this.fail(r);}}async complete(e){this.isProcessed||(this._status="COMPLETED",this._result=e,await this.call("_A_Command_onComplete",this.scope),this.scope.destroy());}async fail(e){this.isProcessed||(this._status="FAILED",e&&(this._error=e,this.scope.register(e)),await this.call("_A_Command_onFail",this.scope),this.scope.destroy());}on(e,r){this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(r);}off(e,r){this._listeners.get(e)?.delete(r);}emit(e){this._listeners.get(e)?.forEach(async r=>{r(this);});}fromNew(e){super.fromNew(e),this._origin="invoked",this._executionScope=new aConcept.A_Scope({name:`A-Command-Execution-Scope-${this.aseid.toString()}`,components:[b]}),this._createdAt=new Date,this._params=e,this._status="CREATED";}fromJSON(e){super.fromJSON(e),this._origin="serialized",this._executionScope=new aConcept.A_Scope({name:`A-Command-Execution-Scope-${this.aseid.toString()}`,components:[b]}),e.createdAt&&(this._createdAt=new Date(e.createdAt)),e.startedAt&&(this._startTime=new Date(e.startedAt)),e.endedAt&&(this._endTime=new Date(e.endedAt)),this._params=e.params,this._status=e.status,e.error&&(this._error=new D(e.error)),e.result&&(this._result=e.result);}toJSON(){return {...super.toJSON(),code:this.code,status:this._status,params:this._params,createdAt:this._createdAt.toISOString(),startedAt:this._startTime?this._startTime.toISOString():void 0,endedAt:this._endTime?this._endTime.toISOString():void 0,duration:this.duration,idleTime:this.idleTime,result:this.result,error:this.error?this.error.toJSON():void 0}}checkScopeInheritance(){let e;try{e=aConcept.A_Context.scope(this);}catch(r){throw new D({title:D.CommandScopeBindingError,description:`Command ${this.aseid.toString()} is not bound to any context scope. Ensure the command is properly registered within a context before execution.`,originalError:r})}this.scope.isInheritedFrom(aConcept.A_Context.scope(this))||this.scope.inherit(aConcept.A_Context.scope(this));}};i(E,"A_Command"),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Inject(P)),p(1,aConcept.A_Inject(exports.A_Logger))],E.prototype,or,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Inject(P))],E.prototype,rr,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Inject(P))],E.prototype,tr,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Inject(P))],E.prototype,er,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Inject(P)),p(1,aConcept.A_Inject(aConcept.A_Error))],E.prototype,Qt,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Inject(b))],E.prototype,Zt,1),a([aConcept.A_Feature.Extend({after:/.*/}),p(0,aConcept.A_Dependency.Required()),p(0,aConcept.A_Inject(b))],E.prototype,Wt,1),a([aConcept.A_Feature.Extend()],E.prototype,Jt,1),a([aConcept.A_Feature.Extend()],E.prototype,Xt,1),a([aConcept.A_Feature.Extend({after:/.*/}),p(0,aConcept.A_Inject(b))],E.prototype,Kt,1),a([aConcept.A_Feature.Extend({after:/.*/}),p(0,aConcept.A_Dependency.Required()),p(0,aConcept.A_Inject(b)),p(1,aConcept.A_Inject(v))],E.prototype,Ht,1);var De=E;var Me=class Me{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._fs}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){this._fs=await import('fs');}initBrowser(){this._fs={readFileSync:i((t,e)=>(this.logger.warning("fs.readFileSync not available in browser environment"),""),"readFileSync"),existsSync:i(t=>(this.logger.warning("fs.existsSync not available in browser environment"),false),"existsSync"),createReadStream:i(t=>(this.logger.warning("fs.createReadStream not available in browser environment"),null),"createReadStream")};}};i(Me,"A_FSPolyfillClass");var de=Me;var Ge=class Ge{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(t){return this._initialized||(this._fsPolyfill=t,await this.init()),this._crypto}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('crypto');this._crypto={createTextHash:i((e,r="sha384")=>Promise.resolve(`${r}-${t.createHash(r).update(e).digest("base64")}`),"createTextHash"),createFileHash:i((e,r="sha384")=>new Promise(async(o,n)=>{try{if(!this._fsPolyfill)throw new Error("FS polyfill is required for file hashing");let s=t.createHash(r),c=this._fsPolyfill.createReadStream(e);c.on("data",f=>s.update(f)),c.on("end",()=>o(`${r}-${s.digest("base64")}`)),c.on("error",f=>n(f));}catch(s){n(s);}}),"createFileHash")};}initBrowser(){this._crypto={createFileHash:i(()=>(this.logger.warning("File hash not available in browser environment"),Promise.resolve("")),"createFileHash"),createTextHash:i((t,e="SHA-384")=>new Promise(async(r,o)=>{try{if(!crypto.subtle)throw new Error("SubtleCrypto not available");let s=new TextEncoder().encode(t),c=await crypto.subtle.digest(e,s),f=Array.from(new Uint8Array(c)),U=btoa(String.fromCharCode(...f));r(`${e}-${U}`);}catch(n){o(n);}}),"createTextHash")};}};i(Ge,"A_CryptoPolyfillClass");var me=Ge;var $e=class $e{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._http}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('http');this._http={request:t.request,get:t.get,createServer:t.createServer};}initBrowser(){this._http={request:i((t,e)=>(this.logger.warning("http.request not available in browser/test environment, use fetch instead"),this.createMockRequest(t,e,false)),"request"),get:i((t,e)=>(this.logger.warning("http.get not available in browser/test environment, use fetch instead"),this.createMockRequest(typeof t=="string"?{hostname:t}:t,e,false)),"get"),createServer:i(()=>(this.logger.error("http.createServer not available in browser/test environment"),null),"createServer")};}createMockRequest(t,e,r=false){return {end:i(()=>{if(e){let n={statusCode:200,headers:{},on:i((s,c)=>{s==="data"?setTimeout(()=>c("mock data"),0):s==="end"&&setTimeout(()=>c(),0);},"on"),pipe:i(s=>{s.write&&s.write("mock data"),s.end&&s.end();},"pipe")};setTimeout(()=>e(n),0);}},"end"),write:i(n=>{},"write"),on:i((n,s)=>{},"on")}}};i($e,"A_HttpPolyfillClass");var he=$e;var Ue=class Ue{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._https}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('https');this._https={request:t.request,get:t.get,createServer:t.createServer};}initBrowser(){this._https={request:i((t,e)=>(this.logger.warning("https.request not available in browser/test environment, use fetch instead"),this.createMockRequest(t,e,true)),"request"),get:i((t,e)=>(this.logger.warning("https.get not available in browser/test environment, use fetch instead"),this.createMockRequest(typeof t=="string"?{hostname:t}:t,e,true)),"get"),createServer:i(()=>(this.logger.error("https.createServer not available in browser/test environment"),null),"createServer")};}createMockRequest(t,e,r=true){return {end:i(()=>{if(e){let n={statusCode:200,headers:{},on:i((s,c)=>{s==="data"?setTimeout(()=>c("mock data"),0):s==="end"&&setTimeout(()=>c(),0);},"on"),pipe:i(s=>{s.write&&s.write("mock data"),s.end&&s.end();},"pipe")};setTimeout(()=>e(n),0);}},"end"),write:i(n=>{},"write"),on:i((n,s)=>{},"on")}}};i(Ue,"A_HttpsPolyfillClass");var fe=Ue;var ze=class ze{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._path}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){this._path=await import('path');}initBrowser(){this._path={join:i((...t)=>t.join("/").replace(/\/+/g,"/"),"join"),resolve:i((...t)=>{let e="";for(let r of t)r.startsWith("/")?e=r:e=this._path.join(e,r);return e||"/"},"resolve"),dirname:i(t=>t.split("/").slice(0,-1).join("/")||"/","dirname"),basename:i((t,e)=>{let r=t.split("/").pop()||"";return e&&r.endsWith(e)?r.slice(0,-e.length):r},"basename"),extname:i(t=>{let e=t.split(".");return e.length>1?"."+e.pop():""},"extname"),relative:i((t,e)=>e.replace(t,"").replace(/^\//,""),"relative"),normalize:i(t=>t.replace(/\/+/g,"/").replace(/\/$/,"")||"/","normalize"),isAbsolute:i(t=>t.startsWith("/")||/^[a-zA-Z]:/.test(t),"isAbsolute"),parse:i(t=>{let e=this._path.extname(t),r=this._path.basename(t),o=this._path.basename(t,e);return {root:"/",dir:this._path.dirname(t),base:r,ext:e,name:o}},"parse"),format:i(t=>this._path.join(t.dir||"",t.base||""),"format"),sep:"/",delimiter:":"};}};i(ze,"A_PathPolyfillClass");var ye=ze;var Fe=class Fe{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._url}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('url');this._url={parse:t.parse,format:t.format,resolve:t.resolve,URL:t.URL||globalThis.URL,URLSearchParams:t.URLSearchParams||globalThis.URLSearchParams};}initBrowser(){this._url={parse:i(t=>{try{let e=new URL(t);return {protocol:e.protocol,hostname:e.hostname,port:e.port,pathname:e.pathname,search:e.search,hash:e.hash,host:e.host,href:e.href}}catch{return {}}},"parse"),format:i(t=>{try{return new URL("",t.href||`${t.protocol}//${t.host}${t.pathname}${t.search}${t.hash}`).href}catch{return ""}},"format"),resolve:i((t,e)=>{try{return new URL(e,t).href}catch{return e}},"resolve"),URL:globalThis.URL,URLSearchParams:globalThis.URLSearchParams};}};i(Fe,"A_UrlPolyfillClass");var ge=Fe;var Be=class Be{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._buffer}async init(){try{aConcept.A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('buffer');this._buffer={from:t.Buffer.from,alloc:t.Buffer.alloc,allocUnsafe:t.Buffer.allocUnsafe,isBuffer:t.Buffer.isBuffer,concat:t.Buffer.concat};}initBrowser(){this._buffer={from:i((t,e)=>typeof t=="string"?new TextEncoder().encode(t):new Uint8Array(t),"from"),alloc:i((t,e)=>{let r=new Uint8Array(t);return e!==void 0&&r.fill(e),r},"alloc"),allocUnsafe:i(t=>new Uint8Array(t),"allocUnsafe"),isBuffer:i(t=>t instanceof Uint8Array||t instanceof ArrayBuffer,"isBuffer"),concat:i((t,e)=>{let r=e||t.reduce((s,c)=>s+c.length,0),o=new Uint8Array(r),n=0;for(let s of t)o.set(s,n),n+=s.length;return o},"concat")};}};i(Be,"A_BufferPolyfillClass");var ue=Be;var Ye=class Ye{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._process}async init(){try{aConcept.A_Context.environment==="server"?this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}initServer(){this._process={env:process.env,argv:process.argv,platform:process.platform,version:process.version,versions:process.versions,cwd:process.cwd,exit:process.exit,nextTick:process.nextTick};}initBrowser(){this._process={env:{NODE_ENV:"browser",...globalThis.process?.env||{}},argv:["browser"],platform:"browser",version:"browser",versions:{node:"browser"},cwd:i(()=>"/","cwd"),exit:i(t=>{throw this.logger.warning("process.exit not available in browser"),new Error(`Process exit with code ${t}`)},"exit"),nextTick:i((t,...e)=>{setTimeout(()=>t(...e),0);},"nextTick")};}};i(Ye,"A_ProcessPolyfillClass");var Ee=Ye;exports.A_Polyfill=class m extends aConcept.A_Component{constructor(e){super();this.logger=e;this._initializing=null;}get ready(){return this._initialized||(this._initialized=this._loadInternal()),this._initialized}async load(){await this.ready;}async attachToWindow(){aConcept.A_Context.environment==="browser"&&(globalThis.A_Polyfill=this,globalThis.process={env:{NODE_ENV:"production"},cwd:i(()=>"/","cwd")},globalThis.__dirname="/");}async _loadInternal(){this._fsPolyfill=new de(this.logger),this._cryptoPolyfill=new me(this.logger),this._httpPolyfill=new he(this.logger),this._httpsPolyfill=new fe(this.logger),this._pathPolyfill=new ye(this.logger),this._urlPolyfill=new ge(this.logger),this._bufferPolyfill=new ue(this.logger),this._processPolyfill=new Ee(this.logger),await this._fsPolyfill.get(),await this._cryptoPolyfill.get(await this._fsPolyfill.get()),await this._httpPolyfill.get(),await this._httpsPolyfill.get(),await this._pathPolyfill.get(),await this._urlPolyfill.get(),await this._bufferPolyfill.get(),await this._processPolyfill.get();}async fs(){return await this.ready,await this._fsPolyfill.get()}async crypto(){return await this.ready,await this._cryptoPolyfill.get()}async http(){return await this.ready,await this._httpPolyfill.get()}async https(){return await this.ready,await this._httpsPolyfill.get()}async path(){return await this.ready,await this._pathPolyfill.get()}async url(){return await this.ready,await this._urlPolyfill.get()}async buffer(){return await this.ready,await this._bufferPolyfill.get()}async process(){return await this.ready,await this._processPolyfill.get()}};i(exports.A_Polyfill,"A_Polyfill"),a([aConcept.A_Concept.Load()],exports.A_Polyfill.prototype,"load",1),a([aConcept.A_Concept.Load()],exports.A_Polyfill.prototype,"attachToWindow",1),exports.A_Polyfill=a([p(0,aConcept.A_Inject(exports.A_Logger))],exports.A_Polyfill);exports.ConfigReader=class A extends aConcept.A_Component{constructor(e){super();this.polyfill=e;this.DEFAULT_ALLOWED_TO_READ_PROPERTIES=[...aConcept.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...X];}async attachContext(e,r,o){o||(o=new g({defaults:{}}),e.scope.register(o));let n=await this.getProjectRoot();o.set("A_CONCEPT_ROOT_FOLDER",n);}async initialize(e){let r=await this.read();for(let o in r)e.set(o,r[o]);}resolve(e){return e}async read(e=[]){return {}}async getProjectRoot(e=__dirname){return (await this.polyfill.process()).cwd()}};i(exports.ConfigReader,"ConfigReader"),a([aConcept.A_Concept.Load(),p(0,aConcept.A_Inject(aConcept.A_Container)),p(1,aConcept.A_Inject(aConcept.A_Scope)),p(2,aConcept.A_Inject(g))],exports.ConfigReader.prototype,"attachContext",1),a([aConcept.A_Concept.Load(),p(0,aConcept.A_Dependency.Required()),p(0,aConcept.A_Inject(g))],exports.ConfigReader.prototype,"initialize",1),exports.ConfigReader=a([p(0,aConcept.A_Dependency.Required()),p(0,aConcept.A_Inject(exports.A_Polyfill))],exports.ConfigReader);var Ve=class Ve extends exports.ConfigReader{constructor(){super(...arguments);this.FileData=new Map;}getConfigurationProperty_File_Alias(e){return aConcept.A_FormatterHelper.toCamelCase(e)}resolve(e){return this.FileData.get(this.getConfigurationProperty_File_Alias(e))}async read(e){let r=await this.polyfill.fs();try{let o=r.readFileSync(`${aConcept.A_Context.concept}.conf.json`,"utf8"),n=JSON.parse(o);return this.FileData=new Map(Object.entries(n)),n}catch{return {}}}};i(Ve,"FileConfigReader");var se=Ve;var Te=class Te extends exports.ConfigReader{async readEnvFile(t,e,r){let o=await e.fs();o.existsSync(".env")&&o.readFileSync(`${t.get("A_CONCEPT_ROOT_FOLDER")}/.env`,"utf-8").split(`
|
|
44
|
+
`).forEach(n=>{let[s,c]=n.split("=");s&&c&&(process.env[s.trim()]=c.trim());});}getConfigurationProperty_ENV_Alias(t){return aConcept.A_FormatterHelper.toUpperSnakeCase(t)}resolve(t){return process.env[this.getConfigurationProperty_ENV_Alias(t)]}async read(t=[]){let e=[...t,...Object.keys(process.env)],r={};return e.forEach(o=>{r[o]=this.resolve(o);}),r}};i(Te,"ENVConfigReader"),a([aConcept.A_Concept.Load({before:["ENVConfigReader.initialize"]}),p(0,aConcept.A_Inject(g)),p(1,aConcept.A_Inject(exports.A_Polyfill)),p(2,aConcept.A_Inject(aConcept.A_Feature))],Te.prototype,"readEnvFile",1);var W=Te;var Ae=class Ae extends aConcept.A_Container{async prepare(t){if(!this.scope.has(g)){let r=new g({variables:[...aConcept.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...X],defaults:{}});this.scope.register(r);}let e=await t.fs();try{switch(!0){case(aConcept.A_Context.environment==="server"&&!!e.existsSync(`${aConcept.A_Context.concept}.conf.json`)):this.reader=this.scope.resolve(se);break;case(aConcept.A_Context.environment==="server"&&!e.existsSync(`${aConcept.A_Context.concept}.conf.json`)):this.reader=this.scope.resolve(W);break;case aConcept.A_Context.environment==="browser":this.reader=this.scope.resolve(W);break;default:throw new N(N.InitializationError,`Environment ${aConcept.A_Context.environment} is not supported`)}}catch(r){if(r instanceof aConcept.A_ScopeError)throw new N({title:N.InitializationError,description:`Failed to initialize A_ConfigLoader. Reader not found for environment ${aConcept.A_Context.environment}`,originalError:r})}}};i(Ae,"A_ConfigLoader"),a([aConcept.A_Concept.Load({before:/.*/}),p(0,aConcept.A_Inject(exports.A_Polyfill))],Ae.prototype,"prepare",1);var je=Ae;var Pr=(B=>B)(Pr||{});var Se={A_LOGGER_LEVEL:"A_LOGGER_LEVEL",A_LOGGER_DEFAULT_SCOPE_LENGTH:"A_LOGGER_DEFAULT_SCOPE_LENGTH",A_LOGGER_DEFAULT_SCOPE_COLOR:"A_LOGGER_DEFAULT_SCOPE_COLOR",A_LOGGER_DEFAULT_LOG_COLOR:"A_LOGGER_DEFAULT_LOG_COLOR"},$n=[Se.A_LOGGER_LEVEL,Se.A_LOGGER_DEFAULT_SCOPE_LENGTH,Se.A_LOGGER_DEFAULT_SCOPE_COLOR,Se.A_LOGGER_DEFAULT_LOG_COLOR];var xe=class xe extends aConcept.A_Error{};i(xe,"A_ManifestError"),xe.ManifestInitializationError="A-Manifest Initialization Error";var F=xe;var He=class He{constructor(t,e,r,o=false){this.manifest=t;this.component=e;this.method=r;this.checkExclusion=o;}for(t){let e=this.manifest.internal_checkAccess({component:this.component,method:this.method,target:t});return this.checkExclusion?!e:e}};i(He,"A_ManifestChecker");var Z=He;var Xe=class Xe extends aConcept.A_Fragment{constructor(e=[]){super({name:"A-Manifest"});this.rules=[];this.prepare(e);}prepare(e){if(!aConcept.A_TypeGuards.isArray(e))throw new F(F.ManifestInitializationError,"A-Manifest configuration should be an array of configurations");for(let r of e)this.processConfigItem(r);}processConfigItem(e){if(!aConcept.A_TypeGuards.isComponentConstructor(e.component))throw new F(F.ManifestInitializationError,"A-Manifest configuration item should be a A-Component constructor");let r=this.constructorToRegex(e.component);if(e.apply||e.exclude){let o=/.*/;this.rules.push({componentRegex:r,methodRegex:o,applyRegex:e.apply?this.allowedComponentsToRegex(e.apply):void 0,excludeRegex:e.exclude?this.allowedComponentsToRegex(e.exclude):void 0});}if(e.methods&&e.methods.length>0)for(let o of e.methods){let n=this.methodToRegex(o.method);this.rules.push({componentRegex:r,methodRegex:n,applyRegex:o.apply?this.allowedComponentsToRegex(o.apply):void 0,excludeRegex:o.exclude?this.allowedComponentsToRegex(o.exclude):void 0});}}constructorToRegex(e){return new RegExp(`^${this.escapeRegex(e.name)}$`)}methodToRegex(e){return e instanceof RegExp?e:new RegExp(`^${this.escapeRegex(e)}$`)}allowedComponentsToRegex(e){if(e instanceof RegExp)return e;let r=e.map(o=>this.escapeRegex(o.name));return new RegExp(`^(${r.join("|")})$`)}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}configItemToRegexp(e){return this.constructorToRegex(e)}ID(e,r){return `${e.name}.${r}`}isAllowed(e,r){let o=typeof e=="function"?e:e.constructor;return new Z(this,o,r)}internal_checkAccess(e){let r=e.component.name,o=e.method,n=e.target.name,s=this.rules.filter(c=>c.componentRegex.test(r)&&c.methodRegex.test(o)).sort((c,f)=>{let U=c.methodRegex.source===".*",l=f.methodRegex.source===".*";return U&&!l?1:!U&&l?-1:0});if(s.length===0)return true;for(let c of s){if(c.excludeRegex&&c.excludeRegex.test(n))return false;if(c.applyRegex)return c.applyRegex.test(n)}return true}isExcluded(e,r){let o=typeof e=="function"?e:e.constructor;return new Z(this,o,r,true)}};i(Xe,"A_Manifest");var Ke=Xe;var br=(l=>(l.onInit="_A_Memory_onInit",l.onDestroy="_A_Memory_onDestroy",l.onExpire="_A_Memory_onExpire",l.onError="_A_Memory_onError",l.onSerialize="_A_Memory_onSerialize",l.onSet="_A_Memory_onSet",l.onGet="_A_Memory_onGet",l.onDrop="_A_Memory_onDrop",l.onClear="_A_Memory_onClear",l.onHas="_A_Memory_onHas",l))(br||{});var Je=class Je extends aConcept.A_Fragment{constructor(){super(...arguments);this._storage=new Map;}set(e,r){this._storage.set(e,r);}get(e){return this._storage.get(e)}delete(e){this._storage.delete(e);}has(e){return this._storage.has(e)}clear(){this._storage.clear();}};i(Je,"A_MemoryContext");var R=Je;var O=class O extends aConcept.A_Error{};i(O,"A_MemoryError"),O.MemoryInitializationError="Memory initialization error",O.MemoryDestructionError="Memory destruction error",O.MemoryGetError="Memory GET operation failed",O.MemorySetError="Memory SET operation failed",O.MemoryDropError="Memory DROP operation failed",O.MemoryClearError="Memory CLEAR operation failed",O.MemoryHasError="Memory HAS operation failed",O.MemorySerializeError="Memory toJSON operation failed";var d=O;var Mr,Gr,$r,Ur,zr,Fr,Br,Yr,Vr,L=class L extends aConcept.A_Component{get ready(){return this._ready||(this._ready=this.init()),this._ready}async[Vr="_A_Memory_onError"](...t){}async[Yr="_A_Memory_onExpire"](...t){}async[Br="_A_Memory_onInit"](t,...e){t||(t=new R,aConcept.A_Context.scope(this).register(t));}async[Fr="_A_Memory_onDestroy"](t,...e){t.clear();}async[zr="_A_Memory_onGet"](t,e,...r){t.succeed(e.get(t.params.key));}async[Ur="_A_Memory_onHas"](t,e,...r){t.succeed(e.has(t.params.key));}async[$r="_A_Memory_onSet"](t,e,r,...o){console.log("A_Memory onSet called with key:",r.name),console.log("A_Memory onSet called with key:",r.parent?.name),e.set(t.params.key,t.params.value);}async[Gr="_A_Memory_onDrop"](t,e,...r){e.delete(t.params.key);}async[Mr="_A_Memory_onClear"](t,e,...r){e.clear();}async init(){if(this._ready)return this._ready;let t=new aConcept.A_Scope({name:"A-Memory-Init-Scope"}).inherit(aConcept.A_Context.scope(this));try{await this.call("_A_Memory_onInit",t);}catch(e){let r=new d({title:d.MemoryInitializationError,description:"An error occurred during memory initialization",originalError:e});throw t.register(r),await this.call("_A_Memory_onError",t),t.destroy(),r}}async destroy(){let t=new aConcept.A_Scope({name:"A-Memory-Destroy-Scope"}).inherit(aConcept.A_Context.scope(this));try{this._ready=void 0,await this.call("_A_Memory_onDestroy",t);}catch(e){let r=new d({title:d.MemoryDestructionError,description:"An error occurred during memory destruction",originalError:e});throw t.register(r),await this.call("_A_Memory_onError",t),t.destroy(),r}}async get(t){let e=new _("get",{key:t}),r=new aConcept.A_Scope({name:"A-Memory-Get-Operation-Scope",fragments:[e]}).inherit(aConcept.A_Context.scope(this));try{return await this.call("_A_Memory_onGet",r),r.destroy(),e.result}catch(o){let n=new d({title:d.MemoryGetError,description:`An error occurred while getting the value for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("_A_Memory_onError",r),r.destroy(),n}}async has(t){let e=new _("has",{key:t}),r=new aConcept.A_Scope({name:"A-Memory-Has-Operation-Scope",fragments:[e]}).inherit(aConcept.A_Context.scope(this));try{return await this.call("_A_Memory_onHas",r),r.destroy(),e.result}catch(o){let n=new d({title:d.MemoryHasError,description:`An error occurred while checking existence for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("_A_Memory_onError",r),r.destroy(),n}}async set(t,e){let r=new _("set",{key:t,value:e}),o=new aConcept.A_Scope({name:"A-Memory-Set-Operation-Scope",fragments:[r]}).inherit(aConcept.A_Context.scope(this));try{await this.call("_A_Memory_onSet",o);}catch(n){let s=new d({title:d.MemorySetError,description:`An error occurred while setting the value for key "${String(t)}"`,originalError:n});throw o.register(s),await this.call("_A_Memory_onError",o),o.destroy(),s}}async drop(t){let e=new _("drop",{key:t}),r=new aConcept.A_Scope({name:"A-Memory-Drop-Operation-Scope",fragments:[e]}).inherit(aConcept.A_Context.scope(this));try{await this.call("_A_Memory_onDrop",r);}catch(o){let n=new d({title:d.MemoryDropError,description:`An error occurred while dropping the value for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("_A_Memory_onError",r),r.destroy(),n}}async clear(){let t=new _("clear"),e=new aConcept.A_Scope({name:"A-Memory-Clear-Operation-Scope",fragments:[t]}).inherit(aConcept.A_Context.scope(this));try{await this.call("_A_Memory_onClear",e);}catch(r){let o=new d({title:d.MemoryClearError,description:"An error occurred while clearing the memory",originalError:r});throw e.register(o),await this.call("_A_Memory_onError",e),e.destroy(),o}}async toJSON(){let t=new _("serialize"),e=new aConcept.A_Scope({name:"A-Memory-Serialize-Operation-Scope",fragments:[t]}).inherit(aConcept.A_Context.scope(this));try{return await this.call("_A_Memory_onSerialize",e),t.result}catch(r){let o=new d({title:d.MemorySerializeError,description:"An error occurred while serializing the memory",originalError:r});throw e.register(o),await this.call("_A_Memory_onError",e),e.destroy(),o}}};i(L,"A_Memory"),a([aConcept.A_Feature.Extend()],L.prototype,Vr,1),a([aConcept.A_Feature.Extend()],L.prototype,Yr,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Inject(R))],L.prototype,Br,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Inject(R))],L.prototype,Fr,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Dependency.Required()),p(0,aConcept.A_Inject(_)),p(1,aConcept.A_Inject(R))],L.prototype,zr,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Dependency.Required()),p(0,aConcept.A_Inject(_)),p(1,aConcept.A_Inject(R))],L.prototype,Ur,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Dependency.Required()),p(0,aConcept.A_Inject(_)),p(1,aConcept.A_Inject(R)),p(2,aConcept.A_Inject(aConcept.A_Scope))],L.prototype,$r,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Dependency.Required()),p(0,aConcept.A_Inject(_)),p(1,aConcept.A_Inject(R))],L.prototype,Gr,1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Dependency.Required()),p(0,aConcept.A_Inject(_)),p(1,aConcept.A_Inject(R))],L.prototype,Mr,1);var We=L;var qr=(l=>(l.onBeforeLoad="_A_Service_onBeforeLoad",l.onLoad="_A_Service_onLoad",l.onAfterLoad="_A_Service_onAfterLoad",l.onBeforeStart="_A_Service_onBeforeStart",l.onStart="_A_Service_onStart",l.onAfterStart="_A_Service_onAfterStart",l.onBeforeStop="_A_Service_onBeforeStop",l.onStop="_A_Service_onStop",l.onAfterStop="_A_Service_onAfterStop",l.onError="_A_Service_onError",l))(qr||{});var Q=class Q extends aConcept.A_Error{};i(Q,"A_Service_Error"),Q.ServiceLoadError="Service load error",Q.ServiceStartError="Service start error",Q.ServiceStopError="Service stop error";var y=Q;var Kr,Xr,Jr,Wr,Zr,Qr,eo,to,ro,oo,h=class h extends aConcept.A_Container{async load(){try{await this.call("_A_Service_onBeforeLoad"),await this.call("_A_Service_onLoad"),await this.call("_A_Service_onAfterLoad");}catch(t){let e;switch(true){case t instanceof y:e=t;break;case(t instanceof aConcept.A_Error&&t.originalError instanceof y):e=t.originalError;break;default:e=new y({title:y.ServiceLoadError,description:"An error occurred while processing the request.",originalError:t});break}this.scope.register(e),await this.call("_A_Service_onError");}}async start(){try{await this.call("_A_Service_onBeforeStart"),await this.call("_A_Service_onStart"),await this.call("_A_Service_onAfterStart");}catch(t){let e;switch(true){case t instanceof y:e=t;break;case(t instanceof aConcept.A_Error&&t.originalError instanceof y):e=t.originalError;break;default:e=new y({title:y.ServiceStartError,description:"An error occurred while processing the request.",originalError:t});break}this.scope.register(e),await this.call("_A_Service_onError");}}async stop(){try{await this.call("_A_Service_onBeforeStop"),await this.call("_A_Service_onStop"),await this.call("_A_Service_onAfterStop");}catch(t){let e;switch(true){case t instanceof y:e=t;break;case(t instanceof aConcept.A_Error&&t.originalError instanceof y):e=t.originalError;break;default:e=new y({title:y.ServiceStopError,description:"An error occurred while processing the request.",originalError:t});break}this.scope.register(e),await this.call("_A_Service_onError");}}async[oo="_A_Service_onBeforeLoad"](t,...e){t||(this.scope.register(exports.A_Polyfill),t=this.scope.resolve(exports.A_Polyfill));}async[ro="_A_Service_onLoad"](...t){}async[to="_A_Service_onAfterLoad"](...t){}async[eo="_A_Service_onBeforeStart"](...t){}async[Qr="_A_Service_onStart"](...t){}async[Zr="_A_Service_onAfterStart"](...t){}async[Wr="_A_Service_onBeforeStop"](...t){}async[Jr="_A_Service_onStop"](...t){}async[Xr="_A_Service_onAfterStop"](...t){}async[Kr="_A_Service_onError"](t,e,...r){e?.error(t);}};i(h,"A_Service"),a([aConcept.A_Concept.Load()],h.prototype,"load",1),a([aConcept.A_Concept.Start()],h.prototype,"start",1),a([aConcept.A_Concept.Stop()],h.prototype,"stop",1),a([aConcept.A_Feature.Extend(),p(0,aConcept.A_Inject(exports.A_Polyfill))],h.prototype,oo,1),a([aConcept.A_Feature.Extend()],h.prototype,ro,1),a([aConcept.A_Feature.Extend()],h.prototype,to,1),a([aConcept.A_Feature.Extend()],h.prototype,eo,1),a([aConcept.A_Feature.Extend()],h.prototype,Qr,1),a([aConcept.A_Feature.Extend()],h.prototype,Zr,1),a([aConcept.A_Feature.Extend()],h.prototype,Wr,1),a([aConcept.A_Feature.Extend()],h.prototype,Jr,1),a([aConcept.A_Feature.Extend()],h.prototype,Xr,1),a([aConcept.A_Feature.Extend({before:/.*/}),p(0,aConcept.A_Inject(aConcept.A_Error)),p(1,aConcept.A_Inject(exports.A_Logger))],h.prototype,Kr,1);var et=h;var tt=class tt{constructor(){this.promise=new Promise((t,e)=>{this.resolveFn=t,this.rejectFn=e;});}resolve(t){this.resolveFn(t);}reject(t){this.rejectFn(t);}};i(tt,"A_Deferred");var ce=tt;var rt=class rt{constructor(t,e,r){this.config={resolveOnClear:false};r&&(this.config={...this.config,...r}),this.deferred=new ce,this.timeout=setTimeout(()=>e().then((...o)=>this.deferred.resolve(...o)).catch((...o)=>this.deferred.reject(...o)),t);}get promise(){return this.deferred.promise}clear(){this.timeout&&(clearTimeout(this.timeout),this.config.resolveOnClear?this.deferred.resolve(void 0):this.deferred.reject(new aConcept.A_Error("Timeout Cleared")));}};i(rt,"A_ScheduleObject");var ee=rt;var it=class it extends aConcept.A_Component{async schedule(t,e,r){let o=aConcept.A_TypeGuards.isString(t)?new Date(t).getTime():t;return new ee(o-Date.now(),e,r)}async delay(t,e,r){return new ee(t,e,r)}};i(it,"A_Schedule");var ot=it;exports.A_CONSTANTS__CONFIG_ENV_VARIABLES=Jo;exports.A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY=X;exports.A_Channel=Oe;exports.A_ChannelError=Y;exports.A_ChannelFeatures=xt;exports.A_ChannelRequest=te;exports.A_ChannelRequestStatuses=Ct;exports.A_Command=De;exports.A_CommandError=D;exports.A_CommandEvent=Pt;exports.A_CommandFeatures=vt;exports.A_CommandTransitions=Lt;exports.A_Command_Status=Rt;exports.A_Config=g;exports.A_ConfigError=N;exports.A_ConfigLoader=je;exports.A_Deferred=ce;exports.A_ExecutionContext=v;exports.A_LOGGER_ANSI=z;exports.A_LOGGER_COLORS=ct;exports.A_LOGGER_DEFAULT_LEVEL=ci;exports.A_LOGGER_DEFAULT_SCOPE_LENGTH=at;exports.A_LOGGER_ENV_KEYS=ie;exports.A_LOGGER_FORMAT=C;exports.A_LOGGER_SAFE_RANDOM_COLORS=pt;exports.A_LOGGER_TIME_FORMAT=J;exports.A_LoggerEnvVariables=Se;exports.A_LoggerEnvVariablesArray=$n;exports.A_Manifest=Ke;exports.A_ManifestChecker=Z;exports.A_ManifestError=F;exports.A_Memory=We;exports.A_MemoryContext=R;exports.A_MemoryError=d;exports.A_MemoryFeatures=br;exports.A_OperationContext=_;exports.A_Schedule=ot;exports.A_ScheduleObject=ee;exports.A_Service=et;exports.A_ServiceFeatures=qr;exports.A_StateMachine=b;exports.A_StateMachineError=K;exports.A_StateMachineFeatures=bt;exports.A_StateMachineTransition=P;exports.A_TYPES__ConfigFeature=Pr;exports.ENVConfigReader=W;exports.FileConfigReader=se;//# sourceMappingURL=index.cjs.map
|
|
45
45
|
//# sourceMappingURL=index.cjs.map
|