wsp-ms-core 1.1.4 → 1.1.6

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,
@@ -154,6 +155,38 @@ var _DateTime = class _DateTime extends ValueObject {
154
155
  minusSeconds(seconds) {
155
156
  return _DateTime.fromLuxon(this._dt.minus({ seconds }));
156
157
  }
158
+ compareValue(other, unit) {
159
+ const left = unit === "day" ? this._dt.startOf("day") : this._dt;
160
+ const right = unit === "day" ? other._dt.startOf("day") : other._dt;
161
+ const a = left.toMillis();
162
+ const b = right.toMillis();
163
+ if (a === b) {
164
+ return 0;
165
+ }
166
+ return a < b ? -1 : 1;
167
+ }
168
+ compareTo(other, unit = _DateTime.COMPARE_UNIT_MILLIS) {
169
+ return this.compareValue(other, unit);
170
+ }
171
+ isBefore(other, unit = _DateTime.COMPARE_UNIT_MILLIS) {
172
+ return this.compareValue(other, unit) === -1;
173
+ }
174
+ isAfter(other, unit = _DateTime.COMPARE_UNIT_MILLIS) {
175
+ return this.compareValue(other, unit) === 1;
176
+ }
177
+ isSame(other, unit = _DateTime.COMPARE_UNIT_MILLIS) {
178
+ return this.compareValue(other, unit) === 0;
179
+ }
180
+ /** Comparación por fecha calendario (ignora hora) */
181
+ isSameDay(other) {
182
+ return this.isSame(other, _DateTime.COMPARE_UNIT_DAY);
183
+ }
184
+ isBeforeDay(other) {
185
+ return this.isBefore(other, _DateTime.COMPARE_UNIT_DAY);
186
+ }
187
+ isAfterDay(other) {
188
+ return this.isAfter(other, _DateTime.COMPARE_UNIT_DAY);
189
+ }
157
190
  get year() {
158
191
  return this._dt.year;
159
192
  }
@@ -218,6 +251,8 @@ _DateTime.FORMAT_Y_M = "Y-M";
218
251
  _DateTime.FORMAT_Y_M_D = "Y-M-D";
219
252
  _DateTime.FORMAT_Y_M_D_H_m_s = "Y-M-D H:M:S";
220
253
  _DateTime.FORMAT_D_M_Y = "D-M-Y";
254
+ _DateTime.COMPARE_UNIT_MILLIS = "millis";
255
+ _DateTime.COMPARE_UNIT_DAY = "day";
221
256
  _DateTime.FORMATS = {
222
257
  "Y-M": "yyyy-MM",
223
258
  "Y-M-D": "yyyy-MM-dd",
@@ -475,6 +510,92 @@ _PaymentStatus.PENDING_REFUND = new _PaymentStatus("PENDING_REFUND");
475
510
  _PaymentStatus.REFUNDED = new _PaymentStatus("REFUNDED");
476
511
  var PaymentStatus = _PaymentStatus;
477
512
 
513
+ // src/domain/value-objects/UUID.ts
514
+ var crypto = __toESM(require("crypto"));
515
+ var _UUID = class _UUID extends ValueObject {
516
+ constructor(value) {
517
+ super(value);
518
+ }
519
+ validate(uuid) {
520
+ if (!_UUID.isValid(uuid)) {
521
+ throw new InternalError(`Invalid uuid <${uuid}>`);
522
+ }
523
+ }
524
+ toPrimitives() {
525
+ return { value: this.value };
526
+ }
527
+ static create(uuid) {
528
+ return new _UUID(uuid ?? crypto.randomUUID());
529
+ }
530
+ static version(uuid) {
531
+ 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);
532
+ return m ? Number(m[1]) : void 0;
533
+ }
534
+ static isNil(uuid) {
535
+ return /^0{8}-0{4}-0{4}-0{4}-0{12}$/i.test(uuid);
536
+ }
537
+ static isRFCStyle(uuid) {
538
+ 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);
539
+ }
540
+ static isValid(uuid, opts = {}) {
541
+ const allowed = opts.allowedVersions ?? [1, 2, 3, 4, 5, 6, 7, 8];
542
+ const allowNil = opts.allowNil ?? false;
543
+ if (allowNil && _UUID.isNil(uuid))
544
+ return true;
545
+ if (!_UUID.isRFCStyle(uuid))
546
+ return false;
547
+ const v = _UUID.version(uuid);
548
+ return !!v && allowed.includes(v);
549
+ }
550
+ };
551
+ _UUID.NIL = "00000000-0000-0000-0000-000000000000";
552
+ var UUID = _UUID;
553
+
554
+ // src/domain/value-objects/payments/BasicCard.ts
555
+ var BasicCard = class _BasicCard extends ValueObject {
556
+ constructor(uuid, gateway, brand, mask) {
557
+ super({ uuid, gateway, brand, mask });
558
+ }
559
+ validate(props) {
560
+ }
561
+ get uuid() {
562
+ return this._value.uuid;
563
+ }
564
+ get gateway() {
565
+ return this._value.gateway;
566
+ }
567
+ get brand() {
568
+ return this._value.brand;
569
+ }
570
+ get mask() {
571
+ return this._value.mask;
572
+ }
573
+ equals(other) {
574
+ if (!other)
575
+ return false;
576
+ return this._value.uuid.equals(other.uuid);
577
+ }
578
+ toPrimitives() {
579
+ return {
580
+ uuid: this.uuid.value,
581
+ gateway: this.gateway.value,
582
+ brand: this.brand,
583
+ mask: this.mask
584
+ };
585
+ }
586
+ static create(uuid, gateway, brand, mask) {
587
+ return new _BasicCard(uuid, gateway, brand, mask);
588
+ }
589
+ static createFromPrimitives(data) {
590
+ return new _BasicCard(
591
+ UUID.create(String(data?.uuid)),
592
+ PaymentGateway.create(String(data?.gateway)),
593
+ String(data?.brand),
594
+ String(data?.mask)
595
+ );
596
+ }
597
+ };
598
+
478
599
  // src/utils/StringVars.ts
479
600
  var StringVars = class {
480
601
  static parse(str, ob) {
@@ -1047,47 +1168,6 @@ _ProcessStatus.FAILED = new _ProcessStatus("FAILED");
1047
1168
  _ProcessStatus.DEAD = new _ProcessStatus("DEAD");
1048
1169
  var ProcessStatus = _ProcessStatus;
1049
1170
 
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
1171
  // src/application/contracts/IntegrationEvent.ts
1092
1172
  var IntegrationEvent = class extends BaseEvent {
1093
1173
  constructor(tenantUuid, version, type, payload, aggregateUuid, aggregateType) {
@@ -2064,6 +2144,7 @@ var ExchangeRates = class _ExchangeRates extends BaseObject {
2064
2144
  0 && (module.exports = {
2065
2145
  BaseEvent,
2066
2146
  BaseObject,
2147
+ BasicCard,
2067
2148
  BasicUnitOfWork,
2068
2149
  BasicUnitOfWorkFactory,
2069
2150
  Country,