@adaas/a-utils 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -2
- package/dist/index.d.mts +66 -14
- package/dist/index.d.ts +66 -14
- package/dist/index.js +237 -176
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +236 -178
- package/dist/index.mjs.map +1 -1
- package/examples/channel-examples.ts +13 -13
- package/package.json +23 -5
- package/src/index.ts +3 -1
- package/src/lib/A-Channel/A-Channel.component.ts +84 -17
- package/src/lib/A-Channel/A-Channel.error.ts +5 -5
- package/src/lib/A-Channel/A-ChannelRequest.context.ts +1 -1
- package/src/lib/A-Channel/README.md +24 -24
- package/tests/A-Channel.test.ts +14 -14
package/README.md
CHANGED
|
@@ -2,13 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
# A-Utils SDK
|
|
4
4
|
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+

|
|
14
|
+
|
|
5
15
|
This package is a set of common utilities that can be used across projects related or not related to ADAAS Ecosystem.
|
|
6
16
|
In this package it is possible to find useful features to work with structures, objects, types, commands, configuration management, logging, scheduling, and more.
|
|
7
17
|
|
|
8
18
|
|
|
9
19
|
| LTS | Latest | npm |
|
|
10
20
|
|---------------|----------|---------------------------|
|
|
11
|
-
| v0.1.
|
|
21
|
+
| v0.1.14 | v0.1.14 | [@adaas/a-utils](https://www.npmjs.com/package/@adaas/a-utils) |
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## ✨ Key Features
|
|
25
|
+
|
|
26
|
+
🚀 **Communication Channels** - Structured messaging with lifecycle management
|
|
27
|
+
⚡ **Command Pattern** - Event-driven command execution with serialization
|
|
28
|
+
🔧 **Configuration Management** - Multi-source config with type safety
|
|
29
|
+
📝 **Smart Logging** - Scope-aware logging with color support
|
|
30
|
+
🛡️ **Access Control** - Regex-based permission management
|
|
31
|
+
💾 **Memory Management** - Type-safe intermediate value storage
|
|
32
|
+
📅 **Task Scheduling** - Promise-based scheduling with cancellation
|
|
33
|
+
🔌 **Polyfills** - Cross-environment compatibility
|
|
34
|
+
🏗️ **Component Architecture** - Extensible dependency injection system
|
|
12
35
|
|
|
13
36
|
|
|
14
37
|
<!-- TABLE OF CONTENTS -->
|
|
@@ -16,6 +39,7 @@ In this package it is possible to find useful features to work with structures,
|
|
|
16
39
|
|
|
17
40
|
- [About the Project](#overview)
|
|
18
41
|
- [Installation](#installation)
|
|
42
|
+
- [Key Features](#-key-features)
|
|
19
43
|
- [Components](#components)
|
|
20
44
|
- [A-Channel](#a-channel)
|
|
21
45
|
- [A-Command](#a-command)
|
|
@@ -69,7 +93,7 @@ class HttpChannel extends A_Channel {}
|
|
|
69
93
|
class HttpProcessor extends A_Component {
|
|
70
94
|
@A_Feature.Extend({ scope: [HttpChannel] })
|
|
71
95
|
async [A_ChannelFeatures.onRequest](
|
|
72
|
-
@A_Inject(
|
|
96
|
+
@A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
73
97
|
) {
|
|
74
98
|
const response = await fetch(context.params.url);
|
|
75
99
|
(context as any)._result = await response.json();
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
import { A_Fragment, A_Error, A_Component, A_TYPES__Error_Serialized, A_TYPES__Entity_Serialized, A_Meta, A_TYPES__FeatureExtendDecoratorMeta, A_TYPES__FeatureDefineDecoratorMeta, A_Entity, A_Scope, A_TYPES__ConceptENVVariables, A_TYPES__Fragment_Constructor, A_Container, A_Feature, A_TYPES__Component_Constructor, A_TYPES__Entity_Constructor } from '@adaas/a-concept';
|
|
2
2
|
import { A_TYPES__Container_Constructor } from '@adaas/a-concept/dist/src/global/A-Container/A-Container.types';
|
|
3
3
|
|
|
4
|
+
declare enum A_ChannelFeatures {
|
|
5
|
+
/**
|
|
6
|
+
* Allows to extend timeout logic and behavior
|
|
7
|
+
*/
|
|
8
|
+
onTimeout = "onTimeout",
|
|
9
|
+
/**
|
|
10
|
+
* Allows to extend retry logic and behavior
|
|
11
|
+
*/
|
|
12
|
+
onRetry = "onRetry",
|
|
13
|
+
/**
|
|
14
|
+
* Allows to extend circuit breaker logic and behavior
|
|
15
|
+
*/
|
|
16
|
+
onCircuitBreakerOpen = "onCircuitBreakerOpen",
|
|
17
|
+
/**
|
|
18
|
+
* Allows to extend cache logic and behavior
|
|
19
|
+
*/
|
|
20
|
+
onCache = "onCache",
|
|
21
|
+
/**
|
|
22
|
+
* Allows to extend connection logic and behavior
|
|
23
|
+
*/
|
|
24
|
+
onConnect = "onConnect",
|
|
25
|
+
/**
|
|
26
|
+
* Allows to extend disconnection logic and behavior
|
|
27
|
+
*/
|
|
28
|
+
onDisconnect = "onDisconnect",
|
|
29
|
+
/**
|
|
30
|
+
* Allows to extend request preparation logic and behavior
|
|
31
|
+
*/
|
|
32
|
+
onBeforeRequest = "onBeforeRequest",
|
|
33
|
+
/**
|
|
34
|
+
* Allows to extend request sending logic and behavior
|
|
35
|
+
*/
|
|
36
|
+
onRequest = "onRequest",
|
|
37
|
+
/**
|
|
38
|
+
* Allows to extend request post-processing logic and behavior
|
|
39
|
+
*/
|
|
40
|
+
onAfterRequest = "onAfterRequest",
|
|
41
|
+
/**
|
|
42
|
+
* Allows to extend error handling logic and behavior
|
|
43
|
+
*
|
|
44
|
+
* [!] The same approach uses for ALL errors within the channel
|
|
45
|
+
*/
|
|
46
|
+
onError = "onError",
|
|
47
|
+
/**
|
|
48
|
+
* Allows to extend send logic and behavior
|
|
49
|
+
*/
|
|
50
|
+
onSend = "onSend",
|
|
51
|
+
/**
|
|
52
|
+
* Allows to extend consume logic and behavior
|
|
53
|
+
*/
|
|
54
|
+
onConsume = "onConsume"
|
|
55
|
+
}
|
|
4
56
|
declare enum A_ChannelRequestStatuses {
|
|
5
57
|
/**
|
|
6
58
|
* Request is pending
|
|
@@ -23,7 +75,7 @@ type A_ChannelRequestContext_Serialized<_ParamsType extends Record<string, any>
|
|
|
23
75
|
errors?: string[];
|
|
24
76
|
};
|
|
25
77
|
|
|
26
|
-
declare class
|
|
78
|
+
declare class A_ChannelRequest<_ParamsType extends Record<string, any> = Record<string, any>, _ResultType extends Record<string, any> = Record<string, any>> extends A_Fragment {
|
|
27
79
|
protected _params: _ParamsType;
|
|
28
80
|
protected _result?: _ResultType;
|
|
29
81
|
protected _errors: Set<Error>;
|
|
@@ -100,7 +152,7 @@ declare class A_ChannelRequestContext<_ParamsType extends Record<string, any> =
|
|
|
100
152
|
* class HttpProcessor extends A_Component {
|
|
101
153
|
* @A_Feature.Extend({ scope: [HttpChannel] })
|
|
102
154
|
* async [A_ChannelFeatures.onRequest](
|
|
103
|
-
* @A_Inject(
|
|
155
|
+
* @A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
104
156
|
* ) {
|
|
105
157
|
* const response = await fetch(context.params.url);
|
|
106
158
|
* (context as any)._result = await response.json();
|
|
@@ -215,7 +267,7 @@ declare class A_Channel extends A_Component {
|
|
|
215
267
|
* ```typescript
|
|
216
268
|
* @A_Feature.Extend({ scope: [HttpChannel] })
|
|
217
269
|
* async [A_ChannelFeatures.onBeforeRequest](
|
|
218
|
-
* @A_Inject(
|
|
270
|
+
* @A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
219
271
|
* ) {
|
|
220
272
|
* // Validate required parameters
|
|
221
273
|
* if (!context.params.url) {
|
|
@@ -240,7 +292,7 @@ declare class A_Channel extends A_Component {
|
|
|
240
292
|
* ```typescript
|
|
241
293
|
* @A_Feature.Extend({ scope: [HttpChannel] })
|
|
242
294
|
* async [A_ChannelFeatures.onRequest](
|
|
243
|
-
* @A_Inject(
|
|
295
|
+
* @A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
244
296
|
* ) {
|
|
245
297
|
* const response = await fetch(context.params.url);
|
|
246
298
|
* (context as any)._result = await response.json();
|
|
@@ -262,7 +314,7 @@ declare class A_Channel extends A_Component {
|
|
|
262
314
|
* ```typescript
|
|
263
315
|
* @A_Feature.Extend({ scope: [HttpChannel] })
|
|
264
316
|
* async [A_ChannelFeatures.onAfterRequest](
|
|
265
|
-
* @A_Inject(
|
|
317
|
+
* @A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
266
318
|
* ) {
|
|
267
319
|
* console.log(`Request completed in ${Date.now() - context.startTime}ms`);
|
|
268
320
|
* await this.cacheResponse(context.params, context.data);
|
|
@@ -284,7 +336,7 @@ declare class A_Channel extends A_Component {
|
|
|
284
336
|
* ```typescript
|
|
285
337
|
* @A_Feature.Extend({ scope: [HttpChannel] })
|
|
286
338
|
* async [A_ChannelFeatures.onError](
|
|
287
|
-
* @A_Inject(
|
|
339
|
+
* @A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
288
340
|
* ) {
|
|
289
341
|
* console.error('Request failed:', context.params, context.failed);
|
|
290
342
|
* await this.logError(context);
|
|
@@ -306,7 +358,7 @@ declare class A_Channel extends A_Component {
|
|
|
306
358
|
* ```typescript
|
|
307
359
|
* @A_Feature.Extend({ scope: [EventChannel] })
|
|
308
360
|
* async [A_ChannelFeatures.onSend](
|
|
309
|
-
* @A_Inject(
|
|
361
|
+
* @A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
310
362
|
* ) {
|
|
311
363
|
* const { eventType, payload } = context.params;
|
|
312
364
|
* await this.publishEvent(eventType, payload);
|
|
@@ -348,7 +400,7 @@ declare class A_Channel extends A_Component {
|
|
|
348
400
|
* @template _ParamsType The type of request parameters
|
|
349
401
|
* @template _ResultType The type of response data
|
|
350
402
|
* @param params The request parameters
|
|
351
|
-
* @returns {Promise<
|
|
403
|
+
* @returns {Promise<A_ChannelRequest<_ParamsType, _ResultType>>} Request context with response
|
|
352
404
|
*
|
|
353
405
|
* @example
|
|
354
406
|
* ```typescript
|
|
@@ -368,7 +420,7 @@ declare class A_Channel extends A_Component {
|
|
|
368
420
|
* }
|
|
369
421
|
* ```
|
|
370
422
|
*/
|
|
371
|
-
request<_ParamsType extends Record<string, any> = Record<string, any>, _ResultType extends Record<string, any> = Record<string, any>>(params: _ParamsType): Promise<
|
|
423
|
+
request<_ParamsType extends Record<string, any> = Record<string, any>, _ResultType extends Record<string, any> = Record<string, any>>(params: _ParamsType): Promise<A_ChannelRequest<_ParamsType, _ResultType>>;
|
|
372
424
|
/**
|
|
373
425
|
* Sends a fire-and-forget message (Send pattern).
|
|
374
426
|
*
|
|
@@ -420,12 +472,12 @@ declare class A_Channel extends A_Component {
|
|
|
420
472
|
* For fire-and-forget pattern: Use send()
|
|
421
473
|
* For consumer patterns: Implement custom consumer logic using request() in a loop
|
|
422
474
|
*/
|
|
423
|
-
consume<T extends Record<string, any> = Record<string, any>>(): Promise<
|
|
475
|
+
consume<T extends Record<string, any> = Record<string, any>>(): Promise<A_ChannelRequest<any, T>>;
|
|
424
476
|
}
|
|
425
477
|
|
|
426
478
|
declare class A_ChannelError extends A_Error {
|
|
427
479
|
static readonly MethodNotImplemented = "A-Channel Method Not Implemented";
|
|
428
|
-
protected _context?:
|
|
480
|
+
protected _context?: A_ChannelRequest;
|
|
429
481
|
/**
|
|
430
482
|
* Channel Error allows to keep track of errors within a channel if something goes wrong
|
|
431
483
|
*
|
|
@@ -433,11 +485,11 @@ declare class A_ChannelError extends A_Error {
|
|
|
433
485
|
* @param originalError
|
|
434
486
|
* @param context
|
|
435
487
|
*/
|
|
436
|
-
constructor(originalError: string | A_Error | Error | any, context?:
|
|
488
|
+
constructor(originalError: string | A_Error | Error | any, context?: A_ChannelRequest | string);
|
|
437
489
|
/***
|
|
438
490
|
* Returns Context of the error
|
|
439
491
|
*/
|
|
440
|
-
get context():
|
|
492
|
+
get context(): A_ChannelRequest | undefined;
|
|
441
493
|
}
|
|
442
494
|
|
|
443
495
|
declare enum A_TYPES__CommandMetaKey {
|
|
@@ -1351,4 +1403,4 @@ declare class A_Deferred<T> {
|
|
|
1351
1403
|
reject(reason?: any): void;
|
|
1352
1404
|
}
|
|
1353
1405
|
|
|
1354
|
-
export { A_CONSTANTS_A_Command_Features, type A_CONSTANTS__A_Command_Event, A_CONSTANTS__A_Command_Status, A_CONSTANTS__CONFIG_ENV_VARIABLES, A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY, A_Channel, A_ChannelError, A_Command, A_CommandError, A_Config, A_ConfigError, A_ConfigLoader, A_Deferred, A_Logger, A_Manifest, A_ManifestChecker, A_ManifestError, A_Memory, A_Polyfill, A_Schedule, A_ScheduleObject, type A_TYPES__CommandMeta, A_TYPES__CommandMetaKey, type A_TYPES__Command_Constructor, type A_TYPES__Command_Init, type A_TYPES__Command_Listener, type A_TYPES__Command_Serialized, type A_TYPES__ConfigContainerConstructor, type A_TYPES__ConfigENVVariables, A_TYPES__ConfigFeature, type A_UTILS_TYPES__ManifestQuery, type A_UTILS_TYPES__ManifestRule, type A_UTILS_TYPES__Manifest_AllowedComponents, type A_UTILS_TYPES__Manifest_ComponentLevelConfig, type A_UTILS_TYPES__Manifest_Init, type A_UTILS_TYPES__Manifest_MethodLevelConfig, type A_UTILS_TYPES__Manifest_Rules, type A_UTILS_TYPES__ScheduleObjectCallback, type A_UTILS_TYPES__ScheduleObjectConfig, ConfigReader, ENVConfigReader, FileConfigReader, type IbufferInterface, type IcryptoInterface, type Ifspolyfill, type IhttpInterface, type IhttpsInterface, type IpathInterface, type IprocessInterface, type IurlInterface };
|
|
1406
|
+
export { A_CONSTANTS_A_Command_Features, type A_CONSTANTS__A_Command_Event, A_CONSTANTS__A_Command_Status, A_CONSTANTS__CONFIG_ENV_VARIABLES, A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY, A_Channel, A_ChannelError, A_ChannelFeatures, A_ChannelRequest, type A_ChannelRequestContext_Serialized, A_ChannelRequestStatuses, A_Command, A_CommandError, A_Config, A_ConfigError, A_ConfigLoader, A_Deferred, A_Logger, A_Manifest, A_ManifestChecker, A_ManifestError, A_Memory, A_Polyfill, A_Schedule, A_ScheduleObject, type A_TYPES__CommandMeta, A_TYPES__CommandMetaKey, type A_TYPES__Command_Constructor, type A_TYPES__Command_Init, type A_TYPES__Command_Listener, type A_TYPES__Command_Serialized, type A_TYPES__ConfigContainerConstructor, type A_TYPES__ConfigENVVariables, A_TYPES__ConfigFeature, type A_UTILS_TYPES__ManifestQuery, type A_UTILS_TYPES__ManifestRule, type A_UTILS_TYPES__Manifest_AllowedComponents, type A_UTILS_TYPES__Manifest_ComponentLevelConfig, type A_UTILS_TYPES__Manifest_Init, type A_UTILS_TYPES__Manifest_MethodLevelConfig, type A_UTILS_TYPES__Manifest_Rules, type A_UTILS_TYPES__ScheduleObjectCallback, type A_UTILS_TYPES__ScheduleObjectConfig, ConfigReader, ENVConfigReader, FileConfigReader, type IbufferInterface, type IcryptoInterface, type Ifspolyfill, type IhttpInterface, type IhttpsInterface, type IpathInterface, type IprocessInterface, type IurlInterface };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
import { A_Fragment, A_Error, A_Component, A_TYPES__Error_Serialized, A_TYPES__Entity_Serialized, A_Meta, A_TYPES__FeatureExtendDecoratorMeta, A_TYPES__FeatureDefineDecoratorMeta, A_Entity, A_Scope, A_TYPES__ConceptENVVariables, A_TYPES__Fragment_Constructor, A_Container, A_Feature, A_TYPES__Component_Constructor, A_TYPES__Entity_Constructor } from '@adaas/a-concept';
|
|
2
2
|
import { A_TYPES__Container_Constructor } from '@adaas/a-concept/dist/src/global/A-Container/A-Container.types';
|
|
3
3
|
|
|
4
|
+
declare enum A_ChannelFeatures {
|
|
5
|
+
/**
|
|
6
|
+
* Allows to extend timeout logic and behavior
|
|
7
|
+
*/
|
|
8
|
+
onTimeout = "onTimeout",
|
|
9
|
+
/**
|
|
10
|
+
* Allows to extend retry logic and behavior
|
|
11
|
+
*/
|
|
12
|
+
onRetry = "onRetry",
|
|
13
|
+
/**
|
|
14
|
+
* Allows to extend circuit breaker logic and behavior
|
|
15
|
+
*/
|
|
16
|
+
onCircuitBreakerOpen = "onCircuitBreakerOpen",
|
|
17
|
+
/**
|
|
18
|
+
* Allows to extend cache logic and behavior
|
|
19
|
+
*/
|
|
20
|
+
onCache = "onCache",
|
|
21
|
+
/**
|
|
22
|
+
* Allows to extend connection logic and behavior
|
|
23
|
+
*/
|
|
24
|
+
onConnect = "onConnect",
|
|
25
|
+
/**
|
|
26
|
+
* Allows to extend disconnection logic and behavior
|
|
27
|
+
*/
|
|
28
|
+
onDisconnect = "onDisconnect",
|
|
29
|
+
/**
|
|
30
|
+
* Allows to extend request preparation logic and behavior
|
|
31
|
+
*/
|
|
32
|
+
onBeforeRequest = "onBeforeRequest",
|
|
33
|
+
/**
|
|
34
|
+
* Allows to extend request sending logic and behavior
|
|
35
|
+
*/
|
|
36
|
+
onRequest = "onRequest",
|
|
37
|
+
/**
|
|
38
|
+
* Allows to extend request post-processing logic and behavior
|
|
39
|
+
*/
|
|
40
|
+
onAfterRequest = "onAfterRequest",
|
|
41
|
+
/**
|
|
42
|
+
* Allows to extend error handling logic and behavior
|
|
43
|
+
*
|
|
44
|
+
* [!] The same approach uses for ALL errors within the channel
|
|
45
|
+
*/
|
|
46
|
+
onError = "onError",
|
|
47
|
+
/**
|
|
48
|
+
* Allows to extend send logic and behavior
|
|
49
|
+
*/
|
|
50
|
+
onSend = "onSend",
|
|
51
|
+
/**
|
|
52
|
+
* Allows to extend consume logic and behavior
|
|
53
|
+
*/
|
|
54
|
+
onConsume = "onConsume"
|
|
55
|
+
}
|
|
4
56
|
declare enum A_ChannelRequestStatuses {
|
|
5
57
|
/**
|
|
6
58
|
* Request is pending
|
|
@@ -23,7 +75,7 @@ type A_ChannelRequestContext_Serialized<_ParamsType extends Record<string, any>
|
|
|
23
75
|
errors?: string[];
|
|
24
76
|
};
|
|
25
77
|
|
|
26
|
-
declare class
|
|
78
|
+
declare class A_ChannelRequest<_ParamsType extends Record<string, any> = Record<string, any>, _ResultType extends Record<string, any> = Record<string, any>> extends A_Fragment {
|
|
27
79
|
protected _params: _ParamsType;
|
|
28
80
|
protected _result?: _ResultType;
|
|
29
81
|
protected _errors: Set<Error>;
|
|
@@ -100,7 +152,7 @@ declare class A_ChannelRequestContext<_ParamsType extends Record<string, any> =
|
|
|
100
152
|
* class HttpProcessor extends A_Component {
|
|
101
153
|
* @A_Feature.Extend({ scope: [HttpChannel] })
|
|
102
154
|
* async [A_ChannelFeatures.onRequest](
|
|
103
|
-
* @A_Inject(
|
|
155
|
+
* @A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
104
156
|
* ) {
|
|
105
157
|
* const response = await fetch(context.params.url);
|
|
106
158
|
* (context as any)._result = await response.json();
|
|
@@ -215,7 +267,7 @@ declare class A_Channel extends A_Component {
|
|
|
215
267
|
* ```typescript
|
|
216
268
|
* @A_Feature.Extend({ scope: [HttpChannel] })
|
|
217
269
|
* async [A_ChannelFeatures.onBeforeRequest](
|
|
218
|
-
* @A_Inject(
|
|
270
|
+
* @A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
219
271
|
* ) {
|
|
220
272
|
* // Validate required parameters
|
|
221
273
|
* if (!context.params.url) {
|
|
@@ -240,7 +292,7 @@ declare class A_Channel extends A_Component {
|
|
|
240
292
|
* ```typescript
|
|
241
293
|
* @A_Feature.Extend({ scope: [HttpChannel] })
|
|
242
294
|
* async [A_ChannelFeatures.onRequest](
|
|
243
|
-
* @A_Inject(
|
|
295
|
+
* @A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
244
296
|
* ) {
|
|
245
297
|
* const response = await fetch(context.params.url);
|
|
246
298
|
* (context as any)._result = await response.json();
|
|
@@ -262,7 +314,7 @@ declare class A_Channel extends A_Component {
|
|
|
262
314
|
* ```typescript
|
|
263
315
|
* @A_Feature.Extend({ scope: [HttpChannel] })
|
|
264
316
|
* async [A_ChannelFeatures.onAfterRequest](
|
|
265
|
-
* @A_Inject(
|
|
317
|
+
* @A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
266
318
|
* ) {
|
|
267
319
|
* console.log(`Request completed in ${Date.now() - context.startTime}ms`);
|
|
268
320
|
* await this.cacheResponse(context.params, context.data);
|
|
@@ -284,7 +336,7 @@ declare class A_Channel extends A_Component {
|
|
|
284
336
|
* ```typescript
|
|
285
337
|
* @A_Feature.Extend({ scope: [HttpChannel] })
|
|
286
338
|
* async [A_ChannelFeatures.onError](
|
|
287
|
-
* @A_Inject(
|
|
339
|
+
* @A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
288
340
|
* ) {
|
|
289
341
|
* console.error('Request failed:', context.params, context.failed);
|
|
290
342
|
* await this.logError(context);
|
|
@@ -306,7 +358,7 @@ declare class A_Channel extends A_Component {
|
|
|
306
358
|
* ```typescript
|
|
307
359
|
* @A_Feature.Extend({ scope: [EventChannel] })
|
|
308
360
|
* async [A_ChannelFeatures.onSend](
|
|
309
|
-
* @A_Inject(
|
|
361
|
+
* @A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
310
362
|
* ) {
|
|
311
363
|
* const { eventType, payload } = context.params;
|
|
312
364
|
* await this.publishEvent(eventType, payload);
|
|
@@ -348,7 +400,7 @@ declare class A_Channel extends A_Component {
|
|
|
348
400
|
* @template _ParamsType The type of request parameters
|
|
349
401
|
* @template _ResultType The type of response data
|
|
350
402
|
* @param params The request parameters
|
|
351
|
-
* @returns {Promise<
|
|
403
|
+
* @returns {Promise<A_ChannelRequest<_ParamsType, _ResultType>>} Request context with response
|
|
352
404
|
*
|
|
353
405
|
* @example
|
|
354
406
|
* ```typescript
|
|
@@ -368,7 +420,7 @@ declare class A_Channel extends A_Component {
|
|
|
368
420
|
* }
|
|
369
421
|
* ```
|
|
370
422
|
*/
|
|
371
|
-
request<_ParamsType extends Record<string, any> = Record<string, any>, _ResultType extends Record<string, any> = Record<string, any>>(params: _ParamsType): Promise<
|
|
423
|
+
request<_ParamsType extends Record<string, any> = Record<string, any>, _ResultType extends Record<string, any> = Record<string, any>>(params: _ParamsType): Promise<A_ChannelRequest<_ParamsType, _ResultType>>;
|
|
372
424
|
/**
|
|
373
425
|
* Sends a fire-and-forget message (Send pattern).
|
|
374
426
|
*
|
|
@@ -420,12 +472,12 @@ declare class A_Channel extends A_Component {
|
|
|
420
472
|
* For fire-and-forget pattern: Use send()
|
|
421
473
|
* For consumer patterns: Implement custom consumer logic using request() in a loop
|
|
422
474
|
*/
|
|
423
|
-
consume<T extends Record<string, any> = Record<string, any>>(): Promise<
|
|
475
|
+
consume<T extends Record<string, any> = Record<string, any>>(): Promise<A_ChannelRequest<any, T>>;
|
|
424
476
|
}
|
|
425
477
|
|
|
426
478
|
declare class A_ChannelError extends A_Error {
|
|
427
479
|
static readonly MethodNotImplemented = "A-Channel Method Not Implemented";
|
|
428
|
-
protected _context?:
|
|
480
|
+
protected _context?: A_ChannelRequest;
|
|
429
481
|
/**
|
|
430
482
|
* Channel Error allows to keep track of errors within a channel if something goes wrong
|
|
431
483
|
*
|
|
@@ -433,11 +485,11 @@ declare class A_ChannelError extends A_Error {
|
|
|
433
485
|
* @param originalError
|
|
434
486
|
* @param context
|
|
435
487
|
*/
|
|
436
|
-
constructor(originalError: string | A_Error | Error | any, context?:
|
|
488
|
+
constructor(originalError: string | A_Error | Error | any, context?: A_ChannelRequest | string);
|
|
437
489
|
/***
|
|
438
490
|
* Returns Context of the error
|
|
439
491
|
*/
|
|
440
|
-
get context():
|
|
492
|
+
get context(): A_ChannelRequest | undefined;
|
|
441
493
|
}
|
|
442
494
|
|
|
443
495
|
declare enum A_TYPES__CommandMetaKey {
|
|
@@ -1351,4 +1403,4 @@ declare class A_Deferred<T> {
|
|
|
1351
1403
|
reject(reason?: any): void;
|
|
1352
1404
|
}
|
|
1353
1405
|
|
|
1354
|
-
export { A_CONSTANTS_A_Command_Features, type A_CONSTANTS__A_Command_Event, A_CONSTANTS__A_Command_Status, A_CONSTANTS__CONFIG_ENV_VARIABLES, A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY, A_Channel, A_ChannelError, A_Command, A_CommandError, A_Config, A_ConfigError, A_ConfigLoader, A_Deferred, A_Logger, A_Manifest, A_ManifestChecker, A_ManifestError, A_Memory, A_Polyfill, A_Schedule, A_ScheduleObject, type A_TYPES__CommandMeta, A_TYPES__CommandMetaKey, type A_TYPES__Command_Constructor, type A_TYPES__Command_Init, type A_TYPES__Command_Listener, type A_TYPES__Command_Serialized, type A_TYPES__ConfigContainerConstructor, type A_TYPES__ConfigENVVariables, A_TYPES__ConfigFeature, type A_UTILS_TYPES__ManifestQuery, type A_UTILS_TYPES__ManifestRule, type A_UTILS_TYPES__Manifest_AllowedComponents, type A_UTILS_TYPES__Manifest_ComponentLevelConfig, type A_UTILS_TYPES__Manifest_Init, type A_UTILS_TYPES__Manifest_MethodLevelConfig, type A_UTILS_TYPES__Manifest_Rules, type A_UTILS_TYPES__ScheduleObjectCallback, type A_UTILS_TYPES__ScheduleObjectConfig, ConfigReader, ENVConfigReader, FileConfigReader, type IbufferInterface, type IcryptoInterface, type Ifspolyfill, type IhttpInterface, type IhttpsInterface, type IpathInterface, type IprocessInterface, type IurlInterface };
|
|
1406
|
+
export { A_CONSTANTS_A_Command_Features, type A_CONSTANTS__A_Command_Event, A_CONSTANTS__A_Command_Status, A_CONSTANTS__CONFIG_ENV_VARIABLES, A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY, A_Channel, A_ChannelError, A_ChannelFeatures, A_ChannelRequest, type A_ChannelRequestContext_Serialized, A_ChannelRequestStatuses, A_Command, A_CommandError, A_Config, A_ConfigError, A_ConfigLoader, A_Deferred, A_Logger, A_Manifest, A_ManifestChecker, A_ManifestError, A_Memory, A_Polyfill, A_Schedule, A_ScheduleObject, type A_TYPES__CommandMeta, A_TYPES__CommandMetaKey, type A_TYPES__Command_Constructor, type A_TYPES__Command_Init, type A_TYPES__Command_Listener, type A_TYPES__Command_Serialized, type A_TYPES__ConfigContainerConstructor, type A_TYPES__ConfigENVVariables, A_TYPES__ConfigFeature, type A_UTILS_TYPES__ManifestQuery, type A_UTILS_TYPES__ManifestRule, type A_UTILS_TYPES__Manifest_AllowedComponents, type A_UTILS_TYPES__Manifest_ComponentLevelConfig, type A_UTILS_TYPES__Manifest_Init, type A_UTILS_TYPES__Manifest_MethodLevelConfig, type A_UTILS_TYPES__Manifest_Rules, type A_UTILS_TYPES__ScheduleObjectCallback, type A_UTILS_TYPES__ScheduleObjectConfig, ConfigReader, ENVConfigReader, FileConfigReader, type IbufferInterface, type IcryptoInterface, type Ifspolyfill, type IhttpInterface, type IhttpsInterface, type IpathInterface, type IprocessInterface, type IurlInterface };
|