@seidor-cloud-produtos/orbit-backend-lib 2.0.98 → 2.0.99
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/clean-arch/application/consistency-event-dispatcher/consistency-event-dispatcher.js +14 -4
- package/dist/clean-arch/infra/consistency-event-dispatcher/amqp-consistency-event-dispatcher.d.ts +4 -3
- package/dist/clean-arch/infra/consistency-event-dispatcher/amqp-consistency-event-dispatcher.js +7 -7
- package/dist/clean-arch/infra/consistency-event-dispatcher/in-memory-consistency-event-dispatcher.d.ts +3 -4
- package/dist/clean-arch/infra/consistency-event-dispatcher/in-memory-consistency-event-dispatcher.js +7 -7
- package/package.json +1 -1
package/dist/clean-arch/application/consistency-event-dispatcher/consistency-event-dispatcher.js
CHANGED
|
@@ -5,12 +5,22 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const consistency_event_1 = tslib_1.__importDefault(require("../../domain/events/consistency-event"));
|
|
6
6
|
class ConsistencyEventDispatcher {
|
|
7
7
|
async dispatch(entity, authorizerHeaders, eventName) {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
try {
|
|
9
|
+
const event = new consistency_event_1.default(entity, authorizerHeaders, eventName);
|
|
10
|
+
await this.publish(event);
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
console.error(`Failed to dispatch consistency event: ${error}`);
|
|
14
|
+
}
|
|
10
15
|
}
|
|
11
16
|
async dispatchBatch(entities, authorizerHeaders, eventName) {
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
try {
|
|
18
|
+
const events = entities.map(entity => new consistency_event_1.default(entity, authorizerHeaders, eventName));
|
|
19
|
+
await Promise.all(events.map(event => this.publish(event)));
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error(`Failed to dispatch batch consistency events: ${error}`);
|
|
23
|
+
}
|
|
14
24
|
}
|
|
15
25
|
}
|
|
16
26
|
exports.ConsistencyEventDispatcher = ConsistencyEventDispatcher;
|
package/dist/clean-arch/infra/consistency-event-dispatcher/amqp-consistency-event-dispatcher.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ConsistencyEventDispatcher } from '../../application/consistency-event-dispatcher/consistency-event-dispatcher';
|
|
2
|
+
import AmqpQueue from '../queue/rabbitmq/amqp-lib';
|
|
2
3
|
import ConsistencyEvent from '../../domain/events/consistency-event';
|
|
3
|
-
export declare class
|
|
4
|
-
protected
|
|
5
|
-
constructor(
|
|
4
|
+
export declare class AmqpConsistencyEventDispatcher extends ConsistencyEventDispatcher {
|
|
5
|
+
protected amqp: AmqpQueue;
|
|
6
|
+
constructor(amqp: AmqpQueue);
|
|
6
7
|
publish(event: ConsistencyEvent): Promise<void>;
|
|
7
8
|
}
|
package/dist/clean-arch/infra/consistency-event-dispatcher/amqp-consistency-event-dispatcher.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AmqpConsistencyEventDispatcher = void 0;
|
|
4
4
|
const consistency_event_dispatcher_1 = require("../../application/consistency-event-dispatcher/consistency-event-dispatcher");
|
|
5
|
-
class
|
|
6
|
-
|
|
7
|
-
constructor(
|
|
5
|
+
class AmqpConsistencyEventDispatcher extends consistency_event_dispatcher_1.ConsistencyEventDispatcher {
|
|
6
|
+
amqp;
|
|
7
|
+
constructor(amqp) {
|
|
8
8
|
super();
|
|
9
|
-
this.
|
|
9
|
+
this.amqp = amqp;
|
|
10
10
|
}
|
|
11
11
|
async publish(event) {
|
|
12
|
-
this.
|
|
12
|
+
await this.amqp.publish(event.name, event, { storeMessageOnError: false });
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
exports.
|
|
15
|
+
exports.AmqpConsistencyEventDispatcher = AmqpConsistencyEventDispatcher;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ConsistencyEventDispatcher } from '../../application/consistency-event-dispatcher/consistency-event-dispatcher';
|
|
2
|
-
import AmqpQueue from '../queue/rabbitmq/amqp-lib';
|
|
3
2
|
import ConsistencyEvent from '../../domain/events/consistency-event';
|
|
4
|
-
export declare class
|
|
5
|
-
protected
|
|
6
|
-
constructor(
|
|
3
|
+
export declare class InMemoryConsistencyEventDispatcher extends ConsistencyEventDispatcher {
|
|
4
|
+
protected events: ConsistencyEvent[];
|
|
5
|
+
constructor(events?: ConsistencyEvent[]);
|
|
7
6
|
publish(event: ConsistencyEvent): Promise<void>;
|
|
8
7
|
}
|
package/dist/clean-arch/infra/consistency-event-dispatcher/in-memory-consistency-event-dispatcher.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.InMemoryConsistencyEventDispatcher = void 0;
|
|
4
4
|
const consistency_event_dispatcher_1 = require("../../application/consistency-event-dispatcher/consistency-event-dispatcher");
|
|
5
|
-
class
|
|
6
|
-
|
|
7
|
-
constructor(
|
|
5
|
+
class InMemoryConsistencyEventDispatcher extends consistency_event_dispatcher_1.ConsistencyEventDispatcher {
|
|
6
|
+
events;
|
|
7
|
+
constructor(events = []) {
|
|
8
8
|
super();
|
|
9
|
-
this.
|
|
9
|
+
this.events = events;
|
|
10
10
|
}
|
|
11
11
|
async publish(event) {
|
|
12
|
-
|
|
12
|
+
this.events.push(event);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
exports.
|
|
15
|
+
exports.InMemoryConsistencyEventDispatcher = InMemoryConsistencyEventDispatcher;
|