@quanticjs/events-core 6.0.0
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/DomainEvent.d.ts +14 -0
- package/dist/DomainEvent.js +28 -0
- package/dist/IEventPublisher.d.ts +6 -0
- package/dist/IEventPublisher.js +4 -0
- package/dist/OutboxCleanupService.d.ts +7 -0
- package/dist/OutboxCleanupService.js +64 -0
- package/dist/OutboxEvent.entity.d.ts +18 -0
- package/dist/OutboxEvent.entity.js +87 -0
- package/dist/OutboxPublisherService.d.ts +14 -0
- package/dist/OutboxPublisherService.js +107 -0
- package/dist/QuanticEventsCoreModule.d.ts +4 -0
- package/dist/QuanticEventsCoreModule.js +33 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +18 -0
- package/dist/migrations/1717700000000-RenameStreamKeyToTopic.d.ts +6 -0
- package/dist/migrations/1717700000000-RenameStreamKeyToTopic.js +15 -0
- package/package.json +29 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface DomainEventPayload {
|
|
2
|
+
[key: string]: unknown;
|
|
3
|
+
}
|
|
4
|
+
export declare class DomainEvent {
|
|
5
|
+
readonly eventType: string;
|
|
6
|
+
readonly aggregateId: string;
|
|
7
|
+
readonly payload: DomainEventPayload;
|
|
8
|
+
readonly organizationId?: string | undefined;
|
|
9
|
+
readonly routingKey?: string | undefined;
|
|
10
|
+
readonly eventId: string;
|
|
11
|
+
readonly occurredAt: Date;
|
|
12
|
+
constructor(eventType: string, aggregateId: string, payload: DomainEventPayload, organizationId?: string | undefined, routingKey?: string | undefined);
|
|
13
|
+
get topic(): string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DomainEvent = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
class DomainEvent {
|
|
6
|
+
eventType;
|
|
7
|
+
aggregateId;
|
|
8
|
+
payload;
|
|
9
|
+
organizationId;
|
|
10
|
+
routingKey;
|
|
11
|
+
eventId;
|
|
12
|
+
occurredAt;
|
|
13
|
+
constructor(eventType, aggregateId, payload, organizationId, routingKey) {
|
|
14
|
+
this.eventType = eventType;
|
|
15
|
+
this.aggregateId = aggregateId;
|
|
16
|
+
this.payload = payload;
|
|
17
|
+
this.organizationId = organizationId;
|
|
18
|
+
this.routingKey = routingKey;
|
|
19
|
+
this.eventId = (0, uuid_1.v4)();
|
|
20
|
+
this.occurredAt = new Date();
|
|
21
|
+
}
|
|
22
|
+
get topic() {
|
|
23
|
+
const category = this.eventType.split('.')[0];
|
|
24
|
+
const base = `arex.events.${category}s`;
|
|
25
|
+
return this.routingKey ? `${base}.${this.routingKey}` : base;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.DomainEvent = DomainEvent;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DomainEvent } from './DomainEvent';
|
|
2
|
+
export interface IEventPublisher {
|
|
3
|
+
publish(event: DomainEvent): Promise<void>;
|
|
4
|
+
publishToDestination(destination: string, fields: Record<string, string>): Promise<string | null>;
|
|
5
|
+
}
|
|
6
|
+
export declare const EVENT_PUBLISHER: unique symbol;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var OutboxCleanupService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.OutboxCleanupService = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const schedule_1 = require("@nestjs/schedule");
|
|
16
|
+
const typeorm_1 = require("typeorm");
|
|
17
|
+
const OutboxEvent_entity_1 = require("./OutboxEvent.entity");
|
|
18
|
+
const BATCH_SIZE = 1000;
|
|
19
|
+
const BATCH_PAUSE_MS = 100;
|
|
20
|
+
const RETENTION_DAYS = 7;
|
|
21
|
+
let OutboxCleanupService = OutboxCleanupService_1 = class OutboxCleanupService {
|
|
22
|
+
dataSource;
|
|
23
|
+
logger = new common_1.Logger(OutboxCleanupService_1.name);
|
|
24
|
+
constructor(dataSource) {
|
|
25
|
+
this.dataSource = dataSource;
|
|
26
|
+
}
|
|
27
|
+
async cleanup() {
|
|
28
|
+
const repo = this.dataSource.getRepository(OutboxEvent_entity_1.OutboxEvent);
|
|
29
|
+
const cutoff = new Date();
|
|
30
|
+
cutoff.setDate(cutoff.getDate() - RETENTION_DAYS);
|
|
31
|
+
let totalDeleted = 0;
|
|
32
|
+
// eslint-disable-next-line no-constant-condition
|
|
33
|
+
while (true) {
|
|
34
|
+
const batch = await repo.find({
|
|
35
|
+
where: {
|
|
36
|
+
status: OutboxEvent_entity_1.OutboxEventStatus.Published,
|
|
37
|
+
publishedAt: (0, typeorm_1.LessThan)(cutoff),
|
|
38
|
+
},
|
|
39
|
+
take: BATCH_SIZE,
|
|
40
|
+
});
|
|
41
|
+
if (batch.length === 0)
|
|
42
|
+
break;
|
|
43
|
+
await repo.remove(batch);
|
|
44
|
+
totalDeleted += batch.length;
|
|
45
|
+
if (batch.length < BATCH_SIZE)
|
|
46
|
+
break;
|
|
47
|
+
await new Promise((resolve) => setTimeout(resolve, BATCH_PAUSE_MS));
|
|
48
|
+
}
|
|
49
|
+
if (totalDeleted > 0) {
|
|
50
|
+
this.logger.log(`Cleaned up ${totalDeleted} published outbox events`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.OutboxCleanupService = OutboxCleanupService;
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, schedule_1.Cron)('0 3 * * *'),
|
|
57
|
+
__metadata("design:type", Function),
|
|
58
|
+
__metadata("design:paramtypes", []),
|
|
59
|
+
__metadata("design:returntype", Promise)
|
|
60
|
+
], OutboxCleanupService.prototype, "cleanup", null);
|
|
61
|
+
exports.OutboxCleanupService = OutboxCleanupService = OutboxCleanupService_1 = __decorate([
|
|
62
|
+
(0, common_1.Injectable)(),
|
|
63
|
+
__metadata("design:paramtypes", [typeorm_1.DataSource])
|
|
64
|
+
], OutboxCleanupService);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare enum OutboxEventStatus {
|
|
2
|
+
Pending = "Pending",
|
|
3
|
+
Published = "Published",
|
|
4
|
+
Failed = "Failed"
|
|
5
|
+
}
|
|
6
|
+
export declare class OutboxEvent {
|
|
7
|
+
id: string;
|
|
8
|
+
eventType: string;
|
|
9
|
+
aggregateId: string;
|
|
10
|
+
topic: string;
|
|
11
|
+
payload: Record<string, unknown>;
|
|
12
|
+
organizationId: string | null;
|
|
13
|
+
status: OutboxEventStatus;
|
|
14
|
+
publishAttempts: number;
|
|
15
|
+
lastError: string | null;
|
|
16
|
+
createdAt: Date;
|
|
17
|
+
publishedAt: Date | null;
|
|
18
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.OutboxEvent = exports.OutboxEventStatus = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
var OutboxEventStatus;
|
|
15
|
+
(function (OutboxEventStatus) {
|
|
16
|
+
OutboxEventStatus["Pending"] = "Pending";
|
|
17
|
+
OutboxEventStatus["Published"] = "Published";
|
|
18
|
+
OutboxEventStatus["Failed"] = "Failed";
|
|
19
|
+
})(OutboxEventStatus || (exports.OutboxEventStatus = OutboxEventStatus = {}));
|
|
20
|
+
let OutboxEvent = class OutboxEvent {
|
|
21
|
+
id;
|
|
22
|
+
eventType;
|
|
23
|
+
aggregateId;
|
|
24
|
+
topic;
|
|
25
|
+
payload;
|
|
26
|
+
organizationId;
|
|
27
|
+
status;
|
|
28
|
+
publishAttempts;
|
|
29
|
+
lastError;
|
|
30
|
+
createdAt;
|
|
31
|
+
publishedAt;
|
|
32
|
+
};
|
|
33
|
+
exports.OutboxEvent = OutboxEvent;
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], OutboxEvent.prototype, "id", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ type: 'varchar' }),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], OutboxEvent.prototype, "eventType", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.Column)({ type: 'varchar' }),
|
|
44
|
+
__metadata("design:type", String)
|
|
45
|
+
], OutboxEvent.prototype, "aggregateId", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, typeorm_1.Column)({ type: 'varchar' }),
|
|
48
|
+
__metadata("design:type", String)
|
|
49
|
+
], OutboxEvent.prototype, "topic", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, typeorm_1.Column)({ type: 'jsonb' }),
|
|
52
|
+
__metadata("design:type", Object)
|
|
53
|
+
], OutboxEvent.prototype, "payload", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, typeorm_1.Column)({ type: 'uuid', nullable: true }),
|
|
56
|
+
__metadata("design:type", Object)
|
|
57
|
+
], OutboxEvent.prototype, "organizationId", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, typeorm_1.Column)({
|
|
60
|
+
type: 'enum',
|
|
61
|
+
enum: OutboxEventStatus,
|
|
62
|
+
default: OutboxEventStatus.Pending,
|
|
63
|
+
}),
|
|
64
|
+
__metadata("design:type", String)
|
|
65
|
+
], OutboxEvent.prototype, "status", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, typeorm_1.Column)({ type: 'int', default: 0 }),
|
|
68
|
+
__metadata("design:type", Number)
|
|
69
|
+
], OutboxEvent.prototype, "publishAttempts", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
|
|
72
|
+
__metadata("design:type", Object)
|
|
73
|
+
], OutboxEvent.prototype, "lastError", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, typeorm_1.CreateDateColumn)({ type: 'timestamptz' }),
|
|
76
|
+
__metadata("design:type", Date)
|
|
77
|
+
], OutboxEvent.prototype, "createdAt", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, typeorm_1.Column)({ type: 'timestamptz', nullable: true }),
|
|
80
|
+
__metadata("design:type", Object)
|
|
81
|
+
], OutboxEvent.prototype, "publishedAt", void 0);
|
|
82
|
+
exports.OutboxEvent = OutboxEvent = __decorate([
|
|
83
|
+
(0, typeorm_1.Entity)('outbox_events'),
|
|
84
|
+
(0, typeorm_1.Index)('idx_outbox_pending', ['status', 'createdAt'], {
|
|
85
|
+
where: `"status" = 'Pending'`,
|
|
86
|
+
})
|
|
87
|
+
], OutboxEvent);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
|
2
|
+
import { DataSource } from 'typeorm';
|
|
3
|
+
import { IEventPublisher } from './IEventPublisher';
|
|
4
|
+
export declare class OutboxPublisherService implements OnModuleInit, OnModuleDestroy {
|
|
5
|
+
private readonly dataSource;
|
|
6
|
+
private readonly publisher;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
private timer;
|
|
9
|
+
private processing;
|
|
10
|
+
constructor(dataSource: DataSource, publisher: IEventPublisher);
|
|
11
|
+
onModuleInit(): void;
|
|
12
|
+
onModuleDestroy(): void;
|
|
13
|
+
private pollAndPublish;
|
|
14
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var OutboxPublisherService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.OutboxPublisherService = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const typeorm_1 = require("typeorm");
|
|
19
|
+
const OutboxEvent_entity_1 = require("./OutboxEvent.entity");
|
|
20
|
+
const IEventPublisher_1 = require("./IEventPublisher");
|
|
21
|
+
const POLL_INTERVAL_MS = 100;
|
|
22
|
+
const BATCH_SIZE = 50;
|
|
23
|
+
const MAX_PUBLISH_ATTEMPTS = 5;
|
|
24
|
+
const DLQ_DESTINATION = 'arex.events.dlq';
|
|
25
|
+
let OutboxPublisherService = OutboxPublisherService_1 = class OutboxPublisherService {
|
|
26
|
+
dataSource;
|
|
27
|
+
publisher;
|
|
28
|
+
logger = new common_1.Logger(OutboxPublisherService_1.name);
|
|
29
|
+
timer = null;
|
|
30
|
+
processing = false;
|
|
31
|
+
constructor(dataSource, publisher) {
|
|
32
|
+
this.dataSource = dataSource;
|
|
33
|
+
this.publisher = publisher;
|
|
34
|
+
}
|
|
35
|
+
onModuleInit() {
|
|
36
|
+
this.timer = setInterval(() => this.pollAndPublish(), POLL_INTERVAL_MS);
|
|
37
|
+
this.logger.log(`Outbox publisher started (${POLL_INTERVAL_MS}ms poll interval)`);
|
|
38
|
+
}
|
|
39
|
+
onModuleDestroy() {
|
|
40
|
+
if (this.timer) {
|
|
41
|
+
clearInterval(this.timer);
|
|
42
|
+
this.timer = null;
|
|
43
|
+
}
|
|
44
|
+
this.logger.log('Outbox publisher stopped');
|
|
45
|
+
}
|
|
46
|
+
async pollAndPublish() {
|
|
47
|
+
if (this.processing)
|
|
48
|
+
return;
|
|
49
|
+
this.processing = true;
|
|
50
|
+
try {
|
|
51
|
+
const repo = this.dataSource.getRepository(OutboxEvent_entity_1.OutboxEvent);
|
|
52
|
+
const events = await repo.find({
|
|
53
|
+
where: { status: OutboxEvent_entity_1.OutboxEventStatus.Pending },
|
|
54
|
+
order: { createdAt: 'ASC' },
|
|
55
|
+
take: BATCH_SIZE,
|
|
56
|
+
});
|
|
57
|
+
for (const event of events) {
|
|
58
|
+
try {
|
|
59
|
+
await this.publisher.publishToDestination(event.topic, {
|
|
60
|
+
eventId: event.id,
|
|
61
|
+
eventType: event.eventType,
|
|
62
|
+
aggregateId: event.aggregateId,
|
|
63
|
+
organizationId: event.organizationId || '',
|
|
64
|
+
payload: JSON.stringify(event.payload),
|
|
65
|
+
occurredAt: event.createdAt.toISOString(),
|
|
66
|
+
});
|
|
67
|
+
event.status = OutboxEvent_entity_1.OutboxEventStatus.Published;
|
|
68
|
+
event.publishedAt = new Date();
|
|
69
|
+
await repo.save(event);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
event.publishAttempts += 1;
|
|
73
|
+
event.lastError = error.message;
|
|
74
|
+
if (event.publishAttempts >= MAX_PUBLISH_ATTEMPTS) {
|
|
75
|
+
event.status = OutboxEvent_entity_1.OutboxEventStatus.Failed;
|
|
76
|
+
this.logger.error(`Event ${event.id} exceeded max attempts, routing to DLQ`);
|
|
77
|
+
try {
|
|
78
|
+
await this.publisher.publishToDestination(DLQ_DESTINATION, {
|
|
79
|
+
eventId: event.id,
|
|
80
|
+
eventType: event.eventType,
|
|
81
|
+
aggregateId: event.aggregateId,
|
|
82
|
+
error: event.lastError || 'unknown',
|
|
83
|
+
payload: JSON.stringify(event.payload),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
this.logger.error(`Failed to route event ${event.id} to DLQ`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
await repo.save(event);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
this.logger.error('Outbox poll cycle failed', error.stack);
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
this.processing = false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
exports.OutboxPublisherService = OutboxPublisherService;
|
|
103
|
+
exports.OutboxPublisherService = OutboxPublisherService = OutboxPublisherService_1 = __decorate([
|
|
104
|
+
(0, common_1.Injectable)(),
|
|
105
|
+
__param(1, (0, common_1.Inject)(IEventPublisher_1.EVENT_PUBLISHER)),
|
|
106
|
+
__metadata("design:paramtypes", [typeorm_1.DataSource, Object])
|
|
107
|
+
], OutboxPublisherService);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var QuanticEventsCoreModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.QuanticEventsCoreModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const OutboxPublisherService_1 = require("./OutboxPublisherService");
|
|
13
|
+
const OutboxCleanupService_1 = require("./OutboxCleanupService");
|
|
14
|
+
let QuanticEventsCoreModule = QuanticEventsCoreModule_1 = class QuanticEventsCoreModule {
|
|
15
|
+
static forRoot() {
|
|
16
|
+
return {
|
|
17
|
+
module: QuanticEventsCoreModule_1,
|
|
18
|
+
providers: [
|
|
19
|
+
OutboxPublisherService_1.OutboxPublisherService,
|
|
20
|
+
OutboxCleanupService_1.OutboxCleanupService,
|
|
21
|
+
],
|
|
22
|
+
exports: [
|
|
23
|
+
OutboxPublisherService_1.OutboxPublisherService,
|
|
24
|
+
OutboxCleanupService_1.OutboxCleanupService,
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.QuanticEventsCoreModule = QuanticEventsCoreModule;
|
|
30
|
+
exports.QuanticEventsCoreModule = QuanticEventsCoreModule = QuanticEventsCoreModule_1 = __decorate([
|
|
31
|
+
(0, common_1.Global)(),
|
|
32
|
+
(0, common_1.Module)({})
|
|
33
|
+
], QuanticEventsCoreModule);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { DomainEvent } from './DomainEvent';
|
|
2
|
+
export type { DomainEventPayload } from './DomainEvent';
|
|
3
|
+
export { OutboxEvent, OutboxEventStatus } from './OutboxEvent.entity';
|
|
4
|
+
export { IEventPublisher, EVENT_PUBLISHER } from './IEventPublisher';
|
|
5
|
+
export { OutboxPublisherService } from './OutboxPublisherService';
|
|
6
|
+
export { OutboxCleanupService } from './OutboxCleanupService';
|
|
7
|
+
export { QuanticEventsCoreModule } from './QuanticEventsCoreModule';
|
|
8
|
+
export { RenameStreamKeyToTopic1717700000000 } from './migrations/1717700000000-RenameStreamKeyToTopic';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RenameStreamKeyToTopic1717700000000 = exports.QuanticEventsCoreModule = exports.OutboxCleanupService = exports.OutboxPublisherService = exports.EVENT_PUBLISHER = exports.OutboxEventStatus = exports.OutboxEvent = exports.DomainEvent = void 0;
|
|
4
|
+
var DomainEvent_1 = require("./DomainEvent");
|
|
5
|
+
Object.defineProperty(exports, "DomainEvent", { enumerable: true, get: function () { return DomainEvent_1.DomainEvent; } });
|
|
6
|
+
var OutboxEvent_entity_1 = require("./OutboxEvent.entity");
|
|
7
|
+
Object.defineProperty(exports, "OutboxEvent", { enumerable: true, get: function () { return OutboxEvent_entity_1.OutboxEvent; } });
|
|
8
|
+
Object.defineProperty(exports, "OutboxEventStatus", { enumerable: true, get: function () { return OutboxEvent_entity_1.OutboxEventStatus; } });
|
|
9
|
+
var IEventPublisher_1 = require("./IEventPublisher");
|
|
10
|
+
Object.defineProperty(exports, "EVENT_PUBLISHER", { enumerable: true, get: function () { return IEventPublisher_1.EVENT_PUBLISHER; } });
|
|
11
|
+
var OutboxPublisherService_1 = require("./OutboxPublisherService");
|
|
12
|
+
Object.defineProperty(exports, "OutboxPublisherService", { enumerable: true, get: function () { return OutboxPublisherService_1.OutboxPublisherService; } });
|
|
13
|
+
var OutboxCleanupService_1 = require("./OutboxCleanupService");
|
|
14
|
+
Object.defineProperty(exports, "OutboxCleanupService", { enumerable: true, get: function () { return OutboxCleanupService_1.OutboxCleanupService; } });
|
|
15
|
+
var QuanticEventsCoreModule_1 = require("./QuanticEventsCoreModule");
|
|
16
|
+
Object.defineProperty(exports, "QuanticEventsCoreModule", { enumerable: true, get: function () { return QuanticEventsCoreModule_1.QuanticEventsCoreModule; } });
|
|
17
|
+
var _1717700000000_RenameStreamKeyToTopic_1 = require("./migrations/1717700000000-RenameStreamKeyToTopic");
|
|
18
|
+
Object.defineProperty(exports, "RenameStreamKeyToTopic1717700000000", { enumerable: true, get: function () { return _1717700000000_RenameStreamKeyToTopic_1.RenameStreamKeyToTopic1717700000000; } });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RenameStreamKeyToTopic1717700000000 = void 0;
|
|
4
|
+
class RenameStreamKeyToTopic1717700000000 {
|
|
5
|
+
name = 'RenameStreamKeyToTopic1717700000000';
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`ALTER TABLE outbox_events RENAME COLUMN stream_key TO topic`);
|
|
8
|
+
await queryRunner.query(`UPDATE outbox_events SET topic = REPLACE(topic, ':', '.')`);
|
|
9
|
+
}
|
|
10
|
+
async down(queryRunner) {
|
|
11
|
+
await queryRunner.query(`UPDATE outbox_events SET topic = REPLACE(topic, '.', ':')`);
|
|
12
|
+
await queryRunner.query(`ALTER TABLE outbox_events RENAME COLUMN topic TO stream_key`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.RenameStreamKeyToTopic1717700000000 = RenameStreamKeyToTopic1717700000000;
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@quanticjs/events-core",
|
|
3
|
+
"version": "6.0.0",
|
|
4
|
+
"description": "Transport-agnostic domain event abstractions — DomainEvent, OutboxEvent, IEventPublisher, outbox services",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"registry": "https://registry.npmjs.org",
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc -p tsconfig.json",
|
|
17
|
+
"test": "jest --passWithNoTests",
|
|
18
|
+
"clean": "rm -rf dist"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@quanticjs/core": "^6.0.0",
|
|
22
|
+
"uuid": "^11.1.0"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@nestjs/common": "^11.0.0",
|
|
26
|
+
"@nestjs/schedule": "^5.0.0",
|
|
27
|
+
"typeorm": "^0.3.20"
|
|
28
|
+
}
|
|
29
|
+
}
|