@adaas/a-utils 0.1.15 → 0.1.16

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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A_Inject, A_Scope, A_Feature, A_Concept, A_Container, A_Error, A_TypeGuards, A_Fragment, A_Component, A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY, A_CommonHelper, A_FormatterHelper, A_Context, A_IdentityHelper, A_Entity, A_ScopeError } from '@adaas/a-concept';
1
+ import { A_Inject, A_Scope, A_Feature, A_Concept, A_Container, A_Error, A_TypeGuards, A_Fragment, A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY, A_CommonHelper, A_FormatterHelper, A_Component, A_Context, A_IdentityHelper, A_Entity, A_ScopeError } from '@adaas/a-concept';
2
2
 
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -186,125 +186,352 @@ var A_Config = class extends A_Fragment {
186
186
  }
187
187
  };
188
188
 
189
+ // src/lib/A-Logger/A-Logger.constants.ts
190
+ var A_LOGGER_DEFAULT_SCOPE_LENGTH = 20;
191
+ var A_LOGGER_COLORS = {
192
+ green: "32",
193
+ // Success, completion messages
194
+ blue: "34",
195
+ // Info, general messages
196
+ red: "31",
197
+ // Errors, critical issues
198
+ yellow: "33",
199
+ // Warnings, caution messages
200
+ gray: "90",
201
+ // Debug, less important info
202
+ magenta: "35",
203
+ // Special highlighting
204
+ cyan: "36",
205
+ // Headers, titles
206
+ white: "37",
207
+ // Default text
208
+ pink: "95"
209
+ // Custom highlighting
210
+ };
211
+ var A_LOGGER_ANSI = {
212
+ RESET: "\x1B[0m",
213
+ PREFIX: "\x1B[",
214
+ SUFFIX: "m"
215
+ };
216
+ var A_LOGGER_TIME_FORMAT = {
217
+ MINUTES_PAD: 2,
218
+ SECONDS_PAD: 2,
219
+ MILLISECONDS_PAD: 3,
220
+ SEPARATOR: ":"
221
+ };
222
+ var A_LOGGER_FORMAT = {
223
+ SCOPE_OPEN: "[",
224
+ SCOPE_CLOSE: "]",
225
+ TIME_OPEN: "|",
226
+ TIME_CLOSE: "|",
227
+ SEPARATOR: "-------------------------------",
228
+ PIPE: "| "
229
+ };
230
+ var A_LOGGER_ENV_KEYS = {
231
+ LOG_LEVEL: "A_LOGGER_LEVEL"
232
+ };
233
+
189
234
  // src/lib/A-Logger/A-Logger.component.ts
190
235
  var A_Logger = class extends A_Component {
191
- constructor(scope) {
236
+ // =============================================
237
+ // Constructor and Initialization
238
+ // =============================================
239
+ /**
240
+ * Initialize A_Logger with dependency injection
241
+ *
242
+ * @param scope - The current scope context for message prefixing
243
+ * @param config - Optional configuration for log level filtering
244
+ */
245
+ constructor(scope, config) {
192
246
  super();
193
247
  this.scope = scope;
194
- this.colors = {
195
- green: "32",
196
- blue: "34",
197
- red: "31",
198
- yellow: "33",
199
- gray: "90",
200
- magenta: "35",
201
- cyan: "36",
202
- white: "37",
203
- pink: "95"
204
- };
205
- this.config = this.scope.has(A_Config) ? this.scope.resolve(A_Config) : void 0;
248
+ this.config = config;
249
+ this.COLORS = A_LOGGER_COLORS;
250
+ this.STANDARD_SCOPE_LENGTH = config?.get("A_LOGGER_DEFAULT_SCOPE_LENGTH") || A_LOGGER_DEFAULT_SCOPE_LENGTH;
206
251
  }
252
+ // =============================================
253
+ // Scope and Formatting Utilities
254
+ // =============================================
255
+ /**
256
+ * Get the formatted scope length for consistent message alignment
257
+ * Uses a standard length to ensure all messages align properly regardless of scope name
258
+ *
259
+ * @returns The scope length to use for padding calculations
260
+ */
207
261
  get scopeLength() {
208
- return this.scope.name.length;
262
+ return Math.max(this.scope.name.length, this.STANDARD_SCOPE_LENGTH);
209
263
  }
264
+ /**
265
+ * Get the formatted scope name with proper padding
266
+ * Ensures consistent width for all scope names in log output
267
+ *
268
+ * @returns Padded scope name for consistent formatting
269
+ */
270
+ get formattedScope() {
271
+ return this.scope.name.padEnd(this.STANDARD_SCOPE_LENGTH);
272
+ }
273
+ // =============================================
274
+ // Message Compilation and Formatting
275
+ // =============================================
276
+ /**
277
+ * Compile log arguments into formatted console output with colors and proper alignment
278
+ *
279
+ * This method handles the core formatting logic for all log messages:
280
+ * - Applies terminal color codes for visual distinction
281
+ * - Formats scope names with consistent padding
282
+ * - Handles different data types appropriately
283
+ * - Maintains proper indentation for multi-line content
284
+ *
285
+ * @param color - The color key to apply to the message
286
+ * @param args - Variable arguments to format and display
287
+ * @returns Array of formatted strings ready for console output
288
+ */
210
289
  compile(color, ...args) {
290
+ const timeString = this.getTime();
291
+ const scopePadding = " ".repeat(this.scopeLength + 3);
292
+ const isMultiArg = args.length > 1;
211
293
  return [
212
- `\x1B[${this.colors[color]}m[${this.scope.name}] |${this.getTime()}|`,
213
- args.length > 1 ? `
214
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------` : "",
294
+ // Header with color, scope, and timestamp
295
+ `${A_LOGGER_ANSI.PREFIX}${this.COLORS[color]}${A_LOGGER_ANSI.SUFFIX}${A_LOGGER_FORMAT.SCOPE_OPEN}${this.formattedScope}${A_LOGGER_FORMAT.SCOPE_CLOSE} ${A_LOGGER_FORMAT.TIME_OPEN}${timeString}${A_LOGGER_FORMAT.TIME_CLOSE}`,
296
+ // Top separator for multi-argument messages
297
+ isMultiArg ? `
298
+ ${scopePadding}${A_LOGGER_FORMAT.TIME_OPEN}${A_LOGGER_FORMAT.SEPARATOR}` : "",
299
+ // Process each argument with appropriate formatting
215
300
  ...args.map((arg, i) => {
301
+ const shouldAddNewline = i > 0 || isMultiArg;
216
302
  switch (true) {
217
303
  case arg instanceof A_Error:
218
304
  return this.compile_A_Error(arg);
219
305
  case arg instanceof Error:
220
306
  return this.compile_Error(arg);
221
- case typeof arg === "object":
222
- return JSON.stringify(arg, null, 2).replace(/\n/g, `
223
- ${" ".repeat(this.scopeLength + 3)}| `);
307
+ case (typeof arg === "object" && arg !== null):
308
+ return this.formatObject(arg, shouldAddNewline, scopePadding);
224
309
  default:
225
- return String(
226
- (i > 0 || args.length > 1 ? "\n" : "") + arg
227
- ).replace(/\n/g, `
228
- ${" ".repeat(this.scopeLength + 3)}| `);
310
+ return this.formatString(String(arg), shouldAddNewline, scopePadding);
229
311
  }
230
312
  }),
231
- args.length > 1 ? `
232
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------\x1B[0m` : "\x1B[0m"
313
+ // Bottom separator and color reset
314
+ isMultiArg ? `
315
+ ${scopePadding}${A_LOGGER_FORMAT.TIME_OPEN}${A_LOGGER_FORMAT.SEPARATOR}${A_LOGGER_ANSI.RESET}` : A_LOGGER_ANSI.RESET
233
316
  ];
234
317
  }
235
- get allowedToLog() {
236
- return this.config ? this.config.get("CONFIG_VERBOSE") !== void 0 && this.config.get("CONFIG_VERBOSE") !== "false" && this.config.get("CONFIG_VERBOSE") !== false : true;
318
+ /**
319
+ * Format an object for display with proper JSON indentation
320
+ *
321
+ * @param obj - The object to format
322
+ * @param shouldAddNewline - Whether to add a newline prefix
323
+ * @param scopePadding - The padding string for consistent alignment
324
+ * @returns Formatted object string
325
+ */
326
+ formatObject(obj, shouldAddNewline, scopePadding) {
327
+ let jsonString;
328
+ try {
329
+ jsonString = JSON.stringify(obj, null, 2);
330
+ } catch (error) {
331
+ const seen = /* @__PURE__ */ new WeakSet();
332
+ jsonString = JSON.stringify(obj, (key, value) => {
333
+ if (typeof value === "object" && value !== null) {
334
+ if (seen.has(value)) {
335
+ return "[Circular Reference]";
336
+ }
337
+ seen.add(value);
338
+ }
339
+ return value;
340
+ }, 2);
341
+ }
342
+ const formatted = jsonString.replace(/\n/g, `
343
+ ${scopePadding}${A_LOGGER_FORMAT.PIPE}`);
344
+ return shouldAddNewline ? `
345
+ ${scopePadding}${A_LOGGER_FORMAT.PIPE}` + formatted : formatted;
346
+ }
347
+ /**
348
+ * Format a string for display with proper indentation
349
+ *
350
+ * @param str - The string to format
351
+ * @param shouldAddNewline - Whether to add a newline prefix
352
+ * @param scopePadding - The padding string for consistent alignment
353
+ * @returns Formatted string
354
+ */
355
+ formatString(str, shouldAddNewline, scopePadding) {
356
+ const prefix = shouldAddNewline ? "\n" : "";
357
+ return (prefix + str).replace(/\n/g, `
358
+ ${scopePadding}${A_LOGGER_FORMAT.PIPE}`);
359
+ }
360
+ // =============================================
361
+ // Log Level Management
362
+ // =============================================
363
+ /**
364
+ * Determine if a log message should be output based on configured log level
365
+ *
366
+ * Log level hierarchy:
367
+ * - debug: Shows all messages
368
+ * - info: Shows info, warning, and error messages
369
+ * - warn: Shows warning and error messages only
370
+ * - error: Shows error messages only
371
+ * - all: Shows all messages (alias for debug)
372
+ *
373
+ * @param logMethod - The type of log method being called
374
+ * @returns True if the message should be logged, false otherwise
375
+ */
376
+ shouldLog(logMethod) {
377
+ const shouldLog = this.config?.get(A_LOGGER_ENV_KEYS.LOG_LEVEL) || "all";
378
+ switch (shouldLog) {
379
+ case "debug":
380
+ return true;
381
+ case "info":
382
+ return logMethod === "log" || logMethod === "warning" || logMethod === "error";
383
+ case "warn":
384
+ return logMethod === "warning" || logMethod === "error";
385
+ case "error":
386
+ return logMethod === "error";
387
+ case "all":
388
+ return true;
389
+ default:
390
+ return false;
391
+ }
237
392
  }
238
393
  log(param1, ...args) {
239
- if (!this.allowedToLog)
240
- return;
241
- if (typeof param1 === "string" && this.colors[param1]) {
394
+ if (!this.shouldLog("log")) return;
395
+ if (typeof param1 === "string" && this.COLORS[param1]) {
242
396
  console.log(...this.compile(param1, ...args));
243
- return;
244
397
  } else {
245
398
  console.log(...this.compile("blue", param1, ...args));
246
399
  }
247
400
  }
401
+ /**
402
+ * Log warning messages with yellow color coding
403
+ *
404
+ * Use for non-critical issues that should be brought to attention
405
+ * but don't prevent normal operation
406
+ *
407
+ * @param args - Arguments to log as warnings
408
+ *
409
+ * @example
410
+ * ```typescript
411
+ * logger.warning('Deprecated method used');
412
+ * logger.warning('Rate limit approaching:', { current: 95, limit: 100 });
413
+ * ```
414
+ */
248
415
  warning(...args) {
249
- if (!this.allowedToLog)
250
- return;
416
+ if (!this.shouldLog("warning")) return;
251
417
  console.log(...this.compile("yellow", ...args));
252
418
  }
419
+ /**
420
+ * Log error messages with red color coding
421
+ *
422
+ * Use for critical issues, exceptions, and failures that need immediate attention
423
+ *
424
+ * @param args - Arguments to log as errors
425
+ * @returns void (for compatibility with console.log)
426
+ *
427
+ * @example
428
+ * ```typescript
429
+ * logger.error('Database connection failed');
430
+ * logger.error(new Error('Validation failed'));
431
+ * logger.error('Critical error:', error, { context: 'user-registration' });
432
+ * ```
433
+ */
253
434
  error(...args) {
254
- if (this.config && this.config.get("CONFIG_IGNORE_ERRORS"))
255
- return;
256
- return console.log(...this.compile("red", ...args));
435
+ if (!this.shouldLog("error")) return;
436
+ console.log(...this.compile("red", ...args));
257
437
  }
438
+ // =============================================
439
+ // Specialized Error Formatting
440
+ // =============================================
441
+ /**
442
+ * Legacy method for A_Error logging (kept for backward compatibility)
443
+ *
444
+ * @deprecated Use error() method instead which handles A_Error automatically
445
+ * @param error - The A_Error instance to log
446
+ */
258
447
  log_A_Error(error) {
259
448
  const time = this.getTime();
260
- console.log(`\x1B[31m[${this.scope.name}] |${time}| ERROR ${error.code}
261
- ${" ".repeat(this.scopeLength + 3)}| ${error.message}
262
- ${" ".repeat(this.scopeLength + 3)}| ${error.description}
263
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------
264
- ${" ".repeat(this.scopeLength + 3)}| ${error.stack?.split("\n").map((line, index) => index === 0 ? line : `${" ".repeat(this.scopeLength + 3)}| ${line}`).join("\n") || "No stack trace"}
265
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------
266
- \x1B[0m` + (error.originalError ? `\x1B[31m${" ".repeat(this.scopeLength + 3)}| Wrapped From ${error.originalError.message}
267
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------
268
- ${" ".repeat(this.scopeLength + 3)}| ${error.originalError.stack?.split("\n").map((line, index) => index === 0 ? line : `${" ".repeat(this.scopeLength + 3)}| ${line}`).join("\n") || "No stack trace"}
269
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------
270
- \x1B[0m` : "") + (error.link ? `\x1B[31m${" ".repeat(this.scopeLength + 3)}| Read in docs: ${error.link}
271
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------
449
+ const scopePadding = " ".repeat(this.scopeLength + 3);
450
+ console.log(`\x1B[31m[${this.formattedScope}] |${time}| ERROR ${error.code}
451
+ ${scopePadding}| ${error.message}
452
+ ${scopePadding}| ${error.description}
453
+ ${scopePadding}|-------------------------------
454
+ ${scopePadding}| ${error.stack?.split("\n").map((line, index) => index === 0 ? line : `${scopePadding}| ${line}`).join("\n") || "No stack trace"}
455
+ ${scopePadding}|-------------------------------
456
+ \x1B[0m` + (error.originalError ? `\x1B[31m${scopePadding}| Wrapped From ${error.originalError.message}
457
+ ${scopePadding}|-------------------------------
458
+ ${scopePadding}| ${error.originalError.stack?.split("\n").map((line, index) => index === 0 ? line : `${scopePadding}| ${line}`).join("\n") || "No stack trace"}
459
+ ${scopePadding}|-------------------------------
460
+ \x1B[0m` : "") + (error.link ? `\x1B[31m${scopePadding}| Read in docs: ${error.link}
461
+ ${scopePadding}|-------------------------------
272
462
  \x1B[0m` : ""));
273
463
  }
464
+ /**
465
+ * Format A_Error instances for inline display within compiled messages
466
+ *
467
+ * Provides detailed formatting for A_Error objects including:
468
+ * - Error code and message
469
+ * - Description and stack trace
470
+ * - Original error information (if wrapped)
471
+ * - Documentation links (if available)
472
+ *
473
+ * @param error - The A_Error instance to format
474
+ * @returns Formatted string ready for display
475
+ */
274
476
  compile_A_Error(error) {
275
- this.getTime();
477
+ const scopePadding = " ".repeat(this.scopeLength + 3);
276
478
  return `
277
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------
278
- ${" ".repeat(this.scopeLength + 3)}| Error: | ${error.code}
279
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------
280
- ${" ".repeat(this.scopeLength + 3)}|${" ".repeat(10)}| ${error.message}
281
- ${" ".repeat(this.scopeLength + 3)}|${" ".repeat(10)}| ${error.description}
282
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------
283
- ${" ".repeat(this.scopeLength + 3)}| ${error.stack?.split("\n").map((line, index) => index === 0 ? line : `${" ".repeat(this.scopeLength + 3)}| ${line}`).join("\n") || "No stack trace"}
284
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------` + (error.originalError ? `${" ".repeat(this.scopeLength + 3)}| Wrapped From ${error.originalError.message}
285
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------
286
- ${" ".repeat(this.scopeLength + 3)}| ${error.originalError.stack?.split("\n").map((line, index) => index === 0 ? line : `${" ".repeat(this.scopeLength + 3)}| ${line}`).join("\n") || "No stack trace"}
287
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------` : "") + (error.link ? `${" ".repeat(this.scopeLength + 3)}| Read in docs: ${error.link}
288
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------` : "");
479
+ ${scopePadding}|-------------------------------
480
+ ${scopePadding}| Error: | ${error.code}
481
+ ${scopePadding}|-------------------------------
482
+ ${scopePadding}|${" ".repeat(10)}| ${error.message}
483
+ ${scopePadding}|${" ".repeat(10)}| ${error.description}
484
+ ${scopePadding}|-------------------------------
485
+ ${scopePadding}| ${error.stack?.split("\n").map((line, index) => index === 0 ? line : `${scopePadding}| ${line}`).join("\n") || "No stack trace"}
486
+ ${scopePadding}|-------------------------------` + (error.originalError ? `${scopePadding}| Wrapped From ${error.originalError.message}
487
+ ${scopePadding}|-------------------------------
488
+ ${scopePadding}| ${error.originalError.stack?.split("\n").map((line, index) => index === 0 ? line : `${scopePadding}| ${line}`).join("\n") || "No stack trace"}
489
+ ${scopePadding}|-------------------------------` : "") + (error.link ? `${scopePadding}| Read in docs: ${error.link}
490
+ ${scopePadding}|-------------------------------` : "");
289
491
  }
492
+ /**
493
+ * Format standard Error instances for inline display within compiled messages
494
+ *
495
+ * Converts standard JavaScript Error objects into a readable JSON format
496
+ * with proper indentation and stack trace formatting
497
+ *
498
+ * @param error - The Error instance to format
499
+ * @returns Formatted string ready for display
500
+ */
290
501
  compile_Error(error) {
502
+ const scopePadding = " ".repeat(this.scopeLength + 3);
291
503
  return JSON.stringify({
292
504
  name: error.name,
293
505
  message: error.message,
294
- stack: error.stack?.split("\n").map((line, index) => index === 0 ? line : `${" ".repeat(this.scopeLength + 3)}| ${line}`).join("\n")
506
+ stack: error.stack?.split("\n").map((line, index) => index === 0 ? line : `${scopePadding}| ${line}`).join("\n")
295
507
  }, null, 2).replace(/\n/g, `
296
- ${" ".repeat(this.scopeLength + 3)}| `).replace(/\\n/g, "\n");
508
+ ${scopePadding}| `).replace(/\\n/g, "\n");
297
509
  }
510
+ // =============================================
511
+ // Utility Methods
512
+ // =============================================
513
+ /**
514
+ * Generate timestamp string for log messages
515
+ *
516
+ * Format: MM:SS:mmm (minutes:seconds:milliseconds)
517
+ * This provides sufficient precision for debugging while remaining readable
518
+ *
519
+ * @returns Formatted timestamp string
520
+ *
521
+ * @example
522
+ * Returns: "15:42:137" for 3:42:15 PM and 137 milliseconds
523
+ */
298
524
  getTime() {
299
525
  const now = /* @__PURE__ */ new Date();
300
- const minutes = String(now.getMinutes()).padStart(2, "0");
301
- const seconds = String(now.getSeconds()).padStart(2, "0");
302
- const milliseconds = String(now.getMilliseconds()).padStart(4, "0");
303
- return `${minutes}:${seconds}:${milliseconds}`;
526
+ const minutes = String(now.getMinutes()).padStart(A_LOGGER_TIME_FORMAT.MINUTES_PAD, "0");
527
+ const seconds = String(now.getSeconds()).padStart(A_LOGGER_TIME_FORMAT.SECONDS_PAD, "0");
528
+ const milliseconds = String(now.getMilliseconds()).padStart(A_LOGGER_TIME_FORMAT.MILLISECONDS_PAD, "0");
529
+ return `${minutes}${A_LOGGER_TIME_FORMAT.SEPARATOR}${seconds}${A_LOGGER_TIME_FORMAT.SEPARATOR}${milliseconds}`;
304
530
  }
305
531
  };
306
532
  A_Logger = __decorateClass([
307
- __decorateParam(0, A_Inject(A_Scope))
533
+ __decorateParam(0, A_Inject(A_Scope)),
534
+ __decorateParam(1, A_Inject(A_Config))
308
535
  ], A_Logger);
309
536
 
310
537
  // src/lib/A-Channel/A-Channel.component.ts
@@ -613,12 +840,6 @@ __decorateClass([
613
840
  ], GlobalErrorhandler.prototype, "anotherError", 1);
614
841
 
615
842
  // src/lib/A-Command/A-Command.constants.ts
616
- var A_TYPES__CommandMetaKey = /* @__PURE__ */ ((A_TYPES__CommandMetaKey2) => {
617
- A_TYPES__CommandMetaKey2["EXTENSIONS"] = "a-command-extensions";
618
- A_TYPES__CommandMetaKey2["FEATURES"] = "a-command-features";
619
- A_TYPES__CommandMetaKey2["ABSTRACTIONS"] = "a-command-abstractions";
620
- return A_TYPES__CommandMetaKey2;
621
- })(A_TYPES__CommandMetaKey || {});
622
843
  var A_CONSTANTS__A_Command_Status = /* @__PURE__ */ ((A_CONSTANTS__A_Command_Status2) => {
623
844
  A_CONSTANTS__A_Command_Status2["CREATED"] = "CREATED";
624
845
  A_CONSTANTS__A_Command_Status2["INITIALIZATION"] = "INITIALIZATION";
@@ -630,14 +851,14 @@ var A_CONSTANTS__A_Command_Status = /* @__PURE__ */ ((A_CONSTANTS__A_Command_Sta
630
851
  A_CONSTANTS__A_Command_Status2["FAILED"] = "FAILED";
631
852
  return A_CONSTANTS__A_Command_Status2;
632
853
  })(A_CONSTANTS__A_Command_Status || {});
633
- var A_CONSTANTS_A_Command_Features = /* @__PURE__ */ ((A_CONSTANTS_A_Command_Features2) => {
634
- A_CONSTANTS_A_Command_Features2["INIT"] = "init";
635
- A_CONSTANTS_A_Command_Features2["COMPLIED"] = "complied";
636
- A_CONSTANTS_A_Command_Features2["EXECUTE"] = "execute";
637
- A_CONSTANTS_A_Command_Features2["COMPLETE"] = "complete";
638
- A_CONSTANTS_A_Command_Features2["FAIL"] = "fail";
639
- return A_CONSTANTS_A_Command_Features2;
640
- })(A_CONSTANTS_A_Command_Features || {});
854
+ var A_CommandFeatures = /* @__PURE__ */ ((A_CommandFeatures2) => {
855
+ A_CommandFeatures2["onInit"] = "onInit";
856
+ A_CommandFeatures2["onCompile"] = "onCompile";
857
+ A_CommandFeatures2["onExecute"] = "onExecute";
858
+ A_CommandFeatures2["onComplete"] = "onComplete";
859
+ A_CommandFeatures2["onFail"] = "onFail";
860
+ return A_CommandFeatures2;
861
+ })(A_CommandFeatures || {});
641
862
  var A_Memory = class extends A_Fragment {
642
863
  /**
643
864
  * Memory object that allows to store intermediate values and errors
@@ -658,7 +879,7 @@ var A_Memory = class extends A_Fragment {
658
879
  * @param requiredKeys
659
880
  * @returns
660
881
  */
661
- async verifyPrerequisites(requiredKeys) {
882
+ async prerequisites(requiredKeys) {
662
883
  return requiredKeys.every((key) => this._memory.has(key));
663
884
  }
664
885
  /**
@@ -824,9 +1045,8 @@ var A_Command = class extends A_Entity {
824
1045
  }
825
1046
  this._status = "INITIALIZATION" /* INITIALIZATION */;
826
1047
  this._startTime = /* @__PURE__ */ new Date();
827
- this.checkScopeInheritance();
828
- this.emit("init");
829
- await this.call("init", this.scope);
1048
+ this.emit("onInit" /* onInit */);
1049
+ await this.call("onInit" /* onInit */, this.scope);
830
1050
  this._status = "INITIALIZED" /* INITIALIZED */;
831
1051
  }
832
1052
  // Should compile everything before execution
@@ -836,8 +1056,8 @@ var A_Command = class extends A_Entity {
836
1056
  }
837
1057
  this.checkScopeInheritance();
838
1058
  this._status = "COMPILATION" /* COMPILATION */;
839
- this.emit("compile");
840
- await this.call("compile", this.scope);
1059
+ this.emit("onCompile" /* onCompile */);
1060
+ await this.call("onCompile" /* onCompile */, this.scope);
841
1061
  this._status = "COMPILED" /* COMPILED */;
842
1062
  }
843
1063
  /**
@@ -850,8 +1070,8 @@ var A_Command = class extends A_Entity {
850
1070
  return;
851
1071
  this._status = "IN_PROGRESS" /* IN_PROGRESS */;
852
1072
  this.checkScopeInheritance();
853
- this.emit("execute");
854
- await this.call("execute", this.scope);
1073
+ this.emit("onExecute" /* onExecute */);
1074
+ await this.call("onExecute" /* onExecute */, this.scope);
855
1075
  }
856
1076
  /**
857
1077
  * Executes the command logic.
@@ -866,6 +1086,7 @@ var A_Command = class extends A_Entity {
866
1086
  } catch (error) {
867
1087
  await this.fail();
868
1088
  }
1089
+ this._executionScope.destroy();
869
1090
  }
870
1091
  /**
871
1092
  * Marks the command as completed
@@ -875,8 +1096,8 @@ var A_Command = class extends A_Entity {
875
1096
  this._status = "COMPLETED" /* COMPLETED */;
876
1097
  this._endTime = /* @__PURE__ */ new Date();
877
1098
  this._result = this.scope.resolve(A_Memory).toJSON();
878
- this.emit("complete");
879
- return await this.call("complete", this.scope);
1099
+ this.emit("onComplete" /* onComplete */);
1100
+ await this.call("onComplete" /* onComplete */, this.scope);
880
1101
  }
881
1102
  /**
882
1103
  * Marks the command as failed
@@ -886,8 +1107,8 @@ var A_Command = class extends A_Entity {
886
1107
  this._status = "FAILED" /* FAILED */;
887
1108
  this._endTime = /* @__PURE__ */ new Date();
888
1109
  this._errors = this.scope.resolve(A_Memory).Errors;
889
- this.emit("fail");
890
- return await this.call("fail", this.scope);
1110
+ this.emit("onFail" /* onFail */);
1111
+ await this.call("onFail" /* onFail */, this.scope);
891
1112
  }
892
1113
  // --------------------------------------------------------------------------
893
1114
  // A-Command Event-Emitter methods
@@ -1714,18 +1935,17 @@ var ConfigReader = class extends A_Component {
1714
1935
  super();
1715
1936
  this.polyfill = polyfill;
1716
1937
  }
1717
- async attachContext(container, feature) {
1718
- if (!container.scope.has(A_Config)) {
1719
- const newConfig = new A_Config({
1938
+ async attachContext(container, feature, config) {
1939
+ if (!config) {
1940
+ config = new A_Config({
1720
1941
  variables: [
1721
1942
  ...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,
1722
1943
  ...A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY
1723
1944
  ],
1724
1945
  defaults: {}
1725
1946
  });
1726
- container.scope.register(newConfig);
1947
+ container.scope.register(config);
1727
1948
  }
1728
- const config = container.scope.resolve(A_Config);
1729
1949
  const rootDir = await this.getProjectRoot();
1730
1950
  config.set("A_CONCEPT_ROOT_FOLDER", rootDir);
1731
1951
  }
@@ -1765,7 +1985,8 @@ var ConfigReader = class extends A_Component {
1765
1985
  __decorateClass([
1766
1986
  A_Concept.Load(),
1767
1987
  __decorateParam(0, A_Inject(A_Container)),
1768
- __decorateParam(1, A_Inject(A_Feature))
1988
+ __decorateParam(1, A_Inject(A_Feature)),
1989
+ __decorateParam(2, A_Inject(A_Config))
1769
1990
  ], ConfigReader.prototype, "attachContext", 1);
1770
1991
  __decorateClass([
1771
1992
  A_Concept.Load(),
@@ -2147,6 +2368,6 @@ var A_Schedule = class extends A_Component {
2147
2368
  }
2148
2369
  };
2149
2370
 
2150
- export { A_CONSTANTS_A_Command_Features, A_CONSTANTS__A_Command_Status, A_CONSTANTS__CONFIG_ENV_VARIABLES, A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY, A_Channel, A_ChannelError, A_ChannelFeatures, A_ChannelRequest, A_ChannelRequestStatuses, A_Command, A_CommandError, A_Config, A_ConfigError, A_ConfigLoader, A_Deferred, A_Logger, A_Manifest, A_ManifestChecker, A_ManifestError, A_Memory, A_Polyfill, A_Schedule, A_ScheduleObject, A_TYPES__CommandMetaKey, A_TYPES__ConfigFeature, ConfigReader, ENVConfigReader, FileConfigReader };
2371
+ export { A_CONSTANTS__A_Command_Status, A_CONSTANTS__CONFIG_ENV_VARIABLES, A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY, A_Channel, A_ChannelError, A_ChannelFeatures, A_ChannelRequest, A_ChannelRequestStatuses, A_Command, A_CommandError, A_CommandFeatures, A_Config, A_ConfigError, A_ConfigLoader, A_Deferred, A_Logger, A_Manifest, A_ManifestChecker, A_ManifestError, A_Memory, A_Polyfill, A_Schedule, A_ScheduleObject, A_TYPES__ConfigFeature, ConfigReader, ENVConfigReader, FileConfigReader };
2151
2372
  //# sourceMappingURL=index.mjs.map
2152
2373
  //# sourceMappingURL=index.mjs.map