@sap/cds-messaging
Advanced tools
Comparing version 1.2.1 to 1.4.0
@@ -9,2 +9,14 @@ # Changelog | ||
## Version 1.4.0 - 2019-11-19 | ||
### Removed | ||
- The `namespace` property of a services does not need to be set anymore | ||
## Version 1.3.0 - 2019-10-29 | ||
### Removed | ||
- `npm-shrinkwrap.json` | ||
## Version 1.2.1 - 2019-10-16 | ||
@@ -11,0 +23,0 @@ |
@@ -196,2 +196,3 @@ const FeatureNotSupportedError = require('../utils/FeatureNotSupported') | ||
const enterpriseMessagingOptions = { | ||
namespace: connectionOptions.credentials.namespace, | ||
amqp: connectionOptions.credentials.messaging.filter(entry => entry.protocol.includes('amqp10ws'))[0], | ||
@@ -198,0 +199,0 @@ management: connectionOptions.credentials.management[0] |
@@ -28,3 +28,3 @@ const dataHandler = require('./dataHandler') | ||
function _getSource ({ queueEnd, appName, appID, ownNamespace }) { | ||
function _deriveSource ({ queueEnd, appName, appID, ownNamespace }) { | ||
const shrunkAppID = appID.substring(0, 4) | ||
@@ -57,6 +57,3 @@ return ownNamespace | ||
msgOptions.namespace || | ||
(msgOptions.credentials && msgOptions.credentials.namespace) || | ||
'CAP' | ||
// TODO: Get the own namespace from API (not yet developed) | ||
const ownNamespace = namespaceOfService | ||
(msgOptions.credentials && msgOptions.credentials.namespace) | ||
const vcapApplication = process.env.VCAP_APPLICATION && JSON.parse(process.env.VCAP_APPLICATION) | ||
@@ -66,7 +63,5 @@ const appName = (vcapApplication && vcapApplication.application_name.replace(INVALID_SYMBOLS, '')) || 'unknownApp' | ||
const shrunkService = _shrinkService(service) | ||
const prefix = (msgOptions.credentials && msgOptions.credentials.prefix) || `${namespaceOfService}/${shrunkService}` | ||
const prefix = msgOptions.credentials && msgOptions.credentials.prefix | ||
const queueEnd = (msgOptions.credentials && msgOptions.credentials.prefix) || shrunkService | ||
const source = | ||
(msgOptions.credentials && msgOptions.credentials.queue && `queue:${msgOptions.credentials.queue}`) || | ||
_getSource({ queueEnd, appName, appID, ownNamespace }) | ||
const customSource = msgOptions.credentials && msgOptions.credentials.queue && `queue:${msgOptions.credentials.queue}` | ||
@@ -79,3 +74,4 @@ const options = { | ||
shrunkService, | ||
source, | ||
customSource, | ||
queueEnd, | ||
namespaceOfService, | ||
@@ -100,2 +96,6 @@ prefix, | ||
function _getPrefixForTopic (options, client) { | ||
return options.prefix || `${options.namespaceOfService || client._options.namespace}/${options.shrunkService}` | ||
} | ||
function _addSubscription (onHandler, options) { | ||
@@ -105,4 +105,5 @@ _pendingOperations(this) | ||
this.acquire({}, 'messaging').then(client => { | ||
const queueName = _getQueueName(options.source) | ||
const topic = _getTopicFromOnHandler(onHandler, options.prefix) | ||
const source = _getSource(client, options) | ||
const queueName = _getQueueNameFromSource(source) | ||
const topic = _getTopicFromOnHandler(onHandler, _getPrefixForTopic(options, client)) | ||
if (client._options.kind === 'enterprise-messaging') { | ||
@@ -127,6 +128,16 @@ _pendingOperations(client) | ||
function _getSource (client, options) { | ||
const ownNamespace = client._options.namespace | ||
return ( | ||
options.customSource || | ||
_deriveSource({ queueEnd: options.queueEnd, appName: options.appName, appID: options.appID, ownNamespace }) | ||
) | ||
} | ||
function _createQueueAndAddSubscription (normalizedHandler, options) { | ||
return this.acquire({}, 'messaging').then(client => { | ||
const queueName = _getQueueName(options.source) | ||
const topic = _getTopicFromOnHandler(normalizedHandler, options.prefix) | ||
const source = _getSource(client, options) | ||
const queueName = _getQueueNameFromSource(source) | ||
const prefixForTopic = _getPrefixForTopic(options, client) | ||
const topic = _getTopicFromOnHandler(normalizedHandler, prefixForTopic) | ||
if (client._options.kind === 'enterprise-messaging') { | ||
@@ -142,3 +153,3 @@ client._pendingOperations = _pendingOperations(client) | ||
} | ||
client.on(dataHandler(options.onHandlers, options.errHandlers, options.prefix), null, options.source) | ||
client.on(dataHandler(options.onHandlers, options.errHandlers, prefixForTopic), null, source) | ||
this.release(client) | ||
@@ -178,3 +189,3 @@ }) | ||
function _getQueueName (source) { | ||
function _getQueueNameFromSource (source) { | ||
return source.replace('queue:', '') | ||
@@ -219,3 +230,6 @@ } | ||
try { | ||
this.deleteQueue(_getQueueName(this.messagingOptions.source)) | ||
const client = await this.acquire({}, 'messaging') | ||
const source = _getSource(client, this.messagingOptions) | ||
this.release(client) | ||
await this.deleteQueue(_getQueueNameFromSource(source)) | ||
} catch (err) {} | ||
@@ -232,5 +246,4 @@ } | ||
this.acquire({}, 'messaging').then(client => { | ||
const namespace = options.namespaceOfService | ||
const namespace = options.namespaceOfService || client._options.namespace | ||
const shrunkService = options.shrunkService | ||
const [target, msg] = _getTargetAndMessage(payload, namespace, shrunkService, entity, event, header) | ||
@@ -237,0 +250,0 @@ client.emit(msg, target) |
@@ -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.2.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.4.0","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
53494
1020