@prodforcode/event-forge-rabbitmq 1.0.0 → 1.0.1
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/golevelup-publisher.d.ts +18 -0
- package/dist/golevelup-publisher.d.ts.map +1 -0
- package/dist/golevelup-publisher.js +41 -0
- package/dist/golevelup-publisher.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/microservices-publisher.d.ts +11 -0
- package/dist/microservices-publisher.d.ts.map +1 -0
- package/dist/microservices-publisher.js +34 -0
- package/dist/microservices-publisher.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IMessagePublisher, OutboxMessage, PublishOptions } from '@prodforcode/event-forge-core';
|
|
2
|
+
export interface RabbitMQPublishOptions extends PublishOptions {
|
|
3
|
+
persistent?: boolean;
|
|
4
|
+
contentType?: string;
|
|
5
|
+
messageId?: string;
|
|
6
|
+
timestamp?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface AmqpConnection {
|
|
9
|
+
publish<T = unknown>(exchange: string, routingKey: string, message: T, options?: RabbitMQPublishOptions): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare class GolevelupPublisher implements IMessagePublisher {
|
|
12
|
+
private readonly amqpConnection;
|
|
13
|
+
private readonly exchange;
|
|
14
|
+
constructor(amqpConnection: AmqpConnection, exchange: string);
|
|
15
|
+
publish(message: OutboxMessage, options?: PublishOptions): Promise<void>;
|
|
16
|
+
private buildRoutingKey;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=golevelup-publisher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"golevelup-publisher.d.ts","sourceRoot":"","sources":["../src/golevelup-publisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAKjG,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAE5D,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,CAAC,GAAG,OAAO,EACjB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,CAAC,EACV,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB;AAMD,qBAAa,kBAAmB,YAAW,iBAAiB;IAExD,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBADR,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,MAAM;IAG7B,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAsC9E,OAAO,CAAC,eAAe;CAGxB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GolevelupPublisher = void 0;
|
|
4
|
+
class GolevelupPublisher {
|
|
5
|
+
amqpConnection;
|
|
6
|
+
exchange;
|
|
7
|
+
constructor(amqpConnection, exchange) {
|
|
8
|
+
this.amqpConnection = amqpConnection;
|
|
9
|
+
this.exchange = exchange;
|
|
10
|
+
}
|
|
11
|
+
async publish(message, options) {
|
|
12
|
+
const routingKey = this.buildRoutingKey(message);
|
|
13
|
+
const rabbitMQOptions = {
|
|
14
|
+
...options,
|
|
15
|
+
persistent: true,
|
|
16
|
+
contentType: 'application/json',
|
|
17
|
+
messageId: message.id,
|
|
18
|
+
timestamp: message.createdAt.getTime(),
|
|
19
|
+
headers: {
|
|
20
|
+
...options?.headers,
|
|
21
|
+
'x-aggregate-type': message.aggregateType,
|
|
22
|
+
'x-aggregate-id': message.aggregateId,
|
|
23
|
+
'x-event-type': message.eventType,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
await this.amqpConnection.publish(this.exchange, routingKey, {
|
|
27
|
+
id: message.id,
|
|
28
|
+
aggregateType: message.aggregateType,
|
|
29
|
+
aggregateId: message.aggregateId,
|
|
30
|
+
eventType: message.eventType,
|
|
31
|
+
payload: message.payload,
|
|
32
|
+
metadata: message.metadata,
|
|
33
|
+
createdAt: message.createdAt,
|
|
34
|
+
}, rabbitMQOptions);
|
|
35
|
+
}
|
|
36
|
+
buildRoutingKey(message) {
|
|
37
|
+
return `${message.aggregateType}.${message.eventType}`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.GolevelupPublisher = GolevelupPublisher;
|
|
41
|
+
//# sourceMappingURL=golevelup-publisher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"golevelup-publisher.js","sourceRoot":"","sources":["../src/golevelup-publisher.ts"],"names":[],"mappings":";;;AAiCA,MAAa,kBAAkB;IAEV;IACA;IAFnB,YACmB,cAA8B,EAC9B,QAAgB;QADhB,mBAAc,GAAd,cAAc,CAAgB;QAC9B,aAAQ,GAAR,QAAQ,CAAQ;IAChC,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,OAAsB,EAAE,OAAwB;QAC5D,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAEjD,MAAM,eAAe,GAA2B;YAC9C,GAAG,OAAO;YACV,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,kBAAkB;YAC/B,SAAS,EAAE,OAAO,CAAC,EAAE;YACrB,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE;YACtC,OAAO,EAAE;gBACP,GAAG,OAAO,EAAE,OAAO;gBACnB,kBAAkB,EAAE,OAAO,CAAC,aAAa;gBACzC,gBAAgB,EAAE,OAAO,CAAC,WAAW;gBACrC,cAAc,EAAE,OAAO,CAAC,SAAS;aAClC;SACF,CAAC;QAEF,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC/B,IAAI,CAAC,QAAQ,EACb,UAAU,EACV;YACE,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,SAAS,EAAE,OAAO,CAAC,SAAS;SAC7B,EACD,eAAe,CAChB,CAAC;IACJ,CAAC;IAOO,eAAe,CAAC,OAAsB;QAC5C,OAAO,GAAG,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IACzD,CAAC;CACF;AA/CD,gDA+CC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./golevelup-publisher"), exports);
|
|
18
|
+
__exportStar(require("./microservices-publisher"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,4DAA0C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IMessagePublisher, OutboxMessage, PublishOptions } from '@prodforcode/event-forge-core';
|
|
2
|
+
export interface ClientProxy {
|
|
3
|
+
emit<TResult = unknown, TInput = unknown>(pattern: string, data: TInput): Promise<TResult> | TResult;
|
|
4
|
+
}
|
|
5
|
+
export declare class MicroservicesPublisher implements IMessagePublisher {
|
|
6
|
+
private readonly clientProxy;
|
|
7
|
+
constructor(clientProxy: ClientProxy);
|
|
8
|
+
publish(message: OutboxMessage, options?: PublishOptions): Promise<void>;
|
|
9
|
+
private buildPattern;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=microservices-publisher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"microservices-publisher.d.ts","sourceRoot":"","sources":["../src/microservices-publisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAMjG,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,EACtC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CAC/B;AAMD,qBAAa,sBAAuB,YAAW,iBAAiB;IAClD,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,WAAW;IAE/C,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA8B9E,OAAO,CAAC,YAAY;CAGrB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MicroservicesPublisher = void 0;
|
|
4
|
+
class MicroservicesPublisher {
|
|
5
|
+
clientProxy;
|
|
6
|
+
constructor(clientProxy) {
|
|
7
|
+
this.clientProxy = clientProxy;
|
|
8
|
+
}
|
|
9
|
+
async publish(message, options) {
|
|
10
|
+
const pattern = this.buildPattern(message);
|
|
11
|
+
const messageData = {
|
|
12
|
+
id: message.id,
|
|
13
|
+
aggregateType: message.aggregateType,
|
|
14
|
+
aggregateId: message.aggregateId,
|
|
15
|
+
eventType: message.eventType,
|
|
16
|
+
payload: message.payload,
|
|
17
|
+
metadata: {
|
|
18
|
+
...message.metadata,
|
|
19
|
+
...options?.headers,
|
|
20
|
+
messageId: message.id,
|
|
21
|
+
timestamp: message.createdAt.getTime(),
|
|
22
|
+
persistent: true,
|
|
23
|
+
contentType: 'application/json',
|
|
24
|
+
},
|
|
25
|
+
createdAt: message.createdAt,
|
|
26
|
+
};
|
|
27
|
+
await this.clientProxy.emit(pattern, messageData);
|
|
28
|
+
}
|
|
29
|
+
buildPattern(message) {
|
|
30
|
+
return message.eventType;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.MicroservicesPublisher = MicroservicesPublisher;
|
|
34
|
+
//# sourceMappingURL=microservices-publisher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"microservices-publisher.js","sourceRoot":"","sources":["../src/microservices-publisher.ts"],"names":[],"mappings":";;;AAiBA,MAAa,sBAAsB;IACJ;IAA7B,YAA6B,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAEzD,KAAK,CAAC,OAAO,CAAC,OAAsB,EAAE,OAAwB;QAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAE3C,MAAM,WAAW,GAAG;YAClB,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,QAAQ,EAAE;gBACR,GAAG,OAAO,CAAC,QAAQ;gBACnB,GAAG,OAAO,EAAE,OAAO;gBACnB,SAAS,EAAE,OAAO,CAAC,EAAE;gBACrB,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE;gBACtC,UAAU,EAAE,IAAI;gBAChB,WAAW,EAAE,kBAAkB;aAChC;YACD,SAAS,EAAE,OAAO,CAAC,SAAS;SAC7B,CAAC;QAEF,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IACpD,CAAC;IASO,YAAY,CAAC,OAAsB;QACzC,OAAO,OAAO,CAAC,SAAS,CAAC;IAC3B,CAAC;CACF;AApCD,wDAoCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prodforcode/event-forge-rabbitmq",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "RabbitMQ publishers for Universal Inbox-Outbox Pattern",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"author": "Event-Forge",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@prodforcode/event-forge-core": "1.0.
|
|
20
|
+
"@prodforcode/event-forge-core": "1.0.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/jest": "^29.5.11",
|