@cap-js-community/event-queue 1.8.5 → 1.8.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js-community/event-queue",
3
- "version": "1.8.5",
3
+ "version": "1.8.6",
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",
@@ -34,7 +34,8 @@ const publishEvent = async (tx, events, { skipBroadcast = false, skipInsertEvent
34
34
  throw EventQueueError.notInitialized();
35
35
  }
36
36
  const eventsForProcessing = Array.isArray(events) ? events : [events];
37
- for (const { type, subType, startAfter } of eventsForProcessing) {
37
+ for (const event of eventsForProcessing) {
38
+ const { type, subType, startAfter } = event;
38
39
  const eventConfig = config.getEventConfig(type, subType);
39
40
  if (!eventConfig) {
40
41
  throw EventQueueError.unknownEventType(type, subType);
@@ -46,8 +47,11 @@ const publishEvent = async (tx, events, { skipBroadcast = false, skipInsertEvent
46
47
  if (eventConfig.isPeriodic) {
47
48
  throw EventQueueError.manuelPeriodicEventInsert(type, subType);
48
49
  }
49
- }
50
50
 
51
+ if (typeof event.payload !== "string") {
52
+ event.payload = JSON.stringify(event.payload);
53
+ }
54
+ }
51
55
  if (config.insertEventsBeforeCommit && !skipInsertEventsBeforeCommit) {
52
56
  _registerHandlerAndAddEvents(tx, events);
53
57
  } else {
@@ -101,18 +101,27 @@ const _getNewTokenInfo = async (tenantId) => {
101
101
  return tokenInfo;
102
102
  } catch (err) {
103
103
  tokenInfoCache[tenantId] = null;
104
- cds.log(COMPONENT_NAME).warn("failed to request tokenInfo", err);
104
+ cds.log(COMPONENT_NAME).warn("failed to request tokenInfo", {
105
+ err: err.message,
106
+ responseCode: err.responseCode,
107
+ responseText: err.responseText,
108
+ });
105
109
  }
106
110
  };
107
111
 
108
112
  const getTokenInfo = async (tenantId) => {
109
- if (!isTenantIdValidCb(TenantIdCheckTypes.getTokenInfo, tenantId)) {
113
+ if (!(await isTenantIdValidCb(TenantIdCheckTypes.getTokenInfo, tenantId))) {
110
114
  return null;
111
115
  }
112
116
 
113
117
  if (!cds.requires?.auth?.credentials) {
114
118
  return null; // no credentials not tokenInfo
115
119
  }
120
+
121
+ if (!config.isMultiTenancy) {
122
+ return null; // does only make sense for multi tenancy
123
+ }
124
+
116
125
  if (!cds.requires?.auth.kind.match(/jwt|xsuaa/i)) {
117
126
  cds.log(COMPONENT_NAME).warn("Only 'jwt' or 'xsuaa' are supported as values for auth.kind.");
118
127
  return null;