@cap-js-community/event-queue
Advanced tools
Comparing version 1.3.1 to 1.3.2
{ | ||
"name": "@cap-js-community/event-queue", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "An event queue that enables secure transactional processing of asynchronous and periodic events, featuring instant event processing with Redis Pub/Sub and load distribution across all application instances.", | ||
@@ -47,3 +47,3 @@ "main": "src/index.js", | ||
"verror": "1.10.1", | ||
"yaml": "2.3.4" | ||
"yaml": "2.4.0" | ||
}, | ||
@@ -50,0 +50,0 @@ "devDependencies": { |
@@ -87,17 +87,15 @@ "use strict"; | ||
const logger = cds.log(COMPONENT); | ||
config.checkRedisEnabled(); | ||
cds.on("connect", (service) => { | ||
if (service.name === "db") { | ||
config.processEventsAfterPublish && dbHandler.registerEventQueueDbHandler(service); | ||
config.cleanupLocksAndEventsForDev && registerCleanupForDevDb().catch(() => {}); | ||
registerEventProcessors(); | ||
} | ||
}); | ||
config.fileContent = await readConfigFromFile(config.configFilePath); | ||
config.checkRedisEnabled(); | ||
if (config.processEventsAfterPublish) { | ||
cds.on("connect", (service) => { | ||
if (service.name === "db") { | ||
dbHandler.registerEventQueueDbHandler(service); | ||
config.cleanupLocksAndEventsForDev && registerCleanupForDevDb().catch(() => {}); | ||
} | ||
}); | ||
} | ||
!config.skipCsnCheck && (await csnCheck()); | ||
monkeyPatchCAPOutbox(); | ||
registerEventProcessors(); | ||
registerCdsShutdown(); | ||
@@ -104,0 +102,0 @@ logger.info("event queue initialized", { |
@@ -71,11 +71,19 @@ "use strict"; | ||
const _mapToEventAndPublish = async (context, name, msg) => { | ||
const _mapToEventAndPublish = async (context, name, req) => { | ||
let startAfter; | ||
for (const header in req.headers ?? {}) { | ||
if (header.toLocaleLowerCase() === "x-eventqueue-startafter") { | ||
startAfter = req.headers[header]; | ||
delete req.headers[header]; | ||
break; | ||
} | ||
} | ||
const event = { | ||
contextUser: context.user.id, | ||
...(msg._fromSend || (msg.reply && { _fromSend: true })), // send or emit | ||
...(msg.inbound && { inbound: msg.inbound }), | ||
...(msg.event && { event: msg.event }), | ||
...(msg.data && { data: msg.data }), | ||
...(msg.headers && { headers: msg.headers }), | ||
...(msg.query && { query: msg.query }), | ||
...(req._fromSend || (req.reply && { _fromSend: true })), // send or emit | ||
...(req.inbound && { inbound: req.inbound }), | ||
...(req.event && { event: req.event }), | ||
...(req.data && { data: req.data }), | ||
...(req.headers && { headers: req.headers }), | ||
...(req.query && { query: req.query }), | ||
}; | ||
@@ -87,2 +95,3 @@ | ||
payload: JSON.stringify(event), | ||
...(startAfter && { startAfter }), | ||
}); | ||
@@ -89,0 +98,0 @@ }; |
@@ -60,2 +60,9 @@ "use strict"; | ||
contextTx.context.user = user; | ||
try { | ||
contextTx.set?.({ | ||
"$user.id": user.id, | ||
}); | ||
} catch { | ||
/* empty */ | ||
} | ||
await fn(contextTx, ...parameters); | ||
@@ -62,0 +69,0 @@ } |
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
160895
3958
+ Addedyaml@2.4.0(transitive)
- Removedyaml@2.3.4(transitive)
Updatedyaml@2.4.0