@adaas/a-utils 0.1.15 → 0.1.17

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