@cap-js-community/event-queue 1.10.2 → 1.10.4

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.10.2",
3
+ "version": "1.10.4",
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",
@@ -174,7 +174,12 @@ class EventQueueProcessorBase {
174
174
  eventSubType: this.#eventSubType,
175
175
  iterationCounter,
176
176
  });
177
- this.#eventSchedulerInstance.scheduleEvent(this.__context.tenant, this.#eventType, this.#eventSubType, new Date());
177
+ this.#eventSchedulerInstance.scheduleEvent(
178
+ this.__context.tenant,
179
+ this.#eventType,
180
+ this.#eventSubType,
181
+ new Date(Date.now() + 5 * 1000) // add some offset to make sure all locks are released
182
+ );
178
183
  }
179
184
 
180
185
  logStartMessage() {
package/src/config.js CHANGED
@@ -638,18 +638,17 @@ class Config {
638
638
  let cron;
639
639
 
640
640
  // NOTE: logic is as follows:
641
- // - if event.utc is true --> always use UTC
641
+ // - if event.utc is true --> always use UTC (default is false)
642
642
  // - if event.useCronTimezone is false OR event.cronTimezone is not defined --> use UTC as well
643
643
  // - if event.utc is not true AND event.cronTimezone is set AND event.useCronTimezone is NOT set to false use event.cronTimezone
644
644
  event.utc = event.utc ?? UTC_DEFAULT;
645
-
646
- if (!event.cronTimezone) {
645
+ if (!this.cronTimezone) {
647
646
  event.useCronTimezone = false;
648
647
  } else {
649
648
  event.useCronTimezone = event.useCronTimezone ?? USE_CRON_TZ_DEFAULT;
650
649
  }
651
650
 
652
- event.tz = event.utc || !event.useCronTimezone ? "UTC" : event.cronTimezone;
651
+ event.tz = event.utc || !event.useCronTimezone ? "UTC" : this.cronTimezone;
653
652
 
654
653
  try {
655
654
  cron = CronExpressionParser.parse(event.cron);
package/src/initialize.js CHANGED
@@ -182,6 +182,14 @@ const monkeyPatchCAPOutbox = () => {
182
182
  get: () => eventQueueAsOutbox.unboxed,
183
183
  configurable: true,
184
184
  });
185
+ Object.defineProperty(cds, "queued", {
186
+ get: () => eventQueueAsOutbox.outboxed,
187
+ configurable: true,
188
+ });
189
+ Object.defineProperty(cds, "unqueued", {
190
+ get: () => eventQueueAsOutbox.unboxed,
191
+ configurable: true,
192
+ });
185
193
  }
186
194
  };
187
195
 
@@ -47,7 +47,6 @@ function outboxed(srv, customOpts) {
47
47
  customOpts || {}
48
48
  );
49
49
  config.addCAPOutboxEventBase(srv.name, outboxOpts);
50
- // TODO: check req.event ?? req.method
51
50
  const specificSettings = config.getCdsOutboxEventSpecificConfig(srv.name, req.event);
52
51
  if (specificSettings) {
53
52
  outboxOpts = config.addCAPOutboxEventSpecificAction(srv.name, req.event);
@@ -68,9 +68,7 @@ const _messageHandlerProcessEvents = async (messageData) => {
68
68
  }
69
69
  }
70
70
 
71
- if (
72
- !(config.getEventConfig(type, serviceNameOrSubType) && config.shouldBeProcessedInThisApplication(type, subType))
73
- ) {
71
+ if (!(config.getEventConfig(type, subType) && config.shouldBeProcessedInThisApplication(type, subType))) {
74
72
  logger.debug("event is not configured to be processed on this app-name", {
75
73
  tenantId,
76
74
  type,