@cap-js-community/event-queue 2.1.0-beta.2 → 2.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/db/Event.cds +1 -1
- package/package.json +1 -1
- package/src/outbox/eventQueueAsOutbox.js +16 -5
package/db/Event.cds
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cap-js-community/event-queue",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.3",
|
|
4
4
|
"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.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -11,6 +11,8 @@ const CDS_EVENT_TYPE = "CAP_OUTBOX";
|
|
|
11
11
|
const COMPONENT_NAME = "/eventQueue/eventQueueAsOutbox";
|
|
12
12
|
const EVENT_QUEUE_SPECIFIC_FIELDS = ["startAfter", "referenceEntity", "referenceEntityKey", "namespace"];
|
|
13
13
|
|
|
14
|
+
const TO_COPY = ["inbound", "event", "data", "queue", "results", "method", "path", "params", "entity", "service"];
|
|
15
|
+
|
|
14
16
|
function outboxed(srv, customOpts) {
|
|
15
17
|
if (!(new.target || customOpts)) {
|
|
16
18
|
const former = srv[OUTBOXED];
|
|
@@ -102,18 +104,27 @@ const _mapToEventAndPublish = async (req, namespace, subType, eventHeaders, cont
|
|
|
102
104
|
}
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
|
-
|
|
106
107
|
const event = {
|
|
107
108
|
contextUser: context.user.id,
|
|
108
109
|
...(req._fromSend || (req.reply && { _fromSend: true })), // send or emit
|
|
109
|
-
...(req.inbound && { inbound: req.inbound }),
|
|
110
|
-
...(req.event && { event: req.event }),
|
|
111
|
-
...(req.data && { data: req.data }),
|
|
112
110
|
...(eventHeaders && { headers: eventHeaders }),
|
|
113
|
-
...(req.query && { query: req.query }),
|
|
114
111
|
...(Object.keys(contextProperties).length && { ...contextProperties }),
|
|
115
112
|
};
|
|
116
113
|
|
|
114
|
+
for (const prop of TO_COPY) {
|
|
115
|
+
if (req[prop]) {
|
|
116
|
+
event[prop] = req[prop];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (req.query) {
|
|
121
|
+
event.query = typeof req.query.flat === "function" ? req.query.flat() : req.query;
|
|
122
|
+
delete event.query._target;
|
|
123
|
+
delete event.query.__target;
|
|
124
|
+
delete event.query.target;
|
|
125
|
+
delete event.data; // `req.data` should be a getter to whatever is in `req.query`
|
|
126
|
+
}
|
|
127
|
+
|
|
117
128
|
await publishEvent(
|
|
118
129
|
cds.tx(context),
|
|
119
130
|
{
|