@adaas/a-utils 0.0.9 → 0.1.2

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 (175) hide show
  1. package/dist/index.d.ts +22 -15
  2. package/dist/index.js +56 -22
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/constants/errors.constants.d.ts +0 -65
  5. package/dist/src/constants/errors.constants.js +0 -72
  6. package/dist/src/constants/errors.constants.js.map +1 -1
  7. package/dist/src/lib/A-Channel/A-Channel.component.d.ts +3 -0
  8. package/dist/src/lib/A-Channel/A-Channel.component.js +8 -0
  9. package/dist/src/lib/A-Channel/A-Channel.component.js.map +1 -0
  10. package/dist/src/lib/A-Channel/A-Channel.error.d.ts +3 -0
  11. package/dist/src/lib/A-Channel/A-Channel.error.js +8 -0
  12. package/dist/src/lib/A-Channel/A-Channel.error.js.map +1 -0
  13. package/dist/src/lib/A-Channel/A-Channel.types.d.ts +0 -0
  14. package/dist/src/lib/A-Channel/A-Channel.types.js +2 -0
  15. package/dist/src/lib/A-Channel/A-Channel.types.js.map +1 -0
  16. package/dist/src/lib/A-Command/A-Command.constants.d.ts +22 -0
  17. package/dist/src/lib/A-Command/A-Command.constants.js +28 -0
  18. package/dist/src/lib/A-Command/A-Command.constants.js.map +1 -0
  19. package/dist/src/lib/A-Command/A-Command.entity.d.ts +133 -0
  20. package/dist/src/lib/A-Command/A-Command.entity.js +273 -0
  21. package/dist/src/lib/A-Command/A-Command.entity.js.map +1 -0
  22. package/dist/src/lib/A-Command/A-Command.error.d.ts +3 -0
  23. package/dist/src/lib/A-Command/A-Command.error.js +8 -0
  24. package/dist/src/lib/A-Command/A-Command.error.js.map +1 -0
  25. package/dist/src/lib/A-Command/A-Command.types.d.ts +73 -0
  26. package/dist/src/lib/A-Command/A-Command.types.js +4 -0
  27. package/dist/src/lib/A-Command/A-Command.types.js.map +1 -0
  28. package/dist/src/lib/A-Config/A-Config.constants.d.ts +3 -0
  29. package/dist/src/lib/A-Config/A-Config.constants.js +6 -0
  30. package/dist/src/lib/A-Config/A-Config.constants.js.map +1 -0
  31. package/dist/src/lib/A-Config/A-Config.container.d.ts +8 -0
  32. package/dist/src/lib/A-Config/A-Config.container.js +75 -0
  33. package/dist/src/lib/A-Config/A-Config.container.js.map +1 -0
  34. package/dist/src/lib/A-Config/A-Config.context.d.ts +29 -0
  35. package/dist/src/lib/A-Config/A-Config.context.js +63 -0
  36. package/dist/src/lib/A-Config/A-Config.context.js.map +1 -0
  37. package/dist/src/lib/A-Config/A-Config.error.d.ts +4 -0
  38. package/dist/src/lib/A-Config/A-Config.error.js +9 -0
  39. package/dist/src/lib/A-Config/A-Config.error.js.map +1 -0
  40. package/dist/src/lib/A-Config/A-Config.types.d.ts +19 -0
  41. package/dist/src/lib/A-Config/A-Config.types.js +7 -0
  42. package/dist/src/lib/A-Config/A-Config.types.js.map +1 -0
  43. package/dist/src/lib/A-Config/components/ConfigReader.component.d.ts +30 -0
  44. package/dist/src/lib/A-Config/components/ConfigReader.component.js +85 -0
  45. package/dist/src/lib/A-Config/components/ConfigReader.component.js.map +1 -0
  46. package/dist/src/lib/A-Config/components/ENVConfigReader.component.d.ts +10 -0
  47. package/dist/src/lib/A-Config/components/ENVConfigReader.component.js +37 -0
  48. package/dist/src/lib/A-Config/components/ENVConfigReader.component.js.map +1 -0
  49. package/dist/src/lib/A-Config/components/FileConfigReader.component.d.ts +11 -0
  50. package/dist/src/lib/A-Config/components/FileConfigReader.component.js +47 -0
  51. package/dist/src/lib/A-Config/components/FileConfigReader.component.js.map +1 -0
  52. package/dist/src/lib/A-Logger/A-Logger.component.d.ts +29 -0
  53. package/dist/src/lib/A-Logger/A-Logger.component.js +152 -0
  54. package/dist/src/lib/A-Logger/A-Logger.component.js.map +1 -0
  55. package/dist/src/lib/A-Logger/A-Logger.types.d.ts +0 -0
  56. package/dist/src/lib/A-Logger/A-Logger.types.js +2 -0
  57. package/dist/src/lib/A-Logger/A-Logger.types.js.map +1 -0
  58. package/dist/src/lib/A-Memory/A-Memory.context.d.ts +64 -0
  59. package/dist/src/lib/A-Memory/A-Memory.context.js +105 -0
  60. package/dist/src/lib/A-Memory/A-Memory.context.js.map +1 -0
  61. package/dist/src/lib/A-Polyfill/A-Polyfill.component.d.ts +20 -0
  62. package/dist/src/lib/A-Polyfill/A-Polyfill.component.js +53 -0
  63. package/dist/src/lib/A-Polyfill/A-Polyfill.component.js.map +1 -0
  64. package/dist/src/{global/A_Polyfills.d.ts → lib/A-Polyfill/A-Polyfill.types.d.ts} +1 -13
  65. package/dist/src/lib/A-Polyfill/A-Polyfill.types.js +2 -0
  66. package/dist/src/lib/A-Polyfill/A-Polyfill.types.js.map +1 -0
  67. package/dist/src/lib/A-Polyfill/A-Polyfills.class.d.ts +10 -0
  68. package/dist/src/{global/A_Polyfills.js → lib/A-Polyfill/A-Polyfills.class.js} +4 -4
  69. package/dist/src/lib/A-Polyfill/A-Polyfills.class.js.map +1 -0
  70. package/dist/src/{global/A_Deferred.class.d.ts → lib/A-Schedule/A-Deferred.class.d.ts} +4 -0
  71. package/dist/src/{global/A_Deferred.class.js → lib/A-Schedule/A-Deferred.class.js} +5 -1
  72. package/dist/src/lib/A-Schedule/A-Deferred.class.js.map +1 -0
  73. package/dist/src/lib/A-Schedule/A-Schedule.component.d.ts +57 -0
  74. package/dist/src/lib/A-Schedule/A-Schedule.component.js +49 -0
  75. package/dist/src/lib/A-Schedule/A-Schedule.component.js.map +1 -0
  76. package/dist/src/{types/A_ScheduleObject.types.d.ts → lib/A-Schedule/A-Schedule.types.d.ts} +2 -1
  77. package/dist/src/{types/ASEID.types.js → lib/A-Schedule/A-Schedule.types.js} +1 -3
  78. package/dist/src/lib/A-Schedule/A-Schedule.types.js.map +1 -0
  79. package/dist/src/lib/A-Schedule/A-ScheduleObject.class.d.ts +29 -0
  80. package/dist/src/{global/A_ScheduleObject.class.js → lib/A-Schedule/A-ScheduleObject.class.js} +25 -5
  81. package/dist/src/lib/A-Schedule/A-ScheduleObject.class.js.map +1 -0
  82. package/index.ts +25 -50
  83. package/jest.config.ts +3 -3
  84. package/package.json +6 -6
  85. package/src/constants/errors.constants.ts +0 -78
  86. package/src/lib/A-Channel/A-Channel.component.ts +8 -0
  87. package/src/lib/A-Channel/A-Channel.error.ts +6 -0
  88. package/src/lib/A-Channel/A-Channel.types.ts +0 -0
  89. package/src/lib/A-Command/A-Command.constants.ts +31 -0
  90. package/src/lib/A-Command/A-Command.entity.ts +327 -0
  91. package/src/lib/A-Command/A-Command.error.ts +6 -0
  92. package/src/lib/A-Command/A-Command.types.ts +100 -0
  93. package/src/lib/A-Config/A-Config.constants.ts +13 -0
  94. package/src/lib/A-Config/A-Config.container.ts +63 -0
  95. package/src/lib/A-Config/A-Config.context.ts +117 -0
  96. package/src/lib/A-Config/A-Config.error.ts +7 -0
  97. package/src/lib/A-Config/A-Config.types.ts +26 -0
  98. package/src/lib/A-Config/components/ConfigReader.component.ts +67 -0
  99. package/src/lib/A-Config/components/ENVConfigReader.component.ts +31 -0
  100. package/src/lib/A-Config/components/FileConfigReader.component.ts +42 -0
  101. package/src/lib/A-Logger/A-Logger.component.ts +190 -0
  102. package/src/lib/A-Logger/A-Logger.types.ts +0 -0
  103. package/src/lib/A-Memory/A-Memory.context.ts +115 -0
  104. package/src/lib/A-Polyfill/A-Polyfill.component.ts +45 -0
  105. package/src/lib/A-Polyfill/A-Polyfill.types.ts +10 -0
  106. package/src/{global/A_Polyfills.ts → lib/A-Polyfill/A-Polyfills.class.ts} +2 -16
  107. package/src/{global/A_Deferred.class.ts → lib/A-Schedule/A-Deferred.class.ts} +4 -0
  108. package/src/lib/A-Schedule/A-Schedule.component.ts +89 -0
  109. package/src/{types/A_ScheduleObject.types.ts → lib/A-Schedule/A-Schedule.types.ts} +7 -2
  110. package/src/{global/A_ScheduleObject.class.ts → lib/A-Schedule/A-ScheduleObject.class.ts} +25 -7
  111. package/tests/A-Channel.test.ts +16 -0
  112. package/tests/A-Command.test.ts +133 -0
  113. package/tests/A-Config.test.ts +185 -0
  114. package/tests/A-Polyfill.test.ts +67 -0
  115. package/tests/A-Schedule.test.ts +84 -0
  116. package/tests/jest.setup.ts +35 -0
  117. package/tsconfig.build.json +56 -0
  118. package/tsconfig.json +2 -2
  119. package/dist/src/global/ASEID.class.d.ts +0 -77
  120. package/dist/src/global/ASEID.class.js +0 -129
  121. package/dist/src/global/ASEID.class.js.map +0 -1
  122. package/dist/src/global/A_Deferred.class.js.map +0 -1
  123. package/dist/src/global/A_Entity.class.d.ts +0 -49
  124. package/dist/src/global/A_Entity.class.js +0 -94
  125. package/dist/src/global/A_Entity.class.js.map +0 -1
  126. package/dist/src/global/A_Error.class.d.ts +0 -13
  127. package/dist/src/global/A_Error.class.js +0 -63
  128. package/dist/src/global/A_Error.class.js.map +0 -1
  129. package/dist/src/global/A_Polyfills.js.map +0 -1
  130. package/dist/src/global/A_ScheduleObject.class.d.ts +0 -9
  131. package/dist/src/global/A_ScheduleObject.class.js.map +0 -1
  132. package/dist/src/global/A_ServerError.class.d.ts +0 -13
  133. package/dist/src/global/A_ServerError.class.js +0 -57
  134. package/dist/src/global/A_ServerError.class.js.map +0 -1
  135. package/dist/src/helpers/A_Common.helper.d.ts +0 -42
  136. package/dist/src/helpers/A_Common.helper.js +0 -214
  137. package/dist/src/helpers/A_Common.helper.js.map +0 -1
  138. package/dist/src/helpers/A_ID.helper.d.ts +0 -17
  139. package/dist/src/helpers/A_ID.helper.js +0 -26
  140. package/dist/src/helpers/A_ID.helper.js.map +0 -1
  141. package/dist/src/helpers/A_Schedule.helper.d.ts +0 -6
  142. package/dist/src/helpers/A_Schedule.helper.js +0 -21
  143. package/dist/src/helpers/A_Schedule.helper.js.map +0 -1
  144. package/dist/src/types/ASEID.types.d.ts +0 -65
  145. package/dist/src/types/ASEID.types.js.map +0 -1
  146. package/dist/src/types/A_Common.types.d.ts +0 -59
  147. package/dist/src/types/A_Common.types.js +0 -3
  148. package/dist/src/types/A_Common.types.js.map +0 -1
  149. package/dist/src/types/A_Entity.types.d.ts +0 -13
  150. package/dist/src/types/A_Entity.types.js +0 -4
  151. package/dist/src/types/A_Entity.types.js.map +0 -1
  152. package/dist/src/types/A_Error.type.d.ts +0 -7
  153. package/dist/src/types/A_Error.type.js +0 -3
  154. package/dist/src/types/A_Error.type.js.map +0 -1
  155. package/dist/src/types/A_Error.types.d.ts +0 -7
  156. package/dist/src/types/A_Error.types.js +0 -3
  157. package/dist/src/types/A_Error.types.js.map +0 -1
  158. package/dist/src/types/A_ScheduleObject.types.js +0 -3
  159. package/dist/src/types/A_ScheduleObject.types.js.map +0 -1
  160. package/dist/src/types/A_ServerError.types.d.ts +0 -4
  161. package/dist/src/types/A_ServerError.types.js +0 -3
  162. package/dist/src/types/A_ServerError.types.js.map +0 -1
  163. package/src/global/ASEID.class.ts +0 -208
  164. package/src/global/A_Error.class.ts +0 -88
  165. package/src/global/A_ServerError.class.ts +0 -70
  166. package/src/helpers/A_Common.helper.ts +0 -265
  167. package/src/helpers/A_ID.helper.ts +0 -32
  168. package/src/helpers/A_Schedule.helper.ts +0 -25
  169. package/src/types/ASEID.types.ts +0 -86
  170. package/src/types/A_Common.types.ts +0 -111
  171. package/src/types/A_Entity.types.ts +0 -17
  172. package/src/types/A_Error.types.ts +0 -10
  173. package/src/types/A_ServerError.types.ts +0 -7
  174. package/tests/default.test.ts +0 -173
  175. package/tests/polyfill.test.ts +0 -37
@@ -0,0 +1,273 @@
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
@@ -0,0 +1 @@
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,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as/a-concept";
2
+ export declare class A_CommandError extends A_Error {
3
+ }
@@ -0,0 +1,8 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,73 @@
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
+ };
@@ -0,0 +1,4 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"A-Command.types.js","sourceRoot":"","sources":["../../../../src/lib/A-Command/A-Command.types.ts"],"names":[],"mappings":";;AACA,+DAA6H"}
@@ -0,0 +1,3 @@
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 [];
@@ -0,0 +1,6 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,8 @@
1
+ import { A_Container } from "@adaas/a-concept";
2
+ import { A_Config } from "./A-Config.context";
3
+ import { A_Polyfill } from "../A-Polyfill/A-Polyfill.component";
4
+ export declare class A_ConfigLoader extends A_Container {
5
+ private reader;
6
+ prepare(polyfill: A_Polyfill): Promise<void>;
7
+ readVariables(config: A_Config): Promise<void>;
8
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
9
+ return function (target, key) { decorator(target, key, paramIndex); }
10
+ };
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.A_ConfigLoader = void 0;
22
+ const a_concept_1 = require("@adaas/a-concept");
23
+ const A_Config_context_1 = require("./A-Config.context");
24
+ const A_Polyfill_component_1 = require("../A-Polyfill/A-Polyfill.component");
25
+ const A_Config_error_1 = require("./A-Config.error");
26
+ const FileConfigReader_component_1 = require("./components/FileConfigReader.component");
27
+ const ENVConfigReader_component_1 = require("./components/ENVConfigReader.component");
28
+ class A_ConfigLoader extends a_concept_1.A_Container {
29
+ prepare(polyfill) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const fs = yield polyfill.fs();
32
+ try {
33
+ switch (true) {
34
+ case a_concept_1.A_Context.environment === 'server' && !!fs.existsSync(`${a_concept_1.A_Context.concept}.conf.json`):
35
+ this.reader = this.scope.resolve(FileConfigReader_component_1.FileConfigReader);
36
+ break;
37
+ case a_concept_1.A_Context.environment === 'server' && !fs.existsSync(`${a_concept_1.A_Context.concept}.conf.json`):
38
+ this.reader = this.scope.resolve(ENVConfigReader_component_1.ENVConfigReader);
39
+ break;
40
+ case a_concept_1.A_Context.environment === 'browser':
41
+ this.reader = this.scope.resolve(ENVConfigReader_component_1.ENVConfigReader);
42
+ break;
43
+ default:
44
+ throw new A_Config_error_1.A_ConfigError(A_Config_error_1.A_ConfigError.InitializationError, `Environment ${a_concept_1.A_Context.environment} is not supported`);
45
+ }
46
+ }
47
+ catch (error) {
48
+ if (error instanceof a_concept_1.A_ScopeError) {
49
+ throw new A_Config_error_1.A_ConfigError({
50
+ title: A_Config_error_1.A_ConfigError.InitializationError,
51
+ description: `Failed to initialize A_ConfigLoader. Reader not found for environment ${a_concept_1.A_Context.environment}`,
52
+ originalError: error,
53
+ });
54
+ }
55
+ }
56
+ });
57
+ }
58
+ readVariables(config) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ yield this.reader.inject(config);
61
+ });
62
+ }
63
+ }
64
+ exports.A_ConfigLoader = A_ConfigLoader;
65
+ __decorate([
66
+ a_concept_1.A_Concept.Load(),
67
+ __param(0, (0, a_concept_1.A_Inject)(A_Polyfill_component_1.A_Polyfill))
68
+ ], A_ConfigLoader.prototype, "prepare", null);
69
+ __decorate([
70
+ a_concept_1.A_Concept.Load({
71
+ after: ['A_ConfigLoader.prepare']
72
+ }),
73
+ __param(0, (0, a_concept_1.A_Inject)(A_Config_context_1.A_Config))
74
+ ], A_ConfigLoader.prototype, "readVariables", null);
75
+ //# sourceMappingURL=A-Config.container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"A-Config.container.js","sourceRoot":"","sources":["../../../../src/lib/A-Config/A-Config.container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,gDAA6F;AAE7F,yDAA8C;AAC9C,6EAAgE;AAChE,qDAAiD;AACjD,wFAA2E;AAC3E,sFAAyE;AAGzE,MAAa,cAAe,SAAQ,uBAAW;IAMrC,OAAO,CACa,QAAoB;;YAE1C,MAAM,EAAE,GAAG,MAAM,QAAQ,CAAC,EAAE,EAAE,CAAC;YAE/B,IAAI,CAAC;gBACD,QAAQ,IAAI,EAAE,CAAC;oBAEX,KAAK,qBAAS,CAAC,WAAW,KAAK,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,qBAAS,CAAC,OAAO,YAAY,CAAC;wBACxF,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAe,6CAAgB,CAAC,CAAC;wBACjE,MAAM;oBAEV,KAAK,qBAAS,CAAC,WAAW,KAAK,QAAQ,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,qBAAS,CAAC,OAAO,YAAY,CAAC;wBACvF,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAe,2CAAe,CAAC,CAAC;wBAChE,MAAM;oBAEV,KAAK,qBAAS,CAAC,WAAW,KAAK,SAAS;wBACpC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAe,2CAAe,CAAC,CAAC;wBAChE,MAAM;oBAEV;wBACI,MAAM,IAAI,8BAAa,CACnB,8BAAa,CAAC,mBAAmB,EACjC,eAAe,qBAAS,CAAC,WAAW,mBAAmB,CAC1D,CAAC;gBACV,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,IAAI,KAAK,YAAY,wBAAY,EAAE,CAAC;oBAChC,MAAM,IAAI,8BAAa,CAAC;wBACpB,KAAK,EAAE,8BAAa,CAAC,mBAAmB;wBACxC,WAAW,EAAE,yEAAyE,qBAAS,CAAC,WAAW,EAAE;wBAC7G,aAAa,EAAE,KAAK;qBACvB,CAAC,CAAA;gBACN,CAAC;YACL,CAAC;QAEL,CAAC;KAAA;IAMK,aAAa,CACK,MAAgB;;YAEpC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrC,CAAC;KAAA;CACJ;AArDD,wCAqDC;AA/CS;IADL,qBAAS,CAAC,IAAI,EAAE;IAEZ,WAAA,IAAA,oBAAQ,EAAC,iCAAU,CAAC,CAAA;6CAmCxB;AAMK;IAHL,qBAAS,CAAC,IAAI,CAAC;QACZ,KAAK,EAAE,CAAC,wBAAwB,CAAC;KACpC,CAAC;IAEG,WAAA,IAAA,oBAAQ,EAAC,2BAAQ,CAAC,CAAA;mDAGtB"}
@@ -0,0 +1,29 @@
1
+ import { A_Fragment, A_TYPES__ConceptENVVariables } from "@adaas/a-concept";
2
+ import { A_TYPES__ConfigContainerConstructor } from "./A-Config.types";
3
+ export declare class A_Config<T extends Array<string | A_TYPES__ConceptENVVariables[number]> = any[]> extends A_Fragment {
4
+ config: A_TYPES__ConfigContainerConstructor<T>;
5
+ private VARIABLES;
6
+ CONFIG_PROPERTIES: T;
7
+ protected DEFAULT_ALLOWED_TO_READ_PROPERTIES: ("A_CONCEPT_NAME" | "A_CONCEPT_ROOT_SCOPE" | "A_CONCEPT_ENVIRONMENT" | "A_CONCEPT_ROOT_FOLDER" | "A_ERROR_DEFAULT_DESCRIPTION")[];
8
+ constructor(config: Partial<A_TYPES__ConfigContainerConstructor<T>>);
9
+ /**
10
+ * This method is used to get the configuration property by name
11
+ *
12
+ * @param property
13
+ * @returns
14
+ */
15
+ get<_OutType = any>(property: T[number] | typeof this.DEFAULT_ALLOWED_TO_READ_PROPERTIES[number]): _OutType;
16
+ /**
17
+ *
18
+ * This method is used to set the configuration property by name
19
+ * OR set multiple properties at once by passing an array of objects
20
+ *
21
+ * @param variables
22
+ */
23
+ set(variables: Array<{
24
+ property: T[number] | A_TYPES__ConceptENVVariables[number];
25
+ value: any;
26
+ }>): any;
27
+ set(variables: Partial<Record<T[number] | A_TYPES__ConceptENVVariables[number], any>>): any;
28
+ set(property: T[number] | A_TYPES__ConceptENVVariables[number], value: any): any;
29
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.A_Config = void 0;
4
+ const a_concept_1 = require("@adaas/a-concept");
5
+ const A_Config_constants_1 = require("./A-Config.constants");
6
+ class A_Config extends a_concept_1.A_Fragment {
7
+ constructor(config) {
8
+ super({
9
+ name: 'A_Config'
10
+ });
11
+ this.VARIABLES = new Map();
12
+ this.DEFAULT_ALLOWED_TO_READ_PROPERTIES = [
13
+ ...a_concept_1.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,
14
+ ...A_Config_constants_1.A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY
15
+ ];
16
+ this.config = a_concept_1.A_CommonHelper.deepCloneAndMerge(config, {
17
+ strict: false,
18
+ defaults: {},
19
+ variables: a_concept_1.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY
20
+ });
21
+ this.CONFIG_PROPERTIES = this.config.variables ? this.config.variables : [];
22
+ this.config.variables.forEach((variable) => {
23
+ this.VARIABLES.set(a_concept_1.A_FormatterHelper.toUpperSnakeCase(variable), this.config.defaults[variable]);
24
+ });
25
+ }
26
+ /**
27
+ * This method is used to get the configuration property by name
28
+ *
29
+ * @param property
30
+ * @returns
31
+ */
32
+ get(property) {
33
+ if (this.CONFIG_PROPERTIES.includes(property)
34
+ || this.DEFAULT_ALLOWED_TO_READ_PROPERTIES.includes(property)
35
+ || !(this.config.strict))
36
+ return this.VARIABLES.get(a_concept_1.A_FormatterHelper.toUpperSnakeCase(property));
37
+ throw new Error('Property not exists or not allowed to read');
38
+ // return this.concept.Errors.throw(A_SDK_CONSTANTS__ERROR_CODES.CONFIGURATION_PROPERTY_NOT_EXISTS_OR_NOT_ALLOWED_TO_READ) as never;
39
+ }
40
+ set(property, value) {
41
+ var _a;
42
+ const array = Array.isArray(property)
43
+ ? property
44
+ : typeof property === 'string'
45
+ ? [{ property, value }]
46
+ : Object
47
+ .keys(property)
48
+ .map((key) => ({
49
+ property: key,
50
+ value: property[key]
51
+ }));
52
+ for (const { property, value } of array) {
53
+ let targetValue = value
54
+ ? value
55
+ : ((_a = this.config) === null || _a === void 0 ? void 0 : _a.defaults)
56
+ ? this.config.defaults[property]
57
+ : undefined;
58
+ this.VARIABLES.set(a_concept_1.A_FormatterHelper.toUpperSnakeCase(property), targetValue);
59
+ }
60
+ }
61
+ }
62
+ exports.A_Config = A_Config;
63
+ //# sourceMappingURL=A-Config.context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"A-Config.context.js","sourceRoot":"","sources":["../../../../src/lib/A-Config/A-Config.context.ts"],"names":[],"mappings":";;;AAAA,gDAAyJ;AAEzJ,6DAA+E;AAG/E,MAAa,QAEX,SAAQ,sBAAU;IAehB,YACI,MAAuD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O,CAAC,QAAQ,CAAC;YACjC,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,OAAO,QAAQ,KAAK,QAAQ;gBAC1B,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;gBACvB,CAAC,CAAC,MAAM;qBACH,IAAI,CAAC,QAAQ,CAAC;qBACd,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;oBACX,QAAQ,EAAE,GAAG;oBACb,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC;iBACvB,CAAC,CAAC,CAAC;QAEhB,KAAK,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,KAAK,EAAE,CAAC;YAEtC,IAAI,WAAW,GAAG,KAAK;gBACnB,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,CAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,QAAQ;oBACnB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAqB,CAAC;oBAC7C,CAAC,CAAC,SAAS,CAAC;YAEpB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,6BAAiB,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC;QAClF,CAAC;IACL,CAAC;CACJ;AA/GD,4BA+GC"}
@@ -0,0 +1,4 @@
1
+ import { A_Error } from "@adaas/a-concept";
2
+ export declare class A_ConfigError extends A_Error {
3
+ static readonly InitializationError = "A-Config Initialization Error";
4
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.A_ConfigError = void 0;
4
+ const a_concept_1 = require("@adaas/a-concept");
5
+ class A_ConfigError extends a_concept_1.A_Error {
6
+ }
7
+ exports.A_ConfigError = A_ConfigError;
8
+ A_ConfigError.InitializationError = 'A-Config Initialization Error';
9
+ //# sourceMappingURL=A-Config.error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"A-Config.error.js","sourceRoot":"","sources":["../../../../src/lib/A-Config/A-Config.error.ts"],"names":[],"mappings":";;;AAAA,gDAA2C;AAG3C,MAAa,aAAc,SAAQ,mBAAO;;AAA1C,sCAGC;AADmB,iCAAmB,GAAG,+BAA+B,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { A_TYPES__ConceptENVVariables, A_TYPES__Fragment_Constructor } from "@adaas/a-concept";
2
+ export declare enum A_TYPES__ConfigFeature {
3
+ }
4
+ export type A_TYPES__ConfigContainerConstructor<T extends Array<string | A_TYPES__ConceptENVVariables[number]>> = {
5
+ /**
6
+ * If set to true, the SDK will throw an error if the variable is not defined OR not presented in the defaults
7
+ */
8
+ strict: boolean;
9
+ /**
10
+ * Allows to define the names of variable to be loaded
11
+ */
12
+ variables: T;
13
+ /**
14
+ * Allows to set the default values for the variables
15
+ */
16
+ defaults: {
17
+ [key in T[number]]?: any;
18
+ };
19
+ } & A_TYPES__Fragment_Constructor;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.A_TYPES__ConfigFeature = void 0;
4
+ var A_TYPES__ConfigFeature;
5
+ (function (A_TYPES__ConfigFeature) {
6
+ })(A_TYPES__ConfigFeature || (exports.A_TYPES__ConfigFeature = A_TYPES__ConfigFeature = {}));
7
+ //# sourceMappingURL=A-Config.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"A-Config.types.js","sourceRoot":"","sources":["../../../../src/lib/A-Config/A-Config.types.ts"],"names":[],"mappings":";;;AAEA,IAAY,sBAEX;AAFD,WAAY,sBAAsB;AAElC,CAAC,EAFW,sBAAsB,sCAAtB,sBAAsB,QAEjC"}