Comparing version 0.17.1 to 0.18.0
@@ -64,6 +64,6 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var Context, Eventric, GlobalContext, Projection, Remote, inmemoryStore, logger, remoteInmemory, uidGenerator, | ||
var Context, Eventric, GlobalContext, Projection, Remote, inmemoryRemote, inmemoryStore, logger, uuidGenerator, | ||
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | ||
remoteInmemory = __webpack_require__(2); | ||
inmemoryRemote = __webpack_require__(2); | ||
@@ -80,3 +80,3 @@ GlobalContext = __webpack_require__(3); | ||
uidGenerator = __webpack_require__(11); | ||
uuidGenerator = __webpack_require__(11); | ||
@@ -97,3 +97,3 @@ logger = __webpack_require__(7); | ||
this._projectionService = new Projection(this._globalContext); | ||
this.addRemoteEndpoint(remoteInmemory.endpoint); | ||
this.addRemoteEndpoint(inmemoryRemote.endpoint); | ||
this.setStore(inmemoryStore, {}); | ||
@@ -117,10 +117,8 @@ } | ||
Eventric.prototype.context = function(name) { | ||
var context, error; | ||
var context; | ||
if (!name) { | ||
error = 'Contexts must have a name'; | ||
this.log.error(error); | ||
throw new Error(error); | ||
throw new Error('Contexts must have a name'); | ||
} | ||
context = new Context(name); | ||
this._delegateAllDomainEventsToRemoteEndpoint(context); | ||
this._delegateAllDomainEventsToRemoteEndpoints(context); | ||
this._contexts[name] = context; | ||
@@ -146,12 +144,5 @@ return context; | ||
Eventric.prototype.getContext = function(name) { | ||
return this._contexts[name]; | ||
}; | ||
Eventric.prototype.remote = function(contextName) { | ||
var error; | ||
if (!contextName) { | ||
error = 'Missing context name'; | ||
this.log.error(error); | ||
throw new Error(error); | ||
throw new Error('Missing context name'); | ||
} | ||
@@ -166,4 +157,4 @@ return new Remote(contextName); | ||
Eventric.prototype.generateUid = function() { | ||
return uidGenerator.generateUid(); | ||
Eventric.prototype.generateUuid = function() { | ||
return uuidGenerator.generateUuid(); | ||
}; | ||
@@ -177,6 +168,6 @@ | ||
var context, error; | ||
context = this.getContext(request.contextName); | ||
context = this._contexts[request.contextName]; | ||
if (!context) { | ||
error = new Error("Tried to handle Remote RPC with not registered context " + request.contextName); | ||
this.log.error(error.stack); | ||
logger.error(error.stack); | ||
callback(error, null); | ||
@@ -187,2 +178,3 @@ return; | ||
error = new Error("RPC operation '" + request.functionName + "' not allowed"); | ||
logger.error(error.stack); | ||
callback(error, null); | ||
@@ -193,3 +185,3 @@ return; | ||
error = new Error("Remote RPC function " + request.functionName + " not found on Context " + request.contextName); | ||
this.log.error(error.stack); | ||
logger.error(error.stack); | ||
callback(error, null); | ||
@@ -205,3 +197,3 @@ return; | ||
Eventric.prototype._delegateAllDomainEventsToRemoteEndpoint = function(context) { | ||
Eventric.prototype._delegateAllDomainEventsToRemoteEndpoints = function(context) { | ||
return context.subscribeToAllDomainEvents((function(_this) { | ||
@@ -499,7 +491,5 @@ return function(domainEvent) { | ||
contextNames = eventric.getRegisteredContextNames(); | ||
return contextNames.map((function(_this) { | ||
return function(contextName) { | ||
return eventric.remote(contextName); | ||
}; | ||
})(this)); | ||
return contextNames.map(function(contextName) { | ||
return eventric.remote(contextName); | ||
}); | ||
}; | ||
@@ -537,5 +527,5 @@ | ||
var Projection, Remote, logger, remoteInmemory; | ||
var Projection, Remote, inmemoryRemote, logger; | ||
remoteInmemory = __webpack_require__(2); | ||
inmemoryRemote = __webpack_require__(2); | ||
@@ -551,3 +541,2 @@ logger = __webpack_require__(7); | ||
this._contextName = _contextName; | ||
this.name = this._contextName; | ||
this._params = {}; | ||
@@ -558,3 +547,3 @@ this._projectionClasses = {}; | ||
this.projectionService = new Projection(this); | ||
this.setClient(remoteInmemory.client); | ||
this.setClient(inmemoryRemote.client); | ||
this._exposeRpcOperationsAsMemberFunctions(); | ||
@@ -698,3 +687,3 @@ } | ||
var Projection, logger, uidGenerator, | ||
var Projection, logger, uuidGenerator, | ||
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | ||
@@ -704,3 +693,3 @@ | ||
uidGenerator = __webpack_require__(11); | ||
uuidGenerator = __webpack_require__(11); | ||
@@ -730,3 +719,3 @@ Projection = (function() { | ||
} | ||
projectionId = uidGenerator.generateUid(); | ||
projectionId = uuidGenerator.generateUuid(); | ||
aggregateId = null; | ||
@@ -902,23 +891,29 @@ projection.$subscribeHandlersWithAggregateId = function(_aggregateId) { | ||
var UidGenerator; | ||
var UuidGenerator; | ||
UidGenerator = (function() { | ||
function UidGenerator() {} | ||
UuidGenerator = (function() { | ||
function UuidGenerator() {} | ||
UidGenerator.prototype.generateUid = function(delimiter) { | ||
if (delimiter == null) { | ||
delimiter = "-"; | ||
} | ||
return this._s4() + this._s4() + delimiter + this._s4() + delimiter + this._s4() + delimiter + this._s4() + delimiter + this._s4() + this._s4() + this._s4(); | ||
}; | ||
UuidGenerator.prototype._uuidTemplate = 'xxxxxxxx-xxxx-4xxx-vxxx-xxxxxxxxxxxx'; | ||
UidGenerator.prototype._s4 = function() { | ||
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1); | ||
UuidGenerator.prototype.generateUuid = function() { | ||
var uuid; | ||
uuid = this._uuidTemplate.replace(/[xv]/g, function(characterToReplace) { | ||
var randomNumber, variant; | ||
randomNumber = Math.floor(Math.random() * 16); | ||
if (characterToReplace === 'x') { | ||
return randomNumber.toString(16); | ||
} else { | ||
variant = randomNumber & 0x3 | 0x8; | ||
return variant.toString(16); | ||
} | ||
}); | ||
return uuid; | ||
}; | ||
return UidGenerator; | ||
return UuidGenerator; | ||
})(); | ||
module.exports = new UidGenerator; | ||
module.exports = new UuidGenerator; | ||
@@ -937,3 +932,3 @@ | ||
var AggregateRepository, Context, DomainEvent, EventBus, Projection, logger, uidGenerator, | ||
var AggregateRepository, Context, DomainEvent, EventBus, Projection, logger, uuidGenerator, | ||
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, | ||
@@ -952,3 +947,3 @@ slice = [].slice; | ||
uidGenerator = __webpack_require__(11); | ||
uuidGenerator = __webpack_require__(11); | ||
@@ -1133,3 +1128,3 @@ Context = (function() { | ||
return new DomainEvent({ | ||
id: uidGenerator.generateUid(), | ||
id: uuidGenerator.generateUuid(), | ||
name: domainEventName, | ||
@@ -1207,6 +1202,17 @@ aggregate: aggregate, | ||
commandServicesToInject = _this._getCommandServicesToInject(); | ||
return Promise.resolve(_this._commandHandlers[commandName].apply(commandServicesToInject, [params])).then(function(result) { | ||
return Promise.resolve().then(function() { | ||
return _this._commandHandlers[commandName].apply(commandServicesToInject, [params]); | ||
}).then(function(result) { | ||
logger.debug('Completed Command', commandName); | ||
return resolve(result); | ||
})["catch"](reject); | ||
})["catch"](function(error) { | ||
var commandErrorMessage; | ||
commandErrorMessage = "Context " + _this.name + " rejects with an error in command " + commandName + " with arguments " + (JSON.stringify(params)); | ||
if (!error) { | ||
reject(new Error(commandErrorMessage)); | ||
return; | ||
} | ||
error.message = commandErrorMessage + " - original error message: " + error.message; | ||
return reject(error); | ||
}); | ||
}; | ||
@@ -1283,3 +1289,5 @@ })(this)); | ||
} | ||
return Promise.resolve(_this._queryHandlers[queryName].apply(_this._di, [params])).then(function(result) { | ||
return Promise.resolve().then(function() { | ||
return _this._queryHandlers[queryName].apply(_this._di, [params]); | ||
}).then(function(result) { | ||
logger.debug("Completed Query " + queryName + " with Result " + result); | ||
@@ -1521,3 +1529,3 @@ return resolve(result); | ||
var Aggregate, AggregateRepository, logger, uidGenerator, | ||
var Aggregate, AggregateRepository, logger, uuidGenerator, | ||
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | ||
@@ -1529,3 +1537,3 @@ | ||
uidGenerator = __webpack_require__(11); | ||
uuidGenerator = __webpack_require__(11); | ||
@@ -1576,3 +1584,3 @@ AggregateRepository = (function() { | ||
} | ||
aggregate.id = aggregate.instance.$id = uidGenerator.generateUid(); | ||
aggregate.id = aggregate.instance.$id = uuidGenerator.generateUuid(); | ||
aggregate.instance.$save = function() { | ||
@@ -1579,0 +1587,0 @@ return _this.save(aggregate); |
@@ -14,3 +14,3 @@ { | ||
"author": "efa Team <team@efa-gmbh.com>", | ||
"version": "0.17.1", | ||
"version": "0.18.0", | ||
"repository": { | ||
@@ -17,0 +17,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
65
15177
680034