diff --git a/.npmrc b/.npmrc index cffe8cdef..dcdeb5fbb 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1,2 @@ save-exact=true +foreground-scripts=true diff --git a/bfx-report-ui b/bfx-report-ui index 081912542..23c4be0bb 160000 --- a/bfx-report-ui +++ b/bfx-report-ui @@ -1 +1 @@ -Subproject commit 08191254267cbe608a35b8ec160edab4cd8fe4ea +Subproject commit 23c4be0bbfd1fd8dfde411e7cf7abd2e08c96e98 diff --git a/package-lock.json b/package-lock.json index 91bce0a31..5cec6e1b4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bfx-reports-framework", - "version": "4.22.5", + "version": "4.23.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "bfx-reports-framework", - "version": "4.22.5", + "version": "4.23.0", "license": "Apache-2.0", "dependencies": { "better-npm-run": "0.1.1", @@ -1395,8 +1395,8 @@ } }, "node_modules/bfx-report": { - "version": "4.12.6", - "resolved": "git+ssh://git@github.com/bitfinexcom/bfx-report.git#19609fc1681730017c6d1b96f5b044d08a82c5bd", + "version": "4.13.0", + "resolved": "git+ssh://git@github.com/bitfinexcom/bfx-report.git#197542337c46a54e17dec32bd89fcd44f4be7fec", "license": "Apache-2.0", "dependencies": { "ajv": "8.17.1", diff --git a/package.json b/package.json index 76fcedcef..fa48288a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bfx-reports-framework", - "version": "4.22.5", + "version": "4.23.0", "description": "Bitfinex reports framework", "main": "worker.js", "license": "Apache-2.0", 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 280992c0b..f2b957ceb 100644 --- a/test/test-cases/api-sync-mode-sqlite-test-cases.js +++ b/test/test-cases/api-sync-mode-sqlite-test-cases.js @@ -1452,52 +1452,6 @@ module.exports = ( ]) }) - it('it should be successfully performed by the getPayInvoiceList method', async function () { - this.timeout(5000) - - const res = await agent - .post(`${basePath}/json-rpc`) - .type('json') - .send({ - auth, - method: 'getPayInvoiceList', - params: { - start: 0, - end, - limit: 2 - }, - id: 5 - }) - .expect('Content-Type', /json/) - .expect(200) - - assert.isObject(res.body) - assert.propertyVal(res.body, 'id', 5) - assert.isObject(res.body.result) - assert.isArray(res.body.result.res) - assert.isNumber(res.body.result.nextPage) - - const resItem = res.body.result.res[0] - - assert.isObject(resItem) - assert.containsAllKeys(resItem, [ - 'id', - 't', - 'duration', - 'amount', - 'currency', - 'orderId', - 'payCurrencies', - 'webhook', - 'redirectUrl', - 'status', - 'customerInfo', - 'invoices', - 'payment', - 'merchantName' - ]) - }) - it('it should be successfully performed by the getTrades method', async function () { this.timeout(5000) @@ -2767,34 +2721,6 @@ module.exports = ( await testMethodOfGettingReportFile(procPromise, aggrPromise, res) }) - it('it should be successfully performed by the getPayInvoiceListFile method', async function () { - this.timeout(60000) - - const procPromise = queueToPromise(params.processorQueue) - const aggrPromise = queueToPromise(params.aggregatorQueue) - - const res = await agent - .post(`${basePath}/json-rpc`) - .type('json') - .send({ - auth, - method: 'getPayInvoiceListFile', - params: { - isPDFRequired, - end, - start, - limit: 100, - timezone: -3, - email - }, - id: 5 - }) - .expect('Content-Type', /json/) - .expect(200) - - await testMethodOfGettingReportFile(procPromise, aggrPromise, res) - }) - it('it should be successfully performed by the getTradesFile method', async function () { this.timeout(60000) diff --git a/workers/loc.api/bfx.api.router/index.js b/workers/loc.api/bfx.api.router/index.js index cabbba25f..2c63b640e 100644 --- a/workers/loc.api/bfx.api.router/index.js +++ b/workers/loc.api/bfx.api.router/index.js @@ -41,7 +41,6 @@ class BfxApiRouter extends BaseBfxApiRouter { ['positionsAudit', 90], ['wallets', 90], ['ledgers', 90], - ['payInvoiceList', 90], ['accountTrades', 90], ['fundingTrades', 90], ['trades', 10], diff --git a/workers/loc.api/service.report.framework.js b/workers/loc.api/service.report.framework.js index f353d84e1..74ca7200a 100644 --- a/workers/loc.api/service.report.framework.js +++ b/workers/loc.api/service.report.framework.js @@ -718,28 +718,6 @@ class FrameworkReportService extends ReportService { }, 'getLedgers', args, cb) } - /** - * @override - */ - getPayInvoiceList (space, args, cb) { - return this._privResponder(async () => { - if (!await this.isSyncModeWithDbData(space, args)) { - return this._subAccountApiData - .getDataForSubAccount( - (args) => super.getPayInvoiceList(space, args), - args, - { datePropName: 't' } - ) - } - - return this._dao.findInCollBy( - this._SYNC_API_METHODS.PAY_INVOICE_LIST, - args, - { isPrepareResponse: true, shouldParamsBeVerified: true } - ) - }, 'getPayInvoiceList', args, cb) - } - /** * @override */ diff --git a/workers/loc.api/service.report.js b/workers/loc.api/service.report.js index 1183c430b..0b212cc27 100644 --- a/workers/loc.api/service.report.js +++ b/workers/loc.api/service.report.js @@ -19,10 +19,6 @@ class ReportService extends BaseReportService { return super.getLedgers(null, args) } - [SYNC_API_METHODS.PAY_INVOICE_LIST] (args) { - return super.getPayInvoiceList(null, args) - } - [SYNC_API_METHODS.TRADES] (args) { return super.getTrades(null, args) } diff --git a/workers/loc.api/sync/dao/dao.better.sqlite.js b/workers/loc.api/sync/dao/dao.better.sqlite.js index e5bf46bc7..9dc7a18ff 100644 --- a/workers/loc.api/sync/dao/dao.better.sqlite.js +++ b/workers/loc.api/sync/dao/dao.better.sqlite.js @@ -5,9 +5,6 @@ const setImmediatePromise = promisify(setImmediate) const MAIN_DB_WORKER_ACTIONS = require( 'bfx-facs-db-better-sqlite/worker/db-worker-actions/db-worker-actions.const' ) -const { - normalizeFilterParams -} = require('bfx-report/workers/loc.api/helpers') const { getValidationSchemaId, getFilterValidationSchemaId @@ -913,7 +910,7 @@ class BetterSqliteDAO extends DAO { */ async findInCollBy ( method, - reqArgs, + args, opts ) { const { @@ -932,13 +929,12 @@ class BetterSqliteDAO extends DAO { : this._getMethodCollMap().get(method) const apiMethodName = filterModelNameMap.get(method) ?? {} - const args = normalizeFilterParams(apiMethodName, reqArgs) if (shouldParamsBeVerified) { const schemaId = getValidationSchemaId(apiMethodName) const filterSchemaId = getFilterValidationSchemaId(apiMethodName) - await this.dataValidator.validate(reqArgs, schemaId) + await this.dataValidator.validate(args, schemaId) await this.dataValidator.validate( { params: args?.params?.filter }, filterSchemaId diff --git a/workers/loc.api/sync/dao/db-migrations/sqlite-migrations/migration.v33.js b/workers/loc.api/sync/dao/db-migrations/sqlite-migrations/migration.v33.js deleted file mode 100644 index 39a027363..000000000 --- a/workers/loc.api/sync/dao/db-migrations/sqlite-migrations/migration.v33.js +++ /dev/null @@ -1,68 +0,0 @@ -'use strict' - -const AbstractMigration = require('./abstract.migration') -const { getSqlArrToModifyColumns } = require('./helpers') - -const { - ID_PRIMARY_KEY -} = require('./helpers/const') - -class MigrationV33 extends AbstractMigration { - /** - * @override - */ - up () { - const sqlArr = [ - 'ALTER TABLE users ADD COLUMN shouldNotSyncOnStartupAfterUpdate INT', - 'ALTER TABLE users ADD COLUMN isSyncOnStartupRequired INT', - - 'UPDATE users SET shouldNotSyncOnStartupAfterUpdate = 0', - 'UPDATE users SET isSyncOnStartupRequired = 0' - ] - - this.addSql(sqlArr) - } - - /** - * @override - */ - beforeDown () { return this.dao.disableForeignKeys() } - - /** - * @override - */ - down () { - const sqlArr = [ - ...getSqlArrToModifyColumns( - 'users', - { - _id: ID_PRIMARY_KEY, - id: 'BIGINT', - email: 'VARCHAR(255)', - apiKey: 'VARCHAR(255)', - apiSecret: 'VARCHAR(255)', - authToken: 'VARCHAR(255)', - active: 'INT', - isDataFromDb: 'INT', - timezone: 'VARCHAR(255)', - username: 'VARCHAR(255)', - passwordHash: 'VARCHAR(255)', - isNotProtected: 'INT', - isSubAccount: 'INT', - isSubUser: 'INT', - createdAt: 'BIGINT', - updatedAt: 'BIGINT' - } - ) - ] - - this.addSql(sqlArr) - } - - /** - * @override - */ - afterDown () { return this.dao.enableForeignKeys() } -} - -module.exports = MigrationV33 diff --git a/workers/loc.api/sync/dao/db-migrations/sqlite-migrations/migration.v43.1758267170867.js b/workers/loc.api/sync/dao/db-migrations/sqlite-migrations/migration.v43.1758267170867.js new file mode 100644 index 000000000..5ddc4be4d --- /dev/null +++ b/workers/loc.api/sync/dao/db-migrations/sqlite-migrations/migration.v43.1758267170867.js @@ -0,0 +1,87 @@ +'use strict' + +/* + * CREATED_AT: 2025-09-19T07:32:50.867Z + * VERSION: v43 + */ + +const AbstractMigration = require('./abstract.migration') + +class MigrationV43 extends AbstractMigration { + /** + * @override + */ + up () { + const sqlArr = [ + 'DROP TABLE payInvoiceList' + ] + + this.addSql(sqlArr) + } + + /** + * @override + */ + down () { + const sqlArr = [ + `CREATE TABLE payInvoiceList ( + _id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + id VARCHAR(255), + t BIGINT, + duration INT, + amount DECIMAL(22,12), + currency VARCHAR(255), + orderId VARCHAR(255), + payCurrencies TEXT, + webhook VARCHAR(255), + redirectUrl VARCHAR(255), + status VARCHAR(255), + customerInfo TEXT, + invoices TEXT, + payment TEXT, + merchantName VARCHAR(255), + subUserId INT, + user_id INT NOT NULL, + CONSTRAINT payInvoiceList_fk_user_id + FOREIGN KEY (user_id) + REFERENCES users(_id) + ON UPDATE CASCADE + ON DELETE CASCADE, + CONSTRAINT payInvoiceList_fk_subUserId + FOREIGN KEY (subUserId) + REFERENCES users(_id) + ON UPDATE CASCADE + ON DELETE CASCADE + )`, + + `CREATE UNIQUE INDEX payInvoiceList_id_user_id + ON payInvoiceList(id, user_id)`, + `CREATE INDEX payInvoiceList_user_id_currency_t + ON payInvoiceList(user_id, currency, t)`, + `CREATE INDEX payInvoiceList_user_id_id_t + ON payInvoiceList(user_id, id, t)`, + `CREATE INDEX payInvoiceList_user_id_t + ON payInvoiceList(user_id, t)`, + `CREATE INDEX payInvoiceList_user_id_subUserId_t + ON payInvoiceList(user_id, subUserId, t) + WHERE subUserId IS NOT NULL`, + `CREATE INDEX payInvoiceList_subUserId_id + ON payInvoiceList(subUserId, id) + WHERE subUserId IS NOT NULL` + ] + + this.addSql(sqlArr) + } + + /** + * @override + */ + before () { return this.dao.disableForeignKeys() } + + /** + * @override + */ + after () { return this.dao.enableForeignKeys() } +} + +module.exports = MigrationV43 diff --git a/workers/loc.api/sync/schema/allowed.colls.js b/workers/loc.api/sync/schema/allowed.colls.js index d13a4cb21..3ea010ced 100644 --- a/workers/loc.api/sync/schema/allowed.colls.js +++ b/workers/loc.api/sync/schema/allowed.colls.js @@ -28,6 +28,5 @@ module.exports = { CANDLES: TABLES_NAMES.CANDLES, STATUS_MESSAGES: TABLES_NAMES.STATUS_MESSAGES, LOGINS: TABLES_NAMES.LOGINS, - CHANGE_LOGS: TABLES_NAMES.CHANGE_LOGS, - PAY_INVOICE_LIST: TABLES_NAMES.PAY_INVOICE_LIST + CHANGE_LOGS: TABLES_NAMES.CHANGE_LOGS } diff --git a/workers/loc.api/sync/schema/models/index.js b/workers/loc.api/sync/schema/models/index.js index 925c77cfd..42ac9ba0d 100644 --- a/workers/loc.api/sync/schema/models/index.js +++ b/workers/loc.api/sync/schema/models/index.js @@ -7,7 +7,7 @@ * in the `workers/loc.api/sync/dao/db-migrations/sqlite-migrations` folder, * e.g. `migration.v1.js`, where `v1` is `SUPPORTED_DB_VERSION` */ -const SUPPORTED_DB_VERSION = 42 +const SUPPORTED_DB_VERSION = 43 const TABLES_NAMES = require('../tables-names') @@ -26,7 +26,6 @@ const positionsHistory = require('./positions-history') const positionsSnapshot = require('./positions-snapshot') const logins = require('./logins') const changeLogs = require('./change-logs') -const payInvoiceList = require('./pay-invoice-list') const tickersHistory = require('./tickers-history') const statusMessages = require('./status-messages') const publicCollsConf = require('./public-colls-conf') @@ -60,7 +59,6 @@ const models = new Map([ [TABLES_NAMES.POSITIONS_SNAPSHOT, positionsSnapshot], [TABLES_NAMES.LOGINS, logins], [TABLES_NAMES.CHANGE_LOGS, changeLogs], - [TABLES_NAMES.PAY_INVOICE_LIST, payInvoiceList], [TABLES_NAMES.TICKERS_HISTORY, tickersHistory], [TABLES_NAMES.STATUS_MESSAGES, statusMessages], [TABLES_NAMES.PUBLIC_COLLS_CONF, publicCollsConf], diff --git a/workers/loc.api/sync/schema/models/pay-invoice-list.js b/workers/loc.api/sync/schema/models/pay-invoice-list.js deleted file mode 100644 index 65756378a..000000000 --- a/workers/loc.api/sync/schema/models/pay-invoice-list.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict' - -const Model = require('./model') - -module.exports = new Model({ - id: Model.VARCHAR, - t: Model.BIGINT, - duration: Model.INTEGER, - amount: Model.DECIMAL, - currency: Model.VARCHAR, - orderId: Model.VARCHAR, - payCurrencies: Model.TEXT, // JSON - webhook: Model.VARCHAR, - redirectUrl: Model.VARCHAR, - status: Model.VARCHAR, - customerInfo: Model.TEXT, // JSON - invoices: Model.TEXT, // JSON - payment: Model.TEXT, // JSON - merchantName: Model.VARCHAR, - subUserId: Model.INTEGER, - user_id: Model.INTEGER_NOT_NULL, - - [Model.UNIQUE_INDEX_FIELD_NAME]: ['id', 'user_id'], - [Model.INDEX_FIELD_NAME]: [ - ['user_id', 'currency', 't'], - ['user_id', 'id', 't'], - ['user_id', 't'], - ['user_id', 'subUserId', 't', - 'WHERE subUserId IS NOT NULL'], - ['subUserId', 'id', - 'WHERE subUserId IS NOT NULL'] - ], - [Model.CONSTR_FIELD_NAME]: [ - Model.COMMON_CONSTRAINTS.USER_ID_CONSTRAINT, - Model.COMMON_CONSTRAINTS.SUB_USER_ID_CONSTRAINT - ] -}) diff --git a/workers/loc.api/sync/schema/sync-schema/index.js b/workers/loc.api/sync/schema/sync-schema/index.js index ed54d5d7e..fb5e592e8 100644 --- a/workers/loc.api/sync/schema/sync-schema/index.js +++ b/workers/loc.api/sync/schema/sync-schema/index.js @@ -16,7 +16,6 @@ const positionsHistory = require('./positions-history') const positionsSnapshot = require('./positions-snapshot') const logins = require('./logins') const changeLogs = require('./change-logs') -const payInvoiceList = require('./pay-invoice-list') const tickersHistory = require('./tickers-history') const wallets = require('./wallets') const symbols = require('./symbols') @@ -43,7 +42,6 @@ const _methodCollMap = new Map([ [SYNC_API_METHODS.POSITIONS_SNAPSHOT, positionsSnapshot], [SYNC_API_METHODS.LOGINS, logins], [SYNC_API_METHODS.CHANGE_LOGS, changeLogs], - [SYNC_API_METHODS.PAY_INVOICE_LIST, payInvoiceList], [SYNC_API_METHODS.TICKERS_HISTORY, tickersHistory], [SYNC_API_METHODS.WALLETS, wallets], [SYNC_API_METHODS.SYMBOLS, symbols], diff --git a/workers/loc.api/sync/schema/sync-schema/pay-invoice-list.js b/workers/loc.api/sync/schema/sync-schema/pay-invoice-list.js deleted file mode 100644 index d98a88476..000000000 --- a/workers/loc.api/sync/schema/sync-schema/pay-invoice-list.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict' - -const Model = require('./model') - -module.exports = new Model({ - [Model.NAME]: Model.ALLOWED_COLLS.PAY_INVOICE_LIST, - [Model.MAX_LIMIT]: 100, - [Model.DATE_FIELD_NAME]: 't', - [Model.SYMBOL_FIELD_NAME]: 'currency', - [Model.ORDER]: [['t', Model.ORDERS.DESC]], - [Model.IS_SYNC_REQUIRED_AT_LEAST_ONCE]: false, - [Model.TYPE]: Model.ALLOWED_COLLS_TYPES.INSERTABLE_ARRAY_OBJECTS -}) diff --git a/workers/loc.api/sync/schema/sync.api.methods.js b/workers/loc.api/sync/schema/sync.api.methods.js index 62882430f..2ff63518c 100644 --- a/workers/loc.api/sync/schema/sync.api.methods.js +++ b/workers/loc.api/sync/schema/sync.api.methods.js @@ -15,7 +15,6 @@ const LOGINS = '_getLogins' const CHANGE_LOGS = '_getChangeLogs' const TICKERS_HISTORY = '_getTickersHistory' const CANDLES = '_getCandles' -const PAY_INVOICE_LIST = '_getPayInvoiceList' const WALLETS = '_getWallets' const SYMBOLS = '_getSymbols' @@ -43,7 +42,6 @@ module.exports = { CHANGE_LOGS, TICKERS_HISTORY, CANDLES, - PAY_INVOICE_LIST, WALLETS, SYMBOLS, diff --git a/workers/loc.api/sync/schema/tables-names.js b/workers/loc.api/sync/schema/tables-names.js index e41ccc3db..37f4b600a 100644 --- a/workers/loc.api/sync/schema/tables-names.js +++ b/workers/loc.api/sync/schema/tables-names.js @@ -31,6 +31,5 @@ module.exports = { SYNC_USER_STEPS: 'syncUserSteps', LOGINS: 'logins', CHANGE_LOGS: 'changeLogs', - PAY_INVOICE_LIST: 'payInvoiceList', SUB_ACCOUNTS: 'subAccounts' }