wsp-ms-core 1.0.95 → 1.0.97

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/dist/index.d.mts CHANGED
@@ -651,26 +651,11 @@ declare class DefaultMysqlInboxRunner {
651
651
  start(): Promise<void>;
652
652
  }
653
653
 
654
- interface InboxRepository {
655
- create(event: InboxRecord): Promise<void>;
656
- update(event: InboxRecord): Promise<void>;
657
- listPending(limit: number): Promise<InboxRecord[]>;
658
- }
659
-
660
- declare class InboxMysqlRepository implements InboxRepository {
661
- private readonly connection;
662
- constructor(connection: DatabaseConnection);
663
- private recordToRowValues;
664
- create(record: InboxRecord): Promise<void>;
665
- update(record: InboxRecord): Promise<void>;
666
- listPending(limit: number): Promise<InboxRecord[]>;
667
- }
668
-
669
654
  type InboxHandlerProcessor = (record: InboxRecord) => void;
670
655
  declare class DefaultMysqlInboxProcessor {
671
- private repository;
656
+ private uovFactory;
672
657
  private handlers;
673
- constructor(repository: InboxMysqlRepository);
658
+ constructor(uowFactory: BasicUnitOfWorkFactory);
674
659
  private sleep;
675
660
  addHandlerForTopic(topic: string, handler: InboxHandlerProcessor): void;
676
661
  processRecords(): Promise<void>;
package/dist/index.d.ts CHANGED
@@ -651,26 +651,11 @@ declare class DefaultMysqlInboxRunner {
651
651
  start(): Promise<void>;
652
652
  }
653
653
 
654
- interface InboxRepository {
655
- create(event: InboxRecord): Promise<void>;
656
- update(event: InboxRecord): Promise<void>;
657
- listPending(limit: number): Promise<InboxRecord[]>;
658
- }
659
-
660
- declare class InboxMysqlRepository implements InboxRepository {
661
- private readonly connection;
662
- constructor(connection: DatabaseConnection);
663
- private recordToRowValues;
664
- create(record: InboxRecord): Promise<void>;
665
- update(record: InboxRecord): Promise<void>;
666
- listPending(limit: number): Promise<InboxRecord[]>;
667
- }
668
-
669
654
  type InboxHandlerProcessor = (record: InboxRecord) => void;
670
655
  declare class DefaultMysqlInboxProcessor {
671
- private repository;
656
+ private uovFactory;
672
657
  private handlers;
673
- constructor(repository: InboxMysqlRepository);
658
+ constructor(uowFactory: BasicUnitOfWorkFactory);
674
659
  private sleep;
675
660
  addHandlerForTopic(topic: string, handler: InboxHandlerProcessor): void;
676
661
  processRecords(): Promise<void>;
package/dist/index.js CHANGED
@@ -1886,8 +1886,9 @@ var DefaultMysqlInboxRunner = class {
1886
1886
 
1887
1887
  // src/infrastructure/runners/default-mysql-inbox-processor.ts
1888
1888
  var DefaultMysqlInboxProcessor = class {
1889
- constructor(repository) {
1890
- this.repository = repository;
1889
+ constructor(uowFactory) {
1890
+ this.uovFactory = uowFactory;
1891
+ this.handlers = /* @__PURE__ */ new Map();
1891
1892
  }
1892
1893
  async sleep() {
1893
1894
  return new Promise((r) => setTimeout(r, 5e3));
@@ -1896,12 +1897,16 @@ var DefaultMysqlInboxProcessor = class {
1896
1897
  this.handlers.set(topic, handler);
1897
1898
  }
1898
1899
  async processRecords() {
1899
- const records = await this.repository.listPending(20);
1900
- for (let record of records) {
1901
- if (this.handlers.has(record.topic)) {
1902
- await this.handlers.get(record.topic)(record);
1900
+ const uow = await this.uovFactory.create();
1901
+ const repository = new InboxMysqlRepository(uow.connection);
1902
+ await uow.execute(async () => {
1903
+ const records = await repository.listPending(20);
1904
+ for (let record of records) {
1905
+ if (this.handlers.has(record.topic)) {
1906
+ await this.handlers.get(record.topic)(record);
1907
+ }
1903
1908
  }
1904
- }
1909
+ });
1905
1910
  }
1906
1911
  async start() {
1907
1912
  console.log("[inbox-runner-processor]: start");