@quanticjs/events 2.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.
@@ -0,0 +1,13 @@
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 eventId: string;
10
+ readonly occurredAt: Date;
11
+ constructor(eventType: string, aggregateId: string, payload: DomainEventPayload, organizationId?: string | undefined);
12
+ get streamKey(): string;
13
+ }
@@ -0,0 +1,25 @@
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
+ eventId;
11
+ occurredAt;
12
+ constructor(eventType, aggregateId, payload, organizationId) {
13
+ this.eventType = eventType;
14
+ this.aggregateId = aggregateId;
15
+ this.payload = payload;
16
+ this.organizationId = organizationId;
17
+ this.eventId = (0, uuid_1.v4)();
18
+ this.occurredAt = new Date();
19
+ }
20
+ get streamKey() {
21
+ const category = this.eventType.split('.')[0];
22
+ return `arex:events:${category}s`;
23
+ }
24
+ }
25
+ exports.DomainEvent = DomainEvent;
@@ -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
+ streamKey: 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
+ streamKey;
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, "streamKey", 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 { RedisStreamPublisher } from './RedisStreamPublisher';
4
+ export declare class OutboxPublisherService implements OnModuleInit, OnModuleDestroy {
5
+ private readonly dataSource;
6
+ private readonly redisPublisher;
7
+ private readonly logger;
8
+ private timer;
9
+ private processing;
10
+ constructor(dataSource: DataSource, redisPublisher: RedisStreamPublisher);
11
+ onModuleInit(): void;
12
+ onModuleDestroy(): void;
13
+ private pollAndPublish;
14
+ }
@@ -0,0 +1,104 @@
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 OutboxPublisherService_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.OutboxPublisherService = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const typeorm_1 = require("typeorm");
16
+ const OutboxEvent_entity_1 = require("./OutboxEvent.entity");
17
+ const RedisStreamPublisher_1 = require("./RedisStreamPublisher");
18
+ const POLL_INTERVAL_MS = 100;
19
+ const BATCH_SIZE = 50;
20
+ const MAX_PUBLISH_ATTEMPTS = 5;
21
+ const DLQ_STREAM = 'arex:events:dlq';
22
+ let OutboxPublisherService = OutboxPublisherService_1 = class OutboxPublisherService {
23
+ dataSource;
24
+ redisPublisher;
25
+ logger = new common_1.Logger(OutboxPublisherService_1.name);
26
+ timer = null;
27
+ processing = false;
28
+ constructor(dataSource, redisPublisher) {
29
+ this.dataSource = dataSource;
30
+ this.redisPublisher = redisPublisher;
31
+ }
32
+ onModuleInit() {
33
+ this.timer = setInterval(() => this.pollAndPublish(), POLL_INTERVAL_MS);
34
+ this.logger.log(`Outbox publisher started (${POLL_INTERVAL_MS}ms poll interval)`);
35
+ }
36
+ onModuleDestroy() {
37
+ if (this.timer) {
38
+ clearInterval(this.timer);
39
+ this.timer = null;
40
+ }
41
+ this.logger.log('Outbox publisher stopped');
42
+ }
43
+ async pollAndPublish() {
44
+ if (this.processing)
45
+ return;
46
+ this.processing = true;
47
+ try {
48
+ const repo = this.dataSource.getRepository(OutboxEvent_entity_1.OutboxEvent);
49
+ const events = await repo.find({
50
+ where: { status: OutboxEvent_entity_1.OutboxEventStatus.Pending },
51
+ order: { createdAt: 'ASC' },
52
+ take: BATCH_SIZE,
53
+ });
54
+ for (const event of events) {
55
+ try {
56
+ await this.redisPublisher.publishToStream(event.streamKey, {
57
+ eventId: event.id,
58
+ eventType: event.eventType,
59
+ aggregateId: event.aggregateId,
60
+ organizationId: event.organizationId || '',
61
+ payload: JSON.stringify(event.payload),
62
+ occurredAt: event.createdAt.toISOString(),
63
+ });
64
+ event.status = OutboxEvent_entity_1.OutboxEventStatus.Published;
65
+ event.publishedAt = new Date();
66
+ await repo.save(event);
67
+ }
68
+ catch (error) {
69
+ event.publishAttempts += 1;
70
+ event.lastError = error.message;
71
+ if (event.publishAttempts >= MAX_PUBLISH_ATTEMPTS) {
72
+ event.status = OutboxEvent_entity_1.OutboxEventStatus.Failed;
73
+ this.logger.error(`Event ${event.id} exceeded max attempts, routing to DLQ`);
74
+ try {
75
+ await this.redisPublisher.publishToStream(DLQ_STREAM, {
76
+ eventId: event.id,
77
+ eventType: event.eventType,
78
+ aggregateId: event.aggregateId,
79
+ error: event.lastError || 'unknown',
80
+ payload: JSON.stringify(event.payload),
81
+ });
82
+ }
83
+ catch {
84
+ this.logger.error(`Failed to route event ${event.id} to DLQ`);
85
+ }
86
+ }
87
+ await repo.save(event);
88
+ }
89
+ }
90
+ }
91
+ catch (error) {
92
+ this.logger.error('Outbox poll cycle failed', error.stack);
93
+ }
94
+ finally {
95
+ this.processing = false;
96
+ }
97
+ }
98
+ };
99
+ exports.OutboxPublisherService = OutboxPublisherService;
100
+ exports.OutboxPublisherService = OutboxPublisherService = OutboxPublisherService_1 = __decorate([
101
+ (0, common_1.Injectable)(),
102
+ __metadata("design:paramtypes", [typeorm_1.DataSource,
103
+ RedisStreamPublisher_1.RedisStreamPublisher])
104
+ ], OutboxPublisherService);
@@ -0,0 +1,4 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ export declare class QuanticEventsModule {
3
+ static forRoot(): DynamicModule;
4
+ }
@@ -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 QuanticEventsModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.QuanticEventsModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const RedisStreamPublisher_1 = require("./RedisStreamPublisher");
13
+ const OutboxPublisherService_1 = require("./OutboxPublisherService");
14
+ let QuanticEventsModule = QuanticEventsModule_1 = class QuanticEventsModule {
15
+ static forRoot() {
16
+ return {
17
+ module: QuanticEventsModule_1,
18
+ providers: [
19
+ RedisStreamPublisher_1.RedisStreamPublisher,
20
+ OutboxPublisherService_1.OutboxPublisherService,
21
+ ],
22
+ exports: [
23
+ RedisStreamPublisher_1.RedisStreamPublisher,
24
+ OutboxPublisherService_1.OutboxPublisherService,
25
+ ],
26
+ };
27
+ }
28
+ };
29
+ exports.QuanticEventsModule = QuanticEventsModule;
30
+ exports.QuanticEventsModule = QuanticEventsModule = QuanticEventsModule_1 = __decorate([
31
+ (0, common_1.Global)(),
32
+ (0, common_1.Module)({})
33
+ ], QuanticEventsModule);
@@ -0,0 +1,18 @@
1
+ import { Logger, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
2
+ import type { Redis } from 'ioredis';
3
+ export declare abstract class RedisStreamConsumer implements OnModuleInit, OnModuleDestroy {
4
+ protected readonly redis?: Redis | undefined;
5
+ protected readonly logger: Logger;
6
+ abstract readonly streamKey: string;
7
+ abstract readonly consumerGroup: string;
8
+ abstract readonly consumerName: string;
9
+ protected shouldHandle(_fields: Record<string, string>): boolean;
10
+ abstract handleMessage(fields: Record<string, string>): Promise<void>;
11
+ private running;
12
+ private blockingClient?;
13
+ constructor(redis?: Redis | undefined);
14
+ onModuleInit(): Promise<void>;
15
+ onModuleDestroy(): Promise<void>;
16
+ private consumeLoop;
17
+ private readMessages;
18
+ }
@@ -0,0 +1,118 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.RedisStreamConsumer = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const core_1 = require("@quanticjs/core");
18
+ let RedisStreamConsumer = class RedisStreamConsumer {
19
+ redis;
20
+ logger = new common_1.Logger(this.constructor.name);
21
+ shouldHandle(_fields) {
22
+ return true;
23
+ }
24
+ running = false;
25
+ blockingClient;
26
+ constructor(redis) {
27
+ this.redis = redis;
28
+ }
29
+ async onModuleInit() {
30
+ if (!this.redis) {
31
+ this.logger.warn('Redis client not available — consumer disabled');
32
+ return;
33
+ }
34
+ this.blockingClient = this.redis.duplicate();
35
+ this.blockingClient.on('error', (err) => this.logger.error(`Blocking client error on ${this.streamKey}: ${err.message}`));
36
+ try {
37
+ await this.redis.xgroup('CREATE', this.streamKey, this.consumerGroup, '0', 'MKSTREAM');
38
+ this.logger.log(`Created consumer group "${this.consumerGroup}" on "${this.streamKey}"`);
39
+ }
40
+ catch (err) {
41
+ if (!err.message?.includes('BUSYGROUP')) {
42
+ throw err;
43
+ }
44
+ }
45
+ this.running = true;
46
+ void this.consumeLoop();
47
+ }
48
+ async onModuleDestroy() {
49
+ this.running = false;
50
+ if (this.blockingClient) {
51
+ this.blockingClient.disconnect();
52
+ this.blockingClient = undefined;
53
+ }
54
+ }
55
+ async consumeLoop() {
56
+ await this.readMessages('0');
57
+ while (this.running) {
58
+ await this.readMessages('>');
59
+ }
60
+ }
61
+ async readMessages(id) {
62
+ if (!this.redis || !this.blockingClient || !this.running)
63
+ return;
64
+ try {
65
+ const blockMs = id === '>' ? 5000 : undefined;
66
+ const args = [
67
+ 'GROUP',
68
+ this.consumerGroup,
69
+ this.consumerName,
70
+ 'COUNT',
71
+ '10',
72
+ ];
73
+ if (blockMs !== undefined) {
74
+ args.push('BLOCK', blockMs);
75
+ }
76
+ args.push('STREAMS', this.streamKey, id);
77
+ const results = await this.blockingClient.xreadgroup(...args);
78
+ if (!results || results.length === 0) {
79
+ if (id === '0')
80
+ return;
81
+ return;
82
+ }
83
+ const [, entries] = results[0];
84
+ if (entries.length === 0 && id === '0') {
85
+ return;
86
+ }
87
+ for (const [messageId, fieldArray] of entries) {
88
+ const fields = {};
89
+ for (let i = 0; i < fieldArray.length; i += 2) {
90
+ fields[fieldArray[i]] = fieldArray[i + 1];
91
+ }
92
+ if (!this.shouldHandle(fields)) {
93
+ await this.redis.xack(this.streamKey, this.consumerGroup, messageId);
94
+ continue;
95
+ }
96
+ try {
97
+ await this.handleMessage(fields);
98
+ await this.redis.xack(this.streamKey, this.consumerGroup, messageId);
99
+ }
100
+ catch (err) {
101
+ this.logger.error(`Failed to process message ${messageId} on ${this.streamKey}: ${err.message}`, err.stack);
102
+ }
103
+ }
104
+ }
105
+ catch (err) {
106
+ if (!this.running)
107
+ return;
108
+ this.logger.error(`Consumer read error on ${this.streamKey}: ${err.message}`, err.stack);
109
+ await new Promise((r) => setTimeout(r, 2000));
110
+ }
111
+ }
112
+ };
113
+ exports.RedisStreamConsumer = RedisStreamConsumer;
114
+ exports.RedisStreamConsumer = RedisStreamConsumer = __decorate([
115
+ __param(0, (0, common_1.Optional)()),
116
+ __param(0, (0, common_1.Inject)(core_1.REDIS_CLIENT)),
117
+ __metadata("design:paramtypes", [Function])
118
+ ], RedisStreamConsumer);
@@ -0,0 +1,9 @@
1
+ import type { Redis } from 'ioredis';
2
+ import { DomainEvent } from './DomainEvent';
3
+ export declare class RedisStreamPublisher {
4
+ private readonly redis?;
5
+ private readonly logger;
6
+ constructor(redis?: Redis | undefined);
7
+ publish(event: DomainEvent): Promise<void>;
8
+ publishToStream(streamKey: string, fields: Record<string, string>): Promise<string | null>;
9
+ }
@@ -0,0 +1,60 @@
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 RedisStreamPublisher_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.RedisStreamPublisher = void 0;
17
+ const common_1 = require("@nestjs/common");
18
+ const core_1 = require("@quanticjs/core");
19
+ const MAX_STREAM_LENGTH = 10000;
20
+ let RedisStreamPublisher = RedisStreamPublisher_1 = class RedisStreamPublisher {
21
+ redis;
22
+ logger = new common_1.Logger(RedisStreamPublisher_1.name);
23
+ constructor(redis) {
24
+ this.redis = redis;
25
+ }
26
+ async publish(event) {
27
+ if (!this.redis) {
28
+ this.logger.warn('Redis client not available, skipping event publish');
29
+ return;
30
+ }
31
+ await this.publishToStream(event.streamKey, {
32
+ eventId: event.eventId,
33
+ eventType: event.eventType,
34
+ aggregateId: event.aggregateId,
35
+ organizationId: event.organizationId || '',
36
+ payload: JSON.stringify(event.payload),
37
+ occurredAt: event.occurredAt.toISOString(),
38
+ });
39
+ }
40
+ async publishToStream(streamKey, fields) {
41
+ if (!this.redis)
42
+ return null;
43
+ try {
44
+ const messageId = await this.redis.xadd(streamKey, 'MAXLEN', '~', String(MAX_STREAM_LENGTH), '*', ...Object.entries(fields).flat());
45
+ this.logger.debug(`Published to ${streamKey}: ${messageId}`);
46
+ return messageId;
47
+ }
48
+ catch (error) {
49
+ this.logger.error(`Failed to publish to ${streamKey}`, error.stack);
50
+ throw error;
51
+ }
52
+ }
53
+ };
54
+ exports.RedisStreamPublisher = RedisStreamPublisher;
55
+ exports.RedisStreamPublisher = RedisStreamPublisher = RedisStreamPublisher_1 = __decorate([
56
+ (0, common_1.Injectable)(),
57
+ __param(0, (0, common_1.Optional)()),
58
+ __param(0, (0, common_1.Inject)(core_1.REDIS_CLIENT)),
59
+ __metadata("design:paramtypes", [Function])
60
+ ], RedisStreamPublisher);
@@ -0,0 +1,7 @@
1
+ export { DomainEvent } from './DomainEvent';
2
+ export type { DomainEventPayload } from './DomainEvent';
3
+ export { OutboxEvent, OutboxEventStatus } from './OutboxEvent.entity';
4
+ export { RedisStreamPublisher } from './RedisStreamPublisher';
5
+ export { RedisStreamConsumer } from './RedisStreamConsumer';
6
+ export { OutboxPublisherService } from './OutboxPublisherService';
7
+ export { QuanticEventsModule } from './QuanticEventsModule';
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuanticEventsModule = exports.OutboxPublisherService = exports.RedisStreamConsumer = exports.RedisStreamPublisher = 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 RedisStreamPublisher_1 = require("./RedisStreamPublisher");
10
+ Object.defineProperty(exports, "RedisStreamPublisher", { enumerable: true, get: function () { return RedisStreamPublisher_1.RedisStreamPublisher; } });
11
+ var RedisStreamConsumer_1 = require("./RedisStreamConsumer");
12
+ Object.defineProperty(exports, "RedisStreamConsumer", { enumerable: true, get: function () { return RedisStreamConsumer_1.RedisStreamConsumer; } });
13
+ var OutboxPublisherService_1 = require("./OutboxPublisherService");
14
+ Object.defineProperty(exports, "OutboxPublisherService", { enumerable: true, get: function () { return OutboxPublisherService_1.OutboxPublisherService; } });
15
+ var QuanticEventsModule_1 = require("./QuanticEventsModule");
16
+ Object.defineProperty(exports, "QuanticEventsModule", { enumerable: true, get: function () { return QuanticEventsModule_1.QuanticEventsModule; } });
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@quanticjs/events",
3
+ "version": "2.0.0",
4
+ "description": "Domain events for quanticjs — outbox pattern, Redis Streams pub/sub",
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": "^2.0.0",
22
+ "uuid": "^11.1.0"
23
+ },
24
+ "peerDependencies": {
25
+ "@nestjs/common": "^11.0.0",
26
+ "ioredis": "^5.0.0",
27
+ "typeorm": "^0.3.20"
28
+ }
29
+ }