wsp-ms-core 1.0.56 → 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;
@@ -207,48 +270,35 @@ declare class PaymentStatus extends ValueObject<string> {
207
270
  static readonly SUPPORTED: readonly string[];
208
271
  static readonly DONE: PaymentStatus;
209
272
  static readonly PENDING: PaymentStatus;
273
+ static readonly IN_PROGRESS: PaymentStatus;
210
274
  static readonly FAILED: PaymentStatus;
211
275
  static readonly CANCELED: PaymentStatus;
212
276
  static readonly HOLD: PaymentStatus;
213
277
  static readonly REFUNDED: PaymentStatus;
214
278
  private constructor();
215
279
  protected validate(status: string): void;
280
+ get isDone(): boolean;
281
+ get isPending(): boolean;
282
+ get isInProgress(): boolean;
283
+ get isFailed(): boolean;
284
+ get isCanceled(): boolean;
285
+ get isHold(): boolean;
286
+ get isRefunded(): boolean;
216
287
  toPrimitives(): Record<string, unknown>;
217
288
  static create(gateway: string): PaymentStatus;
218
289
  }
219
290
 
220
- interface PriceProps {
221
- amount: number;
222
- currency: Currency;
223
- }
224
- declare class Price extends ValueObject<PriceProps> {
225
- static readonly MIN_AMOUNT: number;
226
- static readonly MAX_AMOUNT: number;
227
- private constructor();
228
- protected validate(props: {
229
- amount: number;
230
- currency: Currency;
231
- }): void;
232
- get amount(): number;
233
- get currency(): Currency;
234
- equals(other?: Price | null): boolean;
235
- private assertSameCurrency;
236
- add(other: Price): Price;
237
- subtract(other: Price): Price;
238
- toPrimitives(): Record<string, unknown>;
239
- static create(amount: number, currency: Currency | string | number): Price;
240
- 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[]>;
241
295
  }
242
296
 
243
- interface EventBus {
297
+ declare class EventBus {
298
+ private readonly repository;
299
+ constructor(repository: EventBusRepository);
244
300
  publish(event: DomainEvent): Promise<void>;
245
- }
246
-
247
- interface EventBusRepository {
248
- save(event: DomainEvent): Promise<void>;
249
- listPending(limit: number): Promise<DomainEvent[]>;
250
- markProcessed(id: number): Promise<void>;
251
- incrementRetries(id: number): Promise<void>;
301
+ publishMany(events: DomainEvent[]): Promise<void>;
252
302
  }
253
303
 
254
304
  interface DatabaseConnection<Q = string, Params = unknown[], Row = Record<string, unknown>> {
@@ -391,4 +441,4 @@ declare class ExchangeRates extends BaseObject<ExchangeRatesProps> {
391
441
  static createFromPrimitives(data: any): ExchangeRates;
392
442
  }
393
443
 
394
- 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,71 +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
- toPrimitives() {
445
- return { value: this.value };
446
- }
447
- static create(gateway) {
448
- return new _PaymentStatus(gateway.trim().toUpperCase());
449
- }
450
- };
451
- _PaymentStatus.SUPPORTED = ["DONE", "PENDING", "FAILED", "CANCELED", "HOLD", "REFUNDED"];
452
- _PaymentStatus.DONE = new _PaymentStatus("DONE");
453
- _PaymentStatus.PENDING = new _PaymentStatus("PENDING");
454
- _PaymentStatus.FAILED = new _PaymentStatus("FAILED");
455
- _PaymentStatus.CANCELED = new _PaymentStatus("CANCELED");
456
- _PaymentStatus.HOLD = new _PaymentStatus("HOLD");
457
- _PaymentStatus.REFUNDED = new _PaymentStatus("REFUNDED");
458
- var PaymentStatus = _PaymentStatus;
459
-
460
557
  // src/utils/StringVars.ts
461
558
  var StringVars = class {
462
559
  static parse(str, ob) {
@@ -612,47 +709,107 @@ _Price.MIN_AMOUNT = -1e6;
612
709
  _Price.MAX_AMOUNT = 1e9;
613
710
  var Price = _Price;
614
711
 
615
- // src/domain/value-objects/UUID.ts
616
- import * as crypto from "crypto";
617
- var _UUID = class _UUID extends ValueObject {
618
- constructor(value) {
619
- super(value);
712
+ // src/domain/value-objects/payments/PaymentGateway.ts
713
+ var _PaymentGateway = class _PaymentGateway extends ValueObject {
714
+ constructor(gateway) {
715
+ super(gateway);
620
716
  }
621
- validate(uuid) {
622
- if (!_UUID.isValid(uuid)) {
623
- 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`);
624
720
  }
625
721
  }
722
+ isExternal() {
723
+ return _PaymentGateway.EXTERNALS.includes(this.value);
724
+ }
626
725
  toPrimitives() {
627
726
  return { value: this.value };
628
727
  }
629
- static create(uuid) {
630
- return new _UUID(uuid != null ? uuid : crypto.randomUUID());
728
+ static create(gateway) {
729
+ return new _PaymentGateway(gateway.trim().toUpperCase());
631
730
  }
632
- static version(uuid) {
633
- 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);
634
- 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);
635
755
  }
636
- static isNil(uuid) {
637
- 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
+ }
638
760
  }
639
- static isRFCStyle(uuid) {
640
- 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";
641
763
  }
642
- static isValid(uuid, opts = {}) {
643
- var _a, _b;
644
- const allowed = (_a = opts.allowedVersions) != null ? _a : [1, 2, 3, 4, 5, 6, 7, 8];
645
- const allowNil = (_b = opts.allowNil) != null ? _b : false;
646
- if (allowNil && _UUID.isNil(uuid))
647
- return true;
648
- if (!_UUID.isRFCStyle(uuid))
649
- return false;
650
- const v = _UUID.version(uuid);
651
- 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
+ }
652
811
  }
653
812
  };
654
- _UUID.NIL = "00000000-0000-0000-0000-000000000000";
655
- var UUID = _UUID;
656
813
 
657
814
  // src/application/unit-of-work/BasicUnitOfWork.ts
658
815
  var BasicUnitOfWork = class {
@@ -977,8 +1134,10 @@ export {
977
1134
  DomainEntity,
978
1135
  DomainError,
979
1136
  DomainEvent,
1137
+ DomainEventStatus,
980
1138
  Email,
981
1139
  ErrorManager,
1140
+ EventBus,
982
1141
  ExchangeRates,
983
1142
  FatalError,
984
1143
  HttpHealthCheckController,