@adaas/a-utils 0.1.7 → 0.1.9

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 (35) hide show
  1. package/README.md +393 -6
  2. package/dist/index.d.ts +7 -2
  3. package/dist/index.js +38 -7
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/lib/A-Channel/A-Channel.component.d.ts +19 -0
  6. package/dist/src/lib/A-Channel/A-Channel.component.js +76 -0
  7. package/dist/src/lib/A-Channel/A-Channel.component.js.map +1 -1
  8. package/dist/src/lib/A-Channel/A-Channel.error.d.ts +1 -0
  9. package/dist/src/lib/A-Channel/A-Channel.error.js +1 -0
  10. package/dist/src/lib/A-Channel/A-Channel.error.js.map +1 -1
  11. package/dist/src/lib/A-Config/A-Config.container.js +1 -1
  12. package/dist/src/lib/A-Config/A-Config.container.js.map +1 -1
  13. package/dist/src/lib/A-Manifest/A-Manifest.context.d.ts +52 -0
  14. package/dist/src/lib/A-Manifest/A-Manifest.context.js +154 -0
  15. package/dist/src/lib/A-Manifest/A-Manifest.context.js.map +1 -0
  16. package/dist/src/lib/A-Manifest/A-Manifest.error.d.ts +4 -0
  17. package/dist/src/lib/A-Manifest/A-Manifest.error.js +9 -0
  18. package/dist/src/lib/A-Manifest/A-Manifest.error.js.map +1 -0
  19. package/dist/src/lib/A-Manifest/A-Manifest.types.d.ts +43 -0
  20. package/dist/src/lib/A-Manifest/A-Manifest.types.js +3 -0
  21. package/dist/src/lib/A-Manifest/A-Manifest.types.js.map +1 -0
  22. package/dist/src/lib/A-Manifest/classes/A-ManifestChecker.class.d.ts +13 -0
  23. package/dist/src/lib/A-Manifest/classes/A-ManifestChecker.class.js +24 -0
  24. package/dist/src/lib/A-Manifest/classes/A-ManifestChecker.class.js.map +1 -0
  25. package/index.ts +42 -10
  26. package/package.json +2 -2
  27. package/src/lib/A-Channel/A-Channel.component.ts +70 -2
  28. package/src/lib/A-Channel/A-Channel.error.ts +2 -0
  29. package/src/lib/A-Config/A-Config.container.ts +1 -1
  30. package/src/lib/A-Manifest/A-Manifest.context.ts +198 -0
  31. package/src/lib/A-Manifest/A-Manifest.error.ts +7 -0
  32. package/src/lib/A-Manifest/A-Manifest.types.ts +62 -0
  33. package/src/lib/A-Manifest/README.md +201 -0
  34. package/src/lib/A-Manifest/classes/A-ManifestChecker.class.ts +24 -0
  35. package/tests/A-Manifest.test.ts +290 -0
package/README.md CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  # A-Utils SDK
4
4
 
5
- This package is a set of common utils that can be used across projects related or not related to ADAAS Ecosystem.
6
- In this package it is possible to find useful features to work with structures, objects and types.
5
+ This package is a set of common utilities that can be used across projects related or not related to ADAAS Ecosystem.
6
+ In this package it is possible to find useful features to work with structures, objects, types, commands, configuration management, logging, scheduling, and more.
7
7
 
8
8
 
9
9
  | LTS | Latest | npm |
10
10
  |---------------|----------|---------------------------|
11
- | v1.0.0 | v1.0.1 | [@adaas/a-utils](https://npm.com) |
11
+ | v0.1.7 | v0.1.7 | [@adaas/a-utils](https://npm.com) |
12
12
 
13
13
 
14
14
  <!-- TABLE OF CONTENTS -->
@@ -16,23 +16,409 @@ In this package it is possible to find useful features to work with structures,
16
16
 
17
17
  - [About the Project](#overview)
18
18
  - [Installation](#installation)
19
- - [ENV Variables](#environment-variables)
19
+ - [Components](#components)
20
+ - [A-Channel](#a-channel)
21
+ - [A-Command](#a-command)
22
+ - [A-Config](#a-config)
23
+ - [A-Logger](#a-logger)
24
+ - [A-Manifest](#a-manifest)
25
+ - [A-Memory](#a-memory)
26
+ - [A-Polyfill](#a-polyfill)
27
+ - [A-Schedule](#a-schedule)
28
+ - [Environment Variables](#environment-variables)
20
29
  - [Links](#links)
21
30
 
22
31
 
23
32
  ## Installation
24
33
 
25
34
  ```bash
26
-
27
35
  cd /your/project/location
28
- adf
29
36
  npm i @adaas/a-utils
37
+ ```
38
+
39
+ ## Components
40
+
41
+ ### A-Channel
42
+
43
+ A communication channel component that provides messaging capabilities within the ADAAS ecosystem.
44
+
45
+ **Basic Usage:**
46
+ ```typescript
47
+ import { A_Channel } from '@adaas/a-utils';
48
+
49
+ const channel = new A_Channel();
50
+ // Channel is ready for use
51
+ ```
52
+
53
+ **Features:**
54
+ - Inter-component communication
55
+ - Message routing and handling
56
+ - Integration with A-Context
57
+
58
+ ---
59
+
60
+ ### A-Command
61
+
62
+ A powerful command execution system that provides structured command patterns with lifecycle management, status tracking, and serialization capabilities.
30
63
 
64
+ **Basic Usage:**
65
+ ```typescript
66
+ import { A_Command } from '@adaas/a-utils';
67
+
68
+ // Create a command
69
+ const command = new A_Command({});
70
+
71
+ // Execute the command
72
+ await command.execute();
73
+
74
+ console.log(command.status); // 'COMPLETED'
75
+ console.log(command.duration); // Execution time in ms
76
+ ```
77
+
78
+ **Advanced Usage:**
79
+ ```typescript
80
+ // Command with custom logic
81
+ class CustomCommand extends A_Command {
82
+ async execute() {
83
+ // Your custom command logic here
84
+ return await super.execute();
85
+ }
86
+ }
87
+
88
+ // Serialization
89
+ const command = new A_Command({});
90
+ await command.execute();
91
+
92
+ const serialized = command.toJSON();
93
+ const deserializedCommand = new A_Command(serialized);
31
94
  ```
32
95
 
96
+ **Features:**
97
+ - Command execution with lifecycle management
98
+ - Status tracking (INITIALIZED, PROCESSING, COMPLETED, FAILED)
99
+ - Built-in timing and duration tracking
100
+ - JSON serialization/deserialization
101
+ - Scope integration with dependency injection
102
+ - Memory management integration
103
+
104
+ **Command Status:**
105
+ - `INITIALIZED` - Command created but not started
106
+ - `PROCESSING` - Command is currently executing
107
+ - `COMPLETED` - Command finished successfully
108
+ - `FAILED` - Command execution failed
109
+
110
+ ---
111
+
112
+ ### A-Config
113
+
114
+ A flexible configuration management system that supports multiple sources (environment variables, files) with type safety and validation.
115
+
116
+ **Basic Usage:**
117
+ ```typescript
118
+ import { A_Config } from '@adaas/a-utils';
119
+
120
+ // Simple configuration
121
+ const config = new A_Config({
122
+ variables: ['API_URL', 'PORT'] as const,
123
+ defaults: {
124
+ PORT: '3000'
125
+ }
126
+ });
127
+
128
+ console.log(config.get('PORT')); // '3000' or ENV value
129
+ console.log(config.get('API_URL')); // ENV value or undefined
130
+ ```
131
+
132
+ **Advanced Usage with File Loading:**
133
+ ```typescript
134
+ import { A_Config, A_ConfigLoader, ENVConfigReader, FileConfigReader } from '@adaas/a-utils';
135
+
136
+ // Configuration with multiple sources
137
+ const config = new A_Config({
138
+ variables: ['DATABASE_URL', 'JWT_SECRET', 'LOG_LEVEL'] as const,
139
+ defaults: {
140
+ LOG_LEVEL: 'info'
141
+ }
142
+ });
143
+
144
+ // Use with config loader for file support
145
+ const configLoader = new A_ConfigLoader();
146
+ // Automatically loads from .env files and environment variables
147
+ ```
148
+
149
+ **Features:**
150
+ - Type-safe configuration management
151
+ - Multiple data sources (ENV, files)
152
+ - Default value support
153
+ - Automatic environment variable loading
154
+ - Integration with ADAAS concept system
155
+ - Validation and error handling
156
+
157
+ ---
158
+
159
+ ### A-Logger
160
+
161
+ A comprehensive logging system with color support, scope awareness, and configurable output formatting.
162
+
163
+ **Basic Usage:**
164
+ ```typescript
165
+ import { A_Logger } from '@adaas/a-utils';
166
+ import { A_Scope } from '@adaas/a-concept';
167
+
168
+ const scope = new A_Scope({
169
+ name: 'MyApp',
170
+ components: [A_Logger]
171
+ });
172
+
173
+ const logger = scope.resolve(A_Logger);
174
+
175
+ logger.log('Hello World');
176
+ logger.error('Something went wrong');
177
+ logger.warning('This is a warning');
178
+ logger.success('Operation completed');
179
+ ```
180
+
181
+ **Features:**
182
+ - Colored console output
183
+ - Scope-aware logging
184
+ - Multiple log levels (log, error, warning, success)
185
+ - Integration with A-Config for configuration
186
+ - Formatted output with timestamps and scope information
187
+
188
+ ---
189
+
190
+ ### A-Manifest
191
+
192
+ A powerful access control and permission management system that allows fine-grained control over component and method access using regex patterns and rule-based configurations.
193
+
194
+ **Basic Usage:**
195
+ ```typescript
196
+ import { A_Manifest } from '@adaas/a-utils';
197
+ import { A_Component } from '@adaas/a-concept';
198
+
199
+ class UserController extends A_Component {
200
+ get() { return 'users'; }
201
+ post() { return 'create user'; }
202
+ delete() { return 'delete user'; }
203
+ }
204
+
205
+ class GuestUser extends A_Component {}
206
+ class AdminUser extends A_Component {}
33
207
 
208
+ // Component-level access control
209
+ const manifest = new A_Manifest([
210
+ {
211
+ component: UserController,
212
+ exclude: [GuestUser] // Guests cannot access UserController
213
+ }
214
+ ]);
34
215
 
216
+ // Check permissions
217
+ const canAccess = manifest.isAllowed(UserController, 'get').for(GuestUser); // false
218
+ const adminAccess = manifest.isAllowed(UserController, 'get').for(AdminUser); // true
219
+ ```
220
+
221
+ **Method-Level Control:**
222
+ ```typescript
223
+ const manifest = new A_Manifest([
224
+ {
225
+ component: UserController,
226
+ methods: [
227
+ {
228
+ method: 'delete',
229
+ apply: [AdminUser] // Only admins can delete
230
+ },
231
+ {
232
+ method: 'post',
233
+ exclude: [GuestUser] // Guests cannot create
234
+ }
235
+ ]
236
+ }
237
+ ]);
238
+ ```
239
+
240
+ **Regex Pattern Support:**
241
+ ```typescript
242
+ const manifest = new A_Manifest([
243
+ {
244
+ component: UserController,
245
+ methods: [
246
+ {
247
+ method: /^(post|put|delete)$/, // All mutating operations
248
+ exclude: [GuestUser]
249
+ }
250
+ ]
251
+ }
252
+ ]);
253
+ ```
254
+
255
+ **Complex Scenarios:**
256
+ ```typescript
257
+ const manifest = new A_Manifest([
258
+ {
259
+ component: UserController,
260
+ exclude: [GuestUser], // Base rule: guests excluded
261
+ methods: [
262
+ {
263
+ method: 'get',
264
+ apply: [GuestUser, AdminUser] // Override: guests can read
265
+ }
266
+ ]
267
+ }
268
+ ]);
269
+
270
+ // Results:
271
+ // UserController.get for GuestUser -> true (method override)
272
+ // UserController.post for GuestUser -> false (component exclusion)
273
+ ```
274
+
275
+ **Features:**
276
+ - Component-level and method-level access control
277
+ - Regex pattern matching for flexible rules
278
+ - Rule precedence (method-level overrides component-level)
279
+ - Fluent API for permission checking
280
+ - Support for inclusion (`apply`) and exclusion (`exclude`) rules
281
+ - Type-safe configuration with TypeScript
282
+
283
+ ---
284
+
285
+ ### A-Memory
286
+
287
+ A type-safe memory management system for storing intermediate values and tracking errors during complex operations.
288
+
289
+ **Basic Usage:**
290
+ ```typescript
291
+ import { A_Memory } from '@adaas/a-utils';
292
+
293
+ // Create memory instance
294
+ const memory = new A_Memory<{
295
+ userId: string;
296
+ userData: any;
297
+ processedData: any;
298
+ }>({
299
+ userId: '12345'
300
+ });
301
+
302
+ // Store values
303
+ memory.set('userData', { name: 'John', email: 'john@example.com' });
304
+ memory.set('processedData', processUserData(memory.get('userData')));
305
+
306
+ // Check prerequisites
307
+ const hasRequired = await memory.verifyPrerequisites(['userId', 'userData']);
308
+ console.log(hasRequired); // true
309
+
310
+ // Access values
311
+ const userId = memory.get('userId');
312
+ const allData = memory.toJSON();
313
+ ```
314
+
315
+ **Error Tracking:**
316
+ ```typescript
317
+ import { A_Error } from '@adaas/a-concept';
318
+
319
+ const memory = new A_Memory();
320
+
321
+ // Errors are automatically tracked
322
+ try {
323
+ // Some operation that might fail
324
+ throw new A_Error('Something went wrong');
325
+ } catch (error) {
326
+ memory.addError(error);
327
+ }
328
+
329
+ // Check for errors
330
+ if (memory.Errors) {
331
+ console.log('Errors occurred:', memory.Errors);
332
+ }
333
+ ```
334
+
335
+ **Features:**
336
+ - Type-safe value storage
337
+ - Prerequisite verification
338
+ - Error tracking and management
339
+ - JSON serialization
340
+ - Generic type support for custom data structures
341
+
342
+ ---
343
+
344
+ ### A-Polyfill
345
+
346
+ A polyfill management system that provides consistent API support across different environments.
347
+
348
+ **Basic Usage:**
349
+ ```typescript
350
+ import { A_Polyfill } from '@adaas/a-utils';
351
+
352
+ const polyfill = new A_Polyfill();
353
+ // Polyfill ensures consistent API availability
354
+ ```
355
+
356
+ **Features:**
357
+ - Cross-environment compatibility
358
+ - Automatic polyfill detection and application
359
+ - Integration with A-Component system
360
+
361
+ ---
362
+
363
+ ### A-Schedule
364
+
365
+ A comprehensive scheduling and task management system with support for delays, cancellation, and promise-based operations.
366
+
367
+ **Basic Usage:**
368
+ ```typescript
369
+ import { A_Schedule } from '@adaas/a-utils';
370
+ import { A_Scope } from '@adaas/a-concept';
371
+
372
+ const scope = new A_Scope({
373
+ components: [A_Schedule]
374
+ });
375
+
376
+ const schedule = scope.resolve(A_Schedule);
377
+
378
+ // Schedule a delayed operation
379
+ const scheduler = await schedule.delay(3000, async () => {
380
+ return 'Task completed after 3 seconds';
381
+ });
382
+
383
+ const result = await scheduler.promise; // 'Task completed after 3 seconds'
384
+ ```
385
+
386
+ **Cancellation Support:**
387
+ ```typescript
388
+ const scheduler = await schedule.delay(5000, async () => {
389
+ return 'This might be cancelled';
390
+ });
391
+
392
+ // Cancel the scheduled task
393
+ scheduler.cancel();
394
+
395
+ try {
396
+ await scheduler.promise;
397
+ } catch (error) {
398
+ console.log('Task was cancelled');
399
+ }
400
+ ```
401
+
402
+ **Advanced Scheduling:**
403
+ ```typescript
404
+ // Schedule multiple tasks
405
+ const tasks = await Promise.all([
406
+ schedule.delay(1000, () => 'Task 1'),
407
+ schedule.delay(2000, () => 'Task 2'),
408
+ schedule.delay(3000, () => 'Task 3')
409
+ ]);
410
+
411
+ const results = await Promise.all(tasks.map(t => t.promise));
412
+ console.log(results); // ['Task 1', 'Task 2', 'Task 3']
413
+ ```
35
414
 
415
+ **Features:**
416
+ - Promise-based task scheduling
417
+ - Configurable delays
418
+ - Task cancellation support
419
+ - Multiple concurrent task management
420
+ - Integration with A-Component dependency injection
421
+ - Type-safe task execution
36
422
 
37
423
  ## Environment Variables
38
424
 
@@ -40,6 +426,7 @@ npm i @adaas/a-utils
40
426
  |---------------|----------|---------------------------|
41
427
  | A_NAMESPACE | YES | Your desired Namespace for the project |
42
428
 
429
+ Additional environment variables may be required by specific components like A-Config depending on your configuration setup.
43
430
 
44
431
  ## Links
45
432
 
package/dist/index.d.ts CHANGED
@@ -12,11 +12,16 @@ export { ENVConfigReader } from './src/lib/A-Config/components/ENVConfigReader.c
12
12
  export { FileConfigReader } from './src/lib/A-Config/components/FileConfigReader.component';
13
13
  export * from './src/lib/A-Config/A-Config.types';
14
14
  export * from './src/lib/A-Config/A-Config.constants';
15
+ export { A_Logger } from './src/lib/A-Logger/A-Logger.component';
16
+ export { A_Manifest } from './src/lib/A-Manifest/A-Manifest.context';
17
+ export { A_ManifestError } from './src/lib/A-Manifest/A-Manifest.error';
18
+ export { A_ManifestChecker } from './src/lib/A-Manifest/classes/A-ManifestChecker.class';
19
+ export * from './src/lib/A-Manifest/A-Manifest.types';
15
20
  export { A_Memory } from './src/lib/A-Memory/A-Memory.context';
16
21
  export { A_Polyfill } from './src/lib/A-Polyfill/A-Polyfill.component';
17
22
  export { A_PolyfillClass } from './src/lib/A-Polyfill/A-Polyfills.class';
18
- export { A_Logger } from './src/lib/A-Logger/A-Logger.component';
23
+ export * from './src/lib/A-Polyfill/A-Polyfill.types';
19
24
  export { A_Schedule } from './src/lib/A-Schedule/A-Schedule.component';
20
- export * from './src/lib/A-Schedule/A-Schedule.types';
21
25
  export { A_ScheduleObject } from './src/lib/A-Schedule/A-ScheduleObject.class';
22
26
  export { A_Deferred } from './src/lib/A-Schedule/A-Deferred.class';
27
+ export * from './src/lib/A-Schedule/A-Schedule.types';
package/dist/index.js CHANGED
@@ -14,18 +14,27 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.A_Deferred = exports.A_ScheduleObject = exports.A_Schedule = exports.A_Logger = exports.A_PolyfillClass = exports.A_Polyfill = exports.A_Memory = exports.FileConfigReader = exports.ENVConfigReader = exports.ConfigReader = exports.A_ConfigError = exports.A_Config = exports.A_ConfigLoader = exports.A_CommandError = exports.A_Command = exports.A_ChannelError = exports.A_Channel = void 0;
17
+ exports.A_Deferred = exports.A_ScheduleObject = exports.A_Schedule = exports.A_PolyfillClass = exports.A_Polyfill = exports.A_Memory = exports.A_ManifestChecker = exports.A_ManifestError = exports.A_Manifest = exports.A_Logger = exports.FileConfigReader = exports.ENVConfigReader = exports.ConfigReader = exports.A_ConfigError = exports.A_Config = exports.A_ConfigLoader = exports.A_CommandError = exports.A_Command = exports.A_ChannelError = exports.A_Channel = void 0;
18
+ // ============================================================================
19
+ // A-Channel Components
20
+ // ============================================================================
18
21
  var A_Channel_component_1 = require("./src/lib/A-Channel/A-Channel.component");
19
22
  Object.defineProperty(exports, "A_Channel", { enumerable: true, get: function () { return A_Channel_component_1.A_Channel; } });
20
23
  var A_Channel_error_1 = require("./src/lib/A-Channel/A-Channel.error");
21
24
  Object.defineProperty(exports, "A_ChannelError", { enumerable: true, get: function () { return A_Channel_error_1.A_ChannelError; } });
22
- // export * from './src/lib/A-Channel/A-Channel.types';
25
+ // export * from './src/lib/A-Channel/A-Channel.types'; // Empty file
26
+ // ============================================================================
27
+ // A-Command Components
28
+ // ============================================================================
23
29
  var A_Command_entity_1 = require("./src/lib/A-Command/A-Command.entity");
24
30
  Object.defineProperty(exports, "A_Command", { enumerable: true, get: function () { return A_Command_entity_1.A_Command; } });
25
31
  var A_Command_error_1 = require("./src/lib/A-Command/A-Command.error");
26
32
  Object.defineProperty(exports, "A_CommandError", { enumerable: true, get: function () { return A_Command_error_1.A_CommandError; } });
27
33
  __exportStar(require("./src/lib/A-Command/A-Command.types"), exports);
28
34
  __exportStar(require("./src/lib/A-Command/A-Command.constants"), exports);
35
+ // ============================================================================
36
+ // A-Config Components
37
+ // ============================================================================
29
38
  var A_Config_container_1 = require("./src/lib/A-Config/A-Config.container");
30
39
  Object.defineProperty(exports, "A_ConfigLoader", { enumerable: true, get: function () { return A_Config_container_1.A_ConfigLoader; } });
31
40
  var A_Config_context_1 = require("./src/lib/A-Config/A-Config.context");
@@ -40,21 +49,43 @@ var FileConfigReader_component_1 = require("./src/lib/A-Config/components/FileCo
40
49
  Object.defineProperty(exports, "FileConfigReader", { enumerable: true, get: function () { return FileConfigReader_component_1.FileConfigReader; } });
41
50
  __exportStar(require("./src/lib/A-Config/A-Config.types"), exports);
42
51
  __exportStar(require("./src/lib/A-Config/A-Config.constants"), exports);
52
+ // ============================================================================
53
+ // A-Logger Components
54
+ // ============================================================================
55
+ var A_Logger_component_1 = require("./src/lib/A-Logger/A-Logger.component");
56
+ Object.defineProperty(exports, "A_Logger", { enumerable: true, get: function () { return A_Logger_component_1.A_Logger; } });
57
+ // export * from './src/lib/A-Logger/A-Logger.types'; // Empty file
58
+ // ============================================================================
59
+ // A-Manifest Components
60
+ // ============================================================================
61
+ var A_Manifest_context_1 = require("./src/lib/A-Manifest/A-Manifest.context");
62
+ Object.defineProperty(exports, "A_Manifest", { enumerable: true, get: function () { return A_Manifest_context_1.A_Manifest; } });
63
+ var A_Manifest_error_1 = require("./src/lib/A-Manifest/A-Manifest.error");
64
+ Object.defineProperty(exports, "A_ManifestError", { enumerable: true, get: function () { return A_Manifest_error_1.A_ManifestError; } });
65
+ var A_ManifestChecker_class_1 = require("./src/lib/A-Manifest/classes/A-ManifestChecker.class");
66
+ Object.defineProperty(exports, "A_ManifestChecker", { enumerable: true, get: function () { return A_ManifestChecker_class_1.A_ManifestChecker; } });
67
+ __exportStar(require("./src/lib/A-Manifest/A-Manifest.types"), exports);
68
+ // ============================================================================
69
+ // A-Memory Components
70
+ // ============================================================================
43
71
  var A_Memory_context_1 = require("./src/lib/A-Memory/A-Memory.context");
44
72
  Object.defineProperty(exports, "A_Memory", { enumerable: true, get: function () { return A_Memory_context_1.A_Memory; } });
73
+ // ============================================================================
74
+ // A-Polyfill Components
75
+ // ============================================================================
45
76
  var A_Polyfill_component_1 = require("./src/lib/A-Polyfill/A-Polyfill.component");
46
77
  Object.defineProperty(exports, "A_Polyfill", { enumerable: true, get: function () { return A_Polyfill_component_1.A_Polyfill; } });
47
78
  var A_Polyfills_class_1 = require("./src/lib/A-Polyfill/A-Polyfills.class");
48
79
  Object.defineProperty(exports, "A_PolyfillClass", { enumerable: true, get: function () { return A_Polyfills_class_1.A_PolyfillClass; } });
49
- // export * from './src/lib/A-Polyfill/A-Polyfill.types';
50
- var A_Logger_component_1 = require("./src/lib/A-Logger/A-Logger.component");
51
- Object.defineProperty(exports, "A_Logger", { enumerable: true, get: function () { return A_Logger_component_1.A_Logger; } });
52
- // export * from './src/lib/A-Logger/A-Logger.types';
80
+ __exportStar(require("./src/lib/A-Polyfill/A-Polyfill.types"), exports);
81
+ // ============================================================================
82
+ // A-Schedule Components
83
+ // ============================================================================
53
84
  var A_Schedule_component_1 = require("./src/lib/A-Schedule/A-Schedule.component");
54
85
  Object.defineProperty(exports, "A_Schedule", { enumerable: true, get: function () { return A_Schedule_component_1.A_Schedule; } });
55
- __exportStar(require("./src/lib/A-Schedule/A-Schedule.types"), exports);
56
86
  var A_ScheduleObject_class_1 = require("./src/lib/A-Schedule/A-ScheduleObject.class");
57
87
  Object.defineProperty(exports, "A_ScheduleObject", { enumerable: true, get: function () { return A_ScheduleObject_class_1.A_ScheduleObject; } });
58
88
  var A_Deferred_class_1 = require("./src/lib/A-Schedule/A-Deferred.class");
59
89
  Object.defineProperty(exports, "A_Deferred", { enumerable: true, get: function () { return A_Deferred_class_1.A_Deferred; } });
90
+ __exportStar(require("./src/lib/A-Schedule/A-Schedule.types"), exports);
60
91
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,+EAAoE;AAA3D,gHAAA,SAAS,OAAA;AAClB,uEAAqE;AAA5D,iHAAA,cAAc,OAAA;AACvB,uDAAuD;AAGvD,yEAAiE;AAAxD,6GAAA,SAAS,OAAA;AAClB,uEAAqE;AAA5D,iHAAA,cAAc,OAAA;AACvB,sEAAoD;AACpD,0EAAwD;AAGxD,4EAAuE;AAA9D,oHAAA,cAAc,OAAA;AACvB,wEAA+D;AAAtD,4GAAA,QAAQ,OAAA;AACjB,oEAAkE;AAAzD,+GAAA,aAAa,OAAA;AACtB,+FAAoF;AAA3E,sHAAA,YAAY,OAAA;AACrB,qGAA0F;AAAjF,4HAAA,eAAe,OAAA;AACxB,uGAA4F;AAAnF,8HAAA,gBAAgB,OAAA;AACzB,oEAAkD;AAClD,wEAAsD;AAGtD,wEAA8D;AAArD,4GAAA,QAAQ,OAAA;AAEjB,kFAAuE;AAA9D,kHAAA,UAAU,OAAA;AACnB,4EAAyE;AAAhE,oHAAA,eAAe,OAAA;AACxB,yDAAyD;AAEzD,4EAAiE;AAAxD,8GAAA,QAAQ,OAAA;AACjB,qDAAqD;AAGrD,kFAAsE;AAA7D,kHAAA,UAAU,OAAA;AACnB,wEAAqD;AACrD,sFAA8E;AAArE,0HAAA,gBAAgB,OAAA;AACzB,0EAAkE;AAAzD,8GAAA,UAAU,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAC/E,+EAAoE;AAA3D,gHAAA,SAAS,OAAA;AAClB,uEAAqE;AAA5D,iHAAA,cAAc,OAAA;AACvB,qEAAqE;AAGrE,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAC/E,yEAAiE;AAAxD,6GAAA,SAAS,OAAA;AAClB,uEAAqE;AAA5D,iHAAA,cAAc,OAAA;AACvB,sEAAoD;AACpD,0EAAwD;AAGxD,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAC/E,4EAAuE;AAA9D,oHAAA,cAAc,OAAA;AACvB,wEAA+D;AAAtD,4GAAA,QAAQ,OAAA;AACjB,oEAAkE;AAAzD,+GAAA,aAAa,OAAA;AACtB,+FAAoF;AAA3E,sHAAA,YAAY,OAAA;AACrB,qGAA0F;AAAjF,4HAAA,eAAe,OAAA;AACxB,uGAA4F;AAAnF,8HAAA,gBAAgB,OAAA;AACzB,oEAAkD;AAClD,wEAAsD;AAGtD,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAC/E,4EAAiE;AAAxD,8GAAA,QAAQ,OAAA;AACjB,mEAAmE;AAGnE,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAC/E,8EAAqE;AAA5D,gHAAA,UAAU,OAAA;AACnB,0EAAwE;AAA/D,mHAAA,eAAe,OAAA;AACxB,gGAAyF;AAAhF,4HAAA,iBAAiB,OAAA;AAC1B,wEAAsD;AAGtD,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAC/E,wEAA+D;AAAtD,4GAAA,QAAQ,OAAA;AAGjB,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAC/E,kFAAuE;AAA9D,kHAAA,UAAU,OAAA;AACnB,4EAAyE;AAAhE,oHAAA,eAAe,OAAA;AACxB,wEAAsD;AAGtD,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAC/E,kFAAuE;AAA9D,kHAAA,UAAU,OAAA;AACnB,sFAA+E;AAAtE,0HAAA,gBAAgB,OAAA;AACzB,0EAAmE;AAA1D,8GAAA,UAAU,OAAA;AACnB,wEAAsD"}
@@ -1,3 +1,22 @@
1
1
  import { A_Component } from "@adaas/a-concept";
2
2
  export declare class A_Channel extends A_Component {
3
+ /**
4
+ * Indicates whether the channel is processing requests
5
+ */
6
+ protected _processing: boolean;
7
+ /**
8
+ * Indicates whether the channel is connected
9
+ */
10
+ protected _initialized?: Promise<void>;
11
+ /**
12
+ * Indicates whether the channel is processing requests
13
+ */
14
+ get processing(): boolean;
15
+ /**
16
+ * Indicates whether the channel is connected
17
+ */
18
+ get initialize(): Promise<void>;
19
+ connect(): Promise<void>;
20
+ request(params: any): Promise<any>;
21
+ send(message: any): Promise<void>;
3
22
  }
@@ -1,8 +1,84 @@
1
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
15
+ });
16
+ };
2
17
  Object.defineProperty(exports, "__esModule", { value: true });
3
18
  exports.A_Channel = void 0;
4
19
  const a_concept_1 = require("@adaas/a-concept");
20
+ const A_Channel_error_1 = require("./A-Channel.error");
5
21
  class A_Channel extends a_concept_1.A_Component {
22
+ constructor() {
23
+ super(...arguments);
24
+ /**
25
+ * Indicates whether the channel is processing requests
26
+ */
27
+ this._processing = false;
28
+ }
29
+ /**
30
+ * Indicates whether the channel is processing requests
31
+ */
32
+ get processing() {
33
+ return this._processing;
34
+ }
35
+ /**
36
+ * Indicates whether the channel is connected
37
+ */
38
+ get initialize() {
39
+ if (!this._initialized) {
40
+ this._initialized = this.connect();
41
+ }
42
+ return this._initialized;
43
+ }
44
+ connect() {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ throw new A_Channel_error_1.A_ChannelError(A_Channel_error_1.A_ChannelError.MethodNotImplemented, `The connect method is not implemented in ${this.constructor.name} channel. This method is required to initialize the channel before use. So please implement it in the derived class.`);
47
+ });
48
+ }
49
+ request(params) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ throw new A_Channel_error_1.A_ChannelError(A_Channel_error_1.A_ChannelError.MethodNotImplemented, `The request method is not implemented in ${this.constructor.name} channel.`);
52
+ });
53
+ }
54
+ send(message) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ throw new A_Channel_error_1.A_ChannelError(A_Channel_error_1.A_ChannelError.MethodNotImplemented, `The send method is not implemented in ${this.constructor.name} channel.`);
57
+ });
58
+ }
6
59
  }
7
60
  exports.A_Channel = A_Channel;
61
+ __decorate([
62
+ a_concept_1.A_Feature.Define()
63
+ /**
64
+ * Initializes the channel before use
65
+ */
66
+ ], A_Channel.prototype, "connect", null);
67
+ __decorate([
68
+ a_concept_1.A_Feature.Define()
69
+ /**
70
+ * Allows to send a request through the channel
71
+ *
72
+ * @param req - The request parameters
73
+ * @returns The response from the channel
74
+ */
75
+ ], A_Channel.prototype, "request", null);
76
+ __decorate([
77
+ a_concept_1.A_Feature.Define()
78
+ /**
79
+ * Uses for Fire-and-Forget messaging through the channel
80
+ *
81
+ * @param message - can be of any type depending on the channel implementation
82
+ */
83
+ ], A_Channel.prototype, "send", null);
8
84
  //# sourceMappingURL=A-Channel.component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"A-Channel.component.js","sourceRoot":"","sources":["../../../../src/lib/A-Channel/A-Channel.component.ts"],"names":[],"mappings":";;;AAAA,gDAA0D;AAI1D,MAAa,SAAU,SAAQ,uBAAW;CAGzC;AAHD,8BAGC"}
1
+ {"version":3,"file":"A-Channel.component.js","sourceRoot":"","sources":["../../../../src/lib/A-Channel/A-Channel.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,gDAA0D;AAC1D,uDAAmD;AAInD,MAAa,SAAU,SAAQ,uBAAW;IAA1C;;QAEI;;WAEG;QACO,gBAAW,GAAY,KAAK,CAAC;IAgE3C,CAAC;IA1DG;;QAEI;IACJ,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IACD;;OAEG;IACH,IAAI,UAAU;QACV,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACrB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QACvC,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAOK,OAAO;;YACT,MAAM,IAAI,gCAAc,CACpB,gCAAc,CAAC,oBAAoB,EACnC,4CAA4C,IAAI,CAAC,WAAW,CAAC,IAAI,sHAAsH,CAC1L,CAAC;QACN,CAAC;KAAA;IAUK,OAAO,CAAC,MAAW;;YACrB,MAAM,IAAI,gCAAc,CACpB,gCAAc,CAAC,oBAAoB,EACnC,4CAA4C,IAAI,CAAC,WAAW,CAAC,IAAI,WAAW,CAC/E,CAAC;QACN,CAAC;KAAA;IAUK,IAAI,CAAC,OAAY;;YACnB,MAAM,IAAI,gCAAc,CACpB,gCAAc,CAAC,oBAAoB,EACnC,yCAAyC,IAAI,CAAC,WAAW,CAAC,IAAI,WAAW,CAC5E,CAAC;QACN,CAAC;KAAA;CAEJ;AArED,8BAqEC;AArCS;IAJL,qBAAS,CAAC,MAAM,EAAE;IACnB;;OAEG;wCAMF;AAUK;IAPL,qBAAS,CAAC,MAAM,EAAE;IACnB;;;;;OAKG;wCAMF;AAUK;IANL,qBAAS,CAAC,MAAM,EAAE;IACnB;;;;OAIG;qCAMF"}
@@ -1,3 +1,4 @@
1
1
  import { A_Error } from "@adaas/a-concept";
2
2
  export declare class A_ChannelError extends A_Error {
3
+ static readonly MethodNotImplemented = "A-Channel Method Not Implemented";
3
4
  }
@@ -5,4 +5,5 @@ const a_concept_1 = require("@adaas/a-concept");
5
5
  class A_ChannelError extends a_concept_1.A_Error {
6
6
  }
7
7
  exports.A_ChannelError = A_ChannelError;
8
+ A_ChannelError.MethodNotImplemented = 'A-Channel Method Not Implemented';
8
9
  //# sourceMappingURL=A-Channel.error.js.map
@@ -1 +1 @@
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;CAE1C;AAFD,wCAEC"}
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"}