Skip to content

Commit

Permalink
Merge pull request #395 from ZIMkaRU/refactoring/move-sync-schema-to-…
Browse files Browse the repository at this point in the history
…separate-files

Move sync schema to separate files
  • Loading branch information
ezewer authored Jul 23, 2024
2 parents be7f0ec + b9a226d commit ee25929
Show file tree
Hide file tree
Showing 27 changed files with 578 additions and 405 deletions.
405 changes: 0 additions & 405 deletions workers/loc.api/sync/schema/sync-schema.js

This file was deleted.

23 changes: 23 additions & 0 deletions workers/loc.api/sync/schema/sync-schema/candles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict'

const TABLES_NAMES = require('../tables-names')
const ALLOWED_COLLS = require('../allowed.colls')
const COLLS_TYPES = require('../colls.types')

const { getModelOf } = require('../models')

module.exports = {
name: ALLOWED_COLLS.CANDLES,
maxLimit: 10000,
dateFieldName: 'mts',
symbolFieldName: '_symbol',
timeframeFieldName: '_timeframe',
sort: [['mts', -1]],
hasNewData: false,
start: [],
confName: 'candlesConf',
isSyncRequiredAtLeastOnce: true,
additionalApiCallArgs: { isNotMoreThanInnerMax: true },
type: COLLS_TYPES.PUBLIC_INSERTABLE_ARRAY_OBJECTS,
model: getModelOf(TABLES_NAMES.CANDLES)
}
20 changes: 20 additions & 0 deletions workers/loc.api/sync/schema/sync-schema/change-logs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'

const TABLES_NAMES = require('../tables-names')
const ALLOWED_COLLS = require('../allowed.colls')
const COLLS_TYPES = require('../colls.types')

const { getModelOf } = require('../models')

module.exports = {
name: ALLOWED_COLLS.CHANGE_LOGS,
maxLimit: 10000,
dateFieldName: 'mtsCreate',
symbolFieldName: null,
sort: [['mtsCreate', -1]],
hasNewData: false,
start: [],
isSyncRequiredAtLeastOnce: false,
type: COLLS_TYPES.INSERTABLE_ARRAY_OBJECTS,
model: getModelOf(TABLES_NAMES.CHANGE_LOGS)
}
18 changes: 18 additions & 0 deletions workers/loc.api/sync/schema/sync-schema/currencies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'

const TABLES_NAMES = require('../tables-names')
const ALLOWED_COLLS = require('../allowed.colls')
const COLLS_TYPES = require('../colls.types')

const { getModelOf } = require('../models')

module.exports = {
name: ALLOWED_COLLS.CURRENCIES,
maxLimit: 10000,
projection: null,
sort: [['name', 1]],
hasNewData: false,
isSyncRequiredAtLeastOnce: true,
type: COLLS_TYPES.PUBLIC_UPDATABLE_ARRAY_OBJECTS,
model: getModelOf(TABLES_NAMES.CURRENCIES)
}
20 changes: 20 additions & 0 deletions workers/loc.api/sync/schema/sync-schema/funding-credit-history.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'

const TABLES_NAMES = require('../tables-names')
const ALLOWED_COLLS = require('../allowed.colls')
const COLLS_TYPES = require('../colls.types')

const { getModelOf } = require('../models')

module.exports = {
name: ALLOWED_COLLS.FUNDING_CREDIT_HISTORY,
maxLimit: 10000,
dateFieldName: 'mtsUpdate',
symbolFieldName: 'symbol',
sort: [['mtsUpdate', -1]],
hasNewData: false,
start: [],
isSyncRequiredAtLeastOnce: false,
type: COLLS_TYPES.INSERTABLE_ARRAY_OBJECTS,
model: getModelOf(TABLES_NAMES.FUNDING_CREDIT_HISTORY)
}
20 changes: 20 additions & 0 deletions workers/loc.api/sync/schema/sync-schema/funding-loan-history.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'

const TABLES_NAMES = require('../tables-names')
const ALLOWED_COLLS = require('../allowed.colls')
const COLLS_TYPES = require('../colls.types')

const { getModelOf } = require('../models')

module.exports = {
name: ALLOWED_COLLS.FUNDING_LOAN_HISTORY,
maxLimit: 10000,
dateFieldName: 'mtsUpdate',
symbolFieldName: 'symbol',
sort: [['mtsUpdate', -1]],
hasNewData: false,
start: [],
isSyncRequiredAtLeastOnce: false,
type: COLLS_TYPES.INSERTABLE_ARRAY_OBJECTS,
model: getModelOf(TABLES_NAMES.FUNDING_LOAN_HISTORY)
}
20 changes: 20 additions & 0 deletions workers/loc.api/sync/schema/sync-schema/funding-offer-history.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'

const TABLES_NAMES = require('../tables-names')
const ALLOWED_COLLS = require('../allowed.colls')
const COLLS_TYPES = require('../colls.types')

const { getModelOf } = require('../models')

module.exports = {
name: ALLOWED_COLLS.FUNDING_OFFER_HISTORY,
maxLimit: 10000,
dateFieldName: 'mtsUpdate',
symbolFieldName: 'symbol',
sort: [['mtsUpdate', -1]],
hasNewData: false,
start: [],
isSyncRequiredAtLeastOnce: false,
type: COLLS_TYPES.INSERTABLE_ARRAY_OBJECTS,
model: getModelOf(TABLES_NAMES.FUNDING_OFFER_HISTORY)
}
20 changes: 20 additions & 0 deletions workers/loc.api/sync/schema/sync-schema/funding-trades.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'

const TABLES_NAMES = require('../tables-names')
const ALLOWED_COLLS = require('../allowed.colls')
const COLLS_TYPES = require('../colls.types')

const { getModelOf } = require('../models')

module.exports = {
name: ALLOWED_COLLS.FUNDING_TRADES,
maxLimit: 1000,
dateFieldName: 'mtsCreate',
symbolFieldName: 'symbol',
sort: [['mtsCreate', -1]],
hasNewData: false,
start: [],
isSyncRequiredAtLeastOnce: false,
type: COLLS_TYPES.INSERTABLE_ARRAY_OBJECTS,
model: getModelOf(TABLES_NAMES.FUNDING_TRADES)
}
18 changes: 18 additions & 0 deletions workers/loc.api/sync/schema/sync-schema/futures.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'

const TABLES_NAMES = require('../tables-names')
const ALLOWED_COLLS = require('../allowed.colls')
const COLLS_TYPES = require('../colls.types')

const { getModelOf } = require('../models')

module.exports = {
name: ALLOWED_COLLS.FUTURES,
maxLimit: 10000,
projection: 'pairs',
sort: [['pairs', 1]],
hasNewData: false,
isSyncRequiredAtLeastOnce: true,
type: COLLS_TYPES.PUBLIC_UPDATABLE_ARRAY,
model: getModelOf(TABLES_NAMES.FUTURES)
}
18 changes: 18 additions & 0 deletions workers/loc.api/sync/schema/sync-schema/inactive-currencies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'

const TABLES_NAMES = require('../tables-names')
const ALLOWED_COLLS = require('../allowed.colls')
const COLLS_TYPES = require('../colls.types')

const { getModelOf } = require('../models')

module.exports = {
name: ALLOWED_COLLS.INACTIVE_CURRENCIES,
maxLimit: 10000,
projection: 'pairs',
sort: [['pairs', 1]],
hasNewData: false,
isSyncRequiredAtLeastOnce: true,
type: COLLS_TYPES.PUBLIC_UPDATABLE_ARRAY,
model: getModelOf(TABLES_NAMES.INACTIVE_CURRENCIES)
}
18 changes: 18 additions & 0 deletions workers/loc.api/sync/schema/sync-schema/inactive-symbols.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'

const TABLES_NAMES = require('../tables-names')
const ALLOWED_COLLS = require('../allowed.colls')
const COLLS_TYPES = require('../colls.types')

const { getModelOf } = require('../models')

module.exports = {
name: ALLOWED_COLLS.INACTIVE_SYMBOLS,
maxLimit: 10000,
projection: 'pairs',
sort: [['pairs', 1]],
hasNewData: false,
isSyncRequiredAtLeastOnce: true,
type: COLLS_TYPES.PUBLIC_UPDATABLE_ARRAY,
model: getModelOf(TABLES_NAMES.INACTIVE_SYMBOLS)
}
67 changes: 67 additions & 0 deletions workers/loc.api/sync/schema/sync-schema/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
'use strict'

const SYNC_API_METHODS = require('../sync.api.methods')

const ledgers = require('./ledgers')
const trades = require('./trades')
const fundingTrades = require('./funding-trades')
const publicTrades = require('./public-trades')
const statusMessages = require('./status-messages')
const orders = require('./orders')
const movements = require('./movements')
const fundingOfferHistory = require('./funding-offer-history')
const fundingLoanHistory = require('./funding-loan-history')
const fundingCreditHistory = require('./funding-credit-history')
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')
const mapSymbols = require('./map-symbols')
const inactiveCurrencies = require('./inactive-currencies')
const inactiveSymbols = require('./inactive-symbols')
const futures = require('./futures')
const currencies = require('./currencies')
const marginCurrencyList = require('./margin-currency-list')
const candles = require('./candles')

const _methodCollMap = new Map([
[SYNC_API_METHODS.LEDGERS, ledgers],
[SYNC_API_METHODS.TRADES, trades],
[SYNC_API_METHODS.FUNDING_TRADES, fundingTrades],
[SYNC_API_METHODS.PUBLIC_TRADES, publicTrades],
[SYNC_API_METHODS.STATUS_MESSAGES, statusMessages],
[SYNC_API_METHODS.ORDERS, orders],
[SYNC_API_METHODS.MOVEMENTS, movements],
[SYNC_API_METHODS.FUNDING_OFFER_HISTORY, fundingOfferHistory],
[SYNC_API_METHODS.FUNDING_LOAN_HISTORY, fundingLoanHistory],
[SYNC_API_METHODS.FUNDING_CREDIT_HISTORY, fundingCreditHistory],
[SYNC_API_METHODS.POSITIONS_HISTORY, positionsHistory],
[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],
[SYNC_API_METHODS.MAP_SYMBOLS, mapSymbols],
[SYNC_API_METHODS.INACTIVE_CURRENCIES, inactiveCurrencies],
[SYNC_API_METHODS.INACTIVE_SYMBOLS, inactiveSymbols],
[SYNC_API_METHODS.FUTURES, futures],
[SYNC_API_METHODS.CURRENCIES, currencies],
[SYNC_API_METHODS.MARGIN_CURRENCY_LIST, marginCurrencyList],
[SYNC_API_METHODS.CANDLES, candles]
])

const { cloneSchema } = require('../helpers')

const getMethodCollMap = (methodCollMap = _methodCollMap) => {
return cloneSchema(methodCollMap)
}

module.exports = {
getMethodCollMap
}
20 changes: 20 additions & 0 deletions workers/loc.api/sync/schema/sync-schema/ledgers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'

const TABLES_NAMES = require('../tables-names')
const ALLOWED_COLLS = require('../allowed.colls')
const COLLS_TYPES = require('../colls.types')

const { getModelOf } = require('../models')

module.exports = {
name: ALLOWED_COLLS.LEDGERS,
maxLimit: 2500,
dateFieldName: 'mts',
symbolFieldName: 'currency',
sort: [['mts', -1], ['id', -1]],
hasNewData: false,
start: [],
isSyncRequiredAtLeastOnce: true,
type: COLLS_TYPES.INSERTABLE_ARRAY_OBJECTS,
model: getModelOf(TABLES_NAMES.LEDGERS)
}
20 changes: 20 additions & 0 deletions workers/loc.api/sync/schema/sync-schema/logins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'

const TABLES_NAMES = require('../tables-names')
const ALLOWED_COLLS = require('../allowed.colls')
const COLLS_TYPES = require('../colls.types')

const { getModelOf } = require('../models')

module.exports = {
name: ALLOWED_COLLS.LOGINS,
maxLimit: 10000,
dateFieldName: 'time',
symbolFieldName: null,
sort: [['time', -1]],
hasNewData: false,
start: [],
isSyncRequiredAtLeastOnce: true,
type: COLLS_TYPES.INSERTABLE_ARRAY_OBJECTS,
model: getModelOf(TABLES_NAMES.LOGINS)
}
18 changes: 18 additions & 0 deletions workers/loc.api/sync/schema/sync-schema/map-symbols.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'

const TABLES_NAMES = require('../tables-names')
const ALLOWED_COLLS = require('../allowed.colls')
const COLLS_TYPES = require('../colls.types')

const { getModelOf } = require('../models')

module.exports = {
name: ALLOWED_COLLS.MAP_SYMBOLS,
maxLimit: 10000,
projection: ['key', 'value'],
sort: [['key', 1]],
hasNewData: false,
isSyncRequiredAtLeastOnce: true,
type: COLLS_TYPES.PUBLIC_UPDATABLE_ARRAY_OBJECTS,
model: getModelOf(TABLES_NAMES.MAP_SYMBOLS)
}
18 changes: 18 additions & 0 deletions workers/loc.api/sync/schema/sync-schema/margin-currency-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'

const TABLES_NAMES = require('../tables-names')
const ALLOWED_COLLS = require('../allowed.colls')
const COLLS_TYPES = require('../colls.types')

const { getModelOf } = require('../models')

module.exports = {
name: ALLOWED_COLLS.MARGIN_CURRENCY_LIST,
maxLimit: 10000,
projection: 'symbol',
sort: [['symbol', 1]],
hasNewData: false,
isSyncRequiredAtLeastOnce: true,
type: COLLS_TYPES.PUBLIC_UPDATABLE_ARRAY,
model: getModelOf(TABLES_NAMES.MARGIN_CURRENCY_LIST)
}
20 changes: 20 additions & 0 deletions workers/loc.api/sync/schema/sync-schema/movements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'

const TABLES_NAMES = require('../tables-names')
const ALLOWED_COLLS = require('../allowed.colls')
const COLLS_TYPES = require('../colls.types')

const { getModelOf } = require('../models')

module.exports = {
name: ALLOWED_COLLS.MOVEMENTS,
maxLimit: 250,
dateFieldName: 'mtsUpdated',
symbolFieldName: 'currency',
sort: [['mtsUpdated', -1]],
hasNewData: false,
start: [],
isSyncRequiredAtLeastOnce: true,
type: COLLS_TYPES.INSERTABLE_ARRAY_OBJECTS,
model: getModelOf(TABLES_NAMES.MOVEMENTS)
}
20 changes: 20 additions & 0 deletions workers/loc.api/sync/schema/sync-schema/orders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'

const TABLES_NAMES = require('../tables-names')
const ALLOWED_COLLS = require('../allowed.colls')
const COLLS_TYPES = require('../colls.types')

const { getModelOf } = require('../models')

module.exports = {
name: ALLOWED_COLLS.ORDERS,
maxLimit: 2500,
dateFieldName: 'mtsUpdate',
symbolFieldName: 'symbol',
sort: [['mtsUpdate', -1]],
hasNewData: false,
start: [],
isSyncRequiredAtLeastOnce: false,
type: COLLS_TYPES.INSERTABLE_ARRAY_OBJECTS,
model: getModelOf(TABLES_NAMES.ORDERS)
}
Loading

0 comments on commit ee25929

Please sign in to comment.