@sap/cds-messaging
Advanced tools
Comparing version 1.1.1 to 1.2.1
@@ -9,2 +9,14 @@ # Changelog | ||
## Version 1.2.1 - 2019-10-16 | ||
### Added | ||
- `headers` parameter for `.emit` | ||
## Version 1.2.0 - 2019-10-02 | ||
### Changed | ||
- Minor improvements | ||
## Version 1.1.1 - 2019-09-18 | ||
@@ -11,0 +23,0 @@ |
@@ -106,2 +106,3 @@ const FeatureNotSupportedError = require('../utils/FeatureNotSupported') | ||
* @param {String} target to be sent to the queue(s). | ||
* @param {Object} headers to be sent to the queue(s). | ||
* @public | ||
@@ -108,0 +109,0 @@ */ |
@@ -47,2 +47,3 @@ const { resolve } = require('../utils/thenable') | ||
.catch(err => { | ||
console.error(err) | ||
const chain = errHandlers.reduce((chain, errHandler) => chain.then(() => errHandler(err)), resolve()) | ||
@@ -49,0 +50,0 @@ return chain.then(() => raw.done()) |
@@ -164,3 +164,3 @@ const dataHandler = require('./dataHandler') | ||
if (!csnEvent || (csnEvent.kind !== 'type' && csnEvent.kind !== 'event')) { | ||
throw new Error(`Event '${normalizedHandler.event}' is not in model.`) | ||
throw new Error(`Element '${normalizedHandler.event}' is not in model.`) | ||
} | ||
@@ -196,7 +196,2 @@ } | ||
// FIXME: Dirty hack for TechEd | ||
if (_event && _event.toUpperCase() === 'CREATED' && _entity === 'ServiceOrder') { | ||
_topic = `sap/S4HANAOD/sun1/BO/ServiceOrder/Created` | ||
_event = null | ||
} | ||
return { event: _event, entity: _entity, handler: _handler, topic: _topic } | ||
@@ -222,4 +217,4 @@ } | ||
function _emit (options) { | ||
return function (event, entity, payload) { | ||
if (!payload && entity && !event.startsWith('topic:') && !event.includes('/')) { | ||
return function (event, entity, payload, header) { | ||
if (!payload && entity && typeof event === 'string' && !event.startsWith('topic:') && !event.includes('/')) { | ||
_checkValidEvent({ event }, options) | ||
@@ -233,4 +228,4 @@ } | ||
const [target, data] = _targetAndDataForEmit(payload, namespace, shrunkService, entity, event) | ||
client.emit({ data }, target) | ||
const [target, msg] = _getTargetAndMessage(payload, namespace, shrunkService, entity, event, header) | ||
client.emit(msg, target) | ||
this.release(client) | ||
@@ -246,12 +241,18 @@ }) | ||
function _targetAndDataForEmit (payload, namespace, shrunkService, entity, event) { | ||
return payload | ||
? [`topic:${namespace}/${shrunkService}/${entity}/${event}`, payload] | ||
function _handleEventAsString (payload, namespace, shrunkService, entity, event) { | ||
return event.startsWith('topic:') | ||
? [event, { data: entity, ...payload }] | ||
: event.includes('/') | ||
? [`topic:${event}`, { data: entity, ...payload }] | ||
: [`topic:${namespace}/${shrunkService}/${event}`, { data: entity, ...payload }] | ||
} | ||
function _getTargetAndMessage (payload, namespace, shrunkService, entity, event, header) { | ||
return typeof payload === 'object' && typeof entity !== 'object' | ||
? [`topic:${namespace}/${shrunkService}/${entity}/${event}`, { data: payload, ...header }] | ||
: entity | ||
? event.startsWith('topic:') | ||
? [event, entity] | ||
: event.includes('/') | ||
? [`topic:${event}`, entity] | ||
: [`topic:${namespace}/${shrunkService}/${event}`, entity] | ||
: [null, event] | ||
? typeof event === 'string' | ||
? _handleEventAsString(payload, namespace, shrunkService, entity, event) | ||
: [null, { data: event, ...entity }] | ||
: [null, { data: event, ...payload }] | ||
} | ||
@@ -258,0 +259,0 @@ |
@@ -1,1 +0,1 @@ | ||
{"bundleDependencies":false,"dependencies":{},"deprecated":false,"description":"","engines":{"node":">= 8.9.0"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"{lib,test}/**/*.js":["prettier-standard","standard --fix","git add"]},"main":"lib/index.js","name":"@sap/cds-messaging","version":"1.1.1","license":"SEE LICENSE IN developer-license-3.1.txt"} | ||
{"bundleDependencies":false,"dependencies":{},"deprecated":false,"description":"","engines":{"node":">= 8.9.0"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"{lib,test}/**/*.js":["prettier-standard","standard --fix","git add"]},"main":"lib/index.js","name":"@sap/cds-messaging","version":"1.2.1","license":"SEE LICENSE IN developer-license-3.1.txt"} |
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
52687
1007