refactor: schema modularization
This commit is contained in:
parent
d9e3a9e61f
commit
82b5db6908
35 changed files with 2423 additions and 685 deletions
15
lib/new-admin/graphql/resolvers/blacklist.resolver.js
Normal file
15
lib/new-admin/graphql/resolvers/blacklist.resolver.js
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
const blacklist = require('../../../blacklist')
|
||||||
|
|
||||||
|
const resolvers = {
|
||||||
|
Query: {
|
||||||
|
blacklist: () => blacklist.getBlacklist()
|
||||||
|
},
|
||||||
|
Mutation: {
|
||||||
|
deleteBlacklistRow: (...[, { cryptoCode, address }]) =>
|
||||||
|
blacklist.deleteFromBlacklist(cryptoCode, address),
|
||||||
|
insertBlacklistRow: (...[, { cryptoCode, address }]) =>
|
||||||
|
blacklist.insertIntoBlacklist(cryptoCode, address)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = resolvers
|
||||||
11
lib/new-admin/graphql/resolvers/config.resolver.js
Normal file
11
lib/new-admin/graphql/resolvers/config.resolver.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
const { accounts: accountsConfig, countries, languages } = require('../../config')
|
||||||
|
|
||||||
|
const resolver = {
|
||||||
|
Query: {
|
||||||
|
countries: () => countries,
|
||||||
|
languages: () => languages,
|
||||||
|
accountsConfig: () => accountsConfig
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = resolver
|
||||||
10
lib/new-admin/graphql/resolvers/currency.resolver.js
Normal file
10
lib/new-admin/graphql/resolvers/currency.resolver.js
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
const { coins, currencies } = require('../../config')
|
||||||
|
|
||||||
|
const resolver = {
|
||||||
|
Query: {
|
||||||
|
currencies: () => currencies,
|
||||||
|
cryptoCurrencies: () => coins
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = resolver
|
||||||
21
lib/new-admin/graphql/resolvers/customer.resolver.js
Normal file
21
lib/new-admin/graphql/resolvers/customer.resolver.js
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
const anonymous = require('../../../constants').anonymousCustomer
|
||||||
|
const customers = require('../../../customers')
|
||||||
|
|
||||||
|
const resolvers = {
|
||||||
|
Customer: {
|
||||||
|
isAnonymous: parent => (parent.customerId === anonymous.uuid)
|
||||||
|
},
|
||||||
|
Query: {
|
||||||
|
customers: () => customers.getCustomersList(),
|
||||||
|
customer: (...[, { customerId }]) => customers.getCustomerById(customerId)
|
||||||
|
},
|
||||||
|
Mutation: {
|
||||||
|
setCustomer: (root, { customerId, customerInput }, context, info) => {
|
||||||
|
const token = context.req.cookies && context.req.cookies.token
|
||||||
|
if (customerId === anonymous.uuid) return customers.getCustomerById(customerId)
|
||||||
|
return customers.updateCustomer(customerId, customerInput, token)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = resolvers
|
||||||
9
lib/new-admin/graphql/resolvers/funding.resolver.js
Normal file
9
lib/new-admin/graphql/resolvers/funding.resolver.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
const funding = require('../../modules/funding')
|
||||||
|
|
||||||
|
const resolvers = {
|
||||||
|
Query: {
|
||||||
|
funding: () => funding.getFunding()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = resolvers
|
||||||
35
lib/new-admin/graphql/resolvers/index.js
Normal file
35
lib/new-admin/graphql/resolvers/index.js
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
const { mergeResolvers } = require('@graphql-tools/merge')
|
||||||
|
|
||||||
|
const blacklist = require('./blacklist.resolver')
|
||||||
|
const config = require('./config.resolver')
|
||||||
|
const currency = require('./currency.resolver')
|
||||||
|
const customer = require('./customer.resolver')
|
||||||
|
const funding = require('./funding.resolver')
|
||||||
|
const log = require('./log.resolver')
|
||||||
|
const machine = require('./machine.resolver')
|
||||||
|
const pairing = require('./pairing.resolver')
|
||||||
|
const promo = require('./promo.resolver')
|
||||||
|
const scalar = require('./scalar.resolver')
|
||||||
|
const settings = require('./settings.resolver')
|
||||||
|
const status = require('./status.resolver')
|
||||||
|
const transaction = require('./transaction.resolver')
|
||||||
|
const version = require('./version.resolver')
|
||||||
|
|
||||||
|
const resolvers = [
|
||||||
|
blacklist,
|
||||||
|
config,
|
||||||
|
currency,
|
||||||
|
customer,
|
||||||
|
funding,
|
||||||
|
log,
|
||||||
|
machine,
|
||||||
|
pairing,
|
||||||
|
promo,
|
||||||
|
scalar,
|
||||||
|
settings,
|
||||||
|
status,
|
||||||
|
transaction,
|
||||||
|
version
|
||||||
|
]
|
||||||
|
|
||||||
|
module.exports = mergeResolvers(resolvers)
|
||||||
19
lib/new-admin/graphql/resolvers/log.resolver.js
Normal file
19
lib/new-admin/graphql/resolvers/log.resolver.js
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
const { parseAsync } = require('json2csv')
|
||||||
|
|
||||||
|
const logs = require('../../../logs')
|
||||||
|
const serverLogs = require('../../modules/server-logs')
|
||||||
|
|
||||||
|
const resolvers = {
|
||||||
|
Query: {
|
||||||
|
machineLogs: (...[, { deviceId, from, until, limit, offset }]) =>
|
||||||
|
logs.simpleGetMachineLogs(deviceId, from, until, limit, offset),
|
||||||
|
machineLogsCsv: (...[, { deviceId, from, until, limit, offset }]) =>
|
||||||
|
logs.simpleGetMachineLogs(deviceId, from, until, limit, offset).then(parseAsync),
|
||||||
|
serverLogs: (...[, { from, until, limit, offset }]) =>
|
||||||
|
serverLogs.getServerLogs(from, until, limit, offset),
|
||||||
|
serverLogsCsv: (...[, { from, until, limit, offset }]) =>
|
||||||
|
serverLogs.getServerLogs(from, until, limit, offset).then(parseAsync)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = resolvers
|
||||||
25
lib/new-admin/graphql/resolvers/machine.resolver.js
Normal file
25
lib/new-admin/graphql/resolvers/machine.resolver.js
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
const DataLoader = require('dataloader')
|
||||||
|
|
||||||
|
const { machineAction } = require('../../modules/machines')
|
||||||
|
|
||||||
|
const machineLoader = require('../../../machine-loader')
|
||||||
|
const machineEventsByIdBatch = require('../../../postgresql_interface').machineEventsByIdBatch
|
||||||
|
|
||||||
|
const machineEventsLoader = new DataLoader(ids => {
|
||||||
|
return machineEventsByIdBatch(ids)
|
||||||
|
}, { cache: false })
|
||||||
|
|
||||||
|
const resolvers = {
|
||||||
|
Machine: {
|
||||||
|
latestEvent: parent => machineEventsLoader.load(parent.deviceId)
|
||||||
|
},
|
||||||
|
Query: {
|
||||||
|
machines: () => machineLoader.getMachineNames(),
|
||||||
|
machine: (...[, { deviceId }]) => machineLoader.getMachine(deviceId)
|
||||||
|
},
|
||||||
|
Mutation: {
|
||||||
|
machineAction: (...[, { deviceId, action, cashbox, cassette1, cassette2, newName }]) => machineAction({ deviceId, action, cashbox, cassette1, cassette2, newName })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = resolvers
|
||||||
9
lib/new-admin/graphql/resolvers/pairing.resolver.js
Normal file
9
lib/new-admin/graphql/resolvers/pairing.resolver.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
const pairing = require('../../modules/pairing')
|
||||||
|
|
||||||
|
const resolvers = {
|
||||||
|
Mutation: {
|
||||||
|
createPairingTotem: (...[, { name }]) => pairing.totem(name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = resolvers
|
||||||
13
lib/new-admin/graphql/resolvers/promo.resolver.js
Normal file
13
lib/new-admin/graphql/resolvers/promo.resolver.js
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
const promoCodeManager = require('../../../promo-codes')
|
||||||
|
|
||||||
|
const resolvers = {
|
||||||
|
Query: {
|
||||||
|
promoCodes: () => promoCodeManager.getAvailablePromoCodes()
|
||||||
|
},
|
||||||
|
Mutation: {
|
||||||
|
createPromoCode: (...[, { code, discount }]) => promoCodeManager.createPromoCode(code, discount),
|
||||||
|
deletePromoCode: (...[, { codeId }]) => promoCodeManager.deletePromoCode(codeId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = resolvers
|
||||||
10
lib/new-admin/graphql/resolvers/scalar.resolver.js
Normal file
10
lib/new-admin/graphql/resolvers/scalar.resolver.js
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
const { GraphQLDateTime } = require('graphql-iso-date')
|
||||||
|
const { GraphQLJSON, GraphQLJSONObject } = require('graphql-type-json')
|
||||||
|
|
||||||
|
const resolvers = {
|
||||||
|
JSON: GraphQLJSON,
|
||||||
|
JSONObject: GraphQLJSONObject,
|
||||||
|
Date: GraphQLDateTime
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = resolvers
|
||||||
25
lib/new-admin/graphql/resolvers/settings.resolver.js
Normal file
25
lib/new-admin/graphql/resolvers/settings.resolver.js
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
const got = require('got')
|
||||||
|
|
||||||
|
const settingsLoader = require('../../../new-settings-loader')
|
||||||
|
|
||||||
|
const notify = () => got.post('http://localhost:3030/dbChange')
|
||||||
|
.catch(e => console.error('Error: lamassu-server not responding'))
|
||||||
|
|
||||||
|
const resolvers = {
|
||||||
|
Query: {
|
||||||
|
accounts: () => settingsLoader.loadAccounts(),
|
||||||
|
config: () => settingsLoader.loadLatestConfigOrNone()
|
||||||
|
},
|
||||||
|
Mutation: {
|
||||||
|
saveAccounts: (...[, { accounts }]) => settingsLoader.saveAccounts(accounts),
|
||||||
|
resetAccounts: (...[, { schemaVersion }]) => settingsLoader.resetAccounts(schemaVersion),
|
||||||
|
saveConfig: (...[, { config }]) => settingsLoader.saveConfig(config).then(it => {
|
||||||
|
notify()
|
||||||
|
return it
|
||||||
|
}),
|
||||||
|
resetConfig: (...[, { schemaVersion }]) => settingsLoader.resetConfig(schemaVersion),
|
||||||
|
migrateConfigAndAccounts: () => settingsLoader.migrate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = resolvers
|
||||||
9
lib/new-admin/graphql/resolvers/status.resolver.js
Normal file
9
lib/new-admin/graphql/resolvers/status.resolver.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
const supervisor = require('../../modules/supervisor')
|
||||||
|
|
||||||
|
const resolvers = {
|
||||||
|
Query: {
|
||||||
|
uptime: () => supervisor.getAllProcessInfo()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = resolvers
|
||||||
24
lib/new-admin/graphql/resolvers/transaction.resolver.js
Normal file
24
lib/new-admin/graphql/resolvers/transaction.resolver.js
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
const DataLoader = require('dataloader')
|
||||||
|
const { parseAsync } = require('json2csv')
|
||||||
|
|
||||||
|
const transactions = require('../../modules/transactions')
|
||||||
|
const anonymous = require('../../../constants').anonymousCustomer
|
||||||
|
|
||||||
|
const transactionsLoader = new DataLoader(ids => transactions.getCustomerTransactionsBatch(ids))
|
||||||
|
|
||||||
|
const resolvers = {
|
||||||
|
Customer: {
|
||||||
|
transactions: parent => transactionsLoader.load(parent.id)
|
||||||
|
},
|
||||||
|
Transaction: {
|
||||||
|
isAnonymous: parent => (parent.customerId === anonymous.uuid)
|
||||||
|
},
|
||||||
|
Query: {
|
||||||
|
transactions: (...[, { from, until, limit, offset }]) =>
|
||||||
|
transactions.batch(from, until, limit, offset),
|
||||||
|
transactionsCsv: (...[, { from, until, limit, offset }]) =>
|
||||||
|
transactions.batch(from, until, limit, offset).then(parseAsync)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = resolvers
|
||||||
9
lib/new-admin/graphql/resolvers/version.resolver.js
Normal file
9
lib/new-admin/graphql/resolvers/version.resolver.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
const serverVersion = require('../../../../package.json').version
|
||||||
|
|
||||||
|
const resolvers = {
|
||||||
|
Query: {
|
||||||
|
serverVersion: () => serverVersion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = resolvers
|
||||||
|
|
@ -1,445 +1,7 @@
|
||||||
const { gql } = require('apollo-server-express')
|
const types = require('./types')
|
||||||
const { parseAsync } = require('json2csv')
|
const resolvers = require('./resolvers')
|
||||||
const { GraphQLDateTime } = require('graphql-iso-date')
|
|
||||||
const { GraphQLJSON, GraphQLJSONObject } = require('graphql-type-json')
|
|
||||||
const got = require('got')
|
|
||||||
const DataLoader = require('dataloader')
|
|
||||||
|
|
||||||
const machineLoader = require('../../machine-loader')
|
module.exports = {
|
||||||
const customers = require('../../customers')
|
resolvers: resolvers,
|
||||||
const { machineAction } = require('../modules/machines')
|
typeDefs: types
|
||||||
const logs = require('../../logs')
|
|
||||||
const settingsLoader = require('../../new-settings-loader')
|
|
||||||
// const tokenManager = require('../../token-manager')
|
|
||||||
const blacklist = require('../../blacklist')
|
|
||||||
const machineEventsByIdBatch = require('../../postgresql_interface').machineEventsByIdBatch
|
|
||||||
const promoCodeManager = require('../../promo-codes')
|
|
||||||
const notifierQueries = require('../../notifier/queries')
|
|
||||||
const bills = require('../bills')
|
|
||||||
const anonymous = require('../../constants').anonymousCustomer
|
|
||||||
|
|
||||||
const serverVersion = require('../../../package.json').version
|
|
||||||
|
|
||||||
const transactions = require('../modules/transactions')
|
|
||||||
const funding = require('../modules/funding')
|
|
||||||
const forex = require('../../forex')
|
|
||||||
const supervisor = require('../modules/supervisor')
|
|
||||||
const serverLogs = require('../modules/server-logs')
|
|
||||||
const pairing = require('../modules/pairing')
|
|
||||||
const plugins = require('../../plugins')
|
|
||||||
const {
|
|
||||||
accounts: accountsConfig,
|
|
||||||
coins,
|
|
||||||
countries,
|
|
||||||
currencies,
|
|
||||||
languages
|
|
||||||
} = require('../config')
|
|
||||||
|
|
||||||
const typeDefs = gql`
|
|
||||||
scalar JSON
|
|
||||||
scalar JSONObject
|
|
||||||
scalar Date
|
|
||||||
|
|
||||||
type Currency {
|
|
||||||
code: String!
|
|
||||||
display: String!
|
|
||||||
}
|
|
||||||
|
|
||||||
type CryptoCurrency {
|
|
||||||
code: String!
|
|
||||||
display: String!
|
|
||||||
}
|
|
||||||
|
|
||||||
type Country {
|
|
||||||
code: String!
|
|
||||||
display: String!
|
|
||||||
}
|
|
||||||
|
|
||||||
type Language {
|
|
||||||
code: String!
|
|
||||||
display: String!
|
|
||||||
}
|
|
||||||
|
|
||||||
type MachineStatus {
|
|
||||||
label: String!
|
|
||||||
type: String!
|
|
||||||
}
|
|
||||||
|
|
||||||
type Machine {
|
|
||||||
name: String!
|
|
||||||
deviceId: ID!
|
|
||||||
paired: Boolean!
|
|
||||||
lastPing: Date
|
|
||||||
pairedAt: Date
|
|
||||||
version: String
|
|
||||||
model: String
|
|
||||||
cashbox: Int
|
|
||||||
cassette1: Int
|
|
||||||
cassette2: Int
|
|
||||||
statuses: [MachineStatus]
|
|
||||||
latestEvent: MachineEvent
|
|
||||||
}
|
|
||||||
|
|
||||||
type Customer {
|
|
||||||
id: ID!
|
|
||||||
authorizedOverride: String
|
|
||||||
daysSuspended: Int
|
|
||||||
frontCameraPath: String
|
|
||||||
frontCameraOverride: String
|
|
||||||
phone: String
|
|
||||||
isAnonymous: Boolean
|
|
||||||
smsOverride: String
|
|
||||||
idCardData: JSONObject
|
|
||||||
idCardDataOverride: String
|
|
||||||
idCardDataExpiration: Date
|
|
||||||
idCardPhotoPath: String
|
|
||||||
idCardPhotoOverride: String
|
|
||||||
usSsn: String
|
|
||||||
usSsnOverride: String
|
|
||||||
sanctions: Boolean
|
|
||||||
sanctionsAt: Date
|
|
||||||
sanctionsOverride: String
|
|
||||||
totalTxs: Int
|
|
||||||
totalSpent: String
|
|
||||||
lastActive: Date
|
|
||||||
lastTxFiat: String
|
|
||||||
lastTxFiatCode: String
|
|
||||||
lastTxClass: String
|
|
||||||
transactions: [Transaction]
|
|
||||||
}
|
|
||||||
|
|
||||||
input CustomerInput {
|
|
||||||
authorizedOverride: String
|
|
||||||
frontCameraPath: String
|
|
||||||
frontCameraOverride: String
|
|
||||||
phone: String
|
|
||||||
smsOverride: String
|
|
||||||
idCardData: JSONObject
|
|
||||||
idCardDataOverride: String
|
|
||||||
idCardDataExpiration: Date
|
|
||||||
idCardPhotoPath: String
|
|
||||||
idCardPhotoOverride: String
|
|
||||||
usSsn: String
|
|
||||||
usSsnOverride: String
|
|
||||||
sanctions: Boolean
|
|
||||||
sanctionsAt: Date
|
|
||||||
sanctionsOverride: String
|
|
||||||
totalTxs: Int
|
|
||||||
totalSpent: String
|
|
||||||
lastActive: Date
|
|
||||||
lastTxFiat: String
|
|
||||||
lastTxFiatCode: String
|
|
||||||
lastTxClass: String
|
|
||||||
}
|
|
||||||
|
|
||||||
type AccountConfig {
|
|
||||||
code: String!
|
|
||||||
display: String!
|
|
||||||
class: String!
|
|
||||||
cryptos: [String]
|
|
||||||
deprecated: Boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
type MachineLog {
|
|
||||||
id: ID!
|
|
||||||
logLevel: String!
|
|
||||||
timestamp: Date!
|
|
||||||
message: String!
|
|
||||||
}
|
|
||||||
|
|
||||||
type ServerLog {
|
|
||||||
id: ID!
|
|
||||||
logLevel: String!
|
|
||||||
timestamp: Date!
|
|
||||||
message: String
|
|
||||||
}
|
|
||||||
|
|
||||||
type CoinFunds {
|
|
||||||
cryptoCode: String!
|
|
||||||
errorMsg: String
|
|
||||||
fundingAddress: String
|
|
||||||
fundingAddressUrl: String
|
|
||||||
confirmedBalance: String
|
|
||||||
pending: String
|
|
||||||
fiatConfirmedBalance: String
|
|
||||||
fiatPending: String
|
|
||||||
fiatCode: String
|
|
||||||
display: String
|
|
||||||
unitScale: String
|
|
||||||
}
|
|
||||||
|
|
||||||
type ProcessStatus {
|
|
||||||
name: String!
|
|
||||||
state: String!
|
|
||||||
uptime: Int!
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserToken {
|
|
||||||
token: String!
|
|
||||||
name: String!
|
|
||||||
created: Date!
|
|
||||||
user_agent: String
|
|
||||||
ip_address: String
|
|
||||||
}
|
|
||||||
|
|
||||||
type PromoCode {
|
|
||||||
id: ID!
|
|
||||||
code: String!
|
|
||||||
discount: Int!
|
|
||||||
}
|
|
||||||
|
|
||||||
type Transaction {
|
|
||||||
id: ID!
|
|
||||||
txClass: String!
|
|
||||||
deviceId: ID!
|
|
||||||
toAddress: String
|
|
||||||
cryptoAtoms: String!
|
|
||||||
cryptoCode: String!
|
|
||||||
fiat: String!
|
|
||||||
fiatCode: String!
|
|
||||||
fee: String
|
|
||||||
txHash: String
|
|
||||||
phone: String
|
|
||||||
error: String
|
|
||||||
created: Date
|
|
||||||
send: Boolean
|
|
||||||
sendConfirmed: Boolean
|
|
||||||
dispense: Boolean
|
|
||||||
timedout: Boolean
|
|
||||||
sendTime: Date
|
|
||||||
errorCode: String
|
|
||||||
operatorCompleted: Boolean
|
|
||||||
sendPending: Boolean
|
|
||||||
cashInFee: String
|
|
||||||
cashInFeeCrypto: String
|
|
||||||
minimumTx: Float
|
|
||||||
customerId: ID
|
|
||||||
isAnonymous: Boolean
|
|
||||||
txVersion: Int!
|
|
||||||
termsAccepted: Boolean
|
|
||||||
commissionPercentage: String
|
|
||||||
rawTickerPrice: String
|
|
||||||
isPaperWallet: Boolean
|
|
||||||
customerPhone: String
|
|
||||||
customerIdCardDataNumber: String
|
|
||||||
customerIdCardDataExpiration: Date
|
|
||||||
customerIdCardData: JSONObject
|
|
||||||
customerName: String
|
|
||||||
customerFrontCameraPath: String
|
|
||||||
customerIdCardPhotoPath: String
|
|
||||||
expired: Boolean
|
|
||||||
machineName: String
|
|
||||||
discount: Int
|
|
||||||
}
|
|
||||||
|
|
||||||
type Blacklist {
|
|
||||||
createdByOperator: Boolean!
|
|
||||||
cryptoCode: String!
|
|
||||||
address: String!
|
|
||||||
}
|
|
||||||
|
|
||||||
type MachineEvent {
|
|
||||||
id: ID
|
|
||||||
deviceId: String
|
|
||||||
eventType: String
|
|
||||||
note: String
|
|
||||||
created: Date
|
|
||||||
age: Float
|
|
||||||
deviceTime: Date
|
|
||||||
}
|
|
||||||
|
|
||||||
type Rate {
|
|
||||||
code: String
|
|
||||||
name: String
|
|
||||||
rate: Float
|
|
||||||
}
|
|
||||||
|
|
||||||
type Notification {
|
|
||||||
id: ID!
|
|
||||||
type: String
|
|
||||||
detail: JSON
|
|
||||||
message: String
|
|
||||||
created: Date
|
|
||||||
read: Boolean
|
|
||||||
valid: Boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
type Bills {
|
|
||||||
fiat: Int
|
|
||||||
deviceId: ID
|
|
||||||
created: Date
|
|
||||||
cashbox: Int
|
|
||||||
}
|
|
||||||
|
|
||||||
type Query {
|
|
||||||
countries: [Country]
|
|
||||||
currencies: [Currency]
|
|
||||||
languages: [Language]
|
|
||||||
accountsConfig: [AccountConfig]
|
|
||||||
cryptoCurrencies: [CryptoCurrency]
|
|
||||||
machines: [Machine]
|
|
||||||
machine(deviceId: ID!): Machine
|
|
||||||
customers: [Customer]
|
|
||||||
customer(customerId: ID!): Customer
|
|
||||||
machineLogs(deviceId: ID!, from: Date, until: Date, limit: Int, offset: Int): [MachineLog]
|
|
||||||
machineLogsCsv(deviceId: ID!, from: Date, until: Date, limit: Int, offset: Int): String
|
|
||||||
funding: [CoinFunds]
|
|
||||||
serverVersion: String!
|
|
||||||
uptime: [ProcessStatus]
|
|
||||||
serverLogs(from: Date, until: Date, limit: Int, offset: Int): [ServerLog]
|
|
||||||
serverLogsCsv(from: Date, until: Date, limit: Int, offset: Int): String
|
|
||||||
transactions(
|
|
||||||
from: Date
|
|
||||||
until: Date
|
|
||||||
limit: Int
|
|
||||||
offset: Int
|
|
||||||
deviceId: ID
|
|
||||||
): [Transaction]
|
|
||||||
transactionsCsv(from: Date, until: Date, limit: Int, offset: Int): String
|
|
||||||
accounts: JSONObject
|
|
||||||
config: JSONObject
|
|
||||||
blacklist: [Blacklist]
|
|
||||||
# userTokens: [UserToken]
|
|
||||||
promoCodes: [PromoCode]
|
|
||||||
cryptoRates: JSONObject
|
|
||||||
fiatRates: [Rate]
|
|
||||||
notifications: [Notification]
|
|
||||||
alerts: [Notification]
|
|
||||||
hasUnreadNotifications: Boolean
|
|
||||||
bills: [Bills]
|
|
||||||
}
|
|
||||||
|
|
||||||
type SupportLogsResponse {
|
|
||||||
id: ID!
|
|
||||||
timestamp: Date!
|
|
||||||
deviceId: ID
|
|
||||||
}
|
|
||||||
|
|
||||||
enum MachineAction {
|
|
||||||
rename
|
|
||||||
emptyCashInBills
|
|
||||||
resetCashOutBills
|
|
||||||
setCassetteBills
|
|
||||||
unpair
|
|
||||||
reboot
|
|
||||||
shutdown
|
|
||||||
restartServices
|
|
||||||
}
|
|
||||||
|
|
||||||
type Mutation {
|
|
||||||
machineAction(deviceId:ID!, action: MachineAction!, cashbox: Int, cassette1: Int, cassette2: Int, newName: String): Machine
|
|
||||||
setCustomer(customerId: ID!, customerInput: CustomerInput): Customer
|
|
||||||
saveConfig(config: JSONObject): JSONObject
|
|
||||||
resetConfig(schemaVersion: Int): JSONObject
|
|
||||||
createPairingTotem(name: String!): String
|
|
||||||
saveAccounts(accounts: JSONObject): JSONObject
|
|
||||||
resetAccounts(schemaVersion: Int): JSONObject
|
|
||||||
migrateConfigAndAccounts: JSONObject
|
|
||||||
# revokeToken(token: String!): UserToken
|
|
||||||
deleteBlacklistRow(cryptoCode: String!, address: String!): Blacklist
|
|
||||||
insertBlacklistRow(cryptoCode: String!, address: String!): Blacklist
|
|
||||||
createPromoCode(code: String!, discount: Int!): PromoCode
|
|
||||||
deletePromoCode(codeId: ID!): PromoCode
|
|
||||||
toggleClearNotification(id: ID!, read: Boolean!): Notification
|
|
||||||
clearAllNotifications: Notification
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
const transactionsLoader = new DataLoader(ids => transactions.getCustomerTransactionsBatch(ids))
|
|
||||||
const machineEventsLoader = new DataLoader(ids => {
|
|
||||||
return machineEventsByIdBatch(ids)
|
|
||||||
}, { cache: false })
|
|
||||||
|
|
||||||
const notify = () => got.post('http://localhost:3030/dbChange')
|
|
||||||
.catch(e => console.error('Error: lamassu-server not responding'))
|
|
||||||
|
|
||||||
const resolvers = {
|
|
||||||
JSON: GraphQLJSON,
|
|
||||||
JSONObject: GraphQLJSONObject,
|
|
||||||
Date: GraphQLDateTime,
|
|
||||||
Customer: {
|
|
||||||
transactions: parent => transactionsLoader.load(parent.id),
|
|
||||||
isAnonymous: parent => (parent.id === anonymous.uuid)
|
|
||||||
},
|
|
||||||
Transaction: {
|
|
||||||
isAnonymous: parent => (parent.customerId === anonymous.uuid)
|
|
||||||
},
|
|
||||||
Machine: {
|
|
||||||
latestEvent: parent => machineEventsLoader.load(parent.deviceId)
|
|
||||||
},
|
|
||||||
Query: {
|
|
||||||
countries: () => countries,
|
|
||||||
currencies: () => currencies,
|
|
||||||
languages: () => languages,
|
|
||||||
accountsConfig: () => accountsConfig,
|
|
||||||
cryptoCurrencies: () => coins,
|
|
||||||
machines: () => machineLoader.getMachineNames(),
|
|
||||||
machine: (...[, { deviceId }]) => machineLoader.getMachine(deviceId),
|
|
||||||
customers: () => customers.getCustomersList(),
|
|
||||||
customer: (...[, { customerId }]) => customers.getCustomerById(customerId),
|
|
||||||
funding: () => funding.getFunding(),
|
|
||||||
machineLogs: (...[, { deviceId, from, until, limit, offset }]) =>
|
|
||||||
logs.simpleGetMachineLogs(deviceId, from, until, limit, offset),
|
|
||||||
machineLogsCsv: (...[, { deviceId, from, until, limit, offset }]) =>
|
|
||||||
logs.simpleGetMachineLogs(deviceId, from, until, limit, offset).then(parseAsync),
|
|
||||||
serverVersion: () => serverVersion,
|
|
||||||
uptime: () => supervisor.getAllProcessInfo(),
|
|
||||||
serverLogs: (...[, { from, until, limit, offset }]) =>
|
|
||||||
serverLogs.getServerLogs(from, until, limit, offset),
|
|
||||||
serverLogsCsv: (...[, { from, until, limit, offset }]) =>
|
|
||||||
serverLogs.getServerLogs(from, until, limit, offset).then(parseAsync),
|
|
||||||
transactions: (...[, { from, until, limit, offset, deviceId }]) =>
|
|
||||||
transactions.batch(from, until, limit, offset, deviceId),
|
|
||||||
transactionsCsv: (...[, { from, until, limit, offset }]) =>
|
|
||||||
transactions.batch(from, until, limit, offset).then(parseAsync),
|
|
||||||
config: () => settingsLoader.loadLatestConfigOrNone(),
|
|
||||||
accounts: () => settingsLoader.showAccounts(),
|
|
||||||
blacklist: () => blacklist.getBlacklist(),
|
|
||||||
// userTokens: () => tokenManager.getTokenList()
|
|
||||||
promoCodes: () => promoCodeManager.getAvailablePromoCodes(),
|
|
||||||
cryptoRates: () =>
|
|
||||||
settingsLoader.loadLatest().then(settings => {
|
|
||||||
const pi = plugins(settings)
|
|
||||||
return pi.getRawRates().then(r => {
|
|
||||||
return {
|
|
||||||
withCommissions: pi.buildRates(r),
|
|
||||||
withoutCommissions: pi.buildRatesNoCommission(r)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
fiatRates: () => forex.getFiatRates(),
|
|
||||||
notifications: () => notifierQueries.getNotifications(),
|
|
||||||
hasUnreadNotifications: () => notifierQueries.hasUnreadNotifications(),
|
|
||||||
alerts: () => notifierQueries.getAlerts(),
|
|
||||||
bills: () => bills.getBills()
|
|
||||||
},
|
|
||||||
Mutation: {
|
|
||||||
machineAction: (...[, { deviceId, action, cashbox, cassette1, cassette2, newName }]) => machineAction({ deviceId, action, cashbox, cassette1, cassette2, newName }),
|
|
||||||
createPairingTotem: (...[, { name }]) => pairing.totem(name),
|
|
||||||
saveAccounts: (...[, { accounts }]) => settingsLoader.saveAccounts(accounts),
|
|
||||||
resetAccounts: (...[, { schemaVersion }]) => settingsLoader.resetAccounts(schemaVersion),
|
|
||||||
setCustomer: (root, { customerId, customerInput }, context, info) => {
|
|
||||||
const token = context.req.cookies && context.req.cookies.token
|
|
||||||
if (customerId === anonymous.uuid) return customers.getCustomerById(customerId)
|
|
||||||
return customers.updateCustomer(customerId, customerInput, token)
|
|
||||||
},
|
|
||||||
saveConfig: (...[, { config }]) => settingsLoader.saveConfig(config)
|
|
||||||
.then(it => {
|
|
||||||
notify()
|
|
||||||
return it
|
|
||||||
}),
|
|
||||||
resetConfig: (...[, { schemaVersion }]) => settingsLoader.resetConfig(schemaVersion),
|
|
||||||
migrateConfigAndAccounts: () => settingsLoader.migrate(),
|
|
||||||
deleteBlacklistRow: (...[, { cryptoCode, address }]) =>
|
|
||||||
blacklist.deleteFromBlacklist(cryptoCode, address),
|
|
||||||
insertBlacklistRow: (...[, { cryptoCode, address }]) =>
|
|
||||||
blacklist.insertIntoBlacklist(cryptoCode, address),
|
|
||||||
// revokeToken: (...[, { token }]) => tokenManager.revokeToken(token)
|
|
||||||
createPromoCode: (...[, { code, discount }]) => promoCodeManager.createPromoCode(code, discount),
|
|
||||||
deletePromoCode: (...[, { codeId }]) => promoCodeManager.deletePromoCode(codeId),
|
|
||||||
toggleClearNotification: (...[, { id, read }]) => notifierQueries.setRead(id, read),
|
|
||||||
clearAllNotifications: () => notifierQueries.markAllAsRead()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { resolvers, typeDefs }
|
|
||||||
|
|
|
||||||
20
lib/new-admin/graphql/types/blacklist.type.js
Normal file
20
lib/new-admin/graphql/types/blacklist.type.js
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
const { gql } = require('apollo-server-express')
|
||||||
|
|
||||||
|
const typeDef = gql`
|
||||||
|
type Blacklist {
|
||||||
|
createdByOperator: Boolean!
|
||||||
|
cryptoCode: String!
|
||||||
|
address: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
type Query {
|
||||||
|
blacklist: [Blacklist]
|
||||||
|
}
|
||||||
|
|
||||||
|
type Mutation {
|
||||||
|
deleteBlacklistRow(cryptoCode: String!, address: String!): Blacklist
|
||||||
|
insertBlacklistRow(cryptoCode: String!, address: String!): Blacklist
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
module.exports = typeDef
|
||||||
29
lib/new-admin/graphql/types/config.type.js
Normal file
29
lib/new-admin/graphql/types/config.type.js
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
const { gql } = require('apollo-server-express')
|
||||||
|
|
||||||
|
const typeDef = gql`
|
||||||
|
type Country {
|
||||||
|
code: String!
|
||||||
|
display: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
type Language {
|
||||||
|
code: String!
|
||||||
|
display: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
type AccountConfig {
|
||||||
|
code: String!
|
||||||
|
display: String!
|
||||||
|
class: String!
|
||||||
|
cryptos: [String]
|
||||||
|
deprecated: Boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
type Query {
|
||||||
|
countries: [Country]
|
||||||
|
languages: [Language]
|
||||||
|
accountsConfig: [AccountConfig]
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
module.exports = typeDef
|
||||||
20
lib/new-admin/graphql/types/currency.type.js
Normal file
20
lib/new-admin/graphql/types/currency.type.js
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
const { gql } = require('apollo-server-express')
|
||||||
|
|
||||||
|
const typeDef = gql`
|
||||||
|
type Currency {
|
||||||
|
code: String!
|
||||||
|
display: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
type CryptoCurrency {
|
||||||
|
code: String!
|
||||||
|
display: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
type Query {
|
||||||
|
currencies: [Currency]
|
||||||
|
cryptoCurrencies: [CryptoCurrency]
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
module.exports = typeDef
|
||||||
66
lib/new-admin/graphql/types/customer.type.js
Normal file
66
lib/new-admin/graphql/types/customer.type.js
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
const { gql } = require('apollo-server-express')
|
||||||
|
|
||||||
|
const typeDef = gql`
|
||||||
|
type Customer {
|
||||||
|
id: ID!
|
||||||
|
authorizedOverride: String
|
||||||
|
daysSuspended: Int
|
||||||
|
frontCameraPath: String
|
||||||
|
frontCameraOverride: String
|
||||||
|
phone: String
|
||||||
|
isAnonymous: Boolean
|
||||||
|
smsOverride: String
|
||||||
|
idCardData: JSONObject
|
||||||
|
idCardDataOverride: String
|
||||||
|
idCardDataExpiration: Date
|
||||||
|
idCardPhotoPath: String
|
||||||
|
idCardPhotoOverride: String
|
||||||
|
usSsn: String
|
||||||
|
usSsnOverride: String
|
||||||
|
sanctions: Boolean
|
||||||
|
sanctionsAt: Date
|
||||||
|
sanctionsOverride: String
|
||||||
|
totalTxs: Int
|
||||||
|
totalSpent: String
|
||||||
|
lastActive: Date
|
||||||
|
lastTxFiat: String
|
||||||
|
lastTxFiatCode: String
|
||||||
|
lastTxClass: String
|
||||||
|
transactions: [Transaction]
|
||||||
|
}
|
||||||
|
|
||||||
|
input CustomerInput {
|
||||||
|
authorizedOverride: String
|
||||||
|
frontCameraPath: String
|
||||||
|
frontCameraOverride: String
|
||||||
|
phone: String
|
||||||
|
smsOverride: String
|
||||||
|
idCardData: JSONObject
|
||||||
|
idCardDataOverride: String
|
||||||
|
idCardDataExpiration: Date
|
||||||
|
idCardPhotoPath: String
|
||||||
|
idCardPhotoOverride: String
|
||||||
|
usSsn: String
|
||||||
|
usSsnOverride: String
|
||||||
|
sanctions: Boolean
|
||||||
|
sanctionsAt: Date
|
||||||
|
sanctionsOverride: String
|
||||||
|
totalTxs: Int
|
||||||
|
totalSpent: String
|
||||||
|
lastActive: Date
|
||||||
|
lastTxFiat: String
|
||||||
|
lastTxFiatCode: String
|
||||||
|
lastTxClass: String
|
||||||
|
}
|
||||||
|
|
||||||
|
type Query {
|
||||||
|
customers: [Customer]
|
||||||
|
customer(customerId: ID!): Customer
|
||||||
|
}
|
||||||
|
|
||||||
|
type Mutation {
|
||||||
|
setCustomer(customerId: ID!, customerInput: CustomerInput): Customer
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
module.exports = typeDef
|
||||||
23
lib/new-admin/graphql/types/funding.type.js
Normal file
23
lib/new-admin/graphql/types/funding.type.js
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
const { gql } = require('apollo-server-express')
|
||||||
|
|
||||||
|
const typeDef = gql`
|
||||||
|
type CoinFunds {
|
||||||
|
cryptoCode: String!
|
||||||
|
errorMsg: String
|
||||||
|
fundingAddress: String
|
||||||
|
fundingAddressUrl: String
|
||||||
|
confirmedBalance: String
|
||||||
|
pending: String
|
||||||
|
fiatConfirmedBalance: String
|
||||||
|
fiatPending: String
|
||||||
|
fiatCode: String
|
||||||
|
display: String
|
||||||
|
unitScale: String
|
||||||
|
}
|
||||||
|
|
||||||
|
type Query {
|
||||||
|
funding: [CoinFunds]
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
module.exports = typeDef
|
||||||
35
lib/new-admin/graphql/types/index.js
Normal file
35
lib/new-admin/graphql/types/index.js
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
const { mergeTypeDefs } = require('@graphql-tools/merge')
|
||||||
|
|
||||||
|
const blacklist = require('./blacklist.type')
|
||||||
|
const config = require('./config.type')
|
||||||
|
const currency = require('./currency.type')
|
||||||
|
const customer = require('./customer.type')
|
||||||
|
const funding = require('./funding.type')
|
||||||
|
const log = require('./log.type')
|
||||||
|
const machine = require('./machine.type')
|
||||||
|
const pairing = require('./pairing.type')
|
||||||
|
const promo = require('./promo.type')
|
||||||
|
const scalar = require('./scalar.type')
|
||||||
|
const settings = require('./settings.type')
|
||||||
|
const status = require('./status.type')
|
||||||
|
const transaction = require('./transaction.type')
|
||||||
|
const version = require('./version.type')
|
||||||
|
|
||||||
|
const types = [
|
||||||
|
blacklist,
|
||||||
|
config,
|
||||||
|
currency,
|
||||||
|
customer,
|
||||||
|
funding,
|
||||||
|
log,
|
||||||
|
machine,
|
||||||
|
pairing,
|
||||||
|
promo,
|
||||||
|
scalar,
|
||||||
|
settings,
|
||||||
|
status,
|
||||||
|
transaction,
|
||||||
|
version
|
||||||
|
]
|
||||||
|
|
||||||
|
module.exports = mergeTypeDefs(types)
|
||||||
26
lib/new-admin/graphql/types/log.type.js
Normal file
26
lib/new-admin/graphql/types/log.type.js
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
const { gql } = require('apollo-server-express')
|
||||||
|
|
||||||
|
const typeDef = gql`
|
||||||
|
type MachineLog {
|
||||||
|
id: ID!
|
||||||
|
logLevel: String!
|
||||||
|
timestamp: Date!
|
||||||
|
message: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
type ServerLog {
|
||||||
|
id: ID!
|
||||||
|
logLevel: String!
|
||||||
|
timestamp: Date!
|
||||||
|
message: String
|
||||||
|
}
|
||||||
|
|
||||||
|
type Query {
|
||||||
|
machineLogs(deviceId: ID!, from: Date, until: Date, limit: Int, offset: Int): [MachineLog]
|
||||||
|
machineLogsCsv(deviceId: ID!, from: Date, until: Date, limit: Int, offset: Int): String
|
||||||
|
serverLogs(from: Date, until: Date, limit: Int, offset: Int): [ServerLog]
|
||||||
|
serverLogsCsv(from: Date, until: Date, limit: Int, offset: Int): String
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
module.exports = typeDef
|
||||||
55
lib/new-admin/graphql/types/machine.type.js
Normal file
55
lib/new-admin/graphql/types/machine.type.js
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
const { gql } = require('apollo-server-express')
|
||||||
|
|
||||||
|
const typeDef = gql`
|
||||||
|
type MachineStatus {
|
||||||
|
label: String!
|
||||||
|
type: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
type Machine {
|
||||||
|
name: String!
|
||||||
|
deviceId: ID!
|
||||||
|
paired: Boolean!
|
||||||
|
lastPing: Date
|
||||||
|
pairedAt: Date
|
||||||
|
version: String
|
||||||
|
model: String
|
||||||
|
cashbox: Int
|
||||||
|
cassette1: Int
|
||||||
|
cassette2: Int
|
||||||
|
statuses: [MachineStatus]
|
||||||
|
latestEvent: MachineEvent
|
||||||
|
}
|
||||||
|
|
||||||
|
type MachineEvent {
|
||||||
|
id: ID
|
||||||
|
deviceId: String
|
||||||
|
eventType: String
|
||||||
|
note: String
|
||||||
|
created: Date
|
||||||
|
age: Float
|
||||||
|
deviceTime: Date
|
||||||
|
}
|
||||||
|
|
||||||
|
enum MachineAction {
|
||||||
|
rename
|
||||||
|
emptyCashInBills
|
||||||
|
resetCashOutBills
|
||||||
|
setCassetteBills
|
||||||
|
unpair
|
||||||
|
reboot
|
||||||
|
shutdown
|
||||||
|
restartServices
|
||||||
|
}
|
||||||
|
|
||||||
|
type Query {
|
||||||
|
machines: [Machine]
|
||||||
|
machine(deviceId: ID!): Machine
|
||||||
|
}
|
||||||
|
|
||||||
|
type Mutation {
|
||||||
|
machineAction(deviceId:ID!, action: MachineAction!, cashbox: Int, cassette1: Int, cassette2: Int, newName: String): Machine
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
module.exports = typeDef
|
||||||
9
lib/new-admin/graphql/types/pairing.type.js
Normal file
9
lib/new-admin/graphql/types/pairing.type.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
const { gql } = require('apollo-server-express')
|
||||||
|
|
||||||
|
const typeDef = gql`
|
||||||
|
type Mutation {
|
||||||
|
createPairingTotem(name: String!): String
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
module.exports = typeDef
|
||||||
20
lib/new-admin/graphql/types/promo.type.js
Normal file
20
lib/new-admin/graphql/types/promo.type.js
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
const { gql } = require('apollo-server-express')
|
||||||
|
|
||||||
|
const typeDef = gql`
|
||||||
|
type PromoCode {
|
||||||
|
id: ID!
|
||||||
|
code: String!
|
||||||
|
discount: Int
|
||||||
|
}
|
||||||
|
|
||||||
|
type Query {
|
||||||
|
promoCodes: [PromoCode]
|
||||||
|
}
|
||||||
|
|
||||||
|
type Mutation {
|
||||||
|
createPromoCode(code: String!, discount: Int!): PromoCode
|
||||||
|
deletePromoCode(codeId: ID!): PromoCode
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
module.exports = typeDef
|
||||||
9
lib/new-admin/graphql/types/scalar.type.js
Normal file
9
lib/new-admin/graphql/types/scalar.type.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
const { gql } = require('apollo-server-express')
|
||||||
|
|
||||||
|
const typeDef = gql`
|
||||||
|
scalar JSON
|
||||||
|
scalar JSONObject
|
||||||
|
scalar Date
|
||||||
|
`
|
||||||
|
|
||||||
|
module.exports = typeDef
|
||||||
18
lib/new-admin/graphql/types/settings.type.js
Normal file
18
lib/new-admin/graphql/types/settings.type.js
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
const { gql } = require('apollo-server-express')
|
||||||
|
|
||||||
|
const typeDef = gql`
|
||||||
|
type Query {
|
||||||
|
accounts: JSONObject
|
||||||
|
config: JSONObject
|
||||||
|
}
|
||||||
|
|
||||||
|
type Mutation {
|
||||||
|
saveAccounts(accounts: JSONObject): JSONObject
|
||||||
|
resetAccounts(schemaVersion: Int): JSONObject
|
||||||
|
saveConfig(config: JSONObject): JSONObject
|
||||||
|
resetConfig(schemaVersion: Int): JSONObject
|
||||||
|
migrateConfigAndAccounts: JSONObject
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
module.exports = typeDef
|
||||||
15
lib/new-admin/graphql/types/status.type.js
Normal file
15
lib/new-admin/graphql/types/status.type.js
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
const { gql } = require('apollo-server-express')
|
||||||
|
|
||||||
|
const typeDef = gql`
|
||||||
|
type ProcessStatus {
|
||||||
|
name: String!
|
||||||
|
state: String!
|
||||||
|
uptime: Int!
|
||||||
|
}
|
||||||
|
|
||||||
|
type Query {
|
||||||
|
uptime: [ProcessStatus]
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
module.exports = typeDef
|
||||||
54
lib/new-admin/graphql/types/transaction.type.js
Normal file
54
lib/new-admin/graphql/types/transaction.type.js
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
const { gql } = require('apollo-server-express')
|
||||||
|
|
||||||
|
const typeDef = gql`
|
||||||
|
type Transaction {
|
||||||
|
id: ID!
|
||||||
|
txClass: String!
|
||||||
|
deviceId: ID!
|
||||||
|
toAddress: String
|
||||||
|
cryptoAtoms: String!
|
||||||
|
cryptoCode: String!
|
||||||
|
fiat: String!
|
||||||
|
fiatCode: String!
|
||||||
|
fee: String
|
||||||
|
txHash: String
|
||||||
|
phone: String
|
||||||
|
error: String
|
||||||
|
created: Date
|
||||||
|
send: Boolean
|
||||||
|
sendConfirmed: Boolean
|
||||||
|
dispense: Boolean
|
||||||
|
timedout: Boolean
|
||||||
|
sendTime: Date
|
||||||
|
errorCode: String
|
||||||
|
operatorCompleted: Boolean
|
||||||
|
sendPending: Boolean
|
||||||
|
cashInFee: String
|
||||||
|
cashInFeeCrypto: String
|
||||||
|
minimumTx: Float
|
||||||
|
customerId: ID
|
||||||
|
isAnonymous: Boolean
|
||||||
|
txVersion: Int!
|
||||||
|
termsAccepted: Boolean
|
||||||
|
commissionPercentage: String
|
||||||
|
rawTickerPrice: String
|
||||||
|
isPaperWallet: Boolean
|
||||||
|
customerPhone: String
|
||||||
|
customerIdCardDataNumber: String
|
||||||
|
customerIdCardDataExpiration: Date
|
||||||
|
customerIdCardData: JSONObject
|
||||||
|
customerName: String
|
||||||
|
customerFrontCameraPath: String
|
||||||
|
customerIdCardPhotoPath: String
|
||||||
|
expired: Boolean
|
||||||
|
machineName: String
|
||||||
|
discount: Int
|
||||||
|
}
|
||||||
|
|
||||||
|
type Query {
|
||||||
|
transactions(from: Date, until: Date, limit: Int, offset: Int, deviceId: ID): [Transaction]
|
||||||
|
transactionsCsv(from: Date, until: Date, limit: Int, offset: Int): String
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
module.exports = typeDef
|
||||||
9
lib/new-admin/graphql/types/version.type.js
Normal file
9
lib/new-admin/graphql/types/version.type.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
const { gql } = require('apollo-server-express')
|
||||||
|
|
||||||
|
const typeDef = gql`
|
||||||
|
type Query {
|
||||||
|
serverVersion: String!
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
module.exports = typeDef
|
||||||
|
|
@ -5,25 +5,6 @@ const configManager = require('../../new-config-manager')
|
||||||
const wallet = require('../../wallet')
|
const wallet = require('../../wallet')
|
||||||
const ticker = require('../../ticker')
|
const ticker = require('../../ticker')
|
||||||
const coinUtils = require('../../coin-utils')
|
const coinUtils = require('../../coin-utils')
|
||||||
const logger = require('../../logger')
|
|
||||||
|
|
||||||
function allScopes (cryptoScopes, machineScopes) {
|
|
||||||
const scopes = []
|
|
||||||
cryptoScopes.forEach(c => {
|
|
||||||
machineScopes.forEach(m => scopes.push([c, m]))
|
|
||||||
})
|
|
||||||
|
|
||||||
return scopes
|
|
||||||
}
|
|
||||||
|
|
||||||
function allMachineScopes (machineList, machineScope) {
|
|
||||||
const machineScopes = []
|
|
||||||
|
|
||||||
if (machineScope === 'global' || machineScope === 'both') machineScopes.push('global')
|
|
||||||
if (machineScope === 'specific' || machineScope === 'both') machineList.forEach(r => machineScopes.push(r))
|
|
||||||
|
|
||||||
return machineScopes
|
|
||||||
}
|
|
||||||
|
|
||||||
function computeCrypto (cryptoCode, _balance) {
|
function computeCrypto (cryptoCode, _balance) {
|
||||||
const cryptoRec = coinUtils.getCryptoCurrency(cryptoCode)
|
const cryptoRec = coinUtils.getCryptoCurrency(cryptoCode)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ function validateOTP (otp) {
|
||||||
.catch(() => ({ success: false, expired: false }))
|
.catch(() => ({ success: false, expired: false }))
|
||||||
}
|
}
|
||||||
|
|
||||||
function register (otp, ua, ip) {
|
function register (otp, ua, ip) {
|
||||||
return validateOTP(otp)
|
return validateOTP(otp)
|
||||||
.then(r => {
|
.then(r => {
|
||||||
if (!r.success) return r
|
if (!r.success) return r
|
||||||
|
|
|
||||||
1986
package-lock.json
generated
1986
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -36,6 +36,7 @@
|
||||||
"got": "^7.1.0",
|
"got": "^7.1.0",
|
||||||
"graphql": "^15.5.0",
|
"graphql": "^15.5.0",
|
||||||
"graphql-iso-date": "^3.6.1",
|
"graphql-iso-date": "^3.6.1",
|
||||||
|
"graphql-tools": "^7.0.2",
|
||||||
"graphql-type-json": "^0.3.1",
|
"graphql-type-json": "^0.3.1",
|
||||||
"helmet": "^3.8.1",
|
"helmet": "^3.8.1",
|
||||||
"inquirer": "^5.2.0",
|
"inquirer": "^5.2.0",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue