diff --git a/back/methods/dms/uploadFile.js b/back/methods/dms/uploadFile.js index 1604a6afa..220f944d8 100644 --- a/back/methods/dms/uploadFile.js +++ b/back/methods/dms/uploadFile.js @@ -5,40 +5,36 @@ module.exports = Self => { Self.remoteMethodCtx('uploadFile', { description: 'Uploads a file and inserts into dms model', accessType: 'WRITE', - accepts: [{ - arg: 'options', - type: 'object' - }, - { - arg: 'warehouseId', - type: 'Number', - description: '' - }, - { - arg: 'companyId', - type: 'Number', - description: '' - }, - { - arg: 'dmsTypeId', - type: 'Number', - description: '' - }, - { - arg: 'reference', - type: 'String', - description: '' - }, - { - arg: 'description', - type: 'String', - description: '' - }, - { - arg: 'hasFile', - type: 'Boolean', - description: '' - }], + accepts: [ + { + arg: 'options', + type: 'object' + }, { + arg: 'warehouseId', + type: 'Number', + description: '' + }, { + arg: 'companyId', + type: 'Number', + description: '' + }, { + arg: 'dmsTypeId', + type: 'Number', + description: '' + }, { + arg: 'reference', + type: 'String', + description: '' + }, { + arg: 'description', + type: 'String', + description: '' + }, { + arg: 'hasFile', + type: 'Boolean', + description: '' + } + ], returns: { type: 'Object', root: true @@ -49,17 +45,24 @@ module.exports = Self => { } }); - Self.uploadFile = async(ctx, options = {}) => { + Self.uploadFile = async(ctx, options) => { const models = Self.app.models; const storageConnector = Self.app.dataSources.storage.connector; const myUserId = ctx.req.accessToken.userId; const myWorker = await models.Worker.findOne({where: {userFk: myUserId}}); const args = ctx.args; const fileOptions = {}; - const hasParentTransaction = options && options.transaction; - if (!options.transaction) - options.transaction = await Self.beginTransaction({}); + let tx; + let myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } try { const hasWriteRole = await models.DmsType.hasWriteRole(ctx, args.dmsTypeId); @@ -83,11 +86,11 @@ module.exports = Self => { reference: args.reference, description: args.description, hasFile: args.hasFile - }, options).then(newDms => { + }, myOptions).then(newDms => { const extension = storageConnector.getFileExtension(file.name); const fileName = `${newDms.id}.${extension}`; - return newDms.updateAttribute('file', fileName, options); + return newDms.updateAttribute('file', fileName, myOptions); }).then(dms => { return models.Container.getContainer('temp').then(container => { const originPath = `${container.client.root}/${container.name}/${file.name}`; @@ -104,14 +107,10 @@ module.exports = Self => { const resolvedPromise = await Promise.all(promises); - if (!hasParentTransaction) - await options.transaction.commit(); - + if (tx) await tx.commit(); return resolvedPromise; } catch (e) { - if (!hasParentTransaction) - await options.transaction.rollback(); - + if (tx) await tx.rollback(); throw e; } }; diff --git a/loopback/common/models/loggable.js b/loopback/common/models/loggable.js index 32b5db430..781509e92 100644 --- a/loopback/common/models/loggable.js +++ b/loopback/common/models/loggable.js @@ -112,7 +112,7 @@ module.exports = function(Self) { for (let key1 in ctx.Model.relations) { let val1 = ctx.Model.relations[key1]; if (val1.keyFrom == key && key != 'id') { - let recordSet = await ctx.Model.app.models[val1.modelTo.modelName].findById(val, options); + let recordSet = await ctx.Model.app.models[val1.modelTo.modelName].findById(val, null, options); let showField = val1.modelTo && val1.modelTo.definition.settings.log && val1.modelTo.definition.settings.log.showField && recordSet && recordSet[val1.modelTo.definition.settings.log.showField]; if (!showField) { diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 41287c2a7..c2bf8463e 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -11,6 +11,20 @@ module.exports = function(Self) { setup() { Self.super_.setup.call(this); + /** + * Setting a global transaction timeout to find out if the service + * is blocked because the connection pool is empty. + */ + this.once('dataSourceAttached', () => { + let orgBeginTransaction = this.beginTransaction; + this.beginTransaction = function(options, cb) { + options = options || {}; + if (!options.timeout) + options.timeout = 30000; + return orgBeginTransaction.call(this, options, cb); + }; + }); + // Register field ACL validation /* this.beforeRemote('prototype.patchAttributes', ctx => this.checkUpdateAcls(ctx)); this.beforeRemote('updateAll', ctx => this.checkUpdateAcls(ctx)); @@ -41,10 +55,11 @@ module.exports = function(Self) { }, async crud(deletes, updates, creates) { - let transaction = await this.beginTransaction({}); - let options = {transaction}; + let tx = await this.beginTransaction({}); try { + let options = {transaction: tx}; + if (deletes) { let promises = []; for (let id of deletes) @@ -65,9 +80,9 @@ module.exports = function(Self) { } } - await transaction.commit(); + await tx.commit(); } catch (error) { - await transaction.rollback(); + await tx.rollback(); throw error; } }, diff --git a/loopback/server/middleware.development.json b/loopback/server/middleware.development.json index 071c11a30..9cb38a275 100644 --- a/loopback/server/middleware.development.json +++ b/loopback/server/middleware.development.json @@ -3,7 +3,7 @@ "strong-error-handler": { "params": { "debug": true, - "log": true + "log": false } } } diff --git a/loopback/server/middleware.json b/loopback/server/middleware.json index 5945458c7..7fbd27250 100644 --- a/loopback/server/middleware.json +++ b/loopback/server/middleware.json @@ -49,6 +49,10 @@ }, "final:after": { "./middleware/error-handler": {}, - "strong-error-handler": {} + "strong-error-handler": { + "params": { + "log": false + } + } } } diff --git a/loopback/server/middleware/error-handler.js b/loopback/server/middleware/error-handler.js index 2ac11f608..8772220de 100644 --- a/loopback/server/middleware/error-handler.js +++ b/loopback/server/middleware/error-handler.js @@ -1,4 +1,5 @@ const UserError = require('../../util/user-error'); +const logToConsole = require('strong-error-handler/lib/logger'); module.exports = function() { return function(err, req, res, next) { @@ -23,6 +24,9 @@ module.exports = function() { if (err.sqlState == '45000') return next(new UserError(req.__(err.sqlMessage))); + if (!err.statusCode || err.statusCode >= 500) + logToConsole(req, err); + next(err); }; }; diff --git a/modules/agency/back/methods/zone/clone.js b/modules/agency/back/methods/zone/clone.js index 0f406c49a..7924415ed 100644 --- a/modules/agency/back/methods/zone/clone.js +++ b/modules/agency/back/methods/zone/clone.js @@ -21,39 +21,40 @@ module.exports = Self => { Self.clone = async id => { const models = Self.app.models; - const transaction = await Self.beginTransaction({}); - const options = {transaction}; - - // Find original zone - const zone = await models.Zone.findOne({ - fields: [ - 'name', - 'hour', - 'warehouseFk', - 'agencyModeFk', - 'travelingDays', - 'price', - 'bonus', - 'isVolumetric'], - where: {id} - }, options); - - const hour = zone.hour; - const offset = hour.getTimezoneOffset() * 60000; - hour.setTime(hour.getTime() + offset); - - // Find all original included geolocations - const includedGeo = await models.ZoneIncluded.find({ - fields: ['geoFk', 'isIncluded'], - where: {zoneFk: id} - }, options); - - // Find all original selected days - const calendarDays = await models.ZoneCalendar.find({ - where: {zoneFk: id} - }, options); + const tx = await Self.beginTransaction({}); try { + let options = {transaction: tx}; + + // Find original zone + const zone = await models.Zone.findOne({ + fields: [ + 'name', + 'hour', + 'warehouseFk', + 'agencyModeFk', + 'travelingDays', + 'price', + 'bonus', + 'isVolumetric'], + where: {id} + }, options); + + const hour = zone.hour; + const offset = hour.getTimezoneOffset() * 60000; + hour.setTime(hour.getTime() + offset); + + // Find all original included geolocations + const includedGeo = await models.ZoneIncluded.find({ + fields: ['geoFk', 'isIncluded'], + where: {zoneFk: id} + }, options); + + // Find all original selected days + const calendarDays = await models.ZoneCalendar.find({ + where: {zoneFk: id} + }, options); + const newZone = await Self.create(zone, options); const newIncludedGeo = includedGeo.map(included => { included.zoneFk = newZone.id; @@ -66,11 +67,11 @@ module.exports = Self => { await models.ZoneIncluded.create(newIncludedGeo, options); await models.ZoneCalendar.create(newCalendayDays, options); - await transaction.commit(); + await tx.commit(); return newZone; } catch (e) { - await transaction.rollback(); + await tx.rollback(); throw e; } }; diff --git a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js index de07dd780..379eec368 100644 --- a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js +++ b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js @@ -19,7 +19,7 @@ module.exports = Self => { } }); - async function addSalesToTicket(salesToRefund, ticketFk, transaction) { + async function addSalesToTicket(salesToRefund, ticketFk, options) { let formatedSales = []; salesToRefund.forEach(sale => { let formatedSale = { @@ -35,10 +35,10 @@ module.exports = Self => { }; formatedSales.push(formatedSale); }); - return await Self.app.models.Sale.create(formatedSales, transaction); + return await Self.app.models.Sale.create(formatedSales, options); } - async function insertIntoClaimEnd(createdSales, claimId, workerId, transaction) { + async function insertIntoClaimEnd(createdSales, claimId, workerId, options) { let formatedSales = []; createdSales.forEach(sale => { let formatedSale = { @@ -48,17 +48,17 @@ module.exports = Self => { }; formatedSales.push(formatedSale); }); - return await Self.app.models.ClaimEnd.create(formatedSales, transaction); + return await Self.app.models.ClaimEnd.create(formatedSales, options); } - async function saveObservation(observation, transaction) { + async function saveObservation(observation, options) { let query = `INSERT INTO vn.ticketObservation(ticketFk, observationTypeFk, description) VALUES(?, ?, ?) ON DUPLICATE KEY UPDATE description = CONCAT(vn.ticketObservation.description, VALUES(description),' ')`; await Self.rawSql(query, [ observation.ticketFk, observation.observationTypeFk, observation.description - ], transaction); + ], options); } Self.importToNewRefundTicket = async(ctx, id) => { @@ -109,37 +109,39 @@ module.exports = Self => { ] }; - let transaction = await Self.beginTransaction({}); + let tx = await Self.beginTransaction({}); try { - let newRefundTicket = await models.Ticket.new(ctx, params, {transaction: transaction}); + let options = {transaction: tx}; + + let newRefundTicket = await models.Ticket.new(ctx, params, options); let observation = { description: `Reclama ticket: ${claim.ticketFk}`, ticketFk: newRefundTicket.id, observationTypeFk: obsevationType.id }; - await saveObservation(observation, {transaction: transaction}); + await saveObservation(observation, options); await models.TicketTracking.create({ ticketFk: newRefundTicket.id, stateFk: state.id, workerFk: worker.id - }, {transaction: transaction}); + }, options); let salesToRefund = await models.ClaimBeginning.find(salesFilter); - let createdSales = await addSalesToTicket(salesToRefund, newRefundTicket.id, {transaction: transaction}); - insertIntoClaimEnd(createdSales, id, worker.id, {transaction: transaction}); + let createdSales = await addSalesToTicket(salesToRefund, newRefundTicket.id, options); + insertIntoClaimEnd(createdSales, id, worker.id, options); await Self.rawSql('CALL vn.ticketCalculateClon(?, ?)', [ newRefundTicket.id, claim.ticketFk - ], {transaction: transaction}); + ], options); - await transaction.commit(); + await tx.commit(); return newRefundTicket; } catch (e) { - await transaction.rollback(); + await tx.rollback(); throw e; } }; diff --git a/modules/claim/back/methods/claim/createFromSales.js b/modules/claim/back/methods/claim/createFromSales.js index f3f4171af..0e4e34603 100644 --- a/modules/claim/back/methods/claim/createFromSales.js +++ b/modules/claim/back/methods/claim/createFromSales.js @@ -26,27 +26,29 @@ module.exports = Self => { Self.createFromSales = async(ctx, params) => { let model = Self.app.models; - let transaction = await Self.beginTransaction({}); + let tx = await Self.beginTransaction({}); try { + let options = {transaction: tx}; + let userId = ctx.req.accessToken.userId; let worker = await Self.app.models.Worker.findOne({where: {userFk: userId}}); params.claim.workerFk = worker.id; - let newClaim = await Self.create(params.claim, {transaction}); + let newClaim = await Self.create(params.claim, options); let promises = []; for (let i = 0; i < params.sales.length; i++) { - promises.push(model.ClaimBeginning.create( - {saleFk: params.sales[i].id, - claimFk: newClaim.id, - quantity: params.sales[i].quantity}, - {transaction})); + promises.push(model.ClaimBeginning.create({ + saleFk: params.sales[i].id, + claimFk: newClaim.id, + quantity: params.sales[i].quantity + }, options)); } await Promise.all(promises); - await transaction.commit(); + await tx.commit(); return newClaim; } catch (e) { - transaction.rollback(); + await tx.rollback(); throw e; } }; diff --git a/modules/claim/back/methods/claim/regularizeClaim.js b/modules/claim/back/methods/claim/regularizeClaim.js index 8ae47a3fa..5c54a7a2f 100644 --- a/modules/claim/back/methods/claim/regularizeClaim.js +++ b/modules/claim/back/methods/claim/regularizeClaim.js @@ -30,8 +30,10 @@ module.exports = Self => { where: {claimFk: params.claimFk} }); - let transaction = await Self.beginTransaction({}); + let tx = await Self.beginTransaction({}); try { + let options = {transaction: tx}; + for (let i = 0; i < claimEnds.length; i++) { const claimEnd = claimEnds[i]; const destination = claimEnd.claimDestination(); @@ -45,7 +47,7 @@ module.exports = Self => { addressFk: addressFk, companyFk: sale.ticket().companyFk, warehouseFk: sale.ticket().warehouseFk - }, transaction); + }, options); let address = await models.Address.findOne({ where: {id: addressFk} @@ -58,7 +60,7 @@ module.exports = Self => { warehouseFk: sale.ticket().warehouseFk, companyFk: sale.ticket().companyFk, userId: userId - }, transaction); + }, options); } await models.Sale.create({ @@ -68,7 +70,7 @@ module.exports = Self => { quantity: -sale.quantity, price: sale.price, discount: 100 - }, {transaction: transaction}); + }, options); if (sale.ticket().client().salesPerson()) { await sendMessage(ctx, { @@ -78,20 +80,20 @@ module.exports = Self => { quantity: sale.quantity, concept: sale.concept, nickname: address.nickname - }, transaction); + }, options); } } let claim = await Self.findById(params.claimFk); claim = await claim.updateAttributes({ claimStateFk: resolvedState - }, {transaction: transaction}); + }, options); - await transaction.commit(); + await tx.commit(); return claim; } catch (e) { - await transaction.rollback(); + await tx.rollback(); throw e; } }; @@ -117,7 +119,7 @@ module.exports = Self => { }); } - async function getTicketId(params, transaction) { + async function getTicketId(params, options) { const currentDate = new Date(); currentDate.setHours(null, null, null); @@ -129,12 +131,12 @@ module.exports = Self => { shipped: currentDate, landed: currentDate } - }, {transaction: transaction}); + }, options); return ticket && ticket.id; } - async function createTicket(ctx, params, transaction) { + async function createTicket(ctx, params, options) { let ticket = await Self.app.models.Ticket.new(ctx, { shipped: new Date(), @@ -144,18 +146,18 @@ module.exports = Self => { companyFk: params.companyFk, addressFk: params.addressFk, userId: params.userId - }, {transaction: transaction}); + }, options); return ticket.id; } - async function sendMessage(ctx, params, transaction) { + async function sendMessage(ctx, params, options) { const message = `Envio ${params.quantity} unidades de "${params.concept}" (#${params.itemFk}) a ` + `"${params.nickname}" provenientes del ticket #${params.ticketFk}`; await Self.app.models.Message.send(ctx, { recipientFk: params.recipientFk, message: message - }, {transaction: transaction}); + }, options); } }; diff --git a/modules/claim/front/detail/index.html b/modules/claim/front/detail/index.html index 456a2ac73..a7031e31a 100644 --- a/modules/claim/front/detail/index.html +++ b/modules/claim/front/detail/index.html @@ -129,29 +129,28 @@ enable="true">
- -
MANÁ: {{$ctrl.mana | currency: 'EUR':0}}
-
-
- - - - - -
-

New price

-

{{($ctrl.saleClaimed.quantity * $ctrl.saleClaimed.sale.price) - - (($ctrl.newDiscount * ($ctrl.saleClaimed.quantity * $ctrl.saleClaimed.sale.price))/100) - | currency: 'EUR':2}} -

-
+ +
MANÁ: {{$ctrl.mana | currency: 'EUR':0}}
+
+
+ + + + + +
+

New price

+

{{($ctrl.saleClaimed.quantity * $ctrl.saleClaimed.sale.price) - + (($ctrl.newDiscount * ($ctrl.saleClaimed.quantity * $ctrl.saleClaimed.sale.price))/100) + | currency: 'EUR':2}} +

+
-

\ No newline at end of file diff --git a/modules/client/back/methods/address/createDefaultAddress.js b/modules/client/back/methods/address/createDefaultAddress.js index 46691717c..c757f9f85 100644 --- a/modules/client/back/methods/address/createDefaultAddress.js +++ b/modules/client/back/methods/address/createDefaultAddress.js @@ -19,23 +19,25 @@ module.exports = function(Self) { Self.createDefaultAddress = async data => { const Address = Self.app.models.Address; const Client = Self.app.models.Client; - const transaction = await Address.beginTransaction({}); + const tx = await Address.beginTransaction({}); try { + let options = {transaction: tx}; + let address = data.address; - let newAddress = await Address.create(address, {transaction}); - let client = await Client.findById(address.clientFk, {transaction}); + let newAddress = await Address.create(address, options); + let client = await Client.findById(address.clientFk, options); if (data.isDefaultAddress) { await client.updateAttributes({ defaultAddressFk: newAddress.id - }, {transaction}); + }, options); } - await transaction.commit(); + await tx.commit(); return newAddress; } catch (e) { - await transaction.rollback(); + await tx.rollback(); throw e; } }; diff --git a/modules/client/back/methods/client/confirmTransaction.js b/modules/client/back/methods/client/confirmTransaction.js index 30a09c5a1..997c3de7a 100644 --- a/modules/client/back/methods/client/confirmTransaction.js +++ b/modules/client/back/methods/client/confirmTransaction.js @@ -19,15 +19,17 @@ module.exports = Self => { }); Self.confirmTransaction = async(ctx, id) => { - let transaction = await Self.beginTransaction({}); let userId = ctx.req.accessToken.userId; + let tx = await Self.beginTransaction({}); try { - let oldTpvTransaction = await Self.app.models.TpvTransaction.findById(id, {options: transaction}); + let options = {transaction: tx}; - let confirm = await Self.rawSql('CALL hedera.tpvTransactionConfirmById(?)', [id], {options: transaction}); + let oldTpvTransaction = await Self.app.models.TpvTransaction.findById(id, null, options); - let tpvTransaction = await Self.app.models.TpvTransaction.findById(id, {options: transaction}); + let confirm = await Self.rawSql('CALL hedera.tpvTransactionConfirmById(?)', [id], options); + + let tpvTransaction = await Self.app.models.TpvTransaction.findById(id, null, options); let oldInstance = {status: oldTpvTransaction.status}; let newInstance = {status: tpvTransaction.status}; @@ -42,12 +44,12 @@ module.exports = Self => { newInstance: newInstance }; - await Self.app.models.ClientLog.create(logRecord, {options: transaction}); + await Self.app.models.ClientLog.create(logRecord, options); - await transaction.commit(); + await tx.commit(); return confirm; } catch (e) { - await transaction.rollback(); + await tx.rollback(); throw e; } }; diff --git a/modules/client/back/methods/client/createWithUser.js b/modules/client/back/methods/client/createWithUser.js index de18d4f4d..36ab28443 100644 --- a/modules/client/back/methods/client/createWithUser.js +++ b/modules/client/back/methods/client/createWithUser.js @@ -25,10 +25,12 @@ module.exports = function(Self) { }; const Account = Self.app.models.Account; const Address = Self.app.models.Address; - const transaction = await Account.beginTransaction({}); + const tx = await Account.beginTransaction({}); try { - let account = await Account.create(user, {transaction}); + let options = {transaction: tx}; + + let account = await Account.create(user, options); let client = await Self.create({ id: account.id, name: data.name, @@ -42,7 +44,7 @@ module.exports = function(Self) { provinceFk: data.provinceFk, countryFk: data.countryFk, isEqualizated: data.isEqualizated - }, {transaction}); + }, options); let address = await Address.create({ @@ -54,16 +56,16 @@ module.exports = function(Self) { provinceFk: client.provinceFk, isEqualizated: client.isEqualizated, isActive: true - }, {transaction}); + }, options); await client.updateAttributes({ defaultAddressFk: address.id - }, {transaction}); + }, options); - await transaction.commit(); + await tx.commit(); return client; } catch (e) { - await transaction.rollback(); + await tx.rollback(); throw e; } }; diff --git a/modules/client/back/methods/client/uploadFile.js b/modules/client/back/methods/client/uploadFile.js index 7187d684f..6b7a49459 100644 --- a/modules/client/back/methods/client/uploadFile.js +++ b/modules/client/back/methods/client/uploadFile.js @@ -50,11 +50,12 @@ module.exports = Self => { Self.uploadFile = async(ctx, id) => { const models = Self.app.models; - const transaction = await Self.beginTransaction({}); - const options = {transaction}; const promises = []; + const tx = await Self.beginTransaction({}); try { + const options = {transaction: tx}; + const uploadedFiles = await models.Dms.uploadFile(ctx, options); uploadedFiles.forEach(dms => { const newClientDms = models.ClientDms.create({ @@ -66,11 +67,11 @@ module.exports = Self => { }); const resolvedPromises = await Promise.all(promises); - await transaction.commit(); + await tx.commit(); return resolvedPromises; } catch (err) { - await transaction.rollback(); + await tx.rollback(); throw err; } }; diff --git a/modules/client/back/methods/credit-classification/createWithInsurance.js b/modules/client/back/methods/credit-classification/createWithInsurance.js index 66e11d271..368e9a41a 100644 --- a/modules/client/back/methods/credit-classification/createWithInsurance.js +++ b/modules/client/back/methods/credit-classification/createWithInsurance.js @@ -23,11 +23,13 @@ module.exports = Self => { }); Self.createWithInsurance = async(data, ctx) => { - let transaction = await Self.beginTransaction({}); + let tx = await Self.beginTransaction({}); try { + let options = {transaction: tx}; + let classificationSchema = {client: data.clientFk, started: data.started}; - let newClassification = await Self.create(classificationSchema, {transaction}); + let newClassification = await Self.create(classificationSchema, options); let CreditInsurance = Self.app.models.CreditInsurance; let insuranceSchema = { creditClassification: newClassification.id, @@ -35,13 +37,13 @@ module.exports = Self => { grade: data.grade }; - let newCreditInsurance = await CreditInsurance.create(insuranceSchema, {transaction}); - await transaction.commit(); + let newCreditInsurance = await CreditInsurance.create(insuranceSchema, options); + await tx.commit(); await CreditInsurance.messageSend(newCreditInsurance, ctx.req.accessToken); return newClassification; } catch (e) { - transaction.rollback(); + await tx.rollback(); throw e; } }; diff --git a/modules/invoiceOut/back/methods/invoiceOut/delete.js b/modules/invoiceOut/back/methods/invoiceOut/delete.js index afbd226a8..5700669c7 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/delete.js +++ b/modules/invoiceOut/back/methods/invoiceOut/delete.js @@ -21,24 +21,24 @@ module.exports = Self => { }); Self.delete = async id => { - const transaction = await Self.beginTransaction({}); + const tx = await Self.beginTransaction({}); try { + let options = {transaction: tx}; + let invoiceOut = await Self.findById(id); let tickets = await Self.app.models.Ticket.find({where: {refFk: invoiceOut.ref}}); const promises = []; tickets.forEach(ticket => { - promises.push(ticket.updateAttribute('refFk', null, {transaction})); + promises.push(ticket.updateAttribute('refFk', null, options)); }); - return Promise.all(promises).then(async() => { - await invoiceOut.destroy({transaction}); - await transaction.commit(); - - return tickets; - }); + await Promise.all(promises); + await invoiceOut.destroy(options); + await tx.commit(); + return tickets; } catch (e) { - await transaction.rollback(); + await tx.rollback(); throw e; } }; diff --git a/modules/invoiceOut/back/methods/invoiceOut/regenerate.js b/modules/invoiceOut/back/methods/invoiceOut/regenerate.js index 77123318a..e075ac1e4 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/regenerate.js +++ b/modules/invoiceOut/back/methods/invoiceOut/regenerate.js @@ -24,11 +24,13 @@ module.exports = Self => { const models = Self.app.models; const invoiceReportFk = 30; // FIXME - Should be deprecated const worker = await models.Worker.findOne({where: {userFk: userId}}); - const transaction = await Self.beginTransaction({}); + const tx = await Self.beginTransaction({}); try { + let options = {transaction: tx}; + // Remove all invoice references from tickets - const invoiceOut = await models.InvoiceOut.findById(id, {transaction}); + const invoiceOut = await models.InvoiceOut.findById(id, null, options); await invoiceOut.updateAttributes({ hasPdf: false }); @@ -36,13 +38,13 @@ module.exports = Self => { // Send to print queue await Self.rawSql(` INSERT INTO vn.printServerQueue (reportFk, param1, workerFk) - VALUES (?, ?, ?)`, [invoiceReportFk, id, worker.id], {transaction}); + VALUES (?, ?, ?)`, [invoiceReportFk, id, worker.id], options); - await transaction.commit(); + await tx.commit(); return invoiceOut; } catch (e) { - await transaction.rollback(); + await tx.rollback(); throw e; } }; diff --git a/modules/item/back/methods/item/clone.js b/modules/item/back/methods/item/clone.js index d2f887354..501cdc8d7 100644 --- a/modules/item/back/methods/item/clone.js +++ b/modules/item/back/methods/item/clone.js @@ -23,11 +23,12 @@ module.exports = Self => { }); Self.clone = async itemId => { - let transaction = await Self.beginTransaction({}); - let options = {transaction}; + let tx = await Self.beginTransaction({}); try { - const origin = await Self.findById(itemId, options); + let options = {transaction: tx}; + + const origin = await Self.findById(itemId, null, options); if (!origin) throw new UserError(`That item doesn't exists`); @@ -46,11 +47,10 @@ module.exports = Self => { await cloneTags(origin.id, newItem.id, promises, options); await Promise.all(promises); - await transaction.commit(); - + await tx.commit(); return newItem; } catch (e) { - await transaction.rollback(); + await tx.rollback(); throw e; } }; diff --git a/modules/item/back/methods/item/new.js b/modules/item/back/methods/item/new.js index b8e42213c..1d3f6f230 100644 --- a/modules/item/back/methods/item/new.js +++ b/modules/item/back/methods/item/new.js @@ -33,16 +33,18 @@ module.exports = Self => { throw new UserError(`You don't have enough privileges to do that`); } - let transaction = await Self.beginTransaction({}); + let tx = await Self.beginTransaction({}); try { + let options = {transaction: tx}; + let provisionalName = params.provisionalName; delete params.provisionalName; - let item = await Self.app.models.Item.create(params, {transaction: transaction}); + let item = await Self.app.models.Item.create(params, options); let typeTags = await Self.app.models.ItemTypeTag.find({where: {itemTypeFk: item.typeFk}}); let query = `SET @isTriggerDisabled = TRUE`; - await Self.rawSql(query, null, {transaction: transaction}); + await Self.rawSql(query, null, options); let nameTag = await Self.app.models.Tag.findOne({where: {name: 'Nombre temporal'}}); @@ -53,18 +55,18 @@ module.exports = Self => { newTags.push({itemFk: item.id, tagFk: typeTag.tagFk, value: '', priority: typeTag.priority}); }); - await Self.app.models.ItemTag.create(newTags, {transaction: transaction}); + await Self.app.models.ItemTag.create(newTags, options); query = `SET @isTriggerDisabled = FALSE`; - await Self.rawSql(query, null, {transaction: transaction}); + await Self.rawSql(query, null, options); query = `CALL vn.itemRefreshTags(?)`; - await Self.rawSql(query, [item.id], {transaction: transaction}); - await transaction.commit(); + await Self.rawSql(query, [item.id], options); + await tx.commit(); return item; } catch (e) { - await transaction.rollback(); + await tx.rollback(); throw e; } }; diff --git a/modules/item/back/methods/item/regularize.js b/modules/item/back/methods/item/regularize.js index 9dc619877..17f1dbe1e 100644 --- a/modules/item/back/methods/item/regularize.js +++ b/modules/item/back/methods/item/regularize.js @@ -42,15 +42,17 @@ module.exports = Self => { where: {description: 'Corregido'} }); - let transaction = await Self.beginTransaction({}); + let tx = await Self.beginTransaction({}); try { + let options = {transaction: tx}; + let item = await models.Item.findById(itemFk); let ticketFk = await getTicketId({ clientFk: itemDestination.address.clientFk, addressFk: itemDestination.addressFk, warehouseFk: warehouseFk - }, transaction); + }, options); if (!ticketFk) { ticketFk = await createTicket(ctx, { @@ -58,15 +60,15 @@ module.exports = Self => { addressFk: itemDestination.addressFk, warehouseFk: warehouseFk, userId: userId - }, transaction); + }, options); } let query = ` CALL vn.getItemVisibleAvailable(?,curdate(),?,?)`; - let options = [itemFk, warehouseFk, true]; - let [res] = await Self.rawSql(query, options, {transaction: transaction}); + let params = [itemFk, warehouseFk, true]; + let [res] = await Self.rawSql(query, params, options); let newQuantity = res[0].visible - quantity; @@ -76,16 +78,16 @@ module.exports = Self => { concept: item.name, quantity: newQuantity, discount: 100 - }, {transaction: transaction}); + }, options); - await transaction.commit(); + await tx.commit(); return ticketFk; } catch (e) { - await transaction.rollback(); + await tx.rollback(); throw e; } - async function createTicket(ctx, params, transaction) { + async function createTicket(ctx, params, options) { let ticket = await Self.app.models.Ticket.new( ctx, { @@ -96,13 +98,13 @@ module.exports = Self => { companyFk: params.companyFk, addressFk: params.addressFk, userId: params.userId - }, {transaction: transaction}); + }, options); return ticket.id; } - async function getTicketId(params, transaction) { + async function getTicketId(params, options) { const currentDate = new Date(); currentDate.setHours(null, null, null); @@ -113,7 +115,7 @@ module.exports = Self => { shipped: currentDate, landed: currentDate } - }, {transaction: transaction}); + }, options); return ticket && ticket.id; } diff --git a/modules/item/back/methods/item/specs/clone.spec.js b/modules/item/back/methods/item/specs/clone.spec.js index 8ac228485..a1bd0f6c8 100644 --- a/modules/item/back/methods/item/specs/clone.spec.js +++ b/modules/item/back/methods/item/specs/clone.spec.js @@ -1,6 +1,6 @@ const app = require('vn-loopback/server/server'); -describe('item clone()', () => { +fdescribe('item clone()', () => { let nextItemId; beforeEach(async() => { diff --git a/modules/ticket/back/methods/sale/moveToTicket.js b/modules/ticket/back/methods/sale/moveToTicket.js index d4d44c692..c97225301 100644 --- a/modules/ticket/back/methods/sale/moveToTicket.js +++ b/modules/ticket/back/methods/sale/moveToTicket.js @@ -26,8 +26,6 @@ module.exports = Self => { let currentTicket = await models.Ticket.findById(params.currentTicket.currentTicketId); let newTicketData = {}; let receiverTicket = params.receiverTicket; - let transaction = await Self.beginTransaction({}); - let options = {transaction}; let isCurrentTicketEditable = await models.Ticket.isEditable(params.currentTicket.currentTicketId); if (!isCurrentTicketEditable) @@ -55,7 +53,11 @@ module.exports = Self => { }; } + let tx = await Self.beginTransaction({}); + try { + let options = {transaction: tx}; + if (!params.receiverTicket.id) receiverTicket = await models.Ticket.new(ctx, newTicketData, options); @@ -74,11 +76,11 @@ module.exports = Self => { promises.push(currentTicket.updateAttributes({isDeleted: true}, options)); await Promise.all(promises); - await transaction.commit(); + await tx.commit(); return receiverTicket; } catch (error) { - await transaction.rollback(); + await tx.rollback(); throw error; } }; diff --git a/modules/ticket/back/methods/sale/updatePrice.js b/modules/ticket/back/methods/sale/updatePrice.js index 007e17954..e315d6504 100644 --- a/modules/ticket/back/methods/sale/updatePrice.js +++ b/modules/ticket/back/methods/sale/updatePrice.js @@ -30,10 +30,11 @@ module.exports = Self => { Self.updatePrice = async(id, newPrice) => { let models = Self.app.models; - let transaction = await Self.beginTransaction({}); - let options = {transaction}; + let tx = await Self.beginTransaction({}); try { + let options = {transaction: tx}; + let filter = { fields: ['id', 'ticketFk', 'price'], include: { @@ -86,9 +87,9 @@ module.exports = Self => { query = `call vn.manaSpellersRequery(?)`; await Self.rawSql(query, [salesPerson], options); - await transaction.commit(); + await tx.commit(); } catch (error) { - await transaction.rollback(); + await tx.rollback(); throw error; } }; diff --git a/modules/ticket/back/methods/ticket-request/confirm.js b/modules/ticket/back/methods/ticket-request/confirm.js index b5194c67b..c08ecba9b 100644 --- a/modules/ticket/back/methods/ticket-request/confirm.js +++ b/modules/ticket/back/methods/ticket-request/confirm.js @@ -32,10 +32,11 @@ module.exports = Self => { Self.confirm = async ctx => { const models = Self.app.models; - let transaction = await Self.beginTransaction({}); - let options = {transaction: transaction}; + let tx = await Self.beginTransaction({}); try { + let options = {transaction: tx}; + let item = await models.Item.findById(ctx.args.itemFk); if (!item) throw new UserError(`That item doesn't exists`); @@ -88,9 +89,9 @@ module.exports = Self => { message: message }, options); - await transaction.commit(); + await tx.commit(); } catch (error) { - await transaction.rollback(); + await tx.rollback(); throw error; } }; diff --git a/modules/ticket/back/methods/ticket/makeInvoice.js b/modules/ticket/back/methods/ticket/makeInvoice.js index cbfe8e531..2a70bcfa6 100644 --- a/modules/ticket/back/methods/ticket/makeInvoice.js +++ b/modules/ticket/back/methods/ticket/makeInvoice.js @@ -26,19 +26,20 @@ module.exports = function(Self) { Self.makeInvoice = async(ctx, id) => { let userId = ctx.req.accessToken.userId; - let models = Self.app.models; - - let options = {}; - options.transaction = await Self.beginTransaction({}); + let $ = Self.app.models; + let tx = await Self.beginTransaction({}); try { - let ticket = await models.Ticket.findById(id, {fields: ['id', 'clientFk', 'companyFk']}); + let options = {transaction: tx}; - let clientCanBeInvoiced = await models.Client.canBeInvoiced(ticket.clientFk); + let filter = {fields: ['id', 'clientFk', 'companyFk']}; + let ticket = await $.Ticket.findById(id, filter, options); + + let clientCanBeInvoiced = await $.Client.canBeInvoiced(ticket.clientFk); if (!clientCanBeInvoiced) throw new UserError(`This client can't be invoiced`); - let ticketCanBeInvoiced = await models.Ticket.canBeInvoiced(ticket.id); + let ticketCanBeInvoiced = await $.Ticket.canBeInvoiced(ticket.id); if (!ticketCanBeInvoiced) throw new UserError(`This ticket can't be invoiced`); @@ -50,9 +51,12 @@ module.exports = function(Self) { query = `CALL vn.invoiceFromTicket(?)`; await Self.rawSql(query, [ticket.id], options); - query = `CALL vn.invoiceOutMake(?, ?, @invoiceId); - SELECT @invoiceId AS invoiceId;`; - result = await Self.rawSql(query, [serial, null], options); + result = await Self.rawSql( + `CALL vn.invoiceOutMake(?, ?, @invoiceId); + SELECT @invoiceId AS invoiceId;`, + [serial, null], + options + ); let invoice = result[1][0].invoiceId; if (serial != 'R' && invoice) { @@ -60,15 +64,15 @@ module.exports = function(Self) { await Self.rawSql(query, [invoice], options); } - let user = await Self.app.models.Worker.findOne({where: {userFk: userId}}); + let user = await $.Worker.findOne({where: {userFk: userId}}, options); query = `INSERT INTO printServerQueue(reportFk, param1, workerFk) VALUES (?, ?, ?)`; await Self.rawSql(query, [3, invoice, user.id], options); - await options.transaction.commit(); + await tx.commit(); return {invoiceFk: invoice, serial}; } catch (e) { - options.transaction.rollback(); + await tx.rollback(); throw e; } }; diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js index 0b37a2b2c..9be919689 100644 --- a/modules/ticket/back/methods/ticket/new.js +++ b/modules/ticket/back/methods/ticket/new.js @@ -21,8 +21,9 @@ module.exports = Self => { } }); - Self.new = async(ctx, params, transaction) => { - let address = await Self.app.models.Address.findOne({ + Self.new = async(ctx, params, options) => { + let $ = Self.app.models; + let address = await $.Address.findOne({ where: {id: params.addressFk}, fields: ['id', 'clientFk'], include: [ @@ -41,7 +42,7 @@ module.exports = Self => { let agencyMode; if (params && params.agencyModeFk) - agencyMode = await Self.app.models.AgencyMode.findById(params.agencyModeFk); + agencyMode = await $.AgencyMode.findById(params.agencyModeFk); if (address.client().type().code === 'normal' && (!agencyMode || agencyMode.code != 'refund')) { if (address.client().isFreezed) @@ -51,12 +52,19 @@ module.exports = Self => { throw new UserError(`You can't create a ticket for a inactive client`); } - if (!transaction || !transaction.commit) - transaction = await Self.beginTransaction({}); + let tx; + + if ((typeof options) != 'object') + options = {}; + + if (!options.transaction) { + tx = await Self.beginTransaction({}); + options.transaction = tx; + } try { if (!params.shipped && params.landed) { - params.shipped = await Self.app.models.Agency.getShipped(ctx, { + params.shipped = await $.Agency.getShipped(ctx, { landed: params.landed, addressFk: address.id, agencyModeFk: params.agencyModeFk, @@ -65,7 +73,7 @@ module.exports = Self => { } if (params.shipped && !params.landed) { - const landedResult = await Self.app.models.Agency.getLanded(ctx, { + const landedResult = await $.Agency.getLanded(ctx, { shipped: params.shipped, addressFk: address.id, agencyModeFk: params.agencyModeFk, @@ -89,9 +97,9 @@ module.exports = Self => { params.routeFk || null, params.landed, params.userId - ], {options: transaction}); + ], options); - let ticket = await Self.app.models.Ticket.findById(result[1][0].newTicketId, {options: transaction}); + let ticket = await $.Ticket.findById(result[1][0].newTicketId, null, options); let cleanInstance = JSON.parse(JSON.stringify(ticket)); let logRecord = { @@ -104,12 +112,12 @@ module.exports = Self => { newInstance: cleanInstance }; - await Self.app.models.TicketLog.create(logRecord, {options: transaction}); + await $.TicketLog.create(logRecord, options); - await transaction.commit(); + if (tx) await tx.commit(); return await ticket; } catch (e) { - await transaction.rollback(); + if (tx) await tx.rollback(); throw e; } }; diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index e85cce1da..3a5e6fe91 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -36,10 +36,11 @@ module.exports = Self => { Self.updateDiscount = async(id, salesIds, newDiscount) => { const models = Self.app.models; - const transaction = await Self.beginTransaction({}); - const options = {transaction}; + const tx = await Self.beginTransaction({}); try { + const options = {transaction: tx}; + const filter = { fields: ['id', 'ticketFk', 'price'], where: { @@ -112,9 +113,9 @@ module.exports = Self => { query = `call vn.manaSpellersRequery(?)`; await Self.rawSql(query, [salesPersonId], options); - await transaction.commit(); + await tx.commit(); } catch (error) { - await transaction.rollback(); + await tx.rollback(); throw error; } }; diff --git a/modules/ticket/back/methods/ticket/uploadFile.js b/modules/ticket/back/methods/ticket/uploadFile.js index 6af042c8a..7c968f5c9 100644 --- a/modules/ticket/back/methods/ticket/uploadFile.js +++ b/modules/ticket/back/methods/ticket/uploadFile.js @@ -50,11 +50,12 @@ module.exports = Self => { Self.uploadFile = async(ctx, id) => { const models = Self.app.models; - const transaction = await Self.beginTransaction({}); - const options = {transaction}; const promises = []; + const tx = await Self.beginTransaction({}); try { + const options = {transaction: tx}; + const uploadedFiles = await models.Dms.uploadFile(ctx, options); uploadedFiles.forEach(dms => { const newTicketDms = models.TicketDms.create({ @@ -66,11 +67,11 @@ module.exports = Self => { }); const resolvedPromises = await Promise.all(promises); - await transaction.commit(); + await tx.commit(); return resolvedPromises; } catch (err) { - await transaction.rollback(); + await tx.rollback(); throw err; } }; diff --git a/package-lock.json b/package-lock.json index 6e86348fb..0003535ff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1513,7 +1513,7 @@ }, "util": { "version": "0.10.3", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz", "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", "dev": true, "requires": { @@ -1551,15 +1551,23 @@ "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=" }, "async-done": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/async-done/-/async-done-1.3.1.tgz", - "integrity": "sha512-R1BaUeJ4PMoLNJuk+0tLJgjmEqVsdN118+Z8O+alhnQDQgy0kmD5Mqi0DNEmMx2LM0Ed5yekKu+ZXYvIHceicg==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/async-done/-/async-done-1.3.2.tgz", + "integrity": "sha512-uYkTP8dw2og1tu1nmza1n1CMW0qb8gWWlwqMmLb7MhBVs4BXrFziT6HXUd+/RlRA/i4H9AkofYloUbs1fwMqlw==", "dev": true, "requires": { "end-of-stream": "^1.1.0", "once": "^1.3.2", - "process-nextick-args": "^1.0.7", + "process-nextick-args": "^2.0.0", "stream-exhaust": "^1.0.1" + }, + "dependencies": { + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "dev": true + } } }, "async-each": { @@ -1783,7 +1791,7 @@ "base": { "version": "0.11.2", "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", - "integrity": "sha1-e95c7RRbbVUakNuH+DxVi060io8=", + "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", "dev": true, "requires": { "cache-base": "^1.0.1", @@ -2486,7 +2494,7 @@ "cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", - "integrity": "sha1-Cn9GQWgxyLZi7jb+TnxZ129marI=", + "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", "dev": true, "requires": { "collection-visit": "^1.0.0", @@ -2661,7 +2669,7 @@ "class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", - "integrity": "sha1-+TNprouafOAv1B+q0MqDAzGQxGM=", + "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", "dev": true, "requires": { "arr-union": "^3.1.0", @@ -2818,7 +2826,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { @@ -3360,13 +3368,13 @@ "dependencies": { "jsesc": { "version": "0.5.0", - "resolved": "http://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", "dev": true }, "regexpu-core": { "version": "1.0.0", - "resolved": "http://registry.npmjs.org/regexpu-core/-/regexpu-core-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-1.0.0.tgz", "integrity": "sha1-hqdj9Y7k18L2sQLkdkBQ3n7ZDGs=", "dev": true, "requires": { @@ -3377,13 +3385,13 @@ }, "regjsgen": { "version": "0.2.0", - "resolved": "http://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", "integrity": "sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=", "dev": true }, "regjsparser": { "version": "0.1.5", - "resolved": "http://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz", "integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=", "dev": true, "requires": { @@ -3857,7 +3865,7 @@ "dot-prop": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz", - "integrity": "sha1-HxngwuGqDjJ5fEl5nyg3rGr2nFc=", + "integrity": "sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==", "dev": true, "requires": { "is-obj": "^1.0.0" @@ -4023,7 +4031,7 @@ "dependencies": { "fs-extra": { "version": "0.30.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz", + "resolved": "http://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz", "integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=", "dev": true, "requires": { @@ -4036,7 +4044,7 @@ }, "jsonfile": { "version": "2.4.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", + "resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", "dev": true, "requires": { @@ -4332,14 +4340,14 @@ } }, "es6-weak-map": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz", - "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz", + "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", "dev": true, "requires": { "d": "1", - "es5-ext": "^0.10.14", - "es6-iterator": "^2.0.1", + "es5-ext": "^0.10.46", + "es6-iterator": "^2.0.3", "es6-symbol": "^3.1.1" } }, @@ -5025,7 +5033,7 @@ }, "file-loader": { "version": "1.1.11", - "resolved": "https://registry.npmjs.org/file-loader/-/file-loader-1.1.11.tgz", + "resolved": "http://registry.npmjs.org/file-loader/-/file-loader-1.1.11.tgz", "integrity": "sha512-TGR4HU7HUsGg6GCOPJnFk06RhWgEWFLAGWiT6rcD+GRC2keU3s9RGJ+b3Z6/U73jwwNb2gKLJ7YCrp+jvU4ALg==", "dev": true, "requires": { @@ -5126,9 +5134,9 @@ } }, "fined": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/fined/-/fined-1.1.1.tgz", - "integrity": "sha512-jQp949ZmEbiYHk3gkbdtpJ0G1+kgtLQBNdP5edFP7Fh+WAYceLQz6yO1SBj72Xkg8GVyTB3bBzAYrHJVh5Xd5g==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fined/-/fined-1.2.0.tgz", + "integrity": "sha512-ZYDqPLGxDkDhDZBjZBb+oD1+j0rA4E0pXY50eplAAOPg2N/gUBSSk5IM1/QhPfyVo19lJ+CvXpqfvk+b2p/8Ng==", "dev": true, "requires": { "expand-tilde": "^2.0.2", @@ -6125,9 +6133,9 @@ }, "dependencies": { "glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -6166,7 +6174,7 @@ "global-modules": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", - "integrity": "sha1-bXcPDrUjrHgWTXK15xqIdyZcw+o=", + "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", "dev": true, "requires": { "global-prefix": "^1.0.1", @@ -7022,7 +7030,7 @@ }, "kind-of": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz", "integrity": "sha1-FAo9LUGjbS78+pN3tiwk+ElaXEQ=", "dev": true }, @@ -7206,7 +7214,7 @@ "dependencies": { "es6-promise": { "version": "3.3.1", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz", + "resolved": "http://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz", "integrity": "sha1-oIzd6EzNvzTQJ6FFG8kdS80ophM=", "dev": true }, @@ -8219,7 +8227,7 @@ "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha1-LBY7P6+xtgbZ0Xko8FwqHDjgdnc=", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", "dev": true, "requires": { "isobject": "^3.0.1" @@ -8410,7 +8418,7 @@ }, "jasmine-core": { "version": "2.99.1", - "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.99.1.tgz", + "resolved": "http://registry.npmjs.org/jasmine-core/-/jasmine-core-2.99.1.tgz", "integrity": "sha1-5kAN8ea1bhMLYcS80JPap/boyhU=", "dev": true }, @@ -8427,7 +8435,7 @@ "jasmine-spec-reporter": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-4.2.1.tgz", - "integrity": "sha1-HWMq7ANBZwrTJPkrqEtLMrNeniI=", + "integrity": "sha512-FZBoZu7VE5nR7Nilzy+Np8KuVIOxF4oXDPDknehCYBDE080EnlPu0afdZNmpGDBRCUBv3mj5qgqCRmk6W/K8vg==", "dev": true, "requires": { "colors": "1.1.2" @@ -8693,7 +8701,7 @@ "karma-chrome-launcher": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz", - "integrity": "sha1-zxudBxNswY/iOTJ9JGVMPbw2is8=", + "integrity": "sha512-uf/ZVpAabDBPvdPdveyk1EPgbnloPvFFGgmRhYLTDH7gEB4nZdSBk8yTU47w1g/drLSx5uMOkjKk7IWKfWg/+w==", "dev": true, "requires": { "fs-access": "^1.0.0", @@ -8875,19 +8883,42 @@ } }, "liftoff": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-2.5.0.tgz", - "integrity": "sha1-IAkpG7Mc6oYbvxCnwVooyvdcMew=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-3.1.0.tgz", + "integrity": "sha512-DlIPlJUkCV0Ips2zf2pJP0unEoT1kwYhiiPUGF3s/jtxTCjziNLoiVVh+jqWOWeFi6mmwQ5fNxvAUyPad4Dfog==", "dev": true, "requires": { "extend": "^3.0.0", - "findup-sync": "^2.0.0", + "findup-sync": "^3.0.0", "fined": "^1.0.1", "flagged-respawn": "^1.0.0", "is-plain-object": "^2.0.4", "object.map": "^1.0.0", "rechoir": "^0.6.2", "resolve": "^1.1.7" + }, + "dependencies": { + "findup-sync": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-3.0.0.tgz", + "integrity": "sha512-YbffarhcicEhOrm4CtrwdKBdCuz576RLdhJDsIfvNtxUuhdRet1qZcsMjqbePtAseKdAnDyM/IyXbu7PRPRLYg==", + "dev": true, + "requires": { + "detect-file": "^1.0.0", + "is-glob": "^4.0.0", + "micromatch": "^3.0.4", + "resolve-dir": "^1.0.1" + } + }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + } } }, "load-json-file": { @@ -10667,7 +10698,7 @@ }, "minimist": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, "minstache": { @@ -10681,7 +10712,7 @@ "dependencies": { "commander": { "version": "1.0.4", - "resolved": "https://registry.npmjs.org/commander/-/commander-1.0.4.tgz", + "resolved": "http://registry.npmjs.org/commander/-/commander-1.0.4.tgz", "integrity": "sha1-Xt6xruI8T7VBprcNaSq+8ZZpotM=", "dev": true, "requires": { @@ -11209,7 +11240,7 @@ "dependencies": { "jsesc": { "version": "0.5.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "resolved": "http://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", "dev": true } @@ -11839,7 +11870,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -11867,6 +11899,7 @@ "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -11881,7 +11914,8 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", @@ -12010,7 +12044,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -12022,6 +12057,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -12036,6 +12072,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -12043,7 +12080,8 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", @@ -12149,7 +12187,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -12304,6 +12343,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -12411,9 +12451,9 @@ } }, "now-and-later": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/now-and-later/-/now-and-later-2.0.0.tgz", - "integrity": "sha1-vGHLtFbXnLMiB85HygUTb/Ln1u4=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/now-and-later/-/now-and-later-2.0.1.tgz", + "integrity": "sha512-KGvQ0cB70AQfg107Xvs/Fbu+dGmZoTRJp2TaPwcwQm3/7PteUyN2BCgk8KBMPGBUXZdVwyWS8fDCGFygBm19UQ==", "dev": true, "requires": { "once": "^1.3.2" @@ -12652,7 +12692,7 @@ "dependencies": { "minimist": { "version": "0.0.10", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", "dev": true }, @@ -13300,7 +13340,7 @@ }, "pretty-bytes": { "version": "1.0.4", - "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz", + "resolved": "http://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz", "integrity": "sha1-CiLoIQYJrTVUL4yNXSFZr/B1HIQ=", "dev": true, "requires": { @@ -13371,7 +13411,7 @@ }, "readable-stream": { "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { @@ -13383,13 +13423,13 @@ }, "string_decoder": { "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "dev": true }, "through2": { "version": "0.2.3", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.2.3.tgz", + "resolved": "http://registry.npmjs.org/through2/-/through2-0.2.3.tgz", "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=", "dev": true, "requires": { @@ -14289,7 +14329,7 @@ }, "safe-regex": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "dev": true, "requires": { @@ -14414,7 +14454,7 @@ "dependencies": { "source-map": { "version": "0.4.4", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "resolved": "http://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", "dev": true, "requires": { @@ -14554,7 +14594,7 @@ "set-value": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha1-ca5KiPD+77v1LR6mBPP7MV67YnQ=", + "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", "dev": true, "requires": { "extend-shallow": "^2.0.1", @@ -14670,7 +14710,7 @@ }, "string-width": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "resolved": "http://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, "requires": { @@ -14746,7 +14786,7 @@ "snapdragon-node": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", - "integrity": "sha1-bBdfhv8UvbByRWPo88GwIaKGhTs=", + "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", "dev": true, "requires": { "define-property": "^1.0.0", @@ -14797,7 +14837,7 @@ "snapdragon-util": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", - "integrity": "sha1-+VZHlIbyrNeXAGk/b3uAXkWrVuI=", + "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", "dev": true, "requires": { "kind-of": "^3.2.0" @@ -15153,7 +15193,7 @@ "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", - "integrity": "sha1-fLCd2jqGWFcFxks5pkZgOGguj+I=", + "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", "dev": true, "requires": { "extend-shallow": "^3.0.0" @@ -15345,7 +15385,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { @@ -16238,7 +16278,7 @@ "touch": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", - "integrity": "sha1-/jZfX3XsntTlaCXgu3bSSrdK+Ds=", + "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", "dev": true, "requires": { "nopt": "~1.0.10" @@ -16452,9 +16492,9 @@ } }, "undertaker": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/undertaker/-/undertaker-1.2.0.tgz", - "integrity": "sha1-M52kZGJS0ILcN45wgGcpl1DhG0k=", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/undertaker/-/undertaker-1.2.1.tgz", + "integrity": "sha512-71WxIzDkgYk9ZS+spIB8iZXchFhAdEo2YU8xYqBYJ39DIUIqziK78ftm26eecoIY49X0J2MLhG4hr18Yp6/CMA==", "dev": true, "requires": { "arr-flatten": "^1.0.1", @@ -16724,7 +16764,7 @@ "useragent": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/useragent/-/useragent-2.3.0.tgz", - "integrity": "sha1-IX+UOtVAyyEoZYqyP8lg9qiMmXI=", + "integrity": "sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw==", "dev": true, "requires": { "lru-cache": "4.1.x", @@ -16789,9 +16829,9 @@ "dev": true }, "v8flags": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.2.tgz", - "integrity": "sha512-MtivA7GF24yMPte9Rp/BWGCYQNaUj86zeYxV/x2RRJMKagImbbv3u8iJC57lNhWLPcGLJmHcHmFWkNsplbbLWw==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.3.tgz", + "integrity": "sha512-amh9CCg3ZxkzQ48Mhcb8iX7xpAfYJgePHxWMQCBWECpOSqJUXgY26ncA61UTV0BkPqfhcy6mzwCIoP4ygxpW8w==", "dev": true, "requires": { "homedir-polyfill": "^1.0.1" @@ -17461,7 +17501,7 @@ }, "globby": { "version": "6.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", + "resolved": "http://registry.npmjs.org/globby/-/globby-6.1.0.tgz", "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", "dev": true, "requires": { @@ -17474,7 +17514,7 @@ "dependencies": { "pify": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true } diff --git a/package.json b/package.json index ed5f51057..cfc93f447 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "eslint-plugin-jasmine": "^2.10.1", "fancy-log": "^1.3.2", "file-loader": "^1.1.11", - "gulp": "^4.0.0", + "gulp": "^4.0.2", "gulp-concat": "^2.6.1", "gulp-env": "^0.4.0", "gulp-file": "^0.4.0",