Skip to content

Commit 179ef5d

Browse files
authored
Merge pull request #522 from bitfinexcom/staging
Release version to master
2 parents 349fcab + 0bb4bf1 commit 179ef5d

12 files changed

Lines changed: 108 additions & 18 deletions

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bitfinex/bfx-reports-framework",
3-
"version": "5.2.1",
3+
"version": "5.3.0",
44
"description": "Bitfinex reports framework",
55
"main": "worker.js",
66
"engines": {

test/helpers/helpers.mock-rest-v2.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,17 @@ const getMockDataOpts = () => ({
5050
delete_token: null,
5151
login: null,
5252
login_verify: null,
53+
captcha_providers: null,
54+
captcha_required: null,
5355
platform_status: null
5456
})
5557

5658
const getExtraMockMethods = () => (new Map([
5759
['post', {
5860
'/v2/login': 'login',
59-
'/v2/login/verify': 'login_verify'
61+
'/v2/login/verify': 'login_verify',
62+
'/v2/int/captcha/providers': 'captcha_providers',
63+
'/v2/int/captcha/required': 'captcha_required'
6064
}]
6165
]))
6266

test/helpers/mock-data.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ module.exports = new Map([
2525
'2023-03-21T12:00:00.000Z'
2626
]
2727
],
28+
[
29+
'captcha_providers',
30+
['hcaptcha']
31+
],
32+
[
33+
'captcha_required',
34+
true
35+
],
2836
[
2937
'generate_token',
3038
['pub:api:88888888-4444-4444-4444-121212121212-caps:s:o:f:w:wd:a-write']

test/test-cases/api-sync-mode-sqlite-test-cases.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,48 @@ module.exports = (
175175
assert.isString(res.body.result[1])
176176
})
177177

178+
it('it should be successfully performed by the getCaptchaProviders method', async function () {
179+
this.timeout(5000)
180+
181+
const res = await agent
182+
.post(`${basePath}/json-rpc`)
183+
.type('json')
184+
.send({
185+
method: 'getCaptchaProviders',
186+
id: 5
187+
})
188+
.expect('Content-Type', /json/)
189+
.expect(200)
190+
191+
assert.isObject(res.body)
192+
assert.propertyVal(res.body, 'id', 5)
193+
assert.isArray(res.body.result)
194+
assert.isString(res.body.result[0])
195+
assert.strictEqual(res.body.result[0], 'hcaptcha')
196+
})
197+
198+
it('it should be successfully performed by the isCaptchaRequired method', async function () {
199+
this.timeout(5000)
200+
201+
const res = await agent
202+
.post(`${basePath}/json-rpc`)
203+
.type('json')
204+
.send({
205+
method: 'isCaptchaRequired',
206+
params: {
207+
method: 'login'
208+
},
209+
id: 5
210+
})
211+
.expect('Content-Type', /json/)
212+
.expect(200)
213+
214+
assert.isObject(res.body)
215+
assert.propertyVal(res.body, 'id', 5)
216+
assert.isBoolean(res.body.result)
217+
assert.isOk(res.body.result)
218+
})
219+
178220
it('it should be successfully performed by the signIn method', async function () {
179221
this.timeout(5000)
180222

workers/api.framework.report.wrk.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ const {
3939
PDFBufferUnderElectronCreationError,
4040
PDFBufferUnderFrameworkCreationError
4141
} = require('@bitfinex/bfx-report/workers/loc.api/errors')
42+
const QUEUE_EVENT_NAMES = require(
43+
'@bitfinex/bfx-report/workers/loc.api/queue/queue.event.names'
44+
)
4245

4346
const appDeps = require('./loc.api/di/app.deps')
4447
const TYPES = require('./loc.api/di/types')
@@ -208,7 +211,7 @@ class WrkReportFrameWorkApi extends WrkReportServiceApi {
208211

209212
await wsTransport.start()
210213

211-
processorQueue.on('error:base', (err, job) => {
214+
processorQueue.on(QUEUE_EVENT_NAMES.ERROR_BASE, (err, job) => {
212215
if (
213216
!(err instanceof PDFBufferUnderElectronCreationError) &&
214217
!(err instanceof PDFBufferUnderFrameworkCreationError)
@@ -223,7 +226,7 @@ class WrkReportFrameWorkApi extends WrkReportServiceApi {
223226
this.logger.error(`WS_EVENT_EMITTER:REPORT_FILE_FAILED: ${err.stack || err}`)
224227
})
225228
})
226-
aggregatorQueue.on('completed', (res) => {
229+
aggregatorQueue.on(QUEUE_EVENT_NAMES.COMPLETED, (res) => {
227230
const {
228231
reportFilesMetadata,
229232
csvFilesMetadata, // For compatibility with old implementation

workers/loc.api/generate-report-file/csv-writer/full-snapshot-report-csv-writer.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const {
99
const {
1010
omitExtraParamFieldsForReportExport
1111
} = require('@bitfinex/bfx-report/workers/loc.api/generate-report-file/helpers')
12+
const QUEUE_EVENT_NAMES = require(
13+
'@bitfinex/bfx-report/workers/loc.api/queue/queue.event.names'
14+
)
1215

1316
module.exports = (
1417
rService,
@@ -29,7 +32,7 @@ module.exports = (
2932
...args?.params
3033
}
3134

32-
queue.emit('progress', 0)
35+
queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 0)
3336

3437
if (typeof jobData === 'string') {
3538
await streamWriter(
@@ -40,7 +43,7 @@ module.exports = (
4043
}]
4144
)
4245

43-
queue.emit('progress', 100)
46+
queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 100)
4447

4548
return
4649
}
@@ -173,5 +176,5 @@ module.exports = (
173176
]
174177
)
175178

176-
queue.emit('progress', 100)
179+
queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 100)
177180
}

workers/loc.api/generate-report-file/csv-writer/full-tax-report-csv-writer.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const {
99
const {
1010
omitExtraParamFieldsForReportExport
1111
} = require('@bitfinex/bfx-report/workers/loc.api/generate-report-file/helpers')
12+
const QUEUE_EVENT_NAMES = require(
13+
'@bitfinex/bfx-report/workers/loc.api/queue/queue.event.names'
14+
)
1215

1316
module.exports = (
1417
rService,
@@ -30,7 +33,7 @@ module.exports = (
3033
...args?.params
3134
}
3235

33-
queue.emit('progress', 0)
36+
queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 0)
3437

3538
if (typeof jobData === 'string') {
3639
await streamWriter(
@@ -41,7 +44,7 @@ module.exports = (
4144
}]
4245
)
4346

44-
queue.emit('progress', 100)
47+
queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 100)
4548

4649
return
4750
}
@@ -206,5 +209,5 @@ module.exports = (
206209
]
207210
)
208211

209-
queue.emit('progress', 100)
212+
queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 100)
210213
}

workers/loc.api/generate-report-file/csv-writer/transaction-tax-report-csv-writer.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ const TRANSLATION_NAMESPACES = require(
1212
const {
1313
omitExtraParamFieldsForReportExport
1414
} = require('@bitfinex/bfx-report/workers/loc.api/generate-report-file/helpers')
15+
const QUEUE_EVENT_NAMES = require(
16+
'@bitfinex/bfx-report/workers/loc.api/queue/queue.event.names'
17+
)
1518

1619
module.exports = (
1720
rService,
@@ -35,7 +38,7 @@ module.exports = (
3538
}
3639
const { language } = params ??
3740

38-
queue.emit('progress', 0)
41+
queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 0)
3942

4043
if (typeof jobData === 'string') {
4144
await streamWriter(
@@ -46,7 +49,7 @@ module.exports = (
4649
}]
4750
)
4851

49-
queue.emit('progress', 100)
52+
queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 100)
5053

5154
return
5255
}
@@ -108,5 +111,5 @@ ${i18next.t('template.delistedCcyMessageEnd', transOpts)}\
108111
csvStreamDataMap
109112
)
110113

111-
queue.emit('progress', 100)
114+
queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 100)
112115
}

0 commit comments

Comments
 (0)