Comparing version 1.2.0 to 1.2.1
@@ -113,3 +113,3 @@ 'use strict'; | ||
} | ||
var self = this; | ||
@@ -159,10 +159,10 @@ async.each(cmds, function (cmd, fn) { | ||
} | ||
var self = this; | ||
async.waterfall([ | ||
function (callb) { | ||
if (!self.id || !dotty.exists(evt, self.id)) { | ||
debug('has no id, generate new one'); | ||
if (!self.getNewIdForThisSaga) { | ||
@@ -178,3 +178,3 @@ return self.sagaStore.getNewId(callb); | ||
}, | ||
function (id, callb) { | ||
@@ -185,3 +185,3 @@ self.sagaStore.get(id, function (err, data) { | ||
} | ||
if (!data && self.existing) { | ||
@@ -191,3 +191,3 @@ debug('this saga only wants to be executed, if already existing'); | ||
} | ||
var sagaModel = new SagaModel(id); | ||
@@ -202,6 +202,6 @@ if (data) { | ||
function (sagaModel, callb) { | ||
// attach commit function | ||
debug('attach commit function'); | ||
/** | ||
@@ -213,20 +213,19 @@ * Commits the saga data and its commands. | ||
sagaModel.commit = function (clb) { | ||
if (sagaModel.isDestroyed()) { | ||
self.sagaStore.remove(sagaModel.id, clb); | ||
} else { | ||
async.parallel([ | ||
function (callback) { | ||
self.checkForId(sagaModel.getUndispatchedCommands(), callback); | ||
}, | ||
function (callback) { | ||
self.checkForId(sagaModel.getTimeoutCommands(), callback); | ||
} | ||
], function (err) { | ||
if (err) { | ||
debug(err); | ||
return callback(err); | ||
} | ||
async.parallel([ | ||
function (callback) { | ||
self.checkForId(sagaModel.getUndispatchedCommands(), callback); | ||
}, | ||
function (callback) { | ||
self.checkForId(sagaModel.getTimeoutCommands(), callback); | ||
} | ||
], function (err) { | ||
if (err) { | ||
debug(err); | ||
return callback(err); | ||
} | ||
if (sagaModel.isDestroyed()) { | ||
self.sagaStore.remove(sagaModel.id, clb); | ||
} else { | ||
sagaModel.setCommitStamp(new Date()); | ||
sagaModel.setCommitStamp(new Date()); | ||
var undispCmds = _.map(sagaModel.getUndispatchedCommands(), function (c) { | ||
@@ -248,6 +247,6 @@ return { id: dotty.get(c, self.definitions.command.id), payload: c }; | ||
}); | ||
}); | ||
} | ||
} | ||
}); | ||
}; | ||
// attach addCommandToSend function | ||
@@ -264,3 +263,3 @@ debug('attach addCommandToSend function'); | ||
} | ||
sagaModel.addUnsentCommand(cmd); | ||
@@ -281,3 +280,3 @@ }; | ||
} | ||
cmds.forEach(function (cmd) { | ||
@@ -289,3 +288,3 @@ if (!dotty.exists(cmd, self.definitions.command.meta) && dotty.exists(evt, self.definitions.event.meta) && | ||
}); | ||
sagaModel.addTimeout(date, cmds); | ||
@@ -296,3 +295,3 @@ }; | ||
}, | ||
function (sagaModel, callb) { | ||
@@ -313,3 +312,3 @@ self.sagaFn(self.getPayload(evt), sagaModel, function (err) { | ||
} | ||
// detach addCommandToSend function | ||
@@ -328,3 +327,3 @@ debug('detach addCommandToSend function'); | ||
} | ||
], callback); | ||
@@ -331,0 +330,0 @@ |
{ | ||
"author": "adrai", | ||
"name": "cqrs-saga", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
@@ -0,1 +1,4 @@ | ||
## [v1.2.1](https://github.com/adrai/node-cqrs-saga/compare/v1.2.0...v1.2.1) | ||
- generate command id if not set even if destroying the saga | ||
## [v1.2.0](https://github.com/adrai/node-cqrs-saga/compare/v1.1.3...v1.2.0) | ||
@@ -2,0 +5,0 @@ - added getInfo function |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
263632