@adaas/a-utils 0.1.10 → 0.1.12

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.
Files changed (125) hide show
  1. package/README.md +87 -32
  2. package/dist/index.d.mts +933 -0
  3. package/dist/index.d.ts +933 -27
  4. package/dist/index.js +1786 -90
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +1764 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/examples/command-examples.ts +268 -0
  9. package/package.json +5 -3
  10. package/src/index.ts +70 -0
  11. package/src/lib/A-Command/A-Command.constants.ts +4 -0
  12. package/src/lib/A-Command/A-Command.entity.ts +31 -13
  13. package/src/lib/A-Command/A-Command.types.ts +6 -1
  14. package/src/lib/A-Command/README.md +645 -0
  15. package/src/lib/A-Logger/A-Logger.component.ts +10 -3
  16. package/src/lib/A-Memory/A-Memory.context.ts +15 -0
  17. package/src/lib/A-Polyfill/A-Polyfill.component.ts +153 -15
  18. package/src/lib/A-Polyfill/A-Polyfill.types.ts +54 -0
  19. package/src/lib/A-Polyfill/classes/A-Buffer-Polyfill.class.ts +85 -0
  20. package/src/lib/A-Polyfill/classes/A-Crypto-Polyfill.class.ts +87 -0
  21. package/src/lib/A-Polyfill/classes/A-FS-Polyfill.class.ts +61 -0
  22. package/src/lib/A-Polyfill/classes/A-Http-Polyfill.class.ts +100 -0
  23. package/src/lib/A-Polyfill/classes/A-Https-Polyfill.class.ts +100 -0
  24. package/src/lib/A-Polyfill/classes/A-Path-Polyfill.class.ts +97 -0
  25. package/src/lib/A-Polyfill/classes/A-Process-Polyfill.class.ts +73 -0
  26. package/src/lib/A-Polyfill/classes/A-Url-Polyfill.class.ts +88 -0
  27. package/tests/A-Command.test.ts +447 -2
  28. package/tests/A-Config.test.ts +5 -5
  29. package/tests/A-Memory.test.ts +189 -0
  30. package/tests/A-Polyfill.test.ts +446 -29
  31. package/tsconfig.json +1 -1
  32. package/tsup.config.ts +15 -0
  33. package/dist/src/constants/errors.constants.d.ts +0 -0
  34. package/dist/src/constants/errors.constants.js +0 -2
  35. package/dist/src/constants/errors.constants.js.map +0 -1
  36. package/dist/src/lib/A-Channel/A-Channel.component.d.ts +0 -22
  37. package/dist/src/lib/A-Channel/A-Channel.component.js +0 -84
  38. package/dist/src/lib/A-Channel/A-Channel.component.js.map +0 -1
  39. package/dist/src/lib/A-Channel/A-Channel.error.d.ts +0 -4
  40. package/dist/src/lib/A-Channel/A-Channel.error.js +0 -9
  41. package/dist/src/lib/A-Channel/A-Channel.error.js.map +0 -1
  42. package/dist/src/lib/A-Channel/A-Channel.types.d.ts +0 -0
  43. package/dist/src/lib/A-Channel/A-Channel.types.js +0 -2
  44. package/dist/src/lib/A-Channel/A-Channel.types.js.map +0 -1
  45. package/dist/src/lib/A-Command/A-Command.constants.d.ts +0 -22
  46. package/dist/src/lib/A-Command/A-Command.constants.js +0 -28
  47. package/dist/src/lib/A-Command/A-Command.constants.js.map +0 -1
  48. package/dist/src/lib/A-Command/A-Command.entity.d.ts +0 -133
  49. package/dist/src/lib/A-Command/A-Command.entity.js +0 -273
  50. package/dist/src/lib/A-Command/A-Command.entity.js.map +0 -1
  51. package/dist/src/lib/A-Command/A-Command.error.d.ts +0 -3
  52. package/dist/src/lib/A-Command/A-Command.error.js +0 -8
  53. package/dist/src/lib/A-Command/A-Command.error.js.map +0 -1
  54. package/dist/src/lib/A-Command/A-Command.types.d.ts +0 -73
  55. package/dist/src/lib/A-Command/A-Command.types.js +0 -4
  56. package/dist/src/lib/A-Command/A-Command.types.js.map +0 -1
  57. package/dist/src/lib/A-Config/A-Config.constants.d.ts +0 -3
  58. package/dist/src/lib/A-Config/A-Config.constants.js +0 -6
  59. package/dist/src/lib/A-Config/A-Config.constants.js.map +0 -1
  60. package/dist/src/lib/A-Config/A-Config.container.d.ts +0 -6
  61. package/dist/src/lib/A-Config/A-Config.container.js +0 -77
  62. package/dist/src/lib/A-Config/A-Config.container.js.map +0 -1
  63. package/dist/src/lib/A-Config/A-Config.context.d.ts +0 -29
  64. package/dist/src/lib/A-Config/A-Config.context.js +0 -63
  65. package/dist/src/lib/A-Config/A-Config.context.js.map +0 -1
  66. package/dist/src/lib/A-Config/A-Config.error.d.ts +0 -4
  67. package/dist/src/lib/A-Config/A-Config.error.js +0 -9
  68. package/dist/src/lib/A-Config/A-Config.error.js.map +0 -1
  69. package/dist/src/lib/A-Config/A-Config.types.d.ts +0 -19
  70. package/dist/src/lib/A-Config/A-Config.types.js +0 -7
  71. package/dist/src/lib/A-Config/A-Config.types.js.map +0 -1
  72. package/dist/src/lib/A-Config/components/ConfigReader.component.d.ts +0 -30
  73. package/dist/src/lib/A-Config/components/ConfigReader.component.js +0 -103
  74. package/dist/src/lib/A-Config/components/ConfigReader.component.js.map +0 -1
  75. package/dist/src/lib/A-Config/components/ENVConfigReader.component.d.ts +0 -14
  76. package/dist/src/lib/A-Config/components/ENVConfigReader.component.js +0 -72
  77. package/dist/src/lib/A-Config/components/ENVConfigReader.component.js.map +0 -1
  78. package/dist/src/lib/A-Config/components/FileConfigReader.component.d.ts +0 -11
  79. package/dist/src/lib/A-Config/components/FileConfigReader.component.js +0 -47
  80. package/dist/src/lib/A-Config/components/FileConfigReader.component.js.map +0 -1
  81. package/dist/src/lib/A-Logger/A-Logger.component.d.ts +0 -29
  82. package/dist/src/lib/A-Logger/A-Logger.component.js +0 -152
  83. package/dist/src/lib/A-Logger/A-Logger.component.js.map +0 -1
  84. package/dist/src/lib/A-Logger/A-Logger.types.d.ts +0 -0
  85. package/dist/src/lib/A-Logger/A-Logger.types.js +0 -2
  86. package/dist/src/lib/A-Logger/A-Logger.types.js.map +0 -1
  87. package/dist/src/lib/A-Manifest/A-Manifest.context.d.ts +0 -52
  88. package/dist/src/lib/A-Manifest/A-Manifest.context.js +0 -154
  89. package/dist/src/lib/A-Manifest/A-Manifest.context.js.map +0 -1
  90. package/dist/src/lib/A-Manifest/A-Manifest.error.d.ts +0 -4
  91. package/dist/src/lib/A-Manifest/A-Manifest.error.js +0 -9
  92. package/dist/src/lib/A-Manifest/A-Manifest.error.js.map +0 -1
  93. package/dist/src/lib/A-Manifest/A-Manifest.types.d.ts +0 -43
  94. package/dist/src/lib/A-Manifest/A-Manifest.types.js +0 -3
  95. package/dist/src/lib/A-Manifest/A-Manifest.types.js.map +0 -1
  96. package/dist/src/lib/A-Manifest/classes/A-ManifestChecker.class.d.ts +0 -14
  97. package/dist/src/lib/A-Manifest/classes/A-ManifestChecker.class.js +0 -24
  98. package/dist/src/lib/A-Manifest/classes/A-ManifestChecker.class.js.map +0 -1
  99. package/dist/src/lib/A-Memory/A-Memory.context.d.ts +0 -64
  100. package/dist/src/lib/A-Memory/A-Memory.context.js +0 -105
  101. package/dist/src/lib/A-Memory/A-Memory.context.js.map +0 -1
  102. package/dist/src/lib/A-Polyfill/A-Polyfill.component.d.ts +0 -20
  103. package/dist/src/lib/A-Polyfill/A-Polyfill.component.js +0 -53
  104. package/dist/src/lib/A-Polyfill/A-Polyfill.component.js.map +0 -1
  105. package/dist/src/lib/A-Polyfill/A-Polyfill.types.d.ts +0 -9
  106. package/dist/src/lib/A-Polyfill/A-Polyfill.types.js +0 -3
  107. package/dist/src/lib/A-Polyfill/A-Polyfill.types.js.map +0 -1
  108. package/dist/src/lib/A-Polyfill/A-Polyfills.class.d.ts +0 -11
  109. package/dist/src/lib/A-Polyfill/A-Polyfills.class.js +0 -123
  110. package/dist/src/lib/A-Polyfill/A-Polyfills.class.js.map +0 -1
  111. package/dist/src/lib/A-Schedule/A-Deferred.class.d.ts +0 -12
  112. package/dist/src/lib/A-Schedule/A-Deferred.class.js +0 -23
  113. package/dist/src/lib/A-Schedule/A-Deferred.class.js.map +0 -1
  114. package/dist/src/lib/A-Schedule/A-Schedule.component.d.ts +0 -57
  115. package/dist/src/lib/A-Schedule/A-Schedule.component.js +0 -49
  116. package/dist/src/lib/A-Schedule/A-Schedule.component.js.map +0 -1
  117. package/dist/src/lib/A-Schedule/A-Schedule.types.d.ts +0 -10
  118. package/dist/src/lib/A-Schedule/A-Schedule.types.js +0 -3
  119. package/dist/src/lib/A-Schedule/A-Schedule.types.js.map +0 -1
  120. package/dist/src/lib/A-Schedule/A-ScheduleObject.class.d.ts +0 -29
  121. package/dist/src/lib/A-Schedule/A-ScheduleObject.class.js +0 -58
  122. package/dist/src/lib/A-Schedule/A-ScheduleObject.class.js.map +0 -1
  123. package/index.ts +0 -71
  124. package/src/lib/A-Polyfill/A-Polyfills.class.ts +0 -99
  125. package/tsconfig.build.json +0 -56
@@ -1 +0,0 @@
1
- {"version":3,"file":"A-Channel.error.js","sourceRoot":"","sources":["../../../../src/lib/A-Channel/A-Channel.error.ts"],"names":[],"mappings":";;;AAAA,gDAA2C;AAG3C,MAAa,cAAe,SAAQ,mBAAO;;AAA3C,wCAIC;AAFmB,mCAAoB,GAAG,kCAAkC,CAAC"}
File without changes
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=A-Channel.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A-Channel.types.js","sourceRoot":"","sources":["../../../../src/lib/A-Channel/A-Channel.types.ts"],"names":[],"mappings":""}
@@ -1,22 +0,0 @@
1
- export declare enum A_TYPES__CommandMetaKey {
2
- EXTENSIONS = "a-command-extensions",
3
- FEATURES = "a-command-features",
4
- ABSTRACTIONS = "a-command-abstractions"
5
- }
6
- export declare enum A_CONSTANTS__A_Command_Status {
7
- INITIALIZED = "INITIALIZED",
8
- IN_PROGRESS = "IN_PROGRESS",
9
- COMPLETED = "COMPLETED",
10
- FAILED = "FAILED"
11
- }
12
- /**
13
- * A-Command Lifecycle Features
14
- */
15
- export declare enum A_CONSTANTS_A_Command_Features {
16
- INIT = "init",
17
- COMPLIED = "complied",
18
- EXECUTE = "execute",
19
- COMPLETE = "complete",
20
- FAIL = "fail"
21
- }
22
- export type A_CONSTANTS__A_Command_Event = 'init' | 'compile' | 'execute' | 'complete' | 'fail';
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.A_CONSTANTS_A_Command_Features = exports.A_CONSTANTS__A_Command_Status = exports.A_TYPES__CommandMetaKey = void 0;
4
- var A_TYPES__CommandMetaKey;
5
- (function (A_TYPES__CommandMetaKey) {
6
- A_TYPES__CommandMetaKey["EXTENSIONS"] = "a-command-extensions";
7
- A_TYPES__CommandMetaKey["FEATURES"] = "a-command-features";
8
- A_TYPES__CommandMetaKey["ABSTRACTIONS"] = "a-command-abstractions";
9
- })(A_TYPES__CommandMetaKey || (exports.A_TYPES__CommandMetaKey = A_TYPES__CommandMetaKey = {}));
10
- var A_CONSTANTS__A_Command_Status;
11
- (function (A_CONSTANTS__A_Command_Status) {
12
- A_CONSTANTS__A_Command_Status["INITIALIZED"] = "INITIALIZED";
13
- A_CONSTANTS__A_Command_Status["IN_PROGRESS"] = "IN_PROGRESS";
14
- A_CONSTANTS__A_Command_Status["COMPLETED"] = "COMPLETED";
15
- A_CONSTANTS__A_Command_Status["FAILED"] = "FAILED";
16
- })(A_CONSTANTS__A_Command_Status || (exports.A_CONSTANTS__A_Command_Status = A_CONSTANTS__A_Command_Status = {}));
17
- /**
18
- * A-Command Lifecycle Features
19
- */
20
- var A_CONSTANTS_A_Command_Features;
21
- (function (A_CONSTANTS_A_Command_Features) {
22
- A_CONSTANTS_A_Command_Features["INIT"] = "init";
23
- A_CONSTANTS_A_Command_Features["COMPLIED"] = "complied";
24
- A_CONSTANTS_A_Command_Features["EXECUTE"] = "execute";
25
- A_CONSTANTS_A_Command_Features["COMPLETE"] = "complete";
26
- A_CONSTANTS_A_Command_Features["FAIL"] = "fail";
27
- })(A_CONSTANTS_A_Command_Features || (exports.A_CONSTANTS_A_Command_Features = A_CONSTANTS_A_Command_Features = {}));
28
- //# sourceMappingURL=A-Command.constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A-Command.constants.js","sourceRoot":"","sources":["../../../../src/lib/A-Command/A-Command.constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,uBAIX;AAJD,WAAY,uBAAuB;IAC/B,8DAAmC,CAAA;IACnC,0DAA+B,CAAA;IAC/B,kEAAuC,CAAA;AAC3C,CAAC,EAJW,uBAAuB,uCAAvB,uBAAuB,QAIlC;AAED,IAAY,6BAKX;AALD,WAAY,6BAA6B;IACrC,4DAA2B,CAAA;IAC3B,4DAA2B,CAAA;IAC3B,wDAAuB,CAAA;IACvB,kDAAiB,CAAA;AACrB,CAAC,EALW,6BAA6B,6CAA7B,6BAA6B,QAKxC;AAED;;GAEG;AACH,IAAY,8BAMX;AAND,WAAY,8BAA8B;IACtC,+CAAa,CAAA;IACb,uDAAqB,CAAA;IACrB,qDAAmB,CAAA;IACnB,uDAAqB,CAAA;IACrB,+CAAa,CAAA;AACjB,CAAC,EANW,8BAA8B,8CAA9B,8BAA8B,QAMzC"}
@@ -1,133 +0,0 @@
1
- import { A_TYPES__Command_Init, A_TYPES__Command_Listener, A_TYPES__Command_Serialized } from "./A-Command.types";
2
- import { A_CONSTANTS__A_Command_Event, A_CONSTANTS__A_Command_Status } from "./A-Command.constants";
3
- import { A_Entity, A_Error, A_Scope } from "@adaas/a-concept";
4
- export declare class A_Command<InvokeType extends A_TYPES__Command_Init = A_TYPES__Command_Init, ResultType extends Record<string, any> = Record<string, any>, LifecycleEvents extends string = A_CONSTANTS__A_Command_Event> extends A_Entity<InvokeType, A_TYPES__Command_Serialized<ResultType>> {
5
- /**
6
- * Command Identifier that corresponds to the class name
7
- */
8
- static get code(): string;
9
- protected _result?: ResultType;
10
- protected _executionScope: A_Scope;
11
- protected _errors?: Set<A_Error>;
12
- protected _params: InvokeType;
13
- protected _status: A_CONSTANTS__A_Command_Status;
14
- protected _listeners: Map<LifecycleEvents | A_CONSTANTS__A_Command_Event, Set<A_TYPES__Command_Listener<InvokeType, ResultType, LifecycleEvents>>>;
15
- protected _startTime?: Date;
16
- protected _endTime?: Date;
17
- /**
18
- * Execution Duration in milliseconds
19
- */
20
- get duration(): number | undefined;
21
- /**
22
- * A shared scope between all features of the command during its execution
23
- */
24
- get scope(): A_Scope;
25
- /**
26
- * Unique code identifying the command type
27
- * Example: 'user.create', 'task.complete', etc.
28
- *
29
- */
30
- get code(): string;
31
- /**
32
- * Current status of the command
33
- */
34
- get status(): A_CONSTANTS__A_Command_Status;
35
- /**
36
- * Start time of the command execution
37
- */
38
- get startedAt(): Date | undefined;
39
- /**
40
- * End time of the command execution
41
- */
42
- get endedAt(): Date | undefined;
43
- /**
44
- * Result of the command execution stored in the context
45
- */
46
- get result(): ResultType | undefined;
47
- /**
48
- * Errors encountered during the command execution stored in the context
49
- */
50
- get errors(): Set<A_Error> | undefined;
51
- /**
52
- * Parameters used to invoke the command
53
- */
54
- get params(): InvokeType;
55
- /**
56
- * Indicates if the command has failed
57
- */
58
- get isFailed(): boolean;
59
- /**
60
- * Indicates if the command has completed successfully
61
- */
62
- get isCompleted(): boolean;
63
- /**
64
- *
65
- * A-Command represents an executable command with a specific code and parameters.
66
- * It can be executed within a given scope and stores execution results and errors.
67
- *
68
- *
69
- * A-Command should be context independent and execution logic should be based on attached components
70
- *
71
- * @param code
72
- * @param params
73
- */
74
- constructor(
75
- /**
76
- * Command invocation parameters
77
- */
78
- params: InvokeType | A_TYPES__Command_Serialized<ResultType> | string);
79
- init(): Promise<void>;
80
- compile(): Promise<void>;
81
- /**
82
- * Executes the command logic.
83
- */
84
- execute(): Promise<any>;
85
- /**
86
- * Marks the command as completed
87
- */
88
- complete(): Promise<void>;
89
- /**
90
- * Marks the command as failed
91
- */
92
- fail(): Promise<void>;
93
- /**
94
- * Registers an event listener for a specific event
95
- *
96
- * @param event
97
- * @param listener
98
- */
99
- on(event: LifecycleEvents | A_CONSTANTS__A_Command_Event, listener: A_TYPES__Command_Listener<InvokeType, ResultType, LifecycleEvents>): void;
100
- /**
101
- * Removes an event listener for a specific event
102
- *
103
- * @param event
104
- * @param listener
105
- */
106
- off(event: LifecycleEvents | A_CONSTANTS__A_Command_Event, listener: A_TYPES__Command_Listener<InvokeType, ResultType, LifecycleEvents>): void;
107
- /**
108
- * Emits an event to all registered listeners
109
- *
110
- * @param event
111
- */
112
- emit(event: LifecycleEvents | A_CONSTANTS__A_Command_Event): void;
113
- /**
114
- * Allows to create a Command instance from new data
115
- *
116
- * @param newEntity
117
- */
118
- fromNew(newEntity: InvokeType): void;
119
- /**
120
- * Allows to convert serialized data to Command instance
121
- *
122
- * [!] By default it omits params as they are not stored in the serialized data
123
- *
124
- * @param serialized
125
- */
126
- fromJSON(serialized: A_TYPES__Command_Serialized<ResultType>): void;
127
- /**
128
- * Converts the Command instance to a plain object
129
- *
130
- * @returns
131
- */
132
- toJSON(): A_TYPES__Command_Serialized<ResultType>;
133
- }
@@ -1,273 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.A_Command = void 0;
13
- const A_Command_constants_1 = require("./A-Command.constants");
14
- const a_concept_1 = require("@adaas/a-concept");
15
- const A_Memory_context_1 = require("../A-Memory/A-Memory.context");
16
- class A_Command extends a_concept_1.A_Entity {
17
- // ====================================================================
18
- // ================== Static A-Command Information ====================
19
- // ====================================================================
20
- /**
21
- * Command Identifier that corresponds to the class name
22
- */
23
- static get code() {
24
- return super.entity;
25
- }
26
- /**
27
- * Execution Duration in milliseconds
28
- */
29
- get duration() {
30
- return this._endTime && this._startTime
31
- ? this._endTime.getTime() - this._startTime.getTime()
32
- : this._startTime
33
- ? new Date().getTime() - this._startTime.getTime()
34
- : undefined;
35
- }
36
- /**
37
- * A shared scope between all features of the command during its execution
38
- */
39
- get scope() {
40
- return this._executionScope;
41
- }
42
- /**
43
- * Unique code identifying the command type
44
- * Example: 'user.create', 'task.complete', etc.
45
- *
46
- */
47
- get code() {
48
- return this.constructor.code;
49
- }
50
- /**
51
- * Current status of the command
52
- */
53
- get status() {
54
- return this._status;
55
- }
56
- /**
57
- * Start time of the command execution
58
- */
59
- get startedAt() {
60
- return this._startTime;
61
- }
62
- /**
63
- * End time of the command execution
64
- */
65
- get endedAt() {
66
- return this._endTime;
67
- }
68
- /**
69
- * Result of the command execution stored in the context
70
- */
71
- get result() {
72
- return this._result;
73
- }
74
- /**
75
- * Errors encountered during the command execution stored in the context
76
- */
77
- get errors() {
78
- return this._errors;
79
- }
80
- /**
81
- * Parameters used to invoke the command
82
- */
83
- get params() {
84
- return this._params;
85
- }
86
- /**
87
- * Indicates if the command has failed
88
- */
89
- get isFailed() {
90
- return this._status === A_Command_constants_1.A_CONSTANTS__A_Command_Status.FAILED;
91
- }
92
- /**
93
- * Indicates if the command has completed successfully
94
- */
95
- get isCompleted() {
96
- return this._status === A_Command_constants_1.A_CONSTANTS__A_Command_Status.COMPLETED;
97
- }
98
- /**
99
- *
100
- * A-Command represents an executable command with a specific code and parameters.
101
- * It can be executed within a given scope and stores execution results and errors.
102
- *
103
- *
104
- * A-Command should be context independent and execution logic should be based on attached components
105
- *
106
- * @param code
107
- * @param params
108
- */
109
- constructor(
110
- /**
111
- * Command invocation parameters
112
- */
113
- params) {
114
- super(params);
115
- this._listeners = new Map();
116
- }
117
- // --------------------------------------------------------------------------
118
- // A-Command Lifecycle Methods
119
- // --------------------------------------------------------------------------
120
- // should create a new Task in DB with basic records
121
- init() {
122
- return __awaiter(this, void 0, void 0, function* () {
123
- this._status = A_Command_constants_1.A_CONSTANTS__A_Command_Status.IN_PROGRESS;
124
- this._startTime = new Date();
125
- if (!this.scope.isInheritedFrom(a_concept_1.A_Context.scope(this))) {
126
- this.scope.inherit(a_concept_1.A_Context.scope(this));
127
- }
128
- this.emit('init');
129
- return yield this.call('init', this.scope);
130
- });
131
- }
132
- // Should compile everything before execution
133
- compile() {
134
- return __awaiter(this, void 0, void 0, function* () {
135
- this.emit('compile');
136
- return yield this.call('compile', this.scope);
137
- });
138
- }
139
- /**
140
- * Executes the command logic.
141
- */
142
- execute() {
143
- return __awaiter(this, void 0, void 0, function* () {
144
- try {
145
- yield this.init();
146
- yield this.compile();
147
- this.emit('execute');
148
- yield this.call('execute', this.scope);
149
- yield this.complete();
150
- }
151
- catch (error) {
152
- yield this.fail();
153
- }
154
- });
155
- }
156
- /**
157
- * Marks the command as completed
158
- */
159
- complete() {
160
- return __awaiter(this, void 0, void 0, function* () {
161
- this._status = A_Command_constants_1.A_CONSTANTS__A_Command_Status.COMPLETED;
162
- this._endTime = new Date();
163
- this._result = this.scope.resolve(A_Memory_context_1.A_Memory).toJSON();
164
- this.emit('complete');
165
- return yield this.call('complete', this.scope);
166
- });
167
- }
168
- /**
169
- * Marks the command as failed
170
- */
171
- fail() {
172
- return __awaiter(this, void 0, void 0, function* () {
173
- this._status = A_Command_constants_1.A_CONSTANTS__A_Command_Status.FAILED;
174
- this._endTime = new Date();
175
- this._errors = this.scope.resolve(A_Memory_context_1.A_Memory).Errors;
176
- this.emit('fail');
177
- return yield this.call('fail', this.scope);
178
- });
179
- }
180
- // --------------------------------------------------------------------------
181
- // A-Command Event-Emitter methods
182
- // --------------------------------------------------------------------------
183
- /**
184
- * Registers an event listener for a specific event
185
- *
186
- * @param event
187
- * @param listener
188
- */
189
- on(event, listener) {
190
- if (!this._listeners.has(event)) {
191
- this._listeners.set(event, new Set());
192
- }
193
- this._listeners.get(event).add(listener);
194
- }
195
- /**
196
- * Removes an event listener for a specific event
197
- *
198
- * @param event
199
- * @param listener
200
- */
201
- off(event, listener) {
202
- var _a;
203
- (_a = this._listeners.get(event)) === null || _a === void 0 ? void 0 : _a.delete(listener);
204
- }
205
- /**
206
- * Emits an event to all registered listeners
207
- *
208
- * @param event
209
- */
210
- emit(event) {
211
- var _a;
212
- (_a = this._listeners.get(event)) === null || _a === void 0 ? void 0 : _a.forEach(listener => {
213
- listener(this);
214
- });
215
- }
216
- // --------------------------------------------------------------------------
217
- // A-Entity Base Class Overrides
218
- // --------------------------------------------------------------------------
219
- // Serialization / Deserialization
220
- // -------------------------------------------------------------------------
221
- /**
222
- * Allows to create a Command instance from new data
223
- *
224
- * @param newEntity
225
- */
226
- fromNew(newEntity) {
227
- super.fromNew(newEntity);
228
- this._executionScope = new a_concept_1.A_Scope();
229
- this._executionScope.register(new A_Memory_context_1.A_Memory());
230
- this._params = newEntity;
231
- this._status = A_Command_constants_1.A_CONSTANTS__A_Command_Status.INITIALIZED;
232
- }
233
- /**
234
- * Allows to convert serialized data to Command instance
235
- *
236
- * [!] By default it omits params as they are not stored in the serialized data
237
- *
238
- * @param serialized
239
- */
240
- fromJSON(serialized) {
241
- super.fromJSON(serialized);
242
- this._executionScope = new a_concept_1.A_Scope();
243
- const memory = new A_Memory_context_1.A_Memory();
244
- this._executionScope.register(memory);
245
- if (serialized.startedAt)
246
- this._startTime = new Date(serialized.startedAt);
247
- if (serialized.endedAt)
248
- this._endTime = new Date(serialized.endedAt);
249
- // Restore result and errors in the memory
250
- if (serialized.result) {
251
- Object.entries(serialized.result).forEach(([key, value]) => {
252
- memory.set(key, value);
253
- });
254
- }
255
- if (serialized.errors) {
256
- serialized.errors.forEach(err => {
257
- memory.error(new a_concept_1.A_Error(err));
258
- });
259
- }
260
- this._status = serialized.status || A_Command_constants_1.A_CONSTANTS__A_Command_Status.INITIALIZED;
261
- }
262
- /**
263
- * Converts the Command instance to a plain object
264
- *
265
- * @returns
266
- */
267
- toJSON() {
268
- return Object.assign(Object.assign({}, super.toJSON()), { code: this.code, status: this._status, startedAt: this._startTime ? this._startTime.toISOString() : undefined, endedAt: this._endTime ? this._endTime.toISOString() : undefined, duration: this.duration, result: this.result, errors: this.errors ? Array.from(this.errors).map(err => err.toJSON()) : undefined });
269
- }
270
- ;
271
- }
272
- exports.A_Command = A_Command;
273
- //# sourceMappingURL=A-Command.entity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A-Command.entity.js","sourceRoot":"","sources":["../../../../src/lib/A-Command/A-Command.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,+DAG+B;AAC/B,gDAAyE;AACzE,mEAAwD;AAGxD,MAAa,SAIX,SAAQ,oBAA6D;IAEnE,uEAAuE;IACvE,uEAAuE;IACvE,uEAAuE;IAEvE;;OAEG;IACH,MAAM,KAAK,IAAI;QACX,OAAO,KAAK,CAAC,MAAM,CAAC;IACxB,CAAC;IAsBD;;OAEG;IACH,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,UAAU;YACnC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE;YACrD,CAAC,CAAC,IAAI,CAAC,UAAU;gBACb,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE;gBAClD,CAAC,CAAC,SAAS,CAAC;IACxB,CAAC;IACD;;OAEG;IACH,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IACD;;;;OAIG;IACH,IAAI,IAAI;QACJ,OAAQ,IAAI,CAAC,WAAgC,CAAC,IAAI,CAAC;IACvD,CAAC;IACD;;OAEG;IACH,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IACD;;OAEG;IACH,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IACD;;OAEG;IACH,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IACD;;OAEG;IACH,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,OAAO,C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,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,EAChE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,IACrF;IACL,CAAC;IAAA,CAAC;CACL;AAzTD,8BAyTC"}
@@ -1,3 +0,0 @@
1
- import { A_Error } from "@adaas/a-concept";
2
- export declare class A_CommandError extends A_Error {
3
- }
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.A_CommandError = void 0;
4
- const a_concept_1 = require("@adaas/a-concept");
5
- class A_CommandError extends a_concept_1.A_Error {
6
- }
7
- exports.A_CommandError = A_CommandError;
8
- //# sourceMappingURL=A-Command.error.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A-Command.error.js","sourceRoot":"","sources":["../../../../src/lib/A-Command/A-Command.error.ts"],"names":[],"mappings":";;;AAAA,gDAA2C;AAG3C,MAAa,cAAe,SAAQ,mBAAO;CAE1C;AAFD,wCAEC"}
@@ -1,73 +0,0 @@
1
- import { A_Command } from "./A-Command.entity";
2
- import { A_CONSTANTS__A_Command_Event, A_CONSTANTS__A_Command_Status, A_TYPES__CommandMetaKey } from "./A-Command.constants";
3
- import { A_Meta, A_TYPES__Entity_Serialized, A_TYPES__Error_Serialized, A_TYPES__FeatureDefineDecoratorMeta, A_TYPES__FeatureExtendDecoratorMeta } from "@adaas/a-concept";
4
- /**
5
- * Command constructor type
6
- * Uses the generic type T to specify the type of the entity
7
- */
8
- export type A_TYPES__Command_Constructor<T = A_Command> = new (...args: any[]) => T;
9
- /**
10
- * Command initialization type
11
- */
12
- export type A_TYPES__Command_Init = any;
13
- /**
14
- * Command serialized type
15
- */
16
- export type A_TYPES__Command_Serialized<ResultType extends Record<string, any> = Record<string, any>> = {
17
- /**
18
- * Unique code of the command
19
- */
20
- code: string;
21
- /**
22
- * Current status of the command
23
- */
24
- status: A_CONSTANTS__A_Command_Status;
25
- /**
26
- * The time when the command was created
27
- */
28
- startedAt?: string;
29
- /**
30
- * The time when the command execution ended
31
- */
32
- endedAt?: string;
33
- /**
34
- * Duration of the command execution in milliseconds
35
- */
36
- duration?: number;
37
- /**
38
- * Result of the command execution
39
- */
40
- result?: ResultType;
41
- /**
42
- * List of errors occurred during the command execution
43
- */
44
- errors?: Array<A_TYPES__Error_Serialized>;
45
- } & A_TYPES__Entity_Serialized;
46
- /**
47
- * Command listener type
48
- */
49
- export type A_TYPES__Command_Listener<InvokeType extends A_TYPES__Command_Init = A_TYPES__Command_Init, ResultType extends Record<string, any> = Record<string, any>, LifecycleEvents extends string = A_CONSTANTS__A_Command_Event> = (command?: A_Command<InvokeType, ResultType, LifecycleEvents>) => void;
50
- /**
51
- * Command meta type
52
- */
53
- export type A_TYPES__CommandMeta = {
54
- [A_TYPES__CommandMetaKey.EXTENSIONS]: A_Meta<{
55
- /**
56
- * Where Key the regexp for what to apply the extension
57
- * A set of container names or a wildcard, or a regexp
58
- *
59
- *
60
- * Where value is the extension instructions
61
- */
62
- [Key: string]: A_TYPES__FeatureExtendDecoratorMeta[];
63
- }>;
64
- case: any;
65
- [A_TYPES__CommandMetaKey.FEATURES]: A_Meta<{
66
- /**
67
- * Where Key is the name of the feature
68
- *
69
- * Where value is the list of features
70
- */
71
- [Key: string]: A_TYPES__FeatureDefineDecoratorMeta;
72
- }>;
73
- };
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const A_Command_constants_1 = require("./A-Command.constants");
4
- //# sourceMappingURL=A-Command.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A-Command.types.js","sourceRoot":"","sources":["../../../../src/lib/A-Command/A-Command.types.ts"],"names":[],"mappings":";;AACA,+DAA6H"}
@@ -1,3 +0,0 @@
1
- export declare const A_CONSTANTS__CONFIG_ENV_VARIABLES: {};
2
- export type A_TYPES__ConfigENVVariables = (typeof A_CONSTANTS__CONFIG_ENV_VARIABLES)[keyof typeof A_CONSTANTS__CONFIG_ENV_VARIABLES][];
3
- export declare const A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY: readonly [];
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY = exports.A_CONSTANTS__CONFIG_ENV_VARIABLES = void 0;
4
- exports.A_CONSTANTS__CONFIG_ENV_VARIABLES = {};
5
- exports.A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY = [];
6
- //# sourceMappingURL=A-Config.constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A-Config.constants.js","sourceRoot":"","sources":["../../../../src/lib/A-Config/A-Config.constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,iCAAiC,GAAG,EAEvC,CAAA;AAOG,QAAA,uCAAuC,GAAG,EAE7C,CAAC"}
@@ -1,6 +0,0 @@
1
- import { A_Container } from "@adaas/a-concept";
2
- import { A_Polyfill } from "../A-Polyfill/A-Polyfill.component";
3
- export declare class A_ConfigLoader extends A_Container {
4
- private reader;
5
- prepare(polyfill: A_Polyfill): Promise<void>;
6
- }