Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const runService = service => {
assertEnvVar('COZY_URL')
assertEnvVar('COZY_CREDENTIALS')
const client = new CozyClient({
uri: process.env.COZY_URL.trim(),
schema,
token: process.env.COZY_CREDENTIALS.trim()
})
Document.registerClient(client)
return service({ client }).catch(e => {
// eslint-disable-next-line no-console
console.error(e)
process.exit(1)
})
}
/**
* Visualizer to see links between transactions and bills.
*
* Launch with `cozy-run-dev visualizer/index.js`
*/
const Linker = require('ducks/billsMatching/Linker/Linker').default
const { cozyClient } = require('cozy-konnector-libs')
const { Document } = require('cozy-doctypes')
const { Bill } = require('models')
const path = require('path')
// TODO Find out why our models parent class and Document from cozy-doctypes are different
Document.registerClient(cozyClient)
Bill.registerClient(cozyClient)
class DryLinker extends Linker {
commitChanges() {
return Promise.resolve()
}
}
const generate = async options => {
const bills = await Bill.fetchAll()
const linker = new DryLinker(cozyClient)
const results = await linker.linkBillsToOperations(bills, undefined, options)
return results
}
const main = async () => {
attachProcessEventHandlers()
const client = CozyClient.fromEnv(process.env)
Document.registerClient(client)
const options = await getOptions(cozyClient)
log('info', 'Options:')
log('info', JSON.stringify(options))
await onOperationOrBillCreate(client, options)
}