@nmshd/app-runtime 2.0.0-alpha.3 → 2.0.0-alpha.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/README.md CHANGED
@@ -7,7 +7,7 @@ The App-Runtime extends the Runtime with App-specific functionality.
7
7
 
8
8
  ## Documentation
9
9
 
10
- The documentation for this project is currently under construction.
10
+ You can find the documentation for Enmeshed on [enmeshed.eu](https://enmeshed.eu).
11
11
 
12
12
  ## Feedback
13
13
 
@@ -17,7 +17,7 @@ Share your feedback with the Enmeshed team by contributing to the [discussions](
17
17
 
18
18
  ## Contribute
19
19
 
20
- Currently contribution to this project is not possible. This will change soon.
20
+ Contribution to this project is highly apprecicated. Head over to our [contribution guide](https://github.com/nmshd/.github/blob/main/CONTRIBUTING.md) to learn more.
21
21
 
22
22
  ## License
23
23
 
@@ -8,11 +8,11 @@ const crypto_1 = require("@nmshd/crypto");
8
8
  const runtime_1 = require("@nmshd/runtime");
9
9
  const transport_1 = require("@nmshd/transport");
10
10
  exports.buildInformation = {
11
- version: "2.0.0-alpha.3",
12
- build: "12",
13
- date: "2022-07-04T14:34:38+00:00",
14
- commit: "ce394ace4ec83d3509f4f0c8bef6fd342891ed29",
15
- dependencies: {"@js-soft/docdb-access-loki":"^1.0.3","@js-soft/native-abstractions":"^1.1.0","@nmshd/runtime":"2.0.0-alpha.25","lodash":"^4.17.21"},
11
+ version: "2.0.0-alpha.6",
12
+ build: "17",
13
+ date: "2022-07-19T13:27:53+00:00",
14
+ commit: "6fac45e109bc1f82f4cb7010552b612291f3c297",
15
+ dependencies: {"@js-soft/docdb-access-loki":"^1.0.3","@js-soft/native-abstractions":"^1.2.0","@nmshd/runtime":"2.0.0-alpha.37","lodash":"^4.17.21"},
16
16
  libraries: {
17
17
  serval: ts_serval_1.buildInformation,
18
18
  crypto: crypto_1.buildInformation,
@@ -1,5 +1,5 @@
1
- import { DataEvent, MailDVO, RequestMailDVO } from "@nmshd/runtime";
2
- export declare class MailReceivedEvent extends DataEvent<MailDVO | RequestMailDVO> {
1
+ import { DataEvent, MailDVO } from "@nmshd/runtime";
2
+ export declare class MailReceivedEvent extends DataEvent<MailDVO> {
3
3
  static readonly namespace: string;
4
- constructor(address: string, message: MailDVO | RequestMailDVO);
4
+ constructor(address: string, message: MailDVO);
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MailReceivedEvent.js","sourceRoot":"","sources":["../../src/events/MailReceivedEvent.ts"],"names":[],"mappings":";;;AAAA,4CAAmE;AAEnE,MAAa,iBAAkB,SAAQ,mBAAmC;IAGtE,YAAmB,OAAe,EAAE,OAAiC;QACjE,KAAK,CAAC,iBAAiB,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IACxD,CAAC;;AALL,8CAMC;AAL0B,2BAAS,GAAW,kBAAkB,CAAA"}
1
+ {"version":3,"file":"MailReceivedEvent.js","sourceRoot":"","sources":["../../src/events/MailReceivedEvent.ts"],"names":[],"mappings":";;;AAAA,4CAAmD;AAEnD,MAAa,iBAAkB,SAAQ,mBAAkB;IAGrD,YAAmB,OAAe,EAAE,OAAgB;QAChD,KAAK,CAAC,iBAAiB,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IACxD,CAAC;;AALL,8CAMC;AAL0B,2BAAS,GAAW,kBAAkB,CAAA"}
@@ -1,8 +1,8 @@
1
- import { DataEvent, MessageDVO, RequestDVO, RequestMailDVO } from "@nmshd/runtime";
1
+ import { DataEvent, LocalRequestDVO, RequestMessageDVO } from "@nmshd/runtime";
2
2
  export declare class RequestReceivedEvent extends DataEvent<{
3
- request: RequestDVO;
4
- message: MessageDVO | RequestMailDVO;
3
+ request: LocalRequestDVO;
4
+ message: RequestMessageDVO;
5
5
  }> {
6
6
  static readonly namespace: string;
7
- constructor(address: string, request: RequestDVO, message: MessageDVO | RequestMailDVO);
7
+ constructor(address: string, request: LocalRequestDVO, message: RequestMessageDVO);
8
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RequestReceivedEvent.js","sourceRoot":"","sources":["../../src/events/RequestReceivedEvent.ts"],"names":[],"mappings":";;;AAAA,4CAAkF;AAElF,MAAa,oBAAqB,SAAQ,mBAGxC;IAGE,YAAmB,OAAe,EAAE,OAAmB,EAAE,OAAoC;QACzF,KAAK,CAAC,oBAAoB,CAAC,SAAS,EAAE,OAAO,EAAE;YAC3C,OAAO;YACP,OAAO;SACV,CAAC,CAAA;IACN,CAAC;;AAXL,oDAYC;AAR0B,8BAAS,GAAW,qBAAqB,CAAA"}
1
+ {"version":3,"file":"RequestReceivedEvent.js","sourceRoot":"","sources":["../../src/events/RequestReceivedEvent.ts"],"names":[],"mappings":";;;AAAA,4CAA8E;AAE9E,MAAa,oBAAqB,SAAQ,mBAGxC;IAGE,YAAmB,OAAe,EAAE,OAAwB,EAAE,OAA0B;QACpF,KAAK,CAAC,oBAAoB,CAAC,SAAS,EAAE,OAAO,EAAE;YAC3C,OAAO;YACP,OAAO;SACV,CAAC,CAAA;IACN,CAAC;;AAXL,oDAYC;AAR0B,8BAAS,GAAW,qBAAqB,CAAA"}
@@ -1,9 +1,9 @@
1
1
  import { Result } from "@js-soft/ts-utils";
2
- import { IdentityDVO, MailDVO, MessageDVO, RelationshipChangeDTO, RelationshipTemplateDTO, RequestMailDVO, TokenDTO } from "@nmshd/runtime";
2
+ import { IdentityDVO, MailDVO, MessageDVO, RelationshipChangeDTO, RelationshipTemplateDTO, RequestMessageDVO, TokenDTO } from "@nmshd/runtime";
3
3
  import { LocalAccountDTO } from "../../multiAccount";
4
4
  import { UserfriendlyApplicationError } from "../../UserfriendlyApplicationError";
5
5
  export interface IUIBridge {
6
- showMessage(account: LocalAccountDTO, relationship: IdentityDVO, message: MessageDVO | MailDVO | RequestMailDVO): Promise<Result<void>>;
6
+ showMessage(account: LocalAccountDTO, relationship: IdentityDVO, message: MessageDVO | MailDVO | RequestMessageDVO): Promise<Result<void>>;
7
7
  showRelationship(account: LocalAccountDTO, relationship: IdentityDVO): Promise<Result<void>>;
8
8
  showRelationshipChange(account: LocalAccountDTO, relationship: IdentityDVO, change: RelationshipChangeDTO): Promise<Result<void>>;
9
9
  showRelationshipTemplate(account: LocalAccountDTO, relationshipTemplate: RelationshipTemplateDTO): Promise<Result<void>>;
@@ -8,7 +8,7 @@ export interface IAppRuntimeModuleConstructor {
8
8
  export interface AppRuntimeModuleConfiguration extends ModuleConfiguration {
9
9
  }
10
10
  export declare abstract class AppRuntimeModule<TConfig extends AppRuntimeModuleConfiguration = AppRuntimeModuleConfiguration> extends RuntimeModule<TConfig, AppRuntime> {
11
- private readonly registeredNativeEventSubscriptions;
11
+ private readonly nativeEventSubscriptionIds;
12
12
  protected subscribeToNativeEvent<TEvent>(event: Event, handler: EventHandler<TEvent>): void;
13
13
  protected unsubscribeFromAllEvents(): void;
14
14
  }
@@ -5,7 +5,7 @@ const runtime_1 = require("@nmshd/runtime");
5
5
  class AppRuntimeModule extends runtime_1.RuntimeModule {
6
6
  constructor() {
7
7
  super(...arguments);
8
- this.registeredNativeEventSubscriptions = [];
8
+ this.nativeEventSubscriptionIds = [];
9
9
  }
10
10
  subscribeToNativeEvent(event, handler) {
11
11
  const subscriptionResult = this.runtime.nativeEnvironment.eventBus.subscribe(event, handler);
@@ -13,14 +13,12 @@ class AppRuntimeModule extends runtime_1.RuntimeModule {
13
13
  this.logger.error(subscriptionResult.error);
14
14
  throw subscriptionResult.error;
15
15
  }
16
- this.registeredNativeEventSubscriptions.push({ id: subscriptionResult.value, target: event });
16
+ this.nativeEventSubscriptionIds.push(subscriptionResult.value);
17
17
  }
18
18
  unsubscribeFromAllEvents() {
19
19
  super.unsubscribeFromAllEvents();
20
- for (const subscription of this.registeredNativeEventSubscriptions) {
21
- this.runtime.nativeEnvironment.eventBus.unsubscribe(subscription.target, subscription.id);
22
- }
23
- this.registeredNativeEventSubscriptions.splice(0);
20
+ this.nativeEventSubscriptionIds.forEach((id) => this.runtime.nativeEnvironment.eventBus.unsubscribe(id));
21
+ this.nativeEventSubscriptionIds.splice(0);
24
22
  }
25
23
  }
26
24
  exports.AppRuntimeModule = AppRuntimeModule;
@@ -1 +1 @@
1
- {"version":3,"file":"AppRuntimeModule.js","sourceRoot":"","sources":["../../src/modules/AppRuntimeModule.ts"],"names":[],"mappings":";;;AAEA,4CAAmE;AASnE,MAAsB,gBAEpB,SAAQ,uBAAkC;IAF5C;;QAGqB,uCAAkC,GAAoC,EAAE,CAAA;IAqB7F,CAAC;IAnBa,sBAAsB,CAAS,KAAY,EAAE,OAA6B;QAChF,MAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAC5F,IAAI,kBAAkB,CAAC,OAAO,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAA;YAC3C,MAAM,kBAAkB,CAAC,KAAK,CAAA;SACjC;QAED,IAAI,CAAC,kCAAkC,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;IACjG,CAAC;IAEkB,wBAAwB;QACvC,KAAK,CAAC,wBAAwB,EAAE,CAAA;QAEhC,KAAK,MAAM,YAAY,IAAI,IAAI,CAAC,kCAAkC,EAAE;YAChE,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,WAAW,CAAC,YAAY,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,CAAA;SAC5F;QAED,IAAI,CAAC,kCAAkC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IACrD,CAAC;CACJ;AAxBD,4CAwBC"}
1
+ {"version":3,"file":"AppRuntimeModule.js","sourceRoot":"","sources":["../../src/modules/AppRuntimeModule.ts"],"names":[],"mappings":";;;AAEA,4CAAmE;AASnE,MAAsB,gBAEpB,SAAQ,uBAAkC;IAF5C;;QAGqB,+BAA0B,GAAa,EAAE,CAAA;IAkB9D,CAAC;IAhBa,sBAAsB,CAAS,KAAY,EAAE,OAA6B;QAChF,MAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAC5F,IAAI,kBAAkB,CAAC,OAAO,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAA;YAC3C,MAAM,kBAAkB,CAAC,KAAK,CAAA;SACjC;QAED,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAA;IAClE,CAAC;IAEkB,wBAAwB;QACvC,KAAK,CAAC,wBAAwB,EAAE,CAAA;QAEhC,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAA;QACxG,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAC7C,CAAC;CACJ;AArBD,4CAqBC"}
@@ -24,12 +24,8 @@ class MessageReceivedModule extends AppRuntimeModule_1.AppRuntimeModule {
24
24
  }
25
25
  const messageDVO = await session.expander.expandMessageDTO(message);
26
26
  switch (messageDVO.type) {
27
- case "RequestMailDVO":
28
- const requestMail = messageDVO;
29
- this.runtime.eventBus.publish(new events_1.MailReceivedEvent(event.eventTargetAddress, requestMail));
30
- for (const requestDVO of requestMail.requests) {
31
- this.runtime.eventBus.publish(new events_1.RequestReceivedEvent(event.eventTargetAddress, requestDVO, messageDVO));
32
- }
27
+ case "RequestMessageDVO":
28
+ this.runtime.eventBus.publish(new events_1.RequestReceivedEvent(event.eventTargetAddress, messageDVO.request, messageDVO));
33
29
  break;
34
30
  case "MailDVO":
35
31
  const mail = messageDVO;
@@ -1 +1 @@
1
- {"version":3,"file":"MessageReceivedModule.js","sourceRoot":"","sources":["../../../src/modules/runtimeEvents/MessageReceivedModule.ts"],"names":[],"mappings":";;;AAAA,4CAA8E;AAC9E,2DAAuD;AACvD,yCAAsE;AACtE,0DAAqF;AAIrF,MAAa,0BAA2B,SAAQ,iCAAe;CAAG;AAAlE,gEAAkE;AAElE,MAAa,qBAAsB,SAAQ,mCAA6C;IAC7E,KAAK,CAAC,IAAI;QACb,qBAAqB;IACzB,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,gBAAgB,CAAC,8BAAoB,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACtF,CAAC;IAEO,KAAK,CAAC,qBAAqB,CAAC,KAA2B;QAC3D,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAA;QAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;QAC3E,IAAI,CAAC,OAAO,EAAE;YACV,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,KAAK,CAAC,kBAAkB,EAAE,CAAC,CAAA;YAC7E,OAAM;SACT;QACD,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAA;QAEnE,QAAQ,UAAU,CAAC,IAAI,EAAE;YACrB,KAAK,gBAAgB;gBACjB,MAAM,WAAW,GAAmB,UAAU,CAAA;gBAC9C,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,0BAAiB,CAAC,KAAK,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC,CAAA;gBAC3F,KAAK,MAAM,UAAU,IAAI,WAAW,CAAC,QAAQ,EAAE;oBAC3C,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CACzB,IAAI,6BAAoB,CAAC,KAAK,CAAC,kBAAkB,EAAE,UAAU,EAAE,UAAU,CAAC,CAC7E,CAAA;iBACJ;gBACD,MAAK;YACT,KAAK,SAAS;gBACV,MAAM,IAAI,GAAY,UAAU,CAAA;gBAChC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,0BAAiB,CAAC,KAAK,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC,CAAA;gBACpF,MAAK;YACT;gBACI,MAAK;SACZ;IACL,CAAC;IAEM,IAAI;QACP,IAAI,CAAC,wBAAwB,EAAE,CAAA;IACnC,CAAC;CACJ;AAxCD,sDAwCC"}
1
+ {"version":3,"file":"MessageReceivedModule.js","sourceRoot":"","sources":["../../../src/modules/runtimeEvents/MessageReceivedModule.ts"],"names":[],"mappings":";;;AAAA,4CAA8D;AAC9D,2DAAuD;AACvD,yCAAsE;AACtE,0DAAqF;AAIrF,MAAa,0BAA2B,SAAQ,iCAAe;CAAG;AAAlE,gEAAkE;AAElE,MAAa,qBAAsB,SAAQ,mCAA6C;IAC7E,KAAK,CAAC,IAAI;QACb,qBAAqB;IACzB,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,gBAAgB,CAAC,8BAAoB,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACtF,CAAC;IAEO,KAAK,CAAC,qBAAqB,CAAC,KAA2B;QAC3D,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAA;QAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;QAC3E,IAAI,CAAC,OAAO,EAAE;YACV,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,KAAK,CAAC,kBAAkB,EAAE,CAAC,CAAA;YAC7E,OAAM;SACT;QACD,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAA;QAEnE,QAAQ,UAAU,CAAC,IAAI,EAAE;YACrB,KAAK,mBAAmB;gBACpB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CACzB,IAAI,6BAAoB,CAAC,KAAK,CAAC,kBAAkB,EAAE,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CACrF,CAAA;gBACD,MAAK;YACT,KAAK,SAAS;gBACV,MAAM,IAAI,GAAY,UAAU,CAAA;gBAChC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,0BAAiB,CAAC,KAAK,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC,CAAA;gBACpF,MAAK;YACT;gBACI,MAAK;SACZ;IACL,CAAC;IAEM,IAAI;QACP,IAAI,CAAC,wBAAwB,EAAE,CAAA;IACnC,CAAC;CACJ;AApCD,sDAoCC"}
@@ -558,11 +558,11 @@ const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
558
558
  const runtime_1 = __webpack_require__(/*! @nmshd/runtime */ "@nmshd/runtime");
559
559
  const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
560
560
  exports.buildInformation = {
561
- version: "2.0.0-alpha.3",
562
- build: "12",
563
- date: "2022-07-04T14:34:38+00:00",
564
- commit: "ce394ace4ec83d3509f4f0c8bef6fd342891ed29",
565
- dependencies: {"@js-soft/docdb-access-loki":"^1.0.3","@js-soft/native-abstractions":"^1.1.0","@nmshd/runtime":"2.0.0-alpha.25","lodash":"^4.17.21"},
561
+ version: "2.0.0-alpha.6",
562
+ build: "17",
563
+ date: "2022-07-19T13:27:53+00:00",
564
+ commit: "6fac45e109bc1f82f4cb7010552b612291f3c297",
565
+ dependencies: {"@js-soft/docdb-access-loki":"^1.0.3","@js-soft/native-abstractions":"^1.2.0","@nmshd/runtime":"2.0.0-alpha.37","lodash":"^4.17.21"},
566
566
  libraries: {
567
567
  serval: ts_serval_1.buildInformation,
568
568
  crypto: crypto_1.buildInformation,
@@ -1143,7 +1143,7 @@ const runtime_1 = __webpack_require__(/*! @nmshd/runtime */ "@nmshd/runtime");
1143
1143
  class AppRuntimeModule extends runtime_1.RuntimeModule {
1144
1144
  constructor() {
1145
1145
  super(...arguments);
1146
- this.registeredNativeEventSubscriptions = [];
1146
+ this.nativeEventSubscriptionIds = [];
1147
1147
  }
1148
1148
  subscribeToNativeEvent(event, handler) {
1149
1149
  const subscriptionResult = this.runtime.nativeEnvironment.eventBus.subscribe(event, handler);
@@ -1151,14 +1151,12 @@ class AppRuntimeModule extends runtime_1.RuntimeModule {
1151
1151
  this.logger.error(subscriptionResult.error);
1152
1152
  throw subscriptionResult.error;
1153
1153
  }
1154
- this.registeredNativeEventSubscriptions.push({ id: subscriptionResult.value, target: event });
1154
+ this.nativeEventSubscriptionIds.push(subscriptionResult.value);
1155
1155
  }
1156
1156
  unsubscribeFromAllEvents() {
1157
1157
  super.unsubscribeFromAllEvents();
1158
- for (const subscription of this.registeredNativeEventSubscriptions) {
1159
- this.runtime.nativeEnvironment.eventBus.unsubscribe(subscription.target, subscription.id);
1160
- }
1161
- this.registeredNativeEventSubscriptions.splice(0);
1158
+ this.nativeEventSubscriptionIds.forEach((id) => this.runtime.nativeEnvironment.eventBus.unsubscribe(id));
1159
+ this.nativeEventSubscriptionIds.splice(0);
1162
1160
  }
1163
1161
  }
1164
1162
  exports.AppRuntimeModule = AppRuntimeModule;
@@ -1674,12 +1672,8 @@ class MessageReceivedModule extends AppRuntimeModule_1.AppRuntimeModule {
1674
1672
  }
1675
1673
  const messageDVO = await session.expander.expandMessageDTO(message);
1676
1674
  switch (messageDVO.type) {
1677
- case "RequestMailDVO":
1678
- const requestMail = messageDVO;
1679
- this.runtime.eventBus.publish(new events_1.MailReceivedEvent(event.eventTargetAddress, requestMail));
1680
- for (const requestDVO of requestMail.requests) {
1681
- this.runtime.eventBus.publish(new events_1.RequestReceivedEvent(event.eventTargetAddress, requestDVO, messageDVO));
1682
- }
1675
+ case "RequestMessageDVO":
1676
+ this.runtime.eventBus.publish(new events_1.RequestReceivedEvent(event.eventTargetAddress, messageDVO.request, messageDVO));
1683
1677
  break;
1684
1678
  case "MailDVO":
1685
1679
  const mail = messageDVO;
@@ -3222,10 +3216,11 @@ const EventBus_1 = __webpack_require__(/*! ../EventBus */ "./node_modules/@js-so
3222
3216
  const SubscriptionTargetInfo_1 = __webpack_require__(/*! ../SubscriptionTargetInfo */ "./node_modules/@js-soft/ts-utils/dist/eventBus/SubscriptionTargetInfo.js");
3223
3217
  class EventEmitter2EventBus {
3224
3218
  emitter;
3225
- wrappers = new Map();
3219
+ listeners = new Map();
3226
3220
  nextId = 0;
3227
- constructor() {
3228
- this.emitter = new eventemitter2_1.EventEmitter2({ wildcard: true, maxListeners: 50, verboseMemoryLeak: true });
3221
+ invocationPromises = [];
3222
+ constructor(options) {
3223
+ this.emitter = new eventemitter2_1.EventEmitter2({ ...options, wildcard: true, maxListeners: 50, verboseMemoryLeak: true });
3229
3224
  }
3230
3225
  subscribe(subscriptionTarget, handler) {
3231
3226
  return this.registerHandler(subscriptionTarget, handler);
@@ -3233,33 +3228,39 @@ class EventEmitter2EventBus {
3233
3228
  subscribeOnce(subscriptionTarget, handler) {
3234
3229
  return this.registerHandler(subscriptionTarget, handler, true);
3235
3230
  }
3236
- unsubscribe(subscriptionTarget, subscriptionId) {
3237
- return this.unregisterHandler(subscriptionTarget, subscriptionId);
3231
+ unsubscribe(subscriptionId) {
3232
+ return this.unregisterHandler(subscriptionId);
3238
3233
  }
3239
3234
  registerHandler(subscriptionTarget, handler, isOneTimeHandler = false) {
3240
3235
  const subscriptionTargetInfo = SubscriptionTargetInfo_1.SubscriptionTargetInfo.from(subscriptionTarget);
3241
- const handlerId = this.nextId++;
3242
- const handlerWrapper = (event) => {
3236
+ const listenerId = this.nextId++;
3237
+ const handlerWrapper = async (event) => {
3243
3238
  if (!subscriptionTargetInfo.isCompatibleWith(event)) {
3244
3239
  return;
3245
3240
  }
3246
- handler(event);
3247
- if (isOneTimeHandler) {
3248
- this.unsubscribe(subscriptionTarget, handlerId);
3249
- }
3241
+ const invocationPromise = (async () => await handler(event))();
3242
+ this.invocationPromises.push(invocationPromise);
3243
+ await invocationPromise;
3244
+ this.invocationPromises = this.invocationPromises.filter((p) => p !== invocationPromise);
3245
+ if (isOneTimeHandler)
3246
+ this.listeners.delete(listenerId);
3250
3247
  };
3251
- this.wrappers.set(handlerId, handlerWrapper);
3252
- this.emitter.on(subscriptionTargetInfo.namespace, handlerWrapper);
3253
- return handlerId;
3254
- }
3255
- unregisterHandler(subscriptionTarget, handlerId) {
3256
- const subscriptionTargetInfo = SubscriptionTargetInfo_1.SubscriptionTargetInfo.from(subscriptionTarget);
3257
- const handlerWrapper = this.wrappers.get(handlerId);
3258
- if (!handlerWrapper) {
3248
+ if (isOneTimeHandler) {
3249
+ const listener = this.emitter.once(subscriptionTargetInfo.namespace, handlerWrapper, { objectify: true });
3250
+ this.listeners.set(listenerId, listener);
3251
+ return listenerId;
3252
+ }
3253
+ const listener = this.emitter.on(subscriptionTargetInfo.namespace, handlerWrapper, { objectify: true });
3254
+ this.listeners.set(listenerId, listener);
3255
+ return listenerId;
3256
+ }
3257
+ unregisterHandler(listenerId) {
3258
+ const listener = this.listeners.get(listenerId);
3259
+ if (!listener) {
3259
3260
  return false;
3260
3261
  }
3261
- this.emitter.off(subscriptionTargetInfo.namespace, handlerWrapper);
3262
- this.wrappers.delete(handlerId);
3262
+ listener.off();
3263
+ this.listeners.delete(listenerId);
3263
3264
  return true;
3264
3265
  }
3265
3266
  publish(event) {
@@ -3269,6 +3270,24 @@ class EventEmitter2EventBus {
3269
3270
  }
3270
3271
  this.emitter.emit(namespace, event);
3271
3272
  }
3273
+ async close(timeout) {
3274
+ this.emitter.removeAllListeners();
3275
+ const waitForInvocations = Promise.all(this.invocationPromises).catch(() => {
3276
+ /* ignore errors */
3277
+ });
3278
+ if (!timeout) {
3279
+ await waitForInvocations;
3280
+ return;
3281
+ }
3282
+ let timeoutId;
3283
+ const timeoutPromise = new Promise((_, reject) => {
3284
+ timeoutId = setTimeout(() => {
3285
+ reject(new Error("timeout exceeded while waiting for events to process"));
3286
+ }, timeout);
3287
+ });
3288
+ await Promise.race([waitForInvocations, timeoutPromise]);
3289
+ clearTimeout(timeoutId);
3290
+ }
3272
3291
  }
3273
3292
  exports.EventEmitter2EventBus = EventEmitter2EventBus;
3274
3293
  //# sourceMappingURL=EventEmitter2EventBus.js.map