-

Bitfinex Report CSV

+

Bitfinex Report

From 4bdd3a6303bca28e9d727020c4810b47bba2e91d Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 19 Jan 2024 13:30:59 +0200 Subject: [PATCH 13/66] Rename method tester for getting report file --- test/3-api-filter-sync-mode-sqlite.spec.js | 6 +-- ...itional-api-sync-mode-sqlite-test-cases.js | 32 ++++++------- .../api-sync-mode-sqlite-test-cases.js | 48 +++++++++---------- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/test/3-api-filter-sync-mode-sqlite.spec.js b/test/3-api-filter-sync-mode-sqlite.spec.js index e55ae8e86..d27916e65 100644 --- a/test/3-api-filter-sync-mode-sqlite.spec.js +++ b/test/3-api-filter-sync-mode-sqlite.spec.js @@ -13,7 +13,7 @@ const { queueToPromise } = require('bfx-report/test/helpers/helpers.core') const { - testMethodOfGettingCsv + testMethodOfGettingReportFile } = require('bfx-report/test/helpers/helpers.tests') const { @@ -864,7 +864,7 @@ describe('API filter', () => { .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getMultipleCsv method', async function () { @@ -914,6 +914,6 @@ describe('API filter', () => { .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) }) diff --git a/test/test-cases/additional-api-sync-mode-sqlite-test-cases.js b/test/test-cases/additional-api-sync-mode-sqlite-test-cases.js index 4271fedb6..3338237b2 100644 --- a/test/test-cases/additional-api-sync-mode-sqlite-test-cases.js +++ b/test/test-cases/additional-api-sync-mode-sqlite-test-cases.js @@ -6,7 +6,7 @@ const { queueToPromise } = require('bfx-report/test/helpers/helpers.core') const { - testMethodOfGettingCsv + testMethodOfGettingReportFile } = require('bfx-report/test/helpers/helpers.tests') const { @@ -659,7 +659,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getBalanceHistoryCsv method', async function () { @@ -685,7 +685,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getSummaryByAsset method', async function () { @@ -830,7 +830,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getFullSnapshotReportCsv method', async function () { @@ -854,7 +854,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getFullSnapshotReportCsv method, store csv to local folder', async function () { @@ -877,7 +877,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv( + await testMethodOfGettingReportFile( procPromise, aggrPromise, res, @@ -906,7 +906,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getFullTaxReportCsv method', async function () { @@ -931,7 +931,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getFullTaxReportCsv method, store csv to local folder', async function () { @@ -955,7 +955,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv( + await testMethodOfGettingReportFile( procPromise, aggrPromise, res, @@ -985,7 +985,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv( + await testMethodOfGettingReportFile( procPromise, aggrPromise, res, @@ -1015,7 +1015,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv( + await testMethodOfGettingReportFile( procPromise, aggrPromise, res, @@ -1046,7 +1046,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getTotalFeesReportCsv method', async function () { @@ -1073,7 +1073,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getPerformingLoanCsv method', async function () { @@ -1099,7 +1099,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getWinLossVSAccountBalanceCsv method', async function () { @@ -1125,7 +1125,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getWeightedAveragesReportCsv method', async function () { @@ -1151,7 +1151,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the removeUser method with token', async function () { diff --git a/test/test-cases/api-sync-mode-sqlite-test-cases.js b/test/test-cases/api-sync-mode-sqlite-test-cases.js index 70650811b..62ba97499 100644 --- a/test/test-cases/api-sync-mode-sqlite-test-cases.js +++ b/test/test-cases/api-sync-mode-sqlite-test-cases.js @@ -7,7 +7,7 @@ const { queueToPromiseMulti } = require('bfx-report/test/helpers/helpers.core') const { - testMethodOfGettingCsv, + testMethodOfGettingReportFile, testProcQueue } = require('bfx-report/test/helpers/helpers.tests') @@ -2757,7 +2757,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should not be successfully performed by the getMultipleCsv method', async function () { @@ -2817,7 +2817,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getPositionsHistoryCsv method', async function () { @@ -2844,7 +2844,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getPositionsAuditCsv method', async function () { @@ -2872,7 +2872,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getWalletsCsv method', async function () { @@ -2896,7 +2896,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getFundingOfferHistoryCsv method', async function () { @@ -2924,7 +2924,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getFundingLoanHistoryCsv method', async function () { @@ -2951,7 +2951,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getFundingCreditHistoryCsv method', async function () { @@ -2978,7 +2978,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getLedgersCsv method', async function () { @@ -3005,7 +3005,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getPayInvoiceListCsv method', async function () { @@ -3032,7 +3032,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getTradesCsv method', async function () { @@ -3059,7 +3059,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getFundingTradesCsv method', async function () { @@ -3086,7 +3086,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getPublicTradesCsv method', async function () { @@ -3114,7 +3114,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should not be successfully performed by the getPublicTradesCsv method, time frame more then a month', async function () { @@ -3197,7 +3197,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getCandlesCsv method', async function () { @@ -3226,7 +3226,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getOrderTradesCsv method', async function () { @@ -3255,7 +3255,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getOrdersCsv method', async function () { @@ -3281,7 +3281,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getActiveOrdersCsv method', async function () { @@ -3304,7 +3304,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getMovementsCsv method', async function () { @@ -3330,7 +3330,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getMovementsCsv method, where amount > 0', async function () { @@ -3357,7 +3357,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getMovementsCsv method, where amount < 0', async function () { @@ -3384,7 +3384,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getLoginsCsv method', async function () { @@ -3410,7 +3410,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should be successfully performed by the getChangeLogsCsv method', async function () { @@ -3436,7 +3436,7 @@ module.exports = ( .expect('Content-Type', /json/) .expect(200) - await testMethodOfGettingCsv(procPromise, aggrPromise, res) + await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) it('it should not be successfully auth by the getLedgersCsv method', async function () { From 88b54ee85e49ea4da7138d31e521fac388340bfd Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 22 Jan 2024 15:18:57 +0200 Subject: [PATCH 14/66] Rework report-path-has-common-folder test case --- test/helpers/helpers.tests.js | 6 +++--- .../additional-api-sync-mode-sqlite-test-cases.js | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/helpers/helpers.tests.js b/test/helpers/helpers.tests.js index a27be7beb..5e4a977e0 100644 --- a/test/helpers/helpers.tests.js +++ b/test/helpers/helpers.tests.js @@ -2,17 +2,17 @@ const { assert } = require('chai') -const testCsvPathHasCommonFolder = ({ aggrRes }) => { +const testReportPathHasCommonFolder = ({ aggrRes }) => { aggrRes.newFilePaths.forEach((newFilePath) => { // example: report-files/user_full-tax-report_FROM_Fri-Dec-01-2017_TO_Fri-May-28-2021/user_full-tax-report_END_SNAPSHOT_Tue-Jun-08-2021.csv assert.match( newFilePath, - /report-files\/[A-Za-z0-9\-_]+\/[A-Za-z0-9\-_]+\.csv$/, + /report-files\/[A-Za-z0-9\-_]+\/[A-Za-z0-9\-_]+\.(csv)|(pdf)$/, 'Has common report folder for group reports' ) }) } module.exports = { - testCsvPathHasCommonFolder + testReportPathHasCommonFolder } diff --git a/test/test-cases/additional-api-sync-mode-sqlite-test-cases.js b/test/test-cases/additional-api-sync-mode-sqlite-test-cases.js index 3338237b2..ba5564410 100644 --- a/test/test-cases/additional-api-sync-mode-sqlite-test-cases.js +++ b/test/test-cases/additional-api-sync-mode-sqlite-test-cases.js @@ -13,7 +13,7 @@ const { getParamsArrToTestTimeframeGrouping } = require('../helpers/helpers.core') const { - testCsvPathHasCommonFolder + testReportPathHasCommonFolder } = require('../helpers/helpers.tests') const getSyncProgressTestCase = require('./get-sync-progress-test-case') @@ -881,7 +881,7 @@ module.exports = ( procPromise, aggrPromise, res, - testCsvPathHasCommonFolder + testReportPathHasCommonFolder ) }) @@ -959,7 +959,7 @@ module.exports = ( procPromise, aggrPromise, res, - testCsvPathHasCommonFolder + testReportPathHasCommonFolder ) }) @@ -989,7 +989,7 @@ module.exports = ( procPromise, aggrPromise, res, - testCsvPathHasCommonFolder + testReportPathHasCommonFolder ) }) @@ -1019,7 +1019,7 @@ module.exports = ( procPromise, aggrPromise, res, - testCsvPathHasCommonFolder + testReportPathHasCommonFolder ) }) From fe303d3253cc654b20f9eca63f4a7b244a7731f7 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 22 Jan 2024 15:28:02 +0200 Subject: [PATCH 15/66] Rework test cases to use non-deprecated methods --- test/3-api-filter-sync-mode-sqlite.spec.js | 20 +-- ...itional-api-sync-mode-sqlite-test-cases.js | 64 +++++----- .../api-sync-mode-sqlite-test-cases.js | 116 +++++++++--------- 3 files changed, 100 insertions(+), 100 deletions(-) diff --git a/test/3-api-filter-sync-mode-sqlite.spec.js b/test/3-api-filter-sync-mode-sqlite.spec.js index d27916e65..e57666328 100644 --- a/test/3-api-filter-sync-mode-sqlite.spec.js +++ b/test/3-api-filter-sync-mode-sqlite.spec.js @@ -687,7 +687,7 @@ describe('API filter', () => { { args: { ...baseArgs, - method: 'getLedgersCsv', + method: 'getLedgersFile', params: { ...baseParams, symbol: ['BTC'], @@ -700,7 +700,7 @@ describe('API filter', () => { { args: { ...baseArgs, - method: 'getLedgersCsv', + method: 'getLedgersFile', params: { ...baseParams, symbol: ['BTC'], @@ -713,7 +713,7 @@ describe('API filter', () => { { args: { ...baseArgs, - method: 'getLedgersCsv', + method: 'getLedgersFile', params: { ...baseParams, symbol: ['BTC'], @@ -726,7 +726,7 @@ describe('API filter', () => { { args: { ...baseArgs, - method: 'getTradesCsv', + method: 'getTradesFile', params: { ...baseParams, symbol: ['tBTCUSD', 'tETHUSD'], @@ -836,7 +836,7 @@ describe('API filter', () => { } }) - it('it should be successfully performed by the getLedgersCsv method', async function () { + it('it should be successfully performed by the getLedgersFile method', async function () { this.timeout(20000) const procPromise = queueToPromise(processorQueue) @@ -847,7 +847,7 @@ describe('API filter', () => { .type('json') .send({ auth, - method: 'getLedgersCsv', + method: 'getLedgersFile', params: { symbol: ['BTC'], end, @@ -867,7 +867,7 @@ describe('API filter', () => { await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getMultipleCsv method', async function () { + it('it should be successfully performed by the getMultipleFile method', async function () { this.timeout(20000) const procPromise = queueToPromise(processorQueue) @@ -878,13 +878,13 @@ describe('API filter', () => { .type('json') .send({ auth, - method: 'getMultipleCsv', + method: 'getMultipleFile', params: { email, language: 'ru', multiExport: [ { - method: 'getTradesCsv', + method: 'getTradesFile', symbol: ['tBTCUSD', 'tETHUSD'], end, start, @@ -898,7 +898,7 @@ describe('API filter', () => { } }, { - method: 'getTickersHistoryCsv', + method: 'getTickersHistoryFile', symbol: 'BTC', end, start, diff --git a/test/test-cases/additional-api-sync-mode-sqlite-test-cases.js b/test/test-cases/additional-api-sync-mode-sqlite-test-cases.js index ba5564410..c8fd83f7d 100644 --- a/test/test-cases/additional-api-sync-mode-sqlite-test-cases.js +++ b/test/test-cases/additional-api-sync-mode-sqlite-test-cases.js @@ -623,7 +623,7 @@ module.exports = ( } }) - it('it should be successfully performed by the getMultipleCsv method', async function () { + it('it should be successfully performed by the getMultipleFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -634,12 +634,12 @@ module.exports = ( .type('json') .send({ auth, - method: 'getMultipleCsv', + method: 'getMultipleFile', params: { email, multiExport: [ { - method: 'getTradesCsv', + method: 'getTradesFile', symbol: ['tBTCUSD', 'tETHUSD'], end, start, @@ -647,7 +647,7 @@ module.exports = ( timezone: 'America/Los_Angeles' }, { - method: 'getBalanceHistoryCsv', + method: 'getBalanceHistoryFile', end, start, timeframe: 'day' @@ -662,7 +662,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getBalanceHistoryCsv method', async function () { + it('it should be successfully performed by the getBalanceHistoryFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -673,7 +673,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getBalanceHistoryCsv', + method: 'getBalanceHistoryFile', params: { end, start, @@ -807,7 +807,7 @@ module.exports = ( assert.propertyVal(res.body, 'id', 5) }) - it('it should be successfully performed by the getWinLossCsv method', async function () { + it('it should be successfully performed by the getWinLossFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -818,7 +818,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getWinLossCsv', + method: 'getWinLossFile', params: { end, start, @@ -833,7 +833,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getFullSnapshotReportCsv method', async function () { + it('it should be successfully performed by the getFullSnapshotReportFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -844,7 +844,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getFullSnapshotReportCsv', + method: 'getFullSnapshotReportFile', params: { end, email @@ -857,7 +857,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getFullSnapshotReportCsv method, store csv to local folder', async function () { + it('it should be successfully performed by the getFullSnapshotReportFile method, store report file to local folder', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -868,7 +868,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getFullSnapshotReportCsv', + method: 'getFullSnapshotReportFile', params: { end }, @@ -885,7 +885,7 @@ module.exports = ( ) }) - it('it should be successfully performed by the getPositionsSnapshotCsv method', async function () { + it('it should be successfully performed by the getPositionsSnapshotFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -896,7 +896,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getPositionsSnapshotCsv', + method: 'getPositionsSnapshotFile', params: { end, email @@ -909,7 +909,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getFullTaxReportCsv method', async function () { + it('it should be successfully performed by the getFullTaxReportFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -920,7 +920,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getFullTaxReportCsv', + method: 'getFullTaxReportFile', params: { end, start, @@ -934,7 +934,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getFullTaxReportCsv method, store csv to local folder', async function () { + it('it should be successfully performed by the getFullTaxReportFile method, store report file to local folder', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -945,7 +945,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getFullTaxReportCsv', + method: 'getFullTaxReportFile', params: { end, start @@ -963,7 +963,7 @@ module.exports = ( ) }) - it('it should be successfully performed by the getFullTaxReportCsv method for starting snapshot, store csv to local folder', async function () { + it('it should be successfully performed by the getFullTaxReportFile method for starting snapshot, store report file to local folder', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -974,7 +974,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getFullTaxReportCsv', + method: 'getFullTaxReportFile', params: { end, start, @@ -993,7 +993,7 @@ module.exports = ( ) }) - it('it should be successfully performed by the getFullTaxReportCsv method for ending snapshot, store csv to local folder', async function () { + it('it should be successfully performed by the getFullTaxReportFile method for ending snapshot, store report file to local folder', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -1004,7 +1004,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getFullTaxReportCsv', + method: 'getFullTaxReportFile', params: { end, start, @@ -1023,7 +1023,7 @@ module.exports = ( ) }) - it('it should be successfully performed by the getTradedVolumeCsv method', async function () { + it('it should be successfully performed by the getTradedVolumeFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -1034,7 +1034,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getTradedVolumeCsv', + method: 'getTradedVolumeFile', params: { end, start, @@ -1049,7 +1049,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getTotalFeesReportCsv method', async function () { + it('it should be successfully performed by the getTotalFeesReportFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -1060,7 +1060,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getTotalFeesReportCsv', + method: 'getTotalFeesReportFile', params: { end, start, @@ -1076,7 +1076,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getPerformingLoanCsv method', async function () { + it('it should be successfully performed by the getPerformingLoanFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -1087,7 +1087,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getPerformingLoanCsv', + method: 'getPerformingLoanFile', params: { end, start, @@ -1102,7 +1102,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getWinLossVSAccountBalanceCsv method', async function () { + it('it should be successfully performed by the getWinLossVSAccountBalanceFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -1113,7 +1113,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getWinLossVSAccountBalanceCsv', + method: 'getWinLossVSAccountBalanceFile', params: { end, start, @@ -1128,7 +1128,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getWeightedAveragesReportCsv method', async function () { + it('it should be successfully performed by the getWeightedAveragesReportFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -1139,7 +1139,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getWeightedAveragesReportCsv', + method: 'getWeightedAveragesReportFile', params: { symbol: 'tBTCUSD', end, diff --git a/test/test-cases/api-sync-mode-sqlite-test-cases.js b/test/test-cases/api-sync-mode-sqlite-test-cases.js index 62ba97499..377436552 100644 --- a/test/test-cases/api-sync-mode-sqlite-test-cases.js +++ b/test/test-cases/api-sync-mode-sqlite-test-cases.js @@ -2720,7 +2720,7 @@ module.exports = ( assert.propertyVal(res.body, 'id', 5) }) - it('it should be successfully performed by the getMultipleCsv method', async function () { + it('it should be successfully performed by the getMultipleFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -2731,12 +2731,12 @@ module.exports = ( .type('json') .send({ auth, - method: 'getMultipleCsv', + method: 'getMultipleFile', params: { email, multiExport: [ { - method: 'getTradesCsv', + method: 'getTradesFile', symbol: ['tBTCUSD', 'tETHUSD'], end, start, @@ -2744,7 +2744,7 @@ module.exports = ( timezone: 'America/Los_Angeles' }, { - method: 'getTickersHistoryCsv', + method: 'getTickersHistoryFile', symbol: 'BTC', end, start, @@ -2760,7 +2760,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should not be successfully performed by the getMultipleCsv method', async function () { + it('it should not be successfully performed by the getMultipleFile method', async function () { this.timeout(60000) const res = await agent @@ -2768,7 +2768,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getMultipleCsv', + method: 'getMultipleFile', params: { email, multiExport: [ @@ -2793,7 +2793,7 @@ module.exports = ( assert.propertyVal(res.body, 'id', 5) }) - it('it should be successfully performed by the getTickersHistoryCsv method', async function () { + it('it should be successfully performed by the getTickersHistoryFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -2804,7 +2804,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getTickersHistoryCsv', + method: 'getTickersHistoryFile', params: { symbol: 'BTC', end, @@ -2820,7 +2820,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getPositionsHistoryCsv method', async function () { + it('it should be successfully performed by the getPositionsHistoryFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -2831,7 +2831,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getPositionsHistoryCsv', + method: 'getPositionsHistoryFile', params: { symbol: 'tBTCUSD', end, @@ -2847,7 +2847,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getPositionsAuditCsv method', async function () { + it('it should be successfully performed by the getPositionsAuditFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -2858,7 +2858,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getPositionsAuditCsv', + method: 'getPositionsAuditFile', params: { id: [12345], symbol: 'tBTCUSD', @@ -2875,7 +2875,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getWalletsCsv method', async function () { + it('it should be successfully performed by the getWalletsFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -2886,7 +2886,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getWalletsCsv', + method: 'getWalletsFile', params: { end, email @@ -2899,7 +2899,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getFundingOfferHistoryCsv method', async function () { + it('it should be successfully performed by the getFundingOfferHistoryFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -2910,7 +2910,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getFundingOfferHistoryCsv', + method: 'getFundingOfferHistoryFile', params: { symbol: 'fUSD', end, @@ -2927,7 +2927,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getFundingLoanHistoryCsv method', async function () { + it('it should be successfully performed by the getFundingLoanHistoryFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -2938,7 +2938,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getFundingLoanHistoryCsv', + method: 'getFundingLoanHistoryFile', params: { symbol: 'fUSD', end, @@ -2954,7 +2954,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getFundingCreditHistoryCsv method', async function () { + it('it should be successfully performed by the getFundingCreditHistoryFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -2965,7 +2965,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getFundingCreditHistoryCsv', + method: 'getFundingCreditHistoryFile', params: { symbol: 'fUSD', end, @@ -2981,7 +2981,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getLedgersCsv method', async function () { + it('it should be successfully performed by the getLedgersFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -2992,7 +2992,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getLedgersCsv', + method: 'getLedgersFile', params: { symbol: ['BTC'], end, @@ -3008,7 +3008,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getPayInvoiceListCsv method', async function () { + it('it should be successfully performed by the getPayInvoiceListFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -3019,7 +3019,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getPayInvoiceListCsv', + method: 'getPayInvoiceListFile', params: { end, start, @@ -3035,7 +3035,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getTradesCsv method', async function () { + it('it should be successfully performed by the getTradesFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -3046,7 +3046,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getTradesCsv', + method: 'getTradesFile', params: { symbol: ['tBTCUSD', 'tETHUSD'], end, @@ -3062,7 +3062,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getFundingTradesCsv method', async function () { + it('it should be successfully performed by the getFundingTradesFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -3073,7 +3073,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getFundingTradesCsv', + method: 'getFundingTradesFile', params: { symbol: ['fBTC', 'fETH'], end, @@ -3089,7 +3089,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getPublicTradesCsv method', async function () { + it('it should be successfully performed by the getPublicTradesFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -3100,7 +3100,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getPublicTradesCsv', + method: 'getPublicTradesFile', params: { symbol: 'tBTCUSD', end, @@ -3117,7 +3117,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should not be successfully performed by the getPublicTradesCsv method, time frame more then a month', async function () { + it('it should not be successfully performed by the getPublicTradesFile method, time frame more then a month', async function () { this.timeout(60000) const res = await agent @@ -3125,7 +3125,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getPublicTradesCsv', + method: 'getPublicTradesFile', params: { symbol: 'tBTCUSD', end, @@ -3146,7 +3146,7 @@ module.exports = ( assert.propertyVal(res.body, 'id', 5) }) - it('it should not be successfully performed by the getPublicTradesCsv method, with symbol array', async function () { + it('it should not be successfully performed by the getPublicTradesFile method, with symbol array', async function () { this.timeout(60000) const res = await agent @@ -3154,7 +3154,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getPublicTradesCsv', + method: 'getPublicTradesFile', params: { symbol: ['tBTCUSD', 'tETHUSD'], end, @@ -3175,7 +3175,7 @@ module.exports = ( assert.propertyVal(res.body, 'id', 5) }) - it('it should be successfully performed by the getStatusMessagesCsv method', async function () { + it('it should be successfully performed by the getStatusMessagesFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -3186,7 +3186,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getStatusMessagesCsv', + method: 'getStatusMessagesFile', params: { symbol: ['tBTCF0:USTF0'], timezone: 'America/Los_Angeles', @@ -3200,7 +3200,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getCandlesCsv method', async function () { + it('it should be successfully performed by the getCandlesFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -3211,7 +3211,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getCandlesCsv', + method: 'getCandlesFile', params: { symbol: 'tBTCUSD', timeframe: '12h', @@ -3229,7 +3229,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getOrderTradesCsv method', async function () { + it('it should be successfully performed by the getOrderTradesFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -3240,7 +3240,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getOrderTradesCsv', + method: 'getOrderTradesFile', params: { id: 12345, symbol: 'tBTCUSD', @@ -3258,7 +3258,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getOrdersCsv method', async function () { + it('it should be successfully performed by the getOrdersFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -3269,7 +3269,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getOrdersCsv', + method: 'getOrdersFile', params: { symbol: 'tBTCUSD', end, @@ -3284,7 +3284,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getActiveOrdersCsv method', async function () { + it('it should be successfully performed by the getActiveOrdersFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -3295,7 +3295,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getActiveOrdersCsv', + method: 'getActiveOrdersFile', params: { email }, @@ -3307,7 +3307,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getMovementsCsv method', async function () { + it('it should be successfully performed by the getMovementsFile method', async function () { this.timeout(3 * 60000) const procPromise = queueToPromise(params.processorQueue) @@ -3318,7 +3318,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getMovementsCsv', + method: 'getMovementsFile', params: { symbol: 'BTC', end, @@ -3333,7 +3333,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getMovementsCsv method, where amount > 0', async function () { + it('it should be successfully performed by the getMovementsFile method, where amount > 0', async function () { this.timeout(3 * 60000) const procPromise = queueToPromise(params.processorQueue) @@ -3344,7 +3344,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getMovementsCsv', + method: 'getMovementsFile', params: { symbol: 'BTC', end, @@ -3360,7 +3360,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getMovementsCsv method, where amount < 0', async function () { + it('it should be successfully performed by the getMovementsFile method, where amount < 0', async function () { this.timeout(3 * 60000) const procPromise = queueToPromise(params.processorQueue) @@ -3371,7 +3371,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getMovementsCsv', + method: 'getMovementsFile', params: { symbol: 'BTC', end, @@ -3387,7 +3387,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getLoginsCsv method', async function () { + it('it should be successfully performed by the getLoginsFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -3398,7 +3398,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getLoginsCsv', + method: 'getLoginsFile', params: { end, start, @@ -3413,7 +3413,7 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getChangeLogsCsv method', async function () { + it('it should be successfully performed by the getChangeLogsFile method', async function () { this.timeout(60000) const procPromise = queueToPromise(params.processorQueue) @@ -3424,7 +3424,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getChangeLogsCsv', + method: 'getChangeLogsFile', params: { end, start, @@ -3439,14 +3439,14 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should not be successfully auth by the getLedgersCsv method', async function () { + it('it should not be successfully auth by the getLedgersFile method', async function () { this.timeout(60000) const res = await agent .post(`${basePath}/json-rpc`) .type('json') .send({ - method: 'getLedgersCsv', + method: 'getLedgersFile', params: { symbol: 'BTC', end, @@ -3467,7 +3467,7 @@ module.exports = ( ]) }) - it('it should be successfully performed by the getLedgersCsv method, with multiple users', async function () { + it('it should be successfully performed by the getLedgersFile method, with multiple users', async function () { this.timeout(5 * 60000) const count = 10 @@ -3484,7 +3484,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getLedgersCsv', + method: 'getLedgersFile', params: { symbol: 'BTC', end, From 5c6c20bd77a9a269d3c51caba6f85ff2bbac527c Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 23 Jan 2024 09:50:28 +0200 Subject: [PATCH 16/66] Fix csv writer to use correct export --- .../csv-writer/full-snapshot-report-csv-writer.js | 2 +- .../csv-writer/full-tax-report-csv-writer.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/workers/loc.api/generate-report-file/csv-writer/full-snapshot-report-csv-writer.js b/workers/loc.api/generate-report-file/csv-writer/full-snapshot-report-csv-writer.js index 18fc3c746..bdf404362 100644 --- a/workers/loc.api/generate-report-file/csv-writer/full-snapshot-report-csv-writer.js +++ b/workers/loc.api/generate-report-file/csv-writer/full-snapshot-report-csv-writer.js @@ -5,7 +5,7 @@ const { } = require('bfx-report/workers/loc.api/queue/write-data-to-stream/helpers') const { streamWriter -} = require('bfx-report/workers/loc.api/generate-csv/csv-writer/helpers') +} = require('bfx-report/workers/loc.api/generate-report-file/csv-writer/helpers') module.exports = ( rService, diff --git a/workers/loc.api/generate-report-file/csv-writer/full-tax-report-csv-writer.js b/workers/loc.api/generate-report-file/csv-writer/full-tax-report-csv-writer.js index 2d257e652..5e016af35 100644 --- a/workers/loc.api/generate-report-file/csv-writer/full-tax-report-csv-writer.js +++ b/workers/loc.api/generate-report-file/csv-writer/full-tax-report-csv-writer.js @@ -5,7 +5,7 @@ const { } = require('bfx-report/workers/loc.api/queue/write-data-to-stream/helpers') const { streamWriter -} = require('bfx-report/workers/loc.api/generate-csv/csv-writer/helpers') +} = require('bfx-report/workers/loc.api/generate-report-file/csv-writer/helpers') module.exports = ( rService, From 7bedd48835f36eef6d10b2cd15e3177b1d271f5b Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 24 Jan 2024 09:59:21 +0200 Subject: [PATCH 17/66] Implement pdf writer service with overridden logic --- package.json | 9 ++-- .../generate-report-file/pdf-writer/index.js | 44 +++++++++++++++++++ 2 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 workers/loc.api/generate-report-file/pdf-writer/index.js diff --git a/package.json b/package.json index ca917183e..09d2bd447 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "bfx-svc-boot-js": "https://github.com/bitfinexcom/bfx-svc-boot-js.git", "csv": "5.5.3", "grenache-nodejs-ws": "git+https://github.com:bitfinexcom/grenache-nodejs-ws.git", + "html-pdf": "3.0.1", "inversify": "6.0.1", "lib-js-util-base": "git+https://github.com/bitfinexcom/lib-js-util-base.git", "lodash": "4.17.21", @@ -20,14 +21,14 @@ "yargs": "17.2.1" }, "devDependencies": { - "bfx-report-express": "git+https://github.com/bitfinexcom/bfx-report-express.git", "bfx-api-mock-srv": "git+https://github.com/bitfinexcom/bfx-api-mock-srv.git", + "bfx-report-express": "git+https://github.com/bitfinexcom/bfx-report-express.git", + "chai": "4.3.4", "grenache-grape": "git+https://github.com/bitfinexcom/grenache-grape.git", "mocha": "10.1.0", - "chai": "4.3.4", "nodemon": "2.0.20", - "supertest": "6.3.2", - "standard": "17.0.0" + "standard": "17.0.0", + "supertest": "6.3.2" }, "contributors": [ "Paolo Ardoino ", diff --git a/workers/loc.api/generate-report-file/pdf-writer/index.js b/workers/loc.api/generate-report-file/pdf-writer/index.js new file mode 100644 index 000000000..18d62a137 --- /dev/null +++ b/workers/loc.api/generate-report-file/pdf-writer/index.js @@ -0,0 +1,44 @@ +'use strict' + +const pdf = require('html-pdf') + +const MainPdfWriter = require( + 'bfx-report/workers/loc.api/generate-report-file/pdf-writer' +) + +const { decorateInjectable } = require('../../di/utils') + +const depsTypes = (TYPES) => [ + TYPES.HasGrcService, + TYPES.GrcBfxReq +] +class PdfWriter extends MainPdfWriter { + /** + * @override + */ + async createPDFBuffer (args) { + const { + template = 'No data', + format = 'portrait', + orientation = 'Letter' + } = args ?? {} + + return await new Promise((resolve, reject) => { + pdf.create(template, { + format, + orientation, + type: 'pdf', + childProcessOptions: { + env: { OPENSSL_CONF: '/dev/null' } + } + }).toBuffer((error, buffer) => { + if (error) return reject(error) + resolve(buffer) + }) + }) + } +} + +decorateInjectable(PdfWriter, depsTypes) + +module.exports = PdfWriter From 32689ad67897971471f811daad46a8b5d1931209 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 24 Jan 2024 10:00:17 +0200 Subject: [PATCH 18/66] Rebind pdf writer service in di --- workers/loc.api/di/app.deps.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/workers/loc.api/di/app.deps.js b/workers/loc.api/di/app.deps.js index 20a079d5b..9ef21913e 100644 --- a/workers/loc.api/di/app.deps.js +++ b/workers/loc.api/di/app.deps.js @@ -119,6 +119,7 @@ const privResponder = require('../responder') const ProcessMessageManager = require('../process.message.manager') const HTTPRequest = require('../http.request') const BfxApiRouter = require('../bfx.api.router') +const PdfWriter = require('../generate-report-file/pdf-writer') decorate(injectable(), EventEmitter) @@ -183,6 +184,9 @@ module.exports = ({ ] ) ) + rebind(TYPES.PdfWriter) + .to(PdfWriter) + .inSingletonScope() bind(TYPES.PrivResponder) .toDynamicValue((ctx) => bindDepsToFn( privResponder, From d8f21687203043bab42123e2359826ff12630b61 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 26 Jan 2024 11:14:49 +0200 Subject: [PATCH 19/66] Add translations for tax report --- .../generate-report-file/pdf-writer/translations.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 workers/loc.api/generate-report-file/pdf-writer/translations.yml diff --git a/workers/loc.api/generate-report-file/pdf-writer/translations.yml b/workers/loc.api/generate-report-file/pdf-writer/translations.yml new file mode 100644 index 000000000..6bd1a1d6b --- /dev/null +++ b/workers/loc.api/generate-report-file/pdf-writer/translations.yml @@ -0,0 +1,7 @@ +en: + template: + fullTaxReport: Full tax report + +ru: + template: + fullTaxReport: Полные налоговые отчеты From 7b83a29c515f0a371f1b2c576396436774849c06 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 26 Jan 2024 11:22:26 +0200 Subject: [PATCH 20/66] Add pdf template for tax report --- .../pdf-writer/template-file-names.js | 5 +++++ .../pdf-writer/templates/full-tax-report.pug | 8 ++++++++ 2 files changed, 13 insertions(+) create mode 100644 workers/loc.api/generate-report-file/pdf-writer/template-file-names.js create mode 100644 workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug diff --git a/workers/loc.api/generate-report-file/pdf-writer/template-file-names.js b/workers/loc.api/generate-report-file/pdf-writer/template-file-names.js new file mode 100644 index 000000000..55e033f8c --- /dev/null +++ b/workers/loc.api/generate-report-file/pdf-writer/template-file-names.js @@ -0,0 +1,5 @@ +'use strict' + +module.exports = { + FULL_TAX_REPORT: 'full-tax-report.pug' +} diff --git a/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug new file mode 100644 index 000000000..6cf16aa3a --- /dev/null +++ b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug @@ -0,0 +1,8 @@ +extends /node_modules/bfx-report/workers/loc.api/generate-report-file/pdf-writer/templates/base.pug + +block content + p + :translate(prop='template.fullTaxReport') + Full tax report + pre + | #{JSON.stringify(apiData, null, 2)} From f795c4d188ebee42b96de19cc40508230fbce872 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 26 Jan 2024 11:24:06 +0200 Subject: [PATCH 21/66] Add tax template to config --- workers/loc.api/generate-report-file/report.file.job.data.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/workers/loc.api/generate-report-file/report.file.job.data.js b/workers/loc.api/generate-report-file/report.file.job.data.js index 871a29df8..1c9287792 100644 --- a/workers/loc.api/generate-report-file/report.file.job.data.js +++ b/workers/loc.api/generate-report-file/report.file.job.data.js @@ -14,6 +14,7 @@ const { checkParams, getDateString } = require('../helpers') +const TEMPLATE_FILE_NAMES = require('./pdf-writer/template-file-names') const { decorateInjectable } = require('../di/utils') @@ -508,7 +509,8 @@ class ReportFileJobData extends BaseReportFileJobData { mtsUpdated: 'date' } }, - csvCustomWriter: this.fullTaxReportCsvWriter + csvCustomWriter: this.fullTaxReportCsvWriter, + pdfCustomTemplateName: TEMPLATE_FILE_NAMES.FULL_TAX_REPORT } return jobData From 94343f655af8aaf38567a755f2ee13b1e84a6f2d Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 26 Jan 2024 11:26:59 +0200 Subject: [PATCH 22/66] Extend templates and translation in extended pdf writer --- .../generate-report-file/pdf-writer/index.js | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/workers/loc.api/generate-report-file/pdf-writer/index.js b/workers/loc.api/generate-report-file/pdf-writer/index.js index 18d62a137..f3d6f0ced 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/index.js +++ b/workers/loc.api/generate-report-file/pdf-writer/index.js @@ -1,18 +1,28 @@ 'use strict' +const path = require('path') const pdf = require('html-pdf') const MainPdfWriter = require( 'bfx-report/workers/loc.api/generate-report-file/pdf-writer' ) -const { decorateInjectable } = require('../../di/utils') +const TEMPLATE_FILE_NAMES = require('./template-file-names') -const depsTypes = (TYPES) => [ - TYPES.HasGrcService, - TYPES.GrcBfxReq -] class PdfWriter extends MainPdfWriter { + constructor (...deps) { + super(...deps) + + this.addTranslations(this.loadTranslations( + path.join(__dirname, 'translations.yml') + )) + this.addTemplates({ + fileNames: TEMPLATE_FILE_NAMES, + templateFolderPath: path.join(__dirname, 'templates') + }) + this.compileTemplate() + } + /** * @override */ @@ -39,6 +49,4 @@ class PdfWriter extends MainPdfWriter { } } -decorateInjectable(PdfWriter, depsTypes) - module.exports = PdfWriter From 60e4a56ea54f1781c685424f7e56c9bd1b670041 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 30 Jan 2024 14:37:16 +0200 Subject: [PATCH 23/66] Add timestamps to full-tax-report response --- workers/loc.api/sync/full.tax.report/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/workers/loc.api/sync/full.tax.report/index.js b/workers/loc.api/sync/full.tax.report/index.js index 2cf223198..45a5a8856 100644 --- a/workers/loc.api/sync/full.tax.report/index.js +++ b/workers/loc.api/sync/full.tax.report/index.js @@ -187,6 +187,11 @@ class FullTaxReport { ) return { + timestamps: { + mtsCreated: Date.now(), + start, + end + }, startingPositionsSnapshot, endingPositionsSnapshot, finalState: { From 00ac2578390d114dfe45365d4d7122f317bc5307 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 30 Jan 2024 14:39:31 +0200 Subject: [PATCH 24/66] Use common format settings in full-tax-report csv writer --- .../csv-writer/full-tax-report-csv-writer.js | 11 +++++------ .../generate-report-file/report.file.job.data.js | 13 ++++++++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/workers/loc.api/generate-report-file/csv-writer/full-tax-report-csv-writer.js b/workers/loc.api/generate-report-file/csv-writer/full-tax-report-csv-writer.js index 5e016af35..c120c4547 100644 --- a/workers/loc.api/generate-report-file/csv-writer/full-tax-report-csv-writer.js +++ b/workers/loc.api/generate-report-file/csv-writer/full-tax-report-csv-writer.js @@ -28,8 +28,6 @@ module.exports = ( ..._params } const args = { ..._args, params } - const { start, end } = params - const mtsCreated = Date.now() queue.emit('progress', 0) @@ -53,6 +51,7 @@ module.exports = ( callerName: 'REPORT_FILE_WRITER' }) const { + timestamps, startingPositionsSnapshot, endingPositionsSnapshot, finalState: { @@ -75,7 +74,7 @@ module.exports = ( columns: columnsCsv.timestamps }, writeFn: (stream) => write( - [{ mtsCreated, start, end }, {}], + [timestamps, {}], stream, formatSettings.timestamps, params @@ -96,7 +95,7 @@ module.exports = ( writeFn: (stream) => write( [...startingPositionsSnapshot, {}], stream, - formatSettings.positionsSnapshot, + formatSettings.startingPositionsSnapshot, params ) }, @@ -115,7 +114,7 @@ module.exports = ( writeFn: (stream) => write( [...endingPositionsSnapshot, {}], stream, - formatSettings.positionsSnapshot, + formatSettings.endingPositionsSnapshot, params ) }, @@ -158,7 +157,7 @@ module.exports = ( writeFn: (stream) => write( [...movements, {}], stream, - formatSettings.movements, + formatSettings.finalState.movements, params ) }, diff --git a/workers/loc.api/generate-report-file/report.file.job.data.js b/workers/loc.api/generate-report-file/report.file.job.data.js index 1c9287792..67226c5ca 100644 --- a/workers/loc.api/generate-report-file/report.file.job.data.js +++ b/workers/loc.api/generate-report-file/report.file.job.data.js @@ -500,13 +500,20 @@ class ReportFileJobData extends BaseReportFileJobData { start: 'date', end: 'date' }, - positionsSnapshot: { + startingPositionsSnapshot: { mtsUpdate: 'date', mtsCreate: 'date', symbol: 'symbol' }, - movements: { - mtsUpdated: 'date' + endingPositionsSnapshot: { + mtsUpdate: 'date', + mtsCreate: 'date', + symbol: 'symbol' + }, + finalState: { + movements: { + mtsUpdated: 'date' + } } }, csvCustomWriter: this.fullTaxReportCsvWriter, From e056ff8b95337c936d7614dbe79036751d275d73 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 30 Jan 2024 14:42:54 +0200 Subject: [PATCH 25/66] Add positions snapshots to full-tax-report pdf template --- .../pdf-writer/templates/full-tax-report.pug | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug index 6cf16aa3a..58625b773 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug +++ b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug @@ -1,8 +1,38 @@ extends /node_modules/bfx-report/workers/loc.api/generate-report-file/pdf-writer/templates/base.pug block content - p - :translate(prop='template.fullTaxReport') - Full tax report - pre - | #{JSON.stringify(apiData, null, 2)} + - const data = Array.isArray(apiData) ? apiData[0] : apiData ?? {} + + ul.responsive-table + li.table-header + each columnVal, columnKey in jobData.columnsCsv.timestamps + .col #{columnVal} + li.table-row + each columnVal, columnKey in jobData.columnsCsv.timestamps + .col #{data.timestamps[columnKey]} + + h3.content-title.left-text + :translate(prop='template.startingPositionsSnapshot') + Starting positions snapshot + + ul.responsive-table.sm + li.table-header + each columnVal, columnKey in jobData.columnsCsv.positionsSnapshot + .col #{columnVal} + each dataItem, dataIndex in data.startingPositionsSnapshot + li.table-row + each columnVal, columnKey in jobData.columnsCsv.positionsSnapshot + .col #{dataItem[columnKey]} + + h3.content-title.left-text + :translate(prop='template.endingPositionsSnapshot') + Ending positions snapshot + + ul.responsive-table.sm + li.table-header + each columnVal, columnKey in jobData.columnsCsv.positionsSnapshot + .col #{columnVal} + each dataItem, dataIndex in data.endingPositionsSnapshot + li.table-row + each columnVal, columnKey in jobData.columnsCsv.positionsSnapshot + .col #{dataItem[columnKey]} From 9855cfda0539a0bc858ad7466f5eba0be3189544 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 30 Jan 2024 14:43:39 +0200 Subject: [PATCH 26/66] Add positions snapshots translations --- .../loc.api/generate-report-file/pdf-writer/translations.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/workers/loc.api/generate-report-file/pdf-writer/translations.yml b/workers/loc.api/generate-report-file/pdf-writer/translations.yml index 6bd1a1d6b..65056b9a1 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/translations.yml +++ b/workers/loc.api/generate-report-file/pdf-writer/translations.yml @@ -1,7 +1,8 @@ en: template: - fullTaxReport: Full tax report + startingPositionsSnapshot: Starting positions snapshot + endingPositionsSnapshot: Ending positions snapshot ru: template: - fullTaxReport: Полные налоговые отчеты + startingPositionsSnapshot: Снимок стартовых позиций From 04222a323691cbf1cb2cd1054db5b75b884e0840 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 31 Jan 2024 10:50:09 +0200 Subject: [PATCH 27/66] Add starting period balances to full-tax-report pdf template --- .../pdf-writer/templates/full-tax-report.pug | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug index 58625b773..e40dbe176 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug +++ b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug @@ -36,3 +36,19 @@ block content li.table-row each columnVal, columnKey in jobData.columnsCsv.positionsSnapshot .col #{dataItem[columnKey]} + + h3.content-title + :translate(prop='template.finalState') + Final state + + h3.content-title.left-text + :translate(prop='template.startingPeriodBalances') + Starting period balances + + ul.responsive-table + li.table-header + each columnVal, columnKey in jobData.columnsCsv.periodBalances + .col #{columnVal} + li.table-row + each columnVal, columnKey in jobData.columnsCsv.periodBalances + .col #{data.finalState.startingPeriodBalances[columnKey]} From 78554c8fa9a91cf921343756f60ec6119d87ae8d Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 31 Jan 2024 10:51:31 +0200 Subject: [PATCH 28/66] Add translations for starting period balances for full-tax-report pdf template --- .../loc.api/generate-report-file/pdf-writer/translations.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/workers/loc.api/generate-report-file/pdf-writer/translations.yml b/workers/loc.api/generate-report-file/pdf-writer/translations.yml index 65056b9a1..af820a7a5 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/translations.yml +++ b/workers/loc.api/generate-report-file/pdf-writer/translations.yml @@ -2,6 +2,8 @@ en: template: startingPositionsSnapshot: Starting positions snapshot endingPositionsSnapshot: Ending positions snapshot + finalState: Final state + startingPeriodBalances: Starting period balances ru: template: From adf5cd8a30c6f787f71aca9ddbb735a06221090c Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 31 Jan 2024 11:01:30 +0200 Subject: [PATCH 29/66] Add movements details to full-tax-report pdf template --- .../pdf-writer/templates/full-tax-report.pug | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug index e40dbe176..abfde32a2 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug +++ b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug @@ -52,3 +52,16 @@ block content li.table-row each columnVal, columnKey in jobData.columnsCsv.periodBalances .col #{data.finalState.startingPeriodBalances[columnKey]} + + h3.content-title.left-text + :translate(prop='template.movementsDetails') + Movements details + + ul.responsive-table.sm + li.table-header + each columnVal, columnKey in jobData.columnsCsv.movements + .col #{columnVal} + each dataItem, dataIndex in data.finalState.movements + li.table-row + each columnVal, columnKey in jobData.columnsCsv.movements + .col #{dataItem[columnKey]} From b81cfbc2e582bcb6000224d4898aaa2ac36671a1 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 31 Jan 2024 11:02:32 +0200 Subject: [PATCH 30/66] Add translations for movements details for full-tax-report pdf template --- workers/loc.api/generate-report-file/pdf-writer/translations.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/workers/loc.api/generate-report-file/pdf-writer/translations.yml b/workers/loc.api/generate-report-file/pdf-writer/translations.yml index af820a7a5..3c5850cf5 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/translations.yml +++ b/workers/loc.api/generate-report-file/pdf-writer/translations.yml @@ -4,6 +4,7 @@ en: endingPositionsSnapshot: Ending positions snapshot finalState: Final state startingPeriodBalances: Starting period balances + movementsDetails: Movements details ru: template: From 53f6e2d69ce1f80243602a90918792b74d9d16ae Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 31 Jan 2024 11:48:29 +0200 Subject: [PATCH 31/66] Add movements total amount to full-tax-report pdf template --- .../pdf-writer/templates/full-tax-report.pug | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug index abfde32a2..33177f6ef 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug +++ b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug @@ -65,3 +65,11 @@ block content li.table-row each columnVal, columnKey in jobData.columnsCsv.movements .col #{dataItem[columnKey]} + + ul.responsive-table.width-by-content + li.table-header + each columnVal, columnKey in jobData.columnsCsv.movementsTotalAmount + .col #{columnVal} + li.table-row + each columnVal, columnKey in jobData.columnsCsv.movementsTotalAmount + .col #{data.finalState[columnKey]} From 0050631f433ab2738caaaa71cef62b61de22820a Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 31 Jan 2024 12:42:29 +0200 Subject: [PATCH 32/66] Add ending period balances to full-tax-report pdf template --- .../pdf-writer/templates/full-tax-report.pug | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug index 33177f6ef..fd915430f 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug +++ b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug @@ -11,7 +11,7 @@ block content each columnVal, columnKey in jobData.columnsCsv.timestamps .col #{data.timestamps[columnKey]} - h3.content-title.left-text + h3.content-title.left-text.table-title :translate(prop='template.startingPositionsSnapshot') Starting positions snapshot @@ -24,7 +24,7 @@ block content each columnVal, columnKey in jobData.columnsCsv.positionsSnapshot .col #{dataItem[columnKey]} - h3.content-title.left-text + h3.content-title.left-text.table-title :translate(prop='template.endingPositionsSnapshot') Ending positions snapshot @@ -37,11 +37,11 @@ block content each columnVal, columnKey in jobData.columnsCsv.positionsSnapshot .col #{dataItem[columnKey]} - h3.content-title + h3.content-title.uppercase-text :translate(prop='template.finalState') Final state - h3.content-title.left-text + h3.content-title.left-text.table-title :translate(prop='template.startingPeriodBalances') Starting period balances @@ -53,11 +53,11 @@ block content each columnVal, columnKey in jobData.columnsCsv.periodBalances .col #{data.finalState.startingPeriodBalances[columnKey]} - h3.content-title.left-text + h3.content-title.left-text.table-title :translate(prop='template.movementsDetails') Movements details - ul.responsive-table.sm + ul.responsive-table.sm.no-margin-bottom li.table-header each columnVal, columnKey in jobData.columnsCsv.movements .col #{columnVal} @@ -66,10 +66,22 @@ block content each columnVal, columnKey in jobData.columnsCsv.movements .col #{dataItem[columnKey]} - ul.responsive-table.width-by-content - li.table-header + ul.responsive-table.sm.width-by-content + li.table-header.no-margin-top each columnVal, columnKey in jobData.columnsCsv.movementsTotalAmount .col #{columnVal} li.table-row each columnVal, columnKey in jobData.columnsCsv.movementsTotalAmount .col #{data.finalState[columnKey]} + + h3.content-title.left-text.table-title + :translate(prop='template.endingPeriodBalances') + Ending period balances + + ul.responsive-table + li.table-header + each columnVal, columnKey in jobData.columnsCsv.periodBalances + .col #{columnVal} + li.table-row + each columnVal, columnKey in jobData.columnsCsv.periodBalances + .col #{data.finalState.endingPeriodBalances[columnKey]} From 42d41cf07a8fad4b5f9921fec3652414ff2c6707 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 31 Jan 2024 12:42:55 +0200 Subject: [PATCH 33/66] Add translations for ending period balances for full-tax-report pdf template --- workers/loc.api/generate-report-file/pdf-writer/translations.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/workers/loc.api/generate-report-file/pdf-writer/translations.yml b/workers/loc.api/generate-report-file/pdf-writer/translations.yml index 3c5850cf5..54e9d6213 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/translations.yml +++ b/workers/loc.api/generate-report-file/pdf-writer/translations.yml @@ -5,6 +5,7 @@ en: finalState: Final state startingPeriodBalances: Starting period balances movementsDetails: Movements details + endingPeriodBalances: Ending period balances ru: template: From 6886d4173359b88906d356dcc0d7905aafc8e440 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 31 Jan 2024 13:06:34 +0200 Subject: [PATCH 34/66] Add total result to full-tax-report pdf template --- .../pdf-writer/templates/full-tax-report.pug | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug index fd915430f..844c49596 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug +++ b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug @@ -67,7 +67,7 @@ block content .col #{dataItem[columnKey]} ul.responsive-table.sm.width-by-content - li.table-header.no-margin-top + li.table-header each columnVal, columnKey in jobData.columnsCsv.movementsTotalAmount .col #{columnVal} li.table-row @@ -78,10 +78,18 @@ block content :translate(prop='template.endingPeriodBalances') Ending period balances - ul.responsive-table + ul.responsive-table.no-margin-bottom li.table-header each columnVal, columnKey in jobData.columnsCsv.periodBalances .col #{columnVal} li.table-row each columnVal, columnKey in jobData.columnsCsv.periodBalances .col #{data.finalState.endingPeriodBalances[columnKey]} + + ul.responsive-table.width-by-content + li.table-header + each columnVal, columnKey in jobData.columnsCsv.totalResult + .col #{columnVal} + li.table-row + each columnVal, columnKey in jobData.columnsCsv.totalResult + .col #{data.finalState[columnKey]} From 80b75eeea4c9417a62b9b3bfec114a46985119cf Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 1 Feb 2024 14:36:57 +0200 Subject: [PATCH 35/66] Improve full snapshot report file job data --- .../loc.api/generate-report-file/report.file.job.data.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/workers/loc.api/generate-report-file/report.file.job.data.js b/workers/loc.api/generate-report-file/report.file.job.data.js index 67226c5ca..43bbfc8b9 100644 --- a/workers/loc.api/generate-report-file/report.file.job.data.js +++ b/workers/loc.api/generate-report-file/report.file.job.data.js @@ -350,10 +350,10 @@ class ReportFileJobData extends BaseReportFileJobData { amount: 'AMOUNT' }, positionsTotalPlUsd: { - plUsd: 'POSITIONS TOTAL P/L USD' + positionsTotalPlUsd: 'POSITIONS TOTAL P/L USD' }, walletsTotalBalanceUsd: { - balanceUsd: 'WALLETS TOTAL BALANCE USD' + walletsTotalBalanceUsd: 'WALLETS TOTAL BALANCE USD' } }, formatSettings: { @@ -377,7 +377,8 @@ class ReportFileJobData extends BaseReportFileJobData { symbol: 'symbol' } }, - csvCustomWriter: this.fullSnapshotReportCsvWriter + csvCustomWriter: this.fullSnapshotReportCsvWriter, + pdfCustomTemplateName: TEMPLATE_FILE_NAMES.FULL_SNAPSHOT_REPORT } return jobData From 211111b181504bb30df072784a82a6f586f529e3 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 1 Feb 2024 14:38:11 +0200 Subject: [PATCH 36/66] Add timestamps to full-snapshot-report response --- workers/loc.api/sync/full.snapshot.report/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/workers/loc.api/sync/full.snapshot.report/index.js b/workers/loc.api/sync/full.snapshot.report/index.js index e768483e0..6875ad66f 100644 --- a/workers/loc.api/sync/full.snapshot.report/index.js +++ b/workers/loc.api/sync/full.snapshot.report/index.js @@ -137,6 +137,10 @@ class FullSnapshotReport { ]) return { + timestamps: { + mtsCreated: Date.now(), + end + }, positionsSnapshot, walletsSnapshot, positionsTickers, From 1af0b856d1f9f2a56499c842e7c15a898a9da0ac Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 1 Feb 2024 14:38:54 +0200 Subject: [PATCH 37/66] Rework full-snapshot-report csv writer --- .../csv-writer/full-snapshot-report-csv-writer.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/workers/loc.api/generate-report-file/csv-writer/full-snapshot-report-csv-writer.js b/workers/loc.api/generate-report-file/csv-writer/full-snapshot-report-csv-writer.js index bdf404362..044d8f04a 100644 --- a/workers/loc.api/generate-report-file/csv-writer/full-snapshot-report-csv-writer.js +++ b/workers/loc.api/generate-report-file/csv-writer/full-snapshot-report-csv-writer.js @@ -27,8 +27,6 @@ module.exports = ( ..._params } const args = { ..._args, params } - const { end } = params - const mtsCreated = Date.now() queue.emit('progress', 0) @@ -53,6 +51,7 @@ module.exports = ( }) const { + timestamps, positionsSnapshot, walletsSnapshot, positionsTickers, @@ -72,7 +71,7 @@ module.exports = ( columns: columnsCsv.timestamps }, writeFn: (stream) => write( - [{ mtsCreated, end }, {}], + [timestamps, {}], stream, formatSettings.timestamps, params @@ -100,7 +99,7 @@ module.exports = ( columns: columnsCsv.positionsTotalPlUsd }, writeFn: (stream) => write( - [{ plUsd: positionsTotalPlUsd }, {}], + [{ positionsTotalPlUsd }, {}], stream, formatSettings.positionsTotalPlUsd, params @@ -128,7 +127,7 @@ module.exports = ( columns: columnsCsv.walletsTotalBalanceUsd }, writeFn: (stream) => write( - [{ balanceUsd: walletsTotalBalanceUsd }, {}], + [{ walletsTotalBalanceUsd }, {}], stream, formatSettings.walletsTotalBalanceUsd, params From 755717f6da54fd618144552e12da6a6a3844f41d Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 1 Feb 2024 14:40:19 +0200 Subject: [PATCH 38/66] Implement full-snapshot-report pdf template --- .../templates/full-snapshot-report.pug | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 workers/loc.api/generate-report-file/pdf-writer/templates/full-snapshot-report.pug diff --git a/workers/loc.api/generate-report-file/pdf-writer/templates/full-snapshot-report.pug b/workers/loc.api/generate-report-file/pdf-writer/templates/full-snapshot-report.pug new file mode 100644 index 000000000..43a7cc372 --- /dev/null +++ b/workers/loc.api/generate-report-file/pdf-writer/templates/full-snapshot-report.pug @@ -0,0 +1,80 @@ +extends /node_modules/bfx-report/workers/loc.api/generate-report-file/pdf-writer/templates/base.pug + +block content + - const data = Array.isArray(apiData) ? apiData[0] : apiData ?? {} + + ul.responsive-table + li.table-header + each columnVal, columnKey in jobData.columnsCsv.timestamps + .col #{columnVal} + li.table-row + each columnVal, columnKey in jobData.columnsCsv.timestamps + .col #{data.timestamps[columnKey]} + + h3.content-title.left-text.table-title + :translate(prop='template.positions') + Positions + + ul.responsive-table.sm.no-margin-bottom + li.table-header + each columnVal, columnKey in jobData.columnsCsv.positionsSnapshot + .col #{columnVal} + each dataItem, dataIndex in data.positionsSnapshot + li.table-row + each columnVal, columnKey in jobData.columnsCsv.positionsSnapshot + .col #{dataItem[columnKey]} + + ul.responsive-table.sm.width-by-content + li.table-header + each columnVal, columnKey in jobData.columnsCsv.positionsTotalPlUsd + .col #{columnVal} + li.table-row + each columnVal, columnKey in jobData.columnsCsv.positionsTotalPlUsd + .col #{data[columnKey]} + + h3.content-title.left-text.table-title + :translate(prop='template.wallets') + Wallets + + ul.responsive-table.no-margin-bottom + li.table-header + each columnVal, columnKey in jobData.columnsCsv.walletsSnapshot + .col #{columnVal} + each dataItem, dataIndex in data.walletsSnapshot + li.table-row + each columnVal, columnKey in jobData.columnsCsv.walletsSnapshot + .col #{dataItem[columnKey]} + + ul.responsive-table.width-by-content + li.table-header + each columnVal, columnKey in jobData.columnsCsv.walletsTotalBalanceUsd + .col #{columnVal} + li.table-row + each columnVal, columnKey in jobData.columnsCsv.walletsTotalBalanceUsd + .col #{data[columnKey]} + + h3.content-title.left-text.table-title + :translate(prop='template.positionsTickers') + Positions tickers + + ul.responsive-table + li.table-header + each columnVal, columnKey in jobData.columnsCsv.positionsTickers + .col #{columnVal} + each dataItem, dataIndex in data.positionsTickers + li.table-row + each columnVal, columnKey in jobData.columnsCsv.positionsTickers + .col #{dataItem[columnKey]} + + h3.content-title.left-text.table-title + :translate(prop='template.walletsTickers') + Wallets tickers + + ul.responsive-table + li.table-header + each columnVal, columnKey in jobData.columnsCsv.walletsTickers + .col #{columnVal} + each dataItem, dataIndex in data.walletsTickers + li.table-row + each columnVal, columnKey in jobData.columnsCsv.walletsTickers + .col #{dataItem[columnKey]} From 0322ef85a446f6c046a8ec657621d0ba80e8acda Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 1 Feb 2024 14:41:02 +0200 Subject: [PATCH 39/66] Register full-snapshot-report pdf template --- .../generate-report-file/pdf-writer/template-file-names.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/workers/loc.api/generate-report-file/pdf-writer/template-file-names.js b/workers/loc.api/generate-report-file/pdf-writer/template-file-names.js index 55e033f8c..bf81fafc8 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/template-file-names.js +++ b/workers/loc.api/generate-report-file/pdf-writer/template-file-names.js @@ -1,5 +1,6 @@ 'use strict' module.exports = { - FULL_TAX_REPORT: 'full-tax-report.pug' + FULL_TAX_REPORT: 'full-tax-report.pug', + FULL_SNAPSHOT_REPORT: 'full-snapshot-report.pug' } From c735c87cbceb12735f632ff7983dcd0ccab9847a Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 1 Feb 2024 14:42:41 +0200 Subject: [PATCH 40/66] Add translations for full-snapshot-report pdf template --- .../loc.api/generate-report-file/pdf-writer/translations.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/workers/loc.api/generate-report-file/pdf-writer/translations.yml b/workers/loc.api/generate-report-file/pdf-writer/translations.yml index 54e9d6213..31834a937 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/translations.yml +++ b/workers/loc.api/generate-report-file/pdf-writer/translations.yml @@ -6,6 +6,10 @@ en: startingPeriodBalances: Starting period balances movementsDetails: Movements details endingPeriodBalances: Ending period balances + positions: Positions + wallets: Wallets + positionsTickers: Positions tickers + walletsTickers: Wallets tickers ru: template: From e0de23c0159e0b4f344054aa76f9af5508b9d1e1 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 5 Feb 2024 12:18:50 +0200 Subject: [PATCH 41/66] Add ability to overwrite column order for full-tax-report pdf --- .../templates/full-snapshot-report.pug | 28 ++++++++-------- .../pdf-writer/templates/full-tax-report.pug | 32 +++++++++---------- .../report.file.job.data.js | 4 +++ 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/workers/loc.api/generate-report-file/pdf-writer/templates/full-snapshot-report.pug b/workers/loc.api/generate-report-file/pdf-writer/templates/full-snapshot-report.pug index 43a7cc372..44f7e6509 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/templates/full-snapshot-report.pug +++ b/workers/loc.api/generate-report-file/pdf-writer/templates/full-snapshot-report.pug @@ -5,10 +5,10 @@ block content ul.responsive-table li.table-header - each columnVal, columnKey in jobData.columnsCsv.timestamps + each columnVal, columnKey in reportColumns.timestamps .col #{columnVal} li.table-row - each columnVal, columnKey in jobData.columnsCsv.timestamps + each columnVal, columnKey in reportColumns.timestamps .col #{data.timestamps[columnKey]} h3.content-title.left-text.table-title @@ -17,19 +17,19 @@ block content ul.responsive-table.sm.no-margin-bottom li.table-header - each columnVal, columnKey in jobData.columnsCsv.positionsSnapshot + each columnVal, columnKey in reportColumns.positionsSnapshot .col #{columnVal} each dataItem, dataIndex in data.positionsSnapshot li.table-row - each columnVal, columnKey in jobData.columnsCsv.positionsSnapshot + each columnVal, columnKey in reportColumns.positionsSnapshot .col #{dataItem[columnKey]} ul.responsive-table.sm.width-by-content li.table-header - each columnVal, columnKey in jobData.columnsCsv.positionsTotalPlUsd + each columnVal, columnKey in reportColumns.positionsTotalPlUsd .col #{columnVal} li.table-row - each columnVal, columnKey in jobData.columnsCsv.positionsTotalPlUsd + each columnVal, columnKey in reportColumns.positionsTotalPlUsd .col #{data[columnKey]} h3.content-title.left-text.table-title @@ -38,19 +38,19 @@ block content ul.responsive-table.no-margin-bottom li.table-header - each columnVal, columnKey in jobData.columnsCsv.walletsSnapshot + each columnVal, columnKey in reportColumns.walletsSnapshot .col #{columnVal} each dataItem, dataIndex in data.walletsSnapshot li.table-row - each columnVal, columnKey in jobData.columnsCsv.walletsSnapshot + each columnVal, columnKey in reportColumns.walletsSnapshot .col #{dataItem[columnKey]} ul.responsive-table.width-by-content li.table-header - each columnVal, columnKey in jobData.columnsCsv.walletsTotalBalanceUsd + each columnVal, columnKey in reportColumns.walletsTotalBalanceUsd .col #{columnVal} li.table-row - each columnVal, columnKey in jobData.columnsCsv.walletsTotalBalanceUsd + each columnVal, columnKey in reportColumns.walletsTotalBalanceUsd .col #{data[columnKey]} h3.content-title.left-text.table-title @@ -59,11 +59,11 @@ block content ul.responsive-table li.table-header - each columnVal, columnKey in jobData.columnsCsv.positionsTickers + each columnVal, columnKey in reportColumns.positionsTickers .col #{columnVal} each dataItem, dataIndex in data.positionsTickers li.table-row - each columnVal, columnKey in jobData.columnsCsv.positionsTickers + each columnVal, columnKey in reportColumns.positionsTickers .col #{dataItem[columnKey]} h3.content-title.left-text.table-title @@ -72,9 +72,9 @@ block content ul.responsive-table li.table-header - each columnVal, columnKey in jobData.columnsCsv.walletsTickers + each columnVal, columnKey in reportColumns.walletsTickers .col #{columnVal} each dataItem, dataIndex in data.walletsTickers li.table-row - each columnVal, columnKey in jobData.columnsCsv.walletsTickers + each columnVal, columnKey in reportColumns.walletsTickers .col #{dataItem[columnKey]} diff --git a/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug index 844c49596..75051747c 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug +++ b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug @@ -5,10 +5,10 @@ block content ul.responsive-table li.table-header - each columnVal, columnKey in jobData.columnsCsv.timestamps + each columnVal, columnKey in reportColumns.timestamps .col #{columnVal} li.table-row - each columnVal, columnKey in jobData.columnsCsv.timestamps + each columnVal, columnKey in reportColumns.timestamps .col #{data.timestamps[columnKey]} h3.content-title.left-text.table-title @@ -17,11 +17,11 @@ block content ul.responsive-table.sm li.table-header - each columnVal, columnKey in jobData.columnsCsv.positionsSnapshot + each columnVal, columnKey in reportColumns.positionsSnapshot .col #{columnVal} each dataItem, dataIndex in data.startingPositionsSnapshot li.table-row - each columnVal, columnKey in jobData.columnsCsv.positionsSnapshot + each columnVal, columnKey in reportColumns.positionsSnapshot .col #{dataItem[columnKey]} h3.content-title.left-text.table-title @@ -30,11 +30,11 @@ block content ul.responsive-table.sm li.table-header - each columnVal, columnKey in jobData.columnsCsv.positionsSnapshot + each columnVal, columnKey in reportColumns.positionsSnapshot .col #{columnVal} each dataItem, dataIndex in data.endingPositionsSnapshot li.table-row - each columnVal, columnKey in jobData.columnsCsv.positionsSnapshot + each columnVal, columnKey in reportColumns.positionsSnapshot .col #{dataItem[columnKey]} h3.content-title.uppercase-text @@ -47,10 +47,10 @@ block content ul.responsive-table li.table-header - each columnVal, columnKey in jobData.columnsCsv.periodBalances + each columnVal, columnKey in reportColumns.periodBalances .col #{columnVal} li.table-row - each columnVal, columnKey in jobData.columnsCsv.periodBalances + each columnVal, columnKey in reportColumns.periodBalances .col #{data.finalState.startingPeriodBalances[columnKey]} h3.content-title.left-text.table-title @@ -59,19 +59,19 @@ block content ul.responsive-table.sm.no-margin-bottom li.table-header - each columnVal, columnKey in jobData.columnsCsv.movements + each columnVal, columnKey in reportColumns.movements .col #{columnVal} each dataItem, dataIndex in data.finalState.movements li.table-row - each columnVal, columnKey in jobData.columnsCsv.movements + each columnVal, columnKey in reportColumns.movements .col #{dataItem[columnKey]} ul.responsive-table.sm.width-by-content li.table-header - each columnVal, columnKey in jobData.columnsCsv.movementsTotalAmount + each columnVal, columnKey in reportColumns.movementsTotalAmount .col #{columnVal} li.table-row - each columnVal, columnKey in jobData.columnsCsv.movementsTotalAmount + each columnVal, columnKey in reportColumns.movementsTotalAmount .col #{data.finalState[columnKey]} h3.content-title.left-text.table-title @@ -80,16 +80,16 @@ block content ul.responsive-table.no-margin-bottom li.table-header - each columnVal, columnKey in jobData.columnsCsv.periodBalances + each columnVal, columnKey in reportColumns.periodBalances .col #{columnVal} li.table-row - each columnVal, columnKey in jobData.columnsCsv.periodBalances + each columnVal, columnKey in reportColumns.periodBalances .col #{data.finalState.endingPeriodBalances[columnKey]} ul.responsive-table.width-by-content li.table-header - each columnVal, columnKey in jobData.columnsCsv.totalResult + each columnVal, columnKey in reportColumns.totalResult .col #{columnVal} li.table-row - each columnVal, columnKey in jobData.columnsCsv.totalResult + each columnVal, columnKey in reportColumns.totalResult .col #{data.finalState[columnKey]} diff --git a/workers/loc.api/generate-report-file/report.file.job.data.js b/workers/loc.api/generate-report-file/report.file.job.data.js index 43bbfc8b9..430725f1c 100644 --- a/workers/loc.api/generate-report-file/report.file.job.data.js +++ b/workers/loc.api/generate-report-file/report.file.job.data.js @@ -451,6 +451,10 @@ class ReportFileJobData extends BaseReportFileJobData { name: 'getFullTaxReport', fileNamesMap: [['getFullTaxReport', 'full-tax-report_FULL_PERIOD']], args: reportFileArgs, + /* + * Example how to overwrite column order for pdf + * columnsPdf: {}, + */ columnsCsv: { timestamps: { mtsCreated: 'CREATED', From a778018dc54169c98a1181c10f4ce36b16845e78 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 6 Feb 2024 11:34:12 +0200 Subject: [PATCH 42/66] Show end timestamp for pdf snapshots --- .../pdf-writer/templates/full-snapshot-report.pug | 3 +++ 1 file changed, 3 insertions(+) diff --git a/workers/loc.api/generate-report-file/pdf-writer/templates/full-snapshot-report.pug b/workers/loc.api/generate-report-file/pdf-writer/templates/full-snapshot-report.pug index 44f7e6509..5bb6963e3 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/templates/full-snapshot-report.pug +++ b/workers/loc.api/generate-report-file/pdf-writer/templates/full-snapshot-report.pug @@ -1,5 +1,8 @@ extends /node_modules/bfx-report/workers/loc.api/generate-report-file/pdf-writer/templates/base.pug +block prepend header + - const hasOnlyEndTimestamp = true + block content - const data = Array.isArray(apiData) ? apiData[0] : apiData ?? {} From e2b41666826625f880f014e730c864962c55b985 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 6 Feb 2024 12:02:50 +0200 Subject: [PATCH 43/66] Add translations for pdf full-tax-report --- .../generate-report-file/pdf-writer/translations.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/workers/loc.api/generate-report-file/pdf-writer/translations.yml b/workers/loc.api/generate-report-file/pdf-writer/translations.yml index 31834a937..30cc29feb 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/translations.yml +++ b/workers/loc.api/generate-report-file/pdf-writer/translations.yml @@ -14,3 +14,12 @@ en: ru: template: startingPositionsSnapshot: Снимок стартовых позиций + endingPositionsSnapshot: Снимок конечных позиций + finalState: Конечное состояние + startingPeriodBalances: Остатки на начало периода + movementsDetails: Детали движений + endingPeriodBalances: Остатки на конец периода + positions: Позиции + wallets: Кошельки + positionsTickers: Тикеры позиций + walletsTickers: Тикеры кошельков From bbdece52ade3ecba009909910e851a91e45c87cd Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 8 Feb 2024 17:55:10 +0200 Subject: [PATCH 44/66] Add process states for pdf creation under electron --- workers/loc.api/process.message.manager/process.states.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/workers/loc.api/process.message.manager/process.states.js b/workers/loc.api/process.message.manager/process.states.js index 2b548f74a..4abfba0a6 100644 --- a/workers/loc.api/process.message.manager/process.states.js +++ b/workers/loc.api/process.message.manager/process.states.js @@ -11,5 +11,8 @@ module.exports = { REQUEST_GET_BACKUP_FILES_METADATA: 'request:get-backup-files-metadata', - REQUEST_UPDATE_USERS_SYNC_ON_STARTUP_REQUIRED_STATE: 'request:update-users-sync-on-startup-required-state' + REQUEST_UPDATE_USERS_SYNC_ON_STARTUP_REQUIRED_STATE: 'request:update-users-sync-on-startup-required-state', + + CREATED_PDF_BUFFER: 'response:created-pdf-buffer', + ERROR_PDF_CREATION: 'error:pdf-creation' } From 4f1159e862909803f7eb3a20e8afb7dc1ce3b242 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 8 Feb 2024 17:56:25 +0200 Subject: [PATCH 45/66] Add process message for pdf creation under electron --- workers/loc.api/process.message.manager/process.messages.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/workers/loc.api/process.message.manager/process.messages.js b/workers/loc.api/process.message.manager/process.messages.js index 4ac7fc5de..063701311 100644 --- a/workers/loc.api/process.message.manager/process.messages.js +++ b/workers/loc.api/process.message.manager/process.messages.js @@ -28,5 +28,7 @@ module.exports = { RESPONSE_GET_BACKUP_FILES_METADATA: 'response:get-backup-files-metadata', - RESPONSE_UPDATE_USERS_SYNC_ON_STARTUP_REQUIRED_STATE: 'response:update-users-sync-on-startup-required-state' + RESPONSE_UPDATE_USERS_SYNC_ON_STARTUP_REQUIRED_STATE: 'response:update-users-sync-on-startup-required-state', + + CREATE_PDF: 'request:create-pdf' } From 87a0d1186ef124c36f999e4f65dd9524031d5902 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 8 Feb 2024 18:09:48 +0200 Subject: [PATCH 46/66] Add ability to request pdf creation under electron --- .../generate-report-file/pdf-writer/index.js | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/workers/loc.api/generate-report-file/pdf-writer/index.js b/workers/loc.api/generate-report-file/pdf-writer/index.js index f3d6f0ced..5c2026877 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/index.js +++ b/workers/loc.api/generate-report-file/pdf-writer/index.js @@ -1,6 +1,9 @@ 'use strict' const path = require('path') +const argv = require('yargs').argv +const { v4: uuidv4 } = require('uuid') + const pdf = require('html-pdf') const MainPdfWriter = require( @@ -13,6 +16,8 @@ class PdfWriter extends MainPdfWriter { constructor (...deps) { super(...deps) + this.isElectronjsEnv = argv.isElectronjsEnv + this.addTranslations(this.loadTranslations( path.join(__dirname, 'translations.yml') )) @@ -33,6 +38,14 @@ class PdfWriter extends MainPdfWriter { orientation = 'Letter' } = args ?? {} + if (this.isElectronjsEnv) { + return await this.createPDFBufferUnderElectron({ + template, + format, + orientation + }) + } + return await new Promise((resolve, reject) => { pdf.create(template, { format, @@ -47,6 +60,36 @@ class PdfWriter extends MainPdfWriter { }) }) } + + // TODO: Need to rework with using ProcessMessageManager + async createPDFBufferUnderElectron (args) { + const uid = `uid-${uuidv4()}-${Date.now()}` + + return await new Promise((resolve, reject) => { + process.on('message', (mess) => { + if ( + mess?.state !== 'response:created-pdf-buffer' && + mess?.state !== 'error:pdf-creation' && + mess?.data?.uid !== uid + ) { + return + } + if (mess?.state === 'error:pdf-creation') { + reject(new Error(mess?.data?.error)) + } + + resolve(Buffer.from(mess?.data?.buffer)) + }) + + process.send({ + state: 'request:create-pdf', + data: { + ...args, + uid + } + }) + }) + } } module.exports = PdfWriter From 2283b8a1347214110fce6e05df0302f440c8ecb2 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 9 Feb 2024 10:36:06 +0200 Subject: [PATCH 47/66] Add state check handler to process message manager --- workers/loc.api/process.message.manager/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/workers/loc.api/process.message.manager/index.js b/workers/loc.api/process.message.manager/index.js index f8d83cf81..0fa7f453d 100644 --- a/workers/loc.api/process.message.manager/index.js +++ b/workers/loc.api/process.message.manager/index.js @@ -92,7 +92,7 @@ class ProcessMessageManager { return onMessage(...args, this.logger) } - addStateToWait (state) { + addStateToWait (state, checkHandler) { if (!this.SET_PROCESS_STATES.has(state)) { throw new ProcessStateSendingError() } @@ -107,7 +107,13 @@ class ProcessMessageManager { resolve: () => {}, reject: () => {}, close: (err, data) => { - if (job.hasClosed) { + if ( + job.hasClosed || + ( + typeof checkHandler === 'function' && + !checkHandler({ err, data }) + ) + ) { return } if (Number.isInteger(job.index)) { From 77a4fdc6cdac4ae2fa1750ba2bdff99f60ee0551 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 9 Feb 2024 10:39:33 +0200 Subject: [PATCH 48/66] Rework create-pdf-buff under electron to use process mess manager --- .../generate-report-file/pdf-writer/index.js | 66 ++++++++++++------- .../process.messages.js | 2 +- .../process.message.manager/process.states.js | 3 +- 3 files changed, 43 insertions(+), 28 deletions(-) diff --git a/workers/loc.api/generate-report-file/pdf-writer/index.js b/workers/loc.api/generate-report-file/pdf-writer/index.js index 5c2026877..e81ee03d4 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/index.js +++ b/workers/loc.api/generate-report-file/pdf-writer/index.js @@ -12,9 +12,28 @@ const MainPdfWriter = require( const TEMPLATE_FILE_NAMES = require('./template-file-names') +const { decorateInjectable } = require('../../di/utils') + +const depsTypes = (TYPES) => [ + TYPES.ROOT_FOLDER_PATH, + TYPES.HasGrcService, + TYPES.GrcBfxReq, + TYPES.ProcessMessageManager +] class PdfWriter extends MainPdfWriter { - constructor (...deps) { - super(...deps) + constructor ( + rootFolderPath, + hasGrcService, + grcBfxReq, + processMessageManager + ) { + super( + rootFolderPath, + hasGrcService, + grcBfxReq + ) + + this.processMessageManager = processMessageManager this.isElectronjsEnv = argv.isElectronjsEnv @@ -61,35 +80,32 @@ class PdfWriter extends MainPdfWriter { }) } - // TODO: Need to rework with using ProcessMessageManager async createPDFBufferUnderElectron (args) { const uid = `uid-${uuidv4()}-${Date.now()}` - return await new Promise((resolve, reject) => { - process.on('message', (mess) => { - if ( - mess?.state !== 'response:created-pdf-buffer' && - mess?.state !== 'error:pdf-creation' && - mess?.data?.uid !== uid - ) { - return - } - if (mess?.state === 'error:pdf-creation') { - reject(new Error(mess?.data?.error)) - } + const { promise } = this.processMessageManager.addStateToWait( + this.processMessageManager.PROCESS_STATES.RESPONSE_PDF_CREATION, + ({ data }) => data?.uid === uid + ) + this.processMessageManager.sendState( + this.processMessageManager.PROCESS_MESSAGES.REQUEST_PDF_CREATION, + { ...args, uid } + ) - resolve(Buffer.from(mess?.data?.buffer)) - }) + const { + err, + buffer + } = (await promise) ?? {} - process.send({ - state: 'request:create-pdf', - data: { - ...args, - uid - } - }) - }) + if (err) { + // TODO: Need to add custom error class + throw new Error(err) + } + + return Buffer.from(buffer) } } +decorateInjectable(PdfWriter, depsTypes) + module.exports = PdfWriter diff --git a/workers/loc.api/process.message.manager/process.messages.js b/workers/loc.api/process.message.manager/process.messages.js index 063701311..07aaad4e3 100644 --- a/workers/loc.api/process.message.manager/process.messages.js +++ b/workers/loc.api/process.message.manager/process.messages.js @@ -30,5 +30,5 @@ module.exports = { RESPONSE_UPDATE_USERS_SYNC_ON_STARTUP_REQUIRED_STATE: 'response:update-users-sync-on-startup-required-state', - CREATE_PDF: 'request:create-pdf' + REQUEST_PDF_CREATION: 'request:pdf-creation' } diff --git a/workers/loc.api/process.message.manager/process.states.js b/workers/loc.api/process.message.manager/process.states.js index 4abfba0a6..348f33f9c 100644 --- a/workers/loc.api/process.message.manager/process.states.js +++ b/workers/loc.api/process.message.manager/process.states.js @@ -13,6 +13,5 @@ module.exports = { REQUEST_UPDATE_USERS_SYNC_ON_STARTUP_REQUIRED_STATE: 'request:update-users-sync-on-startup-required-state', - CREATED_PDF_BUFFER: 'response:created-pdf-buffer', - ERROR_PDF_CREATION: 'error:pdf-creation' + RESPONSE_PDF_CREATION: 'response:pdf-creation' } From f44b61d5cd47c47dc28cd29814a962b893fd3cfc Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 9 Feb 2024 12:48:24 +0200 Subject: [PATCH 49/66] Create pdf using temp file storage under electron --- .../generate-report-file/pdf-writer/index.js | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/workers/loc.api/generate-report-file/pdf-writer/index.js b/workers/loc.api/generate-report-file/pdf-writer/index.js index e81ee03d4..25982022b 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/index.js +++ b/workers/loc.api/generate-report-file/pdf-writer/index.js @@ -1,5 +1,6 @@ 'use strict' +const fs = require('fs/promises') const path = require('path') const argv = require('yargs').argv const { v4: uuidv4 } = require('uuid') @@ -9,6 +10,9 @@ const pdf = require('html-pdf') const MainPdfWriter = require( 'bfx-report/workers/loc.api/generate-report-file/pdf-writer' ) +const { + createUniqueFileName +} = require('bfx-report/workers/loc.api/queue/helpers/utils') const TEMPLATE_FILE_NAMES = require('./template-file-names') @@ -83,18 +87,30 @@ class PdfWriter extends MainPdfWriter { async createPDFBufferUnderElectron (args) { const uid = `uid-${uuidv4()}-${Date.now()}` + const uniqueFileName = await createUniqueFileName( + this.rootFolderPath, + { isHTMLRequired: true } + ) + await fs.writeFile(uniqueFileName, args?.template) + const { promise } = this.processMessageManager.addStateToWait( this.processMessageManager.PROCESS_STATES.RESPONSE_PDF_CREATION, ({ data }) => data?.uid === uid ) this.processMessageManager.sendState( this.processMessageManager.PROCESS_MESSAGES.REQUEST_PDF_CREATION, - { ...args, uid } + { + templateFilePath: uniqueFileName, + format: args?.format, + orientation: args?.orientation, + uid + } ) const { err, - buffer + buffer, + pdfFilePath } = (await promise) ?? {} if (err) { @@ -102,6 +118,16 @@ class PdfWriter extends MainPdfWriter { throw new Error(err) } + if ( + pdfFilePath && + typeof pdfFilePath === 'string' + ) { + const fileBuffer = await fs.readFile(pdfFilePath) + await fs.rm(pdfFilePath, { force: true, maxRetries: 3 }) + + return fileBuffer + } + return Buffer.from(buffer) } } From 68548dc67fdce94f6879ea8eb1bf592992877894 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 12 Feb 2024 10:24:11 +0200 Subject: [PATCH 50/66] Add custom error class PDFBufferUnderElectronCreationError --- workers/loc.api/errors/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/workers/loc.api/errors/index.js b/workers/loc.api/errors/index.js index 6cd45c546..a47f70b14 100644 --- a/workers/loc.api/errors/index.js +++ b/workers/loc.api/errors/index.js @@ -248,6 +248,17 @@ class AuthTokenTTLSettingError extends ArgsParamsError { } } +class PDFBufferUnderElectronCreationError extends BaseError { + constructor (electronErrStr) { + const _args = getErrorArgs( + { data: { electronErrStr } }, + 'ERR_PDF_BUFFER_UNDER_ELECTRON_HAS_NOT_BEEN_CREATED' + ) + + super(_args) + } +} + module.exports = { BaseError, CollSyncPermissionError, @@ -284,5 +295,6 @@ module.exports = { LastSyncedInfoGettingError, SyncInfoUpdatingError, AuthTokenGenerationError, - AuthTokenTTLSettingError + AuthTokenTTLSettingError, + PDFBufferUnderElectronCreationError } From 01c2c92b57e98ffa40f6e85dda4e77110e0bf1b9 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 12 Feb 2024 10:25:36 +0200 Subject: [PATCH 51/66] Use custom error class PDFBufferUnderElectronCreationError --- workers/loc.api/generate-report-file/pdf-writer/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/workers/loc.api/generate-report-file/pdf-writer/index.js b/workers/loc.api/generate-report-file/pdf-writer/index.js index 25982022b..a73eca63b 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/index.js +++ b/workers/loc.api/generate-report-file/pdf-writer/index.js @@ -15,6 +15,9 @@ const { } = require('bfx-report/workers/loc.api/queue/helpers/utils') const TEMPLATE_FILE_NAMES = require('./template-file-names') +const { + PDFBufferUnderElectronCreationError +} = require('../../errors') const { decorateInjectable } = require('../../di/utils') @@ -114,8 +117,7 @@ class PdfWriter extends MainPdfWriter { } = (await promise) ?? {} if (err) { - // TODO: Need to add custom error class - throw new Error(err) + throw new PDFBufferUnderElectronCreationError(err) } if ( From 4cb70ea45b0392125b97faf09c3c16a193800753 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 14 Feb 2024 11:56:43 +0200 Subject: [PATCH 52/66] Provide opt to require pdf for base api test cases --- .../api-sync-mode-sqlite-test-cases.js | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/test/test-cases/api-sync-mode-sqlite-test-cases.js b/test/test-cases/api-sync-mode-sqlite-test-cases.js index 377436552..62f3a2750 100644 --- a/test/test-cases/api-sync-mode-sqlite-test-cases.js +++ b/test/test-cases/api-sync-mode-sqlite-test-cases.js @@ -27,7 +27,8 @@ module.exports = ( }, date, end, - start + start, + isPDFRequired } = params const auth = { token: '' } @@ -2734,6 +2735,7 @@ module.exports = ( method: 'getMultipleFile', params: { email, + isPDFRequired, multiExport: [ { method: 'getTradesFile', @@ -2771,6 +2773,7 @@ module.exports = ( method: 'getMultipleFile', params: { email, + isPDFRequired, multiExport: [ { symbol: ['tBTCUSD', 'tETHUSD'], @@ -2806,6 +2809,7 @@ module.exports = ( auth, method: 'getTickersHistoryFile', params: { + isPDFRequired, symbol: 'BTC', end, start, @@ -2833,6 +2837,7 @@ module.exports = ( auth, method: 'getPositionsHistoryFile', params: { + isPDFRequired, symbol: 'tBTCUSD', end, start, @@ -2860,6 +2865,7 @@ module.exports = ( auth, method: 'getPositionsAuditFile', params: { + isPDFRequired, id: [12345], symbol: 'tBTCUSD', end, @@ -2888,6 +2894,7 @@ module.exports = ( auth, method: 'getWalletsFile', params: { + isPDFRequired, end, email }, @@ -2912,6 +2919,7 @@ module.exports = ( auth, method: 'getFundingOfferHistoryFile', params: { + isPDFRequired, symbol: 'fUSD', end, start, @@ -2940,6 +2948,7 @@ module.exports = ( auth, method: 'getFundingLoanHistoryFile', params: { + isPDFRequired, symbol: 'fUSD', end, start, @@ -2967,6 +2976,7 @@ module.exports = ( auth, method: 'getFundingCreditHistoryFile', params: { + isPDFRequired, symbol: 'fUSD', end, start, @@ -2994,6 +3004,7 @@ module.exports = ( auth, method: 'getLedgersFile', params: { + isPDFRequired, symbol: ['BTC'], end, start, @@ -3021,6 +3032,7 @@ module.exports = ( auth, method: 'getPayInvoiceListFile', params: { + isPDFRequired, end, start, limit: 100, @@ -3048,6 +3060,7 @@ module.exports = ( auth, method: 'getTradesFile', params: { + isPDFRequired, symbol: ['tBTCUSD', 'tETHUSD'], end, start, @@ -3075,6 +3088,7 @@ module.exports = ( auth, method: 'getFundingTradesFile', params: { + isPDFRequired, symbol: ['fBTC', 'fETH'], end, start, @@ -3102,6 +3116,7 @@ module.exports = ( auth, method: 'getPublicTradesFile', params: { + isPDFRequired, symbol: 'tBTCUSD', end, start: (new Date()).setDate(date.getDate() - 27), @@ -3127,6 +3142,7 @@ module.exports = ( auth, method: 'getPublicTradesFile', params: { + isPDFRequired, symbol: 'tBTCUSD', end, start, @@ -3156,6 +3172,7 @@ module.exports = ( auth, method: 'getPublicTradesFile', params: { + isPDFRequired, symbol: ['tBTCUSD', 'tETHUSD'], end, start, @@ -3188,6 +3205,7 @@ module.exports = ( auth, method: 'getStatusMessagesFile', params: { + isPDFRequired, symbol: ['tBTCF0:USTF0'], timezone: 'America/Los_Angeles', email @@ -3213,6 +3231,7 @@ module.exports = ( auth, method: 'getCandlesFile', params: { + isPDFRequired, symbol: 'tBTCUSD', timeframe: '12h', end, @@ -3242,6 +3261,7 @@ module.exports = ( auth, method: 'getOrderTradesFile', params: { + isPDFRequired, id: 12345, symbol: 'tBTCUSD', end, @@ -3271,6 +3291,7 @@ module.exports = ( auth, method: 'getOrdersFile', params: { + isPDFRequired, symbol: 'tBTCUSD', end, start, @@ -3297,6 +3318,7 @@ module.exports = ( auth, method: 'getActiveOrdersFile', params: { + isPDFRequired, email }, id: 5 @@ -3320,6 +3342,7 @@ module.exports = ( auth, method: 'getMovementsFile', params: { + isPDFRequired, symbol: 'BTC', end, start, @@ -3346,6 +3369,7 @@ module.exports = ( auth, method: 'getMovementsFile', params: { + isPDFRequired, symbol: 'BTC', end, start, @@ -3373,6 +3397,7 @@ module.exports = ( auth, method: 'getMovementsFile', params: { + isPDFRequired, symbol: 'BTC', end, start, @@ -3400,6 +3425,7 @@ module.exports = ( auth, method: 'getLoginsFile', params: { + isPDFRequired, end, start, limit: 1000, @@ -3426,6 +3452,7 @@ module.exports = ( auth, method: 'getChangeLogsFile', params: { + isPDFRequired, end, start, limit: 1000, @@ -3448,6 +3475,7 @@ module.exports = ( .send({ method: 'getLedgersFile', params: { + isPDFRequired, symbol: 'BTC', end, start, @@ -3486,6 +3514,7 @@ module.exports = ( auth, method: 'getLedgersFile', params: { + isPDFRequired, symbol: 'BTC', end, start, From 5d9178c6cb0e775202b8716b42aa00fa31063b91 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 14 Feb 2024 11:57:12 +0200 Subject: [PATCH 53/66] Provide opt to require pdf for additional api test cases --- ...itional-api-sync-mode-sqlite-test-cases.js | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/test-cases/additional-api-sync-mode-sqlite-test-cases.js b/test/test-cases/additional-api-sync-mode-sqlite-test-cases.js index c8fd83f7d..768dc5d2e 100644 --- a/test/test-cases/additional-api-sync-mode-sqlite-test-cases.js +++ b/test/test-cases/additional-api-sync-mode-sqlite-test-cases.js @@ -30,7 +30,8 @@ module.exports = ( isSubAccount }, end, - start + start, + isPDFRequired } = params const auth = { token: '' } @@ -637,6 +638,7 @@ module.exports = ( method: 'getMultipleFile', params: { email, + isPDFRequired, multiExport: [ { method: 'getTradesFile', @@ -675,6 +677,7 @@ module.exports = ( auth, method: 'getBalanceHistoryFile', params: { + isPDFRequired, end, start, timeframe: 'day', @@ -820,6 +823,7 @@ module.exports = ( auth, method: 'getWinLossFile', params: { + isPDFRequired, end, start, timeframe: 'day', @@ -846,6 +850,7 @@ module.exports = ( auth, method: 'getFullSnapshotReportFile', params: { + isPDFRequired, end, email }, @@ -870,6 +875,7 @@ module.exports = ( auth, method: 'getFullSnapshotReportFile', params: { + isPDFRequired, end }, id: 5 @@ -898,6 +904,7 @@ module.exports = ( auth, method: 'getPositionsSnapshotFile', params: { + isPDFRequired, end, email }, @@ -922,6 +929,7 @@ module.exports = ( auth, method: 'getFullTaxReportFile', params: { + isPDFRequired, end, start, email @@ -947,6 +955,7 @@ module.exports = ( auth, method: 'getFullTaxReportFile', params: { + isPDFRequired, end, start }, @@ -976,6 +985,7 @@ module.exports = ( auth, method: 'getFullTaxReportFile', params: { + isPDFRequired, end, start, isStartSnapshot: true @@ -1006,6 +1016,7 @@ module.exports = ( auth, method: 'getFullTaxReportFile', params: { + isPDFRequired, end, start, isEndSnapshot: true @@ -1036,6 +1047,7 @@ module.exports = ( auth, method: 'getTradedVolumeFile', params: { + isPDFRequired, end, start, timeframe: 'day', @@ -1062,6 +1074,7 @@ module.exports = ( auth, method: 'getTotalFeesReportFile', params: { + isPDFRequired, end, start, timeframe: 'day', @@ -1089,6 +1102,7 @@ module.exports = ( auth, method: 'getPerformingLoanFile', params: { + isPDFRequired, end, start, timeframe: 'day', @@ -1115,6 +1129,7 @@ module.exports = ( auth, method: 'getWinLossVSAccountBalanceFile', params: { + isPDFRequired, end, start, timeframe: 'day', @@ -1131,6 +1146,11 @@ module.exports = ( it('it should be successfully performed by the getWeightedAveragesReportFile method', async function () { this.timeout(60000) + // TODO: Wait for implementation of pdf template in the next release + if (isPDFRequired) { + this.skip() + } + const procPromise = queueToPromise(params.processorQueue) const aggrPromise = queueToPromise(params.aggregatorQueue) @@ -1141,6 +1161,7 @@ module.exports = ( auth, method: 'getWeightedAveragesReportFile', params: { + isPDFRequired, symbol: 'tBTCUSD', end, start, From 8c6f6b87f2d73dbf5ae48bd44067404b98a9c9e2 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 14 Feb 2024 12:03:12 +0200 Subject: [PATCH 54/66] Add pdf generation test coverage for base api --- test/1-api-sync-mode-sqlite.spec.js | 38 +++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/test/1-api-sync-mode-sqlite.spec.js b/test/1-api-sync-mode-sqlite.spec.js index 39cbb2151..555bc7779 100644 --- a/test/1-api-sync-mode-sqlite.spec.js +++ b/test/1-api-sync-mode-sqlite.spec.js @@ -106,10 +106,21 @@ describe('Sync mode API with SQLite', () => { }) describe('Use BFX API keys', () => { - signUpTestCase(agent, params) - apiSyncModeSqliteTestCases(agent, params) - signUpTestCase(agent, params) - removeUserTestCases(agent, params) + describe('CSV generation', () => { + params.isPDFRequired = false + signUpTestCase(agent, params) + apiSyncModeSqliteTestCases(agent, params) + signUpTestCase(agent, params) + removeUserTestCases(agent, params) + }) + + describe('PDF generation', () => { + params.isPDFRequired = true + signUpTestCase(agent, params) + apiSyncModeSqliteTestCases(agent, params) + signUpTestCase(agent, params) + removeUserTestCases(agent, params) + }) }) describe('Use BFX auth token', () => { @@ -120,9 +131,20 @@ describe('Sync mode API with SQLite', () => { await rmAllFiles(tempDirPath, ['README.md']) }) - signUpTestCase(agent, paramsWithAuthToken) - apiSyncModeSqliteTestCases(agent, paramsWithAuthToken) - signUpTestCase(agent, paramsWithAuthToken) - removeUserTestCases(agent, paramsWithAuthToken) + describe('CSV generation', () => { + paramsWithAuthToken.isPDFRequired = false + signUpTestCase(agent, paramsWithAuthToken) + apiSyncModeSqliteTestCases(agent, paramsWithAuthToken) + signUpTestCase(agent, paramsWithAuthToken) + removeUserTestCases(agent, paramsWithAuthToken) + }) + + describe('PDF generation', () => { + paramsWithAuthToken.isPDFRequired = true + signUpTestCase(agent, paramsWithAuthToken) + apiSyncModeSqliteTestCases(agent, paramsWithAuthToken) + signUpTestCase(agent, paramsWithAuthToken) + removeUserTestCases(agent, paramsWithAuthToken) + }) }) }) From a8af93603b1197aae2ada6a0c1faaf4a6680d0af Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 14 Feb 2024 12:03:36 +0200 Subject: [PATCH 55/66] Add pdf generation test coverage for additional api --- .../2-additional-api-sync-mode-sqlite.spec.js | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/test/2-additional-api-sync-mode-sqlite.spec.js b/test/2-additional-api-sync-mode-sqlite.spec.js index 640c6030e..1b862c12c 100644 --- a/test/2-additional-api-sync-mode-sqlite.spec.js +++ b/test/2-additional-api-sync-mode-sqlite.spec.js @@ -105,8 +105,17 @@ describe('Additional sync mode API with SQLite', () => { }) describe('Use BFX API keys', () => { - signUpTestCase(agent, params) - additionalApiSyncModeSqliteTestCases(agent, params) + describe('CSV generation', () => { + params.isPDFRequired = false + signUpTestCase(agent, params) + additionalApiSyncModeSqliteTestCases(agent, params) + }) + + describe('PDF generation', () => { + params.isPDFRequired = true + signUpTestCase(agent, params) + additionalApiSyncModeSqliteTestCases(agent, params) + }) }) describe('Use BFX auth token', () => { @@ -117,7 +126,16 @@ describe('Additional sync mode API with SQLite', () => { await rmAllFiles(tempDirPath, ['README.md']) }) - signUpTestCase(agent, paramsWithAuthToken) - additionalApiSyncModeSqliteTestCases(agent, paramsWithAuthToken) + describe('CSV generation', () => { + paramsWithAuthToken.isPDFRequired = false + signUpTestCase(agent, paramsWithAuthToken) + additionalApiSyncModeSqliteTestCases(agent, paramsWithAuthToken) + }) + + describe('PDF generation', () => { + paramsWithAuthToken.isPDFRequired = true + signUpTestCase(agent, paramsWithAuthToken) + additionalApiSyncModeSqliteTestCases(agent, paramsWithAuthToken) + }) }) }) From 153a75447e2b4c76b04a0114a44bbf3301d06fb8 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 14 Feb 2024 12:34:18 +0200 Subject: [PATCH 56/66] Add pdf generation test coverage for sub-account --- test/4-sub-account.spec.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/test/4-sub-account.spec.js b/test/4-sub-account.spec.js index 81ad912c7..b2bb493c2 100644 --- a/test/4-sub-account.spec.js +++ b/test/4-sub-account.spec.js @@ -536,14 +536,34 @@ describe('Sub-account', () => { } describe('Sync mode API', () => { - before(beforeFn) + describe('CSV generation', () => { + before(beforeFn) + + params.isPDFRequired = false + apiSyncModeSqliteTestCases(agent, params) + }) - apiSyncModeSqliteTestCases(agent, params) + describe('PDF generation', () => { + before(beforeFn) + + params.isPDFRequired = true + apiSyncModeSqliteTestCases(agent, params) + }) }) describe('Additional sync mode API', () => { - before(beforeFn) + describe('CSV generation', () => { + before(beforeFn) + + params.isPDFRequired = false + additionalApiSyncModeSqliteTestCases(agent, params) + }) - additionalApiSyncModeSqliteTestCases(agent, params) + describe('PDF generation', () => { + before(beforeFn) + + params.isPDFRequired = true + additionalApiSyncModeSqliteTestCases(agent, params) + }) }) describe('Removing sub-account API', () => { before(beforeFn) From 8eb02049faa3cd35ece66892071f2716a76d72aa Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 15 Feb 2024 11:16:26 +0200 Subject: [PATCH 57/66] Fix MaxListenersExceededWarning for ipc when pdf process --- workers/loc.api/process.message.manager/index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/workers/loc.api/process.message.manager/index.js b/workers/loc.api/process.message.manager/index.js index 0fa7f453d..a528c9ae4 100644 --- a/workers/loc.api/process.message.manager/index.js +++ b/workers/loc.api/process.message.manager/index.js @@ -40,6 +40,9 @@ class ProcessMessageManager { ) this._mainHandler = null + + this.isInited = false + this.areDepsInjected = false } setDeps ( @@ -47,12 +50,22 @@ class ProcessMessageManager { dbBackupManager, recalcSubAccountLedgersBalancesHook ) { + if (this.areDepsInjected) { + return + } + this.dao = dao this.dbBackupManager = dbBackupManager this.recalcSubAccountLedgersBalancesHook = recalcSubAccountLedgersBalancesHook + + this.areDepsInjected = true } init () { + if (this.isInited) { + return this + } + this._mainHandler = onMessage(async (err, state, data) => { if (!this.SET_PROCESS_STATES.has(state)) { return @@ -71,11 +84,14 @@ class ProcessMessageManager { this._processQueuePromises(state, err, data) }, this.logger) + this.isInited = true + return this } stop () { offMessage(this._mainHandler) + this.isInited = false } sendState (state, data) { From 212b4232dec3ab46fa2e390acb55916bc7151869 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 20 Feb 2024 12:32:19 +0200 Subject: [PATCH 58/66] Stop auth token refresh interval if auth error --- workers/loc.api/sync/authenticator/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/workers/loc.api/sync/authenticator/index.js b/workers/loc.api/sync/authenticator/index.js index dbe81c3fe..79f98a06d 100644 --- a/workers/loc.api/sync/authenticator/index.js +++ b/workers/loc.api/sync/authenticator/index.js @@ -7,7 +7,8 @@ const { ArgsParamsError } = require('bfx-report/workers/loc.api/errors') const { - isENetError + isENetError, + isAuthError } = require('bfx-report/workers/loc.api/helpers') const { serializeVal } = require('../dao/helpers') @@ -1385,6 +1386,10 @@ class Authenticator { authToken: prevAuthToken }) } catch (err) { + if (isAuthError(err)) { + clearInterval(newAuthTokenRefreshInterval) + } + this.logger.debug(err) await this.wsEventEmitterFactory() From 658888436ba349328fc6a8600e48977e36076af0 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 29 Feb 2024 09:03:10 +0400 Subject: [PATCH 59/66] Set header/footer height into html-pdf lib --- .../generate-report-file/pdf-writer/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/workers/loc.api/generate-report-file/pdf-writer/index.js b/workers/loc.api/generate-report-file/pdf-writer/index.js index a73eca63b..ce787fa92 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/index.js +++ b/workers/loc.api/generate-report-file/pdf-writer/index.js @@ -61,7 +61,9 @@ class PdfWriter extends MainPdfWriter { const { template = 'No data', format = 'portrait', - orientation = 'Letter' + orientation = 'Letter', + headerHeight = '70mm', + footerHeight = '28mm' } = args ?? {} if (this.isElectronjsEnv) { @@ -72,8 +74,18 @@ class PdfWriter extends MainPdfWriter { }) } + const headerOpt = headerHeight + ? { header: { height: headerHeight } } + : {} + const footerOpt = footerHeight + ? { footer: { height: footerHeight } } + : {} + return await new Promise((resolve, reject) => { pdf.create(template, { + ...headerOpt, + ...footerOpt, + format, orientation, type: 'pdf', From 5e14894aeb82723755efab5e1d061dc4db2e81f1 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 29 Feb 2024 09:03:40 +0400 Subject: [PATCH 60/66] Normalize font size in templates --- .../pdf-writer/templates/full-snapshot-report.pug | 4 ++-- .../pdf-writer/templates/full-tax-report.pug | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/workers/loc.api/generate-report-file/pdf-writer/templates/full-snapshot-report.pug b/workers/loc.api/generate-report-file/pdf-writer/templates/full-snapshot-report.pug index 5bb6963e3..adbfd50ac 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/templates/full-snapshot-report.pug +++ b/workers/loc.api/generate-report-file/pdf-writer/templates/full-snapshot-report.pug @@ -18,7 +18,7 @@ block content :translate(prop='template.positions') Positions - ul.responsive-table.sm.no-margin-bottom + ul.responsive-table.no-margin-bottom li.table-header each columnVal, columnKey in reportColumns.positionsSnapshot .col #{columnVal} @@ -27,7 +27,7 @@ block content each columnVal, columnKey in reportColumns.positionsSnapshot .col #{dataItem[columnKey]} - ul.responsive-table.sm.width-by-content + ul.responsive-table.width-by-content li.table-header each columnVal, columnKey in reportColumns.positionsTotalPlUsd .col #{columnVal} diff --git a/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug index 75051747c..3c524322b 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug +++ b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug @@ -15,7 +15,7 @@ block content :translate(prop='template.startingPositionsSnapshot') Starting positions snapshot - ul.responsive-table.sm + ul.responsive-table li.table-header each columnVal, columnKey in reportColumns.positionsSnapshot .col #{columnVal} @@ -28,7 +28,7 @@ block content :translate(prop='template.endingPositionsSnapshot') Ending positions snapshot - ul.responsive-table.sm + ul.responsive-table li.table-header each columnVal, columnKey in reportColumns.positionsSnapshot .col #{columnVal} @@ -57,7 +57,7 @@ block content :translate(prop='template.movementsDetails') Movements details - ul.responsive-table.sm.no-margin-bottom + ul.responsive-table.no-margin-bottom li.table-header each columnVal, columnKey in reportColumns.movements .col #{columnVal} @@ -66,7 +66,7 @@ block content each columnVal, columnKey in reportColumns.movements .col #{dataItem[columnKey]} - ul.responsive-table.sm.width-by-content + ul.responsive-table.width-by-content li.table-header each columnVal, columnKey in reportColumns.movementsTotalAmount .col #{columnVal} From 92bfc3fdc8666398464071d0845711b83829f053 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 29 Feb 2024 14:20:49 +0400 Subject: [PATCH 61/66] Fix header height consideration --- workers/loc.api/generate-report-file/pdf-writer/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workers/loc.api/generate-report-file/pdf-writer/index.js b/workers/loc.api/generate-report-file/pdf-writer/index.js index ce787fa92..efe84f446 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/index.js +++ b/workers/loc.api/generate-report-file/pdf-writer/index.js @@ -62,7 +62,7 @@ class PdfWriter extends MainPdfWriter { template = 'No data', format = 'portrait', orientation = 'Letter', - headerHeight = '70mm', + headerHeight = '54mm', footerHeight = '28mm' } = args ?? {} From 5a7507841a2c81b58d54d1f22f69d4421b835b11 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 1 Mar 2024 09:47:26 +0200 Subject: [PATCH 62/66] Improve statement details content placing --- workers/loc.api/generate-report-file/pdf-writer/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workers/loc.api/generate-report-file/pdf-writer/index.js b/workers/loc.api/generate-report-file/pdf-writer/index.js index efe84f446..90bf60cd7 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/index.js +++ b/workers/loc.api/generate-report-file/pdf-writer/index.js @@ -62,7 +62,7 @@ class PdfWriter extends MainPdfWriter { template = 'No data', format = 'portrait', orientation = 'Letter', - headerHeight = '54mm', + headerHeight = '65mm', footerHeight = '28mm' } = args ?? {} From 9d4fa4c8470aeb66ea262de5977ca8c5b0b715c9 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 5 Mar 2024 15:23:08 +0200 Subject: [PATCH 63/66] Set 90sec timeout for html-pdf lib --- workers/loc.api/generate-report-file/pdf-writer/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/workers/loc.api/generate-report-file/pdf-writer/index.js b/workers/loc.api/generate-report-file/pdf-writer/index.js index 90bf60cd7..2695eda86 100644 --- a/workers/loc.api/generate-report-file/pdf-writer/index.js +++ b/workers/loc.api/generate-report-file/pdf-writer/index.js @@ -89,6 +89,7 @@ class PdfWriter extends MainPdfWriter { format, orientation, type: 'pdf', + timeout: 90000, childProcessOptions: { env: { OPENSSL_CONF: '/dev/null' } } From 7acfa883e2636445f7d05928f468911949d52373 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 6 Mar 2024 07:07:00 +0200 Subject: [PATCH 64/66] Fix c cyrillic letter --- config/service.report.json.example | 2 +- .../api-sync-mode-sqlite-test-cases.js | 8 +-- workers/loc.api/di/app.deps.js | 8 +-- workers/loc.api/di/types.js | 2 +- workers/loc.api/helpers/schema.js | 12 ++-- workers/loc.api/service.report.framework.js | 62 +++++++++---------- workers/loc.api/sync/colls.accessors/index.js | 4 +- .../public.colls.conf.accessors.js | 20 +++--- .../sync/data.inserter/data.checker/index.js | 6 +- 9 files changed, 62 insertions(+), 62 deletions(-) diff --git a/config/service.report.json.example b/config/service.report.json.example index 02cd17d8c..5dc3959d2 100644 --- a/config/service.report.json.example +++ b/config/service.report.json.example @@ -15,7 +15,7 @@ }, "isSpamRestrictionMode": true, "isAddedUniqueEndingToReportFileName": true, - "isСompress": true, + "isCompress": true, "isLoggerDisabled": false, "dbDriver": "better-sqlite", "verboseSql": false, diff --git a/test/test-cases/api-sync-mode-sqlite-test-cases.js b/test/test-cases/api-sync-mode-sqlite-test-cases.js index 62f3a2750..ae03d76f5 100644 --- a/test/test-cases/api-sync-mode-sqlite-test-cases.js +++ b/test/test-cases/api-sync-mode-sqlite-test-cases.js @@ -910,7 +910,7 @@ module.exports = ( assert.propertyVal(res.body.result[0], 'start', start) }) - it('it should be successfully performed by the editAllPublicСollsСonfs method', async function () { + it('it should be successfully performed by the editAllPublicCollsConfs method', async function () { this.timeout(5000) const res = await agent @@ -918,7 +918,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'editAllPublicСollsСonfs', + method: 'editAllPublicCollsConfs', params: { publicTradesConf: [ { @@ -967,7 +967,7 @@ module.exports = ( getSyncProgressTestCase(agent, { basePath, auth }) - it('it should be successfully performed by the getAllPublicСollsСonfs method', async function () { + it('it should be successfully performed by the getAllPublicCollsConfs method', async function () { this.timeout(5000) const res = await agent @@ -975,7 +975,7 @@ module.exports = ( .type('json') .send({ auth, - method: 'getAllPublicСollsСonfs', + method: 'getAllPublicCollsConfs', id: 5 }) .expect('Content-Type', /json/) diff --git a/workers/loc.api/di/app.deps.js b/workers/loc.api/di/app.deps.js index 9ef21913e..db53474f0 100644 --- a/workers/loc.api/di/app.deps.js +++ b/workers/loc.api/di/app.deps.js @@ -73,7 +73,7 @@ const RecalcSubAccountLedgersBalancesHook = require( ) const BetterSqliteDAO = require('../sync/dao/dao.better.sqlite') const { - PublicСollsСonfAccessors + PublicCollsConfAccessors } = require('../sync/colls.accessors') const Movements = require('../sync/movements') const WinLossVSAccountBalance = require('../sync/win.loss.vs.account.balance') @@ -143,7 +143,7 @@ module.exports = ({ ['_progress', TYPES.Progress], ['_syncSchema', TYPES.SyncSchema], ['_dao', TYPES.DAO], - ['_publicСollsСonfAccessors', TYPES.PublicСollsСonfAccessors], + ['_publicCollsConfAccessors', TYPES.PublicCollsConfAccessors], ['_wallets', TYPES.Wallets], ['_balanceHistory', TYPES.BalanceHistory], ['_winLoss', TYPES.WinLoss], @@ -216,8 +216,8 @@ module.exports = ({ bind(TYPES.WSEventEmitter) .to(WSEventEmitter) .inSingletonScope() - bind(TYPES.PublicСollsСonfAccessors) - .to(PublicСollsСonfAccessors) + bind(TYPES.PublicCollsConfAccessors) + .to(PublicCollsConfAccessors) .inSingletonScope() bind(TYPES.Progress) .to(Progress) diff --git a/workers/loc.api/di/types.js b/workers/loc.api/di/types.js index 6d4fca304..ab72b5cd5 100644 --- a/workers/loc.api/di/types.js +++ b/workers/loc.api/di/types.js @@ -28,7 +28,7 @@ module.exports = { DB: Symbol.for('DB'), DAO: Symbol.for('DAO'), BetterSqliteDAO: Symbol.for('BetterSqliteDAO'), - PublicСollsСonfAccessors: Symbol.for('PublicСollsСonfAccessors'), + PublicCollsConfAccessors: Symbol.for('PublicCollsConfAccessors'), SearchClosePriceAndSumAmount: Symbol.for('SearchClosePriceAndSumAmount'), Wallets: Symbol.for('Wallets'), BalanceHistory: Symbol.for('BalanceHistory'), diff --git a/workers/loc.api/helpers/schema.js b/workers/loc.api/helpers/schema.js index 5e1cb5e92..db81e9197 100644 --- a/workers/loc.api/helpers/schema.js +++ b/workers/loc.api/helpers/schema.js @@ -60,7 +60,7 @@ const paramsSchemaForCandlesApi = { } } -const paramsSchemaForEditAllPublicСollsСonfs = { +const paramsSchemaForEditAllPublicCollsConfs = { type: 'object', properties: { candlesConf: { @@ -111,7 +111,7 @@ const paramsSchemaForEditAllPublicСollsСonfs = { } } -const paramsSchemaForEditPublicСollsСonf = { +const paramsSchemaForEditPublicCollsConf = { type: ['array', 'object'], if: { type: 'array' @@ -136,7 +136,7 @@ const paramsSchemaForEditPublicСollsСonf = { } } -const paramsSchemaForEditCandlesСonf = { +const paramsSchemaForEditCandlesConf = { type: ['array', 'object'], if: { type: 'array' @@ -449,9 +449,9 @@ const paramsSchemaForCandlesFile = { } module.exports = { - paramsSchemaForEditAllPublicСollsСonfs, - paramsSchemaForEditPublicСollsСonf, - paramsSchemaForEditCandlesСonf, + paramsSchemaForEditAllPublicCollsConfs, + paramsSchemaForEditPublicCollsConf, + paramsSchemaForEditCandlesConf, paramsSchemaForCreateSubAccount, paramsSchemaForUpdateSubAccount, paramsSchemaForBalanceHistoryApi, diff --git a/workers/loc.api/service.report.framework.js b/workers/loc.api/service.report.framework.js index bea5a3ba1..057c195a8 100644 --- a/workers/loc.api/service.report.framework.js +++ b/workers/loc.api/service.report.framework.js @@ -465,38 +465,38 @@ class FrameworkReportService extends ReportService { getPublicTradesConf (space, args = {}, cb) { return this._privResponder(() => { - return this._publicСollsСonfAccessors - .getPublicСollsСonf('publicTradesConf', args) + return this._publicCollsConfAccessors + .getPublicCollsConf('publicTradesConf', args) }, 'getPublicTradesConf', args, cb) } getTickersHistoryConf (space, args = {}, cb) { return this._privResponder(() => { - return this._publicСollsСonfAccessors - .getPublicСollsСonf('tickersHistoryConf', args) + return this._publicCollsConfAccessors + .getPublicCollsConf('tickersHistoryConf', args) }, 'getTickersHistoryConf', args, cb) } getStatusMessagesConf (space, args = {}, cb) { return this._privResponder(() => { - return this._publicСollsСonfAccessors - .getPublicСollsСonf('statusMessagesConf', args) + return this._publicCollsConfAccessors + .getPublicCollsConf('statusMessagesConf', args) }, 'getStatusMessagesConf', args, cb) } getCandlesConf (space, args = {}, cb) { return this._privResponder(() => { - return this._publicСollsСonfAccessors - .getPublicСollsСonf('candlesConf', args) + return this._publicCollsConfAccessors + .getPublicCollsConf('candlesConf', args) }, 'getCandlesConf', args, cb) } editPublicTradesConf (space, args = {}, cb) { return this._privResponder(async () => { - checkParams(args, 'paramsSchemaForEditPublicСollsСonf') + checkParams(args, 'paramsSchemaForEditPublicCollsConf') - await this._publicСollsСonfAccessors - .editPublicСollsСonf('publicTradesConf', args) + await this._publicCollsConfAccessors + .editPublicCollsConf('publicTradesConf', args) if (isNotSyncRequired(args)) { return true @@ -514,10 +514,10 @@ class FrameworkReportService extends ReportService { editTickersHistoryConf (space, args = {}, cb) { return this._privResponder(async () => { - checkParams(args, 'paramsSchemaForEditPublicСollsСonf') + checkParams(args, 'paramsSchemaForEditPublicCollsConf') - await this._publicСollsСonfAccessors - .editPublicСollsСonf('tickersHistoryConf', args) + await this._publicCollsConfAccessors + .editPublicCollsConf('tickersHistoryConf', args) if (isNotSyncRequired(args)) { return true @@ -535,10 +535,10 @@ class FrameworkReportService extends ReportService { editStatusMessagesConf (space, args = {}, cb) { return this._privResponder(async () => { - checkParams(args, 'paramsSchemaForEditPublicСollsСonf') + checkParams(args, 'paramsSchemaForEditPublicCollsConf') - await this._publicСollsСonfAccessors - .editPublicСollsСonf('statusMessagesConf', args) + await this._publicCollsConfAccessors + .editPublicCollsConf('statusMessagesConf', args) if (isNotSyncRequired(args)) { return true @@ -556,10 +556,10 @@ class FrameworkReportService extends ReportService { editCandlesConf (space, args = {}, cb) { return this._privResponder(async () => { - checkParams(args, 'paramsSchemaForEditCandlesСonf') + checkParams(args, 'paramsSchemaForEditCandlesConf') - await this._publicСollsСonfAccessors - .editPublicСollsСonf('candlesConf', args) + await this._publicCollsConfAccessors + .editPublicCollsConf('candlesConf', args) if (isNotSyncRequired(args)) { return true @@ -575,12 +575,12 @@ class FrameworkReportService extends ReportService { }, 'editCandlesConf', args, cb) } - editAllPublicСollsСonfs (space, args = {}, cb) { + editAllPublicCollsConfs (space, args = {}, cb) { return this._privResponder(async () => { - checkParams(args, 'paramsSchemaForEditAllPublicСollsСonfs') + checkParams(args, 'paramsSchemaForEditAllPublicCollsConfs') - const syncedColls = await this._publicСollsСonfAccessors - .editAllPublicСollsСonfs(args) + const syncedColls = await this._publicCollsConfAccessors + .editAllPublicCollsConfs(args) if (isNotSyncRequired(args)) { return true @@ -596,10 +596,10 @@ class FrameworkReportService extends ReportService { }, 'editCandlesConf', args, cb) } - getAllPublicСollsСonfs (space, args = {}, cb) { + getAllPublicCollsConfs (space, args = {}, cb) { return this._privResponder(() => { - return this._publicСollsСonfAccessors - .getAllPublicСollsСonfs(args) + return this._publicCollsConfAccessors + .getAllPublicCollsConfs(args) }, 'editCandlesConf', args, cb) } @@ -879,7 +879,7 @@ class FrameworkReportService extends ReportService { checkParams(args, 'paramsSchemaForApi', ['symbol']) - return this._publicСollsСonfAccessors + return this._publicCollsConfAccessors .getPublicData( (args) => super.getTickersHistory(space, args), args, @@ -903,7 +903,7 @@ class FrameworkReportService extends ReportService { checkParams(args, 'paramsSchemaForPublicTrades', ['symbol']) - return this._publicСollsСonfAccessors + return this._publicCollsConfAccessors .getPublicData( (args) => super.getPublicTrades(space, args), args, @@ -949,7 +949,7 @@ class FrameworkReportService extends ReportService { } } - return this._publicСollsСonfAccessors + return this._publicCollsConfAccessors .getPublicData( (args) => super.getStatusMessages(space, args), preparedArgs, @@ -987,7 +987,7 @@ class FrameworkReportService extends ReportService { } } - return this._publicСollsСonfAccessors + return this._publicCollsConfAccessors .getPublicData( (args) => super.getCandles(space, args), argsWithParamsByDefault, diff --git a/workers/loc.api/sync/colls.accessors/index.js b/workers/loc.api/sync/colls.accessors/index.js index 89d26d162..fd6a311d6 100644 --- a/workers/loc.api/sync/colls.accessors/index.js +++ b/workers/loc.api/sync/colls.accessors/index.js @@ -1,9 +1,9 @@ 'use strict' -const PublicСollsСonfAccessors = require( +const PublicCollsConfAccessors = require( './public.colls.conf.accessors' ) module.exports = { - PublicСollsСonfAccessors + PublicCollsConfAccessors } diff --git a/workers/loc.api/sync/colls.accessors/public.colls.conf.accessors.js b/workers/loc.api/sync/colls.accessors/public.colls.conf.accessors.js index 64a2143c2..19f2efe52 100644 --- a/workers/loc.api/sync/colls.accessors/public.colls.conf.accessors.js +++ b/workers/loc.api/sync/colls.accessors/public.colls.conf.accessors.js @@ -26,7 +26,7 @@ const depsTypes = (TYPES) => [ TYPES.TABLES_NAMES, TYPES.Authenticator ] -class PublicСollsСonfAccessors { +class PublicCollsConfAccessors { constructor ( dao, TABLES_NAMES, @@ -68,7 +68,7 @@ class PublicСollsСonfAccessors { )) } - async editAllPublicСollsСonfs (args) { + async editAllPublicCollsConfs (args) { const { params } = { ...args } const _params = pick( params, @@ -83,7 +83,7 @@ class PublicСollsСonfAccessors { params } - await this.editPublicСollsСonf(confName, _args) + await this.editPublicCollsConf(confName, _args) const syncedColl = this.confNamesMap.get(confName) @@ -95,7 +95,7 @@ class PublicСollsСonfAccessors { return syncedColls } - async editPublicСollsСonf (confName, args) { + async editPublicCollsConf (confName, args) { const data = Array.isArray(args.params) ? [...args.params] : [args.params] @@ -185,20 +185,20 @@ class PublicСollsСonfAccessors { ) } - async getAllPublicСollsСonfs (args) { + async getAllPublicCollsConfs (args) { await this.authenticator.verifyRequestUser(args) const confNames = [...this.confNamesMap.keys()] const res = {} for (const confName of confNames) { - res[confName] = await this.getPublicСollsСonf(confName, args) + res[confName] = await this.getPublicCollsConf(confName, args) } return res } - async getPublicСollsСonf (confName, args) { + async getPublicCollsConf (confName, args) { const { _id } = await this.authenticator.verifyRequestUser(args) const { params } = { ...args } const { @@ -422,7 +422,7 @@ class PublicСollsСonfAccessors { notCheckNextPage } = { ...params } - const confs = await this.getPublicСollsСonf( + const confs = await this.getPublicCollsConf( confName, args ) @@ -491,6 +491,6 @@ class PublicСollsСonfAccessors { } } -decorateInjectable(PublicСollsСonfAccessors, depsTypes) +decorateInjectable(PublicCollsConfAccessors, depsTypes) -module.exports = PublicСollsСonfAccessors +module.exports = PublicCollsConfAccessors diff --git a/workers/loc.api/sync/data.inserter/data.checker/index.js b/workers/loc.api/sync/data.inserter/data.checker/index.js index e12af4c60..7ac6c62d3 100644 --- a/workers/loc.api/sync/data.inserter/data.checker/index.js +++ b/workers/loc.api/sync/data.inserter/data.checker/index.js @@ -237,7 +237,7 @@ class DataChecker { ? ['symbol', 'timeframe'] : ['symbol'] - const publicСollsСonf = await this.dao.getElemsInCollBy( + const publicCollsConf = await this.dao.getElemsInCollBy( this.TABLES_NAMES.PUBLIC_COLLS_CONF, { filter: { confName }, @@ -247,11 +247,11 @@ class DataChecker { } ) - if (isEmpty(publicСollsСonf)) { + if (isEmpty(publicCollsConf)) { return } - for (const confs of publicСollsСonf) { + for (const confs of publicCollsConf) { if (this._isInterrupted) { return } From 2fe3a534f15afb1fe739abc686b2d9df4bc7875d Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 6 Mar 2024 09:19:08 +0200 Subject: [PATCH 65/66] Bump version up to 4.15.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 09d2bd447..d6a75e6dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bfx-reports-framework", - "version": "4.14.0", + "version": "4.15.0", "description": "Bitfinex reports framework", "main": "worker.js", "license": "Apache-2.0", From c13a5f24e66672a6ad142b5f66547f9be7d33db3 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 6 Mar 2024 09:19:41 +0200 Subject: [PATCH 66/66] Update bfx-report-ui sub-module --- bfx-report-ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bfx-report-ui b/bfx-report-ui index 1236f970b..3bad34869 160000 --- a/bfx-report-ui +++ b/bfx-report-ui @@ -1 +1 @@ -Subproject commit 1236f970ba0b1c4c9b5274dd1049ade7814febf9 +Subproject commit 3bad3486986d3cc5b44f7c85aa33591d55a5ab7c