wsp-ms-core 1.0.57 → 1.0.58

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.ts CHANGED
@@ -88,13 +88,53 @@ declare abstract class DomainError extends Error {
88
88
  protected constructor(type: string, message?: string);
89
89
  }
90
90
 
91
- declare abstract class DomainEvent<T = unknown> {
92
- readonly type: string;
93
- private readonly _occurredAt;
91
+ declare class DomainEventStatus extends ValueObject<string> {
92
+ static readonly SUPPORTED: readonly string[];
93
+ static readonly PENDING: DomainEventStatus;
94
+ static readonly PROCESSING: DomainEventStatus;
95
+ static readonly PROCESSED: DomainEventStatus;
96
+ static readonly FAILED: DomainEventStatus;
97
+ static readonly DEAD: DomainEventStatus;
98
+ private constructor();
99
+ protected validate(value: string): void;
100
+ toPrimitives(): Record<string, unknown>;
101
+ static create(status: string): DomainEventStatus;
102
+ }
103
+
104
+ declare class DomainEvent {
105
+ private readonly _eventUuid;
106
+ private readonly _tenantUuid;
107
+ private readonly _aggregateUuid;
108
+ private readonly _aggregateType;
109
+ private readonly _eventType;
110
+ private readonly _topic;
94
111
  private readonly _payload;
95
- protected constructor(payload: T);
96
- get payload(): T;
97
- get occurredAt(): DateTime;
112
+ private _status;
113
+ private _attempts;
114
+ private _errorMessage;
115
+ private _publishedAt;
116
+ private _lastAttempt;
117
+ private readonly _createdAt;
118
+ protected constructor(eventUuid: UUID, tenantUuid: UUID, aggregateUuid: UUID, aggregateType: string, eventType: string, topic: string, payload: string, status: DomainEventStatus, attempts: number, errorMessage: string | undefined, publishedAt: DateTime | undefined, lastAttempt: DateTime | undefined, createdAt: DateTime);
119
+ get eventUuid(): UUID;
120
+ get tenantUuid(): UUID;
121
+ get aggregateUuid(): UUID;
122
+ get aggregateType(): string;
123
+ get eventType(): string;
124
+ get topic(): string;
125
+ get payload(): string;
126
+ get status(): DomainEventStatus;
127
+ get attempts(): number;
128
+ get errorMessage(): string | undefined;
129
+ get publishedAt(): DateTime | undefined;
130
+ get lastAttempt(): DateTime | undefined;
131
+ get createdAt(): DateTime;
132
+ incrementAttempts(): void;
133
+ markProcessed(): void;
134
+ markProcessing(): void;
135
+ markWithError(error: string): void;
136
+ toPrimitives(): Record<string, unknown>;
137
+ static reconstitute(data: Record<string, any>): DomainEvent;
98
138
  }
99
139
 
100
140
  declare abstract class BaseObject<T = unknown> {
@@ -186,6 +226,29 @@ declare class Language extends ValueObject<string> {
186
226
  static create(raw: string): Language;
187
227
  }
188
228
 
229
+ interface PriceProps {
230
+ amount: number;
231
+ currency: Currency;
232
+ }
233
+ declare class Price extends ValueObject<PriceProps> {
234
+ static readonly MIN_AMOUNT: number;
235
+ static readonly MAX_AMOUNT: number;
236
+ private constructor();
237
+ protected validate(props: {
238
+ amount: number;
239
+ currency: Currency;
240
+ }): void;
241
+ get amount(): number;
242
+ get currency(): Currency;
243
+ equals(other?: Price | null): boolean;
244
+ private assertSameCurrency;
245
+ add(other: Price): Price;
246
+ subtract(other: Price): Price;
247
+ toPrimitives(): Record<string, unknown>;
248
+ static create(amount: number, currency: Currency | string | number): Price;
249
+ static createFromPrimitives(data: Record<string, unknown>): Price;
250
+ }
251
+
189
252
  declare class PaymentGateway extends ValueObject<string> {
190
253
  static readonly SUPPORTED: readonly string[];
191
254
  private static readonly EXTERNALS;
@@ -225,38 +288,17 @@ declare class PaymentStatus extends ValueObject<string> {
225
288
  static create(gateway: string): PaymentStatus;
226
289
  }
227
290
 
228
- interface PriceProps {
229
- amount: number;
230
- currency: Currency;
231
- }
232
- declare class Price extends ValueObject<PriceProps> {
233
- static readonly MIN_AMOUNT: number;
234
- static readonly MAX_AMOUNT: number;
235
- private constructor();
236
- protected validate(props: {
237
- amount: number;
238
- currency: Currency;
239
- }): void;
240
- get amount(): number;
241
- get currency(): Currency;
242
- equals(other?: Price | null): boolean;
243
- private assertSameCurrency;
244
- add(other: Price): Price;
245
- subtract(other: Price): Price;
246
- toPrimitives(): Record<string, unknown>;
247
- static create(amount: number, currency: Currency | string | number): Price;
248
- static createFromPrimitives(data: Record<string, unknown>): Price;
291
+ interface EventBusRepository {
292
+ create(event: DomainEvent): Promise<void>;
293
+ update(event: DomainEvent): Promise<void>;
294
+ listPending(limit: number): Promise<DomainEvent[]>;
249
295
  }
250
296
 
251
- interface EventBus {
297
+ declare class EventBus {
298
+ private readonly repository;
299
+ constructor(repository: EventBusRepository);
252
300
  publish(event: DomainEvent): Promise<void>;
253
- }
254
-
255
- interface EventBusRepository {
256
- save(event: DomainEvent): Promise<void>;
257
- listPending(limit: number): Promise<DomainEvent[]>;
258
- markProcessed(id: number): Promise<void>;
259
- incrementRetries(id: number): Promise<void>;
301
+ publishMany(events: DomainEvent[]): Promise<void>;
260
302
  }
261
303
 
262
304
  interface DatabaseConnection<Q = string, Params = unknown[], Row = Record<string, unknown>> {
@@ -399,4 +441,4 @@ declare class ExchangeRates extends BaseObject<ExchangeRatesProps> {
399
441
  static createFromPrimitives(data: any): ExchangeRates;
400
442
  }
401
443
 
402
- export { BaseEntity, BaseObject, BasicUnitOfWork, BasicUnitOfWorkFactory, Currency, DatabaseConnection, DatabaseConnector, DateTime, DomainEntity, DomainError, DomainEvent, Email, ErrorManager, ErrorManagerHandleResult, ErrorTemplate, EventBus, EventBusRepository, ExchangeRates, FatalError, HttpController, HttpHealthCheckController, HttpNotFoundController, HttpRequest, HttpResponse, InternalError, Language, Logger, MysqlConnection, MysqlConnector, PaymentGateway, PaymentStatus, Price, UUID, UnitOfWork, UploadedFile, UsageError, ValueObject, adaptExpressErrorHandler, adaptExpressRoute };
444
+ export { BaseEntity, BaseObject, BasicUnitOfWork, BasicUnitOfWorkFactory, Currency, DatabaseConnection, DatabaseConnector, DateTime, DomainEntity, DomainError, DomainEvent, DomainEventStatus, Email, ErrorManager, ErrorManagerHandleResult, ErrorTemplate, EventBus, EventBusRepository, ExchangeRates, FatalError, HttpController, HttpHealthCheckController, HttpNotFoundController, HttpRequest, HttpResponse, InternalError, Language, Logger, MysqlConnection, MysqlConnector, PaymentGateway, PaymentStatus, Price, UUID, UnitOfWork, UploadedFile, UsageError, ValueObject, adaptExpressErrorHandler, adaptExpressRoute };
package/dist/index.js CHANGED
@@ -163,17 +163,186 @@ var DomainError = class extends Error {
163
163
  }
164
164
  };
165
165
 
166
+ // src/domain/errors/InternalError.ts
167
+ var InternalError = class extends DomainError {
168
+ constructor(type, message = "") {
169
+ super(type, message);
170
+ }
171
+ };
172
+
173
+ // src/domain/value-objects/UUID.ts
174
+ import * as crypto from "crypto";
175
+ var _UUID = class _UUID extends ValueObject {
176
+ constructor(value) {
177
+ super(value);
178
+ }
179
+ validate(uuid) {
180
+ if (!_UUID.isValid(uuid)) {
181
+ throw new InternalError(`Invalid uuid <${uuid}>`);
182
+ }
183
+ }
184
+ toPrimitives() {
185
+ return { value: this.value };
186
+ }
187
+ static create(uuid) {
188
+ return new _UUID(uuid != null ? uuid : crypto.randomUUID());
189
+ }
190
+ static version(uuid) {
191
+ const m = /^[0-9a-f]{8}-[0-9a-f]{4}-([1-8])[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.exec(uuid);
192
+ return m ? Number(m[1]) : void 0;
193
+ }
194
+ static isNil(uuid) {
195
+ return /^0{8}-0{4}-0{4}-0{4}-0{12}$/i.test(uuid);
196
+ }
197
+ static isRFCStyle(uuid) {
198
+ return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(uuid);
199
+ }
200
+ static isValid(uuid, opts = {}) {
201
+ var _a, _b;
202
+ const allowed = (_a = opts.allowedVersions) != null ? _a : [1, 2, 3, 4, 5, 6, 7, 8];
203
+ const allowNil = (_b = opts.allowNil) != null ? _b : false;
204
+ if (allowNil && _UUID.isNil(uuid))
205
+ return true;
206
+ if (!_UUID.isRFCStyle(uuid))
207
+ return false;
208
+ const v = _UUID.version(uuid);
209
+ return !!v && allowed.includes(v);
210
+ }
211
+ };
212
+ _UUID.NIL = "00000000-0000-0000-0000-000000000000";
213
+ var UUID = _UUID;
214
+
215
+ // src/domain/value-objects/DomainEventStatus.ts
216
+ var _DomainEventStatus = class _DomainEventStatus extends ValueObject {
217
+ constructor(status) {
218
+ super(status.trim().toUpperCase());
219
+ }
220
+ validate(value) {
221
+ if (!_DomainEventStatus.SUPPORTED.includes(value)) {
222
+ throw new InternalError(`Domain event status <${value}> is not supported`);
223
+ }
224
+ }
225
+ toPrimitives() {
226
+ return void 0;
227
+ }
228
+ static create(status) {
229
+ return new _DomainEventStatus(status);
230
+ }
231
+ };
232
+ _DomainEventStatus.SUPPORTED = ["PENDING", "PROCESSING", "PROCESSED", "FAILED", "DEAD"];
233
+ _DomainEventStatus.PENDING = new _DomainEventStatus("PENDING");
234
+ _DomainEventStatus.PROCESSING = new _DomainEventStatus("PROCESSING");
235
+ _DomainEventStatus.PROCESSED = new _DomainEventStatus("PROCESSED");
236
+ _DomainEventStatus.FAILED = new _DomainEventStatus("FAILED");
237
+ _DomainEventStatus.DEAD = new _DomainEventStatus("DEAD");
238
+ var DomainEventStatus = _DomainEventStatus;
239
+
166
240
  // src/domain/contracts/DomainEvent.ts
167
- var DomainEvent = class {
168
- constructor(payload) {
241
+ var DomainEvent = class _DomainEvent {
242
+ constructor(eventUuid, tenantUuid, aggregateUuid, aggregateType, eventType, topic, payload, status, attempts, errorMessage, publishedAt, lastAttempt, createdAt) {
243
+ this._eventUuid = eventUuid;
244
+ this._tenantUuid = tenantUuid;
245
+ this._aggregateUuid = aggregateUuid;
246
+ this._aggregateType = aggregateType;
247
+ this._eventType = eventType;
248
+ this._topic = topic;
169
249
  this._payload = payload;
170
- this._occurredAt = DateTime.create();
250
+ this._status = status;
251
+ this._attempts = 0;
252
+ this._errorMessage = errorMessage;
253
+ this._publishedAt = publishedAt;
254
+ this._lastAttempt = lastAttempt;
255
+ this._createdAt = createdAt;
256
+ }
257
+ get eventUuid() {
258
+ return this._eventUuid;
259
+ }
260
+ get tenantUuid() {
261
+ return this._tenantUuid;
262
+ }
263
+ get aggregateUuid() {
264
+ return this._aggregateUuid;
265
+ }
266
+ get aggregateType() {
267
+ return this._aggregateType;
268
+ }
269
+ get eventType() {
270
+ return this._eventType;
271
+ }
272
+ get topic() {
273
+ return this._topic;
171
274
  }
172
275
  get payload() {
173
276
  return this._payload;
174
277
  }
175
- get occurredAt() {
176
- return this._occurredAt;
278
+ get status() {
279
+ return this._status;
280
+ }
281
+ get attempts() {
282
+ return this._attempts;
283
+ }
284
+ get errorMessage() {
285
+ return this._errorMessage;
286
+ }
287
+ get publishedAt() {
288
+ return this._publishedAt;
289
+ }
290
+ get lastAttempt() {
291
+ return this._lastAttempt;
292
+ }
293
+ get createdAt() {
294
+ return this._createdAt;
295
+ }
296
+ incrementAttempts() {
297
+ this._attempts++;
298
+ this._lastAttempt = DateTime.now();
299
+ }
300
+ markProcessed() {
301
+ this._status = DomainEventStatus.PROCESSED;
302
+ this._publishedAt = DateTime.now();
303
+ }
304
+ markProcessing() {
305
+ this._status = DomainEventStatus.PROCESSING;
306
+ }
307
+ markWithError(error) {
308
+ this._status = DomainEventStatus.FAILED;
309
+ this._errorMessage = error;
310
+ }
311
+ toPrimitives() {
312
+ var _a, _b, _c, _d, _e;
313
+ return {
314
+ eventUuid: this.eventUuid.value,
315
+ tenantUuid: this.tenantUuid.value,
316
+ aggregateUuid: this.aggregateUuid.value,
317
+ aggregateType: this.aggregateType,
318
+ eventType: this.eventType,
319
+ topic: this.topic,
320
+ payload: this.payload,
321
+ status: this.status.value,
322
+ attempts: this.attempts,
323
+ errorMessage: (_a = this.errorMessage) != null ? _a : void 0,
324
+ publishedAt: (_c = (_b = this.publishedAt) == null ? void 0 : _b.value) != null ? _c : void 0,
325
+ lastAttempt: (_e = (_d = this.lastAttempt) == null ? void 0 : _d.value) != null ? _e : void 0,
326
+ createdAt: this.createdAt.value
327
+ };
328
+ }
329
+ static reconstitute(data) {
330
+ var _a;
331
+ return new _DomainEvent(
332
+ UUID.create(data.event_uuid),
333
+ UUID.create(data.tenant_uuid),
334
+ UUID.create(data.aggregate_uuid),
335
+ String(data.aggregate_type),
336
+ String(data.event_type),
337
+ String(data.topic),
338
+ String(data.payload),
339
+ DomainEventStatus.create(data.status),
340
+ Number(data.attempts),
341
+ (_a = data.error_message) != null ? _a : void 0,
342
+ data.published_at ? DateTime.create(data.published_at) : void 0,
343
+ data.last_attempt ? DateTime.create(data.last_attempt) : void 0,
344
+ data.created_at ? DateTime.create(data.created_at) : void 0
345
+ );
177
346
  }
178
347
  };
179
348
 
@@ -191,13 +360,6 @@ var FatalError = class extends DomainError {
191
360
  }
192
361
  };
193
362
 
194
- // src/domain/errors/InternalError.ts
195
- var InternalError = class extends DomainError {
196
- constructor(type, message = "") {
197
- super(type, message);
198
- }
199
- };
200
-
201
363
  // src/domain/errors/UsageError.ts
202
364
  var UsageError = class extends DomainError {
203
365
  constructor(type, vars = {}) {
@@ -392,93 +554,6 @@ _Language.SPANISH_NICARAGUA = new _Language("es-ni");
392
554
  _Language.SPANISH_PUERTO_RICO = new _Language("es-pr");
393
555
  var Language = _Language;
394
556
 
395
- // src/domain/value-objects/payments/PaymentGateway.ts
396
- var _PaymentGateway = class _PaymentGateway extends ValueObject {
397
- constructor(gateway) {
398
- super(gateway);
399
- }
400
- validate(value) {
401
- if (!_PaymentGateway.SUPPORTED.includes(value)) {
402
- throw new InternalError(`Payment gateway <${value}> is not supported`);
403
- }
404
- }
405
- isExternal() {
406
- return _PaymentGateway.EXTERNALS.includes(this.value);
407
- }
408
- toPrimitives() {
409
- return { value: this.value };
410
- }
411
- static create(gateway) {
412
- return new _PaymentGateway(gateway.trim().toUpperCase());
413
- }
414
- };
415
- _PaymentGateway.SUPPORTED = [
416
- "MERCADOPAGO",
417
- "HANDY",
418
- "WONA_DEBIT",
419
- "WONA_CARD",
420
- "WONA_CASH",
421
- "WONA_TRANSFER",
422
- "WONA_MERCADOPAGO"
423
- ];
424
- _PaymentGateway.EXTERNALS = ["MERCADOPAGO", "STRIPE"];
425
- _PaymentGateway.MERCADOPAGO = new _PaymentGateway("MERCADOPAGO");
426
- _PaymentGateway.HANDY = new _PaymentGateway("HANDY");
427
- _PaymentGateway.WONA_DEBIT = new _PaymentGateway("WONA_DEBIT");
428
- _PaymentGateway.WONA_CARD = new _PaymentGateway("WONA_CARD");
429
- _PaymentGateway.WONA_CASH = new _PaymentGateway("WONA_CASH");
430
- _PaymentGateway.WONA_TRANSFER = new _PaymentGateway("WONA_TRANSFER");
431
- _PaymentGateway.WONA_MERCADOPAGO = new _PaymentGateway("WONA_MERCADOPAGO");
432
- var PaymentGateway = _PaymentGateway;
433
-
434
- // src/domain/value-objects/payments/PaymentStatus.ts
435
- var _PaymentStatus = class _PaymentStatus extends ValueObject {
436
- constructor(status) {
437
- super(status);
438
- }
439
- validate(status) {
440
- if (!_PaymentStatus.SUPPORTED.includes(status)) {
441
- throw new InternalError(`Payment status <${status}> is not supported`);
442
- }
443
- }
444
- get isDone() {
445
- return this.value === "DONE";
446
- }
447
- get isPending() {
448
- return this.value === "PENDING";
449
- }
450
- get isInProgress() {
451
- return this.value === "IN_PROGRESS";
452
- }
453
- get isFailed() {
454
- return this.value === "FAILED";
455
- }
456
- get isCanceled() {
457
- return this.value === "CANCELED";
458
- }
459
- get isHold() {
460
- return this.value === "HOLD";
461
- }
462
- get isRefunded() {
463
- return this.value === "REFUNDED";
464
- }
465
- toPrimitives() {
466
- return { value: this.value };
467
- }
468
- static create(gateway) {
469
- return new _PaymentStatus(gateway.trim().toUpperCase());
470
- }
471
- };
472
- _PaymentStatus.SUPPORTED = ["DONE", "PENDING", "FAILED", "CANCELED", "HOLD", "REFUNDED", "IN_PROGRESS"];
473
- _PaymentStatus.DONE = new _PaymentStatus("DONE");
474
- _PaymentStatus.PENDING = new _PaymentStatus("PENDING");
475
- _PaymentStatus.IN_PROGRESS = new _PaymentStatus("IN_PROGRESS");
476
- _PaymentStatus.FAILED = new _PaymentStatus("FAILED");
477
- _PaymentStatus.CANCELED = new _PaymentStatus("CANCELED");
478
- _PaymentStatus.HOLD = new _PaymentStatus("HOLD");
479
- _PaymentStatus.REFUNDED = new _PaymentStatus("REFUNDED");
480
- var PaymentStatus = _PaymentStatus;
481
-
482
557
  // src/utils/StringVars.ts
483
558
  var StringVars = class {
484
559
  static parse(str, ob) {
@@ -634,47 +709,107 @@ _Price.MIN_AMOUNT = -1e6;
634
709
  _Price.MAX_AMOUNT = 1e9;
635
710
  var Price = _Price;
636
711
 
637
- // src/domain/value-objects/UUID.ts
638
- import * as crypto from "crypto";
639
- var _UUID = class _UUID extends ValueObject {
640
- constructor(value) {
641
- super(value);
712
+ // src/domain/value-objects/payments/PaymentGateway.ts
713
+ var _PaymentGateway = class _PaymentGateway extends ValueObject {
714
+ constructor(gateway) {
715
+ super(gateway);
642
716
  }
643
- validate(uuid) {
644
- if (!_UUID.isValid(uuid)) {
645
- throw new InternalError(`Invalid uuid <${uuid}>`);
717
+ validate(value) {
718
+ if (!_PaymentGateway.SUPPORTED.includes(value)) {
719
+ throw new InternalError(`Payment gateway <${value}> is not supported`);
646
720
  }
647
721
  }
722
+ isExternal() {
723
+ return _PaymentGateway.EXTERNALS.includes(this.value);
724
+ }
648
725
  toPrimitives() {
649
726
  return { value: this.value };
650
727
  }
651
- static create(uuid) {
652
- return new _UUID(uuid != null ? uuid : crypto.randomUUID());
728
+ static create(gateway) {
729
+ return new _PaymentGateway(gateway.trim().toUpperCase());
653
730
  }
654
- static version(uuid) {
655
- const m = /^[0-9a-f]{8}-[0-9a-f]{4}-([1-8])[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.exec(uuid);
656
- return m ? Number(m[1]) : void 0;
731
+ };
732
+ _PaymentGateway.SUPPORTED = [
733
+ "MERCADOPAGO",
734
+ "HANDY",
735
+ "WONA_DEBIT",
736
+ "WONA_CARD",
737
+ "WONA_CASH",
738
+ "WONA_TRANSFER",
739
+ "WONA_MERCADOPAGO"
740
+ ];
741
+ _PaymentGateway.EXTERNALS = ["MERCADOPAGO", "STRIPE"];
742
+ _PaymentGateway.MERCADOPAGO = new _PaymentGateway("MERCADOPAGO");
743
+ _PaymentGateway.HANDY = new _PaymentGateway("HANDY");
744
+ _PaymentGateway.WONA_DEBIT = new _PaymentGateway("WONA_DEBIT");
745
+ _PaymentGateway.WONA_CARD = new _PaymentGateway("WONA_CARD");
746
+ _PaymentGateway.WONA_CASH = new _PaymentGateway("WONA_CASH");
747
+ _PaymentGateway.WONA_TRANSFER = new _PaymentGateway("WONA_TRANSFER");
748
+ _PaymentGateway.WONA_MERCADOPAGO = new _PaymentGateway("WONA_MERCADOPAGO");
749
+ var PaymentGateway = _PaymentGateway;
750
+
751
+ // src/domain/value-objects/payments/PaymentStatus.ts
752
+ var _PaymentStatus = class _PaymentStatus extends ValueObject {
753
+ constructor(status) {
754
+ super(status);
657
755
  }
658
- static isNil(uuid) {
659
- return /^0{8}-0{4}-0{4}-0{4}-0{12}$/i.test(uuid);
756
+ validate(status) {
757
+ if (!_PaymentStatus.SUPPORTED.includes(status)) {
758
+ throw new InternalError(`Payment status <${status}> is not supported`);
759
+ }
660
760
  }
661
- static isRFCStyle(uuid) {
662
- return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(uuid);
761
+ get isDone() {
762
+ return this.value === "DONE";
663
763
  }
664
- static isValid(uuid, opts = {}) {
665
- var _a, _b;
666
- const allowed = (_a = opts.allowedVersions) != null ? _a : [1, 2, 3, 4, 5, 6, 7, 8];
667
- const allowNil = (_b = opts.allowNil) != null ? _b : false;
668
- if (allowNil && _UUID.isNil(uuid))
669
- return true;
670
- if (!_UUID.isRFCStyle(uuid))
671
- return false;
672
- const v = _UUID.version(uuid);
673
- return !!v && allowed.includes(v);
764
+ get isPending() {
765
+ return this.value === "PENDING";
766
+ }
767
+ get isInProgress() {
768
+ return this.value === "IN_PROGRESS";
769
+ }
770
+ get isFailed() {
771
+ return this.value === "FAILED";
772
+ }
773
+ get isCanceled() {
774
+ return this.value === "CANCELED";
775
+ }
776
+ get isHold() {
777
+ return this.value === "HOLD";
778
+ }
779
+ get isRefunded() {
780
+ return this.value === "REFUNDED";
781
+ }
782
+ toPrimitives() {
783
+ return { value: this.value };
784
+ }
785
+ static create(gateway) {
786
+ return new _PaymentStatus(gateway.trim().toUpperCase());
787
+ }
788
+ };
789
+ _PaymentStatus.SUPPORTED = ["DONE", "PENDING", "FAILED", "CANCELED", "HOLD", "REFUNDED", "IN_PROGRESS"];
790
+ _PaymentStatus.DONE = new _PaymentStatus("DONE");
791
+ _PaymentStatus.PENDING = new _PaymentStatus("PENDING");
792
+ _PaymentStatus.IN_PROGRESS = new _PaymentStatus("IN_PROGRESS");
793
+ _PaymentStatus.FAILED = new _PaymentStatus("FAILED");
794
+ _PaymentStatus.CANCELED = new _PaymentStatus("CANCELED");
795
+ _PaymentStatus.HOLD = new _PaymentStatus("HOLD");
796
+ _PaymentStatus.REFUNDED = new _PaymentStatus("REFUNDED");
797
+ var PaymentStatus = _PaymentStatus;
798
+
799
+ // src/application/event-bus/EventBus.ts
800
+ var EventBus = class {
801
+ constructor(repository) {
802
+ this.repository = repository;
803
+ }
804
+ async publish(event) {
805
+ await this.repository.create(event);
806
+ }
807
+ async publishMany(events) {
808
+ for (let event of events) {
809
+ await this.publish(event);
810
+ }
674
811
  }
675
812
  };
676
- _UUID.NIL = "00000000-0000-0000-0000-000000000000";
677
- var UUID = _UUID;
678
813
 
679
814
  // src/application/unit-of-work/BasicUnitOfWork.ts
680
815
  var BasicUnitOfWork = class {
@@ -999,8 +1134,10 @@ export {
999
1134
  DomainEntity,
1000
1135
  DomainError,
1001
1136
  DomainEvent,
1137
+ DomainEventStatus,
1002
1138
  Email,
1003
1139
  ErrorManager,
1140
+ EventBus,
1004
1141
  ExchangeRates,
1005
1142
  FatalError,
1006
1143
  HttpHealthCheckController,