@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.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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;
|
|
@@ -11,7 +11,32 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
11
11
|
return result;
|
|
12
12
|
};
|
|
13
13
|
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
// src/lib/A-Channel/A-Channel.constants.ts
|
|
16
|
+
var A_ChannelFeatures = /* @__PURE__ */ ((A_ChannelFeatures2) => {
|
|
17
|
+
A_ChannelFeatures2["onTimeout"] = "onTimeout";
|
|
18
|
+
A_ChannelFeatures2["onRetry"] = "onRetry";
|
|
19
|
+
A_ChannelFeatures2["onCircuitBreakerOpen"] = "onCircuitBreakerOpen";
|
|
20
|
+
A_ChannelFeatures2["onCache"] = "onCache";
|
|
21
|
+
A_ChannelFeatures2["onConnect"] = "onConnect";
|
|
22
|
+
A_ChannelFeatures2["onDisconnect"] = "onDisconnect";
|
|
23
|
+
A_ChannelFeatures2["onBeforeRequest"] = "onBeforeRequest";
|
|
24
|
+
A_ChannelFeatures2["onRequest"] = "onRequest";
|
|
25
|
+
A_ChannelFeatures2["onAfterRequest"] = "onAfterRequest";
|
|
26
|
+
A_ChannelFeatures2["onError"] = "onError";
|
|
27
|
+
A_ChannelFeatures2["onSend"] = "onSend";
|
|
28
|
+
A_ChannelFeatures2["onConsume"] = "onConsume";
|
|
29
|
+
return A_ChannelFeatures2;
|
|
30
|
+
})(A_ChannelFeatures || {});
|
|
31
|
+
var A_ChannelRequestStatuses = /* @__PURE__ */ ((A_ChannelRequestStatuses2) => {
|
|
32
|
+
A_ChannelRequestStatuses2["PENDING"] = "PENDING";
|
|
33
|
+
A_ChannelRequestStatuses2["SUCCESS"] = "SUCCESS";
|
|
34
|
+
A_ChannelRequestStatuses2["FAILED"] = "FAILED";
|
|
35
|
+
return A_ChannelRequestStatuses2;
|
|
36
|
+
})(A_ChannelRequestStatuses || {});
|
|
37
|
+
|
|
38
|
+
// src/lib/A-Channel/A-ChannelRequest.context.ts
|
|
39
|
+
var A_ChannelRequest = class extends A_Fragment {
|
|
15
40
|
constructor(params = {}) {
|
|
16
41
|
super();
|
|
17
42
|
this._errors = /* @__PURE__ */ new Set();
|
|
@@ -95,7 +120,7 @@ var A_ChannelError = class extends A_Error {
|
|
|
95
120
|
super(originalError, context);
|
|
96
121
|
else
|
|
97
122
|
super(originalError);
|
|
98
|
-
if (context instanceof
|
|
123
|
+
if (context instanceof A_ChannelRequest)
|
|
99
124
|
this._context = context;
|
|
100
125
|
}
|
|
101
126
|
/***
|
|
@@ -110,6 +135,405 @@ var A_ChannelError = class extends A_Error {
|
|
|
110
135
|
// ==========================================================
|
|
111
136
|
A_ChannelError.MethodNotImplemented = "A-Channel Method Not Implemented";
|
|
112
137
|
|
|
138
|
+
// src/lib/A-Config/A-Config.constants.ts
|
|
139
|
+
var A_CONSTANTS__CONFIG_ENV_VARIABLES = {};
|
|
140
|
+
var A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY = [];
|
|
141
|
+
|
|
142
|
+
// src/lib/A-Config/A-Config.context.ts
|
|
143
|
+
var A_Config = class extends A_Fragment {
|
|
144
|
+
constructor(config) {
|
|
145
|
+
super({
|
|
146
|
+
name: "A_Config"
|
|
147
|
+
});
|
|
148
|
+
this.VARIABLES = /* @__PURE__ */ new Map();
|
|
149
|
+
this.DEFAULT_ALLOWED_TO_READ_PROPERTIES = [
|
|
150
|
+
...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,
|
|
151
|
+
...A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY
|
|
152
|
+
];
|
|
153
|
+
this.config = A_CommonHelper.deepCloneAndMerge(config, {
|
|
154
|
+
strict: false,
|
|
155
|
+
defaults: {},
|
|
156
|
+
variables: A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY
|
|
157
|
+
});
|
|
158
|
+
this.CONFIG_PROPERTIES = this.config.variables ? this.config.variables : [];
|
|
159
|
+
this.config.variables.forEach((variable) => {
|
|
160
|
+
this.VARIABLES.set(
|
|
161
|
+
A_FormatterHelper.toUpperSnakeCase(variable),
|
|
162
|
+
this.config.defaults[variable]
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* This method is used to get the configuration property by name
|
|
168
|
+
*
|
|
169
|
+
* @param property
|
|
170
|
+
* @returns
|
|
171
|
+
*/
|
|
172
|
+
get(property) {
|
|
173
|
+
if (this.CONFIG_PROPERTIES.includes(property) || this.DEFAULT_ALLOWED_TO_READ_PROPERTIES.includes(property) || !this.config.strict)
|
|
174
|
+
return this.VARIABLES.get(A_FormatterHelper.toUpperSnakeCase(property));
|
|
175
|
+
throw new Error("Property not exists or not allowed to read");
|
|
176
|
+
}
|
|
177
|
+
set(property, value) {
|
|
178
|
+
const array = Array.isArray(property) ? property : typeof property === "string" ? [{ property, value }] : Object.keys(property).map((key) => ({
|
|
179
|
+
property: key,
|
|
180
|
+
value: property[key]
|
|
181
|
+
}));
|
|
182
|
+
for (const { property: property2, value: value2 } of array) {
|
|
183
|
+
let targetValue = value2 ? value2 : this.config?.defaults ? this.config.defaults[property2] : void 0;
|
|
184
|
+
this.VARIABLES.set(A_FormatterHelper.toUpperSnakeCase(property2), targetValue);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
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
|
+
|
|
234
|
+
// src/lib/A-Logger/A-Logger.component.ts
|
|
235
|
+
var A_Logger = class extends A_Component {
|
|
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) {
|
|
246
|
+
super();
|
|
247
|
+
this.scope = scope;
|
|
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;
|
|
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
|
+
*/
|
|
261
|
+
get scopeLength() {
|
|
262
|
+
return Math.max(this.scope.name.length, this.STANDARD_SCOPE_LENGTH);
|
|
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
|
+
*/
|
|
289
|
+
compile(color, ...args) {
|
|
290
|
+
const timeString = this.getTime();
|
|
291
|
+
const scopePadding = " ".repeat(this.scopeLength + 3);
|
|
292
|
+
const isMultiArg = args.length > 1;
|
|
293
|
+
return [
|
|
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
|
|
300
|
+
...args.map((arg, i) => {
|
|
301
|
+
const shouldAddNewline = i > 0 || isMultiArg;
|
|
302
|
+
switch (true) {
|
|
303
|
+
case arg instanceof A_Error:
|
|
304
|
+
return this.compile_A_Error(arg);
|
|
305
|
+
case arg instanceof Error:
|
|
306
|
+
return this.compile_Error(arg);
|
|
307
|
+
case (typeof arg === "object" && arg !== null):
|
|
308
|
+
return this.formatObject(arg, shouldAddNewline, scopePadding);
|
|
309
|
+
default:
|
|
310
|
+
return this.formatString(String(arg), shouldAddNewline, scopePadding);
|
|
311
|
+
}
|
|
312
|
+
}),
|
|
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
|
|
316
|
+
];
|
|
317
|
+
}
|
|
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
|
+
}
|
|
392
|
+
}
|
|
393
|
+
log(param1, ...args) {
|
|
394
|
+
if (!this.shouldLog("log")) return;
|
|
395
|
+
if (typeof param1 === "string" && this.COLORS[param1]) {
|
|
396
|
+
console.log(...this.compile(param1, ...args));
|
|
397
|
+
} else {
|
|
398
|
+
console.log(...this.compile("blue", param1, ...args));
|
|
399
|
+
}
|
|
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
|
+
*/
|
|
415
|
+
warning(...args) {
|
|
416
|
+
if (!this.shouldLog("warning")) return;
|
|
417
|
+
console.log(...this.compile("yellow", ...args));
|
|
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
|
+
*/
|
|
434
|
+
error(...args) {
|
|
435
|
+
if (!this.shouldLog("error")) return;
|
|
436
|
+
console.log(...this.compile("red", ...args));
|
|
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
|
+
*/
|
|
447
|
+
log_A_Error(error) {
|
|
448
|
+
const time = this.getTime();
|
|
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}|-------------------------------
|
|
462
|
+
\x1B[0m` : ""));
|
|
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
|
+
*/
|
|
476
|
+
compile_A_Error(error) {
|
|
477
|
+
const scopePadding = " ".repeat(this.scopeLength + 3);
|
|
478
|
+
return `
|
|
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}|-------------------------------` : "");
|
|
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
|
+
*/
|
|
501
|
+
compile_Error(error) {
|
|
502
|
+
const scopePadding = " ".repeat(this.scopeLength + 3);
|
|
503
|
+
return JSON.stringify({
|
|
504
|
+
name: error.name,
|
|
505
|
+
message: error.message,
|
|
506
|
+
stack: error.stack?.split("\n").map((line, index) => index === 0 ? line : `${scopePadding}| ${line}`).join("\n")
|
|
507
|
+
}, null, 2).replace(/\n/g, `
|
|
508
|
+
${scopePadding}| `).replace(/\\n/g, "\n");
|
|
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
|
+
*/
|
|
524
|
+
getTime() {
|
|
525
|
+
const now = /* @__PURE__ */ new Date();
|
|
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}`;
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
A_Logger = __decorateClass([
|
|
533
|
+
__decorateParam(0, A_Inject(A_Scope)),
|
|
534
|
+
__decorateParam(1, A_Inject(A_Config))
|
|
535
|
+
], A_Logger);
|
|
536
|
+
|
|
113
537
|
// src/lib/A-Channel/A-Channel.component.ts
|
|
114
538
|
var A_Channel = class extends A_Component {
|
|
115
539
|
/**
|
|
@@ -216,7 +640,7 @@ var A_Channel = class extends A_Component {
|
|
|
216
640
|
* @template _ParamsType The type of request parameters
|
|
217
641
|
* @template _ResultType The type of response data
|
|
218
642
|
* @param params The request parameters
|
|
219
|
-
* @returns {Promise<
|
|
643
|
+
* @returns {Promise<A_ChannelRequest<_ParamsType, _ResultType>>} Request context with response
|
|
220
644
|
*
|
|
221
645
|
* @example
|
|
222
646
|
* ```typescript
|
|
@@ -242,7 +666,7 @@ var A_Channel = class extends A_Component {
|
|
|
242
666
|
const requestScope = new A_Scope({
|
|
243
667
|
name: `a-channel@scope:request:${A_IdentityHelper.generateTimeId()}`
|
|
244
668
|
});
|
|
245
|
-
const context = new
|
|
669
|
+
const context = new A_ChannelRequest(params);
|
|
246
670
|
try {
|
|
247
671
|
requestScope.inherit(A_Context.scope(this));
|
|
248
672
|
requestScope.register(context);
|
|
@@ -307,7 +731,7 @@ var A_Channel = class extends A_Component {
|
|
|
307
731
|
const requestScope = new A_Scope({
|
|
308
732
|
name: `a-channel@scope:send:${A_IdentityHelper.generateTimeId()}`
|
|
309
733
|
});
|
|
310
|
-
const context = new
|
|
734
|
+
const context = new A_ChannelRequest(message);
|
|
311
735
|
try {
|
|
312
736
|
requestScope.inherit(A_Context.scope(this));
|
|
313
737
|
requestScope.register(context);
|
|
@@ -332,7 +756,7 @@ var A_Channel = class extends A_Component {
|
|
|
332
756
|
await this.initialize;
|
|
333
757
|
this._processing = true;
|
|
334
758
|
const requestScope = new A_Scope({ name: `a-channel@scope:consume:${A_IdentityHelper.generateTimeId()}` });
|
|
335
|
-
const context = new
|
|
759
|
+
const context = new A_ChannelRequest();
|
|
336
760
|
try {
|
|
337
761
|
requestScope.inherit(A_Context.scope(this));
|
|
338
762
|
requestScope.register(context);
|
|
@@ -383,14 +807,39 @@ __decorateClass([
|
|
|
383
807
|
name: "onSend" /* onSend */
|
|
384
808
|
})
|
|
385
809
|
], A_Channel.prototype, "onSend", 1);
|
|
810
|
+
var HttpChannel = class extends A_Channel {
|
|
811
|
+
};
|
|
812
|
+
var PollyspotChannel = class extends HttpChannel {
|
|
813
|
+
constructor() {
|
|
814
|
+
super();
|
|
815
|
+
this.baseUrl = "https://pollyspot.example.com";
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
var GlobalErrorhandler = class extends A_Component {
|
|
819
|
+
async handleError(context, logger, config) {
|
|
820
|
+
}
|
|
821
|
+
async anotherError(context, logger, config) {
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
__decorateClass([
|
|
825
|
+
A_Feature.Extend({
|
|
826
|
+
name: "onError" /* onError */,
|
|
827
|
+
scope: [PollyspotChannel]
|
|
828
|
+
}),
|
|
829
|
+
__decorateParam(0, A_Inject(A_ChannelRequest)),
|
|
830
|
+
__decorateParam(1, A_Inject(A_Logger)),
|
|
831
|
+
__decorateParam(2, A_Inject(A_Config))
|
|
832
|
+
], GlobalErrorhandler.prototype, "handleError", 1);
|
|
833
|
+
__decorateClass([
|
|
834
|
+
A_Feature.Extend({
|
|
835
|
+
name: "onError" /* onError */
|
|
836
|
+
}),
|
|
837
|
+
__decorateParam(0, A_Inject(A_ChannelRequest)),
|
|
838
|
+
__decorateParam(1, A_Inject(A_Logger)),
|
|
839
|
+
__decorateParam(2, A_Inject(A_Config))
|
|
840
|
+
], GlobalErrorhandler.prototype, "anotherError", 1);
|
|
386
841
|
|
|
387
842
|
// src/lib/A-Command/A-Command.constants.ts
|
|
388
|
-
var A_TYPES__CommandMetaKey = /* @__PURE__ */ ((A_TYPES__CommandMetaKey2) => {
|
|
389
|
-
A_TYPES__CommandMetaKey2["EXTENSIONS"] = "a-command-extensions";
|
|
390
|
-
A_TYPES__CommandMetaKey2["FEATURES"] = "a-command-features";
|
|
391
|
-
A_TYPES__CommandMetaKey2["ABSTRACTIONS"] = "a-command-abstractions";
|
|
392
|
-
return A_TYPES__CommandMetaKey2;
|
|
393
|
-
})(A_TYPES__CommandMetaKey || {});
|
|
394
843
|
var A_CONSTANTS__A_Command_Status = /* @__PURE__ */ ((A_CONSTANTS__A_Command_Status2) => {
|
|
395
844
|
A_CONSTANTS__A_Command_Status2["CREATED"] = "CREATED";
|
|
396
845
|
A_CONSTANTS__A_Command_Status2["INITIALIZATION"] = "INITIALIZATION";
|
|
@@ -402,14 +851,14 @@ var A_CONSTANTS__A_Command_Status = /* @__PURE__ */ ((A_CONSTANTS__A_Command_Sta
|
|
|
402
851
|
A_CONSTANTS__A_Command_Status2["FAILED"] = "FAILED";
|
|
403
852
|
return A_CONSTANTS__A_Command_Status2;
|
|
404
853
|
})(A_CONSTANTS__A_Command_Status || {});
|
|
405
|
-
var
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
return
|
|
412
|
-
})(
|
|
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 || {});
|
|
413
862
|
var A_Memory = class extends A_Fragment {
|
|
414
863
|
/**
|
|
415
864
|
* Memory object that allows to store intermediate values and errors
|
|
@@ -430,7 +879,7 @@ var A_Memory = class extends A_Fragment {
|
|
|
430
879
|
* @param requiredKeys
|
|
431
880
|
* @returns
|
|
432
881
|
*/
|
|
433
|
-
async
|
|
882
|
+
async prerequisites(requiredKeys) {
|
|
434
883
|
return requiredKeys.every((key) => this._memory.has(key));
|
|
435
884
|
}
|
|
436
885
|
/**
|
|
@@ -596,9 +1045,8 @@ var A_Command = class extends A_Entity {
|
|
|
596
1045
|
}
|
|
597
1046
|
this._status = "INITIALIZATION" /* INITIALIZATION */;
|
|
598
1047
|
this._startTime = /* @__PURE__ */ new Date();
|
|
599
|
-
this.
|
|
600
|
-
this.
|
|
601
|
-
await this.call("init", this.scope);
|
|
1048
|
+
this.emit("onInit" /* onInit */);
|
|
1049
|
+
await this.call("onInit" /* onInit */, this.scope);
|
|
602
1050
|
this._status = "INITIALIZED" /* INITIALIZED */;
|
|
603
1051
|
}
|
|
604
1052
|
// Should compile everything before execution
|
|
@@ -608,8 +1056,8 @@ var A_Command = class extends A_Entity {
|
|
|
608
1056
|
}
|
|
609
1057
|
this.checkScopeInheritance();
|
|
610
1058
|
this._status = "COMPILATION" /* COMPILATION */;
|
|
611
|
-
this.emit("
|
|
612
|
-
await this.call("
|
|
1059
|
+
this.emit("onCompile" /* onCompile */);
|
|
1060
|
+
await this.call("onCompile" /* onCompile */, this.scope);
|
|
613
1061
|
this._status = "COMPILED" /* COMPILED */;
|
|
614
1062
|
}
|
|
615
1063
|
/**
|
|
@@ -622,8 +1070,8 @@ var A_Command = class extends A_Entity {
|
|
|
622
1070
|
return;
|
|
623
1071
|
this._status = "IN_PROGRESS" /* IN_PROGRESS */;
|
|
624
1072
|
this.checkScopeInheritance();
|
|
625
|
-
this.emit("
|
|
626
|
-
await this.call("
|
|
1073
|
+
this.emit("onExecute" /* onExecute */);
|
|
1074
|
+
await this.call("onExecute" /* onExecute */, this.scope);
|
|
627
1075
|
}
|
|
628
1076
|
/**
|
|
629
1077
|
* Executes the command logic.
|
|
@@ -638,6 +1086,7 @@ var A_Command = class extends A_Entity {
|
|
|
638
1086
|
} catch (error) {
|
|
639
1087
|
await this.fail();
|
|
640
1088
|
}
|
|
1089
|
+
this._executionScope.destroy();
|
|
641
1090
|
}
|
|
642
1091
|
/**
|
|
643
1092
|
* Marks the command as completed
|
|
@@ -647,8 +1096,8 @@ var A_Command = class extends A_Entity {
|
|
|
647
1096
|
this._status = "COMPLETED" /* COMPLETED */;
|
|
648
1097
|
this._endTime = /* @__PURE__ */ new Date();
|
|
649
1098
|
this._result = this.scope.resolve(A_Memory).toJSON();
|
|
650
|
-
this.emit("
|
|
651
|
-
|
|
1099
|
+
this.emit("onComplete" /* onComplete */);
|
|
1100
|
+
await this.call("onComplete" /* onComplete */, this.scope);
|
|
652
1101
|
}
|
|
653
1102
|
/**
|
|
654
1103
|
* Marks the command as failed
|
|
@@ -658,8 +1107,8 @@ var A_Command = class extends A_Entity {
|
|
|
658
1107
|
this._status = "FAILED" /* FAILED */;
|
|
659
1108
|
this._endTime = /* @__PURE__ */ new Date();
|
|
660
1109
|
this._errors = this.scope.resolve(A_Memory).Errors;
|
|
661
|
-
this.emit("
|
|
662
|
-
|
|
1110
|
+
this.emit("onFail" /* onFail */);
|
|
1111
|
+
await this.call("onFail" /* onFail */, this.scope);
|
|
663
1112
|
}
|
|
664
1113
|
// --------------------------------------------------------------------------
|
|
665
1114
|
// A-Command Event-Emitter methods
|
|
@@ -773,176 +1222,6 @@ var A_Command = class extends A_Entity {
|
|
|
773
1222
|
}
|
|
774
1223
|
}
|
|
775
1224
|
};
|
|
776
|
-
|
|
777
|
-
// src/lib/A-Config/A-Config.constants.ts
|
|
778
|
-
var A_CONSTANTS__CONFIG_ENV_VARIABLES = {};
|
|
779
|
-
var A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY = [];
|
|
780
|
-
|
|
781
|
-
// src/lib/A-Config/A-Config.context.ts
|
|
782
|
-
var A_Config = class extends A_Fragment {
|
|
783
|
-
constructor(config) {
|
|
784
|
-
super({
|
|
785
|
-
name: "A_Config"
|
|
786
|
-
});
|
|
787
|
-
this.VARIABLES = /* @__PURE__ */ new Map();
|
|
788
|
-
this.DEFAULT_ALLOWED_TO_READ_PROPERTIES = [
|
|
789
|
-
...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,
|
|
790
|
-
...A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY
|
|
791
|
-
];
|
|
792
|
-
this.config = A_CommonHelper.deepCloneAndMerge(config, {
|
|
793
|
-
strict: false,
|
|
794
|
-
defaults: {},
|
|
795
|
-
variables: A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY
|
|
796
|
-
});
|
|
797
|
-
this.CONFIG_PROPERTIES = this.config.variables ? this.config.variables : [];
|
|
798
|
-
this.config.variables.forEach((variable) => {
|
|
799
|
-
this.VARIABLES.set(
|
|
800
|
-
A_FormatterHelper.toUpperSnakeCase(variable),
|
|
801
|
-
this.config.defaults[variable]
|
|
802
|
-
);
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
|
-
/**
|
|
806
|
-
* This method is used to get the configuration property by name
|
|
807
|
-
*
|
|
808
|
-
* @param property
|
|
809
|
-
* @returns
|
|
810
|
-
*/
|
|
811
|
-
get(property) {
|
|
812
|
-
if (this.CONFIG_PROPERTIES.includes(property) || this.DEFAULT_ALLOWED_TO_READ_PROPERTIES.includes(property) || !this.config.strict)
|
|
813
|
-
return this.VARIABLES.get(A_FormatterHelper.toUpperSnakeCase(property));
|
|
814
|
-
throw new Error("Property not exists or not allowed to read");
|
|
815
|
-
}
|
|
816
|
-
set(property, value) {
|
|
817
|
-
const array = Array.isArray(property) ? property : typeof property === "string" ? [{ property, value }] : Object.keys(property).map((key) => ({
|
|
818
|
-
property: key,
|
|
819
|
-
value: property[key]
|
|
820
|
-
}));
|
|
821
|
-
for (const { property: property2, value: value2 } of array) {
|
|
822
|
-
let targetValue = value2 ? value2 : this.config?.defaults ? this.config.defaults[property2] : void 0;
|
|
823
|
-
this.VARIABLES.set(A_FormatterHelper.toUpperSnakeCase(property2), targetValue);
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
};
|
|
827
|
-
var A_Logger = class extends A_Component {
|
|
828
|
-
constructor(scope) {
|
|
829
|
-
super();
|
|
830
|
-
this.scope = scope;
|
|
831
|
-
this.colors = {
|
|
832
|
-
green: "32",
|
|
833
|
-
blue: "34",
|
|
834
|
-
red: "31",
|
|
835
|
-
yellow: "33",
|
|
836
|
-
gray: "90",
|
|
837
|
-
magenta: "35",
|
|
838
|
-
cyan: "36",
|
|
839
|
-
white: "37",
|
|
840
|
-
pink: "95"
|
|
841
|
-
};
|
|
842
|
-
this.config = this.scope.has(A_Config) ? this.scope.resolve(A_Config) : void 0;
|
|
843
|
-
}
|
|
844
|
-
get scopeLength() {
|
|
845
|
-
return this.scope.name.length;
|
|
846
|
-
}
|
|
847
|
-
compile(color, ...args) {
|
|
848
|
-
return [
|
|
849
|
-
`\x1B[${this.colors[color]}m[${this.scope.name}] |${this.getTime()}|`,
|
|
850
|
-
args.length > 1 ? `
|
|
851
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------` : "",
|
|
852
|
-
...args.map((arg, i) => {
|
|
853
|
-
switch (true) {
|
|
854
|
-
case arg instanceof A_Error:
|
|
855
|
-
return this.compile_A_Error(arg);
|
|
856
|
-
case arg instanceof Error:
|
|
857
|
-
return this.compile_Error(arg);
|
|
858
|
-
case typeof arg === "object":
|
|
859
|
-
return JSON.stringify(arg, null, 2).replace(/\n/g, `
|
|
860
|
-
${" ".repeat(this.scopeLength + 3)}| `);
|
|
861
|
-
default:
|
|
862
|
-
return String(
|
|
863
|
-
(i > 0 || args.length > 1 ? "\n" : "") + arg
|
|
864
|
-
).replace(/\n/g, `
|
|
865
|
-
${" ".repeat(this.scopeLength + 3)}| `);
|
|
866
|
-
}
|
|
867
|
-
}),
|
|
868
|
-
args.length > 1 ? `
|
|
869
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------\x1B[0m` : "\x1B[0m"
|
|
870
|
-
];
|
|
871
|
-
}
|
|
872
|
-
get allowedToLog() {
|
|
873
|
-
return this.config ? this.config.get("CONFIG_VERBOSE") !== void 0 && this.config.get("CONFIG_VERBOSE") !== "false" && this.config.get("CONFIG_VERBOSE") !== false : true;
|
|
874
|
-
}
|
|
875
|
-
log(param1, ...args) {
|
|
876
|
-
if (!this.allowedToLog)
|
|
877
|
-
return;
|
|
878
|
-
if (typeof param1 === "string" && this.colors[param1]) {
|
|
879
|
-
console.log(...this.compile(param1, ...args));
|
|
880
|
-
return;
|
|
881
|
-
} else {
|
|
882
|
-
console.log(...this.compile("blue", param1, ...args));
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
warning(...args) {
|
|
886
|
-
if (!this.allowedToLog)
|
|
887
|
-
return;
|
|
888
|
-
console.log(...this.compile("yellow", ...args));
|
|
889
|
-
}
|
|
890
|
-
error(...args) {
|
|
891
|
-
if (this.config && this.config.get("CONFIG_IGNORE_ERRORS"))
|
|
892
|
-
return;
|
|
893
|
-
return console.log(...this.compile("red", ...args));
|
|
894
|
-
}
|
|
895
|
-
log_A_Error(error) {
|
|
896
|
-
const time = this.getTime();
|
|
897
|
-
console.log(`\x1B[31m[${this.scope.name}] |${time}| ERROR ${error.code}
|
|
898
|
-
${" ".repeat(this.scopeLength + 3)}| ${error.message}
|
|
899
|
-
${" ".repeat(this.scopeLength + 3)}| ${error.description}
|
|
900
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
901
|
-
${" ".repeat(this.scopeLength + 3)}| ${error.stack?.split("\n").map((line, index) => index === 0 ? line : `${" ".repeat(this.scopeLength + 3)}| ${line}`).join("\n") || "No stack trace"}
|
|
902
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
903
|
-
\x1B[0m` + (error.originalError ? `\x1B[31m${" ".repeat(this.scopeLength + 3)}| Wrapped From ${error.originalError.message}
|
|
904
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
905
|
-
${" ".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"}
|
|
906
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
907
|
-
\x1B[0m` : "") + (error.link ? `\x1B[31m${" ".repeat(this.scopeLength + 3)}| Read in docs: ${error.link}
|
|
908
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
909
|
-
\x1B[0m` : ""));
|
|
910
|
-
}
|
|
911
|
-
compile_A_Error(error) {
|
|
912
|
-
this.getTime();
|
|
913
|
-
return `
|
|
914
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
915
|
-
${" ".repeat(this.scopeLength + 3)}| Error: | ${error.code}
|
|
916
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
917
|
-
${" ".repeat(this.scopeLength + 3)}|${" ".repeat(10)}| ${error.message}
|
|
918
|
-
${" ".repeat(this.scopeLength + 3)}|${" ".repeat(10)}| ${error.description}
|
|
919
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
920
|
-
${" ".repeat(this.scopeLength + 3)}| ${error.stack?.split("\n").map((line, index) => index === 0 ? line : `${" ".repeat(this.scopeLength + 3)}| ${line}`).join("\n") || "No stack trace"}
|
|
921
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------` + (error.originalError ? `${" ".repeat(this.scopeLength + 3)}| Wrapped From ${error.originalError.message}
|
|
922
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
923
|
-
${" ".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"}
|
|
924
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------` : "") + (error.link ? `${" ".repeat(this.scopeLength + 3)}| Read in docs: ${error.link}
|
|
925
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------` : "");
|
|
926
|
-
}
|
|
927
|
-
compile_Error(error) {
|
|
928
|
-
return JSON.stringify({
|
|
929
|
-
name: error.name,
|
|
930
|
-
message: error.message,
|
|
931
|
-
stack: error.stack?.split("\n").map((line, index) => index === 0 ? line : `${" ".repeat(this.scopeLength + 3)}| ${line}`).join("\n")
|
|
932
|
-
}, null, 2).replace(/\n/g, `
|
|
933
|
-
${" ".repeat(this.scopeLength + 3)}| `).replace(/\\n/g, "\n");
|
|
934
|
-
}
|
|
935
|
-
getTime() {
|
|
936
|
-
const now = /* @__PURE__ */ new Date();
|
|
937
|
-
const minutes = String(now.getMinutes()).padStart(2, "0");
|
|
938
|
-
const seconds = String(now.getSeconds()).padStart(2, "0");
|
|
939
|
-
const milliseconds = String(now.getMilliseconds()).padStart(4, "0");
|
|
940
|
-
return `${minutes}:${seconds}:${milliseconds}`;
|
|
941
|
-
}
|
|
942
|
-
};
|
|
943
|
-
A_Logger = __decorateClass([
|
|
944
|
-
__decorateParam(0, A_Inject(A_Scope))
|
|
945
|
-
], A_Logger);
|
|
946
1225
|
var A_FSPolyfillClass = class {
|
|
947
1226
|
constructor(logger) {
|
|
948
1227
|
this.logger = logger;
|
|
@@ -1656,18 +1935,17 @@ var ConfigReader = class extends A_Component {
|
|
|
1656
1935
|
super();
|
|
1657
1936
|
this.polyfill = polyfill;
|
|
1658
1937
|
}
|
|
1659
|
-
async attachContext(container, feature) {
|
|
1660
|
-
if (!
|
|
1661
|
-
|
|
1938
|
+
async attachContext(container, feature, config) {
|
|
1939
|
+
if (!config) {
|
|
1940
|
+
config = new A_Config({
|
|
1662
1941
|
variables: [
|
|
1663
1942
|
...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,
|
|
1664
1943
|
...A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY
|
|
1665
1944
|
],
|
|
1666
1945
|
defaults: {}
|
|
1667
1946
|
});
|
|
1668
|
-
container.scope.register(
|
|
1947
|
+
container.scope.register(config);
|
|
1669
1948
|
}
|
|
1670
|
-
const config = container.scope.resolve(A_Config);
|
|
1671
1949
|
const rootDir = await this.getProjectRoot();
|
|
1672
1950
|
config.set("A_CONCEPT_ROOT_FOLDER", rootDir);
|
|
1673
1951
|
}
|
|
@@ -1707,7 +1985,8 @@ var ConfigReader = class extends A_Component {
|
|
|
1707
1985
|
__decorateClass([
|
|
1708
1986
|
A_Concept.Load(),
|
|
1709
1987
|
__decorateParam(0, A_Inject(A_Container)),
|
|
1710
|
-
__decorateParam(1, A_Inject(A_Feature))
|
|
1988
|
+
__decorateParam(1, A_Inject(A_Feature)),
|
|
1989
|
+
__decorateParam(2, A_Inject(A_Config))
|
|
1711
1990
|
], ConfigReader.prototype, "attachContext", 1);
|
|
1712
1991
|
__decorateClass([
|
|
1713
1992
|
A_Concept.Load(),
|
|
@@ -2089,6 +2368,6 @@ var A_Schedule = class extends A_Component {
|
|
|
2089
2368
|
}
|
|
2090
2369
|
};
|
|
2091
2370
|
|
|
2092
|
-
export {
|
|
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 };
|
|
2093
2372
|
//# sourceMappingURL=index.mjs.map
|
|
2094
2373
|
//# sourceMappingURL=index.mjs.map
|