wsp-ms-core 1.1.3 → 1.1.5

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.cjs CHANGED
@@ -31,6 +31,7 @@ var src_exports = {};
31
31
  __export(src_exports, {
32
32
  BaseEvent: () => BaseEvent,
33
33
  BaseObject: () => BaseObject,
34
+ BasicCard: () => BasicCard,
34
35
  BasicUnitOfWork: () => BasicUnitOfWork,
35
36
  BasicUnitOfWorkFactory: () => BasicUnitOfWorkFactory,
36
37
  Country: () => Country,
@@ -475,6 +476,92 @@ _PaymentStatus.PENDING_REFUND = new _PaymentStatus("PENDING_REFUND");
475
476
  _PaymentStatus.REFUNDED = new _PaymentStatus("REFUNDED");
476
477
  var PaymentStatus = _PaymentStatus;
477
478
 
479
+ // src/domain/value-objects/UUID.ts
480
+ var crypto = __toESM(require("crypto"));
481
+ var _UUID = class _UUID extends ValueObject {
482
+ constructor(value) {
483
+ super(value);
484
+ }
485
+ validate(uuid) {
486
+ if (!_UUID.isValid(uuid)) {
487
+ throw new InternalError(`Invalid uuid <${uuid}>`);
488
+ }
489
+ }
490
+ toPrimitives() {
491
+ return { value: this.value };
492
+ }
493
+ static create(uuid) {
494
+ return new _UUID(uuid ?? crypto.randomUUID());
495
+ }
496
+ static version(uuid) {
497
+ 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);
498
+ return m ? Number(m[1]) : void 0;
499
+ }
500
+ static isNil(uuid) {
501
+ return /^0{8}-0{4}-0{4}-0{4}-0{12}$/i.test(uuid);
502
+ }
503
+ static isRFCStyle(uuid) {
504
+ 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);
505
+ }
506
+ static isValid(uuid, opts = {}) {
507
+ const allowed = opts.allowedVersions ?? [1, 2, 3, 4, 5, 6, 7, 8];
508
+ const allowNil = opts.allowNil ?? false;
509
+ if (allowNil && _UUID.isNil(uuid))
510
+ return true;
511
+ if (!_UUID.isRFCStyle(uuid))
512
+ return false;
513
+ const v = _UUID.version(uuid);
514
+ return !!v && allowed.includes(v);
515
+ }
516
+ };
517
+ _UUID.NIL = "00000000-0000-0000-0000-000000000000";
518
+ var UUID = _UUID;
519
+
520
+ // src/domain/value-objects/payments/BasicCard.ts
521
+ var BasicCard = class _BasicCard extends ValueObject {
522
+ constructor(uuid, gateway, brand, mask) {
523
+ super({ uuid, gateway, brand, mask });
524
+ }
525
+ validate(props) {
526
+ }
527
+ get uuid() {
528
+ return this._value.uuid;
529
+ }
530
+ get gateway() {
531
+ return this._value.gateway;
532
+ }
533
+ get brand() {
534
+ return this._value.brand;
535
+ }
536
+ get mask() {
537
+ return this._value.mask;
538
+ }
539
+ equals(other) {
540
+ if (!other)
541
+ return false;
542
+ return this._value.uuid.equals(other.uuid);
543
+ }
544
+ toPrimitives() {
545
+ return {
546
+ uuid: this.uuid.value,
547
+ gateway: this.gateway.value,
548
+ brand: this.brand,
549
+ mask: this.mask
550
+ };
551
+ }
552
+ static create(uuid, gateway, brand, mask) {
553
+ return new _BasicCard(uuid, gateway, brand, mask);
554
+ }
555
+ static createFromPrimitives(data) {
556
+ return new _BasicCard(
557
+ UUID.create(String(data?.uuid)),
558
+ PaymentGateway.create(String(data?.gateway)),
559
+ String(data?.brand),
560
+ String(data?.mask)
561
+ );
562
+ }
563
+ };
564
+
478
565
  // src/utils/StringVars.ts
479
566
  var StringVars = class {
480
567
  static parse(str, ob) {
@@ -1047,47 +1134,6 @@ _ProcessStatus.FAILED = new _ProcessStatus("FAILED");
1047
1134
  _ProcessStatus.DEAD = new _ProcessStatus("DEAD");
1048
1135
  var ProcessStatus = _ProcessStatus;
1049
1136
 
1050
- // src/domain/value-objects/UUID.ts
1051
- var crypto = __toESM(require("crypto"));
1052
- var _UUID = class _UUID extends ValueObject {
1053
- constructor(value) {
1054
- super(value);
1055
- }
1056
- validate(uuid) {
1057
- if (!_UUID.isValid(uuid)) {
1058
- throw new InternalError(`Invalid uuid <${uuid}>`);
1059
- }
1060
- }
1061
- toPrimitives() {
1062
- return { value: this.value };
1063
- }
1064
- static create(uuid) {
1065
- return new _UUID(uuid ?? crypto.randomUUID());
1066
- }
1067
- static version(uuid) {
1068
- 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);
1069
- return m ? Number(m[1]) : void 0;
1070
- }
1071
- static isNil(uuid) {
1072
- return /^0{8}-0{4}-0{4}-0{4}-0{12}$/i.test(uuid);
1073
- }
1074
- static isRFCStyle(uuid) {
1075
- 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);
1076
- }
1077
- static isValid(uuid, opts = {}) {
1078
- const allowed = opts.allowedVersions ?? [1, 2, 3, 4, 5, 6, 7, 8];
1079
- const allowNil = opts.allowNil ?? false;
1080
- if (allowNil && _UUID.isNil(uuid))
1081
- return true;
1082
- if (!_UUID.isRFCStyle(uuid))
1083
- return false;
1084
- const v = _UUID.version(uuid);
1085
- return !!v && allowed.includes(v);
1086
- }
1087
- };
1088
- _UUID.NIL = "00000000-0000-0000-0000-000000000000";
1089
- var UUID = _UUID;
1090
-
1091
1137
  // src/application/contracts/IntegrationEvent.ts
1092
1138
  var IntegrationEvent = class extends BaseEvent {
1093
1139
  constructor(tenantUuid, version, type, payload, aggregateUuid, aggregateType) {
@@ -2064,6 +2110,7 @@ var ExchangeRates = class _ExchangeRates extends BaseObject {
2064
2110
  0 && (module.exports = {
2065
2111
  BaseEvent,
2066
2112
  BaseObject,
2113
+ BasicCard,
2067
2114
  BasicUnitOfWork,
2068
2115
  BasicUnitOfWorkFactory,
2069
2116
  Country,