From f79d445d4d0b837771b901a083899eca93510783 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 5 Aug 2024 13:55:33 +0300 Subject: [PATCH 1/8] Remove deprecated isAddedUniqueEndingToCsvName config field --- workers/api.service.report.wrk.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/workers/api.service.report.wrk.js b/workers/api.service.report.wrk.js index 57d2a906..9ae4ff23 100644 --- a/workers/api.service.report.wrk.js +++ b/workers/api.service.report.wrk.js @@ -73,15 +73,6 @@ class WrkReportServiceApi extends WrkApi { loadDIConfig (cont = container) { const conf = this.conf[this.group] - /** - * @deprecated isAddedUniqueEndingToCsvName - * Keep for back compatibility - */ - conf.isAddedUniqueEndingToReportFileName = ( - conf.isAddedUniqueEndingToReportFileName ?? - conf.isAddedUniqueEndingToCsvName - ) - this.container = cont diConfig(conf, this.ctx.root) From 7ce3e9c6ef22d67a308796a0abf24cee8d9362f3 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 5 Aug 2024 13:57:18 +0300 Subject: [PATCH 2/8] Remove deprecated report exporting metadata fields --- workers/loc.api/generate-report-file/index.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/workers/loc.api/generate-report-file/index.js b/workers/loc.api/generate-report-file/index.js index b64e9d01..df1a8d6e 100644 --- a/workers/loc.api/generate-report-file/index.js +++ b/workers/loc.api/generate-report-file/index.js @@ -41,13 +41,7 @@ const _getReportFileStoreStatus = async ({ return { isSaveLocaly: true, localReportFolderPath, - remoteReportUrn, - - /** - * @deprecated fields - */ - localCsvFolderPath: localReportFolderPath, - remoteCsvUrn: remoteReportUrn + remoteReportUrn } } From 6dbb0b62f0f636d8ab0ce832c9d0e8da0f8568ee Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 5 Aug 2024 13:58:55 +0300 Subject: [PATCH 3/8] Remove deprecated main service methods --- workers/loc.api/service.report.js | 115 ------------------------------ 1 file changed, 115 deletions(-) diff --git a/workers/loc.api/service.report.js b/workers/loc.api/service.report.js index 090a7413..78b16b42 100644 --- a/workers/loc.api/service.report.js +++ b/workers/loc.api/service.report.js @@ -678,11 +678,6 @@ class ReportService extends Api { }, 'getWeightedAveragesReport', args, cb) } - /** - * @deprecated - */ - getMultipleCsv (...args) { return this.getMultipleFile(...args) } - getMultipleFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -692,11 +687,6 @@ class ReportService extends Api { }, 'getMultipleFile', args, cb) } - /** - * @deprecated - */ - getTradesCsv (...args) { return this.getTradesFile(...args) } - getTradesFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -706,11 +696,6 @@ class ReportService extends Api { }, 'getTradesFile', args, cb) } - /** - * @deprecated - */ - getFundingTradesCsv (...args) { return this.getFundingTradesFile(...args) } - getFundingTradesFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -720,11 +705,6 @@ class ReportService extends Api { }, 'getFundingTradesFile', args, cb) } - /** - * @deprecated - */ - getTickersHistoryCsv (...args) { return this.getTickersHistoryFile(...args) } - getTickersHistoryFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -734,11 +714,6 @@ class ReportService extends Api { }, 'getTickersHistoryFile', args, cb) } - /** - * @deprecated - */ - getWalletsCsv (...args) { return this.getWalletsFile(...args) } - getWalletsFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -748,11 +723,6 @@ class ReportService extends Api { }, 'getWalletsFile', args, cb) } - /** - * @deprecated - */ - getPositionsHistoryCsv (...args) { return this.getPositionsHistoryFile(...args) } - getPositionsHistoryFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -762,11 +732,6 @@ class ReportService extends Api { }, 'getPositionsHistoryFile', args, cb) } - /** - * @deprecated - */ - getActivePositionsCsv (...args) { return this.getActivePositionsFile(...args) } - getActivePositionsFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -776,11 +741,6 @@ class ReportService extends Api { }, 'getActivePositionsFile', args, cb) } - /** - * @deprecated - */ - getPositionsAuditCsv (...args) { return this.getPositionsAuditFile(...args) } - getPositionsAuditFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -790,11 +750,6 @@ class ReportService extends Api { }, 'getPositionsAuditFile', args, cb) } - /** - * @deprecated - */ - getPublicTradesCsv (...args) { return this.getPublicTradesFile(...args) } - getPublicTradesFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -804,11 +759,6 @@ class ReportService extends Api { }, 'getPublicTradesFile', args, cb) } - /** - * @deprecated - */ - getStatusMessagesCsv (...args) { return this.getStatusMessagesFile(...args) } - getStatusMessagesFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -818,11 +768,6 @@ class ReportService extends Api { }, 'getStatusMessagesFile', args, cb) } - /** - * @deprecated - */ - getCandlesCsv (...args) { return this.getCandlesFile(...args) } - getCandlesFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -832,11 +777,6 @@ class ReportService extends Api { }, 'getCandlesFile', args, cb) } - /** - * @deprecated - */ - getLedgersCsv (...args) { return this.getLedgersFile(...args) } - getLedgersFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -846,11 +786,6 @@ class ReportService extends Api { }, 'getLedgersFile', args, cb) } - /** - * @deprecated - */ - getPayInvoiceListCsv (...args) { return this.getPayInvoiceListFile(...args) } - getPayInvoiceListFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -860,11 +795,6 @@ class ReportService extends Api { }, 'getPayInvoiceListFile', args, cb) } - /** - * @deprecated - */ - getOrderTradesCsv (...args) { return this.getOrderTradesFile(...args) } - getOrderTradesFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -874,11 +804,6 @@ class ReportService extends Api { }, 'getOrderTradesFile', args, cb) } - /** - * @deprecated - */ - getOrdersCsv (...args) { return this.getOrdersFile(...args) } - getOrdersFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -888,11 +813,6 @@ class ReportService extends Api { }, 'getOrdersFile', args, cb) } - /** - * @deprecated - */ - getActiveOrdersCsv (...args) { return this.getActiveOrdersFile(...args) } - getActiveOrdersFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -902,11 +822,6 @@ class ReportService extends Api { }, 'getActiveOrdersFile', args, cb) } - /** - * @deprecated - */ - getMovementsCsv (...args) { return this.getMovementsFile(...args) } - getMovementsFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -916,11 +831,6 @@ class ReportService extends Api { }, 'getMovementsFile', args, cb) } - /** - * @deprecated - */ - getFundingOfferHistoryCsv (...args) { return this.getFundingOfferHistoryFile(...args) } - getFundingOfferHistoryFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -930,11 +840,6 @@ class ReportService extends Api { }, 'getFundingOfferHistoryFile', args, cb) } - /** - * @deprecated - */ - getFundingLoanHistoryCsv (...args) { return this.getFundingLoanHistoryFile(...args) } - getFundingLoanHistoryFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -944,11 +849,6 @@ class ReportService extends Api { }, 'getFundingLoanHistoryFile', args, cb) } - /** - * @deprecated - */ - getFundingCreditHistoryCsv (...args) { return this.getFundingCreditHistoryFile(...args) } - getFundingCreditHistoryFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -958,11 +858,6 @@ class ReportService extends Api { }, 'getFundingCreditHistoryFile', args, cb) } - /** - * @deprecated - */ - getLoginsCsv (...args) { return this.getLoginsFile(...args) } - getLoginsFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -972,11 +867,6 @@ class ReportService extends Api { }, 'getLoginsFile', args, cb) } - /** - * @deprecated - */ - getChangeLogsCsv (...args) { return this.getChangeLogsFile(...args) } - getChangeLogsFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( @@ -986,11 +876,6 @@ class ReportService extends Api { }, 'getChangeLogsFile', args, cb) } - /** - * @deprecated - */ - getWeightedAveragesReportCsv (...args) { return this.getWeightedAveragesReportFile(...args) } - getWeightedAveragesReportFile (space, args, cb) { return this._responder(() => { return this._generateReportFile( From 202f28685f933a48ecc6c5bd120de17d4f43a435 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 6 Aug 2024 13:23:21 +0300 Subject: [PATCH 4/8] Improve db file cleanups for test coverage hooks --- test/helpers/helpers.core.js | 60 ++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/test/helpers/helpers.core.js b/test/helpers/helpers.core.js index 9428a074..12348ede 100644 --- a/test/helpers/helpers.core.js +++ b/test/helpers/helpers.core.js @@ -1,47 +1,55 @@ 'use strict' -const { promisify } = require('util') const path = require('path') -const fs = require('fs') -const readdir = promisify(fs.readdir) -const unlink = promisify(fs.unlink) -const mkdir = promisify(fs.mkdir) +const { + readdir, + mkdir, + rm +} = require('node:fs/promises') const rmDB = async ( dir, - exclude = ['.gitkeep'], - isThrownError + exclude = ['.gitkeep'] ) => { try { - const files = await readdir(dir) - const promisesArr = files.map((file) => { - if (exclude.every(exFile => exFile !== file)) { - return unlink(path.join(dir, file)) + const files = await readdir( + dir, + { withFileTypes: true } + ) + + for (const dirent of files) { + const { name } = dirent + + if ( + !dirent.isFile() || + exclude.some((exFile) => exFile === name) + ) { + continue } - return null - }) - - const res = await Promise.all(promisesArr) - - return res - } catch (err) { - if (!isThrownError) { - return + const filePath = path.join(dir, name) + await rm( + filePath, + { + force: true, + maxRetries: 5, + recursive: true, + retryDelay: 200 + } + ) } - - throw err + } catch (err) { + console.log(err) } } const rmAllFiles = async (dir, exclude) => { try { - await rmDB(dir, exclude, true) + await rmDB(dir, exclude) + await mkdir(dir, { recursive: true }) } catch (err) { - if (err.syscall === 'scandir') { - await mkdir(dir) - } + console.log(err) } } From 67b866f9426469b4ffe317f93bc98914c6140ec3 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 27 Aug 2024 11:46:23 +0300 Subject: [PATCH 5/8] Extend connection refused error processing --- workers/loc.api/helpers/api-errors-testers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workers/loc.api/helpers/api-errors-testers.js b/workers/loc.api/helpers/api-errors-testers.js index 04a8fa78..92b51192 100644 --- a/workers/loc.api/helpers/api-errors-testers.js +++ b/workers/loc.api/helpers/api-errors-testers.js @@ -48,7 +48,7 @@ const isEAiAgainError = (err) => { } const isEConnRefusedError = (err) => { - return /ECONNREFUSED/i.test(_getErrorString(err)) + return /(ECONNREFUSED)|(ERR_CONNECTION_REFUSED)/i.test(_getErrorString(err)) } const isENotFoundError = (err) => { From 677e86e6960c4116992d5fc255cb4c9b79a53943 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 27 Aug 2024 11:48:23 +0300 Subject: [PATCH 6/8] Add connection closed error processing --- workers/loc.api/helpers/api-errors-testers.js | 6 ++++++ workers/loc.api/helpers/index.js | 2 ++ 2 files changed, 8 insertions(+) diff --git a/workers/loc.api/helpers/api-errors-testers.js b/workers/loc.api/helpers/api-errors-testers.js index 92b51192..5ad9cc38 100644 --- a/workers/loc.api/helpers/api-errors-testers.js +++ b/workers/loc.api/helpers/api-errors-testers.js @@ -51,6 +51,10 @@ const isEConnRefusedError = (err) => { return /(ECONNREFUSED)|(ERR_CONNECTION_REFUSED)/i.test(_getErrorString(err)) } +const isEConnClosedError = (err) => { + return /ERR_CONNECTION_CLOSED/i.test(_getErrorString(err)) +} + const isENotFoundError = (err) => { return /ENOTFOUND/i.test(_getErrorString(err)) } @@ -87,6 +91,7 @@ const isENetError = (err) => ( isNodeFetchTimeoutError(err) || isEAiAgainError(err) || isEConnRefusedError(err) || + isEConnClosedError(err) || isENotFoundError(err) || isESocketTimeoutError(err) || isEHostUnreachError(err) || @@ -106,6 +111,7 @@ module.exports = { isNodeFetchTimeoutError, isEAiAgainError, isEConnRefusedError, + isEConnClosedError, isENotFoundError, isESocketTimeoutError, isEHostUnreachError, diff --git a/workers/loc.api/helpers/index.js b/workers/loc.api/helpers/index.js index add351b3..2020d546 100644 --- a/workers/loc.api/helpers/index.js +++ b/workers/loc.api/helpers/index.js @@ -34,6 +34,7 @@ const { isNodeFetchTimeoutError, isEAiAgainError, isEConnRefusedError, + isEConnClosedError, isENotFoundError, isESocketTimeoutError, isENetError, @@ -81,6 +82,7 @@ module.exports = { isNodeFetchTimeoutError, isEAiAgainError, isEConnRefusedError, + isEConnClosedError, isENotFoundError, isESocketTimeoutError, isENetError, From 1f783508f3beeb1f402efba7aa987c68d7a8446d Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 27 Aug 2024 11:55:06 +0300 Subject: [PATCH 7/8] Add Bad Gateway error processing --- workers/loc.api/helpers/api-errors-testers.js | 8 +++++++- workers/loc.api/helpers/index.js | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/workers/loc.api/helpers/api-errors-testers.js b/workers/loc.api/helpers/api-errors-testers.js index 5ad9cc38..f6b50a69 100644 --- a/workers/loc.api/helpers/api-errors-testers.js +++ b/workers/loc.api/helpers/api-errors-testers.js @@ -75,6 +75,10 @@ const isTempUnavailableError = (err) => { return /temporarily_unavailable/i.test(_getErrorString(err)) } +const isBadGatewayError = (err) => { + return /Bad Gateway/i.test(_getErrorString(err)) +} + const isForbiddenError = (err) => { return /forbidden/i.test(_getErrorString(err)) } @@ -96,7 +100,8 @@ const isENetError = (err) => ( isESocketTimeoutError(err) || isEHostUnreachError(err) || isEProtoError(err) || - isTempUnavailableError(err) + isTempUnavailableError(err) || + isBadGatewayError(err) ) module.exports = { @@ -117,6 +122,7 @@ module.exports = { isEHostUnreachError, isEProtoError, isTempUnavailableError, + isBadGatewayError, isENetError, isForbiddenError, isMaintenanceError diff --git a/workers/loc.api/helpers/index.js b/workers/loc.api/helpers/index.js index 2020d546..6f55dc03 100644 --- a/workers/loc.api/helpers/index.js +++ b/workers/loc.api/helpers/index.js @@ -37,6 +37,10 @@ const { isEConnClosedError, isENotFoundError, isESocketTimeoutError, + isEHostUnreachError, + isEProtoError, + isTempUnavailableError, + isBadGatewayError, isENetError, isForbiddenError, isMaintenanceError @@ -85,6 +89,10 @@ module.exports = { isEConnClosedError, isENotFoundError, isESocketTimeoutError, + isEHostUnreachError, + isEProtoError, + isTempUnavailableError, + isBadGatewayError, isENetError, isForbiddenError, isMaintenanceError, From a407446ee8e517435e4da5b33d975cb36d41a15e Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 27 Aug 2024 12:52:33 +0300 Subject: [PATCH 8/8] Bump version up to 4.10.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 476f7aa4..93a3e9f8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bfx-report", - "version": "4.10.6", + "version": "4.10.7", "description": "Reporting tool", "main": "worker.js", "license": "Apache-2.0",