@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.
@@ -2,7 +2,7 @@ import './jest.setup';
2
2
  import { A_Context, A_Component, A_Feature, A_Inject } from '@adaas/a-concept';
3
3
  import { A_Channel } from '@adaas/a-utils/lib/A-Channel/A-Channel.component';
4
4
  import { A_ChannelFeatures } from '@adaas/a-utils/lib/A-Channel/A-Channel.constants';
5
- import { A_ChannelRequestContext } from '@adaas/a-utils/lib/A-Channel/A-ChannelRequest.context';
5
+ import { A_ChannelRequest } from '@adaas/a-utils/lib/A-Channel/A-ChannelRequest.context';
6
6
  import { A_ChannelError } from '@adaas/a-utils/lib/A-Channel/A-Channel.error';
7
7
 
8
8
  jest.retryTimes(0);
@@ -97,7 +97,7 @@ describe('A-Channel tests', () => {
97
97
  const params = { action: 'test', data: 'hello' };
98
98
  const context = await channel.request(params);
99
99
 
100
- expect(context).toBeInstanceOf(A_ChannelRequestContext);
100
+ expect(context).toBeInstanceOf(A_ChannelRequest);
101
101
  expect(context.params).toEqual(params);
102
102
  expect(channel.processing).toBe(false); // Should reset after processing
103
103
  });
@@ -110,7 +110,7 @@ describe('A-Channel tests', () => {
110
110
  class RequestProcessor extends A_Component {
111
111
  @A_Feature.Extend({ scope: [TestChannel] })
112
112
  async [A_ChannelFeatures.onBeforeRequest](
113
- @A_Inject(A_ChannelRequestContext) context: A_ChannelRequestContext
113
+ @A_Inject(A_ChannelRequest) context: A_ChannelRequest
114
114
  ) {
115
115
  processingOrder.push('before');
116
116
  expect(context.params.action).toBe('test');
@@ -118,7 +118,7 @@ describe('A-Channel tests', () => {
118
118
 
119
119
  @A_Feature.Extend({ scope: [TestChannel] })
120
120
  async [A_ChannelFeatures.onRequest](
121
- @A_Inject(A_ChannelRequestContext) context: A_ChannelRequestContext
121
+ @A_Inject(A_ChannelRequest) context: A_ChannelRequest
122
122
  ) {
123
123
  processingOrder.push('during');
124
124
  // Simulate processing and setting result
@@ -127,7 +127,7 @@ describe('A-Channel tests', () => {
127
127
 
128
128
  @A_Feature.Extend({ scope: [TestChannel] })
129
129
  async [A_ChannelFeatures.onAfterRequest](
130
- @A_Inject(A_ChannelRequestContext) context: A_ChannelRequestContext
130
+ @A_Inject(A_ChannelRequest) context: A_ChannelRequest
131
131
  ) {
132
132
  processingOrder.push('after');
133
133
  expect(context.data).toBeDefined();
@@ -159,7 +159,7 @@ describe('A-Channel tests', () => {
159
159
 
160
160
  @A_Feature.Extend({ scope: [ErrorChannel] })
161
161
  async [A_ChannelFeatures.onError](
162
- @A_Inject(A_ChannelRequestContext) context: A_ChannelRequestContext
162
+ @A_Inject(A_ChannelRequest) context: A_ChannelRequest
163
163
  ) {
164
164
  errorCalls.push('error-handled');
165
165
  expect(context.failed).toBe(true);
@@ -196,7 +196,7 @@ describe('A-Channel tests', () => {
196
196
  class TypedProcessor extends A_Component {
197
197
  @A_Feature.Extend({ scope: [TypedChannel] })
198
198
  async [A_ChannelFeatures.onRequest](
199
- @A_Inject(A_ChannelRequestContext) context: A_ChannelRequestContext<TestParams, TestResult>
199
+ @A_Inject(A_ChannelRequest) context: A_ChannelRequest<TestParams, TestResult>
200
200
  ) {
201
201
  const { userId, action } = context.params;
202
202
  (context as any)._result = {
@@ -243,7 +243,7 @@ describe('A-Channel tests', () => {
243
243
  class SendProcessor extends A_Component {
244
244
  @A_Feature.Extend({ scope: [SendChannel] })
245
245
  async [A_ChannelFeatures.onSend](
246
- @A_Inject(A_ChannelRequestContext) context: A_ChannelRequestContext
246
+ @A_Inject(A_ChannelRequest) context: A_ChannelRequest
247
247
  ) {
248
248
  sentMessages.push(context.params);
249
249
  }
@@ -278,7 +278,7 @@ describe('A-Channel tests', () => {
278
278
 
279
279
  @A_Feature.Extend({ scope: [ErrorSendChannel] })
280
280
  async [A_ChannelFeatures.onError](
281
- @A_Inject(A_ChannelRequestContext) context: A_ChannelRequestContext
281
+ @A_Inject(A_ChannelRequest) context: A_ChannelRequest
282
282
  ) {
283
283
  errorCalls.push('send-error-handled');
284
284
  expect(context.failed).toBe(true);
@@ -316,7 +316,7 @@ describe('A-Channel tests', () => {
316
316
  class MultiErrorProcessor extends A_Component {
317
317
  @A_Feature.Extend({ scope: [MultiErrorChannel] })
318
318
  async [A_ChannelFeatures.onRequest](
319
- @A_Inject(A_ChannelRequestContext) context: A_ChannelRequestContext
319
+ @A_Inject(A_ChannelRequest) context: A_ChannelRequest
320
320
  ) {
321
321
  const errorType = context.params.errorType;
322
322
  switch (errorType) {
@@ -333,7 +333,7 @@ describe('A-Channel tests', () => {
333
333
 
334
334
  @A_Feature.Extend({ scope: [MultiErrorChannel] })
335
335
  async [A_ChannelFeatures.onError](
336
- @A_Inject(A_ChannelRequestContext) context: A_ChannelRequestContext
336
+ @A_Inject(A_ChannelRequest) context: A_ChannelRequest
337
337
  ) {
338
338
  errorTypes.push(context.params.errorType);
339
339
  }
@@ -405,7 +405,7 @@ describe('A-Channel tests', () => {
405
405
  class HttpProcessor extends A_Component {
406
406
  @A_Feature.Extend({ scope: [HttpChannel] })
407
407
  async [A_ChannelFeatures.onRequest](
408
- @A_Inject(A_ChannelRequestContext) context: A_ChannelRequestContext
408
+ @A_Inject(A_ChannelRequest) context: A_ChannelRequest
409
409
  ) {
410
410
  httpCalls.push(`HTTP: ${context.params.method} ${context.params.url}`);
411
411
  }
@@ -414,7 +414,7 @@ describe('A-Channel tests', () => {
414
414
  class WebSocketProcessor extends A_Component {
415
415
  @A_Feature.Extend({ scope: [WebSocketChannel] })
416
416
  async [A_ChannelFeatures.onSend](
417
- @A_Inject(A_ChannelRequestContext) context: A_ChannelRequestContext
417
+ @A_Inject(A_ChannelRequest) context: A_ChannelRequest
418
418
  ) {
419
419
  wsCalls.push(`WS: ${context.params.message}`);
420
420
  }
@@ -446,7 +446,7 @@ describe('A-Channel tests', () => {
446
446
  class ConcurrentProcessor extends A_Component {
447
447
  @A_Feature.Extend({ scope: [ConcurrentChannel] })
448
448
  async [A_ChannelFeatures.onRequest](
449
- @A_Inject(A_ChannelRequestContext) context: A_ChannelRequestContext
449
+ @A_Inject(A_ChannelRequest) context: A_ChannelRequest
450
450
  ) {
451
451
  const delay = context.params.delay || 0;
452
452
  await new Promise(resolve => setTimeout(resolve, delay));