@creator.co/wapi 1.2.5 → 1.2.6

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 (115) hide show
  1. package/README.md +216 -5
  2. package/dist/index.d.ts +15 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/package.json +6 -1
  5. package/dist/src/API/Request.d.ts +45 -82
  6. package/dist/src/API/Request.js +49 -77
  7. package/dist/src/API/Request.js.map +1 -1
  8. package/dist/src/API/Response.d.ts +94 -163
  9. package/dist/src/API/Response.js +101 -161
  10. package/dist/src/API/Response.js.map +1 -1
  11. package/dist/src/API/Utils.d.ts +21 -42
  12. package/dist/src/API/Utils.js +22 -43
  13. package/dist/src/API/Utils.js.map +1 -1
  14. package/dist/src/BaseEvent/EventProcessor.d.ts +32 -55
  15. package/dist/src/BaseEvent/EventProcessor.js +30 -38
  16. package/dist/src/BaseEvent/EventProcessor.js.map +1 -1
  17. package/dist/src/BaseEvent/Process.d.ts +20 -43
  18. package/dist/src/BaseEvent/Process.js +16 -27
  19. package/dist/src/BaseEvent/Process.js.map +1 -1
  20. package/dist/src/BaseEvent/Transaction.d.ts +94 -2
  21. package/dist/src/BaseEvent/Transaction.js +49 -4
  22. package/dist/src/BaseEvent/Transaction.js.map +1 -1
  23. package/dist/src/Config/Configuration.d.ts +48 -66
  24. package/dist/src/Config/Configuration.js +25 -42
  25. package/dist/src/Config/Configuration.js.map +1 -1
  26. package/dist/src/Config/EnvironmentVar.d.ts +30 -57
  27. package/dist/src/Config/EnvironmentVar.js +28 -41
  28. package/dist/src/Config/EnvironmentVar.js.map +1 -1
  29. package/dist/src/Crypto/Crypto.d.ts +17 -35
  30. package/dist/src/Crypto/Crypto.js +12 -21
  31. package/dist/src/Crypto/Crypto.js.map +1 -1
  32. package/dist/src/Crypto/JWT.d.ts +21 -32
  33. package/dist/src/Crypto/JWT.js +14 -22
  34. package/dist/src/Crypto/JWT.js.map +1 -1
  35. package/dist/src/Globals.d.ts +26 -94
  36. package/dist/src/Globals.js +26 -95
  37. package/dist/src/Globals.js.map +1 -1
  38. package/dist/src/Logger/Logger.d.ts +82 -105
  39. package/dist/src/Logger/Logger.js +111 -136
  40. package/dist/src/Logger/Logger.js.map +1 -1
  41. package/dist/src/Mailer/Mailer.d.ts +39 -75
  42. package/dist/src/Mailer/Mailer.js +36 -65
  43. package/dist/src/Mailer/Mailer.js.map +1 -1
  44. package/dist/src/Publisher/Publisher.d.ts +17 -25
  45. package/dist/src/Publisher/Publisher.js +21 -32
  46. package/dist/src/Publisher/Publisher.js.map +1 -1
  47. package/dist/src/Server/RouteResolver.d.ts +14 -22
  48. package/dist/src/Server/RouteResolver.js +21 -34
  49. package/dist/src/Server/RouteResolver.js.map +1 -1
  50. package/dist/src/Server/Router.d.ts +72 -51
  51. package/dist/src/Server/Router.js +8 -17
  52. package/dist/src/Server/Router.js.map +1 -1
  53. package/dist/src/Server/lib/ContainerServer.d.ts +15 -31
  54. package/dist/src/Server/lib/ContainerServer.js +13 -28
  55. package/dist/src/Server/lib/ContainerServer.js.map +1 -1
  56. package/dist/src/Server/lib/Server.d.ts +17 -32
  57. package/dist/src/Server/lib/Server.js +18 -28
  58. package/dist/src/Server/lib/Server.js.map +1 -1
  59. package/dist/src/Server/lib/container/GenericHandler.d.ts +5 -0
  60. package/dist/src/Server/lib/container/GenericHandler.js +16 -3
  61. package/dist/src/Server/lib/container/GenericHandler.js.map +1 -1
  62. package/dist/src/Server/lib/container/GenericHandlerEvent.d.ts +22 -37
  63. package/dist/src/Server/lib/container/GenericHandlerEvent.js +29 -41
  64. package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -1
  65. package/dist/src/Server/lib/container/HealthHandler.d.ts +6 -0
  66. package/dist/src/Server/lib/container/HealthHandler.js +6 -0
  67. package/dist/src/Server/lib/container/HealthHandler.js.map +1 -1
  68. package/dist/src/Server/lib/container/Proxy.d.ts +24 -52
  69. package/dist/src/Server/lib/container/Proxy.js +49 -50
  70. package/dist/src/Server/lib/container/Proxy.js.map +1 -1
  71. package/dist/src/Server/lib/container/Utils.d.ts +6 -10
  72. package/dist/src/Server/lib/container/Utils.js +6 -10
  73. package/dist/src/Server/lib/container/Utils.js.map +1 -1
  74. package/dist/src/Validation/Validator.d.ts +9 -13
  75. package/dist/src/Validation/Validator.js +8 -12
  76. package/dist/src/Validation/Validator.js.map +1 -1
  77. package/index.ts +15 -0
  78. package/package.json +6 -1
  79. package/src/API/Request.ts +66 -84
  80. package/src/API/Response.ts +144 -203
  81. package/src/API/Utils.ts +28 -44
  82. package/src/BaseEvent/EventProcessor.ts +52 -77
  83. package/src/BaseEvent/Process.ts +27 -52
  84. package/src/BaseEvent/Transaction.ts +100 -10
  85. package/src/Config/Configuration.ts +59 -76
  86. package/src/Config/EnvironmentVar.ts +39 -62
  87. package/src/Crypto/Crypto.ts +20 -36
  88. package/src/Crypto/JWT.ts +31 -35
  89. package/src/Globals.ts +28 -96
  90. package/src/Logger/Logger.ts +141 -160
  91. package/src/Mailer/Mailer.ts +43 -76
  92. package/src/Publisher/Publisher.ts +31 -40
  93. package/src/Server/RouteResolver.ts +31 -52
  94. package/src/Server/Router.ts +75 -54
  95. package/src/Server/lib/ContainerServer.ts +20 -32
  96. package/src/Server/lib/Server.ts +19 -34
  97. package/src/Server/lib/container/GenericHandler.ts +17 -3
  98. package/src/Server/lib/container/GenericHandlerEvent.ts +44 -54
  99. package/src/Server/lib/container/HealthHandler.ts +6 -0
  100. package/src/Server/lib/container/Proxy.ts +37 -57
  101. package/src/Server/lib/container/Utils.ts +7 -10
  102. package/src/Validation/Validator.ts +11 -13
  103. package/tests/API/Response.test.ts +55 -56
  104. package/tests/BaseEvent/EventProcessor.test.ts +49 -50
  105. package/tests/BaseEvent/Process.test.ts +2 -2
  106. package/tests/BaseEvent/Transaction.test.ts +48 -49
  107. package/tests/Config/Config.test.ts +27 -27
  108. package/tests/Config/EnvironmentVar.test.ts +54 -18
  109. package/tests/Publisher/Publisher.test.ts +3 -3
  110. package/tests/Server/lib/ContainerServer.test.ts +21 -22
  111. package/tests/Server/lib/container/GenericHandler.test.ts +31 -32
  112. package/tests/Server/lib/container/GenericHandlerEvent.test.ts +2 -2
  113. package/tests/Server/lib/container/HealthHandler.test.ts +6 -7
  114. package/tests/Server/lib/container/Proxy.test.ts +37 -35
  115. package/tsconfig.json +1 -1
@@ -1,6 +1,5 @@
1
- import { expect as j_expect } from '@jest/globals'
2
1
  import { APIGatewayEvent, Context } from 'aws-lambda'
3
- import { expect } from 'chai'
2
+ import { expect as c_expect } from 'chai'
4
3
 
5
4
  import Response from '../../src/API/Response'
6
5
  import Transaction from '../../src/BaseEvent/Transaction'
@@ -11,11 +10,11 @@ async function testResponse(r: Response<any>, body: any, optCode?: number, optHe
11
10
  const t = observableTransaction()
12
11
  const context = t['context']
13
12
  const buildR = await r.build(context, t, false)
14
- expect(buildR).to.be.undefined
15
- j_expect(t.responseProxy).toBeCalledTimes(1)
16
- j_expect(context.fail).not.toBeCalled()
17
- j_expect(context.done).not.toBeCalled()
18
- j_expect(context.succeed).toHaveBeenCalledWith({
13
+ c_expect(buildR).to.be.undefined
14
+ expect(t.responseProxy).toBeCalledTimes(1)
15
+ expect(context.fail).not.toBeCalled()
16
+ expect(context.done).not.toBeCalled()
17
+ expect(context.succeed).toHaveBeenCalledWith({
19
18
  statusCode: optCode || 400,
20
19
  headers: {
21
20
  ...defaultHeaders,
@@ -35,28 +34,28 @@ async function testResponse(r: Response<any>, body: any, optCode?: number, optHe
35
34
  describe('Response basics', () => {
36
35
  test('Null body', () => {
37
36
  const r = new Response<null>(200, null)
38
- expect(r.getCode()).to.be.equals(200)
39
- expect(r.getBody()).to.be.null
37
+ c_expect(r.getCode()).to.be.equals(200)
38
+ c_expect(r.getBody()).to.be.null
40
39
  })
41
40
 
42
41
  test('String body', () => {
43
42
  const r = new Response<string>(200, 'abc')
44
- expect(r.getCode()).to.be.equals(200)
45
- expect(r.getBody()).to.be.equals('abc')
43
+ c_expect(r.getCode()).to.be.equals(200)
44
+ c_expect(r.getBody()).to.be.equals('abc')
46
45
  })
47
46
 
48
47
  test('Generic body', () => {
49
48
  const r = new Response<any>(200, { name: 'abc' })
50
49
  r.appendIntoBody('name2', '123')
51
- expect(r.getCode()).to.be.equals(200)
52
- expect(r.getBody().name).to.be.equals('abc')
53
- expect(r.getBody().name2).to.be.equals('123')
50
+ c_expect(r.getCode()).to.be.equals(200)
51
+ c_expect(r.getBody().name).to.be.equals('abc')
52
+ c_expect(r.getBody().name2).to.be.equals('123')
54
53
  })
55
54
 
56
55
  test('Append/validate header', () => {
57
56
  const r = new Response<any>(200, {})
58
57
  r.appendHeader('name2', '123')
59
- expect(r['_headers']['name2']).to.be.equals('123')
58
+ c_expect(r['headers']['name2']).to.be.equals('123')
60
59
  })
61
60
  })
62
61
 
@@ -76,10 +75,10 @@ describe('Response build', () => {
76
75
  )
77
76
  const context = t['context']
78
77
  const buildR = await r.build(context, t, false)
79
- expect(buildR).to.be.undefined
80
- j_expect(context.fail).not.toBeCalled()
81
- j_expect(context.done).not.toBeCalled()
82
- j_expect(context.succeed).toHaveBeenCalledWith({
78
+ c_expect(buildR).to.be.undefined
79
+ expect(context.fail).not.toBeCalled()
80
+ expect(context.done).not.toBeCalled()
81
+ expect(context.succeed).toHaveBeenCalledWith({
83
82
  statusCode: 200,
84
83
  headers: {
85
84
  ...defaultHeaders,
@@ -98,10 +97,10 @@ describe('Response build', () => {
98
97
  const t = observableTransaction()
99
98
  const context = t['context']
100
99
  const buildR = await r.build(context, t, true)
101
- expect(buildR).to.be.undefined
102
- j_expect(context.fail).not.toBeCalled()
103
- j_expect(context.done).not.toBeCalled()
104
- j_expect(context.succeed).not.toBeCalled()
100
+ c_expect(buildR).to.be.undefined
101
+ expect(context.fail).not.toBeCalled()
102
+ expect(context.done).not.toBeCalled()
103
+ expect(context.succeed).not.toBeCalled()
105
104
  })
106
105
 
107
106
  test('Succeeds to transaction context as RAW', async () => {
@@ -112,10 +111,10 @@ describe('Response build', () => {
112
111
  const t = observableTransaction()
113
112
  const context = t['context']
114
113
  const buildR = await r.build(context, t, false)
115
- expect(buildR).to.be.undefined
116
- j_expect(context.fail).not.toBeCalled()
117
- j_expect(context.done).not.toBeCalled()
118
- j_expect(context.succeed).toHaveBeenCalledWith({
114
+ c_expect(buildR).to.be.undefined
115
+ expect(context.fail).not.toBeCalled()
116
+ expect(context.done).not.toBeCalled()
117
+ expect(context.succeed).toHaveBeenCalledWith({
119
118
  ...b,
120
119
  transactionID: 'unknown',
121
120
  })
@@ -130,11 +129,11 @@ describe('Response build', () => {
130
129
  const context = t['context']
131
130
  const buildR = await r.build(context, t, false)
132
131
  await r.build(context, t, false) //pipe twice, should not affect
133
- expect(buildR).to.be.undefined
134
- j_expect(context.fail).not.toBeCalled()
135
- j_expect(context.done).not.toBeCalled()
136
- j_expect(context.succeed).toHaveBeenCalledTimes(1)
137
- j_expect(context.succeed).toHaveBeenCalledWith({
132
+ c_expect(buildR).to.be.undefined
133
+ expect(context.fail).not.toBeCalled()
134
+ expect(context.done).not.toBeCalled()
135
+ expect(context.succeed).toHaveBeenCalledTimes(1)
136
+ expect(context.succeed).toHaveBeenCalledWith({
138
137
  statusCode: 200,
139
138
  headers: {
140
139
  ...defaultHeaders,
@@ -153,10 +152,10 @@ describe('Response build', () => {
153
152
  const t = observableTransaction()
154
153
  const context = t['context']
155
154
  const buildR = await r.build(context, t, false)
156
- expect(buildR).to.be.undefined
157
- j_expect(context.done).not.toBeCalled()
158
- j_expect(context.succeed).not.toBeCalled()
159
- j_expect(context.fail).toHaveBeenCalledTimes(1)
155
+ c_expect(buildR).to.be.undefined
156
+ expect(context.done).not.toBeCalled()
157
+ expect(context.succeed).not.toBeCalled()
158
+ expect(context.fail).toHaveBeenCalledTimes(1)
160
159
  })
161
160
 
162
161
  test('Failure exception to transaction context as RAW', async () => {
@@ -174,11 +173,11 @@ describe('Response build', () => {
174
173
  } catch (e) {
175
174
  exception = e
176
175
  }
177
- expect(buildR).to.be.null
178
- expect(exception).to.not.be.null
179
- j_expect(context.done).not.toBeCalled()
180
- j_expect(context.succeed).not.toBeCalled()
181
- j_expect(context.fail).not.toBeCalled()
176
+ c_expect(buildR).to.be.null
177
+ c_expect(exception).to.not.be.null
178
+ expect(context.done).not.toBeCalled()
179
+ expect(context.succeed).not.toBeCalled()
180
+ expect(context.fail).not.toBeCalled()
182
181
  })
183
182
 
184
183
  test('Failure exception to transaction context as RAW and null body', async () => {
@@ -196,11 +195,11 @@ describe('Response build', () => {
196
195
  } catch (e) {
197
196
  exception = e
198
197
  }
199
- expect(buildR).to.be.null
200
- expect(exception).to.not.be.null
201
- j_expect(context.done).not.toBeCalled()
202
- j_expect(context.succeed).not.toBeCalled()
203
- j_expect(context.fail).not.toBeCalled()
198
+ c_expect(buildR).to.be.null
199
+ c_expect(exception).to.not.be.null
200
+ expect(context.done).not.toBeCalled()
201
+ expect(context.succeed).not.toBeCalled()
202
+ expect(context.fail).not.toBeCalled()
204
203
  })
205
204
 
206
205
  test('Failure exception to transaction context as RAW and custom ero', async () => {
@@ -218,11 +217,11 @@ describe('Response build', () => {
218
217
  } catch (e) {
219
218
  exception = e
220
219
  }
221
- expect(buildR).to.be.null
222
- expect(exception).to.not.be.null
223
- j_expect(context.done).not.toBeCalled()
224
- j_expect(context.succeed).not.toBeCalled()
225
- j_expect(context.fail).not.toBeCalled()
220
+ c_expect(buildR).to.be.null
221
+ c_expect(exception).to.not.be.null
222
+ expect(context.done).not.toBeCalled()
223
+ expect(context.succeed).not.toBeCalled()
224
+ expect(context.fail).not.toBeCalled()
226
225
  })
227
226
  })
228
227
 
@@ -346,11 +345,11 @@ describe('Response shortcuts', () => {
346
345
  const context = t['context']
347
346
  const buildR = await r.build(context, t, false)
348
347
  await r.build(context, t, false) //pipe twice, should not affect
349
- expect(buildR).to.be.undefined
350
- j_expect(context.fail).not.toBeCalled()
351
- j_expect(context.done).not.toBeCalled()
352
- j_expect(context.succeed).toHaveBeenCalledTimes(1)
353
- j_expect(context.succeed).toHaveBeenCalledWith({
348
+ c_expect(buildR).to.be.undefined
349
+ expect(context.fail).not.toBeCalled()
350
+ expect(context.done).not.toBeCalled()
351
+ expect(context.succeed).toHaveBeenCalledTimes(1)
352
+ expect(context.succeed).toHaveBeenCalledWith({
354
353
  statusCode: 200,
355
354
  headers: {
356
355
  ...defaultHeaders,
@@ -1,5 +1,4 @@
1
- import { expect as j_expect } from '@jest/globals'
2
- import { expect } from 'chai'
1
+ import { expect as c_expect } from 'chai'
3
2
 
4
3
  import Response from '../../src/API/Response'
5
4
  import EventProcessor from '../../src/BaseEvent/EventProcessor'
@@ -19,23 +18,23 @@ describe('EventProcessor success invocation path', () => {
19
18
  )
20
19
  let count = 0
21
20
  const handlerResp = await transaction.processEvent(async (transaction, eventRecord) => {
22
- expect(eventRecord).to.be.deep.equal(b)
21
+ c_expect(eventRecord).to.be.deep.equal(b)
23
22
  count++
24
23
  return Response.SuccessResponse(null)
25
24
  })
26
25
  // check resp
27
- expect(count).to.be.equals(2)
28
- expect(handlerResp).to.be.an.instanceof(Response)
26
+ c_expect(count).to.be.equals(2)
27
+ c_expect(handlerResp).to.be.an.instanceof(Response)
29
28
  if (handlerResp instanceof Response) {
30
- expect(handlerResp?.getBody()).to.be.deep.equal({
29
+ c_expect(handlerResp?.getBody()).to.be.deep.equal({
31
30
  transactionID: 'unknown',
32
31
  })
33
- expect(handlerResp.getCode()).to.be.equal(200)
32
+ c_expect(handlerResp.getCode()).to.be.equal(200)
34
33
  }
35
34
  // ctx
36
- j_expect(context.fail).not.toBeCalled()
37
- j_expect(context.done).not.toBeCalled()
38
- j_expect(context.succeed).not.toBeCalled()
35
+ expect(context.fail).not.toBeCalled()
36
+ expect(context.done).not.toBeCalled()
37
+ expect(context.succeed).not.toBeCalled()
39
38
  })
40
39
 
41
40
  test('Simple success - do not decode', async () => {
@@ -50,23 +49,23 @@ describe('EventProcessor success invocation path', () => {
50
49
  )
51
50
  let count = 0
52
51
  const handlerResp = await transaction.processEvent(async (transaction, eventRecord) => {
53
- expect(eventRecord).to.be.deep.equal(JSON.stringify(b))
52
+ c_expect(eventRecord).to.be.deep.equal(JSON.stringify(b))
54
53
  count++
55
54
  return Response.SuccessResponse(null)
56
55
  }, true)
57
56
  // check resp
58
- expect(count).to.be.equals(2)
59
- expect(handlerResp).to.be.an.instanceof(Response)
57
+ c_expect(count).to.be.equals(2)
58
+ c_expect(handlerResp).to.be.an.instanceof(Response)
60
59
  if (handlerResp instanceof Response) {
61
- expect(handlerResp?.getBody()).to.be.deep.equal({
60
+ c_expect(handlerResp?.getBody()).to.be.deep.equal({
62
61
  transactionID: 'unknown',
63
62
  })
64
- expect(handlerResp.getCode()).to.be.equal(200)
63
+ c_expect(handlerResp.getCode()).to.be.equal(200)
65
64
  }
66
65
  // ctx
67
- j_expect(context.fail).not.toBeCalled()
68
- j_expect(context.done).not.toBeCalled()
69
- j_expect(context.succeed).not.toBeCalled()
66
+ expect(context.fail).not.toBeCalled()
67
+ expect(context.done).not.toBeCalled()
68
+ expect(context.succeed).not.toBeCalled()
70
69
  })
71
70
  })
72
71
 
@@ -90,7 +89,7 @@ describe('EventProcessor failure invocation path', () => {
90
89
  err: any = null
91
90
  try {
92
91
  handlerResp = await transaction.processEvent(async (transaction, eventRecord) => {
93
- expect(eventRecord).to.be.deep.equal(b)
92
+ c_expect(eventRecord).to.be.deep.equal(b)
94
93
  count++
95
94
  return count == 1 ? Response.SuccessResponse(null) : Response.BadRequestResponse('Failed!')
96
95
  })
@@ -98,9 +97,9 @@ describe('EventProcessor failure invocation path', () => {
98
97
  err = e
99
98
  }
100
99
  // check resp
101
- expect(count).to.be.equals(2)
102
- expect(handlerResp).to.be.null
103
- expect(err).to.be.deep.equal(
100
+ c_expect(count).to.be.equals(2)
101
+ c_expect(handlerResp).to.be.null
102
+ c_expect(err).to.be.deep.equal(
104
103
  new Error(
105
104
  JSON.stringify({
106
105
  err: 'Failed!',
@@ -109,9 +108,9 @@ describe('EventProcessor failure invocation path', () => {
109
108
  )
110
109
  )
111
110
  // ctx
112
- j_expect(context.fail).not.toBeCalled()
113
- j_expect(context.done).not.toBeCalled()
114
- j_expect(context.succeed).not.toBeCalled()
111
+ expect(context.fail).not.toBeCalled()
112
+ expect(context.done).not.toBeCalled()
113
+ expect(context.succeed).not.toBeCalled()
115
114
  })
116
115
 
117
116
  test('Simple failure w/ null', async () => {
@@ -135,7 +134,7 @@ describe('EventProcessor failure invocation path', () => {
135
134
  handlerResp = await transaction.processEvent(
136
135
  // @ts-ignore
137
136
  async (transaction, eventRecord) => {
138
- expect(eventRecord).to.be.deep.equal(b)
137
+ c_expect(eventRecord).to.be.deep.equal(b)
139
138
  count++
140
139
  return null
141
140
  }
@@ -144,9 +143,9 @@ describe('EventProcessor failure invocation path', () => {
144
143
  err = e
145
144
  }
146
145
  // check resp
147
- expect(count).to.be.equals(1)
148
- expect(handlerResp).to.be.null
149
- expect(err).to.be.deep.equal(
146
+ c_expect(count).to.be.equals(1)
147
+ c_expect(handlerResp).to.be.null
148
+ c_expect(err).to.be.deep.equal(
150
149
  new Error(
151
150
  JSON.stringify({
152
151
  err: Globals.ErrorResponseInvalidServerResponse,
@@ -157,9 +156,9 @@ describe('EventProcessor failure invocation path', () => {
157
156
  )
158
157
  )
159
158
  // ctx
160
- j_expect(context.fail).not.toBeCalled()
161
- j_expect(context.done).not.toBeCalled()
162
- j_expect(context.succeed).not.toBeCalled()
159
+ expect(context.fail).not.toBeCalled()
160
+ expect(context.done).not.toBeCalled()
161
+ expect(context.succeed).not.toBeCalled()
163
162
  })
164
163
 
165
164
  test('Simple failure - allow failures', async () => {
@@ -175,19 +174,19 @@ describe('EventProcessor failure invocation path', () => {
175
174
  )
176
175
  let count = 0
177
176
  const handlerResp = await transaction.processEvent(async (transaction, eventRecord) => {
178
- expect(eventRecord).to.be.deep.equal(b)
177
+ c_expect(eventRecord).to.be.deep.equal(b)
179
178
  count++
180
179
  return count == 1 ? Response.SuccessResponse(null) : Response.BadRequestResponse('Failed!')
181
180
  })
182
181
  // check resp
183
- expect(count).to.be.equals(2)
184
- expect(handlerResp).to.be.deep.equal({
182
+ c_expect(count).to.be.equals(2)
183
+ c_expect(handlerResp).to.be.deep.equal({
185
184
  batchItemFailures: [{ itemIdentifier: '123' }],
186
185
  })
187
186
  // ctx
188
- j_expect(context.fail).not.toBeCalled()
189
- j_expect(context.done).not.toBeCalled()
190
- j_expect(context.succeed).not.toBeCalled()
187
+ expect(context.fail).not.toBeCalled()
188
+ expect(context.done).not.toBeCalled()
189
+ expect(context.succeed).not.toBeCalled()
191
190
  })
192
191
 
193
192
  test('Simple failure w/ null response - allow failures', async () => {
@@ -208,20 +207,20 @@ describe('EventProcessor failure invocation path', () => {
208
207
  const handlerResp = await transaction.processEvent(
209
208
  // @ts-ignore
210
209
  async (transaction, eventRecord) => {
211
- expect(eventRecord).to.be.deep.equal(b)
210
+ c_expect(eventRecord).to.be.deep.equal(b)
212
211
  count++
213
212
  return null
214
213
  }
215
214
  )
216
215
  // check resp
217
- expect(count).to.be.equals(2)
218
- expect(handlerResp).to.be.deep.equal({
216
+ c_expect(count).to.be.equals(2)
217
+ c_expect(handlerResp).to.be.deep.equal({
219
218
  batchItemFailures: [{ itemIdentifier: '456' }, { itemIdentifier: '123' }],
220
219
  })
221
220
  // ctx
222
- j_expect(context.fail).not.toBeCalled()
223
- j_expect(context.done).not.toBeCalled()
224
- j_expect(context.succeed).not.toBeCalled()
221
+ expect(context.fail).not.toBeCalled()
222
+ expect(context.done).not.toBeCalled()
223
+ expect(context.succeed).not.toBeCalled()
225
224
  })
226
225
 
227
226
  test('Simple failure no records', async () => {
@@ -242,9 +241,9 @@ describe('EventProcessor failure invocation path', () => {
242
241
  err = e
243
242
  }
244
243
  // check resp
245
- expect(count).to.be.equals(0)
246
- expect(handlerResp).to.be.null
247
- expect(err).to.be.deep.equal(
244
+ c_expect(count).to.be.equals(0)
245
+ c_expect(handlerResp).to.be.null
246
+ c_expect(err).to.be.deep.equal(
248
247
  new Error(
249
248
  JSON.stringify({
250
249
  err: Globals.ErrorResponseNoRecords,
@@ -253,9 +252,9 @@ describe('EventProcessor failure invocation path', () => {
253
252
  )
254
253
  )
255
254
  // ctx
256
- j_expect(context.fail).not.toBeCalled()
257
- j_expect(context.done).not.toBeCalled()
258
- j_expect(context.succeed).not.toBeCalled()
255
+ expect(context.fail).not.toBeCalled()
256
+ expect(context.done).not.toBeCalled()
257
+ expect(context.succeed).not.toBeCalled()
259
258
  })
260
259
  })
261
260
 
@@ -18,7 +18,7 @@ describe('Process success invocation path', () => {
18
18
  return new Promise(resolve => {
19
19
  setTimeout(() => {
20
20
  expect(count).to.be.equals(2)
21
- clearInterval(proc.interval)
21
+ clearInterval(proc.timeout)
22
22
  resolve(null)
23
23
  }, 250)
24
24
  })
@@ -39,7 +39,7 @@ describe('Process failure invocation path', () => {
39
39
  return new Promise(resolve => {
40
40
  setTimeout(() => {
41
41
  expect(count).to.be.equals(2)
42
- clearInterval(proc.interval)
42
+ clearInterval(proc.timeout)
43
43
  resolve(null)
44
44
  }, 250)
45
45
  })
@@ -1,5 +1,4 @@
1
- import { expect as j_expect } from '@jest/globals'
2
- import { expect } from 'chai'
1
+ import { expect as c_expect } from 'chai'
3
2
 
4
3
  import Response from '../../src/API/Response'
5
4
  import Transaction from '../../src/BaseEvent/Transaction'
@@ -16,11 +15,11 @@ describe('Transaction success invocation path', () => {
16
15
  return Response.SuccessResponse(b)
17
16
  })
18
17
  // check resp
19
- expect(handlerResp).to.be.null
18
+ c_expect(handlerResp).to.be.null
20
19
  // ctx
21
- j_expect(context.fail).not.toBeCalled()
22
- j_expect(context.done).not.toBeCalled()
23
- j_expect(context.succeed).toBeCalledWith({
20
+ expect(context.fail).not.toBeCalled()
21
+ expect(context.done).not.toBeCalled()
22
+ expect(context.succeed).toBeCalledWith({
24
23
  statusCode: 200,
25
24
  body: JSON.stringify(b),
26
25
  headers: defaultHeaders,
@@ -37,13 +36,13 @@ describe('Transaction success invocation path', () => {
37
36
  return Response.SuccessResponse(b)
38
37
  })
39
38
  // check resp
40
- expect(handlerResp).to.be.an.instanceof(Response)
41
- expect(handlerResp?.getBody()).to.be.deep.equals(b)
42
- expect(handlerResp?.getCode()).to.be.equals(200)
39
+ c_expect(handlerResp).to.be.an.instanceof(Response)
40
+ c_expect(handlerResp?.getBody()).to.be.deep.equals(b)
41
+ c_expect(handlerResp?.getCode()).to.be.equals(200)
43
42
  // ctx
44
- j_expect(context.fail).not.toBeCalled()
45
- j_expect(context.done).not.toBeCalled()
46
- j_expect(context.succeed).not.toBeCalled()
43
+ expect(context.fail).not.toBeCalled()
44
+ expect(context.done).not.toBeCalled()
45
+ expect(context.succeed).not.toBeCalled()
47
46
  })
48
47
  })
49
48
 
@@ -61,11 +60,11 @@ describe('Transaction error invocation path without response', () => {
61
60
  return null
62
61
  })
63
62
  // check resp
64
- expect(handlerResp).to.be.null
63
+ c_expect(handlerResp).to.be.null
65
64
  // ctx
66
- j_expect(context.fail).not.toBeCalled()
67
- j_expect(context.done).not.toBeCalled()
68
- j_expect(context.succeed).toBeCalledWith({
65
+ expect(context.fail).not.toBeCalled()
66
+ expect(context.done).not.toBeCalled()
67
+ expect(context.succeed).toBeCalledWith({
69
68
  statusCode: 400,
70
69
  body: JSON.stringify(b),
71
70
  headers: defaultHeaders,
@@ -93,13 +92,13 @@ describe('Transaction error invocation path without response', () => {
93
92
  return null
94
93
  })
95
94
  // check resp
96
- expect(handlerResp).to.be.an.instanceof(Response)
97
- expect(handlerResp?.getBody()).to.be.deep.equals(b)
98
- expect(handlerResp?.getCode()).to.be.equals(400)
95
+ c_expect(handlerResp).to.be.an.instanceof(Response)
96
+ c_expect(handlerResp?.getBody()).to.be.deep.equals(b)
97
+ c_expect(handlerResp?.getCode()).to.be.equals(400)
99
98
  // ctx
100
- j_expect(context.fail).not.toBeCalled()
101
- j_expect(context.done).not.toBeCalled()
102
- j_expect(context.succeed).not.toBeCalled()
99
+ expect(context.fail).not.toBeCalled()
100
+ expect(context.done).not.toBeCalled()
101
+ expect(context.succeed).not.toBeCalled()
103
102
  })
104
103
  })
105
104
 
@@ -118,11 +117,11 @@ describe('Transaction error invocation path with non-Response class response', (
118
117
  return b2
119
118
  })
120
119
  // check resp
121
- expect(handlerResp).to.be.null
120
+ c_expect(handlerResp).to.be.null
122
121
  // ctx
123
- j_expect(context.fail).not.toBeCalled()
124
- j_expect(context.done).not.toBeCalled()
125
- j_expect(context.succeed).toBeCalledWith({
122
+ expect(context.fail).not.toBeCalled()
123
+ expect(context.done).not.toBeCalled()
124
+ expect(context.succeed).toBeCalledWith({
126
125
  statusCode: 400,
127
126
  body: JSON.stringify(b),
128
127
  headers: defaultHeaders,
@@ -139,11 +138,11 @@ describe('Transaction error invocation path with non-Response class response', (
139
138
  return b2
140
139
  })
141
140
  // check resp
142
- expect(handlerResp).to.be.deep.equals(b2)
141
+ c_expect(handlerResp).to.be.deep.equals(b2)
143
142
  // ctx
144
- j_expect(context.fail).not.toBeCalled()
145
- j_expect(context.done).not.toBeCalled()
146
- j_expect(context.succeed).not.toBeCalled()
143
+ expect(context.fail).not.toBeCalled()
144
+ expect(context.done).not.toBeCalled()
145
+ expect(context.succeed).not.toBeCalled()
147
146
  })
148
147
  })
149
148
 
@@ -161,11 +160,11 @@ describe('Transaction error invocation path with exception', () => {
161
160
  throw new Error('Failed!')
162
161
  })
163
162
  // check resp
164
- expect(handlerResp).to.be.null
163
+ c_expect(handlerResp).to.be.null
165
164
  // ctx
166
- j_expect(context.fail).not.toBeCalled()
167
- j_expect(context.done).not.toBeCalled()
168
- j_expect(context.succeed).toBeCalledWith({
165
+ expect(context.fail).not.toBeCalled()
166
+ expect(context.done).not.toBeCalled()
167
+ expect(context.succeed).toBeCalledWith({
169
168
  statusCode: 400,
170
169
  body: JSON.stringify(b),
171
170
  headers: defaultHeaders,
@@ -187,12 +186,12 @@ describe('Transaction error invocation path with exception', () => {
187
186
  throw new Error('Failed!')
188
187
  })
189
188
  // check resp
190
- expect(handlerResp?.getBody()).to.be.deep.equals(b)
191
- expect(handlerResp?.getCode()).to.be.equals(400)
189
+ c_expect(handlerResp?.getBody()).to.be.deep.equals(b)
190
+ c_expect(handlerResp?.getCode()).to.be.equals(400)
192
191
  // ctx
193
- j_expect(context.fail).not.toBeCalled()
194
- j_expect(context.done).not.toBeCalled()
195
- j_expect(context.succeed).not.toBeCalled()
192
+ expect(context.fail).not.toBeCalled()
193
+ expect(context.done).not.toBeCalled()
194
+ expect(context.succeed).not.toBeCalled()
196
195
  })
197
196
 
198
197
  test('Transaction exception - sync return', async () => {
@@ -211,12 +210,12 @@ describe('Transaction error invocation path with exception', () => {
211
210
  err = e
212
211
  }
213
212
  // check resp
214
- expect(handlerResp).to.be.null
215
- expect(err).to.be.deep.equals(error)
213
+ c_expect(handlerResp).to.be.null
214
+ c_expect(err).to.be.deep.equals(error)
216
215
  // ctx
217
- j_expect(context.fail).not.toBeCalled()
218
- j_expect(context.done).not.toBeCalled()
219
- j_expect(context.succeed).not.toBeCalled()
216
+ expect(context.fail).not.toBeCalled()
217
+ expect(context.done).not.toBeCalled()
218
+ expect(context.succeed).not.toBeCalled()
220
219
  })
221
220
  })
222
221
 
@@ -255,9 +254,9 @@ describe('Transaction - db integration', () => {
255
254
 
256
255
  return Response.SuccessResponse(null)
257
256
  })
258
- j_expect(mockCreate).toBeCalledWith(config)
259
- j_expect(mockTrans.select).toBeCalledWith('name')
260
- j_expect(mockTrans.closeSuccess).toBeCalled()
257
+ expect(mockCreate).toBeCalledWith(config)
258
+ expect(mockTrans.select).toBeCalledWith('name')
259
+ expect(mockTrans.closeSuccess).toBeCalled()
261
260
  })
262
261
 
263
262
  test('Errored transaction calls closeFailure', async () => {
@@ -273,8 +272,8 @@ describe('Transaction - db integration', () => {
273
272
 
274
273
  console.log(ss)
275
274
 
276
- j_expect(mockCreate).toBeCalledWith(config)
277
- j_expect(mockTrans.closeFailure).toBeCalled()
275
+ expect(mockCreate).toBeCalledWith(config)
276
+ expect(mockTrans.closeFailure).toBeCalled()
278
277
  })
279
278
  })
280
279