v12.0.0 - initial commit

This commit is contained in:
padreug 2025-12-31 19:04:13 +01:00
commit e2c49ea43c
1145 changed files with 97211 additions and 0 deletions

View file

@ -0,0 +1,27 @@
const machineLoader = require('../../machine-loader')
const { UserInputError } = require('../graphql/errors')
function getMachine(machineId) {
return machineLoader
.getMachines()
.then(machines => machines.find(({ deviceId }) => deviceId === machineId))
}
function machineAction({ deviceId, action, cashUnits, newName }, context) {
const operatorId = context.res.locals.operatorId
return getMachine(deviceId)
.then(machine => {
if (!machine)
throw new UserInputError(`machine:${deviceId} not found`, { deviceId })
return machine
})
.then(() =>
machineLoader.setMachine(
{ deviceId, action, cashUnits, newName },
operatorId,
),
)
.then(() => getMachine(deviceId))
}
module.exports = { machineAction }