diff --git a/.gitignore b/.gitignore
index 0f797fd89..52ca7fd34 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,9 +12,11 @@ logs/*
db/*
!db/.gitkeep
csv/
+report-files/
logs
package-lock.json
workers/loc.api/queue/temp/*.csv
+workers/loc.api/queue/temp/*.pdf
workers/loc.api/queue/temp/*.zip
bfx-report-ui/.env
bfx-report-ui/src
diff --git a/README.md b/README.md
index 7b54d4e6c..d62e4ed6e 100644
--- a/README.md
+++ b/README.md
@@ -130,7 +130,7 @@ Options:
During the setup process, the user will be asked some questions
- if no Docker/docker-compose are found, the user will be prompted to install them
-- to remove all Log and DB and CSV files to setup the app from scratch
+- to remove all Log and DB and report files to setup the app from scratch
- to choose syncing repository branch (master/staging), by default master
- to set NGINX port, by default 80
- to set NGINX host, by default localhost
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
diff --git a/config/service.report.json.example b/config/service.report.json.example
index 815bc2aa0..5dc3959d2 100644
--- a/config/service.report.json.example
+++ b/config/service.report.json.example
@@ -14,8 +14,8 @@
"signedUrlExpireTime": 28800
},
"isSpamRestrictionMode": true,
- "isAddedUniqueEndingToCsvName": true,
- "isСompress": true,
+ "isAddedUniqueEndingToReportFileName": true,
+ "isCompress": true,
"isLoggerDisabled": false,
"dbDriver": "better-sqlite",
"verboseSql": false,
diff --git a/docker-compose.yaml b/docker-compose.yaml
index 2b539d79d..f1a2db4e2 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -55,7 +55,7 @@ services:
volumes:
- temp:/home/node/bfx-reports-framework/temp
- ./db:/home/node/bfx-reports-framework/db
- - ./csv:/home/node/bfx-reports-framework/csv
+ - ./report-files:/home/node/bfx-reports-framework/report-files
- ./logs:/home/node/bfx-reports-framework/logs
environment:
<<: *common-variables
@@ -63,7 +63,7 @@ services:
WORKER_WS_PORT: "1455"
TEMP_FOLDER: "/home/node/bfx-reports-framework/temp"
DB_FOLDER: "/home/node/bfx-reports-framework/db"
- CSV_FOLDER: "/home/node/bfx-reports-framework/csv"
+ REPORT_FOLDER: "/home/node/bfx-reports-framework/report-files"
LOGS_FOLDER: "/home/node/bfx-reports-framework/logs"
SECRET_KEY: ${SECRET_KEY} # Required
SCHEDULER_RULE: ${SCHEDULER_RULE} # Non-required
@@ -122,10 +122,10 @@ services:
- ./nginx-configs/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx-configs/templates:/etc/nginx/templates
- ./logs:/var/log/nginx/bfx-reports-framework
- - ./csv:/var/www/csv
+ - ./report-files:/var/www/report-files
environment:
<<: *common-variables
- CSV_FOLDER: "/var/www/csv"
+ REPORT_FOLDER: "/var/www/report-files"
MAINTENANCE_STATIC_FOLDER: "/var/www/maintenance"
FRONT_BUILD_FOLDER: "/var/www/html"
LOGS_FOLDER: "/var/log/nginx/bfx-reports-framework"
diff --git a/nginx-configs/autoindex-format.xslt b/nginx-configs/autoindex-format.xslt
index 28cf368aa..eba57e079 100644
--- a/nginx-configs/autoindex-format.xslt
+++ b/nginx-configs/autoindex-format.xslt
@@ -242,7 +242,7 @@
- Bitfinex Report CSV
+ Bitfinex Report
diff --git a/nginx-configs/templates/default.conf.template b/nginx-configs/templates/default.conf.template
index b30678ecd..b87b94b03 100644
--- a/nginx-configs/templates/default.conf.template
+++ b/nginx-configs/templates/default.conf.template
@@ -48,7 +48,7 @@ server {
add_header Cache-Control "public";
}
- location /csv {
+ location /report-files {
auth_request /api/auth;
autoindex ${NGINX_AUTOINDEX};
@@ -56,12 +56,12 @@ server {
xslt_stylesheet /etc/nginx/autoindex-format.xslt path='$uri';
try_files $uri/ =404;
- alias ${CSV_FOLDER};
+ alias ${REPORT_FOLDER};
if ($arg_token ~ ".+") {
add_header Set-Cookie "token=$arg_token; Max-Age=3600; SameSite=strict; HttpOnly";
}
- if ($request_filename ~ "^.*/(.+\.(zip|csv))$") {
+ if ($request_filename ~ "^.*/(.+\.(zip|csv|pdf))$") {
set $fname $1;
add_header Content-Disposition 'attachment; filename="$fname"';
}
diff --git a/package.json b/package.json
index ca917183e..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",
@@ -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/scripts/setup.sh b/scripts/setup.sh
index 616fcdaa2..d84128484 100755
--- a/scripts/setup.sh
+++ b/scripts/setup.sh
@@ -194,13 +194,13 @@ fi
if askUser "\
The app will be setup from scratch!\n\
-All Log and DB and CSV files will be removed!\n\
+All Log and DB and report files will be removed!\n\
Are you sure?\
"; then
rm -rf "$ROOT/logs"
- rm -rf "$ROOT/csv"
+ rm -rf "$ROOT/report-files"
mkdir "$ROOT/logs" 2>/dev/null
- mkdir "$ROOT/csv" 2>/dev/null
+ mkdir "$ROOT/report-files" 2>/dev/null
if [ $isDBFoldedRemoved == 1 ]; then
find "$ROOT/db" ! -path "$ROOT/db/.gitkeep" -type f -exec rm -rf {} +
diff --git a/scripts/worker-entrypoint.sh b/scripts/worker-entrypoint.sh
index d1bcf00b8..489cc4729 100755
--- a/scripts/worker-entrypoint.sh
+++ b/scripts/worker-entrypoint.sh
@@ -18,7 +18,7 @@ set -- node "$@" \
"--wsPort" "$WORKER_WS_PORT" \
"--tempFolder" "$TEMP_FOLDER" \
"--dbFolder" "$DB_FOLDER" \
- "--csvFolder" "$CSV_FOLDER" \
+ "--reportFolder" "$REPORT_FOLDER" \
"--logsFolder" "$LOGS_FOLDER" \
"--grape" "http://$GRAPE_HOST:$GRAPE_APH" \
"--secretKey" "$SECRET_KEY"
@@ -27,7 +27,7 @@ if [ -n "${SCHEDULER_RULE:-}" ]; then
set -- "$@" "--schedulerRule" "$SCHEDULER_RULE"
fi
if [ "${NGINX_AUTOINDEX:-}" = "on" ]; then
- set -- "$@" "--remoteCsvUrn" "csv/"
+ set -- "$@" "--remoteReportUrn" "report-files/"
fi
exec "$@"
diff --git a/test/1-api-sync-mode-sqlite.spec.js b/test/1-api-sync-mode-sqlite.spec.js
index be22e20b1..555bc7779 100644
--- a/test/1-api-sync-mode-sqlite.spec.js
+++ b/test/1-api-sync-mode-sqlite.spec.js
@@ -39,7 +39,7 @@ let mockRESTv2Srv = null
const basePath = '/api'
const tempDirPath = path.join(__dirname, '..', 'workers/loc.api/queue/temp')
const dbDirPath = path.join(__dirname, '..', 'db')
-const csvDirPath = path.join(__dirname, '..', 'csv')
+const reportFolderPath = path.join(__dirname, '..', 'report-files')
const date = new Date()
const end = date.getTime()
const start = (new Date()).setDate(date.getDate() - 90)
@@ -78,7 +78,7 @@ describe('Sync mode API with SQLite', () => {
mockRESTv2Srv = createMockRESTv2SrvWithDate(start, end, 100)
- await rmRf(csvDirPath)
+ await rmRf(reportFolderPath)
await rmAllFiles(tempDirPath, ['README.md'])
await rmDB(dbDirPath)
const env = await startEnvironment(false, false, 1)
@@ -98,7 +98,7 @@ describe('Sync mode API with SQLite', () => {
await stopEnvironment()
await rmDB(dbDirPath)
await rmAllFiles(tempDirPath, ['README.md'])
- await rmRf(csvDirPath)
+ await rmRf(reportFolderPath)
try {
await mockRESTv2Srv.close()
@@ -106,23 +106,45 @@ 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', () => {
before(async function () {
this.timeout(20000)
- await rmRf(csvDirPath)
+ await rmRf(reportFolderPath)
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)
+ })
})
})
diff --git a/test/2-additional-api-sync-mode-sqlite.spec.js b/test/2-additional-api-sync-mode-sqlite.spec.js
index 210ee1b65..1b862c12c 100644
--- a/test/2-additional-api-sync-mode-sqlite.spec.js
+++ b/test/2-additional-api-sync-mode-sqlite.spec.js
@@ -38,7 +38,7 @@ let mockRESTv2Srv = null
const basePath = '/api'
const tempDirPath = path.join(__dirname, '..', 'workers/loc.api/queue/temp')
const dbDirPath = path.join(__dirname, '..', 'db')
-const csvDirPath = path.join(__dirname, '..', 'csv')
+const reportFolderPath = path.join(__dirname, '..', 'report-files')
const date = new Date()
const end = date.getTime()
const start = (new Date()).setDate(date.getDate() - 90)
@@ -77,7 +77,7 @@ describe('Additional sync mode API with SQLite', () => {
mockRESTv2Srv = createMockRESTv2SrvWithDate(start, end, 100)
- await rmRf(csvDirPath)
+ await rmRf(reportFolderPath)
await rmAllFiles(tempDirPath, ['README.md'])
await rmDB(dbDirPath)
const env = await startEnvironment(false, false, 1)
@@ -97,7 +97,7 @@ describe('Additional sync mode API with SQLite', () => {
await stopEnvironment()
await rmDB(dbDirPath)
await rmAllFiles(tempDirPath, ['README.md'])
- await rmRf(csvDirPath)
+ await rmRf(reportFolderPath)
try {
await mockRESTv2Srv.close()
@@ -105,19 +105,37 @@ 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', () => {
before(async function () {
this.timeout(20000)
- await rmRf(csvDirPath)
+ await rmRf(reportFolderPath)
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)
+ })
})
})
diff --git a/test/3-api-filter-sync-mode-sqlite.spec.js b/test/3-api-filter-sync-mode-sqlite.spec.js
index e55ae8e86..e57666328 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 {
@@ -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,
@@ -864,10 +864,10 @@ 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 () {
+ 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,
@@ -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/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)
diff --git a/test/helpers/helpers.tests.js b/test/helpers/helpers.tests.js
index 79af47c70..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: reports/csv/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
+ // 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,
- /csv\/[A-Za-z0-9\-_]+\/[A-Za-z0-9\-_]+\.csv$/,
- 'Has csv common folder for group reports'
+ /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 4271fedb6..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
@@ -6,14 +6,14 @@ const {
queueToPromise
} = require('bfx-report/test/helpers/helpers.core')
const {
- testMethodOfGettingCsv
+ testMethodOfGettingReportFile
} = require('bfx-report/test/helpers/helpers.tests')
const {
getParamsArrToTestTimeframeGrouping
} = require('../helpers/helpers.core')
const {
- testCsvPathHasCommonFolder
+ testReportPathHasCommonFolder
} = require('../helpers/helpers.tests')
const getSyncProgressTestCase = require('./get-sync-progress-test-case')
@@ -30,7 +30,8 @@ module.exports = (
isSubAccount
},
end,
- start
+ start,
+ isPDFRequired
} = params
const auth = { token: '' }
@@ -623,7 +624,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 +635,13 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getMultipleCsv',
+ method: 'getMultipleFile',
params: {
email,
+ isPDFRequired,
multiExport: [
{
- method: 'getTradesCsv',
+ method: 'getTradesFile',
symbol: ['tBTCUSD', 'tETHUSD'],
end,
start,
@@ -647,7 +649,7 @@ module.exports = (
timezone: 'America/Los_Angeles'
},
{
- method: 'getBalanceHistoryCsv',
+ method: 'getBalanceHistoryFile',
end,
start,
timeframe: 'day'
@@ -659,10 +661,10 @@ 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 () {
+ it('it should be successfully performed by the getBalanceHistoryFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -673,8 +675,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getBalanceHistoryCsv',
+ method: 'getBalanceHistoryFile',
params: {
+ isPDFRequired,
end,
start,
timeframe: 'day',
@@ -685,7 +688,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 () {
@@ -807,7 +810,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,8 +821,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getWinLossCsv',
+ method: 'getWinLossFile',
params: {
+ isPDFRequired,
end,
start,
timeframe: 'day',
@@ -830,10 +834,10 @@ 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 () {
+ it('it should be successfully performed by the getFullSnapshotReportFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -844,8 +848,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getFullSnapshotReportCsv',
+ method: 'getFullSnapshotReportFile',
params: {
+ isPDFRequired,
end,
email
},
@@ -854,10 +859,10 @@ 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 () {
+ 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,8 +873,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getFullSnapshotReportCsv',
+ method: 'getFullSnapshotReportFile',
params: {
+ isPDFRequired,
end
},
id: 5
@@ -877,15 +883,15 @@ module.exports = (
.expect('Content-Type', /json/)
.expect(200)
- await testMethodOfGettingCsv(
+ await testMethodOfGettingReportFile(
procPromise,
aggrPromise,
res,
- testCsvPathHasCommonFolder
+ testReportPathHasCommonFolder
)
})
- 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,8 +902,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getPositionsSnapshotCsv',
+ method: 'getPositionsSnapshotFile',
params: {
+ isPDFRequired,
end,
email
},
@@ -906,10 +913,10 @@ 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 () {
+ it('it should be successfully performed by the getFullTaxReportFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -920,8 +927,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getFullTaxReportCsv',
+ method: 'getFullTaxReportFile',
params: {
+ isPDFRequired,
end,
start,
email
@@ -931,10 +939,10 @@ 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 () {
+ 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,8 +953,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getFullTaxReportCsv',
+ method: 'getFullTaxReportFile',
params: {
+ isPDFRequired,
end,
start
},
@@ -955,15 +964,15 @@ module.exports = (
.expect('Content-Type', /json/)
.expect(200)
- await testMethodOfGettingCsv(
+ await testMethodOfGettingReportFile(
procPromise,
aggrPromise,
res,
- testCsvPathHasCommonFolder
+ testReportPathHasCommonFolder
)
})
- 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,8 +983,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getFullTaxReportCsv',
+ method: 'getFullTaxReportFile',
params: {
+ isPDFRequired,
end,
start,
isStartSnapshot: true
@@ -985,15 +995,15 @@ module.exports = (
.expect('Content-Type', /json/)
.expect(200)
- await testMethodOfGettingCsv(
+ await testMethodOfGettingReportFile(
procPromise,
aggrPromise,
res,
- testCsvPathHasCommonFolder
+ testReportPathHasCommonFolder
)
})
- 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,8 +1014,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getFullTaxReportCsv',
+ method: 'getFullTaxReportFile',
params: {
+ isPDFRequired,
end,
start,
isEndSnapshot: true
@@ -1015,15 +1026,15 @@ module.exports = (
.expect('Content-Type', /json/)
.expect(200)
- await testMethodOfGettingCsv(
+ await testMethodOfGettingReportFile(
procPromise,
aggrPromise,
res,
- testCsvPathHasCommonFolder
+ testReportPathHasCommonFolder
)
})
- 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,8 +1045,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getTradedVolumeCsv',
+ method: 'getTradedVolumeFile',
params: {
+ isPDFRequired,
end,
start,
timeframe: 'day',
@@ -1046,10 +1058,10 @@ 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 () {
+ it('it should be successfully performed by the getTotalFeesReportFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -1060,8 +1072,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getTotalFeesReportCsv',
+ method: 'getTotalFeesReportFile',
params: {
+ isPDFRequired,
end,
start,
timeframe: 'day',
@@ -1073,10 +1086,10 @@ 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 () {
+ it('it should be successfully performed by the getPerformingLoanFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -1087,8 +1100,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getPerformingLoanCsv',
+ method: 'getPerformingLoanFile',
params: {
+ isPDFRequired,
end,
start,
timeframe: 'day',
@@ -1099,10 +1113,10 @@ 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 () {
+ it('it should be successfully performed by the getWinLossVSAccountBalanceFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -1113,8 +1127,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getWinLossVSAccountBalanceCsv',
+ method: 'getWinLossVSAccountBalanceFile',
params: {
+ isPDFRequired,
end,
start,
timeframe: 'day',
@@ -1125,12 +1140,17 @@ 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 () {
+ 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)
@@ -1139,8 +1159,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getWeightedAveragesReportCsv',
+ method: 'getWeightedAveragesReportFile',
params: {
+ isPDFRequired,
symbol: 'tBTCUSD',
end,
start,
@@ -1151,7 +1172,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..ae03d76f5 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')
@@ -27,7 +27,8 @@ module.exports = (
},
date,
end,
- start
+ start,
+ isPDFRequired
} = params
const auth = { token: '' }
@@ -909,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
@@ -917,7 +918,7 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'editAllPublicСollsСonfs',
+ method: 'editAllPublicCollsConfs',
params: {
publicTradesConf: [
{
@@ -966,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
@@ -974,7 +975,7 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getAllPublicСollsСonfs',
+ method: 'getAllPublicCollsConfs',
id: 5
})
.expect('Content-Type', /json/)
@@ -2720,7 +2721,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 +2732,13 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getMultipleCsv',
+ method: 'getMultipleFile',
params: {
email,
+ isPDFRequired,
multiExport: [
{
- method: 'getTradesCsv',
+ method: 'getTradesFile',
symbol: ['tBTCUSD', 'tETHUSD'],
end,
start,
@@ -2744,7 +2746,7 @@ module.exports = (
timezone: 'America/Los_Angeles'
},
{
- method: 'getTickersHistoryCsv',
+ method: 'getTickersHistoryFile',
symbol: 'BTC',
end,
start,
@@ -2757,10 +2759,10 @@ 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 () {
+ it('it should not be successfully performed by the getMultipleFile method', async function () {
this.timeout(60000)
const res = await agent
@@ -2768,9 +2770,10 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getMultipleCsv',
+ method: 'getMultipleFile',
params: {
email,
+ isPDFRequired,
multiExport: [
{
symbol: ['tBTCUSD', 'tETHUSD'],
@@ -2793,7 +2796,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,8 +2807,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getTickersHistoryCsv',
+ method: 'getTickersHistoryFile',
params: {
+ isPDFRequired,
symbol: 'BTC',
end,
start,
@@ -2817,10 +2821,10 @@ 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 () {
+ it('it should be successfully performed by the getPositionsHistoryFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -2831,8 +2835,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getPositionsHistoryCsv',
+ method: 'getPositionsHistoryFile',
params: {
+ isPDFRequired,
symbol: 'tBTCUSD',
end,
start,
@@ -2844,10 +2849,10 @@ 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 () {
+ it('it should be successfully performed by the getPositionsAuditFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -2858,8 +2863,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getPositionsAuditCsv',
+ method: 'getPositionsAuditFile',
params: {
+ isPDFRequired,
id: [12345],
symbol: 'tBTCUSD',
end,
@@ -2872,10 +2878,10 @@ 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 () {
+ it('it should be successfully performed by the getWalletsFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -2886,8 +2892,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getWalletsCsv',
+ method: 'getWalletsFile',
params: {
+ isPDFRequired,
end,
email
},
@@ -2896,10 +2903,10 @@ 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 () {
+ it('it should be successfully performed by the getFundingOfferHistoryFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -2910,8 +2917,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getFundingOfferHistoryCsv',
+ method: 'getFundingOfferHistoryFile',
params: {
+ isPDFRequired,
symbol: 'fUSD',
end,
start,
@@ -2924,10 +2932,10 @@ 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 () {
+ it('it should be successfully performed by the getFundingLoanHistoryFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -2938,8 +2946,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getFundingLoanHistoryCsv',
+ method: 'getFundingLoanHistoryFile',
params: {
+ isPDFRequired,
symbol: 'fUSD',
end,
start,
@@ -2951,10 +2960,10 @@ 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 () {
+ it('it should be successfully performed by the getFundingCreditHistoryFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -2965,8 +2974,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getFundingCreditHistoryCsv',
+ method: 'getFundingCreditHistoryFile',
params: {
+ isPDFRequired,
symbol: 'fUSD',
end,
start,
@@ -2978,10 +2988,10 @@ 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 () {
+ it('it should be successfully performed by the getLedgersFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -2992,8 +3002,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getLedgersCsv',
+ method: 'getLedgersFile',
params: {
+ isPDFRequired,
symbol: ['BTC'],
end,
start,
@@ -3005,10 +3016,10 @@ 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 () {
+ it('it should be successfully performed by the getPayInvoiceListFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -3019,8 +3030,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getPayInvoiceListCsv',
+ method: 'getPayInvoiceListFile',
params: {
+ isPDFRequired,
end,
start,
limit: 100,
@@ -3032,10 +3044,10 @@ 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 () {
+ it('it should be successfully performed by the getTradesFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -3046,8 +3058,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getTradesCsv',
+ method: 'getTradesFile',
params: {
+ isPDFRequired,
symbol: ['tBTCUSD', 'tETHUSD'],
end,
start,
@@ -3059,10 +3072,10 @@ 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 () {
+ it('it should be successfully performed by the getFundingTradesFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -3073,8 +3086,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getFundingTradesCsv',
+ method: 'getFundingTradesFile',
params: {
+ isPDFRequired,
symbol: ['fBTC', 'fETH'],
end,
start,
@@ -3086,10 +3100,10 @@ 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 () {
+ it('it should be successfully performed by the getPublicTradesFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -3100,8 +3114,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getPublicTradesCsv',
+ method: 'getPublicTradesFile',
params: {
+ isPDFRequired,
symbol: 'tBTCUSD',
end,
start: (new Date()).setDate(date.getDate() - 27),
@@ -3114,10 +3129,10 @@ 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 () {
+ 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,8 +3140,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getPublicTradesCsv',
+ method: 'getPublicTradesFile',
params: {
+ isPDFRequired,
symbol: 'tBTCUSD',
end,
start,
@@ -3146,7 +3162,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,8 +3170,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getPublicTradesCsv',
+ method: 'getPublicTradesFile',
params: {
+ isPDFRequired,
symbol: ['tBTCUSD', 'tETHUSD'],
end,
start,
@@ -3175,7 +3192,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,8 +3203,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getStatusMessagesCsv',
+ method: 'getStatusMessagesFile',
params: {
+ isPDFRequired,
symbol: ['tBTCF0:USTF0'],
timezone: 'America/Los_Angeles',
email
@@ -3197,10 +3215,10 @@ 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 () {
+ it('it should be successfully performed by the getCandlesFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -3211,8 +3229,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getCandlesCsv',
+ method: 'getCandlesFile',
params: {
+ isPDFRequired,
symbol: 'tBTCUSD',
timeframe: '12h',
end,
@@ -3226,10 +3245,10 @@ 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 () {
+ it('it should be successfully performed by the getOrderTradesFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -3240,8 +3259,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getOrderTradesCsv',
+ method: 'getOrderTradesFile',
params: {
+ isPDFRequired,
id: 12345,
symbol: 'tBTCUSD',
end,
@@ -3255,10 +3275,10 @@ 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 () {
+ it('it should be successfully performed by the getOrdersFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -3269,8 +3289,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getOrdersCsv',
+ method: 'getOrdersFile',
params: {
+ isPDFRequired,
symbol: 'tBTCUSD',
end,
start,
@@ -3281,10 +3302,10 @@ 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 () {
+ it('it should be successfully performed by the getActiveOrdersFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -3295,8 +3316,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getActiveOrdersCsv',
+ method: 'getActiveOrdersFile',
params: {
+ isPDFRequired,
email
},
id: 5
@@ -3304,10 +3326,10 @@ 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 () {
+ it('it should be successfully performed by the getMovementsFile method', async function () {
this.timeout(3 * 60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -3318,8 +3340,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getMovementsCsv',
+ method: 'getMovementsFile',
params: {
+ isPDFRequired,
symbol: 'BTC',
end,
start,
@@ -3330,10 +3353,10 @@ 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 () {
+ 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,8 +3367,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getMovementsCsv',
+ method: 'getMovementsFile',
params: {
+ isPDFRequired,
symbol: 'BTC',
end,
start,
@@ -3357,10 +3381,10 @@ 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 () {
+ 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,8 +3395,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getMovementsCsv',
+ method: 'getMovementsFile',
params: {
+ isPDFRequired,
symbol: 'BTC',
end,
start,
@@ -3384,10 +3409,10 @@ 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 () {
+ it('it should be successfully performed by the getLoginsFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -3398,8 +3423,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getLoginsCsv',
+ method: 'getLoginsFile',
params: {
+ isPDFRequired,
end,
start,
limit: 1000,
@@ -3410,10 +3436,10 @@ 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 () {
+ it('it should be successfully performed by the getChangeLogsFile method', async function () {
this.timeout(60000)
const procPromise = queueToPromise(params.processorQueue)
@@ -3424,8 +3450,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getChangeLogsCsv',
+ method: 'getChangeLogsFile',
params: {
+ isPDFRequired,
end,
start,
limit: 1000,
@@ -3436,18 +3463,19 @@ 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 () {
+ 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: {
+ isPDFRequired,
symbol: 'BTC',
end,
start,
@@ -3467,7 +3495,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,8 +3512,9 @@ module.exports = (
.type('json')
.send({
auth,
- method: 'getLedgersCsv',
+ method: 'getLedgersFile',
params: {
+ isPDFRequired,
symbol: 'BTC',
end,
start,
diff --git a/workers/api.framework.report.wrk.js b/workers/api.framework.report.wrk.js
index f1a6fd620..0c9d2ea87 100644
--- a/workers/api.framework.report.wrk.js
+++ b/workers/api.framework.report.wrk.js
@@ -157,13 +157,17 @@ class WrkReportFrameWorkApi extends WrkReportServiceApi {
await wsTransport.start()
aggregatorQueue.on('completed', (res) => {
- const { csvFilesMetadata, userInfo } = res ?? {}
+ const {
+ reportFilesMetadata,
+ csvFilesMetadata, // For compatibility with old implementation
+ userInfo
+ } = res ?? {}
- wsEventEmitter.emitCsvGenerationCompletedToOne(
- { csvFilesMetadata },
+ wsEventEmitter.emitReportFileGenerationCompletedToOne(
+ { reportFilesMetadata: reportFilesMetadata ?? csvFilesMetadata },
userInfo
).then(() => {}, (err) => {
- this.logger.error(`WS_EVENT_EMITTER:CSV_COMPLETED: ${err.stack || err}`)
+ this.logger.error(`WS_EVENT_EMITTER:REPORT_FILE_COMPLETED: ${err.stack || err}`)
})
})
diff --git a/workers/loc.api/di/app.deps.js b/workers/loc.api/di/app.deps.js
index 2146d1509..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')
@@ -91,11 +91,11 @@ const SubAccountApiData = require('../sync/sub.account.api.data')
const PositionsAudit = require('../sync/positions.audit')
const OrderTrades = require('../sync/order.trades')
const CurrencyConverter = require('../sync/currency.converter')
-const CsvJobData = require('../generate-csv/csv.job.data')
+const ReportFileJobData = require('../generate-report-file/report.file.job.data')
const {
fullSnapshotReportCsvWriter,
fullTaxReportCsvWriter
-} = require('../generate-csv/csv-writer')
+} = require('../generate-report-file/csv-writer')
const FullTaxReport = require('../sync/full.tax.report')
const WeightedAveragesReport = require('../sync/weighted.averages.report')
const SqliteDbMigrator = require(
@@ -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)
@@ -142,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],
@@ -183,6 +184,9 @@ module.exports = ({
]
)
)
+ rebind(TYPES.PdfWriter)
+ .to(PdfWriter)
+ .inSingletonScope()
bind(TYPES.PrivResponder)
.toDynamicValue((ctx) => bindDepsToFn(
privResponder,
@@ -212,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)
@@ -391,8 +395,8 @@ module.exports = ({
.to(FullTaxReport)
rebind(TYPES.WeightedAveragesReport)
.to(WeightedAveragesReport)
- rebind(TYPES.CsvJobData)
- .to(CsvJobData)
+ rebind(TYPES.ReportFileJobData)
+ .to(ReportFileJobData)
.inSingletonScope()
rebind(TYPES.GetDataFromApi).toConstantValue(
bindDepsToFn(
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/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
}
diff --git a/workers/loc.api/generate-csv/csv-writer/full-snapshot-report-csv-writer.js b/workers/loc.api/generate-report-file/csv-writer/full-snapshot-report-csv-writer.js
similarity index 92%
rename from workers/loc.api/generate-csv/csv-writer/full-snapshot-report-csv-writer.js
rename to workers/loc.api/generate-report-file/csv-writer/full-snapshot-report-csv-writer.js
index 5d191904b..044d8f04a 100644
--- a/workers/loc.api/generate-csv/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,
@@ -27,8 +27,6 @@ module.exports = (
..._params
}
const args = { ..._args, params }
- const { end } = params
- const mtsCreated = Date.now()
queue.emit('progress', 0)
@@ -49,10 +47,11 @@ module.exports = (
const res = await getDataFromApi({
getData: rService[name].bind(rService),
args,
- callerName: 'CSV_WRITER'
+ callerName: 'REPORT_FILE_WRITER'
})
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
diff --git a/workers/loc.api/generate-csv/csv-writer/full-tax-report-csv-writer.js b/workers/loc.api/generate-report-file/csv-writer/full-tax-report-csv-writer.js
similarity index 92%
rename from workers/loc.api/generate-csv/csv-writer/full-tax-report-csv-writer.js
rename to workers/loc.api/generate-report-file/csv-writer/full-tax-report-csv-writer.js
index 9d1caa0bf..c120c4547 100644
--- a/workers/loc.api/generate-csv/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,
@@ -28,8 +28,6 @@ module.exports = (
..._params
}
const args = { ..._args, params }
- const { start, end } = params
- const mtsCreated = Date.now()
queue.emit('progress', 0)
@@ -50,9 +48,10 @@ module.exports = (
const res = await getDataFromApi({
getData: rService[name].bind(rService),
args,
- callerName: 'CSV_WRITER'
+ 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-csv/csv-writer/index.js b/workers/loc.api/generate-report-file/csv-writer/index.js
similarity index 100%
rename from workers/loc.api/generate-csv/csv-writer/index.js
rename to workers/loc.api/generate-report-file/csv-writer/index.js
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..2695eda86
--- /dev/null
+++ b/workers/loc.api/generate-report-file/pdf-writer/index.js
@@ -0,0 +1,152 @@
+'use strict'
+
+const fs = require('fs/promises')
+const path = require('path')
+const argv = require('yargs').argv
+const { v4: uuidv4 } = require('uuid')
+
+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')
+const {
+ PDFBufferUnderElectronCreationError
+} = require('../../errors')
+
+const { decorateInjectable } = require('../../di/utils')
+
+const depsTypes = (TYPES) => [
+ TYPES.ROOT_FOLDER_PATH,
+ TYPES.HasGrcService,
+ TYPES.GrcBfxReq,
+ TYPES.ProcessMessageManager
+]
+class PdfWriter extends MainPdfWriter {
+ constructor (
+ rootFolderPath,
+ hasGrcService,
+ grcBfxReq,
+ processMessageManager
+ ) {
+ super(
+ rootFolderPath,
+ hasGrcService,
+ grcBfxReq
+ )
+
+ this.processMessageManager = processMessageManager
+
+ this.isElectronjsEnv = argv.isElectronjsEnv
+
+ this.addTranslations(this.loadTranslations(
+ path.join(__dirname, 'translations.yml')
+ ))
+ this.addTemplates({
+ fileNames: TEMPLATE_FILE_NAMES,
+ templateFolderPath: path.join(__dirname, 'templates')
+ })
+ this.compileTemplate()
+ }
+
+ /**
+ * @override
+ */
+ async createPDFBuffer (args) {
+ const {
+ template = 'No data',
+ format = 'portrait',
+ orientation = 'Letter',
+ headerHeight = '65mm',
+ footerHeight = '28mm'
+ } = args ?? {}
+
+ if (this.isElectronjsEnv) {
+ return await this.createPDFBufferUnderElectron({
+ template,
+ format,
+ orientation
+ })
+ }
+
+ 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',
+ timeout: 90000,
+ childProcessOptions: {
+ env: { OPENSSL_CONF: '/dev/null' }
+ }
+ }).toBuffer((error, buffer) => {
+ if (error) return reject(error)
+ resolve(buffer)
+ })
+ })
+ }
+
+ 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,
+ {
+ templateFilePath: uniqueFileName,
+ format: args?.format,
+ orientation: args?.orientation,
+ uid
+ }
+ )
+
+ const {
+ err,
+ buffer,
+ pdfFilePath
+ } = (await promise) ?? {}
+
+ if (err) {
+ throw new PDFBufferUnderElectronCreationError(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)
+ }
+}
+
+decorateInjectable(PdfWriter, depsTypes)
+
+module.exports = PdfWriter
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..bf81fafc8
--- /dev/null
+++ b/workers/loc.api/generate-report-file/pdf-writer/template-file-names.js
@@ -0,0 +1,6 @@
+'use strict'
+
+module.exports = {
+ FULL_TAX_REPORT: 'full-tax-report.pug',
+ FULL_SNAPSHOT_REPORT: '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..adbfd50ac
--- /dev/null
+++ b/workers/loc.api/generate-report-file/pdf-writer/templates/full-snapshot-report.pug
@@ -0,0 +1,83 @@
+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 ?? {}
+
+ ul.responsive-table
+ li.table-header
+ each columnVal, columnKey in reportColumns.timestamps
+ .col #{columnVal}
+ li.table-row
+ each columnVal, columnKey in reportColumns.timestamps
+ .col #{data.timestamps[columnKey]}
+
+ h3.content-title.left-text.table-title
+ :translate(prop='template.positions')
+ Positions
+
+ ul.responsive-table.no-margin-bottom
+ li.table-header
+ each columnVal, columnKey in reportColumns.positionsSnapshot
+ .col #{columnVal}
+ each dataItem, dataIndex in data.positionsSnapshot
+ li.table-row
+ each columnVal, columnKey in reportColumns.positionsSnapshot
+ .col #{dataItem[columnKey]}
+
+ ul.responsive-table.width-by-content
+ li.table-header
+ each columnVal, columnKey in reportColumns.positionsTotalPlUsd
+ .col #{columnVal}
+ li.table-row
+ each columnVal, columnKey in reportColumns.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 reportColumns.walletsSnapshot
+ .col #{columnVal}
+ each dataItem, dataIndex in data.walletsSnapshot
+ li.table-row
+ each columnVal, columnKey in reportColumns.walletsSnapshot
+ .col #{dataItem[columnKey]}
+
+ ul.responsive-table.width-by-content
+ li.table-header
+ each columnVal, columnKey in reportColumns.walletsTotalBalanceUsd
+ .col #{columnVal}
+ li.table-row
+ each columnVal, columnKey in reportColumns.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 reportColumns.positionsTickers
+ .col #{columnVal}
+ each dataItem, dataIndex in data.positionsTickers
+ li.table-row
+ each columnVal, columnKey in reportColumns.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 reportColumns.walletsTickers
+ .col #{columnVal}
+ each dataItem, dataIndex in data.walletsTickers
+ li.table-row
+ 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
new file mode 100644
index 000000000..3c524322b
--- /dev/null
+++ b/workers/loc.api/generate-report-file/pdf-writer/templates/full-tax-report.pug
@@ -0,0 +1,95 @@
+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 reportColumns.timestamps
+ .col #{columnVal}
+ li.table-row
+ each columnVal, columnKey in reportColumns.timestamps
+ .col #{data.timestamps[columnKey]}
+
+ h3.content-title.left-text.table-title
+ :translate(prop='template.startingPositionsSnapshot')
+ Starting positions snapshot
+
+ ul.responsive-table
+ li.table-header
+ each columnVal, columnKey in reportColumns.positionsSnapshot
+ .col #{columnVal}
+ each dataItem, dataIndex in data.startingPositionsSnapshot
+ li.table-row
+ each columnVal, columnKey in reportColumns.positionsSnapshot
+ .col #{dataItem[columnKey]}
+
+ h3.content-title.left-text.table-title
+ :translate(prop='template.endingPositionsSnapshot')
+ Ending positions snapshot
+
+ ul.responsive-table
+ li.table-header
+ each columnVal, columnKey in reportColumns.positionsSnapshot
+ .col #{columnVal}
+ each dataItem, dataIndex in data.endingPositionsSnapshot
+ li.table-row
+ each columnVal, columnKey in reportColumns.positionsSnapshot
+ .col #{dataItem[columnKey]}
+
+ h3.content-title.uppercase-text
+ :translate(prop='template.finalState')
+ Final state
+
+ h3.content-title.left-text.table-title
+ :translate(prop='template.startingPeriodBalances')
+ Starting period balances
+
+ ul.responsive-table
+ li.table-header
+ each columnVal, columnKey in reportColumns.periodBalances
+ .col #{columnVal}
+ li.table-row
+ each columnVal, columnKey in reportColumns.periodBalances
+ .col #{data.finalState.startingPeriodBalances[columnKey]}
+
+ h3.content-title.left-text.table-title
+ :translate(prop='template.movementsDetails')
+ Movements details
+
+ ul.responsive-table.no-margin-bottom
+ li.table-header
+ each columnVal, columnKey in reportColumns.movements
+ .col #{columnVal}
+ each dataItem, dataIndex in data.finalState.movements
+ li.table-row
+ each columnVal, columnKey in reportColumns.movements
+ .col #{dataItem[columnKey]}
+
+ ul.responsive-table.width-by-content
+ li.table-header
+ each columnVal, columnKey in reportColumns.movementsTotalAmount
+ .col #{columnVal}
+ li.table-row
+ each columnVal, columnKey in reportColumns.movementsTotalAmount
+ .col #{data.finalState[columnKey]}
+
+ h3.content-title.left-text.table-title
+ :translate(prop='template.endingPeriodBalances')
+ Ending period balances
+
+ ul.responsive-table.no-margin-bottom
+ li.table-header
+ each columnVal, columnKey in reportColumns.periodBalances
+ .col #{columnVal}
+ li.table-row
+ each columnVal, columnKey in reportColumns.periodBalances
+ .col #{data.finalState.endingPeriodBalances[columnKey]}
+
+ ul.responsive-table.width-by-content
+ li.table-header
+ each columnVal, columnKey in reportColumns.totalResult
+ .col #{columnVal}
+ li.table-row
+ each columnVal, columnKey in reportColumns.totalResult
+ .col #{data.finalState[columnKey]}
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..30cc29feb
--- /dev/null
+++ b/workers/loc.api/generate-report-file/pdf-writer/translations.yml
@@ -0,0 +1,25 @@
+en:
+ template:
+ startingPositionsSnapshot: Starting positions snapshot
+ endingPositionsSnapshot: Ending positions snapshot
+ finalState: Final state
+ startingPeriodBalances: Starting period balances
+ movementsDetails: Movements details
+ endingPeriodBalances: Ending period balances
+ positions: Positions
+ wallets: Wallets
+ positionsTickers: Positions tickers
+ walletsTickers: Wallets tickers
+
+ru:
+ template:
+ startingPositionsSnapshot: Снимок стартовых позиций
+ endingPositionsSnapshot: Снимок конечных позиций
+ finalState: Конечное состояние
+ startingPeriodBalances: Остатки на начало периода
+ movementsDetails: Детали движений
+ endingPeriodBalances: Остатки на конец периода
+ positions: Позиции
+ wallets: Кошельки
+ positionsTickers: Тикеры позиций
+ walletsTickers: Тикеры кошельков
diff --git a/workers/loc.api/generate-csv/csv.job.data.js b/workers/loc.api/generate-report-file/report.file.job.data.js
similarity index 79%
rename from workers/loc.api/generate-csv/csv.job.data.js
rename to workers/loc.api/generate-report-file/report.file.job.data.js
index 2981d0876..430725f1c 100644
--- a/workers/loc.api/generate-csv/csv.job.data.js
+++ b/workers/loc.api/generate-report-file/report.file.job.data.js
@@ -2,11 +2,11 @@
const { omit } = require('lib-js-util-base')
-const BaseCsvJobData = require(
- 'bfx-report/workers/loc.api/generate-csv/csv.job.data'
+const BaseReportFileJobData = require(
+ 'bfx-report/workers/loc.api/generate-report-file/report.file.job.data'
)
const {
- getCsvArgs,
+ getReportFileArgs,
checkJobAndGetUserData
} = require('bfx-report/workers/loc.api/helpers')
@@ -14,6 +14,7 @@ const {
checkParams,
getDateString
} = require('../helpers')
+const TEMPLATE_FILE_NAMES = require('./pdf-writer/template-file-names')
const { decorateInjectable } = require('../di/utils')
@@ -23,7 +24,7 @@ const depsTypes = (TYPES) => [
TYPES.FullTaxReportCsvWriter,
TYPES.WeightedAveragesReportCsvWriter
]
-class CsvJobData extends BaseCsvJobData {
+class ReportFileJobData extends BaseReportFileJobData {
constructor (
rService,
fullSnapshotReportCsvWriter,
@@ -50,12 +51,12 @@ class CsvJobData extends BaseCsvJobData {
}, {})
}
- async getMovementsCsvJobData (
+ async getMovementsFileJobData (
args,
uId,
uInfo
) {
- const _jobData = await super.getMovementsCsvJobData(
+ const _jobData = await super.getMovementsFileJobData(
args,
uId,
uInfo
@@ -76,12 +77,12 @@ class CsvJobData extends BaseCsvJobData {
return jobData
}
- async getLedgersCsvJobData (
+ async getLedgersFileJobData (
args,
uId,
uInfo
) {
- const _jobData = await super.getLedgersCsvJobData(
+ const _jobData = await super.getLedgersFileJobData(
args,
uId,
uInfo
@@ -105,12 +106,12 @@ class CsvJobData extends BaseCsvJobData {
return jobData
}
- async getWalletsCsvJobData (
+ async getWalletsFileJobData (
args,
uId,
uInfo
) {
- const _jobData = await super.getWalletsCsvJobData(
+ const _jobData = await super.getWalletsFileJobData(
args,
uId,
uInfo
@@ -127,12 +128,12 @@ class CsvJobData extends BaseCsvJobData {
return jobData
}
- async getBalanceHistoryCsvJobData (
+ async getBalanceHistoryFileJobData (
args,
uId,
uInfo
) {
- checkParams(args, 'paramsSchemaForBalanceHistoryCsv')
+ checkParams(args, 'paramsSchemaForBalanceHistoryFile')
const {
userId,
@@ -143,14 +144,14 @@ class CsvJobData extends BaseCsvJobData {
uInfo
)
- const csvArgs = getCsvArgs(args)
+ const reportFileArgs = getReportFileArgs(args)
const jobData = {
userInfo,
userId,
name: 'getBalanceHistory',
fileNamesMap: [['getBalanceHistory', 'balance-history']],
- args: csvArgs,
+ args: reportFileArgs,
propNameForPagination: null,
columnsCsv: {
USD: 'USD',
@@ -164,12 +165,12 @@ class CsvJobData extends BaseCsvJobData {
return jobData
}
- async getWinLossCsvJobData (
+ async getWinLossFileJobData (
args,
uId,
uInfo
) {
- checkParams(args, 'paramsSchemaForWinLossCsv')
+ checkParams(args, 'paramsSchemaForWinLossFile')
const {
userId,
@@ -180,14 +181,14 @@ class CsvJobData extends BaseCsvJobData {
uInfo
)
- const csvArgs = getCsvArgs(args)
+ const reportFileArgs = getReportFileArgs(args)
const jobData = {
userInfo,
userId,
name: 'getWinLoss',
fileNamesMap: [['getWinLoss', 'win-loss']],
- args: csvArgs,
+ args: reportFileArgs,
propNameForPagination: null,
columnsCsv: {
USD: 'USD',
@@ -201,12 +202,12 @@ class CsvJobData extends BaseCsvJobData {
return jobData
}
- async getPositionsSnapshotCsvJobData (
+ async getPositionsSnapshotFileJobData (
args,
uId,
uInfo
) {
- checkParams(args, 'paramsSchemaForPositionsSnapshotCsv')
+ checkParams(args, 'paramsSchemaForPositionsSnapshotFile')
const {
userId,
@@ -217,14 +218,14 @@ class CsvJobData extends BaseCsvJobData {
uInfo
)
- const csvArgs = getCsvArgs(args)
+ const reportFileArgs = getReportFileArgs(args)
const jobData = {
userInfo,
userId,
name: 'getPositionsSnapshot',
fileNamesMap: [['getPositionsSnapshot', 'positions-snapshot']],
- args: csvArgs,
+ args: reportFileArgs,
propNameForPagination: null,
columnsCsv: {
id: '#',
@@ -251,13 +252,13 @@ class CsvJobData extends BaseCsvJobData {
return jobData
}
- async getFullSnapshotReportCsvJobData (
+ async getFullSnapshotReportFileJobData (
args,
uId,
uInfo,
opts
) {
- checkParams(args, 'paramsSchemaForFullSnapshotReportCsv')
+ checkParams(args, 'paramsSchemaForFullSnapshotReportFile')
const {
userId,
@@ -300,7 +301,7 @@ class CsvJobData extends BaseCsvJobData {
? _chunkCommonFolder
: `${uName}full-snapshot-report_TO_${endDate}`
- const csvArgs = getCsvArgs(
+ const reportFileArgs = getReportFileArgs(
args,
null,
{ isBaseNameInName: true }
@@ -312,7 +313,7 @@ class CsvJobData extends BaseCsvJobData {
userId,
name: 'getFullSnapshotReport',
fileNamesMap: [['getFullSnapshotReport', fileName]],
- args: csvArgs,
+ args: reportFileArgs,
columnsCsv: {
timestamps: {
mtsCreated: 'CREATED',
@@ -349,10 +350,10 @@ class CsvJobData extends BaseCsvJobData {
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: {
@@ -376,13 +377,14 @@ class CsvJobData extends BaseCsvJobData {
symbol: 'symbol'
}
},
- csvCustomWriter: this.fullSnapshotReportCsvWriter
+ csvCustomWriter: this.fullSnapshotReportCsvWriter,
+ pdfCustomTemplateName: TEMPLATE_FILE_NAMES.FULL_SNAPSHOT_REPORT
}
return jobData
}
- async getFullTaxReportCsvJobData (
+ async getFullTaxReportFileJobData (
args,
uId,
uInfo
@@ -408,7 +410,7 @@ class CsvJobData extends BaseCsvJobData {
if (isStartSnapshot || isEndSnapshot) {
const mts = isStartSnapshot ? start : end
- return this.getFullSnapshotReportCsvJobData(
+ return this.getFullSnapshotReportFileJobData(
{
...args,
params: {
@@ -425,7 +427,7 @@ class CsvJobData extends BaseCsvJobData {
)
}
- checkParams(args, 'paramsSchemaForFullTaxReportCsv')
+ checkParams(args, 'paramsSchemaForFullTaxReportFile')
const {
userId,
@@ -436,7 +438,7 @@ class CsvJobData extends BaseCsvJobData {
uInfo
)
- const csvArgs = getCsvArgs(
+ const reportFileArgs = getReportFileArgs(
args,
null,
{ isBaseNameInName: true }
@@ -448,7 +450,11 @@ class CsvJobData extends BaseCsvJobData {
userId,
name: 'getFullTaxReport',
fileNamesMap: [['getFullTaxReport', 'full-tax-report_FULL_PERIOD']],
- args: csvArgs,
+ args: reportFileArgs,
+ /*
+ * Example how to overwrite column order for pdf
+ * columnsPdf: {},
+ */
columnsCsv: {
timestamps: {
mtsCreated: 'CREATED',
@@ -499,27 +505,35 @@ class CsvJobData extends BaseCsvJobData {
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
+ csvCustomWriter: this.fullTaxReportCsvWriter,
+ pdfCustomTemplateName: TEMPLATE_FILE_NAMES.FULL_TAX_REPORT
}
return jobData
}
- async getTradedVolumeCsvJobData (
+ async getTradedVolumeFileJobData (
args,
uId,
uInfo
) {
- checkParams(args, 'paramsSchemaForTradedVolumeCsv')
+ checkParams(args, 'paramsSchemaForTradedVolumeFile')
const {
userId,
@@ -530,14 +544,14 @@ class CsvJobData extends BaseCsvJobData {
uInfo
)
- const csvArgs = getCsvArgs(args)
+ const reportFileArgs = getReportFileArgs(args)
const jobData = {
userInfo,
userId,
name: 'getTradedVolume',
fileNamesMap: [['getTradedVolume', 'traded-volume']],
- args: csvArgs,
+ args: reportFileArgs,
propNameForPagination: null,
columnsCsv: {
USD: 'USD',
@@ -551,12 +565,12 @@ class CsvJobData extends BaseCsvJobData {
return jobData
}
- async getTotalFeesReportCsvJobData (
+ async getTotalFeesReportFileJobData (
args,
uId,
uInfo
) {
- checkParams(args, 'paramsSchemaForTotalFeesReportCsv')
+ checkParams(args, 'paramsSchemaForTotalFeesReportFile')
const {
userId,
@@ -567,14 +581,14 @@ class CsvJobData extends BaseCsvJobData {
uInfo
)
- const csvArgs = getCsvArgs(args)
+ const reportFileArgs = getReportFileArgs(args)
const jobData = {
userInfo,
userId,
name: 'getTotalFeesReport',
fileNamesMap: [['getTotalFeesReport', 'total-fees-report']],
- args: csvArgs,
+ args: reportFileArgs,
propNameForPagination: null,
columnsCsv: {
USD: 'USD',
@@ -589,12 +603,12 @@ class CsvJobData extends BaseCsvJobData {
return jobData
}
- async getPerformingLoanCsvJobData (
+ async getPerformingLoanFileJobData (
args,
uId,
uInfo
) {
- checkParams(args, 'paramsSchemaForPerformingLoanCsv')
+ checkParams(args, 'paramsSchemaForPerformingLoanFile')
const {
userId,
@@ -605,14 +619,14 @@ class CsvJobData extends BaseCsvJobData {
uInfo
)
- const csvArgs = getCsvArgs(args)
+ const reportFileArgs = getReportFileArgs(args)
const jobData = {
userInfo,
userId,
name: 'getPerformingLoan',
fileNamesMap: [['getPerformingLoan', 'performing-loan']],
- args: csvArgs,
+ args: reportFileArgs,
propNameForPagination: null,
columnsCsv: {
USD: 'USD',
@@ -628,12 +642,12 @@ class CsvJobData extends BaseCsvJobData {
return jobData
}
- async getWinLossVSAccountBalanceCsvJobData (
+ async getWinLossVSAccountBalanceFileJobData (
args,
uId,
uInfo
) {
- checkParams(args, 'paramsSchemaForWinLossVSAccountBalanceCsv')
+ checkParams(args, 'paramsSchemaForWinLossVSAccountBalanceFile')
const {
userId,
@@ -644,7 +658,7 @@ class CsvJobData extends BaseCsvJobData {
uInfo
)
- const csvArgs = getCsvArgs(args)
+ const reportFileArgs = getReportFileArgs(args)
const suffix = args?.params?.isVSPrevDayBalance
? 'balance'
: 'deposits'
@@ -657,7 +671,7 @@ class CsvJobData extends BaseCsvJobData {
'getWinLossVSAccountBalance',
`win-loss-percentage-gains-vs-${suffix}`
]],
- args: csvArgs,
+ args: reportFileArgs,
propNameForPagination: null,
columnsCsv: {
perc: 'PERCENT',
@@ -672,6 +686,6 @@ class CsvJobData extends BaseCsvJobData {
}
}
-decorateInjectable(CsvJobData, depsTypes)
+decorateInjectable(ReportFileJobData, depsTypes)
-module.exports = CsvJobData
+module.exports = ReportFileJobData
diff --git a/workers/loc.api/helpers/check-params.js b/workers/loc.api/helpers/check-params.js
index 8e50f958b..c90ddf5dc 100644
--- a/workers/loc.api/helpers/check-params.js
+++ b/workers/loc.api/helpers/check-params.js
@@ -8,7 +8,7 @@ const schema = require('./schema')
module.exports = (
args,
- schemaName = 'paramsSchemaForCsv',
+ schemaName = 'paramsSchemaForFile',
requireFields = [],
checkParamsField = false
) => {
diff --git a/workers/loc.api/helpers/schema.js b/workers/loc.api/helpers/schema.js
index af5fcecc8..db81e9197 100644
--- a/workers/loc.api/helpers/schema.js
+++ b/workers/loc.api/helpers/schema.js
@@ -3,7 +3,7 @@
const { cloneDeep } = require('lib-js-util-base')
const {
- paramsSchemaForCsv,
+ paramsSchemaForFile,
paramsSchemaForCandlesApi: baseParamsSchemaForCandlesApi
} = require('bfx-report/workers/loc.api/helpers/schema')
@@ -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'
@@ -352,9 +352,9 @@ const paramsSchemaForSummaryByAssetApi = {
const {
timezone,
dateFormat
-} = { ...paramsSchemaForCsv.properties }
+} = { ...paramsSchemaForFile.properties }
-const paramsSchemaForBalanceHistoryCsv = {
+const paramsSchemaForBalanceHistoryFile = {
type: 'object',
properties: {
...cloneDeep(paramsSchemaForBalanceHistoryApi.properties),
@@ -363,7 +363,7 @@ const paramsSchemaForBalanceHistoryCsv = {
}
}
-const paramsSchemaForWinLossCsv = {
+const paramsSchemaForWinLossFile = {
type: 'object',
properties: {
...cloneDeep(paramsSchemaForWinLossApi.properties),
@@ -372,7 +372,7 @@ const paramsSchemaForWinLossCsv = {
}
}
-const paramsSchemaForWinLossVSAccountBalanceCsv = {
+const paramsSchemaForWinLossVSAccountBalanceFile = {
type: 'object',
properties: {
...cloneDeep(paramsSchemaForWinLossVSAccountBalanceApi.properties),
@@ -381,7 +381,7 @@ const paramsSchemaForWinLossVSAccountBalanceCsv = {
}
}
-const paramsSchemaForPositionsSnapshotCsv = {
+const paramsSchemaForPositionsSnapshotFile = {
type: 'object',
properties: {
end: {
@@ -392,7 +392,7 @@ const paramsSchemaForPositionsSnapshotCsv = {
}
}
-const paramsSchemaForFullSnapshotReportCsv = {
+const paramsSchemaForFullSnapshotReportFile = {
type: 'object',
properties: {
end: {
@@ -403,7 +403,7 @@ const paramsSchemaForFullSnapshotReportCsv = {
}
}
-const paramsSchemaForFullTaxReportCsv = {
+const paramsSchemaForFullTaxReportFile = {
type: 'object',
properties: {
...cloneDeep(paramsSchemaForFullTaxReportApi.properties),
@@ -412,7 +412,7 @@ const paramsSchemaForFullTaxReportCsv = {
}
}
-const paramsSchemaForTradedVolumeCsv = {
+const paramsSchemaForTradedVolumeFile = {
type: 'object',
properties: {
...cloneDeep(paramsSchemaForTradedVolumeApi.properties),
@@ -421,7 +421,7 @@ const paramsSchemaForTradedVolumeCsv = {
}
}
-const paramsSchemaForTotalFeesReportCsv = {
+const paramsSchemaForTotalFeesReportFile = {
type: 'object',
properties: {
...cloneDeep(paramsSchemaForTotalFeesReportApi.properties),
@@ -430,7 +430,7 @@ const paramsSchemaForTotalFeesReportCsv = {
}
}
-const paramsSchemaForPerformingLoanCsv = {
+const paramsSchemaForPerformingLoanFile = {
type: 'object',
properties: {
...cloneDeep(paramsSchemaForPerformingLoanApi.properties),
@@ -439,7 +439,7 @@ const paramsSchemaForPerformingLoanCsv = {
}
}
-const paramsSchemaForCandlesCsv = {
+const paramsSchemaForCandlesFile = {
type: 'object',
properties: {
...cloneDeep(paramsSchemaForCandlesApi.properties),
@@ -449,9 +449,9 @@ const paramsSchemaForCandlesCsv = {
}
module.exports = {
- paramsSchemaForEditAllPublicСollsСonfs,
- paramsSchemaForEditPublicСollsСonf,
- paramsSchemaForEditCandlesСonf,
+ paramsSchemaForEditAllPublicCollsConfs,
+ paramsSchemaForEditPublicCollsConf,
+ paramsSchemaForEditCandlesConf,
paramsSchemaForCreateSubAccount,
paramsSchemaForUpdateSubAccount,
paramsSchemaForBalanceHistoryApi,
@@ -465,14 +465,14 @@ module.exports = {
paramsSchemaForPerformingLoanApi,
paramsSchemaForCandlesApi,
paramsSchemaForSummaryByAssetApi,
- paramsSchemaForBalanceHistoryCsv,
- paramsSchemaForWinLossCsv,
- paramsSchemaForWinLossVSAccountBalanceCsv,
- paramsSchemaForPositionsSnapshotCsv,
- paramsSchemaForFullSnapshotReportCsv,
- paramsSchemaForFullTaxReportCsv,
- paramsSchemaForTradedVolumeCsv,
- paramsSchemaForTotalFeesReportCsv,
- paramsSchemaForPerformingLoanCsv,
- paramsSchemaForCandlesCsv
+ paramsSchemaForBalanceHistoryFile,
+ paramsSchemaForWinLossFile,
+ paramsSchemaForWinLossVSAccountBalanceFile,
+ paramsSchemaForPositionsSnapshotFile,
+ paramsSchemaForFullSnapshotReportFile,
+ paramsSchemaForFullTaxReportFile,
+ paramsSchemaForTradedVolumeFile,
+ paramsSchemaForTotalFeesReportFile,
+ paramsSchemaForPerformingLoanFile,
+ paramsSchemaForCandlesFile
}
diff --git a/workers/loc.api/process.message.manager/index.js b/workers/loc.api/process.message.manager/index.js
index f8d83cf81..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) {
@@ -92,7 +108,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 +123,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)) {
diff --git a/workers/loc.api/process.message.manager/process.messages.js b/workers/loc.api/process.message.manager/process.messages.js
index 4ac7fc5de..07aaad4e3 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',
+
+ 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 2b548f74a..348f33f9c 100644
--- a/workers/loc.api/process.message.manager/process.states.js
+++ b/workers/loc.api/process.message.manager/process.states.js
@@ -11,5 +11,7 @@ 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',
+
+ RESPONSE_PDF_CREATION: 'response:pdf-creation'
}
diff --git a/workers/loc.api/service.report.framework.js b/workers/loc.api/service.report.framework.js
index 6878b21f3..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,
@@ -1466,108 +1466,164 @@ class FrameworkReportService extends ReportService {
}
/**
+ * @deprecated
* @override
*/
- getMultipleCsv (space, args, cb) {
+ getMultipleCsv (...args) { return this.getMultipleFile(...args) }
+
+ /**
+ * @override
+ */
+ getMultipleFile (space, args, cb) {
return this._responder(() => {
- return this._generateCsv(
- 'getMultipleCsvJobData',
+ return this._generateReportFile(
+ 'getMultipleFileJobData',
args
)
- }, 'getMultipleCsv', args, cb)
+ }, 'getMultipleFile', args, cb)
}
- getBalanceHistoryCsv (space, args, cb) {
+ /**
+ * @deprecated
+ */
+ getBalanceHistoryCsv (...args) { return this.getBalanceHistoryFile(...args) }
+
+ getBalanceHistoryFile (space, args, cb) {
return this._responder(() => {
- return this._generateCsv(
- 'getBalanceHistoryCsvJobData',
+ return this._generateReportFile(
+ 'getBalanceHistoryFileJobData',
args
)
- }, 'getBalanceHistoryCsv', args, cb)
+ }, 'getBalanceHistoryFile', args, cb)
}
- getWinLossCsv (space, args, cb) {
+ /**
+ * @deprecated
+ */
+ getWinLossCsv (...args) { return this.getWinLossFile(...args) }
+
+ getWinLossFile (space, args, cb) {
return this._responder(() => {
- return this._generateCsv(
- 'getWinLossCsvJobData',
+ return this._generateReportFile(
+ 'getWinLossFileJobData',
args
)
- }, 'getWinLossCsv', args, cb)
+ }, 'getWinLossFile', args, cb)
}
- getPositionsSnapshotCsv (space, args, cb) {
+ /**
+ * @deprecated
+ */
+ getPositionsSnapshotCsv (...args) { return this.getPositionsSnapshotFile(...args) }
+
+ getPositionsSnapshotFile (space, args, cb) {
return this._responder(() => {
- return this._generateCsv(
- 'getPositionsSnapshotCsvJobData',
+ return this._generateReportFile(
+ 'getPositionsSnapshotFileJobData',
args
)
- }, 'getPositionsSnapshotCsv', args, cb)
+ }, 'getPositionsSnapshotFile', args, cb)
}
- getFullSnapshotReportCsv (space, args, cb) {
+ /**
+ * @deprecated
+ */
+ getFullSnapshotReportCsv (...args) { return this.getFullSnapshotReportFile(...args) }
+
+ getFullSnapshotReportFile (space, args, cb) {
return this._responder(() => {
- return this._generateCsv(
- 'getFullSnapshotReportCsvJobData',
+ return this._generateReportFile(
+ 'getFullSnapshotReportFileJobData',
args
)
- }, 'getFullSnapshotReportCsv', args, cb)
+ }, 'getFullSnapshotReportFile', args, cb)
}
- getFullTaxReportCsv (space, args, cb) {
+ /**
+ * @deprecated
+ */
+ getFullTaxReportCsv (...args) { return this.getFullTaxReportFile(...args) }
+
+ getFullTaxReportFile (space, args, cb) {
return this._responder(() => {
- return this._generateCsv(
- 'getFullTaxReportCsvJobData',
+ return this._generateReportFile(
+ 'getFullTaxReportFileJobData',
args
)
- }, 'getFullTaxReportCsv', args, cb)
+ }, 'getFullTaxReportFile', args, cb)
}
- getTradedVolumeCsv (space, args, cb) {
+ /**
+ * @deprecated
+ */
+ getTradedVolumeCsv (...args) { return this.getTradedVolumeFile(...args) }
+
+ getTradedVolumeFile (space, args, cb) {
return this._responder(() => {
- return this._generateCsv(
- 'getTradedVolumeCsvJobData',
+ return this._generateReportFile(
+ 'getTradedVolumeFileJobData',
args
)
- }, 'getTradedVolumeCsv', args, cb)
+ }, 'getTradedVolumeFile', args, cb)
}
- getTotalFeesReportCsv (space, args, cb) {
+ /**
+ * @deprecated
+ */
+ getTotalFeesReportCsv (...args) { return this.getTotalFeesReportFile(...args) }
+
+ getTotalFeesReportFile (space, args, cb) {
return this._responder(() => {
- return this._generateCsv(
- 'getTotalFeesReportCsvJobData',
+ return this._generateReportFile(
+ 'getTotalFeesReportFileJobData',
args
)
- }, 'getTotalFeesReportCsv', args, cb)
+ }, 'getTotalFeesReportFile', args, cb)
}
- getPerformingLoanCsv (space, args, cb) {
+ /**
+ * @deprecated
+ */
+ getPerformingLoanCsv (...args) { return this.getPerformingLoanFile(...args) }
+
+ getPerformingLoanFile (space, args, cb) {
return this._responder(() => {
- return this._generateCsv(
- 'getPerformingLoanCsvJobData',
+ return this._generateReportFile(
+ 'getPerformingLoanFileJobData',
args
)
- }, 'getPerformingLoanCsv', args, cb)
+ }, 'getPerformingLoanFile', args, cb)
}
- getCandlesCsv (space, args, cb) {
+ /**
+ * @deprecated
+ */
+ getCandlesCsv (...args) { return this.getCandlesFile(...args) }
+
+ getCandlesFile (space, args, cb) {
return this._responder(async () => {
if (!await this.isSyncModeWithDbData(space, args)) {
- return super.getCandlesCsv(space, args)
+ return super.getCandlesFile(space, args)
}
- checkParams(args, 'paramsSchemaForCandlesCsv')
+ checkParams(args, 'paramsSchemaForCandlesFile')
- return super.getCandlesCsv(space, args)
- }, 'getCandlesCsv', args, cb)
+ return super.getCandlesFile(space, args)
+ }, 'getCandlesFile', args, cb)
}
- getWinLossVSAccountBalanceCsv (space, args, cb) {
+ /**
+ * @deprecated
+ */
+ getWinLossVSAccountBalanceCsv (...args) { return this.getWinLossVSAccountBalanceFile(...args) }
+
+ getWinLossVSAccountBalanceFile (space, args, cb) {
return this._responder(() => {
- return this._generateCsv(
- 'getWinLossVSAccountBalanceCsvJobData',
+ return this._generateReportFile(
+ 'getWinLossVSAccountBalanceFileJobData',
args
)
- }, 'getWinLossVSAccountBalanceCsv', args, cb)
+ }, 'getWinLossVSAccountBalanceFile', args, cb)
}
}
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()
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
}
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,
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: {
diff --git a/workers/loc.api/ws-transport/ws.event.emitter.js b/workers/loc.api/ws-transport/ws.event.emitter.js
index 2a2001abc..d60487e09 100644
--- a/workers/loc.api/ws-transport/ws.event.emitter.js
+++ b/workers/loc.api/ws-transport/ws.event.emitter.js
@@ -73,6 +73,9 @@ class WSEventEmitter extends AbstractWSEventEmitter {
})
}
+ /**
+ * @deprecated
+ */
emitCsvGenerationCompletedToOne (
handler = () => {},
auth = {}
@@ -88,6 +91,23 @@ class WSEventEmitter extends AbstractWSEventEmitter {
}, 'emitCsvGenerationCompletedToOne')
}
+ async emitReportFileGenerationCompletedToOne (
+ handler = () => {},
+ auth = {}
+ ) {
+ await this.emitCsvGenerationCompletedToOne(handler, auth)
+
+ return this.emit(async (user, ...args) => {
+ if (this.isNotTargetUser(auth, user)) {
+ return { isNotEmitted: true }
+ }
+
+ return typeof handler === 'function'
+ ? await handler(user, ...args)
+ : handler
+ }, 'emitReportFileGenerationCompletedToOne')
+ }
+
emitBfxUnamePwdAuthRequiredToOne (
handler = () => {},
auth = {}