@adaas/a-utils 0.1.14 → 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/README.md +92 -18
- package/dist/index.d.mts +335 -71
- package/dist/index.d.ts +335 -71
- package/dist/index.js +491 -210
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +489 -210
- package/dist/index.mjs.map +1 -1
- package/examples/{channel-examples.ts → A-Channel-examples.ts} +15 -15
- package/examples/{command-examples.ts → A-Command-examples.ts} +47 -45
- package/examples/A-Logger-examples.ts +308 -0
- package/examples/config.ts +1 -1
- package/package.json +26 -7
- package/src/index.ts +3 -1
- package/src/lib/A-Channel/A-Channel.component.ts +84 -17
- package/src/lib/A-Channel/A-Channel.error.ts +5 -5
- package/src/lib/A-Channel/A-ChannelRequest.context.ts +1 -1
- package/src/lib/A-Channel/README.md +24 -24
- package/src/lib/A-Command/A-Command.constants.ts +49 -13
- package/src/lib/A-Command/A-Command.entity.ts +21 -15
- package/src/lib/A-Command/A-Command.types.ts +2 -35
- package/src/lib/A-Config/A-Config.container.ts +3 -3
- package/src/lib/A-Config/components/ConfigReader.component.ts +4 -6
- package/src/lib/A-Logger/A-Logger.component.ts +369 -130
- package/src/lib/A-Logger/A-Logger.constants.ts +69 -0
- package/src/lib/A-Logger/A-Logger.env.ts +27 -0
- package/src/lib/A-Logger/A-Logger.types.ts +3 -0
- package/src/lib/A-Logger/README.md +383 -0
- package/src/lib/A-Manifest/A-Manifest.types.ts +1 -2
- package/src/lib/A-Memory/A-Memory.context.ts +1 -1
- package/tests/A-Channel.test.ts +14 -14
- package/tests/A-Command.test.ts +26 -26
- package/tests/A-Logger.test.ts +520 -0
- package/tests/A-Memory.test.ts +5 -5
- package/tests/A-Polyfill.test.ts +3 -2
package/dist/index.js
CHANGED
|
@@ -13,7 +13,32 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
13
13
|
return result;
|
|
14
14
|
};
|
|
15
15
|
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
// src/lib/A-Channel/A-Channel.constants.ts
|
|
18
|
+
var A_ChannelFeatures = /* @__PURE__ */ ((A_ChannelFeatures2) => {
|
|
19
|
+
A_ChannelFeatures2["onTimeout"] = "onTimeout";
|
|
20
|
+
A_ChannelFeatures2["onRetry"] = "onRetry";
|
|
21
|
+
A_ChannelFeatures2["onCircuitBreakerOpen"] = "onCircuitBreakerOpen";
|
|
22
|
+
A_ChannelFeatures2["onCache"] = "onCache";
|
|
23
|
+
A_ChannelFeatures2["onConnect"] = "onConnect";
|
|
24
|
+
A_ChannelFeatures2["onDisconnect"] = "onDisconnect";
|
|
25
|
+
A_ChannelFeatures2["onBeforeRequest"] = "onBeforeRequest";
|
|
26
|
+
A_ChannelFeatures2["onRequest"] = "onRequest";
|
|
27
|
+
A_ChannelFeatures2["onAfterRequest"] = "onAfterRequest";
|
|
28
|
+
A_ChannelFeatures2["onError"] = "onError";
|
|
29
|
+
A_ChannelFeatures2["onSend"] = "onSend";
|
|
30
|
+
A_ChannelFeatures2["onConsume"] = "onConsume";
|
|
31
|
+
return A_ChannelFeatures2;
|
|
32
|
+
})(A_ChannelFeatures || {});
|
|
33
|
+
var A_ChannelRequestStatuses = /* @__PURE__ */ ((A_ChannelRequestStatuses2) => {
|
|
34
|
+
A_ChannelRequestStatuses2["PENDING"] = "PENDING";
|
|
35
|
+
A_ChannelRequestStatuses2["SUCCESS"] = "SUCCESS";
|
|
36
|
+
A_ChannelRequestStatuses2["FAILED"] = "FAILED";
|
|
37
|
+
return A_ChannelRequestStatuses2;
|
|
38
|
+
})(A_ChannelRequestStatuses || {});
|
|
39
|
+
|
|
40
|
+
// src/lib/A-Channel/A-ChannelRequest.context.ts
|
|
41
|
+
var A_ChannelRequest = class extends aConcept.A_Fragment {
|
|
17
42
|
constructor(params = {}) {
|
|
18
43
|
super();
|
|
19
44
|
this._errors = /* @__PURE__ */ new Set();
|
|
@@ -97,7 +122,7 @@ var A_ChannelError = class extends aConcept.A_Error {
|
|
|
97
122
|
super(originalError, context);
|
|
98
123
|
else
|
|
99
124
|
super(originalError);
|
|
100
|
-
if (context instanceof
|
|
125
|
+
if (context instanceof A_ChannelRequest)
|
|
101
126
|
this._context = context;
|
|
102
127
|
}
|
|
103
128
|
/***
|
|
@@ -112,6 +137,405 @@ var A_ChannelError = class extends aConcept.A_Error {
|
|
|
112
137
|
// ==========================================================
|
|
113
138
|
A_ChannelError.MethodNotImplemented = "A-Channel Method Not Implemented";
|
|
114
139
|
|
|
140
|
+
// src/lib/A-Config/A-Config.constants.ts
|
|
141
|
+
var A_CONSTANTS__CONFIG_ENV_VARIABLES = {};
|
|
142
|
+
var A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY = [];
|
|
143
|
+
|
|
144
|
+
// src/lib/A-Config/A-Config.context.ts
|
|
145
|
+
var A_Config = class extends aConcept.A_Fragment {
|
|
146
|
+
constructor(config) {
|
|
147
|
+
super({
|
|
148
|
+
name: "A_Config"
|
|
149
|
+
});
|
|
150
|
+
this.VARIABLES = /* @__PURE__ */ new Map();
|
|
151
|
+
this.DEFAULT_ALLOWED_TO_READ_PROPERTIES = [
|
|
152
|
+
...aConcept.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,
|
|
153
|
+
...A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY
|
|
154
|
+
];
|
|
155
|
+
this.config = aConcept.A_CommonHelper.deepCloneAndMerge(config, {
|
|
156
|
+
strict: false,
|
|
157
|
+
defaults: {},
|
|
158
|
+
variables: aConcept.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY
|
|
159
|
+
});
|
|
160
|
+
this.CONFIG_PROPERTIES = this.config.variables ? this.config.variables : [];
|
|
161
|
+
this.config.variables.forEach((variable) => {
|
|
162
|
+
this.VARIABLES.set(
|
|
163
|
+
aConcept.A_FormatterHelper.toUpperSnakeCase(variable),
|
|
164
|
+
this.config.defaults[variable]
|
|
165
|
+
);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* This method is used to get the configuration property by name
|
|
170
|
+
*
|
|
171
|
+
* @param property
|
|
172
|
+
* @returns
|
|
173
|
+
*/
|
|
174
|
+
get(property) {
|
|
175
|
+
if (this.CONFIG_PROPERTIES.includes(property) || this.DEFAULT_ALLOWED_TO_READ_PROPERTIES.includes(property) || !this.config.strict)
|
|
176
|
+
return this.VARIABLES.get(aConcept.A_FormatterHelper.toUpperSnakeCase(property));
|
|
177
|
+
throw new Error("Property not exists or not allowed to read");
|
|
178
|
+
}
|
|
179
|
+
set(property, value) {
|
|
180
|
+
const array = Array.isArray(property) ? property : typeof property === "string" ? [{ property, value }] : Object.keys(property).map((key) => ({
|
|
181
|
+
property: key,
|
|
182
|
+
value: property[key]
|
|
183
|
+
}));
|
|
184
|
+
for (const { property: property2, value: value2 } of array) {
|
|
185
|
+
let targetValue = value2 ? value2 : this.config?.defaults ? this.config.defaults[property2] : void 0;
|
|
186
|
+
this.VARIABLES.set(aConcept.A_FormatterHelper.toUpperSnakeCase(property2), targetValue);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
};
|
|
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
|
+
|
|
236
|
+
// src/lib/A-Logger/A-Logger.component.ts
|
|
237
|
+
exports.A_Logger = class A_Logger extends aConcept.A_Component {
|
|
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) {
|
|
248
|
+
super();
|
|
249
|
+
this.scope = scope;
|
|
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;
|
|
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
|
+
*/
|
|
263
|
+
get scopeLength() {
|
|
264
|
+
return Math.max(this.scope.name.length, this.STANDARD_SCOPE_LENGTH);
|
|
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
|
+
*/
|
|
291
|
+
compile(color, ...args) {
|
|
292
|
+
const timeString = this.getTime();
|
|
293
|
+
const scopePadding = " ".repeat(this.scopeLength + 3);
|
|
294
|
+
const isMultiArg = args.length > 1;
|
|
295
|
+
return [
|
|
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
|
|
302
|
+
...args.map((arg, i) => {
|
|
303
|
+
const shouldAddNewline = i > 0 || isMultiArg;
|
|
304
|
+
switch (true) {
|
|
305
|
+
case arg instanceof aConcept.A_Error:
|
|
306
|
+
return this.compile_A_Error(arg);
|
|
307
|
+
case arg instanceof Error:
|
|
308
|
+
return this.compile_Error(arg);
|
|
309
|
+
case (typeof arg === "object" && arg !== null):
|
|
310
|
+
return this.formatObject(arg, shouldAddNewline, scopePadding);
|
|
311
|
+
default:
|
|
312
|
+
return this.formatString(String(arg), shouldAddNewline, scopePadding);
|
|
313
|
+
}
|
|
314
|
+
}),
|
|
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
|
|
318
|
+
];
|
|
319
|
+
}
|
|
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
|
+
}
|
|
394
|
+
}
|
|
395
|
+
log(param1, ...args) {
|
|
396
|
+
if (!this.shouldLog("log")) return;
|
|
397
|
+
if (typeof param1 === "string" && this.COLORS[param1]) {
|
|
398
|
+
console.log(...this.compile(param1, ...args));
|
|
399
|
+
} else {
|
|
400
|
+
console.log(...this.compile("blue", param1, ...args));
|
|
401
|
+
}
|
|
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
|
+
*/
|
|
417
|
+
warning(...args) {
|
|
418
|
+
if (!this.shouldLog("warning")) return;
|
|
419
|
+
console.log(...this.compile("yellow", ...args));
|
|
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
|
+
*/
|
|
436
|
+
error(...args) {
|
|
437
|
+
if (!this.shouldLog("error")) return;
|
|
438
|
+
console.log(...this.compile("red", ...args));
|
|
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
|
+
*/
|
|
449
|
+
log_A_Error(error) {
|
|
450
|
+
const time = this.getTime();
|
|
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}|-------------------------------
|
|
464
|
+
\x1B[0m` : ""));
|
|
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
|
+
*/
|
|
478
|
+
compile_A_Error(error) {
|
|
479
|
+
const scopePadding = " ".repeat(this.scopeLength + 3);
|
|
480
|
+
return `
|
|
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}|-------------------------------` : "");
|
|
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
|
+
*/
|
|
503
|
+
compile_Error(error) {
|
|
504
|
+
const scopePadding = " ".repeat(this.scopeLength + 3);
|
|
505
|
+
return JSON.stringify({
|
|
506
|
+
name: error.name,
|
|
507
|
+
message: error.message,
|
|
508
|
+
stack: error.stack?.split("\n").map((line, index) => index === 0 ? line : `${scopePadding}| ${line}`).join("\n")
|
|
509
|
+
}, null, 2).replace(/\n/g, `
|
|
510
|
+
${scopePadding}| `).replace(/\\n/g, "\n");
|
|
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
|
+
*/
|
|
526
|
+
getTime() {
|
|
527
|
+
const now = /* @__PURE__ */ new Date();
|
|
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}`;
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
exports.A_Logger = __decorateClass([
|
|
535
|
+
__decorateParam(0, aConcept.A_Inject(aConcept.A_Scope)),
|
|
536
|
+
__decorateParam(1, aConcept.A_Inject(A_Config))
|
|
537
|
+
], exports.A_Logger);
|
|
538
|
+
|
|
115
539
|
// src/lib/A-Channel/A-Channel.component.ts
|
|
116
540
|
var A_Channel = class extends aConcept.A_Component {
|
|
117
541
|
/**
|
|
@@ -218,7 +642,7 @@ var A_Channel = class extends aConcept.A_Component {
|
|
|
218
642
|
* @template _ParamsType The type of request parameters
|
|
219
643
|
* @template _ResultType The type of response data
|
|
220
644
|
* @param params The request parameters
|
|
221
|
-
* @returns {Promise<
|
|
645
|
+
* @returns {Promise<A_ChannelRequest<_ParamsType, _ResultType>>} Request context with response
|
|
222
646
|
*
|
|
223
647
|
* @example
|
|
224
648
|
* ```typescript
|
|
@@ -244,7 +668,7 @@ var A_Channel = class extends aConcept.A_Component {
|
|
|
244
668
|
const requestScope = new aConcept.A_Scope({
|
|
245
669
|
name: `a-channel@scope:request:${aConcept.A_IdentityHelper.generateTimeId()}`
|
|
246
670
|
});
|
|
247
|
-
const context = new
|
|
671
|
+
const context = new A_ChannelRequest(params);
|
|
248
672
|
try {
|
|
249
673
|
requestScope.inherit(aConcept.A_Context.scope(this));
|
|
250
674
|
requestScope.register(context);
|
|
@@ -309,7 +733,7 @@ var A_Channel = class extends aConcept.A_Component {
|
|
|
309
733
|
const requestScope = new aConcept.A_Scope({
|
|
310
734
|
name: `a-channel@scope:send:${aConcept.A_IdentityHelper.generateTimeId()}`
|
|
311
735
|
});
|
|
312
|
-
const context = new
|
|
736
|
+
const context = new A_ChannelRequest(message);
|
|
313
737
|
try {
|
|
314
738
|
requestScope.inherit(aConcept.A_Context.scope(this));
|
|
315
739
|
requestScope.register(context);
|
|
@@ -334,7 +758,7 @@ var A_Channel = class extends aConcept.A_Component {
|
|
|
334
758
|
await this.initialize;
|
|
335
759
|
this._processing = true;
|
|
336
760
|
const requestScope = new aConcept.A_Scope({ name: `a-channel@scope:consume:${aConcept.A_IdentityHelper.generateTimeId()}` });
|
|
337
|
-
const context = new
|
|
761
|
+
const context = new A_ChannelRequest();
|
|
338
762
|
try {
|
|
339
763
|
requestScope.inherit(aConcept.A_Context.scope(this));
|
|
340
764
|
requestScope.register(context);
|
|
@@ -385,14 +809,39 @@ __decorateClass([
|
|
|
385
809
|
name: "onSend" /* onSend */
|
|
386
810
|
})
|
|
387
811
|
], A_Channel.prototype, "onSend", 1);
|
|
812
|
+
var HttpChannel = class extends A_Channel {
|
|
813
|
+
};
|
|
814
|
+
var PollyspotChannel = class extends HttpChannel {
|
|
815
|
+
constructor() {
|
|
816
|
+
super();
|
|
817
|
+
this.baseUrl = "https://pollyspot.example.com";
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
var GlobalErrorhandler = class extends aConcept.A_Component {
|
|
821
|
+
async handleError(context, logger, config) {
|
|
822
|
+
}
|
|
823
|
+
async anotherError(context, logger, config) {
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
__decorateClass([
|
|
827
|
+
aConcept.A_Feature.Extend({
|
|
828
|
+
name: "onError" /* onError */,
|
|
829
|
+
scope: [PollyspotChannel]
|
|
830
|
+
}),
|
|
831
|
+
__decorateParam(0, aConcept.A_Inject(A_ChannelRequest)),
|
|
832
|
+
__decorateParam(1, aConcept.A_Inject(exports.A_Logger)),
|
|
833
|
+
__decorateParam(2, aConcept.A_Inject(A_Config))
|
|
834
|
+
], GlobalErrorhandler.prototype, "handleError", 1);
|
|
835
|
+
__decorateClass([
|
|
836
|
+
aConcept.A_Feature.Extend({
|
|
837
|
+
name: "onError" /* onError */
|
|
838
|
+
}),
|
|
839
|
+
__decorateParam(0, aConcept.A_Inject(A_ChannelRequest)),
|
|
840
|
+
__decorateParam(1, aConcept.A_Inject(exports.A_Logger)),
|
|
841
|
+
__decorateParam(2, aConcept.A_Inject(A_Config))
|
|
842
|
+
], GlobalErrorhandler.prototype, "anotherError", 1);
|
|
388
843
|
|
|
389
844
|
// src/lib/A-Command/A-Command.constants.ts
|
|
390
|
-
var A_TYPES__CommandMetaKey = /* @__PURE__ */ ((A_TYPES__CommandMetaKey2) => {
|
|
391
|
-
A_TYPES__CommandMetaKey2["EXTENSIONS"] = "a-command-extensions";
|
|
392
|
-
A_TYPES__CommandMetaKey2["FEATURES"] = "a-command-features";
|
|
393
|
-
A_TYPES__CommandMetaKey2["ABSTRACTIONS"] = "a-command-abstractions";
|
|
394
|
-
return A_TYPES__CommandMetaKey2;
|
|
395
|
-
})(A_TYPES__CommandMetaKey || {});
|
|
396
845
|
var A_CONSTANTS__A_Command_Status = /* @__PURE__ */ ((A_CONSTANTS__A_Command_Status2) => {
|
|
397
846
|
A_CONSTANTS__A_Command_Status2["CREATED"] = "CREATED";
|
|
398
847
|
A_CONSTANTS__A_Command_Status2["INITIALIZATION"] = "INITIALIZATION";
|
|
@@ -404,14 +853,14 @@ var A_CONSTANTS__A_Command_Status = /* @__PURE__ */ ((A_CONSTANTS__A_Command_Sta
|
|
|
404
853
|
A_CONSTANTS__A_Command_Status2["FAILED"] = "FAILED";
|
|
405
854
|
return A_CONSTANTS__A_Command_Status2;
|
|
406
855
|
})(A_CONSTANTS__A_Command_Status || {});
|
|
407
|
-
var
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
return
|
|
414
|
-
})(
|
|
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 || {});
|
|
415
864
|
var A_Memory = class extends aConcept.A_Fragment {
|
|
416
865
|
/**
|
|
417
866
|
* Memory object that allows to store intermediate values and errors
|
|
@@ -432,7 +881,7 @@ var A_Memory = class extends aConcept.A_Fragment {
|
|
|
432
881
|
* @param requiredKeys
|
|
433
882
|
* @returns
|
|
434
883
|
*/
|
|
435
|
-
async
|
|
884
|
+
async prerequisites(requiredKeys) {
|
|
436
885
|
return requiredKeys.every((key) => this._memory.has(key));
|
|
437
886
|
}
|
|
438
887
|
/**
|
|
@@ -598,9 +1047,8 @@ var A_Command = class extends aConcept.A_Entity {
|
|
|
598
1047
|
}
|
|
599
1048
|
this._status = "INITIALIZATION" /* INITIALIZATION */;
|
|
600
1049
|
this._startTime = /* @__PURE__ */ new Date();
|
|
601
|
-
this.
|
|
602
|
-
this.
|
|
603
|
-
await this.call("init", this.scope);
|
|
1050
|
+
this.emit("onInit" /* onInit */);
|
|
1051
|
+
await this.call("onInit" /* onInit */, this.scope);
|
|
604
1052
|
this._status = "INITIALIZED" /* INITIALIZED */;
|
|
605
1053
|
}
|
|
606
1054
|
// Should compile everything before execution
|
|
@@ -610,8 +1058,8 @@ var A_Command = class extends aConcept.A_Entity {
|
|
|
610
1058
|
}
|
|
611
1059
|
this.checkScopeInheritance();
|
|
612
1060
|
this._status = "COMPILATION" /* COMPILATION */;
|
|
613
|
-
this.emit("
|
|
614
|
-
await this.call("
|
|
1061
|
+
this.emit("onCompile" /* onCompile */);
|
|
1062
|
+
await this.call("onCompile" /* onCompile */, this.scope);
|
|
615
1063
|
this._status = "COMPILED" /* COMPILED */;
|
|
616
1064
|
}
|
|
617
1065
|
/**
|
|
@@ -624,8 +1072,8 @@ var A_Command = class extends aConcept.A_Entity {
|
|
|
624
1072
|
return;
|
|
625
1073
|
this._status = "IN_PROGRESS" /* IN_PROGRESS */;
|
|
626
1074
|
this.checkScopeInheritance();
|
|
627
|
-
this.emit("
|
|
628
|
-
await this.call("
|
|
1075
|
+
this.emit("onExecute" /* onExecute */);
|
|
1076
|
+
await this.call("onExecute" /* onExecute */, this.scope);
|
|
629
1077
|
}
|
|
630
1078
|
/**
|
|
631
1079
|
* Executes the command logic.
|
|
@@ -640,6 +1088,7 @@ var A_Command = class extends aConcept.A_Entity {
|
|
|
640
1088
|
} catch (error) {
|
|
641
1089
|
await this.fail();
|
|
642
1090
|
}
|
|
1091
|
+
this._executionScope.destroy();
|
|
643
1092
|
}
|
|
644
1093
|
/**
|
|
645
1094
|
* Marks the command as completed
|
|
@@ -649,8 +1098,8 @@ var A_Command = class extends aConcept.A_Entity {
|
|
|
649
1098
|
this._status = "COMPLETED" /* COMPLETED */;
|
|
650
1099
|
this._endTime = /* @__PURE__ */ new Date();
|
|
651
1100
|
this._result = this.scope.resolve(A_Memory).toJSON();
|
|
652
|
-
this.emit("
|
|
653
|
-
|
|
1101
|
+
this.emit("onComplete" /* onComplete */);
|
|
1102
|
+
await this.call("onComplete" /* onComplete */, this.scope);
|
|
654
1103
|
}
|
|
655
1104
|
/**
|
|
656
1105
|
* Marks the command as failed
|
|
@@ -660,8 +1109,8 @@ var A_Command = class extends aConcept.A_Entity {
|
|
|
660
1109
|
this._status = "FAILED" /* FAILED */;
|
|
661
1110
|
this._endTime = /* @__PURE__ */ new Date();
|
|
662
1111
|
this._errors = this.scope.resolve(A_Memory).Errors;
|
|
663
|
-
this.emit("
|
|
664
|
-
|
|
1112
|
+
this.emit("onFail" /* onFail */);
|
|
1113
|
+
await this.call("onFail" /* onFail */, this.scope);
|
|
665
1114
|
}
|
|
666
1115
|
// --------------------------------------------------------------------------
|
|
667
1116
|
// A-Command Event-Emitter methods
|
|
@@ -775,176 +1224,6 @@ var A_Command = class extends aConcept.A_Entity {
|
|
|
775
1224
|
}
|
|
776
1225
|
}
|
|
777
1226
|
};
|
|
778
|
-
|
|
779
|
-
// src/lib/A-Config/A-Config.constants.ts
|
|
780
|
-
var A_CONSTANTS__CONFIG_ENV_VARIABLES = {};
|
|
781
|
-
var A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY = [];
|
|
782
|
-
|
|
783
|
-
// src/lib/A-Config/A-Config.context.ts
|
|
784
|
-
var A_Config = class extends aConcept.A_Fragment {
|
|
785
|
-
constructor(config) {
|
|
786
|
-
super({
|
|
787
|
-
name: "A_Config"
|
|
788
|
-
});
|
|
789
|
-
this.VARIABLES = /* @__PURE__ */ new Map();
|
|
790
|
-
this.DEFAULT_ALLOWED_TO_READ_PROPERTIES = [
|
|
791
|
-
...aConcept.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,
|
|
792
|
-
...A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY
|
|
793
|
-
];
|
|
794
|
-
this.config = aConcept.A_CommonHelper.deepCloneAndMerge(config, {
|
|
795
|
-
strict: false,
|
|
796
|
-
defaults: {},
|
|
797
|
-
variables: aConcept.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY
|
|
798
|
-
});
|
|
799
|
-
this.CONFIG_PROPERTIES = this.config.variables ? this.config.variables : [];
|
|
800
|
-
this.config.variables.forEach((variable) => {
|
|
801
|
-
this.VARIABLES.set(
|
|
802
|
-
aConcept.A_FormatterHelper.toUpperSnakeCase(variable),
|
|
803
|
-
this.config.defaults[variable]
|
|
804
|
-
);
|
|
805
|
-
});
|
|
806
|
-
}
|
|
807
|
-
/**
|
|
808
|
-
* This method is used to get the configuration property by name
|
|
809
|
-
*
|
|
810
|
-
* @param property
|
|
811
|
-
* @returns
|
|
812
|
-
*/
|
|
813
|
-
get(property) {
|
|
814
|
-
if (this.CONFIG_PROPERTIES.includes(property) || this.DEFAULT_ALLOWED_TO_READ_PROPERTIES.includes(property) || !this.config.strict)
|
|
815
|
-
return this.VARIABLES.get(aConcept.A_FormatterHelper.toUpperSnakeCase(property));
|
|
816
|
-
throw new Error("Property not exists or not allowed to read");
|
|
817
|
-
}
|
|
818
|
-
set(property, value) {
|
|
819
|
-
const array = Array.isArray(property) ? property : typeof property === "string" ? [{ property, value }] : Object.keys(property).map((key) => ({
|
|
820
|
-
property: key,
|
|
821
|
-
value: property[key]
|
|
822
|
-
}));
|
|
823
|
-
for (const { property: property2, value: value2 } of array) {
|
|
824
|
-
let targetValue = value2 ? value2 : this.config?.defaults ? this.config.defaults[property2] : void 0;
|
|
825
|
-
this.VARIABLES.set(aConcept.A_FormatterHelper.toUpperSnakeCase(property2), targetValue);
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
};
|
|
829
|
-
exports.A_Logger = class A_Logger extends aConcept.A_Component {
|
|
830
|
-
constructor(scope) {
|
|
831
|
-
super();
|
|
832
|
-
this.scope = scope;
|
|
833
|
-
this.colors = {
|
|
834
|
-
green: "32",
|
|
835
|
-
blue: "34",
|
|
836
|
-
red: "31",
|
|
837
|
-
yellow: "33",
|
|
838
|
-
gray: "90",
|
|
839
|
-
magenta: "35",
|
|
840
|
-
cyan: "36",
|
|
841
|
-
white: "37",
|
|
842
|
-
pink: "95"
|
|
843
|
-
};
|
|
844
|
-
this.config = this.scope.has(A_Config) ? this.scope.resolve(A_Config) : void 0;
|
|
845
|
-
}
|
|
846
|
-
get scopeLength() {
|
|
847
|
-
return this.scope.name.length;
|
|
848
|
-
}
|
|
849
|
-
compile(color, ...args) {
|
|
850
|
-
return [
|
|
851
|
-
`\x1B[${this.colors[color]}m[${this.scope.name}] |${this.getTime()}|`,
|
|
852
|
-
args.length > 1 ? `
|
|
853
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------` : "",
|
|
854
|
-
...args.map((arg, i) => {
|
|
855
|
-
switch (true) {
|
|
856
|
-
case arg instanceof aConcept.A_Error:
|
|
857
|
-
return this.compile_A_Error(arg);
|
|
858
|
-
case arg instanceof Error:
|
|
859
|
-
return this.compile_Error(arg);
|
|
860
|
-
case typeof arg === "object":
|
|
861
|
-
return JSON.stringify(arg, null, 2).replace(/\n/g, `
|
|
862
|
-
${" ".repeat(this.scopeLength + 3)}| `);
|
|
863
|
-
default:
|
|
864
|
-
return String(
|
|
865
|
-
(i > 0 || args.length > 1 ? "\n" : "") + arg
|
|
866
|
-
).replace(/\n/g, `
|
|
867
|
-
${" ".repeat(this.scopeLength + 3)}| `);
|
|
868
|
-
}
|
|
869
|
-
}),
|
|
870
|
-
args.length > 1 ? `
|
|
871
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------\x1B[0m` : "\x1B[0m"
|
|
872
|
-
];
|
|
873
|
-
}
|
|
874
|
-
get allowedToLog() {
|
|
875
|
-
return this.config ? this.config.get("CONFIG_VERBOSE") !== void 0 && this.config.get("CONFIG_VERBOSE") !== "false" && this.config.get("CONFIG_VERBOSE") !== false : true;
|
|
876
|
-
}
|
|
877
|
-
log(param1, ...args) {
|
|
878
|
-
if (!this.allowedToLog)
|
|
879
|
-
return;
|
|
880
|
-
if (typeof param1 === "string" && this.colors[param1]) {
|
|
881
|
-
console.log(...this.compile(param1, ...args));
|
|
882
|
-
return;
|
|
883
|
-
} else {
|
|
884
|
-
console.log(...this.compile("blue", param1, ...args));
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
warning(...args) {
|
|
888
|
-
if (!this.allowedToLog)
|
|
889
|
-
return;
|
|
890
|
-
console.log(...this.compile("yellow", ...args));
|
|
891
|
-
}
|
|
892
|
-
error(...args) {
|
|
893
|
-
if (this.config && this.config.get("CONFIG_IGNORE_ERRORS"))
|
|
894
|
-
return;
|
|
895
|
-
return console.log(...this.compile("red", ...args));
|
|
896
|
-
}
|
|
897
|
-
log_A_Error(error) {
|
|
898
|
-
const time = this.getTime();
|
|
899
|
-
console.log(`\x1B[31m[${this.scope.name}] |${time}| ERROR ${error.code}
|
|
900
|
-
${" ".repeat(this.scopeLength + 3)}| ${error.message}
|
|
901
|
-
${" ".repeat(this.scopeLength + 3)}| ${error.description}
|
|
902
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
903
|
-
${" ".repeat(this.scopeLength + 3)}| ${error.stack?.split("\n").map((line, index) => index === 0 ? line : `${" ".repeat(this.scopeLength + 3)}| ${line}`).join("\n") || "No stack trace"}
|
|
904
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
905
|
-
\x1B[0m` + (error.originalError ? `\x1B[31m${" ".repeat(this.scopeLength + 3)}| Wrapped From ${error.originalError.message}
|
|
906
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
907
|
-
${" ".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"}
|
|
908
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
909
|
-
\x1B[0m` : "") + (error.link ? `\x1B[31m${" ".repeat(this.scopeLength + 3)}| Read in docs: ${error.link}
|
|
910
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
911
|
-
\x1B[0m` : ""));
|
|
912
|
-
}
|
|
913
|
-
compile_A_Error(error) {
|
|
914
|
-
this.getTime();
|
|
915
|
-
return `
|
|
916
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
917
|
-
${" ".repeat(this.scopeLength + 3)}| Error: | ${error.code}
|
|
918
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
919
|
-
${" ".repeat(this.scopeLength + 3)}|${" ".repeat(10)}| ${error.message}
|
|
920
|
-
${" ".repeat(this.scopeLength + 3)}|${" ".repeat(10)}| ${error.description}
|
|
921
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
922
|
-
${" ".repeat(this.scopeLength + 3)}| ${error.stack?.split("\n").map((line, index) => index === 0 ? line : `${" ".repeat(this.scopeLength + 3)}| ${line}`).join("\n") || "No stack trace"}
|
|
923
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------` + (error.originalError ? `${" ".repeat(this.scopeLength + 3)}| Wrapped From ${error.originalError.message}
|
|
924
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
925
|
-
${" ".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"}
|
|
926
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------` : "") + (error.link ? `${" ".repeat(this.scopeLength + 3)}| Read in docs: ${error.link}
|
|
927
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------` : "");
|
|
928
|
-
}
|
|
929
|
-
compile_Error(error) {
|
|
930
|
-
return JSON.stringify({
|
|
931
|
-
name: error.name,
|
|
932
|
-
message: error.message,
|
|
933
|
-
stack: error.stack?.split("\n").map((line, index) => index === 0 ? line : `${" ".repeat(this.scopeLength + 3)}| ${line}`).join("\n")
|
|
934
|
-
}, null, 2).replace(/\n/g, `
|
|
935
|
-
${" ".repeat(this.scopeLength + 3)}| `).replace(/\\n/g, "\n");
|
|
936
|
-
}
|
|
937
|
-
getTime() {
|
|
938
|
-
const now = /* @__PURE__ */ new Date();
|
|
939
|
-
const minutes = String(now.getMinutes()).padStart(2, "0");
|
|
940
|
-
const seconds = String(now.getSeconds()).padStart(2, "0");
|
|
941
|
-
const milliseconds = String(now.getMilliseconds()).padStart(4, "0");
|
|
942
|
-
return `${minutes}:${seconds}:${milliseconds}`;
|
|
943
|
-
}
|
|
944
|
-
};
|
|
945
|
-
exports.A_Logger = __decorateClass([
|
|
946
|
-
__decorateParam(0, aConcept.A_Inject(aConcept.A_Scope))
|
|
947
|
-
], exports.A_Logger);
|
|
948
1227
|
var A_FSPolyfillClass = class {
|
|
949
1228
|
constructor(logger) {
|
|
950
1229
|
this.logger = logger;
|
|
@@ -1658,18 +1937,17 @@ exports.ConfigReader = class ConfigReader extends aConcept.A_Component {
|
|
|
1658
1937
|
super();
|
|
1659
1938
|
this.polyfill = polyfill;
|
|
1660
1939
|
}
|
|
1661
|
-
async attachContext(container, feature) {
|
|
1662
|
-
if (!
|
|
1663
|
-
|
|
1940
|
+
async attachContext(container, feature, config) {
|
|
1941
|
+
if (!config) {
|
|
1942
|
+
config = new A_Config({
|
|
1664
1943
|
variables: [
|
|
1665
1944
|
...aConcept.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,
|
|
1666
1945
|
...A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY
|
|
1667
1946
|
],
|
|
1668
1947
|
defaults: {}
|
|
1669
1948
|
});
|
|
1670
|
-
container.scope.register(
|
|
1949
|
+
container.scope.register(config);
|
|
1671
1950
|
}
|
|
1672
|
-
const config = container.scope.resolve(A_Config);
|
|
1673
1951
|
const rootDir = await this.getProjectRoot();
|
|
1674
1952
|
config.set("A_CONCEPT_ROOT_FOLDER", rootDir);
|
|
1675
1953
|
}
|
|
@@ -1709,7 +1987,8 @@ exports.ConfigReader = class ConfigReader extends aConcept.A_Component {
|
|
|
1709
1987
|
__decorateClass([
|
|
1710
1988
|
aConcept.A_Concept.Load(),
|
|
1711
1989
|
__decorateParam(0, aConcept.A_Inject(aConcept.A_Container)),
|
|
1712
|
-
__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))
|
|
1713
1992
|
], exports.ConfigReader.prototype, "attachContext", 1);
|
|
1714
1993
|
__decorateClass([
|
|
1715
1994
|
aConcept.A_Concept.Load(),
|
|
@@ -2091,14 +2370,17 @@ var A_Schedule = class extends aConcept.A_Component {
|
|
|
2091
2370
|
}
|
|
2092
2371
|
};
|
|
2093
2372
|
|
|
2094
|
-
exports.A_CONSTANTS_A_Command_Features = A_CONSTANTS_A_Command_Features;
|
|
2095
2373
|
exports.A_CONSTANTS__A_Command_Status = A_CONSTANTS__A_Command_Status;
|
|
2096
2374
|
exports.A_CONSTANTS__CONFIG_ENV_VARIABLES = A_CONSTANTS__CONFIG_ENV_VARIABLES;
|
|
2097
2375
|
exports.A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY = A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY;
|
|
2098
2376
|
exports.A_Channel = A_Channel;
|
|
2099
2377
|
exports.A_ChannelError = A_ChannelError;
|
|
2378
|
+
exports.A_ChannelFeatures = A_ChannelFeatures;
|
|
2379
|
+
exports.A_ChannelRequest = A_ChannelRequest;
|
|
2380
|
+
exports.A_ChannelRequestStatuses = A_ChannelRequestStatuses;
|
|
2100
2381
|
exports.A_Command = A_Command;
|
|
2101
2382
|
exports.A_CommandError = A_CommandError;
|
|
2383
|
+
exports.A_CommandFeatures = A_CommandFeatures;
|
|
2102
2384
|
exports.A_Config = A_Config;
|
|
2103
2385
|
exports.A_ConfigError = A_ConfigError;
|
|
2104
2386
|
exports.A_ConfigLoader = A_ConfigLoader;
|
|
@@ -2109,7 +2391,6 @@ exports.A_ManifestError = A_ManifestError;
|
|
|
2109
2391
|
exports.A_Memory = A_Memory;
|
|
2110
2392
|
exports.A_Schedule = A_Schedule;
|
|
2111
2393
|
exports.A_ScheduleObject = A_ScheduleObject;
|
|
2112
|
-
exports.A_TYPES__CommandMetaKey = A_TYPES__CommandMetaKey;
|
|
2113
2394
|
exports.A_TYPES__ConfigFeature = A_TYPES__ConfigFeature;
|
|
2114
2395
|
exports.ENVConfigReader = ENVConfigReader;
|
|
2115
2396
|
exports.FileConfigReader = FileConfigReader;
|